SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
- DbWidgetHandle widgetHandle = registerWidgetInternal(widgetPkgname, widgetRegInfo, wacSecurity);
- registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
- //TODO: remove construction from handle and move that call to registerWidgetInternal
- // in new version external fiels should be register together with other informations
+ registerWidgetInternal(widgetPkgname, widgetRegInfo, wacSecurity);
transaction.Commit();
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
}
void WidgetDAO::registerWidget(
- WrtDB::DbWidgetHandle handle,
- const WidgetRegisterInfo & widgetRegInfo,
- const IWacSecurity &wacSecurity)
+ WrtDB::DbWidgetHandle handle,
+ const WidgetRegisterInfo &widgetRegInfo,
+ const IWacSecurity &wacSecurity)
{
LogDebug("Registering widget");
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
{
DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
- registerWidgetInternal(L"", widgetRegInfo, wacSecurity, handle);
+ registerWidgetInternal(generateTizenId(), widgetRegInfo, wacSecurity, handle);
transaction.Commit();
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to register widget")
return widgetHandle;
}
-DbWidgetHandle WidgetDAO::registerWidgetInternal(
+WidgetPkgName WidgetDAO::registerWidgetGenerateTizenId(
+ const WidgetRegisterInfo &pWidgetRegisterInfo,
+ const IWacSecurity &wacSecurity)
+{
+ WidgetPkgName widgetPkgName = generateTizenId();
+ registerWidget(widgetPkgName, pWidgetRegisterInfo, wacSecurity);
+ return widgetPkgName;
+}
+
+void WidgetDAO::registerWidgetInternal(
const WidgetPkgName & widgetName,
const WidgetRegisterInfo &widgetRegInfo,
const IWacSecurity &wacSecurity,
registerEncryptedResouceInfo(widgetHandle, widgetRegInfo);
- return widgetHandle;
+ registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
}
void WidgetDAO::registerOrUpdateWidget(
DPL::DB::ORM::wrt::ScopedTransaction transaction(&WrtDatabase::interface());
unregisterWidgetInternal(widgetName);
- DbWidgetHandle widgetHandle = registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity);
- registerExternalLocations(widgetHandle, widgetRegInfo.externalLocations);
- //TODO: remove construction from handle and move that call to registerWidgetInternal
- // in new version external fiels should be register together with other informations
+ registerWidgetInternal(widgetName, widgetRegInfo, wacSecurity);
transaction.Commit();
}
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to reregister widget")
}
row.Set_back_supported(widgetConfigurationInfo.backSupported);
row.Set_access_network(widgetConfigurationInfo.accessNetwork);
- row.Set_pkgname(regInfo.pkgname);
row.Set_pkg_type(regInfo.packagingType.pkgType);
Try
}
}
-void WidgetDAO::registerExternalLocations(const ExternalLocationList & externals)
-{
- registerExternalLocations(m_widgetHandle, externals);
-}
-
void WidgetDAO::registerExternalLocations(DbWidgetHandle widgetHandle,
const ExternalLocationList & externals)
{
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed in GetWidgetInfoRow")
}
+const int MAX_TIZENID_LENGTH = 10;
+
} // namespace
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to check if widget exist")
}
-bool WidgetDAOReadOnly::isWidgetInstalled(DPL::String pkgName)
+bool WidgetDAOReadOnly::isWidgetInstalled(const WidgetPkgName & pkgName)
{
LogDebug("Checking if widget exist. package name " << pkgName);
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get background page")
}
+WidgetPkgName WidgetDAOReadOnly::generateTizenId() {
+ std::string allowed("0123456789"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz");
+ WidgetPkgName tizenId;
+ tizenId.resize(MAX_TIZENID_LENGTH);
+ do {
+ for (int i = 0; i < MAX_TIZENID_LENGTH; ++i) {
+ tizenId[i] = allowed[rand() % allowed.length()];
+ }
+ } while (isWidgetInstalled(tizenId));
+ return tizenId;
+}
+
#undef SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
#undef SQL_CONNECTION_EXCEPTION_HANDLER_END
#undef CHECK_WIDGET_EXISTENCE
bool getBackSupported() const;
static bool isWidgetInstalled(DbWidgetHandle handle);
- static bool isWidgetInstalled(DPL::String pkgName);
+ static bool isWidgetInstalled(const WidgetPkgName & pkgName);
/* This method get path of the splash image.
*
* @return Name of file containing background page
*/
DPL::OptionalString getBackgroundPage() const;
+
+ /**
+ * @brief generateTizenId generates new tizen id
+ *
+ * If widget do not supplies it's own tizen id, this method can be used,
+ * although it should be removed in future.
+ *
+ * @return new tizen id
+ */
+ static WidgetPkgName generateTizenId();
};
} // namespace WrtDB
const WidgetRegisterInfo &widgetRegInfo,
const IWacSecurity &wacSecurity);
- static void registerWidget(
- WrtDB::DbWidgetHandle handle,
- const WidgetRegisterInfo &widgetRegInfo,
- const IWacSecurity &wacSecurity) __attribute__((deprecated));
-
static DbWidgetHandle registerWidget(
const WidgetRegisterInfo &pWidgetRegisterInfo,
const IWacSecurity &wacSecurity) __attribute__((deprecated));
/**
+ * @brief registerWidgetGenerateTizenId Registers widget with auto-generated tizen id
+ *
+ * This function is disadviced and should be used only in tests.
+ * Function is not thread-safe.
+ *
+ * @param pWidgetRegisterInfo registeration information
+ * @param wacSecurity Widget's security certificates.
+ * @return pkgname generated
+ */
+ static WidgetPkgName registerWidgetGenerateTizenId(
+ const WidgetRegisterInfo &pWidgetRegisterInfo,
+ const IWacSecurity &wacSecurity);
+
+ /**
* This method re-registers the widget information to the DB when it is installed.
*
* It performs unregistration and new registration of widget in db in one transaction.
const WidgetRegisterInfo &widgetRegInfo,
const IWacSecurity &wacSecurity);
+ static void registerWidget(
+ WrtDB::DbWidgetHandle handle,
+ const WidgetRegisterInfo &widgetRegInfo,
+ const IWacSecurity &wacSecurity) __attribute__((deprecated));
+
/**
* This method removes a widget's information from EmDB.
*
*/
void updateFeatureRejectStatus(const DbWidgetFeature &widgetFeature);
- void registerExternalLocations(const ExternalLocationList & externals) __attribute__((deprecated));
-
private:
//Methods used during widget registering
static DbWidgetHandle registerWidgetInfo(
static void registerExternalLocations(DbWidgetHandle widgetHandle,
const ExternalLocationList & externals);
- static DbWidgetHandle registerWidgetInternal(
+ static void registerWidgetInternal(
const WidgetPkgName & widgetName,
const WidgetRegisterInfo &widgetRegInfo,
const IWacSecurity &wacSecurity,