void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode) { auto activities = json.value("ocs").toMap().value("data").toList(); qDebug() << "*** activities" << activities; ActivityList list; AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr")); _currentlyFetching.remove(ai); list.setAccountName( ai->account()->displayName()); foreach( auto activ, activities ) { auto json = activ.toMap(); Activity a; a._accName = ai->account()->displayName(); a._id = json.value("id").toLongLong(); a._subject = json.value("subject").toString(); a._message = json.value("message").toString(); a._file = json.value("file").toString(); a._link = json.value("link").toUrl(); a._dateTime = json.value("date").toDateTime(); list.append(a); }
void Application::slotLogout() { AccountState* ai = AccountStateManager::instance()->accountState(); if (ai) { AccountPtr a = ai->account(); // invalidate & forget token/password a->credentials()->invalidateToken(); // terminate all syncs and unload folders FolderMan *folderMan = FolderMan::instance(); folderMan->setSyncEnabled(false); folderMan->terminateSyncProcess(); ai->setSignedOut(true); // show result _gui->slotComputeOverallSyncStatus(); } }
void ServerNotificationHandler::slotNotificationsReceived(const QVariantMap& json, int statusCode) { if( statusCode != 200 ) { qDebug() << Q_FUNC_INFO << "Notifications failed with status code " << statusCode; deleteLater(); return; } auto notifies = json.value("ocs").toMap().value("data").toList(); AccountState* ai = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr")); ActivityList list; foreach( auto element, notifies ) { Activity a; auto json = element.toMap(); a._type = Activity::NotificationType; a._accName = ai->account()->displayName(); a._id = json.value("notification_id").toLongLong(); a._subject = json.value("subject").toString(); a._message = json.value("message").toString(); QString s = json.value("link").toString(); if( !s.isEmpty() ) { a._link = QUrl(s); } a._dateTime = json.value("datetime").toDateTime(); auto actions = json.value("actions").toList(); foreach( auto action, actions) { auto actionJson = action.toMap(); ActivityLink al; al._label = QUrl::fromPercentEncoding(actionJson.value("label").toByteArray()); al._link = actionJson.value("link").toString(); al._verb = actionJson.value("type").toByteArray(); al._isPrimary = actionJson.value("primary").toBool(); a._links.append(al); }