landmarks/locationlandmarks/localaccess/inc/EPos_RPosLmLocalAccessSubsession.h
changeset 0 667063e416a2
equal deleted inserted replaced
-1:000000000000 0:667063e416a2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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 a subsession handle with operations related to
       
    15 *  local access.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef RPOSLMLOCALACCESSSUBSESSION_H
       
    22 #define RPOSLMLOCALACCESSSUBSESSION_H
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <EPos_Landmarks.h>
       
    26 #include "epos_cposlmlocaldatabase.h"
       
    27 #include "EPos_CPosLmLocalInitializeOp.h"
       
    28 #include "epos_rposlmlocalnameindex.h"
       
    29 
       
    30 class RPosLandmarkServer;
       
    31 
       
    32 /**
       
    33 *  This class is a subsession handle with operations related to
       
    34 *  local access.
       
    35 *
       
    36 *  @lib eposlmlocalaccess.lib
       
    37 *  @since S60 3.0
       
    38 */
       
    39 class RPosLmLocalAccessSubsession : public RSubSessionBase
       
    40     {
       
    41     friend class RPosLmLocalNameIndex;
       
    42     public:
       
    43 
       
    44         /**
       
    45         * C++ default constructor.
       
    46         *
       
    47         */
       
    48         RPosLmLocalAccessSubsession();
       
    49 
       
    50         /**
       
    51         * Creates a local access subsession with the Landmarks Server.
       
    52         *
       
    53         * @param[in] aServer Is a connected session with the Landmarks Server.
       
    54         * @return @p KErrNone if successful, otherwise one of the system-wide
       
    55         * error codes.
       
    56         */
       
    57         TInt Open( RPosLandmarkServer& aServer );
       
    58 
       
    59         /**
       
    60         * Closes the subsession.
       
    61         */
       
    62         void Close();
       
    63 
       
    64         /**
       
    65         * Registers the session at the server by sending the database URI to it.
       
    66         * @param[in] aUri Database URI.
       
    67         */
       
    68         void RegisterSessionL( const TDesC& aUri );
       
    69 
       
    70         /**
       
    71         * Listens for a database event from the server.
       
    72         *
       
    73         * @param[out] aEvent Will contain the event information when an event
       
    74         *   occurs.
       
    75         * @param[out] aStatus Will be completed with @p KErrNone if an event
       
    76         *   occurs and an error code if some error was encountered.
       
    77         */
       
    78         void NotifyDatabaseEvent( TPosLmEvent& aEvent, TRequestStatus& aStatus );
       
    79 
       
    80         /**
       
    81         * Cancels a call to @ref NotifyDatabaseEvent.
       
    82         *
       
    83         * @return @p KErrNone if the request was successfully cancelled,
       
    84         *   otherwise a system wide error code.
       
    85         */
       
    86         TInt CancelNotifyDatabaseEvent();
       
    87 
       
    88         /**
       
    89         * Reports an event in the Landmarks Server.
       
    90         * @param[in] aEventType Type of event.
       
    91         * @param[in] aId Optional landmarks ID.
       
    92         * @return KErrNone if successful. Otherwise any system-wide error code.
       
    93         */
       
    94         TInt ReportEvent(
       
    95             TPosLmEventType aEventType,
       
    96             TPosLmItemId aId = KPosLmNullItemId );
       
    97 
       
    98         /**
       
    99         * Sets a lock on the database.
       
   100         *
       
   101         * @param aLockType The type of lock to set.
       
   102         * @return KErrNone if successful, otherwise KErrLocked or one of the
       
   103         *   other system wide error codes.
       
   104         */
       
   105         TInt SetDatabaseLock( CPosLmLocalDatabase::TLockType aLockType );
       
   106 
       
   107         /**
       
   108         * Releases a lock on the database.
       
   109         *
       
   110         * @param aLockType The type of lock to set.
       
   111         * @return KErrNone if successful, otherwise KErrLocked or one of the
       
   112         *   other system wide error codes.
       
   113         */
       
   114         TInt ReleaseDatabaseLock( CPosLmLocalDatabase::TLockType aLockType );
       
   115 
       
   116         /**
       
   117         * Sends a message to the Landmarks Server to create the default
       
   118         * database.
       
   119         *
       
   120         * @param[in] aUri Database URI.
       
   121         * @param[in] aReplaceDb Boolean whether database should be replaced or not.
       
   122         */
       
   123         void CreateDefaultDbL( const TDesC& aUri, TBool aReplaceDb );
       
   124 
       
   125         /**
       
   126         * Initializes the database synchronously.
       
   127         *
       
   128         * @param aInitType The type of initialization.
       
   129         * @return KErrNone if successful or one of the other system wide error
       
   130         *  codes.
       
   131         */
       
   132         TInt InitializeDbSync(
       
   133             CPosLmLocalInitializeOp::TInitializeType aInitType );
       
   134 
       
   135         /**
       
   136         * Initializes the database asynchronously.
       
   137         *
       
   138         * @param[in] aInitType The type of initialization.
       
   139         * @param[in,out] aStatusPckg The status of the initialization.
       
   140         * @param[in,out] aProgressPckg The progress of the initialization.
       
   141         * @param[in,out] aInitFlagPckg The init flag to update after the
       
   142         *   initialization.
       
   143         * @param[out] aStatus The request status of the initialization.
       
   144         */
       
   145         void InitializeDbAsync(
       
   146             CPosLmLocalInitializeOp::TInitializeType aInitType,
       
   147             TPckgBuf<TInt>* aStatusPckg,
       
   148             TPckg<TReal32>* aProgressPckg,
       
   149             TPckg<TUint>* aInitFlagPckg,
       
   150             TRequestStatus& aStatus );
       
   151 
       
   152         /**
       
   153         * Cancels a call to @ref InitializeDbAsync.
       
   154         *
       
   155         * @param aInitType The type of initialization.
       
   156         * @return @p KErrNone if the request was successfully cancelled,
       
   157         *   otherwise a system wide error code.
       
   158         */
       
   159         TInt CancelInitializeDbAsync(
       
   160             CPosLmLocalInitializeOp::TInitializeType aInitType );
       
   161 
       
   162     private:
       
   163 
       
   164         // By default, prohibit copy constructor
       
   165         RPosLmLocalAccessSubsession(
       
   166             const RPosLmLocalAccessSubsession&);
       
   167         // Prohibit assigment operator
       
   168         RPosLmLocalAccessSubsession& operator=(
       
   169             const RPosLmLocalAccessSubsession&);
       
   170 
       
   171     private:    // Data
       
   172 
       
   173         TPtr8 iEventPtr;
       
   174 
       
   175     };
       
   176 
       
   177 #endif      // RPOSLMLOCALACCESSSUBSESSION_H