Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add some device mode logic to ssu core
  • Loading branch information
Bernd Wachter committed Mar 28, 2013
1 parent b2478d5 commit 0a221d6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions libssu/ssu.cpp
Expand Up @@ -82,6 +82,14 @@ QString Ssu::flavour(){
return "release";
}

int Ssu::deviceMode(){
if (!settings->contains("deviceMode")){
settings->setValue("deviceMode", ReleaseMode);
return ReleaseMode;
} else
return settings->value("deviceMode").toInt();
}

QString Ssu::domain(){
if (settings->contains("domain"))
return settings->value("domain").toString();
Expand Down Expand Up @@ -468,6 +476,19 @@ bool Ssu::setCredentials(QDomDocument *response){
return true;
}

void Ssu::setDeviceMode(int mode, int editMode){
int oldMode = settings->value("deviceMode").toInt();

if ((editMode & Add) == Add){
oldMode |= mode;
} else if ((editMode & Remove) == Remove){
oldMode &= ~mode;
} else
oldMode = mode;

settings->setValue("deviceMode", oldMode);
}

void Ssu::setError(QString errorMessage){
errorFlag = true;
errorString = errorMessage;
Expand Down
20 changes: 20 additions & 0 deletions libssu/ssu.h
Expand Up @@ -54,6 +54,10 @@ class Ssu: public QObject {
* @return current flavour (usually something like testing, release, ..)
*/
Q_INVOKABLE QString flavour();
/**
* Get the current mode bits for the device
*/
Q_INVOKABLE int deviceMode();
/**
* Get the current domain used in registration
* @return domain, or "" if not set
Expand Down Expand Up @@ -87,6 +91,10 @@ class Ssu: public QObject {
QString repoUrl(QString repoName, bool rndRepo=false,
QHash<QString, QString> repoParameters=QHash<QString, QString>(),
QHash<QString, QString> parametersOverride=QHash<QString, QString>());
/**
* Set mode bits for the device
*/
Q_INVOKABLE void setDeviceMode(int mode, int editMode=Replace);
/**
* Set the flavour used when resolving RND repositories
*/
Expand All @@ -113,6 +121,18 @@ class Ssu: public QObject {
*/
Q_INVOKABLE bool useSslVerify();

enum DeviceMode {
RepoManager = 0x1,
RndMode = 0x2,
ReleaseMode = 0x4,
StrictMode = 0x8
};

enum EditMode {
Replace = 0x1,
Add = 0x2,
Remove = 0x4
};

// compat stuff, might go away when refactoring is finished
Q_INVOKABLE QString deviceFamily(){ return deviceInfo.deviceFamily(); };
Expand Down

0 comments on commit 0a221d6

Please sign in to comment.