|
1 /* |
|
2 * Copyright (c) 2010 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: QT Service application the implements support for |
|
15 * starting Java applications using "javaapp:" QUrl |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <QList> |
|
20 #include <QUrl> |
|
21 #include <xqappmgr.h> |
|
22 #include <xqaiwrequest.h> |
|
23 |
|
24 #include "logger.h" |
|
25 #include "requestapp.h" |
|
26 |
|
27 |
|
28 RequestApp::RequestApp(int &argc, char **argv) : QApplication(argc, argv) |
|
29 { |
|
30 LOG(EJavaQtServiceApp, EInfo, "RequestApp (QApplication) constructor called"); |
|
31 } |
|
32 |
|
33 void RequestApp::sendRequest() |
|
34 { |
|
35 QString uriString = arguments().at(1); |
|
36 std::wstring stdWStrUri = uriString.toStdWString(); |
|
37 LOG1(EJavaQtServiceApp, EInfo, |
|
38 "SLOT RequestApp::sendRequest called with Uri %S", stdWStrUri.c_str()); |
|
39 |
|
40 QUrl uri(uriString); |
|
41 XQApplicationManager appMgr; |
|
42 XQAiwRequest *request = appMgr.create(uri); |
|
43 if (!request) |
|
44 { |
|
45 // No handlers for the URI |
|
46 ELOG1(EJavaQtServiceApp, |
|
47 "RequestApp::sendRequest No QtHighway service found for URI: %S", |
|
48 stdWStrUri.c_str()); |
|
49 exit(KErrNotFound); |
|
50 return; |
|
51 } |
|
52 |
|
53 // Set function parameters |
|
54 QList<QVariant> args; |
|
55 args << uri.toString(); |
|
56 request->setArguments(args); |
|
57 |
|
58 // Send the request |
|
59 if (!request->send()) |
|
60 { |
|
61 // Request failed. |
|
62 int error = request->lastError(); |
|
63 ELOG2(EJavaQtServiceApp, |
|
64 "RequestApp::sendRequest QtHighway request failed " |
|
65 "with err %d, URI was %S", |
|
66 error, stdWStrUri.c_str()); |
|
67 delete request; |
|
68 exit(KErrCompletion); |
|
69 return; |
|
70 } |
|
71 |
|
72 delete request; |
|
73 |
|
74 exit(KErrNone); // Exit with OK status |
|
75 } |
|
76 |
|
77 |
|
78 |