diff options
author | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-15 13:28:18 +0200 |
---|---|---|
committer | Martin Wolf <ext-martin.2.wolf@nokia.com> | 2010-02-15 13:28:18 +0200 |
commit | abb51ffa0565eb589dc74ca39a8396f865d8fbdc (patch) | |
tree | fe87952260b5b5a49cb7652400957975ad400d19 /resourceqt-client/resourceqt-client.cpp | |
parent | 75d34a403884640d9203c6eed3ed3b74964e94e8 (diff) |
Fixes to resourceqt-client example
Diffstat (limited to 'resourceqt-client/resourceqt-client.cpp')
-rw-r--r-- | resourceqt-client/resourceqt-client.cpp | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/resourceqt-client/resourceqt-client.cpp b/resourceqt-client/resourceqt-client.cpp index f17ebaf..89aef76 100644 --- a/resourceqt-client/resourceqt-client.cpp +++ b/resourceqt-client/resourceqt-client.cpp @@ -18,6 +18,8 @@ public: resourcesAll = 0; resourcesOptional = 0; + autoRelease = false; + alwaysReply = false; parseArguments(argc, argv); } @@ -38,6 +40,8 @@ public: uint32_t resourcesAll; uint32_t resourcesOptional; QString applicationClass; + bool autoRelease; + bool alwaysReply; void printMessage(const char *fmt, ...) { @@ -71,16 +75,15 @@ private: { int option; - while( (option = getopt(argc, argv, "hf:s:")) != -1 ) + while( (option = getopt(argc, argv, "hm:o:")) != -1 ) { switch (option) { case 'h': usage(0); return; - case 'f': - printf("-f - not implemented!\n"); - //config.mode = parseModeValues(optarg, 1); + case 'm': + parseModeValues(optarg); break; case 'o': resourcesOptional = Client::parseResourceList(optarg); @@ -135,15 +138,40 @@ private: return str; } + void parseModeValues(QString modeListStr) + { + if( !modeListStr.isEmpty() && !modeListStr.isNull() ) + { + QStringList modeList = modeListStr.split(",", QString::SkipEmptyParts); + + for( int i = 0; i < modeList.count(); i++ ) + { + if( modeList[i] == "AutoRelease" ) + { + autoRelease = true; + } + else if( modeList[i] == "AlwaysReply" ) + { + alwaysReply = true; + } + else + { + const char* mode = qPrintable(modeList[i]); + printMessage("Ignoring unknown mode '%s'!", mode); + } + } + } + } + void usage(int theExitCode) { - printf("usage: %s [-h] [-t] [-v] [-f mode-values]" + printf("usage: %s [-h] [-t] [-v] [-m mode-values]" "[-o optional-resources] [-s shared-resources -m shared-mask] " "class all-resources\n", exeName); printf("\toptions:\n"); printf("\t h\tprint this help message and exit\n"); - printf("\t f\tmode values. See 'modes' below for the " + printf("\t m\tmode values. See 'modes' below for the " "\n\t\tsyntax of <mode-values>\n"); printf("\t o\toptional resources. See 'resources' below for the " "syntax of\n\t\t<optional-resources>\n"); @@ -193,7 +221,7 @@ int main(int argc, char *argv[]) QCoreApplication app(argc, argv); Client client(parser.applicationClass); - if( !client.initialize(parser.resourcesAll, parser.resourcesOptional) ) + if( !client.initialize(parser.resourcesAll, parser.resourcesOptional, parser.alwaysReply, parser.autoRelease) ) { parser.printMessage("initialization failed!"); return EINVAL; |