Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mkcal] Store the remote URL for a component.
  • Loading branch information
dcaliste committed Jan 12, 2021
1 parent eedb0f5 commit af6cfc3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/sqliteformat.cpp
Expand Up @@ -259,8 +259,7 @@ bool SqliteFormat::modifyComponents(const Incidence::Ptr &incidence, const QStri
QByteArray category;
QByteArray location;
QByteArray description;
QUrl uristr;
QByteArray uri;
QByteArray url;
QByteArray contact;
QByteArray attachments;
QByteArray relatedtouid;
Expand Down Expand Up @@ -426,9 +425,8 @@ bool SqliteFormat::modifyComponents(const Incidence::Ptr &incidence, const QStri
relatedtouid = incidence->relatedTo().toUtf8();
sqlite3_bind_text(stmt1, index, relatedtouid.constData(), relatedtouid.length(), SQLITE_STATIC);

uristr = incidence->uri();
uri = uristr.toString().toUtf8();
sqlite3_bind_text(stmt1, index, uri.constData(), uri.length(), SQLITE_STATIC);
url = incidence->url().toString().toUtf8();
sqlite3_bind_text(stmt1, index, url.constData(), url.length(), SQLITE_STATIC);

uid = incidence->uid().toUtf8();
sqlite3_bind_text(stmt1, index, uid.constData(), uid.length(), SQLITE_STATIC);
Expand Down Expand Up @@ -1353,8 +1351,10 @@ Incidence::Ptr SqliteFormat::selectComponents(sqlite3_stmt *stmt1, sqlite3_stmt
QString relatedtouid = QString::fromUtf8((const char *) sqlite3_column_text(stmt1, index++));
incidence->setRelatedTo(relatedtouid);

//QString uri = QString::fromUtf8((const char *)sqlite3_column_text(stmt1, index++)); // uri
index++;
QUrl url(QString::fromUtf8((const char *)sqlite3_column_text(stmt1, index++)));
if (url.isValid()) {
incidence->setUrl(url);
}

// set the real uid to uid
incidence->setUid(QString::fromUtf8((const char *) sqlite3_column_text(stmt1, index++)));
Expand Down
32 changes: 32 additions & 0 deletions tests/tst_storage.cpp
Expand Up @@ -1749,6 +1749,38 @@ void tst_storage::tst_loadSeries()
QVERIFY(m_calendar->incidence(single->uid()));
}

void tst_storage::tst_url_data()
{
QTest::addColumn<QUrl>("url");

QTest::newRow("no URL")
<< QUrl();
QTest::newRow("simple URL")
<< QUrl("http://example.org/dav/123-456-789.ics");
QTest::newRow("percent encoded URL")
<< QUrl("https://example.org/dav%20user/123-456-789.ics");
}

void tst_storage::tst_url()
{
QFETCH(QUrl, url);

auto event = KCalendarCore::Event::Ptr(new KCalendarCore::Event);
event->setDtStart(QDateTime(QDate(2021, 1, 4), QTime(15, 37),
Qt::LocalTime));
event->setSummary("URL test event");
event->setUrl(url);
QCOMPARE(event->url(), url);

m_calendar->addEvent(event, NotebookId);
m_storage->save();
reloadDb();

auto fetchEvent = m_calendar->event(event->uid());
QVERIFY(fetchEvent);
QCOMPARE(fetchEvent->url(), url);
}

void tst_storage::openDb(bool clear)
{
m_calendar = ExtendedCalendar::Ptr(new ExtendedCalendar(QTimeZone::systemTimeZone()));
Expand Down
2 changes: 2 additions & 0 deletions tests/tst_storage.h
Expand Up @@ -71,6 +71,8 @@ private slots:
void tst_alarms();
void tst_load();
void tst_loadSeries();
void tst_url_data();
void tst_url();

private:
void openDb(bool clear = false);
Expand Down

0 comments on commit af6cfc3

Please sign in to comment.