+wrt-plugins-common (0.3.74) unstable; urgency=low
+
+ * Bug Fix for crash while webapi notification TC is running.
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Mon, 11 Mar 2013 22:36:32 +0900
+
+wrt-plugins-common (0.3.73) unstable; urgency=low
+
+ * Fix injection of javascript
+ * 'on_frame_unload' plugin's callback is not invoked when webapp is terminated.
+ * Fix issues shown by cppcheck for wrt-plugins-common
+ * Fix warnings in compilation of wrt-plugins-common
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Fri, 08 Mar 2013 17:21:00 +0900
+
+wrt-plugins-common (0.3.72) unstable; urgency=low
+
+ * Source code formating unification
+ * Prevent issues fixes
+
+ -- Tae-Jeong Lee <taejeong.lee@samsung.com> Wed, 13 Feb 2013 13:58:48 +0900
+
+wrt-plugins-common (0.3.71) unstable; urgency=low
+
+ * Fix script that populates DB for plugins-tests-widgetdb tests.
+ * Fix WrtAccess singleton deinitialize issue
+ * Preloading plugin so file was changed to work only for root object.
+ * Fixed wrong widget private path
+
+ -- Soyoung Kim <sy037.kim@samsung.com> Fri, 01 Feb 2013 17:00:54 +0900
+
wrt-plugins-common (0.3.70) unstable; urgency=low
* Add tests - widgetdb
-#git:framework/web/wrt-plugins-common wrt-plugins-common_0.3.70
+#git:framework/web/wrt-plugins-common wrt-plugins-common_0.3.74
Name: wrt-plugins-common
Summary: wrt-plugins common library
-Version: 0.3.70
+Version: 0.3.74
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
%if %{with_tests}
%attr(755,root,root) %{_bindir}/widgetdb_tests_prepare_db.sh
- %attr(755,root,root) %{_bindir}/plugins-tests-widgetdb
+ %attr(755,root,root) %{_bindir}/wrt-plugins-common-tests-widgetdb
%endif
%files devel
namespace WrtDeviceApis {
namespace Commons {
-
const std::string Base64::chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
bool Base64::is_base64(unsigned char c)
{
}
std::string Base64::encode(unsigned char* data,
- std::size_t num)
+ std::size_t num)
{
std::string ret;
int i = 0;
{
return ((str.size() % 4) == 0);
}
-
}
} //WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class Base64
{
public:
static std::string encode(unsigned char* data,
- std::size_t num);
+ std::size_t num);
static std::string decode(const std::string& str);
private:
private:
static const std::string chars;
}; // Base64
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Encapsulates width and height of a component.
*/
* @param height Specified height.
*/
Dimension(ValueType width,
- ValueType height) :
+ ValueType height) :
m_width(width),
m_height(height)
- {
- }
+ {}
ValueType getWidth() const
{
}
void setSize(ValueType width,
- ValueType height)
+ ValueType height)
{
m_width = width;
m_height = height;
ValueType m_width;
ValueType m_height;
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Manages listener events emitters.
* Template parameter should be class that derives from @see ListenerEvent.
}
/**
- * Emits event through those emitters that when passed to predicate result in
+ * Emits event through those emitters that when passed to predicate result
+ * in
* returning true by it.
* @param event Event to emit.
* @param pred Predicate - a callable object (function, functor) that takes
*/
template<typename Predicate>
void emitIf(const EventPtrType& event,
- Predicate pred)
+ Predicate pred)
{
DPL::Mutex::ScopedLock lock(&m_mtx);
for (Iterator it = m_emitters.begin(); it != m_emitters.end(); ++it) {
/**
* Lock this object.
- * This lock will be automatically released when out of scope (unless someone
+ * This lock will be automatically released when out of scope (unless
+ * someone
* copies it). Do not use in the same scope as other API of this class.
* @return Lock object.
* @remarks Provided to allow locking emitters in scope of some client
DPL::Mutex m_mtx; ///< Synchronizes operation on this object.
Map m_emitters; ///< Emitters container.
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Base class for listeners.
* Object that is to act as listener should dervie from this class and implement
public:
EventListener(ThreadEnum::Enumeration threadType) :
EventReceiver<TemplateEvent>(threadType)
- {
- }
+ {}
virtual void onAnswerReceived(const DPL::SharedPtr<TemplateEvent>& event) =
0;
void postAnswer(const DPL::SharedPtr<TemplateEvent>& event)
{
- DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::PostEvent(
+ DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::
+ PostEvent(
event);
}
onAnswerReceived(event);
}
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
template<class TemplateEvent>
class SignalEventCall : public DPL::Event::AbstractEventCall
{
DPL::SharedPtr<TemplateEvent> m_event;
+
public:
SignalEventCall(const DPL::SharedPtr<TemplateEvent> &event) : m_event(event)
- {
- }
+ {}
virtual void Call()
{
LogDebug("signaling in SignalEventCall");
}
};
-
template<class TemplateEvent>
class EventReceiver :
protected DPL::Event::Controller<
typename DPL::TypeListDecl<DPL::SharedPtr<TemplateEvent> >::Type>
{
DPL::Event::ThreadEventDispatcher m_threadDispatcher;
+
protected:
EventReceiver(ThreadEnum::Enumeration threadType)
}
};
-
template<class TemplateEvent>
class EventRequestReceiver : private EventReceiver<TemplateEvent>
{
public:
EventRequestReceiver(ThreadEnum::Enumeration threadType) : EventReceiver<
TemplateEvent>(threadType)
- {
- }
+ {}
virtual void OnRequestReceived(const DPL::SharedPtr<TemplateEvent> &event)
= 0;
/*
*
- * @argument delaySeconds - event will be received not sooner than after delay (in seconds)
+ * @argument delaySeconds - event will be received not sooner than after
+ * delay (in seconds)
*/
void PostRequest(const DPL::SharedPtr<TemplateEvent> &event,
- double delaySeconds = 0.0)
+ double delaySeconds = 0.0)
{
LogDebug(__FUNCTION__);
{
LogDebug("state changed to STATE_REQUEST_SEND. Now posting");
if (TemplateEvent::HANDLING_SYNCHRONOUS == event->getHandlingType() &&
- !event->m_synchronousEventFlag) {
+ !event->m_synchronousEventFlag)
+ {
event->m_synchronousEventFlag = new DPL::WaitableEvent();
}
if (0.0 == delaySeconds) {
- DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::
+ DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >
+ ::
PostEvent(event);
} else {
- DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::
+ DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >
+ ::
PostTimedEvent(event, delaySeconds);
}
LogDebug("Event posted.");
LogDebug("calling OnRequestReceived");
OnRequestReceived(event);
event->signalCancelStatusFlag();
- //After Controller ends processing it should call it to signal that work is done
+ //After Controller ends processing it should call it to signal that work
+ // is done
{
DPL::Mutex::ScopedLock lock(&event->m_stateMutex);
if (TemplateEvent::HANDLING_ASYNCHRONOUS_MANUAL_ANSWER !=
event->m_handlingType &&
TemplateEvent::HANDLING_SYNCHRONOUS_MANUAL_ANSWER !=
- event->m_handlingType) {
+ event->m_handlingType)
+ {
event->m_state = TemplateEvent::STATE_ANSWER_SEND;
}
}
//event->Signal();
signalEventByDispatcher(event);
break;
- //when event is in manual answer mode we do nothing - the answer will be send explicit from the code
+ //when event is in manual answer mode we do nothing - the answer will be
+ // send explicit from the code
case TemplateEvent::HANDLING_SYNCHRONOUS_MANUAL_ANSWER:
case TemplateEvent::HANDLING_ASYNCHRONOUS_MANUAL_ANSWER:
LogDebug("Manual answer is set so do nothing.");
}
};
-
template<class TemplateEvent>
class EventAnswerReceiver : private EventReceiver<TemplateEvent>
{
public:
EventAnswerReceiver(ThreadEnum::Enumeration threadType) : EventReceiver<
TemplateEvent>(threadType)
- {
- }
+ {}
virtual void OnAnswerReceived(const DPL::SharedPtr<TemplateEvent> &event) =
0;
{
LogDebug(__FUNCTION__);
event->signalCancelStatusFlag();
- DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::PostEvent(
+ DPL::Event::ControllerEventHandler<DPL::SharedPtr<TemplateEvent> >::
+ PostEvent(
event);
}
LogDebug("checking the state");
DPL::Mutex::ScopedLock lock(&event->m_stateMutex);
- //in case someone changed it to synchronous call, we don't process it
+ //in case someone changed it to synchronous call, we don't process
+ // it
if (TemplateEvent::STATE_CHANGED_TO_SYNCHRONOUS ==
event->m_state || TemplateEvent::STATE_ENDED ==
- event->m_state) {
+ event->m_state)
+ {
LogDebug(
"Handling probably changed to synchronous meanwhile. Will not process it..");
return;
LogDebug("leaving");
}
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
#define PLUGINS_DECLARE_EXCEPTION_TYPE(BaseClass, Class) \
class Class : \
public BaseClass \
const char *function, \
int line, \
const std::string & message = std::string()) : \
- BaseClass(path, function, line, message) \
- { \
- BaseClass::m_className = # Class; \
- m_code = ExceptionCodes::Class; \
- } \
+ BaseClass(path, function, line, message) \
+ { \
+ BaseClass::m_className = #Class; \
+ m_code = ExceptionCodes::Class; \
+ } \
\
- Class(const char *path, \
- const char *function, \
- int line, \
- const DPL::Exception & reason, \
- const std::string & message = std::string()) : \
- BaseClass(path, function, line, reason, message) \
- { \
- BaseClass::m_className = # Class; \
- m_code = ExceptionCodes::Class; \
- } \
- };
+ Class(const char *path, \
+ const char *function, \
+ int line, \
+ const DPL::Exception & reason, \
+ const std::string & message = std::string()) : \
+ BaseClass(path, function, line, reason, message) \
+ { \
+ BaseClass::m_className = #Class; \
+ m_code = ExceptionCodes::Class; \
+ } \
+ };
class ExceptionCodes
{
PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, SecurityException)
/**
- * Thrown when trying to perform action that is not supported by current platform.
+ * Thrown when trying to perform action that is not supported by current
+ * platform.
*/
PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, UnsupportedException)
PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, AlreadyInUseException)
/**
- * Thrown when unpredicted error occurs while a picture or video is being captured
+ * Thrown when unpredicted error occurs while a picture or video is being
+ * captured
* or if endRecording is called while no video is currently captured.
*/
PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, CameraCaptureException)
* Thrown when object is not found.
*/
PLUGINS_DECLARE_EXCEPTION_TYPE(Exception, NotFoundException)
-
}
} // WrtDeviceApisCommon
#include <Commons/plugin_initializer_def.h>
#define ACE_DECLARE_FUNCTION(function_definition) \
- extern WrtDeviceApis::Commons::AceFunction ace_ ## function_definition
+ extern WrtDeviceApis::Commons::AceFunction ace_##function_definition
#define ACE_DECLARE_PARAM(param_definition) \
- extern WrtDeviceApis::Commons::AceDeviceCapParam ace_param_ ## \
+ extern WrtDeviceApis::Commons::AceDeviceCapParam ace_param_## \
param_definition
class DevCapFinder
{
public:
explicit DevCapFinder(const std::string& devcap) : m_searchFor(devcap)
- {
- }
+ {}
explicit DevCapFinder(const char* devcap) : m_searchFor(devcap)
- {
- }
- bool operator()(const WrtDeviceApis::Commons::AceDeviceCapability& dc) const
+ {}
+ bool operator()(const WrtDeviceApis::Commons::AceDeviceCapability& dc)
+ const
{
return m_searchFor == dc.devCapName;
}
} while (0)
/*
- * Macro must be run inside plugin function. Plugin function must follow this declaration:
- * plugin_example_function(JScontextRef cotext, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef *exception);
- * where context, arguments, argumentsCount, exception are fixed and could not be change.
+ * Macro must be run inside plugin function. Plugin function must follow this
+ * declaration:
+ * plugin_example_function(JScontextRef cotext, JSObjectRef function,
+ * JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+ * JSValueRef *exception);
+ * where context, arguments, argumentsCount, exception are fixed and could not
+ * be change.
* */
#define DECLARE_FUNCTION_GETTER(Plugin_Module) \
- WrtDeviceApis::Commons::AceFunction get ## Plugin_Module ## FunctionData( \
+ WrtDeviceApis::Commons::AceFunction get##Plugin_Module##FunctionData( \
const std::string & functionId);
#define DEFINE_FUNCTION_GETTER(Plugin_Module, FunctionMap) \
- WrtDeviceApis::Commons::AceFunction get ## Plugin_Module ## FunctionData( \
+ WrtDeviceApis::Commons::AceFunction get##Plugin_Module##FunctionData( \
const std::string & functionId) \
{ \
WrtDeviceApis::Commons::FunctionMapping::const_iterator it = \
return it->second; \
}
-typedef WrtDeviceApis::Commons::AceFunction (&AceFunctionGetter)(const std::string&);
+typedef WrtDeviceApis::Commons::AceFunction (&AceFunctionGetter)(const std::
+ string&);
namespace WrtDeviceApis {
namespace Commons {
-
enum class AceSecurityStatus
{
AccessGranted,
{
public:
void operator()(AceFunction& /*aceFunction*/) const
- {
- }
+ {}
};
template <typename FunctionGetter,
typename ArgumentsVerifier,
typename ... Args>
AceSecurityStatus aceCheckAccess(
- const FunctionGetter& f,
- const char* functionName,
- Args && ... args)
+ const FunctionGetter& f,
+ const char* functionName,
+ Args && ... args)
{
using namespace WrtDeviceApis::Commons;
return AceSecurityStatus::AccessGranted;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
int aceAddDeviceCap(const AceDeviceCapability& cap,
AceDeviceCaps &instance)
{
instance.push_back(apiFeature);
return 0;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Creates an empty device cap list. Additional device-caps may be added by
* ACE_CREATE_DEVICE_CAP and ACE_ADD_DEVICE_CAP macros
*/
#define ACE_CREATE_DEVICE_CAPS_LIST(device) \
- WrtDeviceApis::Commons::AceDeviceCaps ace_ ## device
+ WrtDeviceApis::Commons::AceDeviceCaps ace_##device
/**
* Creates an empty api features list. Additional api features may be added by
* ACE_CREATE_FEATURE and ACE_ADD_API_FEATURE macros
*/
#define ACE_CREATE_FEATURE_LIST(apifeature) \
- WrtDeviceApis::Commons::AceFeatures ace_ ## apifeature
+ WrtDeviceApis::Commons::AceFeatures ace_##apifeature
/**
* Creates a device capability which should be later added to device cap list
*/
#define ACE_CREATE_DEVICE_CAP(device_cap_id, cap_id) \
- WrtDeviceApis::Commons::AceDeviceCapability ace_ ## device_cap_id = \
+ WrtDeviceApis::Commons::AceDeviceCapability ace_##device_cap_id = \
AceDeviceCapability(cap_id, WrtDeviceApis::Commons::AceDeviceCapParams());
/**
* Create an api feature which should be later added to api features list
*/
#define ACE_CREATE_FEATURE(feature_id, feature_api) \
- WrtDeviceApis::Commons::AceFeature ace_ ## feature_id = { feature_api };
+ WrtDeviceApis::Commons::AceFeature ace_##feature_id = { feature_api \
+ };
/**
* Adds an existing device-cap created by ACE_CREATE_DEVICE_CAP macro to
* device cap list
*/
#define ACE_ADD_DEVICE_CAP(device, device_cap_id) \
- WrtDeviceApis::Commons::aceAddDeviceCap(ace_ ## device_cap_id, ace_ ## device)
+ WrtDeviceApis::Commons::aceAddDeviceCap(ace_##device_cap_id, ace_##device)
/**
* Adds an existing api feature created by ACE_CREATE_FEATURE macro to
* api feature list
*/
#define ACE_ADD_API_FEATURE(apifeature, feature_id) \
- WrtDeviceApis::Commons::aceAddApiFeature(ace_ ## feature_id, \
- ace_ ## apifeature)
+ WrtDeviceApis::Commons::aceAddApiFeature(ace_##feature_id, \
+ ace_##apifeature)
/**
* Creates a function definition with given id that uses provided api feature
* and device capability lists
*/
#define ACE_CREATE_FUNCTION(function_id, function_name, feature_id, device) \
- { function_name, ace_ ## feature_id, ace_ ## device }
+ { function_name, ace_##feature_id, ace_##device }
// Support for param:name begin
#define ACE_CREATE_PARAM(param_definition, param_name, position) \
- static WrtDeviceApis::Commons::AceDeviceCapParam ace_param_ ## \
+ static WrtDeviceApis::Commons::AceDeviceCapParam ace_param_## \
param_definition = \
{ std::string(param_name), position };
typedef std::map <std::string, AceFunction> FunctionMapping;
-int aceAddDeviceCap(const AceDeviceCapability& cap,
- AceDeviceCaps& instance);
-int aceAddApiFeature(const AceFeature& apiFeature,
- AceFeatures& instance);
-
+int aceAddDeviceCap(const AceDeviceCapability &cap,
+ AceDeviceCaps & instance);
+int aceAddApiFeature(const AceFeature &apiFeature,
+ AceFeatures & instance);
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class IEventPrivateData
{
public:
virtual ~IEventPrivateData()
- {
- }
+ {}
};
-
class IEventController
{
DPL::SharedPtr<IEventPrivateData> m_privateData;
+
public:
virtual void waitTillProcessed() = 0;
virtual void waitForAnswer() = 0;
}
virtual bool changeCallToSynchronous() = 0;
virtual ~IEventController()
- {
- }
+ {}
void setPrivateData(
- const DPL::SharedPtr<IEventPrivateData> &privateData)
+ const DPL::SharedPtr<IEventPrivateData> &privateData)
{
m_privateData = privateData;
}
};
typedef DPL::SharedPtr<IEventController> IEventControllerPtr;
-
// CRTP pattern
template<class Super>
class IEvent : /*private DPL::WaitableEvent, */ public IEventController
//if someone is waiting
signalSynchronousEventFlag();
}
+
protected:
DPL::Mutex m_stateMutex;
State m_state;
m_cancelStatusFlag(NULL),
m_cancelled(false),
m_cancelAllowed(false)
- {
- }
+ {}
virtual void waitForAnswer()
{
}
virtual void clearOnCancel()
- {
- }
+ {}
Commons::ExceptionCodes::Enumeration getExceptionCode() const
{
}
virtual bool setForAsynchronousCall(
- EventAnswerReceiver< Super > *remoteController)
+ EventAnswerReceiver< Super > *remoteController)
{
DPL::Mutex::ScopedLock lock(&m_stateMutex);
if (m_cancelled) {
}
/*
- * Normally, after invoking OnRequestReceived in RequestReceiver, the answer is being send automatically (after flow leaves OnRequestReceived).
- * After calling this function, the answer is not being send automatically, you need to call ManualAnswer to send event back.
+ * Normally, after invoking OnRequestReceived in RequestReceiver, the answer
+ * is being send automatically (after flow leaves OnRequestReceived).
+ * After calling this function, the answer is not being send automatically,
+ * you need to call ManualAnswer to send event back.
* It works both in asynchronous and synchronous handling type.
*/
virtual bool switchToManualAnswer()
return m_cancelAllowed;
}
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* This class is related to JSPendingOperation object.
*
virtual void OnCancelEvent(const DPL::SharedPtr<TemplateEvent>& event) = 0;
virtual ~IExternEventCanceler()
- {
- }
+ {}
};
-
}
} // WrtDeviceApisCommon
virtual RealObject getObject() const;
virtual ~JSObject()
- {
- }
+ {}
private:
RealObject m_object;
m_classTemplate(NULL),
m_constructorCallback(classD->js_class_constructor_cb)
{
- if (NULL != classD->js_class_template_getter_fun)
- {
+ if (NULL != classD->js_class_template_getter_fun) {
m_classTemplate = classD->js_class_template_getter_fun();
}
- if(classD->class_options){
+ if (classD->class_options) {
LogDebug("class options is not a null");
m_options = OptionsPtr(new Options(classD->class_options));
}
}
JSObjectDeclaration::~JSObjectDeclaration()
-{
-}
+{}
-bool JSObjectDeclaration::checkIframesSupported() const{
+bool JSObjectDeclaration::checkIframesSupported() const
+{
LogDebug("Check iframe supported");
- if(!m_options ||
- m_options->getIframeObject() == Options::IFrameObject::None)
+ if (!m_options ||
+ m_options->getIframeObject() == Options::IFrameObject::None)
{
LogDebug("Iframe NOT supported for object: " << getName());
return false;
}
JSObjectDeclaration::Options::ClassType
- JSObjectDeclaration::Options::getType() const
+JSObjectDeclaration::Options::getType() const
{
LogDebug("Get type field from declaration's option");
Assert(m_options && "Pointer to options is NULL");
- switch(m_options->type){
+ switch (m_options->type) {
case JS_CLASS: return ClassType::Class;
case JS_FUNCTION: return ClassType::Function;
case JS_INTERFACE: return ClassType::Interface;
}
JSObjectDeclaration::Options::IFrameObject
- JSObjectDeclaration::Options::getIframeObject() const
+JSObjectDeclaration::Options::getIframeObject() const
{
LogDebug("Get Frame Option");
Assert(m_options && "Options object is NULL");
- switch(m_options->iframe_option){
+ switch (m_options->iframe_option) {
case NONE: return IFrameObject::None;
case REFERENCE: return IFrameObject::Reference;
case CREATE_INSTANCE: return IFrameObject::CreateInstance;
}
JSObjectDeclaration::Options::IFrameNotice
- JSObjectDeclaration::Options::getIframeNotice() const
+JSObjectDeclaration::Options::getIframeNotice() const
{
LogDebug("Get Frame Option");
Assert(m_options && "Pointer to options is null");
- switch(m_options->iframe_notice){
+ switch (m_options->iframe_notice) {
case NONE_NOTICE: return IFrameNotice::None;
case ALWAYS_NOTICE: return IFrameNotice::AlwaysNotice;
default:
}
JSObjectDeclaration::Options::IFrameOverlay
- JSObjectDeclaration::Options::getIframeOverlay() const
+JSObjectDeclaration::Options::getIframeOverlay() const
{
LogDebug("Get Frame Option");
Assert(m_options && "Pointer to options is null");
- switch(m_options->iframe_overlay){
+ switch (m_options->iframe_overlay) {
case IGNORED: return IFrameOverlay::Ignored;
case USE_OVERLAYED: return IFrameOverlay::UseOverlayed;
case OVERLAYED_BEFORE_ORIGINAL:
- return IFrameOverlay::OverlayedBeforeOriginal;
+ return IFrameOverlay::OverlayedBeforeOriginal;
default:
Assert(0 && "Wrong value of overlay option");
}
}
JSObjectDeclaration::Options::PrivateData
- JSObjectDeclaration::Options::getPrivateData() const
+JSObjectDeclaration::Options::getPrivateData() const
{
Assert(m_options && m_options->private_data && "empty private data");
return m_options->private_data;
typedef js_class_constructor_cb_t ConstructorCallback;
typedef class_definition_options_t ClassOptions;
-
- class Options : DPL::Noncopyable {
+ class Options : DPL::Noncopyable
+ {
public:
- enum class ClassType{
+ enum class ClassType
+ {
Class,
Function,
Interface
};
- enum class IFrameObject{
+ enum class IFrameObject
+ {
None,
Reference,
CreateInstance
};
- enum class IFrameNotice{
+ enum class IFrameNotice
+ {
None,
AlwaysNotice
};
//only for function
- enum class IFrameOverlay{
- Ignored,
- UseOverlayed,
- OverlayedBeforeOriginal
+ enum class IFrameOverlay
+ {
+ Ignored,
+ UseOverlayed,
+ OverlayedBeforeOriginal
};
typedef js_object_instance_t ObjectInstance;
typedef java_script_context_t JsContext;
typedef void* PrivateData;
- public:
- ClassType getType() const;
+ public:
+ ClassType getType() const;
- IFrameObject getIframeObject() const;
- IFrameNotice getIframeNotice() const;
- IFrameOverlay getIframeOverlay() const;
- js_function_impl getFunctionImpl() const;
+ IFrameObject getIframeObject() const;
+ IFrameNotice getIframeNotice() const;
+ IFrameOverlay getIframeOverlay() const;
+ js_function_impl getFunctionImpl() const;
- void invokeCallback(JsContext ctx,
- ObjectInstance iframe,
- ObjectInstance object) const;
+ void invokeCallback(JsContext ctx,
+ ObjectInstance iframe,
+ ObjectInstance object) const;
- PrivateData getPrivateData() const;
+ PrivateData getPrivateData() const;
- private:
- const ClassOptions* m_options;
+ private:
+ const ClassOptions* m_options;
- private:
- explicit Options(const ClassOptions* options) : m_options(options)
+ private:
+ explicit Options(const ClassOptions* options) : m_options(options)
{
assert(options && "Dont create empty options");
}
friend class JSObjectDeclaration;
-
};
typedef std::shared_ptr<Options> OptionsPtr;
return m_constructorCallback;
}
-
- const OptionsPtr getOptions() const{
+ const OptionsPtr getOptions() const
+ {
return m_options;
}
namespace WrtDeviceApis {
namespace Commons {
-
template<class EventClass>
class ListenerEventEmitter;
ListenerEvent() :
m_mtx(new DPL::Mutex()),
m_code(Commons::ExceptionCodes::None)
- {
- }
+ {}
ListenerEvent(const ListenerEvent &ths) :
m_mtx(new DPL::Mutex()),
m_code(ths.m_code),
m_privateData(ths.m_privateData)
- {
- }
+ {}
ListenerEvent& operator=(const ListenerEvent &other)
{
/**
* Sets event's private data.
- * Event's private data object has to implement @see IEventPrivateData interface.
+ * Event's private data object has to implement @see IEventPrivateData
+ * interface.
* @param data Private data.
* @throw EventWrongStateExeption When event has already been emitted.
*/
Commons::ExceptionCodes::Enumeration m_code; ///< Exception code.
PrivateDataTypePtr m_privateData; ///< Private data.
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
template<class EmitterClass>
class Emitters;
public:
ListenerEventEmitter() : m_listener(NULL)
- {
- }
+ {}
public:
virtual ~ListenerEventEmitter()
- {
- }
+ {}
/**
* Sets event's private data.
- * Event's private data object has to implement @see IEventPrivateData interface.
+ * Event's private data object has to implement @see IEventPrivateData
+ * interface.
* @param data Private data.
- * @remarks Practically private dat should be only set at object creation and
+ * @remarks Practically private dat should be only set at object creation
+ * and
* not chaged during this object lifetime.
*/
virtual void setEventPrivateData(const EventPrivateDataTypePtr& data)
template<class EventClass>
const typename ListenerEventEmitter<EventClass>::IdType ListenerEventEmitter<
EventClass>::emptyId = 0;
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Stores data describing a range of values.
*/
*/
ValueType max;
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
bool validate(const std::string &pattern,
- const std::string &value,
- unsigned int options)
+ const std::string &value,
+ unsigned int options)
{
pcrecpp::RE_Options pcreOpt;
if (options & VALIDATE_MATCH_CASELESS) {
}
std::string filter(const std::string &pattern,
- const std::string &value)
+ const std::string &value)
{
pcrecpp::RE re(pattern);
std::string ret = static_cast<std::string>(value);
re.GlobalReplace(UPPER_P, &ret);
return ret;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
-const unsigned int VALIDATE_MATCH_CASELESS = 0x0001; //use when you want to make caseless match
-const unsigned int VALIDATE_MATCH_FULL = 0x0002; //use when you want supplied text matches a supplied pattern exactly
+const unsigned int VALIDATE_MATCH_CASELESS = 0x0001; //use when you want to
+ // make caseless match
+const unsigned int VALIDATE_MATCH_FULL = 0x0002; //use when you want
+ // supplied text
+ // matches a supplied
+ // pattern exactly
const std::string LOWER_P = "p";
const std::string UPPER_P = "P";
* @return True when value is matched against pattern
*/
bool validate(const std::string &pattern,
- const std::string &value,
- unsigned int options = 0);
+ const std::string &value,
+ unsigned int options = 0);
/**
- * Filter value against pattern(Any character except "0-9+#*Pp" will be removed from value)
+ * Filter value against pattern(Any character except "0-9+#*Pp" will be removed
+ * from value)
* @param pattern Regexp pattern
* @param value String to be filtered
* @return filtered value
*/
std::string filter(const std::string &pattern,
- const std::string &value);
+ const std::string &value);
/**
* Replace character "p" in value by "P"
* @return replaced value
*/
std::string toUpper(const std::string &value);
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
const std::string PATTERN_PHONE_NUMBER_FILTER("[^0-9+#*Pp]");
const std::string PATTERN_PHONE_NUMBER("^[0-9#+*]+$");
const std::string PATTERN_PHONE_NUMBER_P("^\\+?[0-9#*Pp]*[0-9][0-9#*Pp]*$");
const std::string PATTERN_PHONE_NUMBER_PW("^[0-9#+*PpWw]+$");
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
std::string addStartPositionMark(const std::string &value)
{
if (!String::startsWith(value, "^") && !String::startsWith(value, ".*")) {
std::string addEndPositionMark(const std::string &value)
{
if ((!String::endsWith(value, "$") || String::endsWith(value, "\\$")) &&
- !String::endsWith(value, ".*")) {
+ !String::endsWith(value, ".*"))
+ {
return value + "$";
}
return value;
// Escape standard regular expressions' metacharacters,
// i.e.: \, ., -, +, ?, (, ), [, ], ^, $, |
const char* metas = "(\\.|\\-|\\+|\\?|\\(|\\)|\\[|\\]|\\^|\\$|\\|"
- "|(\\\\[^\\*\\%]|\\\\$))"; // \*, \% won't get additional '\'
+ "|(\\\\[^\\*\\%]|\\\\$))"; // \*, \% won't get
+ // additional '\'
pcrecpp::RE(metas).GlobalReplace("\\\\\\1", &result);
return result;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
/**
* Adds ^ character at the beginning in proper way
* @param value Regexp pattern
* @return String with regex special characters escaped.
*/
std::string escape(const std::string& str);
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
template<bool>
struct CompileTimeChecker
{
#define STATIC_CHECK(expr, msg) \
{ \
- class ERROR_ ## msg {}; \
- CompileTimeChecker<(expr)!= 0>((ERROR_ ## msg())); \
+ class ERROR_##msg {}; \
+ CompileTimeChecker<(expr) != 0>((ERROR_##msg())); \
}
/**
* */
#define STATIC_ERROR(msg, C) \
{ \
- C->_ ## msg(); \
+ C->_##msg(); \
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class StringBuilderImpl
{
public:
StringBuilderImpl() : m_counter(1)
- {
- }
+ {}
void append(const std::string& str)
{
};
StringBuilder::StringBuilder() : m_impl(new StringBuilderImpl())
-{
-}
+{}
StringBuilder::~StringBuilder()
{
StringBuilder & StringBuilder::operator=(const StringBuilder& other)
{
- if (this == &other) { return *this; }
+ if (this == &other) {
+ return *this;
+ }
other.m_impl->addRef();
{
return m_impl->toString();
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class StringBuilderImpl;
class StringBuilder
private:
StringBuilderImpl* m_impl;
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
namespace String {
-
std::string lTrim(const std::string& str)
{
std::string result = str;
}
bool startsWith(const std::string& str,
- const std::string& startStr)
+ const std::string& startStr)
{
return str.find(startStr) == 0;
}
bool endsWith(const std::string& str,
- const std::string& endStr)
+ const std::string& endStr)
{
std::size_t pos = str.rfind(endStr);
if (pos == std::string::npos) {
}
std::string unique(const std::string& str,
- const char needle)
+ const char needle)
{
std::string result = str;
}
bool inCStringArray(const std::string& needle,
- const char* stack[])
+ const char* stack[])
{
while (*stack) {
if (needle == *stack) {
}
std::vector<std::string> split(const std::string& str,
- std::string::value_type delim)
+ std::string::value_type delim)
{
std::vector<std::string> result;
std::string::size_type begin = 0, end = 0;
if (!part.empty()) {
result.push_back(part);
}
- if (std::string::npos == end) { break; }
+ if (std::string::npos == end) {
+ break;
+ }
begin = end + 1;
}
return result;
{
return convertTo<int>(str);
}
-
}
}
}
namespace WrtDeviceApis {
namespace Commons {
namespace String {
-
/**
* Removes spaces from begining of the string.
* @param str String to remove spaces from.
std::string parse(const T& data)
{
std::ostringstream oss;
- if (!(oss << data))
- {
+ if (!(oss << data)) {
Throw(ConversionException);
}
return oss.str();
}
-
}
}
}
namespace WrtDeviceApis {
namespace Commons {
-
ThreadPool &ThreadPool::getInstance()
{
static ThreadPool theInstance;
}
DPL::Event::AbstractEventDispatcher *ThreadPool::getDispatcher(
- DPL::Event::ThreadEventDispatcher &callingThreadDispatcher)
+ DPL::Event::ThreadEventDispatcher &callingThreadDispatcher)
{
DPL::Thread *currentThread = DPL::Thread::GetCurrentThread();
//if we are in main thread
}
ThreadPool::ThreadPool()
-{
-}
+{}
ThreadPool::~ThreadPool()
{
}
DPL::Thread* ThreadPool::getThreadHandleCreateIfNotExists(
- ThreadEnum::Enumeration type)
+ ThreadEnum::Enumeration type)
{
DPL::Mutex::ScopedLock lock(&m_threadHandlersMutex);
ThreadHandleMap::iterator element = m_threadHandlers.find(type);
DPL::Thread* newThread = new DPL::Thread();
m_threadHandlers.insert(
m_threadHandlers.begin(),
- std::pair<ThreadEnum::Enumeration,DPL::Thread*>(type, newThread));
+ std::pair<ThreadEnum::Enumeration, DPL::Thread*>(type, newThread));
newThread->Run();
return newThread;
}
}
/* we could stay with
* getThreadHandleCreateIfNotExists(type);
- * but by switch we can attach actually one thread to more than one ThreadEnums
+ * but by switch we can attach actually one thread to more than one
+ * ThreadEnums
*/
switch (type) {
case ThreadEnum::NULL_THREAD:
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::POWER_THREAD);
break;
case ThreadEnum::PLUGIN_TEMPLETE_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::PLUGIN_TEMPLETE_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::PLUGIN_TEMPLETE_THREAD);
break;
case ThreadEnum::BLUETOOTH_THREAD:
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::BLUETOOTH_THREAD);
break;
case ThreadEnum::APPLICATION_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::APPLICATION_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::APPLICATION_THREAD);
break;
case ThreadEnum::GYROSCOPE_THREAD:
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::GYROSCOPE_THREAD);
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::CLOCK_THREAD);
break;
case ThreadEnum::SYSTEMINFO_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::SYSTEMINFO_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::SYSTEMINFO_THREAD);
break;
case ThreadEnum::CALLHISTORY_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::CALLHISTORY_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::CALLHISTORY_THREAD);
break;
case ThreadEnum::ACCOUNT_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::CALLHISTORY_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::CALLHISTORY_THREAD);
break;
case ThreadEnum::NFC_THREAD:
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::NFC_THREAD);
break;
case ThreadEnum::MEDIACONTENT_THREAD:
- thandle = getThreadHandleCreateIfNotExists(ThreadEnum::MEDIACONTENT_THREAD);
+ thandle = getThreadHandleCreateIfNotExists(
+ ThreadEnum::MEDIACONTENT_THREAD);
break;
case ThreadEnum::SE_THREAD:
thandle = getThreadHandleCreateIfNotExists(ThreadEnum::SE_THREAD);
}
return thandle;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class ThreadEnum
{
private:
ThreadEnum()
- {
- }
+ {}
+
public:
enum Enumeration
{
};
};
-
class ThreadPool : private DPL::Noncopyable
{
private:
//DPL::MainEventDispatcher m_mainEventDispatcher;
ThreadPool();
+
public:
~ThreadPool();
* Get proper dispatcher for current calling thread
*/
DPL::Event::AbstractEventDispatcher *getDispatcher(
- DPL::Event::ThreadEventDispatcher &callingThreadDispatcher);
+ DPL::Event::ThreadEventDispatcher &callingThreadDispatcher);
static ThreadPool& getInstance();
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
namespace Time {
-
struct tm* localtime_r(long long int* timep, struct tm* result)
{
UErrorCode status = U_ZERO_ERROR;
UCalendar *cal;
- if( !result || !timep )
- {
+ if (!result || !timep) {
return NULL;
}
cal = ucal_open(NULL, 0, NULL, UCAL_DEFAULT, &status);
- if(U_FAILURE(status))
- {
+ if (U_FAILURE(status)) {
return NULL;
}
ucal_setMillis(cal, (*timep * (double)1000.0), &status);
- result->tm_sec = ucal_get(cal, UCAL_SECOND, &status);
- result->tm_min = ucal_get(cal, UCAL_MINUTE, &status);
- result->tm_hour = ucal_get(cal, UCAL_HOUR, &status);
+ result->tm_sec = ucal_get(cal, UCAL_SECOND, &status);
+ result->tm_min = ucal_get(cal, UCAL_MINUTE, &status);
+ result->tm_hour = ucal_get(cal, UCAL_HOUR, &status);
result->tm_mday = ucal_get(cal, UCAL_DAY_OF_MONTH, &status);
- result->tm_mon = ucal_get(cal, UCAL_MONTH, &status);
- result->tm_year = ucal_get(cal, UCAL_YEAR, &status);
- result->tm_wday = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
- result->tm_yday = ucal_get(cal, UCAL_DAY_OF_YEAR, &status);
- result->tm_isdst= ucal_get(cal, UCAL_DST_OFFSET, &status);
+ result->tm_mon = ucal_get(cal, UCAL_MONTH, &status);
+ result->tm_year = ucal_get(cal, UCAL_YEAR, &status);
+ result->tm_wday = ucal_get(cal, UCAL_DAY_OF_WEEK, &status);
+ result->tm_yday = ucal_get(cal, UCAL_DAY_OF_YEAR, &status);
+ result->tm_isdst = ucal_get(cal, UCAL_DST_OFFSET, &status);
ucal_close(cal);
- if(U_FAILURE(status))
- {
+ if (U_FAILURE(status)) {
return NULL;
- }
- else
- {
+ } else {
return result;
}
}
-
}
}
}
namespace WrtDeviceApis {
namespace Commons {
namespace Time {
-
struct tm* localtime_r(long long int* timep, struct tm* result);
-
}
}
}
namespace WrtDeviceApis {
namespace Commons {
-
template<typename T>
struct IsNull
{
{
static const bool value = false;
};
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
struct AceFeature
{
AceFeature(const std::string& featName) : name(featName) {}
struct AceDeviceCapParam
{
AceDeviceCapParam(const std::string& parName,
- const std::string& parVal) : name(parName),
+ const std::string& parVal) : name(parName),
value(parVal)
- {
- }
+ {}
std::string name;
std::string value;
{
AceDeviceCapability() {}
AceDeviceCapability(const std::string& name,
- const AceDeviceCapParams& params) :
+ const AceDeviceCapParams& params) :
devCapName(name),
devCapParams(params)
- {
- }
+ {}
std::string devCapName;
AceDeviceCapParams devCapParams;
IMPLEMENT_SAFE_SINGLETON(WrtDeviceApis::Commons::WrtAccess)
namespace {
-
/**
* Helper class - single parameter and its value
*/
const char *name;
const char *value;
- AceParam():
+ AceParam() :
name(NULL), value(NULL)
{}
- AceParam(const char *name, const char *value):
+ AceParam(const char *name, const char *value) :
name(name), value(value)
{}
};
*/
struct AceParamList
{
- size_t count;
+ size_t count;
AceParam* param;
- AceParamList():
+ AceParamList() :
count(0),
param(NULL)
{}
{
public:
explicit ScopedDeviceCapArray(AceParamList *ptr =
- DeviceCapParamPolicy::NullValue()) :
+ DeviceCapParamPolicy::NullValue()) :
DPL::ScopedResource<DeviceCapParamPolicy>(ptr)
- {
- }
+ {}
AceParamList & operator [](std::ptrdiff_t k) const
{
namespace WrtDeviceApis {
namespace Commons {
-
WrtAccess::WrtAccess() :
- m_initialized(false),
- m_sessionId(GenerateSessionId())
-{
-}
+ m_sessionId(GenerateSessionId()),
+ m_pluginOwners(0)
+{}
WrtAccess::~WrtAccess()
-{
-}
+{}
WrtAccess::SessionId WrtAccess::GenerateSessionId()
{
const size_t SESSION_ID_LENGTH = 32;
std::ostringstream pid;
- pid << static_cast<int> (getpid());
+ pid << static_cast<int>(getpid());
std::string session_id = pid.str();
session_id.reserve(session_id.length() + SESSION_ID_LENGTH);
- for (size_t i = 0; i < SESSION_ID_LENGTH; ++i)
- {
+ for (size_t i = 0; i < SESSION_ID_LENGTH; ++i) {
int c = random() % 16;
- session_id += (c < 10 ?
- static_cast<char>('0' + c) :
- static_cast<char>('A' + c - 10));
+ session_id += (c < 10 ?
+ static_cast<char>('0' + c) :
+ static_cast<char>('A' + c - 10));
}
return session_id;
}
void WrtAccess::initialize(int widgetId)
{
LogDebug("initialize");
- if (widgetId < 0)
- {
+ if (widgetId < 0) {
LogDebug("Invalid widget id");
Throw(Exception);
}
- ace_return_t ret = ace_client_initialize(Wrt::Popup::run_popup);
- Assert(ACE_OK == ret);
- m_initialized = true;
- m_widgetId = widgetId;
+
+ if (!m_pluginOwners++) {
+ ace_return_t ret = ace_client_initialize(Wrt::Popup::run_popup);
+ Assert(ACE_OK == ret);
+ m_widgetId = widgetId;
+ }
}
void WrtAccess::deinitialize(int /*widgetId*/)
{
LogDebug("deinitialize");
- m_initialized = false;
- ace_return_t ret = ace_client_shutdown();
- Assert(ACE_OK == ret);
+
+ if (!--m_pluginOwners) {
+ ace_return_t ret = ace_client_shutdown();
+ Assert(ACE_OK == ret);
+ }
}
int WrtAccess::getWidgetId() const
bool WrtAccess::checkAccessControl(const AceFunction& aceFunction) const
{
- Assert(m_initialized && "WrtAccessSingleton needs to be initialized with"
- "WidgetId during on_widget_start_callback in each plugin");
+ Assert(
+ m_pluginOwners && "WrtAccessSingleton needs to be initialized with"
+ "WidgetId during on_widget_start_callback in each plugin");
size_t deviceCount = aceFunction.deviceCapabilities.size();
DPL::ScopedArray <const char *> deviceScopedArray;
LogDebug("constructing ACE request");
ace_request_t aceRequest;
- aceRequest.session_id = const_cast<const ace_session_id_t>(m_sessionId.c_str());
+ aceRequest.session_id =
+ const_cast<const ace_session_id_t>(m_sessionId.c_str());
aceRequest.widget_handle = getWidgetId();
aceRequest.feature_list.count = featuresCount;
- aceRequest.feature_list.items = const_cast<ace_string_t*>(featureScopedArray.Get());
+ aceRequest.feature_list.items =
+ const_cast<ace_string_t*>(featureScopedArray.Get());
aceRequest.dev_cap_list.count = deviceCount;
aceRequest.dev_cap_list.items = new ace_dev_cap_t[deviceCount];
unsigned int i;
for (i = 0; i < deviceCount; ++i) {
aceRequest.dev_cap_list.items[i].name =
- const_cast<const ace_string_t>(devCapNames[i]);
+ const_cast<const ace_string_t>(devCapNames[i]);
aceRequest.dev_cap_list.items[i].param_list.count = paramList[i].count;
aceRequest.dev_cap_list.items[i].param_list.items =
- new ace_param_t[paramList[i].count];
+ new ace_param_t[paramList[i].count];
unsigned int j;
for (j = 0; j < paramList[i].count; ++j) {
aceRequest.dev_cap_list.items[i].param_list.items[j].name =
- const_cast<ace_string_t>(paramList[i].param[j].name);
+ const_cast<ace_string_t>(paramList[i].param[j].name);
aceRequest.dev_cap_list.items[i].param_list.items[j].value =
- const_cast<ace_string_t>(paramList[i].param[j].value);
+ const_cast<ace_string_t>(paramList[i].param[j].value);
}
}
ace_return_t ret = ace_check_access(&aceRequest, &aceCheckResult);
for (i = 0; i < deviceCount; ++i) {
- delete [] aceRequest.dev_cap_list.items[i].param_list.items;
+ delete[] aceRequest.dev_cap_list.items[i].param_list.items;
}
- delete [] aceRequest.dev_cap_list.items;
+ delete[] aceRequest.dev_cap_list.items;
if (ACE_OK != ret) {
LogError("Error in ace check: " << static_cast<int>(ret));
}
return ACE_TRUE == aceCheckResult;
}
-
}
} // WrtDeviceApisCommon
namespace WrtDeviceApis {
namespace Commons {
-
class WrtAccess
{
-public:
+ public:
void initialize(int widgetId);
void deinitialize(int widgetId);
int getWidgetId() const;
bool checkAccessControl(const AceFunction &aceFunction) const;
-private:
+ private:
typedef std::string SessionId;
SessionId GenerateSessionId();
WrtAccess();
virtual ~WrtAccess();
- bool m_initialized;
int m_widgetId;
SessionId m_sessionId;
+ size_t m_pluginOwners;
+
friend class DPL::Singleton<WrtAccess>;
};
typedef DPL::Singleton<WrtAccess> WrtAccessSingleton;
-
}
} // WrtDeviceApisCommon
/*
* @author Karol Majewski (k.majewski@samsung.com)
* @version 0.1
- * @brief This is a file that you provides interface for wrt-engine while loading and using plugin
- * If you are a plugin developer you need to plugin_initializer.cpp in your module and provide implementation for macros below
+ * @brief This is a file that you provides interface for wrt-engine while
+ * loading and using plugin
+ * If you are a plugin developer you need to plugin_initializer.cpp
+ * in your module and provide implementation for macros below
*/
#ifndef WRTDEVICEAPIS_COMMONS_PLUGIN_INITIALIZER_DEF_H_
* */
#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
-
-
-
//HAVE TO BE IMPLEMENTED IN EVERY PLUGIN
/*
- * You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while loading each widget (for every loaded widget this function will be called)
+ * You have to(!) call this macro in your plugin_initializer.cpp(!) file
+ * providing callback that will be called while loading each widget (for every
+ * loaded widget this function will be called)
* Example:
* plugin_initializer.cpp
- * void on_widget_start_callback(int widgetId, JSContextRef context, const engine_interface_t *interface)
+ * void on_widget_start_callback(int widgetId, JSContextRef context,
+ * const engine_interface_t *interface)
* {
* //...
* }
* PLUGIN_ON_WIDGET_START(on_widget_start_callback)
*/
-#define PLUGIN_ON_WIDGET_START(CALLBACK_NAME) extern "C" const on_widget_start_proc PLUGIN_WIDGET_START_PROC EXPORT_SYMBOL = CALLBACK_NAME;
+#define PLUGIN_ON_WIDGET_START(CALLBACK_NAME) extern "C" const \
+ on_widget_start_proc PLUGIN_WIDGET_START_PROC EXPORT_SYMBOL = CALLBACK_NAME;
/*
* You have to(!) call this macro in your plugin_initializer.cpp(!) file
* PLUGIN_ON_WIDGET_INIT(on_widget_init_callback)
*/
#define PLUGIN_ON_WIDGET_INIT(CALLBACK_NAME) extern "C" \
-const on_widget_init_proc PLUGIN_WIDGET_INIT_PROC EXPORT_SYMBOL = CALLBACK_NAME;
+ const on_widget_init_proc PLUGIN_WIDGET_INIT_PROC EXPORT_SYMBOL = \
+ CALLBACK_NAME;
/*
- * You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while unloading each widget (for every unloaded widget this function will be called)
+ * You have to(!) call this macro in your plugin_initializer.cpp(!) file
+ * providing callback that will be called while unloading each widget (for
+ * every unloaded widget this function will be called)
* Example:
* void on_widget_stop_callback(int widgetId)
* {
* }
* PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
*/
-#define PLUGIN_ON_WIDGET_STOP(CALLBACK_NAME) extern "C" const on_widget_stop_proc PLUGIN_WIDGET_STOP_PROC EXPORT_SYMBOL = CALLBACK_NAME;
+#define PLUGIN_ON_WIDGET_STOP(CALLBACK_NAME) extern "C" const \
+ on_widget_stop_proc PLUGIN_WIDGET_STOP_PROC EXPORT_SYMBOL = CALLBACK_NAME;
/*
- * You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while unloading each page (for every loaded page, including nested page, this function will be called)
+ * You have to(!) call this macro in your plugin_initializer.cpp(!) file
+ * providing callback that will be called while unloading each page (for every
+ * loaded page, including nested page, this function will be called)
* Example:
* void on_frame_load_callback(java_script_context_t context)
* {
* }
* PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
*/
-#define PLUGIN_ON_FRAME_LOAD(CALLBACK_NAME) extern "C" const on_frame_load_proc PLUGIN_FRAME_LOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
+#define PLUGIN_ON_FRAME_LOAD(CALLBACK_NAME) extern "C" const on_frame_load_proc \
+ PLUGIN_FRAME_LOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
/*
- * You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while ununloading each page (for every unloaded page, including nested page, this function will be called)
+ * You have to(!) call this macro in your plugin_initializer.cpp(!) file
+ * providing callback that will be called while ununloading each page (for
+ * every unloaded page, including nested page, this function will be called)
* Example:
* void on_frame_unload_callback(java_script_context_t context)
* {
* }
* PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
*/
-#define PLUGIN_ON_FRAME_UNLOAD(CALLBACK_NAME) extern "C" const on_frame_unload_proc PLUGIN_FRAME_UNLOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
+#define PLUGIN_ON_FRAME_UNLOAD(CALLBACK_NAME) extern "C" const \
+ on_frame_unload_proc PLUGIN_FRAME_UNLOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
/*
- * You have to(!) define an array of structures in your plugin_initializer.cpp(!) file describing a JS class (class_definition) and it's parent class name (parent_name).
+ * You have to(!) define an array of structures in your
+ * plugin_initializer.cpp(!) file describing a JS class (class_definition) and
+ * it's parent class name (parent_name).
* JS class will be bind to a parent class name (parent_name.jsclass_name).
* Example:
* plugin_initializer.cpp
* PLUGIN_CLASS_MAP_BEGIN
- * PLUGIN_CLASS_MAP_ADD_CLASS("bondi",WrtPluginBondi::JSICameraManager::getClassInfo())
- * PLUGIN_CLASS_MAP_ADD_CLASS("bondi",WrtPluginBondi::JSICameraAnotherClass::getClassInfo())
+ * PLUGIN_CLASS_MAP_ADD_CLASS(
+ * "bondi",
+ * WrtPluginBondi::JSICameraManager::getClassInfo())
+ * PLUGIN_CLASS_MAP_ADD_CLASS(
+ * "bondi",
+ * WrtPluginBondi::JSICameraAnotherClass::getClassInfo())
* PLUGIN_CLASS_MAP_END
*
*/
-#define PLUGIN_CLASS_MAP_BEGIN extern "C" const js_entity_definition_t\
- PLUGIN_CLASS_MAP[] EXPORT_SYMBOL = {
+#define PLUGIN_CLASS_MAP_BEGIN extern "C" const js_entity_definition_t \
+ PLUGIN_CLASS_MAP[] EXPORT_SYMBOL = {
-#define PLUGIN_CLASS_MAP_ADD_INTERFACE(PARENTNAME,INTERFACENAME,\
- JSPRODUCTCLASSTEMPLATE,PRODUCTCONSTRUCTORCB,PRIVDATA) \
- {PARENTNAME,INTERFACENAME,"",JSPRODUCTCLASSTEMPLATE,\
- PRODUCTCONSTRUCTORCB,PRIVDATA},
+#define PLUGIN_CLASS_MAP_ADD_INTERFACE(PARENTNAME, \
+ INTERFACENAME, \
+ JSPRODUCTCLASSTEMPLATE, \
+ PRODUCTCONSTRUCTORCB, \
+ PRIVDATA) \
+ { PARENTNAME, INTERFACENAME, "", JSPRODUCTCLASSTEMPLATE, \
+ PRODUCTCONSTRUCTORCB, PRIVDATA },
-#define PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(PARENTNAME,OBJECTNAME,\
- INTERFACENAME,PRIVDATA)\
- {PARENTNAME,OBJECTNAME,INTERFACENAME,NULL,NULL,PRIVDATA},
+#define PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(PARENTNAME, OBJECTNAME, \
+ INTERFACENAME, PRIVDATA) \
+ { PARENTNAME, OBJECTNAME, INTERFACENAME, NULL, NULL, PRIVDATA },
-#define PLUGIN_CLASS_MAP_ADD_CLASS(PARENTNAME,CLASSNAME,JSCLASSTEMPLATE,\
- PRIVDATA)\
- {PARENTNAME,CLASSNAME,"",JSCLASSTEMPLATE,NULL,PRIVDATA},
+#define PLUGIN_CLASS_MAP_ADD_CLASS(PARENTNAME, CLASSNAME, JSCLASSTEMPLATE, \
+ PRIVDATA) \
+ { PARENTNAME, CLASSNAME, "", JSCLASSTEMPLATE, NULL, PRIVDATA },
-#define PLUGIN_CLASS_MAP_END {NULL,NULL,NULL,NULL,NULL,NULL} };
+#define PLUGIN_CLASS_MAP_END { NULL, NULL, NULL, NULL, NULL, NULL } };
-#define PLUGIN_CLASS_MAP_BEGIN_STATIC static const js_entity_definition_t\
- PLUGIN_CLASS_MAP[] = {
+#define PLUGIN_CLASS_MAP_BEGIN_STATIC static const js_entity_definition_t \
+ PLUGIN_CLASS_MAP[] = {
-#define PLUGIN_GET_CLASS_MAP(CALLBACK_NAME) extern "C" const\
- get_widget_entity_map_proc\
- PLUGIN_GET_CLASS_PROC_MAP EXPORT_SYMBOL = CALLBACK_NAME;
+#define PLUGIN_GET_CLASS_MAP(CALLBACK_NAME) extern "C" const \
+ get_widget_entity_map_proc \
+ PLUGIN_GET_CLASS_PROC_MAP EXPORT_SYMBOL = CALLBACK_NAME;
#endif // WRTDEVICEAPIS_COMMONS_PLUGIN_INITIALIZER_DEF_H_
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
Converter::Converter(JSContextRef context) : m_context(context)
-{
-}
+{}
Converter::~Converter()
-{
-}
+{}
JSObjectRef Converter::toJSObjectRef(const JSValueRef& arg)
{
{
if (!JSValueIsString(m_context, arg) &&
!JSValueIsNumber(m_context, arg) &&
- !JSValueIsBoolean(m_context, arg)) {
+ !JSValueIsBoolean(m_context, arg))
+ {
ThrowMsg(ConversionException,
"Argument is not convertable to JS String.");
}
return toVectorOfT_(arg, &Converter::toString);
}
-std::vector<time_t> Converter::toVectorOfTimeT(const JSValueRef& arg) {
+std::vector<time_t> Converter::toVectorOfTimeT(const JSValueRef& arg)
+{
return toVectorOfT_(arg, &Converter::toDateTimeT);
}
return JSValueMakeNumber(m_context, arg);
}
-JSValueRef Converter::toJSValueRefLong(const long arg) {
+JSValueRef Converter::toJSValueRefLong(const long arg)
+{
return JSValueMakeNumber(m_context, arg);
}
JSValueRef Converter::toJSValueRef(const time_t arg)
{
- struct tm *tminfo = localtime(&arg);
- return toJSValueRef(*tminfo);
+ struct tm tminfo = {0, };
+ localtime_r(&arg, &tminfo);
+ return toJSValueRef(tminfo);
}
JSValueRef Converter::toJSValueRef(const std::vector<std::string>& arg)
return toJSValueRef(std::string(arg));
}
-JSValueRef Converter::toJSValueRef(const std::vector<int>& arg) {
+JSValueRef Converter::toJSValueRef(const std::vector<int>& arg)
+{
return toJSValueRef_(arg);
}
-JSValueRef Converter::toJSValueRef(const std::vector<time_t>& arg) {
+JSValueRef Converter::toJSValueRef(const std::vector<time_t>& arg)
+{
return toJSValueRef_(arg);
}
NOT_IEEE754_REPRESENTATION);
return (value != value);
}
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class Converter : private DPL::Noncopyable
{
public:
std::vector<std::string> toVectorOfStrings(const JSValueRef& arg);
/**
- * Converts JSValueRef to vector of time_t.
- * @param arg JSValueRef to convert.
- * @return std::vector<std::time_t>
- * @throw ConversionException Thrown when conversion fails.
- */
- std::vector<std::time_t> toVectorOfTimeT(const JSValueRef& arg);
+ * Converts JSValueRef to vector of time_t.
+ * @param arg JSValueRef to convert.
+ * @return std::vector<std::time_t>
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ std::vector<std::time_t> toVectorOfTimeT(const JSValueRef& arg);
- /**
+ /**
* Converts boolean value to JSValueRef.
* @param arg Boolean value to convert.
* @return JSValueRef object.
JSValueRef toJSValueRef(unsigned long arg);
/**
- * Converts long value to JSValueRef.
- * @param arg long value to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRefLong(const long arg);
+ * Converts long value to JSValueRef.
+ * @param arg long value to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRefLong(const long arg);
/**
* Converts unsigned long value to JSValueRef.
*/
JSValueRef toJSValueRef(long long int arg);
- /**
+ /**
* Converts STL string to JSValueRef.
* @param arg STL string to convert.
* @return JSValueRef object.
JSValueRef toJSValueRef(const tm& arg);
/**
- * Converts STL vector of integer to JSValueRef.
- * @param arg STL vector of integer to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRef(const std::vector<int>& arg);
+ * Converts STL vector of integer to JSValueRef.
+ * @param arg STL vector of integer to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRef(const std::vector<int>& arg);
- /**
- * Converts STL vector of time_t to JSValueRef.
- * @param arg STL vector of time_t to convert.
- * @return JSValueRef object.
- * @throw ConversionException Thrown when conversion fails.
- */
- JSValueRef toJSValueRef(const std::vector<time_t>& arg);
+ /**
+ * Converts STL vector of time_t to JSValueRef.
+ * @param arg STL vector of time_t to convert.
+ * @return JSValueRef object.
+ * @throw ConversionException Thrown when conversion fails.
+ */
+ JSValueRef toJSValueRef(const std::vector<time_t>& arg);
- /**
+ /**
* Converts STL vector of string to JSStringRef.
* @param arg STL string to convert.
* @return JSValueRef object.
template<typename T, class Derived>
std::vector<T> toVectorOfT_(const JSValueRef& arg,
- T (Derived::*f)(const JSValueRef &),
- Derived* object)
+ T (Derived::*f)(const JSValueRef &),
+ Derived* object)
{
if (JSValueIsNull(m_context,
- arg) || JSValueIsUndefined(m_context, arg)) {
+ arg) || JSValueIsUndefined(m_context, arg))
+ {
return std::vector<T>();
}
if (!JSIsArrayValue(m_context, arg)) {
- ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
+ ThrowMsg(Commons::ConversionException,
+ "Argument is not an JS array.");
}
std::vector<T> result;
template<typename T>
std::vector<T> toVectorOfT_(const JSValueRef& arg,
- T (Converter::*f)(const JSValueRef &))
+ T (Converter::*f)(const JSValueRef &))
{
if (JSValueIsNull(m_context,
- arg) || JSValueIsUndefined(m_context, arg)) {
+ arg) || JSValueIsUndefined(m_context, arg))
+ {
return std::vector<T>();
}
if (!JSIsArrayValue(m_context, arg)) {
- ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
+ ThrowMsg(Commons::ConversionException,
+ "Argument is not an JS array.");
}
std::vector<T> result;
template<class T, class Derived>
JSValueRef toJSValueRef_(const std::vector<T>& arg,
- JSValueRef (Derived::*f)(const T &),
- Derived* object)
+ JSValueRef (Derived::*f)(const T &),
+ Derived* object)
{
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
for (std::size_t i = 0; i < arg.size(); ++i) {
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
typename std::list<T>::const_iterator it = arg.begin();
template<class T, class Derived>
JSValueRef toJSValueRef_(const std::list<T>& arg,
- JSValueRef (Derived::*f)(const T &),
- Derived* object)
+ JSValueRef (Derived::*f)(const T &),
+ Derived* object)
{
JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
if (NULL == jsResult) {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Could not create js array object");
+ ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+ "Could not create js array object");
}
typename std::list<T>::const_iterator it = arg.begin();
{
std::stringstream ss;
if (!(ss << arg)) {
- ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Could not convert to string.");
+ ThrowMsg(WrtDeviceApis::Commons::ConversionException,
+ "Could not convert to string.");
}
return ss.str();
}
typedef ConverterFactory<Converter> BasicConverterFactory;
typedef BasicConverterFactory::ConverterType BasicConverter;
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
DOMExceptionData::DOMExceptionData(int code,
const std::string& message) :
m_code(code),
m_message(message)
-{
-}
+{}
int DOMExceptionData::getCode() const
{
{
return m_message;
}
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class DOMExceptionData
{
public:
explicit DOMExceptionData(int code,
- const std::string& message = std::string());
+ const std::string& message = std::string());
int getCode() const;
std::string getMessage() const;
};
typedef DPL::SharedPtr<DOMExceptionData> DOMExceptionDataPtr;
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
-JSCallbackManagerPtr JSCallbackManager::createObject(JSContextRef context,
- JSValueRef onSuccess,
- JSValueRef onError,
- bool acceptJSNullAsOnSuccess,
- bool acceptJSNullAsOnError)
+JSCallbackManagerPtr JSCallbackManager::createObject(
+ JSContextRef context,
+ JSValueRef onSuccess,
+ JSValueRef onError,
+ bool
+ acceptJSNullAsOnSuccess,
+ bool acceptJSNullAsOnError)
{
LogDebug("entered");
JSObjectRef l_onSuccess = NULL;
LogDebug("onSuccessCallback ptr=" << onSuccess);
LogDebug("onErrorCallback ptr=" << onError);
if (NULL != onSuccess &&
- (!acceptJSNullAsOnSuccess || !JSValueIsNull(context, onSuccess))) {
+ (!acceptJSNullAsOnSuccess || !JSValueIsNull(context, onSuccess)))
+ {
l_onSuccess = JSValueToObject(context, onSuccess, NULL);
if (!l_onSuccess ||
- !JSObjectIsFunction(context, l_onSuccess)) {
+ !JSObjectIsFunction(context, l_onSuccess))
+ {
ThrowMsg(Commons::InvalidArgumentException,
"success callback is not a function");
}
LogWarning("onSuccessCallback is NULL and is not registred");
}
if (NULL != onError &&
- (!acceptJSNullAsOnError || !JSValueIsNull(context, onError))) {
+ (!acceptJSNullAsOnError || !JSValueIsNull(context, onError)))
+ {
l_onError = JSValueToObject(context, onError, NULL);
if (!l_onError ||
- !JSObjectIsFunction(context, l_onError)) {
+ !JSObjectIsFunction(context, l_onError))
+ {
ThrowMsg(Commons::InvalidArgumentException,
"error callback is not a function");
}
}
JSCallbackManager::JSCallbackManager(JSContextRef context,
- JSObjectRef onSuccess,
- JSObjectRef onError) :
+ JSObjectRef onSuccess,
+ JSObjectRef onError) :
m_onSuccess(NULL),
m_onError(NULL),
- m_object(NULL),
- m_context(context)
+ m_context(context),
+ m_object(NULL)
{
LogDebug("entered");
}
void JSCallbackManager::callOnSuccess(JSValueRef obj[],
- int paramCount)
+ int paramCount)
{
LogDebug("entered");
if (m_onSuccess == NULL) {
}
void JSCallbackManager::callOnError(JSValueRef obj[],
- int paramCount)
+ int paramCount)
{
LogDebug("entered");
if (m_onError == NULL) {
return;
}
}
-
}
}
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class JSCallbackManager;
typedef DPL::SharedPtr<JSCallbackManager> JSCallbackManagerPtr;
{
private:
JSCallbackManager()
- {
- }
+ {}
/**
- * Used to create JSCallbackManagerPtr object by factory method createObject
+ * Used to create JSCallbackManagerPtr object by factory method
+ * createObject
*/
JSCallbackManager(JSContextRef context,
- JSObjectRef onSuccess,
- JSObjectRef onError);
+ JSObjectRef onSuccess,
+ JSObjectRef onError);
public:
- //JSCallbackManager( JSContextRef context, JSValueRef onSuccess, JSValueRef onError );
+ //JSCallbackManager( JSContextRef context, JSValueRef onSuccess, JSValueRef
+ // onError );
/**
* Create JSCallbackManagerPtr object witch checking callback parameters
- * if callbacks are NULL it was programmer intention to not use callback and no exception will be rised
+ * if callbacks are NULL it was programmer intention to not use callback and
+ * no exception will be rised
* if callbacks are some object but not a function it will rise exception
* @param[in] context - global context
* @param[in] onSuccess - success callback (may be NULL if not needed)
* @param[in] onError - error callback (may be NULL if not needed)
- * @param[in] acceptJSNullAsOnSuccess - converts JSNull on onSuccess to NULL when true
- * @param[in] acceptJSNullAsOnError - converts JSNull on onError to NULL when true
- * @throw Commons::InvalidArgumentException - if callback is not null and is not a js function
+ * @param[in] acceptJSNullAsOnSuccess - converts JSNull on onSuccess to NULL
+ * when true
+ * @param[in] acceptJSNullAsOnError - converts JSNull on onError to NULL
+ * when true
+ * @throw Commons::InvalidArgumentException - if callback is not null and is
+ * not a js function
*/
static JSCallbackManagerPtr createObject(
- JSContextRef context,
- JSValueRef onSuccess = NULL,
- JSValueRef onError = NULL,
- bool acceptJSNullAsOnSuccess = false,
- bool acceptJSNullAsOnError = false);
+ JSContextRef context,
+ JSValueRef onSuccess = NULL,
+ JSValueRef onError = NULL,
+ bool acceptJSNullAsOnSuccess = false,
+ bool acceptJSNullAsOnError = false);
virtual ~JSCallbackManager();
WrtDeviceApis::CommonsJavaScript::JSDOMException::SECURITY_ERR },
{ "NETWORK_ERR",
WrtDeviceApis::CommonsJavaScript::JSDOMException::NETWORK_ERR },
- { "ABORT_ERR",
+ { "ABORT_ERR",
WrtDeviceApis::CommonsJavaScript::JSDOMException::ABORT_ERR },
{ "TIMEOUT_ERR",
WrtDeviceApis::CommonsJavaScript::JSDOMException::TIMEOUT_ERR },
{ "INVALID_VALUES_ERR",
WrtDeviceApis::CommonsJavaScript::JSDOMException::INVALID_VALUES_ERR },
- { "IO_ERR",
- WrtDeviceApis::CommonsJavaScript::JSDOMException::IO_ERR },
+ { "IO_ERR",
+ WrtDeviceApis::CommonsJavaScript::JSDOMException::IO_ERR },
{ "QUOTA_EXCEEDED_ERR",
WrtDeviceApis::CommonsJavaScript::JSDOMException::QUOTA_EXCEEDED_ERR }
};
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
JSClassRef JSDOMException::m_classRef = NULL;
JSClassDefinition JSDOMException::m_classInfo = {
void JSDOMException::initialize(JSContextRef /*context*/,
JSObjectRef /*object*/)
-{
-}
+{}
void JSDOMException::finalize(JSObjectRef object)
{
const size_t size = sizeof(PROPERTY_ERROR) / sizeof(PROPERTY_ERROR[0]);
for (size_t i = 0; i < size; ++i) {
if (JSStringIsEqualToUTF8CString(propertyName,
- PROPERTY_ERROR[i].name)) {
+ PROPERTY_ERROR[i].name))
+ {
return true;
}
}
if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_CODE)) {
return converter.toJSValueRef(privateObject->getObject()->getCode());
} else if (JSStringIsEqualToUTF8CString(propertyName,
- PROPERTY_MESSAGE)) {
+ PROPERTY_MESSAGE))
+ {
return converter.toJSValueRef(
privateObject->getObject()->getMessage());
}
- }
- catch (const Commons::ConversionException& ex) {
+ } catch (const Commons::ConversionException& ex) {
LogError("Exception: " << ex.GetMessage());
}
return converter.toJSValueRef(PROPERTY_ERROR[i].value);
}
}
- }
- catch (const Commons::ConversionException& ex) {
+ } catch (const Commons::ConversionException& ex) {
LogError("Exception: " << ex.GetMessage());
}
}
void JSDOMException::getPropertyNames(
- JSContextRef /*context*/,
- JSObjectRef /*object*/,
- JSPropertyNameAccumulatorRef accumulator)
+ JSContextRef /*context*/,
+ JSObjectRef /*object*/,
+ JSPropertyNameAccumulatorRef accumulator)
{
const size_t size = sizeof(PROPERTY_ERROR) / sizeof(PROPERTY_ERROR[0]);
for (size_t i = 0; i < size; ++i) {
{
return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
}
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class JSDOMException
{
public:
* The callback invoked when an object is first created.
*/
static void initialize(JSContextRef context,
- JSObjectRef object);
+ JSObjectRef object);
/**
* The callback invoked when an object is finalized.
* The callback invoked when getting a property's value.
*/
static bool hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName);
+ JSObjectRef object,
+ JSStringRef propertyName);
/**
* The callback invoked when getting a property's value.
*/
static JSValueRef getProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
/**
* The callback invoked when getting a property's value.
*/
static JSValueRef getStaticProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static void getPropertyNames(JSContextRef context,
- JSObjectRef object,
- JSPropertyNameAccumulatorRef accumulator);
+ JSObjectRef object,
+ JSPropertyNameAccumulatorRef accumulator);
/**
- * The callback invoked when an object is used as the target of an 'instanceof' expression.
+ * The callback invoked when an object is used as the target of an
+ * 'instanceof' expression.
*/
static bool hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* exception);
+ JSObjectRef constructor,
+ JSValueRef possibleInstance,
+ JSValueRef* exception);
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
static JSClassRef m_classRef;
};
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
#define DEFINE_JS_EXCEPTION_FACTORY(Class, Code) \
JSDOMExceptionFactory JSDOMExceptionFactory::Class(Code)
JSDOMException::QUOTA_EXCEEDED_ERR);
JSDOMExceptionFactory::JSDOMExceptionFactory(int code) : m_code(code)
-{
-}
+{}
JSValueRef JSDOMExceptionFactory::make(JSContextRef context,
- JSValueRef* exception,
- const std::string& message)
+ JSValueRef* exception,
+ const std::string& message)
{
Assert(exception && "Exception object can't be NULL.");
JSDOMException::PrivateObject::ObjectType data(new DOMExceptionData(m_code,
message));
*exception = JSUtils::makeObject(context,
- JSDOMException::getClassRef(),
- data);
+ JSDOMException::getClassRef(),
+ data);
return JSValueMakeUndefined(context);
}
JSObjectRef JSDOMExceptionFactory::make(JSContextRef context,
- const std::string& message)
+ const std::string& message)
{
JSDOMException::PrivateObject::ObjectType data(new DOMExceptionData(m_code,
message));
return JSUtils::makeObject(context,
- JSDOMException::getClassRef(), data);
+ JSDOMException::getClassRef(), data);
}
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
#define DECLARE_JS_EXCEPTION_FACTORY(Class) static JSDOMExceptionFactory Class
class JSDOMExceptionFactory : public DPL::Noncopyable
* JSValueRef* exception)
* {
* ...
- * return JSExceptionFactory::InvalidArgumentException.make(context, exception);
+ * return JSExceptionFactory::InvalidArgumentException.make(context,
+ * exception);
* ...
* }
* @endcode
*/
JSValueRef make(JSContextRef context,
- JSValueRef* exception,
- const std::string& message = std::string());
+ JSValueRef* exception,
+ const std::string& message = std::string());
/**
* Creates exception object.
* @param context JS context of the exception.
* @return JS exception object.
* @code
- * JSObjectRef jsError = JSExceptionFactory::InvalidArgumentException.make(context);
+ * JSObjectRef jsError =
+ * JSExceptionFactory::InvalidArgumentException.make(context);
* @endcode
*/
JSObjectRef make(JSContextRef context,
- const std::string& message = std::string());
+ const std::string& message = std::string());
private:
int m_code;
};
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
namespace {
const char* PLUGIN_NAME = "PendingOperation";
}
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-//typedef Commons::PrivateObjectT<IJSPendingOperationPrivateObject*>::Type PendingOperationPrivateObject;
+//typedef Commons::PrivateObjectT<IJSPendingOperationPrivateObject*>::Type
+// PendingOperationPrivateObject;
class JSPendingOperation
{
* The callback invoked when an object is first created.
*/
static void initialize(JSContextRef context,
- JSObjectRef object);
+ JSObjectRef object);
/**
* The callback invoked when an object is finalized.
static void finalize(JSObjectRef object);
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
* Cancel the pending operation, if it has yet not completed.
*/
static JSValueRef cancel(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
};
} // CommonsJavaScript
} // WrtDeviceApis
{
public:
explicit IJSPendingOperationPrivateObject(
- const DPL::SharedPtr<Commons::IEventController>
- &event) :
+ const DPL::SharedPtr<Commons::IEventController>
+ &event) :
m_event(event)
{
assert(NULL != m_event);
}
virtual ~IJSPendingOperationPrivateObject()
- {
- }
+ {}
protected:
DPL::SharedPtr<Commons::IEventController> m_event;
{
public:
IJSExtCancelPendingOperationPrivateObject(
- const DPL::SharedPtr< TemplateEvent> &event,
- const DPL::SharedPtr<
- Commons::IExternEventCanceler<TemplateEvent> > & cancel) :
+ const DPL::SharedPtr< TemplateEvent> &event,
+ const DPL::SharedPtr<
+ Commons::IExternEventCanceler<TemplateEvent> > & cancel) :
IJSPendingOperationPrivateObject(
DPL::StaticPointerCast<Commons::IEventController>(event)),
m_canceler(cancel)
}
virtual ~IJSExtCancelPendingOperationPrivateObject()
- {
- }
+ {}
protected:
DPL::SharedPtr< Commons::IExternEventCanceler<TemplateEvent> > m_canceler;
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
using namespace WrtDeviceApis::Commons;
-
bool JSUtils::hasProperty(JSStaticValue* properties,
- JSStringRef name)
+ JSStringRef name)
{
JSStaticValue* property = properties;
while (property->name) {
}
JSValueRef JSUtils::getJSProperty(JSContextRef context,
- JSValueRef jsValue,
- const std::string &name,
- JSValueRef *exception)
+ JSValueRef jsValue,
+ const std::string &name,
+ JSValueRef *exception)
{
ScopedJSStringRef jsPropName(JSStringCreateWithUTF8CString(name.c_str()));
Converter converter(context);
}
JSValueRef JSUtils::getJSProperty(JSContextRef context,
- JSObjectRef object,
- const std::string& name)
+ JSObjectRef object,
+ const std::string& name)
{
Converter converter(context);
Try {
}
}
}
- Catch(ConversionException) {
- }
+ Catch(ConversionException) {}
return NULL;
}
JSValueRef JSUtils::getJSPropertyOrUndefined(JSContextRef context,
- JSObjectRef object,
- const std::string& name)
+ JSObjectRef object,
+ const std::string& name)
{
Converter converter(context);
Try {
return JSObjectGetProperty(context, object, propName.get(), NULL);
}
}
- Catch(ConversionException) {
- }
+ Catch(ConversionException) {}
return JSValueMakeUndefined(context);
}
} // CommonsJavaScript
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class JSUtils
{
public:
static bool hasProperty(JSStaticValue* properties,
- JSStringRef name);
+ JSStringRef name);
/**
* Gets a property from JSObject if exists
* @return JSValueRef if property exists, NULL if not
*/
static JSValueRef getJSProperty(JSContextRef context,
- JSValueRef jsValue,
- const std::string &name,
- JSValueRef* exception = NULL);
+ JSValueRef jsValue,
+ const std::string &name,
+ JSValueRef* exception = NULL);
static JSValueRef getJSProperty(JSContextRef context,
- JSObjectRef object,
- const std::string& name);
+ JSObjectRef object,
+ const std::string& name);
static JSValueRef getJSPropertyOrUndefined(JSContextRef context,
- JSObjectRef object,
- const std::string& name);
+ JSObjectRef object,
+ const std::string& name);
template<class C>
static JSObjectRef makeObject(JSContextRef context,
- JSClassRef classRef,
- C data)
+ JSClassRef classRef,
+ C data)
{
typedef typename PrivateObjectT<C>::Type Private;
Private* priv = new Private(context, data);
JSObjectRef object = JSObjectMake(context, classRef, priv);
if (!object) {
- ThrowMsg(Commons::NullPointerException, "Could not create JS object.");
+ ThrowMsg(Commons::NullPointerException,
+ "Could not create JS object.");
}
return object;
}
static JSObjectRef makeObject(JSContextRef context,
- JSClassRef classRef)
+ JSClassRef classRef)
{
typedef PrivateObjectT<void>::Type Private;
Private* priv = new Private(context);
JSObjectRef object = JSObjectMake(context, classRef, priv);
if (!object) {
- ThrowMsg(Commons::NullPointerException, "Could not create JS object.");
+ ThrowMsg(Commons::NullPointerException,
+ "Could not create JS object.");
}
return object;
}
}; // JSUtils
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
template<class T>
struct NoAcquire
{
void acquire(T*)
- {
- }
+ {}
+
protected:
~NoAcquire()
- {
- }
+ {}
};
template<class T>
Assert(object && "Object passed to protect can't be NULL.");
JSValueProtect(object->getContext(), object->getObject());
}
+
protected:
~AcquireByProtect()
- {
- }
+ {}
};
template<class T>
{
(void)object;
}
+
protected:
~NoRelease()
- {
- }
+ {}
};
template<class T>
{
delete object->getObject();
}
+
protected:
~ReleaseByDelete()
- {
- }
+ {}
};
template<class T>
Assert(object && "Object passed to unprotect can't be NULL.");
JSValueUnprotect(object->getContext(), object->getObject());
}
+
protected:
~ReleaseByUnprotect()
- {
- }
+ {}
};
template<class T>
{
protected:
~NoOwnership()
- {
- }
+ {}
};
template<class T>
{
protected:
~OwnershipByAcquisition()
- {
- }
+ {}
};
template<class T>
{
protected:
~OwnershipByProtection()
- {
- }
+ {}
};
template<class PrivateClass,
* @throw NullPointerException When object is pointer and is set to NULL.
*/
PrivateObject(JSContextRef context,
- const PrivateClass& object) :
+ const PrivateClass& object) :
m_context(context),
m_object(object)
{
Assert(NULL != m_context && "Context is NULL.");
- Assert(!Commons::IsNull<PrivateClass>::value(object) && "Object is NULL.");
+ Assert(!Commons::IsNull<PrivateClass>::value(
+ object) && "Object is NULL.");
acquire(this);
}
* Destroys instance of the object.
*/
virtual ~PrivateObject()
- {
- }
+ {}
/**
* Gets stored JS context.
{
typedef PrivateObject<void, NoOwnership> Type;
};
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
ScopedJSStringRef::ScopedJSStringRef(JSStringRef ref) : m_ref(ref)
-{
-}
+{}
ScopedJSStringRef::~ScopedJSStringRef()
{
#include <JavaScriptCore/JavaScript.h>
namespace WrtDeviceApis {
-
namespace CommonsJavaScript {
-
-
AceSecurityStatus aceCheckAccessSimple(
- WrtDeviceApis::Commons::AceFunction aceFunction)
+ WrtDeviceApis::Commons::AceFunction aceFunction)
{
- return aceCheckAccess2<DefaultArgsVerifier<>>(aceFunction);
+ return aceCheckAccess2<DefaultArgsVerifier<> >(aceFunction);
}
-
}
-
}
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
enum class AceSecurityStatus
{
AccessGranted,
{
public:
void operator()(WrtDeviceApis::Commons::AceFunction& aceFunction,
- Args && ... args) const
+ Args && ... args) const
{
static_assert(
WrtDeviceApis::Commons::AlwaysFalse<Args ...>::value,
{
public:
void operator()(WrtDeviceApis::Commons::AceFunction& /*aceFunction*/) const
- {
- }
+ {}
};
template <typename ArgumentsVerifier,
typename ... Args>
AceSecurityStatus aceCheckAccess2(
- WrtDeviceApis::Commons::AceFunction aceFunction,
- Args && ... args)
+ WrtDeviceApis::Commons::AceFunction aceFunction,
+ Args && ... args)
{
using namespace WrtDeviceApis::Commons;
argsVerify(aceFunction, args ...);
Try {
- if (!(WrtAccessSingleton::Instance().checkAccessControl(aceFunction))) {
- LogDebug("Function is not allowed to run");
- return AceSecurityStatus::AccessDenied;
+ if (!(WrtAccessSingleton::Instance().checkAccessControl(aceFunction)))
+ {
+ LogDebug("Function is not allowed to run");
+ return AceSecurityStatus::AccessDenied;
}
}
Catch(WrtDeviceApis::Commons::OutOfRangeException) {
return AceSecurityStatus::AccessGranted;
}
-
-
//The simplest version
AceSecurityStatus aceCheckAccessSimple(
- WrtDeviceApis::Commons::AceFunction aceFunction);
-
+ WrtDeviceApis::Commons::AceFunction aceFunction);
}
}
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
template<typename ParamType,
typename DeviceCapType,
typename FunctionType>
-class StaticDeclarations : public DPL::Noncopyable
+class StaticDeclarations : public DPL::Noncopyable
{
struct FunctionTriplet {
const char* name;
std::vector<DeviceCapType> devCaps;
std::vector<const char*> features;
};
- public:
+ public:
typedef typename std::map<ParamType, const char*> ParamsMap;
typedef std::map<DeviceCapType,
- std::pair<const char*,
- std::vector<ParamType> > > DeviceCapsMaps;
+ std::pair<const char*,
+ std::vector<ParamType> > > DeviceCapsMaps;
typedef std::map<FunctionType, FunctionTriplet > FunctionsMap;
typedef std::map<FunctionType, WrtDeviceApis::Commons::AceFunction>
- AceFunctionsMap;
+ AceFunctionsMap;
typedef std::map<std::string, std::vector<DeviceCapType> > FeaturesMap;
* for given device capability id
* */
static WrtDeviceApis::Commons::AceDeviceCapability
- getDeviceCapabilityWithoutParams(const DeviceCapType& devCapsId)
+ getDeviceCapabilityWithoutParams(const DeviceCapType& devCapsId)
{
WrtDeviceApis::Commons::AceDeviceCapability deviceCap;
auto it = m_deviceCaps.find(devCapsId);
* for given device capability id
* */
static WrtDeviceApis::Commons::AceDeviceCapability
- getDeviceCapability(const DeviceCapType& devCapsId)
+ getDeviceCapability(const DeviceCapType& devCapsId)
{
auto it = m_deviceCaps.find(devCapsId);
}
static void addDeviceCapabilty(
- const DeviceCapType& devCapsId,
- WrtDeviceApis::Commons::AceFunction& aceFunction)
+ const DeviceCapType& devCapsId,
+ WrtDeviceApis::Commons::AceFunction& aceFunction)
{
aceFunction.deviceCapabilities.push_back(
- getDeviceCapability(devCapsId));
+ getDeviceCapability(devCapsId));
}
/**
const std::string& value)
{
//get name of the deviceCaps
- std::string devCapName = getDevCapNameById(devCapId) ;
+ std::string devCapName = getDevCapNameById(devCapId);
std::string paramName = getParamName(paramId);
//search throw all the device capabilities
FOREACH(devCapIt, function.deviceCapabilities) {
- if(devCapIt->devCapName == devCapName) {
+ if (devCapIt->devCapName == devCapName) {
//device capability has been found
//check params
FOREACH(devParamIt, devCapIt->devCapParams) {
- if(devParamIt->name == paramName) {
+ if (devParamIt->name == paramName) {
devParamIt->value = value;
return true;
}
* To set param value function you may use setParamValue Function
* */
static WrtDeviceApis::Commons::AceFunction getEmptyFunction(
- const FunctionType& functionId)
+ const FunctionType& functionId)
{
WrtDeviceApis::Commons::AceFunction function;
auto it = m_functions.find(functionId);
function.name = it->second.first;
return function;
- };
+ }
/**
* The most useful Function
* To set param value function you may use setParamValue function
* */
static WrtDeviceApis::Commons::AceFunction getSecurityFunction(
- const FunctionType& functionId)
+ const FunctionType& functionId)
{
WrtDeviceApis::Commons::AceFunction function;
auto it = m_functions.find(functionId);
function.name = it->second.name;
- FOREACH (featIt, it->second.features)
- function.features.push_back(std::string(*featIt));
+ FOREACH(featIt, it->second.features)
+ function.features.push_back(std::string(*featIt));
FOREACH(devCapIt, it->second.devCaps) {
function.deviceCapabilities.push_back(
- getDeviceCapability(*devCapIt));
+ getDeviceCapability(*devCapIt));
}
return function;
- };
+ }
/**
* To create static map
FOREACH(functionIt, m_functions)
{
m_aceFunctions[functionIt->first] =
- getSecurityFunction(functionIt->first);
+ getSecurityFunction(functionIt->first);
}
}
strndup(featureIt->first.c_str(), featureIt->first.size() + 1);
mapping->features[i].devCaps.devCapsCount =
- featureIt->second.size();
+ featureIt->second.size();
mapping->features[i].devCaps.deviceCaps =
- new char*[mapping->features[i].devCaps.devCapsCount];
+ new char*[mapping->features[i].devCaps.devCapsCount];
for (size_t j = 0;
j < mapping->features[i].devCaps.devCapsCount;
devcaps_t* ret = NULL;
- for (size_t i = 0; i < feats->featuresCount ; ++i)
- {
+ for (size_t i = 0; i < feats->featuresCount; ++i) {
Assert(feats->features &&
feats->features[i].feature_name &&
"NULL api feature in feature mapping");
std::string feat(feats->features[i].feature_name);
- if (feature == feat)
- {
+ if (feature == feat) {
ret = &(feats->features[i].devCaps);
break;
}
static void featuresDeinitializer(feature_mapping_t* mapping)
{
- if (mapping)
- {
- if (mapping->features)
- {
- for (size_t i = 0; i < mapping->featuresCount; ++i)
- {
+ if (mapping) {
+ if (mapping->features) {
+ for (size_t i = 0; i < mapping->featuresCount; ++i) {
free(mapping->features[i].feature_name);
devcaps_t& dc = mapping->features[i].devCaps;
- if (dc.deviceCaps)
- {
- for (size_t j = 0; j < dc.devCapsCount; ++j)
- {
+ if (dc.deviceCaps) {
+ for (size_t j = 0; j < dc.devCapsCount; ++j) {
free(dc.deviceCaps[j]);
}
- delete []dc.deviceCaps;
+ delete[] dc.deviceCaps;
}
}
- delete []mapping->features;
+ delete[] mapping->features;
}
delete mapping;
}
static void getMappingInterface(feature_mapping_interface_t *mapping)
{
- if (mapping)
- {
+ if (mapping) {
mapping->featGetter =
- StaticDeclarations::getFeaturesToDevCapMapping;
+ StaticDeclarations::getFeaturesToDevCapMapping;
mapping->dcGetter = StaticDeclarations::devcapsGetter;
mapping->release = StaticDeclarations::featuresDeinitializer;
}
}
-private:
+ private:
static ParamsMap m_params;
static DeviceCapsMaps m_deviceCaps;
static FunctionsMap m_functions;
static FeaturesMap m_features;
};
-
}
}
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
/**
* synchronously checks access status and throws JS Security exception if
* necessary
break; \
} \
} while (0)
-
}
}
#endif /*WRTDEVICEAPIS_COMMONSJAVASCRIPT_JS_SECURITYEXCEPTIONS_H_ */
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
template<typename T>
class SupportPendingOperation
{
-public:
- virtual T getPendingOperation() const {
+ public:
+ virtual T getPendingOperation() const
+ {
return *m_operation;
}
- virtual void setPendingOperation(const T& operation){
+ virtual void setPendingOperation(const T& operation)
+ {
m_operation = operation;
}
- bool checkPendingOperation() const{
+ bool checkPendingOperation() const
+ {
return !m_operation.IsNull();
}
virtual ~SupportPendingOperation(){}
-protected:
+ protected:
DPL::Optional<T> m_operation;
};
-
}
}
*/
template<typename EventType>
JSObjectRef makePendingOperation(JSContextRef context,
- const DPL::SharedPtr<EventType>& event)
+ const DPL::SharedPtr<EventType>& event)
{
Commons::IEventControllerPtr eventController =
DPL::StaticPointerCast<Commons::IEventController>(event);
template<typename EventType>
JSObjectRef makeExtCancelSupportedPendingOperation(
- JSContextRef context,
- const DPL::SharedPtr<EventType>& event,
- const DPL::SharedPtr<Commons::IExternEventCanceler<EventType> >&
- cancel)
+ JSContextRef context,
+ const DPL::SharedPtr<EventType>& event,
+ const DPL::SharedPtr<Commons::IExternEventCanceler<EventType> >&
+ cancel)
{
IJSPendingOperationPrivateObject* pendingOperation =
new IJSExtCancelPendingOperationPrivateObject<EventType>(event, cancel);
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
Validator::Validator(JSContextRef context,
- JSValueRef* exception) :
+ JSValueRef* exception) :
m_context(context),
m_exception(exception)
{
}
Validator::~Validator()
-{
-}
+{}
bool Validator::isDate(const JSValueRef& arg)
{
if (JSValueIsNull(m_context,
arg) ||
JSValueIsUndefined(m_context,
- arg) || !JSValueIsObject(m_context, arg)) {
+ arg) || !JSValueIsObject(m_context, arg))
+ {
return false;
}
Converter converter(m_context);
bool
Validator::checkArrayKeys(const std::vector<std::string> &allowed,
- JSValueRef argument)
+ JSValueRef argument)
{
if (argument == NULL) {
return true;
found = false;
for (std::list<JSStringRef>::const_iterator it = allowedJS.begin();
it != allowedJS.end();
- it++) {
+ ++it)
+ {
if (JSStringIsEqual(*it,
JSPropertyNameArrayGetNameAtIndex(jsProps,
- i))) {
+ i)))
+ {
found = true;
break;
}
return (JSValueIsNull(m_context, arg) ||
JSValueIsUndefined(m_context, arg));
}
-
} // CommonsJavaScript
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace CommonsJavaScript {
-
class Validator : private DPL::Noncopyable
{
public:
explicit Validator(JSContextRef context,
- JSValueRef* exception = NULL);
+ JSValueRef* exception = NULL);
virtual ~Validator();
/**
* @return true when object's properties are subset of allowed
*/
bool checkArrayKeys(const std::vector<std::string> &allowed,
- JSValueRef argument);
+ JSValueRef argument);
bool isNullOrUndefined(const JSValueRef& arg);
* @return Converter object.
*/
static ValidatorType getValidator(JSContextRef context,
- JSValueRef* exception = NULL)
+ JSValueRef* exception = NULL)
{
C* convert = new C(context, exception);
return ValidatorType(convert);
typedef ValidatorFactory<Validator> BasicValidatorFactory;
typedef BasicValidatorFactory::ValidatorType BasicValidator;
-
} // CommonsJavaScript
} // WrtDeviceApis
#define SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_HEIGHT "height"
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
namespace WrtPlugins {
};
JSStaticValue JSSoftKeyboardChangeEvent::m_property[] = {
- { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_STATE, JSSoftKeyboardChangeEvent::getState,
+ { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_STATE,
+ JSSoftKeyboardChangeEvent::getState,
0, kJSPropertyAttributeReadOnly },
- { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_WIDTH, JSSoftKeyboardChangeEvent::getWidth,
+ { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_WIDTH,
+ JSSoftKeyboardChangeEvent::getWidth,
0, kJSPropertyAttributeReadOnly },
- { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_HEIGHT, JSSoftKeyboardChangeEvent::getHeight,
+ { SOFTKEYBOARD_CHANGE_EVENT_PROPERTY_HEIGHT,
+ JSSoftKeyboardChangeEvent::getHeight,
0, kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
-const JSClassRef JSSoftKeyboardChangeEvent::getClassRef()
+JSClassRef JSSoftKeyboardChangeEvent::getClassRef()
{
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
return &m_classInfo;
}
-JSClassRef JSSoftKeyboardChangeEvent::m_jsClassRef = JSClassCreate(JSSoftKeyboardChangeEvent::getClassInfo());
+JSClassRef JSSoftKeyboardChangeEvent::m_jsClassRef = JSClassCreate(
+ JSSoftKeyboardChangeEvent::getClassInfo());
-void JSSoftKeyboardChangeEvent::initialize(JSContextRef context, JSObjectRef object)
+void JSSoftKeyboardChangeEvent::initialize(JSContextRef /*context*/,
+ JSObjectRef object)
{
LogDebug("entered");
JSSoftKeyboardChangeEventPrivateObject* priv =
- static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(object));
+ static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(
+ object));
Assert(priv && "Missing private object");
}
{
LogDebug("entered");
JSSoftKeyboardChangeEventPrivateObject* priv =
- static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(object));
+ static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(
+ object));
delete priv;
LogDebug("private object is realised");
-
}
JSValueRef JSSoftKeyboardChangeEvent::getState(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered!");
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSSoftKeyboardChangeEvent::getWidth(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered!");
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSSoftKeyboardChangeEvent::getHeight(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
-ISoftKeyboardChangeEventPtr JSSoftKeyboardChangeEvent::getPrivateObject(JSObjectRef arg)
+ISoftKeyboardChangeEventPtr JSSoftKeyboardChangeEvent::getPrivateObject(
+ JSObjectRef arg)
{
JSSoftKeyboardChangeEventPrivateObject* priv =
- static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(arg));
+ static_cast<JSSoftKeyboardChangeEventPrivateObject*>(JSObjectGetPrivate(
+ arg));
if (!priv) {
LogError("Private object not initialized");
#undef CATCH_EXCEPTION_CONVERSION
#undef CATCH_EXCEPTION_NULL_PTR
#undef CATCH_EXCEPTION_PLATFORM_ERROR
-
}
}
namespace WrtPlugins {
namespace Tizen {
-
typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
- WrtDeviceApis::SoftKeyboardChangeEvent::Api::ISoftKeyboardChangeEventPtr>::Type
- JSSoftKeyboardChangeEventPrivateObject;
+ WrtDeviceApis::SoftKeyboardChangeEvent::Api::ISoftKeyboardChangeEventPtr>::
+ Type
+JSSoftKeyboardChangeEventPrivateObject;
class JSSoftKeyboardChangeEvent
{
/**
* This method initializes this in the JS Engine.
*/
- static const JSClassRef getClassRef();
+ static JSClassRef getClassRef();
/**
* Gets object's class description.
static JSStaticValue m_property[];
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
// getters for properties
static JSValueRef getState(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getWidth(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getHeight(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
-
- static WrtDeviceApis::SoftKeyboardChangeEvent::Api::ISoftKeyboardChangeEventPtr
- getPrivateObject(JSObjectRef arg);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+ static WrtDeviceApis::SoftKeyboardChangeEvent::Api::
+ ISoftKeyboardChangeEventPtr
+ getPrivateObject(JSObjectRef arg);
};
} // Tizen
} // WrtPlugins
#define WRT_STORAGE_EVENT_PROPERTY_STORAGE_AREA "storageArea"
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_SECURITY \
- Catch(Commons::SecurityException){\
- LogError("Security exception occured");\
- return JSDOMExceptionFactory::\
- SecurityException.make(context, exception);\
+ Catch(Commons::SecurityException){ \
+ LogError("Security exception occured"); \
+ return JSDOMExceptionFactory:: \
+ SecurityException.make(context, exception); \
}
namespace WrtPlugins {
{ 0, 0, 0, 0 }
};
-const JSClassRef JSStorageEvent::getClassRef()
+JSClassRef JSStorageEvent::getClassRef()
{
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
return &m_classInfo;
}
-JSClassRef JSStorageEvent::m_jsClassRef = JSClassCreate(JSStorageEvent::getClassInfo());
+JSClassRef JSStorageEvent::m_jsClassRef = JSClassCreate(
+ JSStorageEvent::getClassInfo());
-void JSStorageEvent::initialize(JSContextRef context,
+void JSStorageEvent::initialize(JSContextRef /*context*/,
JSObjectRef object)
{
LogDebug("entered");
delete priv;
LogDebug("private object is realised");
-
}
JSValueRef JSStorageEvent::getKey(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
Converter converter(context);
return converter.toJSValueRef(getPrivateObject(object)->getKey());
-
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSStorageEvent::getOldValue(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
DPL::OptionalString oldValue = getPrivateObject(object)->getOldValue();
- if(!oldValue) {
+ if (!oldValue) {
return JSValueMakeNull(context);
} else {
return converter.toJSValueRef(DPL::ToUTF8String(*oldValue));
}
-
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSStorageEvent::getNewValue(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
DPL::OptionalString newValue = getPrivateObject(object)->getNewValue();
- if(!newValue) {
+ if (!newValue) {
return JSValueMakeNull(context);
} else {
return converter.toJSValueRef(DPL::ToUTF8String(*newValue));
}
-
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSStorageEvent::getUrl(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
Converter converter(context);
return converter.toJSValueRef(getPrivateObject(object)->getUrl());
-
}
CATCH_EXCEPTION_CONVERSION
- CATCH_EXCEPTION_NULL_PTR
+ CATCH_EXCEPTION_NULL_PTR
}
JSValueRef JSStorageEvent::getStorageArea(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef /*object*/,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
IStorageEventPtr JSStorageEvent::getPrivateObject(JSObjectRef arg)
#undef CATCH_EXCEPTION_NULL_PTR
#undef CATCH_EXCEPTION_PLATFORM_ERROR
#undef CATCH_EXCEPTION_SECURITY
-
}
}
namespace WrtPlugins {
namespace W3C {
-
typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
WrtDeviceApis::StorageEvent::Api::IStorageEventPtr>::Type
- JSStorageEventPrivateObject;
+JSStorageEventPrivateObject;
class JSStorageEvent
{
/**
* This method initializes this in the JS Engine.
*/
- static const JSClassRef getClassRef();
+ static JSClassRef getClassRef();
/**
* Gets object's class description.
* The callback invoked when an object is first created.
*/
static void initialize(JSContextRef context,
- JSObjectRef object);
+ JSObjectRef object);
/**
* The callback invoked when an object is finalized.
static JSStaticValue m_property[];
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
// getters for properties
static JSValueRef getKey(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getOldValue(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getNewValue(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getUrl(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getStorageArea(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static WrtDeviceApis::StorageEvent::Api::IStorageEventPtr
- getPrivateObject(JSObjectRef arg);
+ getPrivateObject(JSObjectRef arg);
};
} // W3C
} // WrtPlugins
#define TIZEN_SERVICE_EVENT_PROPERTY_BUNDLE "__bundle"
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_SECURITY \
- Catch(Commons::SecurityException){\
- LogError("Security exception occured");\
- return JSDOMExceptionFactory::\
- SecurityException.make(context, exception);\
+ Catch(Commons::SecurityException){ \
+ LogError("Security exception occured"); \
+ return JSDOMExceptionFactory:: \
+ SecurityException.make(context, exception); \
}
namespace WrtPlugins {
{ 0, 0, 0, 0 }
};
-const JSClassRef JSTizenServiceEvent::getClassRef()
+JSClassRef JSTizenServiceEvent::getClassRef()
{
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
return &m_classInfo;
}
-JSClassRef JSTizenServiceEvent::m_jsClassRef = JSClassCreate(JSTizenServiceEvent::getClassInfo());
+JSClassRef JSTizenServiceEvent::m_jsClassRef = JSClassCreate(
+ JSTizenServiceEvent::getClassInfo());
-void JSTizenServiceEvent::initialize(JSContextRef context,
+void JSTizenServiceEvent::initialize(JSContextRef /*context*/,
JSObjectRef object)
{
LogDebug("entered");
JSTizenServiceEventPrivateObject* priv =
- static_cast<JSTizenServiceEventPrivateObject*>(JSObjectGetPrivate(object));
+ static_cast<JSTizenServiceEventPrivateObject*>(JSObjectGetPrivate(
+ object));
Assert(priv && "Missing private object");
}
{
LogDebug("entered");
JSTizenServiceEventPrivateObject* priv =
- static_cast<JSTizenServiceEventPrivateObject*>(JSObjectGetPrivate(object));
+ static_cast<JSTizenServiceEventPrivateObject*>(JSObjectGetPrivate(
+ object));
delete priv;
LogDebug("private object is realised");
-
}
JSValueRef JSTizenServiceEvent::getScale(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSTizenServiceEvent::getBundle(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
ITizenServiceEventPtr JSTizenServiceEvent::getPrivateObject(JSObjectRef arg)
#undef CATCH_EXCEPTION_NULL_PTR
#undef CATCH_EXCEPTION_PLATFORM_ERROR
#undef CATCH_EXCEPTION_SECURITY
-
}
}
namespace WrtPlugins {
namespace Tizen {
-
typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
WrtDeviceApis::TizenServiceEvent::Api::ITizenServiceEventPtr>::Type
- JSTizenServiceEventPrivateObject;
+JSTizenServiceEventPrivateObject;
class JSTizenServiceEvent
{
/**
* This method initializes this in the JS Engine.
*/
- static const JSClassRef getClassRef();
+ static JSClassRef getClassRef();
/**
* Gets object's class description.
* The callback invoked when an object is first created.
*/
static void initialize(JSContextRef context,
- JSObjectRef object);
+ JSObjectRef object);
/**
* The callback invoked when an object is finalized.
static JSStaticValue m_property[];
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
// getters for properties
static JSValueRef getScale(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static JSValueRef getBundle(
- JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception);
+ JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
static WrtDeviceApis::TizenServiceEvent::Api::ITizenServiceEventPtr
- getPrivateObject(JSObjectRef arg);
+ getPrivateObject(JSObjectRef arg);
};
} // Tizen
} // WrtPlugins
const char* ADD_EVENT_LISTENER_NAME = "addEventListener";
}
-namespace JavaScriptFunctions
-{
+namespace JavaScriptFunctions {
//options
- class_definition_options_t jsHookfunctionsOptions =
- {
- JS_FUNCTION,
- CREATE_INSTANCE,
- NONE_NOTICE,
- USE_OVERLAYED, //ignored
- NULL,
- NULL,
- reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptHookProc)
- };
-
- class_definition_options_t jsPrintfunctionsOptions =
- {
- JS_FUNCTION,
- CREATE_INSTANCE,
- NONE_NOTICE,
- USE_OVERLAYED, //ignored
- NULL,
- NULL,
- reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptPrintProc)
- };
-
- class_definition_options_t addEventListenerOptions =
- {
- JS_FUNCTION,
- CREATE_INSTANCE,
- ALWAYS_NOTICE,
- OVERLAYED_BEFORE_ORIGINAL,
- IFrameSupport::RegisterAddEventListener,
- NULL,
- reinterpret_cast<js_function_impl>(AddEventListenerSupport::AddEventListener)
- };
-
- js_entity_definition_t jsPrint =
- {
- JSGLOBAL_OBJECT,
- JSPRINT_NAME,
- "",
- NULL,
- NULL,
- &jsPrintfunctionsOptions
- };
-
- js_entity_definition_t jsHook =
- {
- JSGLOBAL_OBJECT,
- JSHOOK_NAME,
- "",
- NULL,
- NULL,
- &jsHookfunctionsOptions
- };
-
- js_entity_definition_t addEventListener =
- {
- JSGLOBAL_OBJECT,
- ADD_EVENT_LISTENER_NAME,
- "",
- NULL,
- NULL,
- &addEventListenerOptions
- };
- const js_entity_definition_ptr_t jsPrintPtr = &jsPrint;
- const js_entity_definition_ptr_t jsHookPtr = &jsHook;
- const js_entity_definition_ptr_t addEventListenerPtr = &addEventListener;
+class_definition_options_t jsHookfunctionsOptions = {
+ JS_FUNCTION,
+ CREATE_INSTANCE,
+ NONE_NOTICE,
+ USE_OVERLAYED, //ignored
+ NULL,
+ NULL,
+ reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptHookProc)
+};
+
+class_definition_options_t jsPrintfunctionsOptions = {
+ JS_FUNCTION,
+ CREATE_INSTANCE,
+ NONE_NOTICE,
+ USE_OVERLAYED, //ignored
+ NULL,
+ NULL,
+ reinterpret_cast<js_function_impl>(JSCFunctions::JavaScriptPrintProc)
+};
+
+class_definition_options_t addEventListenerOptions = {
+ JS_FUNCTION,
+ CREATE_INSTANCE,
+ ALWAYS_NOTICE,
+ OVERLAYED_BEFORE_ORIGINAL,
+ IFrameSupport::RegisterAddEventListener,
+ NULL,
+ reinterpret_cast<js_function_impl>(AddEventListenerSupport::
+ AddEventListener)
+};
+
+js_entity_definition_t jsPrint = {
+ JSGLOBAL_OBJECT,
+ JSPRINT_NAME,
+ "",
+ NULL,
+ NULL,
+ &jsPrintfunctionsOptions
+};
+
+js_entity_definition_t jsHook = {
+ JSGLOBAL_OBJECT,
+ JSHOOK_NAME,
+ "",
+ NULL,
+ NULL,
+ &jsHookfunctionsOptions
+};
+
+js_entity_definition_t addEventListener = {
+ JSGLOBAL_OBJECT,
+ ADD_EVENT_LISTENER_NAME,
+ "",
+ NULL,
+ NULL,
+ &addEventListenerOptions
+};
+const js_entity_definition_ptr_t jsPrintPtr = &jsPrint;
+const js_entity_definition_ptr_t jsHookPtr = &jsHook;
+const js_entity_definition_ptr_t addEventListenerPtr = &addEventListener;
}
-
bool JsFunctionManager::initialize()
{
LogInfo("JSObjectDeclaration for js functions are intialized");
namespace WrtPlugins {
namespace W3C {
-
IFrameSupport::IFramesContainer IFrameSupport::m_iframesObject =
IFrameSupport::IFramesContainer();
-
-void IFrameSupport::RegisterWidget(java_script_context_t global_context,
+void IFrameSupport::RegisterWidget(java_script_context_t /*global_context*/,
js_object_instance_t iframe,
js_object_instance_t object)
{
LogDebug("New widget instance registered");
- LogDebug("iframe: " << iframe );
- LogDebug("object: " << object );
+ LogDebug("iframe: " << iframe);
+ LogDebug("object: " << object);
getIFrameData(static_cast<JSObjectRef>(iframe))->widget =
static_cast<JSObjectRef>(object);
}
-void IFrameSupport::RegisterAddEventListener(java_script_context_t global_context,
- js_object_instance_t iframe,
- js_object_instance_t object)
+void IFrameSupport::RegisterAddEventListener(
+ java_script_context_t /*global_context*/,
+ js_object_instance_t iframe,
+ js_object_instance_t object)
{
LogDebug("New addEventListener instance registered");
- LogDebug("iframe: " << iframe );
- LogDebug("object: " << object );
+ LogDebug("iframe: " << iframe);
+ LogDebug("object: " << object);
getIFrameData(static_cast<JSObjectRef>(iframe))->addEventListener
= static_cast<JSObjectRef>(object);
}
{
FOREACH(it, m_iframesObject)
{
- if(it->second->widget == widgetObject)
- {
+ if (it->second->widget == widgetObject) {
LogDebug("iframe found");
return it->first;
}
IFrameDataPtr IFrameSupport::getIFrameData(JSObjectRef iframe)
{
auto it = m_iframesObject.find(iframe);
- if(it != m_iframesObject.end()){
+ if (it != m_iframesObject.end()) {
return it->second;
}
return m_iframesObject[iframe] = IFrameDataPtr(new IFrameData());
}
-
}
}
namespace WrtPlugins {
namespace W3C {
-
struct IFrameData
{
IFrameData() : widget(0), addEventListener(0){}
};
typedef std::shared_ptr<IFrameData> IFrameDataPtr;
-
class IFrameSupport
{
public:
private:
static IFrameDataPtr getIFrameData(JSObjectRef iframe);
};
-
}
}
* @brief
*/
-
#include <string>
#include <dpl/log/log.h>
#include <dpl/foreach.h>
namespace WrtPlugins {
namespace W3C {
-
const std::string storageEventName = "storage";
const std::string appServiceEventName = "appservice";
const std::string softKeyboardChangeEventName = "softkeyboardchange";
AddEventListenerSupport::IFramesListeners
- AddEventListenerSupport::m_listeners =
- AddEventListenerSupport::IFramesListeners();
+AddEventListenerSupport::m_listeners =
+ AddEventListenerSupport::IFramesListeners();
JSContextRef AddEventListenerSupport::m_context = NULL;
void AddEventListenerSupport::initialize(JSContextRef context)
{
- if(!m_context) m_context = context;
+ if (!m_context) {
+ m_context = context;
+ }
}
void AddEventListenerSupport::deinitialize()
{
- if(!m_context) {
+ if (!m_context) {
LogDebug("Not yet initialized");
}
m_context = NULL;
}
-bool AddEventListenerSupport::isInitialized()
+bool AddEventListenerSupport::isInitialized()
{
- return m_context!=NULL;
+ return m_context != NULL;
}
JSValueRef AddEventListenerSupport::
-AddEventListener(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
+ AddEventListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* /*exception*/)
{
LogDebug("Add event listener invoked");
LogDebug("This(iframe?):" << thisObject);
}
std::string eventName = WrtDeviceApis::CommonsJavaScript::
- Converter(context).toString(arguments[0]);
+ Converter(context).toString(arguments[0]);
LogDebug("Event name: " << eventName);
- if(eventName != storageEventName &&
- eventName != appServiceEventName &&
- eventName != softKeyboardChangeEventName) {
+ if (eventName != storageEventName &&
+ eventName != appServiceEventName &&
+ eventName != softKeyboardChangeEventName)
+ {
LogDebug("Event type not supported");
return JSValueMakeUndefined(context);
}
JSValueToObject(m_context,
arguments[1],
NULL);
- if(!JSObjectIsFunction(m_context, objectCb))
- {
+ if (!JSObjectIsFunction(m_context, objectCb)) {
LogError("JS object is not a function");
return JSValueMakeUndefined(context);
}
data.object = objectCb;
data.thisObject = thisObject;
- if(eventName == storageEventName) {
+ if (eventName == storageEventName) {
data.eventType = StorageCustomEvent;
} else if (eventName == appServiceEventName) {
data.eventType = ServiceCustomEvent;
}
void AddEventListenerSupport::
-CallStorageListenersFromDifferentIFrames(
+ CallStorageListenersFromDifferentIFrames(
JSObjectRef iframe,
const WrtDeviceApis::StorageEvent::Api::IStorageEventPtr& event)
{
FOREACH(it, m_listeners)
{
- if(it->first == iframe){
+ if (it->first == iframe) {
continue;
}
JSObjectRef eventObject =
JSObjectMake(m_context, JSStorageEvent::getClassRef(), eventPriv);
const size_t argc = 1;
- JSValueRef argv[argc] = {eventObject};
+ JSValueRef argv[argc] = { eventObject };
JSValueProtect(m_context, eventObject);
LogDebug("Call");
if (listener->eventType ==
- StorageCustomEvent)
+ StorageCustomEvent)
{
JSObjectCallAsFunction(
m_context,
}
LogDebug("Done");
-};
+}
void AddEventListenerSupport::
-CallCustomEventListenersFromIFrame(
- JSObjectRef iframe,
- CustomEventType eventType,
- JSObjectRef eventObject)
+ CallCustomEventListenersFromIFrame(
+ JSObjectRef iframe,
+ CustomEventType eventType,
+ JSObjectRef eventObject)
{
LogDebug("Invoked callbacks");
}
const size_t argc = 1;
- JSValueRef argv[argc] = {eventObject};
+ JSValueRef argv[argc] = { eventObject };
JSValueProtect(m_context, eventObject);
FOREACH(listener, *it->second)
}
JSValueUnprotect(m_context, eventObject);
LogDebug("Done");
-};
+}
AddEventListenerSupport::ListenersPtr
-AddEventListenerSupport::getIFrameListeners(JSObjectRef iframe){
+AddEventListenerSupport::getIFrameListeners(JSObjectRef iframe)
+{
auto it = m_listeners.find(iframe);
- if(it != m_listeners.end()){
+ if (it != m_listeners.end()) {
return it->second;
}
return m_listeners[iframe] = ListenersPtr(new Listeners());
}
-
}
}
namespace WrtPlugins {
namespace W3C {
-
class AddEventListenerSupport
{
public:
private:
- struct CallbackData{
- CustomEventType eventType;
+ struct CallbackData {
+ CustomEventType eventType;
JSObjectRef object;
JSObjectRef thisObject;
};
private:
static ListenersPtr getIFrameListeners(JSObjectRef iframe);
};
-
}
}
#include <js_overlay_functions.h>
namespace JSCFunctions {
-
std::string ConvertJSStringToStdString(JSStringRef value)
{
int nSize = JSStringGetLength(value) + 1;
}
JSValueRef JavaScriptHookProc(
- JSContextRef context,
- JSObjectRef /*object*/,
- JSObjectRef /*thisObject*/,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
+ JSContextRef context,
+ JSObjectRef /*object*/,
+ JSObjectRef /*thisObject*/,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
{
bool inError = false;
if (argumentCount < 2 ||
argumentCount > 3 ||
!JSValueIsString(context, arguments[0]) ||
- !JSValueIsString(context, arguments[1])) {
-
+ !JSValueIsString(context, arguments[1]))
+ {
inError = true;
}
JSObjectRef /*thisObject*/,
size_t argumentCount,
const JSValueRef arguments[],
- JSValueRef* exception);
+ JSValueRef * exception);
}
#endif
#include <js_overlay_support.h>
-namespace JSOverlaySupport
-{
-
+namespace JSOverlaySupport {
class JSFunctionDispatcher
{
public:
JSValueRef* exception);
};
-
-
JSObjectPtr createWrappedFunction(
JSGlobalContextRef ctx,
const JSObjectPtr& originalFunction,
return JSObjectPtr(new JSObject(fun));
}
-
-
JSClassDefinition JSFunctionDispatcher::m_classInfo = {
0,
kJSClassAttributeNone,
return classRef;
}
-
void JSFunctionDispatcher::initialize(JSContextRef /*context*/,
JSObjectRef /*object*/)
{
{
LogDebug("finalize");
- PrivateData* priv = static_cast<PrivateData*> (JSObjectGetPrivate(object));
- if(priv)
- {
+ PrivateData* priv = static_cast<PrivateData*>(JSObjectGetPrivate(object));
+ if (priv) {
JSValueUnprotect(priv->context,
static_cast<JSObjectRef>(
priv->overlayFunction->getObject()));
}
}
-
-
JSValueRef JSFunctionDispatcher::callAsFunction(
JSContextRef context,
JSObjectRef object,
JSFunctionDispatcher::PrivateData* priv =
static_cast<JSFunctionDispatcher::PrivateData*>
- (JSObjectGetPrivate(object));
+ (JSObjectGetPrivate(object));
- if(!priv)
- {
+ if (!priv) {
LogError("Private object is NULL");
return result;
}
//call overlayed function
- if (priv->overlayFunction->getObject())
- {
+ if (priv->overlayFunction->getObject()) {
LogDebug("Overlayed function will be invoked...");
result = JSObjectCallAsFunction(
- context,
- static_cast<JSObjectRef>(
- priv->overlayFunction->getObject()),
- thisObject,
- argumentCount,
- arguments,
- exception);
+ context,
+ static_cast<JSObjectRef>(
+ priv->overlayFunction->getObject()),
+ thisObject,
+ argumentCount,
+ arguments,
+ exception);
}
//call original function
- if (priv->originalFunction->getObject())
- {
+ if (priv->originalFunction->getObject()) {
LogDebug("Original function will be invoked..");
result = JSObjectCallAsFunction(
- context,
- static_cast<JSObjectRef>(
- priv->originalFunction->getObject()),
- thisObject,
- argumentCount,
- arguments,
- exception);
+ context,
+ static_cast<JSObjectRef>(
+ priv->originalFunction->getObject()),
+ thisObject,
+ argumentCount,
+ arguments,
+ exception);
}
LogDebug("Done");
return result;
}
-
-
-
-
}
#include <JavaScriptCore/JSObjectRef.h>
#include <Commons/JSObject.h>
-namespace JSOverlaySupport
-{
+namespace JSOverlaySupport {
JSObjectPtr createWrappedFunction(
JSGlobalContextRef ctx,
const JSObjectPtr& originalFunction,
namespace WrtPlugins {
namespace W3C {
-
// If needed, enum for new custom event should be defined here
enum CustomEventType {
StorageCustomEvent,
std::string state; // value is 'on' or 'off'
int width;
int height;
- SoftKeyboardChangeArgs():
+ SoftKeyboardChangeArgs() :
width(0),
height(0)
- {
- }
+ {}
} SoftKeyboardChangeArgs;
// If needed, argument structure of other custom events should be defined here
-
} // W3C
} // WrtPlugins
#endif // _WRT_PLUGINS_JS_OVERLAY_TYPES_H_
{
private:
AppLauncherFactory()
- {
- }
+ {}
+
public:
static AppLauncherFactory& getInstance();
IAppLauncherManagerPtr createAppLauncherManagerObject();
std::string m_applicationFullPath;
std::string m_applicationName;
std::string m_mime;
+
public:
void setMime(const std::string &value)
{
return m_applicationName;
}
virtual void clearOnCancel()
- {
- }
+ {}
EventGetDefaultApplication()
- {
- }
+ {}
};
typedef DPL::SharedPtr<EventGetDefaultApplication>
std::vector<std::string> m_applicationNames;
std::map<ApplicationType, std::string> m_applicationTypesPath;
std::map<ApplicationType, std::string> m_applicationTypesName;
+
public:
void addApplicationTypeByName(const std::pair<ApplicationType,
std::string> &value)
return m_applicationNames;
}
virtual void clearOnCancel()
- {
- }
+ {}
EventGetInstalledApplications()
- {
- }
+ {}
};
typedef DPL::SharedPtr<EventGetInstalledApplications>
{
//Uri type. http://, file://, sms:, mailto: etc
ApplicationUriType m_applicationUriType;
- // used as param to uriType, for example http address, path to file, phone number, etc
+ // used as param to uriType, for example http address, path to file, phone
+ // number, etc
std::string m_applicationUriParam;
//optional parameters for file://
std::vector<std::string> m_applicationParameters;
+
public:
void addApplicationParameter(const std::string &value)
{
return m_applicationUriParam;
}
virtual void clearOnCancel()
- {
- }
+ {}
EventLaunchApplication() : m_applicationUriType(
APPLICATION_URI_TYPE_UNDEFINED)
- {
- }
+ {}
};
typedef DPL::SharedPtr<EventLaunchApplication> EventLaunchApplicationPtr;
APPLAUNCHER_THREAD),
EventRequestReceiverLaunchApplication(Platform::ThreadEnum::
APPLAUNCHER_THREAD)
-{
-}
+{}
IAppLauncherManager::~IAppLauncherManager()
-{
-}
+{}
void IAppLauncherManager::getDefaultApplication(
- const EventGetDefaultApplicationPtr &event)
+ const EventGetDefaultApplicationPtr &event)
{
EventRequestReceiverGetDefaultApplication::PostRequest(event);
}
void IAppLauncherManager::getInstalledApplications(
- const EventGetInstalledApplicationsPtr &event)
+ const EventGetInstalledApplicationsPtr &event)
{
EventRequestReceiverGetInstalledApplications::PostRequest(event);
}
void IAppLauncherManager::launchApplication(
- const EventLaunchApplicationPtr &event)
+ const EventLaunchApplicationPtr &event)
{
EventRequestReceiverLaunchApplication::PostRequest(event);
}
IAppLauncherManager();
virtual ~IAppLauncherManager();
virtual void getDefaultApplication(
- const EventGetDefaultApplicationPtr &event);
+ const EventGetDefaultApplicationPtr &event);
virtual void getInstalledApplications(
- const EventGetInstalledApplicationsPtr &event);
+ const EventGetInstalledApplicationsPtr &event);
virtual void launchApplication(const EventLaunchApplicationPtr &event);
+
protected:
virtual void OnRequestReceived(const EventGetDefaultApplicationPtr &event)
= 0;
virtual void OnRequestReceived(
- const EventGetInstalledApplicationsPtr &event) = 0;
+ const EventGetInstalledApplicationsPtr &event) = 0;
virtual void OnRequestReceived(const EventLaunchApplicationPtr &event) = 0;
};
namespace Api {
namespace Device {
EventClamshellStateChange::EventClamshellStateChange() : m_state(CSS_CLOSE)
-{
-}
+{}
EventClamshellStateChange::~EventClamshellStateChange()
-{
-}
+{}
ClamshellState EventClamshellStateChange::getState() const
{
namespace Api {
namespace Device {
IClamshell::~IClamshell()
-{
-}
+{}
} // Device
} // Api
} // WrtPlugins
* @throw PlatformException If error in platform occurs.
*/
virtual void addOnStateChange(
- const EventClamshellStateChangeEmitterPtr& emitter) = 0;
+ const EventClamshellStateChangeEmitterPtr& emitter) = 0;
/**
* Removes on change state emitter.
* @throw PlatformException If error in platform occurs.
*/
virtual void removeOnStateChange(
- EventClamshellStateChangeEmitter::IdType id) = 0;
+ EventClamshellStateChangeEmitter::IdType id) = 0;
};
} // Device
} // Api
namespace Api {
namespace Device {
IKeypad::~IKeypad()
-{
-}
+{}
} // Device
} // Api
} // WrtPlugins
}
IManager::~IManager()
-{
-}
+{}
} // Device
} // Api
} // WrtPlugins
namespace Api {
namespace Display {
EventChangeOrientation::EventChangeOrientation() : m_orientation(O_PORTRAIT)
-{
-}
+{}
EventChangeOrientation::~EventChangeOrientation()
-{
-}
+{}
Orientation EventChangeOrientation::getOrientation() const
{
namespace Api {
namespace Display {
EventChangeState::EventChangeState() : m_state(ST_OFF)
-{
-}
+{}
EventChangeState::~EventChangeState()
-{
-}
+{}
State EventChangeState::getState() const
{
}
IManager::~IManager()
-{
-}
+{}
} // Display
} // Api
} // WrtPlugins
* @throw UnsupportedException If current platform doesn't support it.
* @throw OutOfRangeException If specified screen doesn't exist.
* @throw PlatformException If error in platform occurs.
- * @remarks On some platforms passing 0 as screen index may result in returning
+ * @remarks On some platforms passing 0 as screen index may result in
+ * returning
* some global screen interface. Other may return default screen.
* @remarks Ownership is NOT passed to the caller.
*/
namespace Api {
namespace Display {
IScreen::~IScreen()
-{
-}
+{}
} // Display
} // Api
} // WrtPlugins
* @throw PlatformException If error in platform occurs.
*/
virtual void addOnChangeOrientation(
- const EventChangeOrientationEmitterPtr& emitter) = 0;
+ const EventChangeOrientationEmitterPtr& emitter) = 0;
/**
* Removes on change size emitter.
* @throw PlatformException If error in platform occurs.
*/
virtual void removeOnChangeOrientation(
- EventChangeOrientationEmitter::IdType id) = 0;
+ EventChangeOrientationEmitter::IdType id) = 0;
/**
* Adds on change state event emitter.
m_success(false),
m_feature(feature),
m_object(0)
- {
- }
+ {}
~EventLoadFeature()
{
}
virtual void clearOnCancel()
- {
- }
+ {}
+
private:
bool m_success;
std::string m_feature;
private:
FeatureManagerFactory()
- {
- }
+ {}
~FeatureManagerFactory()
- {
- }
+ {}
};
} // namespace Api
} // namespace WrtPlugins
IFeatureManager::IFeatureManager() :
Platform::EventRequestReceiver<EventLoadFeature>(Platform::ThreadEnum::
BONDI_THREAD)
-{
-}
+{}
IFeatureManager::~IFeatureManager()
-{
-}
+{}
void IFeatureManager::loadFeature(const EventLoadFeaturePtr &event)
{
*/
virtual void loadFeature(const EventLoadFeaturePtr &event);
+
protected:
virtual void OnRequestReceived(const EventLoadFeaturePtr &event) = 0;
};
}
IEventClose() : m_result(Commons::ExceptionCodes::None)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventClose> IEventClosePtr;
{
Commons::ExceptionCodes::Enumeration m_result;
IGallerySetPtr m_galleries;
+
public:
void setResult(
- const Commons::ExceptionCodes::Enumeration &value)
+ const Commons::ExceptionCodes::Enumeration &value)
{
m_result = value;
}
IEventGetGalleries() : m_result(Commons::ExceptionCodes::None),
m_galleries(NULL)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventGetGalleries> IEventGetGalleriesPtr;
IEventGetMediaItemById() : m_result(Commons::ExceptionCodes::None),
m_id(0)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventGetMediaItemById> IEventGetMediaItemByIdPtr;
public:
void setResult(
- const Commons::ExceptionCodes::Enumeration &value)
+ const Commons::ExceptionCodes::Enumeration &value)
{
m_result = value;
}
}
IEventGetMediaItems() : m_result(Commons::ExceptionCodes::None)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventGetMediaItems> IEventGetMediaItemsPtr;
public:
void setResult(
- const Commons::ExceptionCodes::Enumeration &value)
+ const Commons::ExceptionCodes::Enumeration &value)
{
m_result = value;
}
}
IEventOpen() : m_result(Commons::ExceptionCodes::None)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventOpen> IEventOpenPtr;
}
IEventRefresh() : m_result(Commons::ExceptionCodes::None)
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventRefresh> IEventRefreshPtr;
namespace Api {
namespace Gallery {
IGallery::IGallery()
-{
-}
+{}
IGallery::~IGallery()
-{
-}
+{}
} // Gallery
} // Api
} // WrtPlugins
}
void IGalleryRequestManager::getMediaItemById(
- const IEventGetMediaItemByIdPtr &event)
+ const IEventGetMediaItemByIdPtr &event)
{
EventRequestReceiver< IEventGetMediaItemById >::PostRequest(event);
}
ERRChangeView(Platform::ThreadEnum::GALLERY_THREAD),
ERRGetMediaItems(Platform::ThreadEnum::GALLERY_THREAD),
ERRGetMediaItemById(Platform::ThreadEnum::GALLERY_THREAD)
- {
- }
+ {}
virtual ~IGalleryRequestManager()
- {
- }
+ {}
virtual void getGalleries(const IEventGetGalleriesPtr &event);
virtual void open(const IEventOpenPtr &event);
{
protected:
GalleryFactory()
- {
- }
+ {}
+
public:
static GalleryFactory& getInstance();
IGalleryRequestManagerPtr getGalleryManager();
IMediaItem() : m_id(0),
m_type(UNDEFINED),
m_date(0)
- {
- }
+ {}
virtual ~IMediaItem()
- {
- }
+ {}
virtual const std::string &getFileName() const
{
}
void IViewProperties::setPrimarySortOrder(
- IViewProperties::SortOrder primarySortOrder)
+ IViewProperties::SortOrder primarySortOrder)
{
if (primarySortOrder < NONE || primarySortOrder > BY_TYPE) {
Throw(Commons::InvalidArgumentException);
}
void IViewProperties::setSecondarySortOrder(
- IViewProperties::SortOrder secondarySortOrder)
+ IViewProperties::SortOrder secondarySortOrder)
{
if (secondarySortOrder < NONE || secondarySortOrder > BY_TYPE) {
Throw(Commons::InvalidArgumentException);
m_secondarySortOrder(NONE),
m_startDate(0),
m_endDate(0)
-{
-}
+{}
} // Gallery
} // Api
} // WrtPlugins
}
EventGetCurrentPosition()
- {
- }
+ {}
};
typedef DPL::SharedPtr<EventGetCurrentPosition> EventGetCurrentPositionPtr;
}
EventPositionChanged()
- {
- }
+ {}
};
typedef DPL::SharedPtr<EventPositionChanged> EventPositionChangedPtr;
}
GeolocationFactory::GeolocationFactory()
-{
-}
+{}
}
}
}
IGeolocation::IGeolocation() :
EventRequestReceiver<EventGetCurrentPosition>(ThreadEnum::
GEOLOCATION_THREAD)
-{
-}
+{}
IGeolocation::~IGeolocation()
-{
-}
+{}
}
}
}
* @exception Commons::PlatformException when platform error occurs
*/
virtual long watchPosition(const EventPositionChangedEmitterPtr& emitter,
- long timeout,
- long maximumAge,
- bool highAccuracy) = 0;
+ long timeout,
+ long maximumAge,
+ bool highAccuracy) = 0;
/**
* Stopping periodic location updates started with watchPosition
* Choses location method
* @param method A location method
* @exception Commons::PlatformException when platform error occurs
- * @remarks does nothing when executed with the same method as currently used
+ * @remarks does nothing when executed with the same method as currently
+ * used
*/
virtual void changeLocationMethod(ApiLocationMethod method) = 0;
speed(0.0),
direction(0.0),
altitudeSpeed(0.0)
- {
- }
+ {}
};
typedef DPL::SharedPtr<PositionProperties> PositionPropertiesPtr;
}
IManager::~IManager()
-{
-}
+{}
} // Memory
} // Api
} // WrtPlugins
namespace Api {
namespace System {
IDate::~IDate()
-{
-}
+{}
} // System
} // Api
} // WrtPlugins
}
IEnvironment::~IEnvironment()
-{
-}
+{}
} // System
} // Api
} // WrtPlugins
{
bool m_result;
LogFilterPtr m_filter;
+
public:
void setFilter(LogFilterPtr value)
{
return m_result;
}
virtual void clearOnCancel()
- {
- }
+ {}
IEventClearLog() : m_result(false)
- {
- }
+ {}
~IEventClearLog()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventClearLog> IEventClearLogPtr;
{
bool m_result;
LogFilterPtr m_filter;
+
public:
void setFilter(LogFilterPtr value)
{
return m_result;
}
virtual void clearOnCancel()
- {
- }
+ {}
IEventDeleteLogEntry() : m_result(false)
- {
- }
+ {}
~IEventDeleteLogEntry()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventDeleteLogEntry> IEventDeleteLogEntryPtr;
LogFilterPtr m_filter;
int m_firstCall;
int m_lastCall;
+
public:
void setFirstCall(int value)
{
return m_result;
}
virtual void clearOnCancel()
- {
- }
+ {}
IEventFindLogEntries() : m_result(false),
m_firstCall(0),
m_lastCall(-1)
- {
- }
+ {}
~IEventFindLogEntries()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventFindLogEntries> IEventFindLogEntriesPtr;
bool m_result;
int m_numberOfLogs;
LogFilterPtr m_filter;
+
public:
void setFilter(LogFilterPtr value)
{
return m_result;
}
virtual void clearOnCancel()
- {
- }
+ {}
IEventGetNumberOfLogs() : m_result(false),
m_numberOfLogs(0)
- {
- }
+ {}
~IEventGetNumberOfLogs()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventGetNumberOfLogs> IEventGetNumberOfLogsPtr;
EventRequestReceiverFindLogEntries(Platform::ThreadEnum::TELEPHONY_THREAD),
EventRequestReceiverDeleteLogEntry(Platform::ThreadEnum::TELEPHONY_THREAD),
EventRequestReceiverClearLogs(Platform::ThreadEnum::TELEPHONY_THREAD)
-{
-}
+{}
ILogManager::~ILogManager()
-{
-}
+{}
void ILogManager::getNumberOfLogs(const IEventGetNumberOfLogsPtr &event)
{
virtual void findLogEntries(const IEventFindLogEntriesPtr &event);
virtual void deleteLogEntry(const IEventDeleteLogEntryPtr &event);
virtual void clearLogs(const IEventClearLogPtr &event);
+
protected:
virtual void OnRequestReceived(
- const IEventGetNumberOfLogsPtr &event) = 0;
+ const IEventGetNumberOfLogsPtr &event) = 0;
virtual void OnRequestReceived(const IEventFindLogEntriesPtr &event)
= 0;
virtual void OnRequestReceived(const IEventDeleteLogEntryPtr &event)
m_startTime(0),
m_duration(0),
m_folder(LogEntry::INVALID_FOLDER)
-{
-}
+{}
LogEntry::~LogEntry()
-{
-}
+{}
int LogEntry::getId() const
{
MISSED_CALLS_FOLDER,
INITIATED_CALLS_FOLDER,
INVALID_FOLDER = 10000,
- UNDEFINED_FOLDER /* should be used only to mark a fact filter is not set */
+ UNDEFINED_FOLDER /* should be used only to mark a fact filter
+ *is not set */
} LogFolder;
LogEntry();
m_durationMax(LOG_FILTER_UNDEFINED_DURATION),
m_phoneNumberIsSet(false),
m_descriptionIsSet(false)
-{
-}
+{}
LogFilter::~LogFilter()
-{
-}
+{}
int
LogFilter::getIdFilter() const
{
private:
TelephonyFactory()
- {
- }
+ {}
+
public:
static TelephonyFactory& getInstance();
ILogManagerPtr createLogManagerObject();
ThreadEnum
::
UI_THREAD)
- {
- }
+ {}
virtual void OnRequestReceived(
- const DPL::SharedPtr<IEventSetWallpaper> &event) = 0;
+ const DPL::SharedPtr<IEventSetWallpaper> &event) = 0;
virtual void OnRequestReceived(
- const DPL::SharedPtr<IEventSetCallRingtone> &event) = 0;
+ const DPL::SharedPtr<IEventSetCallRingtone> &event) = 0;
virtual void OnRequestReceived(
- const DPL::SharedPtr<IEventSetMessageRingtone> &event) = 0;
+ const DPL::SharedPtr<IEventSetMessageRingtone> &event) = 0;
+
public:
virtual void setWallpaper(DPL::SharedPtr<IEventSetWallpaper> &event)
{
PostRequest(event);
}
virtual void setMessageRingtone(
- DPL::SharedPtr<IEventSetMessageRingtone> &event)
+ DPL::SharedPtr<IEventSetMessageRingtone> &event)
{
PostRequest(event);
}
virtual ~IPreferences()
- {
- }
+ {}
};
//============================================================
} //namespace
{
public:
IEventSetWallpaper()
- {
- }
+ {}
virtual ~IEventSetWallpaper()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventSetWallpaper> IEventSetWallpaperPtr;
//=========================================================================
{
public:
IEventSetCallRingtone()
- {
- }
+ {}
virtual ~IEventSetCallRingtone()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventSetCallRingtone> IEventSetCallRingtonePtr;
//=========================================================================
{
public:
IEventSetMessageRingtone()
- {
- }
+ {}
virtual ~IEventSetMessageRingtone()
- {
- }
+ {}
};
typedef DPL::SharedPtr<IEventSetMessageRingtone> IEventSetMessageRingtonePtr;
//=========================================================================
{
private:
UIFactory()
- {
- }
+ {}
+
public:
static UIFactory& getInstance();
};
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
enum LocationType
{
LT_APPS,
enum AccessMode
{
- AM_READ = 0x0001,
- AM_WRITE = 0x0002,
- AM_APPEND = 0x0004
+ AM_READ = 0x0001,
+ AM_WRITE = 0x0002,
+ AM_APPEND = 0x0004
};
/**
*/
enum AccessType
{
- AT_EXISTS = 0x0000, //!< AT_EXISTS - checks for existence
- AT_READ = 0x0001, //!< AT_READ - checks for read access
- AT_WRITE = 0x0002, //!< AT_WRITE - checks for write access
- AT_EXEC = 0x0004 //!< AT_EXEC - checks for execution access
+ AT_READ = 0x0001, //!< AT_READ - checks for read access
+ AT_WRITE = 0x0002, //!< AT_WRITE - checks for write access
+ AT_EXEC = 0x0004, //!< AT_EXEC - checks for execution access
+ AT_EXISTS = 0x0008 //!< AT_EXISTS - checks for existence
};
enum Permissions
{
- PERM_NONE = 0x0000,
- PERM_READ = 0x0001,
- PERM_WRITE = 0x0002
+ PERM_NONE = 0x0000,
+ PERM_READ = 0x0001,
+ PERM_WRITE = 0x0002
};
enum PlatformMode
{
- PM_USER_READ = 0x0100,
- PM_USER_WRITE = 0x0080,
- PM_USER_EXEC = 0x0040,
- PM_GROUP_READ = 0x0020,
- PM_GROUP_WRITE = 0x0010,
- PM_GROUP_EXEC = 0x0008,
- PM_OTHER_READ = 0x0004,
- PM_OTHER_WRITE = 0x0002,
- PM_OTHER_EXEC = 0x0001,
- PM_NONE = 0x0000
+ PM_USER_READ = 0x0100,
+ PM_USER_WRITE = 0x0080,
+ PM_USER_EXEC = 0x0040,
+ PM_GROUP_READ = 0x0020,
+ PM_GROUP_WRITE = 0x0010,
+ PM_GROUP_EXEC = 0x0008,
+ PM_OTHER_READ = 0x0004,
+ PM_OTHER_WRITE = 0x0002,
+ PM_OTHER_EXEC = 0x0001,
+ PM_NONE = 0x0000
};
enum Options
{
- OPT_NONE = 0x0000,
- OPT_OVERWRITE = 0x0001,
- OPT_RECURSIVE = 0x0002
+ OPT_NONE = 0x0000,
+ OPT_OVERWRITE = 0x0001,
+ OPT_RECURSIVE = 0x0002
};
enum FindFilter
FF_SIZE
};
typedef std::map<FindFilter, std::string> FiltersMap;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventCopy::EventCopy(const IPathPtr& src,
const IPathPtr& dest) :
m_src(src),
{
m_options = options;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventCopy : public Commons::IEvent<EventCopy>
{
public:
* @return New object.
*/
EventCopy(const IPathPtr& src,
- const IPathPtr& dest);
+ const IPathPtr& dest);
/**
* Gets destination path.
IPathPtr m_src; ///< Source path.
IPathPtr m_dest; ///< Destination path.
INodePtr m_result; ///< Result node.
- int m_options; ///< Options for copy action @see WrtDeviceApis::Api::Filesystem::Options.
+ int m_options; ///< Options for copy action @see
+ // WrtDeviceApis::Api::Filesystem::Options.
};
typedef DPL::SharedPtr<EventCopy> EventCopyPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventFind::EventFind(const IPathPtr& path) : m_path(path)
-{
-}
+{}
IPathPtr EventFind::getPath() const
{
}
void EventFind::addFilter(FindFilter name,
- const std::string& value)
+ const std::string& value)
{
m_filters.insert(std::pair<FindFilter, std::string>(name, value));
}
{
return m_filters;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventFind : public Commons::IEvent<EventFind>
{
public:
* @param value Filter value.
*/
void addFilter(FindFilter name,
- const std::string& value);
+ const std::string& value);
/**
* Gets all filters.
};
typedef DPL::SharedPtr<EventFind> EventFindPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventListNodes::EventListNodes(const INodePtr& node) : m_node(node)
{
Assert(m_node && "Node can't be NULL.");
{
m_list = list;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventListNodes : public Commons::IEvent<EventListNodes>
{
public:
};
typedef DPL::SharedPtr<EventListNodes> EventListNodesPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventMove::EventMove(const IPathPtr& src,
const IPathPtr& dest) :
m_src(src),
{
m_options = options;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventMove : public Commons::IEvent<EventMove>
{
public:
* @return New object.
*/
EventMove(const IPathPtr& src,
- const IPathPtr& dest);
+ const IPathPtr& dest);
/**
* Gets destination path.
IPathPtr m_src; ///< Source path.
IPathPtr m_dest; ///< Destination path.
INodePtr m_result; ///< Result node.
- int m_options; ///< Options for copy action @see WrtDeviceApis::Api::Filesystem::Options.
+ int m_options; ///< Options for copy action @see
+ // WrtDeviceApis::Api::Filesystem::Options.
};
typedef DPL::SharedPtr<EventMove> EventMovePtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventOpen::EventOpen(int mode) : m_mode(mode)
-{
-}
+{}
int EventOpen::getMode() const
{
{
m_stream = stream;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventOpen : public Commons::IEvent<EventOpen>
{
public:
};
typedef DPL::SharedPtr<EventOpen> EventOpenPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
std::string EventReadText::getResult() const
{
return m_result;
{
m_result = result;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventReadText : public Commons::IEvent<EventReadText>
{
public:
};
typedef DPL::SharedPtr<EventReadText> EventReadTextPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventRemove::EventRemove(const IPathPtr& path) :
m_path(path),
m_options(OPT_NONE)
{
m_options = options;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventRemove : public Commons::IEvent<EventRemove>
{
public:
private:
IPathPtr m_path; ///< Source path.
- int m_options; ///< Options for remove action @see WrtDeviceApis::Api::Filesystem::Options.
+ int m_options; ///< Options for remove action @see
+ // WrtDeviceApis::Api::Filesystem::Options.
};
typedef DPL::SharedPtr<EventRemove> EventRemovePtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
EventResolve::EventResolve(const IPathPtr& path) : m_path(path)
-{
-}
+{}
IPathPtr EventResolve::getPath() const
{
{
m_node = node;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class EventResolve : public Commons::IEvent<EventResolve>
{
public:
};
typedef DPL::SharedPtr<EventResolve> EventResolvePtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
IManager& IManager::getInstance()
{
static Manager instance;
Commons::ThreadEnum::FILESYSTEM_THREAD),
Commons::EventRequestReceiver<EventFind>(
Commons::ThreadEnum::FILESYSTEM_THREAD)
-{
-}
+{}
IManager::~IManager()
-{
-}
-
+{}
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
typedef std::vector<IPathPtr> LocationPaths;
typedef std::vector<LocationType> LocationTypes;
/**
* Gets path for specified location type.
- * @param type Location type @see WrtDeviceApis::Api::Filesystem::LocationType.
+ * @param type Location type @see
+ * WrtDeviceApis::Api::Filesystem::LocationType.
* @return Valid path or empty shared pointer.
*/
virtual IPathPtr getLocationPath(LocationType type) const = 0;
/**
* Checks if node at specified path has supplied access rights.
* @param path Path to the node.
- * @param accessType Access right(s) to check @see AccessType. Multiple values
+ * @param accessType Access right(s) to check @see AccessType. Multiple
+ * values
* can be passed using OR operator.
- * @return True if specified node has supplied access rights, false otherwise.
+ * @return True if specified node has supplied access rights, false
+ * otherwise.
*/
virtual bool access(const IPathPtr& path,
- int accessType) const = 0;
+ int accessType) const = 0;
virtual void addOpenedNode(const INodePtr& node) = 0;
virtual void removeOpenedNode(const INodePtr& node) = 0;
virtual void OnRequestReceived(const EventRemovePtr& event) = 0;
virtual void OnRequestReceived(const EventFindPtr& event) = 0;
}; // IManager
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
INode::INode() :
Commons::EventRequestReceiver<EventListNodes>(
Commons::ThreadEnum::FILESYSTEM_THREAD),
Commons::ThreadEnum::FILESYSTEM_THREAD),
Commons::EventRequestReceiver<EventReadText>(
Commons::ThreadEnum::FILESYSTEM_THREAD)
-{
-}
+{}
INode::~INode()
-{
-}
-
+{}
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class INode :
public Commons::EventRequestReceiver<EventListNodes>,
public Commons::EventRequestReceiver<EventOpen>,
* @deprecated
*/
virtual NodeList getChildNodes(const NodeFilterPtr& filter =
- NodeFilterPtr()) const /* WRT_PLUGINS_DEPRECATED */ = 0;
+ NodeFilterPtr()) const /*DEPREC*/ = 0;
/**
* Gets list of direct descendant nodes.
* - OPT_RECURSIVE - attempt to create all necessary sub-directories
*/
virtual INodePtr createChild(const IPathPtr& path,
- NodeType type,
- int options = OPT_NONE) = 0;
+ NodeType type,
+ int options = OPT_NONE) = 0;
/**
* Gets size of this node.
protected:
INode();
};
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class INode;
typedef DPL::SharedPtr<INode> INodePtr;
typedef std::vector<INodePtr> NodeList;
typedef NodeList::iterator NodeListIterator;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
IPathPtr IPath::create(const std::string& str)
{
return Path::create(str);
}
IPath::~IPath()
-{
-}
-
+{}
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-namespace Api{
-
+namespace Api {
class IPath;
typedef DPL::SharedPtr<IPath> IPathPtr;
};
inline const IPathPtr operator+(const IPath& lhs,
- const IPath& rhs)
+ const IPath& rhs)
{
return IPath::create(lhs.getFullPath())->append(rhs.getFullPath());
}
inline const IPathPtr operator+(const IPath& lhs,
- const std::string& rhs)
+ const std::string& rhs)
{
return IPath::create(lhs.getFullPath())->append(rhs);
}
inline const IPathPtr operator+(const std::string& lhs,
- const IPath& rhs)
+ const IPath& rhs)
{
return IPath::create(lhs)->append(rhs.getFullPath());
}
{
return (lhs != rhs.getFullPath());
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
IStream::~IStream()
-{
-}
-
+{}
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
class IStream;
typedef DPL::SharedPtr<IStream> IStreamPtr;
*/
virtual long getSize() const = 0;
};
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
OptionalString NodeFilter::getName() const
{
return m_name;
{
m_size.min = m_size.max = size;
}
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
namespace Api {
-
typedef DPL::Optional<std::string> OptionalString;
typedef DPL::Optional<std::time_t> OptionalDate;
typedef DPL::Optional<std::size_t> OptionalSize;
};
typedef DPL::SharedPtr<NodeFilter> NodeFilterPtr;
-
} // API
} // Filesystem
} // WrtDeviceApis
namespace Filesystem {
namespace Api {
namespace PathUtils {
-
PathList getParts(const IPathPtr& path)
{
PathList result;
}
return result;
}
-
} // PathUtils
} // API
} // Filesystem
namespace Filesystem {
namespace Api {
namespace PathUtils {
-
typedef std::vector<IPathPtr> PathList;
typedef PathList::iterator PathListIterator;
* @return List of paths.
*/
PathList getParts(const IPathPtr& path);
-
} // PathUtils
} // API
} // Filesystem
namespace WrtDeviceApis {
namespace LocalStorage {
namespace Api {
-
class ILocalStorage
{
public:
*
*/
virtual DPL::Optional<std::string> getValue(
- const std::string& key) const = 0;
+ const std::string& key) const = 0;
/**
* Clears the local storage
* @param removeReadOnly - true -remove all elements
- * false - ommit items which have read only flag set
+ * false - ommit items which have read only flag
+ * set
*/
virtual void clear(bool removeReadOnly) = 0;
/**
* Get number of elements in local storage
* @param removeReadOnly - true -remove all elements
- * false - ommit items which have read only flag set
+ * false - ommit items which have read only flag
+ * set
*/
virtual size_t getStorageSize() const = 0;
* virtual destructor
*/
virtual ~ILocalStorage()
- {
- }
-
+ {}
};
typedef DPL::SharedPtr<ILocalStorage> ILocalStoragePtr;
-
} // Api
} // LocalStorage
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace LocalStorage {
namespace Api {
-
ILocalStoragePtr getLocalStorage(int widgetId)
{
return ILocalStoragePtr(new WrtDeviceApis::WidgetInterfaceDAO(widgetId));
}
-
} // Api
} // LocalStorage
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace LocalStorage {
namespace Api {
-
ILocalStoragePtr getLocalStorage(int widgetId);
-
} // Api
} // LocalStorage
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Networking {
-namespace Api {
-} // Api
+namespace Api {} // Api
} // Networking
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Networking {
-namespace Api {
-} // Api
+namespace Api {} // Api
} // Networking
} // WrtDeviceApis
namespace Networking {
namespace Api {
IAdapter::~IAdapter()
-{
-}
+{}
} // Api
} // Networking
} // WrtDeviceApis
namespace Networking {
namespace Api {
IConnection::~IConnection()
-{
-}
+{}
} // Api
} // Networking
} // WrtDeviceApis
}
IManager::~IManager()
-{
-}
+{}
} // Api
} // Networking
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace PluginManager {
namespace Api {
-
class IPluginManager
{
public:
};
typedef DPL::SharedPtr<IPluginManager> IPluginManagerPtr;
-
}
}
}
namespace WrtDeviceApis {
namespace PluginManager {
namespace Api {
-
PluginManagerFactory::PluginManagerFactory()
-{
-}
+{}
PluginManagerFactory& PluginManagerFactory::getInstance()
{
}
IPluginManagerPtr PluginManagerFactory::getPluginManager(
- int widgetHandle,
- const std::string &objectUri,
- JSObjectRef object,
- JSContextRef context) const
+ int widgetHandle,
+ const std::string &objectUri,
+ JSObjectRef object,
+ JSContextRef context) const
{
return IPluginManagerPtr(
- new PluginManager(widgetHandle, objectUri, object, context));
+ new PluginManager(widgetHandle, objectUri, object, context));
}
-
}
}
}
namespace WrtDeviceApis {
namespace PluginManager {
namespace Api {
-
class PluginManagerFactory : private DPL::Noncopyable
{
-public:
+ public:
static PluginManagerFactory& getInstance();
IPluginManagerPtr getPluginManager(
int widgetHandle,
const std::string &objectUri,
JSObjectRef object,
JSContextRef context) const;
-private:
+
+ private:
PluginManagerFactory();
};
-
}
}
}
namespace WrtDeviceApis {
namespace SoftKeyboardChangeEvent {
namespace Api {
-
class ISoftKeyboardChangeEvent
{
- public :
+ public:
virtual std::string getState() const = 0;
virtual int getWidth() const = 0;
virtual int getHeight() const = 0;
- virtual ~ISoftKeyboardChangeEvent() {};
+ virtual ~ISoftKeyboardChangeEvent() {}
};
typedef std::shared_ptr<ISoftKeyboardChangeEvent> ISoftKeyboardChangeEventPtr;
-
} // Api
} // SoftKeyboardChangeEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace SoftKeyboardChangeEvent {
namespace Api {
-
SoftKeyboardChangeEvent::SoftKeyboardChangeEvent(
- std::string state, int width, int height):
+ std::string state, int width, int height) :
m_state(state), m_width(width), m_height(height)
-{
-}
+{}
SoftKeyboardChangeEvent::~SoftKeyboardChangeEvent()
-{
-}
+{}
std::string SoftKeyboardChangeEvent::getState() const
{
{
return m_height;
}
-
} // Api
} // SoftKeyboardChangeEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace SoftKeyboardChangeEvent {
namespace Api {
-
class SoftKeyboardChangeEvent : public ISoftKeyboardChangeEvent
{
- public :
+ public:
explicit SoftKeyboardChangeEvent(
- std::string state,
- int width,
- int height);
+ std::string state,
+ int width,
+ int height);
~SoftKeyboardChangeEvent();
std::string getState() const;
int getWidth() const;
int getHeight() const;
- private :
+ private:
std::string m_state;
int m_width;
int m_height;
};
-
} // Api
} // SoftKeyboardChangeEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace StorageEvent {
namespace Api {
-
class IStorageEvent
{
- public :
+ public:
virtual std::string getKey() const = 0;
virtual DPL::OptionalString getOldValue() const = 0;
virtual void setNewValue(const std::string &inValue) = 0;
virtual void setUrl(const std::string &inUrl) = 0;
virtual void setStorageArea(
- const LocalStorage::Api::ILocalStoragePtr &inStorageArea) = 0;
+ const LocalStorage::Api::ILocalStoragePtr &inStorageArea) = 0;
};
typedef DPL::SharedPtr<IStorageEvent> IStorageEventPtr;
-
} // Api
} // StorageEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace StorageEvent {
namespace Api {
-
StorageEvent::StorageEvent() :
m_storageArea(NULL) {}
StorageEvent::StorageEvent(
- const LocalStorage::Api::ILocalStoragePtr &storageArea) :
+ const LocalStorage::Api::ILocalStoragePtr &storageArea) :
m_storageArea(storageArea) {}
std::string StorageEvent::getKey() const
}
void StorageEvent::setStorageArea(
- const LocalStorage::Api::ILocalStoragePtr &inStorageArea)
+ const LocalStorage::Api::ILocalStoragePtr &inStorageArea)
{
m_storageArea = inStorageArea;
}
-
} // Api
} // StorageEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace StorageEvent {
namespace Api {
-
class StorageEvent : public IStorageEvent
{
- public :
+ public:
StorageEvent();
explicit StorageEvent(
- const LocalStorage::Api::ILocalStoragePtr &storageArea);
+ const LocalStorage::Api::ILocalStoragePtr &storageArea);
std::string getKey() const;
DPL::OptionalString getOldValue() const;
void setNewValue(const std::string &inValue);
void setUrl(const std::string &inUrl);
void setStorageArea(
- const LocalStorage::Api::ILocalStoragePtr &inStorageArea);
+ const LocalStorage::Api::ILocalStoragePtr &inStorageArea);
- private :
+ private:
std::string m_key;
DPL::OptionalString m_oldValue;
DPL::OptionalString m_newValue;
std::string m_url;
LocalStorage::Api::ILocalStoragePtr m_storageArea;
};
-
} // Api
} // StorageEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace StorageEvent {
namespace Api {
-
IStorageEventPtr getStorageEvent()
{
return IStorageEventPtr(new StorageEvent());
}
-
} // Api
} // StorageEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace StorageEvent {
namespace Api {
-
IStorageEventPtr getStorageEvent();
-
} // Api
} // StorageEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace TizenServiceEvent {
namespace Api {
-
class ITizenServiceEvent
{
- public :
+ public:
virtual float getScale() const = 0;
virtual std::string getBundle() const = 0;
virtual void setScale(const float scale) = 0;
virtual void setBundle(const std::string &bundle) = 0;
- virtual ~ITizenServiceEvent() {};
+ virtual ~ITizenServiceEvent() {}
};
typedef DPL::SharedPtr<ITizenServiceEvent> ITizenServiceEventPtr;
-
} // Api
} // TizenServiceEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace TizenServiceEvent {
namespace Api {
-
-TizenServiceEvent::TizenServiceEvent()
-{
-}
+TizenServiceEvent::TizenServiceEvent() :
+ m_scale(0)
+{}
TizenServiceEvent::~TizenServiceEvent()
-{
-}
+{}
float TizenServiceEvent::getScale() const
{
{
m_bundle = bundle;
}
-
} // Api
} // TizenServiceEvent
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace TizenServiceEvent {
namespace Api {
-
class TizenServiceEvent : public ITizenServiceEvent
{
- public :
+ public:
TizenServiceEvent();
~TizenServiceEvent();
void setScale(const float scale);
void setBundle(const std::string &bundle);
- private :
+ private:
float m_scale;
std::string m_bundle;
};
-
} // Api
} // TizenServiceEvent
} // WrtDeviceApis
#include <dpl/shared_ptr.h>
-namespace WrtDeviceApis{
-namespace Widget{
+namespace WrtDeviceApis {
+namespace Widget {
namespace Api {
-
class IWidget;
typedef DPL::SharedPtr<IWidget> IWidgetPtr;
virtual unsigned int getWidth() const = 0;
virtual ~IWidget()
- {
- }
+ {}
};
-
}
}
}
namespace WrtDeviceApis {
namespace Widget {
namespace Api {
-
IWidgetPtr WidgetFactory::createWidget()
{
return IWidgetPtr(new WrtDeviceApis::Widget::Widget());
}
-
}
}
}
namespace WrtDeviceApis {
namespace Widget {
namespace Api {
-
class WidgetFactory : private DPL::Noncopyable
{
public:
private:
WidgetFactory()
- {
- }
+ {}
};
-
}
}
}
namespace WrtDeviceApis {
namespace WidgetDB {
namespace Api {
-
class IWidgetDB;
typedef DPL::SharedPtr<IWidgetDB> IWidgetDBPtr;
typedef std::vector<IWidgetFeaturePtr> Features;
-enum class ConfigAttribute {
+enum class ConfigAttribute
+{
ID,
VERSION,
DESCRIPTION,
STATUS_UNINSTALLED
};
-
class IWidgetDB
{
public:
virtual std::string getUserAgent() const = 0;
virtual InstallationStatus checkInstallationStatus(
- const std::string& gid,
- const std::string& name,
- const std::string& version) const = 0;
+ const std::string& gid,
+ const std::string& name,
+ const std::string& version) const = 0;
virtual Features getWidgetFeatures() const = 0;
virtual std::string getWidgetTemporaryStoragePath() const = 0;
virtual ~IWidgetDB()
- {
- }
-
+ {}
};
-
} // Api
} // WidgetDB
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace WidgetDB {
namespace Api {
-
class IWidgetFeature
{
public:
public:
virtual ~IWidgetFeature()
- {
- }
+ {}
virtual std::string getName() const = 0;
virtual Params getParams() const = 0;
virtual void addParam(const std::string& paramName,
- const std::string& paramValue) = 0;
+ const std::string& paramValue) = 0;
virtual bool isRequestedByWidget() const = 0;
};
typedef DPL::SharedPtr<IWidgetFeature> IWidgetFeaturePtr;
-
} // Api
} // WidgetDB
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace WidgetDB {
namespace Api {
-
IWidgetDBPtr getWidgetDB(int widgetId)
{
return IWidgetDBPtr(new WrtDeviceApis::WidgetDB::WidgetDB(widgetId));
}
-
} // Api
} // WidgetDB
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace WidgetDB {
namespace Api {
-
IWidgetDBPtr getWidgetDB(int widgetId);
-
} // Api
} // WidgetDB
} // WrtDeviceApis
const char* HTTP_ADDRESS_PATTERN = "^(http(s)?://)?\\w+.*$";
const char* FILE_ADDRESS_PATTERN = "^.*\\..*$";
-const char* APPLICATION_ALARM = "org.tizen.clock"; // alarm has been included in clock app
+const char* APPLICATION_ALARM = "org.tizen.clock"; // alarm has been
+ // included in clock app
const char* APPLICATION_BROWSER = "org.tizen.browser";
const char* APPLICATION_CALCULATOR = "org.tizen.calculator";
const char* APPLICATION_CALENDAR = "org.tizen.efl-calendar";
APPLICATION_TYPE_WIDGET_MANAGER,
APPLICATION_EMPTY));
- bool registered_application = false; // A variable that gets set if the current pkg_name is needed by WAC spec, needless of weather the package is visible or not.
+ bool registered_application = false; // A variable that gets set if the
+ // current pkg_name is needed by WAC
+ // spec, needless of weather the
+ // package is visible or not.
app_info info = {};
unsigned int count = record_count(COUNT_MENU, &info);
LogDebug("number of registered applications: " << count);
LogDebug("app_name " << infoAll.Get()[i].app_name);
registered_application = false;
if (infoAll.Get()[i].app_path == NULL ||
- infoAll.Get()[i].app_name == NULL) {
+ infoAll.Get()[i].app_name == NULL)
+ {
LogDebug("Not Registered.");
LogDebug("-----");
continue;
}
if (0 ==
strncmp(APPLICATION_ALARM, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_ALARM] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_ALARM] =
}
if (0 ==
strncmp(APPLICATION_BROWSER, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_BROWSER] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_BROWSER] =
}
if (0 ==
strncmp(APPLICATION_CALCULATOR, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_CALCULATOR] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_CALCULATOR] =
}
if (0 ==
strncmp(APPLICATION_CALENDAR, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_CALENDAR] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_CALENDAR] =
}
if (0 ==
strncmp(APPLICATION_CAMERA, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_CAMERA] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_CAMERA] =
}
if (0 ==
strncmp(APPLICATION_CONTACTS, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_CONTACTS] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_CONTACTS] =
}
if (0 ==
strncmp(APPLICATION_FILES, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_FILES] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_FILES] =
}
if (0 ==
strncmp(APPLICATION_GAMES, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_GAMES] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_GAMES] =
}
if (0 ==
strncmp(APPLICATION_MAIL, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_MAIL] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_MAIL] =
}
if (0 ==
strncmp(APPLICATION_MEDIAPLAYER, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_MEDIAPLAYER] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_MEDIAPLAYER] =
}
if (0 ==
strncmp(APPLICATION_MESSAGING, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_MESSAGING] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_MESSAGING] =
}
if (0 ==
strncmp(APPLICATION_PHONECALL, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_PHONECALL] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_PHONECALL] =
}
if (0 ==
strncmp(APPLICATION_PICTURES, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_PICTURES] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_PICTURES] =
}
if (0 ==
strncmp(APPLICATION_PROG_MANAGER, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_PROG_MANAGER] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_PROG_MANAGER] =
}
if (0 ==
strncmp(APPLICATION_SETTINGS, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_SETTINGS] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_SETTINGS] =
}
if (0 ==
strncmp(APPLICATION_TASKS, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_TASKS] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_TASKS] =
}
if (0 ==
strncmp(APPLICATION_WIDGET_MANAGER, infoAll.Get()[i].pkg_name,
- NAME_LEN)) {
+ NAME_LEN))
+ {
m_applicationTypesByPath[APPLICATION_TYPE_WIDGET_MANAGER] =
infoAll.Get()[i].app_path;
m_applicationTypesByName[APPLICATION_TYPE_WIDGET_MANAGER] =
registered_application = true;
}
if (infoAll.Get()[i].visible == 0 && registered_application ==
- false) {
+ false)
+ {
LogDebug("Not Registered.");
LogDebug("-----");
continue;
}
ApplicationType AppLauncherManager::getRegisteredApplicationType(
- const std::string &name) const
+ const std::string &name) const
{
if (!name.empty()) {
std::map<ApplicationType, std::string>::const_iterator it;
for (it = m_applicationTypesByPath.begin();
it != m_applicationTypesByPath.end();
- ++it) {
+ ++it)
+ {
if (it->second == name) {
return it->first;
}
}
std::string AppLauncherManager::getPathFromApplicationName(
- const std::string &applicationName) const
+ const std::string &applicationName) const
{
if (0 == applicationName.find(WIDGET_URI_PREFIX) && std::string::npos !=
- applicationName.find("?")) {
+ applicationName.find("?"))
+ {
//uri format is: widget://{widgetId}?wname={WidgetName}
LogDebug("found widget:// URI");
std::string uri = applicationName;
uri.erase(0, strlen(WIDGET_URI_PREFIX)); //remove widget://part
std::string widgetId = uri.substr(0, uri.find("?"));
- uri.erase(0, widgetId.size() + 7); //remove widget id and "?wname=" string, so uri contains only widget name now
+ uri.erase(0, widgetId.size() + 7); //remove widget id and "?wname="
+ // string, so uri contains only
+ // widget name now
std::string packageName = APPLICATION_WIDGET + widgetId;
LogDebug(
"Widget id: " << widgetId << ", widget name: " << uri <<
}
std::string AppLauncherManager::getPathFromPackageName(
- const std::string &packageName) const
+ const std::string &packageName) const
{
app_info info = { 0, };
strncpy(info.pkg_name, packageName.c_str(), NAME_LEN);
}
int AppLauncherManager::launchApplicationFileInternal(
- const std::string &uriParameter,
- const std::vector<std::string> &applicationParams)
+ const std::string &uriParameter,
+ const std::vector<std::string> &applicationParams)
{
LogDebug("entered with uriParameter: '" << uriParameter << "'");
ApplicationType appType = getRegisteredApplicationType(uriParameter);
std::vector<std::string>::const_iterator it;
for (it = applicationParams.begin();
it != applicationParams.end();
- ++it) {
+ ++it)
+ {
std::string param(Commons::String::trim(*it));
if (param.empty()) {
continue;
if (params.size() > 0) {
if (appType == APPLICATION_TYPE_PHONECALL) {
//phone number is provided.
- //replace package to make a call, not run application with this functionality
+ //replace package to make a call, not run application with this
+ // functionality
packageName = APPLICATION_PHONECALL_CALLING;
kb = bundle_create();
if (!kb) {
return ERROR_LAUNCHER_EXECUTION_ERROR;
}
- if (bundle_add(kb, "launch-type", "MO") < 0) { // "MO" : normal call, "EMERGENCY" : emergency call
+ if (bundle_add(kb, "launch-type", "MO") < 0) { // "MO" : normal
+ // call,
+ // "EMERGENCY" :
+ // emergency call
bundle_free(kb);
return ERROR_LAUNCHER_EXECUTION_ERROR;
}
}
if (bundle_add(kb, "path",
getRealPath(params.front()).c_str()) <
- 0) {
+ 0)
+ {
bundle_free(kb);
return ERROR_LAUNCHER_EXECUTION_ERROR;
}
return ERROR_LAUNCHER_EXECUTION_ERROR;
}
if (bundle_add(kb, "Path",
- getRealPath(params.front()).c_str()) < 0) {
+ getRealPath(params.front()).c_str()) < 0)
+ {
bundle_free(kb);
return ERROR_LAUNCHER_EXECUTION_ERROR;
}
}
int AppLauncherManager::launchApplicationInternal(
- const ApplicationUriType uriType,
- const std::string &uriParameter,
- const std::vector<std::string> &applicationParams)
+ const ApplicationUriType uriType,
+ const std::string &uriParameter,
+ const std::vector<std::string> &applicationParams)
{
LogDebug(
"entered with uriType: " << uriType << ", uriParameter: " <<
}
std::string AppLauncherManager::getDefaultApplicationByMimeInternal(
- const std::string &mime) const
+ const std::string &mime) const
{
LogDebug("entered with mime: " << mime);
const int bufferSize = 1024;
}
void AppLauncherManager::OnRequestReceived(
- const EventGetDefaultApplicationPtr &event)
+ const EventGetDefaultApplicationPtr &event)
{
LogDebug("entered");
Try
}
void AppLauncherManager::OnRequestReceived(
- const EventGetInstalledApplicationsPtr &event)
+ const EventGetInstalledApplicationsPtr &event)
{
LogDebug("entered");
std::vector<std::string>::const_iterator it1;
for (it1 = m_installedApplications.begin();
it1 != m_installedApplications.end();
- ++it1) {
+ ++it1)
+ {
event->addApplicationFullPath(*it1);
}
for (it1 = m_installedApplicationsNames.begin();
it1 != m_installedApplicationsNames.end();
- ++it1) {
+ ++it1)
+ {
event->addApplicationName(*it1);
}
std::map<ApplicationType, std::string>::const_iterator it2;
for (it2 = m_applicationTypesByPath.begin();
it2 != m_applicationTypesByPath.end();
- ++it2) {
+ ++it2)
+ {
event->addApplicationTypeByPath(*it2);
}
for (it2 = m_applicationTypesByName.begin();
it2 != m_applicationTypesByName.end();
- ++it2) {
+ ++it2)
+ {
event->addApplicationTypeByName(*it2);
}
event->setExceptionCode(Commons::ExceptionCodes::None);
}
void AppLauncherManager::OnRequestReceived(
- const EventLaunchApplicationPtr &event)
+ const EventLaunchApplicationPtr &event)
{
LogDebug("entered");
ApplicationUriType uriType = event->getApplicationUriType();
if (result == SUCCESS_LAUNCHER) {
event->setExceptionCode(Commons::ExceptionCodes::None);
} else if (result == ERROR_LAUNCHER_INVALID_PARAMETER ||
- result == ERROR_LAUNCHER_INVALID_URI) {
+ result == ERROR_LAUNCHER_INVALID_URI)
+ {
event->setExceptionCode(
Commons::ExceptionCodes::InvalidArgumentException);
} else {
public:
AppLauncherManager();
virtual ~AppLauncherManager();
+
protected:
virtual void OnRequestReceived(
- const Api::AppLauncher::EventGetDefaultApplicationPtr &event);
+ const Api::AppLauncher::EventGetDefaultApplicationPtr &event);
virtual void OnRequestReceived(
- const Api::AppLauncher::EventGetInstalledApplicationsPtr &event);
+ const Api::AppLauncher::EventGetInstalledApplicationsPtr &event);
virtual void OnRequestReceived(
- const Api::AppLauncher::EventLaunchApplicationPtr &event);
+ const Api::AppLauncher::EventLaunchApplicationPtr &event);
virtual bool isRegisteredApplication(const std::string &name) const;
virtual Api::AppLauncher::ApplicationType getRegisteredApplicationType(
- const std::string &name) const;
+ const std::string &name) const;
virtual std::string getRealPath(const std::string &path) const;
virtual bool validateHttpAddress(const std::string &value) const;
virtual bool validateEmailAddress(const std::string &value) const;
std::string getDefaultApplicationByMimeInternal(const std::string &mime)
const;
int launchApplicationInternal(
- const Api::AppLauncher::ApplicationUriType uriType,
- const std::string &uriParameter,
- const std::vector<std::string> &applicationParams);
- int launchApplicationFileInternal(const std::string &uriParameter,
- const std::vector<std::string> &applicationParam);
+ const Api::AppLauncher::ApplicationUriType uriType,
+ const std::string &uriParameter,
+ const std::vector<std::string> &applicationParams);
+ int launchApplicationFileInternal(
+ const std::string &uriParameter,
+ const std::vector<std::string> &
+ applicationParam);
static std::map<Api::AppLauncher::ApplicationType,
std::string> m_applicationTypesByPath;
static std::map<Api::AppLauncher::ApplicationType,
#include <Commons/Exception.h>
#include <Commons/TypeTraits.h>
-
namespace WrtDeviceApis {
namespace Camera {
-
template<typename EventPtr>
class CameraPrivateData
{
-public:
+ public:
Camera* camera;
EventPtr event;
};
class OpaquePrivateData
{
-public:
+ public:
EventTypeId eventTypeId;
void* cameraPrivateData;
};
-
//GetEventTypeId
template<typename T>
-EventTypeId getEventTypeId(const T& event){ Assert(0); }
+EventTypeId getEventTypeId(const T& event)
+{
+ Assert(0);
+}
template<>
EventTypeId getEventTypeId<Api::EventBeginRecordingSharedPtr>(
template<typename EventPtr>
CameraPrivateData<EventPtr>* getPrivateData(void* data)
{
- OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*> (data);
+ OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*>(data);
CameraPrivateData<EventPtr>* privateData =
static_cast<CameraPrivateData<EventPtr> *>
template<typename EventPtr>
void deletePrivateData(void* data)
{
- OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*> (data);
+ OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*>(data);
CameraPrivateData<EventPtr>* privateData =
static_cast<CameraPrivateData<EventPtr> *>
delete opaqueData;
}
-
template<typename EventType, typename EventArg>
EventType createEvent(const EventArg& arg1)
{
return EventType(arg1);
}
-
template<typename EventType>
class BaseCallbackHandler : private DPL::Noncopyable
{
-public:
+ public:
explicit BaseCallbackHandler(void* data) :
m_camera(NULL)
{
virtual ~BaseCallbackHandler(){ }
protected:
- virtual void setPrivate(void* /*data*/) {};
+ virtual void setPrivate(void* /*data*/) {}
-protected:
+ protected:
Camera* m_camera;
EventType m_event;
};
class CallbackHandler : public BaseCallbackHandler<EventType>
{
static_assert(WrtDeviceApis::Commons::AlwaysFalse<EventType>::value,
- "Error, no specialization found for given type");
+ "Error, no specialization found for given type");
public:
explicit CallbackHandler(void* data) :
BaseCallbackHandler<EventType>(data)
- {
- }
+ {}
//virtual void post(){ }
};
template<>
-class CallbackHandler<Api::EventBeginRecordingSharedPtr>
- : public BaseCallbackHandler<Api::EventBeginRecordingSharedPtr>
+class CallbackHandler<Api::EventBeginRecordingSharedPtr>:
+ public BaseCallbackHandler<Api::EventBeginRecordingSharedPtr>
{
public:
explicit CallbackHandler(void* data) :
BaseCallbackHandler(data)
{}
- virtual void post(){
+ virtual void post()
+ {
this->m_camera->setRecordingState(Camera::COMPLETED);
this->m_camera->
- DPL::Event::ControllerEventHandler<JobDoneVideoRecordingEvent>::PostEvent(
- createEvent<JobDoneVideoRecordingEvent,
- Api::EventBeginRecordingSharedPtr>(this->m_event));
+ DPL::Event::ControllerEventHandler<JobDoneVideoRecordingEvent>::
+ PostEvent(
+ createEvent<JobDoneVideoRecordingEvent,
+ Api::EventBeginRecordingSharedPtr>(this->m_event));
}
virtual void handleSuccessCallback(void* data)
};
template<>
-class CallbackHandler<Api::EventTakePictureSharedPtr>
- : public BaseCallbackHandler<Api::EventTakePictureSharedPtr>
+class CallbackHandler<Api::EventTakePictureSharedPtr>:
+ public BaseCallbackHandler<Api::EventTakePictureSharedPtr>
{
public:
explicit CallbackHandler(void* data) :
BaseCallbackHandler(data)
{}
- virtual void post(){
+ virtual void post()
+ {
this->m_camera->
- DPL::Event::ControllerEventHandler<JobDoneTakePictureEvent>::PostEvent(
- createEvent<JobDoneTakePictureEvent,
- Api::EventTakePictureSharedPtr>(this->m_event));
+ DPL::Event::ControllerEventHandler<JobDoneTakePictureEvent>::
+ PostEvent(
+ createEvent<JobDoneTakePictureEvent,
+ Api::EventTakePictureSharedPtr>(this->m_event));
}
virtual void setPrivate(void* data)
};
template<>
-class CallbackHandler<Api::EventGetPreviewNodeSharedPtr>
- : public BaseCallbackHandler<Api::EventGetPreviewNodeSharedPtr>
+class CallbackHandler<Api::EventGetPreviewNodeSharedPtr>:
+ public BaseCallbackHandler<Api::EventGetPreviewNodeSharedPtr>
{
public:
explicit CallbackHandler(void* data) :
BaseCallbackHandler(data)
{}
- virtual void post(){
+ virtual void post()
+ {
this->m_camera->
- DPL::Event::ControllerEventHandler<JobDoneCreatePreviewEvent>::PostEvent(
- createEvent<JobDoneCreatePreviewEvent,
- Api::EventGetPreviewNodeSharedPtr>(this->m_event));
+ DPL::Event::ControllerEventHandler<JobDoneCreatePreviewEvent>::
+ PostEvent(
+ createEvent<JobDoneCreatePreviewEvent,
+ Api::EventGetPreviewNodeSharedPtr>(this->m_event));
}
virtual void setPrivate(void* data)
Camera::Camera(const Commons::IWrtCameraPtr& wrtCamera) :
m_wrtCamera(wrtCamera),
- m_stateRecordingVideo (Camera::IDLE)
+ m_stateRecordingVideo(Camera::IDLE)
{
CameraJobDoneController::Touch();
}
CameraJobDoneController::SwitchToThread(NULL);
}
-
void Camera::OnRequestReceived(
- const Api::EventTakePictureSharedPtr & event)
+ const Api::EventTakePictureSharedPtr & event)
{
LogDebug("enter");
camCaptureImageSuccessCallback,
camCaptureImageErrorCallback,
setPendingOperation,
- createPrivateOpaqueData(this,event));
+ createPrivateOpaqueData(this, event));
LogDebug("leaving");
}
void Camera::OnRequestReceived(
- const Api::EventBeginRecordingSharedPtr & event)
+ const Api::EventBeginRecordingSharedPtr & event)
{
LogDebug("enter");
camCaptureVideoSuccessCallback,
camCaptureVideoErrorCallback,
setPendingOperation,
- createPrivateOpaqueData(this,event));
+ createPrivateOpaqueData(this, event));
LogDebug("leaving");
}
void Camera::OnRequestReceived(
- const Api::EventEndRecordingSharedPtr & event)
+ const Api::EventEndRecordingSharedPtr & event)
{
LogDebug("end request");
if (m_stateRecordingVideo == Camera::PROCESSING) {
}
void Camera::OnRequestReceived(
- const Api::EventGetPreviewNodeSharedPtr & event)
+ const Api::EventGetPreviewNodeSharedPtr & event)
{
LogDebug("enter");
m_wrtCamera->createPreviewNode(camPreviewSuccessCallback,
camPreviewErrorCallback,
setPendingOperation,
- createPrivateOpaqueData(this,event));
+ createPrivateOpaqueData(this, event));
LogDebug("leaving");
}
void Camera::camCaptureImageSuccessCallback(
- const char* filename, void* data)
+ const char* filename, void* data)
{
LogDebug("*Picture* Captured. !!!");
}
void Camera::camPreviewSuccessCallback(
- Commons::IWrtCamera::CameraPreviewNode node, void* data)
+ Commons::IWrtCamera::CameraPreviewNode node, void* data)
{
LogDebug("enter");
}
void Camera::OnCancelEvent(
- const Api::EventBeginRecordingSharedPtr& event)
+ const Api::EventBeginRecordingSharedPtr& event)
{
LogDebug(__FUNCTION__);
LogDebug("Set pending operation callback invoked");
Assert(data);
- OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*> (data);
+ OpaquePrivateData* opaqueData = static_cast<OpaquePrivateData*>(data);
Assert(opaqueData->cameraPrivateData);
switch (opaqueData->eventTypeId) {
case BeginRecordingType:
- {
- static_cast<CameraPrivateData<Api::EventBeginRecordingSharedPtr>* > (
- opaqueData->cameraPrivateData)
- ->event->setPendingOperation(pendingOperation);
- break;
- }
+ {
+ static_cast<CameraPrivateData<Api::EventBeginRecordingSharedPtr>* >(
+ opaqueData->cameraPrivateData)
+ ->event->setPendingOperation(pendingOperation);
+ break;
+ }
case CreatePreviewType:
- {
- static_cast<CameraPrivateData<Api::EventGetPreviewNodeSharedPtr>* > (
- opaqueData->cameraPrivateData)
- ->event->setPendingOperation(pendingOperation);
- break;
- }
+ {
+ static_cast<CameraPrivateData<Api::EventGetPreviewNodeSharedPtr>* >(
+ opaqueData->cameraPrivateData)
+ ->event->setPendingOperation(pendingOperation);
+ break;
+ }
case TakePictureType:
- {
- static_cast<CameraPrivateData<Api::EventGetPreviewNodeSharedPtr>* > (
- opaqueData->cameraPrivateData)
- ->event->setPendingOperation(pendingOperation);
- break;
- }
- default:
- Assert(0);
+ {
+ static_cast<CameraPrivateData<Api::EventGetPreviewNodeSharedPtr>* >(
+ opaqueData->cameraPrivateData)
+ ->event->setPendingOperation(pendingOperation);
+ break;
+ }
+ default:
+ Assert(0);
}
}
-
-
}
}
#include <Commons/Dimension.h>
#include <Commons/WrtWrapper/IWrtCamera.h>
-namespace WrtDeviceApis{
-namespace Camera{
-
+namespace WrtDeviceApis {
+namespace Camera {
DECLARE_GENERIC_EVENT_1(JobDoneTakePictureEvent,
Camera::Api::EventTakePictureSharedPtr)
DECLARE_GENERIC_EVENT_1(JobDoneVideoRecordingEvent,
DECLARE_GENERIC_EVENT_1(JobDoneCreatePreviewEvent,
Camera::Api::EventGetPreviewNodeSharedPtr)
-
typedef DPL::TypeListDecl<JobDoneTakePictureEvent,
JobDoneVideoRecordingEvent,
JobDoneCreatePreviewEvent
- >::Type JobDoneEvents;
+ >::Type JobDoneEvents;
typedef DPL::Event::Controller<JobDoneEvents> CameraJobDoneController;
-class Camera: public Api::ICamera,
- public CameraJobDoneController
+class Camera : public Api::ICamera,
+ public CameraJobDoneController
{
-public:
- enum CameraState{
+ public:
+ enum CameraState {
IDLE,
PROCESSING,
COMPLETED
};
-public:
+ public:
explicit Camera(const Commons::IWrtCameraPtr& wrtCamera);
virtual ~Camera();
void setRecordingState(CameraState state);
-private:
+ private:
static void camCaptureImageSuccessCallback(const char* filename,
void* data);
static void camCaptureVideoSuccessCallback(const char* filename,
void* data);
static void camPreviewSuccessCallback(
- Commons::IWrtCamera::CameraPreviewNode node, void* data);
+ Commons::IWrtCamera::CameraPreviewNode node, void* data);
static void camCaptureImageErrorCallback(int errorCode, void* data);
static void camCaptureVideoErrorCallback(int errorCode, void* data);
bool checkHighResolutionRequired(const EventType& event) const
{
return event->getCaptureOptionsRef()->getImageResolution()
- == Api::ICaptureOptions::IMAGE_RESOLUTION_HIGH;
+ == Api::ICaptureOptions::IMAGE_RESOLUTION_HIGH;
}
template<typename EventData>
}
static void setPendingOperation(
- Commons::IWrtCamera::CameraPendingOperation pendingOperation, void* data);
+ Commons::IWrtCamera::CameraPendingOperation pendingOperation,
+ void* data);
-private:
+ private:
Commons::IWrtCameraPtr m_wrtCamera;
CameraState m_stateRecordingVideo;
};
-
}
}
#endif /* WRTPLUGINSCAMERA_H_ */
namespace WrtDeviceApis {
namespace Camera {
-
void CameraManager::OnRequestReceived(
const Api::EventGetCamerasPtr &event)
{
LogDebug(__FUNCTION__);
- try
- {
+ try {
if (m_cameras.empty()) {
DPL::Mutex::ScopedLock lock(&m_accessMutex);
if (m_cameras.empty()) {
Commons::IWrtCameraManager::WrtCamerasPtr cameras;
cameras = event->
- getConfiguration()->
+ getConfiguration()->
getWrtWrapper()->
- getCameraManagerInterface()->
- getCameras();
+ getCameraManagerInterface()->
+ getCameras();
FOREACH(it, *cameras)
{
}
}
}
- event->setCamerasRef(m_cameras,0);
+ event->setCamerasRef(m_cameras, 0);
LogDebug("Nr of cameras: " << m_cameras.size());
- }
- catch(const Commons::Exception &exc)
- {
+ } catch (const Commons::Exception &exc) {
LogError("Exception has occurred: " << std::hex << exc.getCode());
event->setExceptionCode(exc.getCode());
}
}
-
}
}
namespace WrtDeviceApis {
namespace Camera {
-
class CameraManager : public Api::ICameraManager
{
-protected:
+ protected:
virtual void OnRequestReceived(
const Api::EventGetCamerasPtr &event);
-private:
+ private:
DPL::Mutex m_accessMutex;
};
-
}
}
#endif /* */
}
Manager::~Manager()
-{
-}
+{}
bool Manager::hasClamshell() const
{
}
Manager::Manager() : m_imei(VCONFKEY_TELEPHONY_IMEI)
-{
-}
+{}
} // Device
} // Platform
} // WrtPlugins
}
Manager::Manager()
-{
-}
+{}
} // Display
} // Platform
} // WrtPlugins
}
void Screen::addOnChangeOrientation(
- const Api::Display::EventChangeOrientationEmitterPtr& emitter)
+ const Api::Display::EventChangeOrientationEmitterPtr& emitter)
{
m_onChangeOrientation.attach(emitter);
ChangeOrientationEmitters::LockType lock = m_onChangeOrientation.getLock();
}
void Screen::removeOnChangeOrientation(
- Api::Display::EventChangeOrientationEmitter::IdType id)
+ Api::Display::EventChangeOrientationEmitter::IdType id)
{
m_onChangeOrientation.detach(id);
ChangeOrientationEmitters::LockType lock = m_onChangeOrientation.getLock();
}
void Screen::addOnChangeState(
- const Api::Display::EventChangeStateEmitterPtr& emitter)
+ const Api::Display::EventChangeStateEmitterPtr& emitter)
{
m_onChangeState.attach(emitter);
ChangeStateEmitters::LockType lock = m_onChangeState.getLock();
}
void Screen::removeOnChangeState(
- Api::Display::EventChangeStateEmitter::IdType id)
+ Api::Display::EventChangeStateEmitter::IdType id)
{
m_onChangeState.detach(id);
ChangeStateEmitters::LockType lock = m_onChangeState.getLock();
Screen::Screen(std::size_t index) :
m_index(index),
m_powerState(VCONFKEY_PM_STATE)
-{
-}
+{}
bool Screen::getXDpyProperty(const char* pattern,
- const pcrecpp::Arg& arg1,
- const pcrecpp::Arg& arg2)
+ const pcrecpp::Arg& arg1,
+ const pcrecpp::Arg& arg2)
{
FILE* pipe = popen(COMMAND_XDPYINFO, "r");
if (pipe == NULL) {
}
void Screen::onChangeState(const VConf::Node* /*node*/,
- void* data)
+ void* data)
{
Screen* this_ = static_cast<Screen*>(data);
Api::Display::EventChangeStatePtr event(new Api::Display::EventChangeState());
}
int Screen::onChangeOrientation(appcore_rm rot,
- void* data)
+ void* data)
{
Screen* this_ = static_cast<Screen*>(data);
Api::Display::EventChangeOrientationPtr event(
* @see WrtPlugins::Api::Display::IScreen::addOnChangeOrientation()
*/
void addOnChangeOrientation(
- const Api::Display::EventChangeOrientationEmitterPtr& emitter);
+ const Api::Display::EventChangeOrientationEmitterPtr& emitter);
/**
* @see WrtPlugins::Api::Display::IScreen::removeOnChangeOrientation()
*/
void removeOnChangeOrientation(
- Api::Display::EventChangeOrientationEmitter::IdType id);
+ Api::Display::EventChangeOrientationEmitter::IdType id);
/**
* @see WrtPlugins::Api::Display::IScreen::addOnChangeState()
*/
void addOnChangeState(
- const Api::Display::EventChangeStateEmitterPtr& emitter);
+ const Api::Display::EventChangeStateEmitterPtr& emitter);
/**
* @see WrtPlugins::Api::Display::IScreen::removeOnChangeState()
* @return Zero or positive value on success, -1 on failure.
*/
static bool getXDpyProperty(const char* pattern,
- const pcrecpp::Arg& arg1 = pcrecpp::RE::no_arg,
- const pcrecpp::Arg& arg2 = pcrecpp::RE::no_arg);
+ const pcrecpp::Arg& arg1 = pcrecpp::RE::no_arg,
+ const pcrecpp::Arg& arg2 = pcrecpp::RE::no_arg);
/**
* Callback run when device's power state changes.
* @param data User data.
*/
static void onChangeState(const VConf::Node* node,
- void* data);
+ void* data);
/**
* Callback run when device's orientation changes.
* @return Error code (?) - not specified in documentation.
*/
static int onChangeOrientation(appcore_rm rot,
- void* data);
+ void* data);
protected:
explicit Screen(std::size_t index);
protected:
std::size_t m_index; ///< Index of the screen.
- ChangeOrientationEmitters m_onChangeOrientation; ///< Change orientation emitters.
+ ChangeOrientationEmitters m_onChangeOrientation; ///< Change orientation
+ // emitters.
ChangeStateEmitters m_onChangeState; ///< Change state emitters.
VConf::Key m_powerState; ///< Key for power manager state.
};
namespace WrtPlugins {
namespace Platform {
-//static void wrtPlatformCallback(int widgetHandler, JSObjectRef object, void* userParam)
+//static void wrtPlatformCallback(int widgetHandler, JSObjectRef object, void*
+// userParam)
//{
-// FeatureManager::platformCallback(widgetHandler, static_cast<void*>(object), userParam);
+// FeatureManager::platformCallback(widgetHandler,
+// static_cast<void*>(object), userParam);
//}
void FeatureManager::OnRequestReceived(const Api::EventLoadFeaturePtr &event)
DPL::StaticPointerCast<JSCallbackManager,
Platform::IEventPrivateData>(
event->getPrivateData());
- /* TODO uncomment - this function _will_ be available in new wrt-engine API */
+ /* TODO uncomment - this function _will_ be available in new wrt-engine API
+ **/
LogError("*** CRITICAL wrt_dynamic_feature_request is disable!");
- // wrt_dynamic_feature_request(jsCallbackManager->getContext(), event->getFeature().c_str(), wrtPlatformCallback, eventWrapper);
+ // wrt_dynamic_feature_request(jsCallbackManager->getContext(),
+ // event->getFeature().c_str(), wrtPlatformCallback, eventWrapper);
}
void FeatureManager::platformCallback(int,
- void* object,
- void* userParam)
+ void* object,
+ void* userParam)
{
if (object == NULL) {
LogError("Request has been rejected.");
{
public:
FeatureManager()
- {
- }
+ {}
virtual ~FeatureManager()
- {
- }
+ {}
static void platformCallback(int,
- void* object,
- void* userParam);
+ void* object,
+ void* userParam);
+
protected:
virtual void OnRequestReceived(const Api::EventLoadFeaturePtr &event);
+
private:
struct EventWrapper
{
EventWrapper(FeatureManager *featureManager,
- const Api::EventLoadFeaturePtr &event) :
+ const Api::EventLoadFeaturePtr &event) :
m_featureManager(featureManager),
m_event(event)
- {
- }
+ {}
~EventWrapper()
- {
- }
+ {}
FeatureManager *m_featureManager;
Api::EventLoadFeaturePtr m_event;
}
bool compareByFilename(const IMediaItemPtr &lpm,
- const IMediaItemPtr &rpm)
+ const IMediaItemPtr &rpm)
{
return lpm->getFileName().compare(rpm->getFileName()) < 0;
}
bool compareByFileDate(const IMediaItemPtr &lpm,
- const IMediaItemPtr &rpm)
+ const IMediaItemPtr &rpm)
{
return lpm->getDate() < rpm->getDate();
}
bool compareByType(const IMediaItemPtr &lpm,
- const IMediaItemPtr &rpm)
+ const IMediaItemPtr &rpm)
{
return lpm->getType() < rpm->getType();
}
class SearchIdObj
{
unsigned long m_id;
+
public:
SearchIdObj(unsigned long id) : m_id(id)
- {
- }
+ {}
bool operator ()(const IMediaItemPtr &elem)
{
return elem->getId() == m_id;
NodeList nodes = node->getChildNodes();
NodeList::iterator it = nodes.begin(), end = nodes.end();
while (it != end) {
- //Warning: '*it' element will be deleted after out of scope (next iteration)
+ //Warning: '*it' element will be deleted after out of scope (next
+ // iteration)
(*it)->setPermissions(PERM_READ);
searchFiles(SharedPtr<INode>(*it));
++it;
//Copy elements within date period to view struct
for (IMediaItemsSetIterator it = m_mediaItems.begin(),
end = m_mediaItems.end();
- it != end; ++it) {
+ it != end; ++it)
+ {
if ((m_viewProperties.getStartDate() <= (*it)->getDate()) &&
- ((*it)->getDate() <= m_viewProperties.getEndDate())) {
+ ((*it)->getDate() <= m_viewProperties.getEndDate()))
+ {
m_view->push_back(*it);
}
}
m_name(name),
m_opened(false),
m_lastId(0)
- {
- }
+ {}
/*
* Destructor of the gallery
*/
virtual ~Gallery()
- {
- }
+ {}
/*
* Gets number of media items selected by current view
virtual std::string getName() const;
/*
* Opens the gallery
- * \exception Commons::PlatformWrongStateException when gallery is already open
+ * \exception Commons::PlatformWrongStateException when gallery is already
+ * open
*/
virtual void open();
/* Gets the current state of the gallery
namespace WrtPlugins {
namespace Platform {
void GalleryRequestManager::OnRequestReceived(
- const IEventGetGalleriesPtr &event)
+ const IEventGetGalleriesPtr &event)
{
IGallerySetPtr galleries(new IGallerySet());
galleries->push_back(IGalleryPtr(new Gallery("Device")));
}
void GalleryRequestManager::OnRequestReceived(
- const IEventGetMediaItemsPtr &event)
+ const IEventGetMediaItemsPtr &event)
{
Try
{
}
void GalleryRequestManager::OnRequestReceived(
- const IEventGetMediaItemByIdPtr &event)
+ const IEventGetMediaItemByIdPtr &event)
{
Try
{
protected:
virtual void OnRequestReceived(
- const Api::Gallery::IEventGetGalleriesPtr &event);
+ const Api::Gallery::IEventGetGalleriesPtr &event);
virtual void OnRequestReceived(const Api::Gallery::IEventOpenPtr &event);
virtual void OnRequestReceived(const Api::Gallery::IEventRefreshPtr &event);
virtual void OnRequestReceived(const Api::Gallery::IEventClosePtr &event);
virtual void OnRequestReceived(
- const Api::Gallery::IEventChangeViewPtr &event);
+ const Api::Gallery::IEventChangeViewPtr &event);
virtual void OnRequestReceived(
- const Api::Gallery::IEventGetMediaItemsPtr &event);
+ const Api::Gallery::IEventGetMediaItemsPtr &event);
virtual void OnRequestReceived(
- const Api::Gallery::IEventGetMediaItemByIdPtr &event);
+ const Api::Gallery::IEventGetMediaItemByIdPtr &event);
};
}
}
namespace Geolocation {
namespace {
static void positionChangedCallback(LocationObject *obj,
- guint type,
- gpointer data,
- gpointer accuracy,
- Geolocation* this_)
+ guint type,
+ gpointer data,
+ gpointer accuracy,
+ Geolocation* this_)
{
if (this_) {
this_->positionHasChanged(obj, type, data, accuracy);
}
long Geolocation::watchPosition(const EventPositionChangedEmitterPtr& emitter,
- long timeout,
- long maximumAge,
- bool highAccuracy)
+ long timeout,
+ long maximumAge,
+ bool highAccuracy)
{
initialize();
m_positionEmitters.attach(emitter);
}
void Geolocation::positionHasChanged(LocationObject *obj,
- guint type,
- gpointer data,
- gpointer accuracy)
+ guint type,
+ gpointer data,
+ gpointer accuracy)
{
LogDebug("Enter");
if (POSITION_UPDATED != type) {
return;
}
- m_location = location_new(convertMethodToPlatform(m_currentLocationMethod)); //may return NULL
+ //may return NULL
+ m_location = location_new(convertMethodToPlatform(m_currentLocationMethod));
+
if (NULL == m_location) {
ThrowMsg(Commons::PlatformException,
"Couldn't create new location object.");
* @See: IGelocation::getCurrentPosition
*/
virtual void getCurrentPosition(
- const Api::Geolocation::EventGetCurrentPositionPtr& event);
+ const Api::Geolocation::EventGetCurrentPositionPtr& event);
/**
* @See: IGelocation::watchPosition
*/
virtual long watchPosition(
- const Api::Geolocation::EventPositionChangedEmitterPtr& emitter,
- long timeout,
- long maximumAge,
- bool highAccuracy);
+ const Api::Geolocation::EventPositionChangedEmitterPtr& emitter,
+ long timeout,
+ long maximumAge,
+ bool highAccuracy);
/**
* @See: IGelocation::clearWatch
*/
virtual void clearWatch(
- Api::Geolocation::EventPositionChangedEmitter::IdType id);
+ Api::Geolocation::EventPositionChangedEmitter::IdType id);
/**
* @See: IGelocation::changeLocationMethod
* Method to run from platform's callback function
*/
void positionHasChanged(LocationObject *obj,
- guint type,
- gpointer data,
- gpointer accuracy);
+ guint type,
+ gpointer data,
+ gpointer accuracy);
protected:
Geolocation();
virtual void OnRequestReceived(
- const Api::Geolocation::EventGetCurrentPositionPtr& event);
+ const Api::Geolocation::EventGetCurrentPositionPtr& event);
private:
typedef Emitters<Api::Geolocation::EventPositionChangedEmitter>
}
Manager::Manager()
-{
-}
+{}
unsigned long Manager::getMeminfoValue(const char* pattern) const
{
bool matched = false;
std::string line;
while ((std::getline(file, line).rdstate() &
- (std::ifstream::failbit | std::ifstream::eofbit)) == 0) {
+ (std::ifstream::failbit | std::ifstream::eofbit)) == 0)
+ {
if (pcrecpp::RE(pattern).FullMatch(line, &result)) {
matched = true;
break;
Manager();
/**
- * Reads value from meminfo file looking it up using specified regex pattern.
+ * Reads value from meminfo file looking it up using specified regex
+ * pattern.
* Function matches each (whole!) line against specified pattern.
- * @param pattern Perl-like regular expresion used to search through meminfo.
+ * @param pattern Perl-like regular expresion used to search through
+ * meminfo.
* @return Found value.
* @throw PlatformException If could not find meminfo file.
- * @throw UnsupportedException If pattern didn't match any line in meminfo file.
+ * @throw UnsupportedException If pattern didn't match any line in meminfo
+ * file.
*/
unsigned long getMeminfoValue(const char* pattern) const;
};
std::string result;
char line[LINE_MAX] = { 0 };
pcrecpp::RE re(PATTERN_CPUINFO_HARDWARE);
- while (fgets(line, LINE_MAX, file) && !re.FullMatch(line, &result)) {
- }
+ while (fgets(line, LINE_MAX, file) && !re.FullMatch(line, &result)) {}
fclose(file);
if (result.empty()) {
}
Environment::Environment()
-{
-}
+{}
} // System
} // Platform
} // WrtPlugins
}
if (filter->getStartTimeIsSet() &&
(filter->getStartTimeMinFilter() > m_logEntry->getStartTime() ||
- filter->getStartTimeMaxFilter() < m_logEntry->getStartTime())) {
+ filter->getStartTimeMaxFilter() < m_logEntry->getStartTime()))
+ {
return false;
}
if (filter->getDurationIsSet() &&
(filter->getDurationMinFilter() > m_logEntry->getDuration() ||
- filter->getDurationMaxFilter() < m_logEntry->getDuration())) {
+ filter->getDurationMaxFilter() < m_logEntry->getDuration()))
+ {
return false;
}
if (filter->getPhoneNumberIsSet() &&
return false;
}
if (filter->getFolderIsSet() &&
- !filter->checkIfFolderIsSet(m_logEntry->getFolder())) {
+ !filter->checkIfFolderIsSet(m_logEntry->getFolder()))
+ {
return false;
} else if (m_logEntry->getFolder() == LogEntry::INVALID_FOLDER) {
return false;
virtual ~LogEntryWrapper();
bool matchFilters(const Api::LogFilterPtr &filter);
Api::LogEntryPtr getAbstractCall() const;
+
private:
Api::LogEntryPtr m_logEntry;
bool convertPlatformStructToAbstractStruct(CTSvalue *log);
}
std::vector<Api::LogEntryPtr> LogManager::findLogEntriesInternal(
- const LogFilterPtr &filter,
- const int minIndex,
- const int maxIndex)
+ const LogFilterPtr &filter,
+ const int minIndex,
+ const int maxIndex)
{
LogDebug("entered");
std::vector<LogEntryPtr> result;
public:
LogManager();
virtual ~LogManager();
+
protected:
virtual void OnRequestReceived(
- const Api::IEventGetNumberOfLogsPtr &event);
+ const Api::IEventGetNumberOfLogsPtr &event);
virtual void OnRequestReceived(
- const Api::IEventFindLogEntriesPtr &event);
+ const Api::IEventFindLogEntriesPtr &event);
virtual void OnRequestReceived(
- const Api::IEventDeleteLogEntryPtr &event);
+ const Api::IEventDeleteLogEntryPtr &event);
virtual void OnRequestReceived(
- const Api::IEventClearLogPtr &event);
+ const Api::IEventClearLogPtr &event);
int getNumberOfLogsInternal(
- const Api::LogFilterPtr &filter);
+ const Api::LogFilterPtr &filter);
std::vector<Api::LogEntryPtr> findLogEntriesInternal(
- const Api::LogFilterPtr &filter,
- const int minIndex = -1,
- const int maxIndex = -1);
+ const Api::LogFilterPtr &filter,
+ const int minIndex = -1,
+ const int maxIndex = -1);
void deleteLogEntryInternal(int id) const;
void clearLogInternal(
- const Api::LogFilterPtr &filter);
+ const Api::LogFilterPtr &filter);
static int m_instanceCount;
DPL::Mutex m_constructorMutex;
};
namespace WrtDeviceApis {
namespace Filesystem {
-
using namespace Api;
Manager::Locations Manager::m_locations;
}
Manager::~Manager()
-{
-}
+{}
IPathPtr Manager::getBasePath() const
{
}
void Manager::find(const IPathPtr& path,
- const FiltersMap& filters,
- NodeList& result,
- const EventFindPtr& event)
+ const FiltersMap& filters,
+ NodeList& result,
+ const EventFindPtr& event)
{
Try {
Assert(path && "path is NULL");
FTS *fts;
FTSENT *ftsent;
- std::string pth=path->getFullPath();
- char * const paths[] = {const_cast<char * const>(pth.c_str()), NULL};
+ std::string pth = path->getFullPath();
+ char * const paths[] = { const_cast<char * const>(pth.c_str()), NULL };
- if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+ if ((fts =
+ fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL)
+ {
//ERROR
int error = errno;
LogError(__PRETTY_FUNCTION__ << ": fts_open on "
- << pth
- << " failed with error: "
- << strerror(error));
+ << pth
+ << " failed with error: "
+ << strerror(error));
return;
}
while ((ftsent = fts_read(fts)) != NULL) {
- if(event && event->checkCancelled()) break;
+ if (event && event->checkCancelled()) {
+ break;
+ }
switch (ftsent->fts_info) {
- case FTS_DP:
- //directory in postorder - do nothing
- break;
- case FTS_D:
- case FTS_DC:
- case FTS_F:
- case FTS_SL:
- case FTS_SLNONE:
- case FTS_DEFAULT:
- //regular files, symbolic links, directories in preorder
- //and other file entries that can be processed further
- if (matchFilters(ftsent->fts_name, *ftsent->fts_statp, filters)) {
- IPathPtr childPath=IPath::create(ftsent->fts_path);
- result.push_back(Node::resolve(childPath));
- }
- break;
- case FTS_NS:
- case FTS_NSOK:
- case FTS_DOT:
- case FTS_DNR:
- case FTS_ERR:
- default:
- LogWarning(__PRETTY_FUNCTION__
- << ": traversal failed with error: "
- << strerror(ftsent->fts_errno));
- ThrowMsg(Commons::PlatformException,
- "Error reading directory");
+ case FTS_DP:
+ //directory in postorder - do nothing
+ break;
+ case FTS_D:
+ case FTS_DC:
+ case FTS_F:
+ case FTS_SL:
+ case FTS_SLNONE:
+ case FTS_DEFAULT:
+ //regular files, symbolic links, directories in preorder
+ //and other file entries that can be processed further
+ if (matchFilters(ftsent->fts_name, *ftsent->fts_statp,
+ filters))
+ {
+ IPathPtr childPath = IPath::create(ftsent->fts_path);
+ result.push_back(Node::resolve(childPath));
+ }
+ break;
+ case FTS_NS:
+ case FTS_NSOK:
+ case FTS_DOT:
+ case FTS_DNR:
+ case FTS_ERR:
+ default:
+ LogWarning(__PRETTY_FUNCTION__
+ << ": traversal failed with error: "
+ << strerror(ftsent->fts_errno));
+ ThrowMsg(Commons::PlatformException,
+ "Error reading directory");
}
}
if (fts_close(fts) == -1) {
int error = errno;
LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
- << strerror(error));
+ << strerror(error));
ThrowMsg(Commons::PlatformException,
"Could not close platform node.");
}
}
- Catch(Commons::Exception) {
- }
+ Catch(Commons::Exception) {}
}
void Manager::copyElement(
- const std::string &src, const std::string &dest, bool recursive) const
+ const std::string &src, const std::string &dest, bool recursive) const
{
LogDebug("Copying src: " << src << " to: " << dest);
free(data);
}
}
-
}
bool Manager::access(const IPathPtr& path,
- int accessType) const
+ int accessType) const
{
int amode = 0;
- if (accessType & AT_EXISTS) { amode |= F_OK; }
- if (accessType & AT_READ) { amode |= R_OK; }
- if (accessType & AT_WRITE) { amode |= W_OK; }
- if (accessType & AT_EXEC) { amode |= X_OK; }
+ if (accessType & AT_EXISTS) {
+ amode |= F_OK;
+ }
+ if (accessType & AT_READ) {
+ amode |= R_OK;
+ }
+ if (accessType & AT_WRITE) {
+ amode |= W_OK;
+ }
+ if (accessType & AT_EXEC) {
+ amode |= X_OK;
+ }
return (::access(path->getFullPath().c_str(), amode) == 0);
}
bool Manager::matchFilters(const std::string& name,
- const struct stat& info,
- const FiltersMap& filters)
+ const struct stat& info,
+ const FiltersMap& filters)
{
FiltersMap::const_iterator it = filters.begin();
for (; it != filters.end(); ++it) {
if (it->first == FF_NAME) {
- if (!pcrecpp::RE(it->second).PartialMatch(name)) { return false; }
+ if (!pcrecpp::RE(it->second).PartialMatch(name)) {
+ return false;
+ }
} else if (it->first == FF_SIZE) {
std::size_t size;
std::stringstream ss(it->second);
ss >> size;
if (!ss ||
- (size != static_cast<size_t>(info.st_size))) { return false; }
+ (size != static_cast<size_t>(info.st_size)))
+ {
+ return false;
+ }
} else if (it->first == FF_CREATED) {
std::time_t created;
std::stringstream ss(it->second);
ss >> created;
- if (!ss || (created != info.st_ctime)) { return false; }
+ if (!ss || (created != info.st_ctime)) {
+ return false;
+ }
} else if (it->first == FF_MODIFIED) {
std::time_t modified;
std::stringstream ss(it->second);
ss >> modified;
- if (!ss || (modified != info.st_mtime)) { return false; }
+ if (!ss || (modified != info.st_mtime)) {
+ return false;
+ }
}
}
return true;
{
try {
event->setResult(Node::resolve(event->getPath()));
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
}
}
void Manager::checkPaths(
- Api::IPathPtr &src,
- Api::IPathPtr &dest) {
+ Api::IPathPtr &src,
+ Api::IPathPtr &dest)
+{
Assert(dest);
Assert(src);
if (!dest->isAbsolute()) {
if (!access(parent->getPath(), AT_WRITE)) {
ThrowMsg(Commons::SecurityException,
- "Not enough permissions to write to destination.");
+ "Not enough permissions to write to destination.");
}
}
-bool Manager::pathExists(const std::string &path) {
+bool Manager::pathExists(const std::string &path)
+{
errno = 0;
struct stat info;
memset(&info, 0, sizeof(struct stat));
INodePtr srcNode = Node::resolve(event->getSource());
int requiredAccess;
switch (srcNode->getType()) {
- case NT_DIRECTORY:
- requiredAccess = AT_EXEC;
- break;
- case NT_FILE:
- requiredAccess = AT_READ;
- break;
+ case NT_DIRECTORY:
+ requiredAccess = AT_EXEC;
+ break;
+ case NT_FILE:
+ requiredAccess = AT_READ;
+ break;
}
if (!access(srcNode->getPath(), requiredAccess)) {
ThrowMsg(Commons::SecurityException,
- "Not enough permissions to copy source node.");
+ "Not enough permissions to copy source node.");
}
IPathPtr src = event->getSource();
copyElement(realSrc, realDest);
event->setResult(Node::resolve(dest));
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
- catch (const Commons::SecurityException& ex) {
+ } catch (const Commons::SecurityException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
}
INodePtr srcNode = Node::resolve(src);
if (!access(srcNode->getParent()->getPath(), AT_WRITE)) {
ThrowMsg(Commons::SecurityException,
- "Not enough permissions to move source node.");
+ "Not enough permissions to move source node.");
}
checkPaths(src, dest);
dest->getFullPath().c_str()))
{
int error = errno;
- switch (error)
- {
+ switch (error) {
case EXDEV:
- {
- if (destExists) {
- //destination exist. Need to be removed
- Try {
- INodePtr node = Node::resolve(
- event->getDestination());
- node->remove(event->getOptions());
- }
- Catch(Commons::PlatformException) {
- LogError("Exception while removing dest directory");
- event->setExceptionCode(
- Commons::ExceptionCodes::PlatformException);
- }
- Catch(Commons::SecurityException) {
- event->setExceptionCode(
- Commons::ExceptionCodes::SecurityException);
- }
- }
-
- copyElement(src->getFullPath(),
- dest->getFullPath());
- //remove source files
+ {
+ if (destExists) {
+ //destination exist. Need to be removed
Try {
- INodePtr node = Node::resolve(event->getSource());
+ INodePtr node = Node::resolve(
+ event->getDestination());
node->remove(event->getOptions());
}
- Catch(Commons::Exception) {
- LogError("Exception: "
- << _rethrown_exception.GetMessage());
+ Catch(Commons::PlatformException) {
+ LogError("Exception while removing dest directory");
+ event->setExceptionCode(
+ Commons::ExceptionCodes::PlatformException);
+ }
+ Catch(Commons::SecurityException) {
+ event->setExceptionCode(
+ Commons::ExceptionCodes::SecurityException);
}
- break;
}
+
+ copyElement(src->getFullPath(),
+ dest->getFullPath());
+ //remove source files
+ Try {
+ INodePtr node = Node::resolve(event->getSource());
+ node->remove(event->getOptions());
+ }
+ Catch(Commons::Exception) {
+ LogError("Exception: "
+ << _rethrown_exception.GetMessage());
+ }
+ break;
+ }
default:
ThrowMsg(Commons::PlatformException,
"Error on rename: " << DPL::GetErrnoString(error));
}
event->setResult(Node::resolve(dest));
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
- catch (const Commons::SecurityException& ex) {
+ } catch (const Commons::SecurityException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
}
NodeList result;
find(event->getPath(), event->getFilters(), result, event);
event->setResult(result);
- }
- catch (const Commons::Exception& ex) {
+ } catch (const Commons::Exception& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
}
}
void Manager::setupLocation(LocationType location,
- const char* path)
+ const char* path)
{
if (!nodeExists(path)) {
try {
makePath(path, 0755);
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.DumpToString());
return;
}
}
m_locations[location] = IPath::create(path);
}
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
class Manager : public Api::IManager
{
public:
* only by virtual roots.
*/
bool access(const Api::IPathPtr& path,
- int accessType) const;
+ int accessType) const;
void addOpenedNode(const Api::INodePtr& node);
void removeOpenedNode(const Api::INodePtr& node);
protected:
bool matchFilters(const std::string& name,
- const struct stat& info,
- const Api::FiltersMap& filter);
+ const struct stat& info,
+ const Api::FiltersMap& filter);
void OnRequestReceived(const Api::EventResolvePtr& event);
void OnRequestReceived(const Api::EventCopyPtr& event);
*/
void checkPaths(Api::IPathPtr &src, Api::IPathPtr &dest);
bool pathExists(const std::string &path);
+
private:
static Locations m_locations; ///< Paths to default locations.
static const std::size_t m_maxPathLength; ///< Maximum path length.
- static Api::NodeList m_openedNodes; ///< List of nodes that has opened streams.
+ static Api::NodeList m_openedNodes; ///< List of nodes that has opened
+ // streams.
};
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
using namespace Api;
INodePtr Node::resolve(const IPathPtr& path)
"Node does not exist or access denied.");
}
- if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode)) {
+ if (!S_ISDIR(info.st_mode) && !S_ISREG(info.st_mode)) {
ThrowMsg(Commons::PlatformException,
"Platform node is of unsupported type.");
}
NameList result;
errno = 0;
- struct dirent *entry = NULL;
- while ((entry = readdir(dir))) {
- if (!strncmp(entry->d_name, ".",
- 1) || !strncmp(entry->d_name, "..", 2)) {
+ int return_code;
+ struct dirent entry;
+ struct dirent *entry_result;
+ for (return_code = readdir_r(dir, &entry, &entry_result);
+ entry_result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &entry_result)) {
+ if (!strncmp(entry.d_name, ".", 1) ||
+ !strncmp(entry.d_name, "..", 2))
+ {
continue;
}
- result.push_back(entry->d_name);
+ result.push_back(entry.d_name);
}
- if (errno != 0) {
+ if (return_code != 0 || errno != 0) {
ThrowMsg(Commons::PlatformException, "Error while reading directory.");
}
errno = 0;
NodeList result;
- struct dirent *entry = NULL;
- while ((entry = readdir(dir))) {
- if (!strncmp(entry->d_name, ".",
- 1) || !strncmp(entry->d_name, "..", 2)) {
+ int return_code;
+ struct dirent entry;
+ struct dirent *entry_result;
+ for (return_code = readdir_r(dir, &entry, &entry_result);
+ entry_result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &entry, &entry_result)) {
+ if (!strncmp(entry.d_name, ".", 1) ||
+ !strncmp(entry.d_name, "..", 2))
+ {
continue;
}
Try {
Assert(m_path);
- INodePtr node = Node::resolve(*m_path + entry->d_name);
+ INodePtr node = Node::resolve(*m_path + entry.d_name);
node->setPermissions(getPermissions()); // inherit access rights
if (NodeFilterMatcher::match(node, filter)) {
result.push_back(node);
}
}
- Catch(Commons::PlatformException) {
- }
+ Catch(Commons::PlatformException) {}
}
- if (errno != 0) {
+ if (return_code != 0 || errno != 0) {
ThrowMsg(Commons::PlatformException, "Error while reading directory.");
}
}
INodePtr Node::createChild(
- const IPathPtr& path,
- NodeType type,
- int options)
+ const IPathPtr& path,
+ NodeType type,
+ int options)
{
if (m_type != NT_DIRECTORY) {
ThrowMsg(Commons::PlatformException, "Parent node is not a directory.");
if (((mode & AM_READ) && ((m_perms & PERM_READ) == 0)) ||
(((mode & AM_WRITE) ||
- (mode & AM_APPEND)) && ((m_perms & PERM_WRITE) == 0))) {
+ (mode & AM_APPEND)) && ((m_perms & PERM_WRITE) == 0)))
+ {
ThrowMsg(Commons::SecurityException, "Not enough permissions.");
}
{
int result = 0;
struct stat info = stat(m_path);
- if (info.st_mode & S_IRUSR) { result |= PM_USER_READ; }
- if (info.st_mode & S_IWUSR) { result |= PM_USER_WRITE; }
- if (info.st_mode & S_IXUSR) { result |= PM_USER_EXEC; }
- if (info.st_mode & S_IRGRP) { result |= PM_GROUP_READ; }
- if (info.st_mode & S_IWGRP) { result |= PM_GROUP_WRITE; }
- if (info.st_mode & S_IXGRP) { result |= PM_GROUP_EXEC; }
- if (info.st_mode & S_IROTH) { result |= PM_OTHER_READ; }
- if (info.st_mode & S_IWOTH) { result |= PM_OTHER_WRITE; }
- if (info.st_mode & S_IXOTH) { result |= PM_OTHER_EXEC; }
+ if (info.st_mode & S_IRUSR) {
+ result |= PM_USER_READ;
+ }
+ if (info.st_mode & S_IWUSR) {
+ result |= PM_USER_WRITE;
+ }
+ if (info.st_mode & S_IXUSR) {
+ result |= PM_USER_EXEC;
+ }
+ if (info.st_mode & S_IRGRP) {
+ result |= PM_GROUP_READ;
+ }
+ if (info.st_mode & S_IWGRP) {
+ result |= PM_GROUP_WRITE;
+ }
+ if (info.st_mode & S_IXGRP) {
+ result |= PM_GROUP_EXEC;
+ }
+ if (info.st_mode & S_IROTH) {
+ result |= PM_OTHER_READ;
+ }
+ if (info.st_mode & S_IWOTH) {
+ result |= PM_OTHER_WRITE;
+ }
+ if (info.st_mode & S_IXOTH) {
+ result |= PM_OTHER_EXEC;
+ }
return result;
}
struct stat result;
memset(&result, 0, sizeof(struct stat));
if (::stat(path->getFullPath().c_str(),
- &result) != 0)
+ &result) != 0)
{
LogError("File: " << path->getFullPath().c_str());
ThrowMsg(Commons::PlatformException, "Node does not exist or no access");
m_path(path),
m_type(type),
m_perms(PERM_NONE)
-{
-}
+{}
Node* Node::createAsFile(const IPathPtr& path,
- int /* options */)
+ int /* options */)
{
LogDebug("ENTER");
createAsFileInternal(path);
}
Node* Node::createAsDirectory(const IPathPtr& path,
- int options)
+ int options)
{
if (options & OPT_RECURSIVE) {
PathUtils::PathList parts = PathUtils::getParts(path);
PathUtils::PathListIterator it = parts.begin();
for (; it != parts.end(); ++it) {
- if (!exists(*it)) { createAsDirectoryInternal(*it); }
+ if (!exists(*it)) {
+ createAsDirectoryInternal(*it);
+ }
}
}
createAsDirectoryInternal(path);
void Node::createAsDirectoryInternal(const IPathPtr& path)
{
if (mkdir(path->getFullPath().c_str(), S_IRWXU | S_IRWXG | S_IROTH |
- S_IXOTH) != 0) {
+ S_IXOTH) != 0)
+ {
ThrowMsg(Commons::PlatformException,
"Platform node could not be created.");
}
FTS *fts;
FTSENT *ftsent;
int error = 0;
- std::string pth=path->getFullPath();
- char * const paths[] = {const_cast<char * const>(pth.c_str()), NULL};
+ std::string pth = path->getFullPath();
+ char * const paths[] = { const_cast<char * const>(pth.c_str()), NULL };
- if ((fts = fts_open(paths, FTS_PHYSICAL|FTS_NOCHDIR, NULL)) == NULL) {
+ if ((fts =
+ fts_open(paths, FTS_PHYSICAL | FTS_NOCHDIR, NULL)) == NULL)
+ {
//ERROR
error = errno;
LogError(__PRETTY_FUNCTION__ << ": fts_open on "
- << pth
- << " failed with error: "
- << strerror(error));
+ << pth
+ << " failed with error: "
+ << strerror(error));
ThrowMsg(Commons::PlatformException, "Failed to traverse Node");
}
while ((ftsent = fts_read(fts)) != NULL) {
switch (ftsent->fts_info) {
- case FTS_D:
- //directory in preorder - do nothing
- break;
- case FTS_DP:
- //directory in postorder - remove
- errno = 0;
- if (rmdir(ftsent->fts_accpath) != 0) {
- if (errno == EEXIST) {
- ThrowMsg(Commons::PlatformException,
- "Node has child nodes.");
- }
+ case FTS_D:
+ //directory in preorder - do nothing
+ break;
+ case FTS_DP:
+ //directory in postorder - remove
+ errno = 0;
+ if (rmdir(ftsent->fts_accpath) != 0) {
+ if (errno == EEXIST) {
ThrowMsg(Commons::PlatformException,
- "Error while removing platform node.");
- }
- break;
- case FTS_DC:
- case FTS_F:
- case FTS_NSOK:
- case FTS_SL:
- case FTS_SLNONE:
- case FTS_DEFAULT:
- {
- //regular files and other objects that can safely be removed
- IPathPtr file_path = IPath::create(ftsent->fts_path);
- removeAsFile(file_path);
- break;
+ "Node has child nodes.");
}
- case FTS_NS:
- case FTS_DOT:
- case FTS_DNR:
- case FTS_ERR:
- default:
- LogWarning(__PRETTY_FUNCTION__
- << ": traversal failed with error: "
- << strerror(ftsent->fts_errno));
- break;
+ ThrowMsg(Commons::PlatformException,
+ "Error while removing platform node.");
+ }
+ break;
+ case FTS_DC:
+ case FTS_F:
+ case FTS_NSOK:
+ case FTS_SL:
+ case FTS_SLNONE:
+ case FTS_DEFAULT:
+ {
+ //regular files and other objects that can safely be removed
+ IPathPtr file_path = IPath::create(ftsent->fts_path);
+ removeAsFile(file_path);
+ break;
+ }
+ case FTS_NS:
+ case FTS_DOT:
+ case FTS_DNR:
+ case FTS_ERR:
+ default:
+ LogWarning(__PRETTY_FUNCTION__
+ << ": traversal failed with error: "
+ << strerror(ftsent->fts_errno));
+ break;
}
}
if (fts_close(fts) == -1) {
error = errno;
LogWarning(__PRETTY_FUNCTION__ << ": fts_close failed with error: "
- << strerror(error));
+ << strerror(error));
}
} else {
if (rmdir(path->getFullPath().c_str()) != 0) {
ThrowMsg(Commons::PlatformException, "Node has child nodes.");
}
ThrowMsg(Commons::PlatformException,
- "Error while removing platform node.");
+ "Error while removing platform node.");
}
}
}
try {
NodeList list = event->getNode()->getChildNodes(event->getFilter());
event->setResult(list);
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
- catch (const Commons::SecurityException& ex) {
+ } catch (const Commons::SecurityException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
}
try {
IStreamPtr result = open(event->getMode());
event->setResult(result);
- }
- catch (const Commons::PlatformException& ex) {
+ } catch (const Commons::PlatformException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
- }
- catch (const Commons::SecurityException& ex) {
+ } catch (const Commons::SecurityException& ex) {
LogError("Exception: " << ex.GetMessage());
event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
}
DPL::SharedPtr<Stream> stream(new Stream(SharedFromThis(), AM_READ));
while (!stream->isEof()) {
result << stream->getLine();
- if(!stream->isEof())
+ if (!stream->isEof()) {
result << '\n';
+ }
}
stream->close();
return result.str();
// TODO I believe moving this feature to WrtWrapper would make more sense.
return "file://" + m_path->getFullPath();
}
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
class Node :
public Api::INode,
public DPL::EnableSharedFromThis<Node>
Api::INodePtr getChild(const Api::IPathPtr& path);
NameList getChildNames() const;
Api::NodeList getChildNodes(
- const Api::NodeFilterPtr& filter = Api::NodeFilterPtr()) const;
+ const Api::NodeFilterPtr& filter = Api::NodeFilterPtr()) const;
void getChildNodes(const Api::EventListNodesPtr& event);
Api::INodePtr createChild(const Api::IPathPtr & path,
Api::NodeType,
void removeAsFile(const Api::IPathPtr& path);
void removeAsDirectory(const Api::IPathPtr& path,
- bool recursive);
+ bool recursive);
void OnRequestReceived(const Api::EventListNodesPtr& event);
void OnRequestReceived(const Api::EventOpenPtr& event);
};
typedef DPL::SharedPtr<Node> NodePtr;
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
using namespace Api;
bool NodeFilterMatcher::match(const INodePtr& value,
if (!matchRange(value->getCreated(),
filter->getMinCreated(),
- filter->getMaxCreated())) {
+ filter->getMaxCreated()))
+ {
return false;
}
if (!matchRange(value->getModified(),
filter->getMinModified(),
- filter->getMaxModified())) {
+ filter->getMaxModified()))
+ {
return false;
}
if (!matchRange(value->getSize(),
filter->getMinSize(),
- filter->getMaxSize())) {
+ filter->getMaxSize()))
+ {
return false;
}
}
}
bool NodeFilterMatcher::matchString(const std::string& value,
- const OptionalString& filter)
+ const OptionalString& filter)
{
if (!filter.IsNull()) {
return pcrecpp::RE(*filter).PartialMatch(value);
template<typename Type>
bool NodeFilterMatcher::matchRange(const Type& value,
- const DPL::Optional<Type>& min,
- const DPL::Optional<Type>& max)
+ const DPL::Optional<Type>& min,
+ const DPL::Optional<Type>& max)
{
if ((!min.IsNull() && (value < *min)) ||
- (!max.IsNull() && (value > *max))) {
+ (!max.IsNull() && (value > *max)))
+ {
return false;
}
return true;
}
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
class NodeFilterMatcher
{
public:
private:
NodeFilterMatcher();
};
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
using namespace Api;
const Path::SeparatorType Path::m_pathSeparator = '/';
}
Path::Path()
-{
-}
+{}
void Path::reset(const std::string& str)
{
m_fullPath += m_name;
}
}
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
class Path : public Api::IPath,
public DPL::EnableSharedFromThis<Path>
{
std::string m_path; ///< Base path.
std::string m_name; ///< Last part of the path.
};
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
using namespace Api;
Stream::Stream(const NodePtr& parent,
Assert(m_parent && "Stream needs to have parent.");
std::ios_base::openmode mode_ = std::ios_base::binary;
- if (mode & AM_READ) { mode_ |= std::ios_base::in; }
- if (mode & AM_WRITE) { mode_ |= std::ios_base::out; } else if (mode &
- AM_APPEND) {
+ if (mode & AM_READ) {
+ mode_ |= std::ios_base::in;
+ }
+ if (mode & AM_WRITE) {
+ mode_ |= std::ios_base::out;
+ } else if (mode &
+ AM_APPEND)
+ {
mode_ |= (std::ios_base::app | std::ios_base::out);
}
if (!(m_stream << arg)) {
LogError("Error while writing to the stream.");
ThrowMsg(Commons::PlatformException,
- "Error while writing to the stream.");
+ "Error while writing to the stream.");
}
m_stream.flush();
ThrowMsg(Commons::PlatformException, "Stream is not writeable.");
}
}
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
class Node;
typedef DPL::SharedPtr<Node> NodePtr;
private:
Stream(const NodePtr& parent,
- int mode);
+ int mode);
private:
NodePtr m_parent;
};
typedef DPL::SharedPtr<Stream> StreamPtr;
-
} // Filesystem
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace Filesystem {
-
bool nodeExists(const std::string& path)
{
struct stat info;
}
void makePath(const std::string& path,
- mode_t mode)
+ mode_t mode)
{
if (mkpath(path.c_str(), mode) == -1) {
ThrowMsg(Commons::PlatformException, "Couldn't create path: " << path);
}
}
-
}
}
namespace WrtDeviceApis {
namespace Filesystem {
-
bool nodeExists(const std::string& path);
void makePath(const std::string& path, mode_t mode);
-
}
}
namespace WrtDeviceApis {
namespace Networking {
EthernetAdapter::EthernetAdapter()
-{
-}
+{}
void EthernetAdapter::addOnConnected(
- const Api::EventConnectedEmitterPtr& emitter)
+ const Api::EventConnectedEmitterPtr& emitter)
{
m_onConnected.attach(emitter);
}
void EthernetAdapter::removeOnConnected(
- Api::EventConnectedEmitter::IdType id)
+ Api::EventConnectedEmitter::IdType id)
{
m_onConnected.detach(id);
}
void EthernetAdapter::addOnDisconnected(
- const Api::EventDisconnectedEmitterPtr& emitter)
+ const Api::EventDisconnectedEmitterPtr& emitter)
{
m_onDisconnected.attach(emitter);
}
void EthernetAdapter::removeOnDisconnected(
- Api::EventDisconnectedEmitter::IdType id)
+ Api::EventDisconnectedEmitter::IdType id)
{
m_onDisconnected.detach(id);
}
public:
bool isConnected() const /* TODO */
- { return false;
+ {
+ return false;
}
// Api::Networking::IConnectionPtr getConnection() const { /* TODO */ }
void addOnConnected(
- const Api::EventConnectedEmitterPtr& emitter);
+ const Api::EventConnectedEmitterPtr& emitter);
void removeOnConnected(Api::EventConnectedEmitter::IdType id);
void addOnDisconnected(
- const Api::EventDisconnectedEmitterPtr& emitter);
+ const Api::EventDisconnectedEmitterPtr& emitter);
void removeOnDisconnected(
- Api::EventDisconnectedEmitter::IdType id);
+ Api::EventDisconnectedEmitter::IdType id);
Api::IAdapter::Type getAdapterType() const;
namespace WrtDeviceApis {
namespace Networking {
-//net_event_callbacks Manager::m_netEventCallbacks = Manager::getNetEventCallbacks();
+//net_event_callbacks Manager::m_netEventCallbacks =
+// Manager::getNetEventCallbacks();
Manager& Manager::getInstance()
{
//
//void Manager::onNetStatusChange(NetStatusInfo_t* status, void *userData) {
// LogDebug("--| ENTER");
-// LogInfo("Type: " << status->transportType << ", status: " << status->WiFiStatus);
+// LogInfo("Type: " << status->transportType << ", status: " <<
+// status->WiFiStatus);
//}
Manager::Manager()
// Api::IAdapter* adapter = NULL;
//
// adapter = new EthernetAdapter();
- // m_adapters.insert(Adapters::value_type(Api::IAdapter::T_ETHERNET, adapter));
+ // m_adapters.insert(Adapters::value_type(Api::IAdapter::T_ETHERNET,
+ // adapter));
//
// adapter = new WifiAdapter();
// m_adapters.insert(Adapters::value_type(Api::IAdapter::T_WIFI, adapter));
//void Manager::attachListeners() {
// int error = 0;
//
-// if ((error = net_register_client(&m_netEventCallbacks, this)) != NET_ERR_NONE) {
-// LogError("Could not register to datanetworking module (" << error << ").");
+// if ((error = net_register_client(&m_netEventCallbacks, this)) !=
+// NET_ERR_NONE) {
+// LogError("Could not register to datanetworking module (" << error <<
+// ").");
// }
//
// if ((error = wlan_client_register(wlanCallback, this)) != WLAN_ERR_NONE) {
// int error = 0;
//
// if ((error = net_deregister_client()) != NET_ERR_NONE) {
-// LogError("Could not deregister from datanetworking module (" << error << ").");
+// LogError("Could not deregister from datanetworking module (" << error <<
+// ").");
// }
//
// if ((error = wlan_client_deregister()) != WLAN_ERR_NONE) {
// int error;
// int profile = 0;
// char ssid[SSID_MAX_LENGTH + 1] = {0};
-// if ((error = wlan_client_get_connected_ap_info(&profile, ssid)) == WLAN_ERR_NONE) {
+// if ((error = wlan_client_get_connected_ap_info(&profile, ssid)) ==
+// WLAN_ERR_NONE) {
// Adapter* connection = new Adapter();
// connection->setType(Api::IAdapter::T_WIFI);
// connection->setName(ssid);
namespace WrtDeviceApis {
namespace Networking {
WifiAdapter::WifiAdapter()
-{
-}
+{}
void WifiAdapter::addOnConnected(
- const Api::EventConnectedEmitterPtr& emitter)
+ const Api::EventConnectedEmitterPtr& emitter)
{
m_onConnected.attach(emitter);
}
void WifiAdapter::removeOnConnected(
- Api::EventConnectedEmitter::IdType id)
+ Api::EventConnectedEmitter::IdType id)
{
m_onConnected.detach(id);
}
void WifiAdapter::addOnDisconnected(
- const Api::EventDisconnectedEmitterPtr& emitter)
+ const Api::EventDisconnectedEmitterPtr& emitter)
{
m_onDisconnected.attach(emitter);
}
void WifiAdapter::removeOnDisconnected(
- Api::EventDisconnectedEmitter::IdType id)
+ Api::EventDisconnectedEmitter::IdType id)
{
m_onDisconnected.detach(id);
}
public:
bool isConnected() const /* TODO */
- { return false;
+ {
+ return false;
}
//Api::Networking::IConnectionPtr getConnection() const { /* TODO */ }
void addOnConnected(
- const Api::EventConnectedEmitterPtr& emitter);
+ const Api::EventConnectedEmitterPtr& emitter);
void removeOnConnected(Api::EventConnectedEmitter::IdType id);
void addOnDisconnected(
- const Api::EventDisconnectedEmitterPtr& emitter);
+ const Api::EventDisconnectedEmitterPtr& emitter);
void removeOnDisconnected(
- Api::EventDisconnectedEmitter::IdType id);
+ Api::EventDisconnectedEmitter::IdType id);
Api::IAdapter::Type getAdapterType() const;
#include <dpl/log/log.h>
#include <dpl/foreach.h>
-
using namespace std;
namespace {
namespace WrtDeviceApis {
namespace PluginManager {
-
-
PluginManager::PluginManager(int widgetHandle,
const string &objectUri,
JSObjectRef object,
PluginManager::~PluginManager()
{
ObjectList::iterator it = m_objectList.begin();
- for (; it != m_objectList.end(); ++it)
- {
+ for (; it != m_objectList.end(); ++it) {
JSValueUnprotect(m_context, it->second);
}
WrtDB::WrtDatabase::detachFromThread();
}
if (widgetType == WrtDB::APP_TYPE_TIZENWEBAPP) {
- JavaScriptObject jsObject = {m_objectInstance,
- m_shortUri};
+ JavaScriptObject jsObject = { m_objectInstance,
+ m_shortUri };
return PluginLogicSingleton::Instance().loadPluginOnDemand(
- handle, jsObject, const_cast<JSGlobalContextRef>(m_context));
+ handle, jsObject, const_cast<JSGlobalContextRef>(m_context));
}
//check does plugin with feature was requested
- FOREACH (it, features)
+ FOREACH(it, features)
{
- if (it->pluginId == handle)
- {
- if(it->rejected)
- {
+ if (it->pluginId == handle) {
+ if (it->rejected) {
LogWarning("Feature rejected by ACE");
continue;
}
- JavaScriptObject jsObject = {m_objectInstance,
- m_shortUri};
+ JavaScriptObject jsObject = { m_objectInstance,
+ m_shortUri };
return PluginLogicSingleton::Instance().loadPluginOnDemand(
- handle, jsObject, const_cast<JSGlobalContextRef>(m_context));
+ handle, jsObject,
+ const_cast<JSGlobalContextRef>(m_context));
}
}
LogError("Plugin not loaded");
return false;
}
-
Api::IPluginManager::PropertyList PluginManager::getProperties() const
{
if (!m_propertyCache.IsNull()) {
WrtDB::WidgetDAOReadOnly dao(m_widgetHandle);
string localUri = m_objectUri + SEPARATOR;
- if (dao.getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
- {
+ if (dao.getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
WrtDB::PluginHandleList pluginHandleList =
WrtDB::PluginDAOReadOnly::getPluginHandleList();
}
}
}
- }
- else
- {
+ } else {
WrtDB::DbWidgetFeatureSet features;
Try
}
void PluginManager::addPropertiesToList(
- JSPropertyNameAccumulatorRef propertyNames) const
+ JSPropertyNameAccumulatorRef propertyNames) const
{
PropertyList properties = getProperties();
CommonsJavaScript::Converter converter(m_context);
JSPropertyNameAccumulatorAddName(propertyNames, name);
JSStringRelease(name);
}
-
}
-
}
}
namespace WrtDeviceApis {
namespace PluginManager {
-
class PluginManager : public Api::IPluginManager
{
-public:
+ public:
PluginManager(int widgetHandle,
const std::string &objectUri,
JSObjectRef object,
PropertyList getProperties() const;
void addPropertiesToList(JSPropertyNameAccumulatorRef propertyNames) const;
-private:
+ private:
typedef std::map<std::string, JSValueRef> ObjectList;
int m_widgetHandle;
ObjectList m_objectList;
JSContextRef m_context;
};
-
}
}
namespace WrtDeviceApis {
namespace Widget {
-
template<typename T>
class Property
{
explicit Property() :
m_value(),
m_valid(false)
- {
- }
+ {}
void setValue(const T& value)
{
}
virtual ~Property()
- {
- }
+ {}
+
private:
T m_value;
bool m_valid;
#include <WidgetDB/IWidgetDB.h>
#include <WidgetDB/WidgetDBMgr.h>
-
namespace WrtDeviceApis {
namespace Widget {
using namespace std;
using namespace WidgetDB::Api;
-Widget::Widget()
+Widget::Widget()
{
using namespace WrtDeviceApis::Commons;
m_widgetId = WrtAccessSingleton::Instance().getWidgetId();
}
Widget::~Widget()
-{
-}
+{}
string Widget::getProperty(ConfigAttribute attr) const
{
checkWidgetId();
if (!m_height.isValid()) {
- m_height.setValue(Commons::String::toInt(
- getProperty(ConfigAttribute::HEIGHT)));
+ m_height.setValue(Commons::String::convertTo<int>(
+ getProperty(ConfigAttribute::HEIGHT)));
}
return m_height.getValue();
}
checkWidgetId();
if (!m_width.isValid()) {
- m_width.setValue(Commons::String::toInt(
- getProperty(ConfigAttribute::WIDTH)));
+ m_width.setValue(Commons::String::convertTo<int>(
+ getProperty(ConfigAttribute::WIDTH)));
}
return m_width.getValue();
}
namespace WrtDeviceApis {
namespace Widget {
-
class Widget : public Api::IWidget
{
public:
int m_widgetId;
};
-
}
}
#include "WidgetFeature.h"
-
namespace WrtDeviceApis {
namespace WidgetDB {
-
WidgetDB::WidgetDB(int widgetId) : m_widgetId(widgetId) {}
-
int WidgetDB::getWidgetId() const
{
return m_widgetId;
}
// get 'en' language or first from the list if 'en' does not exist
- if (languageTags.size() > 1)
- {
+ if (languageTags.size() > 1) {
FOREACH(lang, languageTags)
{
- if ("en" == DPL::ToUTF8String(*lang))
+ if ("en" == DPL::ToUTF8String(*lang)) {
return "en";
+ }
}
}
- if (!languageTags.empty())
- {
- // get first language tag
+ if (!languageTags.empty()) {
+ // get first language tag
outLanguage = DPL::ToUTF8String(*(languageTags.begin()));
}
return outLanguage;
}
/*License,LicenseHref,Description,Name can be \
- returned with incorect language*/
+ * returned with incorect language*/
std::string WidgetDB::getConfigValue(Api::ConfigAttribute attribute) const
{
LogDebug("entered");
std::ostringstream out;
switch (attribute) {
- case Api::ConfigAttribute::ID: {
+ case Api::ConfigAttribute::ID: {
DPL::OptionalString val = dao.getGUID();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::VERSION: {
DPL::OptionalString val = dao.getVersion();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::DESCRIPTION: {
DPL::OptionalString val = widgetInfo.description;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::LICENSE: {
DPL::OptionalString val = widgetInfo.license;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::LICENSE_HREF: {
DPL::OptionalString val = widgetInfo.licenseHref;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_NAME: {
DPL::OptionalString val = dao.getAuthorName();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_EMAIL: {
DPL::OptionalString val = dao.getAuthorEmail();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::AUTHOR_HREF: {
DPL::OptionalString val = dao.getAuthorHref();
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::NAME: {
DPL::OptionalString val = widgetInfo.name;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::SHORT_NAME: {
DPL::OptionalString val = widgetInfo.shortName;
value = !val ? "" : DPL::ToUTF8String(*val);
- break; }
+ break;
+ }
case Api::ConfigAttribute::ACCESS_NETWORK:
value = dao.getAccessNetworkMode() ? "yes" : "no";
DPL::OptionalInt width = dao.getPreferredSize().width;
!width ? out << "0" : out << *width;
value = out.str();
- break; }
+ break;
+ }
case Api::ConfigAttribute::HEIGHT: {
DPL::OptionalInt height = dao.getPreferredSize().height;
!height ? out << "0" : out << *height;
value = out.str();
- break; }
+ break;
+ }
case Api::ConfigAttribute::INSTALL_PATH:
value = DPL::ToUTF8String(dao.getPath());
return value;
}
-
-
std::string WidgetDB::getUserAgent() const
{
- LogDebug("Widget User_Agent data get");
+ LogDebug("Widget User_Agent data get");
- std::string outUA("not implemented");
- return outUA;
+ std::string outUA("not implemented");
+ return outUA;
}
Api::InstallationStatus WidgetDB::checkInstallationStatus(
const std::string& name,
const std::string& version) const
{
- LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
- "), version(" << version << ")) installation status");
+ LogDebug("Checking widget ( gid(" << gid << "), name(" << name <<
+ "), version(" << version << ")) installation status");
Api::InstallationStatus outStatus;
Try
try {
WrtDB::DbWidgetHandle widgetHandle =
- WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
+ WrtDB::WidgetDAOReadOnly::getHandle(w_guid);
WrtDB::WidgetDAOReadOnly dao(widgetHandle);
DPL::OptionalString ver = dao.getVersion();
} else {
outStatus = Api::InstallationStatus::STATUS_LATEST;
}
- }catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
+ } catch (WrtDB::WidgetDAOReadOnly::Exception::WidgetNotExist) {
outStatus = Api::InstallationStatus::STATUS_UNINSTALLED;
}
}
return outStatus;
}
-
Api::Features WidgetDB::getWidgetFeatures() const
{
LogDebug("entered");
FOREACH(it, features)
{
Api::IWidgetFeaturePtr feature(
- new WidgetFeature(DPL::ToUTF8String((*it).name),
- (*it).required,
- true)); // requested (WidgetFeature param)
+ new WidgetFeature(DPL::ToUTF8String((*it).name),
+ (*it).required,
+ true)); // requested (WidgetFeature param)
// iterating multimap
FOREACH(iterator, (*it).params)
{
// feature is not on outRegisteredFeature so add it with
// 'required' property false
Api::IWidgetFeaturePtr newFeature(new WidgetFeature(
- dao.GetName(),
- false,
- false));
+ dao.GetName(),
+ false,
+ false));
// TODO what about feature params? aren't they needed
outRegisteredFeatures.push_back(newFeature);
return outRegisteredFeatures;
}
-
std::string WidgetDB::getWidgetInstallationPath() const
{
Try
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
std::string result(DPL::ToUTF8String(dao.getFullPath()));
- result.erase(0,strlen("file://"));
+ result.erase(0, strlen("file://"));
std::string::size_type pos = result.size();
std::string separator("/");
pos = result.rfind(separator, pos);
- if((result.size()-pos) >0 && (result.size()-pos) < 2)
- {
+ if ((result.size() - pos) > 0 && (result.size() - pos) < 2) {
result.erase(pos, result.size());
}
- return result;
+ return result;
}
Catch(DPL::Exception)
{
Try
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
- return WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(dao.getPkgName());
+ return
+ WrtDB::WidgetConfig::GetWidgetPersistentStoragePath(
+ dao.getTizenPkgId());
}
Catch(DPL::Exception)
{
Try
{
WrtDB::WidgetDAOReadOnly dao(getWidgetId());
- return WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(dao.getPkgName());
+ return
+ WrtDB::WidgetConfig::GetWidgetTemporaryStoragePath(
+ dao.getTizenPkgId());
}
Catch(DPL::Exception)
{
ReThrow(Commons::PlatformException);
}
}
-
} // WidgetDB
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace WidgetDB {
-
class WidgetDB : public Api::IWidgetDB
{
public:
virtual std::string getUserAgent() const;
virtual Api::InstallationStatus checkInstallationStatus(
- const std::string& gid,
- const std::string& name,
- const std::string& version) const;
+ const std::string& gid,
+ const std::string& name,
+ const std::string& version) const;
virtual Api::Features getWidgetFeatures() const;
private:
int m_widgetId;
-
};
-
} // WidgetDB
} // WrtDeviceApis
#endif // WRTDEVICEAPIS_WIDGETDB_WIDGETDB_H
-
namespace WrtDeviceApis {
namespace WidgetDB {
-
WidgetFeature::WidgetFeature(const std::string& name,
bool required,
bool requested) :
}
void WidgetFeature::addParam(const std::string& paramName,
- const std::string& paramValue)
+ const std::string& paramValue)
{
//LogDebug("entered");
m_params.push_back(std::make_pair(paramName, paramValue));
{
return m_requested;
}
-
} // WidgetDB
} // WrtDeviceApis
namespace WrtDeviceApis {
namespace WidgetDB {
-
class WidgetFeature : public Api::IWidgetFeature
{
public:
WidgetFeature(const std::string& name,
- bool required,
- bool requested);
+ bool required,
+ bool requested);
std::string getName() const;
virtual ~WidgetFeature();
virtual void addParam(const std::string& paramName,
- const std::string& paramValue);
+ const std::string& paramValue);
virtual bool isRequestedByWidget() const;
bool m_requested;
Params m_params;
};
-
} // WidgetDB
} // WrtDeviceApis
}
namespace WrtDeviceApis {
-
WidgetInterfaceDAO::WidgetInterfaceDAO(int widgetHandle) :
m_widgetHandle(widgetHandle),
m_databaseInterface(databaseFileName(widgetHandle), DATABASE_FLAGS)
std::string databaseFile = databaseFileName(m_widgetHandle);
struct stat buffer;
if (stat(databaseFile.c_str(), &buffer) != 0) {
-
//Create fresh database
LogInfo("Creating database " << databaseFile);
Try
{
DPL::DB::SqlConnection con(databaseFile,
- DATABASE_FLAGS, DATABASE_OPTIONS);
+ DATABASE_FLAGS, DATABASE_OPTIONS);
con.ExecCommand(buffer.str().c_str());
}
Catch(DPL::DB::SqlConnection::Exception::Base)
Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<Properties::Row> rows = select.GetRowList();
- if (rows.size() == 0) {
+ if (rows.empty()) {
Properties::Insert insert(&m_databaseInterface);
Properties::Row row;
row.Set_key(DPL::FromUTF8String(key));
row.Set_configxml(fromConfigXml ? 1 : 0);
insert.Values(row);
insert.Execute();
- }
- else {
+ } else {
Assert(rows.size() == 1);
Properties::Row row = rows.front();
if (row.Get_readonly() != 0) {
LogError("Cannot set item " << key << " with value " << value);
ReThrow(Commons::PlatformException);
}
-
}
void WidgetInterfaceDAO::removeItem(const std::string& key)
bool readonly = select.GetSingleValue<Properties::readonly>();
if (readonly) {
ThrowMsg(Commons::LocalStorageValueNoModifableException,
- "Cannot delete item. Item is readonly");
+ "Cannot delete item. Item is readonly");
}
Properties::Delete deleteItem(&m_databaseInterface);
deleteItem.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
}
DPL::Optional<std::string> WidgetInterfaceDAO::getValue(
- const std::string& key) const
+ const std::string& key) const
{
using namespace DPL::DB::ORM;
using namespace DPL::DB::ORM::widget_interface;
Properties::Select select(&m_databaseInterface);
select.Where(Equals<Properties::key>(DPL::FromUTF8String(key)));
std::list<DPL::String> value = select.GetValueList<Properties::value>();
- if (value.size() == 0) {
+ if (value.empty()) {
return DPL::Optional<std::string>();
}
return DPL::Optional<std::string>(DPL::ToUTF8String(value.front()));
Try
{
WrtDB::WidgetDAOReadOnly widgetDAO(widgetHandle);
- WrtDB::WidgetPkgName pkgname = widgetDAO.getPkgName();
+ WrtDB::TizenPkgId pkgid = widgetDAO.getTizenPkgId();
- filename << GetWidgetPersistentStoragePath(pkgname)
+ filename << GetWidgetPersistentStoragePath(pkgid)
<< "/"
<< GetWidgetInterfaceDatabaseFile();
}
WrtDB::WrtDatabase::detachFromThread();
return filename.str();
}
-
}
#include <LocalStorage/ILocalStorage.h>
namespace WrtDeviceApis {
-
class WidgetInterfaceDAO :
public LocalStorage::Api::ILocalStorage
{
bool copyPropertiesFromWrtDatabase();
static std::string databaseFileName(int widgetHandle);
};
-
}
#endif //WRTDEVICEAPIS_COMMONS_WIDGET_INTERFACE_DAO_H_
\ No newline at end of file
* @file wrt_db_sql_generator.h
* @author Bartosz Janiak (b.janiak@samsung.com)
* @version 1.0
- * @brief Macro definitions for generating the SQL input file from database definition.
+ * @brief Macro definitions for generating the SQL input file from
+ * database definition.
*/
//Do not include this file directly! It is used only for SQL code generation.
#include "explorer.h"
#include "plugin_property_support.h"
-// JS overlay
+// JS overlay
#include <js_overlay_support.h>
#include <js_overlay_types.h>
#include <js_overlay_addEventListener.h>
#include <JSClass/JSTizenServiceEvent.h>
#include <JSClass/JSSoftKeyboardChangeEvent.h>
-
namespace {
//const char* SEPARATOR = ".";
const std::string GLOBAL_OBJECT_NAME = "GLOBAL_OBJECT";
m_propertySupport.reset(new WindowPropertySupport(m_context));
// initialization for use of custom event
- if (!AddEventListenerSupport::isInitialized())
- {
+ if (!AddEventListenerSupport::isInitialized()) {
LogInfo("initialization for use of custom event");
AddEventListenerSupport::initialize(context);
}
AddEventListenerSupport::deinitialize();
}
}
-
+
JSObjectPtr Explorer::getJSObjectProperty(const std::string& propertyName,
- JSObjectPtr object)
+ JSObjectPtr object)
{
LogDebug("Get object property " << propertyName);
return JavaScriptInterfaceSingleton::Instance().getJSObjectProperty(
- m_context, object, propertyName);
+ m_context, object, propertyName);
}
JSObjectPtr Explorer::getProperty(
const string& requestedProperty,
- JSObjectPtr providedObject)
+ JSObjectPtr providedObject)
{
LogDebug("Requested Property: " << requestedProperty);
- if(!providedObject)
- {
+ if (!providedObject) {
LogError("Provided object is empty");
return JSObjectPtr();
}
std::string currentPropertyRequested = requestedProperty;
JSObjectPtr currentObject = providedObject;
- while(true)
- {
+ while (true) {
auto pos = currentPropertyRequested.find(".");
- if (pos == string::npos)
- {
+ if (pos == string::npos) {
return getJSObjectProperty(currentPropertyRequested, currentObject);
}
//check if requested object has child
- currentObjectName = currentPropertyRequested.substr(0,pos);
+ currentObjectName = currentPropertyRequested.substr(0, pos);
- if (currentPropertyRequested.size() <= pos+1)
- {
+ if (currentPropertyRequested.size() <= pos + 1) {
LogError("Wrong name of requested property");
return JSObjectPtr();
}
- currentPropertyRequested = currentPropertyRequested.substr(pos+1);
+ currentPropertyRequested = currentPropertyRequested.substr(pos + 1);
currentObject = getJSObjectProperty(currentObjectName, currentObject);
- if(!currentObject)
- {
+ if (!currentObject) {
LogError("Failed to get property: " << currentObjectName);
return JSObjectPtr();
}
bool retValue;
- if (declaration->getParentName() == GLOBAL_OBJECT_NAME)
- {
+ if (declaration->getParentName() == GLOBAL_OBJECT_NAME) {
LogDebug("Connect to Global object");
retValue = register_(declaration, m_globalObject, context);
- }
- else //PIM support
- {
+ } else { //PIM support
LogDebug("Connect to NOT global object");
//it should be master object name
string masterName = declaration->getParentName();
auto pos = masterName.find(".");
- if (string::npos != pos)
- {
+ if (string::npos != pos) {
LogError("ParentName not allowed");
return false;
}
auto masterObject = getJSObjectProperty(masterName, m_globalObject);
- if (masterObject->getObject() == 0)
- {
+ if (masterObject->getObject() == 0) {
return false;
}
- retValue = registerObject(declaration, masterName, masterObject, context);
+ retValue = registerObject(declaration,
+ masterName,
+ masterObject,
+ context);
}
if (declaration->checkIframesSupported()) {
LogDebug("Iframe supported");
m_iframeSupport.registerDeclaration(declaration);
-// m_iframeSupport.invokeCallbackForMainFrame(m_context,
-// declaration,
-// newObject);
- }
- else {
+ // m_iframeSupport.invokeCallbackForMainFrame(m_context,
+ // declaration,
+ // newObject);
+ } else {
LogDebug("Iframe NOT supported");
}
return retValue;
}
-
bool Explorer::registerObject(const JSObjectDeclarationPtr& declaration,
- const std::string& providedObjectName,
- JSObjectPtr providedObject,
- JSGlobalContextRef context)
+ const std::string& providedObjectName,
+ JSObjectPtr providedObject,
+ JSGlobalContextRef context)
{
- LogDebug("Register object. Provided object name: '" << providedObjectName
- << "', registration of: '" << declaration->getName() << "'");
+ LogDebug(
+ "Register object. Provided object name: '" << providedObjectName
+ <<
+ "', registration of: '" << declaration->getName() << "'");
std::string fullParentName = declaration->getParentName();
LogDebug("Parent name: " << declaration->getParentName());
- if(fullParentName == providedObjectName)
- {
+ if (fullParentName == providedObjectName) {
LogDebug("Provided object match equaly to requested parent");
return register_(declaration, providedObject, context);
}
//check if object exists in fullParentName
auto pos = fullParentName.find(providedObjectName);
- if(pos == string::npos)
- {
- LogError("Object: " << declaration->getName()
- << " should be child of: " << declaration->getParentName()
- << " but you provided object: " << providedObjectName);
+ if (pos == string::npos) {
+ LogError(
+ "Object: " << declaration->getName()
+ << " should be child of: " <<
+ declaration->getParentName()
+ << " but you provided object: " <<
+ providedObjectName);
return false;
}
- if (fullParentName.size() <= pos+providedObjectName.size()+1)
- {
+ if (fullParentName.size() <= pos + providedObjectName.size() + 1) {
LogError("Invalid object name");
return false;
}
auto currentRequesteProperty =
- fullParentName.substr(pos+providedObjectName.size()+1);
-
+ fullParentName.substr(pos + providedObjectName.size() + 1);
JSObjectPtr jsObject = getProperty(
- currentRequesteProperty, providedObject);
+ currentRequesteProperty, providedObject);
- if(!jsObject->getObject())
- {
- LogError("Object: '" << declaration->getName()
- << "' should be child of: '" << declaration->getParentName()
- << "'. you provided object: '" << providedObjectName
- << "' but object is null");
+ if (!jsObject->getObject()) {
+ LogError(
+ "Object: '" << declaration->getName()
+ << "' should be child of: '" <<
+ declaration->getParentName()
+ << "'. you provided object: '" <<
+ providedObjectName
+ << "' but object is null");
return false;
}
}
bool Explorer::register_(const JSObjectDeclarationPtr& declaration,
- JSObjectPtr parent,
- JSGlobalContextRef context)
+ JSObjectPtr parent,
+ JSGlobalContextRef context)
{
LogInfo("Registration object: " << declaration->getParentName() <<
"<-" << declaration->getName());
typedef JSObjectDeclaration::Options JO;
- JSGlobalContextRef gContext = (context==NULL)?m_context:context;
+ JSGlobalContextRef gContext = (context == NULL) ? m_context : context;
JSObjectPtr newObject;
JSObjectPtr objectInstance = JavaScriptInterfaceSingleton::Instance().
- createObject(gContext,declaration);
+ createObject(gContext, declaration);
//function creation
if (declaration->getOptions() &&
LogDebug("Loading function object " << declaration->getName());
auto type = declaration->getOptions()->getIframeOverlay();
- if (JO::IFrameOverlay::OverlayedBeforeOriginal == type)
- {
+ if (JO::IFrameOverlay::OverlayedBeforeOriginal == type) {
LogDebug("Create overlayed function");
JSObjectPtr original =
JavaScriptInterfaceSingleton::Instance().
- getJSObjectProperty(gContext,
- parent,
- declaration->getName());
+ getJSObjectProperty(gContext,
+ parent,
+ declaration->getName());
newObject = JSOverlaySupport::
- createWrappedFunction(gContext,
- original,
- objectInstance,
- declaration->getName());
- }
- else
- {
+ createWrappedFunction(gContext,
+ original,
+ objectInstance,
+ declaration->getName());
+ } else {
LogDebug("create normal function");
newObject = objectInstance;
}
- }
- else //object creation
- {
+ } else { //object creation
newObject = objectInstance;
}
JavaScriptInterfaceSingleton::Instance().setObjectProperty(
- gContext,
+ gContext,
parent,
declaration->getName(),
newObject);
objectInstance->getObject());
}
-
return true;
}
-void Explorer::registerObjectIntoIframe(const JSObjectDeclarationPtr& declaration,
- JSObjectPtr frameObject,
- JSGlobalContextRef context)
+void Explorer::registerObjectIntoIframe(
+ const JSObjectDeclarationPtr& declaration,
+ JSObjectPtr frameObject,
+ JSGlobalContextRef context)
{
- if (declaration->getParentName() == GLOBAL_OBJECT_NAME)
- {
+ if (declaration->getParentName() == GLOBAL_OBJECT_NAME) {
LogDebug("Connect to Global object of IFRAME");
register_(declaration, frameObject, context);
return;
//it should be master object name
string masterName = declaration->getParentName();
auto pos = masterName.find(".");
- if (string::npos != pos)
- {
+ if (string::npos != pos) {
LogError("ParentName not allowed");
return;
}
auto masterObject = getJSObjectProperty(masterName, frameObject);
- if (!masterObject->getObject())
- {
+ if (!masterObject->getObject()) {
LogError("Object not exist in frame");
return;
}
}
}
-
void Explorer::loadFrame(JSGlobalContextRef context)
{
LogDebug("Frame attached");
LogDebug("Register main frame");
//register main frame;
- if(frameObject->getObject() == m_globalObject->getObject())
- {
+ if (frameObject->getObject() == m_globalObject->getObject()) {
// Main page was already loaded from constructor
LogDebug("Main page loaded");
return;
{
LogDebug("Remove plugins from iframes");
- if (m_iframeSupport.hasIframes())
- {
+ if (m_iframeSupport.hasIframes()) {
LogDebug("Removing iframes");
JavaScriptInterfaceSingleton::Instance().removeIframes(m_context);
}
{
LogDebug("Deregister object " << declaration->getName());
- if (GLOBAL_OBJECT_NAME != declaration->getParentName())
- {
+ if (GLOBAL_OBJECT_NAME != declaration->getParentName()) {
LogWarning("Ignored remove property " << declaration->getName());
return;
}
if (eventType == ServiceCustomEvent) {
using namespace WrtDeviceApis::TizenServiceEvent::Api;
// set user data of js callback function for 'appservice' js event
- ITizenServiceEventPtr event = ITizenServiceEventPtr(new TizenServiceEvent());
+ ITizenServiceEventPtr event = ITizenServiceEventPtr(
+ new TizenServiceEvent());
event->setScale(m_propertySupport->getScale());
event->setBundle(m_propertySupport->getBundle());
auto eventPriv =
new JSTizenServiceEventPrivateObject(m_context, event);
JSObjectRef eventObject =
- JSObjectMake(m_context, JSTizenServiceEvent::getClassRef(), eventPriv);
+ JSObjectMake(m_context,
+ JSTizenServiceEvent::getClassRef(), eventPriv);
AddEventListenerSupport::CallCustomEventListenersFromIFrame(
- frame, eventType, eventObject);
+ frame, eventType, eventObject);
}
} else if (eventType == SoftKeyboardChangeCustomEvent) {
using namespace WrtDeviceApis::SoftKeyboardChangeEvent::Api;
return;
}
- // set user data of js callback function for 'softkeyboardchange' js event
- SoftKeyboardChangeArgs* args = static_cast<SoftKeyboardChangeArgs *>(data);
+ // set user data of js callback function for 'softkeyboardchange' js
+ // event
+ SoftKeyboardChangeArgs* args =
+ static_cast<SoftKeyboardChangeArgs *>(data);
ISoftKeyboardChangeEventPtr event =
ISoftKeyboardChangeEventPtr(
- new SoftKeyboardChangeEvent(
- args->state,
- args->width,
- args->height));
+ new SoftKeyboardChangeEvent(
+ args->state,
+ args->width,
+ args->height));
LogInfo("softkeyboard event's state: " << args->state);
- // call js callback function for 'softkeyboardchange' js event on each frame
+ // call js callback function for 'softkeyboardchange' js event on each
+ // frame
FOREACH(it, *frameLists)
{
JSObjectRef frame = static_cast<JSObjectRef>((*it).Get()->getObject());
new JSSoftKeyboardChangeEventPrivateObject(m_context, event);
JSObjectRef eventObject =
JSObjectMake(
- m_context,
- JSSoftKeyboardChangeEvent::getClassRef(),
- eventPriv);
+ m_context,
+ JSSoftKeyboardChangeEvent::getClassRef(),
+ eventPriv);
AddEventListenerSupport::CallCustomEventListenersFromIFrame(
- frame, eventType, eventObject);
+ frame, eventType, eventObject);
}
} else {
LogInfo("Not supported custom event type");
return;
}
-
}
WindowPropertySupport* Explorer::getWindowPropertySupport()
JSGlobalContextRef context);
bool register_(const JSObjectDeclarationPtr& declaration,
- JSObjectPtr parent,
- JSGlobalContextRef context);
-
+ JSObjectPtr parent,
+ JSGlobalContextRef context);
JSObjectPtr getJSObjectProperty(const std::string& propertyName,
- JSObjectPtr object);
+ JSObjectPtr object);
JSObjectPtr getProperty(
const std::string& requestedProperty,
- JSObjectPtr providedObject);
+ JSObjectPtr providedObject);
};
typedef DPL::SharedPtr<Explorer> ExplorerPtr;
IMPLEMENT_SINGLETON(JavaScriptInterface)
#define CHECK_JSVALUE_IS_UNDEFINED_RETURN(context, object, ret) \
- if (JSValueIsUndefined(context, object)) {\
- LogError("Object " << #object << " is undefined");\
- return ret;\
+ if (JSValueIsUndefined(context, object)) { \
+ LogError("Object " << #object << " is undefined"); \
+ return ret; \
}
#define CHECK_JSOBJECT_IS_NULL_RETURN(object, ret) \
- if (!object) {\
- LogError("Object " << #object << " is NULL");\
- return ret;\
+ if (!object) { \
+ LogError("Object " << #object << " is NULL"); \
+ return ret; \
}
namespace {
/**
* Converts JSValueRef to std::string
* */
-std::string toString(JSContextRef ctx, JSValueRef value) {
- Assert(ctx && value);
- std::string result;
- JSStringRef str = JSValueToStringCopy(ctx, value, NULL);
- result = toString(str);
- JSStringRelease(str);
- return result;
+std::string toString(JSContextRef ctx, JSValueRef value)
+{
+ Assert(ctx && value);
+ std::string result;
+ JSStringRef str = JSValueToStringCopy(ctx, value, NULL);
+ result = toString(str);
+ JSStringRelease(str);
+ return result;
}
-JSValueRef getProperty(JSContextRef ctx, JSValueRef value, const char* name) {
- Assert(ctx && value && name);
- JSValueRef result = NULL;
- JSObjectRef obj = JSValueToObject(ctx, value, NULL);
- if (obj) {
- JSStringRef str = JSStringCreateWithUTF8CString(name);
- result = JSObjectGetProperty(ctx, obj, str, NULL);
- JSStringRelease(str);
- }
- return result;
+JSValueRef getProperty(JSContextRef ctx, JSValueRef value, const char* name)
+{
+ Assert(ctx && value && name);
+ JSValueRef result = NULL;
+ JSObjectRef obj = JSValueToObject(ctx, value, NULL);
+ if (obj) {
+ JSStringRef str = JSStringCreateWithUTF8CString(name);
+ result = JSObjectGetProperty(ctx, obj, str, NULL);
+ JSStringRelease(str);
+ }
+ return result;
}
-JSValueRef getPropertyObj(JSContextRef ctx, JSObjectRef obj, const char* name) {
- Assert(ctx && obj && name);
- JSStringRef str = JSStringCreateWithUTF8CString(name);
- JSValueRef result = JSObjectGetProperty(ctx, obj, str, NULL);
- JSStringRelease(str);
- return result;
+JSValueRef getPropertyObj(JSContextRef ctx, JSObjectRef obj, const char* name)
+{
+ Assert(ctx && obj && name);
+ JSStringRef str = JSStringCreateWithUTF8CString(name);
+ JSValueRef result = JSObjectGetProperty(ctx, obj, str, NULL);
+ JSStringRelease(str);
+ return result;
}
-JSObjectRef getJSGlobalObject(JSGlobalContextRef context){
+JSObjectRef getJSGlobalObject(JSGlobalContextRef context)
+{
return JSContextGetGlobalObject(context);
}
-
}
typedef JSValueRef (*JSCFunction)(
const JSValueRef arguments[],
JSValueRef* exception);
-
void JavaScriptInterface::setObjectProperty(JSGlobalContextRef context,
- const JSObjectPtr& parentObject,
- const std::string &propertyName,
- const JSObjectPtr& propertyObject)
+ const JSObjectPtr& parentObject,
+ const std::string &propertyName,
+ const JSObjectPtr& propertyObject)
{
LogInfo("Webkit:setting property --" << propertyName << "--");
}
void JavaScriptInterface::removeObjectProperty(JSGlobalContextRef context,
- const JSObjectPtr& parentObject,
- const std::string &propertyName)
+ const JSObjectPtr& parentObject,
+ const std::string &propertyName)
{
if (!context) {
//nothing to do -> no context
JSStringRelease(name);
}
-JavaScriptInterface::PropertiesList JavaScriptInterface::getObjectPropertiesList(
- JSGlobalContextRef context,
- const JSObjectPtr& object) const
+JavaScriptInterface::PropertiesList JavaScriptInterface::
+ getObjectPropertiesList(
+ JSGlobalContextRef context,
+ const JSObjectPtr& object) const
{
PropertiesList result;
JSPropertyNameArrayRef properties = JSObjectCopyPropertyNames(
}
JSObjectPtr JavaScriptInterface::makeJSFunctionObject(
- JSGlobalContextRef context,
- const std::string &name,
- js_function_impl functionImplementation) const
+ JSGlobalContextRef context,
+ const std::string &name,
+ js_function_impl functionImplementation) const
{
LogDebug("Create JS function");
JSStringRef jsFunName = JSStringCreateWithUTF8CString(name.c_str());
JSObjectRef object = JSObjectMakeFunctionWithCallback(
- context,
- jsFunName,
- reinterpret_cast<JSObjectCallAsFunctionCallback>(
+ context,
+ jsFunName,
+ reinterpret_cast<JSObjectCallAsFunctionCallback>(
functionImplementation));
JSStringRelease(jsFunName);
}
JSObjectPtr JavaScriptInterface::makeJSClassObject(
- JSGlobalContextRef context,
- JSObjectDeclaration::ConstClassTemplate classTemplate) const
+ JSGlobalContextRef context,
+ JSObjectDeclaration::ConstClassTemplate classTemplate) const
{
LogDebug("Create JS object");
JSObjectRef object = JSObjectMake(
}
JSObjectPtr JavaScriptInterface::makeJSObjectBasedOnInterface(
- JSGlobalContextRef context,
- const std::string &interfaceName) const
+ JSGlobalContextRef context,
+ const std::string &interfaceName) const
{
LogDebug("Create JS object base on interface: " << interfaceName);
LogDebug("Context: " << context);
-
JSObjectPtr jsInterfaceObj = getJSObjectProperty(context,
- getGlobalObject(context), interfaceName);
+ getGlobalObject(
+ context),
+ interfaceName);
JSObjectRef object = JSObjectCallAsConstructor(context,
- static_cast<JSObjectRef>(jsInterfaceObj->getObject()), 0, NULL,
- NULL);
+ static_cast<JSObjectRef>(
+ jsInterfaceObj->
+ getObject()), 0,
+ NULL,
+ NULL);
return JSObjectPtr(new JSObject(static_cast<void*>(object)));
}
JSObjectPtr JavaScriptInterface::makeJSInterface(
- JSGlobalContextRef context,
- JSObjectDeclaration::ConstClassTemplate classTemplate,
- JSObjectDeclaration::ConstructorCallback constructorCallback) const
+ JSGlobalContextRef context,
+ JSObjectDeclaration::ConstClassTemplate classTemplate,
+ JSObjectDeclaration::ConstructorCallback constructorCallback) const
{
LogDebug("Create JS interface. Context: " << context);
JSObjectRef object = JSObjectMakeConstructor(context,
- static_cast<JSClassRef>(
- const_cast<JSObjectDeclaration::ClassTemplate>(
- classTemplate)),
- reinterpret_cast<JSObjectCallAsConstructorCallback>(
- constructorCallback)
- );
+ static_cast<JSClassRef>(
+ const_cast<
+ JSObjectDeclaration::
+ ClassTemplate>(
+ classTemplate)),
+ reinterpret_cast<
+ JSObjectCallAsConstructorCallback>(
+ constructorCallback)
+ );
return JSObjectPtr(new JSObject(static_cast<void*>(object)));
}
-JSObjectPtr JavaScriptInterface::createObject(JSGlobalContextRef context,
- const JSObjectDeclarationPtr& declaration)
+JSObjectPtr JavaScriptInterface::createObject(
+ JSGlobalContextRef context,
+ const JSObjectDeclarationPtr&
+ declaration)
{
typedef JSObjectDeclaration::Options JO;
- if( declaration->getOptions())
- {
- switch (declaration->getOptions()->getType())
- {
+ if (declaration->getOptions()) {
+ switch (declaration->getOptions()->getType()) {
case JO::ClassType::Function:
return makeJSFunctionObject(
- context,
- declaration->getName(),
- declaration->getOptions()->getFunctionImpl());
+ context,
+ declaration->getName(),
+ declaration->getOptions()->getFunctionImpl());
case JO::ClassType::Class:
if (declaration->getInterfaceName().empty()) {
return makeJSClassObject(
- context,
- declaration->getClassTemplate());
+ context,
+ declaration->getClassTemplate());
} else {
return makeJSObjectBasedOnInterface(
- context,
- declaration->getInterfaceName());
+ context,
+ declaration->getInterfaceName());
}
case JO::ClassType::Interface:
return makeJSInterface(
- context,
- /* product class template */
- declaration->getClassTemplate(),
- declaration->getConstructorCallback());
+ context,
+ /* product class template */
+ declaration->getClassTemplate(),
+ declaration->getConstructorCallback());
default:
LogError("Invalid class type. Making empty JS object.");
return JSObjectPtr(new JSObject(
- JSObjectMake(context, NULL, NULL)));
+ JSObjectMake(context, NULL, NULL)));
}
} else {
LogDebug("No declaration options");
return JSObjectPtr(new JSObject(
- JSObjectMake(
- context,
- static_cast<JSClassRef>(
- const_cast<JSObjectDeclaration::ClassTemplate>(
- declaration->getClassTemplate())),
- NULL)));
+ JSObjectMake(
+ context,
+ static_cast<JSClassRef>(
+ const_cast<JSObjectDeclaration::
+ ClassTemplate>(
+ declaration->getClassTemplate())),
+ NULL)));
}
}
JSObjectPtr JavaScriptInterface::getGlobalObject(JSGlobalContextRef context)
- const
+const
{
return JSObjectPtr(new JSObject(static_cast<JSObject::RealObject>(
- JSContextGetGlobalObject(static_cast<JSGlobalContextRef>(context)))));
+ JSContextGetGlobalObject(static_cast<
+ JSGlobalContextRef>(
+ context)))));
}
JSObjectPtr JavaScriptInterface::copyObjectToIframe(
JSStringRelease(requestedObjectStr);
return JSObjectPtr(
- new JSObject(const_cast<OpaqueJSValue*>(requestedObject)));
+ new JSObject(const_cast<OpaqueJSValue*>(requestedObject)));
}
JavaScriptInterface::ObjectsListPtr
}
JSObjectPtr JavaScriptInterface::getJSObjectProperty(JSGlobalContextRef ctx,
- const JSObjectPtr& frame,
- const std::string& name) const
+ const JSObjectPtr& frame,
+ const std::string& name)
+const
{
JSObjectRef frame_js = static_cast<JSObjectRef>(frame->getObject());
//forward declaration of JSConectexRef
extern "C" {
- typedef const struct OpaqueJSContext* JSContextRef;
- typedef struct OpaqueJSContext* JSGlobalContextRef;
- typedef struct OpaqueJSValue* JSObjectRef;
+typedef const struct OpaqueJSContext* JSContextRef;
+typedef struct OpaqueJSContext* JSGlobalContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
}
class JavaScriptInterface : DPL::Noncopyable
void invokeGarbageCollector(JSGlobalContextRef context);
JSObjectPtr getJSObjectProperty(JSGlobalContextRef ctx,
- const JSObjectPtr& frame,
- const std::string& name) const;
+ const JSObjectPtr& frame,
+ const std::string& name) const;
private:
JavaScriptInterface()
- {
- }
+ {}
JSObjectPtr makeJSFunctionObject(
- JSGlobalContextRef context,
- const std::string &name,
- js_function_impl functionImplementation) const;
+ JSGlobalContextRef context,
+ const std::string &name,
+ js_function_impl functionImplementation) const;
JSObjectPtr makeJSClassObject(
- JSGlobalContextRef context,
- JSObjectDeclaration::ConstClassTemplate classTemplate) const;
+ JSGlobalContextRef context,
+ JSObjectDeclaration::ConstClassTemplate classTemplate) const;
JSObjectPtr makeJSObjectBasedOnInterface(
- JSGlobalContextRef context,
- const std::string &interfaceName) const;
+ JSGlobalContextRef context,
+ const std::string &interfaceName) const;
JSObjectPtr makeJSInterface(
- JSGlobalContextRef context,
- JSObjectDeclaration::ConstClassTemplate classTemplate,
- JSObjectDeclaration::ConstructorCallback constructorCallback) const;
+ JSGlobalContextRef context,
+ JSObjectDeclaration::ConstClassTemplate classTemplate,
+ JSObjectDeclaration::ConstructorCallback constructorCallback) const;
ObjectsListPtr getIframesList(JSContextRef context,
- JSObjectRef object) const;
+ JSObjectRef object) const;
friend class DPL::Singleton<JavaScriptInterface>;
};
const char* theme);
void dispatchJavaScriptEvent(CustomEventType eventType, void* data);
-
};
-
JSPageSession::Impl::Impl(const PluginContainerSupportPtr& support) :
- m_sessionStarted(false)
+ m_widgetHandle(0),
+ m_context(NULL),
+ m_sessionStarted(false),
+ m_objectExplorer(NULL)
{
-// DPL::Log::LogSystemSingleton::Instance().SetTag("WRT_PLUGINS");
+ // DPL::Log::LogSystemSingleton::Instance().SetTag("WRT_PLUGINS");
LogDebug("Initializing Page Session");
m_pluginsSupport = support;
// explicit call to keep singleton's lifetime until calling destructor.
-// JsFunctionManagerSingleton::Instance();
-// JavaScriptInterfaceSingleton::Instance();
+ // JsFunctionManagerSingleton::Instance();
+ // JavaScriptInterfaceSingleton::Instance();
}
JSPageSession::Impl::~Impl()
{
- if(m_sessionStarted)
- {
+ if (m_sessionStarted) {
LogError("Must stop widget session before exit!");
stopSession();
}
LogInfo("Install Plugin '" << library->GetFileName());
-
- if(!library)
- {
+ if (!library) {
LogError("Loading library failed");
return false;
}
LogInfo("Installing requested widget features...");
std::list<std::string> allowedFeatures =
- m_pluginsSupport->getAllowedFeatures(m_widgetHandle);
+ m_pluginsSupport->getAllowedFeatures(m_widgetHandle);
PluginContainerSupport::PluginsList allowedPlugins;
auto plugin = m_pluginsSupport->getPluginForFeature(*feature);
ImplementedObjectsList implObjs =
PluginDAOReadOnly::
- getImplementedObjectsForPluginHandle(plugin->Handle.Get());
+ getImplementedObjectsForPluginHandle(plugin->Handle.Get());
FOREACH(obj, implObjs)
{
LogDebug("Processing object: " << *obj);
/* This can be optimalized, but would need extra data in database.
- There should be a list of features that are allowed to be
- installed at widget start */
+ * There should be a list of features that are allowed to be
+ * installed at widget start */
if (obj->find(".") == obj->rfind(".")) {
allowedPlugins.push_back(plugin);
LogWarning("Plugin will be added: "
LogError("Session not started");
return false;
}
-// //TODO here may be a bug. if plugin contains feature rejected and accepted
-// LogInfo("Installing feature : " << widgetFeature.name);
-// if (widgetFeature.rejected) {
-// LogWarning("This api-feature was rejected");
-// return;
-// }
-//
-// auto plugin = m_pluginsSupport->getPluginModelById(pluginHandle);
-// if (!plugin) {
-// LogError("Failed to load plugin. plugin handle: " << pluginHandle);
-// return false;
-// }
+ // //TODO here may be a bug. if plugin contains feature rejected and
+ // accepted
+ // LogInfo("Installing feature : " << widgetFeature.name);
+ // if (widgetFeature.rejected) {
+ // LogWarning("This api-feature was rejected");
+ // return;
+ // }
+ //
+ // auto plugin = m_pluginsSupport->getPluginModelById(pluginHandle);
+ // if (!plugin) {
+ // LogError("Failed to load plugin. plugin handle: " <<
+ // pluginHandle);
+ // return false;
+ // }
m_pluginsSupport->registerPluginModel(pluginHandle);
return installPluginOnDemand(
- m_pluginsSupport->getPluginModelById(pluginHandle),
- parentObject,
- context);
+ m_pluginsSupport->getPluginModelById(pluginHandle),
+ parentObject,
+ context);
}
bool JSPageSession::Impl::installPluginOnDemand(PluginModelPtr plugin,
- JavaScriptObject& parentObject,
- JSGlobalContextRef context)
+ JavaScriptObject& parentObject,
+ JSGlobalContextRef context)
{
Assert(plugin && "Plugin Model is NULL");
auto library = loadLibrary(plugin);
LogInfo("Install Plugin '" << library->GetFileName());
- if(!library)
- {
+ if (!library) {
LogError("Loading library failed");
return false;
}
- if(!(parentObject.instance))
- {
+ if (!(parentObject.instance)) {
LogError("NULL pointer value");
return false;
}
JSObjectPtr parent(new JSObject(parentObject.instance));
- if (!parent->getObject())
- {
+ if (!parent->getObject()) {
LogError("NULL pointer value");
assert(false);
return false;
parent,
context);
- if(!installationStatus)
- {
- LogError("Object Registration failed : " << (*it)->getName()
- << "; Parent object name: " << parentObject.name);
+ if (!installationStatus) {
+ LogError(
+ "Object Registration failed : " << (*it)->getName()
+ <<
+ "; Parent object name: " << parentObject.name);
return false;
}
}
}
void JSPageSession::Impl::setCustomProperties(double scaleFactor,
- const char* encodedBundle,
- const char* theme)
+ const char* encodedBundle,
+ const char* theme)
{
- LogInfo("set properties of window object " << scaleFactor << ", "
- << encodedBundle << ", " << theme);
+ LogInfo(
+ "set properties of window object " << scaleFactor << ", "
+ << encodedBundle << ", " <<
+ theme);
m_objectExplorer->getWindowPropertySupport()
->setScaleToNavigatorProperty(scaleFactor);
->setThemeToNavigatorProperty(theme);
}
-void JSPageSession::Impl::dispatchJavaScriptEvent(CustomEventType eventType, void* data)
+void JSPageSession::Impl::dispatchJavaScriptEvent(CustomEventType eventType,
+ void* data)
{
// Check if session is already started
if (!m_sessionStarted) {
{
LogInfo("Entered");
- std::string DIR_PATH = "/usr/etc/wrt/injected-javascript";
+ std::string DIR_PATH = "/usr/etc/wrt/injected-javascript";
std::string JS_EXTENSION = ".js";
DIR *dir = opendir(DIR_PATH.c_str());
if (!dir) {
- LogError("opendir(\"" << DIR_PATH << "\") error!" );
+ LogError("opendir(\"" << DIR_PATH << "\") error!");
return;
}
- struct dirent* libdir;
+ int return_code;
+ struct dirent libdir;
+ struct dirent* result;
std::list<std::string> jsFiles;
// make file list from DIR_PATH
- while ((libdir = readdir(dir)) != 0)
- {
- if (strncmp(libdir->d_name, ".", 2) == 0 ||
- strncmp(libdir->d_name, "..", 3) == 0)
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result)) {
+ if (strncmp(libdir.d_name, ".", 2) == 0 ||
+ strncmp(libdir.d_name, "..", 3) == 0)
{
continue;
}
std::string filepath = DIR_PATH;
filepath += "/";
- filepath += libdir->d_name;
+ filepath += libdir.d_name;
std::string lowercase = filepath;
std::transform(lowercase.begin(), lowercase.end(), lowercase.begin(),
towlower);
- if( lowercase.rfind(JS_EXTENSION) == std::string::npos ||
+ if (lowercase.rfind(JS_EXTENSION) == std::string::npos ||
lowercase.length() !=
lowercase.rfind(JS_EXTENSION) + JS_EXTENSION.length() )
{
LogInfo("Added : " << filepath);
jsFiles.push_back(filepath);
}
+ if (0 != return_code)
+ LogError("Error while reading directory.");
closedir(dir);
-
FOREACH(it, jsFiles)
{
LogDebug("load file : " << (*it));
std::string content;
std::ifstream fin(it->c_str());
- while(fin.good())
- {
+ while (fin.good()) {
string line;
std::getline(fin, line);
content += line + "\n";
fin.close();
// execute
- if(!content.empty())
- {
+ if (!content.empty()) {
JSValueRef exception = NULL;
JSStringRef script =
JSStringCreateWithUTF8CString(content.c_str());
JSStringRelease(script);
- if(exception)
- {
+ if (exception) {
LogDebug("Exception Occured while injecting javascript "
- "file. : " << *it);
+ "file. : " << *it);
JSStringRef exceptionJSString =
JSValueToStringCopy(m_context, exception, NULL);
exceptionString, size);
LogDebug("Exception : " << exceptionString);
- delete [] exceptionString;
+ delete[] exceptionString;
JSStringRelease(exceptionJSString);
- }
+ }
}
}
}
void JSPageSession::Impl::startSession(int widgetHandle,
- JSGlobalContextRef context,
- double scaleFactor,
- const char* encodedBundle,
- const char* theme)
+ JSGlobalContextRef context,
+ double scaleFactor,
+ const char* encodedBundle,
+ const char* theme)
{
LogInfo("Starting widget session...");
LogInfo("Widget session stopped.");
}
-
void JSPageSession::Impl::unloadPluginsFromSession()
{
LogDebug("Unload plugins from session");
m_objectExplorer = NULL;
}
-
-
-
void JSPageSession::Impl::performLibrariesUnload()
{
#if 0
PluginPtr JSPageSession::Impl::loadLibrary(PluginModelPtr& pluginModel)
{
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)
- {
+ if (!pluginLib) {
LogError("Loading library failed");
- } else
- {
+ } else {
pluginModel->LibraryInstance.Set(pluginLib);
LogDebug("On widget start");
pluginLib->OnFrameLoad(*context);
}
}
- }
- else
- {
+ } else {
LogDebug("Get from LibraryInstance");
LogDebug("On widget start");
// This is first time for this plugin, start widget Session
return pluginLib;
}
-
void JSPageSession::Impl::loadFrame(JSGlobalContextRef context)
{
LogDebug("Load a frame");
m_objectExplorer->unloadFrame(context);
}
-
void JSPageSession::startSession(int widgetHandle,
- JSGlobalContextRef ctx,
- double scaleFactor,
- const char* encodedBundle,
- const char* theme)
+ JSGlobalContextRef ctx,
+ double scaleFactor,
+ const char* encodedBundle,
+ const char* theme)
{
m_impl->startSession(widgetHandle, ctx, scaleFactor, encodedBundle, theme);
}
}
void JSPageSession::setCustomProperties(double scaleFactor,
- const char* encodedBundle,
- const char* theme)
+ const char* encodedBundle,
+ const char* theme)
{
m_impl->setCustomProperties(scaleFactor, encodedBundle, theme);
}
-void JSPageSession::dispatchJavaScriptEvent(CustomEventType eventType, void* data)
+void JSPageSession::dispatchJavaScriptEvent(CustomEventType eventType,
+ void* data)
{
m_impl->dispatchJavaScriptEvent(eventType, data);
}
}
JSPageSession::JSPageSession(const PluginContainerSupportPtr& containerSupport)
- : m_impl(new JSPageSession::Impl(containerSupport))
-{
-}
+ :
+ m_impl(new JSPageSession::Impl(containerSupport))
+{}
JSPageSession::~JSPageSession()
-{
-}
+{}
//forward declaration of JSConectexRef
extern "C" {
- typedef struct OpaqueJSContext* JSGlobalContextRef;
- typedef struct OpaqueJSValue* JSObjectRef;
+typedef struct OpaqueJSContext* JSGlobalContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
}
struct JavaScriptObject
#include <dlfcn.h>
Plugin::Plugin(const std::string &fileName,
- void *libHandle,
- on_widget_start_proc *apiOnWidgetStart,
- on_widget_init_proc *apiOnWidgetInit,
- on_widget_stop_proc *apiOnWidgetStop,
- on_frame_load_proc* apiOnFrameLoad,
- on_frame_unload_proc* apiOnFrameUnload,
- const ClassPtrList &apiClassList) :
+ void *libHandle,
+ on_widget_start_proc *apiOnWidgetStart,
+ on_widget_init_proc *apiOnWidgetInit,
+ on_widget_stop_proc *apiOnWidgetStop,
+ on_frame_load_proc* apiOnFrameLoad,
+ on_frame_unload_proc* apiOnFrameUnload,
+ const ClassPtrList &apiClassList) :
m_fileName(fileName),
m_libHandle(libHandle),
m_apiOnWidgetStart(apiOnWidgetStart),
m_apiOnFrameLoad(apiOnFrameLoad),
m_apiOnFrameUnload(apiOnFrameUnload),
m_apiClassList(apiClassList)
-{
-}
+{}
Plugin::~Plugin()
{
{
LogDebug("LoadFromFile" << fileName);
- LogDebug("Loading plugin: " << fileName);
-
void *dllHandle;
- dllHandle = dlopen(fileName.c_str(), RTLD_NOW);
+ dllHandle = dlopen(fileName.c_str(), RTLD_LAZY);
+
+ LogDebug("dlopen() done!");
if (dllHandle == NULL) {
LogError(
reinterpret_cast<get_widget_entity_map_proc *>(
dlsym(dllHandle, PLUGIN_GET_CLASS_MAP_PROC_NAME));
- if( getWidgetEntityMapProcPtr )
- {
+ if (getWidgetEntityMapProcPtr) {
rawClassList = (*getWidgetEntityMapProcPtr)();
- LogDebug("rawClassList : " << rawClassList << "by getWidgetClassMapProcPtr()");
- }
- else
- {
+ LogDebug(
+ "rawClassList : " << rawClassList <<
+ "by getWidgetClassMapProcPtr()");
+ } else {
rawClassList =
static_cast<const js_entity_definition_t *>(dlsym(dllHandle,
- PLUGIN_CLASS_MAP_NAME));
- LogDebug("rawClassList : " << rawClassList );
+ PLUGIN_CLASS_MAP_NAME));
+ LogDebug("rawClassList : " << rawClassList);
}
-
if (NULL == onWidgetStartProcPtr || NULL == onWidgetStopProcPtr ||
- /*NULL == onWidgetInitProcPtr ||*/ NULL == rawClassList) {
+ /*NULL == onWidgetInitProcPtr ||*/ NULL == rawClassList)
+ {
LogWarning("#####");
LogWarning(
"##### Warning: The following plugin does not support new plugin API.");
// Parse all class definitions
while (rawEntityListIterator->parent_name != NULL &&
- rawEntityListIterator->object_name != NULL)
+ rawEntityListIterator->object_name != NULL)
{
// Logging
LogInfo("#####");
void Plugin::OnWidgetStart(int widgetId)
{
- if (NULL != m_apiOnWidgetStart)
- {
+ if (NULL != m_apiOnWidgetStart) {
(*m_apiOnWidgetStart)(widgetId);
- }
- else
- {
+ } else {
LogWarning("OnWidgetStart not set!");
}
}
void Plugin::OnWidgetInit(feature_mapping_interface_t* mapping)
{
Assert(NULL != mapping && "NULL mapping interface provided");
- if (NULL != m_apiOnWidgetInit)
- {
+ if (NULL != m_apiOnWidgetInit) {
(*m_apiOnWidgetInit)(mapping);
- }
- else
- {
+ } else {
LogWarning("OnWidgetInit not set!");
}
}
void Plugin::OnWidgetStop(int widgetId)
{
- if (NULL != m_apiOnWidgetStop)
- {
+ if (NULL != m_apiOnWidgetStop) {
(*m_apiOnWidgetStop)(widgetId);
- }
- else
- {
+ } else {
LogWarning("OnWidgetStop not set!");
}
}
void Plugin::OnFrameLoad(java_script_context_t context)
{
- if (NULL != m_apiOnFrameLoad)
- {
+ if (NULL != m_apiOnFrameLoad) {
(*m_apiOnFrameLoad)(context);
- }
- else
- {
+ } else {
LogWarning("OnFrameLoad not set!");
}
}
void Plugin::OnFrameUnload(java_script_context_t context)
{
- if (NULL != m_apiOnFrameUnload)
- {
+ if (NULL != m_apiOnFrameUnload) {
(*m_apiOnFrameUnload)(context);
- }
- else
- {
+ } else {
LogWarning("OnFrameUnload not set!");
}
}
const ClassPtrList m_apiClassList;
Plugin(const std::string &fileName,
- void *libHandle,
- on_widget_start_proc* apiOnWidgetStart,
- on_widget_init_proc* apiOnWidgetInit,
- on_widget_stop_proc* apiOnWidgetStop,
- on_frame_load_proc* apiOnFrameLoad,
- on_frame_unload_proc* apiOnFrameUnload,
- const ClassPtrList &apiClassList);
+ void *libHandle,
+ on_widget_start_proc* apiOnWidgetStart,
+ on_widget_init_proc* apiOnWidgetInit,
+ on_widget_stop_proc* apiOnWidgetStop,
+ on_frame_load_proc* apiOnFrameLoad,
+ on_frame_unload_proc* apiOnFrameUnload,
+ const ClassPtrList &apiClassList);
public:
virtual ~Plugin();
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
-PluginContainerSupport::PluginContainerSupport(): m_initialized(false)
+PluginContainerSupport::PluginContainerSupport() : m_initialized(false)
{
// Reading standard features list from file
readStandardFeaturesList();
void PluginContainerSupport::Initialize(int widgetHandle)
{
- if (isInitialized() == false)
- {
+ if (isInitialized() == false) {
readAllowedPlugins(widgetHandle);
readRootPlugins(widgetHandle);
}
}
-std::list<std::string> PluginContainerSupport::getAllowedFeatures(int widgetHandle) const
+std::list<std::string> PluginContainerSupport::getAllowedFeatures(
+ int widgetHandle) const
{
//TODO it has to return LIST NOT SET!!!
WidgetDAOReadOnly widgetDao(widgetHandle);
LogInfo("Loading api-feature: " << it->name);
if (it->rejected) {
LogWarning("Api-feature was rejected by ace. (Api-feature name: "
- << it->name << ")" );
+ << it->name << ")");
continue;
}
}
FeatureData* dt = NULL;
- std::map<FeatureHandle, FeatureData> featureDataList = FeatureDAOReadOnly::GetFeatures(allowedFeatures);
- DeviceCapList deviceCapabilities = FeatureDAOReadOnly::GetDevCapWithFeatureHandle();
+ std::map<FeatureHandle,
+ FeatureData> featureDataList = FeatureDAOReadOnly::GetFeatures(
+ allowedFeatures);
+ DeviceCapList deviceCapabilities =
+ FeatureDAOReadOnly::GetDevCapWithFeatureHandle();
FOREACH(data, featureDataList) {
dt = &(data->second);
registerPluginModel(dt->pluginHandle);
m_initialized = true;
}
-void PluginContainerSupport::registerFeatureModel(FeatureHandle handle, FeatureData* data, DeviceCapList deviceCapabilities)
+void PluginContainerSupport::registerFeatureModel(
+ FeatureHandle handle,
+ FeatureData* data,
+ DeviceCapList
+ deviceCapabilities)
{
LogDebug("Analyzing feature: " << handle);
FeatureModelPtr model = getFeatureModel(handle);
FOREACH(it, features)
{
auto plugin = getPluginModel(*it);
- if(!plugin)
- {
+ if (!plugin) {
LogError("PluginModel not found");
continue;
}
PluginModelPtr
PluginContainerSupport::getPluginForFeature(const std::string& featureName)
{
- return getPluginModel(getFeatureModel(featureName));
+ return getPluginModel(getFeatureModel(featureName));
}
class PluginContainerSupport
{
-public:
+ public:
typedef std::list<WrtDB::FeatureModelPtr> FeaturesList;
typedef std::list<PluginModelPtr> PluginsList;
-private:
+ private:
// Standard features
typedef std::list<std::string> StandardFeatureList;
bool m_initialized;
-private:
+ private:
// Reading
void readStandardFeaturesList();
// Plugin models
typedef std::multimap<WrtDB::FeatureHandle, std::string> DeviceCapList;
- void registerFeatureModel(WrtDB::FeatureHandle handle, WrtDB::FeatureData* data, DeviceCapList deviceCapabilities);
+ 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 ;
+ WrtDB::FeatureModelPtr getFeatureModel(const std::string &name) const;
+ WrtDB::FeatureModelPtr getFeatureModel(WrtDB::FeatureHandle handle) const;
PluginModelPtr getPluginModel(const WrtDB::FeatureModelPtr &feature) const;
-public:
+ public:
PluginContainerSupport();
- bool isInitialized() { return m_initialized; }
+ bool isInitialized()
+ {
+ return m_initialized;
+ }
void Initialize(int widgetHandle);
void registerPluginModel(WrtDB::DbPluginHandle handle);
std::list<std::string> getAllowedFeatures(int widgetHandle) const;
~PluginContainerSupport();
};
-
typedef std::shared_ptr<PluginContainerSupport> PluginContainerSupportPtr;
#endif // PLUGIN_CONTAINER_SUPPORT_H
LogDebug("Registration iframes-supported plugins " <<
declaration->getName());
- if(declaration->getParentName().find('.') != std::string::npos)
- {
+ if (declaration->getParentName().find('.') != std::string::npos) {
LogWarning("The object will not be loaded to iframes");
return;
}
m_iframesObjects.push_back(declaration);
}
-void IframesSupport::registerIframe(const JSObjectPtr& iframe){
+void IframesSupport::registerIframe(const JSObjectPtr& iframe)
+{
LogDebug("LoadedIframes size: " << m_loadedIframes.size() );
m_loadedIframes.insert(iframe);
}
-void IframesSupport::unregisterIframe(const JSObjectPtr& iframe){
+void IframesSupport::unregisterIframe(const JSObjectPtr& iframe)
+{
LogDebug("LoadedIframes size: " << m_loadedIframes.size() );
auto it_loaded = std::find_if(m_loadedIframes.begin(),
- m_loadedIframes.end(),
- std::bind2nd(EqualToJSObjectPtr(), iframe));
+ m_loadedIframes.end(),
+ std::bind2nd(EqualToJSObjectPtr(), iframe));
//object not found, so thats the new iframe
- if(it_loaded == m_loadedIframes.end()){
+ if (it_loaded == m_loadedIframes.end()) {
LogDebug("Nothing to unregister");
return;
}
#ifndef _WRTENGINE_SRC_PLUGINSERVICE_IFRAME_SUPPORT_H_
#define _WRTENGINE_SRC_PLUGINSERVICE_IFRAME_SUPPORT_H_
-#include<list>
-#include<set>
+#include <list>
+#include <set>
#include <Commons/JSObjectDeclaration.h>
#include <Commons/JSObject.h>
#include "javascript_interface.h"
// used to find matching object from m_loadedIframes
struct EqualToJSObjectPtr
{
- typedef JSObjectPtr first_argument_type;
- typedef JSObjectPtr second_argument_type;
- typedef bool result_type;
+ typedef JSObjectPtr first_argument_type;
+ typedef JSObjectPtr second_argument_type;
+ typedef bool result_type;
result_type operator()(const first_argument_type &s1,
- const second_argument_type &s2) const
+ const second_argument_type &s2) const
{
return (s1->getObject() == s2->getObject());
}
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;
-
public:
Impl();
~Impl();
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) \
+ { \
+ LogError("Object is not available. Wrong flow occured"); \
+ return; \
}
PluginLogic::Impl::Impl()
void PluginLogic::performLibrariesUnload()
{
LogError("Libraries unload TURNED OFF");
-// m_impl->performLibrariesUnload();
+ // 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");
}
-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");
}
m_impl->setCustomProperties(context, scaleFactor, encodedBundle, theme);
}
-void PluginLogic::dispatchJavaScriptEvent(CustomEventType eventType)
+void PluginLogic::dispatchJavaScriptEvent(CustomEventType /*eventType*/)
{
LogError("This function is DEPRECATED");
}
}
PluginLogic::PluginLogic() : m_impl(new PluginLogic::Impl())
-{
-}
+{}
PluginLogic::~PluginLogic()
-{
-}
+{}
void PluginLogic::Impl::initSession(int widgetHandle)
{
LogDebug("Preload plugins so file");
PluginContainerSupport::PluginsList pluginList =
- m_pluginsSupport->getPluginsList();
+ m_pluginsSupport->getPluginsList();
FOREACH(it, pluginList)
{
PluginModelPtr& pluginModel = *it;
+
+ if (!pluginModel->LibraryDependencies.Get()->empty()) {
+ // Only Root Object
+ continue;
+ }
+
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)
- {
+ if (!pluginLib) {
LogError("Loading library failed");
- } else
- {
+ } else {
pluginModel->LibraryInstance.Set(pluginLib);
- LogDebug("pluginModel->LibraryInstance.Set() : " << pluginLib->GetFileName());
+ LogDebug(
+ "pluginModel->LibraryInstance.Set() : " <<
+ pluginLib->GetFileName());
}
- }
- else
- {
+ } else {
LogDebug("Already loaded");
}
}
{
LogInfo("Starting widget session...");
- 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())
- {
+ if (sessionIt != m_sessions.end()) {
LogWarning("Session already started!");
return;
}
LogInfo("Stopping widget session...");
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
+ if (sessionIt == m_sessions.end()) {
LogError("Session not exist!");
return;
}
LogInfo("Load plugin on demand");
auto sessionIt = m_sessions.find(context);
- if (sessionIt == m_sessions.end())
- {
+ if (sessionIt == m_sessions.end()) {
LogWarning("Session not exist!");
return false;
}
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;
}
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;
}
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);
}
void PluginLogic::Impl::setCustomProperties(JSGlobalContextRef context,
const char* encodedBundle,
const char* theme)
{
- LogInfo("set properties of window object " << scaleFactor << ", "
- << encodedBundle << ", " << 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())
- {
+ if (sessionIt == m_sessions.end()) {
LogWarning("Session not exist!");
return;
}
sessionIt->second->setCustomProperties(scaleFactor,
encodedBundle,
theme);
-
}
void PluginLogic::Impl::dispatchJavaScriptEvent(JSGlobalContextRef context,
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;
}
sessionIt->second->dispatchJavaScriptEvent(eventType, data);
-
-
}
using namespace WrtPlugins::W3C;
-
class PluginLogic : DPL::Noncopyable
{
public:
const char* encodedBundle,
const char* theme);
- WRT_PLUGINS_DEPRECATED void dispatchJavaScriptEvent(CustomEventType eventType);
+ WRT_PLUGINS_DEPRECATED void dispatchJavaScriptEvent(
+ CustomEventType eventType);
void dispatchJavaScriptEvent(JSGlobalContextRef ctx,
- CustomEventType eventType,
- void* data);
+ CustomEventType eventType,
+ void* data);
private:
PluginLogic();
PluginDAOReadOnly,
&PluginModel::getHandle,
extFun>
-{
-};
+{};
template <typename RetType, RetType(*extFun) (WrtDB::DbPluginHandle)>
struct BindToFeatureDAOStatic :
WrtDB::DbPluginHandle,
&PluginModel::getHandle,
extFun>
-{
-};
+{};
PluginModel::PluginModel(const WrtDB::DbPluginHandle& handle) :
Handle(this, handle),
LibraryName(this,
BindToPluginDAO<std::string,
- &PluginDAOReadOnly::getLibraryName>::Get),
+ &PluginDAOReadOnly::getLibraryName>::Get),
LibraryPath(this,
BindToPluginDAO<std::string,
- &PluginDAOReadOnly::getLibraryPath>::Get),
+ &PluginDAOReadOnly::getLibraryPath>::Get),
FeatureHandles(this,
BindToFeatureDAOStatic<FeatureHandleListPtr,
- FeatureDAOReadOnly::GetFeatureHandleListForPlugin>::Get),
+ FeatureDAOReadOnly::
+ GetFeatureHandleListForPlugin>::
+ Get),
LibraryDependencies(this,
BindToPluginDAO<PluginHandleSetPtr,
- &PluginDAOReadOnly::getLibraryDependencies>::Get),
+ &PluginDAOReadOnly::
+ getLibraryDependencies>::Get),
LibraryInstance(this, PluginPtr())
-{
-}
+{}
WrtDB::DbPluginHandle PluginModel::getHandle() const
{
public:
/**
- *@brief Plugin handle
+ * *@brief Plugin handle
*/
- DPL::Event::Property<WrtDB::DbPluginHandle, DPL::Event::PropertyReadOnly> Handle;
+ DPL::Event::Property<WrtDB::DbPluginHandle,
+ DPL::Event::PropertyReadOnly> Handle;
/**
- *@brief LibraryName
+ * *@brief LibraryName
*/
DPL::Event::Property<std::string,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> LibraryName;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> LibraryName;
/**
- *@brief Library Path
+ * *@brief Library Path
*/
DPL::Event::Property<std::string,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> LibraryPath;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> LibraryPath;
/**
- *@brief Feature set
+ * *@brief Feature set
*/
DPL::Event::Property<WrtDB::FeatureHandleListPtr,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> FeatureHandles;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>
+ FeatureHandles;
/**
- *@brief Librarydepencies
+ * *@brief Librarydepencies
*/
DPL::Event::Property<WrtDB::PluginHandleSetPtr,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> LibraryDependencies;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>
+ LibraryDependencies;
/**
- *@brief Library instance Low Level
+ * *@brief Library instance Low Level
* */
DPL::Event::Property<PluginPtr,
- DPL::Event::PropertyReadWrite,
- DPL::Event::PropertyStorageCached> LibraryInstance;
+ DPL::Event::PropertyReadWrite,
+ DPL::Event::PropertyStorageCached> LibraryInstance;
public:
PluginModel(const WrtDB::DbPluginHandle& handle);
using namespace PluginModule;
-
-const char *NAVIGATOR_PROPERTY_NAME = "navigator";
+const char *NAVIGATOR_PROPERTY_NAME = "navigator";
const char *SCALE_PROPERTY_NAME = "scale";
-const char *BUNDLE_PROPERTY_NAME = "__bundle";
-const char *THEME_PROPERTY_NAME = "theme";
+const char *BUNDLE_PROPERTY_NAME = "__bundle";
+const char *THEME_PROPERTY_NAME = "theme";
WindowPropertySupport::WindowPropertySupport(
- JSGlobalContextRef context):
+ JSGlobalContextRef context) :
m_scale(0),
m_bundle(""),
m_theme(""),
m_context(context)
-{
-}
+{}
WindowPropertySupport::~WindowPropertySupport()
-{
-}
+{}
float WindowPropertySupport::getScale() const
{
LogInfo("set window.navigator.scale: " << scale);
m_scale = scale;
-
- setPropertyToNavigator(SCALE_PROPERTY_NAME, JSValueMakeNumber(m_context, scale));
+
+ setPropertyToNavigator(SCALE_PROPERTY_NAME,
+ JSValueMakeNumber(m_context, scale));
}
void WindowPropertySupport::setBundleToWindowProperty(const char* bundle)
{
LogInfo("set window.__bundle: " << bundle);
- if(bundle)
- {
+ if (bundle) {
m_bundle = bundle;
JSStringRef bundleString = JSStringCreateWithUTF8CString(bundle);
{
LogInfo("set window.navigator.__theme: " << theme);
- if(theme)
- {
+ if (theme) {
m_theme = theme;
JSStringRef themeString = JSStringCreateWithUTF8CString(theme);
}
void WindowPropertySupport::setPropertyToWindow(const char* propertyName,
- JSValueRef jsValue)
+ JSValueRef jsValue)
{
- if(propertyName)
- {
+ if (propertyName) {
JSObjectRef globalObject = JSContextGetGlobalObject(m_context);
JSStringRef propertyNameString =
}
void WindowPropertySupport::setPropertyToNavigator(const char* propertyName,
- JSValueRef jsValue)
+ JSValueRef jsValue)
{
- if(propertyName)
- {
+ if (propertyName) {
JSObjectRef globalObject = JSContextGetGlobalObject(m_context);
JSStringRef navigatorString =
#include <JavaScriptCore/JavaScript.h>
namespace PluginModule {
-
class WindowPropertySupport
{
public:
- float getScale() const;
- std::string getBundle() const;
- std::string getTheme() const;
- JSGlobalContextRef getJSContext() const;
-
- void setScaleToNavigatorProperty(const double scale);
- void setBundleToWindowProperty(const char* bundle);
- void setThemeToNavigatorProperty(const char* theme);
-
- explicit WindowPropertySupport(JSGlobalContextRef m_context);
- ~WindowPropertySupport();
-
- private:
- float m_scale;
- std::string m_bundle; // string of base64 encoded bundle
- std::string m_theme;
- JSGlobalContextRef m_context;
-
- void setPropertyToWindow(const char* propertyName, JSValueRef jsValue);
- void setPropertyToNavigator(const char* propertyName, JSValueRef jsValue);
+ float getScale() const;
+ std::string getBundle() const;
+ std::string getTheme() const;
+ JSGlobalContextRef getJSContext() const;
+
+ void setScaleToNavigatorProperty(const double scale);
+ void setBundleToWindowProperty(const char* bundle);
+ void setThemeToNavigatorProperty(const char* theme);
+
+ explicit WindowPropertySupport(JSGlobalContextRef m_context);
+ ~WindowPropertySupport();
+
+ private:
+ float m_scale;
+ std::string m_bundle; // string of base64 encoded bundle
+ std::string m_theme;
+ JSGlobalContextRef m_context;
+
+ void setPropertyToWindow(const char* propertyName, JSValueRef jsValue);
+ void setPropertyToNavigator(const char* propertyName, JSValueRef jsValue);
};
-
} // namespace PluginModule
#endif // _PLUGIN_LOGIC_PROPERTY_SUPPORT_H_
#include <string>
#include <dpl/foreach.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
template<typename Sig>
class CallbackSupport
{
-public:
+ public:
typedef typename Sig::Signature SlotSignature;
typedef typename Sig::Type SlotType;
typedef std::string GroupType;
void Connect(const GroupType& group, const SlotType& slot)
{
auto groupIt = m_slots.find(group);
- if (m_slots.end() == groupIt)
- {
+ if (m_slots.end() == groupIt) {
groupIt = m_slots.insert(std::make_pair(group, SlotList())).first;
}
groupIt->second.push_back(slot);
m_slots.erase(group);
}
- template<typename...Args>
- void Invoke(const Args&... args)
+ template<typename ... Args>
+ void Invoke(const Args& ... args)
{
-
FOREACH(groupIt, m_slots)
{
FOREACH(slotIt, groupIt->second)
{
- (*slotIt)(args...);
+ (*slotIt)(args ...);
}
}
}
- template<typename...Args>
- void InvokeGroup(const GroupType& group, const Args&... 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)
+ if (m_slots.end() != groupIt) {
+ FOREACH(slotIt, groupIt->second)
{
- (*slotIt)(args...);
+ (*slotIt)(args ...);
}
}
}
-private:
+ private:
std::map<GroupType, SlotList> m_slots;
};
-
}
#endif
*
* 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
+ * #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
*
*
* */
struct feature_mapping_interface_s;
typedef struct feature_mapping_interface_s feature_mapping_interface_t;
-class WrtPluginsApi::Plugin;
-
extern "C" struct ExportedApi
{
/*
void (*GetProvidedFeatures)(feature_mapping_interface_t*);
};
-
constexpr const char* GetExportedSymbolName()
{
return "dll_api";
#include <list>
extern "C" {
- typedef struct OpaqueJSClass* const (*ClassRef)();
+typedef struct OpaqueJSClass* (*ClassRef)();
}
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
enum class IObjectType
{
Object,
return "window";
}
- virtual void AddChild(const IObjectPtr& ) = 0;
+ virtual void AddChild(const IObjectPtr&) = 0;
/*
* Optional
* */
virtual void setBoolOption(IObjectOption option, bool value) = 0;
- virtual ~IObject(){};
+ virtual ~IObject(){}
};
typedef std::list<IObjectPtr> IObjectsList;
typedef std::shared_ptr<IObjectsList> IObjectsListPtr;
-
}
#endif
#include <IObject.h>
#include <Object.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
inline ObjectPtr CAST(const IObjectPtr& object)
{
return std::dynamic_pointer_cast<Object>(object);
}
-
}
#endif
#include "Object.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
void Object::AddChild(const IObjectPtr& child)
{
- if(!m_children)
- {
+ if (!m_children) {
m_children = IObjectsListPtr(new IObjectsList);
}
m_children->push_back(child);
void Object::setBoolOption(IObjectOption option, bool value)
{
- if(!m_options)
- {
+ if (!m_options) {
m_options = ObjectOptionPtr(new ObjectOption);
- }
-
- switch(option)
- {
- case IObjectOption::Overlayed:
- m_options->overlayedMode = value;
- break;
- default:
- break;
- }
+ }
+
+ switch (option) {
+ case IObjectOption::Overlayed:
+ m_options->overlayedMode = value;
+ break;
+ default:
+ break;
+ }
}
IObjectsListPtr Object::GetChildren() const
ObjectOptionPtr Object::GetOptions() const
{
- return m_options;
+ 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)
-{
-}
+ 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)
-{
-}
+ 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)
-{
-}
+ IObjectType type) :
+ m_name(name),
+ m_parentName(parentName),
+ m_type(type),
+ m_interfaceRef(interfaceRef),
+ m_interfaceName(interfaceName),
+ m_constructorRef(constructorRef)
+{}
Object::~Object()
-{
-}
-
+{}
}
#include <IObject.h>
#include <dpl/optional.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
class Object;
typedef std::shared_ptr<Object> ObjectPtr;
};
typedef std::shared_ptr<ObjectOption> ObjectOptionPtr;
-
class Object : public IObject
{
public:
~Object();
- void AddChild(const IObjectPtr& );
+ void AddChild(const IObjectPtr&);
void setBoolOption(IObjectOption option, bool value);
- IObjectsListPtr GetChildren() const ;
+ IObjectsListPtr GetChildren() const;
ClassRef GetClass() const;
IObjectsListPtr m_children;
};
-
}
#endif
namespace WrtPluginsApi {
namespace ObjectFactory {
-
IObjectPtr createObject(
const char* name,
ClassRef ref,
parentName,
type));
}
-
}
}
namespace WrtPluginsApi {
namespace ObjectFactory {
+IObjectPtr createObject(
+ const char* name,
+ ClassRef ref,
+ IObjectType type = IObjectType::Object);
- 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 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);
+IObjectPtr createObjectWithInterface(
+ const char* name,
+ ClassRef interfaceRef,
+ const char* interfaceName,
+ ClassRef constructorRef,
+ const char* parentName = IObject::WINDOW_OBJECT(),
+ IObjectType type = IObjectType::Object);
}
}
#endif
*/
#include "Plugin.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
void Plugin::AddObject(const IObjectPtr& object)
{
- m_objects->push_back(object);
+ m_objects->push_back(object);
}
IObjectsListPtr Plugin::GetObjects() const
}
Plugin::~Plugin()
-{
-}
+{}
Plugin::Plugin() : m_objects(new IObjectsList())
-{
-}
-
+{}
}
#include <list>
#include <IObject.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
class Plugin
{
-public:
+ public:
void AddObject(const IObjectPtr& object);
IObjectsListPtr GetObjects() const;
virtual ~Plugin();
-private:
+ private:
IObjectsListPtr m_objects;
};
-
}
#endif
#include "Plugin.h"
#include <dpl/assert.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
PluginRegistration::PluginRegistration(Impl* impl) : m_impl(impl)
{
Assert(impl != 0 && "impl is NULL");
}
#define EXPLICIT_INSTATIATE_PLUGIN_REGISTRATION(SignalSignature) \
- template void PluginRegistration::Connect<SignalSignature>( \
- const typename SignalSignature::Type&)
+ 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);
-
}
#include "Plugin.h"
#include "PluginSignals.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
class PluginRegistration
{
-public:
+ public:
class Impl;
explicit PluginRegistration(PluginRegistration::Impl* impl);
void AddPlugin(Plugin& plugin);
-private:
+ private:
std::unique_ptr<Impl> m_impl;
};
-
}
#endif
#include "Plugin.h"
#include <dpl/log/log.h>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
class PluginRegistration::Impl
{
-public:
- Impl(SignalsSupport& registry, const std::string& libraryName)
- : m_registry(registry),
- m_libraryName(libraryName)
+ public:
+ Impl(SignalsSupport& registry, const std::string& libraryName) :
+ m_registry(registry),
+ m_libraryName(libraryName)
{}
void AddPlugin(Plugin& plugin)
m_registry.Disconnect(m_libraryName);
}
-private:
+ private:
SignalsSupport& m_registry;
std::string m_libraryName;
};
-
}
#endif
#include <dpl/log/log.h>
#include <dpl/foreach.h>
-
-namespace {
-const char* DLL_ENTRY_POINT_NAME = "dll_api";
-}
-
-namespace WrtPluginsApi
-{
-
+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)
- {
+ 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");
+ if (it == m_plugins.end()) {
+ if (!LoadFromFile(libraryName)) {
+ LogError("Failed to load lib" << libraryName);
+ ThrowMsg(PluginNotFound, "Failed to load plugin");
}
return m_plugins[libraryName];
Plugin& plugin)
{
auto it = m_plugins.find(libraryName);
- if (it != m_plugins.end())
- {
- if (&plugin == it->second)
- {
+ if (it != m_plugins.end()) {
+ if (&plugin == it->second) {
m_plugins.erase(it);
}
}
{
LogDebug("Unload all plugins");
- typedef void (*UnregisterFunction) (PluginRegistration&, Plugin&);
+ typedef void (*UnregisterFunction)(PluginRegistration&, Plugin&);
FOREACH(libraryIt, m_libraries)
{
auto pluginIt = m_plugins.find(libraryIt->first);
- if (m_plugins.end() != pluginIt)
- {
+ if (m_plugins.end() != pluginIt) {
void* handle = dlopen(libraryIt->first.c_str(), RTLD_NOW);
if (!handle) {
LogError("Error: " << dlerror());
ExportedApi* entryPoint =
static_cast<ExportedApi*>
- (dlsym(handle, GetExportedSymbolName()));
- if (NULL == entryPoint)
- {
+ (dlsym(handle, GetExportedSymbolName()));
+ if (NULL == entryPoint) {
LogError("Error: " << dlerror());
continue;
}
- if (entryPoint->Unregister == NULL)
- {
+ if (entryPoint->Unregister == NULL) {
LogError("Error Unregister function not set");
continue;
}
ExportedApi* entryPoint =
static_cast<ExportedApi*>(dlsym(handle, GetExportedSymbolName()));
- if (NULL == entryPoint)
- {
+ if (NULL == entryPoint) {
LogError("Error: " << dlerror());
return false;
}
- if (entryPoint->Register == NULL)
- {
+ if (entryPoint->Register == NULL) {
LogError("Error Register function not set");
return false;
}
- if (entryPoint->Unregister== NULL)
- {
+ if (entryPoint->Unregister == NULL) {
LogError("Error Unregister function not set");
return false;
}
PluginRegistration registration(
- new PluginRegistration::Impl(*this, libraryName));
+ new PluginRegistration::Impl(*this, libraryName));
entryPoint->Register(registration);
return true;
}
-
PluginRegistry::~PluginRegistry()
{
//TODO discuss ... when the unload should be called
-// UnloadAll();
+ // UnloadAll();
}
-
}
#include "Plugin.h"
#include <dpl/exception.h>
-namespace WrtPluginsApi
-{
-
+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:
+ public:
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, PluginNotFound)
- template <typename T, typename ...Args>
- void Call(Args... args)
+ template <typename T, typename ... Args>
+ void Call(Args ... args)
{
- Invoke<T>(args...);
+ Invoke<T>(args ...);
}
- template <typename T, typename ...Args>
+ template <typename T, typename ... Args>
void CallGroup(const typename CallbackSupport<T>::GroupType& type,
- Args... args)
+ Args ... args)
{
- InvokeGroup<T>(type, args...);
+ InvokeGroup<T>(type, args ...);
}
void AddPlugin(const std::string& libraryName, Plugin& plugin);
void UnloadAll();
~PluginRegistry();
-private:
+
+ private:
bool LoadFromFile(const std::string& libraryName);
typedef void* Symbol;
};
typedef std::shared_ptr<PluginRegistry> PluginRegistryPtr;
-
}
#endif
#include "SignalSignature.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
struct OnWidgetStart : SignalSignature<void (int)> {};
struct OnWidgetStop : SignalSignature<void (int)> {};
-struct OnFrameLoad: SignalSignature<void (void*)> {};
+struct OnFrameLoad : SignalSignature<void (void*)> {};
struct OnFrameUnload : SignalSignature<void (void*)> {};
-
}
#endif
#include <functional>
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
template<typename> struct SignalSignature;
-template<typename R, typename ...Args>
-struct SignalSignature<R (Args...)>
+template<typename R, typename ... Args>
+struct SignalSignature<R(Args ...)>
{
- typedef R (*Signature) (Args...);
- typedef std::function<R (Args...)> Type;
+ typedef R (*Signature)(Args ...);
+ typedef std::function<R(Args ...)> Type;
};
-
}
#endif
#include "PluginSignals.h"
#include "Plugin.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
class SignalsSupport
{
-public:
+ 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);
+ Tuple::get_by_type<CallbackSupport<T> >(m_slots).Connect(libraryName,
+ slot);
}
void Disconnect(const std::string& libraryName)
virtual void AddPlugin(const std::string& libraryName, Plugin& plugin) = 0;
-protected:
- template<typename T, typename ...Args>
- void Invoke(const Args&... args)
+ protected:
+ template<typename T, typename ... Args>
+ void Invoke(const Args& ... args)
{
- Tuple::get_by_type<CallbackSupport<T>>(m_slots).Invoke(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)
+ 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...);
+ Tuple::get_by_type<CallbackSupport<T> >(m_slots).InvokeGroup(
+ libraryName,
+ args ...);
}
-private:
- template<int N, typename ...Args>
- void DisconnectSlot(std::tuple<Args...>& slots,
+ 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);
+ DisconnectSlot<N - 1>(slots, libraryName);
}
- template<int N, typename ...Args>
- void DisconnectSlot(std::tuple<Args...>& slots,
- const std::string& 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,
+ template<typename ... Args>
+ void DisconnectGroup(std::tuple<Args ...>& slots,
const std::string& libraryName)
{
- DisconnectSlot<sizeof...(Args)-1>(slots, libraryName);
+ DisconnectSlot<sizeof ... (Args)-1>(slots, libraryName);
}
std::tuple<CallbackSupport<OnWidgetStart>,
CallbackSupport<OnWidgetStop>,
CallbackSupport<OnFrameLoad>,
- CallbackSupport<OnFrameUnload>> m_slots;
+ CallbackSupport<OnFrameUnload> > m_slots;
};
-
}
#endif
size_t featuresCount;
} feature_mapping_t;
-
typedef feature_mapping_t* pfeature_mapping_t;
typedef pfeature_mapping_t (*features_getter)(void);
namespace WrtPluginsApi {
namespace Traits {
namespace Detail {
-
-template<size_t, typename RequiredType, typename ...TupleArgTypes>
+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...>
+ 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;
+ 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...>
+template<size_t n, typename RequiredType, typename ... TupleArgTypes>
+struct index_of_<n, RequiredType, RequiredType, TupleArgTypes ...>
{
static const size_t value = n;
};
template<size_t n, typename RequiredType>
struct index_of_<n, RequiredType, RequiredType>
{
- static const size_t value = n;
+ static const size_t value = n;
};
/*
{
static const size_t value = -1;
};
-
}
}
}
//forward declaration
extern "C" {
- typedef struct OpaqueJSContext* JSGlobalContextRef;
- typedef struct OpaqueJSValue* JSObjectRef;
+typedef struct OpaqueJSContext* JSGlobalContextRef;
+typedef struct OpaqueJSValue* JSObjectRef;
}
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
struct JavaScriptObject
{
JSObjectRef instance;
std::string name;
};
-
}
#endif
#include "detail/traits.h"
-namespace WrtPluginsApi
-{
-
+namespace WrtPluginsApi {
namespace Traits {
-
/**
* Gets index of specified type in the type list.
*/
-template<typename RequiredType, typename ...TupleArgTypes>
+template<typename RequiredType, typename ... TupleArgTypes>
struct index_of
{
static const size_t value = Detail::index_of_<0,
- RequiredType,
- TupleArgTypes...>::value;
+ RequiredType,
+ TupleArgTypes ...>::value;
};
-
}
-
}
#endif
namespace WrtPluginsApi {
namespace Tuple {
-
-template<typename T, typename ...Args>
-T& get_by_type(std::tuple<Args...>& tuple)
+template<typename T, typename ... Args>
+T& get_by_type(std::tuple<Args ...>& tuple)
{
- return std::get<Traits::index_of<T, Args...>::value>(tuple);
+ return std::get<Traits::index_of<T, Args ...>::value>(tuple);
}
-
}
}
const int PluginsInstaller::INSTALLATION_ERROR = -1;
-PluginsInstaller::PluginsInstaller()
- : m_initialized(false)
+PluginsInstaller::PluginsInstaller() :
+ m_initialized(false)
{
LogInfo("PluginsInstaller created.");
}
}
PluginsInstaller::ReturnStatus PluginsInstaller::installPlugin(
- const std::string& libPath)
+ const std::string& libPath)
{
if (!m_initialized) {
LogError("Plugins installer not initialized.");
}
LogInfo("Plugin installation started. Checking path: " << libPath);
- if (!PluginUtils::checkPath(libPath))
+ if (!PluginUtils::checkPath(libPath)) {
return ReturnStatus::WrongPluginPath;
+ }
LogInfo("Plugin path ok. Searching for config file...");
std::string metaFileName = libPath + DIRECTORY_SEPARATOR +
std::string(WrtDB::GlobalConfig::GetPluginMetafileName());
- if (PluginUtils::checkFileExistance(metaFileName))
- {
+ if (PluginUtils::checkFileExistance(metaFileName)) {
return installPluginFromMetafile(libPath, metaFileName);
}
PluginMetafileData pluginInfo;
pluginInfo.m_libraryName = getLibraryName(libPath);
- LogInfo("Config file done. Lib name: " << pluginInfo.m_libraryName
- << ". Searching for installed plugin...");
+ LogInfo(
+ "Config file done. Lib name: " << pluginInfo.m_libraryName
+ <<
+ ". Searching for installed plugin...");
if (WrtDB::PluginDAO::isPluginInstalled(pluginInfo.m_libraryName)) {
LogInfo("Plugin already installed.");
FOREACH(o, *plugin->GetObjects()) {
libraryObjects->addObjects(CAST(*o)->GetParentName(),
- CAST(*o)->GetName());
+ CAST(*o)->GetName());
LogDebug("[Parent << Object] " << CAST(*o)->GetParentName()
- << " << "
- << CAST(*o)->GetName());
+ << " << "
+ << CAST(*o)->GetName());
registerObjects(libraryObjects, plugin->GetObjects());
}
LogInfo("Registration done. Resolving dependencies...");
//TODO: can it be replaced with resolvePluginDependencies(handle)
- if (!registerAndUpdateInstallation(pluginHandle, libraryObjects))
+ if (!registerAndUpdateInstallation(pluginHandle, libraryObjects)) {
return ReturnStatus::InstallationWaiting;
- } Catch (DPL::Exception) {
+ }
+ } Catch(DPL::Exception) {
LogError("Failed to make database entry.");
return ReturnStatus::DatabaseError;
}
}
PluginObjectsPtr PluginsInstaller::loadLibraryFromMetafile(
- const std::string& libName) const
+ const std::string& libName) const
{
LogInfo("Loading library: " << libName);
void *dlHandle = dlopen(libName.c_str(), RTLD_NOW);
- if (dlHandle == NULL ) {
+ if (dlHandle == NULL) {
LogError(
- "Failed to load plugin: " << libName <<
- ". Reason: " << dlerror());
+ "Failed to load plugin: " << libName <<
+ ". Reason: " << dlerror());
ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
}
getWidgetEntityMapProcPtr =
reinterpret_cast<get_widget_entity_map_proc *>(dlsym(dlHandle,
- PLUGIN_GET_CLASS_MAP_PROC_NAME));
+ PLUGIN_GET_CLASS_MAP_PROC_NAME));
if (getWidgetEntityMapProcPtr) {
rawEntityList = (*getWidgetEntityMapProcPtr)();
} else {
rawEntityList =
static_cast<const js_entity_definition_t *>(dlsym(dlHandle,
- PLUGIN_CLASS_MAP_NAME));
+ PLUGIN_CLASS_MAP_NAME));
}
if (rawEntityList == NULL) {
LogInfo("#####");
while (rawEntityListIterator->parent_name != NULL &&
- rawEntityListIterator->object_name != NULL)
+ rawEntityListIterator->object_name != NULL)
{
LogInfo("##### [" << rawEntityListIterator->object_name << "]: ");
LogInfo("##### Parent: " << rawEntityListIterator->parent_name);
LogInfo("#####");
libraryObjects->addObjects(rawEntityListIterator->parent_name,
- rawEntityListIterator->object_name);
+ rawEntityListIterator->object_name);
++rawEntityListIterator;
}
return libraryObjects;
}
-
PluginsInstaller::ReturnStatus PluginsInstaller::installPluginFromMetafile(
- const std::string& path, const std::string& metaFilePath)
+ const std::string& path, const std::string& metaFilePath)
{
if (!m_initialized) {
LogError("Plugins installer not initialized.");
{
pluginData = parseMetafile(metaFilePath);
}
- Catch (PluginInstall::Exceptions::XMLFileParsingException)
+ Catch(PluginInstall::Exceptions::XMLFileParsingException)
{
LogError("Parsing metafile failed.");
return ReturnStatus::MetafileError;
return ReturnStatus::AlreadyInstalled;
}
Try {
-
- LogError("path is: " << path << ", libraryName: " << pluginData->m_libraryName);
+ LogError(
+ "path is: " << path << ", libraryName: " <<
+ pluginData->m_libraryName);
PluginObjectsPtr objects = loadLibraryFromMetafile(
- path + DIRECTORY_SEPARATOR + pluginData->m_libraryName);
+ path + DIRECTORY_SEPARATOR + pluginData->m_libraryName);
PluginHandle pluginHandle =
PluginDAO::registerPlugin(*pluginData, path);
LogInfo("Objects registered. Finishing...");
- if (!registerAndUpdateInstallation(pluginHandle, objects))
+ if (!registerAndUpdateInstallation(pluginHandle, objects)) {
return ReturnStatus::InstallationWaiting;
- } Catch (DPL::Exception) {
+ }
+ } Catch(DPL::Exception) {
LogError("Failed to make database entry.");
return ReturnStatus::DatabaseError;
}
}
LogInfo("Plugin DIRECTORY IS" << PLUGIN_PATH);
- struct dirent* libdir;
+ int return_code;
+ struct dirent libdir;
+ struct dirent* result;
errno = 0;
std::list<std::string> pluginsPaths;
- while ((libdir = readdir(dir)) != 0) {
- if (strcmp(libdir->d_name, ".") == 0 ||
- strcmp(libdir->d_name, "..") == 0) {
+ for (return_code = readdir_r(dir, &libdir, &result);
+ result != NULL && return_code == 0;
+ return_code = readdir_r(dir, &libdir, &result)) {
+ if (strcmp(libdir.d_name, ".") == 0 ||
+ strcmp(libdir.d_name, "..") == 0)
+ {
continue;
}
std::string path = PLUGIN_PATH;
path += "/";
- path += libdir->d_name;
+ path += libdir.d_name;
struct stat tmp;
pluginsPaths.push_back(path);
}
+ if (0 != return_code)
+ LogError("Error while reading directory.");
+
if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) {
LogError("Failed to close dir: " << PLUGIN_PATH);
}
LogDebug("Plugins to install: " << pluginsPaths.size());
- for (int k = 0; k <= pluginsPaths.size(); ++k)
+ for (size_t k = 0; k <= pluginsPaths.size(); ++k) {
printf(" ");
+ }
printf("]\r[");
int installedPluginsCount = 0;
ReturnStatus ret = ReturnStatus::Unknown;
installedPluginsCount += installWaitingPlugins();
m_registry.UnloadAll();
LogInfo("Installed " << installedPluginsCount
- << " plugins of total: " << pluginsPaths.size());
+ << " plugins of total: " << pluginsPaths.size());
return installedPluginsCount;
}
int pluginsInstalled = 0;
FOREACH(it, *waitingPlugins)
{
- if (resolvePluginDependencies(*it))
+ if (resolvePluginDependencies(*it)) {
++pluginsInstalled;
+ }
}
return pluginsInstalled;
}
void PluginsInstaller::registerObjects(const PluginObjectsPtr& libObj,
const IObjectsListPtr& objects) const
{
- LogDebug("registerObjects invoked");
-
- FOREACH(o, *objects)
- {
- auto children = CAST(*o)->GetChildren();
-
- if(children)
- {
- FOREACH(c, *children)
- {
- libObj->addObjects(CAST(*o)->GetName(), CAST(*c)->GetName());
-
- LogDebug("[Parent << Object] " << CAST(*c)->GetName()
- << " << "
- << CAST(*o)->GetName());
- }
-
- registerObjects(libObj, children);
- }
- }
-}
+ LogDebug("registerObjects invoked");
+ FOREACH(o, *objects)
+ {
+ auto children = CAST(*o)->GetChildren();
+
+ if (children) {
+ FOREACH(c, *children)
+ {
+ libObj->addObjects(CAST(*o)->GetName(), CAST(*c)->GetName());
+
+ LogDebug("[Parent << Object] " << CAST(*c)->GetName()
+ << " << "
+ << CAST(*o)->GetName());
+ }
+
+ registerObjects(libObj, children);
+ }
+ }
+}
PluginsInstaller::OptionalPluginMetafileData PluginsInstaller::parseMetafile(
- const std::string& path) const
+ const std::string& path) const
{
LogInfo("Plugin Config file::" << path);
Try
Catch(ValidationCore::ParserSchemaException::Base) {
LogError("Error during file processing " << path);
ThrowMsg(PluginInstall::Exceptions::XMLFileParsingException,
- "Parsing metafile failed");
+ "Parsing metafile failed");
}
}
std::string pluginPath = dirPath;
size_t indexpos = pluginPath.find_last_of('/');
- if (std::string::npos == indexpos)
- {
+ if (std::string::npos == indexpos) {
indexpos = 0;
- }
- else
- {
+ } else {
indexpos += 1; // move after '/'
}
}
bool PluginsInstaller::registerAndUpdateInstallation(
- const WrtDB::DbPluginHandle& pluginHandle,
- const PluginObjectsPtr& libraries)
+ const WrtDB::DbPluginHandle& pluginHandle,
+ const PluginObjectsPtr& libraries)
{
PluginHandleSetPtr handles = PluginHandleSetPtr(new PluginHandleSet);
{
void *dlHandle = dlopen(filename.c_str(), RTLD_NOW);
if (dlHandle == NULL) {
- LogError("Failed to load plugin: " << filename << ". Reason: " << dlerror());
+ LogError(
+ "Failed to load plugin: " << filename << ". Reason: " << dlerror());
return false;
}
Try
{
ExportedApi* entryPoint =
- static_cast<ExportedApi*> (dlsym(dlHandle, GetExportedSymbolName()));
+ static_cast<ExportedApi*>(dlsym(dlHandle, GetExportedSymbolName()));
if (NULL == entryPoint) {
LogError("Error: " << dlerror());
- ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ ThrowMsg(PluginInstall::Exceptions::LibraryException,
+ "Library error");
}
// obtain feature -> dev-cap mapping
- feature_mapping_interface_t mappingInterface = {NULL, NULL, NULL};
+ feature_mapping_interface_t mappingInterface = { NULL, NULL, NULL };
entryPoint->GetProvidedFeatures(&mappingInterface);
if (!mappingInterface.featGetter || !mappingInterface.release ||
- !mappingInterface.dcGetter) {
+ !mappingInterface.dcGetter)
+ {
LogError("Failed to obtain mapping interface from .so");
- ThrowMsg(PluginInstall::Exceptions::LibraryException, "Library error");
+ ThrowMsg(PluginInstall::Exceptions::LibraryException,
+ "Library error");
}
feature_mapping_t* devcapMapping = mappingInterface.featGetter();
LogDebug("Feature: " << feature.m_name);
const devcaps_t* dc =
- mappingInterface.dcGetter(devcapMapping,
- devcapMapping->features[i].feature_name);
+ mappingInterface.dcGetter(
+ devcapMapping,
+ devcapMapping->features[i].
+ feature_name);
LogDebug("device=cap: " << dc);
}
mappingInterface.release(devcapMapping);
- } Catch (PluginInstall::Exceptions::PluginsInstallerException)
+ } Catch(PluginInstall::Exceptions::PluginsInstallerException)
{
LogError("Exception while feature mapping");
dlclose(dlHandle);
return true;
}
-void PluginsInstaller::registerPluginObjects(const WrtDB::DbPluginHandle& handle,
- const PluginObjectsPtr libObjects) const
+void PluginsInstaller::registerPluginObjects(
+ const WrtDB::DbPluginHandle& handle,
+ const PluginObjectsPtr libObjects)
+const
{
- //register implemented objects
+ //register implemented objects
PluginObjects::ObjectsPtr objects =
libObjects->getImplementedObject();
class PluginsInstaller
{
-public:
+ public:
static const int INSTALLATION_ERROR;
enum class ReturnStatus
{
bool resolvePluginDependencies(PluginHandle handle);
bool isInitialized();
-private:
+
+ private:
friend class DPL::Singleton<PluginsInstaller>;
PluginsInstaller();
typedef DPL::Singleton<PluginsInstaller> PluginsInstallerSingleton;
-
#endif /* WRT_PLUGINS_INSTALLER_PLUGIN_INSTALLER_H */
namespace PluginInstall {
namespace Exceptions {
-
DECLARE_EXCEPTION_TYPE(DPL::Exception, PluginsInstallerException)
DECLARE_EXCEPTION_TYPE(PluginsInstallerException, LibraryException)
DECLARE_EXCEPTION_TYPE(PluginsInstallerException, XMLFileParsingException)
-
} //namespace
} //namespace
}
void PluginMetafileReader::blankFunction(PluginMetafileData & /* data */)
-{
-}
+{}
void PluginMetafileReader::tokenEndLibraryName(PluginMetafileData &data)
{
}
if (!objectName.compare(0, GLOBAL_OBJECT_NAME.size(),
- GLOBAL_OBJECT_NAME)) {
+ GLOBAL_OBJECT_NAME))
+ {
return objectName;
}
if (!objectName.compare(0, OLD_GLOBAL_OBJECT_NAME.size(),
- OLD_GLOBAL_OBJECT_NAME))
+ OLD_GLOBAL_OBJECT_NAME))
{
return GLOBAL_OBJECT_NAME;
}
}
std::string normalizeName(const std::string& objectName,
- const std::string& parentName)
+ const std::string& parentName)
{
if (objectName.empty() || parentName.empty()) {
LogError("Normalize name, name size or parent name size is 0");
}
void PluginObjects::addObjects(const std::string& parentName,
- const std::string& name)
+ const std::string& name)
{
- LogDebug("\n Parent: " << parentName
- << "\n Name: " << name
- << "\n After: Implemented: " << normalizeName(name, parentName)
- << "\n After Dependent: " << normalizeName(parentName)
+ LogDebug("\n Parent: " << parentName
+ << "\n Name: " << name
+ << "\n After: Implemented: " <<
+ normalizeName(name, parentName)
+ << "\n After Dependent: " <<
+ normalizeName(parentName)
);
addImplementedObject(normalizeName(name, parentName));
//add object declaration
void addObjects(const std::string& parentName,
- const std::string& name);
+ const std::string& name);
//check if library implemements object given as name
bool hasObject(const std::string& name) const;
using namespace WrtDB;
namespace PluginUtils {
-
//checks if file exists and is regular file
bool checkFileExistance(const std::string& filename)
{
return false;
}
-std::string cutOffFileName(const std::string& path) {
+std::string cutOffFileName(const std::string& path)
+{
size_t found = path.find_last_of("/");
if (found == std::string::npos) {
return path;
}
}
-bool checkPath(const std::string& path) {
+bool checkPath(const std::string& path)
+{
struct stat st;
if (0 == stat(path.c_str(), &st) && S_ISDIR(st.st_mode)) {
return true;
{
bool if_ok = true;
if_ok &= (checkPath(cutOffFileName(
- GlobalConfig::GetWrtDatabaseFilePath())));
+ GlobalConfig::GetWrtDatabaseFilePath())));
if (!if_ok) {
LogError(
- "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
- "> does not exist.");
+ "Path <" << GlobalConfig::GetWrtDatabaseFilePath() <<
+ "> does not exist.");
}
if_ok &= (checkPath(GlobalConfig::GetDevicePluginPath()));
if (!if_ok) {
LogError(
- "Path <" << GlobalConfig::GetDevicePluginPath() <<
- "> does not exist.");
+ "Path <" << GlobalConfig::GetDevicePluginPath() <<
+ "> does not exist.");
}
if_ok &= (checkPath(GlobalConfig::GetUserInstalledWidgetPath()));
if (!if_ok) {
LogError(
- "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
- "> does not exist.");
+ "Path <" << GlobalConfig::GetUserInstalledWidgetPath() <<
+ "> does not exist.");
}
return if_ok;
}
-
} //namespace PluginUtils
#include <sys/stat.h>
namespace PluginUtils {
-
bool checkFileExistance(const std::string& filename);
std::string cutOffFileName(const std::string& path);
bool checkPath(const std::string& path);
bool checkPaths();
-
}
#endif // PLUGIN_UTILS_H
#include <string>
#include <cstdio>
-int main(int argc, char *argv[])
+int main(int /*argc*/, char */*argv*/[])
{
DPL::Log::LogSystemSingleton::Instance().SetTag("PLUGINS_INSTALLER");
LogInfo("Plugins installation started.");
#define LOCAL_STORAGE_PROPERTY_LENGTH "length"
#define CATCH_EXCEPTION_NO_MODIFABLE \
- Catch(Commons::LocalStorageValueNoModifableException) {\
- LogError("The item is read only");\
- return JSDOMExceptionFactory::\
- NoModificationAllowedException.make(context, exception);\
+ Catch(Commons::LocalStorageValueNoModifableException) { \
+ LogError("The item is read only"); \
+ return JSDOMExceptionFactory:: \
+ NoModificationAllowedException.make(context, exception); \
}
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_SECURITY \
- Catch(Commons::SecurityException){\
- LogError("Security exception occured");\
- return JSDOMExceptionFactory::\
- SecurityException.make(context, exception);\
+ Catch(Commons::SecurityException){ \
+ LogError("Security exception occured"); \
+ return JSDOMExceptionFactory:: \
+ SecurityException.make(context, exception); \
}
#define CATCH_EXCEPTION_OUT_OF_RANGE \
- Catch(Commons::OutOfRangeException) {\
- LogError("OutOfRangeException");\
- return JSDOMExceptionFactory::\
- QuotaExceededException.make(context, exception);\
+ Catch(Commons::OutOfRangeException) { \
+ LogError("OutOfRangeException"); \
+ return JSDOMExceptionFactory:: \
+ QuotaExceededException.make(context, exception); \
}
#define CATCH_EXCEPTION_INVALID_ARG \
- Catch(Commons::InvalidArgumentException) {\
- LogError("Pair for given key doesnt exist");\
- return JSValueMakeNull(context);\
+ Catch(Commons::InvalidArgumentException) { \
+ LogError("Pair for given key doesnt exist"); \
+ return JSValueMakeNull(context); \
}
namespace WrtPlugins {
namespace W3C {
-
-
ILocalStoragePtr getIStorage(JSObjectRef arg)
{
LogWarning("get localstorage object");
}
return priv->widgetObject;
-
}
-enum class ModificationType{
+enum class ModificationType
+{
RemoveItem,
SetItem
};
DPL::Optional<std::string> oldValue =
getIStorage(thisObject)->getValue(key);
- if (ModificationType::SetItem == type)
- {
+ if (ModificationType::SetItem == type) {
getIStorage(thisObject)->setItem(key, value, false);
- }
- else if (ModificationType::RemoveItem == type)
- {
+ } else if (ModificationType::RemoveItem == type) {
getIStorage(thisObject)->removeItem(key);
- }
- else
- {
+ } else {
Assert(0 && "Wrong Modification type");
}
//key
storageEvent->setKey(key);
//oldvalue
- if (!!oldValue) { storageEvent->setOldValue(*oldValue); }
+ if (!!oldValue) {
+ storageEvent->setOldValue(*oldValue);
+ }
//newValue
- if(!!newValue){ storageEvent->setNewValue(*newValue); }
+ if (!!newValue) {
+ storageEvent->setNewValue(*newValue);
+ }
return storageEvent;
}
-
-JSClassDefinition JSPreferences::m_classInfo =
-{
+JSClassDefinition JSPreferences::m_classInfo = {
0,
kJSClassAttributeNone,
PREFERENCES_PLUGIN_NAME,
hasProperty,
getProperty,
setProperty,
- NULL,//DeleteProperty,
- NULL,//GetPropertyNames,
- NULL,//CallAsFunction,
- NULL,//CallAsConstructor,
- NULL,//HasInstance,
- NULL,//ConvertToType,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL, //HasInstance,
+ NULL, //ConvertToType,
};
JSStaticFunction JSPreferences::m_function[] = {
{ 0, 0, 0 }
};
-JSStaticValue JSPreferences::m_property[] =
-{
- {LOCAL_STORAGE_PROPERTY_LENGTH,
- JSPreferences::getLength,
- NULL,
- kJSPropertyAttributeReadOnly},
+JSStaticValue JSPreferences::m_property[] = {
+ { LOCAL_STORAGE_PROPERTY_LENGTH,
+ JSPreferences::getLength,
+ NULL,
+ kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
-const JSClassRef JSPreferences::getClassRef()
+JSClassRef JSPreferences::getClassRef()
{
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
JSClassCreate(JSPreferences::getClassInfo());
void JSPreferences::initialize(JSContextRef context,
- JSObjectRef object)
+ JSObjectRef object)
{
LogDebug("entered. Context: " << context);
LocalStoragePrivateData* priv =
- static_cast<LocalStoragePrivateData*>(JSObjectGetPrivate(object));
+ static_cast<LocalStoragePrivateData*>(JSObjectGetPrivate(object));
Assert(priv && "private object of preferences is NULL");
}
{
LogDebug("entered");
LocalStoragePrivateData* priv =
- static_cast<LocalStoragePrivateData*>(JSObjectGetPrivate(object));
+ static_cast<LocalStoragePrivateData*>(JSObjectGetPrivate(object));
delete priv;
LogDebug("private object is realised");
}
JSValueRef JSPreferences::removeItem(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSObjectRef thisObject,
- size_t argumentCount,
+ size_t /*argumentCount*/,
const JSValueRef arguments[],
JSValueRef* exception)
{
key);
auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
+ getIFrameObjectForWidget(getWidgetObject(thisObject));
Assert(iframe && "Iframe is NULL");
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSPreferences::setItem(JSContextRef context,
JSObjectRef object,
JSObjectRef thisObject,
- size_t argumentCount,
+ size_t /*argumentCount*/,
const JSValueRef arguments[],
JSValueRef* exception)
{
value);
auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
+ getIFrameObjectForWidget(getWidgetObject(thisObject));
Assert(iframe && "Iframe is NULL");
AddEventListenerSupport::
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
CATCH_EXCEPTION_SECURITY
- CATCH_EXCEPTION_OUT_OF_RANGE
+ CATCH_EXCEPTION_OUT_OF_RANGE
}
-
JSValueRef JSPreferences::clear(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
+ size_t /*argumentCount*/,
+ const JSValueRef /*arguments*/[],
JSValueRef* exception)
{
LogDebug("entered");
Try {
getIStorage(thisObject)->clear(false);
-
auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(thisObject));
+ getIFrameObjectForWidget(getWidgetObject(thisObject));
Assert(iframe && "Iframe is NULL");
}
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSPreferences::getItem(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSObjectRef thisObject,
- size_t argumentCount,
+ size_t /*argumentCount*/,
const JSValueRef arguments[],
JSValueRef* exception)
{
DPL::Optional<std::string> value =
getIStorage(thisObject)->getValue(key);
- if (!value)
+ if (!value) {
return JSValueMakeNull(context);
- else
+ } else {
return converter.toJSValueRef(*value);
+ }
}
CATCH_EXCEPTION_INVALID_ARG
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
}
JSValueRef JSPreferences::key(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSObjectRef thisObject,
size_t argumentCount,
const JSValueRef arguments[],
{
LogDebug("entered");
- Try{
- if (argumentCount<1) {
+ Try {
+ if (argumentCount < 1) {
LogError("No argument found");
Throw(Commons::InvalidArgumentException);
}
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
CATCH_EXCEPTION_SECURITY
- CATCH_EXCEPTION_INVALID_ARG
+ CATCH_EXCEPTION_INVALID_ARG
}
JSValueRef JSPreferences::getLength(JSContextRef context,
JSObjectRef object,
- JSStringRef propertyName,
+ JSStringRef /*propertyName*/,
JSValueRef* exception)
{
LogDebug("enter");
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
CATCH_EXCEPTION_SECURITY
- CATCH_EXCEPTION_INVALID_ARG
+ CATCH_EXCEPTION_INVALID_ARG
}
bool JSPreferences::hasProperty(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName)
+ JSObjectRef object,
+ JSStringRef propertyName)
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
- if(!getIStorage(object)->getValue(key)) {
+ if (!getIStorage(object)->getValue(key)) {
return false;
} else {
return true;
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
LogDebug("end");
- if (!value)
+ if (!value) {
return JSValueMakeNull(context);
- else
+ } else {
return converter.toJSValueRef(*value);
+ }
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_INVALID_ARG
+ CATCH_EXCEPTION_INVALID_ARG
}
bool JSPreferences::setProperty(JSContextRef context,
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
value);
auto iframe = IFrameSupport::
- getIFrameObjectForWidget(getWidgetObject(object));
+ getIFrameObjectForWidget(getWidgetObject(object));
Assert(iframe && "Iframe is NULL");
AddEventListenerSupport::
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
CATCH_EXCEPTION_PLATFORM_ERROR
- CATCH_EXCEPTION_SECURITY
+ CATCH_EXCEPTION_SECURITY
return false;
}
#undef CATCH_EXCEPTION_SECURITY
#undef CATCH_EXCEPTION_OUT_OF_RANGE
#undef CATCH_EXCEPTION_INVALID_ARG
-
}
}
namespace WrtPlugins {
namespace W3C {
-
-struct LocalStoragePrivateData{
+struct LocalStoragePrivateData {
WrtDeviceApis::LocalStorage::Api::ILocalStoragePtr istorage;
//parent
JSObjectRef widgetObject;
class JSPreferences
{
-public:
+ public:
/**
* This method initializes this in the JS Engine.
*/
- static const JSClassRef getClassRef();
+ static JSClassRef getClassRef();
/**
* Gets object's class description.
*/
static const JSClassDefinition* getClassInfo();
-private:
+ private:
/**
* The callback invoked when an object is first created.
*/
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
-
};
}
}
#include <Commons/WrtAccess/WrtAccess.h>
#include <js-overlay/js_iframe_support.h>
-
#define CATCH_EXCEPTION_NO_MODIFABLE \
- Catch(Commons::LocalStorageValueNoModifableException) {\
- LogError("The item is read only");\
- return JSDOMExceptionFactory::\
- NoModificationAllowedException.make(context, exception);\
+ Catch(Commons::LocalStorageValueNoModifableException) { \
+ LogError("The item is read only"); \
+ return JSDOMExceptionFactory:: \
+ NoModificationAllowedException.make(context, exception); \
}
#define CATCH_EXCEPTION_CONVERSION \
- Catch(Commons::ConversionException) {\
- LogError("Error on conversion");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::ConversionException) { \
+ LogError("Error on conversion"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_NULL_PTR \
- Catch(Commons::NullPointerException) {\
- LogError("Error on pointer, null value");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::NullPointerException) { \
+ LogError("Error on pointer, null value"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_PLATFORM_ERROR \
- Catch(Commons::PlatformException){\
- LogError("PlatformException occured");\
- return JSDOMExceptionFactory::\
- UnknownException.make(context, exception);\
+ Catch(Commons::PlatformException){ \
+ LogError("PlatformException occured"); \
+ return JSDOMExceptionFactory:: \
+ UnknownException.make(context, exception); \
}
#define CATCH_EXCEPTION_SECURITY \
- Catch(Commons::SecurityException){\
- LogError("Security exception occured");\
- return JSDOMExceptionFactory::\
- SecurityException.make(context, exception);\
+ Catch(Commons::SecurityException){ \
+ LogError("Security exception occured"); \
+ return JSDOMExceptionFactory:: \
+ SecurityException.make(context, exception); \
}
#define CATCH_EXCEPTION_OUT_OF_RANGE \
- Catch(Commons::OutOfRangeException) {\
- LogError("OutOfRangeException");\
- return JSDOMExceptionFactory::\
- QuotaExceededException.make(context, exception);\
+ Catch(Commons::OutOfRangeException) { \
+ LogError("OutOfRangeException"); \
+ return JSDOMExceptionFactory:: \
+ QuotaExceededException.make(context, exception); \
}
#define CATCH_EXCEPTION_INVALID_ARG \
- Catch(Commons::InvalidArgumentException) {\
- LogError("Pair for given key doesnt exist");\
- return JSValueMakeNull(context);\
+ Catch(Commons::InvalidArgumentException) { \
+ LogError("Pair for given key doesnt exist"); \
+ return JSValueMakeNull(context); \
}
#define WIDGET_PLUGIN_NAME "Widget"
namespace WrtPlugins {
namespace W3C {
-
using namespace WrtDeviceApis;
using namespace WrtDeviceApis::Commons;
using namespace WrtDeviceApis::CommonsJavaScript;
using namespace WrtDeviceApis::Widget;
-
struct WidgetPrivateObject
{
Widget::Api::IWidgetPtr iwidget;
JSObjectRef preferencesObject;
//TEMP
- int widgetId;
+ //int widgetId // TODO: check is it necessary (g.rynkowski)
JSObjectRef widgetObject;
};
typedef std::shared_ptr<WidgetPrivateObject> WidgetPrivateObjectPtr;
typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT
- <WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
+<WidgetPrivateObjectPtr>::Type JSWidgetPrivateObject;
WrtDeviceApis::Widget::Api::IWidgetPtr getIWidget(JSObjectRef arg)
{
return priv->getObject()->iwidget;
}
-
LocalStorage::Api::ILocalStoragePtr getLocalStorage(int widgetId)
{
LocalStorage::Api::ILocalStoragePtr storage(
JSPreferences::getClassRef(),
priv);
- if(!preferences){
+ if (!preferences) {
LogError("Preferences object is null");
delete priv;
}
JSValueProtect(context, preferences);
return preferences;
-};
-
+}
JSClassDefinition JSWidget::m_classInfo = {
0,
{ 0, 0, 0, 0 }
};
-const JSClassRef JSWidget::getClassRef()
+JSClassRef JSWidget::getClassRef()
{
if (!m_jsClassRef) {
m_jsClassRef = JSClassCreate(&m_classInfo);
JSContextRef JSWidget::m_globalContext = NULL;
void JSWidget::initialize(JSContextRef context,
- JSObjectRef object)
+ JSObjectRef object)
{
LogDebug("entered. Context : " << context);
LogDebug("Object: " << object);
createPreferencesObject(context,
object,
widgetId);
- if(!preferences){
+ if (!preferences) {
LogError("Failed to create preferences object");
}
priv = new JSWidgetPrivateObject(context, widgetPriv);
JSObjectSetPrivate(object, priv);
LogDebug("private object created");
-
}
Catch(Commons::InvalidArgumentException){
LogError("You should register widget id in ON_WIDGET_START");
LogError("Failed to create private object for JSWidget");
return;
}
-
}
}
}
void JSWidget::acquireGlobalContext(java_script_context_t global_context,
- js_object_instance_t iframe,
- js_object_instance_t object)
+ js_object_instance_t iframe,
+ js_object_instance_t object)
{
IFrameSupport::RegisterWidget(global_context, iframe, object);
if (!m_globalContext) {
}
JSValueRef JSWidget::getAuthor(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
LogDebug("entered");
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getAuthorEmail(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getAuthorHref(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getDescription(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getId(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getName(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getShortName(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getVersion(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getHeight(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
JSValueRef JSWidget::getWidth(JSContextRef context,
- JSObjectRef object,
- JSStringRef propertyName,
- JSValueRef* exception)
+ JSObjectRef object,
+ JSStringRef /*propertyName*/,
+ JSValueRef* exception)
{
Try {
Converter converter(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_PLATFORM_ERROR
+ CATCH_EXCEPTION_PLATFORM_ERROR
}
bool JSWidget::hasProperty(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSStringRef propertyName)
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
std::string key = converter.toString(propertyName);
- if (key=="preferences") {
+ if (key == "preferences") {
Converter converter(context);
JSObjectRef pref = getPreferences(object);
- if (!pref)
- {
+ if (!pref) {
LogError("Preferences object is NULL");
return JSValueMakeUndefined(context);
}
CATCH_EXCEPTION_CONVERSION
CATCH_EXCEPTION_NULL_PTR
- CATCH_EXCEPTION_INVALID_ARG
+ CATCH_EXCEPTION_INVALID_ARG
}
bool JSWidget::setProperty(JSContextRef context,
- JSObjectRef object,
+ JSObjectRef /*object*/,
JSStringRef propertyName,
- JSValueRef jvalue,
+ JSValueRef /*jvalue*/,
JSValueRef* exception)
{
LogDebug("enter");
- Try{
+ Try {
Converter converter(context);
std::string key = converter.toString(propertyName);
- if (key == "preferences"){
+ if (key == "preferences") {
LogError("Object is read only");
return true;
}
}
CATCH_EXCEPTION_INVALID_ARG
CATCH_EXCEPTION_CONVERSION
- CATCH_EXCEPTION_NULL_PTR
+ CATCH_EXCEPTION_NULL_PTR
return false;
}
JSObjectRef JSWidget::callAsConstructor(JSContextRef context,
- JSObjectRef constructor,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
+ JSObjectRef /*constructor*/,
+ size_t /*argumentCount*/,
+ const JSValueRef /*arguments*/[],
+ JSValueRef* /*exception*/)
{
LogDebug("widget constructor");
if (!m_globalContext) {
LogError("Global context not set. Creating 'widget' object with "
- "local context!");
+ "local context!");
return JSObjectMake(context, JSWidget::getClassRef(), NULL);
}
return JSObjectMake(m_globalContext, JSWidget::getClassRef(), NULL);
#undef CATCH_EXCEPTION_SECURITY
#undef CATCH_EXCEPTION_OUT_OF_RANGE
#undef CATCH_EXCEPTION_INVALID_ARG
-
}
}
namespace WrtPlugins {
namespace W3C {
-
-
class JSWidget
{
public:
/**
* This method initializes this in the JS Engine.
*/
- static const JSClassRef getClassRef();
+ static JSClassRef getClassRef();
/**
* Gets object's class description.
* called in finalize may fail because of invalid context.
*/
static void acquireGlobalContext(java_script_context_t global_context,
- js_object_instance_t iframe,
- js_object_instance_t object);
+ js_object_instance_t iframe,
+ js_object_instance_t object);
private:
/**
* The callback invoked when an object is first created.
*/
static void initialize(JSContextRef context,
- JSObjectRef object);
+ JSObjectRef object);
/**
* The callback invoked when an object is finalized.
static JSStaticValue m_property[];
/**
- * This structure contains properties and callbacks that define a type of object.
+ * This structure contains properties and callbacks that define a type of
+ * object.
*/
static JSClassDefinition m_classInfo;
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
-
};
}
}
namespace WrtPlugins {
namespace W3C {
-
template <>
WidgetDeclarations::ParamsMap WidgetDeclarations::m_params =
- WrtPlugins::W3C::WidgetDeclarations::ParamsMap();
+ WrtPlugins::W3C::WidgetDeclarations::ParamsMap();
template <>
WidgetDeclarations::DeviceCapsMaps WidgetDeclarations::m_deviceCaps =
- WrtPlugins::W3C::WidgetDeclarations::DeviceCapsMaps();
-
+ WrtPlugins::W3C::WidgetDeclarations::DeviceCapsMaps();
template <>
-WidgetDeclarations::FeaturesMap WidgetDeclarations::m_features =
-{
+WidgetDeclarations::FeaturesMap WidgetDeclarations::m_features = {
{
"http://w3cWidgetInterface.com/w3c-widget-interface",
- {
- }
+ {}
}
};
template <>
WidgetDeclarations::FunctionsMap WidgetDeclarations::m_functions =
- WrtPlugins::W3C::WidgetDeclarations::FunctionsMap();
-
+ WrtPlugins::W3C::WidgetDeclarations::FunctionsMap();
} // namespace Wac2_0
} // namespace WrtPlugins
namespace WrtPlugins {
namespace W3C {
+enum class WidgetParamId
+{};
-enum class WidgetParamId {
-};
+enum class WidgetDeviceCapId
+{};
-enum class WidgetDeviceCapId {
-};
-
-enum class WidgetFunctionId {
-};
+enum class WidgetFunctionId
+{};
typedef WrtDeviceApis::CommonsJavaScript::StaticDeclarations <
- WidgetParamId,
- WidgetDeviceCapId,
- WidgetFunctionId> WidgetDeclarations;
-
+ WidgetParamId,
+ WidgetDeviceCapId,
+ WidgetFunctionId> WidgetDeclarations;
}
}
using namespace WrtDeviceApis;
using namespace WrtDeviceApis::Commons;
-namespace Options{
-
-class_definition_options_t WidgetOptions =
-{
+namespace Options {
+class_definition_options_t WidgetOptions = {
JS_CLASS,
CREATE_INSTANCE,
ALWAYS_NOTICE,
NULL
};
-class_definition_options_t WidgetInterfaceOptions =
-{
+class_definition_options_t WidgetInterfaceOptions = {
JS_INTERFACE,
CREATE_INSTANCE,
ALWAYS_NOTICE,
NULL,
NULL
};
-
};
void on_widget_init_callback(feature_mapping_interface_t *mapping)
{
WrtAccessSingleton::Instance().initialize(widgetId);
}
- Catch (Commons::Exception)
+ Catch(Commons::Exception)
{
LogError("Wrt wrapper registration failed");
return;
{
WrtAccessSingleton::Instance().deinitialize(widgetId);
}
- Catch (Commons::Exception)
+ Catch(Commons::Exception)
{
LogError("Wrt wrapper registration failed");
return;
}
-
}
PLUGIN_ON_WIDGET_START(on_widget_start_callback)
PLUGIN_CLASS_MAP_BEGIN
PLUGIN_CLASS_MAP_ADD_INTERFACE(
- WRT_JS_EXTENSION_OBJECT_GLOBAL,
- INTERFACE_WIDGET_NAME,
- (js_class_template_getter)WrtPlugins::W3C::JSWidget::getClassRef,
- reinterpret_cast<js_class_constructor_cb_t>(WrtPlugins::W3C::JSWidget::callAsConstructor),
- &Options::WidgetInterfaceOptions)
+ WRT_JS_EXTENSION_OBJECT_GLOBAL,
+ INTERFACE_WIDGET_NAME,
+ (js_class_template_getter) WrtPlugins::W3C::JSWidget::getClassRef,
+ reinterpret_cast<js_class_constructor_cb_t>(WrtPlugins::W3C::JSWidget::
+ callAsConstructor),
+ &Options::WidgetInterfaceOptions)
PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(
- WRT_JS_EXTENSION_OBJECT_GLOBAL,
- OBJECT_WIDGET,
- INTERFACE_WIDGET_NAME,
- &Options::WidgetOptions)
+ WRT_JS_EXTENSION_OBJECT_GLOBAL,
+ OBJECT_WIDGET,
+ INTERFACE_WIDGET_NAME,
+ &Options::WidgetOptions)
PLUGIN_CLASS_MAP_END
*/
/*
- * This is just a example pop-up that shows how to use a new C-API in wrt-security.
+ * 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 "Popup.h"
namespace { // anonymous
-
-static void set_validity_from_checkbox(struct ace_popup_data *pdp) {
-
- if(NULL == pdp){
+static void set_validity_from_checkbox(struct ace_popup_data *pdp)
+{
+ if (NULL == pdp) {
LogError("pdp is NULL; return");
return;
}
return;
}
-static void on_done(void) {
+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 */) {
-
+static void grant_answer(void *data,
+ Evas_Object * /* obj */,
+ void * /* event_info */)
+{
LogDebug("grant_answer");
- if(NULL == data){
+ if (NULL == data) {
LogError("data is NULL; return");
return;
}
- struct ace_popup_data *pdp = static_cast <struct ace_popup_data *> (data);
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *>(data);
set_validity_from_checkbox(pdp);
on_done();
}
-static void deny_answer(void *data, Evas_Object * /* obj */, void * /* event_info */) {
-
+static void deny_answer(void *data,
+ Evas_Object * /* obj */,
+ void * /* event_info */)
+{
LogDebug("deny_answer");
- if(NULL == data){
+ if (NULL == data) {
LogError("data is NULL; return");
return;
}
- struct ace_popup_data *pdp = static_cast <struct ace_popup_data *> (data);
+ struct ace_popup_data *pdp = static_cast <struct ace_popup_data *>(data);
set_validity_from_checkbox(pdp);
on_done();
}
-static int _ace_params_deserializer(ace_param_list_t* ace_param_list, Wrt::Popup::BinaryStream *stream){
-
+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){
+ if (NULL == ace_param_list || NULL == stream) {
LogError("ace_param_list or stream is NULL; return -1");
return -1;
}
std::string name;
std::string value;
- if(count == 0){
+ 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)));
+ ace_param_list->items =
+ static_cast <ace_param_t *>(malloc(count * sizeof(ace_param_t)));
memset(ace_param_list->items, 0, count * sizeof(ace_param_t));
- for(size_t i=0; i < count; ++i){
+ for (size_t i = 0; i < count; ++i) {
DPL::Deserialization::Deserialize(*stream, name);
ace_param_list->items[i].name =
- strdup(const_cast <char *> (name.c_str()));
+ strdup(const_cast <char *>(name.c_str()));
DPL::Deserialization::Deserialize(*stream, value);
ace_param_list->items[i].value =
- strdup(const_cast <char *> (value.c_str()));
+ strdup(const_cast <char *>(value.c_str()));
}
return 0;
}
-static void _ace_params_finalize(ace_param_list_t* ace_param_list) {
+static void _ace_params_finalize(ace_param_list_t* ace_param_list)
+{
if (!ace_param_list || !ace_param_list->items) {
LogDebug("List is null, nothing to do");
return;
ace_param_list->count = 0;
}
-static void show_popup(struct ace_popup_data *pdp) {
+static void show_popup(struct ace_popup_data *pdp)
+{
LogDebug("show_popup()");
- if(NULL == pdp){
+ if (NULL == pdp) {
LogError("pdp is NULL; return");
return;
}
- const char *resource_type = static_cast <char *> (pdp->resource_name);
+ 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 *win = 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;
+ 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_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)){
+ 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);
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);
+ Evas_Object *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_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);
+ Evas_Object *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_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);
}
// Run the efl mainloop
elm_run();
}
-
} // anonymous
-
EAPI_MAIN int
-elm_main(int argc , char ** argv)
+elm_main(int argc, char ** argv)
{
UNHANDLED_EXCEPTION_HANDLER_BEGIN
{
-// int pipe_in and int pipe_out should be passed to Popup via args.
+ // 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
+ // 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
try {
DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-POPUP-BIN");
//cannot run logger
return ACE_INTERNAL_ERROR;
}
- LogDebug("############################ popup binary ################################");
+ LogDebug(
+ "############################ popup binary ################################");
- if(argc < 3){
- LogError("To few args passed in exec to popup-bin - should be at least 3:");
+ 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]);
+ LogDebug("Passed args: " << argv[0] << ", " << argv[1] << ", " <<
+ argv[2]);
int pipe_in;
int pipe_out;
+ std::stringstream parsing_stream;
// Parsing args (pipe_in, pipe_out)
- if ( 0 == sscanf(argv[1], "%d", &pipe_in) ){
+ parsing_stream.str(argv[1]);
+ parsing_stream >> pipe_in;
+ if ( parsing_stream.fail() ) {
LogError("Error while parsing pipe_in; return ACE_INTERNAL_ERROR");
return ACE_INTERNAL_ERROR;
}
- if ( 0 == sscanf(argv[2], "%d", &pipe_out) ){
+ parsing_stream.clear();
+ parsing_stream.str(argv[2]);
+ parsing_stream >> pipe_out;
+ if ( parsing_stream.fail() ) {
LogError("Error while parsing pipe_out; return ACE_INTERNAL_ERROR");
return ACE_INTERNAL_ERROR;
}
- LogDebug("Parsed pipes: IN: " << pipe_in <<", OUT: " << pipe_out);
+ parsing_stream.clear();
+ LogDebug("Parsed pipes: IN: " << pipe_in << ", OUT: " << pipe_out);
- int buff_size = 1024;
+ int buff_size = 1024;
char line[buff_size];
struct ace_popup_data pd;
// timeout is set for 10 seconds
do {
count = TEMP_FAILURE_RETRY(read(pipe_in, line, buff_size));
- if ( timeout < difftime(time(NULL), time_start) ) {
+ 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){
+ if (count < 0) {
close(pipe_in);
close(pipe_out);
- LogError("read returned a negative value (" << count <<")");
- LogError("errno: " << strerror( errno ) );
+ 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)");
+ 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));
+ stream.Write(count, static_cast <void *>(line));
int popup_type = ACE_ONESHOT;
std::string resource_name_str;
std::string session_id_str;
DPL::Deserialization::Deserialize(stream, popup_type);
LogDebug("popup_type_int : " << popup_type);
- pdp->popup_type = static_cast <ace_popup_t> (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 =
- strdup(const_cast <ace_resource_t> (resource_name_str.c_str()));
+ strdup(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 =
- strdup(const_cast <ace_session_id_t> (session_id_str.c_str()));
+ strdup(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);
+ pdp->handle = static_cast <ace_widget_handle_t>(handle);
- if(_ace_params_deserializer(&(pdp->param_list), &stream)){
+ if (_ace_params_deserializer(&(pdp->param_list), &stream)) {
return ACE_INTERNAL_ERROR;
}
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()))){
+ 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;
if (pdp->validation_return == ACE_OK) {
LogDebug("ACE_OK");
- }
- else if (pdp->validation_return == ACE_INVALID_ARGUMENTS) {
+ } else if (pdp->validation_return == ACE_INVALID_ARGUMENTS) {
LogError("ACE_INVALID_ARGUMENTS");
- }
- else if (pdp->validation_return == ACE_INTERNAL_ERROR) {
+ } else if (pdp->validation_return == ACE_INTERNAL_ERROR) {
LogError("ACE_INTERNAL_ERROR");
- }
- else if (pdp->validation_return == ACE_ACE_UNKNOWN_ERROR) {
+ } else if (pdp->validation_return == ACE_ACE_UNKNOWN_ERROR) {
LogError("ACE_ACE_UNKNOWN_ERROR");
- }
- else {
+ } else {
LogError("Really unknown error!!!");
}
- LogDebug("############################ /popup binary ################################");
+ 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
+ // 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.
_ace_params_finalize(&(pdp->param_list));
#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;
+ 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;
+ Eina_Bool per_session;
+ Eina_Bool always;
- ace_validity_t remember_choice;
+ ace_validity_t remember_choice;
};
*/
/*
- * This is just a example pop-up that shows how to use a new C-API in wrt-security.
+ * 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 "popup-runner.h"
namespace { // anonymous
-
const char *POPUP_EXEC = "/usr/bin/wrt-popup-ace-runtime";
-void _ace_params_serializer (const ace_param_list_t* ace_param_list, Wrt::Popup::BinaryStream *stream){
-
+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){
+ 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);
+ size_t count = static_cast <size_t>(ace_param_list->count);
DPL::Serialization::Serialize(*stream, count);
- for(size_t i=0; i < count; ++i){
+ for (size_t i = 0; i < count; ++i) {
std::string name(ace_param_list->items[i].name);
DPL::Serialization::Serialize(*stream, name);
DPL::Serialization::Serialize(*stream, value);
}
}
-
} // anonymous namespace
namespace Wrt {
namespace Popup {
-
// BinaryStream class implementation
-void BinaryStream::Read(size_t num, void * bytes) {
+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){
+ if (i + m_readPosition >= max_size) {
return;
}
- static_cast <unsigned char*> (bytes)[i] = m_data[i + m_readPosition];
+ static_cast <unsigned char*>(bytes)[i] = m_data[i + m_readPosition];
}
m_readPosition += num;
}
-void BinaryStream::Write(size_t num, const void * bytes) {
+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]);
+ m_data.push_back(static_cast <const unsigned char*>(bytes)[i]);
}
}
-BinaryStream::BinaryStream() {
+BinaryStream::BinaryStream()
+{
m_readPosition = 0;
}
-BinaryStream::~BinaryStream() {
-}
+BinaryStream::~BinaryStream() {}
-const unsigned char* BinaryStream::char_pointer() const {
+const unsigned char* BinaryStream::char_pointer() const
+{
return &m_data[0];
}
-size_t BinaryStream::size() const {
+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)
+ 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 )
+ 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("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);
+ 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, handle_int);
- _ace_params_serializer (ace_param_list, &stream);
+ _ace_params_serializer(ace_param_list, &stream);
- int fd_send_to_child[2];
- int fd_send_to_parent[2];
+ int fd_send_to_child[2];
+ int fd_send_to_parent[2];
pid_t childpid;
- if(0 != pipe(fd_send_to_child)){
+ if (0 != pipe(fd_send_to_child)) {
LogError("Cannot create pipes!");
return ACE_INTERNAL_ERROR;
}
- if(0 != pipe(fd_send_to_parent)){
+ if (0 != pipe(fd_send_to_parent)) {
LogError("Cannot create pipes!");
return ACE_INTERNAL_ERROR;
}
return ACE_ACE_UNKNOWN_ERROR;
}
- if(childpid == 0) { // Child process
+ if (childpid == 0) { // Child process
LogDebug("Child");
// read data from parent
std::stringstream pipe_in_buff;
std::stringstream pipe_out_buff;
- pipe_in_buff << fd_send_to_parent[1];
+ 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_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]);
+ 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){
+ 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;
+ 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()))){
+ 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;
}
int status;
wait(&status);
LogDebug("STATUS EXIT ON POPUP (CHILD): " << status);
- switch (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);
+ 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);
+ 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);
+ 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);
+ 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){
+
+ if (0 < count) {
BinaryStream stream_in;
+ int validation_result_int;
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);
+ *validation_result = static_cast <ace_bool_t>(validation_result_int);
LogDebug("validation_result :");
- switch (*validation_result){
+ switch (*validation_result) {
case ACE_FALSE:
LogDebug("ACE_FALSE");
break;
LogDebug("UNKNOWN - DEFAULT");
break;
}
- }
- else {
+ } else {
LogDebug("count = " << count);
LogDebug("UNKNOWN_ERROR");
return ACE_ACE_UNKNOWN_ERROR;
LogError("This should not happend!!!");
return ACE_ACE_UNKNOWN_ERROR;
}
-
} // Popup
} // Wrt
namespace Wrt {
namespace Popup {
-
-class BinaryStream : public DPL::IStream {
+class BinaryStream : public DPL::IStream
+{
public:
- void Read (size_t num, void * bytes);
+ void Read (size_t num, void * bytes);
void Write(size_t num, const void * bytes);
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
- );
-
+ 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
namespace Wrt {
namespace PopupSerializer {
-
void appendArg(int arg, DPL::BinaryQueue &buffer)
{
size_t argSize = sizeof(arg);
buffer.FlattenConsume(str.get(), size);
return std::string(str.get(), str.get() + size);
}
-
}
} // Wrt
namespace Wrt {
namespace PopupSerializer {
-
void appendArg(int arg, DPL::BinaryQueue &buffer);
void appendArg(const std::string &arg, DPL::BinaryQueue &buffer);
int getIntArg(DPL::BinaryQueue &buffer);
std::string getStringArg(DPL::BinaryQueue &buffer);
-
}
} // Wrt
namespace Wrt {
namespace Popup {
+InfoPopup::InfoPopup() :
+ m_parent(NULL)
+{}
void InfoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
{
PopupSerializer::appendArg(answer.buttonAnswer, retValue);
m_parent->response(retValue);
}
-
} // Popup
} // Wrt
namespace Wrt {
namespace Popup {
-
class InfoPopup : public IPopup
{
-public:
+ public:
+ InfoPopup();
virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
-private:
+ private:
void responseCallback(const Renderer::AnswerCallbackData &answer);
WrtPopup* m_parent;
};
-
} // Popup
} // Wrt
namespace Wrt {
namespace Popup {
-
YesNoCheckPopup::~YesNoCheckPopup()
-{
-}
+{}
-Renderer::CtrlPopupPtr YesNoCheckPopup::createPopup(DPL::BinaryQueueAutoPtr data)
+Renderer::CtrlPopupPtr YesNoCheckPopup::createPopup(
+ DPL::BinaryQueueAutoPtr data)
{
std::string title = PopupSerializer::getStringArg(*data);
std::string message = PopupSerializer::getStringArg(*data);
std::string checkboxLabel = PopupSerializer::getStringArg(*data);
Assert(data->Empty());
LogDebug("title: " << title << " message: " << message << " checkbox: " <<
- checkboxLabel);
+ checkboxLabel);
Renderer::CtrlPopupPtr popup =
Renderer::PopupControllerSingleton::Instance().CreatePopup();
}
void YesNoCheckPopup::responseCallback(
- const Renderer::AnswerCallbackData &answer)
+ const Renderer::AnswerCallbackData &answer)
{
bool result = (POPUP_YES_VALUE == answer.buttonAnswer);
DPL::BinaryQueue retValue;
PopupSerializer::appendArg(answer.chackState, retValue);
m_parent->response(retValue);
}
-
-
} // Popup
} // Wrt
* @file YesNoCheckPopup.cpp
* @author Przmeyslaw Ciezkowsko (p.ciezkowski@samsung.com)
* @version 1.0
- * @brief Popup that contains 'Yes' and 'No' buttons and checkbox. Inplementation
+ * @brief Popup that contains 'Yes' and 'No' buttons and checkbox.
+ * Inplementation
*/
#include "YesNoPopup.h"
namespace Wrt {
namespace Popup {
-
-class YesNoCheckPopup: public YesNoPopup {
-public:
+class YesNoCheckPopup : public YesNoPopup
+{
+ public:
virtual ~YesNoCheckPopup();
-protected:
+
+ protected:
virtual Renderer::CtrlPopupPtr createPopup(DPL::BinaryQueueAutoPtr data);
virtual void responseCallback(const Renderer::AnswerCallbackData &answer);
-
};
-
} // Popup
} // Wrt
namespace Wrt {
namespace Popup {
-
void YesNoPopup::show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent)
{
LogDebug("Entered");
}
YesNoPopup::~YesNoPopup()
-{
-}
+{}
Renderer::CtrlPopupPtr YesNoPopup::createPopup(DPL::BinaryQueueAutoPtr data)
{
popup->Append(new Renderer::PopupObject::Button(NO_LABEL, POPUP_NO_VALUE));
return popup;
}
-
} // Popup
} // Wrt
namespace Wrt {
namespace Popup {
-
const char YES_LABEL[] = "Yes";
const char NO_LABEL[] = "No";
const int POPUP_YES_VALUE = 1;
class YesNoPopup : public IPopup
{
-public:
+ public:
virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent);
virtual ~YesNoPopup();
-protected:
+
+ protected:
virtual Renderer::CtrlPopupPtr createPopup(DPL::BinaryQueueAutoPtr data);
virtual void responseCallback(const Renderer::AnswerCallbackData &answer);
WrtPopup* m_parent;
};
-
} // Popup
} // Wrt
* @file evas_object.cpp
* @author Lukasz Wrzosek (l.wrzosel@samsung.com)
* @version 1.0
- * @brief This file is the implementation for Evas_Object wrapper from Efl.
+ * @brief This file is the implementation for Evas_Object wrapper from
+ * Efl.
*/
#include "evas_object.h"
#include <stddef.h>
#include <dpl/foreach.h>
-
namespace Wrt {
namespace Popup {
namespace Renderer {
-
Evas_Object* EvasObject::IConnection::GetEvasObject()
{
return m_object->GetObject();
EvasObject::IConnection::IConnection(EvasObject::EvasObjectShared* object) :
m_object(object)
-{
-}
+{}
void EvasObject::IConnection::SmartCallbackWrapper(void* data,
- Evas_Object* /*object*/,
- void* event_info)
+ Evas_Object* /*object*/,
+ void* event_info)
{
Assert(data);
IConnection* Calle = static_cast<IConnection*>(data);
}
void EvasObject::IConnection::EvasCallbackWrapper(void* data,
- Evas* /*evas*/,
- Evas_Object* /*object*/,
- void* event_info)
+ Evas* /*evas*/,
+ Evas_Object* /*object*/,
+ void* event_info)
{
Assert(data);
IConnection* Calle = static_cast<IConnection*>(data);
}
EvasObject::EvasObjectShared::SmartConnectionBase::SmartConnectionBase(
- const std::string& name,
- EvasObject::EvasObjectShared* object) :
+ const std::string& name,
+ EvasObject::EvasObjectShared* object) :
IConnection(object),
m_callbackName(name)
-{
-}
+{}
void EvasObject::EvasObjectShared::SmartConnectionBase::ConnectPrv()
{
}
EvasObject::EvasObjectShared::EvasConnectionBase::EvasConnectionBase(
- Evas_Callback_Type type,
- EvasObject::EvasObjectShared* object) :
+ Evas_Callback_Type type,
+ EvasObject::EvasObjectShared* object) :
IConnection(object),
m_callbackType(type)
-{
-}
+{}
void EvasObject::EvasObjectShared::EvasConnectionBase::ConnectPrv()
{
EvasObject::EvasObjectShared::EvasObjectShared() :
m_object(NULL)
-{
-}
+{}
EvasObject::EvasObjectShared::EvasObjectShared(Evas_Object* object) :
m_object(object)
}
void EvasObject::EvasObjectShared::StaticOnDelEvent(void* data,
- Evas* /*e*/,
- Evas_Object* /*o*/,
- void* /*ev*/)
+ Evas* /*e*/,
+ Evas_Object* /*o*/,
+ void* /*ev*/)
{
Assert(data);
EvasObjectShared* This = static_cast<EvasObjectShared*>(data);
EvasObject::EvasObject() :
m_object(new EvasObjectShared())
-{
-}
+{}
EvasObject::EvasObject(Evas_Object* object) :
m_object(new EvasObjectShared(object))
-{
-}
+{}
EvasObject::EvasObject(const EvasObject& other) :
m_object(other.m_object)
-{
-}
+{}
//this destructor must be here to let pimpl with shared_ptr work without warning
EvasObject::~EvasObject()
-{
-}
+{}
EvasObject& EvasObject::operator=(const EvasObject& other)
{
Assert(m_object);
return m_object->GetObject();
}
-
}
} // namespace DPL
} // namespace Popup
namespace Wrt {
namespace Popup {
namespace Renderer {
-
class EvasObject
{
class EvasObjectShared;
private:
IConnection(EvasObjectShared* object);
virtual ~IConnection()
- {
- }
+ {}
virtual void Call(void* /*event_info*/) = 0;
static void SmartCallbackWrapper(void* data,
- Evas_Object* /*object*/,
- void* event_info);
+ Evas_Object* /*object*/,
+ void* event_info);
static void EvasCallbackWrapper(void* data,
- Evas* /*evas*/,
- Evas_Object* /*object*/,
- void* event_info);
+ Evas* /*evas*/,
+ Evas_Object* /*object*/,
+ void* event_info);
virtual void ConnectPrv() = 0;
virtual void DisconnectPrv() = 0;
{
public:
SmartConnectionBase(const std::string& name,
- EvasObjectShared* object);
+ EvasObjectShared* object);
virtual void ConnectPrv();
virtual void DisconnectPrv();
Args ... args);
SmartConnection(const std::string& name,
- CbType callback,
- EvasObjectShared* object,
- Args ... args) :
+ CbType callback,
+ EvasObjectShared* object,
+ Args ... args) :
SmartConnectionBase(name, object),
m_callback(callback),
m_args(args ...)
- {
- }
+ {}
virtual ~SmartConnection()
- {
- }
+ {}
virtual void Call(void* event_info)
{
void* event_info, ArgType1 *arg1);
SmartMemberConnection1(const std::string& name,
- CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- EvasObjectShared* object) :
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
SmartConnectionBase(name, object),
m_callback(callback),
m_callee(callee),
m_arg1(arg1)
- {
- }
+ {}
virtual ~SmartMemberConnection1()
- {
- }
+ {}
virtual void Call(void* event_info)
{
ArgType2* arg2);
SmartMemberConnection2(const std::string& name,
- CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2,
- EvasObjectShared* object) :
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
SmartConnectionBase(name, object),
m_callback(callback),
m_callee(callee),
m_arg1(arg1),
m_arg2(arg2)
- {
- }
+ {}
virtual ~SmartMemberConnection2()
- {
- }
+ {}
virtual void Call(void* event_info)
{
{
public:
EvasConnectionBase(Evas_Callback_Type type,
- EvasObjectShared* object);
+ EvasObjectShared* object);
virtual void ConnectPrv();
virtual void DisconnectPrv();
ArgType1 *arg1);
EvasConnection1(Evas_Callback_Type type,
- CbType callback,
- ArgType1* arg1,
- EvasObjectShared* object) :
+ CbType callback,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
EvasConnectionBase(type, object),
m_callback(callback),
m_arg1(arg1)
- {
- }
+ {}
virtual ~EvasConnection1()
- {
- }
+ {}
virtual void Call(void* event_info)
{
ArgType1 *arg1, ArgType2 *arg2);
EvasConnection2(Evas_Callback_Type type,
- CbType callback,
- ArgType1* arg1,
- ArgType2* arg2,
- EvasObjectShared* object) :
+ CbType callback,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
EvasConnectionBase(type, object),
m_callback(callback),
m_arg1(arg1),
m_arg2(arg2)
- {
- }
+ {}
virtual ~EvasConnection2()
- {
- }
+ {}
virtual void Call(void* event_info)
{
void* event_info, ArgType1 *arg1);
EvasMemberConnection1(Evas_Callback_Type type,
- CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- EvasObjectShared* object) :
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ EvasObjectShared* object) :
EvasConnectionBase(type, object),
m_callback(callback),
m_callee(callee),
m_arg1(arg1)
- {
- }
+ {}
virtual ~EvasMemberConnection1()
- {
- }
+ {}
virtual void Call(void* event_info)
{
ArgType2* arg2);
EvasMemberConnection2(Evas_Callback_Type type,
- CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2,
- EvasObjectShared* object) :
+ CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2,
+ EvasObjectShared* object) :
EvasConnectionBase(type, object),
m_callback(callback),
m_callee(callee),
m_arg1(arg1),
m_arg2(arg2)
- {
- }
+ {}
virtual ~EvasMemberConnection2()
- {
- }
+ {}
virtual void Call(void* event_info)
{
~EvasObjectShared();
template<typename ... Args>
- IConnection* ConnectSmartCallback(const char* callbackName,
- typename SmartConnection<Args ...>::CbType callback,
- Args ... args)
+ IConnection* ConnectSmartCallback(
+ const char* callbackName,
+ typename SmartConnection<Args ...>::
+ CbType callback,
+ Args ... args)
{
Assert(m_object);
Assert(callbackName);
template <class ThisType, class ArgType1, class ArgType2>
IConnection* ConnectMemberSmartCallback(
- const char* callbackName,
- typename SmartMemberConnection2<ThisType, ArgType1,
- ArgType2>::CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2)
+ const char* callbackName,
+ typename SmartMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
Assert(callee);
template <class ThisType, class ArgType1>
IConnection* ConnectMemberSmartCallback(
- const char* callbackName,
- typename SmartMemberConnection1<ThisType,
- ArgType1>::CbType callback,
- ThisType* callee,
- ArgType1* arg1)
+ const char* callbackName,
+ typename SmartMemberConnection1<ThisType,
+ ArgType1>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1)
{
Assert(m_object);
Assert(callee);
template <class ArgType1, class ArgType2>
IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType,
- typename EvasConnection2<ArgType1, ArgType2>::CbType callback,
- ArgType1* arg1,
- ArgType2* arg2)
+ typename EvasConnection2<ArgType1,
+ ArgType2>::
+ CbType callback,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
Assert(callbackType);
}
template <class ArgType1>
- IConnection* ConnectEvasCallback(Evas_Callback_Type callbackType,
- typename EvasConnection1<ArgType1>::CbType callback,
- ArgType1* arg1)
+ IConnection* ConnectEvasCallback(
+ Evas_Callback_Type callbackType,
+ typename EvasConnection1<ArgType1>::
+ CbType callback,
+ ArgType1* arg1)
{
Assert(m_object);
Assert(callbackType);
template <class ThisType, class ArgType1, class ArgType2>
IConnection* ConnectMemberEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasMemberConnection2<ThisType, ArgType1,
- ArgType2>::CbType callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2)
+ Evas_Callback_Type callbackType,
+ typename EvasMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
Assert(callee);
template <class ThisType, class ArgType1>
IConnection* ConnectMemberEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasMemberConnection1<ThisType,
- ArgType1>::CbType callback,
- ThisType* callee,
- ArgType1* arg1)
+ Evas_Callback_Type callbackType,
+ typename EvasMemberConnection1<ThisType,
+ ArgType1>::CbType callback,
+ ThisType* callee,
+ ArgType1* arg1)
{
Assert(m_object);
Assert(callee);
void DisconnectAll();
static void StaticOnDelEvent(void* data,
- Evas* /*e*/,
- Evas_Object* /*o*/,
- void* /*ev*/);
+ Evas* /*e*/,
+ Evas_Object* /*o*/,
+ void* /*ev*/);
IConnectionsSet m_connections;
Evas_Object* m_object;
template <class ... Args>
IConnection* ConnectSmartCallback(
- const char* callbackName,
- typename EvasObjectShared::SmartConnection<Args ...>::CbType
- callback,
- Args ... args)
+ const char* callbackName,
+ typename EvasObjectShared::SmartConnection<Args ...>::CbType
+ callback,
+ Args ... args)
{
Assert(m_object);
return m_object->ConnectSmartCallback(callbackName, callback, args ...);
template <class ThisType, class ArgType1, class ArgType2>
IConnection* ConnectMemberSmartCallback(
- const char* callbackName,
- typename EvasObjectShared::SmartMemberConnection2<ThisType,
- ArgType1,
- ArgType2>::CbType
- callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2)
+ const char* callbackName,
+ typename EvasObjectShared::SmartMemberConnection2<ThisType,
+ ArgType1,
+ ArgType2>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
Assert(callee);
template <class ThisType, class ArgType1>
IConnection* ConnectMemberSmartCallback(
- const char* callbackName,
- typename EvasObjectShared::SmartMemberConnection1<ThisType,
- ArgType1>::CbType
- callback,
- ThisType* callee,
- ArgType1* arg1)
+ const char* callbackName,
+ typename EvasObjectShared::SmartMemberConnection1<ThisType,
+ ArgType1>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1)
{
Assert(m_object);
Assert(callee);
template <class ArgType1, class ArgType2>
IConnection* ConnectEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
- callback,
- ArgType1* arg1,
- ArgType2* arg2)
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+ callback,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
return m_object->ConnectEvasCallback(callbackType, callback, arg1, arg2);
template <class ArgType1>
IConnection* ConnectEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
- callback,
- ArgType1* arg1)
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasConnection1<ArgType1>::CbType
+ callback,
+ ArgType1* arg1)
{
Assert(m_object);
return m_object->ConnectEvasCallback(callbackType, callback, arg1);
template <class ThisType, class ArgType1>
IConnection* ConnectMemberEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasObjectShared::EvasMemberConnection1<ThisType,
- ArgType1>::CbType
- callback,
- ThisType* callee,
- ArgType1* arg1)
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasMemberConnection1<ThisType,
+ ArgType1>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1)
{
Assert(m_object);
Assert(callee);
template <class ThisType, class ArgType1, class ArgType2>
IConnection* ConnectMemberEvasCallback(
- Evas_Callback_Type callbackType,
- typename EvasObjectShared::EvasMemberConnection2<ThisType, ArgType1,
- ArgType2>::CbType
- callback,
- ThisType* callee,
- ArgType1* arg1,
- ArgType2* arg2)
+ Evas_Callback_Type callbackType,
+ typename EvasObjectShared::EvasMemberConnection2<ThisType, ArgType1,
+ ArgType2>::CbType
+ callback,
+ ThisType* callee,
+ ArgType1* arg1,
+ ArgType2* arg2)
{
Assert(m_object);
Assert(callee);
private:
EvasObjectSharedPtr m_object;
};
-
}
-}//namespace
-}//namespace
-
+} //namespace
+} //namespace
#endif //WRT_SRC_DOMAIN_EFL_EVAS_OBJECT_H
namespace Wrt {
namespace Popup {
namespace Renderer {
-
struct AnswerCallbackData
{
int buttonAnswer;
typedef void (*PopupCallbackType)(const AnswerCallbackData& answer,
void *data);
virtual void Show(PopupCallbackType callback,
- void* data) = 0;
+ void* data) = 0;
virtual ~IPopup()
- {
- }
+ {}
private:
friend class PopupManager;
friend class std::shared_ptr<IPopup>;
};
-
}
} // namespace Popup
} // namespace Wrt
namespace Wrt {
namespace Popup {
namespace Renderer {
-
void CtrlPopup::SetTitle(const std::string &title)
{
Assert(m_popup);
}
CtrlPopup::~CtrlPopup()
-{
-}
+{}
void CtrlPopup::EmitAnswer(const AnswerCallbackData & answer)
{
}
PopupController::PopupController() : m_canvas(NULL)
-{
-}
+{}
CtrlPopupPtr PopupController::CreatePopup() const
{
}
void PopupController::StaticOnAnswerReceived(const AnswerCallbackData & answer,
- CtrlPopupPtr* popup)
+ CtrlPopupPtr* popup)
{
Assert(popup != NULL);
(*popup)->EmitAnswer(answer);
PopupAnswerCallback answerCall = event.GetArg1();
AnswerCallbackData answer = event.GetArg2();
answerCall.Call(answer);
- event.GetArg0()->DPL::Event::EventSupport<PopupAnswerEvent>::RemoveListener(this);
+ event.GetArg0()->DPL::Event::EventSupport<PopupAnswerEvent>::RemoveListener(
+ this);
}
void PopupControllerUser::ListenForAnswer(CtrlPopupPtr popup)
{
popup->DPL::Event::EventSupport<PopupAnswerEvent>::AddListener(this);
}
-
}
} //namespace Popup
} //namespace Wrt
/**
* To display a popup from a given class:
*
- **class ABC
- **{
+ * class ABC
+ * {
* void AskUser()
* {
* }
* void DoSomeLogicWithAnswer()
* {
* }
- **};
+ * };
*
* ... update the class to something simmilar:
*
- **class ABC : Popup::PopupControllerUser
- **{
+ * class ABC : Popup::PopupControllerUser
+ * {
* void AskUser() {
* using namespace Popup;
* CtrlPopupPtr popup =
* else if (answer == 2)
* ;//name2 pressed
* }
- **};
+ * };
**/
#ifndef WRT_SRC_POPUP_CONTROLLER_POPUP_CONTROLLER_H_
namespace Wrt {
namespace Popup {
namespace Renderer {
-
typedef int LabelId;
struct PopupAnswerCallback
void* callee;
MemberPtr member;
void (*callTranslator)(PopupAnswerCallback* callData,
- const AnswerCallbackData& answer);
+ const AnswerCallbackData& answer);
void Call(const AnswerCallbackData& answer)
{
void Append(PopupObject::IPopupObject *object);
~CtrlPopup();
+
private:
friend class PopupController;
friend class std::shared_ptr<CtrlPopup>;
private:
static void StaticOnAnswerReceived(const AnswerCallbackData& answer,
- CtrlPopupPtr* popup);
+ CtrlPopupPtr* popup);
};
class PopupControllerUser : DPL::Event::EventListener<PopupAnswerEvent>
};
static PopupAnswerCallback Create(Type* callee,
- MemberPtr callback)
+ MemberPtr callback)
{
PopupAnswerCallback callData;
}
static void MemberCallbackTranslator(PopupAnswerCallback* callData,
- const AnswerCallbackData& answer)
+ const AnswerCallbackData& answer)
{
Type* typedThis = static_cast<Type*>(callData->callee);
Caster caster;
template <class Type>
PopupAnswerCallback MakeAnswerCallback(Type* This,
- void (Type::*callback)
- (const AnswerCallbackData &))
+ void (Type::*callback)
+ (const AnswerCallbackData &))
{
return PopupAnswerCallbackCreator<Type>::Create(This, callback);
}
};
typedef DPL::Singleton<PopupController> PopupControllerSingleton;
-
}
} //namespace Popup
} //namespace Wrt
namespace Wrt {
namespace Popup {
namespace Renderer {
-
void PopupManager::Initialize(PopupRendererPtr renderer)
{
Assert(!m_initialized);
Assert(m_initialized);
return m_popupRenderer->CreatePopup();
}
-
}
} // namespace Popup
} // namespace Wrt
namespace Wrt {
namespace Popup {
namespace Renderer {
-
class PopupManager : DPL::Noncopyable
{
template <class ArgType>
IPopupPtr CreatePopup();
template <class ArgType>
- void RunAsyncWithArgType(IPopupPtr popup,
- typename TemplatedPopupCallback<ArgType>::Type callback,
- ArgType* argument)
+ void RunAsyncWithArgType(
+ IPopupPtr popup,
+ typename TemplatedPopupCallback<ArgType>::Type
+ callback,
+ ArgType* argument)
{
Assert(callback);
WrapCbAndArg<ArgType>* wrapped =
}
void Show(IPopupPtr popup,
- IPopup::PopupCallbackType callback,
- void* userdata)
+ IPopup::PopupCallbackType callback,
+ void* userdata)
{
popup->Show(callback, userdata);
}
struct WrapCbAndArg
{
WrapCbAndArg(typename TemplatedPopupCallback<ArgType>::Type cb,
- ArgType* arg) :
+ ArgType* arg) :
callback(cb),
argument(arg)
- {
- }
+ {}
typename TemplatedPopupCallback<ArgType>::Type callback;
ArgType* argument;
template <class ArgType>
static void CallbackArgTypeTranslator(const AnswerCallbackData & answer,
- void* data)
+ void* data)
{
WrapCbAndArg<ArgType>* wrapped =
static_cast< WrapCbAndArg<ArgType>* >(data);
};
typedef DPL::Singleton<PopupManager> PopupManagerSingleton;
-
}
} // namespace Popup
} // namespace Wrt
namespace Wrt {
namespace Popup {
namespace Renderer {
-
namespace PopupObject {
class IPopupObject;
class PopupObjectBase;
virtual Check* asCheck() = 0;
virtual PopupType getType() const = 0;
virtual ~IPopupObject()
- {
- }
+ {}
};
class PopupObjectBase : public IPopupObject
protected:
PopupObjectBase(PopupType type) : m_type(type)
- {
- }
+ {}
PopupType m_type;
};
{
public:
Button(const std::string& label,
- int labelId) :
+ int labelId) :
PopupObjectBase(BUTTON),
m_label(label),
m_labelId(labelId)
- {
- }
+ {}
Button* asButton()
{
Label(const std::string &label) :
PopupObjectBase(LABEL),
m_label(label)
- {
- }
+ {}
Label* asLabel()
{
Check(const std::string &label) :
PopupObjectBase(CHECK),
m_checkLabel(label)
- {
- }
+ {}
Check* asCheck()
{
std::string m_checkLabel;
};
} /*PopupObject*/
-
}
-}//namespace Popup
-}//namespace Wrt
+} //namespace Popup
+} //namespace Wrt
#endif //WRT_SRC_POPUP_POPUPOBJECT_H_
#include "evas_object.h"
namespace Wrt {
-
namespace {
using namespace Popup;
const char* EDJ_NAME = "/usr/share/edje/ace/generic_popup.edj";
namespace Popup {
namespace Renderer {
-
class PopupRenderer::Impl
{
public:
Impl() :
m_popupsToRender(),
m_current(),
- m_initialized(false)
- {
- }
+ m_initialized(false),
+ m_checkState(false),
+ m_themeIndexV(0),
+ m_externalCanvas(NULL)
+ {}
~Impl()
{
}
void ButtonCallback(EvasObject::IConnection* /*connection*/,
- void* /*event_info*/,
- void* data)
+ void* /*event_info*/,
+ void* data)
{
LogInfo("ButtonCallback");
Assert(m_initialized);
}
void CheckCallback(EvasObject::IConnection* connection,
- void* /*event_info*/,
- void* /* unused */)
+ void* /*event_info*/,
+ void* /* unused */)
{
m_checkState =
elm_check_state_get(connection->GetEvasObject());
}
void DoRender(const PopupObject::Label& object,
- EvasObject& parent,
- EvasObject& layout,
- int themeIndex)
+ EvasObject& parent,
+ EvasObject& layout,
+ int themeIndex)
{
EvasObject label(elm_label_add(parent));
}
void DoRender(const PopupObject::Check& object,
- EvasObject& parent,
- EvasObject& layout,
- int themeIndex)
+ EvasObject& parent,
+ EvasObject& layout,
+ int themeIndex)
{
EvasObject check(elm_check_add(parent));
}
void DoRender(const PopupObject::Button& object,
- EvasObject &parent)
+ EvasObject &parent)
{
EvasObject btn(elm_button_add(parent));
btn.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
&Impl::ButtonCallback,
this,
- reinterpret_cast<void*>(object.getLabelId()));
+ reinterpret_cast<void*>(object.
+ getLabelId()));
m_createdObjects.push_back(btn);
}
void DoRender(const PopupObject::Button& object1,
- const PopupObject::Button& object2,
- EvasObject &parent)
+ const PopupObject::Button& object2,
+ EvasObject &parent)
{
DoRender(object1, parent);
btn2.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
&Impl::ButtonCallback,
this,
- reinterpret_cast<void*>(object2.getLabelId()));
+ reinterpret_cast<void*>(object2.
+ getLabelId()));
m_createdObjects.push_back(btn2);
}
void DoRender(const PopupObject::Button& object1,
- const PopupObject::Button& object2,
- const PopupObject::Button& object3,
- EvasObject &parent)
+ const PopupObject::Button& object2,
+ const PopupObject::Button& object3,
+ EvasObject &parent)
{
DoRender(object1, object2, parent);
btn3.ConnectMemberSmartCallback(BUTTON_CLICKED_CALLBACK_NAME,
&Impl::ButtonCallback,
this,
- reinterpret_cast<void*>(object3.getLabelId()));
+ reinterpret_cast<void*>(object3.
+ getLabelId()));
m_createdObjects.push_back(btn3);
}
m_themeIndexV = 0;
// preprocessing
- std::vector<int> countPopupObjects = {0 /* PopupObject::BUTTON */,
- 0 /* PopupObject::LABEL */,
- 0 /* PopupObject::CHECK */};
+ std::vector<int> countPopupObjects = { 0 /* PopupObject::BUTTON */,
+ 0 /* PopupObject::LABEL */,
+ 0 /* PopupObject::CHECK */ };
FOREACH(it, m_current->GetPopupObjects()) {
Assert((*it)->getType() < countPopupObjects.size() &&
- "Wrong PopupObject assigned");
+ "Wrong PopupObject assigned");
countPopupObjects[(*it)->getType()]++;
}
int needsIndexV = countPopupObjects[PopupObject::LABEL] +
layout);
// show buution
- switch(buttonObjectList.size()) {
+ switch (buttonObjectList.size()) {
case 0:
LogInfo("no button");
break;
IPopupPtr PopupRenderer::CreatePopup()
{
return std::static_pointer_cast<IPopup>(IPopupPtr
- (new Popup(shared_from_this())));
+ (new Popup(shared_from_this())));
}
void PopupRenderer::Render(PopupPtr popup)
{
m_impl->setExternalCanvas(externalCanvas);
}
-
}
} // namespace Popup
} // namespace Wrt
namespace Wrt {
namespace Popup {
namespace Renderer {
-
class PopupRenderer : public std::enable_shared_from_this<PopupRenderer>
{
public:
void Deinitialize();
IPopupPtr CreatePopup();
virtual void setExternalCanvas(void* externalCanvas);
+
protected:
class Popup;
typedef std::shared_ptr<Popup> PopupPtr;
}
virtual void Show(IPopup::PopupCallbackType callback,
- void* data)
+ void* data)
{
Assert(callback);
m_data = data;
friend class PopupObjectTheme;
Popup(std::shared_ptr<PopupRenderer> renderer) : m_renderer(renderer)
- {
- }
+ {}
void ForwardAnswer(const AnswerCallbackData & answer) const
{
};
typedef std::shared_ptr<PopupRenderer> PopupRendererPtr;
-
}
} // namespace Popup
} // namespace Wrt
namespace Wrt {
namespace Popup {
-
bool WrtPopup::openPipes()
{
Try
{
Try
{
- if (m_pipesOpened)
- {
+ if (m_pipesOpened) {
DPL::WaitableHandleWatchSupport::InheritedContext()->
RemoveWaitableHandleWatch(this,
m_input.WaitableReadHandle(),
}
}
-void WrtPopup::OnEventReceived(const QuitEvent &/* event */)
+void WrtPopup::OnEventReceived(const QuitEvent & /* event */)
{
LogDebug("Quiting");
closePipes();
void WrtPopup::OnWaitableHandleEvent(DPL::WaitableHandle waitableHandle,
DPL::WaitMode::Type /*mode*/)
{
- if (waitableHandle == m_input.WaitableReadHandle())
- {
+ if (waitableHandle == m_input.WaitableReadHandle()) {
readInputData();
}
}
m_input.Read(std::numeric_limits<std::size_t>::max());
int popupType = PopupSerializer::getIntArg(*data);
LogDebug("popup type " << popupType);
- switch(popupType) {
+ switch (popupType) {
case YES_NO_PROMPT:
m_popup.reset(new YesNoPopup());
m_popup->show(data, this);
void WrtPopup::OnCreate()
{
- if (!openPipes())
- {
+ if (!openPipes()) {
PostEvent(QuitEvent());
}
LogInfo("On Create");
Renderer::PopupManagerSingleton::Instance().Deinitialize();
LogDebug("App Finished");
}
-
}
}
namespace Wrt {
namespace Popup {
-
DECLARE_GENERIC_EVENT_0(QuitEvent)
class WrtPopup;
class IPopup : public Renderer::PopupControllerUser
{
-public:
+ public:
virtual void show(DPL::BinaryQueueAutoPtr data, WrtPopup* parent) = 0;
virtual ~IPopup() {}
};
typedef std::unique_ptr<IPopup> IPopupPtr;
-
class WrtPopup :
public DPL::WaitableHandleWatchSupport::WaitableHandleListener,
public DPL::Application,
private DPL::Event::Controller<DPL::TypeListDecl<QuitEvent>::Type>
{
-public:
+ public:
WrtPopup(int argc, char **argv);
virtual ~WrtPopup();
void response(DPL::BinaryQueue result);
-protected:
+ protected:
//DPL::Application functions
virtual void OnStop();
virtual void OnCreate();
virtual void OnEventReceived(const QuitEvent &event);
virtual void OnWaitableHandleEvent(DPL::WaitableHandle waitableHandle,
DPL::WaitMode::Type mode);
-private:
+
+ private:
void showAcePrompt(DPL::BinaryQueueAutoPtr data);
void communicationBoxResponse(int buttonAnswer,
DPL::NamedInputPipe m_input;
DPL::NamedOutputPipe m_output;
};
-
}
}
namespace Wrt {
namespace Popup {
-
PopupInvoker::PopupInvoker() :
- m_inputName(tmpnam(NULL)),
- m_outputName(tmpnam(NULL))
+ m_inputName(tmpnam_r(NULL)),
+ m_outputName(tmpnam_r(NULL))
{
Try
{
m_output.Create(m_outputName);
LogDebug("Pipes created");
}
- Catch (DPL::Exception)
+ Catch(DPL::Exception)
{
LogError("Cannot create pipes");
}
m_output.Destroy(m_outputName);
LogDebug("Pipes destroyed");
}
- Catch (DPL::Exception)
+ Catch(DPL::Exception)
{
LogError("Cannot destroy pipes");
}
}
-bool PopupInvoker::askYesNo(const std::string& title, const std::string& message)
+bool PopupInvoker::askYesNo(const std::string& title,
+ const std::string& message)
{
Try
{
}
PopupResponse PopupInvoker::askYesNoCheckbox(const std::string& title,
- const std::string& message, const std::string& checkboxLabel)
+ const std::string& message,
+ const std::string& checkboxLabel)
{
Try
{
const int result = PopupSerializer::getIntArg(*resultData);
const int rememberResult = PopupSerializer::getIntArg(*resultData);
- LogDebug("Popup result is: " << result << " remeber: " << rememberResult);
+ LogDebug(
+ "Popup result is: " << result << " remeber: " << rememberResult);
Assert(resultData->Empty());
tmp.Close();
void PopupInvoker::executePopup()
{
pid_t pid = fork();
- if (pid == -1)
- {
+ if (pid == -1) {
//error occured
LogError("Cannot display popup!");
Assert(false);
}
- if (pid == 0)
- {
+ if (pid == 0) {
//child process
int ret = execl(POPUP_EXEC,
POPUP_EXEC,
DPL::WaitableHandle handle = m_input.WaitableReadHandle();
DPL::WaitForSingleHandle(handle);
}
-
} // Popup
} // Wrt
#include <dpl/named_output_pipe.h>
/*
-
- Example usage:
-
- bool result = PopupInvoker().askYesNo("title", "message");
-
+ *
+ * Example usage:
+ *
+ * bool result = PopupInvoker().askYesNo("title", "message");
+ *
*/
namespace Wrt {
namespace Popup {
-
enum PopupResponse {
NO_DO_REMEMBER,
NO_DONT_REMEMBER,
class PopupInvoker
{
-public:
+ public:
class Exception
{
public:
const std::string &message,
const std::string &buttonLabel = std::string("OK"));
PopupResponse askYesNoCheckbox(const std::string& title,
- const std::string& message, const std::string& checkboxLabel);
+ const std::string& message,
+ const std::string& checkboxLabel);
-private:
+ private:
void executePopup();
const std::string m_inputName;
const std::string m_outputName;
};
-
} // Popup
} // Wrt
# @brief
#
-SET(TARGET_WIDGETDB_TEST "plugins-tests-widgetdb")
+SET(TARGET_WIDGETDB_TEST "wrt-plugins-common-tests-widgetdb")
pkg_search_module(dpl REQUIRED dpl-efl)
pkg_search_module(dpl-test REQUIRED dpl-test-efl)
{
int ret = system("/usr/bin/widgetdb_tests_prepare_db.sh start");
- if (!WIFEXITED(ret)) { //unexpected termiate
+ if (!WIFEXITED(ret)) { //unexpected terminate
LogDebug("Fail while preparing database. Restoring");
- system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ ret = system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ if (ret != 0)
+ LogError("Finalization script has return error: " << ret);
+
return -1;
} else if (WEXITSTATUS(ret)) { //wrong script command, nothing done
- LogError("Preparation script has return error: " << ret
- << ". Quitting");
- return -1;
+ LogError("Preparation script has return error: " << ret
+ << ". Quitting");
+ return -1;
}
LogInfo("Starting tests");
WrtDB::WrtDatabase::detachFromThread();
- system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ ret = system("/usr/bin/widgetdb_tests_prepare_db.sh stop");
+ if (ret != 0) {
+ LogError("Finalization script has return error: " << ret);
+ return -1;
+ }
+
return status;
}
std::string temp(in); \
RUNNER_ASSERT_MSG(temp == (test), "Equals: [" << temp << "]"); \
} \
- while(0)
+ while (0)
RUNNER_TEST_GROUP_INIT(WidgetDB)
/*
-Name: widgetDB_test_get_language1
-Description: check default widget language
-Expected: default should be "en"
-*/
+ * Name: widgetDB_test_get_language1
+ * Description: check default widget language
+ * Expected: default should be "en"
+ */
RUNNER_TEST(widgetDB_test_get_language1)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string lang = widget->getLanguage();
LogDebug("language is: " << lang);
RUNNER_ASSERT_WHAT_EQUALS(lang, "en");
-
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_language2
-Description: check language returned by WidgetDB if widget does nto exists
-Expected: result should be ""
-*/
+ * Name: widgetDB_test_get_language2
+ * Description: check language returned by WidgetDB if widget does nto exists
+ * Expected: result should be ""
+ */
RUNNER_TEST(widgetDB_test_get_language2)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(1000); //widget not exist
std::string lang = widget->getLanguage();
LogDebug("language is: " << lang);
RUNNER_ASSERT_WHAT_EQUALS(lang, "");
-
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_id
-Description: check GUID returned by WidgetDB
-Expected: GUID should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_id
+ * Description: check GUID returned by WidgetDB
+ * Expected: GUID should match this, which was inserted into widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_id)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::ID);
LogDebug("id is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_id_2000");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_version
-Description: check version returned by WidgetDB
-Expected: version should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_version
+ * Description: check version returned by WidgetDB
+ * Expected: version should match this, which was inserted into widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_version)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::VERSION);
LogDebug("version is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "1.0.0");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_description
-Description: check description returned by WidgetDB
-Expected: description should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_description
+ * Description: check description returned by WidgetDB
+ * Expected: description should match this, which was inserted into widget
+ * database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_description)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::DESCRIPTION);
LogDebug("description is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_desc_2000_en");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_license
-Description: check license returned by WidgetDB
-Expected: license should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_license
+ * Description: check license returned by WidgetDB
+ * Expected: license should match this, which was inserted into widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_license)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE);
LogDebug("licence is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_2000_en");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_license_href
-Description: check license href returned by WidgetDB
-Expected: license href should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_license_href
+ * Description: check license href returned by WidgetDB
+ * Expected: license href should match this, which was inserted into widget
+ * database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_license_href)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::LICENSE_HREF);
LogDebug("license href is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_lic_href_2000_en");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_author_name
-Description: check author name href returned by WidgetDB
-Expected: author name should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_author_name
+ * Description: check author name href returned by WidgetDB
+ * Expected: author name should match this, which was inserted into widget
+ * database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_author_name)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_NAME);
LogDebug("author name is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_name_2000");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_author_href
-Description: check author href returned by WidgetDB
-Expected: author href should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_author_href
+ * Description: check author href returned by WidgetDB
+ * Expected: author href should match this, which was inserted into widget
+ * database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_author_href)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_HREF);
LogDebug("author href is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_href_2000");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_author_email
-Description: check author email returned by WidgetDB
-Expected: author email should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_author_email
+ * Description: check author email returned by WidgetDB
+ * Expected: author email should match this, which was inserted into widget
+ * database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_author_email)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::AUTHOR_EMAIL);
LogDebug("author email is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "a_email_2000");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_name
-Description: check localized widget name returned by WidgetDB
-Expected: localized widget name should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_name
+ * Description: check localized widget name returned by WidgetDB
+ * Expected: localized widget name should match this, which was inserted into
+ * widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_name)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::NAME);
LogDebug("name is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_name_2000_en");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_short_name
-Description: check localized widget short name returned by WidgetDB
-Expected: localized widget short name should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_short_name
+ * Description: check localized widget short name returned by WidgetDB
+ * Expected: localized widget short name should match this, which was inserted
+ * into widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_short_name)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::SHORT_NAME);
LogDebug("short name is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "w_shortname_2000_en");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_access_network
-Description: check network access returned by WidgetDB
-Expected: network access should be set to "yes"
-*/
+ * Name: widgetDB_test_get_config_value_access_network
+ * Description: check network access returned by WidgetDB
+ * Expected: network access should be set to "yes"
+ */
RUNNER_TEST(widgetDB_test_get_config_value_access_network)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(
- ConfigAttribute::ACCESS_NETWORK);
+ ConfigAttribute::ACCESS_NETWORK);
LogDebug("acces network is always true: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "yes");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_width
-Description: check widget prefered width returned by WidgetDB
-Expected: widget prefered width should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_width
+ * Description: check widget prefered width returned by WidgetDB
+ * Expected: widget prefered width should match this, which was inserted into
+ * widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_width)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::WIDTH);
LogDebug("width is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "100");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_height
-Description: check widget prefered height returned by WidgetDB
-Expected: widget prefered height should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_height
+ * Description: check widget prefered height returned by WidgetDB
+ * Expected: widget prefered height should match this, which was inserted into
+ * widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_height)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::HEIGHT);
LogDebug("height is: " << tmp);
RUNNER_ASSERT_WHAT_EQUALS(tmp, "200");
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_paths
-Description: check widget installation path returned by WidgetDB
-Expected: widget installation path should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_get_config_value_paths
+ * Description: check widget installation path returned by WidgetDB
+ * Expected: widget installation path should match this, which was inserted into
+ * widget database
+ */
RUNNER_TEST(widgetDB_test_get_config_value_paths)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
std::string tmp = widget->getConfigValue(ConfigAttribute::INSTALL_PATH);
LogDebug("install path is: " << tmp);
tmp = widget->getConfigValue(
- ConfigAttribute::PUBLIC_STORAGE_PATH);
+ ConfigAttribute::PUBLIC_STORAGE_PATH);
LogDebug("public storage path is: " << tmp);
-
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogDebug("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_get_config_value_empty
-Description: check if requesting GUID from WidgetDB throw excpetion if widget does not exists
-Expected: accessing GUID should throw WrtDeviceApis::Commons::SecurityException
-*/
+ * Name: widgetDB_test_get_config_value_empty
+ * Description: check if requesting GUID from WidgetDB throw excpetion if widget
+ * does not exists
+ * Expected: accessing GUID should throw
+ * WrtDeviceApis::Commons::SecurityException
+ */
RUNNER_TEST(widgetDB_test_get_config_value_empty)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2005);
- std::string tmp = widget->getConfigValue(ConfigAttribute::ID);
+ widget->getConfigValue(ConfigAttribute::ID);
//exception should be thrown
RUNNER_ASSERT(false);
-
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogDebug("OK. Exception thrown." << e.DumpToString());
}
}
/*
-Name: widgetDB_test_check_installation_status_installed
-Description: check if widget is installed by WidgetDB
-Expected: plugin should be notified that widget is installed
-*/
+ * Name: widgetDB_test_check_installation_status_installed
+ * Description: check if widget is installed by WidgetDB
+ * Expected: plugin should be notified that widget is installed
+ */
RUNNER_TEST(widgetDB_test_check_installation_status_installed)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
InstallationStatus tmp = widget->checkInstallationStatus(
- "w_id_2000", "w_name_2000_en", "2.0.0");
+ "w_id_2000", "w_name_2000_en", "2.0.0");
RUNNER_ASSERT(tmp == InstallationStatus::STATUS_INSTALLED);
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_check_installation_status_uninstalled
-Description: check if widget is not installed by WidgetDB
-Expected: plugin should be notified that widget is not installed
-*/
+ * Name: widgetDB_test_check_installation_status_uninstalled
+ * Description: check if widget is not installed by WidgetDB
+ * Expected: plugin should be notified that widget is not installed
+ */
RUNNER_TEST(widgetDB_test_check_installation_status_uninstalled)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
InstallationStatus tmp = widget->checkInstallationStatus(
- "w_id_2011", "w_name_2000_en", "2.0.0");
+ "w_id_2011", "w_name_2000_en", "2.0.0");
RUNNER_ASSERT(tmp == InstallationStatus::STATUS_UNINSTALLED);
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_check_installation_status_latest
-Description: check if widget installation information is taken from latest version
-Expected: plugin installation status should be same is both calls of WidgetDB
-*/
+ * Name: widgetDB_test_check_installation_status_latest
+ * Description: check if widget installation information is taken from latest
+ * version
+ * Expected: plugin installation status should be same is both calls of WidgetDB
+ */
RUNNER_TEST(widgetDB_test_check_installation_status_latest)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
InstallationStatus tmp1 = widget->checkInstallationStatus(
- "w_id_2000", "w_name_2000_en", "0.1.0");
+ "w_id_2000", "w_name_2000_en", "0.1.0");
InstallationStatus tmp2 = widget->checkInstallationStatus(
- "w_id_2000", "w_name_2000_en", "1.0.0");
+ "w_id_2000", "w_name_2000_en", "1.0.0");
RUNNER_ASSERT(tmp1 == InstallationStatus::STATUS_LATEST);
RUNNER_ASSERT(tmp2 == InstallationStatus::STATUS_LATEST);
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_widget_feature
-Description: check accessiblity of widget features and their values by WidgetDB
-Expected: feature names and values should match this, which was inserted into widget database
-*/
+ * Name: widgetDB_test_widget_feature
+ * Description: check accessiblity of widget features and their values by
+ * WidgetDB
+ * Expected: feature names and values should match this, which was inserted into
+ * widget database
+ */
RUNNER_TEST(widgetDB_test_widget_feature)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2000);
Features features = widget->getWidgetFeatures();
FOREACH(it, features)
{
- std::string name = (*it)->getName();
- if ("first_2000" == name)
- {
- RUNNER_ASSERT((*it)->getParams().size() == 4);
-
- RUNNER_ASSERT((*it)->isRequired());
- }
- else if ("second_2000" == name)
- {
- RUNNER_ASSERT((*it)->getParams().size() == 1);
- }
- else if ("third_2000" == name)
- {
- IWidgetFeature::Params params = (*it)->getParams();
-
- RUNNER_ASSERT(params.size() == 1);
- RUNNER_ASSERT_WHAT_EQUALS("third_2000", params.begin()->first);
- RUNNER_ASSERT_WHAT_EQUALS("thirdValue1", params.begin()->second);
- RUNNER_ASSERT(!(*it)->isRequired());
- }
- else if ("fourth_2000" == name)
- {
- RUNNER_ASSERT((*it)->getParams().size() == 0);
- }
- else if ("fifth_2000" == name)
- {
- RUNNER_ASSERT((*it)->getParams().size() == 0);
- }
- else
- RUNNER_ASSERT(false);
+ std::string name = (*it)->getName();
+ if ("first_2000" == name) {
+ RUNNER_ASSERT((*it)->getParams().size() == 4);
+
+ RUNNER_ASSERT((*it)->isRequired());
+ } else if ("second_2000" == name) {
+ RUNNER_ASSERT((*it)->getParams().size() == 1);
+ } else if ("third_2000" == name) {
+ IWidgetFeature::Params params = (*it)->getParams();
+
+ RUNNER_ASSERT(params.size() == 1);
+ RUNNER_ASSERT_WHAT_EQUALS("third_2000", params.begin()->first);
+ RUNNER_ASSERT_WHAT_EQUALS("thirdValue1", params.begin()->second);
+ RUNNER_ASSERT(!(*it)->isRequired());
+ } else if ("fourth_2000" == name) {
+ RUNNER_ASSERT((*it)->getParams().size() == 0);
+ } else if ("fifth_2000" == name) {
+ RUNNER_ASSERT((*it)->getParams().size() == 0);
+ } else {
+ RUNNER_ASSERT(false);
+ }
}
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogError("Exception thrown." << e.DumpToString());
RUNNER_ASSERT(false);
}
}
/*
-Name: widgetDB_test_widget_feature2
-Description: check if requesting features from WidgetDB throw excpetion if widget does not exists
-Expected: exception should be raise if widget does not exists
-*/
+ * Name: widgetDB_test_widget_feature2
+ * Description: check if requesting features from WidgetDB throw excpetion if
+ * widget does not exists
+ * Expected: exception should be raise if widget does not exists
+ */
RUNNER_TEST(widgetDB_test_widget_feature2)
{
- try
- {
+ try {
IWidgetDBPtr widget = getWidgetDB(2011); //no such widget
Features features = widget->getWidgetFeatures();
RUNNER_ASSERT(false);
- }
- catch(const WrtDeviceApis::Commons::SecurityException &e)
- {
+ } catch (const WrtDeviceApis::Commons::SecurityException &e) {
LogDebug("OK. Exception thrown." << e.DumpToString());
}
}
#Widgets
INS_ALL_WIDGETEXT="insert into WidgetExtendedInfo(app_id, share_href, signature_type)"
- INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, back_supported, access_network, defaultlocale, pkgname)"
+ INS_ALL_WIDGET="insert into WidgetInfo(app_id, widget_id, widget_version, widget_width, widget_height, author_name, author_email, author_href, base_folder, webkit_plugins_required, recognized, wac_signed, distributor_signed, min_version, back_supported, access_network, defaultlocale, tizen_appid)"
INS_ALL_WIDGET_LOC="insert into LocalizedWidgetInfo(app_id, widget_locale, widget_name, widget_shortname, widget_description, widget_license, widget_license_file, widget_license_href)"
INS_ALL_WIDGET_ICONS="insert into WidgetIcon(app_id, icon_src, icon_width, icon_height)"
INS_ALL_WIDGET_LOC_ICONS="insert into WidgetLocalizedIcon(app_id, icon_id, widget_locale)"
INS_ALL_WIDGET_STARTFILE="insert into WidgetStartFile(app_id, src)"
INS_ALL_WIDGET_LOC_STARTFILE="insert into WidgetLocalizedStartFile(app_id, start_file_id, widget_locale, type, encoding)"
INS_ALL_WIDGET_DEFPREF="insert into WidgetDefaultPreference(app_id, key_name, key_value, readonly)"
- INS_ALL_WIDGET_PREF="insert into WidgetPreference(pkgname, key_name, key_value, readonly)"
+ INS_ALL_WIDGET_PREF="insert into WidgetPreference(tizen_appid, key_name, key_value, readonly)"
INS_ALL_WIDGET_FEATURE="insert into WidgetFeature(widget_feature_id, app_id, name, required, rejected)"
INS_ALL_WIDGET_FEATURE_PARAM="insert into FeatureParam(widget_feature_id, name, value)"
INS_ALL_WIDGET_WINMODES="insert into WidgetWindowModes(app_id, window_mode)"
sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2000, 'w_id_2000', '1.0.0', 100, 200, 'a_name_2000', 'a_email_2000', 'a_href_2000', 'basef_2000', 1, 1, 1, 1, '1.0', 0, 0, 'en', 'tid2000')";
sqlite3 $WRT_DB "${INS_ALL_WIDGET} VALUES(2001, 'w_id_2001', '2.0.0', 100, 200, 'a_name_2001', 'a_email_2001', 'a_href_2001', 'basef_2001', 1, 1, 1, 1, '0.5', 0, 0, 'en', 'tid2001')";
- sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2002, 0, 'tid2002')";
- sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, pkgname) VALUES(2003, 0, 'NOTUSEDPKGNAME3')"; # for properties tests
+ sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2002, 0, 'tid2002')";
+ sqlite3 $WRT_DB "insert into WidgetInfo(app_id, back_supported, tizen_appid) VALUES(2003, 0, 'NOTUSEDPKGNAME3')"; # for properties tests
sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2000, 'share_href_2000', 0)";
sqlite3 $WRT_DB "${INS_ALL_WIDGETEXT} VALUES(2001, 'share_href_2001', 0)";
--- /dev/null
+indent_align_string=true\r
+indent_braces=false\r
+indent_braces_no_func=false\r
+indent_brace_parent=false\r
+indent_namespace=false\r
+indent_extern=false\r
+indent_class=true\r
+indent_class_colon=false\r
+indent_else_if=false\r
+indent_func_call_param=false\r
+indent_func_def_param=false\r
+indent_func_proto_param=false\r
+indent_func_class_param=false\r
+indent_func_ctor_var_param=false\r
+indent_template_param=false\r
+indent_func_param_double=false\r
+indent_relative_single_line_comments=false\r
+indent_col1_comment=true\r
+indent_access_spec_body=false\r
+indent_paren_nl=false\r
+indent_comma_paren=false\r
+indent_bool_paren=false\r
+indent_square_nl=false\r
+indent_preserve_sql=false\r
+indent_align_assign=false\r
+sp_balance_nested_parens=false\r
+align_keep_tabs=false\r
+align_with_tabs=false\r
+align_on_tabstop=false\r
+align_number_left=false\r
+align_func_params=false\r
+align_same_func_call_params=false\r
+align_var_def_colon=false\r
+align_var_def_attribute=false\r
+align_var_def_inline=false\r
+align_right_cmt_mix=false\r
+align_on_operator=false\r
+align_mix_var_proto=false\r
+align_single_line_func=false\r
+align_single_line_brace=false\r
+align_nl_cont=false\r
+align_left_shift=true\r
+nl_collapse_empty_body=true\r
+nl_assign_leave_one_liners=false\r
+nl_class_leave_one_liners=false\r
+nl_enum_leave_one_liners=false\r
+nl_getset_leave_one_liners=false\r
+nl_func_leave_one_liners=false\r
+nl_if_leave_one_liners=false\r
+nl_multi_line_cond=true\r
+nl_multi_line_define=false\r
+nl_before_case=false\r
+nl_after_case=false\r
+nl_after_return=false\r
+nl_after_semicolon=true\r
+nl_after_brace_open=false\r
+nl_after_brace_open_cmt=false\r
+nl_after_vbrace_open=false\r
+nl_after_brace_close=false\r
+nl_define_macro=false\r
+nl_squeeze_ifdef=false\r
+nl_ds_struct_enum_cmt=false\r
+nl_ds_struct_enum_close_brace=false\r
+nl_create_if_one_liner=false\r
+nl_create_for_one_liner=false\r
+nl_create_while_one_liner=false\r
+ls_for_split_full=true\r
+ls_func_split_full=true\r
+nl_after_multiline_comment=false\r
+eat_blanks_after_open_brace=true\r
+eat_blanks_before_close_brace=true\r
+mod_pawn_semicolon=false\r
+mod_full_paren_if_bool=false\r
+mod_remove_extra_semicolon=true\r
+mod_sort_import=false\r
+mod_sort_using=false\r
+mod_sort_include=false\r
+mod_move_case_break=false\r
+mod_remove_empty_return=false\r
+cmt_indent_multi=true\r
+cmt_c_group=false\r
+cmt_c_nl_start=false\r
+cmt_c_nl_end=false\r
+cmt_cpp_group=false\r
+cmt_cpp_nl_start=false\r
+cmt_cpp_nl_end=false\r
+cmt_cpp_to_c=false\r
+cmt_star_cont=true\r
+cmt_multi_check_last=true\r
+cmt_insert_before_preproc=false\r
+pp_indent_at_level=false\r
+pp_region_indent_code=false\r
+pp_if_indent_code=false\r
+pp_define_at_level=false\r
+indent_columns=4\r
+indent_member=4\r
+indent_access_spec=-2\r
+code_width=80\r
+nl_max=2\r
+nl_before_access_spec=2\r
+cmt_width=80\r
+indent_with_tabs=0\r
+sp_arith=force\r
+sp_assign=force\r
+sp_enum_assign=force\r
+sp_pp_concat=remove\r
+sp_pp_stringify=remove\r
+sp_bool=force\r
+sp_compare=force\r
+sp_paren_brace=force\r
+sp_angle_paren=remove\r
+sp_before_sparen=force\r
+sp_inside_sparen=remove\r
+sp_after_sparen=force\r
+sp_sparen_brace=force\r
+sp_before_semi=remove\r
+sp_after_semi_for_empty=remove\r
+sp_before_square=remove\r
+sp_before_squares=remove\r
+sp_inside_square=remove\r
+sp_after_comma=force\r
+sp_before_comma=remove\r
+sp_after_class_colon=force\r
+sp_before_class_colon=force\r
+sp_before_case_colon=remove\r
+sp_inside_braces=add\r
+sp_inside_fparens=remove\r
+sp_inside_fparen=remove\r
+sp_func_call_paren=remove\r
+sp_func_class_paren=remove\r
+sp_else_brace=force\r
+sp_brace_else=force\r
+sp_catch_brace=force\r
+sp_brace_catch=force\r
+sp_try_brace=force\r
+sp_before_dc=remove\r
+sp_after_dc=remove\r
+sp_not=remove\r
+sp_inv=remove\r
+sp_addr=remove\r
+sp_member=remove\r
+sp_deref=remove\r
+sp_sign=remove\r
+sp_incdec=remove\r
+sp_cond_colon=force\r
+sp_cond_question=force\r
+sp_case_label=force\r
+nl_assign_brace=remove\r
+nl_if_brace=remove\r
+nl_brace_else=remove\r
+nl_elseif_brace=remove\r
+nl_else_brace=remove\r
+nl_else_if=remove\r
+nl_try_brace=remove\r
+nl_for_brace=remove\r
+nl_catch_brace=remove\r
+nl_brace_catch=remove\r
+nl_while_brace=remove\r
+nl_do_brace=remove\r
+nl_brace_while=remove\r
+nl_switch_brace=remove\r
+nl_namespace_brace=remove\r
+nl_class_brace=force\r
+nl_fdef_brace=force\r
+pos_class_comma=trail\r
+pos_class_colon=trail\r
+mod_full_brace_do=add\r
+mod_full_brace_for=add\r
+mod_full_brace_if=add\r
+mod_full_brace_while=add\r
--- /dev/null
+uncrustify -c uncrustify.cfg --no-backup `find . -regex "\(.*\.cpp\|.*\.h\|.*\.c\|.*\.cc\)" | grep -v "orm.h\|orm_generator.h\|3rdparty\|examples"`