예제 #1
0
void CDTpController::maybeStartOfflineOperations(CDTpAccountPtr accountWrapper)
{
    if (!accountWrapper->hasRoster()) {
        return;
    }

    Tp::AccountPtr account = accountWrapper->account();

    // Start removal operation
    mOfflineRosterBuffer->beginGroup(offlineRemovals);
    QStringList idsToRemove = mOfflineRosterBuffer->value(account->objectPath()).toStringList();
    mOfflineRosterBuffer->endGroup();
    if (!idsToRemove.isEmpty()) {
        CDTpRemovalOperation *op = new CDTpRemovalOperation(accountWrapper, idsToRemove);
        connect(op,
                SIGNAL(finished(Tp::PendingOperation *)),
                SLOT(onRemovalFinished(Tp::PendingOperation *)));
    }

    // Start invitation operation
    mOfflineRosterBuffer->beginGroup(offlineInvitations);
    QStringList idsToInvite = mOfflineRosterBuffer->value(account->objectPath()).toStringList();
    mOfflineRosterBuffer->endGroup();
    if (!idsToInvite.isEmpty()) {
        // FIXME: We should also save the localId for offline operations
        CDTpInvitationOperation *op = new CDTpInvitationOperation(mStorage, accountWrapper, idsToInvite, 0);
        connect(op,
                SIGNAL(finished(Tp::PendingOperation *)),
                SLOT(onInvitationFinished(Tp::PendingOperation *)));
    }
}
PresenceSource::PresenceSource(const Tp::AccountPtr &account, QObject *parent)
    : Plasma::DataContainer(parent),
      m_account(account)
{
    kDebug() << "PresenceSource created for account:" <<
        account->objectPath();

    setData("DisplayName", "");
    setData("Nickname", "");
    setData("AccountAvatar", "");
    setData("AccountIcon", "");
    setData("PresenceType", "");
    setData("PresenceTypeID", 0);
    setData("PresenceStatus", "");
    setData("PresenceStatusMessage", "");
    setData("Enabled", false);

    // Set the object name (which will be the name of the source)
    setObjectName(m_account->objectPath());

    // Make the account become ready with the desired features
    connect(m_account->becomeReady(Tp::Account::FeatureProtocolInfo|Tp::Account::FeatureAvatar),
            SIGNAL(finished(Tp::PendingOperation*)),
            this,
            SLOT(onAccountReady(Tp::PendingOperation*)));
}
예제 #3
0
void PendingClear::clearRoom(const Tp::AccountPtr &account, const QString &objectId)
{
    QDBusObjectPath path = QDBusObjectPath(account->objectPath());
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(
                mInterface->ClearEntity(path, objectId, EntityTypeRoom));

    connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
            this,
            SLOT(onLogCleared(QDBusPendingCallWatcher*)));
}
예제 #4
0
void PendingClear::clearAccount(const Tp::AccountPtr &account)
{
    QDBusObjectPath path = QDBusObjectPath(account->objectPath());
    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(
                mInterface->ClearAccount(path));

    connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
            this,
            SLOT(onLogCleared(QDBusPendingCallWatcher*)));
}
예제 #5
0
CDTpAccountPtr CDTpController::insertAccount(const Tp::AccountPtr &account, bool newAccount)
{
    debug() << "Creating wrapper for account" << account->objectPath();

    // Get the list of contact ids waiting to be removed from server
    mOfflineRosterBuffer->beginGroup(offlineRemovals);
    QStringList idsToRemove = mOfflineRosterBuffer->value(account->objectPath()).toStringList();
    mOfflineRosterBuffer->endGroup();

    CDTpAccountPtr accountWrapper = CDTpAccountPtr(new CDTpAccount(account, idsToRemove, newAccount, this));
    mAccounts.insert(account->objectPath(), accountWrapper);

    maybeStartOfflineOperations(accountWrapper);

    // Connect change notifications
    connect(accountWrapper.data(),
            SIGNAL(rosterChanged(CDTpAccountPtr)),
            SLOT(onRosterChanged(CDTpAccountPtr)));
    connect(accountWrapper.data(),
            SIGNAL(changed(CDTpAccountPtr, CDTpAccount::Changes)),
            mStorage,
            SLOT(updateAccount(CDTpAccountPtr, CDTpAccount::Changes)));
    connect(accountWrapper.data(),
            SIGNAL(rosterUpdated(CDTpAccountPtr,
                    const QList<CDTpContactPtr> &,
                    const QList<CDTpContactPtr> &)),
            mStorage,
            SLOT(syncAccountContacts(CDTpAccountPtr,
                    const QList<CDTpContactPtr> &,
                    const QList<CDTpContactPtr> &)));
    connect(accountWrapper.data(),
            SIGNAL(rosterContactChanged(CDTpContactPtr, CDTpContact::Changes)),
            mStorage,
            SLOT(updateContact(CDTpContactPtr, CDTpContact::Changes)));
    connect(accountWrapper.data(),
            SIGNAL(syncStarted(Tp::AccountPtr)),
            SLOT(onSyncStarted(Tp::AccountPtr)));
    connect(accountWrapper.data(),
            SIGNAL(syncEnded(Tp::AccountPtr, int, int)),
            SLOT(onSyncEnded(Tp::AccountPtr, int, int)));

    return accountWrapper;
}
예제 #6
0
void CDTpController::onAccountAdded(const Tp::AccountPtr &account)
{
    if (mAccounts.contains(account->objectPath())) {
        warning() << "Internal error, account was already in controller";
        return;
    }

    CDTpAccountPtr accountWrapper = insertAccount(account, true);
    mStorage->createAccount(accountWrapper);
}
예제 #7
0
void CDTpController::onAccountRemoved(const Tp::AccountPtr &account)
{
    CDTpAccountPtr accountWrapper(mAccounts.take(account->objectPath()));
    if (not accountWrapper) {
        warning() << "Internal error, account was not in controller";
        return;
    }
    mStorage->removeAccount(accountWrapper);

    // Drop pending offline operations
    QString accountPath = accountWrapper->account()->objectPath();

    mOfflineRosterBuffer->beginGroup(offlineRemovals);
    mOfflineRosterBuffer->remove(accountPath);
    mOfflineRosterBuffer->endGroup();

    mOfflineRosterBuffer->beginGroup(offlineInvitations);
    mOfflineRosterBuffer->remove(accountPath);
    mOfflineRosterBuffer->endGroup();

    mOfflineRosterBuffer->sync();
}
예제 #8
0
void CDTpController::onSyncEnded(Tp::AccountPtr account, int contactsAdded, int contactsRemoved)
{
    Q_EMIT importEnded(account->serviceName(), account->objectPath(),
        contactsAdded, contactsRemoved, 0);
}
예제 #9
0
void CDTpController::onSyncStarted(Tp::AccountPtr account)
{
    Q_EMIT importStarted(account->serviceName(), account->objectPath());
}