connectionmonitoring/connmon/connectionmonitor/inc/CPsdFax.h
changeset 0 5a93021fdf25
child 71 9f263f780e41
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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:  PSD fax connection information.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPSDFAX_H
       
    19 #define __CPSDFAX_H
       
    20 
       
    21 #include <etel.h>
       
    22 #include <etelmm.h>
       
    23 #include <etelpckt.h>
       
    24 #include <pcktcs.h>
       
    25 #include <rconnmon.h>
       
    26 
       
    27 #include "ConnMonDef.h"
       
    28 
       
    29 class CConnMonServer;
       
    30 class CPsdFaxUpNotifier;
       
    31 class CPsdFaxStatusNotifier;
       
    32 class CPsdFaxConnectionData;
       
    33 
       
    34 _LIT( KExternalName, "external" );
       
    35 
       
    36 // max PSD connection number
       
    37 const TInt KMaxPsdConnectionCount = 2;
       
    38 
       
    39 
       
    40 /**
       
    41  * CPsdFax
       
    42  * @lib CONMONN.LIB
       
    43  */
       
    44 NONSHARABLE_CLASS( CPsdFax ) : public CBase
       
    45     {
       
    46     public:
       
    47         // constructors and destructor
       
    48         CPsdFax(
       
    49                 CConnMonServer* aServer,
       
    50                 RTelServer* aTelServer,
       
    51                 RMobilePhone* aMobilePhone,
       
    52                 RPacketService* aPacketService );
       
    53 
       
    54         void ConstructL();
       
    55         ~CPsdFax();
       
    56 
       
    57         /**
       
    58         * Opens the PDP context.
       
    59         * @since
       
    60         * @param aIndex The index of the PSD connection data table.
       
    61         * @param aName The name of the context.
       
    62         * @return KErrNone if successfull, otherwise a system wide error code.
       
    63         */
       
    64         TInt OpenContext( const TUint aIndex, const TDes& aName );
       
    65 
       
    66         /**
       
    67         * Checks if external PDP context is still valid.
       
    68         * @since
       
    69         * @param aConnectionId The connection ID of the PSD connection.
       
    70         * @return ETrue if context is valid, EFalse otherwise.
       
    71         */
       
    72         TBool IsValid( const TUint aConnectionId );
       
    73 
       
    74         /**
       
    75         * Checks PSD connection data table index
       
    76         * @since
       
    77         * @param aConnectionId The connection ID of the PSD connection.
       
    78         * @return index if found, ohterwise otherwise a system wide error code.
       
    79         */
       
    80         TInt ConnectionIndex( const TUint aConnectionId );
       
    81 
       
    82         /**
       
    83         * Sets connection ID
       
    84         * @since
       
    85         * @param aIndex The connection index of the PSD connection.
       
    86         * @param aConnectionId The connection ID of the PSD connection.
       
    87         * @return KErrNone if successfull, otherwise a system wide error code.
       
    88         */
       
    89         TInt SetConnectionId( const TUint aIndex, const TUint aConnectionId );
       
    90 
       
    91         /**
       
    92         * Gets the fax bearer.
       
    93         * @since
       
    94         * @param aBearer On return, contains the bearer.
       
    95         * @param aBearerInfo On return, contains the detailed(new concept) bearer.
       
    96         * @return KErrNone if successfull, otherwise a system wide error code.
       
    97         */
       
    98         TInt GetBearer( TInt& aBearer, TBearerInfo& aBearerInfo );
       
    99 
       
   100         /**
       
   101         * Gets the access point name of the fax connection.
       
   102         * @since
       
   103         * @param aConnectionId The connection ID of the PSD connection.
       
   104         * @param aName On return, contains the access point name.
       
   105         * @return KErrNone if successfull, otherwise a system wide error code.
       
   106         */
       
   107         TInt GetApn( const TUint aConnectionId, TDes& aName );
       
   108 
       
   109         /**
       
   110         * Gets the protocol type of the fax connection.
       
   111         * @since
       
   112         * @param aConnectionId The connection ID of the PSD connection.
       
   113         * @param aProtocolType On return, contains the protocol type.
       
   114         * @return KErrNone if successfull, otherwise a system wide error code.
       
   115         */
       
   116         TInt GetProtocolType( const TUint aConnectionId, TInt& aProtocolType );
       
   117 
       
   118         /**
       
   119         * Gets the status of the fax connection.
       
   120         * @since
       
   121         * @param aConnectionId The connection ID of the PSD connection.
       
   122         * @param aStatus On return, contains the connection status.
       
   123         * @return KErrNone if successfull, otherwise a system wide error code.
       
   124         */
       
   125         TInt GetStatus( const TUint aConnectionId, TInt& aStatus );
       
   126 
       
   127         /**
       
   128         * Gets the amount of data sent and received (in bytes).
       
   129         * @since
       
   130         * @param aConnectionId The connection ID of the PSD connection.
       
   131         * @param aDLVolume On return, contains the amount received data.
       
   132         * @param aULVolume On return, contains the amount sent data.
       
   133         * @return KErrNone if successfull, otherwise a system wide error code.
       
   134         */
       
   135         TInt GetDataVolumes( const TUint aConnectionId, TUint& aDLVolume, TUint& aULVolume );
       
   136 
       
   137         /**
       
   138         * Gets the amount of data sent and received (in bytes).
       
   139         * @since
       
   140         * @param aConnectionId The connection ID of the PSD connection.
       
   141         * @param aTime On return, contains start time of the connection.
       
   142         * @return KErrNone if successfull, otherwise a system wide error code.
       
   143         */
       
   144         TInt GetStartTime( const TUint aConnectionId, TTime& aTime );
       
   145 
       
   146         /**
       
   147         * Stops the external connection.
       
   148         * @since
       
   149         * @param aConnectionId The connection ID of the PSD connection.
       
   150         * @return KErrNone if successfull, otherwise a system wide error code.
       
   151         */
       
   152         TInt Stop( const TUint aConnectionId );
       
   153 
       
   154          /**
       
   155         * Delete connections allocated recources.
       
   156         * @since
       
   157         * @return void
       
   158         */
       
   159         void DeleteConnections();
       
   160 
       
   161     private:
       
   162 
       
   163     private: // Data
       
   164         // Pointer to ConnMon server
       
   165         CConnMonServer* iServer;
       
   166 
       
   167         // Pointer to ETel server
       
   168         RTelServer* iTelServer;
       
   169 
       
   170         // Pointer to mobile phone
       
   171         RMobilePhone* iMobilePhone;
       
   172 
       
   173         // Pointer to the packet service
       
   174         RPacketService* iPacketService;
       
   175 
       
   176         // Connection up event watcher
       
   177         CPsdFaxUpNotifier* iConnUpNotifier;
       
   178 
       
   179         // Data table for each connection
       
   180         CPsdFaxConnectionData* iConnectionData[KMaxPsdConnectionCount];
       
   181     };
       
   182 
       
   183 
       
   184 /**
       
   185  * CPsdFaxUpNotifier
       
   186  * @lib CONNMON.LIB
       
   187  */
       
   188 NONSHARABLE_CLASS( CPsdFaxUpNotifier ) : public CActive
       
   189     {
       
   190     public: // Constructors and destructor
       
   191         CPsdFaxUpNotifier(
       
   192                 CPsdFax* aFaxModule,
       
   193                 CConnMonServer* aServer,
       
   194                 RPacketService* aPacketService );
       
   195 
       
   196         void Construct();
       
   197         ~CPsdFaxUpNotifier();
       
   198 
       
   199     public:  // New methods
       
   200         /**
       
   201         * Requests a new event (connection up) from ETEL.
       
   202         * @since
       
   203         * @param
       
   204         * @return void
       
   205         */
       
   206         void Receive();
       
   207 
       
   208     private: // Methods from base classes
       
   209          /**
       
   210         * From CActive Cancels the asyncronous request
       
   211         * @since
       
   212         * @param
       
   213         * @return void
       
   214         */
       
   215         void DoCancel();
       
   216 
       
   217          /**
       
   218         * From CActive Handles the the event that has arrived from ETEL.
       
   219         * @since
       
   220         * @param
       
   221         * @return void
       
   222         */
       
   223         void RunL();
       
   224 
       
   225     private: // Data
       
   226         CPsdFax*        iFaxModule;
       
   227         CConnMonServer* iServer;
       
   228         RPacketService* iPacketService;
       
   229         TBuf<KMaxName>  iName;
       
   230         TEventInfo      iEventInfo;
       
   231     };
       
   232 
       
   233 
       
   234 /**
       
   235  * CPsdFaxConnectionData
       
   236  * @lib CONNMON.LIB
       
   237  */
       
   238 NONSHARABLE_CLASS( CPsdFaxConnectionData ) : public CBase
       
   239     {
       
   240     public: // Constructors and destructor
       
   241         CPsdFaxConnectionData(
       
   242                 CPsdFax* aFaxModule,
       
   243                 CConnMonServer* aServer,
       
   244                 RPacketService* aPacketService );
       
   245 
       
   246         void ConstructL();
       
   247         TInt Construct();
       
   248         ~CPsdFaxConnectionData();
       
   249 
       
   250         /**
       
   251         * Opens the PDP context.
       
   252         * @since
       
   253         * @param aName The name of the context.
       
   254         * @return KErrNone if successfull, otherwise a system wide error code.
       
   255         */
       
   256         TInt OpenContext( const TDes& aName );
       
   257 
       
   258         /**
       
   259         * Closes the PDP context.
       
   260         * @since
       
   261         * @return void
       
   262         */
       
   263         void CloseContext();
       
   264 
       
   265         /**
       
   266         * Checks if the PDP context is open.
       
   267         * @since
       
   268         * @return ETrue if context is open, EFalse otherwise.
       
   269         */
       
   270         TBool IsOpen();
       
   271 
       
   272         /**
       
   273         * Gets the amount of data sent and received (in bytes).
       
   274         * @since
       
   275         * @param aDLVolume On return, contains the amount received data.
       
   276         * @param aULVolume On return, contains the amount sent data.
       
   277         * @return KErrNone if successfull, otherwise a system wide error code.
       
   278         */
       
   279         TInt GetDataVolumes( TUint& aDLVolume, TUint& aULVolume ) const;
       
   280 
       
   281         /**
       
   282         * Stops the external connection.
       
   283         * @since
       
   284         * @return KErrNone if successfull, otherwise a system wide error code.
       
   285         */
       
   286         TInt Stop();
       
   287 
       
   288         /**
       
   289         * Removes connection from server tables.
       
   290         * @since
       
   291         * @return void.
       
   292         */
       
   293         void RemoveFromServer();
       
   294 
       
   295         /**
       
   296         * Sets connection ID.
       
   297         * @since
       
   298         * @param aConnectionId The connection ID of the PSD connection.
       
   299         * @return void.
       
   300         */
       
   301         void SetConnectionId( const TUint& aConnectionId );
       
   302 
       
   303         /**
       
   304         * Gets connection ID.
       
   305         * @since
       
   306         * @return connection ID.
       
   307         */
       
   308         TUint ConnectionId() const;
       
   309 
       
   310         /**
       
   311         * Resets connection start time.
       
   312         * @since
       
   313         * @return void.
       
   314         */
       
   315         void ResetStartTime();
       
   316 
       
   317         /**
       
   318         * Gets connection start time.
       
   319         * @since
       
   320         * @return KErrNone if successfull, otherwise a system wide error code.
       
   321         */
       
   322         TInt GetStartTime( TTime& aTime ) const;
       
   323 
       
   324         /**
       
   325         * Gets the access point name of the fax connection.
       
   326         * @since
       
   327         * @param aName On return, contains the access point name.
       
   328         * @return KErrNone if successfull, otherwise a system wide error code.
       
   329         */
       
   330         TInt GetApn( TDes& aName );
       
   331 
       
   332         /**
       
   333         * Converts the access point name to correct format (UNICODE).
       
   334         * @since
       
   335         * @param aResult On return, contains the access point name in correct format.
       
   336         * @param aName Access point name in the original format (UNICODE).
       
   337         * @return void.
       
   338         */
       
   339         void ConvertAPN( TDes& aResult, const TDesC& aName ) const ;
       
   340 
       
   341         /**
       
   342         * Converts the access point name to correct format (UNICODE).
       
   343         * @since
       
   344         * @param aResult On return, contains the access point name in correct format.
       
   345         * @param aName Access point name in the original format (UTF8).
       
   346         * @return void.
       
   347         */
       
   348         void ConvertAPN( TDes& aResult, const TDesC8& aName ) const;
       
   349 
       
   350         /**
       
   351         * Gets the protocl type of the fax connection.
       
   352         * @since
       
   353         * @param aProtocolType On return, contains the protocol type.
       
   354         * @return KErrNone if successfull, otherwise a system wide error code.
       
   355         */
       
   356         TInt GetProtocolType( TInt& aProtocolType );
       
   357 
       
   358         /**
       
   359         * Gets the status of the fax connection.
       
   360         * @since
       
   361         * @param aStatus On return, contains the connection status.
       
   362         * @return KErrNone if successfull, otherwise a system wide error code.
       
   363         */
       
   364         TInt GetStatus( TInt& aStatus ) const;
       
   365 
       
   366         /**
       
   367         * Maps the PDP context status to nifvar values
       
   368         * @since
       
   369         * @param aStatus On return, contains the mapped connection status.
       
   370         * @return KErrNone if successfull, otherwise a system wide error code.
       
   371         */
       
   372         TInt MapStatus( TInt& aStatus ) const;
       
   373 
       
   374         /**
       
   375         * Checks if the context is closed.
       
   376         * @since
       
   377         * @return ETrue if context is closed, EFalse otherwise.
       
   378         */
       
   379         TBool IsEnded();
       
   380 
       
   381 
       
   382     private:
       
   383         // Connection ID
       
   384         TUint iConnectionId;
       
   385 
       
   386         // ETrue if context is open
       
   387         TBool iOpen;
       
   388 
       
   389         // ETrue if start time is valid
       
   390         TBool iTimeValid;
       
   391 
       
   392         // ETrue if connection has been up and then ended (killed)
       
   393         TBool iEnded;
       
   394 
       
   395         // Start time
       
   396         TTime iStartTime;
       
   397 
       
   398         // Open fax context
       
   399         RPacketContext iContext;
       
   400 
       
   401         // pointer to PsdFax module
       
   402         CPsdFax* iFaxModule;
       
   403 
       
   404         // pointer to ConnMon server
       
   405         CConnMonServer* iServer;
       
   406 
       
   407         // pointer to packet service
       
   408         RPacketService* iPacketService;
       
   409 
       
   410         // Connection status event watcher
       
   411         CPsdFaxStatusNotifier* iStatusNotifier;
       
   412     };
       
   413 
       
   414 
       
   415 /**
       
   416  * CPsdFaxStatusNotifier
       
   417  * @lib CONNMON.LIB
       
   418  */
       
   419 NONSHARABLE_CLASS( CPsdFaxStatusNotifier ) : public CActive
       
   420     {
       
   421     public: // Constructors and destructor
       
   422         CPsdFaxStatusNotifier(
       
   423                 CPsdFax* aFaxModule,
       
   424                 CConnMonServer* aServer,
       
   425                 RPacketService* aPacketService,
       
   426                 CPsdFaxConnectionData* aConnDataModule );
       
   427 
       
   428         void Construct();
       
   429         ~CPsdFaxStatusNotifier();
       
   430 
       
   431     public:  // New methods
       
   432         /**
       
   433         * Starts listening to status change events from ETEL.
       
   434         * @since
       
   435         * @param aContext The open context to listen to.
       
   436         * @return void
       
   437         */
       
   438         void Start( const RPacketContext& aContext );
       
   439 
       
   440         /**
       
   441         * Requests a new event (status changed) from ETEL.
       
   442         * @since
       
   443         * @param
       
   444         * @return void
       
   445         */
       
   446         void Receive();
       
   447 
       
   448     private: // Methods from base classes
       
   449          /**
       
   450         * From CActive Cancels the asyncronous request
       
   451         * @since
       
   452         * @param
       
   453         * @return void
       
   454         */
       
   455         void DoCancel();
       
   456 
       
   457          /**
       
   458         * From CActive Handles the the event that has arrived from ETEL.
       
   459         * @since
       
   460         * @param
       
   461         * @return void
       
   462         */
       
   463         void RunL();
       
   464 
       
   465     private:  // New methods
       
   466         /**
       
   467         * Sends connection create event to client.
       
   468         * @since
       
   469         * @return KErrNone if successfull, otherwise a system wide error code.
       
   470         */
       
   471         TInt SendConnectionCreateEvent();
       
   472 
       
   473     private: // Data
       
   474         CPsdFax*                       iFaxModule;
       
   475         CConnMonServer*                iServer;
       
   476         RPacketService*                iPacketService;
       
   477         CPsdFaxConnectionData*         iConnDataModule;
       
   478         TEventInfo                     iEventInfo;
       
   479         RPacketContext                 iContext;
       
   480         RPacketContext::TContextStatus iContextStatus;
       
   481 
       
   482     };
       
   483 
       
   484 #endif // __CPSDFAX_H
       
   485 
       
   486 // End-of-file