コード例 #1
0
QList <QSharedPointer<Account> > SystemPrivate::loadAccounts (
    const QString & serviceType, bool includeCustomUI) {

    qDebug() << "PERF: LoadAccounts START";

    QList <QSharedPointer<Account> > retList;
    Accounts::AccountIdList idList =
        m_accountsManager->accountList (serviceType);

    for (int i = 0; i < idList.size (); ++i) {
        Accounts::Account * aAccount = m_accountsManager->account (idList [i]);

        if (aAccount == 0) {
            qWarning() << "Null account received" << i + 1;
            continue;
        }

        Accounts::ServiceList sList = aAccount->services (serviceType);

        for (int j = 0; j < sList.size (); ++j) {
            Accounts::Service aService = sList [j];

            aAccount->selectService (aService);
            qDebug() << "Service" << aService.displayName() << "found for"
                << "account" << aAccount->displayName();

            QSharedPointer <Account> sAccount = QSharedPointer <Account> (
                new Account);

            if (sAccount->init (idList [i], aService.name())) {
                bool append = true;

                if (includeCustomUI == false) {
                    if (sAccount->service()->publishCustom() ==
                        Service::PUBLISH_CUSTOM_TOTAL) {
                        append = false;
                    }
                }

                if (append == true) {
                    retList.append (sAccount);
                }
            }
        }

        delete aAccount;
        aAccount = 0;

    }

    qDebug() << "PERF: LoadAccounts END";

    return retList;
}
コード例 #2
0
void SystemPrivate::accountsAccountCreated (Accounts::AccountId id) {

    // Safety check
    if (accountsListenerEnabled == false) {
        qDebug() << "Account created and ignored";
        return;
    }

    //Check for sharing services under created account
    Accounts::Account * aAcc = m_accountsManager->account (id);
    if (aAcc == 0) {
        qWarning() << "Invalid account ID from Accounts Manager";
        return;
    }

    if (aAcc->supportsService ("sharing") == false) {
        qDebug() << "Account created but without sharing support, ignored.";
        delete aAcc;
        return;
    }

    qDebug() << "Accounts' new account signal received" << id;

    Accounts::ServiceList services = aAcc->services ("sharing");

    for (int i = 0; i < services.count(); ++i) {
        Accounts::Service aService = services.at (i);

        WebUpload::SharedAccount sAccount (new WebUpload::Account (0));

        if (sAccount->init (aAcc->id(), aService.name()) == true) {
            qDebug() << "Emitting signal for new account" << sAccount->name();
            Q_EMIT (newAccount(sAccount));
        }
    }

    delete aAcc;
}
/*!
 * \qmlproperty jsobject AccountService::service
 * An immutable object representing the service which this AccountService
 * instantiates.
 * The returned object will have at least these members:
 * \list
 * \li \c id is the unique identified for this service
 * \li \c displayName
 * \li \c iconName
 * \li \c serviceTypeId identifies the provided service type
 * \li \c translations, the localization domain for translating the provider's
 * display name
 * \endlist
 */
QVariantMap AccountService::service() const
{
    QVariantMap map;
    if (Q_UNLIKELY(accountService == 0)) return map;

    Accounts::Service service = accountService->service();
    map.insert("id", service.name());
    map.insert("displayName", service.displayName());
    map.insert("iconName", service.iconName());
    map.insert("serviceTypeId", service.serviceType());
    map.insert("translations", service.trCatalog());
    return map;
}
コード例 #4
0
    _accountManager = Tp::AccountManager::create();
}

void
ToggleAvailability::activate() {
    if (!_accountManager->isReady(Tp::AccountManager::FeatureCore)) {
        qDebug() << qPrintable(QDateTime::currentDateTime().toString()) << "ToggleAvailability::toggle Telepathy Account Manager was not ready - will retry as soon as it is ready.";
        connect(_accountManager->becomeReady(Tp::AccountManager::FeatureCore),
                SIGNAL(finished(Tp::PendingOperation*)),
                SLOT(onAccountManagerReady(Tp::PendingOperation*)), Qt::UniqueConnection);
        return;
    }

    foreach(Accounts::AccountId accountId, _manager->accountList()) {
        Accounts::Account *account = _manager->account(accountId);
        foreach (const Accounts::Service *service, account->services()) {
            account->selectService(service);

            QString uid = account->valueAsString("tmc-uid");

            if (uid.isEmpty())
                continue;

            Tp::AccountPtr tpAccount
                    = _accountManager->accountForPath(QString("/org/freedesktop/Telepathy/Account/%1").arg(uid));

            if (!tpAccount) {
                qWarning() << "ToggleAvailability::toggle could not find Telepathy account for" << uid;
                continue;
            }
コード例 #5
0
AppletAvialabilityWidget::AppletAvialabilityWidget(QGraphicsItem *parent, Tp::AccountPtr account):
    MWidget(parent),
    m_account(account)
{
    setMaximumSize(64,64);
    setMinimumSize(64,64);

    MFeedback* feedback1 = new MFeedback("priority2_static_press", this);
    connect(this, SIGNAL(pressed()), feedback1, SLOT(play()));
    MFeedback* feedback2 = new MFeedback("priority2_static_release", this);
    connect(this, SIGNAL(released()), feedback2, SLOT(play()));
    MFeedback* feedback3 = new MFeedback("priority2_grab", this);
    connect(this, SIGNAL(longpressed()), feedback3, SLOT(play()));

    m_iconService = new MImageWidget("icon-m-common-presence-unknown", this);
    m_iconService->setAspectRatioMode(Qt::KeepAspectRatio);
    m_iconService->setMaximumSize(64,64);
    m_iconService->setMinimumSize(64,64);
    m_iconService->setPos(0,0);

    m_iconPresence = new MImageWidget("icon-m-common-presence-unknown", this);
    m_iconPresence->setAspectRatioMode(Qt::KeepAspectRatio);
    m_iconPresence->setMaximumSize(24,24);
    m_iconPresence->setPos(40, 0);
    currentIconId = presenceToIconId(m_account->currentPresence());
    requestedIconId = presenceToIconId(m_account->requestedPresence());

    if (m_account->currentPresence().type() == Tp::ConnectionPresenceTypeOffline)
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeAvailable, "", "");
    else
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeOffline, "", "");

    m_iconPresence->setImage(currentIconId);

    isFakePresence = false;

    m_account->setConnectsAutomatically(false);

    QString serviceName = m_account->serviceName();
    Accounts::Manager *manager = new Accounts::Manager();
    Accounts::Service *service = manager->service(serviceName);
    QString serviceIconId = service->iconName();

    m_iconService->setImage(serviceIconId);

    connect(m_account.data(),
            SIGNAL(changingPresence(bool)),
            SLOT(onChangingPresence(bool)));

    connect(m_account.data(),
            SIGNAL(currentPresenceChanged(Tp::Presence)),
            SLOT(onCurrentPresenceChanged(Tp::Presence)));

    connect(m_account.data(),
            SIGNAL(requestedPresenceChanged(Tp::Presence)),
            SLOT(onRequestedPresenceChanged(Tp::Presence)));

    connect(m_account.data(),
            SIGNAL(removed()),
            SLOT(onRemoved()));

    connect(m_account.data(),
            SIGNAL(stateChanged(bool)),
            SLOT(onStateChanged(bool)));

    presenceFaker = new QTimer(this);
    connect(presenceFaker, SIGNAL(timeout()), this, SLOT(fakerupdate()));

    grabGesture(Qt::TapAndHoldGesture);

//    pressTime = new QTimer(this);
//    pressTime->setSingleShot(true);
//    pressTime->setInterval(800);
//    connect(pressTime, SIGNAL(timeout()), this, SLOT(openPresence()));
}
コード例 #6
0
void AccountInterfacePrivate::asyncQueryInfo()
{
    if (!account) {
        qWarning() << "AccountInterface: no account set!  Maybe you forgot to call componentComplete()?";
        setStatus(AccountInterface::Invalid);
        return;
    }

    // note that the account doesn't have a queryInfo() like Identity
    // so we just read the values directly.

    int newIdentifier = account->id();
    if (identifier != newIdentifier) {
        identifier = account->id();
        emit q->identifierChanged();
    }

    if (providerName != account->providerName()) {
        providerName = account->providerName();
        emit q->providerNameChanged();
    }

    // supported service names
    Accounts::ServiceList supportedServices = account->services();
    for (int i = 0; i < supportedServices.size(); ++i) {
        Accounts::Service currService = supportedServices.at(i);
        QString serviceName = currService.name();
        supportedServiceNames.append(serviceName);
    }
    emit q->supportedServiceNamesChanged();

    // identity identifiers
    if (identityIdentifiersPendingInit) {
        pendingInitModifications = true;
        identityIdentifiersPendingInit = false; // explicitly update this on sync if it changes
    } else {
        // enumerate the supported services and the associated credentials
        QVariantMap allCredentials;
        Accounts::ServiceList supportedServices = account->services();
        for (int i = 0; i < supportedServices.size(); ++i) {
            Accounts::Service currService = supportedServices.at(i);
            QString serviceName = currService.name();
            account->selectService(currService);
            int currCredId = account->credentialsId();
            allCredentials.insert(serviceName, currCredId);
            account->selectService(Accounts::Service());
        }
        int currCredId = account->credentialsId();
        allCredentials.insert(QString(), currCredId); // and the global credential id.
        if (identityIdentifiers != allCredentials) {
            identityIdentifiers = allCredentials;
            emit q->identityIdentifiersChanged();
        }
    }

    // enabled
    if (enabledPendingInit) {
        pendingInitModifications = true;
    } else if (enabled != account->enabled()) {
        enabled = account->enabled();
        emit q->enabledChanged();
    }

    // display name
    if (displayNamePendingInit) {
        pendingInitModifications = true;
    } else if (displayName != account->displayName()) {
        displayName = account->displayName();
        emit q->displayNameChanged();
    }

    // configuration values
    if (configurationValuesPendingInit) {
        pendingInitModifications = true;
    } else {
        // enumerate the global configuration values
        QVariantMap allValues;
        QStringList allKeys = account->allKeys();
        foreach (const QString &key, allKeys)
            allValues.insert(key, account->value(key, QVariant(), 0));

        // also enumerate configuration values for all supported services.
        for (int i = 0; i < supportedServices.size(); ++i) {
            Accounts::Service currService = supportedServices.at(i);
            account->selectService(currService);
            QVariantMap serviceValues;
            QStringList serviceKeys = account->allKeys();
            foreach (const QString &key, serviceKeys)
                serviceValues.insert(key, account->value(key, QVariant(), 0));
            QVariantMap existingServiceValues = serviceConfigurationValues.value(currService.name());
            if (serviceValues != existingServiceValues)
                serviceConfigurationValues.insert(currService.name(), serviceValues);
            account->selectService(Accounts::Service());
        }

        // emit change signal for global configuration values only.
        if (configurationValues != allValues) {
            configurationValues = allValues;
            emit q->configurationValuesChanged();
        }
    }

    // enabled services
    if (enabledServiceNamesPendingInit) {
        QStringList tmpList = enabledServiceNames;
        enabledServiceNames.clear(); // clear them all.  this is because of the sync() semantics of service names.
        foreach (const QString &sn, tmpList) {
            if (supportedServiceNames.contains(sn))
                q->enableWithService(sn);
        }
    } else {