[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-google/wip-v0.3] /: Use QExplicitlySharedPointer for passing KGoogle::Account around libkgo
From:       Dan_Vrátil <dan () progdan ! cz>
Date:       2012-03-10 16:33:50
Message-ID: 20120310163350.A5508A60C4 () git ! kde ! org
[Download RAW message or body]

Git commit a29d7f0a924ddcd7461c601a8e7c0d4215b4c3ef by Dan Vrátil.
Committed on 06/03/2012 at 00:17.
Pushed by dvratil into branch 'wip-v0.3'.

Use QExplicitlySharedPointer for passing KGoogle::Account around libkgoogle

M  +5    -5    calendar/calendarresource.cpp
M  +1    -1    calendar/resource_tasks.cpp
M  +15   -15   calendar/settingsdialog.cpp
M  +0    -2    calendar/settingsdialog.h
M  +7    -7    contacts/contactsresource.cpp
M  +4    -4    contacts/settingsdialog.cpp
M  +2    -2    libkgoogle/accessmanager_p.cpp
M  +18   -18   libkgoogle/auth.cpp
M  +6    -6    libkgoogle/auth.h
M  +7    -7    libkgoogle/auth_p.cpp
M  +5    -5    libkgoogle/auth_p.h
M  +3    -3    libkgoogle/authdialog.cpp
M  +3    -3    libkgoogle/authdialog.h
M  +2    -2    libkgoogle/fetchlistjob.cpp
M  +3    -3    libkgoogle/request.cpp
M  +3    -4    libkgoogle/request.h
M  +5    -5    libkgoogle/ui/accountscombo.cpp
M  +2    -1    libkgoogle/ui/accountscombo.h

http://commits.kde.org/akonadi-google/a29d7f0a924ddcd7461c601a8e7c0d4215b4c3ef

diff --git a/calendar/calendarresource.cpp b/calendar/calendarresource.cpp
index 85ec475..41a6715 100644
--- a/calendar/calendarresource.cpp
+++ b/calendar/calendarresource.cpp
@@ -218,7 +218,7 @@ bool CalendarResource::retrieveItem(const Akonadi::Item& item, \
const QSet< QByte  
     }
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -301,7 +301,7 @@ void CalendarResource::itemAdded(const Akonadi::Item& item, const \
Akonadi::Colle  return;
     }
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -323,7 +323,7 @@ void CalendarResource::itemChanged(const Akonadi::Item& item, \
const QSet< QByteA  QUrl url;
     QByteArray data;
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -409,7 +409,7 @@ void CalendarResource::itemRemoved(const Akonadi::Item& item)
         return;
     }
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -433,7 +433,7 @@ void CalendarResource::itemMoved(const Item& item, const \
Collection& collectionS  if (item.mimeType() != Event::eventMimeType())
         return;
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
diff --git a/calendar/resource_tasks.cpp b/calendar/resource_tasks.cpp
index d31d6ce..943159e 100644
--- a/calendar/resource_tasks.cpp
+++ b/calendar/resource_tasks.cpp
@@ -51,7 +51,7 @@ void CalendarResource::taskDoUpdate(Reply* reply)
     TodoPtr todo = item.payload< TodoPtr >();
     Objects::Task ktodo(*todo);
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
diff --git a/calendar/settingsdialog.cpp b/calendar/settingsdialog.cpp
index 68d0191..de487a5 100644
--- a/calendar/settingsdialog.cpp
+++ b/calendar/settingsdialog.cpp
@@ -99,7 +99,7 @@ SettingsDialog::SettingsDialog(WId windowId, QWidget* parent):
             this, SLOT(saveSettings()));
 
     KGoogle::Auth *auth = KGoogle::Auth::instance();
