CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) : QAbstractTableModel(parent) , m_cookieJar(cookieJar) { connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); m_cookieJar->load(); m_cookies = m_cookieJar->cookies(); }
void Plugin::Init (ICoreProxy_ptr proxy) { Proxy_ = proxy; Util::InstallTranslator ("touchstreams"); XSD_.reset (new Util::XmlSettingsDialog); XSD_->RegisterObject (&XmlSettingsManager::Instance (), "touchstreamssettings.xml"); Queue_ = new Util::QueueManager (1000); AuthMgr_ = new Util::SvcAuth::VkAuthManager ("TouchStreams", "3298289", { "audio", "friends" }, XmlSettingsManager::Instance ().property ("Cookies").toByteArray (), proxy, Queue_); connect (AuthMgr_, SIGNAL (cookiesChanged (QByteArray)), this, SLOT (saveCookies (QByteArray))); AlbumsMgr_ = new AlbumsManager (AuthMgr_, proxy, this); FriendsMgr_ = new FriendsManager (AuthMgr_, Queue_, proxy, this); RecsManager_ = new RecsManager ({}, AuthMgr_, Queue_, proxy, this); Model_ = new QStandardItemModel; Model_->appendRow (AlbumsMgr_->GetRootItem ()); Model_->appendRow (FriendsMgr_->GetRootItem ()); Model_->appendRow (RecsManager_->GetRootItem ()); }
void Plugin::Init (ICoreProxy_ptr proxy) { Proxy_ = proxy; Util::InstallTranslator ("touchstreams"); XSD_.reset (new Util::XmlSettingsDialog); XSD_->RegisterObject (&XmlSettingsManager::Instance (), "touchstreamssettings.xml"); Queue_ = new Util::QueueManager (10000); AuthMgr_ = new Util::SvcAuth::VkAuthManager ("TouchStreams", "3298289", { "audio", "friends" }, XmlSettingsManager::Instance ().property ("Cookies").toByteArray (), proxy, Queue_); connect (AuthMgr_, SIGNAL (cookiesChanged (QByteArray)), this, SLOT (saveCookies (QByteArray))); AlbumsMgr_ = new AlbumsManager (AuthMgr_, Queue_, proxy, this); FriendsMgr_ = new FriendsManager (AuthMgr_, Queue_, proxy, this); connect (XSD_.get (), SIGNAL (pushButtonClicked (QString)), this, SLOT (handlePushButton (QString))); }
void VkAuthManager::handleViewUrlChanged (const QUrl& url) { if (!CheckIsBlank (url)) return; emit cookiesChanged (Cookies_->Save ()); sender ()->deleteLater (); }
bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || !m_cookieJar) return false; int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); QList<QNetworkCookie> lst = m_cookies; for (int i = lastRow; i >= row; --i) { lst.removeAt(i); } m_cookieJar->setCookies(lst); disconnect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); m_cookieJar->m_saveTimer->changeOccurred(); emit m_cookieJar->cookiesChanged(); connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); m_cookies = lst; endRemoveRows(); return true; }
void CookieModel::setCookeJar(CookieJar *cookieJar) { if (!cookieJar) return; if (m_cookieJar == cookieJar) return; if (m_cookieJar) disconnect(m_cookieJar, 0, this, 0); m_cookieJar = cookieJar; connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(onCookiesChanged())); m_cookieJar->load(); reset(); }