syncmlfw/ds/settings/inc/nsmlroam.h
changeset 0 b497e44ab2fc
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2004 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:  Multiple bearers
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __NSMLROAM_H_
       
    20 #define __NSMLROAM_H_
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 #include <f32file.h> 
       
    25 #include <s32file.h> 
       
    26 #include <d32dbms.h>
       
    27 
       
    28 //#define __MODULETEST
       
    29 
       
    30 #ifdef __MODULETEST
       
    31 #include "../test/DSSettingsTester/inc/NSmlTest.h"
       
    32 #endif
       
    33 
       
    34 _LIT(KColProfileId, "profileid");
       
    35 _LIT(KColIapId, "iapid");
       
    36 _LIT(KColPriority, "priority");
       
    37 _LIT(KTable, "iaptable");
       
    38 
       
    39 _LIT(KSQLCreateTable, "CREATE TABLE iaptable ( profileid INTEGER NOT NULL, priority INTEGER NOT NULL, iapid UNSIGNED INTEGER )");
       
    40 _LIT(KSQLCreateIndex, "CREATE UNIQUE INDEX iapindex  ON iaptable ( profileid, priority)");
       
    41 _LIT(KSQLDeleteForId, "DELETE FROM iaptable WHERE profileid = %d");
       
    42 _LIT(KSQLInsertQuery, "INSERT INTO iaptable ( profileid, priority, iapid) VALUES (%d, %d, %d)");
       
    43 _LIT(KSQLMatchQuery2, "SELECT profileid, priority, iapid FROM iaptable");
       
    44 _LIT(KSQLSelectUint, "SELECT  profileid, priority, iapid FROM iaptable WHERE profileid = %d and priority = %d");
       
    45 _LIT(KSQLMultiQuery, "SELECT  profileid, priority, iapid FROM iaptable WHERE profileid = %d");
       
    46 
       
    47 const TUint8 KNSmlMaxSQLLength = 100;
       
    48 
       
    49 class CNSmlRoamTable;
       
    50 		
       
    51 class CNSmlRoamItem : public CBase
       
    52 	{
       
    53 	public:
       
    54 		/**
       
    55         * Constructor
       
    56         * @return -
       
    57 		*/
       
    58 		CNSmlRoamItem();
       
    59 
       
    60 		/**
       
    61         * Constructor
       
    62         * @return -
       
    63 		*/
       
    64 		CNSmlRoamItem(TInt aProfileId, TUint32 aIAPId, TInt aPriority);
       
    65 		
       
    66 		/**
       
    67         * Destructor
       
    68         * @return -
       
    69 		*/
       
    70 		virtual ~CNSmlRoamItem();
       
    71 		
       
    72 		/**
       
    73         * TInt ProfileId()
       
    74         * @return - Profile id
       
    75 		*/
       
    76 		inline TInt ProfileId();
       
    77 
       
    78 		/**
       
    79         * TUint32 IapId()
       
    80         * @return - IAP id
       
    81 		*/
       
    82 		inline TUint32 IapId();
       
    83 
       
    84 		/**
       
    85         * TInt Priority()
       
    86         * @return - Priority
       
    87 		*/
       
    88 		inline TInt Priority();
       
    89 			
       
    90 	private:
       
    91 		friend class CNSmlRoamTable;
       
    92 		TInt iProfileId;
       
    93 		TUint32 iIAPId;
       
    94 		TInt iPriority;
       
    95 	};
       
    96 
       
    97 typedef CArrayPtr<CNSmlRoamItem> CNSmlRoamItemArray;
       
    98 typedef CArrayFixFlat<TUint32> CNSmlIAPArray;
       
    99 
       
   100 
       
   101 class CNSmlRoamTable : public CBase
       
   102 	{
       
   103 	public:
       
   104 
       
   105 		/**
       
   106         * Constructor
       
   107 		* NewLC(RDbNamedDatabase& aDatabase)
       
   108 		* @param - Reference to RDBNamedDatabase
       
   109         * @return -  CNSmlRoamTable instance pointer
       
   110 		*/
       
   111 		IMPORT_C static CNSmlRoamTable* NewLC(RDbNamedDatabase& aDatabase);
       
   112 		
       
   113 		/**
       
   114         * Constructor
       
   115 		* NewL(RDbNamedDatabase& aDatabase)
       
   116 		* @param - Reference to RDBNamedDatabase
       
   117         * @return - CNSmlRoamTable instance pointer
       
   118 		*/
       
   119 		IMPORT_C static CNSmlRoamTable* NewL(RDbNamedDatabase& aDatabase);
       
   120 		
       
   121 		/**
       
   122         * Destructor
       
   123         * @return - 
       
   124 		*/
       
   125 		IMPORT_C virtual ~CNSmlRoamTable();
       
   126 		
       
   127 		/**
       
   128         * void PutItemsL(TInt aProfileId, CIapArray* aItems )
       
   129 		* Adds IAPs from array for profile id
       
   130 		* @param TInt aProfileId - Profile id
       
   131 		* @param CNSmlIAPArray* aItems - pointer to (TUint32) IAP array 
       
   132         * @return -
       
   133 		*/
       
   134 		IMPORT_C void PutItemsL(TInt aProfileId, CNSmlIAPArray* aItems );
       
   135 
       
   136 		/**
       
   137         * CIapArray* GetItemsForIdL(TInt aProfileId)
       
   138 		* Gets IAPs for profile in an array
       
   139 		* @param TInt aProfileId - Profile id
       
   140 		* @return - pointer to array of IAPs
       
   141 		*/
       
   142 		IMPORT_C CNSmlIAPArray* GetItemsForIdL(TInt aProfileId);
       
   143 		
       
   144 		/**
       
   145         * TUint32 GetItemIAPL(TInt aProfileId, TInt aPriority)
       
   146 		* Get IAP for profile and priority
       
   147 		* @param TInt aProfileId - Profile id
       
   148 		* @param TInt aPriority - Priority
       
   149 		* @return - IAP id
       
   150 		*/
       
   151 		IMPORT_C TUint32 GetItemIAPL(TInt aProfileId, TInt aPriority);
       
   152 		
       
   153 		/**
       
   154         * void RemoveAllByIdL(TInt aProfileId)
       
   155 		* Removes all IAPs for profile id 
       
   156 		* @param TInt aProfileId - Profile id
       
   157 		* @return -
       
   158 		*/
       
   159 		IMPORT_C void RemoveAllByIdL(TInt aProfileId);
       
   160 
       
   161 #ifdef __MODULETEST	
       
   162 		IMPORT_C CTestClass* Test();
       
   163 #endif
       
   164 	private:
       
   165 
       
   166 		/**
       
   167         * Second construstor
       
   168 		* @return -
       
   169 		*/
       
   170 		void ConstructL();
       
   171 
       
   172 		/**
       
   173 		* Constructor
       
   174 		* CNSmlRoamTable( RDbNamedDatabase& aDatabase )
       
   175 		* @param RDbNamedDatabase& aDatabase - The database to be used.
       
   176         * @return -
       
   177 		*/
       
   178 		CNSmlRoamTable( RDbNamedDatabase& aDatabase );
       
   179 		
       
   180 		/**
       
   181 		* Adds item to table
       
   182 		* AddItemL( CNSmlRoamItem& aItem )
       
   183 		* @param CNSmlRoamItem& aItem - Container for profile id, IAP id and priority
       
   184         * @return -
       
   185 		*/
       
   186 		void AddItemL( CNSmlRoamItem& aItem );
       
   187 		
       
   188 		/**
       
   189 		* Replaces item to table
       
   190 		* void UpdateItemL(RDbView& aView, CNSmlRoamItem& aItem )
       
   191 		* @param RDbView& aView - view to table
       
   192 		* @param - CNSmlRoamItem& aItem - Container for profile id, IAP id and priority
       
   193         * @return -
       
   194 		*/
       
   195 		void UpdateItemL(RDbView& aView, CNSmlRoamItem& aItem );
       
   196 
       
   197 		/**
       
   198 		* Handles the insertion of the item
       
   199 		* void HandleItemL(CNSmlRoamItem& aItem);
       
   200 		* @param CNSmlRoamItem& aItem - Container for profile id, IAP id and priority
       
   201         * @return -
       
   202 		*/
       
   203 		void HandleItemL(CNSmlRoamItem& aItem);
       
   204 
       
   205 		/**
       
   206 		* Checks whether items for Profile id exists
       
   207 		* TBool IsNewItemL(RDbView& aView, TInt aProfileId);
       
   208 		* @param RDbView& aView - View to table
       
   209 		* @param TInt aProfileId - Profile id
       
   210         * @return - ETrue if new item
       
   211 		*/
       
   212 		TBool IsNewItemL(RDbView& aView, TInt aProfileId);
       
   213 
       
   214 		/**
       
   215 		* Checks whether item already exists on table
       
   216 		* TBool IsNewItemL(RDbView& aView, TInt aProfileId);
       
   217 		* @param RDbView& aView - View to table
       
   218 		* @param CNSmlRoamItem& aItem - Container for profile id, IAP id and priority
       
   219         * @return - ETrue if new item
       
   220 		*/
       
   221 		TBool IsNewItemL(RDbView& aView, CNSmlRoamItem& aItem );
       
   222 		
       
   223 	private:		
       
   224 		RDbNamedDatabase& iDatabase;
       
   225 		CDbColSet* iColSet;
       
   226 
       
   227 #ifdef __MODULETEST
       
   228 		CTestClass test;
       
   229 #endif
       
   230 	};
       
   231 
       
   232 #endif