wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp
changeset 19 10810c91db26
child 31 e8f4211554fb
child 38 2dc6da6fb431
equal deleted inserted replaced
3:ff3b37722600 19:10810c91db26
       
     1 /*
       
     2 * Copyright (c) 2009 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 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
    21 #include <xqservicelog.h>
       
    22 #endif
       
    23 #include <xqservicerequest.h>
       
    24 
       
    25 #include <HbLabel>
       
    26 #include <HbDataForm>
       
    27 
       
    28 #include <cpitemdatahelper.h>
       
    29 #include <cpbasesettingview.h>
       
    30 
       
    31 // User includes
       
    32 
       
    33 #include "OstTraceDefinitions.h"
       
    34 #ifdef OST_TRACE_COMPILER_IN_USE
       
    35 #include "cpwlanentryitemdataTraces.h"
       
    36 #endif
       
    37 
       
    38 #include "wlanstatusinfo.h"
       
    39 
       
    40 #include "cpwlanentryitemdata.h"
       
    41 
       
    42 /*!
       
    43     \class CpWlanEntryItemData
       
    44     \brief Implementation of WLAN Status Plugin entry item data.
       
    45 
       
    46 */
       
    47 
       
    48 // External function prototypes
       
    49 
       
    50 // Local constants
       
    51 
       
    52 // ======== LOCAL FUNCTIONS ========
       
    53 
       
    54 // ======== MEMBER FUNCTIONS ========
       
    55 
       
    56 /*!
       
    57     Constructor.
       
    58 */
       
    59 
       
    60 CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) :
       
    61     CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")),
       
    62     mWlanStatusInfo(new WlanStatusInfo(this))
       
    63 {
       
    64     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this);
       
    65     
       
    66     // Listen for WLAN status updates
       
    67     bool connectStatus = connect(
       
    68         mWlanStatusInfo,
       
    69         SIGNAL(statusUpdated()),
       
    70         this,
       
    71         SLOT(statusUpdate()));
       
    72     Q_ASSERT(connectStatus == true);
       
    73     
       
    74     // Update to show initial WLAN status.
       
    75     statusUpdate();
       
    76     
       
    77     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this);
       
    78 }
       
    79 
       
    80 /*!
       
    81     Destructor.
       
    82 */
       
    83 
       
    84 CpWlanEntryItemData::~CpWlanEntryItemData()
       
    85 {
       
    86     OstTraceFunctionEntry1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this);
       
    87     OstTraceFunctionExit1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this);
       
    88 }
       
    89 
       
    90 /*!
       
    91     Function for handling the entry item click.
       
    92 */
       
    93 
       
    94 CpBaseSettingView *CpWlanEntryItemData::createSettingView() const
       
    95 {
       
    96     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY, this);
       
    97     
       
    98 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
    99     qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
       
   100     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView requesting listView()");
       
   101 #endif
       
   102 
       
   103     // Execute synchronous WLAN Sniffer list view
       
   104     XQServiceRequest* snd = new XQServiceRequest("com.nokia.services.wlansniffer.list","listView()",true);
       
   105     bool status = snd->send();
       
   106 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
       
   107     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request completed");
       
   108 #endif    
       
   109     Q_ASSERT(status);
       
   110     delete snd;
       
   111 
       
   112     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT, this);
       
   113     return 0;
       
   114 }
       
   115 
       
   116 /*!
       
   117     Slot for updating the status shown by the plugin.
       
   118     Updates both the text and icon. 
       
   119  */
       
   120 void CpWlanEntryItemData::statusUpdate()
       
   121 {
       
   122     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY, this);
       
   123     
       
   124     // Build icon with (possible) badge
       
   125     HbIcon wlanIcon("qtg_large_wlan");
       
   126     switch (mWlanStatusInfo->status()) {
       
   127     case WlanStatusInfo::WlanStatusOff:
       
   128 #ifdef WLANSTATUSICONBADGING                                // TODO: Remove flagging when icon badging is supported       
       
   129         wlanIcon.addBadge(
       
   130             Qt::AlignTop | Qt::AlignRight,
       
   131             HbIcon("pri_small_super_off"));
       
   132 #endif        
       
   133         break;
       
   134         
       
   135     case WlanStatusInfo::WlanStatusConnected:
       
   136 #ifdef WLANSTATUSICONBADGING                                // TODO: Remove flagging when icon badging is supported       
       
   137         wlanIcon.addBadge(
       
   138             Qt::AlignTop | Qt::AlignRight,
       
   139             HbIcon("qtg_small_online"));
       
   140 #endif        
       
   141         break;
       
   142     }
       
   143     
       
   144     // Set the updated WLAN status
       
   145     this->setEntryItemIcon(wlanIcon);
       
   146     this->setDescription(mWlanStatusInfo->statusText());
       
   147     
       
   148     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT, this);
       
   149 }