|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #include <QObject> |
|
23 #include <qglobal.h> |
|
24 |
|
25 #include "xqservicelog.h" |
|
26 #include "xqaiwutils.h" |
|
27 #include "xqaiwfiledriver.h" |
|
28 |
|
29 XQAiwFileDriver::XQAiwFileDriver(const QFile &file, const XQAiwInterfaceDescriptor& descriptor, const QString &operation) |
|
30 : XQAiwRequestDriver(), |
|
31 mFile(file.fileName()), |
|
32 mUtilities(NULL) |
|
33 { |
|
34 |
|
35 mErrorMsg = ""; |
|
36 mDescr = descriptor; |
|
37 mOperation = operation; |
|
38 |
|
39 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::XQAiwFileDriver: %s", |
|
40 qPrintable(file.fileName())); |
|
41 |
|
42 } |
|
43 |
|
44 |
|
45 XQAiwFileDriver::~XQAiwFileDriver() |
|
46 { |
|
47 XQSERVICE_DEBUG_PRINT("~XQAiwFileDriver::XQAiwFileDriver"); |
|
48 delete mUtilities; |
|
49 |
|
50 } |
|
51 |
|
52 QAction *XQAiwFileDriver::createAction() |
|
53 { |
|
54 return NULL; // Not supported |
|
55 } |
|
56 |
|
57 void XQAiwFileDriver::setArguments(const QList<QVariant> &arguments) |
|
58 { |
|
59 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::setArguments"); |
|
60 mArguments = arguments; |
|
61 } |
|
62 |
|
63 |
|
64 bool XQAiwFileDriver::send(QVariant& retValue) |
|
65 { |
|
66 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::send"); |
|
67 |
|
68 if (mUtilities == NULL) |
|
69 mUtilities = new XQAiwUtils(); |
|
70 if (mUtilities == NULL) |
|
71 { |
|
72 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::Can not create aiw utils"); |
|
73 return false; |
|
74 } |
|
75 QVariant applicationId = mDescr.property(XQAiwInterfaceDescriptor::ImplementationId); |
|
76 XQSERVICE_DEBUG_PRINT("Application id %x", applicationId.toInt()); |
|
77 |
|
78 // Create space separated command line args |
|
79 QString args = mUtilities->createCmdlineArgs(mArguments); |
|
80 XQSERVICE_DEBUG_PRINT("args %s", qPrintable(args)); |
|
81 |
|
82 mErrorCode = mUtilities->launchApplication(applicationId.toInt(), args); |
|
83 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::errorCode %d", mErrorCode); |
|
84 QVariant ret(!mErrorCode); |
|
85 retValue = ret; |
|
86 return (!mErrorCode); |
|
87 } |
|
88 |
|
89 const QString& XQAiwFileDriver::lastErrorMessage() const |
|
90 { |
|
91 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::lastErrorMessage: %s", qPrintable(mErrorMsg)); |
|
92 return mErrorMsg; |
|
93 } |
|
94 |
|
95 int XQAiwFileDriver::lastError() const |
|
96 { |
|
97 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::lastError %d", mErrorCode); |
|
98 return mErrorCode; |
|
99 } |
|
100 |
|
101 const XQAiwInterfaceDescriptor &XQAiwFileDriver::descriptor() const |
|
102 { |
|
103 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::descriptor"); |
|
104 return mDescr; |
|
105 } |
|
106 |
|
107 void XQAiwFileDriver::setEmbedded(bool embedded) |
|
108 { |
|
109 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::setEmbedded"); |
|
110 mEmbedded = embedded; |
|
111 } |
|
112 bool XQAiwFileDriver::isEmbedded() const |
|
113 { |
|
114 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::isEmbedded"); |
|
115 return mEmbedded; |
|
116 } |
|
117 |
|
118 void XQAiwFileDriver::setOperation(const QString &operation) |
|
119 { |
|
120 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::setOperation"); |
|
121 mOperation = operation; |
|
122 } |
|
123 const QString &XQAiwFileDriver::operation() const |
|
124 { |
|
125 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::operation"); |
|
126 return mOperation; |
|
127 } |
|
128 |
|
129 void XQAiwFileDriver::setSynchronous(bool synchronous) |
|
130 { |
|
131 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::setSynchronous"); |
|
132 mSynchronous = synchronous; |
|
133 } |
|
134 bool XQAiwFileDriver::isSynchronous() const |
|
135 { |
|
136 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::isSynchronous"); |
|
137 return mSynchronous; |
|
138 } |
|
139 |
|
140 void XQAiwFileDriver::handleAsyncResponse(const QVariant& value) |
|
141 { |
|
142 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::handleAsyncResponse"); |
|
143 emit requestOk(value); |
|
144 } |
|
145 |
|
146 void XQAiwFileDriver::handleAsyncError(int err) |
|
147 { |
|
148 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::handleAsyncError"); |
|
149 |
|
150 mErrorCode = err; |
|
151 mErrorMsg = XQAiwUtils::createErrorMessage(mErrorCode, "XQAiwFileDriver"); |
|
152 emit requestError(mErrorCode, mErrorMsg); |
|
153 } |
|
154 |
|
155 void XQAiwFileDriver::setBackground(bool background ) |
|
156 { |
|
157 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::setBackground"); |
|
158 mBackground = background; |
|
159 } |
|
160 bool XQAiwFileDriver::isBackground() const |
|
161 { |
|
162 XQSERVICE_DEBUG_PRINT("XQAiwFileDriver::isBackground"); |
|
163 return mBackground; |
|
164 } |
|
165 |