wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Bookmark / BookmarkManager.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 5b37002..3b22439
 #include "JSBookmarkItem.h"
 #include <queue>
 #include <Ecore.h>
-#include <dpl/log/log.h>
 #include <JSTizenException.h>
 #include <JSTizenExceptionFactory.h>
 #include <PlatformException.h>
 #include <favorites.h>
+#include <Logger.h>
 
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace DeviceAPI::Common;
@@ -32,7 +32,7 @@ using namespace DeviceAPI::Common;
 namespace DeviceAPI {
 namespace Bookmark{
 static bool favorites_bookmark_foreach_cb(favorites_bookmark_entry_s *entry, void *user_data) {
-       LogDebug("Entered");
+       LoggerD("Entered");
        if (user_data) {
                BookmarkSearchData *searchData = static_cast<BookmarkSearchData*>(user_data);
                int parentId = 0;
@@ -41,17 +41,17 @@ static bool favorites_bookmark_foreach_cb(favorites_bookmark_entry_s *entry, voi
                else
                        parentId = BookmarkManager::getInstance()->getRootFolderId();
 
-               LogDebug("parentId : " << parentId);
-               LogDebug("m_reculsive : " << searchData->m_reculsive);
-               LogDebug("entry title : " << entry->title);
-               LogDebug("entry id : " << entry->id);
+               LoggerD("parentId : " << parentId);
+               LoggerD("m_reculsive : " << searchData->m_reculsive);
+               LoggerD("entry title : " << entry->title);
+               LoggerD("entry id : " << entry->id);
                if (!(searchData->isAlive) && (entry->id == parentId))
                        searchData->isAlive = true;
 
-               LogDebug("isAlive : " << searchData->isAlive);
+               LoggerD("isAlive : " << searchData->isAlive);
 
                if ((searchData->m_reculsive) || (entry->folder_id == parentId)) {
-                       LogDebug("found subitem : " << entry->title);
+                       LoggerD("found subitem : " << entry->title);
                        BookmarkDataPtr bookmark;
                        if (entry->is_folder)
                                bookmark = BookmarkDataPtr(new BookmarkData(BOOKMARKFOLDER_TYPE, entry->title, "", entry->id, entry->folder_id));
@@ -63,40 +63,40 @@ static bool favorites_bookmark_foreach_cb(favorites_bookmark_entry_s *entry, voi
                if (!(searchData->isAlive) || (searchData->m_reculsive) || (parentId == BookmarkManager::getInstance()->getRootFolderId()) || ((searchData->m_bookmark)->m_type == BOOKMARKFOLDER_TYPE))
                        return true;    
        } else
-               LogDebug("user_data is null");
+               LoggerD("user_data is null");
 
-       LogDebug("stop ");
+       LoggerD("stop ");
        return false;
 }
 
 static bool favorites_bookmark_parent_search_cb(favorites_bookmark_entry_s *entry, void *user_data) {
        if (user_data){
                BookmarkParentSearchData *parentSearchData = static_cast<BookmarkParentSearchData *>(user_data);
-               LogDebug("entry->id : " << entry->id);
+               LoggerD("entry->id : " << entry->id);
                
                if (entry->id == parentSearchData->m_id) {
                        parentSearchData->isAlive = true;
                } else if (entry->id == parentSearchData->m_parentId){
-                       LogDebug("Found parent");
+                       LoggerD("Found parent");
                        parentSearchData->isParentAlive = true;
                        parentSearchData->m_parent = BookmarkDataPtr(new BookmarkData(BOOKMARKFOLDER_TYPE, entry->title, "", entry->id, entry->folder_id));
                } else
                        return true;
 
                if (parentSearchData->isAlive && parentSearchData->isParentAlive) {
-                       LogDebug("Found parent.Stop.");
+                       LoggerD("Found parent.Stop.");
                        return false;
                } else
                        return true;
        }
 
-       LogDebug("user_data is null");
+       LoggerD("user_data is null");
        return false;
 }
 
 
 std::vector<BookmarkDataPtr> BookmarkManager::get(BookmarkSearchDataPtr &searchData){
-       LogDebug("Entered");
+       LoggerD("Entered");
        int count;
        std::vector<BookmarkDataPtr> bookmarkArray;
        if (favorites_bookmark_get_count(&count) == FAVORITES_ERROR_NONE) {
@@ -124,7 +124,7 @@ std::vector<BookmarkDataPtr> BookmarkManager::get(BookmarkSearchDataPtr &searchD
 }
 
 std::vector<BookmarkDataPtr> BookmarkManager::_getCompleteCB(BookmarkSearchDataPtr &searchData){
-    LogDebug("Enter");
+    LoggerD("Enter");
        std::vector<BookmarkDataPtr> bookmarkArray;
        //check if searchData->m_bookmark is in db or not
        if (searchData->isAlive) {
@@ -138,25 +138,25 @@ std::vector<BookmarkDataPtr> BookmarkManager::_getCompleteCB(BookmarkSearchDataP
                                
                                BookmarkData *parent = searchData->m_bookmark;
                                for (it=(searchData->m_results).begin(); it!=(searchData->m_results).end(); ++it)
-                                       LogDebug("it->first:"<<it->first << " it->second:" <<(it->second)->m_id);
+                                       LoggerD("it->first:"<<it->first << " it->second:" <<(it->second)->m_id);
 
                                int lastItemId = (((searchData->m_results).rbegin())->second)->m_id;
-                               LogDebug("end's first:"<<((searchData->m_results).rbegin())->first << "end's second:"<<lastItemId);
+                               LoggerD("end's first:"<<((searchData->m_results).rbegin())->first << "end's second:"<<lastItemId);
                                while (1) {
                                        it = (searchData->m_results).find(parent->m_id);
-                                       LogDebug("it->first:"<<it->first << " parent->m_id:" <<parent->m_id);
+                                       LoggerD("it->first:"<<it->first << " parent->m_id:" <<parent->m_id);
                                        while (it->first == parent->m_id) {
-                                               LogDebug("it->second:"<<(it->second)->m_id);
+                                               LoggerD("it->second:"<<(it->second)->m_id);
                                                bookmarkArray.push_back(it->second);
-                                               LogDebug("m_type:"<<(it->second)->m_type);
+                                               LoggerD("m_type:"<<(it->second)->m_type);
                                                //if it is folder, it will be pushed in folders vector
                                                if ((it->second)->m_type == BOOKMARKFOLDER_TYPE)
                                                        folders.push((it->second).get());
 
                                                if ((it->second)->m_id != lastItemId) {
-                                                       LogDebug("not last item");
+                                                       LoggerD("not last item");
                                                        it++;
-                                                       LogDebug("it->first:"<<it->first << " it->second:" <<(it->second)->m_id);
+                                                       LoggerD("it->first:"<<it->first << " it->second:" <<(it->second)->m_id);
                                                } else
                                                        break;
                                                
@@ -164,7 +164,7 @@ std::vector<BookmarkDataPtr> BookmarkManager::_getCompleteCB(BookmarkSearchDataP
 
                                        if (folders.size()) {
                                                parent = folders.front();
-                                               LogDebug("parent->m_id:" <<parent->m_id);
+                                               LoggerD("parent->m_id:" <<parent->m_id);
                                                folders.pop();
                                        } else
                                                break;
@@ -179,12 +179,12 @@ std::vector<BookmarkDataPtr> BookmarkManager::_getCompleteCB(BookmarkSearchDataP
        } else { // Not found Error because it is not in db
                throw NotFoundException("Can't find the parent folder");
        }
-       LogDebug("Success!");
+       LoggerD("Success!");
        return bookmarkArray;
 }
 
 int BookmarkManager::add(bookmarkType type, const int parent_id, const std::string& title, const std::string& url) {
-       LogDebug("Entered");
+       LoggerD("Entered");
        int id = UNDEFINED_ID;
        int result = favorites_bookmark_add(title.c_str(), url.c_str(), parent_id, static_cast<int>(type), &id);
        if (result == FAVORITES_ERROR_NONE)
@@ -202,7 +202,7 @@ int BookmarkManager::add(bookmarkType type, const int parent_id, const std::stri
 }
 
 void BookmarkManager::remove(BookmarkSearchDataPtr &searchData) {
-       LogDebug("Entered");
+       LoggerD("Entered");
        int result = FAVORITES_ERROR_NONE;
        if (searchData->m_bookmark == NULL)
                result = favorites_bookmark_delete_all_bookmarks();
@@ -223,7 +223,7 @@ void BookmarkManager::remove(BookmarkSearchDataPtr &searchData) {
                                }
                        }
                } catch( const NotFoundException& err) {
-                       LogDebug("Not Found");
+                       LoggerD("Not Found");
                        return;
                }
        }