equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 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 |
|
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 * |
4 * |
9 * Initial Contributors: |
5 * This program is free software: you can redistribute it and/or modify |
10 * Nokia Corporation - initial contribution. |
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
11 * |
13 * |
12 * Contributors: |
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
13 * |
17 * |
14 * Description: |
18 * Description: |
15 * |
19 * |
16 */ |
20 */ |
17 |
|
18 |
21 |
19 #include<bookmarkserver.h> |
22 #include<bookmarkserver.h> |
20 #include<QSqlDatabase> |
23 #include<QSqlDatabase> |
21 #include<QSqlQuery> |
24 #include<QSqlQuery> |
22 #include <QDir> |
25 #include <QDir> |
306 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", m_connectionName); |
309 QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", m_connectionName); |
307 db.setHostName("Simulator"); |
310 db.setHostName("Simulator"); |
308 db.setDatabaseName(dbLocation); |
311 db.setDatabaseName(dbLocation); |
309 |
312 |
310 if (!db.open()) |
313 if (!db.open()) |
311 return -1; |
314 return -1; |
312 |
315 |
313 QFileInfo dbFile(dbLocation); |
316 //Check if the table exists |
314 if (dbFile.exists() && dbFile.size() == 0) |
317 QStringList tablelist = db.tables(QSql::Tables); |
315 { |
318 if (tablelist.count() == 0) { |
316 QSqlQuery query(db); |
319 QSqlQuery query(db); |
317 query.exec( |
320 query.exec( |
318 "CREATE TABLE BookMarkTable (title VARCHAR(40) NOT NULL,url VARCHAR(100),adate VARCHAR(40),tags VARCHAR(40),CONSTRAINT pk_BookMarkTable PRIMARY KEY(title))"); |
321 "CREATE TABLE BookMarkTable (title VARCHAR(40) NOT NULL,url VARCHAR(100),adate VARCHAR(40),tags VARCHAR(40),CONSTRAINT pk_BookMarkTable PRIMARY KEY(title))"); |
319 |
322 |
320 } |
323 } |