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