diff options
author | Andrew Stanley-Jones <andrew.stanley-jones@nokia.com> | 2011-07-13 10:57:30 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-14 07:28:29 +0200 |
commit | e3975f9f51e4988d6fb22d97c5b5365891181dfb (patch) | |
tree | d716d250a35670d1cb97755ec237f06979605ce5 /examples | |
parent | ab95bbefd08356acb3caca32534e52697f5c9306 (diff) |
Add serviceframework examples
Change-Id: If38ed764bf95f5be8e8b5203eec31453b15caed0
Reviewed-on: http://codereview.qt.nokia.com/1549
Reviewed-by: Andrew Stanley-Jones
Diffstat (limited to 'examples')
22 files changed, 1447 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 00000000..7a387c88 --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,11 @@ +TEMPLATE = subdirs +SUBDIRS = \ + serviceframework + +# install +sources.files = README *.pro +sources.path = $$[QT_INSTALL_EXAMPLES] +INSTALLS += sources + +symbian: CONFIG += qt_example +maemo5: CONFIG += qt_example diff --git a/examples/serviceframework/dialer/content/DialButton.qml b/examples/serviceframework/dialer/content/DialButton.qml new file mode 100644 index 00000000..7baae5ac --- /dev/null +++ b/examples/serviceframework/dialer/content/DialButton.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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$ +** +****************************************************************************/ + +import Qt 4.7 + +//Implementation of the dialButton control. +Item { + id: dialButton + width: 25 + height: 25 + property alias buttonText: innerText.text; + property alias color: rectangleButton.color + property color hoverColor: "lightsteelblue" + property color pressColor: "slategray" + signal clicked + + Rectangle { + id: rectangleButton + anchors.fill: parent + radius: 5 + color: "steelblue" + border.width: 3 + border.color: "black" + + Text { + id: innerText + font.pointSize: 20 + anchors.centerIn: parent + } + } + + states: [ + State { + name: "Hovering" + PropertyChanges { + target: rectangleButton + color: hoverColor + } + }, + State { + name: "Pressed" + PropertyChanges { + target: rectangleButton + color: pressColor + } + } + ] + + + transitions: [ + Transition { + from: ""; to: "Hovering" + ColorAnimation { duration: 100 } + }, + Transition { + from: "*"; to: "Pressed" + ColorAnimation { duration: 10 } + } + ] + + MouseArea { + hoverEnabled: true + anchors.fill: dialButton + onEntered: { dialButton.state='Hovering'} + onExited: { dialButton.state=''} + onClicked: { dialButton.clicked();} + onPressed: { dialButton.state="Pressed" } + onReleased: { + if (containsMouse) + dialButton.state="Hovering"; + else + dialButton.state=""; + } + } +} diff --git a/examples/serviceframework/dialer/content/DialScreen.qml b/examples/serviceframework/dialer/content/DialScreen.qml new file mode 100644 index 00000000..46be9ecc --- /dev/null +++ b/examples/serviceframework/dialer/content/DialScreen.qml @@ -0,0 +1,167 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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$ +** +****************************************************************************/ + +import Qt 4.7 + +//Layout of the DialScreen control +//------------------------------------ +//|DialScreen | +//| --------------------- ____ numberPad +//| |dialNumber | / | +//| ---------------------/ _| hangUpButton +//| --------------------/- ------- / | +//| | | | | | |/ | +//| | 1 | 2 | 3 | | | | +//| | | | | | | | +//| ---------------------- | | | +//| | | | | | | | +//| | 4 | 5 | 6 | | | | +//| | | | | ------- | +//| ---------------------- _| callButton +//| | | | | ------- / | +//| | 7 | 8 | 9 | | |/ | +//| | | | | | | | +//| ---------------------- | | | +//| | | | | | | | +//| | * | 0 | # | | | | +//| | | | | | | | +//| ---------------------- ------- | +//| | +//------------------------------------ + +//! [0] +Item { + width: childrenRect.width + height: childrenRect.height + property string dialString + signal dial(string numberToDial) + signal hangup + //! [0] + + Rectangle { + id: dialNumber + height: dialText.height + 5 + width: numberPad.width + anchors.top: parent.top + anchors.left: parent.left + color: "white" + radius: 5 + border.width: 3 + border.color: "black" + + Text { + id: dialText + text: dialString + anchors.centerIn: parent + } + } + + Grid { + id: numberPad + width: childrenRect.width + height: childrenRect.height + anchors.top: dialNumber.bottom + anchors.left: parent.left + anchors.topMargin: 5 + columns: 3 + spacing: 5 + + DialButton { buttonText: "1"; onClicked: { dialString += "1";} } + DialButton { buttonText: "2"; onClicked: { dialString += "2";} } + DialButton { buttonText: "3"; onClicked: { dialString += "3";} } + DialButton { buttonText: "4"; onClicked: { dialString += "4";} } + DialButton { buttonText: "5"; onClicked: { dialString += "5";} } + DialButton { buttonText: "6"; onClicked: { dialString += "6";} } + DialButton { buttonText: "7"; onClicked: { dialString += "7";} } + DialButton { buttonText: "8"; onClicked: { dialString += "8";} } + DialButton { buttonText: "9"; onClicked: { dialString += "9";} } + DialButton { buttonText: "*"; onClicked: { dialString += "*";} } + DialButton { buttonText: "0"; onClicked: { dialString += "0";} } + DialButton { buttonText: "#"; onClicked: { dialString += "#";} } + } + + //! [1] + DialButton { + id: hangUpButton + height: { (numberPad.height / 2) - 2 } + width: 50 + anchors.top: numberPad.top + anchors.left: numberPad.right + anchors.leftMargin: 5 + hoverColor: "red" + color: "crimson" + onClicked: { + dialString = "" + hangup() + } + //! [1] + Image { + anchors.centerIn: parent + source: "hangup.png" + transformOrigin: "Center" + } + } + + //! [2] + DialButton { + id: callButton + width: 50 + height: {(numberPad.height/2) -2} + anchors.top: hangUpButton.bottom + anchors.left: numberPad.right + anchors.leftMargin: 5 + anchors.topMargin: 4 + color: "mediumseagreen" + hoverColor: "lightgreen" + onClicked: { + if (dialString != "") { + dial(dialString) + dialString = "" + } + } + //! [2] + + Image { + anchors.centerIn: parent + source: "call.png" + transformOrigin: "Center" + } + } +} diff --git a/examples/serviceframework/dialer/content/DialerList.qml b/examples/serviceframework/dialer/content/DialerList.qml new file mode 100644 index 00000000..b9ccd5f3 --- /dev/null +++ b/examples/serviceframework/dialer/content/DialerList.qml @@ -0,0 +1,182 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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$ +** +****************************************************************************/ + +import Qt 4.7 +// ![4] +import QtMobility.serviceframework 1.1 +// ![4] + +//Layout of the ServiceList control +//--------------------------------- +//|ServiceList | +//| ----------------------------- | +//| |title | | +//| ----------------------------- | +//| ----------------------------- | +//| |listFrame | | +//| |-------------------------- | | +//| ||serviceListView | | | +//| ||- listItem | | | +//| ||- listItem | | | +//| ||- listItem | | | +//| |---------------------------| | +//| ----------------------------- | +//--------------------------------- + +Rectangle { + id: serviceListControl + property variant dialService: 0 + signal signalSelected + property bool allowselction: true + property bool nohighlightlistitem : true + + Text { + id: title + width: parent.width + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: 5 + anchors.leftMargin: 5 + text: "<b>Select dial service:</b>" + } + + //! [1] + Component { + id: delegate + //! [1] + //Rectangle item to draw a list view item + //This includes 2 line of text: + // ------------------------------------------ + // |Service: LandDialer (1.0) | + // |Interface: com.nokia.qt.examples Dialer | + // ------------------------------------------ + Rectangle { + id: listItem + width: serviceListView.width-20 + height: serviceItemInfo.height + serviceItemInterfaceName.height + border.color: "black" + border.width: 1 + opacity: 0.6 + + //! [2] + MouseArea { + id: listItemMouseRegion + anchors.fill: parent + onClicked: { + if (serviceListControl.allowselction) { + if (serviceListControl.nohighlightlistitem) { + serviceListView.highlight = highlight + serviceListControl.nohighlightlistitem = false; + } + serviceListView.currentIndex = index; + dialService = model.modelData; + signalSelected() + } + } + } + + Text { + id: serviceItemInfo + anchors.top: parent.top + anchors.left: parent.left + anchors.topMargin: 5 + anchors.leftMargin: 3 + text: " <b>Service:</b> " + serviceName + " (" + + majorVersion + "." + + minorVersion + ")" + } + + Text { + id: serviceItemInterfaceName + anchors.top: serviceItemInfo.bottom + anchors.left: parent.left + anchors.topMargin: 2 + anchors.leftMargin: 3 + text: " <b>Interface:</b> " + interfaceName; + } + //! [2] + } + } + + //! [3] + Component { + id: highlight + + Rectangle { + width: childrenRect.width + border.color: "black"; border.width: 2 + height: 30 + color : "lightsteelblue" + gradient: Gradient { + GradientStop {position: 0.0; color: "steelblue"} + GradientStop {position: 0.5; color: "lightsteelblue"} + GradientStop {position: 1.0; color: "steelblue"} + } + } + } + //! [3] + + //! [0] + ListView { + id: serviceListView + height: 50 + width: mainPage.width-10 + anchors.top: title.bottom + anchors.left: title.left + anchors.topMargin: 0 + anchors.leftMargin: 5 + anchors.rightMargin: 5 + model: dialerServiceList.services + opacity: 1 + delegate: delegate +// currentIndex: -1 +// clip: true + } + //! [0] + + //! [5] + ServiceList { + id: dialerServiceList + interfaceName: "com.nokia.qt.examples.Dialer" + majorVersion: 1 + minorVersion: 0 + } + //! [5] +} diff --git a/examples/serviceframework/dialer/content/call.png b/examples/serviceframework/dialer/content/call.png Binary files differnew file mode 100644 index 00000000..cee34a70 --- /dev/null +++ b/examples/serviceframework/dialer/content/call.png diff --git a/examples/serviceframework/dialer/content/hangup.png b/examples/serviceframework/dialer/content/hangup.png Binary files differnew file mode 100644 index 00000000..6c464bda --- /dev/null +++ b/examples/serviceframework/dialer/content/hangup.png diff --git a/examples/serviceframework/dialer/content/qmldir b/examples/serviceframework/dialer/content/qmldir new file mode 100644 index 00000000..97908f73 --- /dev/null +++ b/examples/serviceframework/dialer/content/qmldir @@ -0,0 +1,3 @@ +DialButton DialButton.qml +DialerList DialerList.qml +DialScreen DialScreen.qml diff --git a/examples/serviceframework/dialer/dialer.pro b/examples/serviceframework/dialer/dialer.pro new file mode 100644 index 00000000..4499eba8 --- /dev/null +++ b/examples/serviceframework/dialer/dialer.pro @@ -0,0 +1,41 @@ +QT = core serviceframework declarative qtquick1 +win32: CONFIG += console +mac:CONFIG -= app_bundle + +SOURCES += main.cpp + +RESOURCES += dialer.qrc + +OTHER_FILES += \ +content/DialButton.qml \ +content/DialScreen.qml \ +content/DialerList.qml \ +dialer.qml + + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframework/dialer +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dialer.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframework/dialer +INSTALLS += target sources + +symbian: CONFIG += qt_example +maemo5: CONFIG += qt_example + +symbian*: { + addFiles.sources = remotedialerservice.xml + addFiles.path = /private/2002AC7F/import/ + DEPLOYMENT += addFiles +} +else { + DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\" +} + + +symbian { + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 +} + +# Please do not modify the following two lines. Required for deployment. +include(qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() diff --git a/examples/serviceframework/dialer/dialer.qml b/examples/serviceframework/dialer/dialer.qml new file mode 100644 index 00000000..9d02b615 --- /dev/null +++ b/examples/serviceframework/dialer/dialer.qml @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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$ +** +****************************************************************************/ + +import Qt 4.7 +import QtMobility.serviceframework 1.1 +import com.nokia.components 1.0 +import SPhone 1.0 +import SPhoneLib.JsonDB 1.0 +import "content-sfw-dialer" + + +//Layout of the mainPage +//---------------------------------------------- ____ mainPage +//| ------------------- ---------------------- | / +//| | dialerList | | dialScreen | |/ +//| | | | | | +//| | | | | | +//| | | | | | +//| ------------------- | | | +//| ------------------- | | | +//| | serviceDetails | | | | +//| ------------------- | | | +//| | | | +//| | | | +//| | | | +//| | | | +//| ------------------- | | | +//| | status | | | | +//| ------------------- ---------------------- | +//---------------------------------------------- + + +Rectangle { + id: mainPage + color: "white" + + property variant dialerObject: 0 + width: 240 + height: 380 + + DialerList { + id: dialerList + height: parent.height - dialScreen.height - 10 + width: childrenRect.width-5 + anchors.top: dialScreen.bottom + anchors.left: parent.left + anchors.topMargin: 5 + anchors.leftMargin: 5 + anchors.rightMargin: 5 + radius: 5 + color: "steelblue" + border.color: "black" + border.width: 3 + gradient: + Gradient { + GradientStop { + position: 0.0 + color: "lightsteelblue" + } + + GradientStop { + position: 1.0 + color: "steelblue" + } + } + onSignalSelected: { serviceSelected(); } + } + + function serviceSelected() + { + dialerObject = dialerList.dialService.serviceObject + + serviceDetails.text = "Selected dial service:" + "\n " + + dialerList.dialService.serviceName + + " (" + dialerList.dialService.majorVersion + + "." + dialerList.dialService.minorVersion + ")"; + } + + Text { + id: serviceDetails + text: "Service:" + width: parent.width - dialScreen.width + anchors.topMargin: 5 + anchors.leftMargin: 5 + anchors.rightMargin: 5; + anchors.left: dialScreen.right + anchors.top: parent.top + wrapMode: "WrapAtWordBoundaryOrAnywhere" + } + + Text { + id: status + width: serviceDetails.width + anchors.top: serviceDetails.bottom + anchors.left: dialScreen.right + anchors.leftMargin: 5 + wrapMode: "Wrap" + } + + Timer { + id: clearStatusTimer + interval: 2000 + running: false + repeat: false + onTriggered: { + status.text = "" + } + } + + //! [0] + DialScreen { + id: dialScreen + property bool activeCall : false + property variant currentDialer: 0; + anchors.topMargin: 5 + anchors.leftMargin: 5 + anchors.rightMargin: 5 + anchors.left: parent.left + anchors.top: parent.top + onDial: { + if (activeCall === false) { + if (dialerList.dialService != 0) { + dialerList.allowselction = false; + var o = dialerObject; + status.text = "Dialing " + numberToDial +"..."; + dialScreen.currentDialer = o; + o.dialNumber(numberToDial); + activeCall = true; + + } + } + } + onHangup: { + if (activeCall === true) { + if (dialScreen.currentDialer != 0) { + dialScreen.currentDialer.hangup(); + } + dialerList.allowselction = true; + status.text = "Hang up"; + } + } + } + //! [0] + + Service { + id: defaultService + interfaceName: "com.nokia.qt.examples.Dialer" + + Component.onCompleted: { + dialerObject = defaultService.serviceObject; + console.log(dialerObject); + } + } + +// ! [1] + Connections { + target: dialerObject + ignoreUnknownSignals: true + + onStateChanged: { + console.log("State changed"); + if (dialScreen.currentDialer.state == 1) { + status.text += "\nRinging"; + } + else if (dialScreen.currentDialer.state == 2) { + status.text += "\nConnected"; + } + else if (dialScreen.currentDialer.state == 0) { + status.text += "\nConnection terminated"; + dialScreen.activeCall = false; + clearStatusTimer.running = true; + } + else if (dialScreen.currentDialer.state == 3) { + status.text += "\nPhone already engaged"; + } + } + } + //! [1] +} + diff --git a/examples/serviceframework/dialer/dialer.qrc b/examples/serviceframework/dialer/dialer.qrc new file mode 100644 index 00000000..37578288 --- /dev/null +++ b/examples/serviceframework/dialer/dialer.qrc @@ -0,0 +1,10 @@ +<RCC> + <qresource prefix="/"> + <file>content/call.png</file> + <file>content/DialButton.qml</file> + <file>content/DialerList.qml</file> + <file>content/DialScreen.qml</file> + <file>content/hangup.png</file> + <file>dialer.qml</file> + </qresource> +</RCC> diff --git a/examples/serviceframework/dialer/icon.png b/examples/serviceframework/dialer/icon.png Binary files differnew file mode 100644 index 00000000..ff37e456 --- /dev/null +++ b/examples/serviceframework/dialer/icon.png diff --git a/examples/serviceframework/dialer/info.json b/examples/serviceframework/dialer/info.json new file mode 100644 index 00000000..1f9df54f --- /dev/null +++ b/examples/serviceframework/dialer/info.json @@ -0,0 +1,12 @@ +{ + "info-version": "1.0", + "dict": { + "Category": "application", + "Runtime": "qml", + "DisplayName": "Test Dialer", + "Subcategory": "internet", + "Version": "1.0", + "Identifier": "com.nokia.qt.examples.dialer", + "MainQML": "declarative-sfw-dialer.qml" + } +} diff --git a/examples/serviceframework/dialer/main.cpp b/examples/serviceframework/dialer/main.cpp new file mode 100644 index 00000000..e38344e0 --- /dev/null +++ b/examples/serviceframework/dialer/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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 <QtGui/QApplication> +#include "qmlapplicationviewer.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QmlApplicationViewer viewer; + viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape); + viewer.setMainQmlFile(QLatin1String("dialer.qml")); + viewer.showExpanded(); + + return app.exec(); +} diff --git a/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.cpp b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.cpp new file mode 100644 index 00000000..11bedd19 --- /dev/null +++ b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -0,0 +1,157 @@ +// checksum 0x28c7 version 0x2000a +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#include "qmlapplicationviewer.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> +#include <QtDeclarative/QDeclarativeComponent> +#include <QtDeclarative/QDeclarativeEngine> +#include <QtDeclarative/QDeclarativeContext> + +#if defined(QMLJSDEBUGGER) +#include <qt_private/qdeclarativedebughelper_p.h> +#endif + +#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER) +#include <jsdebuggeragent.h> +#endif +#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER) +#include <qdeclarativeviewobserver.h> +#endif + +#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK + +#if defined(QMLJSDEBUGGER) + +// Enable debugging before any QDeclarativeEngine is created +struct QmlJsDebuggingEnabler +{ + QmlJsDebuggingEnabler() + { + QDeclarativeDebugHelper::enableDebugging(); + } +}; + +// Execute code in constructor before first QDeclarativeEngine is instantiated +static QmlJsDebuggingEnabler enableDebuggingHelper; + +#endif // QMLJSDEBUGGER + +class QmlApplicationViewerPrivate +{ + QString mainQmlFile; + friend class QmlApplicationViewer; + static QString adjustPath(const QString &path); +}; + +QString QmlApplicationViewerPrivate::adjustPath(const QString &path) +{ +#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/") + path; +#else + const QString pathInShareDir = QCoreApplication::applicationDirPath() + + QLatin1String("/../share/") + + QFileInfo(QCoreApplication::applicationFilePath()).fileName() + + QLatin1Char('/') + path; + if (QFileInfo(pathInShareDir).exists()) + return pathInShareDir; +#endif +#endif + return path; +} + +QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : + QDeclarativeView(parent), + m_d(new QmlApplicationViewerPrivate) +{ + connect(engine(), SIGNAL(quit()), SLOT(close())); + setResizeMode(QDeclarativeView::SizeRootObjectToView); +#if defined(QMLJSDEBUGGER) && !defined(NO_JSDEBUGGER) + new QmlJSDebugger::JSDebuggerAgent(engine()); +#endif +#if defined(QMLJSDEBUGGER) && !defined(NO_QMLOBSERVER) + new QmlJSDebugger::QDeclarativeViewObserver(this, parent); +#endif +} + +QmlApplicationViewer::~QmlApplicationViewer() +{ + delete m_d; +} + +void QmlApplicationViewer::setMainQmlFile(const QString &file) +{ + m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); + setSource(QUrl::fromLocalFile(m_d->mainQmlFile)); +} + +void QmlApplicationViewer::addImportPath(const QString &path) +{ + engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); +} + +void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) +{ +#ifdef Q_OS_SYMBIAN + if (orientation != ScreenOrientationAuto) { +#if defined(ORIENTATIONLOCK) + const CAknAppUiBase::TAppUiOrientation uiOrientation = + (orientation == ScreenOrientationLockPortrait) ? CAknAppUi::EAppUiOrientationPortrait + : CAknAppUi::EAppUiOrientationLandscape; + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); + Q_UNUSED(error) +#else // ORIENTATIONLOCK + qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); +#endif // ORIENTATIONLOCK + } +#elif defined(Q_WS_MAEMO_5) + Qt::WidgetAttribute attribute; + switch (orientation) { + case ScreenOrientationLockPortrait: + attribute = Qt::WA_Maemo5PortraitOrientation; + break; + case ScreenOrientationLockLandscape: + attribute = Qt::WA_Maemo5LandscapeOrientation; + break; + case ScreenOrientationAuto: + default: + attribute = Qt::WA_Maemo5AutoOrientation; + break; + } + setAttribute(attribute, true); +#else // Q_OS_SYMBIAN + Q_UNUSED(orientation); +#endif // Q_OS_SYMBIAN +} + +void QmlApplicationViewer::showExpanded() +{ +#ifdef Q_OS_SYMBIAN + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + showMaximized(); +#else + show(); +#endif +} diff --git a/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.h b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.h new file mode 100644 index 00000000..3a21e826 --- /dev/null +++ b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.h @@ -0,0 +1,39 @@ +// checksum 0x5a59 version 0x2000a +/* + This file was generated by the Qt Quick Application wizard of Qt Creator. + QmlApplicationViewer is a convenience class containing mobile device specific + code such as screen orientation handling. Also QML paths and debugging are + handled here. + It is recommended not to modify this file, since newer versions of Qt Creator + may offer an updated version of it. +*/ + +#ifndef QMLAPPLICATIONVIEWER_H +#define QMLAPPLICATIONVIEWER_H + +#include <QtQuick1/QDeclarativeView> + +class QmlApplicationViewer : public QDeclarativeView +{ + Q_OBJECT + +public: + enum ScreenOrientation { + ScreenOrientationLockPortrait, + ScreenOrientationLockLandscape, + ScreenOrientationAuto + }; + + explicit QmlApplicationViewer(QWidget *parent = 0); + virtual ~QmlApplicationViewer(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + void setOrientation(ScreenOrientation orientation); + void showExpanded(); + +private: + class QmlApplicationViewerPrivate *m_d; +}; + +#endif // QMLAPPLICATIONVIEWER_H diff --git a/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.pri b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.pri new file mode 100644 index 00000000..1c0c7edb --- /dev/null +++ b/examples/serviceframework/dialer/qmlapplicationviewer/qmlapplicationviewer.pri @@ -0,0 +1,154 @@ +# checksum 0x3dc8 version 0x2000a +# This file was generated by the Qt Quick Application wizard of Qt Creator. +# The code below adds the QmlApplicationViewer to the project and handles the +# activation of QML debugging. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +QT += declarative + +SOURCES += $$PWD/qmlapplicationviewer.cpp +HEADERS += $$PWD/qmlapplicationviewer.h +INCLUDEPATH += $$PWD + +defineTest(minQtVersion) { + maj = $$1 + min = $$2 + patch = $$3 + isEqual(QT_MAJOR_VERSION, $$maj) { + isEqual(QT_MINOR_VERSION, $$min) { + isEqual(QT_PATCH_VERSION, $$patch) { + return(true) + } + greaterThan(QT_PATCH_VERSION, $$patch) { + return(true) + } + } + greaterThan(QT_MINOR_VERSION, $$min) { + return(true) + } + } + return(false) +} + +contains(DEFINES, QMLJSDEBUGGER) { + CONFIG(debug, debug|release) { + !minQtVersion(4, 7, 1) { + warning() + warning("Disabling QML debugging:") + warning() + warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.") + warning("This library requires Qt 4.7.1 or newer.") + warning() + DEFINES -= QMLJSDEBUGGER + } else:isEmpty(QMLJSDEBUGGER_PATH) { + warning() + warning("Disabling QML debugging:") + warning() + warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.") + warning("Please specify its location on the qmake command line, eg") + warning(" qmake -r QMLJSDEBUGGER_PATH=$CREATORDIR/share/qtcreator/qmljsdebugger") + warning() + DEFINES -= QMLJSDEBUGGER + } else { + include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) + } + } else { + DEFINES -= QMLJSDEBUGGER + } +} +# This file was generated by an application wizard of Qt Creator. +# The code below handles deployment to Symbian and Maemo, aswell as copying +# of the application data to shadow build directories on desktop. +# It is recommended not to modify this file, since newer versions of Qt Creator +# may offer an updated version of it. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemsources = $${item}.sources + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +symbian { + ICON = $${TARGET}.svg + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -lcone + contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices +} else:win32 { + !isEqual(PWD,$$OUT_PWD) { + copyCommand = @echo Copying application data... + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$eval($${deploymentfolder}.source) + pathSegments = $$split(source, /) + sourceAndTarget = $$MAINPROFILEPWD/$$source $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(pathSegments) + copyCommand += && $(COPY_DIR) $$replace(sourceAndTarget, /, \\) + } + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + installPrefix = /opt/usr + desktopfile.path = /usr/share/applications/hildon + } else { + installPrefix = /usr/local + desktopfile.path = /usr/share/applications + !isEqual(PWD,$$OUT_PWD) { + copyCommand = @echo Copying application data... + for(deploymentfolder, DEPLOYMENTFOLDERS) { + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + copyCommand += && $(MKDIR) $$target + copyCommand += && $(COPY_DIR) $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) $$target + } + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + icon.files = $${TARGET}.png + icon.path = /usr/share/icons/hicolor/64x64/apps + desktopfile.files = $${TARGET}.desktop + target.path = $${installPrefix}/bin + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + export(target.path) + INSTALLS += desktopfile icon target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (TARGET.EPOCHEAPSIZE) +export (TARGET.CAPABILITY) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/examples/serviceframework/remotedialerservice/main.cpp b/examples/serviceframework/remotedialerservice/main.cpp new file mode 100644 index 00000000..f18ca128 --- /dev/null +++ b/examples/serviceframework/remotedialerservice/main.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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 <qremoteserviceregister.h> +#include <QCoreApplication> +#include "remotedialerservice.h" + +int main(int argc, char** argv) +{ + QCoreApplication app(argc, argv); + + //register the unique service + QRemoteServiceRegister* serviceRegister = new QRemoteServiceRegister(); + QRemoteServiceRegister::Entry uniqueEntry = + serviceRegister->createEntry<RemoteDialer>( + "VoipDialer", "com.nokia.qt.examples.Dialer", "1.1"); + uniqueEntry.setInstantiationType(QRemoteServiceRegister::PrivateInstance); + serviceRegister->publishEntries("dialer_service"); + int res = app.exec(); + + delete serviceRegister; + return res; +} diff --git a/examples/serviceframework/remotedialerservice/remotedialerservice.cpp b/examples/serviceframework/remotedialerservice/remotedialerservice.cpp new file mode 100644 index 00000000..c4ab1926 --- /dev/null +++ b/examples/serviceframework/remotedialerservice/remotedialerservice.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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 "remotedialerservice.h" + +RemoteDialer::RemoteDialer(QObject *parent) + : QObject(parent), timerId(0), m_state(DISCONNECTED) +{ + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())+QCoreApplication::applicationPid()); +} + +int RemoteDialer::state() const +{ + return m_state; +} + +void RemoteDialer::dialNumber(const QString& number) +{ + qDebug() << "Dialing Voip number: " << number; + if (m_state != DISCONNECTED) + return; + + if (timerId) + killTimer(timerId); + timerId = startTimer(2000); + m_state = CONNECTING; + emit stateChanged(); + qDebug() << "EMITTED"; +} + +void RemoteDialer::timerEvent(QTimerEvent* /*event*/) +{ + setNewState(); +} + +void RemoteDialer::hangup() +{ + qDebug() << "Hangup on VoipDialer"; + if (timerId) + killTimer(timerId); + timerId = 0; + m_state = DISCONNECTED; + emit stateChanged(); +} + +void RemoteDialer::setNewState() +{ + switch (m_state) { + case DISCONNECTED: + break; + case CONNECTING: + m_state = CONNECTED; + emit stateChanged(); + break; + case CONNECTED: + break; + case ENGAGED: + break; + } +} diff --git a/examples/serviceframework/remotedialerservice/remotedialerservice.h b/examples/serviceframework/remotedialerservice/remotedialerservice.h new file mode 100644 index 00000000..b295b49c --- /dev/null +++ b/examples/serviceframework/remotedialerservice/remotedialerservice.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2010 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 Mobility Components. +** +** $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 REMOTEDIALER_H +#define REMOTEDIALER_H + +#include <qremoteserviceregister.h> +#include <QObject> +#include <QtCore> + +#define DISCONNECTED 0 +#define CONNECTING 1 +#define CONNECTED 2 +#define ENGAGED 3 + +QT_USE_NAMESPACE + +class RemoteDialer : public QObject +{ + Q_OBJECT +public: + RemoteDialer(QObject *parent = 0); + + Q_PROPERTY(int state READ state NOTIFY stateChanged) + int state() const; + +public slots: + void dialNumber(const QString& number); + void hangup(); + +Q_SIGNALS: + void stateChanged(); + +protected: + void timerEvent(QTimerEvent* event); + +private: + void setNewState(); + int timerId; + int m_state; +}; + +#endif diff --git a/examples/serviceframework/remotedialerservice/remotedialerservice.pro b/examples/serviceframework/remotedialerservice/remotedialerservice.pro new file mode 100644 index 00000000..608745f7 --- /dev/null +++ b/examples/serviceframework/remotedialerservice/remotedialerservice.pro @@ -0,0 +1,29 @@ +QT = core serviceframework +win32: CONFIG += console +mac:CONFIG -= app_bundle + +HEADERS += \ + remotedialerservice.h +SOURCES += \ + main.cpp \ + remotedialerservice.cpp + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframework/remotedialer +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS remotedialer.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframework/remotedialer +xml.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframework/xmldata +xml.files = remotedialerservice.xml +INSTALLS += target sources xml + +symbian: CONFIG += qt_example +maemo5: CONFIG += qt_example + +symbian*: { + addFiles.sources = remotedialerservice.xml + addFiles.path = /private/2002AC7F/import/ + DEPLOYMENT += addFiles +} +else { + DEFINES += TESTDATA_DIR=\\\"$$PWD/\\\" +} diff --git a/examples/serviceframework/remotedialerservice/remotedialerservice.xml b/examples/serviceframework/remotedialerservice/remotedialerservice.xml new file mode 100644 index 00000000..8688f2d1 --- /dev/null +++ b/examples/serviceframework/remotedialerservice/remotedialerservice.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<SFW version="1.1"> +<service> + <name>VoipDialer</name> + <ipcaddress>dialer_service</ipcaddress> + <description>Voip Dialer Service</description> + <interface> + <name>com.nokia.qt.examples.Dialer</name> + <version>1.1</version> + <description>VoIP based service implementation of Dialer</description> + </interface> +</service> +</SFW> diff --git a/examples/serviceframework/serviceframework.pro b/examples/serviceframework/serviceframework.pro new file mode 100644 index 00000000..1f25f236 --- /dev/null +++ b/examples/serviceframework/serviceframework.pro @@ -0,0 +1,10 @@ +TEMPLATE = subdirs +SUBDIRS = \ + remotedialerservice \ + dialer + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/statemachine +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS serviceframework.pro README +sources.path = $$[QT_INSTALL_EXAMPLES]/qtsystems/serviceframeeork +INSTALLS += target sources |