void VkAuthManager::GetAuthKey () { if (Token_.isEmpty () || ReceivedAt_.secsTo (QDateTime::currentDateTime ()) > ValidFor_) { RequestAuthKey (); return; } emit gotAuthKey (Token_); }
AudioSearch::AudioSearch (ICoreProxy_ptr proxy, const Media::AudioSearchRequest& query, Util::SvcAuth::VkAuthManager *mgr, Util::QueueManager *queue, QObject *parent) : QObject (parent) , Proxy_ (proxy) , Queue_ (queue) , AuthMgr_ (mgr) , Query_ (query) { connect (AuthMgr_, SIGNAL (gotAuthKey (QString)), this, SLOT (handleGotAuthKey (QString))); AuthMgr_->GetAuthKey (); }
bool VkAuthManager::CheckIsBlank (QUrl location) { if (location.path () != "/blank.html") return false; location = QUrl::fromEncoded (location.toEncoded ().replace ('#', '?')); Token_ = location.queryItemValue ("access_token"); ValidFor_ = location.queryItemValue ("expires_in").toInt (); ReceivedAt_ = QDateTime::currentDateTime (); qDebug () << Q_FUNC_INFO << Token_ << ValidFor_; IsRequesting_ = false; emit gotAuthKey (Token_); return true; }
void VkAuthManager::GetAuthKey () { if (SilentMode_) { PrioManagedQueues_.clear (); ManagedQueues_.clear (); return; } if (!IsAuthenticated ()) { RequestAuthKey (); return; } InvokeQueues (Token_); emit gotAuthKey (Token_); }
bool VkAuthManager::CheckReply (QUrl location) { if (location.path () != "/blank.html") return CheckError (location); location = QUrl::fromEncoded (location.toEncoded ().replace ('#', '?')); #if QT_VERSION < 0x050000 Token_ = location.queryItemValue ("access_token"); ValidFor_ = location.queryItemValue ("expires_in").toInt (); #else const QUrlQuery query { location }; Token_ = query.queryItemValue ("access_token"); ValidFor_ = query.queryItemValue ("expires_in").toInt (); #endif ReceivedAt_ = QDateTime::currentDateTime (); qDebug () << Q_FUNC_INFO << Token_ << ValidFor_; IsRequesting_ = false; InvokeQueues (Token_); emit gotAuthKey (Token_); emit justAuthenticated (); return true; }