diff options
Diffstat (limited to 'qt/examples')
-rw-r--r-- | qt/examples/.cvsignore | 11 | ||||
-rw-r--r-- | qt/examples/Makefile.am | 42 | ||||
-rw-r--r-- | qt/examples/chat.cpp | 136 | ||||
-rw-r--r-- | qt/examples/chat.h | 62 | ||||
-rw-r--r-- | qt/examples/chatadaptor.cpp | 36 | ||||
-rw-r--r-- | qt/examples/chatadaptor.h | 40 | ||||
-rw-r--r-- | qt/examples/chatmainwindow.ui | 188 | ||||
-rw-r--r-- | qt/examples/chatsetnickname.ui | 149 | ||||
-rw-r--r-- | qt/examples/com.trolltech.ChatInterface.xml | 15 | ||||
-rw-r--r-- | qt/examples/complexping.cpp | 91 | ||||
-rw-r--r-- | qt/examples/complexping.h | 37 | ||||
-rw-r--r-- | qt/examples/complexpong.cpp | 86 | ||||
-rw-r--r-- | qt/examples/complexpong.h | 46 | ||||
-rw-r--r-- | qt/examples/hello.cpp | 33 | ||||
-rw-r--r-- | qt/examples/listnames.cpp | 61 | ||||
-rw-r--r-- | qt/examples/ping-common.h | 22 | ||||
-rw-r--r-- | qt/examples/ping.cpp | 48 | ||||
-rw-r--r-- | qt/examples/pong.cpp | 54 | ||||
-rw-r--r-- | qt/examples/pong.h | 34 |
19 files changed, 0 insertions, 1191 deletions
diff --git a/qt/examples/.cvsignore b/qt/examples/.cvsignore deleted file mode 100644 index f6454f28..00000000 --- a/qt/examples/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -*.bb -*.bbg -*.da -*.gcov -*.moc diff --git a/qt/examples/Makefile.am b/qt/examples/Makefile.am deleted file mode 100644 index 0d4c6eba..00000000 --- a/qt/examples/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -INCLUDES=-I$(top_srcdir)/qt $(DBUS_CLIENT_CFLAGS) $(DBUS_QT_CFLAGS) -DDBUS_COMPILATION -LDADD = ../src/libdbus-qt4-1.la - -if HAVE_QT_GUI -chat_LDADD = $(LDADD) $(DBUS_QT_GUI_LIBS) -dist_chat_SOURCES = chat.cpp chat.h chatadaptor.cpp -nodist_chat_SOURCES = chatinterface.cpp -chat.o: ui_chatmainwindow.h ui_chatsetnickname.h chatinterface.h chatadaptor.h chat.moc chatadaptor.moc -ui_chatmainwindow.h: chatmainwindow.ui -ui_chatsetnickname.h: chatsetnickname.ui -chatinterface.cpp chatinterface.h: com.trolltech.ChatInterface.xml - ../tools/dbusidl2cpp -m -p chatinterface $? - $(QT_MOC) -o chatinterface.moc chatinterface.h - -CHAT=chat -endif - - -noinst_PROGRAMS = hello listnames ping pong complexping complexpong $(CHAT) -hello_SOURCES = hello.cpp -listnames_SOURCES = listnames.cpp - -ping_SOURCES = ping.cpp -pong_SOURCES = pong.cpp pong.h -pong.o: pong.moc - -complexping_SOURCES = complexping.cpp complexping.h -complexpong_SOURCES = complexpong.cpp complexpong.h -complexpong.o: complexpong.moc -complexping.o: complexping.moc - -EXTRA_DIST = ping-common.h chatmainwindow.ui chatsetnickname.ui com.trolltech.ChatInterface.xml chatadaptor.h - -CLEANFILES = chat.moc chatadaptor.moc complexping.moc complexpong.moc pong.moc \ - chatinterface.cpp chatinterface.h chatinterface.moc \ - ui_chatmainwindow.h ui_chatsetnickname.h - -%.moc: %.h - $(QT_MOC) $< > $@ -ui_%.h: %.ui - $(QT_UIC) -o $@ $? - diff --git a/qt/examples/chat.cpp b/qt/examples/chat.cpp deleted file mode 100644 index 86ff873b..00000000 --- a/qt/examples/chat.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "chat.h" -#include <QtGui/QApplication> -#include <QtGui/QMessageBox> - -#include "chatadaptor.h" -#include "chatinterface.h" - -ChatMainWindow::ChatMainWindow() - : m_nickname(QLatin1String("nickname")) -{ - setupUi(this); - sendButton->setEnabled(false); - - connect(messageLineEdit, SIGNAL(textChanged(QString)), - this, SLOT(textChangedSlot(QString))); - connect(sendButton, SIGNAL(clicked(bool)), this, SLOT(sendClickedSlot())); - connect(actionChangeNickname, SIGNAL(triggered(bool)), this, SLOT(changeNickname())); - connect(actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(aboutQt())); - connect(qApp, SIGNAL(lastWindowClosed()), this, SLOT(exiting())); - - // add our D-Bus interface and connect to D-Bus - new ChatInterfaceAdaptor(this); - QDBus::systemBus().registerObject("/", this); - - com::trolltech::ChatInterface *iface; - iface = QDBus::systemBus().findInterface<com::trolltech::ChatInterface>(QString(), QString()); - connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString))); - connect(iface, SIGNAL(action(QString,QString)), this, SLOT(actionSlot(QString,QString))); - - NicknameDialog dialog; - dialog.cancelButton->setVisible(false); - dialog.exec(); - m_nickname = dialog.nickname->text().trimmed(); - emit action(m_nickname, QLatin1String("joins the chat")); -} - -ChatMainWindow::~ChatMainWindow() -{ -} - -void ChatMainWindow::rebuildHistory() -{ - QString history = m_messages.join( QLatin1String("\n" ) ); - chatHistory->setPlainText(history); -} - -void ChatMainWindow::messageSlot(const QString &nickname, const QString &text) -{ - QString msg( QLatin1String("<%1> %2") ); - msg = msg.arg(nickname, text); - m_messages.append(msg); - - if (m_messages.count() > 100) - m_messages.removeFirst(); - rebuildHistory(); -} - -void ChatMainWindow::actionSlot(const QString &nickname, const QString &text) -{ - QString msg( QLatin1String("* %1 %2") ); - msg = msg.arg(nickname, text); - m_messages.append(msg); - - if (m_messages.count() > 100) - m_messages.removeFirst(); - rebuildHistory(); -} - -void ChatMainWindow::textChangedSlot(const QString &newText) -{ - sendButton->setEnabled(!newText.isEmpty()); -} - -void ChatMainWindow::sendClickedSlot() -{ - emit message(m_nickname, messageLineEdit->text()); - messageLineEdit->setText(QString()); -} - -void ChatMainWindow::changeNickname() -{ - NicknameDialog dialog(this); - if (dialog.exec() == QDialog::Accepted) { - QString old = m_nickname; - m_nickname = dialog.nickname->text().trimmed(); - emit action(old, QString("is now known as %1").arg(m_nickname)); - } -} - -void ChatMainWindow::aboutQt() -{ - QMessageBox::aboutQt(this); -} - -void ChatMainWindow::exiting() -{ - emit action(m_nickname, QLatin1String("leaves the chat")); -} - -NicknameDialog::NicknameDialog(QWidget *parent) - : QDialog(parent) -{ - setupUi(this); -} - -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - ChatMainWindow chat; - chat.show(); - return app.exec(); -} - -#include "chat.moc" diff --git a/qt/examples/chat.h b/qt/examples/chat.h deleted file mode 100644 index b0e50a35..00000000 --- a/qt/examples/chat.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef CHAT_H -#define CHAT_H - -#include <QtCore/QStringList> -#include <dbus/qdbus.h> -#include "ui_chatmainwindow.h" -#include "ui_chatsetnickname.h" - -class ChatMainWindow: public QMainWindow, Ui::ChatMainWindow -{ - Q_OBJECT - QString m_nickname; - QStringList m_messages; -public: - ChatMainWindow(); - ~ChatMainWindow(); - - void rebuildHistory(); - -signals: - void message(const QString &nickname, const QString &text); - void action(const QString &nickname, const QString &text); - -private slots: - void messageSlot(const QString &nickname, const QString &text); - void actionSlot(const QString &nickname, const QString &text); - void textChangedSlot(const QString &newText); - void sendClickedSlot(); - void changeNickname(); - void aboutQt(); - void exiting(); -}; - -class NicknameDialog: public QDialog, public Ui::NicknameDialog -{ - Q_OBJECT -public: - NicknameDialog(QWidget *parent = 0); -}; - -#endif diff --git a/qt/examples/chatadaptor.cpp b/qt/examples/chatadaptor.cpp deleted file mode 100644 index 525b9aad..00000000 --- a/qt/examples/chatadaptor.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file was generated by dbusidl2cpp version 0.3 - * when processing input file /home/tjmaciei/src/kde4/playground/libs/qt-dbus/examples/com.trolltech.ChatInterface.xml - * - * dbusidl2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved. - * - * This is an auto-generated file. - */ - -#include "chatadaptor.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 ChatInterfaceAdaptor - */ - -ChatInterfaceAdaptor::ChatInterfaceAdaptor(QObject *parent) - : QDBusAbstractAdaptor(parent) -{ - // constructor - setAutoRelaySignals(true); -} - -ChatInterfaceAdaptor::~ChatInterfaceAdaptor() -{ - // destructor -} - - -#include "chatadaptor.moc" diff --git a/qt/examples/chatadaptor.h b/qt/examples/chatadaptor.h deleted file mode 100644 index cbec0120..00000000 --- a/qt/examples/chatadaptor.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file was generated by dbusidl2cpp version 0.3 - * when processing input file /home/tjmaciei/src/kde4/playground/libs/qt-dbus/examples/com.trolltech.ChatInterface.xml - * - * dbusidl2cpp is Copyright (C) 2006 Trolltech AS. All rights reserved. - * - * This is an auto-generated file. - */ - -#ifndef CHATADAPTOR_H_88051142890130 -#define CHATADAPTOR_H_88051142890130 - -#include <QtCore/QObject> -#include <dbus/qdbus.h> -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.trolltech.ChatInterface - */ -class ChatInterfaceAdaptor: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.ChatInterface") -public: - ChatInterfaceAdaptor(QObject *parent); - virtual ~ChatInterfaceAdaptor(); - -public: // PROPERTIES -public slots: // METHODS -signals: // SIGNALS - void action(const QString &nickname, const QString &text); - void message(const QString &nickname, const QString &text); -}; - -#endif diff --git a/qt/examples/chatmainwindow.ui b/qt/examples/chatmainwindow.ui deleted file mode 100644 index 0e4461c3..00000000 --- a/qt/examples/chatmainwindow.ui +++ /dev/null @@ -1,188 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>ChatMainWindow</class> - <widget class="QMainWindow" name="ChatMainWindow" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>600</height> - </rect> - </property> - <property name="windowTitle" > - <string>QtDBus Chat</string> - </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QHBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QTextBrowser" name="chatHistory" > - <property name="acceptDrops" > - <bool>false</bool> - </property> - <property name="toolTip" > - <string>Messages sent and received from other users</string> - </property> - <property name="acceptRichText" > - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="text" > - <string>Message:</string> - </property> - <property name="buddy" > - <cstring>messageLineEdit</cstring> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="messageLineEdit" /> - </item> - <item> - <widget class="QPushButton" name="sendButton" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip" > - <string>Sends a message to other people</string> - </property> - <property name="whatsThis" > - <string/> - </property> - <property name="text" > - <string>Send</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>31</height> - </rect> - </property> - <widget class="QMenu" name="menuQuit" > - <property name="title" > - <string>Help</string> - </property> - <addaction name="actionAboutQt" /> - </widget> - <widget class="QMenu" name="menuFile" > - <property name="title" > - <string>File</string> - </property> - <addaction name="actionChangeNickname" /> - <addaction name="separator" /> - <addaction name="actionQuit" /> - </widget> - <addaction name="menuFile" /> - <addaction name="menuQuit" /> - </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="actionQuit" > - <property name="text" > - <string>Quit</string> - </property> - <property name="shortcut" > - <string>Ctrl+Q</string> - </property> - </action> - <action name="actionAboutQt" > - <property name="icon" > - <iconset/> - </property> - <property name="text" > - <string>About Qt...</string> - </property> - </action> - <action name="actionChangeNickname" > - <property name="text" > - <string>Change nickname...</string> - </property> - <property name="shortcut" > - <string>Ctrl+N</string> - </property> - </action> - </widget> - <pixmapfunction></pixmapfunction> - <tabstops> - <tabstop>chatHistory</tabstop> - <tabstop>messageLineEdit</tabstop> - <tabstop>sendButton</tabstop> - </tabstops> - <resources/> - <connections> - <connection> - <sender>messageLineEdit</sender> - <signal>returnPressed()</signal> - <receiver>sendButton</receiver> - <slot>animateClick()</slot> - <hints> - <hint type="sourcelabel" > - <x>299</x> - <y>554</y> - </hint> - <hint type="destinationlabel" > - <x>744</x> - <y>551</y> - </hint> - </hints> - </connection> - <connection> - <sender>actionQuit</sender> - <signal>triggered(bool)</signal> - <receiver>ChatMainWindow</receiver> - <slot>close()</slot> - <hints> - <hint type="sourcelabel" > - <x>-1</x> - <y>-1</y> - </hint> - <hint type="destinationlabel" > - <x>399</x> - <y>299</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/qt/examples/chatsetnickname.ui b/qt/examples/chatsetnickname.ui deleted file mode 100644 index fb9894e0..00000000 --- a/qt/examples/chatsetnickname.ui +++ /dev/null @@ -1,149 +0,0 @@ -<ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> - <class>NicknameDialog</class> - <widget class="QDialog" name="NicknameDialog" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>396</width> - <height>105</height> - </rect> - </property> - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="windowTitle" > - <string>Set nickname</string> - </property> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>9</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <layout class="QVBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <widget class="QLabel" name="label" > - <property name="sizePolicy" > - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>1</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text" > - <string>New nickname:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="nickname" /> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" > - <property name="margin" > - <number>0</number> - </property> - <property name="spacing" > - <number>6</number> - </property> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>131</width> - <height>31</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="okButton" > - <property name="text" > - <string>OK</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="cancelButton" > - <property name="text" > - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <spacer> - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" > - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <pixmapfunction></pixmapfunction> - <resources/> - <connections> - <connection> - <sender>okButton</sender> - <signal>clicked()</signal> - <receiver>NicknameDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel" > - <x>278</x> - <y>253</y> - </hint> - <hint type="destinationlabel" > - <x>96</x> - <y>254</y> - </hint> - </hints> - </connection> - <connection> - <sender>cancelButton</sender> - <signal>clicked()</signal> - <receiver>NicknameDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel" > - <x>369</x> - <y>253</y> - </hint> - <hint type="destinationlabel" > - <x>179</x> - <y>282</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/qt/examples/com.trolltech.ChatInterface.xml b/qt/examples/com.trolltech.ChatInterface.xml deleted file mode 100644 index 666a9e35..00000000 --- a/qt/examples/com.trolltech.ChatInterface.xml +++ /dev/null @@ -1,15 +0,0 @@ -<!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.trolltech.ChatInterface"> - <signal name="message"> - <arg name="nickname" type="s" direction="out"/> - <arg name="text" type="s" direction="out"/> - </signal> - <signal name="action"> - <arg name="nickname" type="s" direction="out"/> - <arg name="text" type="s" direction="out"/> - </signal> - </interface> -</node> - diff --git a/qt/examples/complexping.cpp b/qt/examples/complexping.cpp deleted file mode 100644 index b977edfc..00000000 --- a/qt/examples/complexping.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <stdio.h> - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> -#include <QtCore/QFile> -#include <QtCore/QDebug> -#include <QtCore/QProcess> - -#include "ping-common.h" -#include "complexping.h" - -void Ping::start(const QString &name, const QString &oldValue, const QString &newValue) -{ - Q_UNUSED(oldValue); - - if (name != SERVICE_NAME || newValue.isEmpty()) - return; - - // open stdin for reading - qstdin.open(stdin, QIODevice::ReadOnly); - - // find our remote - iface = QDBus::sessionBus().findInterface(SERVICE_NAME, "/"); - if (!iface) { - fprintf(stderr, "%s\n", - qPrintable(QDBus::sessionBus().lastError().message())); - QCoreApplication::instance()->quit(); - } - - connect(iface, SIGNAL(aboutToQuit()), QCoreApplication::instance(), SLOT(quit())); - - while (true) { - qDebug() << "Ready"; - - QString line = QString::fromLocal8Bit(qstdin.readLine()).trimmed(); - if (line.isEmpty()) { - iface->call("quit"); - return; - } else if (line == "value") { - QVariant reply = iface->property("value"); - if (!reply.isNull()) - qDebug() << "value =" << reply.toString(); - } else if (line.startsWith("value=")) { - iface->setProperty("value", line.mid(6)); - } else { - QDBusReply<QVariant> reply = iface->call("query", line); - if (reply.isSuccess()) - qDebug() << "Reply was:" << reply.value(); - } - - if (iface->lastError().isValid()) - fprintf(stderr, "Call failed: %s\n", qPrintable(iface->lastError().message())); - } -} - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - Ping ping; - ping.connect(QDBus::sessionBus().busService(), - SIGNAL(nameOwnerChanged(QString,QString,QString)), - SLOT(start(QString,QString,QString))); - - QProcess pong; - pong.start("./complexpong"); - - app.exec(); -} - -#include "complexping.moc" diff --git a/qt/examples/complexping.h b/qt/examples/complexping.h deleted file mode 100644 index 4332ef8a..00000000 --- a/qt/examples/complexping.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef COMPLEXPING_H -#define COMPLEXPING_H - -#include <QtCore/QObject> - -class Ping: public QObject -{ - Q_OBJECT -public slots: - void start(const QString &, const QString &, const QString &); -public: - QFile qstdin; - QDBusInterface *iface; -}; - -#endif diff --git a/qt/examples/complexpong.cpp b/qt/examples/complexpong.cpp deleted file mode 100644 index ff767407..00000000 --- a/qt/examples/complexpong.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <stdio.h> -#include <stdlib.h> - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> -#include <QtCore/QTimer> - -#include "ping-common.h" -#include "complexpong.h" - -// the property -QString Pong::value() const -{ - return m_value; -} - -void Pong::setValue(const QString &newValue) -{ - m_value = newValue; -} - -void Pong::quit() -{ - QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit())); -} - -QVariant Pong::query(const QString &query) -{ - QString q = query.toLower(); - if (q == "hello") - return "World"; - if (q == "ping") - return "Pong"; - if (q == "the answer to life, the universe and everything") - return 42; - if (q.indexOf("unladen swallow") != -1) { - if (q.indexOf("european") != -1) - return 11.0; - return QByteArray("african or european?"); - } - - return "Sorry, I don't know the answer"; -} - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QDBusBusService *bus = QDBus::sessionBus().busService(); - - QObject obj; - Pong *pong = new Pong(&obj); - pong->connect(&app, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit())); - pong->setProperty("value", "initial value"); - QDBus::sessionBus().registerObject("/", &obj); - - if (bus->requestName(SERVICE_NAME, QDBusBusService::AllowReplacingName) != - QDBusBusService::PrimaryOwnerReply) - exit(1); - - app.exec(); - return 0; -} - -#include "complexpong.moc" diff --git a/qt/examples/complexpong.h b/qt/examples/complexpong.h deleted file mode 100644 index c6ad2dbb..00000000 --- a/qt/examples/complexpong.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef COMPLEXPONG_H -#define COMPLEXPONG_H - -#include <QtCore/QObject> - -class Pong: public QDBusAbstractAdaptor -{ - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "com.trolltech.QtDBus.ComplexPong.Pong") - Q_PROPERTY(QString value READ value WRITE setValue) -public: - QString m_value; - QString value() const; - void setValue(const QString &newValue); - - Pong(QObject *obj) : QDBusAbstractAdaptor(obj) - { } -signals: - void aboutToQuit(); -public slots: - QVariant query(const QString &query); - Q_ASYNC void quit(); -}; - -#endif diff --git a/qt/examples/hello.cpp b/qt/examples/hello.cpp deleted file mode 100644 index a287bcb0..00000000 --- a/qt/examples/hello.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <stdio.h> - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - printf("Hello, World\n"); - return 0; -} diff --git a/qt/examples/listnames.cpp b/qt/examples/listnames.cpp deleted file mode 100644 index 27703f5a..00000000 --- a/qt/examples/listnames.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> -#include <QtCore/QStringList> - -void method1() -{ - QDBusReply<QStringList> reply = QDBus::sessionBus().busService()->listNames(); - if (reply.isError()) { - qDebug() << "Error:" << reply.error().message(); - exit(1); - } - foreach (QString name, reply.value()) - qDebug() << name; -} - -void method2() -{ - QDBusInterface *dbus_iface; - QDBusConnection &bus = QDBus::sessionBus(); - dbus_iface = bus.findInterface("org.freedesktop.DBus", "/org/freedesktop/DBus", - "org.freedesktop.DBus"); - qDebug() << dbus_iface->call("ListNames").first(); -} - -void method3() -{ - qDebug() << QDBus::sessionBus().busService()->listNames().value(); -} - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - method1(); - method2(); - method3(); - - return 0; -} diff --git a/qt/examples/ping-common.h b/qt/examples/ping-common.h deleted file mode 100644 index 1870275d..00000000 --- a/qt/examples/ping-common.h +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#define SERVICE_NAME "com.trolltech.QtDBus.PingExample" diff --git a/qt/examples/ping.cpp b/qt/examples/ping.cpp deleted file mode 100644 index ffa53a42..00000000 --- a/qt/examples/ping.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <stdio.h> - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> - -#include "ping-common.h" - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QDBusInterface *iface = QDBus::sessionBus().findInterface(SERVICE_NAME, "/"); - if (iface) { - QDBusReply<QString> reply = iface->call("ping", argc > 1 ? argv[1] : ""); - if (reply.isSuccess()) { - printf("Reply was: %s\n", qPrintable(reply.value())); - return 0; - } - - fprintf(stderr, "Call failed: %s\n", qPrintable(reply.error().message())); - return 1; - } - - fprintf(stderr, "%s\n", - qPrintable(QDBus::sessionBus().lastError().message())); - return 1; -} diff --git a/qt/examples/pong.cpp b/qt/examples/pong.cpp deleted file mode 100644 index b85f1f0c..00000000 --- a/qt/examples/pong.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include <stdio.h> -#include <stdlib.h> - -#include <dbus/qdbus.h> -#include <QtCore/QCoreApplication> -#include <QtCore/QTimer> - -#include "ping-common.h" -#include "pong.h" - -QString Pong::ping(const QString &arg) -{ - QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit())); - return QString("ping(\"%1\") got called").arg(arg); -} - -int main(int argc, char **argv) -{ - QCoreApplication app(argc, argv); - - QDBusBusService *bus = QDBus::sessionBus().busService(); - if (bus->requestName(SERVICE_NAME, QDBusBusService::AllowReplacingName) != - QDBusBusService::PrimaryOwnerReply) - exit(1); - - Pong pong; - QDBus::sessionBus().registerObject("/", &pong, QDBusConnection::ExportSlots); - - app.exec(); - return 0; -} - -#include "pong.moc" diff --git a/qt/examples/pong.h b/qt/examples/pong.h deleted file mode 100644 index de89598f..00000000 --- a/qt/examples/pong.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- C++ -*- - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef PONG_H -#define PONG_H - -#include <QtCore/QObject> - -class Pong: public QObject -{ - Q_OBJECT -public slots: - Q_SCRIPTABLE QString ping(const QString &arg); -}; - -#endif |