connectionmonitoring/connectionmonitorui/src/EasyWLANConnectionInfo.cpp
branchRCL_3
changeset 57 05bc53fe583b
parent 55 fc7b30ed2058
child 58 83ca720e2b9a
equal deleted inserted replaced
55:fc7b30ed2058 57:05bc53fe583b
     1 /*
       
     2 * Copyright (c) 2004 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:  Represents a WLAN connection
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <ConnectionMonitorUi.rsg>
       
    22 #include <ConnectionMonitorUi.mbg>
       
    23 
       
    24 #include "EasyWLANConnectionInfo.h"
       
    25 #include "ConnectionArray.h"
       
    26 #include <StringLoader.h>
       
    27 
       
    28 #include "ConnectionMonitorUiLogger.h"
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 /**
       
    33 * Count of details of WLAN connection
       
    34 */
       
    35 LOCAL_D const TUint KMaxNumOfListBoxItems = 14;
       
    36 
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 // ---------------------------------------------------------
       
    40 // CEasyWlanConnectionInfo::NewL
       
    41 // ---------------------------------------------------------
       
    42 //
       
    43 CEasyWlanConnectionInfo* CEasyWlanConnectionInfo::NewL( TInt aConnectionId,
       
    44                               RConnectionMonitor* const aConnectionMonitor,
       
    45                               TConnMonBearerType aConnectionBearerType,
       
    46                               CActiveWrapper* aActiveWrapper )
       
    47     {
       
    48     CMUILOGGER_ENTERFN(
       
    49         "CEasyWlanConnectionInfo* CEasyWlanConnectionInfo::NewL" );
       
    50     CEasyWlanConnectionInfo* self = new ( ELeave ) CEasyWlanConnectionInfo(
       
    51                                                     aConnectionId,
       
    52                                                     aConnectionMonitor,
       
    53                                                     aConnectionBearerType,
       
    54                                                     aActiveWrapper );
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     CleanupStack::Pop( self );
       
    58     CMUILOGGER_LEAVEFN(
       
    59         "CEasyWlanConnectionInfo* CEasyWlanConnectionInfo::NewL" );
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------
       
    64 // CEasyWlanConnectionInfo::CEasyWlanConnectionInfo
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CEasyWlanConnectionInfo::CEasyWlanConnectionInfo( TInt aConnectionId,
       
    68                               RConnectionMonitor* const aConnectionMonitor,
       
    69                               TConnMonBearerType aConnectionBearerType,
       
    70                               CActiveWrapper* aActiveWrapper )
       
    71     : CWlanConnectionInfo( aConnectionId,
       
    72                            aConnectionMonitor,
       
    73                            aConnectionBearerType,
       
    74                            aActiveWrapper )
       
    75     {
       
    76     iEasyWlan= ETrue;
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CEasyWlanConnectionInfo::ConstructL
       
    81 // ---------------------------------------------------------
       
    82 //
       
    83 void CEasyWlanConnectionInfo::ConstructL()
       
    84     {
       
    85     CMUILOGGER_ENTERFN( "void CEasyWlanConnectionInfo::ConstructL()" );
       
    86 
       
    87     CWlanConnectionInfo::ConstructL();
       
    88 
       
    89     CMUILOGGER_LEAVEFN( "void CEasyWlanConnectionInfo::ConstructL()" );
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CEasyWlanConnectionInfo::~CEasyWlanConnectionInfo
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 CEasyWlanConnectionInfo::~CEasyWlanConnectionInfo()
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CEasyWlanConnectionInfo::DeepCopyL
       
   103 // ---------------------------------------------------------
       
   104 //        
       
   105 CConnectionInfoBase* CEasyWlanConnectionInfo::DeepCopyL()
       
   106 	{
       
   107 	CEasyWlanConnectionInfo* temp = new ( ELeave ) CEasyWlanConnectionInfo(
       
   108                                                     iConnectionId,
       
   109                                                     iConnectionMonitor,
       
   110                                                     iConnectionBearerType,
       
   111                                                     iActiveWrapper );
       
   112                               							
       
   113 	temp->iConnectionName = iConnectionName;
       
   114 	temp->iConnectionStatus = iConnectionStatus;
       
   115 	temp->iUploaded = iUploaded;
       
   116 	temp->iDownloaded = iDownloaded;
       
   117 	temp->iStartTime = iStartTime;
       
   118 	temp->iDuration = iDuration;
       
   119 	temp->iLastSpeedUpdate = iLastSpeedUpdate;
       
   120 	temp->iUpSpeed = iUpSpeed;
       
   121 	temp->iDownSpeed = iDownSpeed;
       
   122 	temp->iListBoxItemText = iListBoxItemText;
       
   123 	
       
   124 	temp->iWlanNetworkName = iWlanNetworkName;
       
   125 	temp->iSignalStrength = iSignalStrength;
       
   126 	temp->iNetworkMode = iNetworkMode;
       
   127 	temp->iSecurityMode = iSecurityMode;
       
   128 	temp->iTxPower = iTxPower;
       
   129 
       
   130 	if ( iDetailsArray )
       
   131 		{
       
   132 		CleanupStack::PushL( temp );		
       
   133 		temp->ToArrayDetailsL();
       
   134 		CleanupStack::Pop( temp );			
       
   135 		}
       
   136 		
       
   137 	return temp;	
       
   138 	}    
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CEasyWlanConnectionInfo::ToArrayDetailsL
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 void CEasyWlanConnectionInfo::ToArrayDetailsL()
       
   145     {
       
   146     CMUILOGGER_ENTERFN( "void CEasyWlanConnectionInfo::ToArrayDetailsL()" );
       
   147 
       
   148     HBufC* temp = NULL;
       
   149     delete iDetailsArray;
       
   150     iDetailsArray = NULL;
       
   151 
       
   152     iDetailsArray = new ( ELeave ) CDesCArrayFlat
       
   153         ( KMaxNumOfListBoxItems );
       
   154 
       
   155     temp = ToStringBearerLC();
       
   156 
       
   157     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_BEARER,
       
   158                                          temp );
       
   159 
       
   160     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_STATUS,
       
   161                                          ToStringStatusLC() );
       
   162 
       
   163     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_WLAN_NETWORK_NAME,
       
   164                                          GetWlanNetworkNameLC() );
       
   165 
       
   166     ToDetailsListBoxItemTextWithAppendL
       
   167         (
       
   168         R_QTN_CMON_HEADING_WLAN_SIGNAL_STRENGTH,
       
   169         ToStringSignalStrengthLC()
       
   170         );
       
   171 
       
   172     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_WLAN_NETWORK_MODE,
       
   173                                          ToStringNetworkModeLC() );
       
   174 
       
   175     ToDetailsListBoxItemTextWithAppendL
       
   176         (
       
   177         R_QTN_CMON_HEADING_WLAN_SECURITY_MODE,
       
   178         ToStringSecurityModeLC()
       
   179         );
       
   180 
       
   181     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_WLAN_TX_POWER,
       
   182                                          ToStringTxPowerLC() );
       
   183         
       
   184     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_TOTAL,
       
   185                                          ToStringTotalTransmittedDataLC() );
       
   186 
       
   187     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_RECEIVED,
       
   188                                          ToStringReceivedDataLC() );
       
   189 
       
   190     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DATA_SENT,
       
   191                                          ToStringSentDataLC() );
       
   192 
       
   193     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_DURATION,
       
   194                                          ToStringDurationLC() );
       
   195 
       
   196     ToDetailsListBoxItemTextWithAppendL( R_QTN_CMON_HEADING_SPEED,
       
   197                                          ToStringTransferSpeedDownLC() );
       
   198 
       
   199     ToDetailsListBoxItemTextWithAppendL( 0, 
       
   200                                          ToStringTransferSpeedUpLC() );
       
   201 
       
   202     CleanupStack::PopAndDestroy
       
   203         (
       
   204         KMaxNumOfListBoxItems - 1,
       
   205         temp
       
   206         );
       
   207 
       
   208     CMUILOGGER_WRITE_F( "KMaxNumOfListBoxItems + cCXSupported : %d",
       
   209                         KMaxNumOfListBoxItems );
       
   210 
       
   211     TInt sharing = RefreshAppNamesL();
       
   212         
       
   213     if ( sharing >= 1 )
       
   214         {
       
   215         for ( TInt i = 0; i < ( sharing ); i++ )
       
   216             {
       
   217             if ( i == 0 )
       
   218                 {
       
   219                 ToDetailsListBoxItemTextWithAppendL( 
       
   220                                     R_QTN_CMON_HEADING_SHARING_INFO,
       
   221                                     ToStringAppNameLC( i ) );
       
   222                 }
       
   223             else
       
   224                 {
       
   225                 ToDetailsListBoxItemTextWithAppendL( 0, 
       
   226                                                 ToStringAppNameLC( i ) );
       
   227                 }
       
   228             }
       
   229         CleanupStack::PopAndDestroy( sharing ); // ToStringAppNameLC()
       
   230         }
       
   231         
       
   232     CMUILOGGER_LEAVEFN( "void CEasyWlanConnectionInfo::ToArrayDetailsL()" );
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------
       
   236 // CEasyWlanConnectionInfo::RefreshDetailsArrayL
       
   237 // ---------------------------------------------------------
       
   238 //
       
   239 void CEasyWlanConnectionInfo::RefreshDetailsArrayL()
       
   240     {
       
   241     CMUILOGGER_ENTERFN( "CEasyWlanConnectionInfo::RefreshDetailsArrayL()" );
       
   242 
       
   243     HBufC* temp = NULL;
       
   244 
       
   245     temp = ToStringStatusLC();
       
   246 
       
   247     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_STATUS,
       
   248                                           temp, 1 );
       
   249 
       
   250     ToDetailsListBoxItemTextWithReplaceL
       
   251         (
       
   252         R_QTN_CMON_HEADING_WLAN_SIGNAL_STRENGTH,
       
   253         ToStringSignalStrengthLC(),
       
   254         3
       
   255         );
       
   256 
       
   257     ToDetailsListBoxItemTextWithReplaceL
       
   258         (
       
   259         R_QTN_CMON_HEADING_WLAN_TX_POWER,
       
   260         ToStringTxPowerLC(),
       
   261         6
       
   262         );
       
   263         
       
   264     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DATA_TOTAL,
       
   265                                           ToStringTotalTransmittedDataLC(),
       
   266                                           7 );
       
   267 
       
   268     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DATA_RECEIVED,
       
   269                                           ToStringReceivedDataLC(),
       
   270                                           8 );
       
   271 
       
   272     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DATA_SENT,
       
   273                                           ToStringSentDataLC(),
       
   274                                           9 );
       
   275 
       
   276     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_DURATION,
       
   277                                           ToStringDurationLC(),
       
   278                                           10 );
       
   279 
       
   280     ToDetailsListBoxItemTextWithReplaceL( R_QTN_CMON_HEADING_SPEED,
       
   281                                           ToStringTransferSpeedDownLC(),
       
   282                                           11 );
       
   283 
       
   284     ToDetailsListBoxItemTextWithReplaceL( 0, 
       
   285                                           ToStringTransferSpeedUpLC(),
       
   286                                           12 );
       
   287 
       
   288     CleanupStack::PopAndDestroy( 9, temp );
       
   289 
       
   290     TInt count = iDetailsArray->Count();
       
   291     TInt realElementsMaxCount = KMaxNumOfListBoxItems;
       
   292 
       
   293     CMUILOGGER_WRITE_F( "count : %d", count );
       
   294     CMUILOGGER_WRITE_F( "realElementsMaxCount : %d", 
       
   295                         realElementsMaxCount );
       
   296 
       
   297     TInt sharing = RefreshAppNamesL();
       
   298 
       
   299     if ( sharing >= 1 )
       
   300         {
       
   301         if ( count >= realElementsMaxCount )
       
   302             {  
       
   303             iDetailsArray->Delete( realElementsMaxCount - 1,
       
   304                                        iDetailsArray->Count() - 13 );
       
   305             iDetailsArray->Compress(); 
       
   306             }
       
   307 
       
   308         for ( TInt i = 0; i < sharing; i++ )
       
   309             {
       
   310             if ( i == 0 )
       
   311                 {
       
   312                 ToDetailsListBoxItemTextWithAppendL( 
       
   313                                         R_QTN_CMON_HEADING_SHARING_INFO,
       
   314                                         ToStringAppNameLC( i ) );
       
   315                 }
       
   316             else
       
   317                 {
       
   318                 ToDetailsListBoxItemTextWithAppendL( 0, 
       
   319                                             ToStringAppNameLC( i ) );
       
   320                 }
       
   321             }
       
   322         CleanupStack::PopAndDestroy( sharing ); // ToStringAppNameLC()
       
   323         }
       
   324     else
       
   325         {
       
   326         if ( count >= realElementsMaxCount )
       
   327             {
       
   328             iDetailsArray->Delete( realElementsMaxCount - 1,
       
   329                                    iDetailsArray->Count() - 13 );
       
   330             iDetailsArray->Compress();              
       
   331             }
       
   332         } 
       
   333 
       
   334     CMUILOGGER_LEAVEFN(
       
   335         "void CEasyWlanConnectionInfo::RefreshDetailsArrayL()" );
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------
       
   339 // CEasyWlanConnectionInfo::RefreshConnectionListBoxItemTextL
       
   340 // ---------------------------------------------------------
       
   341 //
       
   342 void CEasyWlanConnectionInfo::RefreshConnectionListBoxItemTextL()
       
   343     {
       
   344     CMUILOGGER_ENTERFN(
       
   345     "void CEasyWlanConnectionInfo::RefreshConnectionListBoxItemTextL()" );
       
   346 
       
   347     TUint  iconId;
       
   348     HBufC* secondRow = NULL;
       
   349 
       
   350     iconId = GetIconId();
       
   351 
       
   352     if ( iConnectionStatus == EConnectionCreated )
       
   353         {
       
   354         secondRow =  ToStringDurationLC();
       
   355         }
       
   356     else    // if connection has not created yet gives back the status of its.
       
   357         {
       
   358         secondRow = ToStringStatusLC( EFalse );
       
   359         }
       
   360 
       
   361     iListBoxItemText.Format( KConnectonListItemTextFormat, iconId,
       
   362                              &iWlanNetworkName, secondRow );
       
   363     CleanupStack::PopAndDestroy( secondRow );
       
   364 
       
   365     CMUILOGGER_LEAVEFN(
       
   366     "void CEasyWlanConnectionInfo::RefreshConnectionListBoxItemTextL()" );
       
   367     }
       
   368 
       
   369 
       
   370 
       
   371 // End of File