From 38be0d13830efd2d98281c645c3a60afe05ffece Mon Sep 17 00:00:00 2001 From: Qt by Nokia Date: Wed, 27 Apr 2011 12:05:43 +0200 Subject: Initial import from the monolithic Qt. This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12 --- examples/dbus/dbus-chat/chat.cpp | 163 ++++++++++++++++++++++ examples/dbus/dbus-chat/chat.h | 81 +++++++++++ examples/dbus/dbus-chat/chat_adaptor.cpp | 74 ++++++++++ examples/dbus/dbus-chat/chat_adaptor.h | 96 +++++++++++++ examples/dbus/dbus-chat/chat_interface.cpp | 64 +++++++++ examples/dbus/dbus-chat/chat_interface.h | 88 ++++++++++++ examples/dbus/dbus-chat/chatmainwindow.ui | 185 +++++++++++++++++++++++++ examples/dbus/dbus-chat/chatsetnickname.ui | 149 ++++++++++++++++++++ examples/dbus/dbus-chat/com.trolltech.chat.xml | 15 ++ examples/dbus/dbus-chat/dbus-chat.pro | 21 +++ 10 files changed, 936 insertions(+) create mode 100644 examples/dbus/dbus-chat/chat.cpp create mode 100644 examples/dbus/dbus-chat/chat.h create mode 100644 examples/dbus/dbus-chat/chat_adaptor.cpp create mode 100644 examples/dbus/dbus-chat/chat_adaptor.h create mode 100644 examples/dbus/dbus-chat/chat_interface.cpp create mode 100644 examples/dbus/dbus-chat/chat_interface.h create mode 100644 examples/dbus/dbus-chat/chatmainwindow.ui create mode 100644 examples/dbus/dbus-chat/chatsetnickname.ui create mode 100644 examples/dbus/dbus-chat/com.trolltech.chat.xml create mode 100644 examples/dbus/dbus-chat/dbus-chat.pro (limited to 'examples/dbus/dbus-chat') diff --git a/examples/dbus/dbus-chat/chat.cpp b/examples/dbus/dbus-chat/chat.cpp new file mode 100644 index 0000000000..5cc12caafa --- /dev/null +++ b/examples/dbus/dbus-chat/chat.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "chat.h" +#include +#include + +#include "chat_adaptor.h" +#include "chat_interface.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 ChatAdaptor(this); + QDBusConnection::sessionBus().registerObject("/", this); + + com::trolltech::chat *iface; + iface = new com::trolltech::chat(QString(), QString(), QDBusConnection::sessionBus(), this); + //connect(iface, SIGNAL(message(QString,QString)), this, SLOT(messageSlot(QString,QString))); + QDBusConnection::sessionBus().connect(QString(), QString(), "com.trolltech.chat", "message", 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()); + QDBusMessage msg = QDBusMessage::createSignal("/", "com.trolltech.chat", "message"); + msg << m_nickname << messageLineEdit->text(); + QDBusConnection::sessionBus().send(msg); + 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); + + if (!QDBusConnection::sessionBus().isConnected()) { + qWarning("Cannot connect to the D-Bus session bus.\n" + "Please check your system settings and try again.\n"); + return 1; + } + + ChatMainWindow chat; + chat.show(); + return app.exec(); +} diff --git a/examples/dbus/dbus-chat/chat.h b/examples/dbus/dbus-chat/chat.h new file mode 100644 index 0000000000..c7d7b6d2a8 --- /dev/null +++ b/examples/dbus/dbus-chat/chat.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef CHAT_H +#define CHAT_H + +#include +#include +#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/examples/dbus/dbus-chat/chat_adaptor.cpp b/examples/dbus/dbus-chat/chat_adaptor.cpp new file mode 100644 index 0000000000..553e6e10cc --- /dev/null +++ b/examples/dbus/dbus-chat/chat_adaptor.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_adaptor.h -a :chat_adaptor.cpp com.trolltech.chat.xml +** +** qdbusxml2cpp is Copyright (C) 2011 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 "chat_adaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class ChatAdaptor + */ + +ChatAdaptor::ChatAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +ChatAdaptor::~ChatAdaptor() +{ + // destructor +} + diff --git a/examples/dbus/dbus-chat/chat_adaptor.h b/examples/dbus/dbus-chat/chat_adaptor.h new file mode 100644 index 0000000000..2558ceb29f --- /dev/null +++ b/examples/dbus/dbus-chat/chat_adaptor.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -a chat_adaptor.h: com.trolltech.chat.xml +** +** qdbusxml2cpp is Copyright (C) 2011 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 CHAT_ADAPTOR_H_1257535021 +#define CHAT_ADAPTOR_H_1257535021 + +#include +#include + +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.trolltech.chat + */ +class ChatAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.trolltech.chat") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + ChatAdaptor(QObject *parent); + virtual ~ChatAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS +Q_SIGNALS: // SIGNALS + void action(const QString &nickname, const QString &text); + void message(const QString &nickname, const QString &text); +}; + +#endif diff --git a/examples/dbus/dbus-chat/chat_interface.cpp b/examples/dbus/dbus-chat/chat_interface.cpp new file mode 100644 index 0000000000..ea472506de --- /dev/null +++ b/examples/dbus/dbus-chat/chat_interface.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -i chat_interface.h -p :chat_interface.cpp com.trolltech.chat.xml +** +** qdbusxml2cpp is Copyright (C) 2011 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 "chat_interface.h" +/* + * Implementation of interface class ComTrolltechChatInterface + */ + +ComTrolltechChatInterface::ComTrolltechChatInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +ComTrolltechChatInterface::~ComTrolltechChatInterface() +{ +} + diff --git a/examples/dbus/dbus-chat/chat_interface.h b/examples/dbus/dbus-chat/chat_interface.h new file mode 100644 index 0000000000..8db1b4f420 --- /dev/null +++ b/examples/dbus/dbus-chat/chat_interface.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +** +** This file was generated by qdbusxml2cpp version 0.7 +** Command line was: qdbusxml2cpp -p chat_interface.h: com.trolltech.chat.xml +** +** qdbusxml2cpp is Copyright (C) 2011 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 CHAT_INTERFACE_H_1257535021 +#define CHAT_INTERFACE_H_1257535021 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface com.trolltech.chat + */ +class ComTrolltechChatInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "com.trolltech.chat"; } + +public: + ComTrolltechChatInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~ComTrolltechChatInterface(); + +public Q_SLOTS: // METHODS +Q_SIGNALS: // SIGNALS + void action(const QString &nickname, const QString &text); + void message(const QString &nickname, const QString &text); +}; + +namespace com { + namespace trolltech { + typedef ::ComTrolltechChatInterface chat; + } +} +#endif diff --git a/examples/dbus/dbus-chat/chatmainwindow.ui b/examples/dbus/dbus-chat/chatmainwindow.ui new file mode 100644 index 0000000000..0616dcb137 --- /dev/null +++ b/examples/dbus/dbus-chat/chatmainwindow.ui @@ -0,0 +1,185 @@ + + + + + ChatMainWindow + + + + 0 + 0 + 800 + 600 + + + + QtDBus Chat + + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + false + + + Messages sent and received from other users + + + true + + + + + + + 0 + + + 6 + + + + + Message: + + + messageLineEdit + + + + + + + + + + + 1 + 0 + 0 + 0 + + + + Sends a message to other people + + + + + + Send + + + + + + + + + + + + + 0 + 0 + 800 + 31 + + + + + Help + + + + + + File + + + + + + + + + + + + Quit + + + Ctrl+Q + + + + + About Qt... + + + + + Change nickname... + + + Ctrl+N + + + + + + chatHistory + messageLineEdit + sendButton + + + + + messageLineEdit + returnPressed() + sendButton + animateClick() + + + 299 + 554 + + + 744 + 551 + + + + + actionQuit + triggered(bool) + ChatMainWindow + close() + + + -1 + -1 + + + 399 + 299 + + + + + diff --git a/examples/dbus/dbus-chat/chatsetnickname.ui b/examples/dbus/dbus-chat/chatsetnickname.ui new file mode 100644 index 0000000000..fb9894e09f --- /dev/null +++ b/examples/dbus/dbus-chat/chatsetnickname.ui @@ -0,0 +1,149 @@ + + + + + NicknameDialog + + + + 0 + 0 + 396 + 105 + + + + + 1 + 1 + 0 + 0 + + + + Set nickname + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + 1 + 1 + 0 + 0 + + + + New nickname: + + + + + + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 131 + 31 + + + + + + + + OK + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + okButton + clicked() + NicknameDialog + accept() + + + 278 + 253 + + + 96 + 254 + + + + + cancelButton + clicked() + NicknameDialog + reject() + + + 369 + 253 + + + 179 + 282 + + + + + diff --git a/examples/dbus/dbus-chat/com.trolltech.chat.xml b/examples/dbus/dbus-chat/com.trolltech.chat.xml new file mode 100644 index 0000000000..618c8c4dcc --- /dev/null +++ b/examples/dbus/dbus-chat/com.trolltech.chat.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/examples/dbus/dbus-chat/dbus-chat.pro b/examples/dbus/dbus-chat/dbus-chat.pro new file mode 100644 index 0000000000..b474ff8c15 --- /dev/null +++ b/examples/dbus/dbus-chat/dbus-chat.pro @@ -0,0 +1,21 @@ +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . +CONFIG += qdbus + +# Input +HEADERS += chat.h chat_adaptor.h chat_interface.h +SOURCES += chat.cpp chat_adaptor.cpp chat_interface.cpp +FORMS += chatmainwindow.ui chatsetnickname.ui + +#DBUS_ADAPTORS += com.trolltech.chat.xml +#DBUS_INTERFACES += com.trolltech.chat.xml + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/chat +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro *.xml +sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/chat +INSTALLS += target sources + +symbian: include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) -- cgit v1.2.3