wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp
changeset 62 b47b808de481
parent 58 301aeb18ae47
equal deleted inserted replaced
58:301aeb18ae47 62:b47b808de481
     1 /*
       
     2 * Copyright (c) 2009-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: 
       
    15 * WLAN Entry plugin item data implementation.
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 #include <HbApplication>
       
    21 #include <HbLabel>
       
    22 #include <HbDataForm>
       
    23 
       
    24 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
    25 #include <xqservicelog.h>
       
    26 #endif
       
    27 #include <xqappmgr.h>
       
    28 #include <xqaiwdecl.h>
       
    29 #include <xqaiwdeclplat.h>
       
    30 
       
    31 #include <cpitemdatahelper.h>
       
    32 #include <cpbasesettingview.h>
       
    33 
       
    34 // User includes
       
    35 
       
    36 #include "wlanstatusinfo.h"
       
    37 #include "cpwlanentryitemdata.h"
       
    38 
       
    39 #include "OstTraceDefinitions.h"
       
    40 #ifdef OST_TRACE_COMPILER_IN_USE
       
    41 #include "cpwlanentryitemdataTraces.h"
       
    42 #endif
       
    43 
       
    44 /*!
       
    45     \class CpWlanEntryItemData
       
    46     \brief Implementation of WLAN Status Plugin entry item data.
       
    47 
       
    48 */
       
    49 
       
    50 // External function prototypes
       
    51 
       
    52 // Local constants
       
    53 
       
    54 // ======== LOCAL FUNCTIONS ========
       
    55 
       
    56 // ======== MEMBER FUNCTIONS ========
       
    57 
       
    58 /*!
       
    59     Constructor.
       
    60     
       
    61     @param[in,out] itemDataHelper Control Panel item data helper object.
       
    62 */
       
    63 
       
    64 CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) :
       
    65     CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")),
       
    66     mWlanStatusInfo(new WlanStatusInfo(this))
       
    67 {
       
    68     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY);
       
    69     
       
    70     // Listen for WLAN status updates
       
    71     bool connectStatus = connect(
       
    72         mWlanStatusInfo,
       
    73         SIGNAL(statusUpdated()),
       
    74         this,
       
    75         SLOT(statusUpdate()));
       
    76     Q_ASSERT(connectStatus);
       
    77     
       
    78     // Update to show initial WLAN status.
       
    79     statusUpdate();
       
    80     
       
    81     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT);
       
    82 }
       
    83 
       
    84 /*!
       
    85     Destructor.
       
    86 */
       
    87 
       
    88 CpWlanEntryItemData::~CpWlanEntryItemData()
       
    89 {
       
    90     OstTraceFunctionEntry0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY);
       
    91     OstTraceFunctionExit0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT);
       
    92 }
       
    93 
       
    94 /*!
       
    95     Function for handling the entry item click.
       
    96 */
       
    97 
       
    98 CpBaseSettingView *CpWlanEntryItemData::createSettingView() const
       
    99 {
       
   100     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY);
       
   101     
       
   102 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
   103     qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
       
   104     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView requesting listView()");
       
   105 #endif
       
   106 
       
   107     // Execute synchronous WLAN Sniffer list view
       
   108     XQApplicationManager aiwMgr;
       
   109     XQAiwRequest *request = aiwMgr.create(
       
   110         "wlansniffer",
       
   111         XQI_WLAN_SNIFFER,
       
   112         XQOP_WLAN_SNIFFER,
       
   113         true);
       
   114 
       
   115     // The WLAN Sniffer service must always exist
       
   116     Q_ASSERT(request);
       
   117 
       
   118     // The service is synchronous & embedded
       
   119     request->setSynchronous(true);
       
   120     
       
   121     // Window title needs to be set to "Control Panel"
       
   122     XQRequestInfo reqInfo;
       
   123     reqInfo.setInfo(XQINFO_KEY_WINDOW_TITLE, hbTrId("txt_cp_title_control_panel"));
       
   124     request->setInfo(reqInfo);
       
   125     
       
   126     bool status = request->send();
       
   127 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
   128     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request completed");
       
   129 #endif    
       
   130     Q_ASSERT(status);
       
   131     delete request;
       
   132 
       
   133     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT);
       
   134     return 0;
       
   135 }
       
   136 
       
   137 /*!
       
   138     Slot for updating the status shown by the plugin.
       
   139     Updates both the text and icon. 
       
   140  */
       
   141 void CpWlanEntryItemData::statusUpdate()
       
   142 {
       
   143     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY);
       
   144     
       
   145     // Build icon with (possible) badge
       
   146     HbIcon wlanIcon;
       
   147     switch (mWlanStatusInfo->status()) {
       
   148     case WlanStatusInfo::WlanStatusIdle:
       
   149         wlanIcon = HbIcon("qtg_large_wlan");
       
   150         break;
       
   151         
       
   152     case WlanStatusInfo::WlanStatusOff:
       
   153         wlanIcon = HbIcon("qtg_large_wlan_off");
       
   154         break;
       
   155         
       
   156     case WlanStatusInfo::WlanStatusConnected:
       
   157         wlanIcon = HbIcon("qtg_large_wlan");
       
   158         wlanIcon.addBadge(
       
   159             Qt::AlignBottom | Qt::AlignRight,
       
   160             HbIcon("qtg_small_connection"));
       
   161         break;
       
   162         
       
   163 #ifndef QT_NO_DEBUG
       
   164     default:
       
   165         // Unsupported status type detected
       
   166         Q_ASSERT(0);
       
   167         break;
       
   168 #endif        
       
   169     }
       
   170     
       
   171     // Set the updated WLAN status
       
   172     this->setEntryItemIcon(wlanIcon);
       
   173     this->setDescription(mWlanStatusInfo->statusText());
       
   174     
       
   175     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT);
       
   176 }