set(DESTINATION_HEADERS_NON_JS ${DESTINATION_HEADER_PREFIX}/Commons)
set(DESTINATION_HEADERS_JS ${DESTINATION_HEADER_PREFIX}/CommonsJavaScript)
set(DESTINATION_HEADERS_JS_OVERLAY ${DESTINATION_HEADER_PREFIX}/js-overlay)
+set(DESTINATION_HEADERS_WRT_POPUP_RUNNER ${DESTINATION_HEADER_PREFIX}/popup-runner)
################################################################################
# Target platform
configure_and_install_pkg(wrt-plugins-plugin-manager.pc)
configure_and_install_pkg(wrt-plugin-loading.pc)
configure_and_install_pkg(wrt-plugin-js-overlay.pc)
+configure_and_install_pkg(wrt-popup-runner.pc)
+configure_and_install_pkg(wrt-plugins-api-support.pc)
################################################################################
# Cache
+wrt-plugins-common (0.3.60) unstable; urgency=low
+
+ * New Plugin API #2 : Plugins-Installer
+ * Add license installing
+
+ * Git : framework/web/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.60
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Fri, 12 Oct 2012 08:11:28 +0900
+
+wrt-plugins-common (0.3.59) unstable; urgency=low
+
+ * Manifest file fix
+
+ * Git : slp/pkgs/w/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.59
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Tue, 09 Oct 2012 21:00:45 +0900
+
+wrt-plugins-common (0.3.58) unstable; urgency=low
+
+ * [Plugins] Add wrt-popup
+ * [Plugins] New plugin API #1 : API
+ * [Plugins] Change path for "plugin-installation-required"
+
+ * Git : slp/pkgs/w/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.58
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Fri, 05 Oct 2012 07:45:07 +0900
+
+wrt-plugins-common (0.3.57) unstable; urgency=low
+
+ * Add smack manifest
+
+ * Git : framework/web/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.57
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Thu, 20 Sep 2012 20:12:59 +0900
+
+wrt-plugins-common (0.3.56) unstable; urgency=low
+
+ * Read allowed plugins when session start
+ * Converer toLongLong conversion
+
+ * Git : framework/web/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.56
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Wed, 19 Sep 2012 12:14:22 +0900
+
+wrt-plugins-common (0.3.55) unstable; urgency=low
+
+ * [Plugins] Allow to initialize localStorage for many widgets
+ * [Plugins] Upgrade Security dependencies
+
+ * Git : slp/pkgs/w/wrt-plugins-common
+ * Tag : wrt-plugins-common_0.3.55
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Tue, 11 Sep 2012 15:35:20 +0900
+
wrt-plugins-common (0.3.54) unstable; urgency=low
* [Plugins] Code clean up
-#sbs-git:slp/pkgs/w/wrt-plugins-common wrt-plugins-common 0.3.54
+#sbs-git:slp/pkgs/w/wrt-plugins-common wrt-plugins-common 0.3.60
Name: wrt-plugins-common
Summary: wrt-plugins common library
-Version: 0.3.54
+Version: 0.3.60
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
BuildRequires: cmake
BuildRequires: pkgconfig(dpl-efl)
BuildRequires: pkgconfig(wrt-plugins-types)
-BuildRequires: pkgconfig(ace-client)
+BuildRequires: pkgconfig(security-client)
BuildRequires: pkgconfig(dpl-event-efl)
BuildRequires: pkgconfig(ewebkit2)
BuildRequires: pkgconfig(dpl-wrt-dao-ro)
+BuildRequires: pkgconfig(dpl-wrt-dao-rw)
BuildRequires: pkgconfig(dpl-db-efl)
BuildRequires: pkgconfig(libpcrecpp)
BuildRequires: pkgconfig(mm-sound)
BuildRequires: pkgconfig(mm-player)
BuildRequires: pkgconfig(icu-i18n)
+BuildRequires: pkgconfig(libxml-2.0)
+BuildRequires: pkgconfig(cert-svc-vcore)
Requires: ldconfig
%description
make %{?jobs:-j%jobs}
%install
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
%make_install
%clean
%post
mkdir -p /usr/lib/wrt-plugins
mkdir -p /usr/etc/wrt/injected-javascript
-touch /opt/apps/widget/plugin-installation-required
+touch /opt/share/widget/plugin-installation-required
%files
+%manifest wrt-plugins-common.manifest
/usr/etc/wrt-plugins/config.dtd
%{_libdir}/*.so
%{_libdir}/*.so.*
%{_libdir}/wrt-plugins/w3c-widget-interface/libwrt-plugins-w3c-widget-interface.so
%attr(644,root,root) %{_libdir}/wrt-plugins/standard-features-list
%attr(644,root,root) /usr/share/wrt-plugins-common/widget_interface_db.sql
+%attr(755,root,root) %{_bindir}/wrt-popup-runtime
+%attr(755,root,root) %{_bindir}/wrt-plugins-installer
+%{_datadir}/license/%{name}
%files devel
%{_includedir}/*
--- /dev/null
+prefix=/usr
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include
+
+Name: wrt-plugins-api-support
+Description: wrt-plugins-api-support
+Version: @PROJECT_VERSION@
+Requires:
+Libs: -lwrt-plugins-api-support -L${libdir}
+Cflags: -I${includedir}/wrt-plugins-api-support
--- /dev/null
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+exec_prefix=${prefix}
+libdir=${prefix}/lib
+includedir=${prefix}/include/${project_name}
+
+Name: wrt-popup-runner
+Description: Library with function to run wrt runtime popup
+Version: @CMAKE_PROJECT_VERSION@
+Requires: dpl-efl dpl-dbus-efl elementary security-client
+Libs: -L${libdir} -lwrt-popup-runner
+Cflags: -I${includedir}
${CMAKE_CURRENT_SOURCE_DIR}/CommonsJavaScript
${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading
${CMAKE_CURRENT_SOURCE_DIR}/js-overlay
+ ${CMAKE_CURRENT_SOURCE_DIR}/wrt-popup/popup-runner
)
#target names
set(TARGET_COMMONS "wrt-plugins-commons")
set(TARGET_COMMONS_JAVASCRIPT "wrt-plugins-commons-javascript")
set(TARGET_JS_OVERLAY "wrt-plugins-js-overlay")
+SET(TARGET_WRT_POPUP "wrt-popup-runtime")
+SET(TARGET_WRT_POPUP_RUNNER_LIB "wrt-popup-runner")
+set(TARGET_PLUGINS_API_SUPPORT "wrt-plugins-api-support")
set(PLUGIN_LOADING_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugin-loading)
+set(PLUGINS_API_SUPPORT_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/plugins-api-support)
+add_subdirectory(plugins-api-support)
add_subdirectory(plugin-loading)
add_subdirectory(js-overlay)
add_subdirectory(Commons)
add_subdirectory(CommonsJavaScript)
add_subdirectory(modules)
add_subdirectory(standards)
+add_subdirectory(wrt-popup)
+add_subdirectory(plugins-installer)
include_config_file(WrtAccess)
pkg_search_module(plugin-types REQUIRED wrt-plugins-types)
-pkg_search_module(ace-client REQUIRED ace-client)
+pkg_search_module(ace-client REQUIRED security-client)
pkg_search_module(dpl-event REQUIRED dpl-event-efl)
pkg_search_module(icu REQUIRED icu-i18n)
${ace-client_LIBRARIES}
${dpl-event_LIBRARIES}
${icu_LIBRARIES}
+ ${TARGET_WRT_POPUP_RUNNER_LIB}
)
-set_target_properties(${TARGET_NAME} PROPERTIES
+set_target_properties(${TARGET_NAME} PROPERTIES
SOVERSION ${CMAKE_PROJECT_API_VERSION}
VERSION ${CMAKE_PROJECT_VERSION}
)
#include <ace_api_client.h>
#include <dpl/singleton_safe_impl.h>
+#include "popup-runner.h"
IMPLEMENT_SAFE_SINGLETON(WrtDeviceApis::Commons::WrtAccess)
namespace {
LogDebug("Invalid widget id");
Throw(Exception);
}
- // TODO: implement UI handler
- ace_return_t ret = ace_client_initialize(NULL);
- // Assert(ACE_OK == ret); // This is commented because UI handler is not
- // implemented, ace client will work, but initialization will return
- // ACE_INVALID_ARGUMENTS
+ ace_return_t ret = ace_client_initialize(Wrt::Popup::run_popup);
+ Assert(ACE_OK == ret);
m_initialized = true;
m_widgetId = widgetId;
}
return (isNan(tmp) ? 0 : static_cast<long>(tmp));
}
+long long Converter::toLongLong(const JSValueRef& arg)
+{
+ double tmp = toNumber_(arg);
+ return (isNan(tmp) ? 0 : static_cast<long long>(tmp));
+}
+
unsigned long Converter::toULong(const JSValueRef& arg)
{
return static_cast<unsigned long>(toLong(arg));
long toLong(const JSValueRef& arg);
/**
+ * Converts JSvalueRef to long long integer value.
+ * @param arg JSValueRef object to convert.
+ * @return Long long integer value.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ long long toLongLong(const JSValueRef& arg);
+ /**
* Converts JSValueRef to unsigned long value.
* @param arg JSValueRef object to convert.
* @return Unsigned long value.
namespace {
const char *STANDARD_FEATURES_LIST_FILE = "standard-features-list";
+const char* FEATURE_WAC20_DEVICAPIS_NAME = "http://wacapps.net/api/deviceapis";
}
using namespace WrtDB;
-PluginContainerSupport::PluginContainerSupport()
-{
- // Retrieve plugin model list
- readPlugins();
-
- // Retrieve features model list
- readFeatures();
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+PluginContainerSupport::PluginContainerSupport(): m_initialized(false)
+{
// Reading standard features list from file
readStandardFeaturesList();
}
m_standardFeatureList.clear();
}
+void PluginContainerSupport::readAllowedPlugins(int widgetHandle)
+{
+ //TODO it has to return LIST NOT SET!!!
+ WidgetDAOReadOnly widgetDao(widgetHandle);
+ DbWidgetFeatureSet features = widgetDao.getFeaturesList();
+
+ std::list<std::string> allowedFeatures(m_standardFeatureList);
+ FOREACH(it, features) {
+ LogInfo("Loading api-feature: " << it->name);
+ if (it->rejected) {
+ LogWarning("Api-feature was rejected by ace. (Api-feature name: "
+ << it->name << ")" );
+ continue;
+ }
+
+ allowedFeatures.push_back(DPL::ToUTF8String(it->name));
+ }
+
+ auto widgetType = widgetDao.getWidgetType();
+
+ //WAC2.0 requirement
+ if (widgetType == APP_TYPE_WAC20) {
+ auto it = find(allowedFeatures.begin(),
+ allowedFeatures.end(),
+ FEATURE_WAC20_DEVICAPIS_NAME);
+
+ if (allowedFeatures.end() == it) {
+ LogInfo("WAC2.0 Deviceapis not declared but added");
+ allowedFeatures.push_front(FEATURE_WAC20_DEVICAPIS_NAME);
+ }
+ }
+
+ FeatureData* dt = NULL;
+ std::map<FeatureHandle, FeatureData> featureDataList = FeatureDAOReadOnly::GetFeatures(allowedFeatures);
+ DeviceCapList deviceCapabilities = FeatureDAOReadOnly::GetDevCapWithFeatureHandle();
+ FOREACH(data, featureDataList) {
+ dt = &(data->second);
+ registerPluginModel(dt->pluginHandle);
+ registerFeatureModel(data->first, dt, deviceCapabilities);
+ }
+
+ m_initialized = true;
+}
+
+void PluginContainerSupport::registerFeatureModel(FeatureHandle handle, FeatureData* data, DeviceCapList deviceCapabilities)
+{
+ LogDebug("Analyzing feature: " << handle);
+ FeatureModelPtr model = getFeatureModel(handle);
+ if (model) {
+ LogDebug("Model for feature:" << handle << " already created");
+ return;
+ }
+
+ LogDebug("Creating Model for feature:" << handle);
+
+ model.Reset(new FeatureModel(handle));
+
+ std::set<std::string> devCapList;
+ auto ret = deviceCapabilities.equal_range(handle);
+ for (auto devCapIt = ret.first; devCapIt != ret.second; devCapIt++) {
+ devCapList.insert((*devCapIt).second);
+ }
+ model->SetData(data->featureName, devCapList, data->pluginHandle);
+ m_featureModels.insert(model);
+}
+
void PluginContainerSupport::registerPluginModel(DbPluginHandle handle)
{
PluginModelPtr model = getPluginModelById(handle);
m_pluginModels.insert(model);
}
-void PluginContainerSupport::readPlugins()
-{
- LogDebug("Retrieving installed plugin list...");
- PluginHandleList plugins = PluginDAOReadOnly::getPluginHandleList();
-
- FOREACH(it, plugins)
- {
- registerPluginModel(*it);
- }
-}
-
-void PluginContainerSupport::readFeatures()
-{
- std::map<FeatureHandle, std::string> featureNames = FeatureDAOReadOnly::GetNames();
- std::multimap<FeatureHandle, std::string> deviceCapabilities = FeatureDAOReadOnly::GetDevCapWithFeatureHandle();
-
- FOREACH(pluginIt, m_pluginModels)
- {
- PluginModelPtr model = *pluginIt;
- LogDebug("Analyzing Plugin model: " << model->Handle.Get());
-
- WrtDB::DbPluginHandle pluginHandle = model->Handle.Get();
- FeatureHandleListPtr featureHandles = model->FeatureHandles.Get();
-
- FOREACH(featureIt, *featureHandles)
- {
- LogDebug("Analyzing feature: " << *featureIt);
- FeatureModelPtr model = getFeatureModel(*featureIt);
- if (model) {
- LogDebug("Model for feature:" << *featureIt << " already created");
- continue;
- }
-
- LogDebug("Creating Model for feature:" << *featureIt);
-
- model.Reset(new FeatureModel(*featureIt));
-
- std::set<std::string> devCapList;
- auto ret = deviceCapabilities.equal_range(*featureIt);
- for (auto devCapIt = ret.first; devCapIt != ret.second; devCapIt++)
- {
- devCapList.insert((*devCapIt).second);
- }
- model->SetData(featureNames.find(*featureIt)->second, devCapList, pluginHandle);
- m_featureModels.insert(model);
- }
- }
-}
-
void PluginContainerSupport::readStandardFeaturesList()
{
LogDebug("Reading standard features list from file...");
FeatureModelContainer m_featureModels;
+ bool m_initialized;
+
private:
// Reading
- void readPlugins();
- void readFeatures();
void readStandardFeaturesList();
// Plugin models
void registerPluginModel(WrtDB::DbPluginHandle handle);
-
+ typedef std::multimap<WrtDB::FeatureHandle, std::string> DeviceCapList;
+ void registerFeatureModel(WrtDB::FeatureHandle handle, WrtDB::FeatureData* data, DeviceCapList deviceCapabilities);
WrtDB::FeatureModelPtr getFeatureModel(const std::string &name) const ;
WrtDB::FeatureModelPtr getFeatureModel(WrtDB::FeatureHandle handle) const ;
public:
PluginContainerSupport();
+ bool isInitialized() { return m_initialized; }
+ void readAllowedPlugins(int widgetHandle);
+
FeaturesList getStandardFeatures() const;
PluginsList getStandardPlugins() const;
{
LogInfo("Starting widget session...");
+ if (!m_pluginsSupport->isInitialized())
+ m_pluginsSupport->readAllowedPlugins(widgetHandle);
+
auto sessionIt = m_sessions.find(context);
// Check if corresponding session if not already created
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# @file CMakeLists.txt
+# @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
+# @version 1.0
+#
+
+pkg_search_module(dpl REQUIRED dpl-efl)
+
+set(PLUGINS_API_SUPPORT_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/Plugin.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/Object.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ObjectFactory.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/PluginRegistration.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/PluginRegistry.cpp
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${dpl_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_PLUGINS_API_SUPPORT} SHARED
+ ${PLUGINS_API_SUPPORT_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_PLUGIN_API_SUPPORT} PROPERTIES
+ COMPILE_FLAGS -fPIC
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both"
+)
+
+SET_TARGET_PROPERTIES(${TARGET_PLUGINS_API_SUPPORT} PROPERTIES
+ SOVERSION ${CMAKE_PROJECT_API_VERSION}
+ VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+target_link_libraries(${TARGET_PLUGINS_API_SUPPORT}
+ ${dpl_LIBRARIES}
+)
+
+INSTALL(TARGETS ${TARGET_PLUGINS_API_SUPPORT}
+ DESTINATION lib
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+)
+
+INSTALL(FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/ExportedApi.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/Plugin.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/IObject.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/ObjectFactory.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/CallbackSupport.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/tuple.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/PluginSignals.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/SignalSignature.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/PluginRegistration.h
+ DESTINATION include/wrt-plugins-api-support)
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file CallbackSupport.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_CALLBACK_SUPPORT_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_CALLBACK_SUPPORT_H_
+
+#include <map>
+#include <vector>
+#include <string>
+#include <dpl/foreach.h>
+
+namespace WrtPluginsApi
+{
+
+template<typename Sig>
+class CallbackSupport
+{
+public:
+ typedef typename Sig::Signature SlotSignature;
+ typedef typename Sig::Type SlotType;
+ typedef std::string GroupType;
+ typedef std::vector<SlotType> SlotList;
+
+ void Connect(const GroupType& group, const SlotType& slot)
+ {
+ auto groupIt = m_slots.find(group);
+ if (m_slots.end() == groupIt)
+ {
+ groupIt = m_slots.insert(std::make_pair(group, SlotList())).first;
+ }
+ groupIt->second.push_back(slot);
+ }
+
+ void Disconnect(const GroupType& group)
+ {
+ m_slots.erase(group);
+ }
+
+ template<typename...Args>
+ void Invoke(const Args&... args)
+ {
+
+ FOREACH(groupIt, m_slots)
+ {
+ FOREACH(slotIt, groupIt->second)
+ {
+ (*slotIt)(args...);
+ }
+ }
+ }
+
+ template<typename...Args>
+ void InvokeGroup(const GroupType& group, const Args&... args)
+ {
+ auto groupIt = m_slots.find(group);
+
+ if (m_slots.end() != groupIt)
+ {
+ FOREACH (slotIt, groupIt->second)
+ {
+ (*slotIt)(args...);
+ }
+ }
+ }
+
+private:
+ std::map<GroupType, SlotList> m_slots;
+};
+
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ *
+ * @file ExportedApi.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_EXPORTED_API_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_EXPORTED_API_H_
+
+#include <PluginRegistration.h>
+
+/**
+ * This file provides definition of entry point to the plugin's shared library
+ * used by wrt.
+ *
+ * Each plugin have to provide 1 symbol which is get by dlsym.
+ * The name of required symbol is specified by 'GetExportedSymbolName' function
+ * The type of this symbol is pointer to ExportedApi struct
+ *
+ * To allow access to your plugin, you have to:
+ *
+ * 1)define 3 functions:
+ * - Register,
+ * - Unregister,
+ * - GetProvidedFeatures
+ * (names are not important)
+ *
+ * 2)define global struct named "dll_api" and initialize it with above functions
+ * *Example:
+ * ExportedApi dll_api = {Register, Unregister, GetProvidedFeatures};
+ *
+ *
+ * Detailed Example how the file with api may looks like file:
+ *
+ #include <Commons/Exception.h>
+ #include <Commons/WrtAccess/WrtAccess.h>
+
+ #include <Plugin.h>
+ #include <ObjectFactory.h>
+ #include <PluginRegistration.h>
+ #include <ExportedApi.h>
+
+ #include "JSTest.h"
+ #include "plugin_config.h"
+
+ #define OBJECT_WIDGET "widget"
+ #define OBJECT_TEST "__test"
+
+ using namespace WrtPlugins::W3C;
+ using namespace WrtDeviceApis;
+ using namespace WrtDeviceApis::Commons;
+ using namespace WrtPluginsApi;
+
+ namespace W3CTest
+ {
+
+ void on_widget_start_callback(int widgetId)
+ {
+
+ }
+
+ void on_widget_stop_callback(int widgetId)
+ {
+ }
+
+ }
+
+ void Register(PluginRegistration& r)
+ {
+ Plugin* plugin = new Plugin();
+
+ auto test = ObjectFactory::createMainObject(
+ OBJECT_TEST,
+ WrtPlugins::W3C::JSTest::getClassRef,
+ OBJECT_WIDGET);
+
+ plugin->AddObject(test);
+
+ r.Connect<OnWidgetStart>(W3CTest::on_widget_start_callback);
+
+ r.Connect<OnWidgetStop>(W3CTest::on_widget_stop_callback);
+
+ r.AddPlugin(*plugin);
+ }
+
+ void Unregister(PluginRegistration& r, Plugin* plugin)
+ {
+ r.DisconnectAll();
+ delete plugin;
+ }
+
+ void GetProvidedFeatures(feature_mapping_interface_t *mapping)
+ {
+ WrtPlugins::W3C::WidgetTestDeclarations::getMappingInterface(mapping);
+ }
+
+ ExportedApi dll_api={Register, Unregister, GetProvidedFeatures};
+
+ #undef OBJECT_WIDGET
+ #undef OBJECT_TEST
+ *
+ *
+ * */
+
+//forward declaration
+struct feature_mapping_interface_s;
+typedef struct feature_mapping_interface_s feature_mapping_interface_t;
+
+class WrtPluginsApi::Plugin;
+
+extern "C" struct ExportedApi
+{
+ /*
+ * This function is invoked when library is loaded
+ * */
+ void (*Register)(WrtPluginsApi::PluginRegistration&);
+
+ /*
+ * This function is invoked when library is unloaded
+ * */
+ void (*Unregister)(WrtPluginsApi::PluginRegistration&,
+ WrtPluginsApi::Plugin* plugin);
+
+ /*
+ * This function is invoked by wrt-plugins-installer to obtain
+ * info about features,functions,objects provided by plugin
+ * */
+ void (*GetProvidedFeatures)(feature_mapping_interface_t*);
+};
+
+
+constexpr const char* GetExportedSymbolName()
+{
+ return "dll_api";
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file IObject.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_IOBJECT_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_IOBJECT_H_
+
+#include <memory>
+#include <list>
+
+extern "C" {
+ typedef struct OpaqueJSClass* const (*ClassRef)();
+}
+
+namespace WrtPluginsApi
+{
+
+enum class IObjectType
+{
+ Object,
+ Function,
+ Interface,
+ InterfaceInstance
+};
+
+enum class IObjectOption
+{
+ Overlayed
+};
+
+class IObject;
+typedef std::shared_ptr<IObject> IObjectPtr;
+
+class IObject
+{
+ public:
+ constexpr static const char* WINDOW_OBJECT()
+ {
+ return "window";
+ }
+
+ virtual void AddChild(const IObjectPtr& ) = 0;
+
+ /*
+ * Optional
+ * */
+ virtual void setBoolOption(IObjectOption option, bool value) = 0;
+
+ virtual ~IObject(){};
+};
+
+typedef std::list<IObjectPtr> IObjectsList;
+typedef std::shared_ptr<IObjectsList> IObjectsListPtr;
+
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file IObject_cast.h
+ * @author
+ * @version
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGINS_API_SUPPORT_CAST_H_
+#define _WRT_PLUGINS_COMMON_PLUGINS_API_SUPPORT_CAST_H_
+
+#include <memory>
+#include <IObject.h>
+#include <Object.h>
+
+namespace WrtPluginsApi
+{
+
+inline ObjectPtr CAST(const IObjectPtr& object)
+{
+ return std::dynamic_pointer_cast<Object>(object);
+}
+
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file Object.cpp
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#include "Object.h"
+
+namespace WrtPluginsApi
+{
+
+void Object::AddChild(const IObjectPtr& child)
+{
+ if(!m_children)
+ {
+ m_children = IObjectsListPtr(new IObjectsList);
+ }
+ m_children->push_back(child);
+}
+
+void Object::setBoolOption(IObjectOption option, bool value)
+{
+ if(!m_options)
+ {
+ m_options = ObjectOptionPtr(new ObjectOption);
+ }
+
+ switch(option)
+ {
+ case IObjectOption::Overlayed:
+ m_options->overlayedMode = value;
+ break;
+ default:
+ break;
+ }
+}
+
+IObjectsListPtr Object::GetChildren() const
+{
+ return m_children;
+}
+
+ClassRef Object::GetClass() const
+{
+ return m_classRef;
+}
+
+ClassRef Object::GetClassConstructor() const
+{
+ return m_constructorRef;
+}
+
+const char* Object::GetInterfaceName() const
+{
+ return m_interfaceName;
+}
+
+const char* Object::GetName() const
+{
+ return m_name;
+}
+
+IObjectType Object::GetType() const
+{
+ return m_type;
+}
+
+const char* Object::GetParentName() const
+{
+ return m_parentName;
+}
+
+ObjectOptionPtr Object::GetOptions() const
+{
+ return m_options;
+}
+
+Object::Object(const char* name,
+ ClassRef ref,
+ IObjectType type)
+ : m_name(name),
+ m_classRef(ref),
+ m_parentName(0),
+ m_type(type),
+ m_interfaceRef(0),
+ m_interfaceName(0),
+ m_constructorRef(0)
+{
+}
+
+Object::Object(const char* name,
+ ClassRef ref,
+ const char* parentName,
+ IObjectType type)
+ : m_name(name),
+ m_classRef(ref),
+ m_parentName(parentName),
+ m_type(type),
+ m_interfaceRef(0),
+ m_interfaceName(0),
+ m_constructorRef(0)
+{
+}
+
+Object::Object(const char* name,
+ ClassRef interfaceRef,
+ const char* interfaceName,
+ ClassRef constructorRef,
+ const char* parentName,
+ IObjectType type)
+ : m_name(name),
+ m_parentName(parentName),
+ m_type(type),
+ m_interfaceRef(interfaceRef),
+ m_interfaceName(interfaceName),
+ m_constructorRef(constructorRef)
+{
+}
+
+Object::~Object()
+{
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file IObject.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_OBJECT_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_OBJECT_H_
+
+#include <memory>
+#include <list>
+
+#include <IObject.h>
+#include <dpl/optional.h>
+
+namespace WrtPluginsApi
+{
+
+class Object;
+typedef std::shared_ptr<Object> ObjectPtr;
+
+struct ObjectOption
+{
+ DPL::Optional<bool> overlayedMode;
+};
+typedef std::shared_ptr<ObjectOption> ObjectOptionPtr;
+
+
+class Object : public IObject
+{
+ public:
+ Object(const char* name,
+ ClassRef ref,
+ IObjectType type = IObjectType::Object);
+
+ Object(const char* name,
+ ClassRef ref,
+ const char* parentName = IObject::WINDOW_OBJECT(),
+ IObjectType type = IObjectType::Object);
+
+ Object(const char* name,
+ ClassRef interfaceRef,
+ const char* interfaceName,
+ ClassRef constructorRef,
+ const char* parentName = IObject::WINDOW_OBJECT(),
+ IObjectType type = IObjectType::Object);
+
+ ~Object();
+
+ void AddChild(const IObjectPtr& );
+
+ void setBoolOption(IObjectOption option, bool value);
+
+ IObjectsListPtr GetChildren() const ;
+
+ ClassRef GetClass() const;
+
+ /*
+ * Available only for object with type InterfaceInstance
+ * */
+ ClassRef GetClassConstructor() const;
+
+ const char* GetInterfaceName() const;
+
+ const char* GetName() const;
+
+ IObjectType GetType() const;
+
+ const char* GetParentName() const;
+
+ ObjectOptionPtr GetOptions() const;
+
+ private:
+ const char* m_name;
+ ClassRef m_classRef;
+
+ const char* m_parentName;
+
+ IObjectType m_type;
+
+ ClassRef m_interfaceRef;
+ const char* m_interfaceName;
+ ClassRef m_constructorRef;
+
+ ObjectOptionPtr m_options;
+
+ IObjectsListPtr m_children;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ObjectFactory.cpp
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#include "ObjectFactory.h"
+#include "Object.h"
+
+namespace WrtPluginsApi {
+namespace ObjectFactory {
+
+IObjectPtr createObject(
+ const char* name,
+ ClassRef ref,
+ IObjectType type)
+{
+ return IObjectPtr(new Object(name, ref, type));
+}
+
+IObjectPtr createMainObject(
+ const char* name,
+ ClassRef ref,
+ const char* parentName,
+ IObjectType type)
+{
+ return IObjectPtr(new Object(name, ref, parentName, type));
+}
+
+IObjectPtr createObjectWithInterface(
+ const char* name,
+ ClassRef interfaceRef,
+ const char* interfaceName,
+ ClassRef constructorRef,
+ const char* parentName,
+ IObjectType type)
+{
+ return IObjectPtr(new Object(name,
+ interfaceRef,
+ interfaceName,
+ constructorRef,
+ parentName,
+ type));
+}
+
+}
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ObjectFactory.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_OBJECT_FACTORY_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_OBJECT_FACTORY_H_
+
+#include <memory>
+#include <IObject.h>
+
+namespace WrtPluginsApi {
+namespace ObjectFactory {
+
+ IObjectPtr createObject(
+ const char* name,
+ ClassRef ref,
+ IObjectType type = IObjectType::Object);
+
+ IObjectPtr createMainObject(
+ const char* name,
+ ClassRef ref,
+ const char* parentName = IObject::WINDOW_OBJECT(),
+ IObjectType type = IObjectType::Object);
+
+ IObjectPtr createObjectWithInterface(
+ const char* name,
+ ClassRef interfaceRef,
+ const char* interfaceName,
+ ClassRef constructorRef,
+ const char* parentName = IObject::WINDOW_OBJECT(),
+ IObjectType type = IObjectType::Object);
+}
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file Plugin.cpp
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#include "Plugin.h"
+
+namespace WrtPluginsApi
+{
+
+void Plugin::AddObject(const IObjectPtr& object)
+{
+ m_objects->push_back(object);
+}
+
+IObjectsListPtr Plugin::GetObjects() const
+{
+ return m_objects;
+}
+
+Plugin::~Plugin()
+{
+}
+
+Plugin::Plugin() : m_objects(new IObjectsList())
+{
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file Plugin.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_H_
+
+#include <list>
+#include <IObject.h>
+
+namespace WrtPluginsApi
+{
+
+class Plugin
+{
+public:
+ void AddObject(const IObjectPtr& object);
+
+ IObjectsListPtr GetObjects() const;
+
+ Plugin();
+
+ virtual ~Plugin();
+
+private:
+ IObjectsListPtr m_objects;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginRegistration.cpp
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#include "PluginRegistration.h"
+
+#include "PluginRegistrationImpl.h"
+#include "Plugin.h"
+#include <dpl/assert.h>
+
+namespace WrtPluginsApi
+{
+
+PluginRegistration::PluginRegistration(Impl* impl) : m_impl(impl)
+{
+ Assert(impl != 0 && "impl is NULL");
+}
+
+template<typename SignalSignature>
+void PluginRegistration::Connect(const typename SignalSignature::Type& slot)
+{
+ m_impl->Connect<SignalSignature>(slot);
+}
+
+void PluginRegistration::DisconnectAll()
+{
+ m_impl->DisconnectAll();
+}
+
+void PluginRegistration::AddPlugin(Plugin& plugin)
+{
+ m_impl->AddPlugin(plugin);
+}
+
+#define EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(SignalSignature) \
+ template void PluginRegistration::Connect<SignalSignature>( \
+ const typename SignalSignature::Type&)
+
+EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(OnWidgetStart);
+EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(OnWidgetStop);
+EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(OnFrameLoad);
+EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(OnFrameUnload);
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginRegistration.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_REGISTRATION_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_REGISTRATION_H_
+
+#include <memory>
+#include "Plugin.h"
+#include "PluginSignals.h"
+
+namespace WrtPluginsApi
+{
+
+class PluginRegistration
+{
+public:
+ class Impl;
+
+ explicit PluginRegistration(PluginRegistration::Impl* impl);
+
+ template<typename SignalSignature>
+ void Connect(const typename SignalSignature::Type& slot);
+
+ void DisconnectAll();
+
+ void AddPlugin(Plugin& plugin);
+
+private:
+ std::unique_ptr<Impl> m_impl;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginRegistrationImpl.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_REGISTRATION_IMPL_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_REGISTRATION_IMPL_H_
+
+#include <string>
+#include "SignalsSupport.h"
+#include "Plugin.h"
+#include <dpl/log/log.h>
+
+namespace WrtPluginsApi
+{
+
+class PluginRegistration::Impl
+{
+public:
+ Impl(SignalsSupport& registry, const std::string& libraryName)
+ : m_registry(registry),
+ m_libraryName(libraryName)
+ {}
+
+ void AddPlugin(Plugin& plugin)
+ {
+ m_registry.AddPlugin(m_libraryName, plugin);
+ }
+
+ template<typename T>
+ void Connect(const typename T::Type& slot)
+ {
+ m_registry.Connect<T>(m_libraryName, slot);
+ }
+
+ void DisconnectAll()
+ {
+ m_registry.Disconnect(m_libraryName);
+ }
+
+private:
+ SignalsSupport& m_registry;
+ std::string m_libraryName;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginRegistry.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#include "PluginRegistry.h"
+#include "PluginRegistration.h"
+#include "PluginRegistrationImpl.h"
+#include "ExportedApi.h"
+
+#include <dlfcn.h>
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <algorithm>
+
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+
+
+namespace {
+const char* DLL_ENTRY_POINT_NAME = "dll_api";
+}
+
+namespace WrtPluginsApi
+{
+
+void PluginRegistry::AddPlugin(const std::string& libraryName,
+ Plugin& plugin)
+{
+ LogDebug("Adding plugin for library: " << libraryName);
+
+ auto libraryIt = m_plugins.find(libraryName);
+ if (m_plugins.end() == libraryIt)
+ {
+ m_plugins[libraryName] = &plugin;
+ }
+}
+
+Plugin* PluginRegistry::GetPlugin(const std::string& libraryName)
+{
+ auto it = m_plugins.find(libraryName);
+ if (it == m_plugins.end())
+ {
+ if (!LoadFromFile(libraryName))
+ {
+ LogError("Failed to load lib" << libraryName);
+ ThrowMsg(PluginNotFound, "Failed to load plugin");
+ }
+
+ return m_plugins[libraryName];
+ }
+
+ return it->second;
+}
+
+void PluginRegistry::RemovePlugin(const std::string& libraryName,
+ Plugin& plugin)
+{
+ auto it = m_plugins.find(libraryName);
+ if (it != m_plugins.end())
+ {
+ if (&plugin == it->second)
+ {
+ m_plugins.erase(it);
+ }
+ }
+}
+
+void PluginRegistry::UnloadAll()
+{
+ LogDebug("Unload all plugins");
+
+ typedef void (*UnregisterFunction) (PluginRegistration&, Plugin&);
+
+ FOREACH(libraryIt, m_libraries)
+ {
+ auto pluginIt = m_plugins.find(libraryIt->first);
+ if (m_plugins.end() != pluginIt)
+ {
+ void* handle = dlopen(libraryIt->first.c_str(), RTLD_NOW);
+ if (!handle) {
+ LogError("Error: " << dlerror());
+ continue;
+ }
+
+ ExportedApi* entryPoint =
+ static_cast<ExportedApi*>
+ (dlsym(handle, GetExportedSymbolName()));
+ if (NULL == entryPoint)
+ {
+ LogError("Error: " << dlerror());
+ continue;
+ }
+ if (entryPoint->Unregister == NULL)
+ {
+ LogError("Error Unregister function not set");
+ continue;
+ }
+
+ PluginRegistration registration(
+ new PluginRegistration::Impl(*this, libraryIt->first));
+
+ entryPoint->Unregister(registration, (pluginIt->second));
+
+ m_plugins.erase(pluginIt);
+ }
+ dlclose(libraryIt->second);
+ }
+}
+
+bool PluginRegistry::LoadFromFile(const std::string& libraryName)
+{
+ void* handle = dlopen(libraryName.c_str(), RTLD_NOW);
+ if (!handle) {
+ LogError("Error: " << dlerror());
+ return false;
+ }
+ m_libraries[libraryName] = handle;
+
+ ExportedApi* entryPoint =
+ static_cast<ExportedApi*>(dlsym(handle, GetExportedSymbolName()));
+ if (NULL == entryPoint)
+ {
+ LogError("Error: " << dlerror());
+ return false;
+ }
+
+ if (entryPoint->Register == NULL)
+ {
+ LogError("Error Register function not set");
+ return false;
+ }
+ if (entryPoint->Unregister== NULL)
+ {
+ LogError("Error Unregister function not set");
+ return false;
+ }
+
+ PluginRegistration registration(
+ new PluginRegistration::Impl(*this, libraryName));
+ entryPoint->Register(registration);
+
+ return true;
+}
+
+
+PluginRegistry::~PluginRegistry()
+{
+ //TODO discuss ... when the unload should be called
+// UnloadAll();
+}
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginRegistry.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_LOADING_PLUGIN_REGISTRY_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_LOADING_PLUGIN_REGISTRY_H_
+
+#include <map>
+#include <string>
+#include "SignalsSupport.h"
+#include "Plugin.h"
+#include <dpl/exception.h>
+
+namespace WrtPluginsApi
+{
+
+typedef std::list<Plugin*> PluginsList;
+typedef std::shared_ptr<PluginsList> PluginsListPtr;
+typedef std::map< std::string, PluginsListPtr> PluginsSet;
+
+class PluginRegistry : public SignalsSupport
+{
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, PluginNotFound)
+
+ template <typename T, typename ...Args>
+ void Call(Args... args)
+ {
+ Invoke<T>(args...);
+ }
+
+ template <typename T, typename ...Args>
+ void CallGroup(const typename CallbackSupport<T>::GroupType& type,
+ Args... args)
+ {
+ InvokeGroup<T>(type, args...);
+ }
+
+ void AddPlugin(const std::string& libraryName, Plugin& plugin);
+
+ /*
+ * @throw PluginNotFound
+ * */
+ Plugin* GetPlugin(const std::string& libraryName);
+
+ void RemovePlugin(const std::string& libraryName, Plugin& plugin);
+
+ void UnloadAll();
+
+ ~PluginRegistry();
+private:
+ bool LoadFromFile(const std::string& libraryName);
+
+ typedef void* Symbol;
+
+ std::map<std::string, Plugin*> m_plugins;
+ std::map<std::string, void*> m_libraries;
+};
+
+typedef std::shared_ptr<PluginRegistry> PluginRegistryPtr;
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file PluginSignals.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_SIGNALS_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_PLUGIN_SIGNALS_H_
+
+#include "SignalSignature.h"
+
+namespace WrtPluginsApi
+{
+
+struct OnWidgetStart : SignalSignature<void (int)> {};
+
+struct OnWidgetStop : SignalSignature<void (int)> {};
+
+struct OnFrameLoad: SignalSignature<void (void*)> {};
+
+struct OnFrameUnload : SignalSignature<void (void*)> {};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file SignalSignature.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNAL_SIGNATURE_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNAL_SIGNATURE_H_
+
+#include <functional>
+
+namespace WrtPluginsApi
+{
+
+template<typename> struct SignalSignature;
+
+template<typename R, typename ...Args>
+struct SignalSignature<R (Args...)>
+{
+ typedef R (*Signature) (Args...);
+ typedef std::function<R (Args...)> Type;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file IPluginRegistry.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNALS_SUPPORT_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNALS_SUPPORT_H_
+
+#include <tuple>
+#include <string>
+#include "CallbackSupport.h"
+#include "tuple.h"
+#include "PluginSignals.h"
+#include "Plugin.h"
+
+namespace WrtPluginsApi
+{
+
+class SignalsSupport
+{
+public:
+ virtual ~SignalsSupport() {}
+
+ template<typename T>
+ void Connect(const std::string& libraryName, const typename T::Type& slot)
+ {
+ Tuple::get_by_type<CallbackSupport<T>>(m_slots).Connect(libraryName,
+ slot);
+ }
+
+ void Disconnect(const std::string& libraryName)
+ {
+ DisconnectGroup(m_slots, libraryName);
+ }
+
+ virtual void AddPlugin(const std::string& libraryName, Plugin& plugin) = 0;
+
+protected:
+ template<typename T, typename ...Args>
+ void Invoke(const Args&... args)
+ {
+ Tuple::get_by_type<CallbackSupport<T>>(m_slots).Invoke(args...);
+ }
+
+ template<typename T, typename ...Args>
+ void InvokeGroup(const std::string& libraryName, const Args&... args)
+ {
+ Tuple::get_by_type<CallbackSupport<T>>(m_slots).InvokeGroup(libraryName,
+ args...);
+ }
+
+private:
+ template<int N, typename ...Args>
+ void DisconnectSlot(std::tuple<Args...>& slots,
+ const std::string& libraryName,
+ typename std::enable_if<(N >= 0)>::type* = NULL)
+ {
+ std::get<N>(slots).Disconnect(libraryName);
+ DisconnectSlot<N-1>(slots, libraryName);
+ }
+
+ template<int N, typename ...Args>
+ void DisconnectSlot(std::tuple<Args...>& slots,
+ const std::string& libraryName,
+ typename std::enable_if<(N == -1)>::type* = NULL)
+ {
+ }
+
+ template<typename ...Args>
+ void DisconnectGroup(std::tuple<Args...>& slots,
+ const std::string& libraryName)
+ {
+ DisconnectSlot<sizeof...(Args)-1>(slots, libraryName);
+ }
+
+ std::tuple<CallbackSupport<OnWidgetStart>,
+ CallbackSupport<OnWidgetStop>,
+ CallbackSupport<OnFrameLoad>,
+ CallbackSupport<OnFrameUnload>> m_slots;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file
+ * @author
+ * @version
+ * @brief TODO This header must be removed because it does not fit to current
+ * solution, its just a temporary approach.
+ */
+#ifndef _WRT_PLUGINS_COMMON_FEATURE_API_SO_FEATURES_H_
+#define _WRT_PLUGINS_COMMON_FEATURE_API_SO_FEATURES_H_
+
+#define PLUGIN_WIDGET_INIT_PROC_NAME "on_widget_init"
+//#define PLUGIN_WIDGET_INIT_PROC_NAME \
+// "_Z23on_widget_init_callbackP27feature_mapping_interface_s"
+
+//TODO remove
+/*
+ * list of device caps
+ */
+typedef struct devcaps_s
+{
+ char** deviceCaps;
+ size_t devCapsCount;
+} devcaps_t;
+
+/*
+ * mapping from a feature to corresponding list of device capabilities
+ */
+typedef struct feature_devcaps_s
+{
+ char* feature_name;
+ devcaps_t devCaps;
+} feature_devcaps_t;
+
+/*
+ * list of feature_devcaps_t structs
+ */
+typedef struct feature_mapping_s
+{
+ feature_devcaps_t* features;
+ size_t featuresCount;
+} feature_mapping_t;
+
+
+typedef feature_mapping_t* pfeature_mapping_t;
+
+typedef pfeature_mapping_t (*features_getter)(void);
+
+typedef const devcaps_t* (*devcaps_getter)(pfeature_mapping_t /*features*/,
+ const char* /*featureName*/);
+typedef void (*deinitializer)(pfeature_mapping_t /*features*/);
+
+typedef struct feature_mapping_interface_s
+{
+ features_getter featGetter; /* returns a list of api features */
+ devcaps_getter dcGetter; /*
+ * for a given api feature returns a list of
+ * corresponding device capabilities
+ */
+
+ deinitializer release; /* as memory ownership of features is
+ * transfered to callee you have to call
+ * the release function ptr on features
+ */
+} feature_mapping_interface_t;
+
+typedef void (*on_widget_init_proc)(feature_mapping_interface_t *interface);
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file traits.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_DETAIL_TRAITS_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_DETAIL_TRAITS_H_
+
+namespace WrtPluginsApi {
+namespace Traits {
+namespace Detail {
+
+template<size_t, typename RequiredType, typename ...TupleArgTypes>
+struct index_of_;
+
+/*
+ * CurrentArgType is not equal to RequiredType, check next tuple's argument
+ */
+template<size_t n,
+ typename RequiredType,
+ typename CurrentArgType,
+ typename ...TupleArgTypes>
+struct index_of_<n, RequiredType, CurrentArgType, TupleArgTypes...>
+{
+ static const size_t value = index_of_<n + 1,
+ RequiredType,
+ TupleArgTypes...>::value;
+};
+
+/*
+ * RequiredType found on tuple's args list
+ * return position on tuple's list
+ */
+template<size_t n, typename RequiredType, typename ...TupleArgTypes>
+struct index_of_<n, RequiredType, RequiredType, TupleArgTypes...>
+{
+ static const size_t value = n;
+};
+
+/*
+ * RequiredType found on last position of tuple's args list
+ * return position on tuple's list
+ */
+template<size_t n, typename RequiredType>
+struct index_of_<n, RequiredType, RequiredType>
+{
+ static const size_t value = n;
+};
+
+/*
+ * RequiredType was not found on tuple args list
+ */
+template<size_t n, typename RequiredType, typename LastArgType>
+struct index_of_<n, RequiredType, LastArgType>
+{
+ static const size_t value = -1;
+};
+
+}
+}
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file js_types.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef WRT_PLUGIN_COMMON_API_SUPPORT_JS_TYPES_H_
+#define WRT_PLUGIN_COMMON_API_SUPPORT_JS_TYPES_H_
+
+#include <string>
+
+//forward declaration
+extern "C" {
+ typedef struct OpaqueJSContext* JSGlobalContextRef;
+ typedef struct OpaqueJSValue* JSObjectRef;
+}
+
+namespace WrtPluginsApi
+{
+
+struct JavaScriptObject
+{
+ JSObjectRef instance;
+ std::string name;
+};
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file traits.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_TRAITS_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_TRAITS_H_
+
+#include "detail/traits.h"
+
+namespace WrtPluginsApi
+{
+
+namespace Traits {
+
+/**
+ * Gets index of specified type in the type list.
+ */
+template<typename RequiredType, typename ...TupleArgTypes>
+struct index_of
+{
+ static const size_t value = Detail::index_of_<0,
+ RequiredType,
+ TupleArgTypes...>::value;
+};
+
+}
+
+}
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file tuple.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_TUPLE_H_
+#define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_TUPLE_H_
+
+#include <tuple>
+#include "traits.h"
+
+namespace WrtPluginsApi {
+namespace Tuple {
+
+template<typename T, typename ...Args>
+T& get_by_type(std::tuple<Args...>& tuple)
+{
+ return std::get<Traits::index_of<T, Args...>::value>(tuple);
+}
+
+}
+}
+
+#endif
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# @file CMakeLists.txt
+# @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+# @version 1.0
+#
+
+SET(TARGET_INSTALLER "wrt-plugins-installer")
+SET(TARGET_INSTALLER_STATIC "wrt-installer_static")
+
+SET(INSTALLER_SRC_DIR
+ ${PROJECT_SOURCE_DIR}/src/plugins-installer
+ )
+
+SET(INSTALLER_JOBS
+ ${INSTALLER_SRC_DIR}/jobs
+ )
+
+SET(INSTALLER_INCLUDES
+ ${INSTALLER_SRC_DIR}
+ ${INSTALLER_SRC_DIR}/logic
+ ${INSTALLER_SRC_DIR}/jobs
+ ${INSTALLER_SRC_DIR}/jobs/plugin_install
+ # ${INSTALLER_SRC_DIR}/jobs/widget_install
+ #${INSTALLER_SRC_DIR}/jobs/widget_uninstall
+ ${INSTALLER_SRC_DIR}/misc
+ ${INSTALLER_SRC_DIR}/configuration_parser
+ ${INSTALLER_SRC_DIR}/wrt-installer
+ ${INSTALLER_SRC_DIR}/commons
+ # ${INSTALLER_SRC_DIR}/pkg-manager
+)
+
+SET(INSTALLER_SOURCES
+ ${INSTALLER_JOBS}/job.cpp
+ ${INSTALLER_JOBS}/plugin_install/job_plugin_install.cpp
+ ${INSTALLER_JOBS}/plugin_install/plugin_install_task.cpp
+ ${INSTALLER_JOBS}/plugin_install/plugin_objects.cpp
+ ${INSTALLER_JOBS}/plugin_install/plugin_metafile_reader.cpp
+ ${INSTALLER_SRC_DIR}/logic/installer_logic.cpp
+ ${INSTALLER_SRC_DIR}/logic/installer_controller.cpp
+ ${INSTALLER_SRC_DIR}/misc/libxml_utils.cpp
+ )
+
+PKG_CHECK_MODULES(INSTALLER_STATIC_DEP
+ libxml-2.0
+ cert-svc-vcore
+ dpl-event-efl
+ dpl-wrt-dao-rw
+ libpcrecpp
+ REQUIRED
+ )
+
+INCLUDE_DIRECTORIES(
+ ${INSTALLER_DEP_INCLUDES}
+ ${INSTALLER_INCLUDES}
+ ${INSTALLER_STATIC_DEP_INCLUDE_DIRS}
+ ${PLUGINS_API_SUPPORT_DIRS}
+ )
+
+ADD_LIBRARY(${TARGET_INSTALLER_STATIC} STATIC
+ ${INSTALLER_SOURCES}
+ )
+
+ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS})
+ADD_DEFINITIONS(${INSTALLER_STATIC_DEP_CFLAGS_OTHERS})
+
+TARGET_LINK_LIBRARIES(${TARGET_INSTALLER_STATIC}
+ ${INSTALLER_STATIC_DEP_LIBRARIES}
+ ${TARGET_PLUGINS_API_SUPPORT}
+ )
+
+SET_TARGET_PROPERTIES(${TARGET_INSTALLER_STATIC} PROPERTIES
+ COMPILE_FLAGS -fPIC)
+
+ADD_SUBDIRECTORY(wrt-installer)
--- /dev/null
+!!!options!!! stop
+Widget (un)installer, plugin (un)installer
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * plugin_common_types.h
+ *
+ * Author: Soyoung Kim(sy037.kim@samsung.com)
+ */
+
+#ifndef PLUGIN_COMMON_TYPES_H
+#define PLUGIN_COMMON_TYPES_H
+
+#include <dpl/utils/widget_version.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+
+/**
+* Widget version is optional
+*/
+typedef DPL::Optional<WidgetVersion> OptionalWidgetVersion;
+
+
+/* Define db type */
+typedef WrtDB::DbWidgetHandle WidgetHandle;
+typedef WrtDB::DbWidgetHandleList WidgetHandleList;
+
+typedef WrtDB::DbWidgetFeature WidgetFeature;
+typedef WrtDB::DbWidgetFeatureSet WidgetFeatureSet;
+
+typedef WrtDB::DbWidgetSize WidgetSize;
+
+typedef WrtDB::DbPluginHandle PluginHandle;
+
+#endif /* PLUGIN_COMMON_TYPES_H */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * This file contains the declaration of the error codes of Widget.
+ *
+ * @file wrt_error.h
+ * @author MaQuan (jason.ma@samsung.com)
+ * @version 0.7
+ * @brief This file contains the declaration of the error codes of Widget.
+ */
+
+#ifndef _WRT_ERROR_H_
+#define _WRT_ERROR_H_
+
+#ifndef WRT_ERROR_MASKL8
+#define WRT_ERROR_MASKL8 0xFF
+#endif
+
+#ifndef WRT_SET_IDENT
+#define WRT_SET_IDENT(X) (X & WRT_ERROR_MASKL8)
+#endif
+
+#ifndef WRT_ERROR_SET
+#define WRT_ERROR_SET(X) ((X & WRT_ERROR_MASKL8) << 8)
+#endif
+
+#define WRT_MID_ERRCODE 0x10000 + WRT_SET_IDENT(5)
+
+/*typedef */ enum
+{
+ WRT_GENERAL_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(0),
+ WRT_CONFIG_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(1),
+ WRT_DOMAIN_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(2),
+ WRT_JS_EXT_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(3),
+ WRT_WM_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(4),
+ WRT_PLUGIN_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(5),
+ //_ACE support
+ WRT_SAI_ERRCODE = WRT_MID_ERRCODE + WRT_SET_IDENT(6)
+};
+
+/**
+ * WRT error code description
+ *
+ * @ WRT_SUCCESS
+ * There is no error with WRT operations.
+ *
+ * @ WRT_ERR_UNKNOW
+ * An unknow error happened to WRT.
+ *
+ * @ WRT_ERR_INVALID_ARG
+ * Invalid arguments are passed into WRT functions.
+ *
+ * @ WRT_ERR_OUT_MEMORY
+ * No memory space available for WRT.
+ *
+ * @ WRT_ERR_NO_DISK_SPACE
+ * There is no disk space for widget applications.
+ *
+ *
+ *
+ *
+ */
+enum WrtError
+{
+ /* General errors */
+ WRT_SUCCESS = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x01),
+ WRT_ERR_UNKNOWN = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x02),
+ WRT_ERR_INVALID_ARG = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x03),
+ WRT_ERR_OUT_OF_MEMORY = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x04),
+ WRT_ERR_NO_DISK_SPACE = WRT_GENERAL_ERRCODE + WRT_ERROR_SET(0x05),
+
+ /* Configuration */
+ WRT_CONF_ERR_GCONF_FAILURE = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x01),
+ WRT_CONF_ERR_OBJ_MISSING = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x02),
+ WRT_CONF_ERR_OBJ_EXIST = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x03),
+ WRT_CONF_ERR_START_FILE_MISSING = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x04),
+ WRT_CONF_ERR_EMDB_FAILURE = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x05),
+ WRT_CONF_ERR_EMDB_NO_RECORD = WRT_CONFIG_ERRCODE + WRT_ERROR_SET(0x06),
+
+ /* Domain */
+ WRT_DOMAIN_ERR_CREATE_JS_RT = WRT_DOMAIN_ERRCODE + WRT_ERROR_SET(0x01),
+ WRT_DOMAIN_ERR_MSG_QUEUE = WRT_DOMAIN_ERRCODE + WRT_ERROR_SET(0x02),
+
+ /* Widget manager*/
+ WRT_WM_ERR_NOT_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x01),
+ WRT_WM_ERR_HIGH_VER_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x02),
+ WRT_WM_ERR_LOW_VER_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x03),
+ WRT_WM_ERR_INVALID_ARCHIVE = WRT_WM_ERRCODE + WRT_ERROR_SET(0x04),
+ WRT_WM_ERR_INVALID_CERTIFICATION = WRT_WM_ERRCODE + WRT_ERROR_SET(0x05),
+ WRT_WM_ERR_NULL_CERTIFICATION = WRT_WM_ERRCODE + WRT_ERROR_SET(0x06),
+ WRT_WM_ERR_INSTALLATION_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x07),
+ WRT_WM_ERR_ALREADY_INSTALLED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x08),
+ WRT_WM_ERR_INSTALL_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x09),
+ WRT_WM_ERR_DELETE_BY_SERVER = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0a),
+ WRT_WM_ERR_DEINSTALLATION_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0b),
+ WRT_WM_ERR_INCORRECT_UPDATE_INFO = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0c),
+ WRT_WM_ERR_UNREG_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0d),
+ WRT_WM_ERR_REMOVE_FILES_FAILED = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0e),
+ WRT_WM_ERR_ALREADY_LATEST = WRT_WM_ERRCODE + WRT_ERROR_SET(0x0f),
+ WRT_WM_ERR_UPDATE_CANCEL = WRT_WM_ERRCODE + WRT_ERROR_SET(0x10),
+ WRT_WM_ERR_IS_FACTORY_WIDGET = WRT_WM_ERRCODE + WRT_ERROR_SET(0x11),
+ WRT_WM_ERR_INVALID_APP_ID = WRT_WM_ERRCODE + WRT_ERROR_SET(0x12),
+
+ /* Access Control Manager */
+ WRT_SAI_ERR_INIT_ACE_FAILED = WRT_SAI_ERRCODE + WRT_ERROR_SET(0x01)
+};
+
+namespace CommonError {
+enum Type
+{
+ WrtSuccess, ///< Success
+
+ HandleNotFound, ///< Widget handle was not found
+ AlreadyRunning, ///< Widget is already running
+ AlreadyStopped, ///< Widget is already stopped
+ InvalidLanguage, ///< Widget is invalid in current locales
+ StillAuthorizing, ///< Widget is still autorizing and has not yet finished it
+ EarlyKilled, ///< Widget was early killed during launch
+ AccessDenied, ///< Access denied from ACE
+ CertificateRevoked, ///< Some certificate was revoked.
+ /// Widget is not allowed to run.
+
+ Unknown ///< Temporary error. Try to not use this.
+};
+}
+#endif /* _WRT_ERROR_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file deny_all_parser.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef DENY_ALL_PARSER_H
+#define DENY_ALL_PARSER_H
+
+#include "element_parser.h"
+
+struct DenyAllParser : public ElementParser
+{
+ static ElementParserPtr Create();
+ virtual void Accept(const Element& /*element*/);
+ virtual void Accept(const XmlAttribute& /*attribute*/);
+ virtual void Accept(const Text& /*text*/);
+ virtual void Verify()
+ {
+ }
+ virtual ActionFunc GetElementParser(const DPL::String& ns,
+ const DPL::String& name);
+
+ DenyAllParser();
+};
+
+#endif // DENY_ALL_PARSER_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file element_parser.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef ELEMENT_PARSER_H_
+#define ELEMENT_PARSER_H_
+
+#include <map>
+#include <string>
+#include <cstring>
+#include <dpl/fast_delegate.h>
+#include <dpl/exception.h>
+#include <dpl/optional.h>
+#include <dpl/string.h>
+#include <dpl/shared_ptr.h>
+#include <dpl/enable_shared_from_this.h>
+
+struct XmlAttribute
+{
+ DPL::String prefix;
+ DPL::String name;
+ DPL::String value;
+ DPL::String ns;
+ DPL::String lang;
+};
+
+struct Element
+{
+ DPL::String name;
+ DPL::String value;
+ DPL::String ns;
+ DPL::String lang;
+};
+
+struct Text
+{
+ DPL::String value;
+ DPL::String ns;
+ DPL::String lang;
+};
+
+class ElementParser;
+
+typedef DPL::SharedPtr<ElementParser> ElementParserPtr;
+
+class ElementParser : public DPL::EnableSharedFromThis<ElementParser>
+{
+ public:
+ class Exception
+ {
+ public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, ParseError)
+ };
+ typedef DPL::FastDelegate0<ElementParserPtr> ActionFunc;
+ typedef std::map<DPL::String, ActionFunc> FuncMap;
+
+ virtual void Accept(const Element&) = 0;
+ virtual void Accept(const XmlAttribute&) = 0;
+ virtual void Accept(const Text&) = 0;
+ virtual void Verify() = 0;
+ virtual ActionFunc GetElementParser(const DPL::String &ns,
+ const DPL::String &name) = 0;
+ virtual ~ElementParser()
+ {
+ }
+
+ protected:
+ ElementParser()
+ {
+ }
+};
+
+#endif // ELEMENT_PARSER_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file ignoring_parser.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef IGNORING_PARSER_H_
+#define IGNORING_PARSER_H_
+
+#include "element_parser.h"
+
+struct IgnoringParser : public ElementParser
+{
+ static ElementParserPtr Create();
+ virtual ActionFunc GetElementParser(const DPL::String& ns,
+ const DPL::String& name);
+ virtual void Accept(const Element&);
+ virtual void Accept(const Text&);
+ virtual void Accept(const XmlAttribute&);
+ virtual void Verify();
+
+ IgnoringParser();
+
+ private:
+ ElementParserPtr Reuse();
+};
+
+#endif // IGNORING_PARSER_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file libiriwrapper.cpp
+ * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com
+ * @version 0.1
+ * @brief Libiri parser wrapper
+ */
+
+#ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
+#define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
+
+#include <iostream>
+#include <iri.h>
+
+//TODO: Design and implement new IRI manager class
+//
+namespace LibIri {
+struct Wrapper
+{
+ Wrapper(const char* aIri);
+ ~Wrapper();
+ iri_t *m_Iri;
+ //! \brief Returns true if iri is valid
+ bool Validate();
+};
+
+std::ostream & operator<<(std::ostream& a_stream,
+ const Wrapper& a_wrapper);
+} //namespace LibIri
+
+#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_LIBIRIWRAPPER_H_
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file parser_runner.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef PARSER_RUNNER_H_
+#define PARSER_RUNNER_H_
+
+#include <string>
+#include <dpl/noncopyable.h>
+#include <dpl/abstract_input.h>
+#include "element_parser.h"
+
+class ParserRunner : private DPL::Noncopyable
+{
+ public:
+ void Parse(const std::string& filename,
+ ElementParserPtr root);
+ void Parse(DPL::AbstractInput *input,
+ ElementParserPtr root);
+
+ ParserRunner();
+ ~ParserRunner();
+
+ private:
+ class Impl;
+ Impl* m_impl;
+};
+
+#endif // PARSER_RUNNER_H_
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file root_parser.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
+#define _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
+
+#include <dpl/log/log.h>
+#include "element_parser.h"
+
+template<typename ta_Parser>
+class RootParser : public ElementParser
+{
+ public:
+ typedef typename ta_Parser::Data Data;
+ virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
+ const DPL::String& name)
+ {
+ if (name == m_tag) {
+ return DPL::MakeDelegate(this,
+ &RootParser<ta_Parser>::OnWidgetElement);
+ } else {
+ ThrowMsg(Exception::ParseError,
+ name << " != " << m_tag);
+ }
+ }
+
+ RootParser(Data data,
+ const DPL::String& tag) :
+ m_data(data),
+ m_tag(tag)
+ {
+ }
+
+ virtual ~RootParser()
+ {
+ }
+
+ virtual void Accept(const Element& /*element*/)
+ {
+ LogDebug("element");
+ }
+
+ virtual void Accept(const XmlAttribute& /*attribute*/)
+ {
+ LogDebug("attribute");
+ }
+
+ virtual void Accept(const Text& /*text*/)
+ {
+ LogDebug("text");
+ }
+
+ virtual void Verify()
+ {
+ LogDebug("");
+ }
+
+ private:
+
+ ElementParserPtr OnWidgetElement()
+ {
+ typedef ta_Parser Parser;
+ return ElementParserPtr(new Parser(this->m_data));
+ }
+
+ Data m_data;
+ const DPL::String& m_tag;
+};
+
+#endif // _WRT_ENGINE_SRC_INSTALLERCORE_CONFIGURATION_PARSER_ROOT_PARSER_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /**
+ * This file have been implemented in compliance with W3C WARP SPEC.
+ * but there are some patent issue between W3C WARP SPEC and APPLE.
+ * so if you want to use this file, refer to the README file in root directory
+ */
+/**
+ * @file widget_parser.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 0.1
+ * @brief
+ */
+#ifndef WIDGET_PARSER_H_
+#define WIDGET_PARSER_H_
+
+#include "element_parser.h"
+#include <list>
+#include <map>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
+
+namespace ConfigurationNamespace {
+static const DPL::String W3CWidgetNamespaceName =
+ L"http://www.w3.org/ns/widgets";
+static const DPL::String WacWidgetNamespaceNameForLinkElement =
+ L"http://wacapps.net/ns/widgets#";
+static const DPL::String WacWidgetNamespaceName =
+ L"http://wacapps.net/ns/widgets";
+static const DPL::String TizenWebAppNamespaceName =
+ L"http://tizen.org/ns/widgets";
+}
+
+namespace PluginsPrefix {
+const char * const W3CPluginsPrefix = "http://www.w3.org/";
+const char * const WACPluginsPrefix = "http://wacapps.net/api/";
+const char * const TIZENPluginsPrefix = "http://tizen.org/api/";
+}
+
+namespace Unicode {
+enum Direction
+{
+ LRE,
+ RLE,
+ LRO,
+ RLO,
+ EMPTY
+};
+}
+
+class WidgetParser : public ElementParser
+{
+ public:
+ ElementParserPtr OnNameElement();
+ ElementParserPtr OnDescriptionElement();
+ ElementParserPtr OnAuthorElement();
+ ElementParserPtr OnLicenseElement();
+ ElementParserPtr OnIconElement();
+ ElementParserPtr OnContentElement();
+ ElementParserPtr OnFeatureElement();
+ ElementParserPtr OnPreferenceElement();
+ ElementParserPtr OnAccessElement();
+ ElementParserPtr OnFlashElement();
+ ElementParserPtr OnLinkElement();
+ ElementParserPtr OnSettingElement();
+ ElementParserPtr OnServiceElement();
+ ElementParserPtr OnApplicationElement();
+ ElementParserPtr OnSplashElement();
+ ElementParserPtr OnBackgroundElement();
+
+ virtual ActionFunc GetElementParser(const DPL::String& ns,
+ const DPL::String& name);
+
+ virtual void Accept(const Element&);
+ virtual void Accept(const Text&);
+ virtual void Accept(const XmlAttribute&);
+ virtual void Verify();
+
+ //Typedef used by RootParser
+ typedef WrtDB::ConfigParserData& Data;
+
+ WidgetParser(Data&);
+
+ private:
+ Data& m_data;
+ Unicode::Direction m_textDirection;
+ FuncMap m_map;
+ DPL::Optional<DPL::String> m_version;
+ DPL::Optional<DPL::String> m_minVersion;
+ std::list<DPL::String> m_windowModes;
+ DPL::Optional<DPL::String> m_defaultlocale;
+ std::map<DPL::String, DPL::String> m_nameSpaces;
+};
+
+struct IconParser;
+struct ContentParser;
+
+#endif // WIDGET_PARSER_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <job.h>
+#include <installer_controller.h>
+
+namespace Jobs {
+Job::Job(InstallationType installType) :
+ m_installationType(installType),
+ m_UndoType(false),
+ m_paused(false)
+{
+}
+
+InstallationType Job::GetInstallationType() const
+{
+ return m_installationType;
+}
+
+bool Job::GetUndoType() const
+{
+ return m_UndoType;
+}
+
+void Job::SetUndoType(bool flag)
+{
+ m_UndoType = flag;
+}
+
+bool Job::IsPaused() const
+{
+ return m_paused;
+}
+
+void Job::SetPaused(bool paused)
+{
+ if (paused) {
+ Pause();
+ } else {
+ Resume();
+ }
+}
+
+void Job::Pause()
+{
+ if (m_paused) {
+ return;
+ }
+
+ // Pause
+ m_paused = true;
+}
+
+void Job::Resume()
+{
+ if (!m_paused) {
+ return;
+ }
+
+ // Continue
+ m_paused = false;
+
+ // Trigger next steps
+ CONTROLLER_POST_EVENT(Logic::InstallerController,
+ InstallerControllerEvents::NextStepEvent(this));
+}
+
+void Job::SetJobHandle(JobHandle handle)
+{
+ m_handle = handle;
+}
+
+JobHandle Job::GetJobHandle() const
+{
+ return m_handle;
+}
+
+void Job::SendProgress()
+{
+}
+
+void Job::SendFinishedSuccess()
+{
+}
+
+void Job::SendFinishedFailure()
+{
+}
+
+void Job::SaveExceptionData(const Jobs::JobExceptionBase&)
+{
+}
+} //namespace Jobs
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef INSTALLER_MODEL_H
+#define INSTALLER_MODEL_H
+
+#include <dpl/task_list.h>
+
+namespace Jobs {
+class JobExceptionBase;
+/**
+ * @brief Defines installation and uninstallation type.
+ */
+enum InstallationType
+{
+ Installation, ///< defines install process
+ Uninstallation, ///< defines uninstall process
+ PluginInstallation ///< defines plugin installation process
+};
+
+typedef int JobHandle;
+
+class Job :
+ public DPL::TaskList
+{
+ public:
+ Job(InstallationType installType);
+
+ InstallationType GetInstallationType() const;
+
+ // Undo
+ void SetUndoType(bool flag);
+ bool GetUndoType() const;
+
+ // Pause/resume support
+ bool IsPaused() const;
+ void SetPaused(bool paused);
+ void Pause();
+ void Resume();
+ void SetJobHandle(JobHandle handle);
+ JobHandle GetJobHandle() const;
+ virtual void SendProgress();
+ virtual void SendFinishedSuccess();
+ virtual void SendFinishedFailure();
+
+ virtual void SaveExceptionData(const Jobs::JobExceptionBase&);
+ private:
+ JobHandle m_handle;
+ InstallationType m_installationType;
+ bool m_UndoType; //TODO change name to m_AbortStarted
+ bool m_paused;
+};
+} //namespace Jobs
+
+#endif // INSTALLER_MODEL_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
+#define SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
+
+#include <string>
+
+typedef std::string ProgressDescription;
+typedef float ProgressPercent;
+
+namespace Jobs {
+template<typename T_InstallationStep,
+ T_InstallationStep lastElement>
+class JobProgressBase
+{
+ protected:
+ bool m_progressFlag;
+ ProgressDescription m_progresDescription;
+ ProgressPercent m_progresPercent;
+
+ public:
+ JobProgressBase() : m_progressFlag(false),
+ m_progresPercent(0.0)
+ {
+ }
+
+ void SetProgressFlag(bool flag)
+ {
+ m_progressFlag = flag;
+ }
+ bool GetProgressFlag() const
+ {
+ return m_progressFlag;
+ }
+
+ ProgressDescription GetProgressDescription() const
+ {
+ return m_progresDescription;
+ }
+
+ ProgressPercent GetProgressPercent() const
+ {
+ return m_progresPercent;
+ }
+
+ void UpdateProgress(T_InstallationStep step,
+ ProgressDescription const &description)
+ {
+ m_progresPercent =
+ ((static_cast<ProgressPercent>(step) + 1.0) /
+ static_cast<ProgressPercent>(lastElement)) * 100;
+ m_progresDescription = description;
+ }
+};
+
+template<class T_JobStruct>
+class JobContextBase
+{
+ public:
+ JobContextBase(const T_JobStruct& jobStruct) :
+ m_jobStruct(jobStruct)
+ {
+ }
+
+ T_JobStruct getInstallerStruct() const
+ {
+ return m_jobStruct;
+ } //TODO RENAME
+
+ protected:
+ T_JobStruct m_jobStruct;
+};
+
+template<typename T_finishedCb, typename T_progressCb>
+struct JobCallbacksBase
+{
+ T_finishedCb finishedCallback;
+ T_progressCb progressCallback;
+ void *userParam;
+
+ // It must be empty-constructible as a parameter of generic event
+ JobCallbacksBase() :
+ finishedCallback(0),
+ progressCallback(0),
+ userParam(0)
+ {
+ }
+
+ JobCallbacksBase(T_finishedCb finished,
+ T_progressCb progress,
+ void *param) :
+ finishedCallback(finished),
+ progressCallback(progress),
+ userParam(param)
+ {
+ }
+};
+} //namespace Jobs
+
+#endif // SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file job_exception_base.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#include <dpl/exception.h>
+
+#ifndef SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
+#define SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_
+
+#define DECLARE_JOB_EXCEPTION_BASE(Base, Class, Param) \
+ class Class : \
+ public Base { \
+ public: \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const std::string & message = std::string()) : \
+ Base(path, function, line, message) \
+ { \
+ m_className = # Class; \
+ m_param = Param; \
+ } \
+ \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const Exception &reason, \
+ const std::string & message = std::string()) : \
+ Base(path, function, line, reason, message) \
+ { \
+ m_className = # Class; \
+ m_param = Param; \
+ } \
+ \
+ virtual int getParam() const \
+ { \
+ return m_param; \
+ } \
+ protected: \
+ int m_param; \
+ };
+//TODO template for m_param
+
+#define DECLARE_JOB_EXCEPTION(Base, Class, Param) \
+ class Class : \
+ public Base { \
+ public: \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const std::string & message = std::string()) : \
+ Base(path, function, line, message) \
+ { \
+ m_className = # Class; \
+ m_param = Param; \
+ } \
+ \
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const Exception &reason, \
+ const std::string & message = std::string()) : \
+ Base(path, function, line, reason, message) \
+ { \
+ m_className = # Class; \
+ m_param = Param; \
+ } \
+ \
+ virtual int getParam() const \
+ { \
+ return m_param; \
+ } \
+ };
+//TODO template for m_param
+
+//TODO maybe use DPL:: DECLARE_EXCEPTION_TYPE instead of creating own
+
+namespace Jobs {
+DECLARE_JOB_EXCEPTION_BASE(DPL::Exception, JobExceptionBase, 0)
+}
+
+#endif /* SRC_INSTALLER_CORE_JOBS_JOB_EXCEPTION_BASE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file job_plugin_install.cpp
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+#include <plugin_install/job_plugin_install.h>
+#include <plugin_install/plugin_install_task.h>
+#include <widget_install/widget_installer_struct.h> //TODO remove
+
+//#include <plugin_logic.h>
+#include "plugin_objects.h"
+
+namespace Jobs {
+namespace PluginInstall {
+JobPluginInstall::JobPluginInstall(std::string const &pluginPath,
+ const PluginInstallerStruct &installerStruct) :
+ Job(PluginInstallation),
+ JobContextBase<PluginInstallerStruct>(installerStruct)
+{
+ //
+ // Init installer context
+ //
+ m_context.pluginFilePath = pluginPath;
+ m_context.pluginHandle = INVALID_HANDLE;
+ m_context.installationCompleted = false;
+
+ m_context.installerTask = this;
+ //
+ // Create main installation tasks
+ //
+ AddTask(new PluginInstallTask(&m_context));
+}
+
+void JobPluginInstall::SendProgress()
+{
+ if (GetProgressFlag() && getInstallerStruct().progressCallback != NULL) {
+ LogDebug("Call Plugin install progressCallback");
+ getInstallerStruct().progressCallback(getInstallerStruct().userParam,
+ GetProgressPercent(), GetProgressDescription());
+ }
+}
+
+void JobPluginInstall::SendFinishedSuccess()
+{
+ PluginHandle handle = getNewPluginHandle();
+
+ if (handle != Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE &&
+ isReadyToInstall())
+ {
+ LogDebug("Call Plugin install success finishedCallback");
+ getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
+ Exceptions::Success);
+ } else {
+ LogDebug("Call Plugin install waiting finishedCallback");
+ getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
+ Exceptions::InstallationWaiting);
+
+ LogInfo("Installation: " << getFilePath() <<
+ " NOT possible");
+ }
+}
+
+void JobPluginInstall::SendFinishedFailure()
+{
+ LogError("Error in plugin installation step: " << m_exceptionCaught);
+ LogError("Message: " << m_exceptionMessage);
+
+ LogDebug("Call Plugin install failure finishedCallback");
+ getInstallerStruct().finishedCallback(getInstallerStruct().userParam,
+ m_exceptionCaught);
+}
+
+void JobPluginInstall::SaveExceptionData(const Jobs::JobExceptionBase &e)
+{
+ m_exceptionCaught = static_cast<Exceptions::Type>(e.getParam());
+ m_exceptionMessage = e.GetMessage();
+}
+} //namespace Jobs
+} //namespace PluginInstall
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file job_plugin_install.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
+#define WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_
+
+//SYSTEM INCLUDES
+#include <string>
+
+//WRT INCLUDES
+#include <job.h>
+#include <job_base.h>
+#include <plugin_install/plugin_installer_struct.h>
+#include <plugin_install/plugin_installer_context.h>
+
+namespace Jobs {
+namespace PluginInstall {
+class JobPluginInstall :
+ public Job,
+ public JobProgressBase<PluginInstallerContext::PluginInstallStep,
+ PluginInstallerContext::PLUGIN_INSTALL_END>,
+ public JobContextBase<PluginInstallerStruct>
+{
+ public:
+ static const WrtDB::DbPluginHandle INVALID_HANDLE = -1;
+
+ public:
+ /**
+ * @brief Automaticaly sets installation process
+ */
+ JobPluginInstall(std::string const &pluginPath,
+ const PluginInstallerStruct &installerStruct);
+
+ WrtDB::DbPluginHandle getNewPluginHandle() const
+ {
+ return m_context.pluginHandle;
+ }
+ std::string getFilePath() const
+ {
+ return m_context.pluginFilePath;
+ }
+ bool isReadyToInstall() const
+ {
+ return m_context.installationCompleted;
+ }
+
+ void SendProgress();
+ void SendFinishedSuccess();
+ void SendFinishedFailure();
+ void SaveExceptionData(const Jobs::JobExceptionBase &e);
+ private:
+ //TODO move somewhere this attribute
+ //(as it is in all Jobs...)
+ PluginInstallerContext m_context;
+
+ //TODO move it to base class of all jobs
+ //maybe separate JobBase class for this?
+ Exceptions::Type m_exceptionCaught;
+ std::string m_exceptionMessage;
+};
+} //namespace Jobs
+} //namespace PluginInstall
+
+#endif /* WRT_SRC_INSTALLER_CORE_JOB_JOB_PLUGIN_INSTALL_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file install_one_task.cpp
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+//SYSTEM INCLUDES
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dlfcn.h>
+
+//WRT INCLUDES
+#include <dpl/log/log.h>
+#include <dpl/foreach.h>
+#include <job.h>
+#include "plugin_install_task.h"
+#include "job_plugin_install.h"
+#include "plugin_installer_errors.h"
+#include "plugin_metafile_reader.h"
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <wrt_common_types.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+#include <dpl/wrt-dao-rw/plugin_dao.h>
+#include "plugin_objects.h"
+
+#include <PluginRegistry.h>
+#include <Plugin.h>
+#include <IObject_cast.h>
+#include <SoFeatures.h>
+#include <ExportedApi.h>
+
+using namespace WrtDB;
+using namespace WrtPluginsApi;
+
+namespace {
+const std::string DIRECTORY_SEPARATOR = std::string("/");
+}
+
+#define SET_PLUGIN_INSTALL_PROGRESS(step, desc) \
+ m_context->installerTask->UpdateProgress( \
+ PluginInstallerContext::step, desc);
+
+#define DISABLE_IF_PLUGIN_WITHOUT_LIB() \
+ if(m_pluginInfo.m_libraryName.empty()) \
+ { \
+ LogWarning("Plugin without library."); \
+ return; \
+ }
+
+namespace Jobs {
+namespace PluginInstall {
+
+PluginInstallTask::PluginInstallTask(PluginInstallerContext *inCont) :
+ DPL::TaskDecl<PluginInstallTask>(this),
+ m_context(inCont),
+ m_dataFromConfigXML(true)
+{
+ AddStep(&PluginInstallTask::stepCheckPluginPath);
+ AddStep(&PluginInstallTask::stepParseConfigFile);
+ AddStep(&PluginInstallTask::stepFindPluginLibrary);
+ AddStep(&PluginInstallTask::stepCheckIfAlreadyInstalled);
+ AddStep(&PluginInstallTask::stepLoadPluginLibrary);
+ AddStep(&PluginInstallTask::stepRegisterPlugin);
+ AddStep(&PluginInstallTask::stepRegisterFeatures);
+ AddStep(&PluginInstallTask::stepRegisterPluginObjects);
+ AddStep(&PluginInstallTask::stepResolvePluginDependencies);
+
+ SET_PLUGIN_INSTALL_PROGRESS(START, "Installation initialized");
+}
+
+PluginInstallTask::~PluginInstallTask()
+{
+}
+
+void PluginInstallTask::stepCheckPluginPath()
+{
+ LogInfo("Plugin installation: step CheckPluginPath");
+
+ struct stat tmp;
+
+ if (-1 == stat(m_context->pluginFilePath.c_str(), &tmp)) {
+ ThrowMsg(Exceptions::PluginPathFailed,
+ "Stat function failed");
+ }
+
+ if (!S_ISDIR(tmp.st_mode)) {
+ ThrowMsg(Exceptions::PluginPathFailed,
+ "Invalid Directory");
+ }
+
+ SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_PATH, "Path to plugin verified");
+}
+
+void PluginInstallTask::stepParseConfigFile()
+{
+ LogInfo("Plugin installation: step parse config file");
+
+ struct stat tmp;
+
+ std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
+ std::string(GlobalConfig::GetPluginMetafileName());
+
+ if (-1 == stat(filename.c_str(), &tmp)) {
+ m_dataFromConfigXML = false;
+ return;
+ }
+
+ LogInfo("Plugin Config file::" << filename);
+
+ Try
+ {
+ PluginMetafileReader reader;
+ reader.initialize(filename);
+ reader.read(m_pluginInfo);
+
+ FOREACH(it, m_pluginInfo.m_featureContainer)
+ {
+ LogDebug("Parsed feature : " << it->m_name);
+ FOREACH (devCap, it->m_deviceCapabilities) {
+ LogDebug(" | DevCap : " << *devCap);
+ }
+ }
+
+ SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_PATH, "Config file analyzed");
+ }
+ Catch(ValidationCore::ParserSchemaException::Base)
+ {
+ LogError("Error during file processing " << filename);
+ ThrowMsg(Exceptions::PluginMetafileFailed,
+ "Metafile error");
+ }
+}
+
+void PluginInstallTask::stepFindPluginLibrary()
+{
+ if (m_dataFromConfigXML)
+ {
+ return;
+ }
+ LogDebug("Plugin installation: step find plugin library");
+ std::string pluginPath = m_context->pluginFilePath;
+ size_t indexpos = pluginPath.find_last_of('/');
+
+ if (std::string::npos == indexpos)
+ {
+ indexpos = 0;
+ }
+ else
+ {
+ indexpos += 1; // move after '/'
+ }
+
+ std::string libName = pluginPath.substr(indexpos);
+ libName = GlobalConfig::GetPluginPrefix() + libName + GlobalConfig::GetPluginSuffix();
+ LogDebug("Plugin .so: " << libName);
+ m_pluginInfo.m_libraryName = libName;
+}
+
+void PluginInstallTask::stepCheckIfAlreadyInstalled()
+{
+ if (PluginDAO::isPluginInstalled(m_pluginInfo.m_libraryName)) {
+ ThrowMsg(Exceptions::PluginAlreadyInstalled,
+ "Plugin already installed");
+ }
+
+ SET_PLUGIN_INSTALL_PROGRESS(PLUGIN_EXISTS_CHECK, "Check if plugin exist");
+}
+
+void PluginInstallTask::stepLoadPluginLibrary()
+{
+ LogInfo("Plugin installation: step load library");
+
+ DISABLE_IF_PLUGIN_WITHOUT_LIB()
+
+ std::string filename = m_context->pluginFilePath + DIRECTORY_SEPARATOR +
+ m_pluginInfo.m_libraryName;
+
+ LogDebug("Loading plugin: " << filename);
+
+ void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
+ if (dlHandle == NULL ) {
+ LogError(
+ "Failed to load plugin: " << filename <<
+ ". Reason: " << dlerror());
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ //TODO move it out
+ PluginRegistry registry;
+
+ Plugin* plugin;
+
+ Try{
+ plugin = registry.GetPlugin(filename);
+ }
+ Catch(DPL::Exception)
+ {
+ LogError("Loading library failed " << filename);
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ if(!plugin)
+ {
+ LogError("Failed to open library" << filename);
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ m_libraryObjects = PluginObjectsPtr(new PluginObjects());
+
+ LogInfo("#####");
+ LogInfo("##### Plugin: " << filename << " supports new plugin API");
+ LogInfo("#####");
+
+ FOREACH(o, *plugin->GetObjects())
+ {
+ m_libraryObjects->addObjects(CAST(*o)->GetParentName(),
+ CAST(*o)->GetName());
+
+ LogDebug("[Parent << Object] " << CAST(*o)->GetParentName()
+ << " << "
+ << CAST(*o)->GetName());
+
+ registerObjects(plugin->GetObjects());
+ }
+
+
+ if (!m_dataFromConfigXML)
+ {
+ ExportedApi* entryPoint =
+ static_cast<ExportedApi*>(dlsym(dlHandle, GetExportedSymbolName()));
+ if (NULL == entryPoint)
+ {
+ LogError("Error: " << dlerror());
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ // obtain feature -> dev-cap mapping
+ feature_mapping_interface_t mappingInterface = { NULL, NULL, NULL };
+ entryPoint->GetProvidedFeatures(&mappingInterface);
+
+ if (!mappingInterface.featGetter || !mappingInterface.release ||
+ !mappingInterface.dcGetter)
+ {
+ LogError("Failed to obtain mapping interface from .so");
+ ThrowMsg(Exceptions::PluginLibraryError, "Library error");
+ }
+
+ feature_mapping_t* devcapMapping = mappingInterface.featGetter();
+
+ LogDebug("Getting mapping from features to device capabilities");
+
+ for (size_t i = 0; i < devcapMapping->featuresCount; ++i)
+ {
+ PluginMetafileData::Feature feature;
+ feature.m_name = devcapMapping->features[i].feature_name;
+
+ LogDebug("Feature: " << feature.m_name);
+
+ const devcaps_t* dc =
+ mappingInterface.dcGetter(devcapMapping,
+ devcapMapping->features[i].feature_name);
+
+ LogDebug("device=cap: " << dc);
+
+ if (dc)
+ {
+ LogDebug("devcaps count: " << dc->devCapsCount);
+
+ for (size_t j = 0; j < dc->devCapsCount; ++j)
+ {
+ LogDebug("devcap: " << dc->deviceCaps[j]);
+ feature.m_deviceCapabilities.insert(dc->deviceCaps[j]);
+ }
+ }
+
+ m_pluginInfo.m_featureContainer.insert(feature);
+ }
+
+ mappingInterface.release(devcapMapping);
+ }
+
+ // Unload library
+ if (dlclose(dlHandle) != 0) {
+ LogError("Cannot close plugin handle");
+ } else {
+ LogDebug("Library is unloaded");
+ }
+
+ // Load export table
+ LogDebug("Library successfuly loaded and parsed");
+
+ SET_PLUGIN_INSTALL_PROGRESS(LOADING_LIBRARY, "Library loaded and analyzed");
+}
+
+void PluginInstallTask::stepRegisterPlugin()
+{
+ LogInfo("Plugin installation: step register Plugin");
+
+ m_pluginHandle =
+ PluginDAO::registerPlugin(m_pluginInfo, m_context->pluginFilePath);
+
+ SET_PLUGIN_INSTALL_PROGRESS(REGISTER_PLUGIN, "Plugin registered");
+}
+
+void PluginInstallTask::stepRegisterFeatures()
+{
+ LogInfo("Plugin installation: step register features");
+
+ FOREACH(it, m_pluginInfo.m_featureContainer)
+ {
+ LogError("PluginHandle: " << m_pluginHandle);
+ FeatureDAO::RegisterFeature(*it, m_pluginHandle);
+ }
+ SET_PLUGIN_INSTALL_PROGRESS(REGISTER_FEATURES, "Features registered");
+}
+
+void PluginInstallTask::stepRegisterPluginObjects()
+{
+ LogInfo("Plugin installation: step register objects");
+
+ DISABLE_IF_PLUGIN_WITHOUT_LIB()
+
+ //register implemented objects
+ PluginObjects::ObjectsPtr objects =
+ m_libraryObjects->getImplementedObject();
+
+ FOREACH(it, *objects)
+ {
+ PluginDAO::registerPluginImplementedObject(*it, m_pluginHandle);
+ }
+
+ //register requiredObjects
+ objects = m_libraryObjects->getDependentObjects();
+
+ FOREACH(it, *objects)
+ {
+ if (m_libraryObjects->hasObject(*it)) {
+ LogDebug("Dependency from the same library. ignored");
+ continue;
+ }
+
+ PluginDAO::registerPluginRequiredObject(*it, m_pluginHandle);
+ }
+
+ SET_PLUGIN_INSTALL_PROGRESS(REGISTER_OBJECTS, "Plugin Objects registered");
+}
+
+void PluginInstallTask::stepResolvePluginDependencies()
+{
+ LogInfo("Plugin installation: step resolve dependencies ");
+
+ //DISABLE_IF_PLUGIN_WITHOUT_LIB
+ if(m_pluginInfo.m_libraryName.empty())
+ {
+ PluginDAO::setPluginInstallationStatus(m_pluginHandle,
+ PluginDAO::INSTALLATION_COMPLETED);
+ //Installation completed
+ m_context->pluginHandle = m_pluginHandle;
+ m_context->installationCompleted = true;
+ LogWarning("Plugin without library.");
+ return;
+ }
+
+ PluginHandleSetPtr handles = PluginHandleSetPtr(new PluginHandleSet);
+
+ DbPluginHandle handle = INVALID_PLUGIN_HANDLE;
+
+ //register requiredObjects
+ FOREACH(it, *(m_libraryObjects->getDependentObjects()))
+ {
+ if (m_libraryObjects->hasObject(*it)) {
+ LogDebug("Dependency from the same library. ignored");
+ continue;
+ }
+
+ handle = PluginDAO::getPluginHandleForImplementedObject(*it);
+ if (handle == INVALID_PLUGIN_HANDLE) {
+ LogError("Library implementing: " << *it << " NOT FOUND");
+ PluginDAO::setPluginInstallationStatus(
+ m_pluginHandle,
+ PluginDAO::INSTALLATION_WAITING);
+ return;
+ }
+
+ handles->insert(handle);
+ }
+
+ PluginDAO::registerPluginLibrariesDependencies(m_pluginHandle, handles);
+
+ PluginDAO::setPluginInstallationStatus(m_pluginHandle,
+ PluginDAO::INSTALLATION_COMPLETED);
+
+ //Installation completed
+ m_context->pluginHandle = m_pluginHandle;
+ m_context->installationCompleted = true;
+
+ SET_PLUGIN_INSTALL_PROGRESS(RESOLVE_DEPENDENCIES, "Dependencies resolved");
+}
+
+void PluginInstallTask::registerObjects(const IObjectsListPtr& objects)
+{
+ LogDebug("registerObjects invoked");
+
+ FOREACH(o, *objects)
+ {
+ auto children = CAST(*o)->GetChildren();
+
+ if(children)
+ {
+ FOREACH(c, *children)
+ {
+ m_libraryObjects->addObjects(CAST(*o)->GetName(),
+ CAST(*c)->GetName());
+
+ LogDebug("[Parent << Object] " << CAST(*c)->GetName()
+ << " << "
+ << CAST(*o)->GetName());
+ }
+
+ registerObjects(children);
+ }
+ }
+}
+
+#undef SET_PLUGIN_INSTALL_PROGRESS
+} //namespace Jobs
+} //namespace PluginInstall
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file install.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef INSTALL_H_
+#define INSTALL_H_
+
+//WRT INCLUDES
+#include <dpl/task.h>
+#include "plugin_installer_context.h"
+#include "plugin_objects.h"
+#include <IObject.h>
+
+namespace Jobs {
+namespace PluginInstall {
+class PluginInstallTask :
+ public DPL::TaskDecl<PluginInstallTask>
+{
+ public:
+ PluginInstallTask(PluginInstallerContext *inCont);
+ virtual ~PluginInstallTask();
+
+ private:
+ //data
+ PluginInstallerContext *m_context;
+
+ //PluginMetafile
+ WrtDB::PluginMetafileData m_pluginInfo;
+
+ //Plugin LibraryObjects
+ PluginObjectsPtr m_libraryObjects;
+
+ WrtDB::DbPluginHandle m_pluginHandle;
+
+ bool m_dataFromConfigXML;
+
+ //steps
+ void stepCheckPluginPath();
+ void stepFindPluginLibrary();
+ void stepParseConfigFile();
+ void stepCheckIfAlreadyInstalled();
+ void stepLoadPluginLibrary();
+ void stepRegisterPlugin();
+ void stepRegisterFeatures();
+ void stepRegisterPluginObjects();
+ void stepResolvePluginDependencies();
+
+ void registerObjects(const WrtPluginsApi::IObjectsListPtr& objects);
+};
+} //namespace Jobs
+} //namespace PluginInstall
+
+#endif /* INSTALL_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file plugin_installer_structs.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief Definition file of plugin installer tasks data structures
+ */
+#ifndef WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
+#define WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
+
+#include <string>
+#include <dpl/wrt-dao-ro/feature_dao_read_only.h>
+//#include <plugin_model.h>
+
+using namespace WrtDB;
+
+namespace Jobs {
+namespace PluginInstall {
+class JobPluginInstall;
+}
+}
+
+struct PluginInstallerContext
+{
+ enum PluginInstallStep
+ {
+ START,
+ PLUGIN_PATH,
+ CONFIG_FILE,
+ PLUGIN_EXISTS_CHECK,
+ LOADING_LIBRARY,
+ REGISTER_PLUGIN,
+ REGISTER_FEATURES,
+ REGISTER_OBJECTS,
+ RESOLVE_DEPENDENCIES,
+ PLUGIN_INSTALL_END
+ };
+
+ std::string pluginFilePath; ///< plugin directory
+ WrtDB::DbPluginHandle pluginHandle;
+ // if this value is true the plugin model may be created
+ // if not plugin installation has failed from some reason
+ bool installationCompleted;
+
+ //used to set installation progress
+ Jobs::PluginInstall::JobPluginInstall* installerTask;
+};
+
+#endif // WRT_SRC_INSTALLERCORE_PLUGININSTALLERTASKS_PLUGININSTALLERCONTEXT_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_installer_errors.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef \
+ WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
+#define \
+ WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_
+
+#include <job_exception_base.h>
+
+namespace Jobs {
+namespace PluginInstall {
+namespace Exceptions {
+enum Type
+{
+ Success, ///< Success
+
+ WrongPluginPath, ///< ?
+ MetafileError, ///< ?
+ AlreadyInstalled, ///< ?
+ LoadingLibraryError, ///< Loading library by dlopen failed.
+ /// It may be caused by missing symbols
+ InstallationWaiting, /// Installation failed due to dependencies
+ Unknown ///< Temporary error. Try to not use this.
+};
+
+DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, Unknown)
+DECLARE_JOB_EXCEPTION(Base, PluginPathFailed, WrongPluginPath)
+DECLARE_JOB_EXCEPTION(Base, PluginMetafileFailed, MetafileError)
+DECLARE_JOB_EXCEPTION(Base, PluginAlreadyInstalled, AlreadyInstalled)
+DECLARE_JOB_EXCEPTION(Base, PluginLibraryError, LoadingLibraryError)
+DECLARE_JOB_EXCEPTION(Base, InstallationWaitingError, InstallationWaiting)
+DECLARE_JOB_EXCEPTION(Base, UnknownError, Unknown)
+} //namespace
+} //namespace
+} //namespace
+
+#endif /* WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_INSTALLER_ERRORS_H_ */
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_installer_struct.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for widget installer struct
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
+#define WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
+
+#include <job_base.h>
+#include <plugin_install/plugin_installer_errors.h>
+
+//Plugin Installer typedefs
+typedef void (*PluginInstallerFinishedCallback)(
+ void *userParam,
+ Jobs::PluginInstall::Exceptions::Type);
+
+//installer progress
+typedef void (*PluginInstallerProgressCallback)(
+ void *userParam,
+ ProgressPercent percent,
+ const ProgressDescription &description);
+
+//Plugin Installetion Struct
+typedef Jobs::JobCallbacksBase<PluginInstallerFinishedCallback,
+ PluginInstallerProgressCallback>
+PluginInstallerStruct;
+
+#endif // WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_PLUGIN_INSTALLER_STRUCT_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_metafile_reader.cpp
+ * @author Grzegorz Krawczyk(g.krawczyk@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "plugin_metafile_reader.h"
+
+using namespace WrtDB;
+
+namespace {
+const std::string XML_NAMESPACE = "";
+
+const std::string TOKEN_LIBRARY_NAME = "library-name";
+const std::string TOKEN_API_FEATURE = "api-feature";
+const std::string TOKEN_NAME = "name";
+const std::string TOKEN_DEVICECAPABILITY = "device-capability";
+}
+
+PluginMetafileReader::PluginMetafileReader() : m_parserSchema(this)
+{
+ m_parserSchema.addEndTagCallback(
+ TOKEN_LIBRARY_NAME,
+ XML_NAMESPACE,
+ &PluginMetafileReader::tokenEndLibraryName);
+
+ m_parserSchema.addEndTagCallback(
+ TOKEN_API_FEATURE,
+ XML_NAMESPACE,
+ &PluginMetafileReader::tokenEndApiFeature);
+
+ m_parserSchema.addEndTagCallback(
+ TOKEN_NAME,
+ XML_NAMESPACE,
+ &PluginMetafileReader::tokenEndName);
+
+ m_parserSchema.addEndTagCallback(
+ TOKEN_DEVICECAPABILITY,
+ XML_NAMESPACE,
+ &PluginMetafileReader::tokenEndDeviceCapability);
+}
+
+void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
+{
+}
+
+void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
+{
+ data.m_libraryName = m_parserSchema.getText();
+}
+
+void PluginMetafileReader::tokenEndApiFeature(PluginMetafileData &data)
+{
+ data.m_featureContainer.insert(m_feature);
+ m_feature.m_deviceCapabilities.clear();
+}
+
+void PluginMetafileReader::tokenEndName(PluginMetafileData & /* data */)
+{
+ m_feature.m_name = m_parserSchema.getText();
+}
+
+void PluginMetafileReader::tokenEndDeviceCapability(PluginMetafileData& /*data*/)
+{
+ m_feature.m_deviceCapabilities.insert(m_parserSchema.getText());
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_metafile_reader.h
+ * @author Grzegorz Krawczyk(g.krawczyk@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_METAFILE_READER_H_
+#define WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_METAFILE_READER_H_
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <vcore/ParserSchema.h>
+
+class PluginMetafileReader
+{
+ public:
+ PluginMetafileReader();
+
+ void initialize(const std::string &filename)
+ {
+ m_parserSchema.initialize(filename,
+ true,
+ ValidationCore::SaxReader::VALIDATION_DTD,
+ std::string());
+ }
+
+ void read(WrtDB::PluginMetafileData &data)
+ {
+ m_parserSchema.read(data);
+ }
+
+ private:
+ void blankFunction(WrtDB::PluginMetafileData &data);
+
+ void tokenEndLibraryName(WrtDB::PluginMetafileData &data);
+ void tokenEndApiFeature(WrtDB::PluginMetafileData &data);
+ void tokenEndName(WrtDB::PluginMetafileData &data);
+ void tokenEndDeviceCapability(WrtDB::PluginMetafileData &data);
+
+ WrtDB::PluginMetafileData::Feature m_feature;
+
+ ValidationCore::ParserSchema<PluginMetafileReader,
+ WrtDB::PluginMetafileData> m_parserSchema;
+};
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_objects.h
+ * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
+ * @version
+ * @brief
+ */
+#include <string>
+#include <dpl/log/log.h>
+#include "plugin_objects.h"
+#include <IObject.h>
+
+namespace {
+const char* SEPARATOR = ".";
+const std::string GLOBAL_OBJECT_NAME = WrtPluginsApi::IObject::WINDOW_OBJECT();
+
+std::string normalizeName(const std::string& objectName)
+{
+ if (objectName.empty()) {
+ LogError("Normalize name, name size is 0");
+ return objectName;
+ }
+
+ if (!objectName.compare(0, GLOBAL_OBJECT_NAME.size(),
+ GLOBAL_OBJECT_NAME)) {
+ return objectName;
+ }
+
+ //each object in storage has name started from $GLOBAL_OBJECT_NAME$
+ return GLOBAL_OBJECT_NAME + std::string(SEPARATOR) + objectName;
+}
+
+std::string normalizeName(const std::string& objectName,
+ const std::string& parentName)
+{
+ if (objectName.empty() || parentName.empty()) {
+ LogError("Normalize name, name size or parent name size is 0");
+ return std::string();
+ }
+
+ std::string normalizedName;
+ normalizedName = normalizeName(parentName) +
+ std::string(SEPARATOR) + objectName;
+
+ return normalizedName;
+}
+}
+
+PluginObjects::PluginObjects()
+{
+ m_implemented = ObjectsPtr(new Objects());
+ m_dependent = ObjectsPtr(new Objects());
+}
+
+PluginObjects::ObjectsPtr PluginObjects::getImplementedObject() const
+{
+ return m_implemented;
+}
+
+PluginObjects::ObjectsPtr PluginObjects::getDependentObjects() const
+{
+ return m_dependent;
+}
+
+void PluginObjects::addObjects(const std::string& parentName,
+ const std::string& name)
+{
+ LogDebug("\n Parent: " << parentName
+ << "\n Name: " << name
+ << "\n After: Implemented: " << normalizeName(name, parentName)
+ << "\n After Dependent: " << normalizeName(parentName)
+ );
+
+ addImplementedObject(normalizeName(name, parentName));
+ addDependentObject(normalizeName(parentName));
+}
+
+void PluginObjects::addDependentObject(const std::string& value)
+{
+ if (!value.compare(GLOBAL_OBJECT_NAME)) {
+ //dont add dependency to GLOBAL_OBJECT
+ return;
+ }
+ m_dependent->insert(value);
+}
+
+bool PluginObjects::hasObject(const std::string& name) const
+{
+ return m_implemented->find(name) != m_implemented->end();
+}
+
+void PluginObjects::addImplementedObject(const std::string& value)
+{
+ m_implemented->insert(value);
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin_objects.h
+ * @author Grzegorz Krawczyk(g.krawczyk@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_OBJECTS_H_
+#define WRT_SRC_INSTALLER_CORE_PLUGIN_INSTALLER_TASKS_PLUGIN_OBJECTS_H_
+
+#include <dpl/shared_ptr.h>
+#include <string>
+#include <set>
+#include <list>
+
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+//TODO TO BE MOVED SOMEWHERE ELSE
+// AS OTHER MODULES (LIKE DAO) USE IT
+
+class PluginObjects : public WrtDB::PluginObjectsDAO
+{
+ public:
+ explicit PluginObjects();
+
+ //getters for objects from library
+ ObjectsPtr getImplementedObject() const;
+ ObjectsPtr getDependentObjects() const;
+
+ //add object declaration
+ void addObjects(const std::string& parentName,
+ const std::string& name);
+
+ //check if library implemements object given as name
+ bool hasObject(const std::string& name) const;
+
+ private:
+ void addImplementedObject(const std::string& value);
+ void addDependentObject(const std::string& value);
+};
+
+typedef DPL::SharedPtr<PluginObjects> PluginObjectsPtr;
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file installer_errors.h
+ * @author Pawel Sikorski (p.sikorski@samgsung.com)
+ * @version
+ * @brief
+ */
+
+#ifndef INSTALLER_ERRORS_H_
+#define INSTALLER_ERRORS_H_
+
+#include <dpl/exception.h>
+#include <job_exception_base.h>
+
+//TODO SafeException(...)
+
+namespace Jobs {
+namespace WidgetInstall {
+namespace Exceptions {
+enum Type
+{
+ Success, ///< Success
+
+ ErrorInvalidWidgetPackage, ///< ?
+ ErrorWidgetDoesNotExist, ///< ?
+ ErrorFactoryWidget, ///< Widget is factory installed, and cannot be uninstalled
+ ErrorAreadyUninstalling, ///< Widget is already being uninstalled
+ ErrorOutOfDiskSpace, ///< ?
+ ErrorInvalidPackage, ///< Widget signature is invalid.
+ ErrorAlreadyInstalled, ///< ?
+ ErrorInternal, ///< ?
+ ErrorNotAllowed, ///< Widget installation or update not allowed
+ ///< because violation of policy ocurred
+ ErrorDeferred, ///< Widget installation was deferred and will be continued when possible
+ ErrorDatabaseFailure, ///< Failure in database
+ ErrorRemovingFolderFailure, ///< Failure in removing existing widget folder
+ ErrorInstallOspServcie, ///< Failure in installing osp service
+ ErrorUpdateWidget, ///< Failure in widget update.
+ ErrorUnknown ///< Temporary error. Try to not use this.
+};
+
+DECLARE_JOB_EXCEPTION_BASE(JobExceptionBase, Base, ErrorUnknown)
+
+// PREPARE
+DECLARE_JOB_EXCEPTION(Base, NotAllowed, ErrorNotAllowed)
+DECLARE_JOB_EXCEPTION(Base, Deferred, ErrorDeferred)
+DECLARE_JOB_EXCEPTION(Base, InvalidWidgetUrl, ErrorInvalidWidgetPackage)
+
+//UNZIP
+DECLARE_JOB_EXCEPTION(Base, OpenZipFailed, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, GetZipGlobalInfoFailed, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, ZipEmpty, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, GetZippedFileInfoFailed, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, ZippedFileVersionTooNew, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, OutOfDiskSpace, ErrorOutOfDiskSpace)
+DECLARE_JOB_EXCEPTION(Base, InternalError, ErrorInternal)
+
+//CERTIFY
+DECLARE_JOB_EXCEPTION(Base, InvalidPackage, ErrorInvalidPackage)
+
+//WCONFIG
+DECLARE_JOB_EXCEPTION(Base, WidgetConfigFileInvalid, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, NotInstalled, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, InstallationFailed, ErrorInvalidWidgetPackage)
+DECLARE_JOB_EXCEPTION(Base, AlreadyInstalled, ErrorAlreadyInstalled)
+DECLARE_JOB_EXCEPTION(Base, UnknownError, ErrorUnknown)
+DECLARE_JOB_EXCEPTION(Base, DatabaseFailure, ErrorDatabaseFailure)
+DECLARE_JOB_EXCEPTION(Base, RemovingFolderFailure, ErrorRemovingFolderFailure)
+
+DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorUnknown)
+
+// Installation osp service
+DECLARE_JOB_EXCEPTION(Base, RequestInstallOspsvc, ErrorInstallOspServcie)
+DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
+//UPDATE
+DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, InsertNewWidgetFailed, ErrorUpdateWidget)
+DECLARE_JOB_EXCEPTION(Base, RemoveBackupFailed, ErrorUpdateWidget)
+} //namespace
+} //namespace
+} //namespace
+
+#endif /* INSTALLER_ERRORS_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file widget_installer_struct.h
+ * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
+ * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
+ * @version 1.0
+ * @brief Implementation file for widget installer struct
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
+#define WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
+
+//SYSTEM INCLUDES
+#include <dpl/assert.h>
+
+//WRT INCLUDES
+#include <job_base.h>
+#include <job.h>
+#include <widget_install/widget_install_errors.h>
+#include <wrt_common_types.h>
+
+//Widget Installer typedefs
+typedef void (*InstallerFinishedCallback)(
+ void *userParam,
+ WidgetHandle,
+ Jobs::WidgetInstall::Exceptions::Type);
+
+typedef void (*InstallerProgressCallback)(void *userParam,
+ ProgressPercent percent,
+ const ProgressDescription &);
+
+namespace WidgetUpdateMode {
+enum Type
+{
+ Zero = 0,
+
+ // Bits
+ NotInstalled = 1 << 0,
+ IncomingVersionNotStd = 1 << 1,
+ ExistingVersionNotStd = 1 << 2,
+ BothVersionsNotStd = 1 << 3,
+ ExistingVersionOlder = 1 << 4,
+ ExistingVersionEqual = 1 << 5,
+ ExistingVersionNewer = 1 << 6,
+
+ // Policies
+ PolicyNeverUpdate = NotInstalled,
+
+ PolicyWac = NotInstalled |
+ ExistingVersionOlder,
+
+ PolicyAlwaysInstall = NotInstalled |
+ IncomingVersionNotStd |
+ ExistingVersionNotStd |
+ BothVersionsNotStd |
+ ExistingVersionOlder |
+ ExistingVersionEqual |
+ ExistingVersionNewer,
+
+ PolicyForceInstall = PolicyAlwaysInstall
+};
+
+inline Type operator | (const Type &a,
+ const Type &b)
+{
+ return static_cast<Type>(static_cast<unsigned long>(a) |
+ static_cast<unsigned long>(b));
+}
+
+inline Type operator & (const Type &a,
+ const Type &b)
+{
+ return static_cast<Type>(static_cast<unsigned long>(a) &
+ static_cast<unsigned long>(b));
+}
+}
+
+//TODO into namespace
+//InstallationStruct
+typedef Jobs::JobCallbacksBase<InstallerFinishedCallback,
+ InstallerProgressCallback>
+WidgetInstallCallbackBase;
+
+//Widget Installation Struct
+struct WidgetInstallationStruct : public WidgetInstallCallbackBase
+{
+ WidgetUpdateMode::Type updateMode;
+ bool m_quiet;
+
+ // It must be empty-constructible as a parameter of generic event
+ WidgetInstallationStruct() : updateMode(WidgetUpdateMode::Zero),
+ m_quiet(true)
+ {
+ }
+
+ WidgetInstallationStruct(InstallerFinishedCallback finished,
+ InstallerProgressCallback progress,
+ void *param,
+ WidgetUpdateMode::Type mode,
+ bool quiet) :
+ WidgetInstallCallbackBase(finished, progress, param),
+ updateMode(mode),
+ m_quiet(quiet)
+ {
+ }
+};
+
+#endif // WRT_SRC_INSTALLER_CORE_INSTALLER_TASKS_WIDGET_INSTALLER_STRUCT_H_
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "installer_controller.h"
+#include <dpl/log/log.h>
+#include <dpl/singleton_impl.h>
+
+IMPLEMENT_SINGLETON(Logic::InstallerController)
+
+namespace Logic
+{
+
+InstallerController::InstallerController()
+{
+}
+
+//void InstallerController::OnEventReceived(
+// const InstallerControllerEvents::InstallWidgetEvent &event)
+//{
+// std::string fileName = event.GetArg0();
+// WidgetInstallationStruct installerStruct = event.GetArg1();
+// Jobs::JobHandle handle =
+// m_installerLogic.InstallWidget(fileName, installerStruct);
+//
+// //TODO return handle to API
+// (void)handle;
+//}
+
+void InstallerController::OnEventReceived(
+ const InstallerControllerEvents::InstallPluginEvent &event)
+{
+ std::string dirName = event.GetArg0();
+ PluginInstallerStruct installerStruct = event.GetArg1();
+
+ Jobs::JobHandle handle =
+ m_installerLogic.InstallPlugin(dirName, installerStruct);
+
+ //TODO return handle to API
+ (void)handle;
+}
+
+//void InstallerController::OnEventReceived(
+// const InstallerControllerEvents::UninstallWidgetEvent &event)
+//{
+// WidgetHandle widgetHandle = event.GetArg0();
+// WidgetUninstallationStruct uninstallerStruct = event.GetArg1();
+// Jobs::JobHandle handle =
+// m_installerLogic.UninstallWidget(widgetHandle, uninstallerStruct);
+//
+// //TODO return handle to API
+// (void)handle;
+//}
+
+Eina_Bool InstallerController::AddNextStep(void *data)
+{
+ Jobs::Job* model = static_cast<Jobs::Job *>(data);
+ CONTROLLER_POST_EVENT(InstallerController,
+ InstallerControllerEvents::NextStepEvent(model));
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+void InstallerController::OnEventReceived(
+ const InstallerControllerEvents::NextStepEvent &event)
+{
+ Jobs::Job* model = event.GetArg0();
+ Assert(model != NULL);
+
+ if (m_installerLogic.NextStep(model)) {
+ ecore_idler_add(AddNextStep, model);
+ }
+}
+
+//void InstallerController::OnEventReceived(
+// const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent &
+// event)
+//{
+// (void)event;
+// m_installerLogic.InstallDeferredWidgetPackages();
+//}
+
+void InstallerController::OnEventReceived(
+ const InstallerControllerEvents::InitializeEvent & /*event*/)
+{
+ m_installerLogic.Initialize();
+}
+
+void InstallerController::OnEventReceived(
+ const InstallerControllerEvents::TerminateEvent & /*event*/)
+{
+ m_installerLogic.Terminate();
+}
+
+} //Logic
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
+#define WRT_SRC_INSTALLER_CORE_INSTALLER_CONTROLLER_H_
+
+#include <dpl/singleton.h>
+#include <dpl/event/controller.h>
+#include <dpl/generic_event.h>
+#include <string>
+#include <map>
+#include <dpl/task_list.h>
+#include <dpl/task.h>
+#include <dpl/type_list.h>
+#include <widget_install/widget_installer_struct.h>
+#include <installer_logic.h>
+#include <job.h>
+
+/**
+ * @brief holds events send to InstallControler
+ */
+namespace InstallerControllerEvents {
+/**
+ * @brief Event for inicieting instalation process.
+ *
+ * This event holds std::string witch should be path to widget package
+ */
+//DECLARE_GENERIC_EVENT_2(InstallWidgetEvent,
+// std::string,
+// WidgetInstallationStruct) // (zipFileName, installerStruct)
+
+/**
+ * @brief Event for iniciating plugin instalation process.
+ * This event holds std::string witch should be path to plugin directory
+ * and PluginInstallerStruct which contain
+ * StatusCallack, progressCallback and private data for callbacks
+ */
+DECLARE_GENERIC_EVENT_2(InstallPluginEvent, std::string, PluginInstallerStruct)
+
+/**
+ * @brief Event for inicietig widget uninstallation.
+ *
+ * WidgetHandler is used to point witch widget shuld be uninstalled
+ */
+//DECLARE_GENERIC_EVENT_2(UninstallWidgetEvent,
+// WidgetHandle,
+// WidgetUninstallationStruct)
+//
+/**
+ * @brief Event for pushing installation process forward.
+ */
+DECLARE_GENERIC_EVENT_1(NextStepEvent, Jobs::Job *)
+
+//DECLARE_GENERIC_EVENT_0(InstallDeferredWidgetPackagesEvent)
+
+DECLARE_GENERIC_EVENT_0(InitializeEvent)
+DECLARE_GENERIC_EVENT_0(TerminateEvent)
+
+} // namespace InstallerEvents
+
+
+namespace Logic {
+
+/**
+ * @brief Controls Widget installation
+ *
+ * Main Controler of wiget installation/uninstallation, this is also used
+ * for pushing forward each of processes.
+ * It waits for three events:
+ * <ul>
+ * <li>InstallWidgetEvent</li>
+ * <li>UninstallWidgetEvent</li>
+ * <li>NextStepEvent</li>
+ * </ul>
+ */
+
+typedef DPL::TypeListDecl<
+// InstallerControllerEvents::InstallWidgetEvent,
+ InstallerControllerEvents::InstallPluginEvent,
+// InstallerControllerEvents::UninstallWidgetEvent,
+ InstallerControllerEvents::NextStepEvent,
+// InstallerControllerEvents::InstallDeferredWidgetPackagesEvent,
+ InstallerControllerEvents::InitializeEvent,
+ InstallerControllerEvents::TerminateEvent>::Type
+InstallerControllerEventsSet;
+
+class InstallerController : public DPL::Event::Controller<InstallerControllerEventsSet>
+{
+ protected:
+ /**
+ * @brief Executed on InstallWidgetEvent received.
+ */
+// virtual void OnEventReceived(
+// const InstallerControllerEvents::InstallWidgetEvent &event);
+//
+ /**
+ * @brief Executed on InstallPluginEvent received.
+ */
+ virtual void OnEventReceived(
+ const InstallerControllerEvents::InstallPluginEvent &event);
+
+ /**
+ * @brief Executed on UninstallWidgetEvent received.
+ */
+// virtual void OnEventReceived(
+// const InstallerControllerEvents::UninstallWidgetEvent &event);
+ /**
+ * @brief Executed on NextStepEvent received.
+ */
+ virtual void OnEventReceived(
+ const InstallerControllerEvents::NextStepEvent &event);
+
+// virtual void OnEventReceived(
+// const InstallerControllerEvents::InstallDeferredWidgetPackagesEvent
+// &event);
+
+ virtual void OnEventReceived(
+ const InstallerControllerEvents::InitializeEvent &event);
+ virtual void OnEventReceived(
+ const InstallerControllerEvents::TerminateEvent &event);
+
+ private:
+ // Embedded logic
+ Logic::InstallerLogic m_installerLogic;
+
+ InstallerController();
+
+ static Eina_Bool AddNextStep(void *data);
+
+ friend class DPL::Singleton<InstallerController>;
+};
+
+typedef DPL::Singleton<InstallerController> InstallerControllerSingleton;
+
+}
+
+#endif // INSTALLER_CONTROLLER_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <installer_logic.h>
+#include <installer_controller.h>
+#include <dpl/string.h>
+#include <dpl/foreach.h>
+#include <dpl/wrt-dao-rw/feature_dao.h>
+#include <dpl/wrt-dao-rw/plugin_dao.h>
+#include <plugin_install/job_plugin_install.h>
+#include <job_exception_base.h>
+#include <plugin_install/plugin_objects.h>
+
+using namespace WrtDB;
+
+namespace Logic {
+
+InstallerLogic::InstallerLogic() :
+ m_NextHandle(0)
+{
+}
+
+InstallerLogic::~InstallerLogic()
+{
+ Assert(m_jobs.empty() && "There are still running jobs");
+ //FIXME what should be done here?
+}
+
+void InstallerLogic::Initialize()
+{
+ LogDebug("Done");
+}
+
+void InstallerLogic::Terminate()
+{
+ //TODO how to delete, if it is still running, paused and so on
+ FOREACH(it, m_jobs)
+ {
+ it->second->SetPaused(true); //FIXME this is not enough!
+ }
+
+ LogDebug("Done");
+}
+
+Jobs::JobHandle InstallerLogic::AddAndStartJob(Jobs::Job *job)
+{
+ Jobs::JobHandle handle = GetNewJobHandle();
+ job->SetJobHandle(handle);
+
+ m_jobs.insert(std::make_pair(handle, job));
+
+ //Start job
+ CONTROLLER_POST_EVENT(InstallerController,
+ InstallerControllerEvents::NextStepEvent(job));
+
+ return handle;
+}
+
+//InstallWidget, UninstallWidget InstallPlugin method are almost the same
+// But each Job has different constructor, so creating new Job is specific
+// i.e. widgetHandle, path etc...
+//Jobs::JobHandle InstallerLogic::InstallWidget(std::string const & widgetPath,
+// const WidgetInstallationStruct &installerStruct)
+//{
+// LogDebug("New Widget Installation:");
+//
+// Jobs::Job *job =
+// new Jobs::WidgetInstall::JobWidgetInstall(widgetPath, installerStruct);
+//
+// return AddAndStartJob(job);
+//}
+//
+//Jobs::JobHandle InstallerLogic::UninstallWidget(WidgetHandle widgetHandle,
+// const WidgetUninstallationStruct &uninstallerStruct)
+//{
+// LogDebug("New Widget Uninstallation");
+//
+// Jobs::Job *job =
+// new Jobs::WidgetUninstall::JobWidgetUninstall(widgetHandle,
+// uninstallerStruct);
+//
+// return AddAndStartJob(job);
+//}
+
+Jobs::JobHandle InstallerLogic::InstallPlugin(std::string const & pluginPath,
+ const PluginInstallerStruct &installerStruct)
+{
+ LogDebug("New Plugin Installation");
+
+ Jobs::Job *job =
+ new Jobs::PluginInstall::JobPluginInstall(pluginPath, installerStruct);
+
+ return AddAndStartJob(job);
+}
+
+#define TRANSLATE_JOB_EXCEPTION() \
+ _rethrown_exception.getParam()
+#define TRANSLATE_JOB_MESSAGE() \
+ _rethrown_exception.GetMessage()
+
+bool InstallerLogic::NextStep(Jobs::Job *job)
+{
+ Try {
+ bool stepSucceded = job->NextStep();
+
+ job->SendProgress();
+
+ if (stepSucceded) {
+ return !job->IsPaused();
+ }
+
+ if (!job->GetUndoType()) {
+ //job successfully finished
+
+ //send finished callback
+ job->SendFinishedSuccess();
+
+ switch (job->GetInstallationType()) {
+ case Jobs::PluginInstallation:
+ //todo move it somewhere
+ InstallWaitingPlugins();
+ break;
+ default: //because of warning
+ break;
+ }
+ } else {
+ //job abort process completed
+ job->SendFinishedFailure();
+ }
+
+ //clean job
+ m_jobs.erase(job->GetJobHandle());
+ delete job;
+
+ return false;
+ }
+ catch (Jobs::JobExceptionBase &exc) {
+ //start revert job
+ LogInfo("Exception occured: " << exc.getParam() <<
+ ". Reverting job...");
+ bool hasAbortSteps = job->Abort();
+ job->SetUndoType(true);
+ job->SaveExceptionData(exc);
+
+ if (!hasAbortSteps) {
+ //no AbortSteps
+ job->SendFinishedFailure();
+
+ //clean job
+ m_jobs.erase(job->GetJobHandle());
+ delete job;
+ }
+ return hasAbortSteps;
+ }
+}
+
+//TODO this should be moved somewhere...when it should take place? after widget
+//is closing?
+//void InstallerLogic::InstallDeferredWidgetPackages()
+//{
+// LogWarning("Not implemented");
+// // LogInfo("Installing deferred widget packages...");
+// //
+// // WidgetPackageList packages = GlobalDAO::GetDefferedWidgetPackageInstallationList();
+// //
+// // LogInfo(packages.size() << " widget package(s) to install");
+// //
+// // // Make a copy of widget packages to install, because some
+// // // widget packages may still fail because they are running
+// // m_packagesToInstall = packages;
+// //
+// // // Start processing
+// // InstallSingleDeferredPackage();
+//}
+//
+//void InstallerLogic::InstallSingleDeferredPackage()
+//{
+// LogWarning("Not implemented");
+// // if (m_packagesToInstall.empty())
+// // return;
+// //
+// // // Take single package
+// // DPL::String widgetPackage = m_packagesToInstall.front();
+// // m_packagesToInstall.pop_front();
+// //
+// // // Remove it from DB
+// // GlobalDAO::RemoveDefferedWidgetPackageInstallation(widgetPackage);
+// //
+// // // Begin installation
+// // LogInfo("Installing deferred widget package: " << widgetPackage);
+// //
+// // // Post installation
+// // CONTROLLER_POST_EVENT(
+// // InstallerController, InstallerControllerEvents::InstallWidgetEvent(
+// // DPL::ToUTF8String(widgetPackage).c_str(), WidgetInstallationStruct(
+// // &DummyInstallCallback, &DummyProgressCallback, NULL,
+// // WidgetUpdateMode::PolicyWac)));
+//}
+
+void InstallerLogic::InstallWaitingPlugins()
+{
+ PluginHandleSetPtr waitingPlugins;
+
+ waitingPlugins =
+ PluginDAO::getPluginHandleByStatus(PluginDAO::INSTALLATION_WAITING);
+
+ FOREACH(it, *waitingPlugins)
+ {
+ resolvePluginDependencies(*it);
+ }
+}
+
+bool InstallerLogic::resolvePluginDependencies(PluginHandle handle)
+{
+ PluginHandleSetPtr dependencies(new PluginHandleSet);
+
+ PluginObjects::ObjectsPtr requiredObjects =
+ PluginDAO::getRequiredObjectsForPluginHandle(handle);
+
+ PluginHandle depHandle =
+ Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE;
+
+ FOREACH(requiredObject, *requiredObjects)
+ {
+ depHandle =
+ PluginDAO::getPluginHandleForImplementedObject(*requiredObject);
+
+ if (depHandle ==
+ Jobs::PluginInstall::JobPluginInstall::INVALID_HANDLE) {
+ LogError("Library implementing: " <<
+ *requiredObject << " NOT FOUND");
+
+ //PluginDAO::SetPluginInstallationStatus(INSTALLATION_WAITING);
+ return false;
+ }
+ dependencies->insert(depHandle);
+ }
+
+ PluginDAO::registerPluginLibrariesDependencies(handle, dependencies);
+ PluginDAO::setPluginInstallationStatus(handle,
+ PluginDAO::INSTALLATION_COMPLETED);
+
+ return true;
+}
+
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef WRT_SRC_INSTALLER_CORE_INSTALLER_LOGIC_H_
+#define WRT_SRC_INSTALLER_CORE_INSTALLER_LOGIC_H_
+
+#include <dpl/wrt-dao-rw/widget_dao.h>
+#include <dpl/wrt-dao-rw/global_dao.h>
+#include <dpl/wrt-dao-ro/feature_model.h>
+#include <plugin_install/plugin_installer_struct.h>
+#include <job.h>
+#include <wrt_common_types.h>
+
+namespace Logic {
+
+class InstallerLogic
+{
+ typedef std::map<Jobs::JobHandle, Jobs::Job*> JobsContainer;
+ JobsContainer m_jobs;
+
+// void InstallDeferredWidgetPackages();
+// void InstallSingleDeferredPackage();
+
+ void InstallWaitingPlugins();
+ bool resolvePluginDependencies(PluginHandle handle);
+
+ Jobs::JobHandle m_NextHandle;
+ Jobs::JobHandle GetNewJobHandle()
+ {
+ return m_NextHandle++;
+ }
+ Jobs::JobHandle AddAndStartJob(Jobs::Job *job);
+ public:
+ virtual ~InstallerLogic();
+
+ void Initialize();
+
+ void Terminate();
+
+// Jobs::JobHandle InstallWidget(std::string const & widgetPath,
+// const WidgetInstallationStruct &installerStruct);
+//
+// Jobs::JobHandle UninstallWidget(WidgetHandle widgetHandle,
+// const WidgetUninstallationStruct &uninstallerStruct);
+//
+ Jobs::JobHandle InstallPlugin(std::string const & pluginPath,
+ const PluginInstallerStruct &installerStruct);
+
+ bool NextStep(Jobs::Job* installModel);
+
+ //TODO implement me
+ bool AbortJob(const Jobs::JobHandle & /*handle*/)
+ {
+ LogWarning("Not implemented");
+ return true;
+ }
+
+ private:
+ InstallerLogic();
+
+ friend class InstallerController;
+};
+
+}
+
+#endif // INSTALLER_LOGIC_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "feature_logic.h"
+
+#include <list>
+
+#include <dpl/assert.h>
+#include <dpl/noncopyable.h>
+#include <dpl/string.h>
+#include <dpl/foreach.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+
+FeatureLogic::FeatureLogic(WidgetHandle handle)
+ : m_rejected(false)
+{
+ WrtDB::WidgetDAOReadOnly widgetDao(handle);
+ WidgetFeatureSet featureSet = widgetDao.getFeaturesList();
+ FOREACH(it, featureSet) {
+ LogInfo("Feature name : " << it->name);
+ WrtDB::DeviceCapabilitySet dcs =
+ WrtDB::GlobalDAOReadOnly::GetDeviceCapability(it->name);
+ FOREACH (devCap, dcs) {
+ LogInfo("--- dev cap : " << *devCap);
+ }
+ Feature feature(*it, dcs);
+ m_featureList.push_back(feature);
+ }
+ m_currentFeature = m_featureList.begin();
+
+ // ok we must set iterator on the first processable node
+ if (!isProcessable()) {
+ next();
+ }
+}
+
+bool FeatureLogic::isDone() const
+{
+ return m_currentFeature == m_featureList.end();
+}
+
+bool FeatureLogic::next()
+{
+ while (!isDone()) {
+ if (m_currentFeature->currentCap != m_currentFeature->devCapSet.end()) {
+ m_currentFeature->currentCap++;
+ } else {
+ ++m_currentFeature;
+ }
+ // we moved pointer
+ if (isProcessable()) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
+void FeatureLogic::setAceResponse(bool allowed)
+{
+ Assert(isProcessable() && "Wrong usage");
+ if (!allowed) {
+ m_currentFeature->rejected = true;
+ if (m_currentFeature->required) {
+ m_rejected = true;
+ }
+ }
+}
+
+DPL::String FeatureLogic::getDevice() const
+{
+ return *(m_currentFeature->currentCap);
+}
+
+bool FeatureLogic::isProcessable() const
+{
+ if (isDone()) {
+ return false;
+ }
+
+ if (m_currentFeature->currentCap == m_currentFeature->devCapSet.end()) {
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace WidgetInstall
+} // namespace Jobs
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SRC_INSTALLER_MISC_FEATURE_LOGIC
+#define SRC_INSTALLER_MISC_FEATURE_LOGIC
+
+#include <list>
+#include <string>
+
+#include <dpl/assert.h>
+#include <dpl/noncopyable.h>
+#include <dpl/shared_ptr.h>
+
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
+#include <wrt_common_types.h>
+
+namespace Jobs {
+namespace WidgetInstall {
+
+class FeatureLogic : DPL::Noncopyable {
+ public:
+
+ FeatureLogic(WidgetHandle handle);
+
+ bool isDone() const;
+
+ bool next();
+
+ void setAceResponse(bool allowed);
+
+ DPL::String getDevice() const;
+
+ bool isRejected(void) const
+ {
+ return m_rejected;
+ }
+
+ struct Feature : public WidgetFeature {
+ WrtDB::DeviceCapabilitySet devCapSet;
+ WrtDB::DeviceCapabilitySet::const_iterator currentCap;
+
+ Feature(const WidgetFeature &wf, const WrtDB::DeviceCapabilitySet &set)
+ : WidgetFeature(wf)
+ , devCapSet(set)
+ {
+ currentCap = devCapSet.begin();
+ }
+
+ explicit Feature(const Feature &second) : WidgetFeature(second)
+ {
+ devCapSet = second.devCapSet;
+ currentCap = devCapSet.find(*second.currentCap);
+ rejected = second.rejected;
+ }
+ private:
+ void operator=(const Feature &second) {
+ name = second.name;
+ devCapSet = second.devCapSet;
+ required = second.required;
+ rejected = second.rejected;
+ pluginId = second.pluginId;
+ params = second.params;
+ currentCap = devCapSet.find(*second.currentCap);
+ }
+ };
+
+ typedef std::list<Feature> FeatureList;
+ typedef FeatureList::const_iterator FeatureIterator;
+
+ FeatureIterator resultBegin() { return m_featureList.begin(); }
+ FeatureIterator resultEnd() { return m_featureList.end(); }
+
+ private:
+ bool isProcessable() const;
+
+ FeatureList m_featureList;
+ FeatureList::iterator m_currentFeature;
+ bool m_rejected;
+};
+
+typedef DPL::SharedPtr<FeatureLogic> FeatureLogicPtr;
+
+} // namespace WidgetInstall
+} // namespace Jobs
+
+#endif // SRC_INSTALLER_MISC_FEATURE_LOGIC
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file libxml_utils.cpp
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ */
+
+#include "libxml_utils.h"
+
+#include <dpl/singleton_impl.h>
+
+IMPLEMENT_SINGLETON(LibxmlUtils)
+
+LibxmlUtils::LibxmlUtils() : isInitialized(false)
+{
+}
+
+LibxmlUtils::~LibxmlUtils()
+{
+ if(isInitialized)
+ {
+ LogDebug("Libxml - cleaning");
+ // Cleanup function for the XML library.
+ xmlCleanupParser();
+ //this is to debug memory for regression tests
+ xmlMemoryDump();
+ }
+}
+
+void LibxmlUtils::init()
+{
+ if(!isInitialized)
+ {
+ LIBXML_TEST_VERSION
+ isInitialized = true;
+ LogDebug("Libxml have been initialized");
+ }
+ LogDebug("Libxml already initialized");
+}
+
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file libxml_utils.h
+ * @author Tomasz Iwanek (t.iwanek@samsung.com)
+ */
+
+#ifndef LIBXML_UTILS_H
+#define LIBXML_UTILS_H
+
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+
+#include <dpl/singleton.h>
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+#include <dpl/exception.h>
+
+/**
+ * @brief The LibxmlUtils class
+ *
+ * Singleton for assurence for libxml2 initialization
+ *
+ * Use: LibxmlUtils::Instance().init(); to initialize library
+ *
+ */
+class LibxmlUtils
+{
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, Libxml2Error)
+
+ LibxmlUtils();
+ ~LibxmlUtils();
+
+ void init();
+private:
+ bool isInitialized;
+
+ friend class DPL::Singleton<LibxmlUtils>;
+};
+
+typedef DPL::Singleton<LibxmlUtils> LibxmlSingleton;
+
+#endif // LIBXML_UTILS_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file
+ * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include "wac_widget_id.h"
+
+#include <memory>
+#include <string>
+
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+
+#include <iri.h>
+#include <vcore/ValidatorCommon.h>
+
+namespace {
+const char *SCHEME_HTTP = "http";
+const char *SCHEME_HTTPS = "https";
+}
+
+WacWidgetId::WacWidgetId(const DPL::OptionalString &widgetId) :
+ m_schemaMatch(false)
+{
+ if (!widgetId.IsNull()) {
+ std::string wid = DPL::ToUTF8String(*widgetId);
+ parse(wid.c_str());
+ }
+}
+
+bool WacWidgetId::matchHost(const DPL::String &second) const
+{
+ LogDebug("m_schemaMatch is: " << m_schemaMatch);
+ if (!m_schemaMatch) {
+ return false;
+ }
+
+ LogDebug("Matching DNS identity: " << m_host <<
+ " " << DPL::ToUTF8String(second));
+
+ return m_host == DPL::ToUTF8String(second);
+}
+
+void WacWidgetId::parse(const char *url)
+{
+ LogDebug("Widget id to parse: " << url);
+
+ std::unique_ptr<iri_struct, std::function<void(iri_struct*)> >
+ iri(iri_parse(url), iri_destroy);
+
+ if (!iri.get()) {
+ LogDebug("Error in parsing widget id.");
+ return; // m_schemaMatch == false;
+ }
+
+ std::string scheme;
+
+ if (iri.get()->scheme) {
+ scheme = iri.get()->scheme;
+ } else {
+ LogWarning("Error. No scheme in widget id.");
+ return; // m_schemaMatch == false;
+ }
+
+ // should we support HTTP and HTTPS? wac says nothing
+ // std::transform(m_scheme.begin(), m_scheme.end(), m_scheme.begin(), tolower);
+
+ // We only match "http" and "https" schemas
+ if ((scheme != SCHEME_HTTP) && (scheme != SCHEME_HTTPS)) {
+ LogWarning("Unknown scheme in widget id." << scheme);
+ return; // m_schemaMatch == false;
+ } else {
+ m_schemaMatch = true;
+ }
+
+ if (iri.get()->host) {
+ m_host = iri.get()->host;
+ LogDebug("Host has been set to: " << m_host);
+ }
+
+ // What to do when host is empty? No info in wac documentation.
+
+ // Any post processing algorithm? No info in wac documentation.
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file
+ * @author Bartlomiej Grzelewski (b.grzelewski@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#ifndef WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
+#define WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
+
+#include <dpl/string.h>
+#include <dpl/optional_typedefs.h>
+
+class WacWidgetId
+{
+ public:
+ explicit WacWidgetId(const DPL::OptionalString &widgetId);
+ bool matchHost(const DPL::String &second) const;
+
+ private:
+ void parse(const char *url);
+
+ bool m_schemaMatch;
+ std::string m_host;
+};
+
+#endif // WRT_ENGINE_SRC_INSTALLER_CORE_MISC_WAC_WIDGET_ID_H
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file widget_location.cpp
+ * @author Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#include "widget_location.h"
+
+#include <dpl/utils/wrt_utility.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/assert.h>
+#include <dpl/log/log.h>
+#include <dpl/sstream.h>
+#include <dpl/localization/localization_utils.h>
+
+#include <widget_install/task_commons.h>
+
+
+WidgetLocation::DirectoryDeletor::DirectoryDeletor()
+{
+ m_dirpath = Jobs::WidgetInstall::createTempPath();
+}
+
+WidgetLocation::DirectoryDeletor::~DirectoryDeletor()
+{
+ LogDebug("Removing widget installation temporary directory: " << m_dirpath.c_str());
+ _WrtUtilRemoveDir(m_dirpath.c_str());
+}
+
+std::string WidgetLocation::DirectoryDeletor::getTempPath() const
+{
+ return m_dirpath;
+}
+
+WidgetLocation::WidgetLocation() : m_browser(false)
+{
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname) : m_pkgname(widgetname), m_browser(false)
+{
+}
+
+WidgetLocation::~WidgetLocation()
+{
+}
+
+WidgetLocation::WidgetLocation(const std::string & widgetname,
+ std::string sourcePath,
+ bool browserRequest,
+ WrtDB::PkgType t):
+ m_pkgname(widgetname),
+ m_widgetSource(sourcePath),
+ m_browser(browserRequest),
+ m_type(t),
+ m_temp(new WidgetLocation::DirectoryDeletor())
+{
+}
+
+// TODO cache all these paths
+std::string WidgetLocation::getInstallationDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath());
+}
+
+std::string WidgetLocation::getPackageInstallationDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname;
+}
+
+std::string WidgetLocation::getSourceDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname + WrtDB::GlobalConfig::GetWidgetSrcPath();
+}
+
+std::string WidgetLocation::getBinaryDir() const
+{
+ return std::string(WrtDB::GlobalConfig::GetUserInstalledWidgetPath()) + "/"
+ + m_pkgname + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getBackupDir() const
+{
+ return getPackageInstallationDir() + "/backup";
+}
+
+std::string WidgetLocation::getBackupSourceDir() const
+{
+ return getBackupDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+}
+
+std::string WidgetLocation::getBackupBinaryDir() const
+{
+ return getBackupDir() + WrtDB::GlobalConfig::GetUserWidgetExecPath();
+}
+
+std::string WidgetLocation::getTemporaryPackageDir() const
+{
+ return m_temp->getTempPath();
+}
+
+bool WidgetLocation::browserRequest() const
+{
+ return m_browser;
+}
+
+std::string WidgetLocation::getTemporaryRootDir() const
+{
+ if(m_type == WrtDB::PKG_TYPE_TIZEN_WITHSVCAPP)
+ {
+ return getTemporaryPackageDir() + WrtDB::GlobalConfig::GetWidgetSrcPath();
+ }
+ else
+ {
+ return getTemporaryPackageDir();
+ }
+}
+
+std::string WidgetLocation::getConfigurationDir() const
+{
+ if(m_browser)
+ {
+ std::string path = ".";
+ int index = m_widgetSource.find_last_of("\\/");
+ if (index != std::string::npos)
+ {
+ path = m_widgetSource.substr(0, index);
+ }
+ return path;
+ }
+ else
+ {
+ return getTemporaryRootDir();
+ }
+}
+
+std::string WidgetLocation::getInstalledIconPath() const
+{
+ return m_iconPath;
+}
+
+std::string WidgetLocation::getWidgetSource() const
+{
+ return m_widgetSource;
+}
+
+void WidgetLocation::setIconTargetFilenameForLocale(const std::string & icon)
+{
+ m_iconPath = icon;
+}
+
+void WidgetLocation::registerExternalLocation(const std::string & file)
+{
+ m_externals.push_back(file);
+}
+
+WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
+{
+ return m_externals;
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file widget_location.h
+ * @author Iwanek Tomasz (t.iwanek@smasung.com)
+ */
+#ifndef WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+#define WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
+
+#include <string>
+
+#include <dpl/shared_ptr.h>
+#include <dpl/wrt-dao-ro/common_dao_types.h>
+#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+
+/**
+ * @brief The WidgetLocation class
+ *
+ * Object that stores locations of several files/directories according
+ * to package name
+ *
+ * Current package layout (of installed package) is following:
+ *
+ * /opt/apps/[package_name]
+ * \_____________ /data
+ * \_____________ /bin
+ * \_____________ /bin/[id_of_installed_package]
+ * \_____________ /res/wgt/
+ * \___ config.xml
+ * \___ [widgets_archive_content]
+ *
+ * 1) Normal Widget
+ * Developer provides content of res/wgt directory (package contains that directory as root).
+ *
+ * 2) For OSP Service Hybrid App is actually a bit different:
+ * Root is OSP Service directory, WebApp content is located in [root]/res/wgt
+ *
+ * Temporary directory is directory when widget is placed at the begining
+ * of installation process. After parsing process of config.xml, destination directory is created.
+ */
+class WidgetLocation
+{
+ class DirectoryDeletor
+ {
+ public:
+ DirectoryDeletor();
+ ~DirectoryDeletor();
+ std::string getTempPath() const;
+ private:
+ std::string m_dirpath;
+ };
+
+public:
+ DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
+ DECLARE_EXCEPTION_TYPE(Base, NoTemporaryPath)
+ /**
+ * @brief WidgetLocation
+ *
+ * Creates useless object. Needed by DPL::Optional
+ */
+ WidgetLocation();
+ /**
+ * @brief WidgetLocation Builds paths for widget location during uninstallation
+ *
+ * Uninstallation process needs only installed package directory.
+ *
+ * @param widgetname name of widget
+ */
+ WidgetLocation(const std::string & widgetname);
+ /**
+ * @brief WidgetLocation Builds paths for widget location during installation
+ *
+ * @param widgetname name of widget
+ * @param browserRequest is browser Request
+ * @param sourcePath given source path
+ * @param t declaraced type of widget if type is needed
+ *
+ * In destruction removes temporary directory
+ */
+ WidgetLocation(const std::string & widgetname, std::string sourcePath,
+ bool browserRequest = false, WrtDB::PkgType t = WrtDB::PKG_TYPE_TIZEN_WEBAPP);
+ ~WidgetLocation();
+
+ // Installed paths
+ std::string getInstallationDir() const; // /opt/apps
+ std::string getPackageInstallationDir() const; // /opt/apps/[package]
+ std::string getSourceDir() const; // /opt/apps/[package]/res/wgt
+ std::string getBinaryDir() const; // /opt/apps/[package]/bin
+ std::string getBackupDir() const; // /opt/apps/[package]/backup
+ std::string getBackupSourceDir() const; // /opt/apps/[package]/backup/res/wgt
+ std::string getBackupBinaryDir() const; // /opt/apps/[package]/backup/bin
+
+ bool browserRequest() const;
+
+ // Temporary paths
+ /**
+ * @brief getTemporaryRootDir
+ * @return value of root for developer's provide package (root of unpacked .wgt file)
+ */
+ std::string getTemporaryPackageDir() const;
+ /**
+ * @brief getTemporaryRootDir
+ *
+ * Value of this will differs according to type of installed widget.
+ *
+ * @return value of root for content in temporary directory to be copied into 'res/wgt'
+ */
+ std::string getTemporaryRootDir() const;
+ /**
+ * @brief getConfigurationDir Returns rott directory for configuration requirements
+ *
+ * 1) For packed widgets it is just root of unpacked sources
+ * 2) For browser installation it is directory name of widget passed to installer
+ *
+ * @return configuration directory
+ */
+ std::string getConfigurationDir() const;
+
+ //icons
+ /**
+ * @brief setIconTargetFilenameForLocale set installed ion path according to locale
+ * @param icon path of application icon
+ */
+ void setIconTargetFilenameForLocale(const std::string &icon);
+ /**
+ * @brief getIconTargetFilename gets icon path suffix for locale
+ * @param languageTag language tag
+ * @return value of suffix of path
+ */
+ DPL::String getIconTargetFilename(const DPL::String& languageTag) const;
+ /**
+ * @brief getIconTargetFilename gets icon full path
+ * @param languageTag language tag
+ * @return value of full path
+ */
+ std::string getInstalledIconPath() const;
+
+ /**
+ * @brief getWidgetSourcePath return widget's source path given to installer
+ * @return value of source path
+ */
+ std::string getWidgetSource() const;
+
+ //external files
+ /**
+ * @brief registerExternalFile Registers file for database registration
+ * @param file
+ *
+ * Registered file will be stored in database and removed automatically a
+ *
+ * @return
+ */
+ void registerExternalLocation(const std::string & file);
+ /**
+ * @brief listExternalFile list all file to be registered
+ */
+ WrtDB::ExternalLocationList listExternalLocations() const;
+
+private:
+ std::string m_widgetSource; // Source widget zip file/widget url
+ bool m_browser; // is browser request installation
+ std::string m_pkgname; //name of package
+ std::string m_iconPath; //installed icon path
+ WrtDB::PkgType m_type;
+ DPL::SharedPtr<DirectoryDeletor> m_temp; //directory
+ WrtDB::ExternalLocationList m_externals;
+};
+
+#endif // WRT_INSTALLER_SRC_MISC_WIDGET_LOCATION_H
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# @file CMakeLists.txt
+# @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+# @version 1.0
+#
+
+SET(WRT_INSTALLER_DIR
+ ${INSTALLER_SRC_DIR}/wrt-installer
+ )
+
+#SET(PKG_MANAGER_DIR
+# ${INSTALLER_SRC_DIR}/pkg-manager
+# )
+
+SET(WRT_INSTALLER_SOURCES
+ ${WRT_INSTALLER_DIR}/wrt_installer.cpp
+ ${WRT_INSTALLER_DIR}/wrt_installer_api.cpp
+ ${WRT_INSTALLER_DIR}/installer_callbacks_translate.cpp
+ ${WRT_INSTALLER_DIR}/plugin_utils.cpp
+ ${WRT_INSTALLER_DIR}/language_subtag_rst_tree.cpp
+ ${WRT_INSTALLER_DIR}/installer_main_thread.cpp
+ ${WRT_INSTALLER_DIR}/option_parser.cpp
+ # ${PKG_MANAGER_DIR}/pkgmgr_signal.cpp
+)
+
+PKG_CHECK_MODULES(WRT_INSTALLER_DEPS
+ # pkgmgr-installer
+ libpcrecpp
+ # ace-install
+ REQUIRED)
+
+INCLUDE_DIRECTORIES(
+ # ${PKG_MANAGER_DIR}
+ ${WRT_INSTALLER_DEP_INCLUDES}
+ ${WRT_INSTALLER_INCLUDES}
+ ${WRT_INSTALLER_DEPS_INCLUDE_DIRS}
+)
+
+ADD_EXECUTABLE(${TARGET_INSTALLER}
+ ${TARGET_INSTALLER_STATIC_SRC}
+ ${WRT_INSTALLER_SOURCES}
+)
+
+ADD_DEFINITIONS(${WRT_INSTALLER_DEPS_CFLAGS})
+
+TARGET_LINK_LIBRARIES(${TARGET_INSTALLER}
+ ${TARGET_INSTALLER_STATIC}
+ ${WRT_INSTALLER_DEPS_LIBRARIES}
+)
+
+
+SET_TARGET_PROPERTIES(${TARGET_INSTALLER} PROPERTIES
+ LINK_FLAGS "-Wl,--as-needed -Wl,--hash-style=both -Wl"
+ BUILD_WITH_INSTALL_RPATH ON
+ INSTALL_RPATH_USE_LINK_PATH ON
+)
+
+INSTALL(TARGETS ${TARGET_INSTALLER} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file api_callbacks_translate.h
+ * @author Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief Source file for api callbacks translate functions
+ */
+
+#include <installer_callbacks_translate.h>
+#include <dpl/log/log.h>
+
+namespace InstallerCallbacksTranslate {
+WrtErrStatus TranslateError(CommonError::Type status)
+{
+ switch (status) {
+ case CommonError::WrtSuccess:
+ return WRT_SUCCESS;
+
+ case CommonError::HandleNotFound:
+ return WRT_ERROR_HANDLE_NOT_FOUND;
+
+ case CommonError::AlreadyRunning:
+ return WRT_ERROR_ALREADY_RUNNING;
+
+ case CommonError::InvalidLanguage:
+ return WRT_ERROR_INVALID_LANGUAGE;
+
+ case CommonError::AlreadyStopped:
+ return WRT_ERROR_ALREADY_STOPPED;
+
+ case CommonError::StillAuthorizing:
+ return WRT_ERROR_STILL_AUTHORIZING;
+
+ case CommonError::EarlyKilled:
+ return WRT_ERROR_EARLY_KILLED;
+
+ case CommonError::AccessDenied:
+ return WRT_ERROR_ACCESS_DENIED;
+
+ default:
+ LogError("Untranslatable error: " << status);
+ return WRT_ERROR_INTERNAL;
+ }
+}
+
+void StatusCallback(int widget_handle,
+ CommonError::Type result,
+ void *data)
+{
+ LogDebug("StatusCallback called " << widget_handle << " | " << result);
+ Assert(data != NULL);
+
+ WrtErrStatus error = TranslateError(result);
+ StatusCallbackStruct* statusCallbackStruct =
+ static_cast<StatusCallbackStruct*>(data);
+
+ if (statusCallbackStruct->status_callback) {
+ statusCallbackStruct->status_callback(widget_handle,
+ error,
+ statusCallbackStruct->userdata);
+ } else {
+ LogInfo("StatusCallback: ignoring NULL callback pointer");
+ }
+
+ delete statusCallbackStruct;
+}
+
+//// callback for finished install
+//void installFinishedCallback(void *userParam,
+// WidgetHandle widget_handle,
+// Jobs::WidgetInstall::Exceptions::Type status)
+//{
+// Assert(userParam != NULL);
+//
+// StatusCallbackStruct *apiStr =
+// static_cast<StatusCallbackStruct*>(userParam);
+//
+// if (apiStr->status_callback) {
+// // Translate error
+// WrtErrStatus errorStatus;
+//
+// switch (status) {
+// case Jobs::WidgetInstall::Exceptions::Success:
+// errorStatus = WRT_SUCCESS;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorInvalidWidgetPackage:
+// errorStatus = WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorWidgetDoesNotExist:
+// errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorFactoryWidget:
+// errorStatus = WRT_INSTALLER_ERROR_FACTORY_WIDGET;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorAreadyUninstalling:
+// errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorOutOfDiskSpace:
+// errorStatus = WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorInvalidPackage:
+// errorStatus = WRT_INSTALLER_ERROR_INVALID_CERTIFICATE;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorAlreadyInstalled:
+// errorStatus = WRT_INSTALLER_ERROR_ALREADY_INSTALLED;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorInternal:
+// errorStatus = WRT_INSTALLER_ERROR_INTERNAL;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorNotAllowed:
+// errorStatus = WRT_INSTALLER_ERROR_NOT_ALLOWED;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorDeferred:
+// errorStatus = WRT_INSTALLER_ERROR_DEFERRED;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorDatabaseFailure:
+// errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorInstallOspServcie:
+// errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+// break;
+//
+// case Jobs::WidgetInstall::Exceptions::ErrorUnknown:
+// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
+// break;
+//
+// default:
+// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
+// break;
+// }
+//
+// // Callback
+// apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
+// } else {
+// LogInfo("installFinishedCallback: No callback");
+// }
+//}
+
+// callback for finished install
+//void uninstallFinishedCallback(void *userParam,
+// WidgetHandle widget_handle,
+// Jobs::WidgetUninstall::Exceptions::Type status)
+//{
+// Assert(userParam != NULL);
+//
+// StatusCallbackStruct *apiStr =
+// static_cast<StatusCallbackStruct*>(userParam);
+//
+// if (apiStr->status_callback) {
+// // Translate error
+// WrtErrStatus errorStatus;
+//
+// switch (status) {
+// case Jobs::WidgetUninstall::Exceptions::Success:
+// errorStatus = WRT_SUCCESS;
+// break;
+//
+// case Jobs::WidgetUninstall::Exceptions::ErrorAlreadyUninstalling:
+// errorStatus = WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING;
+// break;
+//
+// case Jobs::WidgetUninstall::Exceptions::ErrorWidgetDoesNotExist:
+// errorStatus = WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST;
+// break;
+//
+// case Jobs::WidgetUninstall::Exceptions::ErrorDatabaseFailure:
+// errorStatus = WRT_INSTALLER_ERROR_DATABASE_FAILURE;
+// break;
+//
+// case Jobs::WidgetUninstall::Exceptions::ErrorUninstallOspSvcFailed:
+// errorStatus = WRT_INSTALLER_ERROR_OSPSVC;
+// break;
+//
+// case Jobs::WidgetUninstall::Exceptions::ErrorUnknown:
+// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
+// break;
+//
+// default:
+// errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
+// break;
+// }
+//
+// // Callback
+// apiStr->status_callback(widget_handle, errorStatus, apiStr->userdata);
+// } else {
+// LogInfo("uninstallFinishedCallback: No callback");
+// }
+//}
+
+void pluginInstallFinishedCallback(void *userParam,
+ Jobs::PluginInstall::Exceptions::Type status)
+{
+ Assert(userParam);
+
+ PluginStatusCallbackStruct *apiStr =
+ static_cast<PluginStatusCallbackStruct*>(userParam);
+
+ if (apiStr->statusCallback) {
+ // Translate error
+ WrtErrStatus errorStatus;
+
+ switch (status) {
+ case Jobs::PluginInstall::Exceptions::Success:
+ errorStatus = WRT_SUCCESS;
+ break;
+ case Jobs::PluginInstall::Exceptions::WrongPluginPath:
+ errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH;
+ break;
+ case Jobs::PluginInstall::Exceptions::MetafileError:
+ errorStatus = WRT_PLUGIN_INSTALLER_ERROR_METAFILE;
+ break;
+ case Jobs::PluginInstall::Exceptions::AlreadyInstalled:
+ errorStatus = WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED;
+ break;
+ case Jobs::PluginInstall::Exceptions::LoadingLibraryError:
+ errorStatus = WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR;
+ break;
+ case Jobs::PluginInstall::Exceptions::InstallationWaiting:
+ errorStatus = WRT_PLUGIN_INSTALLER_ERROR_WAITING;
+ break;
+ default:
+ errorStatus = WRT_INSTALLER_ERROR_UNKNOWN;
+ break;
+ }
+
+ apiStr->statusCallback(errorStatus, apiStr->userdata);
+ } else {
+ LogInfo("PluginInstallFinishedCallback: No callback");
+ }
+
+ delete apiStr;
+}
+
+// callback for progress of install OR uninstall
+void installProgressCallback(void *userParam,
+ ProgressPercent percent,
+ const ProgressDescription &description)
+{
+ Assert(userParam != NULL);
+
+ StatusCallbackStruct *apiStr =
+ static_cast<StatusCallbackStruct*>(userParam);
+
+ if (apiStr->progress_callback) {
+ //CALLBACK EXEC
+ LogInfo("Entered " << percent << "% " << description);
+ apiStr->progress_callback(static_cast<float>(percent),
+ description.c_str(),
+ apiStr->userdata);
+ } else {
+ LogInfo("installProgressCallback: ignoring NULL callback pointer");
+ }
+}
+
+} //namespace
+
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file api_callbacks_translate.h
+ * @author Pawel Sikorski (p.sikorski@samsung.com)
+ * @version 1.0
+ * @brief Header file for api callbacks translate functions
+ */
+#ifndef WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_
+#define WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_
+
+#include <wrt_installer_api.h>
+#include <wrt_common_types.h>
+//#include <widget_install/widget_install_errors.h>
+//#include <widget_uninstall/widget_uninstall_errors.h>
+#include <plugin_install/plugin_installer_errors.h>
+#include <job_base.h>
+
+namespace InstallerCallbacksTranslate {
+struct StatusCallbackStruct
+{
+ void* userdata;
+ WrtInstallerStatusCallback status_callback;
+ WrtProgressCallback progress_callback;
+
+ StatusCallbackStruct(void* u,
+ WrtInstallerStatusCallback s,
+ WrtProgressCallback p) :
+ userdata(u),
+ status_callback(s),
+ progress_callback(p)
+ {
+ }
+};
+
+struct PluginStatusCallbackStruct
+{
+ void* userdata;
+ WrtPluginInstallerStatusCallback statusCallback;
+ WrtProgressCallback progressCallback;
+
+ PluginStatusCallbackStruct(void* u,
+ WrtPluginInstallerStatusCallback s,
+ WrtProgressCallback p) :
+ userdata(u),
+ statusCallback(s),
+ progressCallback(p)
+ {
+ }
+};
+
+void StatusCallback(int widget_handle,
+ CommonError::Type result,
+ void *data);
+
+//void installFinishedCallback(void *userParam,
+// WidgetHandle widget_handle,
+// Jobs::WidgetInstall::Exceptions::Type status);
+//
+//void uninstallFinishedCallback(void *userParam,
+// WidgetHandle widget_handle,
+// Jobs::WidgetUninstall::Exceptions::Type status);
+
+void pluginInstallFinishedCallback(void *userParam,
+ Jobs::PluginInstall::Exceptions::Type status);
+
+// callback for progress of install OR uninstall
+void installProgressCallback(void *userParam,
+ ProgressPercent percent,
+ const ProgressDescription &description);
+
+} //namespace
+
+#endif /* WRT_SRC_API_API_CALLBACKS_TRANSLATE_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file installer_main_thread.cpp
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#include "installer_main_thread.h"
+#include <dpl/assert.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+#include <vcore/VCore.h>
+#include <dpl/singleton_impl.h>
+#include <dpl/assert.h>
+#include <installer_controller.h>
+//#include <dpl/popup/popup_controller.h>
+//#include <dpl/popup/popup_manager.h>
+//#include <ace_api_install.h>
+
+IMPLEMENT_SINGLETON(InstallerMainThread)
+
+using namespace WrtDB;
+//using namespace DPL::Popup;
+
+InstallerMainThread::InstallerMainThread() : m_attached(false) {
+}
+
+InstallerMainThread::~InstallerMainThread() {
+ Assert(!m_attached);
+}
+
+void InstallerMainThread::AttachDatabases()
+{
+ Assert(!m_attached);
+ // Attach databases
+ ValidationCore::AttachToThreadRW();
+// ace_return_t ret = ace_install_initialize();
+// Assert(ACE_OK == ret); // to be changed to exception in the future
+ WrtDB::WrtDatabase::attachToThreadRW();
+ m_attached = true;
+}
+
+void InstallerMainThread::DetachDatabases()
+{
+ Assert(m_attached);
+ m_attached = false;
+ // Detach databases
+ ValidationCore::DetachFromThread();
+// ace_return_t ret = ace_install_shutdown();
+// Assert(ACE_OK == ret); // to be changed to exception in the future
+ WrtDB::WrtDatabase::detachFromThread();
+}
+
+void InstallerMainThread::TouchArchitecture()
+{
+ // Touch controller
+ Logic::InstallerControllerSingleton::Instance().Touch();
+}
+
+void InstallerMainThread::TouchArchitectureOnlyInstaller()
+{
+ // Touch controller
+ Logic::InstallerControllerSingleton::Instance().Touch();
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file installer_main_thread.h
+ * @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
+ * @version 1.0
+ */
+
+#ifndef INSTALLER_MAINTHREAD_H_
+#define INSTALLER_MAINTHREAD_H_
+
+#include <dpl/singleton.h>
+
+class InstallerMainThread {
+ public:
+ void AttachDatabases();
+ void DetachDatabases();
+ void TouchArchitecture();
+ void TouchArchitectureOnlyInstaller();
+
+ private:
+ friend class DPL::Singleton<InstallerMainThread>;
+
+ InstallerMainThread();
+ virtual ~InstallerMainThread();
+
+ bool m_attached;
+};
+
+typedef DPL::Singleton<InstallerMainThread> InstallerMainThreadSingleton;
+
+#endif /* INSTALLER_MAINTHREAD_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file language_subtag_rst_tree.cpp
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ */
+#include <language_subtag_rst_tree.h>
+#include <dpl/log/log.h>
+#include <dpl/db/orm.h>
+#include <dpl/string.h>
+#include <dpl/wrt-dao-ro/global_dao_read_only.h>
+#include <iterator>
+#include <vector>
+#include <ctype.h>
+#include <dpl/singleton_impl.h>
+IMPLEMENT_SINGLETON(LanguageSubtagRstTree)
+
+bool LanguageSubtagRstTree::ValidateLanguageTag(const std::string &tag_input)
+{
+ std::string tag = tag_input;
+ std::transform(tag.begin(), tag.end(), tag.begin(), &tolower);
+
+ std::vector<DPL::String> parts;
+ DPL::Tokenize(DPL::FromUTF8String(tag),
+ '-',
+ std::back_inserter(parts),
+ false);
+ std::vector<DPL::String>::iterator token = parts.begin();
+ if (token == parts.end()) {
+ return false;
+ }
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_LANGUAGE)) {
+ ++token;
+ } else {
+ return false;
+ }
+
+ if (token == parts.end()) {
+ return true;
+ }
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_EXTLANG)) {
+ ++token;
+ }
+
+ if (token == parts.end()) {
+ return true;
+ }
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_SCRIPT)) {
+ ++token;
+ }
+
+ if (token == parts.end()) {
+ return true;
+ }
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(*token, RECORD_TYPE_REGION)) {
+ ++token;
+ }
+
+ if (token == parts.end()) {
+ return true;
+ }
+ while (token != parts.end()) {
+ if (WrtDB::GlobalDAOReadOnly::IsValidSubTag(
+ *token, RECORD_TYPE_VARIANT))
+ {
+ ++token;
+ } else {
+ break;
+ }
+ }
+
+ //'u' - unicode extension - only one BCP47 extension is registered.
+ //TODO: unicode extension should be also validated (l.wrzosek)
+ if (token == parts.end()) {
+ return true;
+ }
+ if (*token == L"u") {
+ ++token;
+ bool one_or_more = false;
+ while (token != parts.end() &&
+ token->size() > 1 &&
+ token->size() <= 8) {
+ one_or_more = true;
+ ++token;
+ }
+ if (!one_or_more) {
+ return false;
+ }
+ }
+
+ //'x' - privateuse
+ if (token == parts.end()) {
+ return true;
+ }
+ if (*token == L"x") {
+ ++token;
+ bool one_or_more = false;
+ while (token != parts.end() &&
+ !token->empty() &&
+ token->size() <= 8) {
+ one_or_more = true;
+ ++token;
+ }
+ if (!one_or_more) {
+ return false;
+ }
+ }
+
+ if (token == parts.end()) {
+ return true;
+ }
+
+ //Try private use now:
+ token = parts.begin();
+ if (*token == L"x") {
+ ++token;
+ bool one_or_more = false;
+ while (token != parts.end() &&
+ !token->empty() &&
+ token->size() <= 8) {
+ one_or_more = true;
+ ++token;
+ }
+ return one_or_more;
+ }
+
+ //grandfathered is always rejected
+ return false;
+}
+
+#define TEST_LANG(str, cond) \
+ if (LanguageSubtagRstTreeSingleton::Instance().\
+ ValidateLanguageTag(str) == cond) {\
+ LogDebug("Good validate status for lang: " << str);\
+ } else {\
+ LogError("Wrong validate status for lang: " << str\
+ << ", should be " << cond);\
+ }
+
+void LanguageSubtagRstTree::Initialize()
+{
+ /* Temporarily added unit test. Commented out due to performance drop.
+ TEST_LANG("zh", true);
+ TEST_LANG("esx-al", true);
+ TEST_LANG("zh-Hant", true);
+ TEST_LANG("zh-Hant-CN", true);
+ TEST_LANG("zh-Hant-CN-x-private1-private2", true);
+ TEST_LANG("plxxx", false);
+ TEST_LANG("pl-x-private111", false);
+ TEST_LANG("x-private1", false); //do not support pure private ones
+ TEST_LANG("x-private22", false);
+ TEST_LANG("i-private22", false); //do not support i-*
+ */
+}
+
+#undef TEST_LANG
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file language_subtag_rst_tree.h
+ * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
+ * @version 1.0
+ */
+#ifndef LANGUAGE_SUBTAG_RST_TREE_H
+#define LANGUAGE_SUBTAG_RST_TREE_H
+
+#include <dpl/singleton.h>
+#include <dpl/noncopyable.h>
+#include <string>
+class LanguageSubtagRstTree : DPL::Noncopyable
+{
+ public:
+ void Initialize();
+ bool ValidateLanguageTag(const std::string &tag);
+};
+
+typedef DPL::Singleton<LanguageSubtagRstTree> LanguageSubtagRstTreeSingleton;
+
+enum iana_record_types_e
+{
+ RECORD_TYPE_LANGUAGE,
+ RECORD_TYPE_SCRIPT,
+ RECORD_TYPE_REGION,
+ RECORD_TYPE_VARIANT,
+ RECORD_TYPE_GRANDFATHERED,
+ RECORD_TYPE_REDUNDANT,
+ RECORD_TYPE_EXTLANG
+};
+
+#endif //LANGUAGE_SUBTAG_RST_TREE_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file option_parser.cpp
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @brief Implementation file for OptionParser.
+ */
+
+#include <vector>
+#include <algorithm>
+#include <dpl/string.h>
+#include "option_parser.h"
+
+DPL::OptionalString OptionParser::QueryOption(int argc,
+ char* argv[],
+ const std::string& name)
+{
+ DPL::OptionalString result;
+
+ std::vector<std::string> args(argv, (argv + argc));
+
+ auto it = std::find_if(args.begin(),
+ args.end(),
+ [&name](const std::string& option){
+ return (option == name);
+ });
+
+ if (it != args.end())
+ {
+ std::string value;
+ while ((++it != args.end()) && !IsOption(*it))
+ {
+ value += *it + " ";
+ }
+ result = DPL::FromUTF8String(value);
+ }
+
+ return result;
+}
+
+bool OptionParser::IsOption(const std::string& name)
+{
+ return (name.find('-') == 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file option_parser.h
+ * @author Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ * @brief Header file for OptionParser.
+ */
+
+#ifndef WRT_INSTALLER_SRC_WRT_INSTALLER_OPTION_PARSER_H_
+#define WRT_INSTALLER_SRC_WRT_INSTALLER_OPTION_PARSER_H_
+
+#include <string>
+#include <dpl/optional_typedefs.h>
+
+class OptionParser
+{
+public:
+ static DPL::OptionalString QueryOption(int argc,
+ char* argv[],
+ const std::string& name);
+
+private:
+ static bool IsOption(const std::string& name);
+};
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin-utils.cpp
+ * @author
+ * @version 1.0
+ * @brief Header file for plugin util
+ */
+
+#include "plugin_utils.h"
+#include <dpl/semaphore.h>
+#include <dpl/exception.h>
+#include <dpl/log/log.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+
+using namespace WrtDB;
+
+namespace PluginUtils {
+const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+
+static DPL::Semaphore semaphore(PLUGIN_INSTALL_SEMAPHORE);
+
+bool lockPluginInstallation()
+{
+ Try {
+ semaphore.Lock();
+ return true;
+ }
+ Catch(DPL::Semaphore::Exception::Base){
+ return false;
+ }
+}
+
+bool unlockPluginInstallation()
+{
+ Try {
+ semaphore.Unlock();
+ return true;
+ }
+ Catch(DPL::Semaphore::Exception::Base){
+ return false;
+ }
+}
+
+bool checkPluginInstallationRequired()
+{
+ std::string installRequest =
+ std::string(GlobalConfig::GetPluginInstallInitializerName());
+
+ FileState::Type installationRequest =
+ checkFile(installRequest);
+
+ switch (installationRequest) {
+ case FileState::FILE_EXISTS:
+ return true;
+ case FileState::FILE_NOT_EXISTS:
+ return false;
+ default:
+ LogWarning("Opening installation request file failed");
+ return false;
+ }
+}
+
+bool removeInstallationRequiredFlag()
+{
+ std::string installRequest =
+ std::string(GlobalConfig::GetPluginInstallInitializerName());
+
+ return removeFile(installRequest);
+}
+
+//checks if file exists and is regular file
+FileState::Type checkFile(const std::string& filename)
+{
+ struct stat tmp;
+
+ if (-1 == stat(filename.c_str(), &tmp)) {
+ if (ENOENT == errno) {
+ return FileState::FILE_NOT_EXISTS;
+ }
+ return FileState::FILE_READ_DATA_ERROR;
+ } else if (!S_ISREG(tmp.st_mode)) {
+ return FileState::FILE_EXISTS_NOT_REGULAR;
+ }
+ return FileState::FILE_EXISTS;
+}
+
+bool removeFile(const std::string& filename)
+{
+ if (0 != unlink(filename.c_str())) {
+ return false;
+ }
+
+ return true;
+}
+} //namespace PluginUtils
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file plugin-utils.h
+ * @author
+ * @version 1.0
+ * @brief Header file for plugin util
+ */
+#ifndef PLUGIN_UTILS_H
+#define PLUGIN_UTILS_H
+
+#include <string>
+#include <sys/stat.h>
+
+namespace PluginUtils {
+struct FileState
+{
+ enum Type
+ {
+ FILE_EXISTS,
+ FILE_EXISTS_NOT_REGULAR,
+ FILE_NOT_EXISTS,
+ FILE_READ_DATA_ERROR
+ };
+};
+
+bool lockPluginInstallation();
+bool unlockPluginInstallation();
+bool checkPluginInstallationRequired();
+bool removeInstallationRequiredFlag();
+FileState::Type checkFile(const std::string& filename);
+bool removeFile(const std::string& filename);
+
+}
+#endif // PLUGIN_UTILS_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/* @file wrt_installer.cpp
+ * @version 1.0
+ * @brief Implementation file for installer
+ */
+
+#include "wrt_installer.h"
+#include "plugin_utils.h"
+
+#include <cstdlib>
+#include <string>
+#include <fstream>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <dpl/optional.h>
+#include <dpl/scoped_free.h>
+#include <dpl/optional_typedefs.h>
+#include <dpl/exception.h>
+#include <dpl/sstream.h>
+#include <vconf.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/wrt-dao-ro/config_parser_data.h>
+#include <dpl/localization/localization_utils.h>
+#include <dpl/popup/popup_controller.h>
+#include <dpl/optional_typedefs.h>
+#include <dpl/string.h>
+#include <dpl/abstract_waitable_input_adapter.h>
+#include <dpl/abstract_waitable_output_adapter.h>
+#include <dpl/zip_input.h>
+#include <dpl/scoped_ptr.h>
+#include <dpl/binary_queue.h>
+#include <dpl/copy.h>
+#include <dpl/utils/wrt_global_settings.h>
+#include "option_parser.h"
+#include <parser_runner.h>
+#include <widget_parser.h>
+#include <root_parser.h>
+//#include <pkg-manager/pkgmgr_signal.h>
+
+#define NOFILE_CNT_FOR_INSTALLER 9999
+
+using namespace WrtDB;
+
+namespace { // anonymous
+const char AUL_ARG_KEY[] = "widget_arg";
+const char * const PKGMGR_INSTALL_MSG = "Install widget";
+const char * const PKGMGR_UNINSTALL_MSG = "Uninstall widget";
+
+const double BASE_LAYOUT_W = 720.0f;
+const double BASE_LAYOUT_H = 1280.0f;
+
+const char * const CONFIG_XML = "config.xml";
+
+struct PluginInstallerData
+{
+ void* wrtInstaller;
+ std::string pluginPath;
+};
+} // namespace anonymous
+
+WrtInstaller::WrtInstaller(int argc, char **argv) :
+ Application(argc, argv, "backend", false),
+ DPL::TaskDecl<WrtInstaller>(this),
+ m_packagePath(),
+ m_handle(-1),
+ m_initialized(false),
+ m_numPluginsToInstall(0),
+ m_totalPlugins(0),
+ m_returnStatus(-1),
+// m_installByPkgmgr(false),
+ m_quiet(true),
+// m_popup(NULL),
+ m_startupPluginInstallation(false)
+{
+ Touch();
+ LogDebug("App Created");
+}
+
+WrtInstaller::~WrtInstaller()
+{
+ LogDebug("App Finished");
+}
+
+void WrtInstaller::OnStop()
+{
+ LogInfo("Stopping Dummy Client");
+}
+
+void WrtInstaller::OnCreate()
+{
+ LogInfo("Creating DummyClient");
+
+ AddStep(&WrtInstaller::initStep);
+
+ std::string arg = m_argv[0];
+
+ if (arg.empty()) {
+ return showHelpAndQuit();
+ }
+
+ installNewPlugins();
+
+ if (arg.find("wrt-installer") != std::string::npos)
+ {
+ if (m_argc <= 1) {
+ return showHelpAndQuit();
+ }
+
+ arg = m_argv[1];
+ if (arg == "-h" || arg == "--help") {
+ if (m_argc != 2) {
+ return showHelpAndQuit();
+ }
+
+ // Just show help
+ return showHelpAndQuit();
+ } else if (arg == "-p" || arg == "--install-plugins") {
+ if (m_argc != 2) {
+ return showHelpAndQuit();
+ }
+ if (!m_startupPluginInstallation) {
+ AddStep(&WrtInstaller::installPluginsStep);
+ } else {
+ LogInfo("Plugin installation alredy started");
+ }
+ }
+ else
+ {
+ LogError("Unknown option");
+ return showHelpAndQuit();
+ }
+ }
+
+ AddStep(&WrtInstaller::shutdownStep);
+ DPL::Event::ControllerEventHandler<
+ WRTInstallerNS::NextStepEvent>::PostEvent(
+ WRTInstallerNS::NextStepEvent());
+}
+
+//void WrtInstaller::OnReset(bundle *b)
+//{
+// const char * bundledVal = bundle_get_val(b, AUL_ARG_KEY);
+// if (bundledVal != NULL) {
+// m_bundleValue = bundledVal;
+// LogInfo("Bundled value for (" << AUL_ARG_KEY << ") key received: " <<
+// m_bundleValue);
+// }
+//}
+
+int WrtInstaller::getReturnStatus() const
+{
+ if (!m_returnStatus) {
+ return RE_SUCCESS;
+ } else {
+ return RE_FAIL;
+ }
+}
+
+void WrtInstaller::OnTerminate()
+{
+ LogDebug("Wrt Shutdown now");
+ PluginUtils::unlockPluginInstallation();
+ if (m_initialized) {
+ wrt_installer_shutdown();
+ }
+// delete m_popup;
+}
+
+void WrtInstaller::showHelpAndQuit()
+{
+ printf("Usage: wrt-installer [OPTION]... [WIDGET: ID/NAME/GUID/PATH]...\n"
+ "Operate with WebRuntime daemon: install, uninstall"
+ " and launch widgets.\n"
+ "Query list of installed widgets and setup up debugging support.\n"
+ "\n"
+ "Exactly one option must be selected.\n"
+ "Mandatory arguments to long options are mandatory for short "
+ "options too.\n"
+ " -h, --help show this help\n"
+ " -p, --install-plugins install plugins\n"
+ "\n");
+
+ Quit();
+}
+
+void WrtInstaller::OnEventReceived(const WRTInstallerNS::QuitEvent& /*event*/)
+{
+ LogDebug("Quiting");
+
+ if (m_initialized) {
+ LogDebug("Wrt Shutdown now");
+ SwitchToStep(&WrtInstaller::shutdownStep);
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>::PostEvent(
+ WRTInstallerNS::NextStepEvent());
+ } else {
+ LogDebug("Quiting application");
+ return Quit();
+ }
+}
+
+void WrtInstaller::OnEventReceived(
+ const WRTInstallerNS::NextStepEvent& /*event*/)
+{
+ LogDebug("Executing next step");
+ NextStep();
+}
+
+void WrtInstaller::OnEventReceived(
+ const WRTInstallerNS::InstallPluginEvent& /*event*/)
+{
+ PluginInstallerData* privateData = new PluginInstallerData;
+ privateData->wrtInstaller = this;
+
+ if (!(*m_pluginsPaths).empty()) {
+ privateData->pluginPath = (*m_pluginsPaths).front();
+ (*m_pluginsPaths).pop_front();
+
+ wrt_install_plugin(privateData->pluginPath.c_str(),
+ static_cast<void*>(privateData),
+ &staticWrtPluginInstallationCallback,
+ &staticWrtPluginInstallProgressCb);
+ } else {
+ delete privateData;
+ }
+}
+
+void WrtInstaller::initStep()
+{
+ wrt_installer_init(this, staticWrtInitCallback);
+}
+
+//void WrtInstaller::installStep()
+//{
+// LogDebug("Installing widget ...");
+// DPL::ScopedFree<char> packagePath(canonicalize_file_name(
+// m_packagePath.c_str()));
+//
+// wrt_install_widget(packagePath ? packagePath.Get() : m_packagePath.c_str(),
+// this, &staticWrtStatusCallback,
+// (!m_quiet || m_installByPkgmgr)
+// ? &staticWrtInstallProgressCallback : NULL,
+// m_installPolicy,
+// m_quiet);
+//}
+
+void WrtInstaller::installPluginsStep()
+{
+ LogDebug("Installing plugins ...");
+
+ if (m_startupPluginInstallation) {
+ LogInfo("Plugin installation started because new plugin package found");
+ } else if (!PluginUtils::lockPluginInstallation()) {
+ LogError("Failed to open plugin installation lock file"
+ " Plugins are currently installed by other process");
+ staticWrtPluginInstallationCallback(WRT_PLUGIN_INSTALLER_ERROR_LOCK,
+ this);
+ return;
+ }
+
+ std::string PLUGIN_PATH = std::string(GlobalConfig::GetDevicePluginPath());
+
+ DIR *dir;
+ dir = opendir(PLUGIN_PATH.c_str());
+
+ if (!dir) {
+ return;
+ }
+
+ LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+ struct dirent* libdir;
+
+ errno = 0;
+
+ std::list<std::string> pluginsPaths;
+
+ while ((libdir = readdir(dir)) != 0) {
+ if (strcmp(libdir->d_name, ".") == 0 ||
+ strcmp(libdir->d_name, "..") == 0)
+ {
+ continue;
+ }
+
+ std::string path = PLUGIN_PATH;
+ path += "/";
+ path += libdir->d_name;
+
+ struct stat tmp;
+
+ if (stat(path.c_str(), &tmp) == -1) {
+ LogError("Failed to open file" << path);
+ continue;
+ }
+
+ if (!S_ISDIR(tmp.st_mode)) {
+ LogError("Not a directory" << path);
+ continue;
+ }
+
+ pluginsPaths.push_back(path);
+ }
+
+ //set nb of plugins to install
+ //this value indicate how many callbacks are expected
+ m_numPluginsToInstall = pluginsPaths.size();
+ LogInfo("Plugins to install: " << m_numPluginsToInstall);
+ m_pluginsPaths = pluginsPaths;
+
+ m_totalPlugins = m_numPluginsToInstall;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>
+ ::PostEvent(WRTInstallerNS::InstallPluginEvent());
+
+ if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+ LogError("Failed to close dir: " << dir);
+ }
+}
+
+//void WrtInstaller::uninstallStep()
+//{
+// LogDebug("Uninstalling widget ...");
+// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+// (!m_quiet || m_installByPkgmgr)
+// ? &staticWrtUninstallProgressCallback : NULL);
+//}
+
+//void WrtInstaller::uninstallPkgNameStep()
+//{
+// LogDebug("Uninstalling widget ...");
+// WrtErrStatus status = wrt_get_widget_by_pkgname(m_name, &m_handle);
+// if (status == WRT_SUCCESS) {
+// LogDebug("Get Widget Handle by package name : " << m_handle);
+// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+// (!m_quiet || m_installByPkgmgr)
+// ? &staticWrtUninstallProgressCallback : NULL);
+// } else {
+// printf("failed: can not uninstall widget\n");
+// LogError("Fail to uninstalling widget... ");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+//}
+
+//void WrtInstaller::uninstallGuidStep()
+//{
+// LogDebug("Uninstalling widget ...");
+// WrtErrStatus status = wrt_get_widget_by_guid(m_name, &m_handle);
+// if (status == WRT_SUCCESS) {
+// LogDebug("Get Widget Handle by guid : " << m_handle);
+// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+// !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
+// } else {
+// printf("failed: can not uninstall widget\n");
+// LogError("Fail to uninstalling widget... ");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+//}
+//
+//void WrtInstaller::unistallWgtFileStep()
+//{
+// LogDebug("Uninstalling widget ...");
+//
+// Try {
+// // Parse config
+// ParserRunner parser;
+// ConfigParserData configInfo;
+//
+// // Open zip file
+// DPL::ScopedPtr<DPL::ZipInput> zipFile(
+// new DPL::ZipInput(m_packagePath));
+//
+// // Open config.xml file
+// DPL::ScopedPtr<DPL::ZipInput::File> configFile(
+// zipFile->OpenFile(CONFIG_XML));
+//
+// // Extract config
+// DPL::BinaryQueue buffer;
+// DPL::AbstractWaitableInputAdapter inputAdapter(configFile.Get());
+// DPL::AbstractWaitableOutputAdapter outputAdapter(&buffer);
+// DPL::Copy(&inputAdapter, &outputAdapter);
+// parser.Parse(&buffer,
+// ElementParserPtr(
+// new RootParser<WidgetParser>(configInfo,
+// DPL::FromUTF32String(
+// L"widget"))));
+//
+// DPL::OptionalString widgetGUID = configInfo.widget_id;
+//
+// std::string guid = DPL::ToUTF8String(*widgetGUID);
+//
+// WrtErrStatus status = wrt_get_widget_by_guid(guid, &m_handle);
+// if (status == WRT_SUCCESS) {
+// LogDebug("Get Widget Handle by guid : " << m_handle);
+// wrt_uninstall_widget(m_handle, this, &staticWrtStatusCallback,
+// !m_quiet ? &staticWrtUninstallProgressCallback : NULL);
+// } else {
+// LogError("Fail to uninstalling widget... ");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+// }
+// Catch(DPL::ZipInput::Exception::OpenFailed)
+// {
+// LogError("Failed to open widget package");
+// printf("failed: widget package does not exist\n");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+// Catch(DPL::ZipInput::Exception::OpenFileFailed)
+// {
+// printf("failed: widget config file does not exist\n");
+// LogError("Failed to open config.xml file");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+// Catch(ElementParser::Exception::ParseError)
+// {
+// printf("failed: can not parse config file\n");
+// LogError("Failed to parse config.xml file");
+// m_returnStatus = -1;
+// DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+// WRTInstallerNS::QuitEvent());
+// }
+//}
+
+void WrtInstaller::shutdownStep()
+{
+ LogDebug("Closing Wrt connection ...");
+ if (m_initialized) {
+ wrt_installer_shutdown();
+ m_initialized = false;
+ DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+}
+
+void WrtInstaller::staticWrtInitCallback(WrtErrStatus status,
+ void* userdata)
+{
+ WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
+ Assert(This);
+
+ if (status == WRT_SUCCESS) {
+ LogDebug("Init succesfull");
+ This->m_initialized = true;
+ This->m_returnStatus = 0;
+
+// if (!This->m_quiet) {
+// This->m_popup = new InstallerPopup;
+// This->m_popup->init();
+// }
+
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+ ::PostEvent(WRTInstallerNS::NextStepEvent());
+ } else {
+ LogError("Init unsuccesfull");
+ This->m_returnStatus = -1;
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>::PostEvent(
+ WRTInstallerNS::QuitEvent());
+ }
+}
+//
+//void WrtInstaller::staticWrtStatusCallback(int handle,
+// WrtErrStatus status,
+// void* userdata)
+//{
+// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
+// Assert(This);
+//
+// Step current = This->GetCurrentStep();
+// DPL::String resultMsg;
+// std::string printMsg;
+//
+// if (current == &WrtInstaller::installStep)
+// {
+// resultMsg = DPL::FromUTF8String(PKGMGR_INSTALL_MSG);
+// printMsg = "installed";
+// } else if (current == &WrtInstaller::uninstallStep ||
+// current == &WrtInstaller::uninstallPkgNameStep ||
+// current == &WrtInstaller::uninstallGuidStep ||
+// current == &WrtInstaller::unistallWgtFileStep)
+// {
+// resultMsg = DPL::FromUTF8String(PKGMGR_UNINSTALL_MSG);
+// printMsg = "uninstalled";
+// }
+//
+// if (WRT_SUCCESS != status) {
+// // Failure
+// LogDebug("Step failed");
+// This->m_returnStatus = -1;
+//
+// if (!This->m_quiet) {
+// resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_FAILURE);
+// This->m_popup->showPopup(This, resultMsg, failResultCallback);
+// } else {
+// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
+// ::PostEvent(WRTInstallerNS::QuitEvent());
+// }
+//
+// switch (status) {
+// case WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE:
+// This->m_returnStatus = 1; //this status is specific
+// printf("failed: invalid widget package\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST:
+// printf("failed: widget package does not exist\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_FACTORY_WIDGET:
+// printf("failed: factory widget\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING:
+// printf("failed: already uninstalling\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE:
+// printf("failed: out of disk space\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_INVALID_CERTIFICATE:
+// printf("failed: invalid certificate\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_ALREADY_INSTALLED:
+// printf("failed: already installed\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_INTERNAL:
+// printf("failed: internal error\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_NOT_ALLOWED:
+// printf("failed: installation or update not allowed; invalid"
+// " mode\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_DEFERRED:
+// printf("deferred: widget update will continue after the widget"
+// " has been stopped\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_DATABASE_FAILURE:
+// printf("failed: database failure\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_OSPSVC:
+// printf("failed: during installation or uninstallation osp service\n");
+// break;
+//
+// case WRT_INSTALLER_ERROR_UNKNOWN:
+// printf("failed: unknown error\n");
+// break;
+//
+// default:
+// break;
+// }
+// } else {
+//
+// printf("%s : %d\n", printMsg.c_str(), handle);
+// LogDebug("Status succesfull");
+// This->m_handle = handle;
+// This->m_returnStatus = 0;
+// resultMsg += L" : " + DPL::FromUTF8String(PKGMGR_END_SUCCESS);
+//
+// if (!This->m_quiet) {
+// This->m_popup->showPopup(This, resultMsg, showResultCallback);
+// } else {
+// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+// ::PostEvent(WRTInstallerNS::NextStepEvent());
+// }
+// }
+//}
+
+void WrtInstaller::staticWrtPluginInstallationCallback(WrtErrStatus status,
+ void* userdata)
+{
+ Assert(userdata);
+
+ PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
+
+ WrtInstaller *This = static_cast<WrtInstaller*>(data->wrtInstaller);
+
+ std::string path = std::string(data->pluginPath);
+ delete data;
+
+ This->m_numPluginsToInstall--;
+ LogDebug("Plugins to install: " << This->m_numPluginsToInstall);
+
+ if (This->m_numPluginsToInstall < 1) {
+ LogDebug("All plugins installation completed");
+
+ //remove installation request
+ if (!PluginUtils::removeInstallationRequiredFlag()) {
+ LogInfo("Failed to remove file initializing plugin installation");
+ }
+
+ //remove lock file
+ if (!PluginUtils::unlockPluginInstallation()) {
+ LogInfo("Failed to remove installation lock");
+ }
+
+// if (!This->m_quiet) {
+// This->m_popup->init();
+// elm_progressbar_value_set(This->m_popup->m_progressbar, 100.0);
+// evas_object_show(This->m_popup->m_popup);
+// }
+
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+ ::PostEvent(WRTInstallerNS::NextStepEvent());
+ } else {
+// if (!This->m_quiet) {
+// This->m_popup->init();
+// float percent = (This->m_totalPlugins - This->m_numPluginsToInstall)/(float)This->m_totalPlugins;
+// elm_progressbar_value_set(This->m_popup->m_progressbar, percent);
+// evas_object_show(This->m_popup->m_popup);
+// }
+
+ This->DPL::Event::ControllerEventHandler<WRTInstallerNS::InstallPluginEvent>::PostEvent(
+ WRTInstallerNS::InstallPluginEvent());
+ }
+
+ if (WRT_SUCCESS == status) {
+ This->m_returnStatus = 0;
+ LogDebug("One plugin Installation succesfull: " << path);
+ return;
+ }
+
+ // Failure
+ LogWarning("One of the plugins installation failed!: " << path);
+
+ if (WRT_PLUGIN_INSTALLER_ERROR_WAITING == status) {
+ LogInfo("Plugin installation is waiting for dependencies");
+ }
+
+ switch (status) {
+ case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
+ LogError("failed: wrong path to plugin directory\n");
+ break;
+
+ case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
+ LogError("failed: plugin metafile error\n");
+ break;
+
+ case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
+ LogError("failed: plugin already installed\n");
+ break;
+
+ case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
+ LogError("failed: plugin library: missing symbols or structures\n");
+ break;
+
+ case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
+ LogError("failed: unknown error\n");
+ break;
+
+ default:
+ break;
+ }
+}
+
+void WrtInstaller::staticWrtPluginInstallProgressCb(float percent,
+ const char* description,
+ void* userdata)
+{
+ PluginInstallerData* data = static_cast<PluginInstallerData*>(userdata);
+
+ std::string path = std::string(data->pluginPath);
+
+ LogInfo("Plugin Installation: " << path <<
+ " progress: " << percent <<
+ "description " << description);
+}
+
+//void WrtInstaller::staticWrtInstallProgressCallback(float percent,
+// const char* description, void* userdata)
+//{
+// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
+// std::stringstream percentStr;
+// LogInfo(" progress: " << percent <<
+// " description: " << description);
+//
+// if (!This->m_quiet) {
+// This->m_popup->init();
+// elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+// evas_object_show(This->m_popup->m_popup);
+// }
+//}
+//void WrtInstaller::staticWrtUninstallProgressCallback(float percent,
+// const char* description, void* userdata)
+//{
+// WrtInstaller *This = static_cast<WrtInstaller*>(userdata);
+// std::stringstream percentStr;
+// LogInfo(" progress: " << percent <<
+// " description: " << description);
+//
+// if (!This->m_quiet) {
+// This->m_popup->init();
+// elm_progressbar_value_set(This->m_popup->m_progressbar, percent/100.0);
+// evas_object_show(This->m_popup->m_popup);
+// }
+//}
+
+#if 0
+WrtInstaller::InstallerPopup::InstallerPopup() :
+ m_win(NULL),
+ m_popup(NULL),
+ m_progressbar(NULL)
+{
+}
+
+WrtInstaller::InstallerPopup::~InstallerPopup()
+{
+ LogDebug("App Finished");
+}
+
+void WrtInstaller::InstallerPopup::init()
+{
+ LogDebug("Window Init");
+
+ if (m_win == NULL) {
+ // create window
+ m_win = createWin("wrt-installer");
+
+ // create popup
+ m_popup = elm_popup_add(m_win);
+
+ // create progressbar
+ m_progressbar = elm_progressbar_add(m_popup);
+ elm_object_style_set(m_progressbar, "list_progress");
+ elm_progressbar_horizontal_set(m_progressbar, EINA_TRUE);
+ evas_object_size_hint_align_set(m_progressbar, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(m_progressbar, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ elm_object_content_set(m_popup, m_progressbar);
+ elm_progressbar_value_set(m_progressbar, 0.0);
+ evas_object_show(m_progressbar);
+
+ evas_object_show(m_popup);
+ evas_object_show(m_win);
+ }
+}
+
+Evas_Object* WrtInstaller::InstallerPopup::createWin(const char *name)
+{
+ Evas_Object *win;
+ win = elm_win_add(NULL, name, ELM_WIN_DIALOG_BASIC);
+
+ int w, h;
+ if(!win)
+ return NULL;
+
+ elm_win_alpha_set(win, EINA_TRUE);
+ elm_win_title_set(win, name);
+ elm_win_borderless_set(win, EINA_TRUE);
+ elm_win_raise(win);
+
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+ evas_object_resize(win, w, h);
+ return win;
+}
+
+void WrtInstaller::InstallerPopup::showPopup(void* userdata,
+ const DPL::String& pkgMsg,
+ ShowResultCallback callback)
+{
+ Evas_Object *btn;
+
+
+ LogDebug("Result Popup Created");
+ evas_object_del(m_popup);
+ m_popup = NULL;
+
+ m_popup = elm_popup_add(m_win);
+ if (!m_popup)
+ return;
+
+ btn = elm_button_add(m_popup);
+ if (!btn) {
+ evas_object_del(m_popup);
+ return;
+ }
+ elm_object_text_set(btn, "OK");
+ evas_object_smart_callback_add(btn, "clicked", callback, userdata);
+ elm_object_part_content_set(m_popup, "button1", btn);
+ elm_object_part_text_set(m_popup, "title,text", "RESULT");
+ elm_object_text_set(m_popup, DPL::ToUTF8String(pkgMsg).c_str());
+
+ evas_object_show(m_popup);
+ evas_object_show(m_win);
+
+}
+#endif
+
+//void WrtInstaller::showResultCallback(void *data, Evas_Object* /*obj*/,
+// void* /*event_info*/)
+//{
+// WrtInstaller *This = static_cast<WrtInstaller*>(data);
+// Assert(This);
+//
+// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::NextStepEvent>
+// ::PostEvent(WRTInstallerNS::NextStepEvent());
+//}
+//
+//void WrtInstaller::failResultCallback(void *data, Evas_Object* /*obj*/,
+// void* /*event_info*/)
+//{
+// WrtInstaller *This = static_cast<WrtInstaller*>(data);
+// Assert(This);
+//
+// This->DPL::Event::ControllerEventHandler<WRTInstallerNS::QuitEvent>
+// ::PostEvent(WRTInstallerNS::QuitEvent());
+//}
+
+void WrtInstaller::installNewPlugins()
+{
+ LogDebug("Install new plugins");
+
+ if (!PluginUtils::lockPluginInstallation()) {
+ LogInfo("Lock NOT created");
+ return;
+ }
+
+ if (!PluginUtils::checkPluginInstallationRequired()) {
+ LogDebug("Plugin installation not required");
+ PluginUtils::unlockPluginInstallation();
+ return;
+ }
+
+ m_startupPluginInstallation = true;
+ AddStep(&WrtInstaller::installPluginsStep);
+}
+
+int main(int argc, char *argv[])
+{
+ // Output on stdout will be flushed after every newline character,
+ // even if it is redirected to a pipe. This is useful for running
+ // from a script and parsing output.
+ // (Standard behavior of stdlib is to use full buffering when
+ // redirected to a pipe, which means even after an end of line
+ // the output may not be flushed).
+ setlinebuf(stdout);
+
+ // Check and re-set the file open limitation
+ struct rlimit rlim;
+ if (getrlimit(RLIMIT_NOFILE, &rlim) != -1) {
+ LogDebug("RLIMIT_NOFILE sft(" << rlim.rlim_cur << ")" );
+ LogDebug("RLIMIT_NOFILE hrd(" << rlim.rlim_max << ")" );
+
+ if (rlim.rlim_cur < NOFILE_CNT_FOR_INSTALLER) {
+ rlim.rlim_cur = NOFILE_CNT_FOR_INSTALLER;
+ rlim.rlim_max = NOFILE_CNT_FOR_INSTALLER;
+ if (setrlimit(RLIMIT_NOFILE, &rlim) == -1) {
+ LogError("setrlimit is fail!!");
+ }
+ }
+ } else {
+ LogError("getrlimit is fail!!");
+ }
+
+ // set evas backend type for emulator
+ // popup isn't showed in the emulator,
+ // if backend isn't set to SW backend
+// if (GlobalSettings::IsEmulator()) {
+// if (setenv("ELM_ENGINE", "x11", 1)) {
+// LogDebug("Enable backend");
+// }
+// }
+
+ WrtInstaller app(argc, argv);
+ int ret = app.Exec();
+ LogDebug("App returned: " << ret);
+ ret = app.getReturnStatus();
+ LogDebug("WrtInstaller returned: " << ret);
+ return ret;
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file wrt_installer.h
+ * @version 1.0
+ * @brief Implementation file for installer
+ */
+#ifndef WRT_CLIENT_H
+#define WRT_CLIENT_H
+
+#include <dpl/application.h>
+#include <dpl/generic_event.h>
+#include <dpl/event/controller.h>
+#include <dpl/type_list.h>
+#include <dpl/task.h>
+#include <dpl/log/log.h>
+#include <dpl/string.h>
+#include <string>
+//#include <utilX.h>
+#include <wrt_installer_api.h>
+//#include <pkgmgr_installer.h>
+
+namespace WRTInstallerNS { //anonymous
+DECLARE_GENERIC_EVENT_0(QuitEvent)
+DECLARE_GENERIC_EVENT_0(NextStepEvent)
+DECLARE_GENERIC_EVENT_0(InstallPluginEvent)
+}
+
+typedef void (*ShowResultCallback)(void *data, Evas_Object *obj,
+ void *event_info);
+
+enum ReturnValue
+{
+ RE_SUCCESS,
+ RE_FAIL
+};
+
+class WrtInstaller :
+ public DPL::Application,
+ private DPL::Event::Controller<DPL::TypeListDecl<
+ WRTInstallerNS::QuitEvent,
+ WRTInstallerNS::NextStepEvent,
+ WRTInstallerNS::InstallPluginEvent>::Type>,
+ public DPL::TaskDecl<WrtInstaller>
+{
+ public:
+ WrtInstaller(int argc,
+ char **argv);
+ virtual ~WrtInstaller();
+
+
+ int getReturnStatus() const;
+
+ class InstallerPopup
+ {
+ public:
+ InstallerPopup();
+ virtual ~InstallerPopup();
+
+ void init();
+ Evas_Object* createWin(const char* name);
+ void showPopup(void* userdata, const DPL::String& pkgMsg,
+ ShowResultCallback callback);
+
+ Evas_Object* m_win;
+ Evas_Object* m_popup;
+ Evas_Object* m_progressbar;
+ };
+
+ protected:
+ virtual void OnStop();
+ virtual void OnCreate();
+// virtual void OnReset(bundle *b);
+ virtual void OnTerminate();
+
+ private:
+ void showHelpAndQuit();
+
+ // Events
+ virtual void OnEventReceived(const WRTInstallerNS::QuitEvent &event);
+ virtual void OnEventReceived(const WRTInstallerNS::NextStepEvent& event);
+ virtual void OnEventReceived(const WRTInstallerNS::InstallPluginEvent& event);
+
+ // Installation steps
+ void initStep();
+// void installStep();
+ void installNewPlugins();
+ void installPluginsStep();
+// void uninstallStep();
+// void uninstallPkgNameStep();
+// void uninstallGuidStep();
+// void unistallWgtFileStep();
+ void shutdownStep();
+ void registerCallbackStep();
+// void queryListStep();
+
+
+ // Static callbacks
+ static void staticWrtInitCallback(WrtErrStatus status,
+ void* userdata);
+// static void staticWrtStatusCallback(int handle,
+// WrtErrStatus status,
+// void* userdata);
+ static void staticWrtPluginInstallationCallback(WrtErrStatus status,
+ void* userdata);
+ static void staticWrtPluginInstallProgressCb(float percent,
+ const char* description,
+ void* userdata);
+// static void staticWrtInstallProgressCallback(float percent,
+// const char* description,
+// void* userdata);
+//
+// static void staticWrtUninstallProgressCallback(float percent,
+// const char* description,
+// void* userdata);
+//
+// static void showResultCallback(void *data, Evas_Object *obj,
+// void *event_info);
+// static void failResultCallback(void *data, Evas_Object *obj,
+// void *event_info);
+
+ // Private data
+ wrt_widget_install_mode_e m_installPolicy;
+ std::string m_bundleValue;
+ std::string m_packagePath;
+ int m_handle;
+ std::string m_name;
+ bool m_initialized;
+ size_t m_numPluginsToInstall;
+ size_t m_totalPlugins;
+ int m_returnStatus;
+// bool m_installByPkgmgr;
+ bool m_quiet;
+ InstallerPopup *m_popup;
+ bool m_startupPluginInstallation;
+ std::string m_webAppConfig;
+ std::string m_webAppIcon;
+
+ typedef std::list<std::string> PluginPathList;
+ DPL::Optional<PluginPathList> m_pluginsPaths;
+};
+#endif // WRT_CLIENT_H
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file wrt_installer_api.cpp
+ * @author Chung Jihoon (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief This file contains definitions of wrt installer api
+ */
+#include <stdlib.h>
+#include <list>
+#include <string>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dpl/exception.h>
+#include <dpl/log/log.h>
+#include <dpl/assert.h>
+#include <dpl/semaphore.h>
+#include <dpl/sstream.h>
+#include <libxml/parser.h>
+#include <vconf.h>
+
+#include <wrt_installer_api.h>
+#include <installer_callbacks_translate.h>
+#include <installer_controller.h>
+#include <language_subtag_rst_tree.h>
+#include <dpl/localization/localization_utils.h>
+#include <dpl/wrt-dao-ro/global_config.h>
+#include <dpl/utils/widget_version.h>
+#include <dpl/popup/popup_manager.h>
+#include <dpl/popup/popup_controller.h>
+#include <wrt_type.h>
+#include <dpl/localization/w3c_file_localization.h>
+#include <dpl/wrt-dao-ro/WrtDatabase.h>
+#include <vcore/VCore.h>
+#include <installer_main_thread.h>
+
+using namespace WrtDB;
+
+#undef TRUE
+#undef FALSE
+#define TRUE 0
+#define FALSE -1
+
+#ifdef __cplusplus
+
+#define EXPORT_API __attribute__((visibility("default")))
+extern "C"
+{
+#endif
+// inline WidgetUpdateMode::Type translateWidgetUpdateMode(
+// wrt_widget_update_mode_t updateMode)
+// {
+// WidgetUpdateMode::Type result = WidgetUpdateMode::Zero;
+//
+// if (updateMode & WRT_WIM_NOT_INSTALLED) {
+// result = result | WidgetUpdateMode::NotInstalled;
+// }
+//
+// if (updateMode & WRT_WIM_INCOMING_VERSION_NOT_STD) {
+// result = result | WidgetUpdateMode::IncomingVersionNotStd;
+// }
+//
+// if (updateMode & WRT_WIM_EXISTING_VERSION_NOT_STD) {
+// result = result | WidgetUpdateMode::ExistingVersionNotStd;
+// }
+//
+// if (updateMode & WRT_WIM_BOTH_VERSIONS_NOT_STD) {
+// result = result | WidgetUpdateMode::BothVersionsNotStd;
+// }
+//
+// if (updateMode & WRT_WIM_EXISTING_VERSION_OLDER) {
+// result = result | WidgetUpdateMode::ExistingVersionOlder;
+// }
+//
+// if (updateMode & WRT_WIM_EXISTING_VERSION_EQUAL) {
+// result = result | WidgetUpdateMode::ExistingVersionEqual;
+// }
+//
+// if (updateMode & WRT_WIM_EXISTING_VERSION_NEWER) {
+// result = result | WidgetUpdateMode::ExistingVersionNewer;
+// }
+//
+// return result;
+// }
+//
+// void localizationSetting()
+// {
+// char* lang = vconf_get_str(VCONFKEY_LANGSET);
+// if (!lang) {
+// LogError("Cannot get locale settings from vconf");
+// } else {
+// LogDebug("Language set to: " << lang);
+//
+// using namespace LocalizationUtils;
+//
+// LanguageTagsList list;
+// list.push_back(DPL::FromUTF8String(lang));
+// SetSystemLanguageTags(list);
+//
+// LogDebug("LanguageChanged to " << lang);
+// }
+// }
+
+ const char PLUGIN_INSTALL_SEMAPHORE[] = "/.wrt_plugin_install_lock";
+ static int wrt_count_plugin;
+
+ static std::string cutOffFileName(const std::string& path)
+ {
+ size_t found = path.find_last_of("/");
+ if (found == std::string::npos) {
+ return path;
+ } else {
+ return path.substr(0, found);
+ }
+ }
+
+ static bool checkPath(const std::string& path)
+ {
+ struct stat st;
+ if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
+ return true;
+ }
+ LogError("Cannot access directory [ " << path << " ]");
+ return false;
+ }
+
+ static bool checkPaths()
+ {
+ bool if_ok = true;
+ if_ok &= (checkPath(cutOffFileName(
+ GlobalConfig::GetWrtDatabaseFilePath())));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
+ "> does not exist.");
+ }
+
+ if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetDevicePluginPath() <<
+ "> does not exist.");
+ }
+
+ if_ok &= (checkPath(GlobalConfig::GetFactoryInstalledWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetFactoryInstalledWidgetPath() <<
+ "> does not exist.");
+ }
+
+ if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
+ if (!if_ok) {
+ LogError(
+ "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+ "> does not exist.");
+ }
+ return if_ok;
+ }
+
+ void plugin_install_status_cb(WrtErrStatus status,
+ void* userparam)
+ {
+ Assert(userparam);
+
+ wrt_plugin_data *plugin_data = static_cast<wrt_plugin_data*>(userparam);
+
+ if (--wrt_count_plugin < 1) {
+ LogDebug("All plugins installation completed");
+
+ LogDebug("Call SetAllinstallpluginsCallback");
+ plugin_data->plugin_installed_cb(plugin_data->user_data);
+ }
+
+ if (status == WRT_SUCCESS) {
+ LogInfo(
+ "plugin installation is successful: " <<
+ plugin_data->plugin_path);
+ return;
+ }
+
+ LogError("Fail to install plugin : " << plugin_data->plugin_path);
+
+ switch (status) {
+ case WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH:
+ LogError("Failed : Plugin install path is wrong");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_METAFILE:
+ LogError("Failed : Plugin Metafile Error");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED:
+ LogError("Failed : This Plugin is already installed");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR:
+ LogError("Failed : Library Error. Missing symbol or structures");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_WAITING:
+ LogError("Failed : Waiting for plugin dependencies");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_LOCK:
+ LogError("Failed : Lock Error");
+ break;
+ case WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN:
+ LogError("Failed : Unkown Error");
+ break;
+ default:
+ break;
+ }
+ }
+
+ void plugin_install_progress_cb(float percent,
+ const char* description,
+ void* userdata)
+ {
+ char *plugin_path = static_cast<char*>(userdata);
+
+ LogInfo("Install plugin : " << plugin_path <<
+ ", Progress : " << percent <<
+ ", Description : " << description);
+ }
+
+ EXPORT_API int wrt_installer_init(void *userdata,
+ WrtInstallerInitCallback callback)
+ {
+ // Set DPL/LOG MID
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+
+ try
+ {
+ LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+ LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
+
+ // Touch InstallerController Singleton
+ InstallerMainThreadSingleton::Instance().TouchArchitecture();
+
+ // Check paths
+ if (!checkPaths()) {
+ if (callback) {
+ callback(WRT_ERROR_NO_PATH, userdata);
+ }
+ return TRUE;
+ }
+
+ // Initialize ValidationCore - this must be done before AttachDatabases
+ ValidationCore::VCoreInit(
+ std::string(GlobalConfig::GetFingerprintListFile()),
+ std::string(GlobalConfig::GetFingerprintListSchema()),
+ std::string(GlobalConfig::GetVCoreDatabaseFilePath()));
+
+ InstallerMainThreadSingleton::Instance().AttachDatabases();
+
+ //checking for correct DB version
+// if (!WrtDB::WrtDatabase::CheckTableExist(DB_CHECKSUM_STR)) {
+// LogError("WRONG VERSION OF WRT DATABASE");
+// Assert(false && "WRONG VERSION OF WRT DATABASE");
+// return FALSE;
+// }
+ LogWarning("Database check not implemented!");
+
+ LogInfo("Prepare libxml2 to work in multithreaded program.");
+ xmlInitParser();
+
+ // Initialize Language Subtag registry
+ LanguageSubtagRstTreeSingleton::Instance().Initialize();
+// localizationSetting();
+
+ // Installer init
+ CONTROLLER_POST_SYNC_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::
+ InitializeEvent());
+
+ // Install deferred widget packages
+// CONTROLLER_POST_EVENT(
+// Logic::InstallerController,
+// InstallerControllerEvents::
+// InstallDeferredWidgetPackagesEvent());
+
+ if (callback) {
+ LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+ callback(WRT_SUCCESS, userdata);
+ }
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during Init:");
+ DPL::Exception::DisplayKnownException(ex);
+ if (callback) {
+ callback(WRT_ERROR_INTERNAL, userdata);
+ }
+ return FALSE;
+ }
+ // OK
+ return TRUE;
+ }
+
+ EXPORT_API void wrt_installer_shutdown()
+ {
+ try
+ {
+ LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+
+ // Installer termination
+ CONTROLLER_POST_SYNC_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::
+ TerminateEvent());
+
+ InstallerMainThreadSingleton::Instance().DetachDatabases();
+
+ // This must be done after DetachDatabase
+ ValidationCore::VCoreDeinit();
+
+ // Global deinit check
+ LogInfo("Cleanup libxml2 global values.");
+ xmlCleanupParser();
+
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during Shutdown:");
+ DPL::Exception::DisplayKnownException(ex);
+ }
+ }
+
+// EXPORT_API void wrt_install_widget(const char *path,
+// void* userdata,
+// WrtInstallerStatusCallback status_cb,
+// WrtProgressCallback progress_cb,
+// wrt_widget_update_mode_t update_mode,
+// bool quiet)
+// {
+// UNHANDLED_EXCEPTION_HANDLER_BEGIN
+// {
+// LogInfo("[WRT-API] INSTALL WIDGET: " << path);
+// // Post installation event
+// CONTROLLER_POST_EVENT(
+// Logic::InstallerController,
+// InstallerControllerEvents::InstallWidgetEvent(
+// path, WidgetInstallationStruct(
+// InstallerCallbacksTranslate::installFinishedCallback,
+// InstallerCallbacksTranslate::installProgressCallback,
+// new InstallerCallbacksTranslate::StatusCallbackStruct(
+// userdata, status_cb, progress_cb),
+// translateWidgetUpdateMode(update_mode),
+// quiet)));
+// }
+// UNHANDLED_EXCEPTION_HANDLER_END
+// }
+//
+// EXPORT_API void wrt_uninstall_widget(int widget_handle,
+// void* userdata,
+// WrtInstallerStatusCallback status_cb,
+// WrtProgressCallback progress_cb)
+// {
+// UNHANDLED_EXCEPTION_HANDLER_BEGIN
+// {
+// LogInfo("[WRT-API] UNINSTALL WIDGET: " << widget_handle);
+// // Post uninstallation event
+// CONTROLLER_POST_EVENT(
+// Logic::InstallerController,
+// InstallerControllerEvents::UninstallWidgetEvent(
+// widget_handle,
+// WidgetUninstallationStruct(
+// InstallerCallbacksTranslate::uninstallFinishedCallback,
+// InstallerCallbacksTranslate::installProgressCallback,
+// new InstallerCallbacksTranslate::StatusCallbackStruct(
+// userdata, status_cb, progress_cb))));
+// }
+// UNHANDLED_EXCEPTION_HANDLER_END
+// }
+
+ EXPORT_API void wrt_install_plugin(
+ const char *pluginDir,
+ void *user_param,
+ WrtPluginInstallerStatusCallback status_cb,
+ WrtProgressCallback progress_cb)
+ {
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ LogInfo("[WRT-API] INSTALL PLUGIN: " << pluginDir);
+ //Private data for status callback
+ //Resource is free in pluginInstallFinishedCallback
+ InstallerCallbacksTranslate::PluginStatusCallbackStruct*
+ callbackStruct =
+ new InstallerCallbacksTranslate::PluginStatusCallbackStruct(
+ user_param, status_cb, progress_cb);
+
+ CONTROLLER_POST_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::InstallPluginEvent(
+ std::string(pluginDir),
+ PluginInstallerStruct(
+ InstallerCallbacksTranslate::
+ pluginInstallFinishedCallback,
+ InstallerCallbacksTranslate::
+ installProgressCallback, callbackStruct)));
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
+ }
+
+ EXPORT_API void wrt_install_all_plugins(
+ WrtAllPluginInstalledCallback installed_cb,
+ void *user_param)
+ {
+ UNHANDLED_EXCEPTION_HANDLER_BEGIN
+ {
+ std::string installRequest =
+ std::string(GlobalConfig::GetPluginInstallInitializerName());
+
+ LogDebug("Install new plugins");
+
+ Try {
+ DPL::Semaphore lock(PLUGIN_INSTALL_SEMAPHORE);
+ }
+ Catch(DPL::Semaphore::Exception::Base){
+ LogError("Failed to create installation lock");
+ return;
+ }
+
+ struct stat tmp;
+
+ if (-1 == stat(installRequest.c_str(), &tmp) ||
+ !S_ISREG(tmp.st_mode))
+ {
+ if (ENOENT == errno) {
+ LogDebug("Plugin installation not required");
+
+ LogDebug("Call SetAllinstallPluginCallback");
+ installed_cb(user_param);
+
+ DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+ return;
+ }
+ LogWarning("Opening installation request file failed");
+ }
+
+ std::string PLUGIN_PATH =
+ std::string(GlobalConfig::GetDevicePluginPath());
+
+ DIR *dir;
+ dir = opendir(PLUGIN_PATH.c_str());
+ if (!dir) {
+ DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+ return;
+ }
+
+ LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
+ struct dirent* libdir;
+
+ errno = 0;
+
+ std::list<std::string> pluginsPaths;
+
+ while ((libdir = readdir(dir)) != 0) {
+ if (strcmp(libdir->d_name, ".") == 0 ||
+ strcmp(libdir->d_name, "..") == 0)
+ {
+ continue;
+ }
+
+ std::string path = PLUGIN_PATH;
+ path += "/";
+ path += libdir->d_name;
+
+ struct stat tmp;
+
+ if (stat(path.c_str(), &tmp) == -1) {
+ LogError("Failed to open file" << path);
+ continue;
+ }
+
+ if (!S_ISDIR(tmp.st_mode)) {
+ LogError("Not a directory" << path);
+ continue;
+ }
+
+ pluginsPaths.push_back(path);
+ }
+
+ wrt_count_plugin = pluginsPaths.size();
+
+ FOREACH(it, pluginsPaths) {
+ wrt_plugin_data *plugin_data = new wrt_plugin_data;
+
+ plugin_data->plugin_installed_cb = installed_cb;
+ plugin_data->plugin_path = const_cast<char*>(it->c_str());
+ plugin_data->user_data = user_param;
+
+ wrt_install_plugin(
+ it->c_str(), static_cast<void*>(plugin_data),
+ plugin_install_status_cb,
+ plugin_install_progress_cb);
+ }
+
+ if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
+ LogError("Failed to close dir: " << dir);
+ }
+
+ if (0 != unlink(installRequest.c_str())) {
+ LogError("Failed to remove file initializing plugin "
+ "installation");
+ }
+
+ Try {
+ DPL::Semaphore::Remove(PLUGIN_INSTALL_SEMAPHORE);
+ }
+ Catch(DPL::Semaphore::Exception::Base){
+ LogInfo("Failed to remove installation lock");
+ }
+ }
+ UNHANDLED_EXCEPTION_HANDLER_END
+ }
+
+ EXPORT_API int wrt_installer_init_for_tests(void *userdata,
+ WrtInstallerInitCallback callback)
+ {
+ // Set DPL/LOG MID
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+
+ try
+ {
+ LogInfo("[WRT-API] INITIALIZING WRT INSTALLER...");
+ LogInfo("[WRT-API] BUILD: " << __TIMESTAMP__);
+
+ // Touch InstallerController Singleton
+ InstallerMainThreadSingleton::Instance().
+ TouchArchitectureOnlyInstaller();
+
+ // Check paths
+ if (!checkPaths()) {
+ if (callback) {
+ callback(WRT_ERROR_NO_PATH, userdata);
+ }
+ return TRUE;
+ }
+
+ CONTROLLER_POST_SYNC_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::
+ InitializeEvent());
+
+ if (callback) {
+ LogInfo("[WRT-API] WRT INSTALLER INITIALIZATION CALLBACK");
+ callback(WRT_SUCCESS, userdata);
+ }
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during Init:");
+ DPL::Exception::DisplayKnownException(ex);
+ if (callback) {
+ callback(WRT_ERROR_INTERNAL, userdata);
+ }
+ return FALSE;
+ }
+
+ // OK
+ return TRUE;
+ }
+
+ EXPORT_API void wrt_installer_shutdown_for_tests()
+ {
+ try
+ {
+ LogInfo("[WRT-API] DEINITIALIZING WRT INSTALLER...");
+
+ // Installer termination
+ CONTROLLER_POST_SYNC_EVENT(
+ Logic::InstallerController,
+ InstallerControllerEvents::
+ TerminateEvent());
+
+ // Global deinit check
+ LogInfo("Cleanup libxml2 global values.");
+ xmlCleanupParser();
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during Shutdown:");
+ DPL::Exception::DisplayKnownException(ex);
+ }
+ }
+
+ EXPORT_API WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
+ int *widget_handle)
+ {
+ try
+ {
+ LogInfo("[WRT-API] GETTING WIDGET HANDLE BY PKG NAME : "
+ << pkgname);
+
+ WidgetHandle handle = WidgetDAOReadOnly::getHandle(
+ DPL::FromASCIIString(pkgname));
+ *widget_handle = static_cast<int>(handle);
+ return WRT_SUCCESS;
+ }
+ catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ LogError("Error package name is not found");
+ return WRT_ERROR_PKGNAME_NOT_FOUND;
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during get widget id by package name");
+ DPL::Exception::DisplayKnownException(ex);
+ return WRT_ERROR_INTERNAL;
+ }
+ }
+
+ EXPORT_API WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
+ int *widget_handle)
+ {
+ try
+ {
+ LogInfo("[WRT-API] GETTING WIDGET HANDLE BY WidgetID : "
+ << guid);
+
+ WidgetGUID widget_guid = DPL::FromUTF8String(guid);
+ WidgetHandle handle = WidgetDAOReadOnly::getHandle(widget_guid);
+ *widget_handle = static_cast<int>(handle);
+ return WRT_SUCCESS;
+ }
+ catch (WidgetDAOReadOnly::Exception::WidgetNotExist)
+ {
+ LogError("Error package name is not found");
+ return WRT_ERROR_PKGNAME_NOT_FOUND;
+ }
+ catch (const DPL::Exception& ex)
+ {
+ LogError("Internal Error during get widget id by package name");
+ DPL::Exception::DisplayKnownException(ex);
+ return WRT_ERROR_INTERNAL;
+ }
+ }
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file wrt_installer_api.h
+ * @author Chung Jihoon (jihoon.chung@samsung.com)
+ * @version 1.0
+ * @brief This file contains declarations of wrt_installer_api
+ */
+
+/*
+ * @defgroup wrt_engine_group WebRunTime engine Library
+ * @ingroup internet_FW
+ * Functions to APIs to access wrt-engine
+ */
+
+#ifndef WRT_INSTALLER_API_H_
+#define WRT_INSTALLER_API_H_
+
+#include <string>
+#include <stdbool.h>
+#include <stddef.h>
+#include <wrt_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Callback function type invoked after async init function
+ */
+typedef void (*WrtInstallerInitCallback)(WrtErrStatus status,
+ void *data);
+
+/**
+ * Callback function type invoked after async functions
+ */
+typedef void (*WrtPluginInstallerStatusCallback)(WrtErrStatus status,
+ void *data);
+
+/**
+ * Callback function type invoked after async functions
+ */
+typedef void (*WrtInstallerStatusCallback)(int widget_handle,
+ WrtErrStatus status,
+ void *data);
+
+/**
+ * Callback function type invoked after async functions
+ */
+typedef void (*WrtProgressCallback)(float percent,
+ const char *description,
+ void *data);
+
+/**
+ * Callback function type invoked when all plugin installations are finished
+ */
+typedef void (*WrtAllPluginInstalledCallback)(void *userdata);
+
+typedef struct
+{
+ WrtAllPluginInstalledCallback plugin_installed_cb;
+ char *plugin_path;
+ void *user_data;
+} wrt_plugin_data;
+
+/**
+ * @fn int wrt_installer_init(void *userdata, WrtInstallerInitCallback callback)
+ * @brief Initializes WRT
+ *
+ * This method is used to initialize wrt-engine.
+ * It connects to database, initializes webkit, widget and plugin logic.
+ *
+ * @param [in] userdata - User parameters to be passed to the callback
+ * @param [in] callback - The callback function that is launched, after
+ * wrt initialization.
+ * The callback is called in the context of the
+ * application's main loop.
+ *
+ * @return 0 on success, -1 on failure
+ *
+ * Sample code:
+ * @code
+ * int main (int argc, char *argv[])
+ * {
+ * init_loop(argc, argv);
+ * printf("Initializing WRT");
+ * wrt_init(NULL, &init_cb);
+ *
+ * wait_for_wrt_init();
+ * printf("Starting tests");
+ *
+ * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
+ * argv);
+ *
+ * wrt_installer_shutdown();
+ * quit_loop();
+ * return status;
+ * }
+ * @endcode
+ *
+ * @see wrt_installer_shutdown
+ */
+typedef enum wrt_widget_install_mode_e
+{
+ /**
+ * Raw install bit flags
+ */
+ WRT_WIM_NOT_INSTALLED = (1 << 0),
+ WRT_WIM_INCOMING_VERSION_NOT_STD = (1 << 1),
+ WRT_WIM_EXISTING_VERSION_NOT_STD = (1 << 2),
+ WRT_WIM_BOTH_VERSIONS_NOT_STD = (1 << 3),
+ WRT_WIM_EXISTING_VERSION_OLDER = (1 << 4),
+ WRT_WIM_EXISTING_VERSION_EQUAL = (1 << 5),
+ WRT_WIM_EXISTING_VERSION_NEWER = (1 << 6),
+
+ /**
+ * Update default policies
+ */
+
+ /* Never update policy
+ */
+ WRT_WIM_POLICY_NEVER_UPDATE = WRT_WIM_NOT_INSTALLED,
+
+ /* WAC update policy
+ */
+ WRT_WIM_POLICY_WAC = WRT_WIM_NOT_INSTALLED |
+ WRT_WIM_EXISTING_VERSION_OLDER,
+
+ /* Always update policy
+ */
+ WRT_WIM_POLICY_ALWAYS_INSTALL = WRT_WIM_NOT_INSTALLED |
+ WRT_WIM_INCOMING_VERSION_NOT_STD |
+ WRT_WIM_EXISTING_VERSION_NOT_STD |
+ WRT_WIM_BOTH_VERSIONS_NOT_STD |
+ WRT_WIM_EXISTING_VERSION_OLDER |
+ WRT_WIM_EXISTING_VERSION_EQUAL |
+ WRT_WIM_EXISTING_VERSION_NEWER,
+
+ /* Force install policy
+ */
+ WRT_WIM_POLICY_FORCE_INSTALL = WRT_WIM_POLICY_ALWAYS_INSTALL
+} wrt_widget_update_mode_t;
+
+int wrt_installer_init(void *userdata,
+ WrtInstallerInitCallback callback);
+
+/**
+ * @fn void wrt_installer_shutdown(void)
+ * @brief Deinitializes WRT
+ *
+ * This method is used to deinitialize wrt-engine.
+ * It deinitializes widget logic, plugin logic, shuts down connection to
+ * database, switchs back to single thread and does deinit checks.
+ *
+ * @return nothing
+ *
+ * Sample code:
+ * @code
+ * int main (int argc, char *argv[])
+ * {
+ * init_loop(argc, argv);
+ * printf("Initializing WRT");
+ * wrt_init(NULL, &init_cb);
+ *
+ * wait_for_wrt_init();
+ * printf("Starting tests");
+ *
+ * int status = DPL_TestRunnerSingleton_Instance().ExecTestRunner(argc,
+ * argv);
+ *
+ * wrt_installer_shutdown();
+ * quit_loop();
+ * return status;
+ * }
+ * @endcode
+ *
+ * @see wrt_init
+ */
+void wrt_installer_shutdown(void);
+
+/**
+ * @fn void wrt_install_widget(const char *widget_package_path,
+ * void *user_parameter,
+ * WrtInstallerStatusCallback status_callback,
+ * WrtProgressCallback progress_callback,
+ * wrt_widget_update_mode_t update_mode);
+ *
+ * @brief Installs widget from given path
+ *
+ * This method is used to install widget from a given path.
+ *
+ * @param [in] widget_package_path Path of the widget package.
+ * @param [in] user_parameter User parameters to be passed to the callback
+ * @param [in] status_cb Call to this one will be done at the end of
+ * operation
+ * The callback is called in the context of the
+ * application's
+ * @param [in] progress_cb Callback function to get data of install
+ * progress
+ * If you don't want to get progress data, this
+ * should be NULL
+ * @param [in] install_mode Installation mode
+ * @return Nothing (status returned in callback).
+ *
+ * Sample code:
+ * @code
+ * wrt_install_widget(path.c_str(),
+ * NULL,
+ * install_cb,
+ * progress_cb,
+ * WRT_WIM_POLICY_WAC);
+ * @endcode
+ *
+ * @see wrt_installer_uninstall_widget
+ */
+void wrt_install_widget(const char *path,
+ void *user_parameter,
+ WrtInstallerStatusCallback status_callback,
+ WrtProgressCallback progress_callback,
+ wrt_widget_update_mode_t update_mode,
+ bool quiet);
+
+/**
+ * @fn void wrt_installer_uninstall_widget (int widget_handle,
+ * void* userdata,
+ * WrtInstallerStatusCallback cb)
+ * @brief Uninstalls widget using its id
+ *
+ * This method is used to uninstall the widget specified by its handle.
+ * The callback function is called when the uninstall operation is done.
+ *
+ * @param [in] widget_handle - widget id
+ * @param [in] userdata - user parameters to be passed to the callback
+ * @param [in] status_cb - Call to this one will be done at the end of
+ * operation
+ * The callback is called in the context of the
+ application's
+ * @param [in] progress_cb - Callback function to get data of install progress
+ * If you don't want to get progress data, this
+ * should be NULL
+ *
+ * @return nothing (status returned in callback).
+ *
+ * Sample code:
+ * @code //TODO SAMPLE
+ * wrt_installer_uninstall_widget( appId, NULL, uninstall_cb, progress_cb);
+ * @endcode
+ *
+ * @see wrt_installer_install_widget
+ */
+void wrt_uninstall_widget (int widget_handle,
+ void* userdata,
+ WrtInstallerStatusCallback status_cb,
+ WrtProgressCallback progress_cb);
+
+/**
+ * @fn void wrt_install_plugin(const char *pluginDirectory,
+ * void *userData,
+ * WrtInstallerStatusCallback statusCallback,
+ * WrtProgressCallback progressCallback)
+ *
+ * @brief Installs plugin from given path
+ *
+ * This method installs new plugin from specified location and calls a callback
+ * function when the operation is done.
+ *
+ * @param [in] pluginDirectory - plugin directory
+ * @param [in] userData - user parameters to be passed to the callback
+ * @param [in] statusCallback - user callback to call after installation
+ * @param [in] progressCallback - user callback to call when plugin
+ * installation progress has changed
+ *
+ * @return nothing (status returned in callback).
+ *
+ * Sample code:
+ * @code
+ * wrt_install_plugin("/usr/lib/wrt-plugins/",NULL,NULL,NULL);
+ * @endcode
+ *
+ * @see wrt_install_plugin
+ */
+void wrt_install_plugin(const char *pluginDirectory,
+ void *userData,
+ WrtPluginInstallerStatusCallback statusCallback,
+ WrtProgressCallback progressCallback);
+
+/**
+ * @brief To install plugins for first excution
+ *
+ * This method install plugins
+ *
+ * @return nothing
+ */
+void wrt_install_all_plugins(WrtAllPluginInstalledCallback installed_cb,
+ void *user_param);
+
+/**
+ * @brief To initialize for tests
+ *
+ * This method is wrt init for tests
+ *
+ * @return int
+ */
+int wrt_installer_init_for_tests(void *userdata,
+ WrtInstallerInitCallback callback);
+
+/**
+ * @brief To shutdown for tests
+ *
+ * This method is wrt shutdown for tests
+ *
+ * @return int
+ */
+void wrt_installer_shutdown_for_tests();
+
+WrtErrStatus wrt_get_widget_by_pkgname(const std::string pkgname,
+ int *widget_handle);
+
+WrtErrStatus wrt_get_widget_by_guid(const std::string guid,
+ int *widget_handle);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WRT_INSTALLER_API_H_ */
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * @file wrt_type.h
+ * @author jihoon Chung (jihoon.Chung@samsung.com)
+ * @version 1.0
+ * @brief This file contains declarations of wrt api
+ */
+
+/*
+ * @defgroup wrt_engine_group WebRunTime engine Library
+ * @ingroup internet_FW
+ * Functions to APIs to access wrt-engine
+ */
+
+#ifndef WRT_TYPE_H_
+#define WRT_TYPE_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define WRT_DEPRECATED __attribute__((deprecated))
+
+typedef enum
+{
+ /* Generic success */
+ WRT_SUCCESS = 0, /*< Success*/
+ WRT_ALREADY_INIT, /*< Wrt already initialized*/
+ WRT_UPDATE_NEED, /*< Widget data has been updated*/
+ WRT_SHUTDOWN, /*<WRT daemon has been closed*/
+
+ /* Version result */
+ WRT_VERSION_OLD = 128, /*< widget's version is older*/
+ WRT_VERSION_NEW, /*< widget's version is latest*/
+ WRT_VERSION_EXACT, /*< widget's version the same as in arg*/
+ WRT_VERSION_NOT_COMPARABLE, /*< widget's version are not comparable */
+
+ /* Error result */
+ WRT_ERROR_INTERNAL = -128, /*< Internal library error.
+ Should never occur */
+ WRT_ERROR_INVALID_PARAMETER, /*< Invalid parameter value was given
+ (eg. NULL) */
+ WRT_ERROR_HANDLE_NOT_FOUND, /*< Widget handle was not found */
+ WRT_ERROR_ID_NOT_FOUND, /*< Widget id was not found */
+ WRT_ERROR_PKGNAME_NOT_FOUND, /*< package name was not found */
+ WRT_ERROR_ALREADY_RUNNING, /*< Widget is already running */
+ WRT_ERROR_ALREADY_STOPPED, /*< Widget is already stopped */
+ WRT_ERROR_STILL_AUTHORIZING, /*< Widget is still autorizing and has not
+ yet finished it */
+ WRT_ERROR_EARLY_KILLED, /*< Widget was early killed during launch */
+ WRT_ERROR_ACCESS_DENIED, /*< Access denied from ACE */
+ WRT_ERROR_NOT_INITIALIZED, /*<Occur if wrt initialization fails*/
+ WRT_ERROR_INIT, /*<Occur if wrt initialization fails*/
+ WRT_ERROR_CONNECTION, /*<Connectiond error occured*/
+ WRT_ERROR_NO_PATH, /*<One of specific directory does not
+ exist*/
+
+ /* Installer Errors*/
+ WRT_INSTALLER_ERROR_INVALID_WIDGET_PACKAGE, /*< */
+ WRT_INSTALLER_ERROR_WIDGET_DOES_NOT_EXIST, /*< */
+ WRT_INSTALLER_ERROR_FACTORY_WIDGET, /*< Widget is factory installed,
+ and cannot be uninstalled */
+ WRT_INSTALLER_ERROR_ALREADY_UNINSTALLING, /*< Widget is already being
+ uninstalled */
+ WRT_INSTALLER_ERROR_OUT_OUT_DISK_SPACE, /*< */
+ WRT_INSTALLER_ERROR_INVALID_CERTIFICATE, /*< */
+ WRT_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Widget is already installed
+ */
+ WRT_INSTALLER_ERROR_INTERNAL, /*< */
+ WRT_INSTALLER_ERROR_NOT_ALLOWED, /*< Widget installation or
+ update not allowed */
+ /*< because violation of policy
+ ocurred */
+ WRT_INSTALLER_ERROR_DEFERRED, /*< Widget installation deferred
+ */
+ WRT_INSTALLER_ERROR_DATABASE_FAILURE, /*< Failure in database */
+ WRT_INSTALLER_ERROR_UNKNOWN, /*< Temporary error. Try to not
+ use this. */
+ WRT_INSTALLER_ERROR_OSPSVC, /*< */
+ WRT_ERROR_INVALID_LANGUAGE, /*< Widget is not valid in
+ current locales*/
+
+ /* Plugin Installer Errors */
+ WRT_PLUGIN_INSTALLER_ERROR_WRONG_PATH, /*< Wrong Path to plugin Dir */
+ WRT_PLUGIN_INSTALLER_ERROR_METAFILE, /*< Plugin metafile error */
+ WRT_PLUGIN_INSTALLER_ERROR_ALREADY_INSTALLED, /*< Plugin already installed*/
+ WRT_PLUGIN_INSTALLER_ERROR_LIBRARY_ERROR, /*< Shared library error*/
+ WRT_PLUGIN_INSTALLER_ERROR_WAITING, /*< Missing dependencies*/
+ WRT_PLUGIN_INSTALLER_ERROR_LOCK, /*< Another installation
+ in progress or lock file
+ error*/
+ WRT_PLUGIN_INSTALLER_ERROR_UNKNOWN /*< Unknown error*/
+} WrtErrStatus;
+
+typedef struct
+{
+ char* id; /**< the widget's id
+ (read from its config.xml during installation)*/
+ char* name; /**< the widget's name
+ (read from its config.xml during installation)*/
+ char* version; /**< the widget's varsion
+ (read from its config.xml during installation)*/
+ char* icon_path; /**< the widget's icon_path
+ (read from its config.xml during installation)*/
+ char* pkg_name; /**< the widget's pkg name */
+
+ /**< the widget's application storage size */
+ size_t application_size;
+ /**< the widget's data storage size */
+ size_t data_size;
+} wrt_widget_info;
+
+typedef struct
+{
+ char *src; /**< valid path to widget's icon*/
+ int width; /**< the width of the icon in pixels*/
+ int height; /**< the height of the icon in pixels*/
+} wrt_widget_icon;
+
+typedef struct
+{
+ int width; /**< the width of the widget in pixels*/
+ int height; /**< the height of the widget in pixels*/
+} wrt_widget_size;
+
+typedef struct
+{
+ char *widget_name; /**< the widget's name*/
+ wrt_widget_icon *widget_icon; /**< the widget's icon data*/
+ wrt_widget_size widget_size; /**< the widget's size data*/
+ wrt_widget_info *widget_info; /**< the widget's info data*/
+} wrt_widget_info_data;
+
+
+/**
+ * @fn inline bool wrt_has_succeded(WrtErrStatus err)
+ * @brief Checks whether call succeded
+ *
+ * This function checks whether call succeded.
+ * If call succeded it returns TRUE.
+ *
+ * @param [in] err WrtErrStatus to check
+ *
+ * @return Result of the test
+ * @retval TRUE - the call was successful
+ * @retval FALSE - the call failed
+ *
+ * Sample code:
+ * @code
+ * static void InitCallback(WrtErrStatus status, void *data)
+ * {
+ * MyApplication *This = (MyApplication *)(data);
+ *
+ * printf("[LAUNCH-WIDGET] init callback");
+ *
+ * if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
+ * {
+ * This->InstallAllPlugins();
+ *
+ * if (This->m_argc == 2)
+ * wrt_install_widget(This->m_argv[1], This, InstallCallback);
+ * }
+ * else if(wrt_has_failed(status))
+ * printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
+ * }
+ * @endcode
+ *
+ * @see wrt_has_failed
+ */
+inline bool wrt_has_succeded(WrtErrStatus err)
+{
+ return (err >= 0);
+}
+
+/**
+ * @fn inline bool wrt_has_failed(WrtErrStatus err)
+ * @brief Checks whether call failed
+ *
+ * This function checks whether call failed.
+ * If call failed it returns TRUE.
+ *
+ * @param [in] err WrtErrStatus to check
+ *
+ * @return Result of the test
+ * @retval TRUE - the call failed
+ * @retval FALSE - the call was successful
+ *
+ * Sample code:
+ * @code
+ * static void InitCallback(WrtErrStatus status, void *data)
+ * {
+ * MyApplication *This = (MyApplication *)(data);
+ *
+ * printf("[LAUNCH-WIDGET] init callback");
+ *
+ * if (wrt_has_succeded(status) && status!=WRT_UPDATE_NEED)
+ * {
+ * This->InstallAllPlugins();
+ *
+ * if (This->m_argc == 2)
+ * wrt_install_widget(This->m_argv[1], This, InstallCallback);
+ * }
+ * else if(wrt_has_failed(status))
+ * printf("[LAUNCH-WIDGET] INITIALIZATION HAS FAILED");
+ * }
+ * @endcode
+ *
+ * @see wrt_has_succeded
+ */
+inline bool wrt_has_failed(WrtErrStatus err)
+{
+ return (err < 0);
+}
+
+namespace CommonError {
+enum Type
+{
+ WrtSuccess, ///< Success
+
+ HandleNotFound, ///< Widget handle was not found
+ AlreadyRunning, ///< Widget is already running
+ AlreadyStopped, ///< Widget is already stopped
+ InvalidLanguage, ///< Widget is invalid in current locales
+ StillAuthorizing, ///< Widget is still autorizing and has not yet finished it
+ EarlyKilled, ///< Widget was early killed during launch
+ AccessDenied, ///< Access denied from ACE
+ CertificateRevoked, ///< Some certificate was revoked.
+ /// Widget is not allowed to run.
+
+ Unknown ///< Temporary error. Try to not use this.
+};
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WRT_TYPE_H_ */
LocalStorage::Api::ILocalStoragePtr getLocalStorage(int widgetId)
{
- static int id = widgetId;
- Assert(id == widgetId && "SPA is not longer supported");
-
- static LocalStorage::Api::ILocalStoragePtr storage(
+ LocalStorage::Api::ILocalStoragePtr storage(
LocalStorage::Api::getLocalStorage(widgetId));
return storage;
--- /dev/null
+ADD_SUBDIRECTORY(popup-bin)
+ADD_SUBDIRECTORY(popup-runner)
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# @file CMakeLists.txt
+# @author Janusz Kozerski (j.kozerski@samsung.com)
+#
+# @version 1.0
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_DEP
+ dpl-efl
+ elementary
+ security-client
+ security-popup-validation
+ REQUIRED)
+
+set(WRT_POPUP_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-bin)
+
+set(WRT_POPUP_SOURCES
+ ${WRT_POPUP_SRC_DIR}/Popup.cpp
+)
+
+ADD_DEFINITIONS(${WRT_POPUP_DEP_CFLAGS})
+
+INCLUDE_DIRECTORIES(
+ ${WRT_POPUP_SRC_DIR}
+ ${WRT_POPUP_DEP_INCLUDE_DIRS}
+)
+
+ADD_EXECUTABLE(${TARGET_WRT_POPUP}
+ ${WRT_POPUP_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP} PROPERTIES
+ COMPILE_FLAGS -fPIC
+)
+
+SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP} PROPERTIES
+ #LINK_FLAGS "-Wl,--as-needed -Wl"
+ SOVERSION ${PROJECT_API_VERSION}
+ VERSION ${PROJECT_VERSION}
+)
+
+target_link_libraries(${TARGET_WRT_POPUP}
+ ${WRT_POPUP_DEP_LIBRARIES}
+ ${TARGET_WRT_POPUP_RUNNER_LIB}
+ ${WRT_POPUP_DEP_LDFLAGS}
+)
+
+INSTALL(TARGETS ${TARGET_WRT_POPUP}
+ DESTINATION bin
+)
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file Popup.c
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+/*
+ * This is just a example pop-up that shows how to use a new C-API in wrt-security.
+ * This pop-up should be re-implemented by members of NGWAP.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <vector>
+#include <ctime>
+
+#include <Elementary.h>
+
+#include <dpl/log/log.h>
+#include <dpl/serialization.h>
+#include <ace_api_common.h>
+#include <ace_api_popup_validation.h>
+
+#include "popup-runner.h"
+#include "Popup.h"
+
+namespace { // anonymous
+
+static void set_validity_from_checkbox(struct ace_popup_data *pdp) {
+
+ if(NULL == pdp){
+ LogError("pdp is NULL; return");
+ return;
+ }
+
+ if (pdp->always) {
+ LogDebug("Remember ALWAYS");
+ pdp->remember_choice = ACE_ALWAYS;
+ return;
+ }
+ if (pdp->per_session) {
+ LogDebug("Remember PER_SESSION");
+ pdp->remember_choice = ACE_PER_SESSION;
+ return;
+ }
+ LogDebug("Remember ONCE");
+ pdp->remember_choice = ACE_ONCE;
+ return;
+}
+
+static void on_done(void) {
+ // Quit the efl-mainloop
+ LogDebug("elm_exit()");
+ elm_exit();
+}
+
+static void grant_answer(void *data, Evas_Object * /* obj */, void * /* event_info */) {
+
+ LogDebug("grant_answer");
+ if(NULL == data){
+ LogError("data is NULL; return");
+ return;
+ }
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *> (data);
+
+ set_validity_from_checkbox(pdp);
+
+ ace_popup_validation_initialize();
+ pdp->validation_return = ace_validate_answer(
+ ACE_TRUE,
+ pdp->remember_choice,
+ pdp->resource_name,
+ pdp->session_id,
+ &(pdp->param_list),
+ pdp->handle,
+ &(pdp->validation_result));
+ ace_popup_validation_shutdown();
+
+ on_done();
+}
+
+static void deny_answer(void *data, Evas_Object * /* obj */, void * /* event_info */) {
+
+ LogDebug("deny_answer");
+ if(NULL == data){
+ LogError("data is NULL; return");
+ return;
+ }
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *> (data);
+
+ set_validity_from_checkbox(pdp);
+
+ ace_popup_validation_initialize();
+ pdp->validation_return = ace_validate_answer(
+ ACE_FALSE,
+ pdp->remember_choice,
+ pdp->resource_name,
+ pdp->session_id,
+ &(pdp->param_list),
+ pdp->handle,
+ &(pdp->validation_result));
+ ace_popup_validation_shutdown();
+
+ on_done();
+}
+
+static int _ace_params_deserializer(ace_param_list_t* ace_param_list, Wrt::Popup::BinaryStream *stream){
+
+ LogDebug("_ace_params_deserializer");
+
+ if(NULL == ace_param_list || NULL == stream){
+ LogError("ace_param_list or stream is NULL; return -1");
+ return -1;
+ }
+
+ // deserialize ace_param_list->count;
+ size_t count = 0;
+ DPL::Deserialization::Deserialize(*stream, count);
+ ace_param_list->count = count;
+ LogDebug("count : " << count);
+
+ std::string name;
+ std::string value;
+ if(count == 0){
+ ace_param_list->items = NULL;
+ return 0;
+ }
+ ace_param_list->items = static_cast <ace_param_t *> (malloc(count * sizeof(ace_param_t)));
+
+ for(size_t i=0; i < count; ++i){
+ DPL::Deserialization::Deserialize(*stream, name);
+ ace_param_list->items[i].name = const_cast <char *> (name.c_str());
+
+ DPL::Deserialization::Deserialize(*stream, value);
+ ace_param_list->items[i].value = const_cast <char *> (value.c_str());
+ }
+ return 0;
+}
+
+static void show_popup(struct ace_popup_data *pdp) {
+ LogDebug("show_popup()");
+
+ if(NULL == pdp){
+ LogError("pdp is NULL; return");
+ return;
+ }
+
+ const char *resource_type = static_cast <char *> (pdp->resource_name);
+
+ Evas_Object *win = NULL;
+ Evas_Object *cb_session = NULL;
+ Evas_Object *cb_always = NULL;
+ Evas_Object *box = NULL;
+ Evas_Object *label = NULL;
+ Evas_Object *grant_button = NULL;
+ Evas_Object *deny_button = NULL;
+ pdp->per_session = EINA_FALSE;
+ pdp->always = EINA_FALSE;
+
+ win = elm_win_add(NULL, "The wrt-client popup", ELM_WIN_NOTIFICATION);
+ elm_win_autodel_set(win, EINA_TRUE);
+ elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
+ evas_object_show(win);
+ elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_TRANSLUCENT);
+
+ pdp->popup = elm_popup_add(win);
+
+ box = elm_box_add(pdp->popup);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
+ evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
+
+ label = elm_label_add(pdp->popup);
+ elm_object_style_set(label, "popup_description/default");
+ elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
+ char *buff = NULL;
+ if(-1 == asprintf(&buff, "Application need an access to %s.<br>Grant or deny?", resource_type)){
+ LogError("asprintf failed - returned -1");
+ evas_object_del(label);
+ evas_object_del(pdp->popup);
+ evas_object_del(win);
+ return;
+ }
+ elm_object_text_set(label, buff);
+ free(buff);
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(label);
+ elm_box_pack_end(box, label);
+
+ LogDebug("popup_type == " << pdp->popup_type);
+ if (pdp->popup_type == ACE_SESSION || pdp->popup_type == ACE_BLANKET) {
+ LogDebug("popup_type == ACE_SESSION || ACE_BLANKET");
+ cb_session = elm_check_add(pdp->popup);
+ elm_object_text_set(cb_session, "Remember choice for this session");
+ elm_check_state_pointer_set(cb_session, &(pdp->per_session));
+ evas_object_smart_callback_add(cb_session, "changed", NULL, NULL);
+ evas_object_size_hint_align_set(cb_session, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(cb_session, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(cb_session);
+ elm_box_pack_end(box, cb_session);
+
+ if (pdp->popup_type == ACE_BLANKET) {
+ LogDebug("popup_type == ACE_BLANKET");
+ cb_always = elm_check_add(pdp->popup);
+ elm_object_text_set(cb_always, "Remember choice forever");
+ elm_check_state_pointer_set(cb_always, &(pdp->always));
+ evas_object_smart_callback_add(cb_always, "changed", NULL, NULL);
+ evas_object_size_hint_align_set(cb_always, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(cb_always, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(cb_always);
+ elm_box_pack_end(box, cb_always);
+ }
+ }
+
+ elm_object_part_content_set(pdp->popup, "default", box);
+
+ grant_button = elm_button_add(pdp->popup);
+ elm_object_text_set(grant_button, "Grant");
+ elm_object_part_content_set(pdp->popup, "button1", grant_button);
+ evas_object_smart_callback_add(grant_button, "clicked", grant_answer, pdp);
+
+ deny_button = elm_button_add(pdp->popup);
+ elm_object_text_set(deny_button, "Deny");
+ elm_object_part_content_set(pdp->popup, "button2", deny_button);
+ evas_object_smart_callback_add(deny_button, "clicked", deny_answer, pdp);
+
+ evas_object_show(pdp->popup);
+
+ // Showing the popup window
+ evas_object_show(win);
+
+ // Run the efl mainloop
+ elm_run();
+}
+
+} // anonymous
+
+
+EAPI_MAIN int
+elm_main(int argc , char ** argv)
+{
+// int pipe_in and int pipe_out should be passed to Popup via args.
+
+// These parameters should be passed to Popup via pipe:
+// ace_popup_t popup_type
+// const ace_resource_t resource_name
+// const ace_session_id_t session_id
+// ace_widget_handle_t handle
+// const ace_param_list_t param_list
+
+
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-POPUP-BIN");
+ LogDebug("############################ popup binary ################################");
+
+ if(argc < 3){
+ LogError("To few args passed in exec to popup-bin - should be at least 3:");
+ LogError("(binary-name, pipe_in, pipe_out)");
+ LogError("return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ LogDebug("Passed args: " << argv[0] <<", " << argv[1] << ", " << argv[2]);
+
+ int pipe_in;
+ int pipe_out;
+
+ // Parsing args (pipe_in, pipe_out)
+ if ( 0 == sscanf(argv[1], "%d", &pipe_in) ){
+ LogError("Error while parsing pipe_in; return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ if ( 0 == sscanf(argv[2], "%d", &pipe_out) ){
+ LogError("Error while parsing pipe_out; return ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ LogDebug("Parsed pipes: IN: " << pipe_in <<", OUT: " << pipe_out);
+
+ int buff_size = 1024;
+ char line[buff_size];
+
+ struct ace_popup_data pd;
+ struct ace_popup_data *pdp = &pd;
+
+ pdp->popup = NULL;
+
+ ssize_t count = 0;
+ time_t time_start;
+ time(&time_start); // now
+ double timeout = 10.0;
+ // try to read parameters from pipe_in
+ // timeout is set for 10 seconds
+ do {
+ count = TEMP_FAILURE_RETRY(read(pipe_in, line, buff_size));
+ if ( timeout < difftime(time(NULL), time_start) ) {
+ LogError("Timeout reached! Exit popup - ACE_INTERNAL_ERROR");
+ close(pipe_in);
+ close(pipe_out);
+ return ACE_INTERNAL_ERROR;
+ }
+ } while (0 == count);
+ if(count < 0){
+ close(pipe_in);
+ close(pipe_out);
+ LogError("read returned a negative value (" << count <<")");
+ LogError("errno: " << strerror( errno ) );
+ LogError("Exit popup - ACE_INTERNAL_ERROR");
+ return ACE_INTERNAL_ERROR;
+ }
+ LogDebug("Read bytes : " << count << " (in " << difftime(time_start, time(NULL)) << " seconds)");
+ close(pipe_in); // cleanup
+
+ Wrt::Popup::BinaryStream stream;
+ stream.Write(count, static_cast <void *> (line));
+ int popup_type = ACE_ONESHOT;
+ std::string resource_name_str;
+ std::string session_id_str;
+ int handle = 0;
+
+ LogDebug("------- Deserialization -------");
+ // Deserialization order:
+ // popup_type, resource_name, session_id, handle, param_list
+
+ DPL::Deserialization::Deserialize(stream, popup_type);
+ LogDebug("popup_type_int : " << popup_type);
+ pdp->popup_type = static_cast <ace_popup_t> (popup_type);
+
+ DPL::Deserialization::Deserialize(stream, resource_name_str);
+ LogDebug("resource_name_char : " << resource_name_str.c_str());
+ pdp->resource_name = const_cast <ace_resource_t> (resource_name_str.c_str());
+
+ DPL::Deserialization::Deserialize(stream, session_id_str);
+ LogDebug("session_id_char : " << session_id_str.c_str());
+ pdp->session_id = const_cast <ace_session_id_t> (session_id_str.c_str());
+
+ DPL::Deserialization::Deserialize(stream, handle);
+ LogDebug("handle_int : " << handle);
+ pdp->handle = static_cast <ace_widget_handle_t> (handle);
+
+ if(_ace_params_deserializer(&(pdp->param_list), &stream)){
+ return ACE_INTERNAL_ERROR;
+ }
+
+ pdp->per_session = EINA_FALSE;
+ pdp->always = EINA_FALSE;
+ pdp->validation_return = ACE_ACE_UNKNOWN_ERROR;
+
+ show_popup(pdp); // Showing popup
+
+ // sending validation_result to popup-runner
+ Wrt::Popup::BinaryStream stream_out;
+
+ LogDebug("pdp->validation_result : " << pdp->validation_result);
+ int validation_result_int = (int) pdp->validation_result;
+ LogDebug("validation_result_int : " << validation_result_int);
+ DPL::Serialization::Serialize(stream_out, validation_result_int);
+ if(-1 == TEMP_FAILURE_RETRY(write(pipe_out, stream_out.char_pointer(), stream_out.size()))){
+ LogError("Write to pipe failed!");
+ close(pipe_out);
+ return ACE_INTERNAL_ERROR;
+ }
+ close(pipe_out);
+
+ if (pdp->validation_return == ACE_OK) {
+ LogDebug("ACE_OK");
+ }
+ else if (pdp->validation_return == ACE_INVALID_ARGUMENTS) {
+ LogError("ACE_INVALID_ARGUMENTS");
+ }
+ else if (pdp->validation_return == ACE_INTERNAL_ERROR) {
+ LogError("ACE_INTERNAL_ERROR");
+ }
+ else if (pdp->validation_return == ACE_ACE_UNKNOWN_ERROR) {
+ LogError("ACE_ACE_UNKNOWN_ERROR");
+ }
+ else {
+ LogError("Really unknown error!!!");
+ }
+
+ LogDebug("############################ /popup binary ################################");
+
+ // Shutdown elementary
+ //LogDebug("elm_shutdown()");
+ //elm_shutdown();
+ // This is commented because, it causes that popup exits with 139 code (Segmentatation violation).
+ // Not calling elm_shutdown() should not have any negative consequences because this binary ends
+ // in next line, and system should clear the memory.
+
+ return pdp->validation_return;
+}
+ELM_MAIN()
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file Popup.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+#include <Elementary.h>
+#include <ace_api_common.h>
+
+struct ace_popup_data {
+ ace_popup_t popup_type;
+ ace_resource_t resource_name;
+ ace_session_id_t session_id;
+ ace_param_list_t param_list;
+ ace_widget_handle_t handle;
+ ace_bool_t validation_result;
+ ace_return_t validation_return;
+
+ Evas_Object *popup;
+ Eina_Bool per_session;
+ Eina_Bool always;
+
+ ace_validity_t remember_choice;
+};
--- /dev/null
+# Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+# @file CMakeLists.txt
+# @author Janusz Kozerski (j.kozerski@samsung.com)
+#
+# @version 1.0
+#
+
+PKG_CHECK_MODULES(WRT_POPUP_RUNNER_LIB_DEP
+ dpl-efl
+ elementary
+ security-client
+ REQUIRED)
+
+set(WRT_POPUP_RUNNER_LIB_SRC_DIR ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-runner)
+
+set(WRT_POPUP_RUNNER_LIB_SOURCES
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}/popup-runner.cpp
+)
+
+ADD_DEFINITIONS(${WRT_POPUP_RUNNER_LIB_DEP_CFLAGS})
+
+INCLUDE_DIRECTORIES(
+ ${WRT_POPUP_RUNNER_LIB_SRC_DIR}
+ ${WRT_POPUP_RUNNER_LIB_DEP_INCLUDE_DIRS}
+)
+
+ADD_LIBRARY(${TARGET_WRT_POPUP_RUNNER_LIB} SHARED
+ ${WRT_POPUP_RUNNER_LIB_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP_RUNNER_LIB} PROPERTIES
+ COMPILE_FLAGS -fPIC
+)
+
+SET_TARGET_PROPERTIES(${TARGET_WRT_POPUP_RUNNER_LIB} PROPERTIES
+ SOVERSION ${CMAKE_PROJECT_API_VERSION}
+ VERSION ${CMAKE_PROJECT_VERSION}
+)
+
+target_link_libraries(${TARGET_WRT_POPUP_RUNNER_LIB}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LIBRARIES}
+ ${WRT_POPUP_RUNNER_LIB_DEP_LDFLAGS}
+)
+
+INSTALL(TARGETS ${TARGET_WRT_POPUP_RUNNER_LIB}
+ DESTINATION lib
+)
+
+INSTALL(FILES ${PROJECT_SOURCE_DIR}/src/wrt-popup/popup-runner/popup-runner.h
+ DESTINATION ${DESTINATION_HEADERS_WRT_POPUP_RUNNER}
+)
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file popup-runner.cpp
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+/*
+ * This is just a example pop-up that shows how to use a new C-API in wrt-security.
+ * This pop-up should be re-implemented by members of NGWAP.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <iostream>
+#include <sstream>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <dpl/log/log.h>
+
+#include "popup-runner.h"
+
+namespace { // anonymous
+
+const char *POPUP_EXEC = "/usr/bin/wrt-popup-runtime"; // wrt-popup-runtime
+
+void _ace_params_serializer (const ace_param_list_t* ace_param_list, Wrt::Popup::BinaryStream *stream){
+
+ LogDebug("_ace_params_serializer");
+
+ if(NULL == ace_param_list || NULL == stream){
+ LogError("*ace_param_list or *stream is NULL; return");
+ return;
+ }
+ LogDebug("Param count : " << ace_param_list->count);
+
+ // serialize ace_param_list->count;
+ size_t count = static_cast <size_t> (ace_param_list->count);
+ DPL::Serialization::Serialize(*stream, count);
+
+ for(size_t i=0; i < count; ++i){
+ std::string name(ace_param_list->items[i].name);
+ DPL::Serialization::Serialize(*stream, name);
+
+ std::string value(ace_param_list->items[i].value);
+ DPL::Serialization::Serialize(*stream, value);
+ }
+}
+
+} // anonymous namespace
+
+namespace Wrt{
+namespace Popup{
+
+// BinaryStream class implementation
+void BinaryStream::Read(size_t num, void * bytes) {
+ size_t max_size = m_data.size();
+ for (size_t i = 0; i < num; ++i) {
+ if( i + m_readPosition >= max_size){
+ return;
+ }
+ static_cast <unsigned char*> (bytes)[i] = m_data[i + m_readPosition];
+ }
+ m_readPosition += num;
+}
+
+void BinaryStream::Write(size_t num, const void * bytes) {
+ for (size_t i = 0; i < num; ++i) {
+ m_data.push_back(static_cast <const unsigned char*> (bytes)[i]);
+ }
+}
+
+BinaryStream::BinaryStream() {
+ m_readPosition = 0;
+}
+
+BinaryStream::~BinaryStream() {
+}
+
+const unsigned char* BinaryStream::char_pointer() const {
+ return &m_data[0];
+}
+
+size_t BinaryStream::size() const {
+ return m_data.size();
+}
+// BinaryStream
+
+ace_return_t run_popup(
+ ace_popup_t popup_type,
+ const ace_resource_t resource_name,
+ const ace_session_id_t session_id,
+ const ace_param_list_t* ace_param_list,
+ ace_widget_handle_t handle,
+ ace_bool_t* validation_result)
+{
+ if ( NULL == resource_name ||
+ NULL == session_id ||
+ NULL == ace_param_list ||
+ NULL == validation_result )
+ {
+ LogError("run_popup : ACE_INVALID_ARGUMENTS");
+ return ACE_INVALID_ARGUMENTS;
+ }
+ LogDebug("popup_type : " << popup_type);
+ LogDebug("resource_name : " << resource_name);
+ LogDebug("session_id : " << session_id);
+ LogDebug("widget handle : " << handle);
+
+ int popup_type_int = static_cast <int> (popup_type);
+ char *resource_name_char = static_cast <char *> (resource_name);
+ char *session_id_char = static_cast <char *> (session_id);
+ int handle_int = static_cast <int> (handle);
+
+ // serialization
+ Wrt::Popup::BinaryStream stream;
+ DPL::Serialization::Serialize(stream, popup_type_int);
+
+ std::string resource_name_str(resource_name_char);
+ DPL::Serialization::Serialize(stream, resource_name_str);
+
+ std::string session_id_str(session_id_char);
+ DPL::Serialization::Serialize(stream, session_id_str);
+
+ DPL::Serialization::Serialize(stream, handle_int);
+
+ _ace_params_serializer (ace_param_list, &stream);
+
+ int fd_send_to_child[2];
+ int fd_send_to_parent[2];
+ pid_t childpid;
+
+ if(0 != pipe(fd_send_to_child)){
+ LogError("Cannot create pipes!");
+ return ACE_INTERNAL_ERROR;
+ }
+ if(0 != pipe(fd_send_to_parent)){
+ LogError("Cannot create pipes!");
+ return ACE_INTERNAL_ERROR;
+ }
+
+ if ((childpid = fork()) == -1) {
+ LogError("Fork() ERROR");
+ return ACE_ACE_UNKNOWN_ERROR;
+ }
+
+ if(childpid == 0) { // Child process
+ LogDebug("Child");
+
+ // read data from parent
+ close(fd_send_to_child[1]);
+
+ // send data to parent
+ close(fd_send_to_parent[0]);
+
+ std::stringstream pipe_in_buff;
+ std::stringstream pipe_out_buff;
+ pipe_in_buff << fd_send_to_parent[1];
+ pipe_out_buff << fd_send_to_child[0];
+ std::string pipe_in = pipe_in_buff.str();
+ std::string pipe_out = pipe_out_buff.str();
+
+ LogDebug("Passed file descriptors: " << fd_send_to_child[0] << ", "<< fd_send_to_parent[1]);
+
+ if (execl(POPUP_EXEC, POPUP_EXEC, pipe_out.c_str(), pipe_in.c_str(), NULL) < 0){
+ LogError("execlp FAILED");
+ }
+
+ LogError("This should not happened!!!");
+
+ } // end of child process - from now you can use DEBUG LOGS
+ else { // Parent process
+ LogDebug("Parent");
+
+ int buff_size = 1024;
+ char result[buff_size];
+ // send data to child
+ close(fd_send_to_child[0]);
+
+ //writing to child
+ LogDebug("Sending message to popup-bin process");
+ if(-1 == TEMP_FAILURE_RETRY(write(fd_send_to_child[1], stream.char_pointer(), stream.size()))){
+ LogError("Write to pipe failed!");
+ return ACE_INTERNAL_ERROR;
+ }
+ close(fd_send_to_child[1]); // cleanup
+ LogDebug("Message has been sent");
+
+ // read data from child
+ close(fd_send_to_parent[1]);
+
+ int status;
+ wait(&status);
+ LogDebug("STATUS EXIT ON POPUP (CHILD): " << status);
+ switch (status){
+
+ case ACE_OK:
+ LogDebug("ACE_OK");
+ break;
+
+ case ACE_INVALID_ARGUMENTS:
+ LogDebug("ACE_INVALID_ARGUMENTS");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t> (status);
+ break;
+
+ case ACE_INTERNAL_ERROR:
+ LogDebug("ACE_INTERNAL_ERROR");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t> (status);
+ break;
+
+ case ACE_ACE_UNKNOWN_ERROR:
+ LogDebug("ACE_ACE_UNKNOWN_ERROR");
+ close(fd_send_to_parent[0]);
+ return static_cast <ace_return_t> (status);
+ break;
+
+ default:
+ LogDebug("UNKNOWN_ERROR");
+ close(fd_send_to_parent[0]);
+ status = (int) ACE_ACE_UNKNOWN_ERROR;
+ return static_cast <ace_return_t> (status);
+ break;
+ }
+
+ int count;
+ count = TEMP_FAILURE_RETRY(read(fd_send_to_parent[0], result, buff_size));
+ close(fd_send_to_parent[0]); // cleanup
+ int validation_result_int;
+
+ if(0 < count){
+ BinaryStream stream_in;
+ stream_in.Write(count, result);
+ LogDebug("RESULT FROM POPUP (CHILD) : [ " << count << " ]");
+ DPL::Deserialization::Deserialize(stream_in, validation_result_int);
+ *validation_result = static_cast <ace_bool_t> (validation_result_int);
+
+ LogDebug("validation_result :");
+ switch (*validation_result){
+ case ACE_FALSE:
+ LogDebug("ACE_FALSE");
+ break;
+ case ACE_TRUE:
+ LogDebug("ACE_TRUE");
+ break;
+ default:
+ LogDebug("UNKNOWN - DEFAULT");
+ break;
+ }
+ }
+ else {
+ LogDebug("count = " << count);
+ LogDebug("UNKNOWN_ERROR");
+ return ACE_ACE_UNKNOWN_ERROR;
+ }
+
+ LogDebug("popup-runner: EXIT");
+ return (ace_return_t) status;
+ }
+
+ LogError("This should not happend!!!");
+ return ACE_ACE_UNKNOWN_ERROR;
+}
+
+} // Popup
+} // Wrt
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * @file popup-runner.h
+ * @author Janusz Kozerski (j.kozerski@samsung.com)
+ * @version 1.0
+ */
+
+#include <ace_api_client.h>
+#include <vector>
+
+#include <dpl/serialization.h>
+
+namespace Wrt{
+namespace Popup{
+
+class BinaryStream : public DPL::IStream {
+ public:
+ void Read (size_t num, void * bytes);
+ void Write(size_t num, const void * bytes);
+
+ BinaryStream();
+ ~BinaryStream();
+
+ const unsigned char* char_pointer() const;
+ size_t size() const;
+
+ private:
+ std::vector<unsigned char> m_data;
+ size_t m_readPosition;
+};
+
+ace_return_t run_popup(
+ ace_popup_t popup_type,
+ const ace_resource_t resource_name,
+ const ace_session_id_t session_id,
+ const ace_param_list_t* ace_param_list,
+ ace_widget_handle_t handle,
+ ace_bool_t* validation_result
+ );
+
+} // Popup
+} // Wrt
--- /dev/null
+<manifest>
+ <define>
+ <domain name="wrt-plugins-common" />
+ <provide>
+ <label name="wrt-plugins-common::wrt-plugins-installer" />
+ </provide>
+ </define>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>