telutils/keysequencerecognitionservice/src/imeikeysequencehandler.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     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 IMEI key sequence handling.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <qsysteminfo.h>
       
    19 #include <hbmessagebox.h>
       
    20 #include <hbdevicemessagebox.h>
       
    21 #include "imeikeysequencehandler.h"
       
    22 #include "keysequencerecognitionservicedefs.h"
       
    23 #include "keysequencerecognitionservicelog.h"
       
    24 
       
    25 QTM_USE_NAMESPACE
       
    26 
       
    27 /*!
       
    28   ImeiKeySequenceHandler::ImeiKeySequenceHandler.
       
    29  */
       
    30 ImeiKeySequenceHandler::ImeiKeySequenceHandler(
       
    31     QObject* parent)
       
    32     :
       
    33     KeySequenceHandler(parent),
       
    34     m_messageBox(0)
       
    35 {
       
    36     DPRINT_METHODENTRYEXIT;
       
    37     
       
    38     setKeySequenceValidator(QRegExp::escape(KCodeImei));
       
    39 }
       
    40 
       
    41 
       
    42 /*!
       
    43   ImeiKeySequenceHandler::~ImeiKeySequenceHandler.
       
    44  */
       
    45 ImeiKeySequenceHandler::~ImeiKeySequenceHandler()
       
    46 {
       
    47     DPRINT_METHODENTRYEXIT;
       
    48     
       
    49     destroyMessageBox();
       
    50 }
       
    51 
       
    52 
       
    53 /*!
       
    54   ImeiKeySequenceHandler::executeKeySequence.
       
    55  */
       
    56 bool ImeiKeySequenceHandler::executeKeySequence(
       
    57     const QString &keySequence)
       
    58 {
       
    59     DPRINT_METHODENTRYEXIT;
       
    60     
       
    61     bool handled = true;
       
    62     
       
    63     if (KCodeImei == keySequence) {
       
    64         launchImeiDialog();
       
    65     } else {
       
    66         handled = false;
       
    67     }
       
    68     
       
    69     return handled;
       
    70 }
       
    71 
       
    72 
       
    73 /*!
       
    74   ImeiKeySequenceHandler::launchImeiDialog().
       
    75  */
       
    76 void ImeiKeySequenceHandler::launchImeiDialog()
       
    77 {
       
    78     DPRINT_METHODENTRYEXIT;
       
    79     
       
    80     destroyMessageBox();
       
    81     
       
    82     QScopedPointer<QSystemDeviceInfo> deviceInfo(new QSystemDeviceInfo()); 
       
    83     QString serialNumber = deviceInfo->imei();
       
    84     QString serialNumberNoteText = 
       
    85         hbTrId("txt_phone_info_serial_no").arg(serialNumber);
       
    86     m_messageBox = new HbDeviceMessageBox(
       
    87         serialNumberNoteText, 
       
    88         HbMessageBox::MessageTypeInformation);
       
    89     m_messageBox->setTimeout(HbPopup::NoTimeout);
       
    90     
       
    91     QObject::connect(
       
    92         m_messageBox, SIGNAL(aboutToClose()), 
       
    93         this, SLOT(destroyMessageBox()));
       
    94     
       
    95     m_messageBox->show();
       
    96 }
       
    97 
       
    98 
       
    99 /*!
       
   100   ImeiKeySequenceHandler::destroyMessageBox.
       
   101  */
       
   102 void ImeiKeySequenceHandler::destroyMessageBox()
       
   103 {
       
   104     DPRINT_METHODENTRYEXIT;
       
   105     
       
   106     if (m_messageBox) {
       
   107         m_messageBox->deleteLater();
       
   108         m_messageBox = 0;
       
   109     }
       
   110 }