connectionmonitoring/connectionmonitorui/inc/ConnectionInfoBase.h
branchRCL_3
changeset 58 83ca720e2b9a
child 69 cf1b3ddbe9a1
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     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 connection
       
    15 *     
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CONNECTIONINFOBASE_H_INCLUDED
       
    21 #define CONNECTIONINFOBASE_H_INCLUDED
       
    22 
       
    23 // INCLUDES
       
    24 #include    <rconnmon.h>
       
    25 #include    <stdlib.h>
       
    26 #include    <badesca.h>
       
    27 #include    <e32std.h>
       
    28 #include    <stdlib.h>
       
    29 
       
    30 // CONSTANTS
       
    31 LOCAL_D const TUint KConnectionListItemText = 64;
       
    32 LOCAL_D const TUint KDetailsListItemText = 64;
       
    33 
       
    34 _LIT( KConnectonListItemTextFormat, "%o\t%S\t%S" );
       
    35 _LIT( KDetailsListItemTextFormat, "%S\t%S" );  
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 
       
    39 class CActiveWrapper;
       
    40 
       
    41 // CLASS DECLARATION
       
    42 
       
    43 enum TConnectionStatus
       
    44     {
       
    45     EConnectionUninitialized,
       
    46     EConnectionCreating,
       
    47     EConnectionCreated,
       
    48     EConnectionSuspended,
       
    49     EConnectionClosing,
       
    50     EConnectionClosed
       
    51     };
       
    52 
       
    53 /**
       
    54 * Order of icons in icon array of containers
       
    55 */
       
    56 enum TIconsOrder
       
    57     {
       
    58     EGprs = 0,
       
    59     ECsd,
       
    60     EHscsd,
       
    61     EEmpty,
       
    62     ESuspended,
       
    63     EWlan
       
    64     };
       
    65 
       
    66 
       
    67 /**
       
    68 * Represents a connection.
       
    69 */
       
    70 class CConnectionInfoBase : public CBase
       
    71     {
       
    72     public: // Constructors, Desturctor
       
    73                 
       
    74         /**
       
    75         * Destructor
       
    76         */
       
    77         virtual ~CConnectionInfoBase();
       
    78 
       
    79     protected:
       
    80         /**
       
    81         * Constructor
       
    82         * @param aConnectionId The id of the given connection.
       
    83         * @param aConnectionMonitor for refreshing details
       
    84         * @param aConnectionBearerType the bearer type of connection
       
    85         * @param aActiveWrapper the for refreshing
       
    86         */
       
    87         CConnectionInfoBase( TInt aConnectionId,
       
    88                              RConnectionMonitor* const aConnectionMonitor,
       
    89                              TConnMonBearerType aConnectionBearerType,
       
    90                              CActiveWrapper* aActiveWrapper );
       
    91 
       
    92         /**
       
    93         * Second phase construction
       
    94         */
       
    95         void ConstructL();
       
    96 
       
    97     public: // New functions
       
    98     
       
    99         /**
       
   100         * Give back a copy of connection. 
       
   101         */
       
   102         virtual CConnectionInfoBase* DeepCopyL() = 0;
       
   103     
       
   104 
       
   105         /**
       
   106         * Refresh required details of connection. 
       
   107         */
       
   108         virtual void RefreshDetailsL() = 0;
       
   109 
       
   110         /**
       
   111         * Refresh iListBoxItemText text, connection ListBox has a reference to
       
   112         * this text.
       
   113         */
       
   114         virtual void RefreshConnectionListBoxItemTextL() = 0;
       
   115 
       
   116         /**
       
   117         * Refresh details array of connection. DetailsListBox has a reference
       
   118         * to this array.
       
   119         */
       
   120         virtual void RefreshDetailsArrayL() = 0;
       
   121 
       
   122         /**
       
   123         * Called, if the status of connection is changed.
       
   124         */ 
       
   125         void StatusChangedL();
       
   126 
       
   127         /**
       
   128         * Gives back the connection is alive or not.
       
   129         * @return ETrue if connection is created or suspended, 
       
   130         * EFalse otherwise
       
   131         */
       
   132         TBool IsAlive() const;
       
   133 
       
   134         /**
       
   135         * Gives back the connection is suspended or not.
       
   136         * @return ETrue if connection is suspended, 
       
   137         * EFalse otherwise
       
   138         */
       
   139         TBool IsSuspended() const;
       
   140                 
       
   141         /**
       
   142         * @return ETrue if deletion of connection started form CMUI,
       
   143         * EFalse otherwise
       
   144         */
       
   145         TBool GetDeletedFromCMUI() const;
       
   146         
       
   147         /**
       
   148         * Sets status of connection to EConnectionClosing
       
   149         */
       
   150         void SetAllDeletedFromCMUI();        
       
   151         
       
   152         /**
       
   153         * Sets iDeletedFromCMUI to ETrue, means dletion of connection
       
   154         * was established from CMUI
       
   155         */
       
   156         void SetDeletedFromCMUI();        
       
   157         
       
   158         /**
       
   159         * Gives back a pointer to the DetailsArray of connection.
       
   160         * @return CDesCArraySeg* iDetailsArray of connection
       
   161         */
       
   162         CDesCArrayFlat* GetDetailsArray() const;
       
   163 
       
   164         /**
       
   165         * Gives back the id of connection
       
   166         * @return the id of connection.
       
   167         */
       
   168         TUint GetConnectionId() const;
       
   169 
       
   170         /**
       
   171         * Gives back the icon id of connection 
       
   172         * @return the icon id of connection 
       
   173         */
       
   174         virtual TUint GetIconId() const = 0;
       
   175 
       
   176         /**
       
   177         * Gives back the connection is EasyWLAN or not.
       
   178         * @return ETrue if the selected conenction EasyWLAN,
       
   179         * EFalse otherwise
       
   180         */
       
   181         virtual TBool IsEasyWLAN() const { return EFalse; };
       
   182         
       
   183         /**
       
   184         * Gives back current Name of Network ( SSID )
       
   185         * @return iNetworkName
       
   186         */
       
   187         virtual HBufC* GetWlanNetworkNameLC() const { return NULL; };
       
   188 
       
   189         /**
       
   190         * Gives back the status of connection 
       
   191         * @return the status of connection 
       
   192         */
       
   193         TConnectionStatus GetStatus() const;
       
   194 
       
   195         /**
       
   196         * Refresh status of connection
       
   197         * @param aConnectionStatus new status of connection
       
   198         */
       
   199         void RefreshConnectionStatus( 
       
   200                                    const TInt aConnectionStatus );
       
   201 
       
   202         /**
       
   203         * Gives back the name of connection 
       
   204         * @return the name of connection 
       
   205         */
       
   206         HBufC* GetNameLC() const;        
       
   207         
       
   208         /**
       
   209         * Gives back the bearertype of connection 
       
   210         * @return the bearertype of connection 
       
   211         */
       
   212         TConnMonBearerType GetBearerType() const;
       
   213         
       
   214         /**
       
   215         * Gives back a pointer the iListBoxItemText of connection 
       
   216         * @return the iListBoxItemText of connection 
       
   217         */
       
   218         TPtrC GetConnectionListBoxItemText() const;
       
   219 
       
   220         /**
       
   221         * Check if connection name is starts with "mRouter" string or not.
       
   222         * ( if this connection is not IR/BT )
       
   223         * @retrun ETrue if starts wiht "mRouter", EFalse otherwise.
       
   224         */
       
   225         TBool CheckMrouterIap();
       
   226     
       
   227     protected:
       
   228         /**
       
   229         * Creates a string for DetailsListBoxItem, title came from resource 
       
   230         * and value from aValueText
       
   231         * @param aResourceId a resource id
       
   232         * @param aValueText the value of text
       
   233         * @retrun  a string consist of resource and value text
       
   234         */
       
   235         HBufC*  ToDetailsListBoxItemTextL( const TUint aResourceId, 
       
   236                                            const HBufC* aValueText ) const;
       
   237 
       
   238         /**
       
   239         * Creates a string for DetailsListBoxItem, title came from resource 
       
   240         * and value from aValueText, and Appends to iDetailsArray
       
   241         * @param aResourceId a resource id
       
   242         * @param aValueText the value of text
       
   243         */
       
   244         void  ToDetailsListBoxItemTextWithAppendL( const TUint aResourceId, 
       
   245                                                    const HBufC* aValueText );
       
   246 
       
   247         /**
       
   248         * Creates a string for DetailsListBoxItem, title came from resource 
       
   249         * and value from aValueText, and Replaces the given element with it
       
   250         * @param aResourceId a resource id
       
   251         * @param aValueText the value of text
       
   252         */
       
   253         void  ToDetailsListBoxItemTextWithReplaceL( const TUint aResourceId, 
       
   254                                                     const HBufC* aValueText,
       
   255                                                     TInt aIndex );
       
   256 
       
   257 
       
   258         /**
       
   259         * Creates an array with requrired details of connection to
       
   260         * the listbox which visulaize details of connection. This member
       
   261         * is called at initialization.
       
   262         */
       
   263         virtual void ToArrayDetailsL() = 0;
       
   264 
       
   265         /**
       
   266         * Refresh status of connection
       
   267         */
       
   268         void RefreshConnectionStatus();
       
   269 
       
   270         /**
       
   271         * Refresh amount of sent and received data of connection
       
   272         */
       
   273         void RefreshSentReceivedDataL();
       
   274 
       
   275         /**
       
   276         * Refresh the value of transfer speeds (Up/Down) of connection
       
   277         */
       
   278         void RefreshTransferSpeedsL();
       
   279                         
       
   280         /**
       
   281         * Refresh the duration of connection.
       
   282         */
       
   283         void RefreshDuration();
       
   284         
       
   285         /**
       
   286         * Refresh the applications names which uses the connection
       
   287         * @return the count of applications use connection 
       
   288         *         (from the user point of view)
       
   289         */
       
   290         TInt RefreshAppNamesL();
       
   291         
       
   292  
       
   293      public: // New functions        
       
   294 
       
   295         /**
       
   296         * Creates a string from bearer of connection
       
   297         * @return string representation of bearer of connection.
       
   298         */
       
   299         HBufC* ToStringBearerLC() const;
       
   300 
       
   301         /**
       
   302         * Creates a string from status of connection
       
   303         * @param aIsDetailsView is ETrue then get localised resources 
       
   304         * to details view otherwise to connections view
       
   305         * @return string representation of status of connection.
       
   306         */
       
   307         HBufC* ToStringStatusLC( TBool aIsDetailsView = ETrue ) const;
       
   308 
       
   309         /**
       
   310         * Creates a string from amount of received data 
       
   311         * and sent data combined/summarized.
       
   312         * @return string representation  of summarized of 
       
   313         * Received and Sent data.
       
   314         */
       
   315         HBufC* ToStringTotalTransmittedDataLC() const;
       
   316 
       
   317         /**
       
   318         * Creates a string from amount of Sent data
       
   319         * @param aToBeThreeDigit the shown digits numbers limited to three
       
   320         * @return string representation of Sent data.
       
   321         */
       
   322         HBufC* ToStringSentDataLC( TBool aToBeThreeDigit = EFalse ) const;
       
   323 
       
   324         /**
       
   325         * Creates a string from amount of Received data
       
   326         * @param aToBeThreeDigit the shown digits numbers limited to three
       
   327         * @return string representation of Received data.
       
   328         */
       
   329         HBufC* ToStringReceivedDataLC( TBool aToBeThreeDigit = EFalse ) const;
       
   330 
       
   331         /**
       
   332         * Creates a string from transfer speed Up of connection
       
   333         * @return string representation of transfer speed Up of 
       
   334         * connection.
       
   335         */
       
   336         HBufC* ToStringTransferSpeedUpLC() const;
       
   337 
       
   338         /**
       
   339         * Creates a string from transfer speed Down of connection
       
   340         * @return string representation of transfer speed Down of 
       
   341         * connection.
       
   342         */
       
   343         HBufC* ToStringTransferSpeedDownLC() const;
       
   344 
       
   345         /**
       
   346         * Creates a string from duraion of the connection.
       
   347         * @return string representation duraion of the connection.
       
   348         */
       
   349         HBufC* ToStringDurationLC() const;
       
   350 
       
   351         /**
       
   352         * Remove directional markers from a string.
       
   353         * @param aStringHolder the string which markers has to remove.
       
   354         */
       
   355         void StringMarkerRemoval( HBufC* aStringHolder );
       
   356 
       
   357         /**
       
   358         * Remove directional markers from a string.
       
   359         * @param aAppIndex the index of Applicaions names array.
       
   360         * @return string representation of used app. name 
       
   361         */
       
   362         HBufC* ToStringAppNameLC( TInt aAppIndex );
       
   363 
       
   364 
       
   365     private:
       
   366         /**
       
   367         * Creates a string from aLoadedData, extended with measure
       
   368         * @param aLoadedData the data is converted to string
       
   369         * @param aToBeThreeDigit the shown digits numbers limited to three
       
   370         * @param aArrowChar the character representation of arrow (Up/Down)
       
   371         * @return string representation of loaded data 
       
   372         */
       
   373         HBufC* ToStringLoadedDataLC( TUint aLoadedData, 
       
   374                                      TBool aToBeThreeDigit = EFalse,
       
   375                                      const TUint aArrowChar = 0 ) const;
       
   376 
       
   377 
       
   378         /**
       
   379         * Creates a string from transfer speed of connection
       
   380         * @param aSpeed the speed is converted to string
       
   381         * @param aArrowChar the character representation of arrow (Up/Down)
       
   382         * @return string representation of transfer speed of 
       
   383         * connection, extended with measure 
       
   384         */
       
   385         HBufC* ToStringTransferSpeedLC( div_t aSpeed, 
       
   386                                         const TUint aArrowChar ) const;
       
   387 
       
   388         /**
       
   389         * Called if iConnectionStatus is changed to created. Initializes
       
   390         * changable details of connection.
       
   391         */
       
   392         void InitializeConnectionInfoL();
       
   393 
       
   394         /**
       
   395          * Compare the provided UID array with the current cached UID array
       
   396          * iClientBuf.
       
   397          * @param aClients New array of UIDs.
       
   398          * @return ETrue if the contents are the same, EFalse otherwise.
       
   399          */
       
   400         TBool IsTheSameUids( TConnMonClientEnumBuf& aClients );
       
   401 
       
   402         /**
       
   403          * Copy the provided UIDs into the cached UID array.
       
   404          * @param aClients New array of UIDs.
       
   405          */
       
   406         void CopyUidsToBuf( TConnMonClientEnumBuf& aClients );
       
   407 
       
   408     protected:
       
   409         
       
   410         /**
       
   411         * Used for refreshing details of connection.
       
   412         */
       
   413         RConnectionMonitor* const           iConnectionMonitor;   
       
   414 
       
   415         /**
       
   416         * The id of connection, given by RConnectionMonitor.
       
   417         */
       
   418         TUint                               iConnectionId;
       
   419 
       
   420         /**
       
   421         * The name of connection
       
   422         */
       
   423         TName                               iConnectionName;    // IAPName
       
   424         
       
   425         /**
       
   426         * BearerType of connection
       
   427         */
       
   428         TConnMonBearerType                  iConnectionBearerType;
       
   429         
       
   430         /**
       
   431         * The status of connection
       
   432         */
       
   433         TConnectionStatus                   iConnectionStatus;
       
   434 
       
   435         /**
       
   436         * The amount of Uploaded data
       
   437         */
       
   438         TUint                               iUploaded;
       
   439 
       
   440         /**
       
   441         * The amount of Downloaded data
       
   442         */
       
   443         TUint                               iDownloaded;
       
   444 
       
   445         /**
       
   446         * The start time of connection
       
   447         */
       
   448         TTime                               iStartTime;
       
   449 
       
   450         /**
       
   451         * The duration of connection
       
   452         */
       
   453         TTime                               iDuration;
       
   454 
       
   455         /**
       
   456         * Used for calculating speed data
       
   457         */
       
   458         TTime                               iLastSpeedUpdate;
       
   459  
       
   460         /**
       
   461         * The speed of transferring Uploaded data
       
   462         */
       
   463         div_t                               iUpSpeed;
       
   464 
       
   465         /**
       
   466         * The speed of transferring Downloaded data
       
   467         */
       
   468         div_t                               iDownSpeed;
       
   469 
       
   470         /**
       
   471         * The text of list item.
       
   472         */
       
   473         TBuf<KConnectionListItemText>       iListBoxItemText; 
       
   474 
       
   475         /**
       
   476         * Descriptor array, contains details of connection. Owned.
       
   477         */
       
   478         CDesCArrayFlat*                     iDetailsArray;
       
   479         
       
   480         /**
       
   481         * ETrue if deletion of connection started form CMUI, EFalse otherwise
       
   482         */
       
   483         TBool								iDeletedFromCMUI;
       
   484         
       
   485         /**
       
   486         * The names of applications use connection.Owned.
       
   487         */
       
   488         CDesCArrayFlat*                     iAppNames;
       
   489         
       
   490         /**
       
   491         * The active object for info. refreshing. NOT Owned.
       
   492         */
       
   493         CActiveWrapper*                     iActiveWrapper;
       
   494 
       
   495         /**
       
   496          * Buffer to cache a connection's client application UIDs.
       
   497          * These are kept in cache so application names are resolved only when
       
   498          * the client list has changed.
       
   499          */
       
   500         TConnMonClientEnumBuf               iClientBuf;
       
   501     };
       
   502 
       
   503 
       
   504 #endif //CONNECTIONINFOBASE_H_INCLUDED
       
   505 
       
   506 // End of File