summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--migrationutility/googlesourceaccount.cpp30
-rw-r--r--migrationutility/googlesourceaccount.h7
-rw-r--r--migrationutility/googlesourceserver.cpp2
3 files changed, 29 insertions, 10 deletions
diff --git a/migrationutility/googlesourceaccount.cpp b/migrationutility/googlesourceaccount.cpp
index a920719..8c29214 100644
--- a/migrationutility/googlesourceaccount.cpp
+++ b/migrationutility/googlesourceaccount.cpp
@@ -244,10 +244,6 @@ void LoginJob::start()
mAccount,
QLatin1String("583467588400.apps.googleusercontent.com"),
QLatin1String("_AwtLuOqS5JcCHWGpq8fxKdd"), this);
-// GoogleAuthJob *authJob = new GoogleAuthJob(
-// account,
-// QLatin1String("583467588400.apps.googleusercontent.com"),
-// QLatin1String("_AwtLuOqS5JcCHWGpq8fxKdd"));
connect(authJob, SIGNAL(finished(KGAPI2::Job*)), this, SLOT(slotAuthJobFinished(KGAPI2::Job*)));
}
@@ -267,7 +263,8 @@ void LoginJob::slotAuthJobFinished(KGAPI2::Job *job)
GoogleSourceAccount::GoogleSourceAccount(QObject* parent)
-: SourceAccount(parent)
+: SourceAccount(parent),
+ mAccount(new KGAPI2::Account)
{
}
@@ -282,14 +279,27 @@ void GoogleSourceAccount::setUser(const QString& username)
mUser = username;
}
+void GoogleSourceAccount::setAccount(const KGAPI2::AccountPtr& account)
+{
+ mAccount = account;
+}
+
+KGAPI2::AccountPtr GoogleSourceAccount::account()
+{
+ return mAccount;
+}
+
KJob* GoogleSourceAccount::login()
{
- mAccount = KGAPI2::AccountPtr(new KGAPI2::Account);
- mAccount->setScopes(QList<QUrl>() << KGAPI2::Account::contactsScopeUrl() << KGAPI2::Account::calendarScopeUrl() << KGAPI2::Account::tasksScopeUrl());
- mAccount->setAccountName(mUser);
+ if (mAccount->accessToken().isEmpty()) {
+ mAccount->setScopes(QList<QUrl>() << KGAPI2::Account::contactsScopeUrl() << KGAPI2::Account::calendarScopeUrl() << KGAPI2::Account::tasksScopeUrl());
+ mAccount->setAccountName(mUser);
- LoginJob *authJob = new LoginJob(mAccount, this);
- return authJob;
+ LoginJob *authJob = new LoginJob(mAccount, this);
+ return authJob;
+ } else {
+ return new DummyJob();
+ }
}
KJob *GoogleSourceAccount::logout()
diff --git a/migrationutility/googlesourceaccount.h b/migrationutility/googlesourceaccount.h
index e1c1bf7..60b1fa8 100644
--- a/migrationutility/googlesourceaccount.h
+++ b/migrationutility/googlesourceaccount.h
@@ -33,6 +33,9 @@ class GoogleSourceAccount: public SourceAccount
public:
explicit GoogleSourceAccount(QObject* parent = 0);
+ void setAccount(const KGAPI2::AccountPtr &account);
+ KGAPI2::AccountPtr account();
+
void setUser(const QString &username);
virtual QPair<Kolab::FolderType, QString> translateFolder(const QString& folder);
@@ -42,6 +45,10 @@ public:
protected:
KGAPI2::AccountPtr mAccount;
QString mUser;
+private:
+ class DummyJob : public KJob {
+ virtual void start() {emitResult();}
+ };
};
class GoogleContactsSourceAccount: public GoogleSourceAccount
diff --git a/migrationutility/googlesourceserver.cpp b/migrationutility/googlesourceserver.cpp
index ec6b056..f609c41 100644
--- a/migrationutility/googlesourceserver.cpp
+++ b/migrationutility/googlesourceserver.cpp
@@ -64,10 +64,12 @@ QList<SourceAccount*> GoogleSourceServer::getSourceAccountsImpl(const QString& u
sourceAccounts << contactsAccount;
GoogleCalendarSourceAccount *calendarAccount = new GoogleCalendarSourceAccount(this);
+ calendarAccount->setAccount(contactsAccount->account());
calendarAccount->setUser(user);
sourceAccounts << calendarAccount;
GoogleTasksSourceAccount *tasksAccount = new GoogleTasksSourceAccount(this);
+ tasksAccount->setAccount(contactsAccount->account());
tasksAccount->setUser(user);
sourceAccounts << tasksAccount;