phoneclientserver/phoneclient/Inc/Messenger/RPhCltMessenger.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:  This class is used to perform messenger originated commands.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef RPhCltMessenger_H
       
    20 #define RPhCltMessenger_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <cphcltmessenger.h> 
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class RPhCltServer;
       
    29 
       
    30 
       
    31 /**
       
    32 *  Messenger interface: provides two-way communication between 
       
    33 *  two or more clients.
       
    34 *
       
    35 * @lib PhoneClient.lib 
       
    36 * @since 3.2
       
    37 *  
       
    38 */
       
    39 class RPhCltMessenger
       
    40 :   public RSubSessionBase
       
    41     {
       
    42     public:  // Constructors and destructor
       
    43         
       
    44         /**
       
    45         * Constructor.
       
    46         */
       
    47         RPhCltMessenger();
       
    48 
       
    49         /**
       
    50         * Desstructor.
       
    51         */
       
    52         ~RPhCltMessenger();
       
    53 
       
    54 
       
    55     public:
       
    56 
       
    57         /**
       
    58         * Open session ready to be sending and receiving messages.
       
    59         *
       
    60         * @param aServer      Pre-opened server session.
       
    61         * @param aCategoryUid Category of messages to be sent or received.
       
    62         *                     Note that there can be many kinds of message uids
       
    63         *                     below one category uid.
       
    64         * @param aDefaultMessageSize The default size of the messages to be sent
       
    65         *                            or received, In bytes. Can be bigger than 
       
    66         *                            KPhCltDefMesSize, but then functionality
       
    67         *                            is not guaranteed.
       
    68         * @return Error code. KErrNone if successful.
       
    69         */
       
    70         TInt Open(
       
    71             RPhCltServer& aServer,
       
    72             const TUid& aCategoryUid,
       
    73             const TInt& aDefaultMessageSize );
       
    74 
       
    75 
       
    76         /**
       
    77         * Closes the session.
       
    78         */
       
    79         void Close();
       
    80 
       
    81 
       
    82         /**
       
    83         * Receives next message. No memory is allocated during the operation of
       
    84         * this method.
       
    85         * 
       
    86         * @param aStatus This request will be completed once message has been 
       
    87         *                received.
       
    88         * @param aMessageSize Tells the size of the received message. If smaller
       
    89         *        than the size of the aMessagePayload, then only the beginning 
       
    90         *        of the received message is copied to aMessagePayload.
       
    91         *                     
       
    92         * @param aMessagePayload Payload of the message. Contains the TUid at 
       
    93         *                        the beginning of the message when completed.
       
    94         */ 
       
    95         void Receive(
       
    96             TRequestStatus& aStatus,
       
    97             TInt& aMessageSize,
       
    98             TDes8& aMessagePayload );
       
    99 
       
   100 
       
   101         /**
       
   102         * Sends message. This is completed only after message has been
       
   103         * delivered to receiver.
       
   104         * No memory is allocated during the operation of this method.
       
   105         * 
       
   106         * @param aStatus This request will be completed once message has been 
       
   107         *                sent.
       
   108         * @param aMessagePayload Payload of the message.
       
   109         */
       
   110         void Send(
       
   111             TRequestStatus& aStatus,
       
   112             const TDesC8& aMessagePayload );
       
   113 
       
   114 
       
   115         /**
       
   116         * Cancel request. This method should only be called during destruction 
       
   117         * to make sure that messages are not missed.
       
   118         * 
       
   119         * @param aRequest request to be canceled.
       
   120         */
       
   121         void CancelRequest( const TPhCltMessengerRequest& aRequest );
       
   122 
       
   123 
       
   124         /**
       
   125         * Skip one message. This method should be called only if Receive 
       
   126         * indicates that there is not enough space in aMessagePayload.
       
   127         * Of course, you should attempt to recover, i.e. call Receive with big 
       
   128         * enough aMessagePayload buffer before calling this method.
       
   129         */
       
   130         void Skip();
       
   131 
       
   132 
       
   133     private:    // Data
       
   134 
       
   135         // Container for received message size.
       
   136         TPtr8                               iReceiveMessageSize;
       
   137 
       
   138         // Used in Receive and Send methods to contain the parameters.
       
   139         TPhCltMessengerParameters           iMessengerParameters;
       
   140 
       
   141         // The packaged version of the iMessengerParameters.
       
   142         TPckg< TPhCltMessengerParameters >  iMesParPckg;
       
   143 
       
   144     };
       
   145 
       
   146 #endif      // RPhCltMessenger_H
       
   147 
       
   148 // End of File