-    connect(auth, SIGNAL(authenticated(KGoogle::Account*)),
+    connect(auth, SIGNAL(authenticated(KGoogle::Account::Ptr&)),
             this, SLOT(reloadAccounts()));
 
     reloadAccounts();
@@ -162,7 +162,7 @@ void SettingsDialog::addAccountClicked()
 {
     KGoogle::Auth *auth = KGoogle::Auth::instance();
 
-    KGoogle::Account *account = new KGoogle::Account();
+    KGoogle::Account::Ptr account(new KGoogle::Account());
     account->addScope(Services::Calendar::ScopeUrl);
     account->addScope(Services::Tasks::ScopeUrl);
 
@@ -175,8 +175,8 @@ void SettingsDialog::addAccountClicked()
 
 void SettingsDialog::removeAccountClicked()
 {
-    KGoogle::Account *account = m_ui->accountsCombo->currentAccount();
-    if (!account)
+    KGoogle::Account::Ptr account = m_ui->accountsCombo->currentAccount();
+    if (account.isNull())
         return;
 
     if (KMessageBox::warningYesNo(
@@ -205,8 +205,8 @@ void SettingsDialog::accountChanged()
     m_ui->calendarsBox->setDisabled(true);
     m_ui->tasksBox->setDisabled(true);
 
-    Account *account = m_ui->accountsCombo->currentAccount();
-    if (account == 0) {
+    Account::Ptr account = m_ui->accountsCombo->currentAccount();
+    if (account.isNull()) {
         m_ui->accountsBox->setEnabled(true);
         m_ui->calendarsList->clear();
         m_ui->calendarsBox->setEnabled(true);
@@ -225,7 +225,7 @@ void SettingsDialog::accountChanged()
     connect(gam, SIGNAL(requestFinished(KGoogle::Request*)),
             gam, SLOT(deleteLater()));
     request = new KGoogle::Request(Services::Calendar::fetchCalendarsUrl(), \
                Request::FetchAll, "Calendar", account);
-    gam->sendRequest(request);
+    gam->queueRequest(request);
 
     m_ui->tasksList->clear();
     gam = new KGoogle::AccessManager;
@@ -250,7 +250,7 @@ void SettingsDialog::addCalendarClicked()
 
 void SettingsDialog::addCalendar(KGoogle::Objects::Calendar *calendar)
 {
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
     Services::Calendar parser;
@@ -303,7 +303,7 @@ void SettingsDialog::editCalendarClicked()
 
 void SettingsDialog::editCalendar(KGoogle::Objects::Calendar *calendar)
 {
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
     Services::Calendar parser;
@@ -346,7 +346,7 @@ void SettingsDialog::removeCalendarClicked()
         return;
     }
 
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
 
@@ -380,7 +380,7 @@ void SettingsDialog::addTaskListClicked()
 void SettingsDialog::reloadCalendarsClicked()
 {
     KGoogle::AccessManager *gam;
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::Request *request;
 
     m_ui->accountsBox->setDisabled(true);
@@ -401,7 +401,7 @@ void SettingsDialog::reloadCalendarsClicked()
 
 void SettingsDialog::addTaskList(TaskList *taskList)
 {
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
     Services::Tasks parser;
@@ -445,7 +445,7 @@ void SettingsDialog::editTaskListClicked()
 
 void SettingsDialog::editTaskList(TaskList *taskList)
 {
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
     Services::Tasks parser;
@@ -488,7 +488,7 @@ void SettingsDialog::removeTaskListClicked()
         return;
     }
 
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::AccessManager *gam;
     KGoogle::Request *request;
 
@@ -511,7 +511,7 @@ void SettingsDialog::removeTaskListClicked()
 void SettingsDialog::reloadTaskListsClicked()
 {
     KGoogle::AccessManager *gam;
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     KGoogle::Request *request;
 
     m_ui->accountsBox->setDisabled(true);
diff --git a/calendar/settingsdialog.h b/calendar/settingsdialog.h
index 20d7f88..6b446b0 100644
--- a/calendar/settingsdialog.h
+++ b/calendar/settingsdialog.h
@@ -31,9 +31,7 @@ class SettingsDialog;
 
 namespace KGoogle
 {
-class Auth;
 class Reply;
-class AccessManager;
 
 namespace Objects
 {
diff --git a/contacts/contactsresource.cpp b/contacts/contactsresource.cpp
index c987878..d24eb9a 100644
--- a/contacts/contactsresource.cpp
+++ b/contacts/contactsresource.cpp
@@ -157,7 +157,7 @@ bool ContactsResource::retrieveItem(const Akonadi::Item& item, \
const QSet< QByte  if (item.mimeType() != KABC::Addressee::mimeType())
         return false;
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -256,7 +256,7 @@ void ContactsResource::itemAdded(const Akonadi::Item& item, const \
Akonadi::Colle  if (!item.hasPayload< KABC::Addressee >())
         return;
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -306,7 +306,7 @@ void ContactsResource::itemChanged(const Akonadi::Item& item, \
const QSet< QByteA  return;
     }
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -350,7 +350,7 @@ void ContactsResource::itemMoved(const Item& item, const \
Collection& collectionS  return;
     }
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -398,7 +398,7 @@ void ContactsResource::itemMoved(const Item& item, const \
Collection& collectionS  void ContactsResource::itemRemoved(const Akonadi::Item& \
item)  {
 
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -621,7 +621,7 @@ void ContactsResource::photoRequestFinished(QNetworkReply* reply)
 
 void ContactsResource::fetchPhoto(Akonadi::Item &item)
 {
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
@@ -644,7 +644,7 @@ void ContactsResource::fetchPhoto(Akonadi::Item &item)
 
 void ContactsResource::updatePhoto(Item &item)
 {
-    Account *account;
+    Account::Ptr account;
     try {
         Auth *auth = Auth::instance();
         account = auth->getAccount(Settings::self()->account());
diff --git a/contacts/settingsdialog.cpp b/contacts/settingsdialog.cpp
index f2d5a10..63e9f99 100644
--- a/contacts/settingsdialog.cpp
+++ b/contacts/settingsdialog.cpp
@@ -61,7 +61,7 @@ SettingsDialog::SettingsDialog(WId windowId, QWidget *parent):
             this, SLOT(removeAccountClicked()));
 
     KGoogle::Auth *auth = KGoogle::Auth::instance();
-    connect(auth, SIGNAL(authenticated(KGoogle::Account*)),
+    connect(auth, SIGNAL(authenticated(KGoogle::Account::Ptr&)),
             this, SLOT(reloadAccounts()));
 
     reloadAccounts();
@@ -107,7 +107,7 @@ void SettingsDialog::addAccountClicked()
 {
     KGoogle::Auth *auth = KGoogle::Auth::instance();
 
-    KGoogle::Account *account = new KGoogle::Account();
+    KGoogle::Account::Ptr account(new KGoogle::Account());
     account->addScope(Services::Contacts::ScopeUrl);
 
     try {
@@ -119,9 +119,9 @@ void SettingsDialog::addAccountClicked()
 
 void SettingsDialog::removeAccountClicked()
 {
-    KGoogle::Account *account = m_ui->accountsCombo->currentAccount();
+    KGoogle::Account::Ptr account = m_ui->accountsCombo->currentAccount();
 
-    if (!account)
+    if (account.isNull())
         return;
 
     if (KMessageBox::warningYesNo(this,
diff --git a/libkgoogle/accessmanager_p.cpp b/libkgoogle/accessmanager_p.cpp
index 0a58005..443206d 100644
--- a/libkgoogle/accessmanager_p.cpp
+++ b/libkgoogle/accessmanager_p.cpp
@@ -46,7 +46,7 @@ AccessManagerPrivate::AccessManagerPrivate(AccessManager* const \
parent):  {
     connect(nam, SIGNAL(finished(QNetworkReply*)),
             this, SLOT(nam_replyReceived(QNetworkReply*)));
-    connect(Auth::instance(), SIGNAL(authenticated(KGoogle::Account*)),
+    connect(Auth::instance(), SIGNAL(authenticated(KGoogle::Account::Ptr&)),
             this, SLOT(authenticated()));
 }
 
@@ -293,7 +293,7 @@ void AccessManagerPrivate::nam_sendRequest(KGoogle::Request* \
request)  
 void AccessManagerPrivate::authenticated()
 {
-    cacheSemaphore->release();;
+    cacheSemaphore->release();
 
     submitCache();
 }
diff --git a/libkgoogle/auth.cpp b/libkgoogle/auth.cpp
index 5d03bea..7e2c962 100644
--- a/libkgoogle/auth.cpp
+++ b/libkgoogle/auth.cpp
@@ -71,16 +71,16 @@ void Auth::setKWalletFolder(const QString& folder)
     d->kwalletFolder = folder;
 }
 
-KGoogle::Account *Auth::getAccount(const QString &account)
+KGoogle::Account::Ptr Auth::getAccount(const QString &account)
 {
     Q_D(Auth);
 
     if (!d->initKWallet())
-        return 0;
+        return Account::Ptr();
 
     if (!d->kwallet->hasFolder(d->kwalletFolder)) {
         throw Exception::UnknownAccount(account);
-        return 0;
+        return Account::Ptr();
     }
 
     d->kwallet->setFolder(d->kwalletFolder);
@@ -88,7 +88,7 @@ KGoogle::Account *Auth::getAccount(const QString &account)
     QMap< QString, QString > map;
     if (d->kwallet->readMap(account, map) != 0) {
         throw Exception::UnknownAccount(account);
-        return 0;
+        return Account::Ptr();
     }
 
     QStringList scopes = map["scopes"].split(',');
@@ -97,25 +97,24 @@ KGoogle::Account *Auth::getAccount(const QString &account)
         scopeUrls << QUrl(scope);
     }
 
-    Account *acc = new Account(account, map["accessToken"], map["refreshToken"], \
                scopeUrls);
-    return acc;
+    return Account::Ptr(new Account(account, map["accessToken"], \
map["refreshToken"], scopeUrls));  }
 
-QList< KGoogle::Account * > Auth::getAccounts()
+QList< KGoogle::Account::Ptr > Auth::getAccounts()
 {
     Q_D(Auth);
 
     if (!d->initKWallet()) {
-        return QList< Account* >();
+        return QList< Account::Ptr >();
     }
 
     if (!d->kwallet->hasFolder(d->kwalletFolder)) {
-        return QList< Account *>();
+        return QList< Account::Ptr >();
     }
 
     d->kwallet->setFolder(d->kwalletFolder);
     QStringList list = d->kwallet->entryList();
-    QList< Account * > accounts;
+    QList< Account::Ptr > accounts;
     foreach(QString accName, list) {
 
         QMap< QString, QString > map;
@@ -135,21 +134,22 @@ QList< KGoogle::Account * > Auth::getAccounts()
             scopeUrls << QUrl(scope);
         }
 
-        accounts.append(new Account(accName, map["accessToken"], \
map["refreshToken"], scopeUrls)); +        accounts.append(Account::Ptr(new \
Account(accName, map["accessToken"], map["refreshToken"], scopeUrls)));  }
 
     return accounts;
 }
 
-void Auth::storeAccount(const KGoogle::Account *account)
+void Auth::storeAccount(const KGoogle::Account::Ptr &account)
 {
     Q_D(Auth);
 
     if (!d->initKWallet())
         return;
 
-    if (!account || account->accountName().isEmpty() ||
-            account->accessToken().isEmpty() || account->refreshToken().isEmpty()) {
+    if (account.isNull() || account->accountName().isEmpty()
+        || account->accessToken().isEmpty() || account->refreshToken().isEmpty()) {
+
         throw Exception::InvalidAccount();
         return;
     }
@@ -174,7 +174,7 @@ void Auth::storeAccount(const KGoogle::Account *account)
     d->kwallet->writeMap(account->accountName(), map);
 }
 
-void Auth::authenticate(KGoogle::Account *account, bool autoSave)
+void Auth::authenticate(KGoogle::Account::Ptr &account, bool autoSave)
 {
     Q_D(Auth);
 
@@ -182,7 +182,7 @@ void Auth::authenticate(KGoogle::Account *account, bool autoSave)
         return;
     }
 
-    if (!account) {
+    if (account.isNull()) {
         throw Exception::InvalidAccount();
         return;
     }
@@ -204,11 +204,11 @@ void Auth::authenticate(KGoogle::Account *account, bool \
autoSave)  }
 }
 
-bool Auth::revoke(Account *account)
+bool Auth::revoke(Account::Ptr &account)
 {
     Q_D(Auth);
 
-    if (!account || account->accountName().isEmpty()) {
+    if (account.isNull() || account->accountName().isEmpty()) {
         return false;
     }
 
diff --git a/libkgoogle/auth.h b/libkgoogle/auth.h
index 256f1fc..151bf56 100644
--- a/libkgoogle/auth.h
+++ b/libkgoogle/auth.h
@@ -93,7 +93,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      * @return Returns KGoogle::Account or NULL when no such account is found in the
      *         KWallet or access to KWallet failed.
      */
-    KGoogle::Account* getAccount(const QString &account);
+    KGoogle::Account::Ptr getAccount(const QString &account);
 
     /**
      * Retrieves list of all accounts from KWallet.
@@ -105,7 +105,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      *
      * @return Returns list of all Google accounts from KWallet.
      */
-    QList< KGoogle::Account* > getAccounts();
+    QList< KGoogle::Account::Ptr > getAccounts();
 
     /**
      * Stores \p account in KWallet.
@@ -123,7 +123,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      *
      * @param account Account to store in KWallet
      */
-    void storeAccount(const KGoogle::Account *account);
+    void storeAccount(const KGoogle::Account::Ptr &account);
 
     /**
      * Authenticates \p account against Google services.
@@ -149,7 +149,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      *                 call KGoogle::Auth::storeAccount() to save changes
      *                 to KWallet.
      */
-    void authenticate(KGoogle::Account *account, bool autoSave = true);
+    void authenticate(KGoogle::Account::Ptr &account, bool autoSave = true);
 
     /**
      * Revokes tokens for \p account and removes it from KWallet.
@@ -163,7 +163,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      * @return Returns \p true when account is succesfully removed, \p false
      *         when account does not exist or something fails.
      */
-    bool revoke(KGoogle::Account *account);
+    bool revoke(KGoogle::Account::Ptr &account);
 
   Q_SIGNALS:
     /**
@@ -180,7 +180,7 @@ class LIBKGOOGLE_EXPORT Auth: public QObject
      * This signal is emitted when \p account was succesfully authenticated
      * (for the first time), or when just tokens were refreshed.
      */
-    void authenticated(KGoogle::Account *account);
+    void authenticated(KGoogle::Account::Ptr &account);
 
   private:
     AuthPrivate* const d_ptr;
diff --git a/libkgoogle/auth_p.cpp b/libkgoogle/auth_p.cpp
index 8999d57..c474303 100644
--- a/libkgoogle/auth_p.cpp
+++ b/libkgoogle/auth_p.cpp
@@ -65,7 +65,7 @@ bool AuthPrivate::initKWallet()
 }
 
 
-void AuthPrivate::fullAuthentication(KGoogle::Account *account, bool autoSave)
+void AuthPrivate::fullAuthentication(KGoogle::Account::Ptr &account, bool autoSave)
 {
     Q_Q(Auth);
 
@@ -74,8 +74,8 @@ void AuthPrivate::fullAuthentication(KGoogle::Account *account, \
bool autoSave)  
     connect(dlg, SIGNAL(error(KGoogle::Error, QString)),
             q, SIGNAL(error(KGoogle::Error, QString)));
-    connect(dlg, SIGNAL(authenticated(KGoogle::Account*)),
-            this, SLOT(fullAuthenticationFinished(KGoogle::Account*)));
+    connect(dlg, SIGNAL(authenticated(KGoogle::Account::Ptr&)),
+            this, SLOT(fullAuthenticationFinished(KGoogle::Account::Ptr&)));
     connect(dlg, SIGNAL(accepted()),
             dlg, SLOT(deleteLater()));
 
@@ -83,7 +83,7 @@ void AuthPrivate::fullAuthentication(KGoogle::Account *account, \
bool autoSave)  dlg->authenticate(account);
 }
 
-void AuthPrivate::fullAuthenticationFinished(KGoogle::Account *account)
+void AuthPrivate::fullAuthenticationFinished(KGoogle::Account::Ptr &account)
 {
     Q_Q(Auth);
 
@@ -111,7 +111,7 @@ void AuthPrivate::fullAuthenticationFinished(KGoogle::Account \
*account)  }
 
 
-void AuthPrivate::refreshTokens(KGoogle::Account *account, bool autoSave)
+void AuthPrivate::refreshTokens(KGoogle::Account::Ptr &account, bool autoSave)
 {
     QNetworkAccessManager *nam = new KIO::Integration::AccessManager(this);
     QNetworkRequest request;
@@ -124,7 +124,7 @@ void AuthPrivate::refreshTokens(KGoogle::Account *account, bool \
autoSave)  request.setUrl(QUrl("https://accounts.google.com/o/oauth2/token"));
     request.setHeader(QNetworkRequest::ContentTypeHeader, \
"application/x-www-form-urlencoded");  request.setAttribute(QNetworkRequest::User, \
                QVariant(autoSave));
-    request.setAttribute(QNetworkRequest::UserMax, \
qVariantFromValue<Account*>(account)); +    \
request.setAttribute(QNetworkRequest::UserMax, qVariantFromValue< Account::Ptr \
>(account));  
     QUrl params;
     params.addQueryItem("client_id", APIClientID);
@@ -151,7 +151,7 @@ void AuthPrivate::refreshTokensFinished(QNetworkReply *reply)
 
     QNetworkRequest request = reply->request();
     bool autoSave = request.attribute(QNetworkRequest::User).toBool();
-    Account *account = \
qVariantValue<Account*>(request.attribute(QNetworkRequest::UserMax)); +    \
Account::Ptr account = qVariantValue< Account::Ptr \
>(request.attribute(QNetworkRequest::UserMax));  
     QByteArray rawData = reply->readAll();
     QJson::Parser parser;
diff --git a/libkgoogle/auth_p.h b/libkgoogle/auth_p.h
index 7fe9082..3e61556 100644
--- a/libkgoogle/auth_p.h
+++ b/libkgoogle/auth_p.h
@@ -21,6 +21,8 @@
 
 #include <qobject.h>
 
+#include "account.h"
+
 namespace KWallet
 {
 class Wallet;
@@ -31,8 +33,6 @@ class QNetworkReply;
 namespace KGoogle
 {
 
-class Account;
-
 class Auth;
 
 /**
@@ -56,10 +56,10 @@ class AuthPrivate: public QObject
     bool initKWallet();
 
   public Q_SLOTS:
-    void fullAuthentication(KGoogle::Account *account, bool autoSave);
-    void fullAuthenticationFinished(KGoogle::Account *account);
+    void fullAuthentication(KGoogle::Account::Ptr &account, bool autoSave);
+    void fullAuthenticationFinished(KGoogle::Account::Ptr &account);
 
-    void refreshTokens(KGoogle::Account *account, bool autoSave);
+    void refreshTokens(KGoogle::Account::Ptr &account, bool autoSave);
     void refreshTokensFinished(QNetworkReply *reply);
 
   private:
diff --git a/libkgoogle/authdialog.cpp b/libkgoogle/authdialog.cpp
index aee3934..5189278 100644
--- a/libkgoogle/authdialog.cpp
+++ b/libkgoogle/authdialog.cpp
@@ -166,8 +166,8 @@ void AuthDialog::accountInfoReceived(KGoogle::Reply* reply)
 
     delete reply;
 
-    accept();
     emit authenticated(m_account);
+    accept();
 }
 
 
@@ -226,10 +226,10 @@ AuthDialog::~AuthDialog()
     delete m_widget;
 }
 
-void AuthDialog::authenticate(KGoogle::Account *account)
+void AuthDialog::authenticate(KGoogle::Account::Ptr &account)
 {
 
-    if (!account || account->scopes().isEmpty()) {
+    if (account.isNull() || account->scopes().isEmpty()) {
         throw KGoogle::Exception::InvalidAccount();
         return;
     }
diff --git a/libkgoogle/authdialog.h b/libkgoogle/authdialog.h
index 9d7a703..a5133c2 100644
--- a/libkgoogle/authdialog.h
+++ b/libkgoogle/authdialog.h
@@ -79,7 +79,7 @@ class LIBKGOOGLE_EXPORT AuthDialog: public KDialog
      *
      * @param account An account to be authenticated.
      */
-    void authenticate(KGoogle::Account *account);
+    void authenticate(KGoogle::Account::Ptr &account);
 
   Q_SIGNALS:
     /**
@@ -90,7 +90,7 @@ class LIBKGOOGLE_EXPORT AuthDialog: public KDialog
      *
      * @param account Successfully authenticated account with name tokens set
      */
-    void authenticated(KGoogle::Account *account);
+    void authenticated(KGoogle::Account::Ptr &account);
 
     /**
      * Emitted whenever an error occurs during the authentication.
@@ -119,7 +119,7 @@ class LIBKGOOGLE_EXPORT AuthDialog: public KDialog
     KWebView *m_webiew;
     QLabel *m_label;
 
-    KGoogle::Account *m_account;
+    KGoogle::Account::Ptr m_account;
 };
 
 #endif // AUTHDIALOG_H
diff --git a/libkgoogle/fetchlistjob.cpp b/libkgoogle/fetchlistjob.cpp
index 89a5a9f..61f746f 100644
--- a/libkgoogle/fetchlistjob.cpp
+++ b/libkgoogle/fetchlistjob.cpp
@@ -60,7 +60,7 @@ void FetchListJob::start()
     Q_D(FetchListJob);
 
     KGoogle::Auth *auth = KGoogle::Auth::instance();
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
     try {
         account = auth->getAccount(d->accountName);
     } catch (KGoogle::Exception::BaseException &e) {
@@ -126,4 +126,4 @@ QString FetchListJob::service() const
     Q_D(const FetchListJob);
 
     return d->service;
-}
\ No newline at end of file
+}
diff --git a/libkgoogle/request.cpp b/libkgoogle/request.cpp
index fc46fb5..192698e 100644
--- a/libkgoogle/request.cpp
+++ b/libkgoogle/request.cpp
@@ -40,7 +40,7 @@ public:
     QByteArray requestData;
     QString contentType;
     QMap< QString, QVariant > properties;
-    KGoogle::Account *account;
+    KGoogle::Account::Ptr account;
 };
 
 }
@@ -55,7 +55,7 @@ Request::Request():
 }
 
 Request::Request(const QUrl &url, const KGoogle::Request::RequestType requestType,
-                 const QString &serviceName, KGoogle::Account *account):
+                 const QString &serviceName, const KGoogle::Account::Ptr &account):
     QNetworkRequest(url),
     d_ptr(new RequestPrivate)
 {
@@ -126,7 +126,7 @@ const QString& Request::contentType() const
     return d_func()->contentType;
 }
 
-KGoogle::Account* Request::account() const
+KGoogle::Account::Ptr Request::account() const
 {
     return d_func()->account;
 }
diff --git a/libkgoogle/request.h b/libkgoogle/request.h
index 1d7b974..b8dfc00 100644
--- a/libkgoogle/request.h
+++ b/libkgoogle/request.h
@@ -25,12 +25,11 @@
 #include <QtCore/QUrl>
 
 #include <libkgoogle/libkgoogle_export.h>
+#include <libkgoogle/account.h>
 
 namespace KGoogle
 {
 
-class Account;
-
 class RequestPrivate;
 
 /**
@@ -62,7 +61,7 @@ class LIBKGOOGLE_EXPORT Request: public QNetworkRequest
      * @param serviceName Name of service this request belongs to.
      * @param account Google Account to which the request should be sent
      */
-    Request(const QUrl &url, const RequestType requestType, const QString \
&serviceName, KGoogle::Account *account); +    Request(const QUrl &url, const \
RequestType requestType, const QString &serviceName, const KGoogle::Account::Ptr \
&account);  
 
     virtual ~Request();
@@ -118,7 +117,7 @@ class LIBKGOOGLE_EXPORT Request: public QNetworkRequest
     /**
      * Returns account to which the request is sent.
      */
-    KGoogle::Account* account() const;
+    KGoogle::Account::Ptr account() const;
 
     /**
      * Set a value of an objects property.
diff --git a/libkgoogle/ui/accountscombo.cpp b/libkgoogle/ui/accountscombo.cpp
index 653798c..0a0d69d 100644
--- a/libkgoogle/ui/accountscombo.cpp
+++ b/libkgoogle/ui/accountscombo.cpp
@@ -35,20 +35,20 @@ AccountsCombo::~AccountsCombo()
 
 }
 
-KGoogle::Account *AccountsCombo::currentAccount() const
+KGoogle::Account::Ptr AccountsCombo::currentAccount() const
 {
     int index = currentIndex();
 
     if (index == -1)
-        return 0;
+        return KGoogle::Account::Ptr();
 
-    return qVariantValue< KGoogle::Account* >(itemData(index, Qt::UserRole));
+    return qVariantValue< KGoogle::Account::Ptr >(itemData(index, Qt::UserRole));
 }
 
 void AccountsCombo::reload()
 {
     KGoogle::Auth *auth = KGoogle::Auth::instance();
-    QList< KGoogle::Account* > accounts;
+    QList< KGoogle::Account::Ptr > accounts;
     clear();
 
     try {
@@ -58,7 +58,7 @@ void AccountsCombo::reload()
         return;
     }
 
-    foreach(KGoogle::Account * account, accounts) {
+    foreach(const KGoogle::Account::Ptr &account, accounts) {
         addItem(account->accountName(), qVariantFromValue(account));
     }
 }
diff --git a/libkgoogle/ui/accountscombo.h b/libkgoogle/ui/accountscombo.h
index ba85707..97df08e 100644
--- a/libkgoogle/ui/accountscombo.h
+++ b/libkgoogle/ui/accountscombo.h
@@ -24,6 +24,7 @@
 #include <qstandarditemmodel.h>
 
 #include <libkgoogle/libkgoogle_export.h>
+#include <libkgoogle/account.h>
 
 namespace KGoogle
 {
@@ -42,7 +43,7 @@ public:
 
     virtual ~AccountsCombo();
 
-    KGoogle::Account* currentAccount() const;
+    KGoogle::Account::Ptr currentAccount() const;
 
 public Q_SLOTS:
     void reload();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic