telutils/keysequencerecognitionservice/src/bluetoothkeysequencehandler.cpp
changeset 51 12bc758d6a02
equal deleted inserted replaced
48:78df25012fda 51:12bc758d6a02
       
     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: Implements bluetooth key sequence handling.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <qmobilityglobal.h>
       
    19 #include <btxqserviceapi.h>
       
    20 #include <QRegExp>
       
    21 #ifdef Q_OS_SYMBIAN
       
    22 #include <xqappmgr.h>
       
    23 #endif //Q_OS_SYMBIAN
       
    24 
       
    25 #include "keysequencerecognitionservicedefs.h"
       
    26 #include "keysequencerecognitionservicelog.h"
       
    27 #include "bluetoothkeysequencehandler.h"
       
    28 
       
    29 /*!
       
    30   BluetoothKeySequenceHandler::BluetoothKeySequenceHandler.
       
    31  */
       
    32 BluetoothKeySequenceHandler::BluetoothKeySequenceHandler(QObject* parent) :
       
    33     KeySequenceHandler(parent)
       
    34 {
       
    35     DPRINT_METHODENTRYEXIT;
       
    36     
       
    37     setKeySequenceValidator(QRegExp::escape(KShowBTAddress) + "|" +
       
    38                             QRegExp::escape(KActivateBTTestMode) + "|" +
       
    39                             QRegExp::escape(KToggleBTSSPDebugMode));
       
    40 }
       
    41 
       
    42 /*!
       
    43   BluetoothKeySequenceHandler::~BluetoothKeySequenceHandler.
       
    44  */
       
    45 BluetoothKeySequenceHandler::~BluetoothKeySequenceHandler()
       
    46 {
       
    47     DPRINT_METHODENTRYEXIT;
       
    48 }
       
    49 
       
    50 
       
    51 /*!
       
    52   BluetoothKeySequenceHandler::executeKeySequence.
       
    53  */
       
    54 bool BluetoothKeySequenceHandler::executeKeySequence(
       
    55     const QString &keySequence)
       
    56 {
       
    57     DPRINT_METHODENTRYEXIT;   
       
    58     bool handled = true;
       
    59     
       
    60     if(keySequence == KShowBTAddress) {
       
    61         showBluetoothLocalAddress();
       
    62     } else if(keySequence == KActivateBTTestMode) {
       
    63         activateBluetoothTestMode();
       
    64     } else if(keySequence == KToggleBTSSPDebugMode) {
       
    65         toggleBluetoothDebugMode();
       
    66     } else {
       
    67         handled = false;
       
    68     }
       
    69 
       
    70     return handled;
       
    71 }
       
    72 
       
    73 void BluetoothKeySequenceHandler::showBluetoothLocalAddress()
       
    74 {
       
    75     DPRINT_METHODENTRYEXIT;
       
    76 #ifdef Q_OS_SYMBIAN
       
    77     XQApplicationManager appManager;
       
    78     QScopedPointer<XQAiwRequest> request(appManager.create(BluetoothServiceName, BluetoothInterfaceShowLocalAddress,
       
    79                                                            BluetoothShowLocalAddress, false));
       
    80     if (request == NULL) {
       
    81         return;
       
    82     }
       
    83     request->send();
       
    84 #endif // Q_OS_SYMBIAN	
       
    85 }
       
    86 
       
    87 void BluetoothKeySequenceHandler::activateBluetoothTestMode()
       
    88 {
       
    89     DPRINT_METHODENTRYEXIT;
       
    90 #ifdef Q_OS_SYMBIAN
       
    91     XQApplicationManager appManager;
       
    92     QScopedPointer<XQAiwRequest> request(appManager.create(BluetoothServiceName, BluetoothInterfaceActivateDutMode,
       
    93                                                            BluetoothActivateDutMode, false));
       
    94     if (request == NULL) {
       
    95         return;
       
    96     }
       
    97     request->send();
       
    98 #endif // Q_OS_SYMBIAN		
       
    99 }
       
   100 
       
   101 void BluetoothKeySequenceHandler::toggleBluetoothDebugMode()
       
   102 {
       
   103     DPRINT_METHODENTRYEXIT;
       
   104 #ifdef Q_OS_SYMBIAN
       
   105     XQApplicationManager appManager;
       
   106     QScopedPointer<XQAiwRequest> request(appManager.create(BluetoothServiceName, BluetoothInterfaceToggleSspDebugMode,
       
   107                                                            BluetoothToggleSspDebugMode, false));
       
   108     if (request == NULL) {
       
   109         return;
       
   110     }
       
   111     request->send();
       
   112 #endif // Q_OS_SYMBIAN			
       
   113 }