Commit f7dcfa5b authored by Shashwat Jolly's avatar Shashwat Jolly
Browse files

Add consts and overrides

parent 001f1fb0
......@@ -88,9 +88,7 @@ void BaseHandler::syncCollection(const QVariant &collectionVariant)
const Collection collection = collectionVariant.value<Collection>();
auto job = new EntriesFetchJob(mClientState->client(), collection, this);
connect(job, &EntriesFetchJob::finished, this, &BaseHandler::slotItemsRetrieved);
job->start();
}
......
......@@ -32,10 +32,10 @@ class CalendarHandler : public CalendarTaskBaseHandler
public:
explicit CalendarHandler(EteSyncResource *resource);
const QString mimeType();
const QString mimeType() override;
protected:
const QString etesyncCollectionType();
const QString etesyncCollectionType() override;
};
#endif
......@@ -50,7 +50,7 @@ void CalendarTaskBaseHandler::getItemListFromEntries(EteSyncEntry **entries, Ite
CharPtr contentStr(etesync_sync_entry_get_content(syncEntry.get()));
KCalendarCore::ICalFormat format;
KCalendarCore::Incidence::Ptr incidence = format.fromString(QStringFromCharPtr(contentStr));
const KCalendarCore::Incidence::Ptr incidence = format.fromString(QStringFromCharPtr(contentStr));
const QString action = QStringFromCharPtr(CharPtr(etesync_sync_entry_get_action(syncEntry.get())));
if (action == QStringLiteral(ETESYNC_SYNC_ENTRY_ACTION_ADD) || action == QStringLiteral(ETESYNC_SYNC_ENTRY_ACTION_CHANGE)) {
......@@ -137,7 +137,7 @@ void CalendarTaskBaseHandler::itemAdded(const Akonadi::Item &item,
calendar->addIncidence(item.payload<Incidence::Ptr>());
KCalendarCore::ICalFormat format;
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
......@@ -162,7 +162,7 @@ void CalendarTaskBaseHandler::itemChanged(const Akonadi::Item &item,
calendar->addIncidence(item.payload<Incidence::Ptr>());
KCalendarCore::ICalFormat format;
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
......@@ -182,12 +182,12 @@ void CalendarTaskBaseHandler::itemRemoved(const Akonadi::Item &item)
{
Collection collection = item.parentCollection();
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
QString calendar = getLocalCalendar(item.remoteId());
const QString calendar = getLocalCalendar(item.remoteId());
EteSyncSyncEntryPtr syncEntry(etesync_sync_entry_new(ETESYNC_SYNC_ENTRY_ACTION_DELETE, charArrFromQString(calendar)));
......@@ -200,7 +200,7 @@ void CalendarTaskBaseHandler::itemRemoved(const Akonadi::Item &item)
void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent)
{
QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid()));
const QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid()));
EteSyncJournalPtr journal(etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION));
/// TODO: Description?
......@@ -223,7 +223,7 @@ void CalendarTaskBaseHandler::collectionAdded(const Akonadi::Collection &collect
void CalendarTaskBaseHandler::collectionChanged(const Akonadi::Collection &collection)
{
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
auto journalColor = EteSyncDEFAULT_COLOR;
......@@ -251,7 +251,7 @@ void CalendarTaskBaseHandler::collectionChanged(const Akonadi::Collection &colle
void CalendarTaskBaseHandler::collectionRemoved(const Akonadi::Collection &collection)
{
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
const auto result = etesync_journal_manager_delete(mClientState->journalManager(), journal.get());
......
......@@ -34,7 +34,7 @@ class CalendarTaskBaseHandler : public BaseHandler
public:
explicit CalendarTaskBaseHandler(EteSyncResource *resource);
void getItemListFromEntries(EteSyncEntry **entries, Item::List &changedItems, Item::List &removedItems, Collection &collection, const QString &journalUid, QString &prevUid);
void getItemListFromEntries(EteSyncEntry **entries, Item::List &changedItems, Item::List &removedItems, Collection &collection, const QString &journalUid, QString &prevUid) override;
void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
......
......@@ -99,7 +99,7 @@ QString ContactHandler::baseDirectoryPath() const
return mResource->baseDirectoryPath() + QStringLiteral("/Contacts");
}
QString ContactHandler::getLocalContact(QString contactUid) const
QString ContactHandler::getLocalContact(const QString &contactUid) const
{
const QString path = baseDirectoryPath() + QLatin1Char('/') + contactUid + QLatin1String(".vcf");
......@@ -138,7 +138,7 @@ void ContactHandler::deleteLocalContact(const KContacts::Addressee &contact)
void ContactHandler::itemAdded(const Akonadi::Item &item,
const Akonadi::Collection &collection)
{
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
......@@ -162,7 +162,7 @@ void ContactHandler::itemChanged(const Akonadi::Item &item,
{
Collection collection = item.parentCollection();
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
......@@ -185,12 +185,12 @@ void ContactHandler::itemRemoved(const Akonadi::Item &item)
{
Collection collection = item.parentCollection();
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCryptoManagerPtr cryptoManager(etesync_journal_get_crypto_manager(journal.get(), mClientState->derived(), mClientState->keypair()));
QString contact = getLocalContact(item.remoteId());
const QString contact = getLocalContact(item.remoteId());
EteSyncSyncEntryPtr syncEntry(etesync_sync_entry_new(ETESYNC_SYNC_ENTRY_ACTION_DELETE, charArrFromQString(contact)));
......@@ -203,7 +203,7 @@ void ContactHandler::itemRemoved(const Akonadi::Item &item)
void ContactHandler::collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent)
{
QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid()));
const QString journalUid = QStringFromCharPtr(CharPtr(etesync_gen_uid()));
EteSyncJournalPtr journal(etesync_journal_new(journalUid, ETESYNC_CURRENT_VERSION));
EteSyncCollectionInfoPtr info(etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), EteSyncDEFAULT_COLOR));
......@@ -221,7 +221,7 @@ void ContactHandler::collectionAdded(const Akonadi::Collection &collection, cons
void ContactHandler::collectionChanged(const Akonadi::Collection &collection)
{
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
EteSyncCollectionInfoPtr info(etesync_collection_info_new(etesyncCollectionType(), collection.displayName(), QString(), EteSyncDEFAULT_COLOR));
......@@ -235,7 +235,7 @@ void ContactHandler::collectionChanged(const Akonadi::Collection &collection)
void ContactHandler::collectionRemoved(const Akonadi::Collection &collection)
{
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = mResource->getJournal(journalUid);
etesync_journal_manager_delete(mClientState->journalManager(), journal.get());
......
......@@ -37,7 +37,7 @@ public:
const QString mimeType() override;
void getItemListFromEntries(EteSyncEntry **entries, Item::List &changedItems, Item::List &removedItems, Collection &collection, const QString &journalUid, QString &prevUid);
void getItemListFromEntries(EteSyncEntry **entries, Item::List &changedItems, Item::List &removedItems, Collection &collection, const QString &journalUid, QString &prevUid) override;
void itemAdded(const Akonadi::Item &item, const Akonadi::Collection &collection) override;
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &parts) override;
......@@ -48,7 +48,7 @@ public:
void collectionRemoved(const Akonadi::Collection &collection) override;
protected:
QString getLocalContact(QString contactUid) const;
QString getLocalContact(const QString &contactUid) const;
void updateLocalContact(const KContacts::Addressee &contact);
void deleteLocalContact(const KContacts::Addressee &contact);
......
......@@ -19,14 +19,6 @@
#include "etesync_debug.h"
EteSyncClientState::EteSyncClientState()
{
}
EteSyncClientState::~EteSyncClientState()
{
}
void EteSyncClientState::init()
{
// Load settings
......
......@@ -25,8 +25,7 @@ class EteSyncClientState : public QObject
{
Q_OBJECT
public:
EteSyncClientState();
~EteSyncClientState();
explicit EteSyncClientState() = default;
void init();
bool initToken(const QString &serverUrl, const QString &username, const QString &password);
......@@ -36,27 +35,27 @@ public:
void saveSettings();
void invalidateToken();
EteSync *client()
EteSync *client() const
{
return mClient.get();
}
QString derived()
QString derived() const
{
return mDerived;
}
EteSyncJournalManager *journalManager()
EteSyncJournalManager *journalManager() const
{
return mJournalManager.get();
}
EteSyncAsymmetricKeyPair *keypair()
EteSyncAsymmetricKeyPair *keypair() const
{
return mKeypair.get();
}
QString username()
QString username() const
{
return mUsername;
}
......
......@@ -246,9 +246,9 @@ BaseHandler *EteSyncResource::fetchHandlerForCollection(const Akonadi::Collectio
void EteSyncResource::retrieveItems(const Akonadi::Collection &collection)
{
int timeSinceLastCacheUpdate = mJournalsCacheUpdateTime.secsTo(QDateTime::currentDateTime());
const int timeSinceLastCacheUpdate = mJournalsCacheUpdateTime.secsTo(QDateTime::currentDateTime());
if (timeSinceLastCacheUpdate <= 30) {
QString journalUid = collection.remoteId();
const QString journalUid = collection.remoteId();
const EteSyncJournalPtr &journal = getJournal(journalUid);
QString lastEntryUid = QStringFromCharPtr(CharPtr(etesync_journal_get_last_uid(journal.get())));
if (lastEntryUid == collection.remoteRevision()) {
......
......@@ -52,8 +52,8 @@ protected Q_SLOTS:
void itemRemoved(const Akonadi::Item &item) override;
void collectionAdded(const Akonadi::Collection &collection, const Akonadi::Collection &parent) override;
void collectionChanged(const Akonadi::Collection &collection);
void collectionRemoved(const Akonadi::Collection &collection);
void collectionChanged(const Akonadi::Collection &collection) override;
void collectionRemoved(const Akonadi::Collection &collection) override;
void configure(WId windowId) override;
......@@ -66,17 +66,11 @@ protected:
void initialiseDirectory(const QString &path) const;
QString getLocalContact(QString contactUid) const;
void updateLocalContact(const KContacts::Addressee &contact);
void deleteLocalContact(const KContacts::Addressee &contact);
QString baseDirectoryPath() const;
bool handleTokenError();
const EteSyncJournalPtr &getJournal(QString journalUid)
const EteSyncJournalPtr &getJournal(const QString &journalUid)
{
return mJournalsCache[journalUid];
}
......
......@@ -83,10 +83,7 @@ bool LoginPage::validatePage()
const QString username = field(QStringLiteral("credentialsUserName")).toString();
const QString password = field(QStringLiteral("credentialsPassword")).toString();
const QString advancedServerUrl = field(QStringLiteral("credentialsServerUrl")).toString();
QString serverUrl = QStringLiteral("https://api.etesync.com");
if (!advancedServerUrl.isNull() && !advancedServerUrl.isEmpty()) {
serverUrl = advancedServerUrl;
}
const QString serverUrl = advancedServerUrl.isEmpty() ? QStringLiteral("https://api.etesync.com") : advancedServerUrl;
const bool loginResult = static_cast<SetupWizard *>(wizard())->mClientState->initToken(serverUrl, username, password);
if (!loginResult) {
mLoginLabel->setText(i18n("Incorrect login credentials. Please try again."));
......@@ -118,7 +115,7 @@ int EncryptionPasswordPage::nextId() const
void EncryptionPasswordPage::initializePage()
{
bool userInfoResult = static_cast<SetupWizard *>(wizard())->mClientState->initUserInfo();
const bool userInfoResult = static_cast<SetupWizard *>(wizard())->mClientState->initUserInfo();
if (!userInfoResult) {
setSubTitle(i18n("Please set your encryption password below, and make sure you got it right, as it can't be recovered if lost!"));
mInitAccount = true;
......@@ -127,12 +124,12 @@ void EncryptionPasswordPage::initializePage()
bool EncryptionPasswordPage::validatePage()
{
QString encryptionPassword = field(QStringLiteral("credentialsEncryptionPassword")).toString();
const QString encryptionPassword = field(QStringLiteral("credentialsEncryptionPassword")).toString();
if (mInitAccount) {
static_cast<SetupWizard *>(wizard())->mClientState->initAccount(encryptionPassword);
return true;
}
bool keypairResult = static_cast<SetupWizard *>(wizard())->mClientState->initKeypair(encryptionPassword);
const bool keypairResult = static_cast<SetupWizard *>(wizard())->mClientState->initKeypair(encryptionPassword);
if (!keypairResult) {
mEncryptionPasswordLabel->setText(i18n("Incorrect encryption password. Please try again."));
}
......
......@@ -32,10 +32,10 @@ class TaskHandler : public CalendarTaskBaseHandler
public:
TaskHandler(EteSyncResource *resource);
const QString mimeType();
const QString mimeType() override;
protected:
const QString etesyncCollectionType();
const QString etesyncCollectionType() override;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment