コード例 #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;
}
/*!
 * \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;
}
コード例 #3
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;
}
コード例 #4
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 {