Clean-up widget dao
authorJihoon Chung <jihoon.chung@samsaung.com>
Tue, 30 Jul 2013 05:26:55 +0000 (14:26 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Sun, 4 Aug 2013 06:26:55 +0000 (06:26 +0000)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution]
Remove deprecated API
Add getPkgId API
[SCMRequest] N/A

Change-Id: I8bd69e6339111217d800bd8777ceeb91bf5031d5

modules/widget_dao/dao/widget_dao.cpp
modules/widget_dao/dao/widget_dao_read_only.cpp
modules/widget_dao/include/dpl/wrt-dao-ro/widget_dao_read_only.h
modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h

index 1061fe0cd55edbf7d12670e56227e84461a94ff9..d9d0944a14c1988ad0a7898e61b4e7ed041d170e 100644 (file)
@@ -869,25 +869,6 @@ void WidgetDAO::unregisterWidget(const TizenAppId & tzAppId)
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
 }
 
-void WidgetDAO::unregisterWidget(WrtDB::DbWidgetHandle handle)
-{
-    LogDebug("Unregistering widget from DB. Handle: " << handle);
-    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
-    {
-        using namespace DPL::DB::ORM;
-        using namespace DPL::DB::ORM::wrt;
-        ScopedTransaction transaction(&WrtDatabase::interface());
-
-        // Delete from table Widget Info
-        WRT_DB_DELETE(del, WidgetInfo, &WrtDatabase::interface())
-        del->Where(Equals<WidgetInfo::app_id>(handle));
-        del->Execute();
-
-        transaction.Commit();
-    }
-    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to unregister widget")
-}
-
 void WidgetDAO::unregisterWidgetInternal(
     const TizenAppId & tzAppId)
 {
index 5b3ffa1ffc492e259e3c931e40f947d57e94de5e..343c29afe69bb34aa292d7c6e4fb787d2e0a5ba7 100644 (file)
@@ -176,6 +176,27 @@ TizenPkgId getTizenPkgIdByHandle(const DbWidgetHandle handle)
     }
     SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in getHandle")
 }
+
+TizenPkgId getTizenPkgIdByAppId(const TizenAppId tzAppid)
+{
+    LogDebug("Getting TizenPkgId by TizenAppId: " << tzAppid);
+
+    SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+    {
+        WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface())
+        select->Where(Equals<WidgetInfo::tizen_appid>(tzAppid));
+        WidgetInfo::Select::RowList rowList = select->GetRowList();
+
+        if (rowList.empty()) {
+            ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist,
+                     "Failed to get widget by tizen appId");
+        }
+        TizenPkgId tzPkgid = rowList.front().Get_tizen_pkgid();
+
+        return tzPkgid;
+    }
+    SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed get pkgId")
+}
 } // namespace
 
 IWidgetSecurity::~IWidgetSecurity()
@@ -264,6 +285,16 @@ TizenPkgId WidgetDAOReadOnly::getTzPkgId() const
     return getTizenPkgIdByHandle(m_widgetHandle);
 }
 
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const DbWidgetHandle handle)
+{
+    return getTizenPkgIdByHandle(handle);
+}
+
+TizenPkgId WidgetDAOReadOnly::getTzPkgId(const TizenAppId tzAppid)
+{
+    return getTizenPkgIdByAppId(tzAppid);
+}
+
 PropertyDAOReadOnly::WidgetPropertyKeyList
 WidgetDAOReadOnly::getPropertyKeyList() const
 {
index 7cf793a27c3c50f8a3b185d0f683e939f992111b..56178d4118c218922fc19e2ac630c55de8e200e4 100644 (file)
@@ -334,6 +334,8 @@ class WidgetDAOReadOnly
      */
 
     TizenPkgId getTzPkgId() const;
+    static TizenPkgId getTzPkgId(const DbWidgetHandle handle);
+    static TizenPkgId getTzPkgId(const TizenAppId tzAppid);
 
     /**
      * This method returns the root directory of widget resource.
@@ -602,15 +604,6 @@ class WidgetDAOReadOnly
      */
     static DbWidgetDAOReadOnlyList getWidgetList();
 
-    /**
-     * This method removes a widget's information from EmDB.
-     *
-     * @see RegisterWidget()
-     * @param[in] widgetHandle    widget's app id
-     * @return true if succeed, false if fail.
-     */
-    static void unregisterWidget(DbWidgetHandle widgetHandle);
-
     /**
      * This method gets author's infomation of a widget which is parsed from
      *  configiration document.
index 42fb6357f541a74ee84f56b03c0e436616ec0d86..6781adc3ce32e28ddd7bad14bb2ab017084dbeec 100644 (file)
@@ -126,9 +126,6 @@ class WidgetDAO : public WidgetDAOReadOnly
      */
     static void unregisterWidget(const TizenAppId & tzAppId);
 
-    static void unregisterWidget(WrtDB::DbWidgetHandle handle) __attribute__((
-                                                                                 deprecated));
-
     /* This method removes widget property
      */
     void removeProperty(const PropertyDAOReadOnly::WidgetPropertyKey &key);