--- /dev/null
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
+*.lo
+.libs
+.deps
+*.la
+Makefile.in
+Makefile
+Documentation/html/
+build-stamp
+*.cmake
+CMakeFiles
+CMakeCache.txt
+data/*.edj
+cmake_build_tmp/
+.cproject
+.project
+debian/files
+debian/tmp/
+debian/wrt/*
+debian/wrt.debhelper.log
+debian/wrt.install
+debian/wrt.postinst
+debian/wrt.postinst.debhelper
+debian/wrt.postrm.debhelper
+debian/wrt.substvars
+debian/wrt-dbg/
+debian/wrt-dbg.substvars
+debian/wrt-test/
+debian/wrt-test.debhelper.log
+debian/wrt-test.substvars
+
DESTINATION /usr/etc/wrt/
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE
)
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/wrt_widget_default_icon.png
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/default_icon_tizen.png
+ DESTINATION share/wrt-engine/
+ )
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/default_icon_wac.png
DESTINATION share/wrt-engine/
)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/data/userAgentProfile.xml
+wrt (0.8.86) unstable; urgency=low
+
+ * [Engine] Splash screen code separated
+ * [Engine] Replace Legacy API to Managed API (#1, aul to capi-appfw-application)
+ * [Engine] Add default icon for tizen
+ * [Engine] Change orientation argument
+ * [Engine] Move checkWACTestCertifiedWidget() to wrt-client side
+ * [Engine] Move localizeWidgetModel() to wrt-client side
+ * [Engine] Move debug settings to wrt-client
+
+ * Git : slp/pkgs/w/wrt
+ * Tag : wrt_0.8.86
+
+ -- Jihoon Chung <jihoon.chung@samsung.com> Thu, 23 Aug 2012 16:24:06 +0900
+
wrt (0.8.85) unstable; urgency=low
* [Engine] WRT API, Widget Controlller and Logic removed
-#sbs-git:slp/pkgs/w/wrt wrt 0.8.85
+#sbs-git:slp/pkgs/w/wrt wrt 0.8.86
Name: wrt
Summary: web runtime
-Version: 0.8.85
+Version: 0.8.86
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
BuildRequires: pkgconfig(ace-client)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(capi-appfw-app-manager)
BuildRequires: pkgconfig(capi-system-haptic)
+BuildRequires: pkgconfig(capi-web-url-download)
BuildRequires: pkgconfig(wrt-plugin-loading)
BuildRequires: pkgconfig(wrt-plugin-js-overlay)
ecore-input
evas
eina
+ ewebkit2
elementary
vconf
cert-svc
libsoup-2.4
ui-gadget-1
- aul
libidn
xmlsec1
secure-storage
PKG_CHECK_MODULES(CORE_MODULE_DEP
libprivilege-control
+ ewebkit2
+ wrt-plugin-js-overlay
+ dpl-efl
REQUIRED
)
/**
* @file core_module.cpp
* @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @author Andrzej Surdej (a.surdej@samsung.com)
* @version 1.0
* @brief File contains definitions of wrt core module.
*/
#include <dpl/assert.h>
#include <dpl/exception.h>
#include <dpl/popup/popup_controller.h>
+#include <dpl/singleton_impl.h>
#include <libxml/parser.h>
#include "localization_setting.h"
#include <dpl/wrt-dao-ro/global_config.h>
#include <widget_deserialize_model.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
+#include <WebKit2/EWebKit2.h>
+
+IMPLEMENT_SINGLETON(WRT::CoreModule)
+
namespace { //Anonymous
+const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
+
std::string cutOffFileName(const std::string& path)
{
size_t found = path.find_last_of("/");
namespace WRT {
-namespace CoreModule {
-
-bool Init()
+class CoreModuleImpl
{
- DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
- LogDebug("Initialize");
- if (!checkPaths()) {
- LogError("Required path does not exist");
- return false;
+public:
+
+ CoreModuleImpl() : m_initialized(false), m_ewkContext(NULL)
+ {
+ LogDebug("enter");
+ }
+
+ ~CoreModuleImpl()
+ {
+ LogError("Core module implementation destroyed");
}
- Try
+
+ bool Init()
+ {
+ if (!m_initialized) {
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT");
+ LogDebug("Initialize");
+ if (!checkPaths()) {
+ LogError("Required path does not exist");
+ return false;
+ }
+ Try
+ {
+ GlobalContext::TouchArchitecture();
+
+ ADD_PROFILING_POINT("attach databases", "start");
+ MainThreadSingleton::Instance().AttachDatabases();
+ ADD_PROFILING_POINT("attach databases", "stop");
+
+ ADD_PROFILING_POINT("xml_parser_init", "start");
+ xmlInitParser();
+ ADD_PROFILING_POINT("xml_parser_init", "stop");
+
+ // Initialize popup manager
+ ADD_PROFILING_POINT("popup_manager_init", "start");
+ DPL::Popup::PopupManagerSingleton::Instance().Initialize(
+ DPL::Popup::PopupRendererPtr(new DPL::Popup::PopupRenderer));
+ ADD_PROFILING_POINT("popup_manager_init", "stop");
+
+ // Initialize Language Subtag registry
+ ADD_PROFILING_POINT("language_rst_init", "start");
+ LocalizationSetting::Initialize();
+ ADD_PROFILING_POINT("language_rst_init", "stop");
+
+
+ // Needed settings for WKContext are located here
+ // create Ewk_Context
+ Ewk_Context* newEwkContext =
+ ewk_context_new_with_injected_bundle_path(bundlePath);
+ if (!newEwkContext) {
+ LogError("Failed to create Ewk_Context");
+ ThrowMsg(DPL::Exception, "Failed to create ewk context");
+ }
+ // cache model setting
+ ewk_context_cache_model_set(newEwkContext,
+ EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
+ m_ewkContext = newEwkContext;
+
+ LogDebug("Initialize finished");
+ } catch (const DPL::Exception& ex) {
+ LogError("Internal Error during screen preparation:");
+ DPL::Exception::DisplayKnownException(ex);
+ /* TODO:
+ * Do deinitialization: check on which step exception occured
+ * and deinitialize only initialized parts.
+ */
+ return false;
+ }
+ m_initialized = true;
+ }
+ return true;
+ }
+
+ void Terminate()
{
- GlobalContext::TouchArchitecture();
-
- ADD_PROFILING_POINT("attach databases", "start");
- MainThreadSingleton::Instance().AttachDatabases();
- ADD_PROFILING_POINT("attach databases", "stop");
-
- ADD_PROFILING_POINT("xml_parser_init", "start");
- xmlInitParser();
- ADD_PROFILING_POINT("xml_parser_init", "stop");
-
- // Initialize popup manager
- ADD_PROFILING_POINT("popup_manager_init", "start");
- DPL::Popup::PopupManagerSingleton::Instance().Initialize(
- DPL::Popup::PopupRendererPtr(new DPL::Popup::PopupRenderer));
- ADD_PROFILING_POINT("popup_manager_init", "stop");
-
- // Initialize Language Subtag registry
- ADD_PROFILING_POINT("language_rst_init", "start");
- LocalizationSetting::Initialize();
- ADD_PROFILING_POINT("language_rst_init", "stop");
-
- LogDebug("Initialize finished");
- } catch (const DPL::Exception& ex) {
- LogError("Internal Error during screen preparation:");
- DPL::Exception::DisplayKnownException(ex);
- /* TODO:
- * Do deinitialization: check on which step exception occured
- * and deinitialize only initialized parts.
- */
- return false;
+ if (m_ewkContext) {
+ LogInfo("finalizeEwkContext called");
+ ewk_context_delete(m_ewkContext);
+ m_ewkContext = 0;
+ }
+ MainThreadSingleton::Instance().DetachDatabases();
+ // Deinitialize popup manager
+ DPL::Popup::PopupManagerSingleton::Instance().Deinitialize();
+
+ LogInfo("Cleanup libxml2 global values.");
+ xmlCleanupParser();
+ m_initialized = false;
}
- return true;
+
+ RunnableWidgetObjectPtr getRunnableWidgetObject(const WidgetHandle& handle)
+ {
+ RunnableWidgetObjectPtr runnable;
+ WidgetModelPtr model = Domain::deserializeWidgetModel(handle);
+ if (!!model) {
+ runnable.reset(new RunnableWidgetObject(model, m_ewkContext));
+ }
+ return runnable;
+ }
+
+private:
+ bool m_initialized;
+ Ewk_Context* m_ewkContext;
+};
+
+CoreModule::CoreModule() : m_impl(new CoreModuleImpl())
+{
}
-void Terminate()
+CoreModule::~CoreModule()
{
- MainThreadSingleton::Instance().DetachDatabases();
- // Deinitialize popup manager
- DPL::Popup::PopupManagerSingleton::Instance().Deinitialize();
+}
- LogInfo("Cleanup libxml2 global values.");
- xmlCleanupParser();
+bool CoreModule::Init()
+{
+ return m_impl->Init();
}
-RunnableWidgetObjectPtr getRunnableWidgetObject(
- const WidgetHandle& handle)
+void CoreModule::Terminate()
{
- RunnableWidgetObjectPtr runnable;
- WidgetModelPtr model = Domain::deserializeWidgetModel(handle);
- if (!!model) {
- runnable.reset(new RunnableWidgetObject(model));
- }
- return runnable;
+ return m_impl->Terminate();
+}
+
+RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(const WidgetHandle& handle)
+{
+ return m_impl->getRunnableWidgetObject(handle);
}
-RunnableWidgetObjectPtr getRunnableWidgetObject(const std::string& packageName)
+RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(const std::string& packageName)
{
DPL::OptionalString pkgName(DPL::FromUTF8String(packageName));
try {
- return CoreModule::getRunnableWidgetObject(
+ return m_impl->getRunnableWidgetObject(
WrtDB::WidgetDAOReadOnly::getHandle(pkgName));
} catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
LogDebug("Widget not found.");
}
}
-} //namespace CoreModule
-
} /* namespace WRT */
/**
* @file core_module.cpp
* @author Przemyslaw Ciezkowski (p.ciezkowski@samsung.com)
+ * @authir Andrzej Surdej (a.surdej@gmail.com)
* @version 1.0
* @brief File contains declarations of wrt core module.
*/
#include <dpl/wrt-dao-ro/wrt_db_types.h>
#include "i_runnable_widget_object.h"
+#include <dpl/singleton.h>
+#include <memory>
namespace WRT {
-namespace CoreModule {
+class CoreModuleImpl; // forward declaration
+
+class CoreModule
+{
+ public:
/**
* Initialize needed by WRT components (database etc).
* Will not throw exception. elm_init() is NOT called in this function.
*/
RunnableWidgetObjectPtr getRunnableWidgetObject(
const std::string& packageName);
-} //namespace CoreModule
+ private:
+ CoreModule();
+ ~CoreModule();
+ std::unique_ptr<CoreModuleImpl> m_impl;
+
+ friend class DPL::Singleton<CoreModule>;
+};
+
+typedef DPL::Singleton<CoreModule> CoreModuleSingleton;
} /* namespace WRT */
#endif /* CORE_MODULE_H_ */
#include <dpl/wrt-dao-ro/wrt_db_types.h>
#include <memory>
#include <Evas.h>
+#include <widget_launch_struct.h>
+#include <widget_model.h>
namespace WRT {
-
-typedef void (*FinishedCallbackFunction)(bool success, void *userData);
-struct FinishedCallback {
- FinishedCallbackFunction callback;
- void* userData;
-};
+typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
class IRunnableWidgetObject {
public:
*/
virtual void PrepareView(Evas_Object *buffer = NULL) = 0;
/**
- * Sets debug mode on/off. When it is on, RT signal is send
- * to wrt-launcher for given pid.
- * @param debugMode
- * @param sdkLauncherPid
- */
- virtual void SetDebugMode(bool debugMode, int sdkLauncherPid) = 0;
- /**
* Shows widget asynchronously. Callback will be called when
* webkit generates website.
* @param callback
*/
- virtual void Show(FinishedCallback callback) = 0;
+ virtual void Show(WidgetLaunchStruct launchStruct) = 0;
/**
* Hides widget. To show it again Reset must be called.
*/
* Resets widgets after calling Hide().
*/
virtual void Reset() = 0;
+ /**
+ * Retrieve widget's model
+ * @return WidgetModelPtr
+ */
+ virtual WidgetModelPtr GetModel() = 0;
};
typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
*/
#include "runnable_widget_object.h"
-#include <widget_localize_model.h>
#include <privilege-control.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include "global_logic.h"
#include <profiling_util.h>
#include <signal.h>
#include <common/window_data.h>
+#include "webkit/bundles/plugin_module_support.h"
namespace { //Anonymous
const std::string STILL_AUTHORIZING = _("IDS_IM_POP_AUTHORIZING_ING_ATNT");
const unsigned int UID_ROOT = 0;
-struct LaunchCallbackData {
- WRT::FinishedCallback callback;
- SDKDebugData* debugData;
- WRT::RunnableWidgetObject* widgetObject;
-};
} // namespace anonymous
namespace WRT {
-RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model) :
- m_widgetModel(model), m_debugMode(false), m_sdkLauncherPid(0) {
+RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context) :
+ m_widgetModel(model),
+ m_ewkContext(context) {
// If current uid is 'root', change privilege to apps
if (UID_ROOT == getuid()) {
// Set privilege by pkgname
set_process_config(DPL::ToUTF8String(widgetModel->PkgName.Get()).c_str());
#endif
- // WAC Waikiki Beta Release Core Specification: Widget Runtime
- // 10 Dec 2010
- //
- // WR-4710 The WRT MUST enable debug functions only for WAC test widgets
- // i.e. the functions must not be usable for normal WAC widgets, even when
- // a WAC test widget is executing.
- ADD_PROFILING_POINT("DeveloperModeCheck", "start");
-
- if (!CheckWACTestCertififedWidget())
- {
- return false;
- }
- ADD_PROFILING_POINT("DeveloperModeCheck", "stop");
-
if (m_widgetModel->StartURL.Get().IsNull()) {
LogWarning("Widget is invalid in currently selected locales");
return false;
}
- // Widget is not running, localized data can be updated
- LocalizeWidgetModel();
-
// Inform view controller about new widget model displaying
ADD_PROFILING_POINT("OCSPCheck", "start");
ADD_PROFILING_POINT("view_logic_init", "start");
m_view = ViewModule::getView();
- WrtDB::WidgetDAOReadOnly dao(m_widgetModel->Handle.Get());
- DPL::OptionalString img_path(dao.getSplashImgSrc());
- if (!img_path.IsNull()) {
- m_windowData->setSplashImagePath((DPL::ToUTF8String(*img_path)).c_str());
+ m_splashScreen.reset(new ViewModule::SplashScreenSupport(m_windowData->m_win));
+ if (m_splashScreen->createSplashScreen(m_widgetModel->Handle.Get())) {
+ m_splashScreen->startSplashScreen();
+
+ // TODO get rid of conformant and splash image
+ m_view->createWebView(
+ m_ewkContext,
+ m_windowData->m_win,
+ m_windowData->m_conformant,
+ DPL::MakeDelegate(
+ m_splashScreen.get(),
+ &ViewModule::SplashScreenSupport::stopSplashScreen)
+ );
+ } else {
+ m_view->createWebView(m_ewkContext,
+ m_windowData->m_win,
+ m_windowData->m_conformant);
}
-
- m_view->createWebView(m_windowData->m_win,
- m_windowData->m_conformant,
- m_windowData->m_splashImage);
evas_object_show(m_windowData->m_win);
initializeWindowModes();
} else {
LogDebug("Buffer is not null, passing to view");
m_view = ViewModule::getView();
- m_view->createWebView(buffer, NULL, NULL);
+ m_view->createWebView(m_ewkContext, buffer, NULL, NULL);
}
m_view->initialize();
m_view->prepareView(m_widgetModel.get());
ADD_PROFILING_POINT("view_logic_init", "stop");
}
-void RunnableWidgetObject::SetDebugMode(bool debugMode, int sdkLauncherPid)
-{
- m_debugMode = debugMode;
- m_sdkLauncherPid = sdkLauncherPid;
-}
-
-void RunnableWidgetObject::LaunchWidgetCallback(WidgetHandle widgetHandle,
- CommonError::Type result,
- const std::string& errorMsg,
- UserParam userParam) {
- LogDebug("Calling callback");
- LaunchCallbackData* launch =
- static_cast<LaunchCallbackData *>(userParam);
-
- if (result == CommonError::WrtSuccess) {
- LogDebug("Launch succesfull");
- launch->callback.callback(true, launch->callback.userData);
- } else {
- LogError("Launch unsuccesfull: " << errorMsg);
- launch->callback.callback(false, launch->callback.userData);
- }
-
- if(launch->debugData->debugMode == true)
- {
- LogDebug("Send RT signal to wrt-launcher(pid: "
- << launch->widgetObject->m_sdkLauncherPid << ", result: "
- << result);
- union sigval sv;
- // send real time signal with result to wrt-launcher
- if(result == CommonError::WrtSuccess)
- {
- LogDebug("userData->portnum : " << launch->debugData->portnum);
- sv.sival_int = launch->debugData->portnum;
- }
- else
- {
- sv.sival_int = -1;
- }
- sigqueue(launch->widgetObject->m_sdkLauncherPid, SIGRTMIN, sv);
- }
-
- LogDebug("Cleaning RunnableWidgetObject launch resources...");
-
- delete launch->debugData->pid;
- delete launch->debugData;
- delete launch;
-}
-
-void RunnableWidgetObject::Show(FinishedCallback callback)
+void RunnableWidgetObject::Show(WidgetLaunchStruct launchStruct)
{
- SDKDebugData* debugData = new SDKDebugData;
- debugData->debugMode = m_debugMode;
- debugData->pid = new unsigned long(getpid());
- LaunchCallbackData* userData = new LaunchCallbackData();
- userData->debugData = debugData;
- userData->callback = callback;
- userData->widgetObject = this;
- WidgetLaunchStruct launch(
- userData->debugData->pid,
- &LaunchWidgetCallback,
- userData,
- userData->debugData,
- "");
connectElmCallback();
- m_view->setLaunchFinishedCallback(launch);
+ m_view->setLaunchFinishedCallback(launchStruct);
m_view->showWidget();
if (m_windowData) {
m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
}
}
-bool RunnableWidgetObject::CheckWACTestCertififedWidget()
-{
- Assert(!!m_widgetModel);
- // WAC test widget
- // A widget signed with a WAC-issued test certificate as described in
- // Developer Mode.
-
- bool developerWidget = m_widgetModel->IsTestWidget.Get();
- bool developerMode =
- GlobalLogicSingleton::Instance().GetGlobalModel()->DeveloperMode.Get();
-
- LogDebug("Is WAC test widget: " << developerWidget);
- LogDebug("Is developer Mode: " << developerMode);
-
- if (developerWidget) {
- if(!developerMode)
- {
- LogError("WAC test certified developer widget is needed for " <<
- "developer mode");
- return false;
- }else{
- //TODO: WR-4660 (show popup about developer widget
- // during launch
- LogInfo("POPUP: THIS IS TEST WIDGET!");
- }
- }
- return true;
-}
-
-void RunnableWidgetObject::LocalizeWidgetModel() {
- Domain::localizeWidgetModel(m_widgetModel);
- m_widgetModel->RunningName.Set(m_widgetModel->Name.Get());
- m_widgetModel->RunningIcon.Set(m_widgetModel->Icon.Get());
- m_widgetModel->RunningStartURL.Set(m_widgetModel->StartURL.Get());
- m_widgetModel->RunningShortName.Set(m_widgetModel->ShortName.Get());
- m_widgetModel->RunningDescription.Set(m_widgetModel->Description.Get());
- m_widgetModel->RunningLicense.Set(m_widgetModel->License.Get());
- m_widgetModel->RunningLicenseHref.Set(m_widgetModel->LicenseHref.Get());
- m_widgetModel->RunningStartFileInfo.Set(
- m_widgetModel->StartFileInfo.Get());
+WidgetModelPtr RunnableWidgetObject::GetModel() {
+ Assert(m_widgetModel);
+ return m_widgetModel;
}
void RunnableWidgetObject::initializeWindowModes()
RunnableWidgetObject::~RunnableWidgetObject()
{
LogDebug("");
- if (m_view) {
- m_view->destroyWebView();
- }
+ PluginModuleSupport::shutdown(m_ewkContext);
}
} /* namespace WRT */
#include <i_view_module.h>
#include <common_error.h>
#include <widget_launch_struct.h>
+#include <common/view_logic_splash_screen_support.h>
+
+#include <WebKit2/ewk_context.h>
class WindowData;
namespace WRT {
-typedef std::shared_ptr<WidgetModel> WidgetModelPtr;
class RunnableWidgetObject : public IRunnableWidgetObject
{
public:
- RunnableWidgetObject(WidgetModelPtr &model);
+ RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context);
bool CheckBeforeLaunch();
void PrepareView(Evas_Object *buffer = NULL);
- void SetDebugMode(bool debugMode, int sdkLauncherPid);
- void Show(FinishedCallback callback); //asynchronous function
+ void Show(WidgetLaunchStruct launchStruct); //asynchronous function
void Hide();
void Suspend();
void Resume();
void Reset();
+ WidgetModelPtr GetModel();
virtual ~RunnableWidgetObject();
private:
static void LaunchWidgetCallback(WidgetHandle widgetHandle,
void connectElmCallback();
WidgetModelPtr m_widgetModel;
- bool checkWACTestCertififedWidget();
void localizeWidgetModel();
ViewModule::IViewModulePtr m_view;
+ Ewk_Context* m_ewkContext;
std::unique_ptr<WindowData> m_windowData;
- bool m_debugMode;
- int m_sdkLauncherPid;
-
+ std::unique_ptr<ViewModule::SplashScreenSupport> m_splashScreen;
};
} /* namespace WRT */
PKG_CHECK_MODULES(VIEW_COMMON_DEP
appsvc
- aul
+ capi-appfw-app-manager
capi-system-haptic
+ capi-web-url-download
dpl-efl
dpl-event-efl
eina
+ elementary
evas
libcurl # uri unescape
libiri
ui-gadget-1
vcore
wrt-commons-auto-save-dao-rw
+ dpl-wrt-dao-ro
wrt-security
ace-client
REQUIRED
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_apps_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_custom_header_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_security_support.cpp
+ ${PROJECT_SOURCE_DIR}/src/view/common/view_logic_splash_screen_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_debugger_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_geolocation_support.cpp
${PROJECT_SOURCE_DIR}/src/view/common/view_logic_password_support.cpp
*/
#include "application_launcher.h"
-#include <aul.h>
+#include <app.h>
+#include <app_manager.h>
+#include <url_download.h>
#include <youtubehd.h>
#include <dpl/singleton_impl.h>
#include <appsvc.h>
using namespace WrtDB;
namespace {
-const char * const BUNDLE_PATH = "path";
-const char * const BUNDLE_COOKIE = "cookie";
+const char * const SERVICE_EXTRA_DATA_KEY_PATH = "path";
+const char * const SERVICE_EXTRA_DATA_KEY_COOKIE = "cookie";
const char * const SCHEME_TYPE_YOUTUBE = "vnd.youtube";
const char * const SCHEME_TYPE_RTSP = "rtsp";
return;
}
- bundle* bundle = bundle_create();
+ service_h serviceHandle = NULL;
+ int ret = SERVICE_ERROR_NONE;
- if (NULL == bundle) {
- LogError("Fail to create bundle");
+ // create service
+ ret = service_create(&serviceHandle);
+ if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
+ LogError("Fail to create service");
return;
}
- if (appsvc_set_uri(bundle, url.c_str())) {
- LogError("Fail to add bundle for path");
- bundle_free(bundle);
+
+ // set service operation
+ ret = service_set_operation(serviceHandle, SERVICE_OPERATION_DOWNLOAD);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set operation [" << ret << "]");
+ service_destroy(serviceHandle);
+ return;
+ }
+
+ // set service uri
+ ret = service_set_uri(serviceHandle, url.c_str());
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set uri [" << ret << "]");
+ service_destroy(serviceHandle);
return;
}
+
+ // set cookie
if (cookie != "null") {
- if (bundle_add(bundle, BUNDLE_COOKIE, cookie.c_str())) {
- LogError("Fail to add bundle for cookie");
- bundle_free(bundle);
+ ret = service_add_extra_data(serviceHandle,
+ SERVICE_EXTRA_DATA_KEY_COOKIE,
+ cookie.c_str());
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to add cookie [" << ret << "]");
+ service_destroy(serviceHandle);
return;
}
}
- if (aul_launch_app(PKG_NAME_DOWNLOAD_PROVIDER.c_str(), bundle) < 0) {
- LogError("aul_launch_app is failed");
+
+ //launch service
+ ret = service_send_launch_request(serviceHandle, NULL, NULL);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to launch service [" << ret << "]");
+ service_destroy(serviceHandle);
+ return;
}
- bundle_free(bundle);
+
+ LogDebug("Success launch " << SERVICE_OPERATION_DOWNLOAD);
+ service_destroy(serviceHandle);
+ return;
} else if (PKG_NAME_VIDEO_PLAYER == pkgName) {
- if (aul_app_is_running(PKG_NAME_VT_MAIN.c_str()))
+ bool isRunning = false;
+ if (APP_MANAGER_ERROR_NONE !=
+ app_manager_is_running(PKG_NAME_VT_MAIN.c_str(), &isRunning))
{
- LogError("video-call is running......");
+ LogError("Fail to get app running information");
+ return;
+ }
+ if (true == isRunning) {
+ LogError("video-call is running");
return;
}
std::string scheme(event.GetArg1());
std::string uri(event.GetArg2());
std::string cookie(event.GetArg3());
- const char* videoPath;
- int aulRVal = AUL_R_ERROR;
+ const char* url;
if ("null" == scheme) {
LogError("scheme is empty");
LogDebug("scheme: " << scheme);
if (SCHEME_TYPE_YOUTUBE == scheme) {
YouTubeHD *youtube = new YouTubeHD(m_widgetHandle);
- videoPath = youtube->getYouTubeHD(uri.c_str());
+ url = youtube->getYouTubeHD(uri.c_str());
delete youtube;
} else if (SCHEME_TYPE_RTSP == scheme ||
(SCHEME_TYPE_HTML5_VIDEO == scheme))
{
- videoPath = uri.c_str();
+ url = uri.c_str();
} else {
LogError("scheme is invalid!!");
return;
}
- bundle *bundle = bundle_create();
- if (bundle == NULL) {
- LogError("Fail to create bundle");
- bundle_free(bundle);
+ service_h serviceHandle = NULL;
+ int ret = SERVICE_ERROR_NONE;
+
+ // create service
+ ret = service_create(&serviceHandle);
+ if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
+ LogError("Fail to create service");
return;
}
- if (! videoPath || strlen(videoPath)==0) {
- LogError("getYouTubeHD is FAILED!!");
- bundle_free(bundle);
+ // set url
+ if (!url || strlen(url) == 0) {
+ LogError("Fail to get url");
+ service_destroy(serviceHandle);
return;
}
- LogDebug("videoPath: " << videoPath);
- if (bundle_add(bundle, BUNDLE_PATH, videoPath) < 0) {
- LogError("bundle_add is FAIL!!");
- bundle_free(bundle);
+ ret = service_add_extra_data(serviceHandle,
+ SERVICE_EXTRA_DATA_KEY_PATH,
+ url);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set url [" << ret << "]");
+ service_destroy(serviceHandle);
return;
}
+ // set cookie
if (SCHEME_TYPE_HTML5_VIDEO == scheme) {
if ("null" != cookie) {
- LogDebug("cookie: " << cookie);
- if (bundle_add(bundle, BUNDLE_COOKIE, cookie.c_str()) < 0) {
- LogError("cookie is empty");
- bundle_free(bundle);
+ ret = service_add_extra_data(serviceHandle,
+ SERVICE_EXTRA_DATA_KEY_COOKIE,
+ cookie.c_str());
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to add cookie [" << ret << "]");
+ service_destroy(serviceHandle);
return;
}
}
}
- aulRVal = aul_launch_app(PKG_NAME_VIDEO_PLAYER.c_str(), bundle);
- if (AUL_R_OK > aulRVal) {
- LogError("aul_launch_app is failed! aulRVal: " << aulRVal);
+ // set package
+ ret = service_set_package(serviceHandle, PKG_NAME_VIDEO_PLAYER.c_str());
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set package [" << ret << "]");
+ service_destroy(serviceHandle);
+ return;
}
- if (bundle_free(bundle)) {
- LogDebug("bundle_free is FAILED!!");
+
+ //launch service
+ ret = service_send_launch_request(serviceHandle, NULL, NULL);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to launch service [" << ret << "]");
+ service_destroy(serviceHandle);
+ return;
}
+ LogDebug("Success launch " << PKG_NAME_VIDEO_PLAYER);
+ service_destroy(serviceHandle);
+ return;
}
}
appsvc_set_operation(args, APPSVC_OPERATION_VIEW);
appsvc_set_mime(args, mimeType.c_str());
appsvc_set_uri(args, uri.c_str());
+ } else if (!strcasecmp(mimeType.c_str(), "video/mp4") ||
+ !strcasecmp(mimeType.c_str(), "vidoe/3gp"))
+ {
+ CONTROLLER_POST_EVENT(
+ ApplicationLauncher,
+ ApplicationLauncherEvents::LaunchApplicationByPkgname(
+ ApplicationLauncherPkgname::PKG_NAME_VIDEO_PLAYER,
+ SCHEME_TYPE_HTML5_VIDEO,
+ uri,
+ "null"));
} else {
LogInfo("Not Supported MIME type in WRT");
return false;
m_conformant = createConformant(m_user_layout);
evas_object_show(m_conformant);
m_progress = createProgress(m_user_layout);
- m_splashImage = createSplashImage(m_user_layout);
result = ug_init(
static_cast<Display*>(ecore_x_display_get()),
elm_object_content_unset(m_conformant);
}
-void WindowData::setSplashImagePath(const char * image_path)
-{
- if (image_path) {
- LogInfo("splash screen image path : " << image_path);
-
- if (elm_icon_file_set(m_splashImage, image_path, NULL)) {
- if (elm_icon_animated_available_get(m_splashImage)) {
- elm_icon_animated_set(m_splashImage, EINA_TRUE);
- elm_icon_animated_play_set(m_splashImage, EINA_FALSE);
- } else {
- elm_icon_animated_set(m_splashImage, EINA_FALSE);
- }
- } else {
- LogError("loading splash image has been failed");
- }
- }
-}
-
void WindowData::loadingOn()
{
LogInfo("loadingOn");
evas_object_move(m_progress, alignedX, alignedY);
}
-Evas_Object* WindowData::createSplashImage(Evas_Object* parent)
-{
- Assert(parent != NULL && "Parent for splash image is null");
-
- Evas_Coord x, y, w, h;
- evas_object_geometry_get(m_win, &x, &y, &w, &h);
-
- Evas_Object* splashImage = elm_icon_add(parent);
-
- evas_object_resize(splashImage, w, h);
- evas_object_image_fill_set(splashImage, 0, 0, w, h);
-
- return splashImage;
-}
-
void WindowData::addNaviBackButtonCallback(
const char* event,
CallbackType callback,
public:
Evas_Object* m_win;
Evas_Object* m_conformant;
- Evas_Object* m_splashImage;
explicit WindowData(unsigned long pid, bool manualInit=false);
virtual ~WindowData();
void init();
void setEvasObjectForLayout(Evas_Object* evas_object);
void unsetEvasObjectForLayout();
- void setSplashImagePath(const char * image_path);
void loadingOn();
void loadingOff();
void moveProgress();
Evas_Object* createUserLayout(Evas_Object* parent);
Evas_Object* createConformant(Evas_Object* parent);
Evas_Object* createProgress(Evas_Object* parent);
- Evas_Object* createSplashImage(Evas_Object* parent);
void alignProgressPosition();
void createTitle(const char* data);
void removeTitle();
#include <memory>
#include <string>
+#include <dpl/fast_delegate.h>
#include <common/evas_object.h>
+#include <WebKit2/ewk_context.h>
#ifndef WRT_SRC_VIEW_I_VIEW_MODULE_H_
#define WRT_SRC_VIEW_I_VIEW_MODULE_H_
struct WidgetLaunchStruct; //FORWARD DECLARATION
struct OperationStatusStruct; //FORWARD DECLARATION
struct InitScreenStruct; //FORWARD DECLARATION
-namespace ViewModule
-{
+namespace ViewModule {
+
+typedef DPL::FastDelegate0<void> ProgresFinishedCallback;
/** \brief Interface to ViewModule. Object of IViewModule type is returned from
* ViewModuleMgr factory.
class IViewModule
{
public:
- virtual void createWebView(Evas_Object* window,
+ virtual void createWebView(Ewk_Context* context,
+ Evas_Object* window,
Evas_Object* conformant = NULL,
- Evas_Object* splashImage = NULL) = 0;
+ ProgresFinishedCallback cb = NULL) = 0;
virtual void destroyWebView() = 0;
virtual void initialize() = 0;
virtual void terminate() = 0;
}
-void ViewLogic::createWebView(Evas_Object* window,
+void ViewLogic::createWebView(Ewk_Context* context,
+ Evas_Object* window,
Evas_Object* conformant,
- Evas_Object* splashImage)
+ ViewModule::ProgresFinishedCallback cb)
{
LogDebug("");
- m_splashImage = splashImage;
- if (m_splashImage) {
- LogInfo("splashImageOn");
- if (elm_icon_animated_get(m_splashImage) == EINA_TRUE) {
- elm_icon_animated_play_set(m_splashImage, EINA_TRUE);
- }
- evas_object_show(m_splashImage);
-
- }
-
- initializeEwkContext();
+ m_finishedCallback = cb;
+ initializeEwkContext(context);
Assert(NULL != m_ewkContext);
Assert(window);
m_window = window;
// evas_object_del(*it);
//}
m_ewkViewList.clear();
- PluginModuleSupport::shutdown(m_ewkContext);
}
void ViewLogic::suspendWidget(
}
}
-void ViewLogic::initializeEwkContext(void)
+void ViewLogic::initializeEwkContext(Ewk_Context* newEwkContext)
{
LogInfo("initializeEwkContext called");
- // Needed settings for WKContext are located here
- // create Ewk_Context
- Ewk_Context* newEwkContext =
- ewk_context_new_with_injected_bundle_path(bundlePath);
- if (!newEwkContext) {
- LogError("Failed to create Ewk_Context");
- Assert(false);
- }
-
+ Assert(newEwkContext && "Ewk_Context provided can not be null");
// bundle callback setting
ewk_context_message_from_injected_bundle_callback_set(
newEwkContext,
contextMessageFromInjectedBundleCallback,
static_cast<void*>(this));
- // cache model setting
- ewk_context_cache_model_set(newEwkContext,
- EWK_CACHE_MODEL_PRIMARY_WEBBROWSER);
-
// proxy server setting
char *proxyAddress = vconf_get_str(VCONFKEY_NETWORK_PROXY);
if ((!proxyAddress) || (strlen(proxyAddress) == 0)
m_appsSupport(new ViewModule::AppsSupport()),
m_vibrationSupport(new ViewModule::VibrationSupport()),
m_window(NULL),
- m_conformant(NULL),
- m_splashImage(NULL)
+ m_conformant(NULL)
{
}
const void* clientinfo)
{
LogDebug("didFinishProgressCallback");
- Assert(clientinfo);
- ViewLogic* This = static_cast<ViewLogic*>(const_cast<void*>(clientinfo));
-
- if (This->m_splashImage) {
- LogInfo("splashImageOff");
- if (elm_icon_animated_get(This->m_splashImage) == EINA_TRUE) {
- elm_icon_animated_play_set(This->m_splashImage, EINA_FALSE);
- }
- evas_object_hide(This->m_splashImage);
- }
+ ViewLogic const * const view = static_cast<ViewLogic const * const>(clientinfo);
+ if (!view->m_finishedCallback.empty())
+ view->m_finishedCallback();
}
void ViewLogic::createWindowCallback(
} else if(orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
LogDebug("orientation is portrait-secondary");
elm_win_rotation_with_resize_set(This->m_window, 180);
- ewk_view_orientation_send(obj, -180);
+ ewk_view_orientation_send(obj, 180);
} else if(orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
LogDebug("orientation is landscape-secondary");
elm_win_rotation_with_resize_set(This->m_window, 90);
class ViewLogic : public ViewModule::IViewModule
{
public:
- void createWebView(Evas_Object* window,
+ void createWebView(Ewk_Context* context,
+ Evas_Object* window,
Evas_Object* conformant = NULL,
- Evas_Object* splashImage = NULL);
+ ViewModule::ProgresFinishedCallback cb = NULL);
void destroyWebView();
void initialize();
void terminate();
void goBack();
// Ewk_Context operations
- void initializeEwkContext(void);
+ void initializeEwkContext(Ewk_Context* context);
void finalizeEwkContext();
ViewLogic();
virtual ~ViewLogic();
Evas_Object* m_currentEwkView;
Evas_Object* m_window;
Evas_Object* m_conformant;
- Evas_Object* m_splashImage;
WidgetModel* m_model;
std::string m_currentUri;
std::string m_blockedUri;
bool m_emptyView;
std::string m_theme;
+ ViewModule::ProgresFinishedCallback m_finishedCallback;
+
std::unique_ptr<SchemeSupport> m_schemeSupport;
std::unique_ptr<ViewModule::AppsSupport> m_appsSupport;
std::unique_ptr<ViewModule::VibrationSupport> m_vibrationSupport;
#include <dpl/optional_typedefs.h>
#include <common/application_data.h>
#include <core_module.h>
+#include <global_logic.h>
+#include <widget_localize_model.h>
WrtClient::WrtClient(int argc, char **argv) :
Application(argc, argv, "wrt-client", false),
void WrtClient::initStep()
{
LogDebug("");
- if (WRT::CoreModule::Init()) {
+ if (WRT::CoreModuleSingleton::Instance().Init()) {
m_initialized = true;
} else {
m_returnStatus = ReturnStatus::Failed;
NextStepEvent());
}
-void WrtClient::LaunchCallback(bool success, void *data) {
- WrtClient* wrtClient = static_cast<WrtClient*>(data);
- if (success) {
+void WrtClient::localizeWidgetModel() {
+ Assert(!!m_widget);
+ WRT::WidgetModelPtr model = m_widget->GetModel();
+ Assert(!!model);
+ Domain::localizeWidgetModel(model);
+ model->RunningName.Set(model->Name.Get());
+ model->RunningIcon.Set(model->Icon.Get());
+ model->RunningStartURL.Set(model->StartURL.Get());
+ model->RunningShortName.Set(model->ShortName.Get());
+ model->RunningDescription.Set(model->Description.Get());
+ model->RunningLicense.Set(model->License.Get());
+ model->RunningLicenseHref.Set(model->LicenseHref.Get());
+ model->RunningStartFileInfo.Set(
+ model->StartFileInfo.Get());
+}
+
+bool WrtClient::checkWACTestCertififedWidget()
+{
+ // WAC Waikiki Beta Release Core Specification: Widget Runtime
+ // 10 Dec 2010
+ //
+ // WR-4710 The WRT MUST enable debug functions only for WAC test widgets
+ // i.e. the functions must not be usable for normal WAC widgets, even when
+ // a WAC test widget is executing.
+ ADD_PROFILING_POINT("DeveloperModeCheck", "start");
+ Assert(!!m_widget);
+ WRT::WidgetModelPtr model = m_widget->GetModel();
+ Assert(!!model);
+ // WAC test widget
+ // A widget signed with a WAC-issued test certificate as described in
+ // Developer Mode.
+
+ bool developerWidget = model->IsTestWidget.Get();
+ bool developerMode =
+ GlobalLogicSingleton::Instance().GetGlobalModel()->DeveloperMode.Get();
+
+ LogDebug("Is WAC test widget: " << developerWidget);
+ LogDebug("Is developer Mode: " << developerMode);
+
+ if (developerWidget) {
+ if(!developerMode)
+ {
+ LogError("WAC test certified developer widget is needed for " <<
+ "developer mode");
+ return false;
+ }else{
+ //TODO: WR-4660 (show popup about developer widget
+ // during launch
+ LogInfo("POPUP: THIS IS TEST WIDGET!");
+ }
+ }
+ ADD_PROFILING_POINT("DeveloperModeCheck", "stop");
+ return true;
+}
+
+void WrtClient::staticWrtLaunchWidgetCallback(int /*handle*/,
+ CommonError::Type status,
+ const std::string& errorMsg,
+ void* userdata)
+{
+ WrtLaunchData* userData = static_cast<WrtLaunchData*>(userdata);
+ WrtClient* wrtClient = static_cast<WrtClient*>(userData->wrtClientContext);
+ SDKDebugData* debug = userData->sdkDebugData;
+
+ if (status == CommonError::WrtSuccess) {
LogDebug("Launch succesfull");
wrtClient->m_launched = true;
printf("launched\n");
fflush(stdout);
} else {
- LogError("Launch unsuccesfull");
+ LogError("Launch unsuccesfull: " << errorMsg);
printf("failed\n");
wrtClient->DPL::Event::ControllerEventHandler<NextStepEvent>::
PostEvent(NextStepEvent());
}
+
+ if(debug->debugMode)
+ {
+ LogDebug("Send RT signal to wrt-launcher(pid: "
+ << wrtClient->m_sdkLauncherPid << ", status: " << status);
+ union sigval sv;
+ /* send real time signal with result to wrt-launcher */
+ if(status == CommonError::WrtSuccess)
+ {
+ LogDebug("userData->portnum : " << debug->portnum);
+ sv.sival_int = debug->portnum;
+ }
+ else
+ {
+ sv.sival_int = -1;
+ }
+ sigqueue(wrtClient->m_sdkLauncherPid, SIGRTMIN, sv);
+ }
+
ApplicationDataSingleton::Instance().freeBundle();
+
+ LogDebug("Cleaning wrtClient launch resources...");
+ delete debug->pid;
+ delete debug;
+ delete userData;
}
void WrtClient::launchStep()
{
LogDebug("Launching widget ...");
- m_widget = WRT::CoreModule::getRunnableWidgetObject(m_handle);
+ m_widget = WRT::CoreModuleSingleton::Instance().getRunnableWidgetObject(m_handle);
if (!m_widget) {
LogError("RunnableWidgetObject is NULL, stop launchStep");
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
return;
}
+ // Widget is not running, localized data can be updated
+ localizeWidgetModel();
+
+ if (!checkWACTestCertififedWidget())
+ {
+ LogWarning("WAC Certificate failed, stop launchStep");
+ return;
+ }
+
m_widgetState = WidgetState_Authorizing;
if (!m_widget->CheckBeforeLaunch()) {
LogError("CheckBeforeLaunch failed, stop launchStep");
LogInfo("Widget launch accepted. Entering running state");
m_widgetState = WidgetState_Running;
m_widget->PrepareView();
- m_widget->SetDebugMode(m_debugMode, m_sdkLauncherPid);
- WRT::FinishedCallback callback;
- callback.callback = &LaunchCallback;
- callback.userData = this;
- m_widget->Show(callback);
+ SDKDebugData* debugData = new SDKDebugData;
+ debugData->debugMode = m_debugMode;
+ debugData->pid = new unsigned long(getpid());
+ WrtLaunchData* userData = new WrtLaunchData;
+ userData->wrtClientContext = this;
+ userData->sdkDebugData = debugData;
+ WidgetLaunchStruct launch(
+ debugData->pid,
+ &staticWrtLaunchWidgetCallback,
+ userData,
+ debugData,
+ "");
+ m_widget->Show(launch);
}
void WrtClient::shutdownStep()
m_widgetState = WidgetState_Stopped;
m_widget->Hide();
m_widget.reset();
- WRT::CoreModule::Terminate();
+ WRT::CoreModuleSingleton::Instance().Terminate();
m_initialized = false;
}
Quit();
#include <dpl/type_list.h>
#include <dpl/task.h>
#include <bundle.h>
-#include <runnable_widget_object.h>
+#include <i_runnable_widget_object.h>
#include "widget_state.h"
DECLARE_GENERIC_EVENT_0(NextStepEvent)
void showHelpAndQuit();
bool checkArgument();
void setSdkLauncherDebugData();
+ bool checkWACTestCertififedWidget();
+ void localizeWidgetModel();
// Events
virtual void OnEventReceived(const NextStepEvent& event);
void launchStep();
void shutdownStep();
- static void LaunchCallback(bool success, void *data);
+ static void staticWrtLaunchWidgetCallback(int,
+ CommonError::Type,
+ const std::string&,
+ void*);
// Private data
int m_handle;
bool m_launched;
)
PKG_CHECK_MODULES(LAUNCHER_PKGS
- aul
- bundle
+ capi-appfw-app-manager
dpl-efl
dpl-db-efl
dpl-wrt-dao-rw
*/
#include <iostream>
#include <string>
-#include <aul.h>
-#include <bundle.h>
+#include <app.h>
+#include <app_manager.h>
#include <string.h>
#include <getopt.h>
#include <stdlib.h>
#define WEBAPP_DEFAULT_UID 5000
#define WEBAPP_DEFAULT_GID 5000
#define LOGGING_DEFAULT_GID 6509
-#define WRT_CHANGE_CLIENT_SH "wrt_change_client.sh";
#define RETURN_ERROR -1
static const char *program;
static void free_widget_info(widget_info* widget_info)
{
- if(widget_info)
- {
+ if (widget_info) {
delete[] widget_info->guid;
delete[] widget_info->name;
delete[] widget_info->version;
static bool display_widget_info()
{
- if (NULL == g_dbConnection)
- {
+ if (NULL == g_dbConnection) {
Try {
g_dbConnection.Reset(new DBConnection());
g_dbConnection->AttachDatabase();
WidgetHandleList widgetList = WrtDB::WidgetDAOReadOnly::getHandleList();
printf("%3s%12s%32s%16s%64s%32s\n",
- "No", "ID", "Name", "Version", "GUID", "Package Name");
+ "No", "ID", "Name", "Version", "GUID", "Package Name");
printf("%3s%12s%32s%16s%64s%32s\n",
- "--", "--", "----", "-------", "----", "------------");
+ "--", "--", "----", "-------", "----", "------------");
int number = 1;
- FOREACH(iterator, widgetList)
- {
+ FOREACH(iterator, widgetList) {
widget_info *info = new widget_info;
memset(info, 0x00, sizeof(widget_info));
if (dl.IsNull()) {
DPL::String languageTag(L"");
localizedInfo = dao.getLocalizedInfo(languageTag);
- }
- else
- {
+ } else {
localizedInfo = dao.getLocalizedInfo(*dl);
}
widget_name = localizedInfo.name;
/*end get WidgetName*/
-
- if(!widget_name.IsNull())
- {
+ if (!widget_name.IsNull()) {
info->name = new_strdup(DPL::ToUTF8String(*widget_name).c_str());
}
- if(!version.IsNull())
- {
+ if (!version.IsNull()) {
info->version = new_strdup(DPL::ToUTF8String(*version).c_str());
- }
- else
- {
+ } else {
std::string installedWidgetVersionString;
installedWidgetVersionString = "";
info->version = new_strdup(installedWidgetVersionString.c_str());
}
- if(!guid.IsNull())
- {
- info->guid= new_strdup(DPL::ToUTF8String(*guid).c_str());
+ if (!guid.IsNull()) {
+ info->guid = new_strdup(DPL::ToUTF8String(*guid).c_str());
}
- if(!package_name.IsNull())
- {
- info->pkg_name= new_strdup(DPL::ToUTF8String(*package_name).c_str());
+ if (!package_name.IsNull()) {
+ info->pkg_name =
+ new_strdup(DPL::ToUTF8String(*package_name).c_str());
}
printf("%3i%12i%32s%16s%64s%32s\n",
number++,
free_widget_info(info);
}
- return 1;
+ return 1;
}
static void print_help(FILE *stream, int /*exit_code*/)
{
- fprintf(stream, "Usage : %s [ ... ]\n", program);
- fprintf(stream,
- " -h --help Display this usage information.\n"
- " -l --list Display installed widgets handle and name list\n"
- " -s [GUID]or[PkgName] --start Launch widget with package name or GUID\n"
- " -k [GUID]or[PkgName] --kill Kill widget with package name or GUID\n"
- " -d --debug Activate debug mode\n"
- " -t [second] --timeout Set timeout of response from widget in debug mode\n"
- " -v [1]or[0] --developer-mode Set developermode\n"
- " -c [1]or[0] --compliance-mode Set compliancemode\n"
- " -i [imei] --fake-imei Set fakeimei\n"
- " -m [meid] --fake-meid Set fakemeid\n"
- " -w [PkgName] --change-wkmode Change webkit mode\n"
- " if you emit this option, 5 seconds is set in debug mode\n"
- );
-}
-
-static int kill_widget(const aul_app_info *info, void *data)
-{
- char *pkgname = (char *) data;
- if(strcmp(info->pkg_name, pkgname) == 0)
- return aul_terminate_pid(info->pid);
- else return -1;
+ fprintf(stream, "Usage : %s [ ... ]\n", program);
+ fprintf(stream,
+ " -h --help Display this usage information.\n"
+ " -l --list Display installed widgets handle and name list\n"
+ " -s [GUID]or[PkgName] --start Launch widget with package name or GUID\n"
+ " -k [GUID]or[PkgName] --kill Kill widget with package name or GUID\n"
+ " -d --debug Activate debug mode\n"
+ " -t [second] --timeout Set timeout of response from widget in debug mode\n"
+ " -v [1]or[0] --developer-mode Set developermode\n"
+ " -c [1]or[0] --compliance-mode Set compliancemode\n"
+ " -i [imei] --fake-imei Set fakeimei\n"
+ " -m [meid] --fake-meid Set fakemeid\n"
+ " if you emit this option, 5 seconds is set in debug mode\n"
+ );
}
static void sighandler(int signo, siginfo_t *si, void *data);
int main(int argc, char* argv[])
{
- int ret = -1;
- bundle *b = NULL;
int next_opt, opt_idx = 0;
int timeout = TIMEOUT_DEFAULT;
- char pkgname[256]="";
- char temp_arg[256]="";
+ char pkgname[256] = "";
+ char temp_arg[256] = "";
char pid[6] = "";
char op = '\0';
struct sigaction sigact;
+ service_h serviceHandle = NULL;
+ int ret = SERVICE_ERROR_NONE;
+
program = argv[0];
- static struct option long_options[] =
- {
+ static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
{"list", no_argument, 0, 'l'},
{"start", required_argument, 0, 's'},
{"compliance-mode", required_argument, 0, 'c'},
{"fake-imei", required_argument, 0, 'i'},
{"fake-meid", required_argument, 0, 'm'},
- {"change-wkmode", required_argument, 0, 'w'},
{0, 0, 0, 0}
};
- if(argv[1] == NULL)
- {
+ if (argv[1] == NULL) {
/* exit if any argument doesn't exist */
print_help(stdout, 0);
return -1;
}
do {
- next_opt = getopt_long(argc, argv,"hls:k:dt:v:c:i:m:w:", long_options, &opt_idx);
+ next_opt = getopt_long(argc,
+ argv,
+ "hls:k:dt:v:c:i:m:",
+ long_options,
+ &opt_idx);
+
+ switch (next_opt) {
+ case 'h':
+ print_help(stdout, 0);
+ break;
- switch(next_opt)
- {
- case 'h':
- print_help(stdout, 0);
- break;
+ case 'l':
+ if (!display_widget_info()) {
+ printf("Fail to display the list of installed widgets");
+ return -1;
+ }
+ break;
- case 'l':
- if(!display_widget_info())
- {
- printf("Fail to display the list of installed widgets");
- return -1;
- }
- break;
+ case 's':
+ case 'k':
+ strncpy(temp_arg, optarg, strlen(optarg));
+ op = next_opt;
+ break;
- case 's':
- case 'k':
- strncpy(temp_arg, optarg, strlen(optarg));
- op = next_opt;
- break;
+ case 't':
+ timeout = atoi(optarg);
+ if (timeout < 0 ) {
+ timeout = TIMEOUT_DEFAULT;
+ }
+ break;
- case 't':
- timeout = atoi(optarg);
- if(timeout < 0 )
- timeout = TIMEOUT_DEFAULT;
- break;
+ case 'd':
+ // create service
+ ret = service_create(&serviceHandle);
+ if (SERVICE_ERROR_NONE != ret && NULL == serviceHandle) {
+ LogError("Fail to create service");
+ return FALSE;
+ }
- case 'd':
- // create bundle data
- b = bundle_create();
- bundle_add(b, "debug", "true");
- snprintf(pid, sizeof(pid), "%d", getpid());
- bundle_add(b, "pid", pid);
- break;
+ // set debug mode
+ ret = service_add_extra_data(serviceHandle,
+ "debug",
+ "true");
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set debug mode [" << ret << "]");
+ service_destroy(serviceHandle);
+ return FALSE;
+ }
+
+ // set pid
+ snprintf(pid, sizeof(pid), "%d", getpid());
+ ret = service_add_extra_data(serviceHandle,
+ "pid",
+ pid);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set pid [" << ret << "]");
+ service_destroy(serviceHandle);
+ return FALSE;
+ }
+ break;
- case 'v':
- strncpy(temp_arg, optarg, strlen(optarg));
- if (NULL == g_dbConnection)
- {
- Try {
- g_dbConnection.Reset(new DBConnection());
- g_dbConnection->AttachDatabase();
- }
- Catch (DPL::DB::SqlConnection::Exception::Base) {
- LogDebug("Fail to connect DB");
- return FALSE;
- }
+ case 'v':
+ strncpy(temp_arg, optarg, strlen(optarg));
+ if (NULL == g_dbConnection) {
+ Try {
+ g_dbConnection.Reset(new DBConnection());
+ g_dbConnection->AttachDatabase();
}
- if(!strcmp("1", temp_arg))
- {
- WrtDB::GlobalDAO::SetDeveloperMode(true);
+ Catch (DPL::DB::SqlConnection::Exception::Base) {
+ LogDebug("Fail to connect DB");
+ return FALSE;
}
- else
- {
- WrtDB::GlobalDAO::SetDeveloperMode(false);
+ }
+ if (!strcmp("1", temp_arg)) {
+ WrtDB::GlobalDAO::SetDeveloperMode(true);
+ } else {
+ WrtDB::GlobalDAO::SetDeveloperMode(false);
+ }
+ break;
+ case 'c':
+ strncpy(temp_arg, optarg, strlen(optarg));
+ if (NULL == g_dbConnection) {
+ Try {
+ g_dbConnection.Reset(new DBConnection());
+ g_dbConnection->AttachDatabase();
}
- break;
- case 'c':
- strncpy(temp_arg, optarg, strlen(optarg));
- if (NULL == g_dbConnection)
- {
- Try {
- g_dbConnection.Reset(new DBConnection());
- g_dbConnection->AttachDatabase();
- }
- Catch (DPL::DB::SqlConnection::Exception::Base) {
- LogDebug("Fail to connect DB");
- return FALSE;
- }
+ Catch (DPL::DB::SqlConnection::Exception::Base) {
+ LogDebug("Fail to connect DB");
+ return FALSE;
}
- if(!strcmp("1", temp_arg))
- {
- WrtDB::GlobalDAO::setComplianceMode(true);
+ }
+ if(!strcmp("1", temp_arg)) {
+ WrtDB::GlobalDAO::setComplianceMode(true);
+ } else {
+ WrtDB::GlobalDAO::setComplianceMode(false);
+ }
+ break;
+ case 'i':
+ strncpy(temp_arg, optarg, strlen(optarg));
+ if (NULL == g_dbConnection) {
+ Try {
+ g_dbConnection.Reset(new DBConnection());
+ g_dbConnection->AttachDatabase();
}
- else
- {
- WrtDB::GlobalDAO::setComplianceMode(false);
+ Catch (DPL::DB::SqlConnection::Exception::Base) {
+ LogDebug("Fail to connect DB");
+ return FALSE;
}
- break;
- case 'i':
- strncpy(temp_arg, optarg, strlen(optarg));
- if (NULL == g_dbConnection)
- {
- Try {
- g_dbConnection.Reset(new DBConnection());
- g_dbConnection->AttachDatabase();
- }
- Catch (DPL::DB::SqlConnection::Exception::Base) {
- LogDebug("Fail to connect DB");
- return FALSE;
- }
+ }
+ WrtDB::GlobalDAO::setComplianceFakeImei(temp_arg);
+ break;
+ case 'm':
+ strncpy(temp_arg, optarg, strlen(optarg));
+ if (NULL == g_dbConnection) {
+ Try {
+ g_dbConnection.Reset(new DBConnection());
+ g_dbConnection->AttachDatabase();
}
- WrtDB::GlobalDAO::setComplianceFakeImei(temp_arg);
- break;
- case 'm':
- strncpy(temp_arg, optarg, strlen(optarg));
- if (NULL == g_dbConnection)
- {
- Try {
- g_dbConnection.Reset(new DBConnection());
- g_dbConnection->AttachDatabase();
- }
- Catch (DPL::DB::SqlConnection::Exception::Base) {
- LogDebug("Fail to connect DB");
- return FALSE;
- }
+ Catch (DPL::DB::SqlConnection::Exception::Base) {
+ LogDebug("Fail to connect DB");
+ return FALSE;
}
- WrtDB::GlobalDAO::setComplianceFakeMeid(temp_arg);
- break;
-
- case 'w':
- {
- strncpy(temp_arg, optarg, strlen(optarg));
- // run mode change script
- // wrt_change_client.sh <pkgname>
- std::stringstream sstr;
- sstr << WRT_CHANGE_CLIENT_SH;
- sstr << " ";
- sstr << temp_arg;
-
- std::string scriptCommand = sstr.str();
- system(scriptCommand.c_str());
}
+ WrtDB::GlobalDAO::setComplianceFakeMeid(temp_arg);
break;
- case -1:
- break;
+ case -1:
+ break;
- default:
- print_help(stdout, 0);
- break;
+ default:
+ print_help(stdout, 0);
+ break;
}
- }while (next_opt != -1);
+ } while (next_opt != -1);
- if((op == 's')||(op == 'k'))
- {
+ if ((op == 's') || (op == 'k')) {
const char *temp = NULL;
- if (NULL == g_dbConnection)
- {
+ if (NULL == g_dbConnection) {
Try {
g_dbConnection.Reset(new DBConnection());
g_dbConnection->AttachDatabase();
}
WidgetHandleList widgetList = WrtDB::WidgetDAOReadOnly::getHandleList();
- FOREACH(iterator, widgetList)
- {
+ FOREACH(iterator, widgetList) {
WrtDB::WidgetDAOReadOnly dao(*iterator);
WrtDB::WidgetGUID d_guid = dao.getGUID();
DPL::OptionalString d_pkgname = dao.getPkgname();
- if(!d_guid.IsNull() && !strcmp(DPL::ToUTF8String(*d_guid).c_str(), temp_arg))
+ if (!d_guid.IsNull() &&
+ !strcmp(DPL::ToUTF8String(*d_guid).c_str(), temp_arg))
{
DPL::Optional<DPL::String> package_name = dao.getPkgname();
temp = DPL::ToUTF8String(*package_name).c_str();
break;
}
- if(!strcmp(DPL::ToUTF8String(*d_pkgname).c_str(), temp_arg))
- {
+ if (!strcmp(DPL::ToUTF8String(*d_pkgname).c_str(), temp_arg)) {
DPL::Optional<DPL::String> package_name = dao.getPkgname();
temp = DPL::ToUTF8String(*package_name).c_str();
break;
}
- }
+ }
- if(temp !=NULL)
- {
+ if (temp != NULL) {
strncpy(pkgname, (char *)temp, strlen(temp));
- }
- else
- {
+ } else {
printf("result: %s\n", "failed");
return -1;
}
}
- if(op == 's')
- {
+ if (op == 's') {
/* check if this is request for debug mode, or not */
- if(b != NULL)
- {
+ if (serviceHandle != NULL) {
/* wait for return from the widget */
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_SIGINFO;
sigact.sa_restorer = NULL;
sigact.sa_sigaction = sighandler;
- if (sigaction(SIGRTMIN, &sigact, 0) == 1)
- {
- printf("signal error\n");
- return -1;
+ if (sigaction(SIGRTMIN, &sigact, 0) == 1) {
+ printf("signal error\n");
+ return -1;
}
}
- if(strlen(pkgname) > 0)
- {
- // do setuid to '5000' uid to communicate with webapp using RT signal.
+ if (strlen(pkgname) > 0) {
+ // do setuid to '5000' uid to communicate
+ //with webapp using RT signal.
gid_t group_list[1];
group_list[0] = LOGGING_DEFAULT_GID;
return -1;
}
- ret = aul_launch_app(pkgname, b);
- }
- else
- {
+ // set package
+ ret = service_set_package(serviceHandle, pkgname);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to set package [" << ret << "]");
+ service_destroy(serviceHandle);
+ return -1;
+ }
+
+ //launch service
+ ret = service_send_launch_request(serviceHandle, NULL, NULL);
+ if (SERVICE_ERROR_NONE != ret) {
+ LogError("Fail to launch service [" << ret << "]");
+ service_destroy(serviceHandle);
+ return -1;
+ }
+
+ service_destroy(serviceHandle);
+ } else {
printf("result: %s\n", "failed");
return -1;
}
- if(b != NULL)
- {
+ if (serviceHandle != NULL) {
// wait RTS signal from widget by 5 second
sleep(timeout);
printf("result: %s\n", "failed");
return -1;
}
- if(ret > 0)
- {
+ if (ret > 0) {
printf("result: %s\n", "launched");
- }
- else
- {
+ } else {
printf("result: %s\n", "failed");
return -1;
}
- }
- else if(op == 'k')
- {
- ret = aul_app_get_running_app_info(kill_widget, pkgname);
+ } else if (op == 'k') {
+ bool isRunning = false;
- if(AUL_R_OK == ret)
- {
- printf("result: %s\n", "killed");
+ //checks whether the application is running
+ ret = app_manager_is_running(pkgname, &isRunning);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ printf("result: %s\n", "failed");
+ return -1;
}
- else
- {
+
+ if (true == isRunning) {
+ // get app_context for running application
+ // app_context must be released with app_context_destroy
+ app_context_h appCtx = NULL;
+ ret = app_manager_get_app_context(pkgname, &appCtx);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ printf("result: %s\n", "failed");
+ return -1;
+ }
+
+ // terminate app_context_h
+ ret = app_manager_terminate_app(appCtx);
+ if (APP_MANAGER_ERROR_NONE != ret) {
+ printf("result: %s\n", "failed");
+ app_context_destroy(appCtx);
+ return -1;
+ } else {
+ printf("result: %s\n", "killed");
+ app_context_destroy(appCtx);
+ return 0;
+ }
+ } else {
printf("result: %s\n", "failed");
return -1;
}
static void sighandler(int signo, siginfo_t *si, void* /*data*/)
{
/* check if this signal is type of RTS */
- if(si->si_code == SI_QUEUE)
- {
+ if (si->si_code == SI_QUEUE) {
//int port;
//printf("RTS pid : %d\n", si->si_pid);
//port = (int) si->si_value.sival_ptr;
//printf("RTS debug port : %d\n", port);
// This sival_int is wrt's status (like WRT_SUCCESS..)
// enum WRT_SUCCESS is 0
- if(si->si_value.sival_int > 0)
- {
+ if (si->si_value.sival_int > 0) {
printf("port: %d\n", (int)si->si_value.sival_int);
printf("result: %s\n", "launched");
- }
- else
+ } else {
printf("result: %s\n", "failed");
- }
- else
- {
+ }
+ } else {
printf("Not RT signal : %d\n", signo);
}
exit (0);