locationcentre/lcserver/inc/lcregappstore.h
branchRCL_3
changeset 16 4721bd00d3da
parent 14 3a25f69541ff
child 21 e15b7f06eba6
equal deleted inserted replaced
14:3a25f69541ff 16:4721bd00d3da
     1 /*
       
     2 * Copyright (c) 2007 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:  Location Centre Server object.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_LCREGAPPSTORE_H
       
    20 #define C_LCREGAPPSTORE_H
       
    21 
       
    22 // SYSTEM INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include <d32dbms.h>    // RDbStoreDatabase
       
    26 
       
    27 // USER INCLUDES
       
    28 
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CFileStore;
       
    32 
       
    33 /**
       
    34  *  Implementation of Location Centre private storage info class.
       
    35  *
       
    36  *  This class provides the implementation of private 
       
    37  *  storage of Location Centre Registration info(services) using 
       
    38  *  symbian DBMS API.
       
    39  */
       
    40 NONSHARABLE_CLASS( CLcRegAppStore )  : public CBase
       
    41     {
       
    42 public:
       
    43    /**
       
    44     * Enum to detect wheather Db is created or not
       
    45     */
       
    46     enum TLcDbStatus
       
    47         {
       
    48         // Db is successfully created
       
    49         ELcDbCreate = 0,
       
    50         // Db is successfully opened
       
    51         ELcDbOpen
       
    52         };
       
    53     
       
    54     /**
       
    55      * Constructs a new instance of CLcRegAppStore.
       
    56      *
       
    57      * @return The new instance of CLcRegAppStore object.
       
    58      * @leave System wide error code if the object creation fails.         
       
    59      */
       
    60     static CLcRegAppStore* NewL( RFs&  aFs );
       
    61     
       
    62     /**
       
    63      * Constructs a new instance of CLcRegAppStore.
       
    64      * Leaves the created instance on the cleanup stack.
       
    65      *
       
    66      * @return The new instance of CLcRegAppStore object.
       
    67      * @leave System wide error code if the object creation fails.         
       
    68      */
       
    69     static CLcRegAppStore* NewLC( RFs&  aFs );        
       
    70 
       
    71     /**
       
    72      * C++ Destructor.
       
    73      * Frees all the resources associated with this Location Centre
       
    74      * server private file handler
       
    75      */
       
    76     virtual ~CLcRegAppStore();
       
    77     
       
    78 
       
    79 public:    
       
    80     /**
       
    81      * This function return the first column and first row 
       
    82      * value which is Uuid.After externalize this we extract 
       
    83      * all the seperate Uuid's of dynamically registered services
       
    84      *
       
    85      * @since S60 v5.0
       
    86      * @param aUuid[ out ] contains the packed Uuid value.
       
    87      */
       
    88 	void GetUuidValueL( TDes8& aUuid );
       
    89 
       
    90     /**
       
    91      * This function insert this packed Uuid value at first column
       
    92      * and first row of the app info database for first time and then do Update
       
    93      *
       
    94      * @since S60 v5.0
       
    95      * @param aAppUid[ in ] Packed Uuid value.
       
    96      * @return 
       
    97      */
       
    98 	void AddDataToTableL( const TDesC8& aAppUid );
       
    99 	
       
   100 private:
       
   101     /**
       
   102      * C++ Default constructor
       
   103      */
       
   104     CLcRegAppStore( RFs&  aFs );
       
   105     
       
   106     /**
       
   107      * Second phase of the two phase constructor
       
   108      */
       
   109     void ConstructL();
       
   110 
       
   111 private: // private API for database operations
       
   112     /**
       
   113      * Open existing app info database in exclusive
       
   114      * (non-shared) mode.
       
   115      * 
       
   116      * @since S60 v5.0
       
   117      * @param aRegAppInfoFile	is full path to app info
       
   118      *              			database file.
       
   119      */
       
   120     void OpenDbL( const TFileName& aRegAppInfoFile );
       
   121 
       
   122     /**
       
   123      *  Creates and opens a new app info database. Creates a
       
   124      *  database file, table structure and an index. The database
       
   125      *  will be open in exclusive (non-shareable) mode. The
       
   126      *  database must be closed, when not used any more. If the
       
   127      *  database exists, it is replaced.
       
   128      * 
       
   129      * @since S60 v5.0
       
   130      * @param aRegAppInfoFile	is full path to app info
       
   131      *              			database file.
       
   132      */
       
   133     void CreateDbL( const TFileName& aRegAppInfoFile );
       
   134 
       
   135     /**
       
   136 	 * Closes the database opened with either OpenDbL or
       
   137      * CreateDbL. It is safe to close the database even if it
       
   138      * is closed.
       
   139      * 
       
   140      * @since S60 v5.0
       
   141      * @param None
       
   142      * @return None.
       
   143      */
       
   144     void Close();    
       
   145 
       
   146     /**
       
   147      * This function creates the app info table.
       
   148      *
       
   149      * @since S60 v5.0
       
   150      * @param None
       
   151      */
       
   152     void CreateAppInfoTableL();
       
   153 
       
   154 
       
   155 private: // Member data
       
   156 	// File server reference comming from the lcregistry
       
   157 	// used for iFileStore
       
   158     RFs&              	iFsSession;
       
   159     
       
   160     // For database operations
       
   161     RDbStoreDatabase 	iRegAppInfoDb;
       
   162     
       
   163     //own: For creating and opening database files 
       
   164     CFileStore*      	iFileStore;
       
   165     
       
   166     // holds the database file name
       
   167     TFileName			iLcRegdbFile;
       
   168     
       
   169     // holds the db creation status
       
   170     TLcDbStatus         iDbStatus;
       
   171     };
       
   172     
       
   173 #endif // C_LCREGAPPSTORE_H