phoneclientserver/phoneserver/Inc/Messenger/CPhSrvMessengerObject.h
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     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:  Messenger object. Contains both send and receive request 
       
    15 *                storages.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CPHSRVMESSENGEROBJECT_H
       
    21 #define CPHSRVMESSENGEROBJECT_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 #include "phsrvmessengertypes.h" 
       
    28 #include <cphcltcommandhandler.h> 
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CPhSrvSubSessionBase;
       
    32 
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  Messenger object, i.e. request storage class.
       
    38 *
       
    39 *  @since 2.6
       
    40 */
       
    41 class CPhSrvMessengerObject : public CBase
       
    42     {
       
    43     public:  // Constructors and destructor
       
    44 
       
    45         /**
       
    46         * Two-phased constructor. 
       
    47         *
       
    48         * @param aSubSession The subsession that owns this object.
       
    49         * @param aParameters The Construct parameters.
       
    50         * @return Pointer to created CPhSrvMessengerObject instance.
       
    51         */
       
    52         static CPhSrvMessengerObject* NewLC(
       
    53             CPhSrvSubSessionBase& aSubSession,
       
    54             const TPhCltMessengerParameters& aParameters );
       
    55 
       
    56 
       
    57         /**
       
    58         * Destructor
       
    59         */
       
    60         ~CPhSrvMessengerObject();
       
    61 
       
    62 
       
    63     public: // New functions
       
    64 
       
    65         /**
       
    66         * Tell the external client (the requester) the result of their 
       
    67         * actions. 
       
    68         *
       
    69         * @param aResultOfAttemptingCall 
       
    70         *        The result of executing the Messenger request.
       
    71         * @param aRequest The request which result this is.
       
    72         */
       
    73         void InformOfMessengerRequest( 
       
    74             const TPhCltPhoneResults aResultOfAttemptingRequest,
       
    75             const TPhCltMessengerCommand aRequest );
       
    76 
       
    77 
       
    78         /**
       
    79         * The sub-session handle.
       
    80         *
       
    81         * @return The unique handle associated with the subsession which 
       
    82         *         initiated a command handler request.
       
    83         */
       
    84         TInt SubSessionHandle() const;
       
    85 
       
    86 
       
    87         /**
       
    88         * Sets the given request active. Use IsRequestActive() to check
       
    89         * whether request can be set active or not.
       
    90         *
       
    91         * @param aParameters The request and it's data that is set active.
       
    92         * @param aMessage The request status container.
       
    93         * @param aSentDataId The Id associated for sent message. Valid only
       
    94         *                    if the request is Send.
       
    95         */
       
    96         void SetActive( 
       
    97             const TPhCltMessengerParameters& aParameters,
       
    98             const RMessage2& aMessage,
       
    99             const TUint aSentDataId );
       
   100 
       
   101 
       
   102         /**
       
   103         * Checks if the given request is already active.
       
   104         *
       
   105         * @param aRequest The request which is checked.
       
   106         * @return ETrue if aRequest is active, EFalse otherwise.
       
   107         */
       
   108         TBool IsRequestActive( const TPhCltMessengerCommand aRequest ) const;
       
   109 
       
   110 
       
   111         /**
       
   112         * Check whether this object is ready to receive the message or not.
       
   113         * 
       
   114         * @param aSentMessage The message that should be received.
       
   115         * @param aSentDataId The Id of the sent message to be received.
       
   116         * @return ETrue if object is ready to receive, EFalse otherwise.
       
   117         */
       
   118         TBool IsReadyToReceive( 
       
   119             const TDesC8& aSentMessage,
       
   120             const TUint aSentDataId );
       
   121 
       
   122 
       
   123         /**
       
   124         * Complete the active receive request. Use IsRequestActive() to find
       
   125         * out whether this method can be called.
       
   126         * 
       
   127         * @param aSentMessage The sent message that is given to receiver.
       
   128         * @param aSentDataId The Id of the sent message.
       
   129         * @return KErrNone if the completion was successful, 
       
   130         *         Symbian error code otherwise.
       
   131         */
       
   132         TInt CompleteReceive(
       
   133             const TDesC8& aSentMessage,
       
   134             const TUint aSentDataId );
       
   135 
       
   136 
       
   137         /**
       
   138         * Return objects Send data length.
       
   139         * 
       
   140         * @return The object's Send data length.
       
   141         */
       
   142         TInt GetSendDataLength();
       
   143 
       
   144 
       
   145         /**
       
   146         * Return objects Send data.
       
   147         * 
       
   148         * @param aDes The descriptor that will contain the sent data after 
       
   149         *             return. Use GetSendDataLength() to see how big buffer is
       
   150         *             needed to return whole sent message.
       
   151         */
       
   152         void GetSendData( TDes8& sDes ) const;
       
   153 
       
   154 
       
   155         /**
       
   156         * Return objects interested Uid.
       
   157         * 
       
   158         * @return The Uid of the messages this object is interested.
       
   159         */
       
   160         const TUid& GetUid() const;
       
   161 
       
   162 
       
   163         /**
       
   164         * Return the ID of the sent message.
       
   165         * 
       
   166         * @return The Id of the sent message.
       
   167         */
       
   168         TUint SentDataId();
       
   169 
       
   170 
       
   171         /**
       
   172         * Check if the received message is skipped or not.
       
   173         * 
       
   174         * @return ETrue if the given message is skipped, otherwise EFalse.
       
   175         */
       
   176         TBool IsMessageSkipped(
       
   177             const TUint aSentDataId );
       
   178 
       
   179 
       
   180     private:
       
   181 
       
   182         /**
       
   183         * C++ constructor
       
   184         */
       
   185         CPhSrvMessengerObject(
       
   186             CPhSrvSubSessionBase& aSubSession );
       
   187 
       
   188 
       
   189         /**
       
   190         * By default Symbian 2nd phase constructor is private.
       
   191         */
       
   192         void ConstructL( const TPhCltMessengerParameters& aParameters );
       
   193 
       
   194 
       
   195     private:  // Data
       
   196 
       
   197         // The Messenger object parameters.
       
   198         TPhSrvMessengerParameters      iParameters;
       
   199 
       
   200         // A handle to the subsession that initiated this request.
       
   201         CPhSrvSubSessionBase&          iSubSession;
       
   202     };
       
   203 
       
   204 
       
   205 #endif // CPHSRVMESSENGEROBJECT_H
       
   206 
       
   207 
       
   208 // End of File