9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: Recognizes the parser messages that needs to be notified to the world |
14 * Description: Recognizes the parser messages that needs to be notified to |
15 * using QtHighway. |
15 * the world using QtHighway. |
16 * |
|
17 */ |
16 */ |
18 |
17 |
19 #include <xqservicerequest.h> |
18 #include <xqservicerequest.h> |
20 #include <pevirtualengine.h> |
19 #include <pevirtualengine.h> |
21 #include "parserrecognizer.h" |
20 #include "parserrecognizer.h" |
22 #include "qtphonelog.h" |
21 #include "qtphonelog.h" |
23 |
22 |
24 ParserRecognizer::ParserRecognizer(QObject* parent) : QObject (parent) |
23 ParserRecognizer::ParserRecognizer(QObject* parent) |
|
24 : |
|
25 QObject(parent), |
|
26 m_currentRequest(0) |
25 { |
27 { |
26 } |
28 } |
27 |
29 |
28 ParserRecognizer::~ParserRecognizer() |
30 ParserRecognizer::~ParserRecognizer() |
29 { |
31 { |
|
32 delete m_currentRequest; |
30 } |
33 } |
31 |
34 |
32 void ParserRecognizer::sendMessage(const int message, const int callId) |
35 void ParserRecognizer::sendMessage(const int message, const int callId) |
33 { |
36 { |
34 Q_UNUSED(callId); // for now |
37 Q_UNUSED(callId); // for now |
40 switch(message) { |
43 switch(message) { |
41 case MEngineMonitor::EPEMessageActivateRfsDeep: |
44 case MEngineMonitor::EPEMessageActivateRfsDeep: |
42 api = "com.nokia.services.telephony"; |
45 api = "com.nokia.services.telephony"; |
43 method = "activateDeepRestoreFactorySettings()"; |
46 method = "activateDeepRestoreFactorySettings()"; |
44 break; |
47 break; |
45 |
48 |
46 case MEngineMonitor::EPEMessageActivateRfsNormal: |
49 case MEngineMonitor::EPEMessageActivateRfsNormal: |
47 api = "com.nokia.services.telephony"; |
50 api = "com.nokia.services.telephony"; |
48 method = "activateNormalRestoreFactorySettings()"; |
51 method = "activateNormalRestoreFactorySettings()"; |
49 break; |
52 break; |
50 |
53 |
51 case MEngineMonitor::EPEMessageActivateWarrantyMode: |
|
52 api = "com.nokia.services.telephony"; |
|
53 method = "activateWarrantyMode()"; |
|
54 break; |
|
55 |
|
56 case MEngineMonitor::EPEMessageShowBTDeviceAddress: |
54 case MEngineMonitor::EPEMessageShowBTDeviceAddress: |
57 api = "com.nokia.services.bluetooth"; |
55 api = "com.nokia.services.bluetooth"; |
58 method = "showBluetoothDeviceAddress()"; |
56 method = "showBluetoothDeviceAddress()"; |
59 break; |
57 break; |
60 |
58 |
61 case MEngineMonitor::EPEMessageShowBTLoopback: |
59 case MEngineMonitor::EPEMessageShowBTLoopback: |
62 api = "com.nokia.services.bluetooth"; |
60 api = "com.nokia.services.bluetooth"; |
63 method = "showBluetoothLoopback()"; |
61 method = "showBluetoothLoopback()"; |
64 break; |
62 break; |
65 |
63 |
66 case MEngineMonitor::EPEMessageBTDebugMode: |
64 case MEngineMonitor::EPEMessageBTDebugMode: |
67 api = "com.nokia.services.bluetooth"; |
65 api = "com.nokia.services.bluetooth"; |
68 method = "activateBluetoothDebugMode()"; |
66 method = "activateBluetoothDebugMode()"; |
69 break; |
67 break; |
70 |
68 |
71 case MEngineMonitor::EPEMessageShowIMEI: |
|
72 api = "com.nokia.services.telephony"; |
|
73 method = "showIMEICode()"; |
|
74 break; |
|
75 |
|
76 case MEngineMonitor::EPEMessageShowVersion: |
69 case MEngineMonitor::EPEMessageShowVersion: |
77 api = "com.nokia.services.telephony"; |
70 api = "com.nokia.services.devicemanager"; |
78 method = "showVersionNumber()"; |
71 method = "showVersionNumber()"; |
79 break; |
72 break; |
80 |
73 |
81 case MEngineMonitor::EPEMessageShowWlanMacAddress: |
|
82 api = "com.nokia.services.wlan"; |
|
83 method = "showWLANMacAddress()"; |
|
84 break; |
|
85 |
|
86 case MEngineMonitor::EPEMessageSSRequestFailed: |
74 case MEngineMonitor::EPEMessageSSRequestFailed: |
87 api = "com.nokia.services.telephony"; |
75 api = "com.nokia.services.telephony"; |
88 method = "supplementaryServiceRequestFailed()"; |
76 method = "supplementaryServiceRequestFailed()"; |
89 break; |
77 break; |
90 |
78 |
91 default: |
79 default: |
92 recognized = false; |
80 recognized = false; |
93 break; |
81 break; |
94 } |
82 } |
95 |
83 |
96 if(recognized) { |
84 if (recognized && (!m_currentRequest)) { |
97 PHONE_DEBUG2("ParserRecognizer::sendMessage api:", api); |
85 PHONE_DEBUG2("ParserRecognizer::sendMessage api:", api); |
98 PHONE_DEBUG2("ParserRecognizer::sendMessage method:", method); |
86 PHONE_DEBUG2("ParserRecognizer::sendMessage method:", method); |
99 XQServiceRequest snd(api, method); |
87 m_currentRequest = new XQServiceRequest(api, method, false); |
100 QVariant err; |
88 // Due to a Qt Highway bug in assignment operator implementation we |
101 snd.send(err); |
89 // need to set request as asynchronous with a setter function. |
|
90 m_currentRequest->setSynchronous(false); |
|
91 connect( |
|
92 m_currentRequest, SIGNAL(requestCompleted(const QVariant &)), |
|
93 this, SLOT(requestCompleted(const QVariant &))); |
|
94 connect( |
|
95 m_currentRequest, SIGNAL(requestError(int)), |
|
96 this, SLOT(requestError(int))); |
|
97 |
|
98 int exceptionAsError = 0; |
|
99 bool requestOk = false; |
|
100 QT_TRYCATCH_ERROR( |
|
101 exceptionAsError, requestOk = m_currentRequest->send()); |
|
102 if ((0 != exceptionAsError) || (!requestOk)) { |
|
103 PHONE_DEBUG2("ParserRecognizer::sendMessage exceptionAsError:", |
|
104 exceptionAsError); |
|
105 PHONE_DEBUG2("ParserRecognizer::sendMessage requestOk:", |
|
106 requestOk); |
|
107 requestCompleted(QVariant()); |
|
108 } |
102 } |
109 } |
103 } |
110 } |
|
111 |
|
112 void ParserRecognizer::requestCompleted(const QVariant &returnValue) |
|
113 { |
|
114 PHONE_DEBUG("ParserRecognizer::requestCompleted"); |
|
115 Q_UNUSED(returnValue); |
|
116 |
|
117 delete m_currentRequest; |
|
118 m_currentRequest = NULL; |
|
119 } |
|
120 |
|
121 void ParserRecognizer::requestError(int error) |
|
122 { |
|
123 PHONE_DEBUG2("ParserRecognizer::requestError", error); |
|
124 |
|
125 delete m_currentRequest; |
|
126 m_currentRequest = NULL; |
|
127 } |