wlanutilities/wlanentryplugin/src/cpwlanentryitemdata.cpp
changeset 38 2dc6da6fb431
parent 19 10810c91db26
child 56 de27cc8389dd
equal deleted inserted replaced
29:dbe86d96ce5b 38:2dc6da6fb431
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009-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".
     8 *
     8 *
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  
    14 * Description: 
    15 *
    15 * WLAN Entry plugin item data implementation.
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 
    19 
       
    20 #include <HbApplication>
       
    21 #include <HbLabel>
       
    22 #include <HbDataForm>
       
    23 
    20 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
    24 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
    21 #include <xqservicelog.h>
    25 #include <xqservicelog.h>
    22 #endif
    26 #endif
    23 #include <xqservicerequest.h>
    27 #include <xqappmgr.h>
       
    28 #include <xqaiwdeclplat.h>
    24 
    29 
    25 #include <HbLabel>
    30 // This workaround can be removed when XQOP_WLAN_SNIFFER is correctly
    26 #include <HbDataForm>
    31 // defined without the "void" parameter restriction:
       
    32 #undef XQOP_WLAN_SNIFFER
       
    33 #define XQOP_WLAN_SNIFFER  QLatin1String("listView()")
    27 
    34 
    28 #include <cpitemdatahelper.h>
    35 #include <cpitemdatahelper.h>
    29 #include <cpbasesettingview.h>
    36 #include <cpbasesettingview.h>
    30 
    37 
    31 // User includes
    38 // User includes
    32 
    39 
       
    40 #include "wlanstatusinfo.h"
       
    41 #include "cpwlanentryitemdata.h"
       
    42 
    33 #include "OstTraceDefinitions.h"
    43 #include "OstTraceDefinitions.h"
    34 #ifdef OST_TRACE_COMPILER_IN_USE
    44 #ifdef OST_TRACE_COMPILER_IN_USE
    35 #include "cpwlanentryitemdataTraces.h"
    45 #include "cpwlanentryitemdataTraces.h"
    36 #endif
    46 #endif
    37 
       
    38 #include "wlanstatusinfo.h"
       
    39 
       
    40 #include "cpwlanentryitemdata.h"
       
    41 
    47 
    42 /*!
    48 /*!
    43     \class CpWlanEntryItemData
    49     \class CpWlanEntryItemData
    44     \brief Implementation of WLAN Status Plugin entry item data.
    50     \brief Implementation of WLAN Status Plugin entry item data.
    45 
    51 
    53 
    59 
    54 // ======== MEMBER FUNCTIONS ========
    60 // ======== MEMBER FUNCTIONS ========
    55 
    61 
    56 /*!
    62 /*!
    57     Constructor.
    63     Constructor.
       
    64     
       
    65     @param[in,out] itemDataHelper Control Panel item data helper object.
    58 */
    66 */
    59 
    67 
    60 CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) :
    68 CpWlanEntryItemData::CpWlanEntryItemData(CpItemDataHelper &itemDataHelper) :
    61     CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")),
    69     CpSettingFormEntryItemData(itemDataHelper, hbTrId("txt_occ_dblist_wireless_lan")),
    62     mWlanStatusInfo(new WlanStatusInfo(this))
    70     mWlanStatusInfo(new WlanStatusInfo(this))
    63 {
    71 {
    64     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this);
    72     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY);
    65     
    73     
    66     // Listen for WLAN status updates
    74     // Listen for WLAN status updates
    67     bool connectStatus = connect(
    75     bool connectStatus = connect(
    68         mWlanStatusInfo,
    76         mWlanStatusInfo,
    69         SIGNAL(statusUpdated()),
    77         SIGNAL(statusUpdated()),
    72     Q_ASSERT(connectStatus == true);
    80     Q_ASSERT(connectStatus == true);
    73     
    81     
    74     // Update to show initial WLAN status.
    82     // Update to show initial WLAN status.
    75     statusUpdate();
    83     statusUpdate();
    76     
    84     
    77     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this);
    85     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT);
    78 }
    86 }
    79 
    87 
    80 /*!
    88 /*!
    81     Destructor.
    89     Destructor.
    82 */
    90 */
    83 
    91 
    84 CpWlanEntryItemData::~CpWlanEntryItemData()
    92 CpWlanEntryItemData::~CpWlanEntryItemData()
    85 {
    93 {
    86     OstTraceFunctionEntry1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY, this);
    94     OstTraceFunctionEntry0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_ENTRY);
    87     OstTraceFunctionExit1(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT, this);
    95     OstTraceFunctionExit0(DUP1_CPWLANENTRYITEMDATA_CPWLANENTRYITEMDATA_EXIT);
    88 }
    96 }
    89 
    97 
    90 /*!
    98 /*!
    91     Function for handling the entry item click.
    99     Function for handling the entry item click.
    92 */
   100 */
    93 
   101 
    94 CpBaseSettingView *CpWlanEntryItemData::createSettingView() const
   102 CpBaseSettingView *CpWlanEntryItemData::createSettingView() const
    95 {
   103 {
    96     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY, this);
   104     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_ENTRY);
    97     
   105     
    98 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
   106 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
    99     qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
   107     qInstallMsgHandler(XQSERVICEMESSAGEHANDLER);
   100     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView requesting listView()");
   108     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView requesting listView()");
   101 #endif
   109 #endif
   102 
   110 
   103     // Execute synchronous WLAN Sniffer list view
   111     // Execute synchronous WLAN Sniffer list view
   104     XQServiceRequest* snd = new XQServiceRequest("com.nokia.services.wlansniffer.list","listView()",true);
   112     XQApplicationManager aiwMgr;
   105     bool status = snd->send();
   113     XQAiwRequest *request = aiwMgr.create(
       
   114         "wlansniffer",
       
   115         XQI_WLAN_SNIFFER,
       
   116         XQOP_WLAN_SNIFFER,
       
   117         true);
       
   118 
       
   119     // The WLAN Sniffer service must always exist
       
   120     Q_ASSERT(request);
       
   121 
       
   122     // The service is synchronous & embedded
       
   123     request->setSynchronous(true);
       
   124     
       
   125     // Window title needs to be set to "Control Panel"
       
   126     XQRequestInfo reqInfo;
       
   127     // TODO: Start using the official define when available
       
   128     reqInfo.setInfo("WindowTitle", hbTrId("txt_cp_title_control_panel"));
       
   129     request->setInfo(reqInfo);
       
   130     
       
   131     bool status = request->send();
   106 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
   132 #ifdef WLANENTRYPLUGIN_SERVICETRACES    
   107     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request completed");
   133     XQSERVICE_DEBUG_PRINT("CpWlanEntryItemData::createSettingView listView() service request completed");
   108 #endif    
   134 #endif    
   109     Q_ASSERT(status);
   135     Q_ASSERT(status);
   110     delete snd;
   136     delete request;
   111 
   137 
   112     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT, this);
   138     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_CREATESETTINGVIEW_EXIT);
   113     return 0;
   139     return 0;
   114 }
   140 }
   115 
   141 
   116 /*!
   142 /*!
   117     Slot for updating the status shown by the plugin.
   143     Slot for updating the status shown by the plugin.
   118     Updates both the text and icon. 
   144     Updates both the text and icon. 
   119  */
   145  */
   120 void CpWlanEntryItemData::statusUpdate()
   146 void CpWlanEntryItemData::statusUpdate()
   121 {
   147 {
   122     OstTraceFunctionEntry1(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY, this);
   148     OstTraceFunctionEntry0(CPWLANENTRYITEMDATA_STATUSUPDATE_ENTRY);
   123     
   149     
   124     // Build icon with (possible) badge
   150     // Build icon with (possible) badge
   125     HbIcon wlanIcon("qtg_large_wlan");
   151     HbIcon wlanIcon;
   126     switch (mWlanStatusInfo->status()) {
   152     switch (mWlanStatusInfo->status()) {
       
   153     case WlanStatusInfo::WlanStatusIdle:
       
   154         wlanIcon = HbIcon("qtg_large_wlan");
       
   155         break;
       
   156         
   127     case WlanStatusInfo::WlanStatusOff:
   157     case WlanStatusInfo::WlanStatusOff:
   128 #ifdef WLANSTATUSICONBADGING                                // TODO: Remove flagging when icon badging is supported       
   158         wlanIcon = HbIcon("qtg_large_wlan_off");
   129         wlanIcon.addBadge(
       
   130             Qt::AlignTop | Qt::AlignRight,
       
   131             HbIcon("pri_small_super_off"));
       
   132 #endif        
       
   133         break;
   159         break;
   134         
   160         
   135     case WlanStatusInfo::WlanStatusConnected:
   161     case WlanStatusInfo::WlanStatusConnected:
   136 #ifdef WLANSTATUSICONBADGING                                // TODO: Remove flagging when icon badging is supported       
   162         wlanIcon = HbIcon("qtg_large_wlan");
   137         wlanIcon.addBadge(
   163         wlanIcon.addBadge(
   138             Qt::AlignTop | Qt::AlignRight,
   164             Qt::AlignBottom | Qt::AlignRight,
   139             HbIcon("qtg_small_online"));
   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;
   140 #endif        
   173 #endif        
   141         break;
       
   142     }
   174     }
   143     
   175     
   144     // Set the updated WLAN status
   176     // Set the updated WLAN status
   145     this->setEntryItemIcon(wlanIcon);
   177     this->setEntryItemIcon(wlanIcon);
   146     this->setDescription(mWlanStatusInfo->statusText());
   178     this->setDescription(mWlanStatusInfo->statusText());
   147     
   179     
   148     OstTraceFunctionExit1(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT, this);
   180     OstTraceFunctionExit0(CPWLANENTRYITEMDATA_STATUSUPDATE_EXIT);
   149 }
   181 }