aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMax Waterman <david.waterman@nokia.com>2010-03-16 09:34:08 +0200
committerMax Waterman <david.waterman@nokia.com>2010-03-16 13:11:45 +0200
commitd95acf8c7e6f209caf7e591b9e04845ef984a0fc (patch)
tree1f67a977095f7109460473d0e861a9d2396e3027 /examples
parentfca860943a28ed1c2947f535dd6771d3b835b2d1 (diff)
Changes: added simple chaining example
RevBy: Holger
Diffstat (limited to 'examples')
-rw-r--r--examples/chaining/README.txt13
-rw-r--r--examples/chaining/chaining.pro6
-rw-r--r--examples/chaining/chainingexampleapp1/chainingexampleapp1.desktop8
-rw-r--r--examples/chaining/chainingexampleapp1/chainingexampleapp1.pro47
-rw-r--r--examples/chaining/chainingexampleapp1/com.nokia.chainingexampleapp1.service3
-rw-r--r--examples/chaining/chainingexampleapp1/imageviewer.cpp30
-rw-r--r--examples/chaining/chainingexampleapp1/imageviewer.h24
-rw-r--r--examples/chaining/chainingexampleapp1/main.cpp24
-rw-r--r--examples/chaining/chainingexampleapp2/chainingexampleapp2.desktop8
-rw-r--r--examples/chaining/chainingexampleapp2/chainingexampleapp2.pro51
-rw-r--r--examples/chaining/chainingexampleapp2/com.nokia.chainingexampleapp2.service4
-rw-r--r--examples/chaining/chainingexampleapp2/imageviewer.cpp31
-rw-r--r--examples/chaining/chainingexampleapp2/imageviewer.h23
-rw-r--r--examples/chaining/chainingexampleapp2/main.cpp36
-rw-r--r--examples/chaining/chainingexampleinterface/chainingexampleinterface.pro35
-rw-r--r--examples/chaining/chainingexampleinterface/com.nokia.ChainingExampleInterface.xml28
16 files changed, 371 insertions, 0 deletions
diff --git a/examples/chaining/README.txt b/examples/chaining/README.txt
new file mode 100644
index 00000000..1c6a34b5
--- /dev/null
+++ b/examples/chaining/README.txt
@@ -0,0 +1,13 @@
+This example shows a basic chaining mechanism.
+
+There are three entities involved in chaining.
+
+1. The interface - chainingexampleinterface.
+It defines what methods, signals, etc the interface consists of.
+Applications wishing to call methods in the interface need to include the interface's header file, and link with the interface's library.
+
+2. The interface user - chainingexampleapp1.
+It is the application that uses the interface. It doesn't care what application actually implements the methods in the interface.
+
+3. The interface provider/implementor - chainingexampleapp2.
+It implements the methods/etc in the interface and so is launched when chainingexampleapp1 calls it's methods via the interface. When the user is done with this app, he/she presses the 'back' button, which calls the DuiApplicationService 'launch' method for app1, thereby raising it to the top, and exits.
diff --git a/examples/chaining/chaining.pro b/examples/chaining/chaining.pro
new file mode 100644
index 00000000..0a4ac404
--- /dev/null
+++ b/examples/chaining/chaining.pro
@@ -0,0 +1,6 @@
+CONFIG += ordered
+TEMPLATE = subdirs
+SUBDIRS = \
+ chainingexampleinterface \
+ chainingexampleapp1 \
+ chainingexampleapp2 \
diff --git a/examples/chaining/chainingexampleapp1/chainingexampleapp1.desktop b/examples/chaining/chainingexampleapp1/chainingexampleapp1.desktop
new file mode 100644
index 00000000..ca8ebe34
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/chainingexampleapp1.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=Chaining Example App1
+Icon=icon-l-video
+X-Maemo-Service=com.nokia.chainingexampleapp1
+Exec=chainingexampleapp1
+Categories=Demos;
+OnlyShowIn=X-DUI;
diff --git a/examples/chaining/chainingexampleapp1/chainingexampleapp1.pro b/examples/chaining/chainingexampleapp1/chainingexampleapp1.pro
new file mode 100644
index 00000000..235a6c80
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/chainingexampleapp1.pro
@@ -0,0 +1,47 @@
+TEMPLATE = app
+TARGET = chainingexampleapp1
+CONFIG += dui # Requires libdui to be installed
+
+OBJECTS_DIR = ./.obj
+MOC_DIR = ./.moc
+
+INCLUDEPATH += \
+ ../chainingexampleinterface \
+
+DEPENDPATH += $$INCLUDEPATH
+
+LIBS += \
+ ../chainingexampleinterface/libchainingexampleinterface.so \
+
+# Input
+SOURCES += \
+ main.cpp \
+ imageviewer.cpp \
+
+HEADERS += \
+ imageviewer.h \
+
+OBJECTS_DIR = .tmp
+MOC_DIR = .tmp
+
+# target installation
+target.path = /usr/bin
+
+#install desktop file
+desktop.files = chainingexampleapp1.desktop
+desktop.path = /usr/share/applications/
+
+# install prf file
+prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
+prf.files = chainingexampleapp1-service.prf
+
+#install service file
+service.files = com.nokia.chainingexampleapp1.service
+service.path = /usr/share/dbus-1/services/
+
+INSTALLS += \
+ target \
+ prf \
+ desktop \
+ service \
+
diff --git a/examples/chaining/chainingexampleapp1/com.nokia.chainingexampleapp1.service b/examples/chaining/chainingexampleapp1/com.nokia.chainingexampleapp1.service
new file mode 100644
index 00000000..6304da48
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/com.nokia.chainingexampleapp1.service
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.nokia.chainingexampleapp1
+Exec=/usr/bin/chainingexampleapp1
diff --git a/examples/chaining/chainingexampleapp1/imageviewer.cpp b/examples/chaining/chainingexampleapp1/imageviewer.cpp
new file mode 100644
index 00000000..e711c920
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/imageviewer.cpp
@@ -0,0 +1,30 @@
+
+#include <QDebug>
+
+#include "chainingexampleinterface.h"
+
+#include "imageviewer.h"
+
+ImageViewer::ImageViewer( const DuiButton &button ) :
+ chainingExampleInterface( new ChainingExampleInterface )
+{
+ QObject::connect( &button, SIGNAL( released() ), this, SLOT( showImage() ) );
+}
+
+ImageViewer::~ImageViewer()
+{
+ delete chainingExampleInterface;
+}
+
+void ImageViewer::showImage()
+{
+ QString imageFilename( "YES" );
+ QStringList list;
+ list << imageFilename;
+
+ if ( chainingExampleInterface->isValid() ) {
+ chainingExampleInterface->showImage( imageFilename, list );
+ } else {
+ qDebug() << "chainingExampleInterface not valid : " << chainingExampleInterface;
+ }
+}
diff --git a/examples/chaining/chainingexampleapp1/imageviewer.h b/examples/chaining/chainingexampleapp1/imageviewer.h
new file mode 100644
index 00000000..05e6e101
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/imageviewer.h
@@ -0,0 +1,24 @@
+#ifndef IMAGEVIEWER_H
+#define IMAGEVIEWER_H
+
+#include <QObject>
+
+#include <DuiButton>
+#include "chainingexampleinterface.h"
+
+class ImageViewer: public QObject
+{
+ Q_OBJECT
+
+public:
+ ImageViewer( const DuiButton &button );
+ ~ImageViewer();
+
+public slots:
+ void showImage();
+
+private:
+ ChainingExampleInterface *chainingExampleInterface;
+};
+
+#endif // IMAGEVIEWER_H
diff --git a/examples/chaining/chainingexampleapp1/main.cpp b/examples/chaining/chainingexampleapp1/main.cpp
new file mode 100644
index 00000000..ba28c88c
--- /dev/null
+++ b/examples/chaining/chainingexampleapp1/main.cpp
@@ -0,0 +1,24 @@
+#include <DuiApplication>
+#include <DuiApplicationPage>
+#include <DuiApplicationWindow>
+#include <DuiButton>
+
+#include "imageviewer.h"
+
+int main(int argc, char** argv)
+{
+ DuiApplication app(argc, argv);
+ DuiApplicationWindow w;
+ w.setObjectName( "Main Window" );
+ w.show();
+
+ DuiApplicationPage p;
+ p.appearNow();
+
+ DuiButton b(p.centralWidget());
+ b.setText("IMAGE");
+
+ ImageViewer myImageViewer( b );
+
+ return app.exec();
+}
diff --git a/examples/chaining/chainingexampleapp2/chainingexampleapp2.desktop b/examples/chaining/chainingexampleapp2/chainingexampleapp2.desktop
new file mode 100644
index 00000000..7d9997c1
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/chainingexampleapp2.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Type=Application
+Name=Chaining Example App2
+Icon=icon-l-video
+X-Maemo-Service=com.nokia.ChainingExampleApp2
+Exec=chainginexampleapp2
+Categories=Demos;
+OnlyShowIn=X-DUI;
diff --git a/examples/chaining/chainingexampleapp2/chainingexampleapp2.pro b/examples/chaining/chainingexampleapp2/chainingexampleapp2.pro
new file mode 100644
index 00000000..29ce3ba6
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/chainingexampleapp2.pro
@@ -0,0 +1,51 @@
+TEMPLATE = app
+TARGET = chainingexampleapp2
+CONFIG += dui # Requires libdui to be installed
+
+OBJECTS_DIR = ./.obj
+MOC_DIR = ./.moc
+
+INCLUDEPATH += \
+
+DEPENDPATH += $$INCLUDEPATH
+
+LIBS += \
+
+system(cp ../chainingexampleinterface/com.nokia.ChainingExampleInterface.xml .)
+system(dui-servicefwgen -a com.nokia.ChainingExampleInterface)
+
+QMAKE_CLEAN += \
+ com.nokia.ChainingExampleInterface.xml \
+ chainingexampleinterfaceadaptor.cpp \
+ chainingexampleinterfaceadaptor.h \
+
+# Input
+SOURCES += \
+ main.cpp \
+ imageviewer.cpp \
+ chainingexampleinterfaceadaptor.cpp \
+
+HEADERS += \
+ imageviewer.h \
+ chainingexampleinterfaceadaptor.h \
+
+# target installation
+target.path = /usr/bin
+
+#install service file
+service.files = com.nokia.ChainingExampleApp2.service
+service.path = /usr/share/dbus-1/services/
+
+#install desktop file
+desktop.files = chainingexampleapp2.desktop
+desktop.path = /usr/share/applications/
+
+# install prf file
+prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
+prf.files = chainingexampleapp2-service.prf
+
+INSTALLS += \
+ target \
+ service \
+ prf \
+ desktop \
diff --git a/examples/chaining/chainingexampleapp2/com.nokia.chainingexampleapp2.service b/examples/chaining/chainingexampleapp2/com.nokia.chainingexampleapp2.service
new file mode 100644
index 00000000..93692572
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/com.nokia.chainingexampleapp2.service
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=com.nokia.ChainingExampleApp2
+Interface=com.nokia.ChainingExampleInterface
+Exec=/usr/bin/chainingexampleapp2
diff --git a/examples/chaining/chainingexampleapp2/imageviewer.cpp b/examples/chaining/chainingexampleapp2/imageviewer.cpp
new file mode 100644
index 00000000..d58cf3f4
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/imageviewer.cpp
@@ -0,0 +1,31 @@
+
+#include "imageviewer.h"
+
+#include <QDebug>
+
+#include <DuiButton>
+#include <DuiApplication>
+#include <DuiApplicationWindow>
+#include <DuiApplicationIfProxy>
+
+ImageViewer::ImageViewer( DuiButton *button )
+{
+ this->button = button;
+}
+
+ImageViewer::~ImageViewer()
+{
+}
+
+bool ImageViewer::showImage(const QString &uri, const QStringList &uriList)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ Q_UNUSED( uriList );
+
+ DuiApplication *duiApp = DuiApplication::instance();
+ duiApp->activeWindow()->raise();
+
+ button->setText( uri );
+
+ return true;
+}
diff --git a/examples/chaining/chainingexampleapp2/imageviewer.h b/examples/chaining/chainingexampleapp2/imageviewer.h
new file mode 100644
index 00000000..2788512a
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/imageviewer.h
@@ -0,0 +1,23 @@
+#ifndef IMAGEVIEWER_H
+#define IMAGEVIEWER_H
+
+#include <QObject>
+
+class DuiButton;
+
+class ImageViewer: public QObject
+{
+ Q_OBJECT
+
+public:
+ ImageViewer( DuiButton *button );
+ ~ImageViewer();
+
+public slots:
+ bool showImage(const QString &uri, const QStringList &uriList);
+
+private:
+ DuiButton *button;
+};
+
+#endif // IMAGEVIEWER_H
diff --git a/examples/chaining/chainingexampleapp2/main.cpp b/examples/chaining/chainingexampleapp2/main.cpp
new file mode 100644
index 00000000..39678fad
--- /dev/null
+++ b/examples/chaining/chainingexampleapp2/main.cpp
@@ -0,0 +1,36 @@
+#include <DuiApplication>
+#include <DuiApplicationPage>
+#include <DuiApplicationWindow>
+#include <DuiButton>
+
+#include "imageviewer.h"
+#include "chainingexampleinterfaceadaptor.h"
+
+#include "imageviewer.h"
+
+int main(int argc, char** argv)
+{
+ DuiApplication app(argc, argv);
+
+ DuiApplicationWindow w;
+ w.show();
+
+ DuiApplicationPage p;
+ p.appearNow();
+
+ DuiButton b(p.centralWidget());
+ b.setText("NO");
+
+ ImageViewer myImageViewer( &b );
+
+ new ChainingExampleInterfaceAdaptor( &myImageViewer );
+
+ QDBusConnection connection = QDBusConnection::sessionBus();
+ bool ret = connection.registerService( "com.nokia.ChainingExampleApp2" );
+
+ ret = connection.registerObject("/", &myImageViewer);
+
+ ret = app.exec();
+
+ return ret;
+}
diff --git a/examples/chaining/chainingexampleinterface/chainingexampleinterface.pro b/examples/chaining/chainingexampleinterface/chainingexampleinterface.pro
new file mode 100644
index 00000000..c8308180
--- /dev/null
+++ b/examples/chaining/chainingexampleinterface/chainingexampleinterface.pro
@@ -0,0 +1,35 @@
+TEMPLATE = lib
+TARGET = chainingexampleinterface
+CONFIG += dll dui
+QT += dbus
+
+system(dui-servicefwgen -p com.nokia.ChainingExampleInterface)
+
+OBJECTS_DIR = ./.obj
+MOC_DIR = ./.moc
+
+SOURCES += chainingexampleinterfaceproxy.cpp chainingexampleinterface.cpp
+HEADERS += chainingexampleinterface.h chainingexampleinterfaceproxy.h
+
+QMAKE_CLEAN += *.cpp *.h *~ *.so*
+
+# target installation
+target.path = /usr/lib
+
+# install headers
+headers.path = /usr/include/chainingexample/service/
+headers.files = $$HEADERS
+
+#install xml file
+xml.files = com.nokia.chainingexampleinterface.xml
+xml.path = /usr/share/dbus-1/interfaces/
+
+# install prf file
+prf.path = $$[QT_INSTALL_DATA]/mkspecs/features
+prf.files = chainingexample-service.prf
+
+INSTALLS += \
+ target \
+ headers \
+ prf \
+ xml \
diff --git a/examples/chaining/chainingexampleinterface/com.nokia.ChainingExampleInterface.xml b/examples/chaining/chainingexampleinterface/com.nokia.ChainingExampleInterface.xml
new file mode 100644
index 00000000..fe72f7a7
--- /dev/null
+++ b/examples/chaining/chainingexampleinterface/com.nokia.ChainingExampleInterface.xml
@@ -0,0 +1,28 @@
+<!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.ChainingExampleInterface">
+ <method name="showPage">
+ <arg name="targetPage" type="s" direction="in" />
+ <arg name="previousPage" type="s" direction="in" />
+ <arg name="" type="b" direction="out"/>
+ </method>
+ <method name="showImage">
+ <arg name="uri" type="s" direction="in" />
+ <arg name="playlistName" type="s" direction="in" />
+ <arg name="defaultBackPage" type="s" direction="in" />
+ <arg name="" type="b" direction="out"/>
+ </method>
+ <method name="showImage" chainTask="true" asyncTask="true">
+ <arg name="uri" type="s" direction="in" />
+ <arg name="uriList" type="as" direction="in" />
+ </method>
+ <method name="showGridWithCapturedContent">
+ <arg name="limit" type="i" direction="in" />
+ <arg name="" type="b" direction="out" />
+ </method>
+ <method name="showSettings">
+ <arg name="" type="b" direction="out" />
+ </method>
+ </interface>
+</node>