menucontentsrv/srvinc/menusrvobject.h
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __MENUSRVOBJECT_H__
       
    19 #define __MENUSRVOBJECT_H__
       
    20 
       
    21 //  INCLUDES
       
    22 
       
    23 #include <e32base.h>
       
    24 
       
    25 // FORWARD DECLARATION
       
    26 
       
    27 class RMessage2;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 * Async request server side base object. Takes ownership of the completion
       
    33 * of one asynchronously completing message.
       
    34 * Derived classes should implement a request method which takes a message
       
    35 * and completes it.
       
    36 */
       
    37 NONSHARABLE_CLASS( CMenuSrvObject ): public CObject
       
    38     {
       
    39 
       
    40 public:     // construction
       
    41 
       
    42     /**
       
    43     * Denstructor. Outstanding message, if any, is completed with cancel.
       
    44     */
       
    45     virtual ~CMenuSrvObject() { Cancel(); }
       
    46 
       
    47     /**
       
    48     * Constructor.
       
    49     */
       
    50     CMenuSrvObject() {}
       
    51 
       
    52 public:     // new methods
       
    53 
       
    54     /**
       
    55     * Cancel request, if any. Base implementation completes the message with
       
    56     * KErrCancel. Override and add real cancellation of outstanding requests.
       
    57     */
       
    58     virtual void Cancel() { Complete( KErrCancel ); }
       
    59 
       
    60 protected:  // new methods
       
    61 
       
    62     /**
       
    63     * Set this message as pending (take ownership of completion).
       
    64     * Call this as LAST thing in the request method,
       
    65     * and DO NOT LEAVE AFTER this is called.
       
    66     * Leaving after this method is called causes double completion of the
       
    67     * message (once by this object, once by the sessions ServiceError()).
       
    68     * @param aMessage Message to complete. Will be completed by this object.
       
    69     */
       
    70     void SetPending( const RMessage2& aMessage );
       
    71 
       
    72     /**
       
    73     * Panic aMessage and leave if this object is pending. Call this as first
       
    74     * thing in request method. (Sanity checking.)
       
    75     * @param aMessage Message.
       
    76     */
       
    77     void PanicIfPendingL( const RMessage2& aMessage );
       
    78 
       
    79     /**
       
    80     * Completes the mesage, if pending. Does nothing if not pending.
       
    81     * @param aReason Completion code.
       
    82     */
       
    83     void Complete( TInt aReason );
       
    84 
       
    85 protected:  // data
       
    86 
       
    87     TBool iPending; ///< Pending. (Owner of an incompleted message).
       
    88     RMessage2 iMessage; ///< The message (valid only if iPending).
       
    89 
       
    90     };
       
    91 
       
    92 #endif // __MENUSRVOBJECT_H__
       
    93             
       
    94 // End of File