201041 default
authorhgs
Fri, 15 Oct 2010 17:29:22 -0400
changeset 15 5ea3798f1248
parent 14 1d6c4b7a8fbd
201041
bookmarks/BookmarkResults.cpp
bookmarks/BookmarksManager.cpp
bookmarks/BookmarksManager.h
bookmarks/TagResults.h
bookmarks/bookmarks.pro
bookmarks/conf/BookmarkData.confml
bookmarks/conf/CI_bookmarks.confml
bookmarks/conf/bookmarks.xml
bookmarks/defaultBookmarks.xml.h
bookmarks/xbelreader.cpp
bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro
bookmarksengine/bookmarksclient/bookmarksclient.pro
bookmarksengine/bookmarksserver/BookmarksServer.pro
bookmarksengine/browsercontentdll/browsercontentdll.pro
bookmarksengine/browsercontentdll/inc/browsercontentdll.h
bookmarksengine/browsercontentdll/src/browsercontentdll.cpp
browserrfsplugin/browserrfs.txt
package_definition.xml
--- a/bookmarks/BookmarkResults.cpp	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/BookmarkResults.cpp	Fri Oct 15 17:29:22 2010 -0400
@@ -7,7 +7,6 @@
 
 #include <QString>
 #include <QObject>
-#include <QSqlDatabase>
 #include <QSqlQuery>
 #include <QSqlError>
 #include <QWidget>
--- a/bookmarks/BookmarksManager.cpp	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/BookmarksManager.cpp	Fri Oct 15 17:29:22 2010 -0400
@@ -1,34 +1,34 @@
 /*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License as published by
-* the Free Software Foundation, version 2.1 of the License.
-* 
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public License
-* along with this program.  If not, 
-* see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
-*
-* Description: This implements the bookmarks API's.
-*
-*/
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 2.1 of the License.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, 
+ * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
+ *
+ * Description: This implements the bookmarks API's.
+ *
+ */
 
 #include<QString>
 #include<QFile>
 #include<QFileInfo>
 #include<QDebug>
-#include<QSqlDatabase>
 #include<QSqlQuery>
 #include<QSqlError>
 #include<QWidget>
 #include<QtGui>
 
+#include "../../../app/browserui/bedrockProvisioning/bedrockprovisioning.h"
 #include "bookmarksapi.h"
 #include "BookmarksManager.h"
 #include "BookmarkFav.h"
@@ -38,10 +38,32 @@
 #include "xbelwriter.h"
 #include "defaultBookmarks.xml.h"
 
