Commit b2dca5a2 authored by Aard's avatar Aard

[ssucli] Add option to set username for home during registration

parent 58366a19
...@@ -181,7 +181,7 @@ void RndSsuCli::optModifyRepo(int action, QStringList opt){ ...@@ -181,7 +181,7 @@ void RndSsuCli::optModifyRepo(int action, QStringList opt){
} }
} }
void RndSsuCli::optRegister(){ void RndSsuCli::optRegister(QStringList opt){
/* /*
* register a new device * register a new device
*/ */
...@@ -189,6 +189,7 @@ void RndSsuCli::optRegister(){ ...@@ -189,6 +189,7 @@ void RndSsuCli::optRegister(){
QString username, password; QString username, password;
QTextStream qin(stdin); QTextStream qin(stdin);
QTextStream qout(stdout); QTextStream qout(stdout);
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
struct termios termNew, termOld; struct termios termNew, termOld;
...@@ -206,6 +207,9 @@ void RndSsuCli::optRegister(){ ...@@ -206,6 +207,9 @@ void RndSsuCli::optRegister(){
tcsetattr(STDIN_FILENO, TCSANOW, &termOld); tcsetattr(STDIN_FILENO, TCSANOW, &termOld);
if (opt.count() == 3 && opt.at(2) == "-h")
ssuSettings->setValue("repository-url-variables/user", username);
ssu.sendRegistration(username, password); ssu.sendRegistration(username, password);
state = Busy; state = Busy;
} }
...@@ -456,9 +460,7 @@ void RndSsuCli::run(){ ...@@ -456,9 +460,7 @@ void RndSsuCli::run(){
// everything without additional arguments gets handled here // everything without additional arguments gets handled here
// functions with arguments need to take care of argument validation themselves // functions with arguments need to take care of argument validation themselves
if (arguments.count() == 2){ if (arguments.count() == 2){
if (arguments.at(1) == "register" || arguments.at(1) == "r") if (arguments.at(1) == "status" || arguments.at(1) == "s")
optRegister();
else if (arguments.at(1) == "status" || arguments.at(1) == "s")
optStatus(); optStatus();
else if (arguments.at(1) == "updaterepos" || arguments.at(1) == "ur") else if (arguments.at(1) == "updaterepos" || arguments.at(1) == "ur")
optUpdateRepos(); optUpdateRepos();
...@@ -480,7 +482,9 @@ void RndSsuCli::run(){ ...@@ -480,7 +482,9 @@ void RndSsuCli::run(){
// functions accepting 0 or more arguments; those need to set state to Idle // functions accepting 0 or more arguments; those need to set state to Idle
// on success // on success
if (arguments.at(1) == "repos" || arguments.at(1) == "lr") if (arguments.at(1) == "register" || arguments.at(1) == "r")
optRegister(arguments);
else if (arguments.at(1) == "repos" || arguments.at(1) == "lr")
optRepos(arguments); optRepos(arguments);
else if (arguments.at(1) == "flavour" || arguments.at(1) == "fl") else if (arguments.at(1) == "flavour" || arguments.at(1) == "fl")
optFlavour(arguments); optFlavour(arguments);
...@@ -539,6 +543,7 @@ void RndSsuCli::usage(){ ...@@ -539,6 +543,7 @@ void RndSsuCli::usage(){
<< "Device management:" << endl << "Device management:" << endl
<< "\tstatus, s \tprint registration status and device information" << endl << "\tstatus, s \tprint registration status and device information" << endl
<< "\tregister, r \tregister this device" << endl << "\tregister, r \tregister this device" << endl
<< "\t [-h] \tconfigure user for OBS home" << endl
<< "\tupdate, up \tupdate repository credentials" << endl << "\tupdate, up \tupdate repository credentials" << endl
<< "\t [-f] \tforce update" << endl << "\t [-f] \tforce update" << endl
<< "\tmodel, mo \tprint name of device model (like N9)" << endl << "\tmodel, mo \tprint name of device model (like N9)" << endl
......
...@@ -35,7 +35,7 @@ class RndSsuCli: public QObject { ...@@ -35,7 +35,7 @@ class RndSsuCli: public QObject {
void optMode(QStringList opt); void optMode(QStringList opt);
void optModel(QStringList opt); void optModel(QStringList opt);
void optModifyRepo(int action, QStringList opt); void optModifyRepo(int action, QStringList opt);
void optRegister(); void optRegister(QStringList opt);
void optRelease(QStringList opt); void optRelease(QStringList opt);
void optRepos(QStringList opt); void optRepos(QStringList opt);
void optStatus(); void optStatus();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment