diff options
Diffstat (limited to 'examples')
37 files changed, 1149 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro index 7dea2cf0..ecd3831b 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -22,3 +22,10 @@ SUBDIRS = \ trackergrid \ imtoolbar \ +# for HAVE_DBUS +include( ../mkspecs/common.pri ) + +contains(DEFINES, HAVE_DBUS) { + SUBDIRS += servicefw +} + diff --git a/examples/servicefw/bin/.gitignore b/examples/servicefw/bin/.gitignore new file mode 100644 index 00000000..cc47e5c0 --- /dev/null +++ b/examples/servicefw/bin/.gitignore @@ -0,0 +1,3 @@ +com.nokia.textprocessor +org.maemo.textprocessor +user diff --git a/examples/servicefw/include/textprocessorinterface.h b/examples/servicefw/include/textprocessorinterface.h new file mode 100644 index 00000000..f74c4dfa --- /dev/null +++ b/examples/servicefw/include/textprocessorinterface.h @@ -0,0 +1,20 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "../provider/serviceif/textprocessorinterface/textprocessorinterface.h" diff --git a/examples/servicefw/include/textprocessorinterfaceproxy.h b/examples/servicefw/include/textprocessorinterfaceproxy.h new file mode 100644 index 00000000..802afa21 --- /dev/null +++ b/examples/servicefw/include/textprocessorinterfaceproxy.h @@ -0,0 +1,20 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "../provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.h" diff --git a/examples/servicefw/misc/.gitignore b/examples/servicefw/misc/.gitignore new file mode 100644 index 00000000..9f25bd8e --- /dev/null +++ b/examples/servicefw/misc/.gitignore @@ -0,0 +1,3 @@ +.dummy +com.nokia.textprocessor.service +org.maemo.textprocessor.service diff --git a/examples/servicefw/misc/com.nokia.textprocessor.service.in b/examples/servicefw/misc/com.nokia.textprocessor.service.in new file mode 100644 index 00000000..144783e1 --- /dev/null +++ b/examples/servicefw/misc/com.nokia.textprocessor.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Interface=com.nokia.TextProcessorInterface +Name=com.nokia.TextProcessor +Exec=@DUI_INSTALL_BIN@/com.nokia.textprocessor diff --git a/examples/servicefw/misc/misc.pro b/examples/servicefw/misc/misc.pro new file mode 100644 index 00000000..f7d30972 --- /dev/null +++ b/examples/servicefw/misc/misc.pro @@ -0,0 +1,37 @@ +DESTDIR=. +TEMPLATE = subdirs +SUBDIRS = + +include( ../../../mkspecs/common.pri ) + +QMAKE_EXTRA_TARGETS += check +check.depends = $$TARGET +check.commands = $$system(true) + +QMAKE_EXTRA_TARGETS += check-xml +check-xml.depends = $$TARGET +check-xml.commands = $$system(true) + + +myname = com.nokia.textprocessor + +service1.CONFIG += no_check_exist +service1.target = $${myname}.service +service1.commands = cat $$IN_PWD/$${myname}.service.in \ + | sed -e "s:@DUI_INSTALL_BIN@:$${DUI_INSTALL_BIN}:g" \ + > $${myname}.service +service1.files = $$OUT_PWD/$${myname}.service +service1.path = $$DUI_DBUS_SERVICES_DIR + +myname = org.maemo.textprocessor + +service2.CONFIG += no_check_exist +service2.target = $${myname}.service +service2.commands = cat $$IN_PWD/$${myname}.service.in \ + | sed -e "s:@DUI_INSTALL_BIN@:$${DUI_INSTALL_BIN}:g" \ + > $${myname}.service +service2.files = $$OUT_PWD/$${myname}.service +service2.path = $$DUI_DBUS_SERVICES_DIR + + +INSTALLS += service1 service2 diff --git a/examples/servicefw/misc/org.maemo.textprocessor.service.in b/examples/servicefw/misc/org.maemo.textprocessor.service.in new file mode 100644 index 00000000..03a62c59 --- /dev/null +++ b/examples/servicefw/misc/org.maemo.textprocessor.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Interface=com.nokia.TextProcessorInterface +Name=org.maemo.TextProcessor +Exec=@DUI_INSTALL_BIN@/org.maemo.textprocessor diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.TextProcessorInterface.xml b/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.TextProcessorInterface.xml new file mode 120000 index 00000000..d0c7161c --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.TextProcessorInterface.xml @@ -0,0 +1 @@ +../../serviceif/textprocessorinterface/com.nokia.TextProcessorInterface.xml
\ No newline at end of file diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.textprocessor.pro b/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.textprocessor.pro new file mode 100644 index 00000000..e0b09a63 --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/com.nokia.textprocessor.pro @@ -0,0 +1,20 @@ +include( ../../../../../mkspecs/common.pri ) + +DESTDIR=../../../bin/ +TARGET=com.nokia.textprocessor +TEMPLATE=app +SOURCES += \ + main.cpp \ + textprocessor.cpp \ + textprocessorinterfaceadaptor.cpp \ + +HEADERS += \ + textprocessor.h \ + textprocessorinterfaceadaptor.h\ + +QT += dbus gui + +target.path = $$DUI_INSTALL_BIN + +INSTALLS += \ + target \ diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/main.cpp b/examples/servicefw/provider/impl/com.nokia.textprocessor/main.cpp new file mode 100644 index 00000000..3fa394f3 --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/main.cpp @@ -0,0 +1,46 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include <QApplication> +#include <QtDebug> + +#include "textprocessor.h" +#include "textprocessorinterfaceadaptor.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + // implements the text processor interface methods + TextProcessor service; + + // memory owned by QDBusAbstractAdaptor instance and must be on the heap + new TextProcessorInterfaceAdaptor(&service); + + QDBusConnection connection = QDBusConnection::sessionBus(); + bool ret = connection.registerService("com.nokia.TextProcessor"); + qDebug() << "textprocessor::main::registerService: com.nokia.TextProcessor: " << ret; + + ret = connection.registerObject("/", &service); + qDebug() << "textprocessor::main::registerObject: /: " << ret; + + int retVal = app.exec(); + + return retVal; +} diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.cpp b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.cpp new file mode 100644 index 00000000..2f3f005c --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "textprocessor.h" +#include <QtDebug> +#include <QString> + +TextProcessor::TextProcessor() + : QObject(0) +{ + qDebug() << "TextProcessor is created!"; +} + +TextProcessor::~TextProcessor() +{ +} + +QString TextProcessor::reverse(const QString &message) +{ + qDebug() << message << "reverse to:"; + + QString mirror; + for (int i = message.size() - 1; i >= 0; --i) { + mirror.append(message[i]); + } + + qDebug() << mirror; + return mirror; +} diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.h b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.h new file mode 100644 index 00000000..e7f530e5 --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessor.h @@ -0,0 +1,37 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef TEXTPROCESSOR_H +#define TEXTPROCESSOR_H + +#include <QObject> + +class QString; + +class TextProcessor : public QObject +{ + Q_OBJECT +public: + TextProcessor(); + virtual ~TextProcessor(); + +public Q_SLOTS: + QString reverse(const QString &message); +}; +#endif diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.cpp b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.cpp new file mode 100644 index 00000000..dc3253a1 --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.cpp @@ -0,0 +1,43 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceAdaptor -a textprocessorinterfaceadaptor com.nokia.TextProcessorInterface.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "textprocessorinterfaceadaptor.h" +#include <QtCore/QMetaObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> + +/* + * Implementation of adaptor class TextProcessorInterfaceAdaptor + */ + +TextProcessorInterfaceAdaptor::TextProcessorInterfaceAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +TextProcessorInterfaceAdaptor::~TextProcessorInterfaceAdaptor() +{ + // destructor +} + +QString TextProcessorInterfaceAdaptor::reverse(const QString &message) +{ + // handle method call com.nokia.TextProcessorInterface.reverse + QString out0; + QMetaObject::invokeMethod(parent(), "reverse", Q_RETURN_ARG(QString, out0), Q_ARG(QString, message)); + return out0; +} + diff --git a/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.h b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.h new file mode 100644 index 00000000..758ddaed --- /dev/null +++ b/examples/servicefw/provider/impl/com.nokia.textprocessor/textprocessorinterfaceadaptor.h @@ -0,0 +1,49 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceAdaptor -a textprocessorinterfaceadaptor com.nokia.TextProcessorInterface-29796.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef TEXTPROCESSORINTERFACEADAPTOR_H_1267694774 +#define TEXTPROCESSORINTERFACEADAPTOR_H_1267694774 + +#include <QtCore/QObject> +#include <QtDBus/QtDBus> +class QByteArray; +template<class T> class QList; +template<class Key, class Value> class QMap; +class QString; +class QStringList; +class QVariant; + +/* + * Adaptor class for interface com.nokia.TextProcessorInterface + */ +class TextProcessorInterfaceAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.nokia.TextProcessorInterface") + Q_CLASSINFO("D-Bus Introspection", "" +" <interface name=\"com.nokia.TextProcessorInterface\">\n" +" <method name=\"reverse\">\n" +" <arg direction=\"in\" type=\"s\" name=\"message\"/>\n" +" <arg direction=\"out\" type=\"s\" name=\"\"/>\n" +" </method>\n" +" </interface>\n" + "") +public: + TextProcessorInterfaceAdaptor(QObject *parent); + virtual ~TextProcessorInterfaceAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + QString reverse(const QString &message); +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/examples/servicefw/provider/impl/impl.pro b/examples/servicefw/provider/impl/impl.pro new file mode 100644 index 00000000..1c288cc9 --- /dev/null +++ b/examples/servicefw/provider/impl/impl.pro @@ -0,0 +1,5 @@ +SUBDIRS = \ + org.maemo.textprocessor \ + com.nokia.textprocessor \ + +TEMPLATE = subdirs diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/com.nokia.TextProcessorInterface.xml b/examples/servicefw/provider/impl/org.maemo.textprocessor/com.nokia.TextProcessorInterface.xml new file mode 120000 index 00000000..d0c7161c --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/com.nokia.TextProcessorInterface.xml @@ -0,0 +1 @@ +../../serviceif/textprocessorinterface/com.nokia.TextProcessorInterface.xml
\ No newline at end of file diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/main.cpp b/examples/servicefw/provider/impl/org.maemo.textprocessor/main.cpp new file mode 100644 index 00000000..65597e98 --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/main.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include <QApplication> +#include <QtDebug> + +#include "textprocessor.h" +#include "textprocessorinterfaceadaptor.h" + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + // implements the text processor interface methods + TextProcessor service; + + // memory owned by QDBusAbstractAdaptor instance and must be on the heap + new TextProcessorInterfaceAdaptor(&service); + + QDBusConnection connection = QDBusConnection::sessionBus(); + bool ret = connection.registerService("org.maemo.TextProcessor"); + qDebug() << "textprocessor::main::registerService: org.maemo.TextProcessor: " << ret; + ret = connection.registerObject("/", &service); + qDebug() << "textprocessor::main::registerObject: /: " << ret; + + int retVal = app.exec(); + + return retVal; +} diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/org.maemo.textprocessor.pro b/examples/servicefw/provider/impl/org.maemo.textprocessor/org.maemo.textprocessor.pro new file mode 100644 index 00000000..747a58a5 --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/org.maemo.textprocessor.pro @@ -0,0 +1,21 @@ +DUIROOT=../../../../.. +include($$DUIROOT/mkspecs/common.pri) + +DESTDIR=$$DUIROOT/bin/ +TARGET=org.maemo.textprocessor +TEMPLATE=app +SOURCES += \ + main.cpp \ + textprocessor.cpp \ + textprocessorinterfaceadaptor.cpp \ + +HEADERS += \ + textprocessor.h \ + textprocessorinterfaceadaptor.h\ + +QT += dbus gui + +target.path = $$DUI_INSTALL_BIN + +INSTALLS += \ + target \ diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.cpp b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.cpp new file mode 100644 index 00000000..ed3229b1 --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "textprocessor.h" +#include <QtDebug> +#include <QString> + +TextProcessor::TextProcessor() + : QObject(0) +{ + qDebug() << "TextProcessor is created!"; +} + +TextProcessor::~TextProcessor() +{ +} + +QString TextProcessor::reverse(const QString &message) +{ + qDebug() << message << "reverse to:"; + + QString mirror; + for (int i = message.size() - 1; i >= 0; --i) { + mirror.append(message[i]); + } + + qDebug() << mirror; + return mirror.toUpper(); +} diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.h b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.h new file mode 100644 index 00000000..e7f530e5 --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessor.h @@ -0,0 +1,37 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef TEXTPROCESSOR_H +#define TEXTPROCESSOR_H + +#include <QObject> + +class QString; + +class TextProcessor : public QObject +{ + Q_OBJECT +public: + TextProcessor(); + virtual ~TextProcessor(); + +public Q_SLOTS: + QString reverse(const QString &message); +}; +#endif diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.cpp b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.cpp new file mode 100644 index 00000000..dc3253a1 --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.cpp @@ -0,0 +1,43 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceAdaptor -a textprocessorinterfaceadaptor com.nokia.TextProcessorInterface.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "textprocessorinterfaceadaptor.h" +#include <QtCore/QMetaObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> + +/* + * Implementation of adaptor class TextProcessorInterfaceAdaptor + */ + +TextProcessorInterfaceAdaptor::TextProcessorInterfaceAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +TextProcessorInterfaceAdaptor::~TextProcessorInterfaceAdaptor() +{ + // destructor +} + +QString TextProcessorInterfaceAdaptor::reverse(const QString &message) +{ + // handle method call com.nokia.TextProcessorInterface.reverse + QString out0; + QMetaObject::invokeMethod(parent(), "reverse", Q_RETURN_ARG(QString, out0), Q_ARG(QString, message)); + return out0; +} + diff --git a/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.h b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.h new file mode 100644 index 00000000..b08ccd5c --- /dev/null +++ b/examples/servicefw/provider/impl/org.maemo.textprocessor/textprocessorinterfaceadaptor.h @@ -0,0 +1,49 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceAdaptor -a textprocessorinterfaceadaptor com.nokia.TextProcessorInterface-30825.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef TEXTPROCESSORINTERFACEADAPTOR_H_1267695582 +#define TEXTPROCESSORINTERFACEADAPTOR_H_1267695582 + +#include <QtCore/QObject> +#include <QtDBus/QtDBus> +class QByteArray; +template<class T> class QList; +template<class Key, class Value> class QMap; +class QString; +class QStringList; +class QVariant; + +/* + * Adaptor class for interface com.nokia.TextProcessorInterface + */ +class TextProcessorInterfaceAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.nokia.TextProcessorInterface") + Q_CLASSINFO("D-Bus Introspection", "" +" <interface name=\"com.nokia.TextProcessorInterface\">\n" +" <method name=\"reverse\">\n" +" <arg direction=\"in\" type=\"s\" name=\"message\"/>\n" +" <arg direction=\"out\" type=\"s\" name=\"\"/>\n" +" </method>\n" +" </interface>\n" + "") +public: + TextProcessorInterfaceAdaptor(QObject *parent); + virtual ~TextProcessorInterfaceAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + QString reverse(const QString &message); +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/examples/servicefw/provider/provider.pro b/examples/servicefw/provider/provider.pro new file mode 100644 index 00000000..d89f75c1 --- /dev/null +++ b/examples/servicefw/provider/provider.pro @@ -0,0 +1,7 @@ +# serviceif must be done before impl +CONFIG += ordered +SUBDIRS = \ + serviceif \ + impl \ + +TEMPLATE = subdirs diff --git a/examples/servicefw/provider/serviceif/serviceif.pro b/examples/servicefw/provider/serviceif/serviceif.pro new file mode 100644 index 00000000..67a0abe6 --- /dev/null +++ b/examples/servicefw/provider/serviceif/serviceif.pro @@ -0,0 +1,4 @@ +SUBDIRS = \ + textprocessorinterface \ + +TEMPLATE = subdirs diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/.gitignore b/examples/servicefw/provider/serviceif/textprocessorinterface/.gitignore new file mode 100644 index 00000000..9ebe64e4 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/.gitignore @@ -0,0 +1 @@ +.dummy diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/com.nokia.TextProcessorInterface.xml b/examples/servicefw/provider/serviceif/textprocessorinterface/com.nokia.TextProcessorInterface.xml new file mode 100644 index 00000000..3ead2eb4 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/com.nokia.TextProcessorInterface.xml @@ -0,0 +1,9 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="com.nokia.TextProcessorInterface"> + <method name="reverse"> + <arg name="message" type="s" direction="in"/> + <arg name="" type="s" direction="out"/> + </method> + </interface> +</node> diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.cpp b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.cpp new file mode 100644 index 00000000..814ab047 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.cpp @@ -0,0 +1,65 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +/* + * automatically generated with the command line : + * ../../../../../tools/dui-servicefwgen -p com.nokia.TextProcessorIf + */ + +#include "textprocessorinterface.h" + +QString TextProcessorInterface::reverse( const QString &message ) +{ + return qobject_cast<TextProcessorInterfaceProxy*>(interfaceProxy)->reverse( message ).value(); +} + +TextProcessorInterface::TextProcessorInterface( const QString& preferredService, QObject* parent ) + : DuiServiceFwBaseIf( TextProcessorInterfaceProxy::staticInterfaceName(), parent ) +{ + // Resolve the provider service name + service = resolveServiceName( interface, preferredService ); + + bool serviceNameInvalid = service.contains( " " ); // "not provided" - when the service wouldn't run + if ( serviceNameInvalid ) { + service.clear(); + } + + if (!service.isEmpty()) { + // Construct the D-Bus proxy + interfaceProxy = new TextProcessorInterfaceProxy( service, "/", QDBusConnection::sessionBus(), this ); + // allConnectSignals go here (empty block if none) + + } +} + +void TextProcessorInterface::setService(const QString & service) +{ + if (service.isEmpty()) return; + + this->service = service; + + if ( interfaceProxy ) { + delete interfaceProxy; + interfaceProxy = 0; + } + interfaceProxy = new TextProcessorInterfaceProxy( service, "/", QDBusConnection::sessionBus(), this ); + { + + } +} diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.h b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.h new file mode 100644 index 00000000..bc1be34d --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.h @@ -0,0 +1,61 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef TEXTPROCESSORINTERFACE_H +#define TEXTPROCESSORINTERFACE_H + +/* + * automatically generated with the command line : + * dui-servicefwgen -p com.nokia.TextProcessorInterface + */ + +#include <QObject> + +#include <duiservicefwbaseif.h> +#include <textprocessorinterfaceproxy.h> + +class TextProcessorInterface : public DuiServiceFwBaseIf +{ +Q_OBJECT + +public: + QString reverse( const QString &message ); + +public: + /*! + * @brief Constructs a base interface + * @param preferredService, define the preferred service provider. Leave + empty if no preferred provider. In most cases, this should be left + empty. + * @param parent Parent object + */ + + TextProcessorInterface( const QString& preferredService = "", QObject* parent = 0 ); + + /*! + * @brief Set the service name + * @param service Name of the desired service + */ + + void setService(const QString & service); +Q_SIGNALS: + + +}; +#endif diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.pro b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.pro new file mode 100644 index 00000000..f65f2a44 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterface.pro @@ -0,0 +1,46 @@ +DUIROOT = ../../../../.. +include($$DUIROOT/mkspecs/common.pri) + +DUILIB = $$DUIROOT/lib +DUISIF = $$DUIROOT/demos/servicefw +DUISFW = $$DUIROOT/duiservicemapper +DUISIFLIB = $$DUISIF/lib +DUISIFINCLUDE = $$DUISIF/include +DUISFWINCLUDE = $$DUIROOT/src/servicefwif + +INCLUDEPATH += \ + $$DUISFWINCLUDE \ + $$DUISFWINCLUDE/include \ + $$DUISIFINCLUDE \ + $$DUIROOT/src/include \ + +DEPENTPATH += $$INCLUDEPATH +TARGET = textprocessor +DESTDIR = $$DUISIFLIB +TEMPLATE = lib +SOURCES += \ + textprocessorinterfaceproxy.cpp \ + textprocessorinterface.cpp \ + +HEADERS += \ + textprocessorinterfaceproxy.h \ + textprocessorinterface.h \ + +QT += dbus + +target.path += $$[QT_INSTALL_LIBS] + +headers.target = .dummy +headers.commands = touch $$headers.target +headers.path = $$[QT_INSTALL_HEADERS] +headers.files = $$HEADERS + +xml.target = .dummy +xml.commands = touch $$xml.target +xml.path = $$DUI_DBUS_INTERFACES_DIR +xml.files = com.nokia.TextProcessorInterface.xml + +INSTALLS += \ + target \ + headers \ + xml \ diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.cpp b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.cpp new file mode 100644 index 00000000..74a815d3 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceProxy -p textprocessorinterfaceproxy com.nokia.TextProcessorInterface-22923.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "textprocessorinterfaceproxy.h" + +/* + * Implementation of interface class TextProcessorInterfaceProxy + */ + +TextProcessorInterfaceProxy::TextProcessorInterfaceProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +TextProcessorInterfaceProxy::~TextProcessorInterfaceProxy() +{ +} + diff --git a/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.h b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.h new file mode 100644 index 00000000..8cbc5b96 --- /dev/null +++ b/examples/servicefw/provider/serviceif/textprocessorinterface/textprocessorinterfaceproxy.h @@ -0,0 +1,54 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c TextProcessorInterfaceProxy -p textprocessorinterfaceproxy com.nokia.TextProcessorInterface-22923.xml + * + * qdbusxml2cpp is Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef TEXTPROCESSORINTERFACEPROXY_H_1267631607 +#define TEXTPROCESSORINTERFACEPROXY_H_1267631607 + +#include <QtCore/QObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> +#include <QtDBus/QtDBus> + +/* + * Proxy class for interface com.nokia.TextProcessorInterface + */ +class TextProcessorInterfaceProxy: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.nokia.TextProcessorInterface"; } + +public: + TextProcessorInterfaceProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~TextProcessorInterfaceProxy(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<QString> reverse(const QString &message) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(message); + return asyncCallWithArgumentList(QLatin1String("reverse"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace com { + namespace nokia { + typedef ::TextProcessorInterfaceProxy TextProcessorInterface; + } +} +#endif diff --git a/examples/servicefw/servicefw.pro b/examples/servicefw/servicefw.pro new file mode 100644 index 00000000..93fc92a6 --- /dev/null +++ b/examples/servicefw/servicefw.pro @@ -0,0 +1,7 @@ +CONFIG += ordered +SUBDIRS += \ + provider \ + user \ + misc \ + +TEMPLATE = subdirs diff --git a/examples/servicefw/user/echowindow.cpp b/examples/servicefw/user/echowindow.cpp new file mode 100644 index 00000000..bc60de95 --- /dev/null +++ b/examples/servicefw/user/echowindow.cpp @@ -0,0 +1,142 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include <QWidget> +#include <QLabel> +#include <QPushButton> +#include <QLineEdit> +#include <QGridLayout> +#include <textprocessorinterface.h> + +#include "echowindow.h" + +EchoWindow::EchoWindow() +{ + createGUI(); + setLayout(layout); + setWindowTitle("TextProcessor Demo"); + + // instantiate the interface + textProcessorInterface = new TextProcessorInterface(); + + // check the interface is valid + if (!textProcessorInterface->isValid()) { + disableTextProcessing(QString(0)); + statusBar->showMessage("Err: Service unavailable"); + } + + // example of how to get a list of all installed services + if (textProcessorInterface->isValid()) { + QStringList services = textProcessorInterface->serviceNames(); + QStringListIterator iterator(services); + qDebug() << "All services:"; + while (iterator.hasNext()) + qDebug() << iterator.next().toLocal8Bit().constData(); + } + + // example of how to get a list of all services for a particular interface + if (textProcessorInterface->isValid()) { + QStringList services = textProcessorInterface->serviceNames("com.nokia.TextProcessorInterface"); + QStringListIterator iterator(services); + qDebug() << "Services implementing com.nokia.TextProcessorInterface:"; + while (iterator.hasNext()) + qDebug() << iterator.next().toLocal8Bit().constData(); + } + + // connect the availability signals + // you likely need to know when a service appears/disappears to + // do things like add/remove an option on a menu + connect( + textProcessorInterface, SIGNAL(serviceAvailable(QString)), + this, SLOT(enableTextProcessing(QString)) + ); + connect( + textProcessorInterface, SIGNAL(serviceUnavailable(QString)), + this, SLOT(disableTextProcessing(QString)) + ); + connect( + textProcessorInterface, SIGNAL(serviceChanged(QString)), + this, SLOT(enableTextProcessing(QString)) + ); +} + +EchoWindow::~EchoWindow() +{ + delete textProcessorInterface; +} + +void EchoWindow::sendEcho() +{ + // call the interface method to reverse the string + QString text = textProcessorInterface->reverse(lineEdit->text()); + + // set the label text to the reversed string + label->setText(text); +} + +/* + * This function is specific to this example. + * Your own code will likely do something different + */ +void EchoWindow::createGUI() +{ + lineEdit = new QLineEdit; + label = new QLabel; + label->setFrameStyle(QFrame::Box | QFrame::Plain); + button = new QPushButton(tr("Send Message")); + statusBar = new QStatusBar; + + connect(lineEdit, SIGNAL(editingFinished()), + this, SLOT(sendEcho())); + connect(button, SIGNAL(clicked()), + this, SLOT(sendEcho())); + + layout = new QGridLayout; + layout->addWidget(new QLabel(tr("Message:")), 0, 0); + layout->addWidget(lineEdit, 0, 1); + layout->addWidget(new QLabel(tr("Answer:")), 1, 0); + layout->addWidget(label, 1, 1); + layout->addWidget(button, 2, 1, Qt::AlignRight); + layout->addWidget(statusBar, 3, 0, 1, 2); + layout->setSizeConstraint(QLayout::SetFixedSize); +} + +/* + * This function is specific to this example. + * Your own code will likely do something different + */ +void EchoWindow::enableTextProcessing(const QString &service) +{ + statusBar->showMessage(service + " is available"); + lineEdit->setEnabled(true); + label->setEnabled(true); + button->setEnabled(true); +} + +/* + * This function is specific to this example. + * Your own code will likely do something different + */ +void EchoWindow::disableTextProcessing(const QString &service) +{ + statusBar->showMessage("Err: " + service + " is unavailable"); + lineEdit->setEnabled(false); + label->setEnabled(false); + button->setEnabled(false); +} diff --git a/examples/servicefw/user/echowindow.h b/examples/servicefw/user/echowindow.h new file mode 100644 index 00000000..cbc506e6 --- /dev/null +++ b/examples/servicefw/user/echowindow.h @@ -0,0 +1,63 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef ECHODIALOG_H +#define ECHODIALOG_H + +#include <QWidget> +#include <QStatusBar> + +class TextProcessorInterface; + +QT_BEGIN_NAMESPACE +class QString; +class QLineEdit; +class QLabel; +class QPushButton; +class QGridLayout; +QT_END_NAMESPACE + +/* + * Example class to demonstrate use of service framework + */ +class EchoWindow : public QWidget +{ + Q_OBJECT + +public: + EchoWindow(); + virtual ~EchoWindow(); + +private slots: + void sendEcho(); + void enableTextProcessing(const QString &service); + void disableTextProcessing(const QString &service); + +private: + void createGUI(); + + TextProcessorInterface *textProcessorInterface; + QLineEdit *lineEdit; + QLabel *label; + QPushButton *button; + QStatusBar *statusBar; + QGridLayout *layout; +}; + +#endif diff --git a/examples/servicefw/user/main.cpp b/examples/servicefw/user/main.cpp new file mode 100644 index 00000000..1f21db5e --- /dev/null +++ b/examples/servicefw/user/main.cpp @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include <QApplication> + +#include "echowindow.h" + +/* + * This is an example program to demonstrate the use of the service framework + */ + +int main(int argv, char *args[]) +{ + QApplication app(argv, args); + + EchoWindow window; + window.show(); + + return app.exec(); +} diff --git a/examples/servicefw/user/user.pro b/examples/servicefw/user/user.pro new file mode 100644 index 00000000..1e5e80f1 --- /dev/null +++ b/examples/servicefw/user/user.pro @@ -0,0 +1,43 @@ +include(../../../mkspecs/common.pri) + +DUIROOT = ../../.. +DUILIB = $$DUIROOT/lib +DUISIF = $$DUIROOT/demos/servicefw +DUISIFINCLUDE = $$DUIROOT/demos/servicefw/include +DUISFWINCLUDE = $$DUIROOT/src/servicefwif +TARGET = user +DESTDIR = $$DUISIF/bin +TEMPLATE = app + +INCLUDEPATH += \ + . \ + $$DUISIFINCLUDE \ + $$DUISFWINCLUDE \ + $$DUISFWINCLUDE/include \ + $$DUISIFINCLUDE \ + $$DUIROOT/src/include \ + +DEPENDPATH += $$INCLUDEPATH + +QMAKE_LIBDIR += \ + $$DUILIB \ + $$DUISIF/lib \ + +HEADERS = \ + echowindow.h \ + +SOURCES = \ + echowindow.cpp \ + main.cpp \ + +LIBS += \ + ../../../lib/libdui.so \ + +QT += dbus +LIBS += \ + -ltextprocessor \ + +target.path = $$DUI_INSTALL_BIN + +INSTALLS += \ + target |