#include <dpl/assert.h>
#include <dpl/scoped_array.h>
-#include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
#include <dpl/foreach.h>
#include <dpl/singleton_impl.h>
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
namespace {
const char *LIBRARY_PATH_SEPARATOR = "/";
-const char* FEATURE_WAC20_DEVICAPIS_NAME = "http://wacapps.net/api/deviceapis";
}
class PluginLogic::Impl
typedef std::map<JSContextRef, JSPageSessionPtr> PagesSessionsSet;
PagesSessionsSet m_sessions;
-
+ unsigned int m_windowHandle;
public:
Impl();
CustomEventType eventType,
void* data);
+ unsigned int windowHandle() const;
+ void setWindowHandle(unsigned int handle);
+
static bool s_sanityCheck;
};
bool PluginLogic::Impl::s_sanityCheck = false;
#define PLUGIN_LOGIC_SANITY_CHECK \
- if(!s_sanityCheck)\
- {\
- LogError("Object is not available. Wrong flow occured");\
- return;\
+ if (!s_sanityCheck) \
+ { \
+ _E("Object is not available. Wrong flow occured"); \
+ return; \
}
-PluginLogic::Impl::Impl()
+PluginLogic::Impl::Impl() :
+ m_windowHandle(0)
{
s_sanityCheck = true;
DPL::Log::LogSystemSingleton::Instance().SetTag("WRT_PLUGINS");
- LogDebug("Initializing Plugin Logic...");
+ _D("Initializing Plugin Logic...");
m_pluginsSupport = PluginContainerSupportPtr(new PluginContainerSupport());
// explicit call to keep singleton's lifetime until calling destructor.
PluginLogic::Impl::~Impl()
{
- LogDebug("");
+ _D("called");
s_sanityCheck = false;
FOREACH(it, m_sessions)
{
- LogError("Must stop widget session before exit!");
+ _W("Must stop widget session before exit!");
it->second->stopSession();
}
-
- LogDebug("Deinitializing plugin Logic...");
}
void PluginLogic::initSession(int widgetHandle)
void PluginLogic::performLibrariesUnload()
{
- LogError("Libraries unload TURNED OFF");
-// m_impl->performLibrariesUnload();
+ _W("This function is DEPRECATED");
+ // m_impl->performLibrariesUnload();
}
bool PluginLogic::loadPluginOnDemand(
return m_impl->loadPluginOnDemand(pluginHandle, parentObject, context);
}
-void PluginLogic::loadPluginsIntoIframes(JSGlobalContextRef context)
+void PluginLogic::loadPluginsIntoIframes(JSGlobalContextRef /*context*/)
{
- LogError("This function is Deprecated");
+ _W("This function is DEPRECATED");
}
-void PluginLogic::setCustomProperties(double scaleFactor,
- const char* encodedBundle,
- const char* theme)
+void PluginLogic::setCustomProperties(double /*scaleFactor*/,
+ const char* /*encodedBundle*/,
+ const char* /*theme*/)
{
- LogError("This function is DEPRECATED");
+ _W("This function is DEPRECATED");
}
void PluginLogic::setCustomProperties(JSGlobalContextRef context,
m_impl->setCustomProperties(context, scaleFactor, encodedBundle, theme);
}
-void PluginLogic::dispatchJavaScriptEvent(CustomEventType eventType)
+void PluginLogic::dispatchJavaScriptEvent(CustomEventType /*eventType*/)
{
- LogError("This function is DEPRECATED");
+ _W("This function is DEPRECATED");
}
void PluginLogic::dispatchJavaScriptEvent(JSGlobalContextRef context,
m_impl->unloadFrame(context);
}
-PluginLogic::PluginLogic() : m_impl(new PluginLogic::Impl())
+unsigned int PluginLogic::windowHandle() const
{
+ return m_impl->windowHandle();
}
-PluginLogic::~PluginLogic()
+void PluginLogic::setWindowHandle(unsigned int handle)
{
+ m_impl->setWindowHandle(handle);
}
+PluginLogic::PluginLogic() : m_impl(new PluginLogic::Impl())
+{}
+
+PluginLogic::~PluginLogic()
+{}
+
void PluginLogic::Impl::initSession(int widgetHandle)
{
- LogInfo("init pluginLogic...");
+ _D(">---------------------[init session START]---------------------<");
m_pluginsSupport->Initialize(widgetHandle);
+ PluginContainerSupport::PluginsList rootPluginList =
+ m_pluginsSupport->getRootPlugins();
- //add standard objects
- LogDebug("Preload plugins so file");
-
- PluginContainerSupport::PluginsList pluginList =
- m_pluginsSupport->getPluginsList();
-
- FOREACH(it, pluginList)
+ FOREACH(it, rootPluginList)
{
PluginModelPtr& pluginModel = *it;
PluginPtr pluginLib = pluginModel->LibraryInstance.Get();
- if (!pluginLib)
- {
+ if (!pluginLib) {
std::string path = pluginModel->LibraryPath.Get() +
- std::string(LIBRARY_PATH_SEPARATOR) +
- pluginModel->LibraryName.Get();
+ std::string(LIBRARY_PATH_SEPARATOR) +
+ pluginModel->LibraryName.Get();
pluginLib = Plugin::LoadFromFile(path);
- if (!pluginLib)
- {
- LogError("Loading library failed");
- } else
- {
+ if (!pluginLib) {
+ _W("Loading library failed");
+ } else {
pluginModel->LibraryInstance.Set(pluginLib);
-
- LogDebug("pluginModel->LibraryInstance.Set() : " << pluginLib->GetFileName());
+ _D("pluginModel->LibraryInstance.Set() : %s",
+ pluginLib->GetFileName().c_str());
}
- }
- else
- {
- LogDebug("Already loaded");
+ } else {
+ _D("Already loaded");
}
}
-
- LogDebug("Preload plugins so file_done");
+ _D("========== init session END ==========");
}
void PluginLogic::Impl::startSession(int widgetHandle,
const char* encodedBundle,
const char* theme)
{
- LogInfo("Starting widget session...");
+ _D("========== start session START ==========");
- if (!m_pluginsSupport->isInitialized())
- {
+ if (!m_pluginsSupport->isInitialized()) {
m_pluginsSupport->Initialize(widgetHandle);
}
auto sessionIt = m_sessions.find(context);
// Check if corresponding session if not already created
- if (sessionIt != m_sessions.end())
- {
- LogWarning("Session already started!");
- return;
+ if (sessionIt != m_sessions.end()) {
+ _W("Session already started!");
+ } else {
+ auto newSession = JSPageSessionPtr(new JSPageSession(m_pluginsSupport));
+ newSession->startSession(widgetHandle,
+ context,
+ scaleFactor,
+ encodedBundle,
+ theme);
+
+ m_sessions[context] = newSession;
}
-
- auto newSession = JSPageSessionPtr(new JSPageSession(m_pluginsSupport));
- newSession->startSession(widgetHandle,
- context,
- scaleFactor,
- encodedBundle,
- theme);
-
- m_sessions[context] = newSession;
+ _D("========== start session END ==========");
}
void PluginLogic::Impl::stopSession(JSGlobalContextRef context)
{
- LogInfo("Stopping widget session...");
+ _D("========== stop session START ==========");
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
- LogError("Session not exist!");
- return;
+ if (sessionIt == m_sessions.end()) {
+ _W("Session not exist!");
+ } else {
+ sessionIt->second->stopSession();
+ m_sessions.erase(sessionIt);
}
-
- sessionIt->second->stopSession();
- m_sessions.erase(sessionIt);
-
- LogInfo("Widget session stopped.");
+ _D("========== stop session END ==========");
}
bool PluginLogic::Impl::loadPluginOnDemand(
JSGlobalContextRef context
)
{
- LogInfo("Load plugin on demand");
+ _D("========== load ondemand plugin ==========");
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
- LogWarning("Session not exist!");
+ if (sessionIt == m_sessions.end()) {
+ _W("Session not exist!");
return false;
}
void PluginLogic::Impl::loadFrame(JSGlobalContextRef context)
{
- LogDebug("Load a frame");
-
+ _D("========== load frame START ==========");
PLUGIN_LOGIC_SANITY_CHECK
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
- LogWarning("Session not exist!");
- return;
+ if (sessionIt == m_sessions.end()) {
+ _W("Session not exist!");
+ } else {
+ sessionIt->second->loadFrame(context);
}
-
- sessionIt->second->loadFrame(context);
+ _D("========== load frame END ==========");
}
void PluginLogic::Impl::unloadFrame(JSGlobalContextRef context)
{
- LogDebug("Unload a frame");
-
+ _D("========== unload frame START ==========");
PLUGIN_LOGIC_SANITY_CHECK
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
+ if (sessionIt == m_sessions.end()) {
LogWarning("Session not exist!");
- return;
- }
+ } else {
+ sessionIt->second->unloadFrame(context);
- sessionIt->second->unloadFrame(context);
- m_sessions.erase(sessionIt);
+ // I don't know why this session should be removed here.
+ // session list is removed also from stopSession().
+ //m_sessions.erase(sessionIt);
+ }
+ _D("========== unload frame END ==========");
}
void PluginLogic::Impl::setCustomProperties(JSGlobalContextRef context,
const char* encodedBundle,
const char* theme)
{
- LogInfo("set properties of window object " << scaleFactor << ", "
- << encodedBundle << ", " << theme);
-
PLUGIN_LOGIC_SANITY_CHECK
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
- LogWarning("Session not exist!");
+ if (sessionIt == m_sessions.end()) {
+ _W("Session not exist!");
return;
}
sessionIt->second->setCustomProperties(scaleFactor,
encodedBundle,
theme);
-
}
void PluginLogic::Impl::dispatchJavaScriptEvent(JSGlobalContextRef context,
CustomEventType eventType,
void* data)
{
- LogDebug("Dispatch event");
-
PLUGIN_LOGIC_SANITY_CHECK
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
- LogWarning("Session not exist!");
+ if (sessionIt == m_sessions.end()) {
+ _W("Session not exist!");
return;
}
sessionIt->second->dispatchJavaScriptEvent(eventType, data);
+}
+unsigned int PluginLogic::Impl::windowHandle() const
+{
+ if (!s_sanityCheck) {
+ LogError("Object is not available. Wrong flow occured");
+ }
+ return m_windowHandle;
+}
+void PluginLogic::Impl::setWindowHandle(unsigned int handle)
+{
+ PLUGIN_LOGIC_SANITY_CHECK
+ m_windowHandle = handle;
}