atext/server/inc/atextsession.h
changeset 0 29b1cd4cb562
child 16 9f17f914e828
equal deleted inserted replaced
-1:000000000000 0:29b1cd4cb562
       
     1 /*
       
     2 * Copyright (c) 2008-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:  The session object for ATEXT server
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_ATEXTSESSION_H
       
    20 #define C_ATEXTSESSION_H
       
    21 
       
    22 #include <e32svr.h>
       
    23 #include "atextpluginobserver.h"
       
    24 #include "atextmetadata.h"
       
    25 #include "atextlisten.h"
       
    26 
       
    27 class CATExtSrv;
       
    28 class CDesC8ArraySeg;
       
    29 class CATExtPluginBase;
       
    30 class CATExtMetadata;
       
    31 
       
    32 /**
       
    33  *  Manages separate ATEXT server sessions for client(s)
       
    34  *
       
    35  *  @since S60 v5.0
       
    36  */
       
    37 NONSHARABLE_CLASS( CATExtSession ) : public CSession2,
       
    38                                      public MATExtPluginObserver,
       
    39                                      public MATExtListen
       
    40     {
       
    41 
       
    42 friend class CATExtMetadata;
       
    43 
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Two-phased constructor.
       
    48      * @param aServer
       
    49      * @return Instance of self
       
    50      */
       
    51     static CATExtSession* NewL( CATExtSrv& aServer, const TVersion& aVersion );
       
    52 
       
    53     /**
       
    54     * Destructor.
       
    55     */
       
    56     ~CATExtSession();
       
    57 
       
    58 private:
       
    59 
       
    60 // from base class CSession2
       
    61 
       
    62     /**
       
    63      * From CSession2.
       
    64      * Handles the servicing of client requests passed to the server
       
    65      *
       
    66      * @since S60 5.0
       
    67      * @param aMessage Message containing the client request
       
    68      * @return None
       
    69      */
       
    70     void ServiceL( const RMessage2& aMessage );
       
    71 
       
    72     CATExtSession( CATExtSrv& aServer, const TVersion& aVersion );
       
    73 
       
    74     /**
       
    75      * Handles the servicing of client requests passed to the server
       
    76      *
       
    77      * @since S60 5.0
       
    78      * @param aMessage Message containing the client request
       
    79      * @return None
       
    80      */
       
    81     void DoServiceL( const RMessage2& aMessage );
       
    82 
       
    83     /**
       
    84      * Handles the servicing of setting up interface
       
    85      *
       
    86      * @since S60 5.0
       
    87      * @param aMessage Message for Connect() client call
       
    88      * @return None
       
    89      */
       
    90     void IpcSetInterfaceL( const RMessage2& aMessage );
       
    91 
       
    92     /**
       
    93      * Synchronously closes the session
       
    94      * Optional: client can do either Close() or SynchronousClose()+Close()
       
    95      *
       
    96      * @since S60 5.0
       
    97      * @param aMessage Message for SynchronousClose() client call
       
    98      * @return None
       
    99      */
       
   100     TInt IpcSynchronousClose( const RMessage2& aMessage );
       
   101 
       
   102     /**
       
   103      * Handles the servicing of AT commands
       
   104      *
       
   105      * @since S60 5.0
       
   106      * @param aMessage Message for HandleCommand() client call
       
   107      * @return Symbian error code on error, KErrNone otherwise
       
   108      */
       
   109     TInt IpcHandleCommand( const RMessage2& aMessage );
       
   110 
       
   111     /**
       
   112      * Handles the servicing of pending AT command cancel
       
   113      *
       
   114      * @since S60 5.0
       
   115      * @param aMessage Message for CancelHandleCommand() client call
       
   116      * @return Symbian error code on error, KErrNone otherwise
       
   117      */
       
   118     TInt IpcCancelHandleCommand( const RMessage2& aMessage );
       
   119 
       
   120     /**
       
   121      * Handles the servicing of getting the next part of a reply for
       
   122      * IpcHandleCommand().
       
   123      *
       
   124      * @since S60 5.0
       
   125      * @param aMessage Message for GetNextPartOfReply() client call
       
   126      * @return Symbian error code on error, KErrNone otherwise
       
   127      */
       
   128     TInt IpcGetNextPartOfReply( const RMessage2& aMessage );
       
   129 
       
   130     /**
       
   131      * Handles the servicing of number of plugins. This information is needed
       
   132      * to instantiate one or more listeners by the user of the client.
       
   133      *
       
   134      * @since S60 5.0
       
   135      * @param aMessage Message for NumberOfPlugins() client call
       
   136      * @return Symbian error code on error, KErrNone otherwise
       
   137      */
       
   138     TInt IpcNumberOfPlugins( const RMessage2& aMessage );
       
   139 
       
   140     /**
       
   141      * Handles the servicing of receiving unsolicited result codes. Note that
       
   142      * IpcMarkUrcHandlingOwnership() must be called immediately after this in
       
   143      * order for the message to receive their destination.
       
   144      *
       
   145      * @since S60 5.0
       
   146      * @param aMessage Message for ReceiveUnsolicitedResult() client call
       
   147      * @return Symbian error code on error, KErrNone otherwise
       
   148      */
       
   149     TInt IpcReceiveUnsolicitedResult( const RMessage2& aMessage );
       
   150 
       
   151     /**
       
   152      * Handles the servicing of pending receiving unsolicited result code
       
   153      * cancel
       
   154      *
       
   155      * @since S60 5.0
       
   156      * @param aMessage Message for CancelReceiveUnsolicitedResult() client call
       
   157      * @return Symbian error code on error, KErrNone otherwise
       
   158      */
       
   159     TInt IpcCancelReceiveUrc( const RMessage2& aMessage );
       
   160 
       
   161     /**
       
   162      * Handles the servicing of marking URC handling ownership.
       
   163      * Call to this function must be done immediately after the call to
       
   164      * IpcReceiveUnsolicitedResult().
       
   165      *
       
   166      * @since S60 5.0
       
   167      * @param aMessage Message for MarkUrcHandlingOwnership() client call
       
   168      * @return Symbian error code on error, KErrNone otherwise
       
   169      */
       
   170     TInt IpcMarkUrcHandlingOwnership( const RMessage2& aMessage );
       
   171 
       
   172     /**
       
   173      * Handles the servicing of ECOM plugin change notifications
       
   174      *
       
   175      * @since S60 5.0
       
   176      * @param aMessage Message for ReceiveEcomPluginChange() client call
       
   177      * @return Symbian error code on error, KErrNone otherwise
       
   178      */
       
   179     TInt IpcReceiveEcomPluginChange( const RMessage2& aMessage );
       
   180 
       
   181     /**
       
   182      * Handles the servicing of pending ECOM plugin change notification cancel
       
   183      *
       
   184      * @since S60 5.0
       
   185      * @param aMessage Message for CancelReceiveEcomPluginChange() client call
       
   186      * @return Symbian error code on error, KErrNone otherwise
       
   187      */
       
   188     TInt IpcCancelReceiveEcomPluginChange( const RMessage2& aMessage );
       
   189 
       
   190     /**
       
   191      * Handles the servicing of quiet mode change reporting.
       
   192      * When quiet mode is on the behavior is the same as with AT command
       
   193      * "ATQ1: Result code suppression". When quiet mode is on then verbose mode
       
   194      * setting has no effect.
       
   195      *
       
   196      * @since S60 5.0
       
   197      * @param aMessage Message for ReportQuietModeChange() client call
       
   198      * @return Symbian error code on error, KErrNone otherwise
       
   199      */
       
   200     TInt IpcReportQuietModeChange( const RMessage2& aMessage );
       
   201 
       
   202     /**
       
   203      * Handles the servicing of verbose mode change reporting.
       
   204      * When verbose mode is on the behavior is the same as with AT command
       
   205      * "ATV1: DCE Response format". If quiet mode is on then this setting has no
       
   206      * effect.
       
   207      *
       
   208      * @since S60 5.0
       
   209      * @param aMessage Message for ReportVerboseModeChange() client call
       
   210      * @return Symbian error code on error, KErrNone otherwise
       
   211      */
       
   212     TInt IpcReportVerboseModeChange( const RMessage2& aMessage );
       
   213 
       
   214     /**
       
   215      * Handles the servicing of character change reporting.
       
   216      * The change to carriage return, line feed and backspace characters is
       
   217      * reported to CATExtPluginBase's protected data so that the it can easily
       
   218      * be used by the plugin implementation.
       
   219      *
       
   220      * @since S60 5.0
       
   221      * @param aMessage Message for ReportCharacterChange() client call
       
   222      * @return Symbian error code on error, KErrNone otherwise
       
   223      */
       
   224     TInt IpcReportCharacterChange( const RMessage2& aMessage );
       
   225 
       
   226     /**
       
   227      * Handles the servicing of reporting listener update readiness.
       
   228      * Client side listener has to use this after it has updates its own
       
   229      * internal states after ECOM plugin change notification.
       
   230      *
       
   231      * @since S60 5.0
       
   232      * @param aMessage Message for ReportListenerUpdateReady() client call
       
   233      * @return Symbian error code on error, KErrNone otherwise
       
   234      */
       
   235     TInt IpcReportListenerUpdateReady( const RMessage2& aMessage );
       
   236 
       
   237     /**
       
   238      * Handles the servicing of NVRAM status change broadcasting.
       
   239      * The NVRAM status change is broadcasted to all of the plugins.
       
   240      *
       
   241      * @since S60 5.0
       
   242      * @param aMessage Message for BroadcastNvramStatusChange() client call
       
   243      * @return Symbian error code on error, KErrNone otherwise
       
   244      */
       
   245     TInt IpcBroadcastNvramStatusChange( const RMessage2& aMessage );
       
   246 
       
   247     /**
       
   248      * Handles the servicing of reporting about external handle command error
       
   249      * condition.
       
   250      * This is for cases when for example DUN decided the reply contained an
       
   251      * error condition but the plugin is still handling the command internally.
       
   252      * Example: "AT+TEST;+TEST2" was given in command line; "AT+TEST" returns
       
   253      * non-EReplyTypeError condition and "AT+TEST2" returns EReplyTypeError.
       
   254      * As the plugin(s) returning the non-EReplyTypeError may still have some
       
   255      * ongoing operation then these plugins are notified about the external
       
   256      * EReplyTypeError in command line processing. It is to be noted that
       
   257      * HandleCommandCancel() is not sufficient to stop the processing as the
       
   258      * command handling has already finished.
       
   259      *
       
   260      * @since S60 5.0
       
   261      * @param aMessage Message for ReportExternalHandleCommandError() client call
       
   262      * @return Symbian error code on error, KErrNone otherwise
       
   263      */
       
   264     TInt IpcReportExternalHandleCommandError( const RMessage2& aMessage );
       
   265 
       
   266     /**
       
   267      * Handles the servicing of reporting about abort condition in command
       
   268      * handling.
       
   269      * This is for cases when for example DUN decided an abort condition was
       
   270      * received from DTE (ITU-T V.250 5.6.1). This API is for notifying the
       
   271      * plugin that abort was requested. However the plugin currently handling
       
   272      * the command may ignore the request if it doesn't support abort for the
       
   273      * command or it may return the changed condition with
       
   274      * HandleCommandCompleted()
       
   275      *
       
   276      * @since S60 5.0
       
   277      * @param aMessage Message for ReportExternalHandleCommandError() client call
       
   278      * @return Symbian error code on error, KErrNone otherwise
       
   279      */
       
   280     TInt IpcReportHandleCommandAbort( const RMessage2& aMessage );
       
   281 
       
   282     /**
       
   283      * Handles the servicing of getting the next special command RSS file entry.
       
   284      * These commands are commands with a matching start but with any ending
       
   285      * sequence. Command "ATD*99***1#" is one of these and the number of thse
       
   286      * commands should be kept minimal.
       
   287      *
       
   288      * @since S60 5.0
       
   289      * @param aMessage Message for GetNextSpecialCommand() client call
       
   290      * @return Symbian error code on error, KErrNone otherwise
       
   291      */
       
   292     TInt IpcGetNextSpecialCommand( const RMessage2& aMessage );
       
   293 
       
   294     /**
       
   295      * Reads a string from a message
       
   296      *
       
   297      * @since S60 5.0
       
   298      * @param aBuffer Destination buffer to which to read the string
       
   299      * @param aDataSlot Slot for the aMessage from where to read the string
       
   300      * @param aMessage Message from where the string is to be read
       
   301      * @return Symbian error code on error, KErrNone otherwise
       
   302      */
       
   303     TInt ReadStringFromMessage( RBuf8& aBuffer,
       
   304                                 TInt aDataSlot,
       
   305                                 const RMessage2& aMessage );
       
   306 
       
   307     /**
       
   308      * Reads a struct from a message
       
   309      *
       
   310      * @since S60 5.0
       
   311      * @param aBuffer Destination buffer to which to read the struct
       
   312      * @param aDataSlot Slot for the aMessage from where to read the struct
       
   313      * @param aMessage Message from where the struct is to be read
       
   314      * @return Symbian error code on error, KErrNone otherwise
       
   315      */
       
   316     TInt ReadStructFromMessage( TDes8& aBuffer,
       
   317                                 TInt aDataSlot,
       
   318                                 const RMessage2& aMessage );
       
   319 
       
   320     /**
       
   321      * Destructs objects/associations for the current session
       
   322      *
       
   323      * @since S60 5.0
       
   324      * @param aSyncClose ETrue if synchronous close, EFalse if Close()
       
   325      * @return None
       
   326      */
       
   327     void Destruct( TBool aSyncClose );
       
   328 
       
   329 // from base class MATExtPluginObserver
       
   330 
       
   331     /**
       
   332      * From MATExtPluginObserver.
       
   333      * Called by extension plugins when there is an unsolicited result code
       
   334      * should be sent to destination.
       
   335      *
       
   336      * Each AT Extension Plugin is responsible to format
       
   337      * result codes properly, e.g. in BT HFP case, the
       
   338      * format should be <cr><lf><result code><cr><lf>
       
   339      *
       
   340      * @since S60 v5.0
       
   341      * @param aPlugin Plugin from which the URC comes
       
   342      * @param aAT the unsolicited result code to be sent.
       
   343      * @return Symbian error code on error, KErrNone otherwise
       
   344      */
       
   345     TInt SendUnsolicitedResult( CATExtPluginBase* aPlugin, const TDesC8& aAT );
       
   346 
       
   347     /**
       
   348      * From MATExtPluginObserver.
       
   349      * Called by Extension Plugins to inform ATEXT that a command
       
   350      * handling has been completed or rejected.
       
   351      *
       
   352      * @since S60 v5.0
       
   353      * @param aPlugin Plugin from which the completion comes
       
   354      * @param aError Error code for completion
       
   355      * @param aReplyType Reply type for the handled AT command
       
   356      * @return Symbian error code on error, KErrNone otherwise
       
   357      */
       
   358     TInt HandleCommandCompleted( CATExtPluginBase* aPlugin,
       
   359                                  TInt aError,
       
   360                                  TATExtensionReplyType aReplyType );
       
   361 
       
   362     /**
       
   363      * From MATExtPluginObserver.
       
   364      * Called by concrete extension plugin to inform the array of supported
       
   365      * commands should be returned
       
   366      *
       
   367      * @since S60 5.0
       
   368      * @param aPlugin Plugin from which the completion comes
       
   369      * @param aCmd Array of supported commands
       
   370      * @return Symbian error code on error, KErrNone otherwise
       
   371      */
       
   372     TInt GetSupportedCommands( CATExtPluginBase* aPlugin,
       
   373                                RPointerArray<HBufC8>& aCmds );
       
   374 
       
   375     /**
       
   376      * From MATExtPluginObserver.
       
   377      * Called by the destructor of CATExtPluginBase.
       
   378      * A concrete service provider implementation should not touch this.
       
   379      *
       
   380      * @param aPlugin Plugin from which the closing comes
       
   381      * @return Symbian error code on error, KErrNone otherwise
       
   382      */
       
   383     TInt ATExtPluginClosed( CATExtPluginBase* aPlugin );
       
   384 
       
   385 // from base class MATExtListen
       
   386 
       
   387     /**
       
   388      * From MATExtListen.
       
   389      * Notifies about an installed plugin.
       
   390      *
       
   391      * @since S60 5.0
       
   392      * @param aPluginUid UID of installed plugin's interface
       
   393      * @param aPluginUid UID of installed plugin
       
   394      * @return Symbian error code on error, KErrNone otherwise
       
   395      */
       
   396     TInt NotifyPluginInstallation( TUid& aIfUid,
       
   397                                    CImplementationInformation* aImplInfo );
       
   398 
       
   399     /**
       
   400      * From MATExtListen.
       
   401      * Notifies about an uninstalled plugin.
       
   402      *
       
   403      * @since S60 5.0
       
   404      * @param aPluginUid UID of uninstalled plugin's interface
       
   405      * @param aPluginUid UID of uninstalled plugin
       
   406      * @return Symbian error code on error, KErrNone otherwise
       
   407      */
       
   408     TInt NotifyPluginUninstallation( TUid& aIfUid,
       
   409                                      TUid& aPluginUid );
       
   410 
       
   411 private:  // data
       
   412 
       
   413     /**
       
   414      * The server
       
   415      */
       
   416     CATExtSrv& iServer;
       
   417 
       
   418     /**
       
   419      * Session to ECOM
       
   420      */
       
   421     REComSession iEComSession;
       
   422 
       
   423     /**
       
   424      * ECOM listener
       
   425      * Own.
       
   426      */
       
   427     CATExtListen* iListener;
       
   428 
       
   429     /**
       
   430      * Metadata
       
   431      * Own.
       
   432      */
       
   433     CATExtMetadata* iMetadata;
       
   434 
       
   435     /**
       
   436      * Version of server
       
   437      */
       
   438     TVersion iVersion;
       
   439 
       
   440     /**
       
   441      * ECOM status message
       
   442      */
       
   443     RMessage2 iEcomStatusMessage;
       
   444 
       
   445     };
       
   446 
       
   447 #endif  // C_ATEXTSESSION_H