+namespace 
+{
+    const QString BOOKMARK_IMPORT_FILENAME = "bookmarks.xml";
+    const QString DEFAULT_BOOKMARKS_IMPORT_FILENAME = "defaultBookmarks.xml";
+    const QString TAGS_TABLE_NAME = "tags";
+    const QString BOOKMARKS_TABLE_NAME = "bookmarks";
+}
+
+BookmarksManager* BookmarksManager::instance() 
+{
+    static BookmarksManager* s_instance;
+    if(!s_instance) {
+        s_instance = new BookmarksManager();
+        if(s_instance->needsImport())
+            s_instance->importDefaultBookmarks();
+    }
+    Q_ASSERT(s_instance);
+    return s_instance;    
+}
+
 BookmarksManager::BookmarksManager(QWidget *parent) :
     QObject(parent)
 {
     setObjectName("bookmarksManager");
+    
+    m_needsImport = false;
 
     m_db = QSqlDatabase::database(BOOKMARKS_DB_NAME);
     if (!m_db.isValid()) {
@@ -51,32 +73,76 @@
     if (m_db.open()) {
         // TODO: Do we need a flag so that this gets called only once OR when
         // creating a database tables "IF NOT EXISTS" is good enough
-        createBookmarksSchema();
+        if(!doesTableExist(BOOKMARKS_TABLE_NAME) || !doesTableExist(TAGS_TABLE_NAME)) {
+            createBookmarksSchema();
+            m_needsImport = true;
+        }
     }
 }
 
-BookmarksManager::~BookmarksManager() {
+BookmarksManager::~BookmarksManager()
+{
     m_db.close();
     QSqlDatabase::removeDatabase(BOOKMARKS_DB_NAME);
 }
 
+bool BookmarksManager::createFile(QString filename, QString fileContents) 
+{
+    QFile file(filename);
+    
+    if(file.exists())
+        file.remove();
+    if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+        return false;
+
+    QTextStream out(&file); 
+    out << fileContents;
+    file.flush();
+    file.close();
+    return file.exists();
+}
+
+void BookmarksManager::deleteFile(QString filename) {
+    QFile::remove(filename);   
+}
+
+bool BookmarksManager::doesTableExist(QString tableName)
+{
+    bool retVal = false;
+    
+    if (!m_db.isValid() || !m_db.isOpen())
+        return false;
+    
+    QSqlQuery query(m_db);
+    query.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name=:tableName");
+    query.bindValue(":tableName", QVariant(tableName));
+    if (query.exec()) {
+        if (query.next()) 
+            retVal = true;
+        query.finish();
+    }
+    return retVal;
+}
+
 /*
  * +-------------+       +----------+
  * |Bookmarks(ID)|* <-> *|Tags(BMID)|
  * +-------------+       +----------+
  */
-void BookmarksManager::createBookmarksSchema() {
+void BookmarksManager::createBookmarksSchema()
+{
     // Bookmarks
     if (!doQuery("CREATE TABLE IF NOT EXISTS bookmarks("
-                    "id INTEGER PRIMARY KEY,"
-                    "title text, "
-                    "url text,"
-                    "sortIndex int DEFAULT 0)")) {
+        "id INTEGER PRIMARY KEY,"
+        "title text, "
+        "url text,"
+        "sortIndex int DEFAULT 0)")) {
         // TODO: do some error handling here!
         return;
     }
     // Make sorting faster
-    if (!doQuery("CREATE INDEX IF NOT EXISTS bm_sort_idx ON bookmarks(sortIndex ASC)")) {
+    if (!doQuery(
+            "CREATE INDEX IF NOT EXISTS bm_sort_idx ON bookmarks(sortIndex ASC)")) {
         // TODO: do some error handling here!
         return;
     }
@@ -90,9 +156,9 @@
     // Note: foreign key constraints are not enforced in the current version of sqlite
     // that we are using.
     if (!doQuery("CREATE TABLE IF NOT EXISTS tags("
-                    "bmid INTEGER,"
-                    "tag text,"
-                    "FOREIGN KEY(bmid) REFERENCES bookmarks(id))")) {
+        "bmid INTEGER,"
+        "tag text,"
+        "FOREIGN KEY(bmid) REFERENCES bookmarks(id))")) {
         // TODO: do some error handling here!
         return;
     }
@@ -107,8 +173,32 @@
     }
 }
 
+int BookmarksManager::importDefaultBookmarks() 
+{
+    int success = FAILURE;
+    // TODO: When Jira Task BR-4939 (https://qtrequirements.europe.nokia.com/browse/BR-4939) is
+    // finished, refactor this to get the path of the bookmarks.xml from that service.   
+    //QString bookmarksFilename = BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("DataBaseDirectory"); 
+    
+    if(QFile::exists(QString("z:/private/10008d39/").append(BOOKMARK_IMPORT_FILENAME))) {
+        success = importBookmarks(QString("z:/private/10008d39/").append(BOOKMARK_IMPORT_FILENAME));
+        qDebug() << "Import of bookmarks.xml " << (success == SUCCESS ? "successful." : "failed.");
+    } else if (QFile::exists(QString("c:/private/10008d39/").append(BOOKMARK_IMPORT_FILENAME))) {
+        success = importBookmarks(QString("c:/private/10008d39/").append(BOOKMARK_IMPORT_FILENAME));
+        qDebug() << "Import of bookmarks.xml " << (success == SUCCESS ? "successful." : "failed.");
+    } else if(createFile(DEFAULT_BOOKMARKS_IMPORT_FILENAME, defaultBookmarksList)) {        
+        success = importBookmarks(DEFAULT_BOOKMARKS_IMPORT_FILENAME);
+        qDebug() << "bookmarks.xml not found. Import of defaultBookmarks.xml " << 
+            (success == SUCCESS ? "successful." : "failed.");
+    } else {
+        qDebug() << "Could not import factory or default bookmarks.";
+    }
+    return success; 
+}
+
 // TODO refactor this - nothing except the schema creation can use it as is
-bool BookmarksManager::doQuery(QString query) {
+bool BookmarksManager::doQuery(QString query)
+{
 #ifdef ENABLE_PERF_TRACE
     PERF_DEBUG() << __PRETTY_FUNCTION__ << query << "\n";
     unsigned int st = WrtPerfTracer::tracer()->startTimer();
@@ -116,15 +206,16 @@
     QSqlQuery db_query(m_db);
     bool ok = db_query.exec(query);
     if (!ok) {
-        qDebug() << "BookmarksManager::doQuery" << QString("ERR: %1 %2").arg(db_query.lastError().type()).arg(db_query.lastError().text()) << " Query: " << db_query.lastQuery();
+        qDebug() << "BookmarksManager::doQuery" << QString("ERR: %1 %2").arg(
+                db_query.lastError().type()).arg(db_query.lastError().text())
+                << " Query: " << db_query.lastQuery();
     }
 #ifdef ENABLE_PERF_TRACE
     PERF_DEBUG() << __PRETTY_FUNCTION__ << WrtPerfTracer::tracer()->elapsedTime(st) << "\n";
 #endif
-    return ok;   
+    return ok;
 }
 
-
 /**==============================================================
  * Description: Normalize a given url, if needed.
  * It adds http:// in front, if the url is relative.
@@ -149,11 +240,11 @@
 {
     int bookmarkId = 0;
     
-    if(URL.isEmpty()) {
-       bookmarkId = FAILURE;
+    if (URL.isEmpty()) {
+        bookmarkId = FAILURE;
     }
-    
-    if(bookmarkId != FAILURE) {
+
+    if (bookmarkId != FAILURE) {
         // do some checking on parameters
         QString updatedTitle = title;
         QString updatedUrl = normalizeUrl(URL);
@@ -165,21 +256,21 @@
             QSqlQuery query(m_db);
             m_db.transaction();
             if (!query.exec("SELECT count(*) from bookmarks")) {
-                lastErrMsg(query);
-                m_db.rollback();
-                return DATABASEERROR;
+                   lastErrMsg(query);
+                   m_db.rollback();
+                   return DATABASEERROR;
             }
             if(query.next()) {
-                query.prepare("UPDATE bookmarks SET sortIndex=sortIndex+1 WHERE sortIndex >= :sIndex");
-                query.bindValue(":sIndex", soIndex);
-                if (!query.exec()) {
-                    lastErrMsg(query);
-                    m_db.rollback();
-                    return DATABASEERROR;
-                 }
-           } 
-           query.prepare("INSERT INTO bookmarks (title, url, sortIndex) "
-                               "VALUES (:title, :url, :sIndex)");
+                   query.prepare("UPDATE bookmarks SET sortIndex=sortIndex+1 WHERE sortIndex >= :sIndex");
+                   query.bindValue(":sIndex", soIndex);
+                   if (!query.exec()) {
+                        lastErrMsg(query);
+                        m_db.rollback();
+                        return DATABASEERROR;
+                   }
+            } 
+            query.prepare("INSERT INTO bookmarks (title, url, sortIndex) "
+                    "VALUES (:title, :url, :sIndex)");
             query.bindValue(":title", QVariant(updatedTitle));
             query.bindValue(":url",    QVariant(updatedUrl));
             query.bindValue(":sIndex",  QVariant(soIndex));
@@ -187,16 +278,16 @@
                 lastErrMsg(query);
                 m_db.rollback();
                 return DATABASEERROR;
-           }
-           // Note: lastInsertId() is not thread-safe
+            }
+            // Note: lastInsertId() is not thread-safe
             bookmarkId = query.lastInsertId().toInt();
             if (!m_db.commit()) {
                 qDebug() << m_db.lastError().text();
                 m_db.rollback();
-               return DATABASEERROR;
+                return DATABASEERROR;
             }
         } else {
-            bookmarkId = FAILURE;
+              bookmarkId = FAILURE;
         }
       }
     return bookmarkId;
@@ -217,25 +308,28 @@
     XbelReader *reader = new XbelReader(this);
     bool retVal = false;
     
-    if(xbelFilePath.isEmpty() || !QFile::exists(xbelFilePath)) {
-        xbelFilePath = "c:\\data\\temp.xml";
+    if (xbelFilePath.isEmpty() || !QFile::exists(xbelFilePath)) {
+        xbelFilePath = DEFAULT_BOOKMARKS_IMPORT_FILENAME;
         QFile file(xbelFilePath);
-        if(file.exists())
+        if (file.exists())
             file.remove();
         if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
             return false;
-        QTextStream out(&file); 
+        QTextStream out(&file);
         out << defaultBookmarksList;
         out.flush();
         file.close();
-    } 
+    }
     QFile file(xbelFilePath);
-    if(file.exists()) {
+    if (file.exists()) {
         file.open(QIODevice::ReadOnly | QIODevice::Text);
         retVal = reader->read(&file);
         file.close();
     }
-    if(reader)
+    if(QFile::exists(DEFAULT_BOOKMARKS_IMPORT_FILENAME)) {
+        QFile::remove(DEFAULT_BOOKMARKS_IMPORT_FILENAME);
+    }
+    if (reader)
         delete reader;
     return retVal ? SUCCESS : FAILURE;
 }
@@ -254,13 +348,13 @@
 {
     XbelWriter *writer = new XbelWriter(this);
     bool retVal = false;
-
-    if(xbelFilePath.isEmpty()) {
+    
+    if (xbelFilePath.isEmpty()) {
         xbelFilePath = "c:\\data\\myBookmarks.xml";
-    }  
+    }
 
     QFile file(xbelFilePath);
-    if(file.exists()) {
+    if (file.exists()) {
         file.remove(xbelFilePath);
     }
     file.open(QIODevice::WriteOnly | QIODevice::Text);
@@ -268,7 +362,7 @@
     file.flush();
     file.close();
     
-    if(writer)
+    if (writer)
         delete writer;
     return retVal ? SUCCESS : FAILURE;
     
@@ -279,29 +373,33 @@
  * and new title or url, it modifies the existing bookmark.
  * Returns : Success(0) or Failure(-1 or -2).
  ================================================================*/
-int BookmarksManager::modifyBookmark(int origBookmarkId, QString newTitle, QString newURL)
+int BookmarksManager::modifyBookmark(int origBookmarkId, QString newTitle,
+        QString newURL)
 {
     int retVal = SUCCESS;
     
     // Client has to at least pass title or url
-    if(newTitle.isEmpty() && newURL.isEmpty())
-       retVal = FAILURE;
-     
-    if(retVal == SUCCESS) {
+    if (newTitle.isEmpty() && newURL.isEmpty())
+        retVal = FAILURE;
     
-        if (m_db.isOpen()) { 
-              QSqlQuery query(m_db);
+    if (retVal == SUCCESS) {
+        
+        if (m_db.isOpen()) {
+            QSqlQuery query(m_db);
             
-            if(newTitle.isEmpty()) {        
-                query.prepare("UPDATE bookmarks SET url=:newurl WHERE id=:bmId");
+            if (newTitle.isEmpty()) {
+                query.prepare(
+                        "UPDATE bookmarks SET url=:newurl WHERE id=:bmId");
                 query.bindValue(":newurl", normalizeUrl(newURL));
                 query.bindValue(":bmId", origBookmarkId);
-            } else if(newURL.isEmpty()) { 
-                query.prepare("UPDATE bookmarks SET title=:newTitle WHERE id=:bmId");
+            } else if (newURL.isEmpty()) {
+                query.prepare(
+                        "UPDATE bookmarks SET title=:newTitle WHERE id=:bmId");
                 query.bindValue(":newTitle", newTitle);
                 query.bindValue(":bmId", origBookmarkId);
             } else {
-                query.prepare("UPDATE bookmarks SET url=:newurl, title=:newTitle WHERE id=:bmId");
+                query.prepare(
+                        "UPDATE bookmarks SET url=:newurl, title=:newTitle WHERE id=:bmId");
                 query.bindValue(":newurl", normalizeUrl(newURL));
                 query.bindValue(":newTitle", newTitle);
                 query.bindValue(":bmId", origBookmarkId);
@@ -309,13 +407,13 @@
             if (!query.exec()) {
                 lastErrMsg(query);
                 return DATABASEERROR;
-            } 
+            }
             if (query.numRowsAffected() == 0) {
                 // No update happened - must be an invalid id
                 // TODO: shall we return some other status
                 retVal = FAILURE;
             }
-        } else 
+        } else
             retVal = FAILURE;
     }
     return retVal;
@@ -328,11 +426,11 @@
 int BookmarksManager::deleteBookmark(int bookmarkId)
 {
     int retVal = SUCCESS;
-   
-    if (m_db.isOpen()) {      
     
+    if (m_db.isOpen()) {
+        
         QSqlQuery query(m_db);
-         
+        
         // TODO: Need to think about whether we need to get sortIndex and update all the 
         // rows after the deletion or not
 
@@ -347,23 +445,23 @@
             m_db.rollback();
             return DATABASEERROR;
         }
-        
+
         query.prepare("DELETE FROM tags WHERE bmid=:bmId");
         query.bindValue(":bmId", bookmarkId);
         if (!query.exec()) {
             lastErrMsg(query);
             m_db.rollback();
             return DATABASEERROR;
-        } 
+        }
         if (!m_db.commit()) {
             qDebug() << m_db.lastError().text();
             m_db.rollback();
             return DATABASEERROR;
-        }         
-    } else 
+        }
+    } else
         retVal = FAILURE;
     
-    return retVal;     
+    return retVal;
 }
 
 /**===================================================================================
@@ -374,32 +472,32 @@
 {
     int retVal = SUCCESS;
     
-    if (m_db.isOpen()) {        
-       QSqlQuery query(m_db);
-           
-       // TODO: check if transaction() has been supported 
-       // by calling hasfeature() function first
-       m_db.transaction();
-       
-       if(!query.exec("DELETE FROM bookmarks")) {  
+    if (m_db.isOpen()) {
+        QSqlQuery query(m_db);
+        
+        // TODO: check if transaction() has been supported 
+        // by calling hasfeature() function first
+        m_db.transaction();
+        
+        if (!query.exec("DELETE FROM bookmarks")) {
             lastErrMsg(query);
             m_db.rollback();
             retVal = DATABASEERROR;
-       } 
-       if (retVal == SUCCESS && !query.exec("DELETE FROM tags")) {
+        }
+        if (retVal == SUCCESS && !query.exec("DELETE FROM tags")) {
             lastErrMsg(query);
             m_db.rollback();
             retVal = DATABASEERROR;
-       } 
-       if (retVal == SUCCESS && !m_db.commit()) {
-           qDebug() << m_db.lastError().text();
-           m_db.rollback();
-           retVal = DATABASEERROR;
-       }
-    } else 
+        }
+        if (retVal == SUCCESS && !m_db.commit()) {
+            qDebug() << m_db.lastError().text();
+            m_db.rollback();
+            retVal = DATABASEERROR;
+        }
+    } else
         retVal = FAILURE;
     
-    return retVal;     
+    return retVal;
 }
 
 /**==============================================================
@@ -409,14 +507,14 @@
 int BookmarksManager::deleteTag(int bookmarkId, QString tagToDelete)
 {
     int retVal = SUCCESS;
- 
-    if(tagToDelete.isEmpty()|| bookmarkId < 0)
-          retVal = FAILURE;
+    
+    if (tagToDelete.isEmpty() || bookmarkId < 0)
+        retVal = FAILURE;
     
     if (retVal == SUCCESS) {
         if (m_db.isOpen()) {
             QSqlQuery query(m_db);
-         
+            
             query.prepare("DELETE FROM tags WHERE bmid=:bmId AND tag=:tag");
             query.bindValue(":bmId", bookmarkId);
             query.bindValue(":tag", tagToDelete);
@@ -424,11 +522,11 @@
                 lastErrMsg(query);
                 retVal = DATABASEERROR;
             }
-        } else 
+        } else
             retVal = FAILURE;
     }
     
-    return retVal;     
+    return retVal;
 }
 
 /**================================================================
@@ -439,23 +537,23 @@
 {
     int retVal = SUCCESS;
     
-    if(tagToAdd.isEmpty()|| bookmarkId < 0)
-       retVal = FAILURE;
+    if (tagToAdd.isEmpty() || bookmarkId < 0)
+        retVal = FAILURE;
     
-    if(retVal == SUCCESS) {
-        if (m_db.isOpen()) {     
-             QSqlQuery query(m_db);
-             
+    if (retVal == SUCCESS) {
+        if (m_db.isOpen()) {
+            QSqlQuery query(m_db);
+            
             query.prepare("INSERT INTO tags (bmid, tag) "
-                     "VALUES (:id, :tag)");                      
-            query.bindValue(":id",   QVariant(bookmarkId));
-            query.bindValue(":tag",  QVariant(tagToAdd));
+                "VALUES (:id, :tag)");
+            query.bindValue(":id", QVariant(bookmarkId));
+            query.bindValue(":tag", QVariant(tagToAdd));
             
             if (!query.exec()) {
                 lastErrMsg(query);
                 retVal = DATABASEERROR;
-            } 
-        } else 
+            }
+        } else
             retVal = FAILURE;
     }
     
@@ -469,17 +567,18 @@
  ===============================================================*/
 BookmarkResults *BookmarksManager::findAllBookmarks()
 {
-    BookmarkResults * results = NULL; 
+    BookmarkResults * results = NULL;
     
     QString queryStr = QString("SELECT "
-                               " id, title, url, sortIndex " 
-                               " FROM bookmarks ORDER BY sortIndex");
+        " id, title, url, sortIndex "
+        " FROM bookmarks ORDER BY sortIndex");
     if (m_db.isOpen()) {
         QSqlQuery *query = new QSqlQuery(m_db);
         if (query->exec(queryStr)) {
-             results = new BookmarkResults(query);
+            results = new BookmarkResults(query);
         } else {
-            qDebug() << query->lastError().text() << " Query: " << query->lastQuery();
+            qDebug() << query->lastError().text() << " Query: "
+                    << query->lastQuery();
             results = NULL;
         }
     }
@@ -492,22 +591,22 @@
  ===============================================================*/
 TagResults *BookmarksManager::findAllTags()
 {
-    TagResults * results = NULL; 
+    TagResults * results = NULL;
     
     if (m_db.isOpen()) {
         QSqlQuery *query = new QSqlQuery(m_db);
         if (query->exec("SELECT DISTINCT tag FROM tags")) {
             // TODO: do we need javascript hack here like in findAllBookmarks API.
-            results = new TagResults(query); 
+            results = new TagResults(query);
         } else {
-            qDebug() << query->lastError().text() << " Query: " << query->lastQuery();
+            qDebug() << query->lastError().text() << " Query: "
+                    << query->lastQuery();
             results = NULL;
         }
     }
     return results;
 }
 
-
 /**==============================================================
  * Description: Finds all the bookmarks associated with a given
  * tag. 
@@ -515,29 +614,29 @@
  ===============================================================*/
 BookmarkResults *BookmarksManager::findBookmarksByTag(QString tag)
 {
-    BookmarkResults * results = NULL; 
+    BookmarkResults * results = NULL;
     
     QString queryStr = QString("SELECT "
-                               " id, title, url, sortIndex " 
-                               " FROM bookmarks b JOIN"
-                               " tags t ON b.id=t.bmid WHERE" 
-                               " t.tag=:tag");
-     if (m_db.isOpen()) {
-         QSqlQuery *query = new QSqlQuery(m_db);
-         query->prepare(queryStr);
-         query->bindValue(":tag", tag);
-         if (query->exec()) {
-             // TODO: do we need javascript hack here like in findAllBookmarks API.
-             results = new BookmarkResults(query);
-         } else {
-            qDebug() << query->lastError().text() << " Query: " << query->lastQuery();
+        " id, title, url, sortIndex "
+        " FROM bookmarks b JOIN"
+        " tags t ON b.id=t.bmid WHERE"
+        " t.tag=:tag");
+    if (m_db.isOpen()) {
+        QSqlQuery *query = new QSqlQuery(m_db);
+        query->prepare(queryStr);
+        query->bindValue(":tag", tag);
+        if (query->exec()) {
+            // TODO: do we need javascript hack here like in findAllBookmarks API.
+            results = new BookmarkResults(query);
+        } else {
+            qDebug() << query->lastError().text() << " Query: "
+                    << query->lastQuery();
             results = NULL;
-         }
-     }
-     return results;
+        }
+    }
+    return results;
 }
 
-
 /**==============================================================
  * Description: Finds all the Tags associated with a given
  * bookmarkID.
@@ -545,25 +644,26 @@
  ===============================================================*/
 TagResults *BookmarksManager::findTagsByBookmark(int bookmarkID)
 {
-     TagResults * results = NULL; 
+    TagResults * results = NULL;
     
-     QString queryStr = QString("SELECT DISTINCT tag "
-                                 " FROM tags t JOIN"
-                                 " bookmarks b ON t.bmid=b.id WHERE" 
-                                 " t.bmid=:id");
-     if (m_db.isOpen()) {
+    QString queryStr = QString("SELECT DISTINCT tag "
+        " FROM tags t JOIN"
+        " bookmarks b ON t.bmid=b.id WHERE"
+        " t.bmid=:id");
+    if (m_db.isOpen()) {
         QSqlQuery *query = new QSqlQuery(m_db);
         query->prepare(queryStr);
         query->bindValue(":id", bookmarkID);
         if (query->exec()) {
             // TODO: do we need javascript hack here like in findAllBookmarks API.
-            results =  new TagResults(query); 
+            results = new TagResults(query);
         } else {
-            qDebug() << query->lastError().text() << " Query: " << query->lastQuery();
+            qDebug() << query->lastError().text() << " Query: "
+                    << query->lastQuery();
             results = NULL;
         }
-     }
-     return results;
+    }
+    return results;
 }
 
 /**==============================================================
@@ -572,37 +672,37 @@
  * Returns: A pointer to BookmarkResults object or NULL.
  ===============================================================*/
 BookmarkResults *BookmarksManager::findUntaggedBookmarks()
-{   
-    BookmarkResults * results = NULL; 
-       
+{
+    BookmarkResults * results = NULL;
+    
     QString queryStr = QString("SELECT "
-                               " id, title, url, sortIndex " 
-                               " FROM bookmarks b LEFT OUTER JOIN"
-                               " tags t ON b.id=t.bmid WHERE" 
-                               " t.bmid IS NULL ORDER BY sortIndex");
+        " id, title, url, sortIndex "
+        " FROM bookmarks b LEFT OUTER JOIN"
+        " tags t ON b.id=t.bmid WHERE"
+        " t.bmid IS NULL ORDER BY sortIndex");
     
-    if (m_db.isOpen()) { 
-       QSqlQuery *query = new QSqlQuery(m_db);
-       if (query->exec(queryStr)) {
-           // TODO: do we need javascript hack here like in findAllBookmarks API.
-           results = new BookmarkResults(query);
-       } else {
-           qDebug() << query->lastError().text() << " Query: " << query->lastQuery();
-           results = NULL;
-       }
+    if (m_db.isOpen()) {
+        QSqlQuery *query = new QSqlQuery(m_db);
+        if (query->exec(queryStr)) {
+            // TODO: do we need javascript hack here like in findAllBookmarks API.
+            results = new BookmarkResults(query);
+        } else {
+            qDebug() << query->lastError().text() << " Query: "
+                    << query->lastQuery();
+            results = NULL;
+        }
     }
     return results;
 }
 
-
 /**==============================================================
  * Description: Reorder bookmarks. Moves a given bookmark to a 
  * passed new index.
  * Returns: SUCCESS(0) or FAILURE (-1 or -2)
  ===============================================================*/
 int BookmarksManager::reorderBookmark(int bookmarkID, int newIndex)
-{   
-    if (newIndex <= 0) 
+{
+    if (newIndex <= 0)
         return FAILURE;
 
     if (!m_db.isOpen())
@@ -659,15 +759,16 @@
 {
     BookmarkFav * results = NULL;
     
-  
-    if (m_db.isOpen()) { 
-        QSqlQuery query(m_db);  
-        query.prepare("SELECT title, url, sortIndex FROM bookmarks WHERE id=:id");
+    if (m_db.isOpen()) {
+        QSqlQuery query(m_db);
+        query.prepare(
+                "SELECT title, url, sortIndex FROM bookmarks WHERE id=:id");
         query.bindValue(":id", bookmarkId);
         if (query.exec()) {
-            if (query.next()) 
-                results = new BookmarkFav(bookmarkId, query.value(0).toString(),
-                         query.value(1).toString(), query.value(2).toInt()); 
+            if (query.next())
+                results = new BookmarkFav(bookmarkId,
+                        query.value(0).toString(), query.value(1).toString(),
+                        query.value(2).toInt());
         } else {
             lastErrMsg(query);
         }
@@ -704,8 +805,10 @@
  * Description: Prints a last error message from the query.
  * Returns: Nothing.
  ===============================================================*/
-void BookmarksManager::lastErrMsg(QSqlQuery& query) 
+void BookmarksManager::lastErrMsg(QSqlQuery& query)
 {
-    qDebug() << "BookmarksManager::lastErrMsg" << QString("ERR: %1 %2").arg(query.lastError().type()).arg(query.lastError().text()) << " Query: " << query.lastQuery();
+    qDebug() << "BookmarksManager::lastErrMsg" << QString("ERR: %1 %2").arg(
+            query.lastError().type()).arg(query.lastError().text())
+            << " Query: " << query.lastQuery();
 }
 
--- a/bookmarks/BookmarksManager.h	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/BookmarksManager.h	Fri Oct 15 17:29:22 2010 -0400
@@ -47,9 +47,16 @@
             FAILURE = -2
     };
     
-    BookmarksManager(QWidget *parent = 0);
-    ~BookmarksManager();
+public: 
+    static BookmarksManager* instance();
 
+public:
+    virtual ~BookmarksManager();
+
+public: // static functions
+    static bool createFile(QString filename, QString fileContents);
+    static void deleteFile(QString filename);
+   
 public slots:
     int addBookmark(QString title, QString URL);
     int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl);
@@ -60,22 +67,32 @@
     BookmarkResults *findAllBookmarks();
     TagResults *findAllTags();
     BookmarkResults *findBookmarksByTag(QString tag);
+    bool needsImport() { return m_needsImport; }
     int importBookmarks(QString xbelFilePath);
+    int importDefaultBookmarks();
     int exportBookmarks(QString xbelFilePath);
     BookmarkFav* findBookmark(int bookmarkId);
     BookmarkResults *findUntaggedBookmarks();
     int reorderBookmark(int bookmarkID, int newIndex);
     TagResults* findTagsByBookmark(int bookmarkID);
-		QMap<QString, QString> findBookmarks(QString atitle);   
- 
+    QMap<QString, QString> findBookmarks(QString atitle);
+    
  private:
+    BookmarksManager(QWidget *parent = 0);
     bool doQuery(QString query);
+    bool doesTableExist(QString tableName);
     void createBookmarksSchema();
     QString normalizeUrl(const QString& url);
     void lastErrMsg(QSqlQuery& query);
 
+    bool m_needsImport;
     QSqlDatabase  m_db;
     // Note: One instance of a query was locking the database even after using finish() and clear()
     //QSqlQuery*    m_query;
 };
+
+#ifndef B_Mgr
+#define B_Mgr BookmarksManager::instance();
+#endif
+
 #endif //BOOKMARKSMANAGER_H
--- a/bookmarks/TagResults.h	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/TagResults.h	Fri Oct 15 17:29:22 2010 -0400
@@ -8,15 +8,13 @@
 #ifndef TAGRESULTS_H_
 #define TAGRESULTS_H_
 
+#include <QWidget>
 #include <QString>
-#include <QObject>
-#include <QSqlDatabase>
-#include <QSqlQuery>
-#include <QSqlError>
-#include <QWidget>
 
 #include "bookmarksapi.h"
 
+class QSqlQuery;
+
 class BOOKMARKSAPI_EXPORT TagResults : public QObject {
 
     Q_OBJECT
--- a/bookmarks/bookmarks.pro	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/bookmarks.pro	Fri Oct 15 17:29:22 2010 -0400
@@ -24,7 +24,18 @@
 
 # HEADERS += $$PWD/inc/browsercontentdllclientdefs.h \
 # $$PWD/inc/browsercontentdll.h
-# SOURCES += $$PWD/src/browsercontentdll.cpp
+# SOURCES += $$PWD/src/browsercontentdll.cpp    
+
+# Build.inf rules
+symbian{
+		BLD_INF_RULES.prj_exports += \
+    "$${LITERAL_HASH}include <platform_paths.hrh>" \
+    "conf/CI_bookmarks.confml MW_LAYER_CONFML(CI_bookmarks.confml)" \
+    "conf/BookmarkItems.gcfml MW_LAYER_GCFML(BookmarkItems.gcfml)" \
+    "conf/CI_bookmarks.confml MW_LAYER_CONFML(BookmarkData.confml)" \
+    "conf/bookmarks.xml /epoc32/data/z/private/10008d39/bookmarks.xml"
+}
+
 isEmpty(BEDROCK_OUTPUT_DIR): { 
     symbian { 
         CONFIG(release, debug|release):BOOKMARKSAPI_OUTPUT_DIR = $$PWD/../../WrtBuild/Release
@@ -77,8 +88,7 @@
     TARGET.EPOCALLOWDLLDATA = 1
     TARGET.CAPABILITY = All \
         -TCB \
-        -DRM \
-        -AllFiles
+        -DRM 
     LIBS += -lefsrv \
         -lcaf \
         -lcafutils
@@ -86,10 +96,15 @@
         $$MW_LAYER_PUBLIC_EXPORT_PATH()
     INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
     INCLUDEPATH += /epoc32/include
-    bookmarksapi.sources = bookmarksapi.dll
-    bookmarksapi.path = /sys/bin
-    DEPLOYMENT += bookmarksapi
-}
+    
+    BLD_INF_RULES.prj_exports += \
+        "./BookmarksManager.h               $$MW_LAYER_PUBLIC_EXPORT_PATH(BookmarksManager.h)" \
+        "./BookmarkFav.h                   $$MW_LAYER_PUBLIC_EXPORT_PATH(BookmarkFav.h)" \
+        "./BookmarkResults.h               $$MW_LAYER_PUBLIC_EXPORT_PATH(BookmarkResults.h)" \
+        "./bookmarksapi.h                  $$MW_LAYER_PUBLIC_EXPORT_PATH(bookmarksapi.h)" \
+        "./TagResults.h                    $$MW_LAYER_PUBLIC_EXPORT_PATH(TagResults.h)" 
+}  
+
 HEADERS = \
 #BookmarkResultsList.h \
     TagResults.h \
--- a/bookmarks/conf/BookmarkData.confml	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/conf/BookmarkData.confml	Fri Oct 15 17:29:22 2010 -0400
@@ -16,10 +16,6 @@
                 <URL>http://geocaching.hu/wap</URL>
             </CustomerBookmarkItem>
             <CustomerBookmarkItem>
-                <Name>Test sites</Name>
-                <URL></URL>
-            </CustomerBookmarkItem>
-            <CustomerBookmarkItem>
                 <Name>DDT</Name>
                 <URL>http://ammo.factory.cellulardata.com:8000/ddt</URL>
             </CustomerBookmarkItem>
@@ -46,7 +42,6 @@
             <NokiaBookmarkItem extensionPolicy="append">
                 <Name>User agent</Name>
                 <URL>http://testsuite.nokia-boston.com/content/wml_ua/wmlheader.asp</URL>
-                <Tag1>Tag1</Tag1>
             </NokiaBookmarkItem>
             <NokiaBookmarkItem>
                 <Name>Google</Name>
@@ -69,14 +64,6 @@
                 <Name>OSS Browser Report</Name>
                 <URL>http://waplabdc.nokia-boston.com/browser/users/OSSBrowser/errorEmail/error.asp</URL>
             </NokiaBookmarkItem>
-            <NokiaBookmarkItem>
-                <Name>Google</Name>
-                <URL>Http://www.google.com</URL>
-            </NokiaBookmarkItem>
-            <NokiaBookmarkItem>
-                <Name/>
-                <URL/>
-            </NokiaBookmarkItem>
             <ThirdPartyBookmarkItem extensionPolicy="append">
                 <Name>XHTML -IOP</Name>
                 <URL>http://rave.cellulardata.com/xhtml/index.xhtml</URL>
--- a/bookmarks/conf/CI_bookmarks.confml	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/conf/CI_bookmarks.confml	Fri Oct 15 17:29:22 2010 -0400
@@ -72,12 +72,12 @@
                 <URL>http://geocaching.hu/wap</URL>
             </CustomerBookmarkItem>
             <CustomerBookmarkItem>
-                <Name>Test sites</Name>
-                <URL></URL>
+                <Name>DDT</Name>
+                <URL>http://ammo.factory.cellulardata.com:8000/ddt</URL>
             </CustomerBookmarkItem>
             <CustomerBookmarkItem>
-                <Name>DDT</Name>
-                <URL>http://ammo.factory.cellulardata.com:8000/ddt</URL>
+                <Name>Browser 8x NFT</Name>
+                <URL>http://iop1.nokia-boston.com/index.html</URL>
             </CustomerBookmarkItem>
             <CustomerBookmarkItem>
                 <Name>DDT (no cookies)</Name>
@@ -102,7 +102,6 @@
             <NokiaBookmarkItem extensionPolicy="append">
                 <Name>User agent</Name>
                 <URL>http://testsuite.nokia-boston.com/content/wml_ua/wmlheader.asp</URL>
-                <Tag1>Tag1</Tag1>
             </NokiaBookmarkItem>
             <NokiaBookmarkItem>
                 <Name>Google</Name>
@@ -125,14 +124,6 @@
                 <Name>OSS Browser Report</Name>
                 <URL>http://waplabdc.nokia-boston.com/browser/users/OSSBrowser/errorEmail/error.asp</URL>
             </NokiaBookmarkItem>
-            <NokiaBookmarkItem>
-                <Name>Google</Name>
-                <URL>Http://www.google.com</URL>
-            </NokiaBookmarkItem>
-            <NokiaBookmarkItem>
-                <Name/>
-                <URL/>
-            </NokiaBookmarkItem>
             <ThirdPartyBookmarkItem extensionPolicy="append">
                 <Name>XHTML -IOP</Name>
                 <URL>http://rave.cellulardata.com/xhtml/index.xhtml</URL>
--- a/bookmarks/conf/bookmarks.xml	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/conf/bookmarks.xml	Fri Oct 15 17:29:22 2010 -0400
@@ -26,7 +26,7 @@
 	<bookmark href="http://www.cnn.com" >
 		<title>CNN</title>
 	</bookmark>
-	<bookmark href="http://www.whatsmayuseragent.com" >
+	<bookmark href="http://www.whatsmyuseragent.com" >
 		<title>What's my user agent?</title>
 	</bookmark>
 	<bookmark href="http://www.youtube.com" >
--- a/bookmarks/defaultBookmarks.xml.h	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/defaultBookmarks.xml.h	Fri Oct 15 17:29:22 2010 -0400
@@ -10,8 +10,8 @@
 
 #include "bookmarksapi.h"
 
-extern const QString defaultBookmarksList = "<!DOCTYPE xbel>\n\
-<xbel version='1.0'>\n\
+extern const QString defaultBookmarksList = "<!DOCTYPE xbel> \n\
+   <xbel version='1.0'>\n\
    <bookmark href='http://www.nokia.com'>\n\
        <title>Nokia</title>\n\
            <info>\n\
--- a/bookmarks/xbelreader.cpp	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarks/xbelreader.cpp	Fri Oct 15 17:29:22 2010 -0400
@@ -141,7 +141,7 @@
     }
 
     int bmID = m_bmgr->addBookmark(title, url);
-    if (bmID > 0) {
+    if (bmID > 0 && tags.size() > 0) {
         QList<QString>::iterator iter;
         for (iter = tags.begin(); iter != tags.end(); ++iter)
             m_bmgr->addTag(bmID, *iter);
@@ -191,9 +191,10 @@
 void XbelReader::readTags(QList<QString>& tags) 
 {
     while(m_xml->readNextStartElement()) {
-        if(m_xml->name() == "tag") 
-            tags.append(m_xml->readElementText());
-        else
+        if(m_xml->name() == "tag") {
+            QString tag = m_xml->readElementText();
+            tags.append(tag);
+        } else
             m_xml->skipCurrentElement();
     }
 
--- a/bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro	Fri Oct 15 17:29:22 2010 -0400
@@ -86,7 +86,7 @@
     TARGET.UID3 = 0x102C2774
     TARGET.VID = VID_DEFAULT
     TARGET.EPOCALLOWDLLDATA = 1
-    TARGET.CAPABILITY = All -TCB -DRM -AllFiles
+    TARGET.CAPABILITY = All -TCB -DRM
     
     INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
    LIBS += -lefsrv -lcaf -lcafutils 
--- a/bookmarksengine/bookmarksclient/bookmarksclient.pro	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/bookmarksclient/bookmarksclient.pro	Fri Oct 15 17:29:22 2010 -0400
@@ -96,14 +96,11 @@
     TARGET.UID3 = 0x200267E6
     TARGET.VID = VID_DEFAULT
     TARGET.EPOCALLOWDLLDATA=1
-    TARGET.CAPABILITY = All -TCB -DRM -AllFiles
+    TARGET.CAPABILITY = All -TCB -DRM
     LIBS += -lefsrv -lcaf -lcafutils
     INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(cwrt) $$MW_LAYER_PUBLIC_EXPORT_PATH()
     INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
     INCLUDEPATH+=/epoc32/include
-    BookMarksClientlibs.sources = BookMarksClient.dll
-    BookMarksClientlibs.path = /sys/bin
-    DEPLOYMENT += BookMarksClientlibs
  
 }
 
--- a/bookmarksengine/bookmarksserver/BookmarksServer.pro	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/bookmarksserver/BookmarksServer.pro	Fri Oct 15 17:29:22 2010 -0400
@@ -83,7 +83,7 @@
     TARGET.UID3 = 0x200267E7
     TARGET.VID = VID_DEFAULT
     TARGET.EPOCALLOWDLLDATA=1
-    TARGET.CAPABILITY = All -TCB -DRM -AllFiles
+    TARGET.CAPABILITY = All -TCB -DRM
     CONFIG +=no_icon
 }
 
--- a/bookmarksengine/browsercontentdll/browsercontentdll.pro	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/browsercontentdll/browsercontentdll.pro	Fri Oct 15 17:29:22 2010 -0400
@@ -92,14 +92,11 @@
     TARGET.UID3 = 0x200267E6
     TARGET.VID = VID_DEFAULT
     TARGET.EPOCALLOWDLLDATA=1
-    TARGET.CAPABILITY = All -TCB -DRM -AllFiles
+    TARGET.CAPABILITY = All -TCB -DRM
     LIBS += -lefsrv -lcaf -lcafutils
     INCLUDEPATH+=$$MW_LAYER_PUBLIC_EXPORT_PATH(cwrt) $$MW_LAYER_PUBLIC_EXPORT_PATH()
     INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
     INCLUDEPATH+=/epoc32/include
-    browsercontentdlllibs.sources = browsercontentdll.dll
-    browsercontentdlllibs.path = /sys/bin
-    DEPLOYMENT += browsercontentdlllibs
  
 }
 
--- a/bookmarksengine/browsercontentdll/inc/browsercontentdll.h	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/browsercontentdll/inc/browsercontentdll.h	Fri Oct 15 17:29:22 2010 -0400
@@ -121,14 +121,11 @@
 BOOKMARKSCLIENT_PRIVATE(BrowserContent)
 public:
 
-    BrowserContent(QString aClientName);
+    BrowserContent(QString aClientName); //used for test purposes only
+    BrowserContent(QString aClientName, QString databaseName);
     ~BrowserContent();
-    int addBookmark(BookmarkLeaf* BookmarkContent);
-    int deleteBookmark(QString title);
     QList<BookmarkLeaf*> fetchAllBookmarks();
     QList<BookmarkLeaf*> suggestBookMarks(QString atitle);
-    int reorderBokmarks(QString title,int new_index);
-	int modifyBookmark(QString aOrgTitle, QString aNewTitle, QString aNewUrl);
 	QObjectList suggestContent(QString atitle);
 
     int addHistory(HistoryLeaf* HistoryContent);
@@ -142,7 +139,7 @@
     QMap<QString, QString> findSimilarHistoryItems(QString atitle);
 
 private:
-  int createDatabase();
+  int createDatabase(QString location);
   QString filterUrl(QString atitle);
   QString findFolderForDate( QDate& nodeDate);
   bool dateInThisMonth(QDate &date);
--- a/bookmarksengine/browsercontentdll/src/browsercontentdll.cpp	Mon Oct 04 14:09:43 2010 -0400
+++ b/bookmarksengine/browsercontentdll/src/browsercontentdll.cpp	Fri Oct 15 17:29:22 2010 -0400
@@ -47,25 +47,32 @@
 /**==============================================================
  * Description: Constructor of BrowserContent
  ================================================================*/
-BrowserContent::BrowserContent(QString aClientName)
+BrowserContent::BrowserContent(QString aClientName)  //used for test purposes only
 {
     BOOKMARKSCLIENT_INITIALIZE(BrowserContent);
     
     priv->m_connectionName=aClientName;
-    createDatabase();
+    createDatabase(dbLocation);
+}
+
+BrowserContent::BrowserContent(QString aClientName, QString databaseName)
+{
+    BOOKMARKSCLIENT_INITIALIZE(BrowserContent);
+
+    priv->m_connectionName=aClientName;
+    createDatabase(databaseName);
 }
 
 /**==============================================================
  * Description: creates the database
  ================================================================*/
-int BrowserContent::createDatabase()
+int BrowserContent::createDatabase(QString name)
 {
     BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
     
     QSqlDatabase sqlDB = QSqlDatabase::addDatabase("QSQLITE", priv->m_connectionName);
     sqlDB.setHostName("Simulator");
-    sqlDB.setDatabaseName(dbLocation);
-
+    sqlDB.setDatabaseName(name);
 
     if (!sqlDB.open())
         return -1;
@@ -100,91 +107,6 @@
     {
     }
 
-/**==============================================================
- * Description: adds the bookmark to the database
- ================================================================*/
-int BrowserContent::addBookmark(
-        BookmarkLeaf* BookmarkContent)
-{
-    BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
-    QSqlError error;
-    QString title =BookmarkContent->getTitle();
-    QString url = BookmarkContent->getUrl();
-    QString adate =BookmarkContent->getDate().toString("dd.MM.yyyy"); 
-    QString tags = BookmarkContent->getTag();
-    int aIndex=BookmarkContent->getIndex();
-    QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName);
-
-    if (db.isOpen()) {
-        QSqlQuery query(db);
-        query.prepare("UPDATE BookMarkTable SET rowindex=rowindex+1 WHERE rowindex>=:aIndex");
-        query.bindValue(":aIndex", aIndex);
-        query.exec();
-        error = query.lastError();
-    
-        query.prepare("INSERT INTO BookMarkTable (title, url, adate, tags, rowindex, domain) "
-            "VALUES (:title, :url, :adate, :tags, :aIndex, :domain)");
-
-        query.bindValue(":title",   QVariant(title));
-        query.bindValue(":url",     QVariant(url));
-        query.bindValue(":adate",   QVariant(adate));
-        query.bindValue(":tags",    QVariant(tags));
-        query.bindValue(":rowindex",QVariant(aIndex));
-        query.bindValue(":domain",  QVariant(filterUrl(url)));
-
-        query.exec();
-        error = query.lastError();
-    }
-
-    if (error.type() == QSqlError::NoError) {
-        return ErrNone;
-    } else {
-        return ErrGeneral;
-    }
-}
-
-/**==============================================================
- * Description: deletes the requested bookmark
- ================================================================*/
-int BrowserContent::deleteBookmark(QString atitle)
-{
-    BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
-    QSqlError error;
-    QString title = atitle;
-    QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName);
-    bool ok;
-    if (db.isOpen()) {
-        QSqlQuery query(db);
-    
-        if(atitle.contains("'", Qt::CaseInsensitive))
-            atitle.replace(QString("'"), QString("''"));
-
-        query.prepare("SELECT title,url,adate,tags,rowindex FROM BookMarkTable WHERE title=:title");
-        query.bindValue(":title", title);
-        query.exec();
-        error = query.lastError();
-        query.next();
-        int aIndex=query.value(4).toInt(&ok);
-
-        query.prepare("DELETE FROM BookMarkTable WHERE title=:title");
-        query.bindValue(":title", title);
-        query.exec();
-        error = query.lastError();
-        if (error.type() == QSqlError::NoError) {
-            query.prepare("UPDATE BookMarkTable set rowindex=rowindex-1 WHERE rowindex>:aIndex");
-            query.bindValue(":aIndex", aIndex);
-            query.exec();
-            error = query.lastError();
-        }
-    }
-        
-    if (error.type() == QSqlError::NoError) {
-        return ErrNone;
-    } else {
-        return ErrGeneral;
-    }
-
-}
 
 
 /**==============================================================
@@ -195,7 +117,7 @@
     BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
     QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName);
     QList<BookmarkLeaf*> nodeslist;
-    
+        
     bool dbopen = db.isOpen();
     bool ok;
     
@@ -260,85 +182,6 @@
     return nodeslist;
 }
 
-/**==============================================================
- * Description: Reoders the Bokmarks based on index
- ================================================================*/
-int BrowserContent::reorderBokmarks(QString title,int new_index)
-{
-    BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
-    QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName);
-    QSqlQuery query(db);
-    QSqlError error;
-    bool ok;
-    
-    if(title.contains("'", Qt::CaseInsensitive))
-      title.replace(QString("'"), QString("''"));
-
-    query.prepare("SELECT title,url,adate,tags,rowindex FROM BookMarkTable WHERE title=:title");
-    query.bindValue(":title", title);
-    query.exec();
-    error = query.lastError();
-    query.next();
-    int old_index=query.value(4).toInt(&ok);
-
-    if(old_index>new_index) {
-          //Moving the item UP
-          query.prepare("UPDATE BookMarkTable set rowindex=rowindex+1 WHERE rowindex BETWEEN :new_index AND :old_index-1");
-    } else if(old_index<new_index) {
-         //Moving items Down
-         query.prepare("UPDATE BookMarkTable set rowindex=rowindex-1 WHERE rowindex BETWEEN :old_index+1 AND :new_index");
-    }
-    
-    query.bindValue(":old_index", old_index);
-    query.bindValue(":new_index", new_index);
-    //Moving items Down
-     query.exec();
-     error= query.lastError();
-
-    if (error.type() == QSqlError::NoError) {
-        query.prepare("UPDATE BookMarkTable set rowindex=:new_index WHERE title=:title");
-        query.bindValue(":title", title);
-        query.bindValue(":new_index", new_index);
-        query.exec();
-        error = query.lastError();
-    }
-
-    if (error.type() == QSqlError::NoError) {
-        //No error
-        return ErrNone;
-    }  else {
-        return ErrGeneral;
-    }
-}
-
-
-/**==============================================================
- * Description: modify the requested bookmark
- ================================================================*/
-int BrowserContent::modifyBookmark(QString aOrgTitle, QString aNewTitle, QString aNewUrl)
-{
-    BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent);
-    QSqlError error;
-    QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName);
-   
-    if (db.isOpen()) {
-        QSqlQuery query(db);
-        query.prepare("UPDATE BookMarkTable set title=:aNewTitle, url=:aNewUrl, domain=:aNewDomain WHERE title=:aOrgTitle");
-        query.bindValue(":aNewTitle", aNewTitle);
-        query.bindValue(":aNewUrl", aNewUrl);
-        query.bindValue(":aNewDomain", filterUrl(aNewUrl));
-        query.bindValue(":aOrgTitle", aOrgTitle);
-        query.exec();
-        error = query.lastError();
-    }
-
-    if (error.type() == QSqlError::NoError) {
-        return ErrNone;
-    } else {
-        return ErrGeneral;
-    }
-}
-
 
 /**==============================================================
  * Description: adds the bookmark to the database
@@ -358,15 +201,45 @@
     if (db.isOpen()) {
         QSqlQuery query(db);
 
-		query.prepare("INSERT INTO HistoryTable (rowindex,pageTitle, url, domain, timestamp) "
+       #ifdef Q_WS_MAEMO_5
+		// Update timestamp on existing entries that have the same URL and title and were time-stamped
+        // within the last 24 hours.  Normally there will only one of these entries.
+        query.prepare(QString("UPDATE HistoryTable "
+                              "SET timestamp=%1 "
+                              "WHERE timestamp>%2 AND url='%3' AND pageTitle='%4'")
+                      .arg(timestamp)
+                      .arg(timestamp - (60 * 60 * 24))
+                      .arg(url)
+                      .arg(title));
+        query.exec();
+        //qDebug() << "==" << __PRETTY_FUNCTION__ << query.executedQuery() << query.numRowsAffected() << query.lastError();
+
+        if(query.numRowsAffected() == 0)
+        {
+            // No recent duplicates found, create a new entry.
+            query.clear();
+            query.prepare("INSERT INTO HistoryTable (rowindex,pageTitle, url, domain, timestamp) "
+                           "VALUES (NULL,:title, :url, :domain, :timestamp)");
+
+            query.bindValue(":title",  QVariant(title));
+            query.bindValue(":url",    QVariant(url));
+            query.bindValue(":domain", QVariant(filterUrl(url)));
+            query.bindValue(":timestamp",  QVariant(timestamp));
+            query.exec();
+            //qDebug() << "==" << __PRETTY_FUNCTION__ << query.executedQuery() << query.lastError();
+            error = query.lastError();
+        }
+        #else
+        query.prepare("INSERT INTO HistoryTable (rowindex,pageTitle, url, domain, timestamp) "
                        "VALUES (NULL,:title, :url, :domain, :timestamp)");
 
         query.bindValue(":title",  QVariant(title));
         query.bindValue(":url",    QVariant(url));
         query.bindValue(":domain", QVariant(filterUrl(url)));
-		query.bindValue(":timestamp",  QVariant(timestamp));
+				query.bindValue(":timestamp",  QVariant(timestamp));
         query.exec();
         error = query.lastError();
+        #endif
     }
 
     if (error.type() == QSqlError::NoError) {
@@ -809,3 +682,4 @@
     }
     return map;
 }    
+    
Binary file browserrfsplugin/browserrfs.txt has changed
--- a/package_definition.xml	Mon Oct 04 14:09:43 2010 -0400
+++ b/package_definition.xml	Fri Oct 15 17:29:22 2010 -0400
@@ -1,16 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <SystemDefinition schema="3.0.0" xmlns:qt="http://www.nokia.com/qt">
- <package id="browser" name="Browser" levels="plugin utils support main">
-  <collection id="bookmarksengine" name="Bookmarks Engine" level="support">
-    <component id="bookmarksengine_build" name="Bookmarks Engine Build" introduced="^4" filter="s60">
-      <unit bldFile="bookmarksengine" qt:proFile="bookmarksengine.pro"/>
-    </component>
-    <component id="bookmarks_build" name="Bookmarks Build" introduced="^4" filter="s60">
-      <unit bldFile="bookmarks" qt:proFile="bookmarks.pro"/>
-    </component>        
-    <component id="browserrfsplugin_build" name="Browserrfsplugin Build" introduced="^4" filter="s60">
-      <unit bldFile="browserrfsplugin" qt:proFile="browserrfsplugin.pro"/>
-    </component>            
-  </collection>
- </package>
+<package id="browser" name="Browser" levels="plugin utils support main">
+<collection id="bookmarksengine" name="Bookmarks Engine" level="support">
+<component id="bookmarksengine_build" name="Bookmarks Engine Build" introduced="^4" filter="s60">
+<unit bldFile="bookmarksengine" qt:proFile="bookmarksengine.pro"/>
+</component>
+<component id="bookmarks_build" name="Bookmarks Build" introduced="^4" filter="s60">
+<unit bldFile="bookmarks" qt:proFile="bookmarks.pro"/>
+</component> 
+<component id="browserrfsplugin_build" name="Browserrfsplugin Build" introduced="^4" filter="s60">
+<unit bldFile="browserrfsplugin" qt:proFile="browserrfsplugin.pro"/>
+</component> 
+</collection>
+</package>
 </SystemDefinition>