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