From: Jihoon Chung Date: Sun, 4 Aug 2013 07:56:49 +0000 (+0900) Subject: Add widgetDAO API to update tizen application id field X-Git-Tag: submit/tizen_2.2/20130927.091100^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb30bf4ffd25fab51ae0e18d1ae9ec30f16e7fed;p=platform%2Fframework%2Fweb%2Fwrt-commons.git Add widgetDAO API to update tizen application id field [Issue#] N/A [Problem] N/A [Cause] N/A [Solution] Add updateTizenAppId WidgetDAO API Deprecated registerOrUpdateWidget, backupAndUpdateWidget and restoreUpdateWidget. [SCMRequest] N/A Change-Id: Iac505db9a7934741071fb8ca1657fac4738dd96f --- diff --git a/modules/widget_dao/dao/widget_dao.cpp b/modules/widget_dao/dao/widget_dao.cpp index d9d0944..e33290f 100644 --- a/modules/widget_dao/dao/widget_dao.cpp +++ b/modules/widget_dao/dao/widget_dao.cpp @@ -239,6 +239,39 @@ TizenAppId WidgetDAO::registerWidgetGeneratePkgId( return tzAppId; } +void WidgetDAO::updateTizenAppId( + const TizenAppId & fromAppId, + const TizenAppId & toAppId) +{ + SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN + { + using namespace DPL::DB::ORM; + using namespace DPL::DB::ORM::wrt; + + ScopedTransaction transaction(&WrtDatabase::interface()); + if (!isWidgetInstalled(fromAppId)) { + ThrowMsg(WidgetDAOReadOnly::Exception::WidgetNotExist, + "Cannot find widget. tzAppId: " << fromAppId); + } + + WRT_DB_SELECT(select, WidgetInfo, &WrtDatabase::interface()) + select->Where(Equals(fromAppId)); + + WidgetInfo::Row row = select->GetSingleRow(); + + //WidgetInfo::Row row; + row.Set_tizen_appid(toAppId); + + WRT_DB_UPDATE(update, WidgetInfo, &WrtDatabase::interface()) + update->Where(Equals(fromAppId)); + update->Values(row); + update->Execute(); + + transaction.Commit(); + } + SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to update appid") +} + void WidgetDAO::registerWidgetInternal( const TizenAppId & tzAppId, const WidgetRegisterInfo &widgetRegInfo, diff --git a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h index 6781adc..a1fb784 100644 --- a/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h +++ b/modules/widget_dao/include/dpl/wrt-dao-rw/widget_dao.h @@ -87,6 +87,9 @@ class WidgetDAO : public WidgetDAOReadOnly const WidgetRegisterInfo &pWidgetRegisterInfo, const IWidgetSecurity &widgetSecurity); + static void updateTizenAppId(const TizenAppId & fromAppId, + const TizenAppId & toAppId); + /** * This method re-registers the widget information to the DB when it is * installed. @@ -103,7 +106,7 @@ class WidgetDAO : public WidgetDAOReadOnly static void registerOrUpdateWidget( const TizenAppId & tzAppId, const WidgetRegisterInfo &widgetRegInfo, - const IWidgetSecurity &widgetSecurity); + const IWidgetSecurity &widgetSecurity) __attribute__((deprecated)); /* This method backup widget information and update new widget information * for restore widget information @@ -112,11 +115,11 @@ class WidgetDAO : public WidgetDAOReadOnly const TizenAppId & oldAppId, const TizenAppId & newAppId, const WidgetRegisterInfo &widgetRegInfo, - const IWidgetSecurity &widgetSecurity); + const IWidgetSecurity &widgetSecurity) __attribute__((deprecated)); static void restoreUpdateWidget( const TizenAppId & oldAppId, - const TizenAppId & newAppId); + const TizenAppId & newAppId) __attribute__((deprecated)); /** * This method removes a widget's information from EmDB. @@ -236,7 +239,7 @@ class WidgetDAO : public WidgetDAOReadOnly static void updateWidgetAppIdInternal( const TizenAppId & fromAppId, - const TizenAppId & toAppId); + const TizenAppId & toAppId) __attribute__((deprecated)); static void insertAppControlInfo(DbWidgetHandle handle, DPL::String src,