telutils/dialpad/src/dialpadbluetootheventfilter.cpp
changeset 53 25b8d29b7c59
parent 51 12bc758d6a02
equal deleted inserted replaced
51:12bc758d6a02 53:25b8d29b7c59
    28 
    28 
    29 const int DialpadLongKeyPressTimeOut(1000);
    29 const int DialpadLongKeyPressTimeOut(1000);
    30 const QString BluetoothCharacter("*");
    30 const QString BluetoothCharacter("*");
    31 
    31 
    32 DialpadBluetoothEventFilter::DialpadBluetoothEventFilter(Dialpad* dialpad, QObject* parent) :
    32 DialpadBluetoothEventFilter::DialpadBluetoothEventFilter(Dialpad* dialpad, QObject* parent) :
    33     QObject(parent), mDialpad(dialpad)
    33     QObject(parent), mDialpad(dialpad), mRequest(0)
    34 {
    34 {
    35     PHONE_TRACE;
    35     PHONE_TRACE;
    36     mLongPressTimer = new QTimer(this);
    36     mLongPressTimer = new QTimer(this);
    37     mLongPressTimer->setSingleShot(true);
    37     mLongPressTimer->setSingleShot(true);
    38     connect(mLongPressTimer,SIGNAL(timeout()), this, SLOT(toggleBluetooth()));
    38     connect(mLongPressTimer,SIGNAL(timeout()), this, SLOT(toggleBluetooth()));
    39 }
    39 }
    40 
    40 
    41 DialpadBluetoothEventFilter::~DialpadBluetoothEventFilter()
    41 DialpadBluetoothEventFilter::~DialpadBluetoothEventFilter()
    42 {
    42 {
       
    43     delete mRequest;
       
    44     mRequest = 0;
    43 }
    45 }
    44 
    46 
    45 bool DialpadBluetoothEventFilter::eventFilter(QObject *watched, QEvent *event)
    47 bool DialpadBluetoothEventFilter::eventFilter(QObject *watched, QEvent *event)
    46 {
    48 {
    47     Q_UNUSED(watched)
    49     Q_UNUSED(watched)
    66 void DialpadBluetoothEventFilter::toggleBluetooth()
    68 void DialpadBluetoothEventFilter::toggleBluetooth()
    67 {
    69 {
    68     PHONE_TRACE;
    70     PHONE_TRACE;
    69     mDialpad->editor().setText(QString(""));
    71     mDialpad->editor().setText(QString(""));
    70 #ifdef Q_OS_SYMBIAN
    72 #ifdef Q_OS_SYMBIAN
    71     XQApplicationManager appManager;
    73     if(mRequest == NULL) {
    72     QScopedPointer<XQAiwRequest> request(appManager.create(BluetoothServiceName, BluetoothInterfaceTogglePower,
    74         XQApplicationManager appManager;
    73                                                            BluetoothTogglePower, false));
    75         mRequest = appManager.create(BluetoothServiceName, BluetoothInterfaceTogglePower,
    74     if (request == NULL) {
    76                                                            BluetoothTogglePower, false);
       
    77     }
       
    78     
       
    79     if (mRequest == NULL) {
    75         return;
    80         return;
       
    81     } else {
       
    82         connect(mRequest, SIGNAL(requestOk(const QVariant&)), this, SLOT(requestOk(const QVariant&)));
       
    83         connect(mRequest, SIGNAL(requestError(int, const QString&)), this, SLOT(requestError(int, const QString&)));
    76     }
    84     }
    77     request->send();
    85 
       
    86     mRequest->setSynchronous(false);
       
    87     mRequest->send();
    78 #endif // Q_OS_SYMBIAN
    88 #endif // Q_OS_SYMBIAN
    79 }
    89 }
       
    90 
       
    91 void DialpadBluetoothEventFilter::requestOk(const QVariant& value)
       
    92 {
       
    93     PHONE_TRACE;
       
    94     Q_UNUSED(value);
       
    95     delete mRequest;
       
    96     mRequest = 0;
       
    97 }
       
    98 
       
    99 void DialpadBluetoothEventFilter::requestError(int errorCode, const QString& errorMessage)
       
   100 {
       
   101     Q_UNUSED(errorCode);
       
   102     Q_UNUSED(errorMessage);
       
   103     PHONE_DEBUG2("DialpadBluetoothEventFilter::requestError - errorCode: ", errorCode);
       
   104     PHONE_DEBUG2("DialpadBluetoothEventFilter::requestError - errorMessage: ", errorMessage);
       
   105     delete mRequest;
       
   106     mRequest = 0;
       
   107 }
       
   108