locsrv_plat/map_and_navigation_provider_api/inc/mnservicebase.h
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  CMnServiceBase class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MN_SERVICEBASE_H
       
    20 #define MN_SERVICEBASE_H
       
    21 
       
    22 #include <AknServerApp.h>
       
    23 
       
    24 class CPosLandmark;
       
    25 
       
    26 /** @brief Base class for all Map and Navigation services.
       
    27  *
       
    28  *  Its only purpose is to provide common base functionality for Map and Navigation
       
    29  *  service classes.
       
    30  *
       
    31  *  There are both synchronous and asynchronous request handlers defined in derived
       
    32  *  service base classes. Implementations of handlers shall behave as follows.
       
    33  *  <ul>
       
    34  *  <li>For Synchronous requests:</li>
       
    35  *  <ul>
       
    36  *  <li>Exit normally to report successful completion</li>
       
    37  *  <li>Leave with error code to report error</li>
       
    38  *  </ul>
       
    39  *  <li>For Asynchronous requests:</li>
       
    40  *  <ul>
       
    41  *  <li>Exit normally as soon as possible. Call dedicated Complete method
       
    42  *      to report successful completion</li>
       
    43  *  <li>Leave with error code to report error found during execution of
       
    44  *      Handle method</li>
       
    45  *  <li>Call CompleteRequest method with error code to report error
       
    46  *      found after execution of Handle method</li>
       
    47  *  <li>Call CancelRequest method to report that user has cancelled
       
    48  *      execution</li>
       
    49  *  </ul>
       
    50  *  </ul>
       
    51  *
       
    52  *  Following error codes shall be used by implementation to report specific cases:
       
    53  *  - KErrCancel - If user has cancelled operation.
       
    54  *  - KErrArgument - If given argument cannot be used for operation. For example, landmark has
       
    55  *          no coordinate or address and cannot be shown on map or address information
       
    56  *          is not sufficient for geocoding.
       
    57  *  - KErrNotSupported - If service feature is not supported, or cannot be executed with given parameters.
       
    58  *          For example, map content not available for specified area etc.
       
    59  *
       
    60  *  @since 3.1
       
    61  *  @lib mnservicelib.lib
       
    62  *  @ingroup MnProviderAPI
       
    63  */
       
    64 class CMnServiceBase : public CAknAppServiceBase
       
    65     {
       
    66     public :
       
    67 
       
    68         /** @brief Completes current asynchronous request.
       
    69          *
       
    70          *  Called by implementations to complete client's request. Used
       
    71          *  by service implementations to report errors during execution
       
    72          *  of asynchronous requests. To report successful completion,
       
    73          *  special methods defined by service base classes should be used
       
    74          *  (e.g. @ref CMnMapViewServiceBase::CompleteSelectionRequest)
       
    75          *
       
    76          *  For synchronous requests, handler should
       
    77          *  just leave if error is detected.
       
    78          *
       
    79          *  @param aResult Error code.
       
    80          *
       
    81          *  @panic "MnPanicServer"-KMnPanicAttemptToCompleteNoRequest
       
    82          *      This method called during execution of synchronous request.
       
    83          */
       
    84         IMPORT_C void CompleteRequest( TInt aResult );
       
    85 
       
    86     protected :
       
    87         /** C++ constructor */
       
    88         CMnServiceBase();
       
    89         /** Destructor */
       
    90         ~CMnServiceBase();
       
    91 
       
    92         /** \internal */
       
    93         void BaseConstructL();
       
    94 
       
    95         /** @brief Reports that client cancelled request.
       
    96          *
       
    97          *  Called by framework to report that request was
       
    98          *  cancelled by client application. Service implementations
       
    99          *  must implement this method. It is not needed to call
       
   100          *  @ref CompleteRequest() in this case.
       
   101          */
       
   102         virtual void DoCancel() =0;
       
   103 
       
   104     protected: // internal methods
       
   105 
       
   106         /** \internal
       
   107          *  Completes client's message
       
   108          */
       
   109         void Complete( const RMessage2& aMsg, TInt aResult );
       
   110 
       
   111         /** \internal
       
   112          *  Informs derived implementation (by calling DoCancel())
       
   113          *  that current async request has been cancelled by client and
       
   114          *  completes it with KErrCancel.
       
   115          */
       
   116         void HandleCancelRequestL( const RMessage2& aMsg );
       
   117 
       
   118         /** \internal
       
   119         * Copies an 8-bit buffer from the address space of the client and puts
       
   120         * the result in the returned argument.
       
   121         *
       
   122         * @param aMessage the message from the client.
       
   123         * @param aClientBufferParam index of message parameter to read as buffer
       
   124         * @return a copy of the client buffer.
       
   125         */
       
   126         static HBufC8* CopyClientBuffer8LC(
       
   127             const RMessage2& aMessage,
       
   128             const TInt aClientBufferParam );
       
   129 
       
   130         /** \internal
       
   131         * Copies a 16-bit buffer from the address space of the client and puts
       
   132         * the result in the returned argument.
       
   133         *
       
   134         * @param aMessage the message from the client.
       
   135         * @param aClientBufferParam index of message parameter to read as buffer
       
   136         * @return a copy of the client buffer.
       
   137         */
       
   138         static HBufC* CopyClientBufferLC(
       
   139             const RMessage2& aMessage,
       
   140             const TInt aClientBufferParam );
       
   141 
       
   142         /** \internal
       
   143          *  Unpacks landmark from client's message.
       
   144          *  @param  aMsg client's message
       
   145          *  @param  aParamIndex index of landmark parameter in message
       
   146          *  @return new copy instance of client's landmark
       
   147          */
       
   148         CPosLandmark* UnpackLandmarkLC( const RMessage2& aMsg, TInt aParamIndex );
       
   149 
       
   150         /** @internal */
       
   151         TInt CurrentAsyncRequest();
       
   152         /** @internal */
       
   153         TBool IsAsyncRequestActive();
       
   154         /** @internal */
       
   155         void PrepareAsyncRequestL( const RMessage2& aMessage );
       
   156 
       
   157     protected:  // from CApaAppServiceBase
       
   158         /** @internal */
       
   159         IMPORT_C void ServiceError( const RMessage2 &aMessage, TInt aError );
       
   160 
       
   161     protected:
       
   162         RMessage2   iMessage;
       
   163 
       
   164     private:
       
   165         TInt        iCurrentRequest;
       
   166     };
       
   167 
       
   168 #endif // MN_SERVICEBASE_H
       
   169