39
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <xqaiwrequest.h>
|
|
19 |
#include <QGraphicsLinearLayout>
|
|
20 |
#include <hbpushbutton.h>
|
|
21 |
#include <hblineedit.h>
|
|
22 |
#include <hblabel.h>
|
|
23 |
#include <hbaction.h>
|
|
24 |
#include <hbinputdialog.h>
|
|
25 |
#include <qdebug>
|
|
26 |
#include <vcxmyvideosdefs.h>
|
|
27 |
#include <xqaiwdecl.h>
|
|
28 |
#include "videoservicestestappview.h"
|
|
29 |
|
|
30 |
VideoServicesTestAppView::VideoServicesTestAppView(QGraphicsItem *parent) :
|
|
31 |
HbView(parent),
|
|
32 |
mReq(0),
|
|
33 |
mResultEdit(0),
|
|
34 |
mErrorCodeEdit(0),
|
|
35 |
mErrorEdit(0)
|
|
36 |
{
|
|
37 |
qDebug() << "VideoServicesTestAppView::VideoServicesTestAppView";
|
|
38 |
createLayout();
|
|
39 |
}
|
|
40 |
|
|
41 |
|
|
42 |
VideoServicesTestAppView::~VideoServicesTestAppView()
|
|
43 |
{
|
|
44 |
qDebug() << "VideoServicesTestAppView::~VideoServicesTestAppView";
|
|
45 |
delete mReq;
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
void VideoServicesTestAppView::handleOk(const QVariant &result)
|
|
50 |
{
|
|
51 |
qDebug() << "VideoServicesTestAppView::handleOk";
|
|
52 |
|
|
53 |
if (!result.canConvert<QStringList>())
|
|
54 |
{
|
|
55 |
mErrorEdit->setText("Corrupt result");
|
|
56 |
}
|
|
57 |
else
|
|
58 |
{
|
|
59 |
QString text = result.value<QString>();
|
|
60 |
if (text.isEmpty())
|
|
61 |
{
|
|
62 |
text = "No result available in this service";
|
|
63 |
}
|
|
64 |
mResultEdit->setText(text);
|
|
65 |
qDebug() << "VideoServicesTestAppView::handleOk" << ": result=" << text;
|
|
66 |
}
|
|
67 |
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
void VideoServicesTestAppView::handleError(int errorCode, const QString& errorMessage)
|
|
72 |
{
|
|
73 |
qDebug() << "VideoServicesTestAppView::handleError" << ": errorCode=" << errorCode << ", msg:" << errorMessage;
|
|
74 |
mErrorEdit->setText(errorMessage);
|
|
75 |
mErrorCodeEdit->setText(QString::number(errorCode));
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
void VideoServicesTestAppView::createLayout()
|
|
80 |
{
|
|
81 |
qDebug() << "VideoServicesTestAppView::createLayout";
|
|
82 |
|
|
83 |
QGraphicsLinearLayout* layout = new QGraphicsLinearLayout(Qt::Vertical);
|
|
84 |
|
|
85 |
if (layout)
|
|
86 |
{
|
|
87 |
QGraphicsLinearLayout *topLayout = new QGraphicsLinearLayout(Qt::Vertical);
|
|
88 |
|
|
89 |
if (topLayout)
|
|
90 |
{
|
|
91 |
//topLayout->addStretch(5);
|
|
92 |
|
|
93 |
mResultEdit = new HbLineEdit;
|
|
94 |
HbLabel* label = new HbLabel("Result:");
|
|
95 |
if (mResultEdit && label)
|
|
96 |
{
|
|
97 |
topLayout->addItem(label);
|
|
98 |
mResultEdit->setMaxRows(5);
|
|
99 |
topLayout->addItem(mResultEdit);
|
|
100 |
}
|
|
101 |
|
|
102 |
mErrorCodeEdit = new HbLineEdit;
|
|
103 |
label = new HbLabel("Error code:");
|
|
104 |
if (mErrorCodeEdit && label)
|
|
105 |
{
|
|
106 |
topLayout->addItem(label);
|
|
107 |
topLayout->addItem(mErrorCodeEdit);
|
|
108 |
}
|
|
109 |
|
|
110 |
mErrorEdit = new HbLineEdit;
|
|
111 |
label = new HbLabel("Error description:");
|
|
112 |
if (mErrorEdit && label)
|
|
113 |
{
|
|
114 |
topLayout->addItem(label);
|
|
115 |
mErrorEdit->setMaxRows(5);
|
|
116 |
topLayout->addItem(mErrorEdit);
|
|
117 |
}
|
|
118 |
|
|
119 |
layout->addItem(topLayout);
|
|
120 |
//layout->setStretchFactor(topLayout, 5);
|
|
121 |
}
|
|
122 |
|
|
123 |
QGraphicsLinearLayout *bottomLayout = new QGraphicsLinearLayout(Qt::Vertical);
|
|
124 |
|
|
125 |
if (bottomLayout)
|
|
126 |
{
|
66
|
127 |
HbPushButton* button = new HbPushButton("Fetch video OLD (removed)");
|
39
|
128 |
if (button)
|
|
129 |
{
|
|
130 |
connect(button, SIGNAL(clicked()), this, SLOT(fetchVideoDeprecatedNewService()));
|
|
131 |
bottomLayout->addItem(button);
|
|
132 |
}
|
|
133 |
|
|
134 |
button = new HbPushButton("Fetch video NEW IF NEW S");
|
|
135 |
if (button)
|
|
136 |
{
|
|
137 |
connect(button, SIGNAL(clicked()), this, SLOT(fetchVideo()));
|
|
138 |
bottomLayout->addItem(button);
|
|
139 |
}
|
|
140 |
|
66
|
141 |
button = new HbPushButton("Browse \"Captured\" videos OLD(removed)");
|
39
|
142 |
if (button)
|
|
143 |
{
|
|
144 |
connect(button, SIGNAL(clicked()), this, SLOT(browseCapturedVideosDeprecatedNewService()));
|
|
145 |
bottomLayout->addItem(button);
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
button = new HbPushButton("Browse \"Captured\" videos NEW IF");
|
|
150 |
if (button)
|
|
151 |
{
|
|
152 |
connect(button, SIGNAL(clicked()), this, SLOT(browseCapturedVideos()));
|
|
153 |
bottomLayout->addItem(button);
|
|
154 |
}
|
|
155 |
|
|
156 |
layout->addItem(bottomLayout);
|
|
157 |
}
|
|
158 |
|
|
159 |
setLayout(layout); // Takes ownership of layout
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
void VideoServicesTestAppView::fetchVideo()
|
|
165 |
{
|
|
166 |
qDebug() << "VideoServicesTestAppView::fetchVideo START";
|
|
167 |
|
|
168 |
mResultEdit->setText("");
|
|
169 |
mErrorEdit->setText("");
|
|
170 |
mErrorCodeEdit->setText("");
|
|
171 |
|
|
172 |
delete mReq;
|
|
173 |
mReq = 0;
|
66
|
174 |
mReq = mAppMgr.create(XQI_VIDEO_FETCH, XQOP_VIDEO_FETCH, true);
|
39
|
175 |
|
|
176 |
qDebug() << "VideoServicesTestAppView::fetchVideo: mReq=" << mReq;
|
|
177 |
|
|
178 |
if (!mReq)
|
|
179 |
{
|
|
180 |
mErrorEdit->setText("Failed to create REQ");
|
|
181 |
return;
|
|
182 |
}
|
|
183 |
else
|
|
184 |
{
|
|
185 |
connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&)));
|
|
186 |
connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&)));
|
|
187 |
}
|
|
188 |
|
|
189 |
// Set arguments for request (application title)
|
|
190 |
XQRequestInfo info;
|
|
191 |
info.setInfo("WindowTitle", "<NEW IF app_name>");
|
|
192 |
mReq->setInfo(info);
|
|
193 |
|
|
194 |
// Make the request
|
|
195 |
if (!mReq->send())
|
|
196 |
{
|
|
197 |
mErrorEdit->setText("Failed to send REQ");
|
|
198 |
qDebug() << "VideoServicesTestAppView::fetchVideo: XQAiwRequest::send returned false";
|
|
199 |
}
|
41
|
200 |
// req no longer needed, remove it
|
|
201 |
delete mReq;
|
|
202 |
mReq = 0;
|
39
|
203 |
|
|
204 |
qDebug() << "VideoServicesTestAppView::fetchVideo END";
|
|
205 |
}
|
|
206 |
|
|
207 |
|
|
208 |
void VideoServicesTestAppView::browseCapturedVideos()
|
|
209 |
{
|
|
210 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos START";
|
|
211 |
|
|
212 |
mResultEdit->setText("");
|
|
213 |
mErrorEdit->setText("");
|
|
214 |
mErrorCodeEdit->setText("");
|
|
215 |
|
|
216 |
delete mReq;
|
|
217 |
mReq = 0;
|
|
218 |
|
66
|
219 |
//mReq = mAppMgr.create(XQI_VIDEO_BROWSE, XQOP_VIDEO_BROWSE, true);
|
|
220 |
mReq = mAppMgr.create(XQI_VIDEO_BROWSE, "browseVideos(int,int)", true);
|
39
|
221 |
|
|
222 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos: mReq=" << mReq;
|
|
223 |
|
|
224 |
if (!mReq)
|
|
225 |
{
|
|
226 |
mErrorEdit->setText("Failed to create REQ");
|
|
227 |
return;
|
|
228 |
}
|
|
229 |
else
|
|
230 |
{
|
|
231 |
connect(mReq, SIGNAL(requestOk(QVariant)), SLOT(handleOk(QVariant)));
|
|
232 |
connect(mReq, SIGNAL(requestError(int,QString)), SLOT(handleError(int,QString)));
|
|
233 |
}
|
|
234 |
|
|
235 |
// - title
|
|
236 |
XQRequestInfo info;
|
|
237 |
info.setInfo("WindowTitle", "<NEW IF app name>");
|
|
238 |
mReq->setInfo(info);
|
|
239 |
|
|
240 |
HbInputDialog *dialog = new HbInputDialog();
|
|
241 |
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
242 |
dialog->setAdditionalRowVisible(true);
|
|
243 |
dialog->setInputMode(HbInputDialog::IntInput, 0);
|
|
244 |
dialog->setInputMode(HbInputDialog::IntInput, 1);
|
|
245 |
dialog->setPromptText("Enter category", 0);
|
|
246 |
dialog->setPromptText("Enter sort role", 1);
|
66
|
247 |
dialog->setValue(KVcxMvcCategoryIdCaptured, 0);
|
|
248 |
dialog->setValue(XQService::SortTitle, 1);
|
39
|
249 |
dialog->open(this, SLOT(browseCapturedVideosFinished(HbAction *)));
|
|
250 |
|
|
251 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos END";
|
|
252 |
}
|
|
253 |
|
|
254 |
void VideoServicesTestAppView::browseCapturedVideosFinished(HbAction *action)
|
|
255 |
{
|
|
256 |
HbInputDialog *dialog = static_cast<HbInputDialog*>(sender());
|
|
257 |
|
|
258 |
int category = dialog->value(0).toInt();
|
|
259 |
int sortRole = dialog->value(1).toInt();
|
|
260 |
|
|
261 |
if(dialog->actions().first() == action)
|
|
262 |
{
|
|
263 |
// set arguments
|
|
264 |
QList<QVariant> args;
|
|
265 |
args.append(QVariant(category));
|
|
266 |
args.append(QVariant(sortRole));
|
|
267 |
mReq->setArguments(args);
|
|
268 |
|
|
269 |
// Make the request
|
|
270 |
if (!mReq->send())
|
|
271 |
{
|
|
272 |
mErrorEdit->setText("Failed to send REQ");
|
|
273 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideosFinished: XQAiwRequest::send returned false";
|
|
274 |
}
|
41
|
275 |
// req no longer needed, remove it
|
|
276 |
delete mReq;
|
|
277 |
mReq = 0;
|
39
|
278 |
}
|
|
279 |
}
|
|
280 |
|
|
281 |
void VideoServicesTestAppView::fetchVideoDeprecatedNewService()
|
|
282 |
{
|
|
283 |
qDebug() << "VideoServicesTestAppView::fetchVideo START";
|
|
284 |
|
|
285 |
mResultEdit->setText("");
|
|
286 |
mErrorEdit->setText("");
|
|
287 |
mErrorCodeEdit->setText("");
|
|
288 |
|
|
289 |
delete mReq;
|
|
290 |
mReq = 0;
|
|
291 |
mReq = mAppMgr.create("videoplayer", "IVideoFetch", "fetch(QString)", true);
|
|
292 |
|
|
293 |
qDebug() << "VideoServicesTestAppView::fetchVideo: mReq=" << mReq;
|
|
294 |
|
|
295 |
if (!mReq)
|
|
296 |
{
|
|
297 |
mErrorEdit->setText("Failed to create REQ");
|
|
298 |
return;
|
|
299 |
}
|
|
300 |
else
|
|
301 |
{
|
|
302 |
connect(mReq, SIGNAL(requestOk(const QVariant&)), SLOT(handleOk(const QVariant&)));
|
|
303 |
connect(mReq, SIGNAL(requestError(int,const QString&)), SLOT(handleError(int,const QString&)));
|
|
304 |
}
|
|
305 |
|
|
306 |
// Set arguments for request (application title)
|
|
307 |
QList<QVariant> args;
|
|
308 |
args << QVariant(QString("<OLD-IF-NEW-S app_name>"));
|
|
309 |
mReq->setArguments(args);
|
|
310 |
|
|
311 |
// Make the request
|
|
312 |
if (!mReq->send())
|
|
313 |
{
|
|
314 |
mErrorEdit->setText("Failed to send REQ");
|
|
315 |
qDebug() << "VideoServicesTestAppView::fetchVideo: XQAiwRequest::send returned false";
|
|
316 |
}
|
41
|
317 |
// req no longer needed, remove it
|
|
318 |
delete mReq;
|
|
319 |
mReq = 0;
|
39
|
320 |
qDebug() << "VideoServicesTestAppView::fetchVideo END";
|
|
321 |
}
|
|
322 |
|
|
323 |
void VideoServicesTestAppView::browseCapturedVideosDeprecatedNewService()
|
|
324 |
{
|
|
325 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos START";
|
|
326 |
|
|
327 |
mResultEdit->setText("");
|
|
328 |
mErrorEdit->setText("");
|
|
329 |
mErrorCodeEdit->setText("");
|
|
330 |
|
|
331 |
delete mReq;
|
|
332 |
mReq = 0;
|
|
333 |
mReq = mAppMgr.create("videoplayer", "IVideoBrowse", "browseVideos(QString,int,int)", true);
|
|
334 |
|
|
335 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos: mReq=" << mReq;
|
|
336 |
|
|
337 |
if (!mReq)
|
|
338 |
{
|
|
339 |
mErrorEdit->setText("Failed to create REQ");
|
|
340 |
return;
|
|
341 |
}
|
|
342 |
else
|
|
343 |
{
|
|
344 |
connect(mReq, SIGNAL(requestOk(QVariant)), SLOT(handleOk(QVariant)));
|
|
345 |
connect(mReq, SIGNAL(requestError(int,QString)), SLOT(handleError(int,QString)));
|
|
346 |
}
|
|
347 |
|
|
348 |
HbInputDialog *dialog = new HbInputDialog();
|
|
349 |
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
350 |
dialog->setAdditionalRowVisible(true);
|
|
351 |
dialog->setInputMode(HbInputDialog::IntInput, 0);
|
|
352 |
dialog->setInputMode(HbInputDialog::IntInput, 1);
|
|
353 |
dialog->setPromptText("Enter category", 0);
|
|
354 |
dialog->setPromptText("Enter sort role", 1);
|
|
355 |
dialog->setValue(3, 0);
|
|
356 |
dialog->setValue(0, 1);
|
|
357 |
dialog->open(this, SLOT(browseCapturedVideosDeprecatedNewServiceFinished(HbAction *)));
|
|
358 |
|
|
359 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideos END";
|
|
360 |
}
|
|
361 |
|
|
362 |
void VideoServicesTestAppView::browseCapturedVideosDeprecatedNewServiceFinished(HbAction *action)
|
|
363 |
{
|
|
364 |
HbInputDialog *dialog = static_cast<HbInputDialog*>(sender());
|
|
365 |
|
|
366 |
const QString title = "<OLD-IF-NEW-S app name>";
|
|
367 |
|
|
368 |
int category = dialog->value(0).toInt();
|
|
369 |
int sortRole = dialog->value(1).toInt();
|
|
370 |
|
|
371 |
if(dialog->actions().first() == action)
|
|
372 |
{
|
|
373 |
// set arguments
|
|
374 |
QList<QVariant> args;
|
|
375 |
args.append(title);
|
|
376 |
args.append(QVariant(category));
|
|
377 |
args.append(QVariant(sortRole));
|
|
378 |
mReq->setArguments(args);
|
|
379 |
|
|
380 |
// Make the request
|
|
381 |
if (!mReq->send())
|
|
382 |
{
|
|
383 |
mErrorEdit->setText("Failed to send REQ");
|
|
384 |
qDebug() << "VideoServicesTestAppView::browseCapturedVideosFinished: XQAiwRequest::send returned false";
|
|
385 |
}
|
41
|
386 |
// req no longer needed, remove it
|
|
387 |
delete mReq;
|
|
388 |
mReq = 0;
|
39
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
// end of file
|