syncmlfw/ds/adapterlog/inc/NSmlAdapterLog.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 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:  AdapterLog header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef NSMLADAPTERLOG_H
       
    21 #define NSMLADAPTERLOG_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <f32file.h>
       
    25 #include <d32dbms.h>
       
    26 #include <SmlDataSyncDefs.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // Default drive, where adapter log is stored
       
    31 const TInt KNSmlAdapterLogDrive = EDriveC;
       
    32 
       
    33 
       
    34 // Dictionary stores' filenames
       
    35 // These are store to private path of process
       
    36 _LIT(KNSmlAdapterLogStore, "nsmladapterlog%d.dat");
       
    37 
       
    38 // Database name
       
    39 // This is stored to DBMS server
       
    40 _LIT(KNSmlAdapterLogDbName, "c:nsmladapterlog.db");
       
    41 
       
    42 // Database tables
       
    43 _LIT(KNSmlTableAdapterLog, "AdapterLog");
       
    44 
       
    45 // AdapterLog table columns
       
    46 _LIT(KNSmlAdapterLogId, "Id");
       
    47 _LIT(KNSmlAdapterLogImplementationUID, "ImplementationUID");
       
    48 _LIT(KNSmlAdapterLogLocalDatabase, "LocalDatabase");
       
    49 _LIT(KNSmlAdapterLogServerId, "ServerId");
       
    50 _LIT(KNSmlAdapterLogRemoteDatabase, "RemoteDatabase");
       
    51 
       
    52 // SQL query
       
    53 _LIT(KSqlGetAdapterLogRow, "SELECT * FROM AdapterLog WHERE ImplementationUID \
       
    54 = %d AND LocalDatabase = '%S' AND ServerId = '%S' AND RemoteDatabase = '%S'" );
       
    55 
       
    56 // row from known server id
       
    57 _LIT(KSqlGetAdapterLogRowFromServerId, "SELECT * FROM AdapterLog WHERE ServerId = '%S'" );
       
    58 
       
    59 
       
    60 // FORWARD DECLARATIONS
       
    61 class CDictionaryStore;
       
    62 
       
    63 
       
    64 // CLASS DECLARATION
       
    65 
       
    66 /**
       
    67 *  CNSmlAdapterLog.
       
    68 *
       
    69 *  @lib NSmlAdapterLog.lib
       
    70 *  @since Series 60 3.0 
       
    71 */
       
    72 class CNSmlAdapterLog : public CBase, public MSmlSyncRelationship
       
    73     {
       
    74     public:  // Constructors and destructor
       
    75         
       
    76         /**
       
    77         * Creates a new instance of the CNSmlAdapterLog class.
       
    78         * The method also creates the AdapterLog database if it does not
       
    79         * exist.
       
    80         */
       
    81         IMPORT_C static CNSmlAdapterLog* NewL();
       
    82         
       
    83         /**
       
    84         * Creates a new instance of the CNSmlAdapterLog class. Method
       
    85         * pushes and leaves the created instance on the cleanup stack.
       
    86         * The method also creates the AdapterLog database if it does not
       
    87         * exist.
       
    88         */
       
    89         IMPORT_C static CNSmlAdapterLog* NewLC();
       
    90         
       
    91         /**
       
    92         * Destructor.
       
    93         */
       
    94         ~CNSmlAdapterLog();
       
    95 
       
    96     public: // New functions
       
    97         
       
    98         /**
       
    99         * Sets the adapter log key with given values.
       
   100         * @param aImplUid Implementation UID.
       
   101         * @param aLocalDB Local database name.
       
   102         * @param aServerId Remote server ID.
       
   103         * @param Remote database name.
       
   104         */
       
   105         IMPORT_C void SetAdapterLogKeyL(const TInt aImplUid,
       
   106                                         const TDesC& aLocalDB,
       
   107                                         const TDesC& aServerId,
       
   108                                         const TDesC& aRemoteDB);
       
   109 		/**
       
   110 		* Replaces the give old server ID with new one.
       
   111         * @param aOldServerId Old remote server ID.
       
   112 		* @param aNewValue New remote server ID.
       
   113 		*/
       
   114 		IMPORT_C void SetServerIdL( TDesC& aOldServerId, TDesC& aNewValue );
       
   115                                               
       
   116     public: // Functions from base classes
       
   117     
       
   118       	/**
       
   119       	* From MSmlSyncRelationship. Returns the unique identifier for the
       
   120       	* synchronisation relationship.
       
   121       	* @return Unique synchronisation task key.
       
   122         */
       
   123         IMPORT_C TSmlSyncTaskKey SyncTaskKey() const;
       
   124         
       
   125         /**
       
   126         * From MSmlSyncRelationship. Opens a specified stream for reading, and
       
   127         * places an item on the cleanup stack to close it.
       
   128         * @param aReadStream Stream to be opened for reading.
       
   129         * @param aStreamUid UID specifying the stream.
       
   130 		*/
       
   131 		IMPORT_C void OpenReadStreamLC(RReadStream& aReadStream,
       
   132 		                               TUid aStreamUid);
       
   133 		
       
   134 		/**
       
   135 		* From MSmlSyncRelationship. Opens the specified stream, or creates a
       
   136 		* new one if it does not exist, and places an item on the cleanup stack
       
   137 		* to close it.
       
   138 		* @param aWriteStream Stream to be opened for writing.
       
   139 		* @param aStreamUid UID specifying the stream.
       
   140 		*/
       
   141 		IMPORT_C void OpenWriteStreamLC(RWriteStream& aWriteStream,
       
   142 		                                TUid aStreamUid);
       
   143 		
       
   144 		/**
       
   145 		* From MSmlSyncRelationship. Tests if the specified stream identified
       
   146 		* exists in the store.
       
   147 		* @param aStreamUid UID specifying the stream.
       
   148 		* @return ETrue, if specified stream is present.
       
   149 		*/
       
   150 		IMPORT_C TBool IsStreamPresentL(TUid aStreamUid) const;
       
   151       
       
   152     private:
       
   153 
       
   154         /**
       
   155         * C++ default constructor.
       
   156         */
       
   157         CNSmlAdapterLog();
       
   158 
       
   159         /**
       
   160         * Symbian 2nd phase constructor.
       
   161         */
       
   162         void ConstructL();
       
   163 
       
   164         void CreateDatabaseL(const TDesC& aFullName);
       
   165         TInt GenerateIdL();
       
   166         void OpenDictionaryStoreL();
       
   167         
       
   168     private:    // Data
       
   169         
       
   170         TInt iID;
       
   171 
       
   172         RDbNamedDatabase iDatabase;
       
   173         RFs iFsSession;
       
   174         RDbs iRdbSession;
       
   175 
       
   176         RDbTable iTable;
       
   177         CDbColSet* iColSet;
       
   178         RDbView iView;
       
   179         
       
   180         CDictionaryStore* iDictionaryStore;
       
   181         
       
   182         HBufC* iPath;
       
   183         static const TInt KMaxPathLength = 256;
       
   184     };
       
   185 
       
   186 #endif      // NSMLADAPTERLOG_H   
       
   187             
       
   188 // End of File