connectionmonitoring/connectionmonitorui/inc/ConnectionInfoBase.h
changeset 0 5a93021fdf25
child 2 086aae6fc07e
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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         * Gives back the name of connection 
       
   197         * @return the name of connection 
       
   198         */
       
   199         HBufC* GetNameLC() const;        
       
   200         
       
   201         /**
       
   202         * Gives back the bearertype of connection 
       
   203         * @return the bearertype of connection 
       
   204         */
       
   205         TConnMonBearerType GetBearerType() const;
       
   206         
       
   207         /**
       
   208         * Gives back a pointer the iListBoxItemText of connection 
       
   209         * @return the iListBoxItemText of connection 
       
   210         */
       
   211         TPtrC GetConnectionListBoxItemText() const;
       
   212 
       
   213         /**
       
   214         * Check if connection name is starts with "mRouter" string or not.
       
   215         * ( if this connection is not IR/BT )
       
   216         * @retrun ETrue if starts wiht "mRouter", EFalse otherwise.
       
   217         */
       
   218         TBool CheckMrouterIap();
       
   219     
       
   220     protected:
       
   221         /**
       
   222         * Creates a string for DetailsListBoxItem, title came from resource 
       
   223         * and value from aValueText
       
   224         * @param aResourceId a resource id
       
   225         * @param aValueText the value of text
       
   226         * @retrun  a string consist of resource and value text
       
   227         */
       
   228         HBufC*  ToDetailsListBoxItemTextL( const TUint aResourceId, 
       
   229                                            const HBufC* aValueText ) const;
       
   230 
       
   231         /**
       
   232         * Creates a string for DetailsListBoxItem, title came from resource 
       
   233         * and value from aValueText, and Appends to iDetailsArray
       
   234         * @param aResourceId a resource id
       
   235         * @param aValueText the value of text
       
   236         */
       
   237         void  ToDetailsListBoxItemTextWithAppendL( const TUint aResourceId, 
       
   238                                                    const HBufC* aValueText );
       
   239 
       
   240         /**
       
   241         * Creates a string for DetailsListBoxItem, title came from resource 
       
   242         * and value from aValueText, and Replaces the given element with it
       
   243         * @param aResourceId a resource id
       
   244         * @param aValueText the value of text
       
   245         */
       
   246         void  ToDetailsListBoxItemTextWithReplaceL( const TUint aResourceId, 
       
   247                                                     const HBufC* aValueText,
       
   248                                                     TInt aIndex );
       
   249 
       
   250 
       
   251         /**
       
   252         * Creates an array with requrired details of connection to
       
   253         * the listbox which visulaize details of connection. This member
       
   254         * is called at initialization.
       
   255         */
       
   256         virtual void ToArrayDetailsL() = 0;
       
   257 
       
   258         /**
       
   259         * Refresh status of connection
       
   260         */
       
   261         void RefreshConnectionStatus();
       
   262 
       
   263         /**
       
   264         * Refresh status of connection
       
   265         * @param aConnectionStatus new status of connection
       
   266         */
       
   267         void RefreshConnectionStatus( 
       
   268                                    const TConnectionStatus aConnectionStatus );
       
   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     protected:
       
   396         
       
   397         /**
       
   398         * Used for refreshing details of connection.
       
   399         */
       
   400         RConnectionMonitor* const           iConnectionMonitor;   
       
   401 
       
   402         /**
       
   403         * The id of connection, given by RConnectionMonitor.
       
   404         */
       
   405         TUint                               iConnectionId;
       
   406 
       
   407         /**
       
   408         * The name of connection
       
   409         */
       
   410         TName                               iConnectionName;    // IAPName
       
   411         
       
   412         /**
       
   413         * BearerType of connection
       
   414         */
       
   415         TConnMonBearerType                  iConnectionBearerType;
       
   416         
       
   417         /**
       
   418         * The status of connection
       
   419         */
       
   420         TConnectionStatus                   iConnectionStatus;
       
   421 
       
   422         /**
       
   423         * The amount of Uploaded data
       
   424         */
       
   425         TUint                               iUploaded;
       
   426 
       
   427         /**
       
   428         * The amount of Downloaded data
       
   429         */
       
   430         TUint                               iDownloaded;
       
   431 
       
   432         /**
       
   433         * The start time of connection
       
   434         */
       
   435         TTime                               iStartTime;
       
   436 
       
   437         /**
       
   438         * The duration of connection
       
   439         */
       
   440         TTime                               iDuration;
       
   441 
       
   442         /**
       
   443         * Used for calculating speed data
       
   444         */
       
   445         TTime                               iLastSpeedUpdate;
       
   446  
       
   447         /**
       
   448         * The speed of transferring Uploaded data
       
   449         */
       
   450         div_t                               iUpSpeed;
       
   451 
       
   452         /**
       
   453         * The speed of transferring Downloaded data
       
   454         */
       
   455         div_t                               iDownSpeed;
       
   456 
       
   457         /**
       
   458         * The text of list item.
       
   459         */
       
   460         TBuf<KConnectionListItemText>       iListBoxItemText; 
       
   461 
       
   462         /**
       
   463         * Descriptor array, contains details of connection. Owned.
       
   464         */
       
   465         CDesCArrayFlat*                     iDetailsArray;
       
   466         
       
   467         /**
       
   468         * ETrue if deletion of connection started form CMUI, EFalse otherwise
       
   469         */
       
   470         TBool								iDeletedFromCMUI;
       
   471         
       
   472         /**
       
   473         * The names of applications use connection.Owned.
       
   474         */
       
   475         CDesCArrayFlat*                     iAppNames;
       
   476         
       
   477         /**
       
   478         * The active object for info. refreshing. NOT Owned.
       
   479         */
       
   480         CActiveWrapper*                     iActiveWrapper;
       
   481     };
       
   482 
       
   483 
       
   484 #endif //CONNECTIONINFOBASE_H_INCLUDED
       
   485 
       
   486 // End of File