# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1286141361 -10800 # Node ID 8f58c9334c71df2a5d321a2f586cbefb214f513e # Parent b61e1b3b145fb5908c47b66e35902736b7124618 Revision: 201037 Kit: 201039 diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/Bookmark.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/Bookmark.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,47 @@ +/* +* 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: +* +*/ +#ifndef BOOKMARK_H +#define BOOKMARK_H + +#include "bookmarksapi.h" +class QString; + +class BOOKMARKSAPI_EXPORT Bookmark { + +public: + QString url() { return m_url; } + QString title() { return m_title; } + int sortIndex() { return m_sortIndex; } + int id() { return m_id; } + + void setUrl(QString url) { m_url = url; } + void setTitle(QString title) { m_title = title; } + void setSortIndex(int sortIndex) { m_sortIndex = sortIndex; } + +private: + QString m_url; + QString m_title; + int m_sortIndex; + int m_id; + +}; + +#endif //BOOKMARK_H diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkFav.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkFav.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,9 @@ +/* + * BookmarkFav1.cpp + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#include "BookmarkFav.h" + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkFav.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkFav.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,62 @@ +/* + * BookmarkFav1.h + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#ifndef BOOKMARKFAV_H_ +#define BOOKMARKFAV_H_ + +#include +#include +#include "bookmarksapi.h" + +class BOOKMARKSAPI_EXPORT BookmarkFav : public QObject { + + Q_OBJECT + + Q_PROPERTY(int id READ id WRITE setId) + Q_PROPERTY(QString url READ url WRITE setUrl) + Q_PROPERTY(QString title READ title WRITE setTitle) + Q_PROPERTY(int sortIndex READ sortIndex WRITE setSortIndex) + +public: + BookmarkFav(int id, QString title, QString url, int sortIndex/*, QString description*/): + m_id(id), + m_title(title), + m_url(url), + m_sortIndex(sortIndex)/*, + m_description(description) */{}; + //TODO: Support XBEL description tag + BookmarkFav() : m_id(-1), m_title(""), m_url(""), m_sortIndex(-1) {}; + +public slots: + int id() const { return m_id; } + QString url() const { return m_url; } + QString title() const { return m_title; } + int sortIndex() const { return m_sortIndex; } + /* QString description() const { return m_description; } */ + + void setId(int id) {m_id = id;} + void setUrl(QString url) { m_url = url; } + void setTitle(QString title) { m_title = title; } + void setSortIndex(int sortIndex) { m_sortIndex = sortIndex; } + /*void setDescription(QString description) { m_description = description; } */ + +// static void registerMetaType(); + +private: + int m_id; + QString m_url; + QString m_title; + int m_sortIndex; + /* QString m_description; */ + +}; + +// For scripting +//Q_DECLARE_METATYPE(BookmarkFav *) + + +#endif /* BOOKMARKFAV_H_ */ diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkResults.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkResults.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,56 @@ +/* + * BookmarkResults.cpp + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "BookmarkResults.h" +#include "BookmarkFav.h" + +BookmarkResults::BookmarkResults(QSqlQuery *query/*, QWidget *parent*/) : + /*QObject(parent), */m_query(query) +{ +// setObjectName("bookmarkResults"); +} + +BookmarkFav *BookmarkResults::nextBookmark() +{ + if (!m_query->isActive()) + return NULL; + if (!m_query->next()) { + m_query->clear(); + return NULL; + } + bool dummy; + return + new BookmarkFav(m_query->value(0).toInt(&dummy), + m_query->value(1).toString(), + m_query->value(2).toString(), + m_query->value(3).toInt(&dummy)); +} + +BookmarkResults::~BookmarkResults() +{ + delete m_query; +} + +bool BookmarkResults::isMoreBookmarks() +{ + //return (m_query->isValid()); + return (m_query->isActive()); +} + +//void BookmarkResults::registerMetaType() +//{ +// qRegisterMetaType("BookmarkResults"); +//} +// diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkResults.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkResults.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,43 @@ +/* + * BookmarkResults.h + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#ifndef BOOKMARKRESULTS_H_ +#define BOOKMARKRESULTS_H_ + +#include + +#include "bookmarksapi.h" +class QSqlQuery; +class BookmarkFav; + +class BOOKMARKSAPI_EXPORT BookmarkResults : public QObject { + + Q_OBJECT + + Q_PROPERTY(BookmarkFav* next READ nextBookmark) + +public slots: + BookmarkFav *nextBookmark(); + // Javascript hack + bool isMoreBookmarks(); + +public: +// BookmarkResults(QSqlQuery *query = 0, QWidget *parent = 0); + BookmarkResults(QSqlQuery *query/*, QWidget *parent = 0*/); + ~BookmarkResults(); +// static void registerMetaType(); + +protected: + QSqlQuery* m_query; + +}; + +// For scripting +//Q_DECLARE_METATYPE(BookmarkResults*) + + +#endif /* BOOKMARKRESULTS_H_ */ diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkResultsList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkResultsList.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,9 @@ +/* + * BookmarkResultsList.cpp + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#include "BookmarkResultsList.h" + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarkResultsList.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarkResultsList.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,27 @@ +/* + * BookmarkResultsList.h + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#ifndef BOOKMARKRESULTSLIST_H_ +#define BOOKMARKRESULTSLIST_H_ + +#include + +template +class BookmarkResultsList : public QList +{ + /* +public: + inline QQueue() {} + inline ~QQueue() {} + inline void enqueue(const T &t) { QList::append(t); } + inline T dequeue() { return QList::takeFirst(); } + inline T &head() { return QList::first(); } + inline const T &head() const { return QList::first(); } +*/ +}; + +#endif /* BOOKMARKRESULTSLIST_H_ */ diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarksManager.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarksManager.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,711 @@ +/* +* 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bookmarksapi.h" +#include "BookmarksManager.h" +#include "BookmarkFav.h" +#include "BookmarkResults.h" +#include "TagResults.h" +#include "xbelreader.h" +#include "xbelwriter.h" +#include "defaultBookmarks.xml.h" + +BookmarksManager::BookmarksManager(QWidget *parent) : + QObject(parent) +{ + setObjectName("bookmarksManager"); + + m_db = QSqlDatabase::database(BOOKMARKS_DB_NAME); + if (!m_db.isValid()) { + m_db = QSqlDatabase::addDatabase("QSQLITE", BOOKMARKS_DB_NAME); + m_db.setDatabaseName(BOOKMARKS_DB_FILE); + } + 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(); + } +} + +BookmarksManager::~BookmarksManager() { + m_db.close(); + QSqlDatabase::removeDatabase(BOOKMARKS_DB_NAME); +} + +/* + * +-------------+ +----------+ + * |Bookmarks(ID)|* <-> *|Tags(BMID)| + * +-------------+ +----------+ + */ +void BookmarksManager::createBookmarksSchema() { + // Bookmarks + if (!doQuery("CREATE TABLE IF NOT EXISTS bookmarks(" + "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)")) { + // TODO: do some error handling here! + return; + } + // We do a lot of lookups by id + if (!doQuery("CREATE INDEX IF NOT EXISTS bm_id_idx ON bookmarks(id ASC)")) { + // TODO: do some error handling here! + return; + } + + // Tags + // 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))")) { + // TODO: do some error handling here! + return; + } + // We do a lot of lookups, both by bookmark id and by tag + if (!doQuery("CREATE INDEX IF NOT EXISTS tags_bmid_idx ON tags(bmid ASC)")) { + // TODO: do some error handling here! + return; + } + if (!doQuery("CREATE INDEX IF NOT EXISTS tags_tag_idx ON tags(tag ASC)")) { + // TODO: do some error handling here! + return; + } +} + +// TODO refactor this - nothing except the schema creation can use it as is +bool BookmarksManager::doQuery(QString query) { +#ifdef ENABLE_PERF_TRACE + PERF_DEBUG() << __PRETTY_FUNCTION__ << query << "\n"; + unsigned int st = WrtPerfTracer::tracer()->startTimer(); +#endif + 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(); + } +#ifdef ENABLE_PERF_TRACE + PERF_DEBUG() << __PRETTY_FUNCTION__ << WrtPerfTracer::tracer()->elapsedTime(st) << "\n"; +#endif + return ok; +} + + +/**============================================================== + * Description: Normalize a given url, if needed. + * It adds http:// in front, if the url is relative. + ================================================================*/ +QString BookmarksManager::normalizeUrl(const QString& url) +{ + // If the URL is relative, add http in front + QString updatedUrl = url; + + if (!url.contains("://")) { + updatedUrl.prepend("http://"); + } + return updatedUrl; +} + +/**============================================================== + * Description: Adds the bookmark to the database, given title and + * url. + * Returns: Returns bookmarkID ( >0)else Failure (-1 or -2) + ================================================================*/ +int BookmarksManager::addBookmark(QString title, QString URL) +{ + int bookmarkId = 0; + + if(URL.isEmpty()) { + bookmarkId = FAILURE; + } + + if(bookmarkId != FAILURE) { + // do some checking on parameters + QString updatedTitle = title; + QString updatedUrl = normalizeUrl(URL); + int soIndex = 1; + if (title.isEmpty()) { + updatedTitle = "Untitled"; + } + if (m_db.isOpen()) { + QSqlQuery query(m_db); + m_db.transaction(); + if (!query.exec("SELECT count(*) from bookmarks")) { + 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.bindValue(":title", QVariant(updatedTitle)); + query.bindValue(":url", QVariant(updatedUrl)); + query.bindValue(":sIndex", QVariant(soIndex)); + if (!query.exec()) { + lastErrMsg(query); + m_db.rollback(); + return DATABASEERROR; + } + // Note: lastInsertId() is not thread-safe + bookmarkId = query.lastInsertId().toInt(); + if (!m_db.commit()) { + qDebug() << m_db.lastError().text(); + m_db.rollback(); + return DATABASEERROR; + } + } else { + bookmarkId = FAILURE; + } + } + return bookmarkId; +} + +/**============================================================== + * Import bookmarks from an XBEL file. If no filename is + * passed in a set of default bookmarks will be imported. + * The default bookmarks used can be changed by updating + * the file "defaultBookmarks.xml.cpp". + * @param xbelFilePath - String containing the path to the + * file to import. + * @return SUCCESS or FAILURE depending on whether the + * import process was successful. + ==============================================================*/ +int BookmarksManager::importBookmarks(QString xbelFilePath) +{ + XbelReader *reader = new XbelReader(this); + bool retVal = false; + + if(xbelFilePath.isEmpty() || !QFile::exists(xbelFilePath)) { + xbelFilePath = "c:\\data\\temp.xml"; + QFile file(xbelFilePath); + if(file.exists()) + file.remove(); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return false; + QTextStream out(&file); + out << defaultBookmarksList; + out.flush(); + file.close(); + } + QFile file(xbelFilePath); + if(file.exists()) { + file.open(QIODevice::ReadOnly | QIODevice::Text); + retVal = reader->read(&file); + file.close(); + } + if(reader) + delete reader; + return retVal ? SUCCESS : FAILURE; +} + +/**============================================================== + * Exports all bookmarks in the database to an XBEL file. This function + * expects a valid file path to be passed in. If the path is not valid + * a default file path will be used. If a file with that name already + * exists at that location, + * @param xbelFilePath String containing the path of the file to + * export to. + * @return SUCCESS or FAILURE depending on whether the + * export process was successful. + ==============================================================*/ +int BookmarksManager::exportBookmarks(QString xbelFilePath) +{ + XbelWriter *writer = new XbelWriter(this); + bool retVal = false; + + if(xbelFilePath.isEmpty()) { + xbelFilePath = "c:\\data\\myBookmarks.xml"; + } + + QFile file(xbelFilePath); + if(file.exists()) { + file.remove(xbelFilePath); + } + file.open(QIODevice::WriteOnly | QIODevice::Text); + retVal = writer->writeFile(&file); + file.flush(); + file.close(); + + if(writer) + delete writer; + return retVal ? SUCCESS : FAILURE; + +} + +/**============================================================== + * Description: Modify the existing bookmark. Given id of the bookmark + * 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 retVal = SUCCESS; + + // Client has to at least pass title or url + if(newTitle.isEmpty() && newURL.isEmpty()) + retVal = FAILURE; + + if(retVal == SUCCESS) { + + if (m_db.isOpen()) { + QSqlQuery query(m_db); + + 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"); + query.bindValue(":newTitle", newTitle); + query.bindValue(":bmId", origBookmarkId); + } else { + 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); + } + 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 + retVal = FAILURE; + } + return retVal; +} + +/**=================================================================================== + * Description: Delete the bookmark item, also delete all the tags associated with it. + * Returns: SUCCESS(0) or Failure(-1 or -2) + ======================================================================================*/ +int BookmarksManager::deleteBookmark(int bookmarkId) +{ + int retVal = SUCCESS; + + 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 + + // TODO: check if transaction() has been supported + // by calling hasfeature() function first + m_db.transaction(); + + query.prepare("DELETE FROM bookmarks WHERE id=:bmId"); + query.bindValue(":bmId", bookmarkId); + if (!query.exec()) { + lastErrMsg(query); + 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 + retVal = FAILURE; + + return retVal; +} + +/**=================================================================================== + * Description: Delete all records from the bookmarks table as well as all the tags. + * Returns: SUCCESS(0) or FAILURE(-1 or -2) + ======================================================================================*/ +int BookmarksManager::clearAll() +{ + 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")) { + lastErrMsg(query); + m_db.rollback(); + retVal = DATABASEERROR; + } + 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 + retVal = FAILURE; + + return retVal; +} + +/**============================================================== + * Description: Deletes a single tag associated with the bookmark + * Returns: SUCCESS(0) or FAILURE (-1 or -2) + ===============================================================*/ +int BookmarksManager::deleteTag(int bookmarkId, QString tagToDelete) +{ + int retVal = SUCCESS; + + 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); + if (!query.exec()) { + lastErrMsg(query); + retVal = DATABASEERROR; + } + } else + retVal = FAILURE; + } + + return retVal; +} + +/**================================================================ + * Description: Adds a single tag associated given the bookmark id + * Returns: SUCCESS(0) or FAILURE (-1 or -2) + ==================================================================*/ +int BookmarksManager::addTag(int bookmarkId, QString tagToAdd) +{ + int retVal = SUCCESS; + + if(tagToAdd.isEmpty()|| bookmarkId < 0) + retVal = FAILURE; + + 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)); + + if (!query.exec()) { + lastErrMsg(query); + retVal = DATABASEERROR; + } + } else + retVal = FAILURE; + } + + return retVal; +} + +/**============================================================== + * Description: Finds all the bookmarks weather they have tags + * or not. + * Returns: A pointer to BookmarkResults object or NULL. + ===============================================================*/ +BookmarkResults *BookmarksManager::findAllBookmarks() +{ + BookmarkResults * results = NULL; + + QString queryStr = QString("SELECT " + " 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); + } else { + qDebug() << query->lastError().text() << " Query: " << query->lastQuery(); + results = NULL; + } + } + return results; +} + +/**============================================================== + * Description: Finds all the distinct tags. + * Returns: A pointer to TagResults object or NULL. + ===============================================================*/ +TagResults *BookmarksManager::findAllTags() +{ + 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); + } else { + qDebug() << query->lastError().text() << " Query: " << query->lastQuery(); + results = NULL; + } + } + return results; +} + + +/**============================================================== + * Description: Finds all the bookmarks associated with a given + * tag. + * Returns: A pointer to BookmarkResults object or NULL. + ===============================================================*/ +BookmarkResults *BookmarksManager::findBookmarksByTag(QString tag) +{ + 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(); + results = NULL; + } + } + return results; +} + + +/**============================================================== + * Description: Finds all the Tags associated with a given + * bookmarkID. + * Returns: A pointer to TagResults object or NULL. + ===============================================================*/ +TagResults *BookmarksManager::findTagsByBookmark(int bookmarkID) +{ + 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()) { + 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); + } else { + qDebug() << query->lastError().text() << " Query: " << query->lastQuery(); + results = NULL; + } + } + return results; +} + +/**============================================================== + * Description: Finds all the Bookmarks that doesn't have any + * tags associated with it. It is needed by export API. + * Returns: A pointer to BookmarkResults object or NULL. + ===============================================================*/ +BookmarkResults *BookmarksManager::findUntaggedBookmarks() +{ + 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"); + + 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) + return FAILURE; + + if (!m_db.isOpen()) + return DATABASEERROR; + + QSqlQuery query(m_db); + + // Make sure the bookmark exists + BookmarkFav *bm = findBookmark(bookmarkID); + if (!bm) + return FAILURE; + + // Next, help stamp out and abolish redundancy. If the bookmark is already at this sortIndex, do nothing. + if (bm->sortIndex() == newIndex) + return SUCCESS; + + /* + * Ok, the way the sortIndex works is that you can specify any sortIndex you want (it doesn't have to be consecutive). + * This means there can be holes in the list of sortIndexes. Whenever someone wants to move a bookmark to a new sort + * position, we just bump everything that was in that position and further down the list by 1 and then set the sortIndex + * of the bookmark to what they want. This should work whether there is more than one bookmark or not. + */ + + // Bump all the bookmarks from this sortIndex down by 1 first + m_db.transaction(); + query.prepare("UPDATE bookmarks SET sortIndex=sortIndex+1 WHERE sortIndex >= :newIndex"); + query.bindValue(":newIndex", newIndex); + if (!query.exec()) { + lastErrMsg(query); + return DATABASEERROR; + } + // Then just set this bookmark's sortIndex to the new value + query.prepare("UPDATE bookmarks SET sortIndex=:newIndex WHERE id=:id"); + query.bindValue(":id", bookmarkID); + query.bindValue(":newIndex", newIndex); + if (!query.exec()) { + lastErrMsg(query); + m_db.rollback(); + return DATABASEERROR; + } + if (!m_db.commit()){ + qDebug() << m_db.lastError().text(); + m_db.rollback(); + return DATABASEERROR; + } + return SUCCESS; +} + +/**============================================================== + * Description: Finds a bookmark based on a given bookmarkID. + * Returns: A pointer to BookmarkFav object or NULL. + ===============================================================*/ +BookmarkFav* BookmarksManager::findBookmark(int bookmarkId) +{ + BookmarkFav * results = NULL; + + + 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()); + } else { + lastErrMsg(query); + } + } + return results; +} + +/**============================================================== + * Description: Finds a bookmark based on a given bookmarkID. + * Returns: A pointer to BookmarkFav object or NULL. + ===============================================================*/ +QMap BookmarksManager::findBookmarks(QString atitle) +{ + QMap map; + + if (m_db.isOpen()) { + QSqlQuery query(m_db); + QString queryStatement = "SELECT url, title FROM bookmarks WHERE title LIKE '%"+atitle+"%' OR url LIKE '%" + atitle + "%'"; + query.prepare(queryStatement); + if(query.exec()) { + while (query.next()){ + QString bookmarkUrl = query.value(0).toString(); + QString bookmarkTitle = query.value(1).toString(); + map.insert( bookmarkUrl, bookmarkTitle ); + } + } else { + lastErrMsg(query); + } + } + return map; +} + +/**============================================================== + * Description: Prints a last error message from the query. + * Returns: Nothing. + ===============================================================*/ +void BookmarksManager::lastErrMsg(QSqlQuery& query) +{ + qDebug() << "BookmarksManager::lastErrMsg" << QString("ERR: %1 %2").arg(query.lastError().type()).arg(query.lastError().text()) << " Query: " << query.lastQuery(); +} + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/BookmarksManager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/BookmarksManager.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,81 @@ +/* +* 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: +* +*/ +#ifndef BOOKMARKSMANAGER_H +#define BOOKMARKSMANAGER_H + +#include +#include +#include +#include +#include + +#include "bookmarksapi.h" +class QWidget; +class BookmarkFav; +class BookmarkResults; +class TagResults; + +#define BOOKMARKS_DB_NAME "Bookmarks" +#define BOOKMARKS_DB_FILE "bookmarks.db" + +class BOOKMARKSAPI_EXPORT BookmarksManager : public QObject { + + Q_OBJECT + +public: + enum status { + SUCCESS = 0, + DATABASEERROR = -1, + FAILURE = -2 + }; + + BookmarksManager(QWidget *parent = 0); + ~BookmarksManager(); + +public slots: + int addBookmark(QString title, QString URL); + int modifyBookmark(int origBookmarkId, QString newTitle, QString newURl); + int deleteBookmark(int bookmarkId); + int clearAll(); + int deleteTag(int bookmarkId, QString tag); + int addTag(int bookmarkId, QString tag); + BookmarkResults *findAllBookmarks(); + TagResults *findAllTags(); + BookmarkResults *findBookmarksByTag(QString tag); + int importBookmarks(QString xbelFilePath); + int exportBookmarks(QString xbelFilePath); + BookmarkFav* findBookmark(int bookmarkId); + BookmarkResults *findUntaggedBookmarks(); + int reorderBookmark(int bookmarkID, int newIndex); + TagResults* findTagsByBookmark(int bookmarkID); + QMap findBookmarks(QString atitle); + + private: + bool doQuery(QString query); + void createBookmarksSchema(); + QString normalizeUrl(const QString& url); + void lastErrMsg(QSqlQuery& query); + + QSqlDatabase m_db; + // Note: One instance of a query was locking the database even after using finish() and clear() + //QSqlQuery* m_query; +}; +#endif //BOOKMARKSMANAGER_H diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/TagResults.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/TagResults.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,41 @@ +/* + * TagResults.cpp + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "TagResults.h" + + +TagResults::TagResults(QSqlQuery *query, QWidget *parent) : QObject(parent), m_query(query) +{ +} + +QString *TagResults::nextTag() +{ + if (!hasMoreTags()) + return NULL; + if (!m_query->next()) { + m_query->clear(); + return NULL; + } + return new QString(m_query->value(0).toString()); +} + +bool TagResults::hasMoreTags() { + return m_query->isActive(); +} + +TagResults::~TagResults() +{ + delete m_query; +} diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/TagResults.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/TagResults.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,45 @@ +/* + * TagResults.h + * + * Created on: Aug 13, 2010 + * Author: mmoretti + */ + +#ifndef TAGRESULTS_H_ +#define TAGRESULTS_H_ + +#include +#include +#include +#include +#include +#include + +#include "bookmarksapi.h" + +class BOOKMARKSAPI_EXPORT TagResults : public QObject { + + Q_OBJECT + + Q_PROPERTY(QString* next READ nextTag) + Q_PROPERTY(bool hasMoreTags READ hasMoreTags) + +public slots: + QString *nextTag(); + +public: + TagResults(QSqlQuery *query, QWidget *parent = 0); + ~TagResults(); + +public: + bool hasMoreTags(); + +protected: + QSqlQuery* m_query; +}; + +// For scripting +//Q_DECLARE_METATYPE(TagResults *) + + +#endif /* TAGRESULTS_H_ */ diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/bookmarks.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/bookmarks.pro Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,110 @@ +# Copyright (c) 2010 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: +TEMPLATE = lib +TARGET = bookmarksapi +ROOT_DIR = $$PWD/.. +include($$ROOT_DIR/browser.pri) +DEFINES += BUILDING_BOOKMARKSAPI_DLL +QT += core \ + network \ + xml \ + sql \ + script + +# HEADERS += $$PWD/inc/browsercontentdllclientdefs.h \ +# $$PWD/inc/browsercontentdll.h +# SOURCES += $$PWD/src/browsercontentdll.cpp +isEmpty(BEDROCK_OUTPUT_DIR): { + symbian { + CONFIG(release, debug|release):BOOKMARKSAPI_OUTPUT_DIR = $$PWD/../../WrtBuild/Release + CONFIG(debug, debug|release):BOOKMARKSAPI_OUTPUT_DIR = $$PWD/../../WrtBuild/Debug + } + else { + CONFIG(release, debug|release):BOOKMARKSAPI_OUTPUT_DIR = $$PWD/../../../../WrtBuild/Release + CONFIG(debug, debug|release):BOOKMARKSAPI_OUTPUT_DIR = $$PWD/../../../../WrtBuild/Debug + } +} +else:BOOKMARKSAPI_OUTPUT_DIR = $$BEDROCK_OUTPUT_DIR +OBJECTS_DIR = $$BOOKMARKSAPI_OUTPUT_DIR/bookmarksapi/tmp +DESTDIR = $$BOOKMARKSAPI_OUTPUT_DIR/bin +MOC_DIR = $$BOOKMARKSAPI_OUTPUT_DIR/bookmarksapi/tmp +RCC_DIR = $$BOOKMARKSAPI_OUTPUT_DIR/bookmarksapi/tmp +TEMPDIR = $$BOOKMARKSAPI_OUTPUT_DIR/bookmarksapi/build + +# QMAKE_LIBDIR = $$BOOKMARKSCLIENTDLL_DATAMODEL_OUTPUT_DIR/bin +INCLUDEPATH += $$PWD + +# I believe the following line to be useless on all platforms. (carol.szabo@nokia.com) +# !s40:LIBS += -Llib +# CONFIG += \ +# building-libs \ +# depend_includepath \ +# dll +CONFIG += dll + +# CONFIG(release, debug|release):!CONFIG(QTDIR_build){ +# !unix : contains(QT_CONFIG, reduce_exports): CONFIG += hide_symbols +# unix : contains(QT_CONFIG, reduce_relocations): CONFIG += bsymbolic_functions +# } +# CONFIG -= warn_on +*-g++*:QMAKE_CXXFLAGS += -Wreturn-type \ + -fno-strict-aliasing +CONFIG(gcov) { + LIBS += -lgcov + QMAKE_CXXFLAGS += -fprofile-arcs \ + -ftest-coverage + message( "building for coverage statics" ) +} +isEmpty(TEMPDIR) { + CONFIG(release, debug|release):TEMPDIR = $$DESTDIR/Release/build + CONFIG(debug, debug|release):TEMPDIR = $$DESTDIR/Debug/build +} +CONFIG (maemo):include(../../../../cwrt-maemo.pri) +symbian: { + TARGET.UID3 = 0x200267E7 + TARGET.VID = VID_DEFAULT + TARGET.EPOCALLOWDLLDATA = 1 + TARGET.CAPABILITY = All \ + -TCB \ + -DRM \ + -AllFiles + LIBS += -lefsrv \ + -lcaf \ + -lcafutils + INCLUDEPATH += $$MW_LAYER_PUBLIC_EXPORT_PATH(cwrt) \ + $$MW_LAYER_PUBLIC_EXPORT_PATH() + INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE + INCLUDEPATH += /epoc32/include + bookmarksapi.sources = bookmarksapi.dll + bookmarksapi.path = /sys/bin + DEPLOYMENT += bookmarksapi +} +HEADERS = \ +#BookmarkResultsList.h \ + TagResults.h \ + BookmarkResults.h \ + BookmarkFav.h \ + xbelreader.h \ + xbelwriter.h \ + BookmarksManager.h \ + bookmarksapi.h \ + Bookmark.h +SOURCES = \ +#BookmarkResultsList.cpp \ + TagResults.cpp \ + BookmarkResults.cpp \ + BookmarkFav.cpp \ + xbelreader.cpp \ + xbelwriter.cpp \ + BookmarksManager.cpp diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/bookmarksapi.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/bookmarksapi.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,32 @@ +/* +* 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: +* +*/ +#ifndef BOOKMARKSAPI_H +#define BOOKMARKSAPI_H + +#ifdef BUILDING_BOOKMARKSAPI_DLL + #define BOOKMARKSAPI_EXPORT Q_DECL_EXPORT +#else + #define BOOKMARKSAPI_EXPORT Q_DECL_IMPORT +#endif + + + +#endif // BOOKMARKSAPI_H diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/conf/BookmarkData.confml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/conf/BookmarkData.confml Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,103 @@ + + + + + false + false + + Tre IOP XHTML + http://rave.cellulardata.com/xhtml/index.xhtml + + + Geocaching.hu + http://geocaching.hu/wap + + + Test sites + + + + DDT + http://ammo.factory.cellulardata.com:8000/ddt + + + DDT (no cookies) + http://ammo.factory.cellulardata.com:8000/ddtnc + + + Digdown + http://digdown1.extra.wirelessfuture.com/ddtnc + + + DLS 2.0 S60 + http://trsrv42.wirelessfuture.com/content/s60/index.wml + + + DLS 2.0 IOP + http://www.it.cellulardata.com/iop/dls20/index.wml + + + Wirelessfuture + http://trsrv29.extra.wirelessfuture.com/drm/index.wml + + + User agent + http://testsuite.nokia-boston.com/content/wml_ua/wmlheader.asp + Tag1 + + + Google + http://www.google.com + + + Eco + http://wap.eco.hu + + + Stop! + http://wap.stop.hu + Tag1 + + + Report Browser Bugs + http://waplabdc.nokia-boston.com/browser/users/Kimono/errorEmail/error.asp + + + OSS Browser Report + http://waplabdc.nokia-boston.com/browser/users/OSSBrowser/errorEmail/error.asp + + + Google + Http://www.google.com + + + + + + + XHTML -IOP + http://rave.cellulardata.com/xhtml/index.xhtml + + + TCG + http://testsuite.nokia-boston.com + + + Widgets + http://widgets.nokia-boston.com + + + S60 Acceptance Test + http://testsuite.nokia-boston.com/s60accept/qstart.asp + + + Tre IOP WML + http://195.134.227.137/1.wml + + + + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/conf/BookmarkItems.gcfml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/conf/BookmarkItems.gcfml Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,272 @@ + + + + + + + + + ======= Customer Top Priority Bookmark Item ======= + + + + + + <xsl:value-of select="Name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======= Top Priority Bookmark Item ======= + + + + + + <xsl:value-of select="Name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======= Customer Bookmark Items ======= + + + + + + + + <xsl:value-of select="Name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======= End Customer Bookmark Items ======= + + + + + + ======= Nokia Bookmark Items ======= + + + + + + + + <xsl:value-of select="Name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======= End Nokia Bookmark Items ======= + + + + ======= Nokia Bookmarks Removed ======= + + + + + + + + + ======= Third Party Bookmark Items ======= + + + + + + <xsl:value-of select="Name"/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======= End Third Party Bookmark Items ======= + + + + ======= Third Party Bookmarks Removed ======= + + + + + + + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/conf/CI_bookmarks.confml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/conf/CI_bookmarks.confml Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,159 @@ + + + + + If selected all Nokia bookmarks are removed. + + + If selected all Third party bookmarks are removed. + + + TBD + + Text field containing name for the Bookmark. Must be unique. + + + + Text of the full URL for a Bookmark.(e.g. http://my.server.com) + + + + Add Description. + + Text field containing name for the Bookmark. Must be unique. + + + + Text of the full URL for a Bookmark.(e.g. http://my.server.com) + + + + Add Description. + + Text field containing name for the Bookmark. Must be unique. + + + + Text of the full URL for a Bookmark. (e.g. http://my.server.com) + + + + Add Description. + + Text field containing name for the Bookmark. Must be unique. + + + + Text of the full URL for a Bookmark. (e.g. http://my.server.com) + + + + Add Description. + + Text field containing name for the Bookmark. Must be unique. + + + + Text of the full URL for a Bookmark. (e.g. http://my.server.com) + + + + + + + false + false + + Tre IOP XHTML + http://rave.cellulardata.com/xhtml/index.xhtml + + + Geocaching.hu + http://geocaching.hu/wap + + + Test sites + + + + DDT + http://ammo.factory.cellulardata.com:8000/ddt + + + DDT (no cookies) + http://ammo.factory.cellulardata.com:8000/ddtnc + + + Digdown + http://digdown1.extra.wirelessfuture.com/ddtnc + + + DLS 2.0 S60 + http://trsrv42.wirelessfuture.com/content/s60/index.wml + + + DLS 2.0 IOP + http://www.it.cellulardata.com/iop/dls20/index.wml + + + Wirelessfuture + http://trsrv29.extra.wirelessfuture.com/drm/index.wml + + + User agent + http://testsuite.nokia-boston.com/content/wml_ua/wmlheader.asp + Tag1 + + + Google + http://www.google.com + + + Eco + http://wap.eco.hu + + + Stop! + http://wap.stop.hu + Tag1 + + + Report Browser Bugs + http://waplabdc.nokia-boston.com/browser/users/Kimono/errorEmail/error.asp + + + OSS Browser Report + http://waplabdc.nokia-boston.com/browser/users/OSSBrowser/errorEmail/error.asp + + + Google + Http://www.google.com + + + + + + + XHTML -IOP + http://rave.cellulardata.com/xhtml/index.xhtml + + + TCG + http://testsuite.nokia-boston.com + + + Widgets + http://widgets.nokia-boston.com + + + S60 Acceptance Test + http://testsuite.nokia-boston.com/s60accept/qstart.asp + + + Tre IOP WML + http://195.134.227.137/1.wml + + + + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/conf/bookmarks.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/conf/bookmarks.xml Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,38 @@ + + + TCG + + + Browser 8.x NFT + + + Browser Testing Center + + + HTML 5 test page + + + Nokia + + + OVI + + + Google + + + GMail + + + CNN + + + What's my user agent? + + + Youtube + + + Iltasanomat + + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/defaultBookmarks.xml.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/defaultBookmarks.xml.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,84 @@ +/* + * defaultBookmarks.xml.h + * + * Created on: Aug 20, 2010 + * Author: chriwhit + */ + +#ifndef DEFAULTBOOKMARKS_XML_H_ +#define DEFAULTBOOKMARKS_XML_H_ + +#include "bookmarksapi.h" + +extern const QString defaultBookmarksList = "\n\ +\n\ + \n\ + Nokia\n\ + \n\ + \n\ + \n\ + nokia\n\ + default\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + Google\n\ + \n\ + \n\ + \n\ + google\n\ + nokia \n\ + search\n\ + default\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + Yahoo\n\ + \n\ + \n\ + \n\ + yahoo\n\ + nokia\n\ + search\n\ + default\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + Google Mail\n\ + \n\ + \n\ + \n\ + google\n\ + email\n\ + nokia\n\ + default\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + \n\ + Nokia Ovi Services\n\ + \n\ + \n\ + \n\ + ovi\n\ + nokia\n\ + default\n\ + \n\ + \n\ + \n\ + \n\ + \n\ +"; + +#endif /* DEFAULTBOOKMARKS_XML_H_ */ diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/xbel-1.0.dtd --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/xbel-1.0.dtd Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/xbelreader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/xbelreader.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,201 @@ +/* +* 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/". +* +*/ +#include +#include +#include + +#include "xbelreader.h" +#include "BookmarksManager.h" + +XbelReader::XbelReader(BookmarksManager *bmgr) : + m_bmgr(bmgr), m_xml(new QXmlStreamReader) +{ +} + +XbelReader::~XbelReader() { + if(m_xml) delete m_xml; +} + +bool XbelReader::read(QIODevice *device) +{ + if(!device) { + m_xml->raiseError(QObject::tr("Invalid Device passed into XBEL Reader.")); + } + if(!m_bmgr) { + m_xml->raiseError(QObject::tr("Invalid BookmarkManager passed into XBEL Reader.")); + } else { + m_xml->setDevice(device); + if(m_xml->readNextStartElement()) { + if(m_xml->name() == "xbel" && + m_xml->attributes().value("version") == "1.0") + readXBEL(); + else + m_xml->raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); + } else + m_xml->raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); + } + + return !m_xml->error(); +} + +/** + * This function should be called before reading any xml elements + * It attempts to validate that the file being read is actually an + * xbel file. + * @return whether the file is an XBEL file. + */ +bool XbelReader::isValidXbel() +{ + // The xbel element must exist and must be version 1.0 + return true; +} + +QString XbelReader::errorString() const +{ + return QObject::tr("%1\nLine %2, column %3") + .arg(m_xml->errorString()) + .arg(m_xml->lineNumber()) + .arg(m_xml->columnNumber()); +} + +void XbelReader::readXBEL() +{ + QString folder = ""; + QList folders; + while (m_xml->readNextStartElement()) { + if (m_xml->name() == "folder") + readFolder(folders); + else if (m_xml->name() == "bookmark") + readBookmark(folders); + else + m_xml->skipCurrentElement(); + } +} + +QString XbelReader::readFolder(QList& parentFolders) +{ + QString folderName = ""; + + while (m_xml->readNextStartElement()) { + if (m_xml->name() == "title") + folderName = m_xml->readElementText(); + else if (m_xml->name() == "folder") { + QList folders; + folders = folders + parentFolders; + if(!folderName.isEmpty()) + folders.append(folderName); + readFolder(folders); + } else if (m_xml->name() == "bookmark") { + QList folders; + folders = folders + parentFolders; + if(!folderName.isEmpty()) + folders.append(folderName); + readBookmark(folders); + } else + m_xml->skipCurrentElement(); + } + return folderName; +} + +void XbelReader::readBookmark(QList& parentFolders) +{ + QXmlStreamAttributes attrs = m_xml->attributes(); + + // if there is no URL attribute skip this bookmark. + if(!attrs.hasAttribute("href")) { + m_xml->skipCurrentElement(); + return; + } + + QString url = attrs.value("href").toString(); + QString title = "Untitled"; + QString desc = ""; + QList tags; + tags = tags + parentFolders; + + while (m_xml->readNextStartElement()) { + if (m_xml->name() == "title") + title = m_xml->readElementText(); + else if(m_xml->name() == "desc") + desc = m_xml->readElementText(); + else if(m_xml->name() == "info") + readInfo(tags); + else + m_xml->skipCurrentElement(); + } + + int bmID = m_bmgr->addBookmark(title, url); + if (bmID > 0) { + QList::iterator iter; + for (iter = tags.begin(); iter != tags.end(); ++iter) + m_bmgr->addTag(bmID, *iter); + } +} + +/** + * Reads the info element. + * @param tags - A reference to a list of string tags + */ +void XbelReader::readInfo(QList& tags) +{ + QString owner = "http://www.nokia.com"; + while(m_xml->readNextStartElement()) { + if(m_xml->name() == "metadata") + readMetadata(tags, owner); + else + m_xml->skipCurrentElement(); + } +} + +/** + * This function reads the metadata XBEL tag. + * @param tags - A reference to a list of strings. This is passed into + * readTags. + * @param owner - A reference to the owner string. This is to allow for + * future support for this attribute. + */ +void XbelReader::readMetadata(QList& tags, QString &owner) +{ + if(m_xml->attributes().hasAttribute("owner")) + owner = m_xml->attributes().value("owner").toString(); + while(m_xml->readNextStartElement()) { + if(m_xml->name() == "tags") + readTags(tags); + else + m_xml->skipCurrentElement(); + } + +} + +/** + * Reads the tags and tag attributes, adding all tags found to + * the list of string tags passed into the function. + * @param tags - Reference to a list of string tags. + */ +void XbelReader::readTags(QList& tags) +{ + while(m_xml->readNextStartElement()) { + if(m_xml->name() == "tag") + tags.append(m_xml->readElementText()); + else + m_xml->skipCurrentElement(); + } + +} + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/xbelreader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/xbelreader.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,55 @@ +/* +* 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/". +* +*/ +#ifndef XBELREADER_H +#define XBELREADER_H + +#include + +class BookmarksManager; +class QXmlStreamReader; +class QIODevice; + +/* + * Reads an XBEL file and imports bookmarks + * Folders are treated as "tags" + * i.e. bookmarks inside folders are imported one at a time and the folder name is added as a tag for that bookmark + */ +class XbelReader +{ +public: // ctor/dtor + XbelReader(BookmarksManager *bmgr); + virtual ~XbelReader(); + +public: // members + bool read(QIODevice *device); + QString errorString() const; + +private: + bool isValidXbel(); + void readXBEL(); + QString readFolder(QList& parentFolders); + void readBookmark(QList& parentFolders); + void readInfo(QList& tags); + void readMetadata(QList& tags, QString &owner); + void readTags(QList& tags); + + BookmarksManager *m_bmgr; + QXmlStreamReader *m_xml; +}; +#endif diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/xbelwriter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/xbelwriter.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,107 @@ +/* +* 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/". +* +*/ + +#include +#include +#include +#include + +#include "xbelwriter.h" +#include "BookmarksManager.h" +#include "BookmarkFav.h" +#include "BookmarkResults.h" +#include "TagResults.h" + + +XbelWriter::XbelWriter(BookmarksManager *bmgr) + : m_bmgr(bmgr), m_xml(new QXmlStreamWriter()) +{ +} + +XbelWriter::~XbelWriter() { + if(m_xml) delete m_xml; +} + +bool XbelWriter::writeFile(QIODevice *device) +{ + bool retVal = false; + if(device && m_bmgr) { + m_xml->setDevice(device); + m_xml->setAutoFormatting(true); + + m_xml->writeStartDocument(); + m_xml->writeDTD(""); + m_xml->writeStartElement("xbel"); + m_xml->writeAttribute("version", "1.0"); + + BookmarkResults *bookmarks = m_bmgr->findAllBookmarks(); + if(bookmarks) { + while (BookmarkFav *bm = bookmarks->nextBookmark()) { + if(!bm->url().isEmpty()) + writeBookmark(bm); + delete bm; + bm = NULL; + } + delete bookmarks; + } + m_xml->writeEndElement(); // xbel + m_xml->writeEndDocument(); + retVal = true; + } + return retVal; +} + +void XbelWriter::writeBookmark(BookmarkFav *bm) +{ + m_xml->writeStartElement("bookmark"); + m_xml->writeAttribute("href", bm->url()); + m_xml->writeTextElement("title", bm->title()); + writeTags(bm->id()); + m_xml->writeEndElement(); // bookmark +} + +void XbelWriter::writeTags(int bmId) +{ + if(bmId > 0) { + + TagResults * tr = m_bmgr->findTagsByBookmark(bmId); + + if(tr) { + m_xml->writeStartElement("info"); + m_xml->writeStartElement("metadata"); + m_xml->writeAttribute("owner", "http://www.nokia.com"); + m_xml->writeStartElement("tags"); + try { + while(QString * tag = tr->nextTag()) { + m_xml->writeTextElement("tag", *tag); + delete tag; + tag = NULL; + } + } catch(...) { + qDebug() << "Exception Thrown while writing tags."; + } + + m_xml->writeEndElement(); // tags + m_xml->writeEndElement(); // metadata + m_xml->writeEndElement(); // info + delete tr; + } + } +} + diff -r b61e1b3b145f -r 8f58c9334c71 bookmarks/xbelwriter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bookmarks/xbelwriter.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,50 @@ +/* +* 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/". +* +*/ +#ifndef XBELWRITER_H +#define XBELWRITER_H + +class BookmarksManager; +class BookmarkFav; +class QXmlStreamWriter; +class QIODevice; + +/* + * This will export all bookmarks + * Each tag will be treated as a folder, so the bookmarks will be output by tag + * (there will be duplicates if a bookmark has more than one tag) + * Then any bookmarks that don't have tags will be written out into the top level + */ +class XbelWriter +{ +public: // ctor/dtor + XbelWriter(BookmarksManager *bmgr); + virtual ~XbelWriter(); + +public: // members + bool writeFile(QIODevice *device); + +private: + void writeBookmark(BookmarkFav * bm); + void writeTags(int bmId); + + QXmlStreamWriter *m_xml; + BookmarksManager *m_bmgr; +}; + +#endif diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro --- a/bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/Bookmarkstestui/Bookmarkstestui.pro Mon Oct 04 00:29:21 2010 +0300 @@ -96,3 +96,6 @@ symbian: { INCLUDEPATH += $$PWD $$MW_LAYER_SYSTEMINCLUDE $$APP_LAYER_SYSTEMINCLUDE } + + +symbian:MMP_RULES += SMPSAFE diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/bookmarksclient/bookmarksclient.pro --- a/bookmarksengine/bookmarksclient/bookmarksclient.pro Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/bookmarksclient/bookmarksclient.pro Mon Oct 04 00:29:21 2010 +0300 @@ -106,3 +106,6 @@ DEPLOYMENT += BookMarksClientlibs } + + +symbian:MMP_RULES += SMPSAFE diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/bookmarksserver/BookmarksServer.pro --- a/bookmarksengine/bookmarksserver/BookmarksServer.pro Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/bookmarksserver/BookmarksServer.pro Mon Oct 04 00:29:21 2010 +0300 @@ -90,3 +90,6 @@ symbian: { INCLUDEPATH += $$PWD $$MW_LAYER_SYSTEMINCLUDE $$APP_LAYER_SYSTEMINCLUDE } + + +symbian:MMP_RULES += SMPSAFE diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/browsercontentdll/browsercontentdll.pro --- a/bookmarksengine/browsercontentdll/browsercontentdll.pro Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/browsercontentdll/browsercontentdll.pro Mon Oct 04 00:29:21 2010 +0300 @@ -102,3 +102,6 @@ DEPLOYMENT += browsercontentdlllibs } + + +symbian:MMP_RULES += SMPSAFE diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/browsercontentdll/inc/browsercontentdll.h --- a/bookmarksengine/browsercontentdll/inc/browsercontentdll.h Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/browsercontentdll/inc/browsercontentdll.h Mon Oct 04 00:29:21 2010 +0300 @@ -27,6 +27,8 @@ #include +static const char KDOUBLEQUOTE[] = """; +static const char KBACKSLASH[] = "\"; class BrowserContentPrivate; class BOOKMARKSCONTENTDLL_EXPORT BookmarkLeaf { @@ -137,6 +139,7 @@ QString fetchSerializedBookmarks(); void fetchSerializedHistory(QVector &folderVector,QMap &mymap); void fetchAllBookmarkTitles(QVector &title); + QMap findSimilarHistoryItems(QString atitle); private: int createDatabase(); diff -r b61e1b3b145f -r 8f58c9334c71 bookmarksengine/browsercontentdll/src/browsercontentdll.cpp --- a/bookmarksengine/browsercontentdll/src/browsercontentdll.cpp Fri Sep 17 08:30:56 2010 +0300 +++ b/bookmarksengine/browsercontentdll/src/browsercontentdll.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -400,7 +400,13 @@ QString title = query.value(0).toString(); if(title.contains("\"", Qt::CaseInsensitive)) title.replace(QString("\""), QString(""")); + //--Encoding backslash used in title-- + if(title.contains("\\", Qt::CaseInsensitive)) + title.replace(QString("\\"), QString(KBACKSLASH)); QString url = query.value(1).toString(); + //--Encoding doublequote used in title-- + if(url.contains("\"", Qt::CaseInsensitive)) + url.replace(QString("\""), QString(KDOUBLEQUOTE)); int aIndex=query.value(2).toInt(&ok); uint timest = query.value(3).toUInt(); QDateTime dtime=QDateTime::fromTime_t ( timest ); @@ -650,8 +656,13 @@ if(title.contains("\"", Qt::CaseInsensitive)) title.replace(QString("\""), QString(""")); + if(title.contains("\\", Qt::CaseInsensitive)) + title.replace(QString("\\"), QString(KBACKSLASH)); QString url = query.value(1).toString(); + //--Encoding URL-- + QUrl url1(url); + url = QString::fromUtf8(url1.toEncoded()); uint timest = query.value(3).toUInt(); QDateTime dtime=QDateTime::fromTime_t ( timest ); QDate adate=dtime.date(); @@ -773,3 +784,28 @@ return false; } + +QMap BrowserContent::findSimilarHistoryItems(QString atitle) +{ + BOOKMARKSCLIENT_PRIVATEPTR(BrowserContent); + QSqlDatabase db = QSqlDatabase::database(priv->m_connectionName); + + QMap map; + + if (db.isOpen()){ + QSqlQuery query(db); + + QString queryStatement = "SELECT url, pageTitle FROM HistoryTable WHERE pageTitle LIKE '%"+atitle+"%' OR url LIKE '%" + atitle + "%'"; + query.prepare(queryStatement); + if(query.exec()) { + while (query.next()){ + QString HistoryUrl = query.value(0).toString(); + QString HistoryTitle = query.value(1).toString(); + map.insert( HistoryUrl, HistoryTitle ); + } + } else { + QSqlError error = query.lastError(); + } + } + return map; +} diff -r b61e1b3b145f -r 8f58c9334c71 browser.pro --- a/browser.pro Fri Sep 17 08:30:56 2010 +0300 +++ b/browser.pro Mon Oct 04 00:29:21 2010 +0300 @@ -21,4 +21,8 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += bookmarksengine +SUBDIRS += bookmarks bookmarksengine + +symbian: { + SUBDIRS += browserrfsplugin +} \ No newline at end of file diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/200169e9.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/200169e9.rss Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,82 @@ +/* +* 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: rss file for browser rfs plugin +* +* +*/ + + + +#include "ecom/registryinfo.rh" + + + +// Declares info for two implementations + +RESOURCE REGISTRY_INFO theInfo + + { + + // UID for the DLL + + dll_uid = 0x200169E9; + + // Declare array of interface info + + interfaces = + + { + + INTERFACE_INFO + + { + + // UID of interface that is implemented + + interface_uid = 0x102073BB; + + implementations = + + { + + IMPLEMENTATION_INFO + + { + + implementation_uid = 0x200169EA; + + version_no = 1; + + display_name = "BrowserRfsPlugin"; + + default_data = "ND"; // N = Normal RFS, D = Deep RFS, I = Init RFS (FirstBoot RFS) + + opaque_data = ""; + + } + + }; + + } + + }; + + } + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/browserrfs.txt Binary file browserrfsplugin/browserrfs.txt has changed diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/browserrfsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/browserrfsplugin.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,106 @@ +/* +* 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: +* +*/ + + + + +#include "BrowserRfsPlugin.h" + +_LIT(KScriptPath, "z:\\resource\\browserrfs.txt"); + +CBrowserRfsPlugin::CBrowserRfsPlugin() + { + } + +CBrowserRfsPlugin::CBrowserRfsPlugin(TAny* /*aInitParams*/): CRFSPlugin() + { + } + + +CBrowserRfsPlugin::~CBrowserRfsPlugin() + { + } + + +// --------------------------------------------------------- +// NewL +// --------------------------------------------------------- +// +CBrowserRfsPlugin* CBrowserRfsPlugin::NewL(TAny* aInitParams) + { + CBrowserRfsPlugin* self = new (ELeave) CBrowserRfsPlugin(aInitParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// + +void CBrowserRfsPlugin::ConstructL() + { +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::ConstructL()")); +// #endif + } + +// --------------------------------------------------------- +// RestoreFactorySettingsL +// --------------------------------------------------------- +// + +//#ifdef _DEBUG +void CBrowserRfsPlugin::RestoreFactorySettingsL( const TRfsReason aType ) +{ +// TODO: +// We can expand the functionalities here further +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::RestoreFactorySettings")); +// #endif +} + + + + +void CBrowserRfsPlugin::GetScriptL( const TRfsReason aType, TDes& aPath ) + { + aPath.Copy( KScriptPath); +/* if(aType == EDeepRfs) + { + aPath.Copy(KScriptPath); + } +*/ + } + + + +void CBrowserRfsPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/, + TDesC& /*aCommand*/ ) + { +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::RestoreFactorySettings")); +// #endif + } + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/browserrfsplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/browserrfsplugin.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,93 @@ +/* +* 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: +* +* +*/ + + + + + + +#ifndef BROWSERRFSPLUGIN_H + +#define BROWSERRFSPLUGIN_H + + + + + +#include + +// #include + +#include + + + + + + + +class CBrowserRfsPlugin: public CRFSPlugin + + { + +public: + + + + + + static CBrowserRfsPlugin* NewL(TAny* aInitParams); + + virtual ~CBrowserRfsPlugin(); + + void RestoreFactorySettingsL( const TRfsReason aType ); + + void GetScriptL( const TRfsReason aType, TDes& aPath ); + + void ExecuteCustomCommandL( const TRfsReason aType, TDesC& aCommand ); + +private: + + + + CBrowserRfsPlugin(); + + + CBrowserRfsPlugin(TAny* aInitParams); + + + void ConstructL(); + + + + }; + + + + + + + +#endif // BrowserRfsPLUGIN_H + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/browserrfsplugin.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/browserrfsplugin.pro Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,29 @@ +# +# Copyright (c) 2010 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: +# + + +TEMPLATE = subdirs + +symbian { + +BLD_INF_RULES.prj_exports += "./browserrfs.txt /epoc32/data/z/resource/browserrfs.txt" + +BLD_INF_RULES.prj_mmpfiles = "./group/browserrfsplugin.mmp" +} diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/group/bld.inf Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,51 @@ +/* +* 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: bld.inf for browser rfs plugin. +* +*/ + + + +PRJ_PLATFORMS + +DEFAULT + + + +PRJ_MMPFILES + +/* ../src/browserrfs.txt /epoc32/data/z/resource/browserrfs.txt */ + +../group/browserrfsplugin.mmp + + + + + +PRJ_EXPORTS + + + + + +PRJ_TESTMMPFILES + + + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/group/browserrfsplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/group/browserrfsplugin.mmp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,50 @@ +/* +* 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: mmp file for browser rfs plugin. +* +*/ + +#include + +TARGET browserrfsplugin.dll + +TARGETTYPE PLUGIN + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT + +UID 0x10009D8D 0x200169E9 + +SOURCEPATH ../src +SOURCE BrowserRfsPlugin.cpp +SOURCE Proxy.cpp + +START RESOURCE 200169E9.rss +TARGET browserrfsplugin.rsc +END + + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE +SYSTEMINCLUDE /epoc32/include/ecom + +LIBRARY euser.lib // Base library +LIBRARY ECom.lib // ECom library +LIBRARY efsrv.lib // File library +DEBUGLIBRARY flogger.lib diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/inc/browserrfsplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/inc/browserrfsplugin.h Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,93 @@ +/* +* 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: +* +* +*/ + + + + + + +#ifndef BROWSERRFSPLUGIN_H + +#define BROWSERRFSPLUGIN_H + + + + + +#include + +// #include + +#include + + + + + + + +class CBrowserRfsPlugin: public CRFSPlugin + + { + +public: + + + + + + static CBrowserRfsPlugin* NewL(TAny* aInitParams); + + virtual ~CBrowserRfsPlugin(); + + void RestoreFactorySettingsL( const TRfsReason aType ); + + void GetScriptL( const TRfsReason aType, TDes& aPath ); + + void ExecuteCustomCommandL( const TRfsReason aType, TDesC& aCommand ); + +private: + + + + CBrowserRfsPlugin(); + + + CBrowserRfsPlugin(TAny* aInitParams); + + + void ConstructL(); + + + + }; + + + + + + + +#endif // BrowserRfsPLUGIN_H + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/proxy.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,62 @@ +/* +* 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/". +* +* This class export ECom interface implementations. +* +*/ + + + + +#include + +#include + + + +#include "BrowserRfsPlugin.h" + + + +// Map the interface UIDs to implementation factory functions + +const TImplementationProxy ImplementationTable[] = + + { + + IMPLEMENTATION_PROXY_ENTRY(0x200169EA, CBrowserRfsPlugin::NewL ) + + }; + + + +// Exported proxy for instantiation method resolution + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + + { + + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + + + return ImplementationTable; + + } + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/src/200169e9.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/src/200169e9.rss Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,82 @@ +/* +* 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: rss file for browser rfs plugin +* +* +*/ + + + +#include "ecom/registryinfo.rh" + + + +// Declares info for two implementations + +RESOURCE REGISTRY_INFO theInfo + + { + + // UID for the DLL + + dll_uid = 0x200169E9; + + // Declare array of interface info + + interfaces = + + { + + INTERFACE_INFO + + { + + // UID of interface that is implemented + + interface_uid = 0x102073BB; + + implementations = + + { + + IMPLEMENTATION_INFO + + { + + implementation_uid = 0x200169EA; + + version_no = 1; + + display_name = "BrowserRfsPlugin"; + + default_data = "ND"; // N = Normal RFS, D = Deep RFS, I = Init RFS (FirstBoot RFS) + + opaque_data = ""; + + } + + }; + + } + + }; + + } + + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/src/browserrfs.txt Binary file browserrfsplugin/src/browserrfs.txt has changed diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/src/browserrfsplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/src/browserrfsplugin.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,106 @@ +/* +* 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: +* +*/ + + + + +#include "BrowserRfsPlugin.h" + +_LIT(KScriptPath, "z:\\resource\\browserrfs.txt"); + +CBrowserRfsPlugin::CBrowserRfsPlugin() + { + } + +CBrowserRfsPlugin::CBrowserRfsPlugin(TAny* /*aInitParams*/): CRFSPlugin() + { + } + + +CBrowserRfsPlugin::~CBrowserRfsPlugin() + { + } + + +// --------------------------------------------------------- +// NewL +// --------------------------------------------------------- +// +CBrowserRfsPlugin* CBrowserRfsPlugin::NewL(TAny* aInitParams) + { + CBrowserRfsPlugin* self = new (ELeave) CBrowserRfsPlugin(aInitParams); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// --------------------------------------------------------- +// ConstructL +// --------------------------------------------------------- +// + +void CBrowserRfsPlugin::ConstructL() + { +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::ConstructL()")); +// #endif + } + +// --------------------------------------------------------- +// RestoreFactorySettingsL +// --------------------------------------------------------- +// + +//#ifdef _DEBUG +void CBrowserRfsPlugin::RestoreFactorySettingsL( const TRfsReason aType ) +{ +// TODO: +// We can expand the functionalities here further +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::RestoreFactorySettings")); +// #endif +} + + + + +void CBrowserRfsPlugin::GetScriptL( const TRfsReason aType, TDes& aPath ) + { + aPath.Copy( KScriptPath); +/* if(aType == EDeepRfs) + { + aPath.Copy(KScriptPath); + } +*/ + } + + + +void CBrowserRfsPlugin::ExecuteCustomCommandL( const TRfsReason /*aType*/, + TDesC& /*aCommand*/ ) + { +// #ifdef _DEBUG +// RDebug::Print(_L("CBrowserRfsPlugin::RestoreFactorySettings")); +// #endif + } + + diff -r b61e1b3b145f -r 8f58c9334c71 browserrfsplugin/src/proxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browserrfsplugin/src/proxy.cpp Mon Oct 04 00:29:21 2010 +0300 @@ -0,0 +1,62 @@ +/* +* 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/". +* +* This class export ECom interface implementations. +* +*/ + + + + +#include + +#include + + + +#include "BrowserRfsPlugin.h" + + + +// Map the interface UIDs to implementation factory functions + +const TImplementationProxy ImplementationTable[] = + + { + + IMPLEMENTATION_PROXY_ENTRY(0x200169EA, CBrowserRfsPlugin::NewL ) + + }; + + + +// Exported proxy for instantiation method resolution + +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + + { + + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + + + + return ImplementationTable; + + } + + + diff -r b61e1b3b145f -r 8f58c9334c71 package_definition.xml --- a/package_definition.xml Fri Sep 17 08:30:56 2010 +0300 +++ b/package_definition.xml Mon Oct 04 00:29:21 2010 +0300 @@ -5,6 +5,9 @@ + + +