|
1 /* |
|
2 * Copyright (c) 2002 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: create/save/get Internet connection methods from database. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <d32dbms.h> |
|
19 #include <e32base.h> |
|
20 |
|
21 //database name |
|
22 //_LIT(KtxDatabaseName, "DBS_INTERNET_ConnectionMethods.db"); |
|
23 _LIT(KtxDatabaseName, "c:InternetConnectionMethods.db"); |
|
24 _LIT( KNonSecureDbFullName, "C:\\system\\data\\InternetConnectionMethods.db" ); |
|
25 |
|
26 //Originator max length |
|
27 #define KOriginatorMaxLength 50 |
|
28 |
|
29 // database column names |
|
30 _LIT(NCol1, "Index"); |
|
31 _LIT(NCol2, "APID"); |
|
32 _LIT(NCol3, "BearerType"); |
|
33 _LIT(NCol4, "Originator"); |
|
34 |
|
35 // database table name |
|
36 _LIT(KtxtItemlist, "itemlist"); |
|
37 |
|
38 class TAccessPointItem |
|
39 { |
|
40 public: |
|
41 TAccessPointItem() : |
|
42 iIndex(-1) |
|
43 { |
|
44 } |
|
45 ; |
|
46 public: |
|
47 TInt iIndex; |
|
48 TUint iAPID; |
|
49 TUint iBearerType; |
|
50 TBuf<KOriginatorMaxLength> iOriginator; |
|
51 }; |
|
52 |
|
53 class CWPInternetAPDB : public CBase |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 */ |
|
59 static CWPInternetAPDB* NewL(); |
|
60 |
|
61 /** |
|
62 * Two-phased constructor. |
|
63 */ |
|
64 static CWPInternetAPDB* NewLC(); |
|
65 |
|
66 public: |
|
67 void ConstructL(); |
|
68 ~CWPInternetAPDB(); |
|
69 public: |
|
70 /** |
|
71 * CreateandOpenL |
|
72 * Creates and Opens the database. |
|
73 * @param name Path of the database |
|
74 * @return void |
|
75 **/ |
|
76 inline void CreateandOpenL(TParse& name); |
|
77 /** |
|
78 * ReadItemsL |
|
79 * Reads the Access Point data from a |
|
80 * database and store the data in a Item array. |
|
81 * @param aItemArray Item Array |
|
82 * @param QueryBuffer SQL Query |
|
83 * @return void |
|
84 **/ |
|
85 void |
|
86 ReadItemsL(RArray<TAccessPointItem>& aItemArray, |
|
87 TFileName QueryBuffer); |
|
88 /** |
|
89 * SaveToDatabaseL |
|
90 * Saves the Access Point data in a database |
|
91 * database and stores the data in a Item array. |
|
92 * @param aIndex Index |
|
93 * @param aAPId Access Point ID |
|
94 * @param aBearerType Bearer Type |
|
95 * @param aOriginator Operator |
|
96 * @return void |
|
97 **/ |
|
98 void SaveToDatabaseL(TInt& aIndex, TUint aAPId, TUint32 aBearerType, |
|
99 const TDesC& aOriginator); |
|
100 /** |
|
101 * ReadDbItemsL |
|
102 * Reads the Access Point data from a |
|
103 * database and stores the data in a Item array. |
|
104 * @param aItemArray Item Array |
|
105 * @return void |
|
106 **/ |
|
107 void ReadDbItemsL(RArray<TAccessPointItem>& aItemArray); |
|
108 |
|
109 /** |
|
110 * ReadDbItemsForOrigL |
|
111 * Reads the Access Point data for an operartor |
|
112 * from a database and stores the data in a Item array. |
|
113 * @param aItemArray Item Array |
|
114 * @param aValue Operator |
|
115 * @return void |
|
116 **/ |
|
117 void ReadDbItemsForOrigL(RArray<TAccessPointItem>& aItemArray, |
|
118 TDesC& aValue); |
|
119 |
|
120 /** |
|
121 * DeleteFromDatabaseL |
|
122 * Deletes the existings rows which have same Access Point ID |
|
123 * @param aAPId Access Point ID |
|
124 * @return TBool deleted rows |
|
125 **/ |
|
126 TBool DeleteFromDatabaseL(TUint aAPId); |
|
127 private: |
|
128 /** |
|
129 * CreateTableL |
|
130 * Creates table for a database |
|
131 * @param aDatabase Database Name |
|
132 * @return void |
|
133 **/ |
|
134 void CreateTableL(RDbDatabase& aDatabase); |
|
135 private: |
|
136 // Database Name |
|
137 RDbNamedDatabase iItemsDatabase; |
|
138 // File session |
|
139 RFs iFsSession; |
|
140 //Datbase session |
|
141 RDbs iRdbSession; |
|
142 }; |