summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorEvan Nguyen <evan.nguyen@nokia.com>2010-08-26 15:40:32 +1000
committerEvan Nguyen <evan.nguyen@nokia.com>2010-08-26 15:40:32 +1000
commitab0bbcf9b944adc91f5c020cea7c2f7dbf7c7678 (patch)
tree1b19901c1c139b9400dc007c7c0d2b44f5245a21 /tools
parentbfb2b17da8934b387199c68229247cba153e256d (diff)
ServiceFW tool updated for IPC and Scope
Diffstat (limited to 'tools')
-rw-r--r--tools/servicefw/servicefw.cpp104
1 files changed, 79 insertions, 25 deletions
diff --git a/tools/servicefw/servicefw.cpp b/tools/servicefw/servicefw.cpp
index 89af0b10ae..e38e66763b 100644
--- a/tools/servicefw/servicefw.cpp
+++ b/tools/servicefw/servicefw.cpp
@@ -72,6 +72,7 @@ private:
bool setOptions(const QStringList &options);
void showAllEntries();
void showInterfaceInfo(const QServiceFilter &filter);
+ void showInterfaceInfo(QList<QServiceInterfaceDescriptor> descriptors);
void showServiceInfo(const QString &service);
QServiceManager *serviceManager;
@@ -129,6 +130,8 @@ void CommandProcessor::showUsage(QTextStream *stream)
"Options:\n"
"\t--system Use the system-wide services database instead of the\n"
"\t user-specific database\n"
+ "\t--user Use the user-specific services database for add/remove.\n"
+ "\t This is the default\n"
"\n";
}
@@ -229,15 +232,25 @@ bool CommandProcessor::setOptions(const QStringList &options)
if (serviceManager)
delete serviceManager;
+ bool systemScope = false;
+ bool userScope = false;
+
QStringList opts = options;
QMutableListIterator<QString> i(opts);
while (i.hasNext()) {
- if (i.next() == "--system") {
- serviceManager = new QServiceManager(QService::SystemScope, this);
+ QString option = i.next();
+ if (option == "--system") {
+ systemScope = true;
+ i.remove();
+ } else if (option == "--user") {
+ userScope = true;
i.remove();
}
}
+ if (!userScope && systemScope)
+ serviceManager = new QServiceManager(QService::SystemScope, this);
+
if (!opts.isEmpty()) {
*stdoutStream << "Bad options: " << opts.join(" ") << "\n\n";
showUsage();
@@ -292,29 +305,65 @@ void CommandProcessor::showServiceInfo(const QString &service)
*stdoutStream << "Service " << service << " not found.\n";
return;
}
+
+ QList<QServiceInterfaceDescriptor> pluginDesc;
+ QList<QServiceInterfaceDescriptor> ipcDesc;
+ foreach (const QServiceInterfaceDescriptor &desc, descriptors) {
+ int serviceType = desc.attribute(QServiceInterfaceDescriptor::ServiceType).toInt();
+ if (serviceType == QService::Plugin)
+ pluginDesc.append(desc);
+ else
+ ipcDesc.append(desc);
+ }
- QString description = descriptors[0].attribute(
- QServiceInterfaceDescriptor::ServiceDescription).toString();
- QStringList capabilities = descriptors[0].attribute(
- QServiceInterfaceDescriptor::Capabilities).toStringList();
-
- *stdoutStream << service << ":\n";
- if (!description.isEmpty())
- *stdoutStream << '\t' << description << '\n';
-
- int serviceType = descriptors[0].attribute(QServiceInterfaceDescriptor::ServiceType).toInt();
- if (serviceType == QService::Plugin)
+ if (pluginDesc.size() > 0) {
+ *stdoutStream << service;
+ if (ipcDesc.size() > 0)
+ *stdoutStream << " (Plugin):\n";
+ else
+ *stdoutStream << ":\n";
+
+ QString description = pluginDesc[0].attribute(
+ QServiceInterfaceDescriptor::ServiceDescription).toString();
+ if (!description.isEmpty())
+ *stdoutStream << '\t' << description << '\n';
+
*stdoutStream << "\tPlugin Library: ";
- else
+ showInterfaceInfo(pluginDesc);
+ }
+
+ if (ipcDesc.size() > 0) {
+ *stdoutStream << service;
+ if (pluginDesc.size() > 0)
+ *stdoutStream << " (IPC):\n";
+ else
+ *stdoutStream << ":\n";
+
+ QString description = ipcDesc[0].attribute(
+ QServiceInterfaceDescriptor::ServiceDescription).toString();
+ if (!description.isEmpty())
+ *stdoutStream << '\t' << description << '\n';
+
*stdoutStream << "\tIPC Address: ";
+ showInterfaceInfo(ipcDesc);
+ }
+}
- *stdoutStream << descriptors[0].attribute(QServiceInterfaceDescriptor::Location).toString() << '\n'
- << "\tCapabilities: " << (capabilities.isEmpty() ? "" : capabilities.join(", ")) << '\n'
- << "\tImplements:\n";
+void CommandProcessor::showInterfaceInfo(QList<QServiceInterfaceDescriptor> descriptors)
+{
+ QService::Scope scope = descriptors[0].scope();
+ *stdoutStream << descriptors[0].attribute(QServiceInterfaceDescriptor::Location).toString() << '\n'
+ << "\tScope: " << (scope == QService::SystemScope ? "All users" : "Current User") << '\n'
+ << "\tImplements:\n";
+
foreach (const QServiceInterfaceDescriptor &desc, descriptors) {
- *stdoutStream << "\t\t" << desc.interfaceName() << ' '
- << desc.majorVersion() << '.' << desc.minorVersion() << '\n';
+ QStringList capabilities = desc.attribute(
+ QServiceInterfaceDescriptor::Capabilities).toStringList();
+
+ *stdoutStream << "\t " << desc.interfaceName() << ' '
+ << desc.majorVersion() << '.' << desc.minorVersion()
+ << (capabilities.isEmpty() ? "" : "\t{" + capabilities.join(", ") + "}") << "\n";
}
}
@@ -323,16 +372,21 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
QStringList args = QCoreApplication::arguments();
- if (args.count() == 1 || args.value(1) == "--help" || args.value(1) == "-h") {
- QTextStream stream(stdout);
- CommandProcessor::showUsage(&stream);
- return 0;
- }
-
+ // check for at least one non-option argument
+ bool exec = false;
+
QStringList options;
for (int i=1; i<args.count(); i++) {
if (args[i].startsWith("--"))
options += args[i];
+ else
+ exec = true;
+ }
+
+ if (!exec || args.count() == 1 || args.value(1) == "--help" || args.value(1) == "-h") {
+ QTextStream stream(stdout);
+ CommandProcessor::showUsage(&stream);
+ return 0;
}
CommandProcessor processor;