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 1061fe0..d9d0944 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 5b3ffa1..343c29a 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 7cf793a..56178d4 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.
@@ -603,15 +605,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 42fb635..6781adc 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);