bluetoothengine/btnotif/btdevicedialogplugin/src/btdeviceinfowidget.cpp
changeset 70 f5508c13dfe0
parent 57 5ebadcda06cb
equal deleted inserted replaced
67:16e4b9007960 70:f5508c13dfe0
     1 /*
     1 /*
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3  * All rights reserved.
     3  * All rights reserved.
     4  * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5  * under the terms of "Eclipse Public License v1.0""
     5  * under the terms of "Eclipse Public License v1.0""
     6  * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    18 
    18 
    19 #include "btdeviceinfowidget.h"
    19 #include "btdeviceinfowidget.h"
    20 #include "bluetoothdevicedialogs.h"
    20 #include "bluetoothdevicedialogs.h"
    21 #include "btdevicedialogpluginerrors.h"
    21 #include "btdevicedialogpluginerrors.h"
    22 #include <btuiiconutil.h>
    22 #include <btuiiconutil.h>
       
    23 #include <HbLabel>
    23 
    24 
    24 const int timeOut = 30000;
    25 const int timeOut = 30000;
    25 
    26 
    26 BtDeviceInfoWidget::BtDeviceInfoWidget(const QVariantMap &parameters)
    27 BtDeviceInfoWidget::BtDeviceInfoWidget(const QVariantMap &parameters)
    27 :mLastError(NoError)
    28 :mLastError(NoError)
    84                     QString deviceAddr(parameters.value(QString::number(TBluetoothDeviceDialog::ELocalAddress)).toString());
    85                     QString deviceAddr(parameters.value(QString::number(TBluetoothDeviceDialog::ELocalAddress)).toString());
    85                     mMessageBox->setText(textStr.arg(deviceAddr));
    86                     mMessageBox->setText(textStr.arg(deviceAddr));
    86                     HbIcon icon(QString("qtg_large_bluetooth"));
    87                     HbIcon icon(QString("qtg_large_bluetooth"));
    87                     mMessageBox->setIcon(icon);
    88                     mMessageBox->setIcon(icon);
    88                     mMessageBox->setTimeout(timeOut);
    89                     mMessageBox->setTimeout(timeOut);
    89                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
    90                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
    90                 }break;
    91                 }break;
    91                 //TODO: Remove this piece of code if notifier is used in toggle
    92                 //TODO: Remove this piece of code if notifier is used in toggle
    92                 case TBluetoothDialogParams::EOfflineQuery:
    93                 case TBluetoothDialogParams::EOfflineQuery:
    93                 {
    94                 {
    94                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
    95                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
    96                     mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
    97                     mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
    97                     HbIcon icon(QString("qtg_large_bluetooth"));
    98                     HbIcon icon(QString("qtg_large_bluetooth"));
    98                     mMessageBox->setIcon(icon);
    99                     mMessageBox->setIcon(icon);
    99                     mMessageBox->setTimeout(timeOut);
   100                     mMessageBox->setTimeout(timeOut);
   100                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   101                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   101                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
       
   102                 }break;
   102                 }break;
   103                 
   103                 
   104                 case TBluetoothDialogParams::ERecvFailed:
   104                 case TBluetoothDialogParams::ERecvFailed:
   105                 {
   105                 {
   106                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
   106                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
   109                     mMessageBox->setText(textStr.arg(devName));
   109                     mMessageBox->setText(textStr.arg(devName));
   110                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   110                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   111                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   111                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   112                     mMessageBox->setIcon(icon);
   112                     mMessageBox->setIcon(icon);
   113                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   113                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   114                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
   114                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   115                 }break;
   115                 }break;
   116         
   116         
   117                 case TBluetoothDialogParams::ESendFailed:
   117                 case TBluetoothDialogParams::ESendFailed:
   118                 {
   118                 {
   119                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
   119                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
   122                     mMessageBox->setText(textStr.arg(devName));
   122                     mMessageBox->setText(textStr.arg(devName));
   123                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   123                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   124                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   124                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   125                     mMessageBox->setIcon(icon);
   125                     mMessageBox->setIcon(icon);
   126                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   126                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   127                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
   127                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   128                 }break;
   128                 }break;
   129                 
   129                 
   130                 case TBluetoothDialogParams::EMemoryFull:
   130                 case TBluetoothDialogParams::EMemoryFull:
   131                 {
   131                 {
   132                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   132                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   133                     QString textStr(hbTrId("txt_error_info_memory_full_delete_data"));
   133                     QString textStr(hbTrId("txt_error_info_memory_full_delete_data"));
   134                     QString driveLetter(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveLetter)).toChar());
   134                     QString driveLetter(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveLetter)).toChar());
   135                     QString driveName(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveName)).toString());
   135                     QString driveName(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveName)).toString());
   136                     mMessageBox->setText(textStr.arg(driveLetter).arg(driveName));
   136                     mMessageBox->setText(textStr.arg(driveLetter).arg(driveName));
   137                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   137                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   138                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
   138                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   139                 }break;
   139                 }break;
   140                 
   140                 
   141                 case TBluetoothDialogParams::EDriveNotFound:
   141                 case TBluetoothDialogParams::EDriveNotFound:
   142                 {
   142                 {
   143                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   143                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   144                     mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_memory_card_has_been_r"));
   144                     mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_memory_card_has_been_r"));
   145                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   145                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   146                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
   146                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   147                 }break;
   147                 }break;
   148                 
   148                 
   149                 case TBluetoothDialogParams::EFileMoved:
   149                 case TBluetoothDialogParams::EFileMoved:
   150                 {
   150                 {
   151                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   151                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
   152                     mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_it_may_be_removed_or_d"));
   152                     mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_it_may_be_removed_or_d"));
   153                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   153                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   154                     connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
   154                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   155                 }break;
   155                 }break;
   156                 
   156                 
   157                 case TBluetoothDialogParams::EUnsupportedImages:
   157                 case TBluetoothDialogParams::EUnsupportedImages:
   158                 {
   158                 {
   159                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   159                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
   162                     mMessageBox->setStandardButtons(HbMessageBox::Continue| HbMessageBox::Cancel);
   162                     mMessageBox->setStandardButtons(HbMessageBox::Continue| HbMessageBox::Cancel);
   163                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   163                     int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
   164                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   164                     HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
   165                     mMessageBox->setIcon(icon);
   165                     mMessageBox->setIcon(icon);
   166                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
   166                     mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
       
   167                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
       
   168                 }break;
       
   169                 
       
   170                 case TBluetoothDialogParams::ECannotUseSAPTemporarily:
       
   171                 {
       
   172                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
       
   173                     mMessageBox->setText(hbTrId("txt_bt_info_sim_access_profile_is_used_next_time_t"));
       
   174                     mMessageBox->setDismissPolicy(HbPopup::TapOutside);
       
   175                     mMessageBox->setTimeout(HbPopup::StandardTimeout);
       
   176                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
       
   177                 }break;
       
   178                 
       
   179                 case TBluetoothDialogParams::ENoSimInDevice:
       
   180                 {
       
   181                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
       
   182                     mMessageBox->setHeadingWidget(new HbLabel(hbTrId("txt_bt_title_no_sim_card_in_the_device")));
       
   183                     mMessageBox->setText(hbTrId("txt_bt_info_do_you_still_want_to_enable_sim_access"));
       
   184                     mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
       
   185                     mMessageBox->setDismissPolicy(HbPopup::TapOutside);
       
   186                     mMessageBox->setTimeout(HbPopup::StandardTimeout);
       
   187                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
       
   188                 }break;
       
   189                 
       
   190                 case TBluetoothDialogParams::EUnableToUseSAP:
       
   191                 {
       
   192                     mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
       
   193                     mMessageBox->setHeadingWidget(new HbLabel(hbTrId("txt_bt_title_unable_to_enter_sim_access_profile")));
       
   194                     mMessageBox->setText(hbTrId("txt_bt_info_try_entering_the_sim_access_profile_ag"));
       
   195                     mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
       
   196                     mMessageBox->setDismissPolicy(HbPopup::TapOutside);
       
   197                     mMessageBox->setTimeout(HbPopup::StandardTimeout);
   167                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   198                     connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   168                 }break;
   199                 }break;
   169                     
   200                     
   170                 default:
   201                 default:
   171                     mLastError = UnknownDeviceDialogError;
   202                     mLastError = UnknownDeviceDialogError;
   186                 mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
   217                 mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
   187                 HbIcon icon(QString("qtg_large_bluetooth"));
   218                 HbIcon icon(QString("qtg_large_bluetooth"));
   188                 mMessageBox->setIcon(icon);
   219                 mMessageBox->setIcon(icon);
   189                 mMessageBox->setTimeout(timeOut);
   220                 mMessageBox->setTimeout(timeOut);
   190                 connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   221                 connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
   191                 connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
       
   192                 }break;
   222                 }break;
   193                 
   223                 
   194             default:
   224             default:
   195                 mLastError = UnknownDeviceDialogError;
   225                 mLastError = UnknownDeviceDialogError;
   196                 break; 
   226                 break; 
   209         }
   239         }
   210     
   240     
   211     return false;
   241     return false;
   212 }
   242 }
   213 
   243 
   214 void BtDeviceInfoWidget::messageBoxClosed(HbAction *action)
       
   215 {
       
   216     Q_UNUSED(action);
       
   217     emit deviceDialogClosed();
       
   218 }
       
   219 
       
   220 void BtDeviceInfoWidget::messageBoxClosed(int action)
   244 void BtDeviceInfoWidget::messageBoxClosed(int action)
   221     {
   245     {
   222     QVariantMap data;
   246     QVariantMap data;
   223     if((action == HbMessageBox::Yes) || (action == HbMessageBox::Continue))
   247     if((action == HbMessageBox::Yes) || (action == HbMessageBox::Continue) || (action == HbMessageBox::Ok))
   224         {
   248         {
   225         data.insert(QString("actionResult"), QVariant(true));
   249         data.insert(QString("actionResult"), QVariant(true));
   226         }
   250         }
   227     else if((action == HbMessageBox::No) || (action == HbMessageBox::Cancel))
   251     else if((action == HbMessageBox::No) || (action == HbMessageBox::Cancel))
   228         {
   252         {