equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of the License "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
36 delete iScrDbHandler; |
36 delete iScrDbHandler; |
37 } |
37 } |
38 |
38 |
39 DbHelper::DbHelper( const std::wstring& aDrivePath, bool aIsSystemDrive) |
39 DbHelper::DbHelper( const std::wstring& aDrivePath, bool aIsSystemDrive) |
40 { |
40 { |
41 std::string dllName = "sqlite3.dll"; |
41 |
|
42 #ifdef __LINUX__ |
|
43 std::string dllName = "sqlite-3.6.1.so"; |
|
44 #else |
|
45 std::string dllName = "sqlite3.dll"; |
|
46 #endif |
42 std::string dbName; |
47 std::string dbName; |
43 |
48 |
44 if (aIsSystemDrive) |
49 if (aIsSystemDrive) |
|
50 #ifdef __TOOLS2_LINUX__ |
|
51 dbName = wstring2string(aDrivePath) + "/sys/install/scr/scr.db"; |
|
52 #else |
45 dbName = wstring2string(aDrivePath) + "\\sys\\install\\scr\\scr.db"; |
53 dbName = wstring2string(aDrivePath) + "\\sys\\install\\scr\\scr.db"; |
|
54 #endif |
46 else |
55 else |
|
56 #ifdef __TOOLS2_LINUX__ |
|
57 dbName = wstring2string(aDrivePath) + "/sys/install/scr/provisioned/scr.db"; |
|
58 #else |
47 dbName = wstring2string(aDrivePath) + "\\sys\\install\\scr\\provisioned\\scr.db"; |
59 dbName = wstring2string(aDrivePath) + "\\sys\\install\\scr\\provisioned\\scr.db"; |
|
60 #endif |
48 |
61 |
49 std::wstring wdbname(string2wstring(dbName)); |
62 std::wstring wdbname(string2wstring(dbName)); |
50 //Create the SCR DB if not present in the System Drive |
63 //Create the SCR DB if not present in the System Drive |
51 if(!FileExists(wdbname)) |
64 if(!FileExists(wdbname)) |
52 { |
65 { |
58 throw InterpretSisError(emsg,retCode); |
71 throw InterpretSisError(emsg,retCode); |
59 } |
72 } |
60 std::string epocRootStr(epocRoot); |
73 std::string epocRootStr(epocRoot); |
61 |
74 |
62 #ifndef __TOOLS2_LINUX__ |
75 #ifndef __TOOLS2_LINUX__ |
63 std::wstring swEnvInfo = string2wstring(epocRootStr) + L"epoc32\\tools\\create_db.xml"; |
76 std::wstring swEnvInfo = string2wstring(epocRootStr) + L"epoc32\\tools\\create_db.xml"; |
64 #else |
77 #else |
65 std::wstring swEnvInfo = string2wstring(epocRootStr) + L"epoc32/tools/create_db.xml"; |
78 std::wstring swEnvInfo = string2wstring(epocRootStr) + L"epoc32/tools/create_db.xml"; |
66 #endif |
79 #endif |
67 |
80 |
68 if(FileExists(swEnvInfo)) |
81 if(FileExists(swEnvInfo)) |
69 { |
82 { |
70 std::string executable = "scrtool.exe"; |
83 #ifdef __TOOLS2_LINUX__ |
|
84 std::string executable = "scrtool"; |
|
85 #else |
|
86 std::string executable = "scrtool.exe"; |
|
87 #endif |
71 std::string command; |
88 std::string command; |
72 |
89 |
73 command = executable + " -c " + dbName + " -f " + wstring2string(swEnvInfo); |
90 command = executable + " -c " + dbName + " -f " + wstring2string(swEnvInfo); |
74 |
91 |
75 std::cout << "Creating DB : " << command << std::endl; |
92 std::cout << "Creating DB : " << command << std::endl; |
95 iScrDbHandler = new CDbProcessor(dllName, dbName); |
112 iScrDbHandler = new CDbProcessor(dllName, dbName); |
96 } |
113 } |
97 catch(CException& aException) |
114 catch(CException& aException) |
98 { |
115 { |
99 int returnCode = aException.GetCode(); |
116 int returnCode = aException.GetCode(); |
100 std::wstring emessage = Utf8ToUcs2( aException.GetMessageA() ); |
117 std::wstring emessage = string2wstring( aException.GetMessageA() ); |
101 |
118 |
102 returnCode = (returnCode == ExceptionCodes::ELibraryLoadError) ? LIBRARYLOAD_ERROR : returnCode; |
119 returnCode = (returnCode == ExceptionCodes::ELibraryLoadError) ? LIBRARYLOAD_ERROR : returnCode; |
103 throw InterpretSisError(emessage,returnCode); |
120 throw InterpretSisError(emessage,returnCode); |
104 } |
121 } |
105 } |
122 } |
266 TUint32 DbHelper::GetUidFromFileName( const std::wstring& aFileName ) const |
283 TUint32 DbHelper::GetUidFromFileName( const std::wstring& aFileName ) const |
267 { |
284 { |
268 std::string selCompId("SELECT ComponentId FROM ComponentsFiles WHERE Location=?;"); |
285 std::string selCompId("SELECT ComponentId FROM ComponentsFiles WHERE Location=?;"); |
269 std::auto_ptr<CStatement> stmtCompId(iScrDbHandler->PrepareStatement(selCompId)); |
286 std::auto_ptr<CStatement> stmtCompId(iScrDbHandler->PrepareStatement(selCompId)); |
270 |
287 |
271 stmtCompId->BindStr(1, aFileName); |
288 stmtCompId->BindStr(1, aFileName.c_str()); |
272 |
289 |
273 TInt32 componentId = 0; |
290 TInt32 componentId = 0; |
274 if(stmtCompId->ProcessNextRow()) |
291 if(stmtCompId->ProcessNextRow()) |
275 { |
292 { |
276 componentId = stmtCompId->IntColumn(0); |
293 componentId = stmtCompId->IntColumn(0); |
278 } |
295 } |
279 |
296 |
280 std::string selCompPropsId("SELECT ComponentId FROM ComponentProperties WHERE StrValue=? and Name like 'WCFile%';"); |
297 std::string selCompPropsId("SELECT ComponentId FROM ComponentProperties WHERE StrValue=? and Name like 'WCFile%';"); |
281 std::auto_ptr<CStatement> stmtCompPropsId(iScrDbHandler->PrepareStatement(selCompPropsId)); |
298 std::auto_ptr<CStatement> stmtCompPropsId(iScrDbHandler->PrepareStatement(selCompPropsId)); |
282 |
299 |
283 stmtCompPropsId->BindStr(1, aFileName); |
300 stmtCompPropsId->BindStr(1, aFileName.c_str()); |
284 |
301 |
285 if(stmtCompPropsId->ProcessNextRow()) |
302 if(stmtCompPropsId->ProcessNextRow()) |
286 { |
303 { |
287 componentId = stmtCompPropsId->IntColumn(0); |
304 componentId = stmtCompPropsId->IntColumn(0); |
288 return GetUid(componentId); |
305 return GetUid(componentId); |