Beispiel #1
0
// @todo the non-device specific repository resolving should move from deviceInfo to repomanager
QStringList SsuRepoManager::repos(bool rnd, SsuDeviceInfo &deviceInfo, int filter){
  QStringList result;

  // read the adaptation specific repositories, as well as the default
  // repositories; default repos are read through deviceInfo as an
  // adaptation is allowed to disable core repositories
  result = deviceInfo.repos(rnd, filter);

  // read the repositories of the available features. While devices have
  // a default list of features to be installed those are only relevant
  // for bootstrapping, so this code just operates on installed features
  SsuFeatureManager featureManager;
  result.append(featureManager.repos(rnd, filter));

  // read user-defined repositories from ssu.ini. This step needs to
  // happen at the end, after all other required repositories are
  // added already

  // TODO: in strict mode, filter the repository list from there
  SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();

  bool updateMode = false;
  bool appInstallMode = false;

  if ((ssuSettings->deviceMode() & Ssu::UpdateMode) == Ssu::UpdateMode)
    updateMode = true;

  if ((ssuSettings->deviceMode() & Ssu::AppInstallMode) == Ssu::AppInstallMode){
    updateMode = true;
    appInstallMode = true;
  }

  if (filter == Ssu::NoFilter ||
      filter == Ssu::UserFilter){
    // user defined repositories, or ones overriding URLs for default ones
    // -> in update mode we need to check for each of those if it already
    //    exists. If it exists, keep it, if it does not, disable it
    ssuSettings->beginGroup("repository-urls");
    QStringList repoUrls = ssuSettings->allKeys();
    ssuSettings->endGroup();

    if (updateMode){
      foreach(const QString &key, repoUrls){
        if (result.contains(key))
          result.append(key);
      }
    } else {
Beispiel #2
0
void Ssu::updateStoreCredentials(){
  QDBusMessage message = QDBusMessage::createMethodCall("com.jolla.jollastore",
                                                        "/StoreClient",
                                                        "com.jolla.jollastore",
                                                        "storeCredentials");
  QDBusPendingReply<QString, QString> reply = SsuCoreConfig::userSessionBus().asyncCall(message);
  reply.waitForFinished();
  if (reply.isError()) {
    setError(QString("Store credentials not received. %1").arg(reply.error().message()));
  } else {
    SsuCoreConfig *settings = SsuCoreConfig::instance();
    settings->beginGroup("credentials-store");
    settings->setValue("username", reply.argumentAt<0>());
    settings->setValue("password", reply.argumentAt<1>());
    settings->endGroup();
    settings->sync();
  }
}
Beispiel #3
0
Datei: ssu.cpp Projekt: lbt/ssu
bool Ssu::setCredentials(QDomDocument *response){
  SsuCoreConfig *settings = SsuCoreConfig::instance();
  // generate list with all scopes for generic section, add sections
  QDomNodeList credentialsList = response->elementsByTagName("credentials");
  QStringList credentialScopes;
  for (int i=0;i<credentialsList.size();i++){
    QDomNode node = credentialsList.at(i);
    QString scope;

    QDomNamedNodeMap attributes = node.attributes();
    if (attributes.contains("scope")){
      scope = attributes.namedItem("scope").toAttr().value();
    } else {
      setError(tr("Credentials element does not have scope"));
      return false;
    }

    if (node.hasChildNodes()){
      QDomElement username = node.firstChildElement("username");
      QDomElement password = node.firstChildElement("password");
      if (username.isNull() || password.isNull()){
        setError(tr("Username and/or password not set"));
        return false;
      } else {
        settings->beginGroup("credentials-" + scope);
        settings->setValue("username", username.text());
        settings->setValue("password", password.text());
        settings->endGroup();
        settings->sync();
        credentialScopes.append(scope);
      }
    } else {
      setError("");
      return false;
    }
  }
  settings->setValue("credentialScopes", credentialScopes);
  settings->setValue("lastCredentialsUpdate", QDateTime::currentDateTime());
  settings->sync();
  emit credentialsChanged();

  return true;
}