summaryrefslogtreecommitdiff
path: root/resourceqt-client
diff options
context:
space:
mode:
authorWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-09-09 16:41:28 +0300
committerWolf Bergenheim <ext-wolf.2.bergenheim@nokia.com>2010-09-09 16:41:28 +0300
commitba2428504b6b20b2f1bd62383d1e88ff6ace10a7 (patch)
tree109e7d7195015cb864417838205863da7fd10772 /resourceqt-client
parentbf87507d83a8911d10fcefcf57d6c8d2f1d9dfae (diff)
downloadlibresourceqt-ba2428504b6b20b2f1bd62383d1e88ff6ace10a7.tar.gz
astyle
Diffstat (limited to 'resourceqt-client')
-rw-r--r--resourceqt-client/client.cpp128
-rw-r--r--resourceqt-client/client.h34
-rw-r--r--resourceqt-client/commandlineparser.cpp39
-rw-r--r--resourceqt-client/commandlineparser.h2
-rw-r--r--resourceqt-client/time-stat.c2
-rw-r--r--resourceqt-client/time-stat.h4
6 files changed, 102 insertions, 107 deletions
diff --git a/resourceqt-client/client.cpp b/resourceqt-client/client.cpp
index 7f999b2..b46f6f3 100644
--- a/resourceqt-client/client.cpp
+++ b/resourceqt-client/client.cpp
@@ -13,13 +13,13 @@ using namespace ResourcePolicy;
QMap<QString, CommandListArgs> Client::commandList;
CommandListArgs::CommandListArgs()
- :args(), help()
+ : args(), help()
{
}
CommandListArgs::CommandListArgs(const QString &arguments, const QString &helpText)
- :args(arguments), help(helpText)
+ : args(arguments), help(helpText)
{
}
@@ -28,8 +28,8 @@ CommandListArgs::~CommandListArgs()
}
Client::Client()
- : QObject(), standardInput(stdin, QIODevice::ReadOnly), stdInNotifier(0, QSocketNotifier::Read), applicationClass(),
- resourceSet(NULL), output(stdout)
+ : QObject(), standardInput(stdin, QIODevice::ReadOnly), stdInNotifier(0, QSocketNotifier::Read), applicationClass(),
+ resourceSet(NULL), output(stdout)
{
mainTimerID = startTimer(0);
commandList["help"] = CommandListArgs("", "print this help message");
@@ -38,10 +38,10 @@ Client::Client()
commandList["acquire"] = CommandListArgs("", "acquire required resources");
commandList["release"] = CommandListArgs("", "release resources");
commandList["update"] = CommandListArgs("", "update modified resource set after add or remove command");
- commandList["add"] = CommandListArgs("reslist [-o]","add reosurce list, if -o provided, set as optional");
- commandList["remove"] = CommandListArgs("reslist [-o]","remove reosurce list, if -o provided, removed only optional flag");
- commandList["audio"] = CommandListArgs("pid <pid> | group <audio group> | tag <name> <value>","set audio properties");
- commandList["addaudio"] = CommandListArgs("<audio group> <pid> <tag name> <tag value>","Add an audio resource and set the porpoerties");
+ commandList["add"] = CommandListArgs("reslist [-o]", "add reosurce list, if -o provided, set as optional");
+ commandList["remove"] = CommandListArgs("reslist [-o]", "remove reosurce list, if -o provided, removed only optional flag");
+ commandList["audio"] = CommandListArgs("pid <pid> | group <audio group> | tag <name> <value>", "set audio properties");
+ commandList["addaudio"] = CommandListArgs("<audio group> <pid> <tag name> <tag value>", "Add an audio resource and set the porpoerties");
commandList["show"] = CommandListArgs("", "show resources");
}
@@ -60,8 +60,8 @@ void Client::showPrompt()
bool Client::initialize(const CommandLineParser &parser)
{
- QSet<ResourcePolicy::ResourceType> allResources;
- QSet<ResourcePolicy::ResourceType> optionalResources;
+ QSet<ResourcePolicy::ResourceType> allResources;
+ QSet<ResourcePolicy::ResourceType> optionalResources;
if (parser.shouldAlwaysReply()) {
output << "client: AlwaysReply" << endl;
@@ -80,7 +80,7 @@ bool Client::initialize(const CommandLineParser &parser)
allResources.unite(parser.resources());
optionalResources.unite(parser.optionalResources());
- foreach (ResourcePolicy::ResourceType resource, allResources) {
+ foreach(ResourcePolicy::ResourceType resource, allResources) {
resourceSet->addResource(resource);
if (optionalResources.contains(resource)) {
resourceSet->resource(resource)->setOptional();
@@ -88,8 +88,7 @@ bool Client::initialize(const CommandLineParser &parser)
}
if (!connect(resourceSet, SIGNAL(resourcesGranted(QList<ResourcePolicy::ResourceType>)),
- this, SLOT(resourceAcquiredHandler(QList<ResourcePolicy::ResourceType>))))
- {
+ this, SLOT(resourceAcquiredHandler(QList<ResourcePolicy::ResourceType>)))) {
return false;
}
@@ -104,16 +103,14 @@ bool Client::initialize(const CommandLineParser &parser)
return false;
}
if (!connect(resourceSet, SIGNAL(resourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &)),
- this, SLOT(resourcesBecameAvailableHandler(const QList<ResourcePolicy::ResourceType> &))))
- {
+ this, SLOT(resourcesBecameAvailableHandler(const QList<ResourcePolicy::ResourceType> &)))) {
return false;
}
if (!connect(&stdInNotifier, SIGNAL(activated(int)), this, SLOT(readLine(int)))) {
return false;
}
if (!connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
- this, SLOT(doExit())))
- {
+ this, SLOT(doExit()))) {
return false;
}
@@ -122,7 +119,7 @@ bool Client::initialize(const CommandLineParser &parser)
return true;
}
-void Client::doExit ()
+void Client::doExit()
{
if (resourceSet != NULL)
resourceSet->release();
@@ -131,41 +128,41 @@ void Client::doExit ()
const char * resourceTypeToString(ResourceType type)
{
switch (type) {
- case AudioPlaybackType:
- return "AudioPlayback";
- case AudioRecorderType:
- return "AudioRecording";
- case VideoPlaybackType:
- return "VideoPlayback";
- case VideoRecorderType:
- return "VideoRegording";
- case VibraType:
- return "Vibra";
- case LedsType:
- return "Leds";
- case BacklightType:
- return "Backlight";
- case SystemButtonType:
- return "SystemButton";
- case LockButtonType:
- return "LockButton";
- case ScaleButtonType:
- return "ScaleButton";
- case SnapButtonType:
- return "SnapButton";
- case LensCoverType:
- return "LensCover";
- case HeadsetButtonsType:
- return "HeadsetButtons";
- default:
- return "Unknown/Invalid Resource";
+ case AudioPlaybackType:
+ return "AudioPlayback";
+ case AudioRecorderType:
+ return "AudioRecording";
+ case VideoPlaybackType:
+ return "VideoPlayback";
+ case VideoRecorderType:
+ return "VideoRegording";
+ case VibraType:
+ return "Vibra";
+ case LedsType:
+ return "Leds";
+ case BacklightType:
+ return "Backlight";
+ case SystemButtonType:
+ return "SystemButton";
+ case LockButtonType:
+ return "LockButton";
+ case ScaleButtonType:
+ return "ScaleButton";
+ case SnapButtonType:
+ return "SnapButton";
+ case LensCoverType:
+ return "LensCover";
+ case HeadsetButtonsType:
+ return "HeadsetButtons";
+ default:
+ return "Unknown/Invalid Resource";
}
}
void Client::showResources(const QList<ResourceType> &resList)
{
output << "Resource Set:\n";
- foreach (ResourceType resource, resList) {
+ foreach(ResourceType resource, resList) {
output << "\t" << resourceTypeToString(resource) << endl;
}
}
@@ -173,7 +170,7 @@ void Client::showResources(const QList<ResourceType> &resList)
void Client::showResources(const QList<Resource*> &resList)
{
output << "Resource Set:\n";
- foreach (Resource* resource, resList) {
+ foreach(Resource* resource, resList) {
output << "\t" << resourceTypeToString(resource->type());
if (resource->isOptional())
output << " (optional)";
@@ -186,7 +183,7 @@ void Client::showResources(const QList<Resource*> &resList)
void Client::resourceAcquiredHandler(const QList<ResourceType>& /*grantedResList*/)
{
long int ms = stop_timer();
- if( ms > 0 ) {
+ if (ms > 0) {
output << "Operation took " << ms << "ms";
}
@@ -204,7 +201,7 @@ void Client::resourceAcquiredHandler(const QList<ResourceType>& /*grantedResList
void Client::resourceDeniedHandler()
{
long int ms = stop_timer();
- if( ms > 0 ) {
+ if (ms > 0) {
output << "Operation took " << ms << "ms";
}
@@ -215,7 +212,7 @@ void Client::resourceDeniedHandler()
void Client::resourceLostHandler()
{
long int ms = stop_timer();
- if( ms > 0 ) {
+ if (ms > 0) {
output << "Operation took " << ms << "ms";
}
@@ -226,7 +223,7 @@ void Client::resourceLostHandler()
void Client::resourceReleasedHandler()
{
long int ms = stop_timer();
- if( ms > 0 ) {
+ if (ms > 0) {
output << "Operation took " << ms << "ms";
}
@@ -265,10 +262,10 @@ void Client::readLine(int)
QMap<QString, CommandListArgs>::const_iterator i =
commandList.constBegin();
while (i != commandList.constEnd()) {
- output << qSetFieldWidth (10) << right << i.key()
- << qSetFieldWidth (1) << " "
- << qSetFieldWidth (55) << left << i.value().args
- << qSetFieldWidth (0) << i.value().help << endl;
+ output << qSetFieldWidth(10) << right << i.key()
+ << qSetFieldWidth(1) << " "
+ << qSetFieldWidth(55) << left << i.value().args
+ << qSetFieldWidth(0) << i.value().help << endl;
++i;
}
}
@@ -280,7 +277,7 @@ void Client::readLine(int)
QList<Resource*> list = resourceSet->resources();
if (!list.count()) {
output << "Resource set is empty, use add command to add some."
- << endl;
+ << endl;
}
else {
showResources(list);
@@ -311,13 +308,13 @@ void Client::readLine(int)
output << "List of desired resources is missing. Use help.";
}
else {
- bool optional=false;
+ bool optional = false;
QSet<ResourcePolicy::ResourceType> resToAdd;
CommandLineParser::parseResourceList(resourceList, resToAdd);
if (flag == "-o") {
optional = true;
}
- foreach (ResourcePolicy::ResourceType resource, resToAdd) {
+ foreach(ResourcePolicy::ResourceType resource, resToAdd) {
if (!resourceSet->contains(resource)) {
resourceSet->addResource(resource);
}
@@ -340,12 +337,12 @@ void Client::readLine(int)
QSet<ResourcePolicy::ResourceType> resToRemove;
CommandLineParser::parseResourceList(resourceList, resToRemove);
if (flag == "-o") {
- foreach (ResourcePolicy::ResourceType resource, resToRemove) {
+ foreach(ResourcePolicy::ResourceType resource, resToRemove) {
resourceSet->resource(resource)->setOptional(false);
}
}
else {
- foreach (ResourcePolicy::ResourceType resource, resToRemove) {
+ foreach(ResourcePolicy::ResourceType resource, resToRemove) {
resourceSet->deleteResource(resource);
}
}
@@ -358,7 +355,7 @@ void Client::readLine(int)
}
else if (command == "audio") {
QString what, group, tagName, tagValue;
- quint32 pid=0;
+ quint32 pid = 0;
input >> what;
if (what.isEmpty() || what.isNull()) {
@@ -389,10 +386,9 @@ void Client::readLine(int)
else if (what == "tag") {
input >> tagName >> tagValue;
if (tagName.isEmpty() || tagName.isNull() ||
- tagValue.isEmpty() || tagValue.isNull())
- {
+ tagValue.isEmpty() || tagValue.isNull()) {
output << "tag requires 2 parameters name and value. See help"
- << endl;
+ << endl;
}
else {
audioResource->setStreamTag(tagValue, tagName);
@@ -406,7 +402,7 @@ void Client::readLine(int)
}
else if (command == "addaudio") {
QString group, tagName, tagValue;
- quint32 pid=0;
+ quint32 pid = 0;
input >> group >> pid >> tagName >> tagValue;
if (group.isEmpty() || (pid == 0) || tagName.isEmpty() || tagValue.isEmpty()) {
diff --git a/resourceqt-client/client.h b/resourceqt-client/client.h
index 1531db7..1a04961 100644
--- a/resourceqt-client/client.h
+++ b/resourceqt-client/client.h
@@ -24,21 +24,21 @@ public:
class Client : public QObject
{
- Q_OBJECT
+ Q_OBJECT
public:
- Client();
- ~Client();
+ Client();
+ ~Client();
- bool initialize(const CommandLineParser &commandParser);
- static uint32_t parseResourceList(QString resourceListStr);
+ bool initialize(const CommandLineParser &commandParser);
+ static uint32_t parseResourceList(QString resourceListStr);
private slots:
- void resourceAcquiredHandler(const QList<ResourcePolicy::ResourceType>& grantedResList);
- void resourceDeniedHandler();
- void resourceLostHandler();
- void resourceReleasedHandler();
- void resourcesBecameAvailableHandler(const QList<ResourcePolicy::ResourceType> &availableResources);
+ void resourceAcquiredHandler(const QList<ResourcePolicy::ResourceType>& grantedResList);
+ void resourceDeniedHandler();
+ void resourceLostHandler();
+ void resourceReleasedHandler();
+ void resourcesBecameAvailableHandler(const QList<ResourcePolicy::ResourceType> &availableResources);
void readLine(int);
void doExit();
@@ -46,18 +46,18 @@ private:
QTextStream standardInput;
QSocketNotifier stdInNotifier;
int mainTimerID;
- QString applicationClass;
- ResourcePolicy::ResourceSet *resourceSet;
+ QString applicationClass;
+ ResourcePolicy::ResourceSet *resourceSet;
QTextStream output;
static QMap<QString, CommandListArgs> commandList;
- ResourcePolicy::Resource* allocateResource(ResourcePolicy::ResourceType resource, bool optional);
- ResourcePolicy::ResourceType getResourceType(uint32_t resource);
+ ResourcePolicy::Resource* allocateResource(ResourcePolicy::ResourceType resource, bool optional);
+ ResourcePolicy::ResourceType getResourceType(uint32_t resource);
- void showPrompt();
- void showResources(const QList<ResourcePolicy::ResourceType> &resList);
- void showResources(const QList<ResourcePolicy::Resource*> &resList);
+ void showPrompt();
+ void showResources(const QList<ResourcePolicy::ResourceType> &resList);
+ void showResources(const QList<ResourcePolicy::Resource*> &resList);
};
#endif
diff --git a/resourceqt-client/commandlineparser.cpp b/resourceqt-client/commandlineparser.cpp
index 979399e..732d361 100644
--- a/resourceqt-client/commandlineparser.cpp
+++ b/resourceqt-client/commandlineparser.cpp
@@ -4,8 +4,8 @@
QHash<QString, ResourcePolicy::ResourceType> CommandLineParser::resourceValues;
CommandLineParser::CommandLineParser():
- allResources(), optResources(), autoRelease(false), alwaysReply(false),
- verbose(false), allowUnkownResourceClass(false), output(stdout)
+ allResources(), optResources(), autoRelease(false), alwaysReply(false),
+ verbose(false), allowUnkownResourceClass(false), output(stdout)
{
resourceValues["AudioPlayback"] = ResourcePolicy::AudioPlaybackType;
resourceValues["VideoPlayback"] = ResourcePolicy::VideoPlaybackType;
@@ -94,17 +94,16 @@ bool CommandLineParser::parseArguments()
bool CommandLineParser::parseClassString(const QString &str)
{
if (!allowUnkownResourceClass &&
- (str != "call") &&
- (str != "camera") &&
- (str != "ringtone") &&
- (str != "alarm") &&
- (str != "navigator") &&
- (str != "game") &&
- (str != "player") &&
- (str != "event") &&
- (str != "background") &&
- (str != "videoeditor") )
- {
+ (str != "call") &&
+ (str != "camera") &&
+ (str != "ringtone") &&
+ (str != "alarm") &&
+ (str != "navigator") &&
+ (str != "game") &&
+ (str != "player") &&
+ (str != "event") &&
+ (str != "background") &&
+ (str != "videoeditor")) {
output << "invalid class " << str;
return false;
}
@@ -114,7 +113,7 @@ bool CommandLineParser::parseClassString(const QString &str)
}
bool CommandLineParser::parseResourceList(const QString &resourceListStr,
- QSet<ResourcePolicy::ResourceType> &resources)
+ QSet<ResourcePolicy::ResourceType> &resources)
{
if (resourceListStr.isEmpty() || resourceListStr.isNull()) {
return false;
@@ -128,7 +127,7 @@ bool CommandLineParser::parseResourceList(const QString &resourceListStr,
}
}
}
-
+
return true;
}
@@ -137,7 +136,7 @@ bool CommandLineParser::parseModeValues(const QString &modeListStr)
if (modeListStr.isEmpty() || modeListStr.isNull()) {
return false;
}
-
+
QStringList modeList = modeListStr.split(",", QString::SkipEmptyParts);
foreach(QString mode, modeList) {
@@ -157,14 +156,14 @@ bool CommandLineParser::parseModeValues(const QString &modeListStr)
void CommandLineParser::usage()
{
output << "usage: resourceqt-client [-h] [-m mode-values]" <<
- "[-o optional-resources] [-s shared-resources -m shared-mask] " <<
- "class all-resources" << endl;
+ "[-o optional-resources] [-s shared-resources -m shared-mask] " <<
+ "class all-resources" << endl;
output << "\toptions:" << endl;
output << "\t h\tprint this help message and exit" << endl;
output << "\t f\tmode values. See 'modes' below for the "
- "\n\t\tsyntax of <mode-values>" << endl;
+ "\n\t\tsyntax of <mode-values>" << endl;
output << "\t o\toptional resources. See 'resources' below for the "
- "syntax of\n\t\t<optional-resources>" << endl;
+ "syntax of\n\t\t<optional-resources>" << endl;
output << "\tclass:" << endl;
output << "\t\tcall\t - for native or 3rd party telephony" << endl;
output << "\t\tcamera\t - for photo applications" << endl;
diff --git a/resourceqt-client/commandlineparser.h b/resourceqt-client/commandlineparser.h
index c799f9b..420c633 100644
--- a/resourceqt-client/commandlineparser.h
+++ b/resourceqt-client/commandlineparser.h
@@ -17,7 +17,7 @@ public:
bool parseArguments();
static bool parseResourceList(const QString &resourceListStr,
- QSet<ResourcePolicy::ResourceType> &resourceList);
+ QSet<ResourcePolicy::ResourceType> &resourceList);
const QSet<ResourcePolicy::ResourceType>& resources() const;
const QSet<ResourcePolicy::ResourceType>& optionalResources() const;
diff --git a/resourceqt-client/time-stat.c b/resourceqt-client/time-stat.c
index c18daa5..fd79916 100644
--- a/resourceqt-client/time-stat.c
+++ b/resourceqt-client/time-stat.c
@@ -24,7 +24,7 @@ long int stop_timer(void)
if (r == 0) {
milliseconds = 1000.0 * (end_time.tv_sec - start_time.tv_sec) +
- (end_time.tv_nsec - start_time.tv_nsec) / 1000000.0;
+ (end_time.tv_nsec - start_time.tv_nsec) / 1000000.0;
}
start_time.tv_sec = 0;
start_time.tv_nsec = 0;
diff --git a/resourceqt-client/time-stat.h b/resourceqt-client/time-stat.h
index e32a4cb..5fbe582 100644
--- a/resourceqt-client/time-stat.h
+++ b/resourceqt-client/time-stat.h
@@ -5,9 +5,9 @@
#ifdef __cplusplus
extern "C" {
#endif
-int start_timer(void);
+ int start_timer(void);
-long int stop_timer(void);
+ long int stop_timer(void);
#ifdef __cplusplus
}
#endif