add patch
[framework/osp/web.git] / src / FWeb_WebBookmarkImpl.cpp
index ed88111..f456449 100755 (executable)
@@ -29,6 +29,7 @@
 #include <FWebBookmarkItem.h>
 #include <FWebWebBookmark.h>
 #include <FBase_StringConverter.h>
+#include <FUiCtrlFrame.h>
 #include "FWeb_BookmarkItemImpl.h"
 #include "FWeb_WebBookmarkImpl.h"
 #include "FWebCtrl_Utility.h"
@@ -36,6 +37,7 @@
 
 using namespace Tizen::Base;
 using namespace Tizen::Graphics;
+using namespace Tizen::Ui::Controls;
 using namespace Tizen::Web::Controls;
 
 
@@ -70,6 +72,7 @@ _WebBookmarkImpl::_WebBookmarkImpl(void)
 
 _WebBookmarkImpl::~_WebBookmarkImpl(void)
 {
+       __bookmarkList.RemoveAll(true);
 }
 
 
@@ -99,8 +102,6 @@ CATCH:
 result
 _WebBookmarkImpl::AddFolder(const String& title, RecordId parentId, RecordId& folderId)
 {
-       result r = E_SUCCESS;
-
        std::unique_ptr<char[]> pTitle(_StringConverter::CopyToCharArrayN(title));
        SysTryReturn(NID_WEB, pTitle.get(), GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
 
@@ -112,7 +113,7 @@ _WebBookmarkImpl::AddFolder(const String& title, RecordId parentId, RecordId& fo
        }
 
        int ret = favorites_bookmark_add(pTitle.get(), null, realParentId, 1, &folderId);
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", ConvertErrorCode(ret));
+       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", GetErrorMessage(ConvertErrorCode(ret)));
 
        return E_SUCCESS;
 }
@@ -134,7 +135,7 @@ _WebBookmarkImpl::AddBookmark(const String& title, const String& url, RecordId p
        }
        
        int ret = favorites_bookmark_add(pTitle.get(), pUrl.get(), realParentId, 0, &bookmarkId);
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", ConvertErrorCode(ret));
+       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", GetErrorMessage(ConvertErrorCode(ret)));
        
        return E_SUCCESS;
 }
@@ -143,36 +144,48 @@ _WebBookmarkImpl::AddBookmark(const String& title, const String& url, RecordId p
 result 
 _WebBookmarkImpl::SetFavicon(RecordId bookmarkId, const Bitmap& favicon)
 {
-       SysTryReturnResult(NID_WEB, favicon.GetWidth() == 16 && favicon.GetHeight() == 16, E_INVALID_DATA, "The size of a favicon must be 16 X 16");
        SysTryReturnResult(NID_WEB, favicon.GetPixelColorFormat() == BITMAP_PIXEL_FORMAT_ARGB8888, E_INVALID_DATA, "The pixel format of a favicon must be ARGB8888");
 
        result r = E_SUCCESS;
+       Frame* pFrame = null;
+
+       BufferInfo bufferInfo;
+       int ret = 0;
 
-       Evas* pEvas = _Utility::GetEvasFromUiApp();
-       SysTryReturn(NID_WEB, pEvas, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
+       Evas_Object* pIcon = null;
 
-       Evas_Object* pIcon = evas_object_image_filled_add(pEvas);
+       Bitmap& temp = const_cast< Bitmap& >(favicon);
+
+       Evas* pEvas = _Utility::GetEvasFromUiApp(pFrame);
+       SysTryCatch(NID_WEB, pEvas, r = GetLastResult(), r, "[%s] Propagating.", GetErrorMessage(r));
+
+        pIcon = evas_object_image_filled_add(pEvas);
        evas_object_image_colorspace_set(pIcon, EVAS_COLORSPACE_ARGB8888);
        evas_object_image_filled_set(pIcon, EINA_TRUE);
        evas_object_image_alpha_set(pIcon,EINA_TRUE);
 
-       Bitmap& temp = const_cast< Bitmap& >(favicon);
-
-       BufferInfo bufferInfo;
        r = temp.Lock(bufferInfo);
-       SysTryReturn(NID_WEB, r == E_SUCCESS, r, r, "[%s] Propagating.", r);
+       SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", r);
 
        evas_object_image_size_set(pIcon, bufferInfo.width, bufferInfo.height);
        evas_object_image_fill_set(pIcon, 0, 0, bufferInfo.width, bufferInfo.height);
        evas_object_image_data_set(pIcon, bufferInfo.pPixels);
 
        r = temp.Unlock();
-       SysTryReturn(NID_WEB, r == E_SUCCESS, r, r, "[%s] Propagating.", r);
+       SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", r);
+
+       ret = favorites_bookmark_set_favicon(bookmarkId, pIcon);
+       SysTryCatch(NID_WEB, ret == FAVORITES_ERROR_NONE, r = ConvertErrorCode(ret), r, "[%s] Propagating.", GetErrorMessage(r));
+
 
-       int ret = favorites_bookmark_set_favicon(bookmarkId, pIcon);
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", ConvertErrorCode(ret));
+       delete pFrame;
 
        return E_SUCCESS;
+
+CATCH:
+       delete pFrame;
+
+       return r;
 }
 
 
@@ -198,7 +211,7 @@ _WebBookmarkImpl::GetRootFolderId(void) const
 {
        int folderId = 0;
        int ret = favorites_bookmark_get_root_folder_id(&folderId);
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, -1, ConvertErrorCode(ret), "[%s] Propagating.", ConvertErrorCode(ret));
+       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, -1, ConvertErrorCode(ret), "[%s] Propagating.", GetErrorMessage(ConvertErrorCode(ret)));
 
        return folderId;
 }
@@ -236,7 +249,7 @@ result
 _WebBookmarkImpl::RemoveAll(void)
 {
        int ret = favorites_bookmark_delete_all_bookmarks();
-       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", ConvertErrorCode(ret));
+       SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, ConvertErrorCode(ret), ConvertErrorCode(ret), "[%s] Propagating.", GetErrorMessage(ConvertErrorCode(ret)));
 
        return E_SUCCESS;
 }