Example #1
0
bool accountExists(){

    Accounts::Manager *manager;
    manager = new Accounts::Manager();
    Accounts::AccountIdList accl = manager->accountList();
    Accounts::Account *a;
    Accounts::ServiceList ss;
    for(int i =0; i<accl.length(); i++)
    {

        a = manager->account(accl[i]);
        ss = a->services();

        for (int j=0; j<ss.length(); j++){

            if(ss[j]->name()=="waxmpp"){

                if(a->valueAsString("imsi") == Utilities::getImsi()){
                    return true;
                }
            }
         }
     }
    return false;
}
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;
}
void ServiceModel::init(Accounts::ServiceList services)
{
    Q_D(ServiceModel);

    d->headerData.insert(ServiceHelperColumn, "serviceHelper");
    d->headerData.insert(ServiceNameColumn, "serviceName");
    d->headerData.insert(ColumnCount, "columncount");
    for (int i = 0; i < services.size(); i++)
    {
        QDomDocument domDocument = services[i].domDocument();
        d->serviceList << new ServiceHelper(services[i]);
    }
}
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;
}
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 {