1 /* |
|
2 # |
|
3 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 # All rights reserved. |
|
5 # |
|
6 # This program is free software: you can redistribute it and/or modify |
|
7 # it under the terms of the GNU Lesser General Public License as published by |
|
8 # the Free Software Foundation, version 2.1 of the License. |
|
9 # |
|
10 # This program is distributed in the hope that it will be useful, |
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 # GNU Lesser General Public License for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU Lesser General Public License |
|
16 # along with this program. If not, |
|
17 # see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
18 # |
|
19 # Description: |
|
20 # |
|
21 */ |
|
22 |
|
23 #include <QDebug> |
|
24 #include <xqservicelog.h> |
|
25 #include <QApplication> |
|
26 #include <QKeyEvent> |
|
27 #include <QLabel> |
|
28 #include <QVBoxLayout> |
|
29 #include <QStackedWidget> |
|
30 #include <QImageReader> |
|
31 #include <QDebug> |
|
32 #include <QTimer> |
|
33 #include <QPushButton> |
|
34 #include <QLineEdit> |
|
35 #include <QDebug> |
|
36 #include <QString> |
|
37 #include <QCheckBox> |
|
38 |
|
39 #include <QListView> |
|
40 |
|
41 #include "testapp3.h" |
|
42 |
|
43 TestApp3::TestApp3( QWidget *parent, Qt::WFlags f ) : QWidget( parent,f ) |
|
44 { |
|
45 qDebug() << "[QTH] [TestApp3] MyServiceTester: START"; |
|
46 QPalette p = qApp->palette(); |
|
47 QColor color(80,20,20); |
|
48 QColor bg(256,20,20); |
|
49 p.setColor(QPalette::Highlight, color.lighter(200)); |
|
50 p.setColor(QPalette::Text, Qt::white); |
|
51 p.setColor(QPalette::Base, bg); |
|
52 p.setColor(QPalette::WindowText, Qt::white); |
|
53 p.setColor(QPalette::Window, bg); |
|
54 p.setColor(QPalette::ButtonText, Qt::white); |
|
55 p.setColor(QPalette::Button, color.lighter(150)); |
|
56 p.setColor(QPalette::Link, QColor(240,40,40)); |
|
57 |
|
58 qApp->setPalette(p); |
|
59 |
|
60 QPushButton *quitButton = new QPushButton(tr("quit")); |
|
61 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); |
|
62 |
|
63 QPushButton *sendButton = new QPushButton(tr("asynsend 10 times")); |
|
64 connect(sendButton, SIGNAL(clicked()), this, SLOT(asyncsend())); |
|
65 |
|
66 label = new QLabel("Test App3"); |
|
67 |
|
68 QVBoxLayout *vl = new QVBoxLayout; |
|
69 vl->setMargin(0); |
|
70 vl->setSpacing(0); |
|
71 |
|
72 vl->addWidget(label); |
|
73 vl->addWidget(sendButton); |
|
74 vl->addWidget(quitButton); |
|
75 |
|
76 setLayout(vl); |
|
77 //showMaximized(); |
|
78 showFullScreen(); |
|
79 |
|
80 i = 0; |
|
81 request = NULL; |
|
82 asyncsend(); |
|
83 qDebug() << "[QTH] [TestApp3] MyServiceTester: END"; |
|
84 } |
|
85 |
|
86 |
|
87 void TestApp3::requestCompleted(const QVariant& data) |
|
88 { |
|
89 i++; |
|
90 qDebug() << "[QTH] [TestApp3] requestCompleted START "; |
|
91 qDebug() << "[QTH] [TestApp3] \t data: " << data.toString() << ", i: " << i; |
|
92 |
|
93 if ( i <= 20 ) |
|
94 { |
|
95 qDebug() << "[QTH] [TestApp3] \t i <= 20 trigger again()"; |
|
96 QString string; |
|
97 string.append("Test app3 -->"); |
|
98 string.append(48+i); |
|
99 string.append("times"); |
|
100 label->setText(string); |
|
101 asyncsend(); |
|
102 } |
|
103 else |
|
104 { |
|
105 /*qDebug() << "[QTH] [MyServiceTester] \t i > 20, setText()"; |
|
106 label->setText("Test app1 Done!"); |
|
107 if(request) |
|
108 { |
|
109 qDebug() << "[QTH] [MyServiceTester] \t \t request != null, delete request"; |
|
110 delete request; |
|
111 request=NULL; |
|
112 }*/ |
|
113 qDebug() << "[QTH] [TestApp3] \t request sent 20 times!!!"; |
|
114 } |
|
115 |
|
116 qDebug() << "[QTH] [TestApp3] requestCompleted STOP"; |
|
117 } |
|
118 |
|
119 |
|
120 |
|
121 void TestApp3::asyncsend() |
|
122 { |
|
123 qDebug() << "[QTH] [TestApp3] asyncsend: START"; |
|
124 |
|
125 QString testString("Test Application 3"); |
|
126 int testInt(112233); |
|
127 |
|
128 QString service("com.nokia.services.testservice.TestService"); |
|
129 QString method("asyncWithParams(QString,int)"); |
|
130 |
|
131 if (!request) |
|
132 { |
|
133 qDebug() << "[QTH] [TestApp3] \t creating request"; |
|
134 request = new XQServiceRequest(service, method, false); |
|
135 qDebug() << "[QTH] [TestApp3] \t connectint signal request->requestCompleted to slot this.requestCompleted"; |
|
136 bool res = connect(request, SIGNAL(requestCompleted(QVariant)), this, SLOT(requestCompleted(QVariant)) ); |
|
137 qDebug() << "[QTH] [TestApp3] \t connect = " << res; |
|
138 *request << testString; |
|
139 *request << testInt; |
|
140 qDebug() << "[QTH] [TestApp3] \t request: " << testString << ", " << testInt; |
|
141 } |
|
142 |
|
143 qDebug() << "[QTH] [TestApp3] \t before request->send()"; |
|
144 bool res = request->send(); |
|
145 qDebug() << "[QTH] [TestApp3] \t after request->send()"; |
|
146 qDebug() << "[QTH] [TestApp3] asyncsend: STOP"; |
|
147 } |
|
148 |
|
149 int main(int argc, char* argv[]) |
|
150 { |
|
151 qInstallMsgHandler(XQSERVICEMESSAGEHANDLER); |
|
152 qDebug() << "[QTH] [TestApp3] main START"; |
|
153 QApplication a(argc, argv); |
|
154 |
|
155 TestApp3* tester = new TestApp3(); |
|
156 qDebug() << "[QTH] [TestApp3] exits"; |
|
157 int rv = a.exec(); |
|
158 delete tester; |
|
159 qDebug() << "[QTH] [TestApp3] main END"; |
|
160 return rv; |
|
161 } |
|
162 |
|