Пример #1
0
void Application::slotUpdateConnectionErrors(int accountState)
{
    bool isConnected = accountState == AccountState::Connected;
    if( !isConnected ) {
        _startupNetworkError = accountState == AccountState::NetworkError;
    }

    AccountState *as = AccountStateManager::instance()->accountState();
    if (as) {
        _gui->setConnectionErrors( isConnected, as->connectionErrors() );
    }
}
Пример #2
0
void Application::slotCheckConnection()
{
    AccountState *accountState = AccountStateManager::instance()->accountState();

    if( accountState ) {
        accountState->checkConnectivity();

    } else {
        // let gui open the setup wizard
        _gui->slotOpenSettingsDialog( true );

        _checkConnectionTimer.stop(); // don't popup the wizard on interval;
    }
}
Пример #3
0
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();
    }
}
Пример #4
0
// current strategy: Fetch 100 items per Account
// ATTENTION: This method is const and thus it is not possible to modify
// the _activityLists hash or so. Doesn't make it easier...
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
{
    if( _activityLists.count() == 0 ) return true;

    for(auto i = _activityLists.begin() ; i != _activityLists.end(); ++i) {
        AccountState *ast = i.key();
        if( ast && ast->isConnected() ) {
            ActivityList activities = i.value();
            if( activities.count() == 0 &&
                    ! _currentlyFetching.contains(ast) ) {
                return true;
            }
        }
    }

    return false;
}
Пример #5
0
// current strategy: Fetch 100 items per Account
bool ActivityListModel::canFetchMore(const QModelIndex& ) const
{
    if( _activityLists.count() == 0 ) return true;

    QMap<AccountState*, ActivityList>::const_iterator i = _activityLists.begin();
    while (i != _activityLists.end()) {
        AccountState *ast = i.key();
        if( !ast->isConnected() ) {
            return false;
        }
        ActivityList activities = i.value();
        if( activities.count() == 0 &&
                ! _currentlyFetching.contains(ast) ) {
            return true;
        }
        ++i;
    }

    return false;
}
Пример #6
0
void ActivityListModel::slotActivitiesReceived(const QVariantMap& json, int statusCode)
{
    auto activities = json.value("ocs").toMap().value("data").toList();

    ActivityList list;
    AccountState* ast = qvariant_cast<AccountState*>(sender()->property("AccountStatePtr"));
    _currentlyFetching.remove(ast);

    foreach( auto activ, activities ) {
        auto json = activ.toMap();

        Activity a;
        a._type = Activity::ActivityType;
        a._accName  = ast->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);
    }
Пример #7
0
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);
        }