SVN commit 925700 by lure: Facebook application type has changed to Desktop (was wrongly set as Web before). This requires slightly different way of authenticating/signing API requests and will therefore break Facebook import/export for all users that will not upgrade to new code. Since Release Candidate 2 is this weekend, this should not be for too long. SVN users should just rebuild. BUG: 182838 M +2 -1 NEWS M +22 -4 facebook/fbtalker.cpp M +21 -17 facebook/fbtalker.h M +6 -2 facebook/fbwindow.cpp M +1 -0 facebook/fbwindow.h --- trunk/extragear/graphics/kipi-plugins/NEWS #925699:925700 @@ -14,7 +14,8 @@ 004 ==> 181334 : IpodExort : The artwork API in libgpod-0.7.0 has changed slightly, IpodExport plugin needs updated. 005 ==> 181853 : MetadataEdit : Entering new xmp meta data removes old one from the image file. 006 ==> 133649 : Print Wizard : Scale images instead of cropping. -007 ==> +007 ==> 182838 : Facebook : Change API authentication to Desktop application type. +008 ==> Kipi-plugins 0.2.0-rc1 - Release date: 21/01/2009 ------------------------------------------------------------------------ --- trunk/extragear/graphics/kipi-plugins/facebook/fbtalker.cpp #925699:925700 @@ -80,7 +80,7 @@ m_job->kill(); } -bool FbTalker::loggedIn() +bool FbTalker::loggedIn() const { return !m_sessionKey.isEmpty(); } @@ -90,6 +90,11 @@ return m_sessionKey; } +QString FbTalker::getSessionSecret() const +{ + return m_sessionSecret; +} + unsigned int FbTalker::getSessionExpires() const { return m_sessionExpires; @@ -129,7 +134,10 @@ concat.append("="); concat.append(it.value()); } - concat.append(m_secretKey); + if (args["session_key"].isEmpty()) + concat.append(m_secretKey); + else + concat.append(m_sessionSecret); KMD5 md5(concat.toUtf8()); return md5.hexDigest().data(); @@ -155,15 +163,20 @@ return concat; } -void FbTalker::authenticate(const QString &sessionKey, unsigned int sessionExpires) +void FbTalker::authenticate(const QString &sessionKey, + const QString &sessionSecret, + unsigned int sessionExpires) { m_loginInProgress = true; - if (!sessionKey.isEmpty() && sessionExpires > (unsigned int)(time(0) + 900)) + if (!sessionKey.isEmpty() + && !sessionSecret.isEmpty() + && sessionExpires > (unsigned int)(time(0) + 900)) { // sessionKey seems to be still valid for at least 15 minutes // - check if it still works m_sessionKey = sessionKey; + m_sessionSecret = sessionSecret; m_sessionExpires = sessionExpires; m_authProgressDlg->setLabelText(i18n("Validate previous session...")); @@ -800,6 +813,7 @@ { m_authToken.clear(); m_sessionKey.clear(); + m_sessionSecret.clear(); m_sessionExpires = 0; m_user.clear(); } @@ -908,6 +922,8 @@ continue; if (node.nodeName() == "session_key") m_sessionKey = node.toElement().text(); + else if (node.nodeName() == "secret") + m_sessionSecret = node.toElement().text(); else if (node.nodeName() == "uid") m_user.id = node.toElement().text().toLongLong(); else if (node.nodeName() == "expires") @@ -962,6 +978,7 @@ // it seems that session expired -> create new token and session m_authToken.clear(); m_sessionKey.clear(); + m_sessionSecret.clear(); m_sessionExpires = 0; m_user.clear(); @@ -1094,6 +1111,7 @@ // consider we are logged out in any case m_sessionKey.clear(); + m_sessionSecret.clear(); m_sessionExpires = 0; m_user.clear(); --- trunk/extragear/graphics/kipi-plugins/facebook/fbtalker.h #925699:925700 @@ -50,13 +50,16 @@ ~FbTalker(); QString getSessionKey() const; + QString getSessionSecret() const; unsigned int getSessionExpires() const; FbUser getUser() const; - bool loggedIn(); + bool loggedIn() const; void cancel(); - void authenticate(const QString& sessionKey, unsigned int sessionExpires); + void authenticate(const QString& sessionKey, + const QString& sessionSecret, + unsigned int sessionExpires); void changePerm(); void logout(); @@ -136,27 +139,28 @@ void slotResult(KJob *job); private: - QWidget* m_parent; + QWidget* m_parent; - QByteArray m_buffer; + QByteArray m_buffer; - QString m_userAgent; - QString m_apiURL; - QString m_apiVersion; - QString m_apiKey; - QString m_secretKey; + QString m_userAgent; + QString m_apiURL; + QString m_apiVersion; + QString m_apiKey; + QString m_secretKey; - bool m_loginInProgress; - QString m_authToken; - QString m_sessionKey; - long m_sessionExpires; - QTime m_callID; + bool m_loginInProgress; + QString m_authToken; + QString m_sessionKey; + QString m_sessionSecret; + unsigned int m_sessionExpires; + QTime m_callID; - FbUser m_user; + FbUser m_user; - KIO::Job* m_job; + KIO::Job* m_job; - State m_state; + State m_state; }; } // namespace KIPIFbPlugin --- trunk/extragear/graphics/kipi-plugins/facebook/fbwindow.cpp #925699:925700 @@ -212,7 +212,7 @@ kDebug(51000) << "Calling Login method"; buttonStateChange(m_talker->loggedIn()); - m_talker->authenticate(m_sessionKey, m_sessionExpires); + m_talker->authenticate(m_sessionKey, m_sessionSecret, m_sessionExpires); } FbWindow::~FbWindow() @@ -230,6 +230,7 @@ KConfig config("kipirc"); KConfigGroup grp = config.group("Facebook Settings"); m_sessionKey = grp.readEntry("Session Key"); + m_sessionSecret = grp.readEntry("Session Secret"); m_sessionExpires = grp.readEntry("Session Expires", 0); m_currentAlbumID = grp.readEntry("Current Album", -1LL); @@ -265,6 +266,7 @@ KConfig config("kipirc"); KConfigGroup grp = config.group("Facebook Settings"); grp.writeEntry("Session Key", m_sessionKey); + grp.writeEntry("Session Secret", m_sessionSecret); grp.writeEntry("Session Expires", m_sessionExpires); grp.writeEntry("Current Album", m_currentAlbumID); grp.writeEntry("Resize", m_widget->m_resizeChB->isChecked()); @@ -306,6 +308,7 @@ m_widget->m_albumsCoB->addItem(i18n(""), 0); m_sessionKey = m_talker->getSessionKey(); + m_sessionSecret = m_talker->getSessionSecret(); m_sessionExpires = m_talker->getSessionExpires(); if (errCode == 0 && m_talker->loggedIn()) @@ -460,11 +463,12 @@ { m_talker->logout(); m_sessionKey.clear(); + m_sessionSecret.clear(); m_sessionExpires = 0; } kDebug(51000) << "Calling Login method"; - m_talker->authenticate(m_sessionKey, m_sessionExpires); + m_talker->authenticate(m_sessionKey, m_sessionSecret, m_sessionExpires); } void FbWindow::slotPermChangeRequest() --- trunk/extragear/graphics/kipi-plugins/facebook/fbwindow.h #925699:925700 @@ -122,6 +122,7 @@ long long m_profileAID; long long m_currentAlbumID; QString m_sessionKey; + QString m_sessionSecret; unsigned int m_sessionExpires; QProgressDialog *m_progressDlg;