diff -r 2f8f8080a020 -r ebdbd102c78a phoneengine/parserrecognizer/src/parserrecognizer.cpp --- a/phoneengine/parserrecognizer/src/parserrecognizer.cpp Mon May 03 12:31:11 2010 +0300 +++ b/phoneengine/parserrecognizer/src/parserrecognizer.cpp Fri May 14 15:51:57 2010 +0300 @@ -1,5 +1,5 @@ /*! -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -11,9 +11,8 @@ * * Contributors: * -* Description: Recognizes the parser messages that needs to be notified to the world -* using QtHighway. -* +* Description: Recognizes the parser messages that needs to be notified to +* the world using QtHighway. */ #include @@ -21,12 +20,16 @@ #include "parserrecognizer.h" #include "qtphonelog.h" -ParserRecognizer::ParserRecognizer(QObject* parent) : QObject (parent) +ParserRecognizer::ParserRecognizer(QObject* parent) + : + QObject(parent), + m_currentRequest(0) { } ParserRecognizer::~ParserRecognizer() { + delete m_currentRequest; } void ParserRecognizer::sendMessage(const int message, const int callId) @@ -42,62 +45,83 @@ api = "com.nokia.services.telephony"; method = "activateDeepRestoreFactorySettings()"; break; - + case MEngineMonitor::EPEMessageActivateRfsNormal: api = "com.nokia.services.telephony"; method = "activateNormalRestoreFactorySettings()"; break; - - case MEngineMonitor::EPEMessageActivateWarrantyMode: - api = "com.nokia.services.telephony"; - method = "activateWarrantyMode()"; - break; - + case MEngineMonitor::EPEMessageShowBTDeviceAddress: api = "com.nokia.services.bluetooth"; method = "showBluetoothDeviceAddress()"; break; - + case MEngineMonitor::EPEMessageShowBTLoopback: api = "com.nokia.services.bluetooth"; method = "showBluetoothLoopback()"; break; - + case MEngineMonitor::EPEMessageBTDebugMode: api = "com.nokia.services.bluetooth"; method = "activateBluetoothDebugMode()"; break; - - case MEngineMonitor::EPEMessageShowIMEI: - api = "com.nokia.services.telephony"; - method = "showIMEICode()"; - break; - + case MEngineMonitor::EPEMessageShowVersion: - api = "com.nokia.services.telephony"; + api = "com.nokia.services.devicemanager"; method = "showVersionNumber()"; break; - - case MEngineMonitor::EPEMessageShowWlanMacAddress: - api = "com.nokia.services.wlan"; - method = "showWLANMacAddress()"; - break; - + case MEngineMonitor::EPEMessageSSRequestFailed: api = "com.nokia.services.telephony"; method = "supplementaryServiceRequestFailed()"; break; - + default: recognized = false; break; } - if(recognized) { + if (recognized && (!m_currentRequest)) { PHONE_DEBUG2("ParserRecognizer::sendMessage api:", api); PHONE_DEBUG2("ParserRecognizer::sendMessage method:", method); - XQServiceRequest snd(api, method); - QVariant err; - snd.send(err); + m_currentRequest = new XQServiceRequest(api, method, false); + // Due to a Qt Highway bug in assignment operator implementation we + // need to set request as asynchronous with a setter function. + m_currentRequest->setSynchronous(false); + connect( + m_currentRequest, SIGNAL(requestCompleted(const QVariant &)), + this, SLOT(requestCompleted(const QVariant &))); + connect( + m_currentRequest, SIGNAL(requestError(int)), + this, SLOT(requestError(int))); + + int exceptionAsError = 0; + bool requestOk = false; + QT_TRYCATCH_ERROR( + exceptionAsError, requestOk = m_currentRequest->send()); + if ((0 != exceptionAsError) || (!requestOk)) { + PHONE_DEBUG2("ParserRecognizer::sendMessage exceptionAsError:", + exceptionAsError); + PHONE_DEBUG2("ParserRecognizer::sendMessage requestOk:", + requestOk); + requestCompleted(QVariant()); + } } } + +void ParserRecognizer::requestCompleted(const QVariant &returnValue) +{ + PHONE_DEBUG("ParserRecognizer::requestCompleted"); + Q_UNUSED(returnValue); + + delete m_currentRequest; + m_currentRequest = NULL; +} + +void ParserRecognizer::requestError(int error) +{ + PHONE_DEBUG2("ParserRecognizer::requestError", error); + + delete m_currentRequest; + m_currentRequest = NULL; +}