#include <EWebKit2.h>
-
IMPLEMENT_SINGLETON(WRT::CoreModule)
namespace { //Anonymous
-
const char * const bundlePath = "/usr/lib/wrt-wk2-bundles/libwrt-wk2-bundle.so";
std::string cutOffFileName(const std::string& path)
if_ok &= (isDir(GetUserInstalledWidgetPath()));
if (!if_ok) {
LogError("Path <" << GetUserInstalledWidgetPath() <<
- "> does not exist.");
+ "> does not exist.");
}
return if_ok;
}
-}// namespace anonymous
+} // namespace anonymous
namespace WRT {
-
class CoreModuleImpl
{
-public:
+ public:
CoreModuleImpl() : m_initialized(false), m_ewkContext(NULL)
{
}
Try
{
- if(!m_ewkContext)
- {
+ if (!m_ewkContext) {
// Needed settings for WKContext are located here
// create Ewk_Context
Ewk_Context* newEwkContext =
Ewk_Cookie_Manager *ewkCookieManager;
ewkCookieManager =
ewk_context_cookie_manager_get(m_ewkContext);
- ewk_cookie_manager_accept_policy_set(ewkCookieManager,
- EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+ ewk_cookie_manager_accept_policy_set(
+ ewkCookieManager,
+ EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
ADD_PROFILING_POINT("WebProcess fork", "stop");
ADD_PROFILING_POINT("attach databases", "start");
/* TODO:
* Do deinitialization: check on which step exception occured
* and deinitialize only initialized parts.
- */
+ */
return false;
}
m_initialized = true;
bool Init(Ewk_Context* ewk_context)
{
- if(ewk_context)
- {
+ if (ewk_context) {
m_ewkContext = ewk_context;
}
}
RunnableWidgetObjectPtr getRunnableWidgetObject(
- const std::string& tizenId)
+ const std::string& tizenId)
{
PluginModuleSupport::init(m_ewkContext, tizenId);
return WrtDB::GlobalDAOReadOnly::GetDeveloperMode();
}
-private:
+ private:
bool m_initialized;
Ewk_Context* m_ewkContext;
};
CoreModule::CoreModule() : m_impl(new CoreModuleImpl())
-{
-}
+{}
CoreModule::~CoreModule()
-{
-}
+{}
bool CoreModule::Init()
{
}
RunnableWidgetObjectPtr CoreModule::getRunnableWidgetObject(
- const std::string& tizenId)
+ const std::string& tizenId)
{
return m_impl->getRunnableWidgetObject(tizenId);
}
{
return m_impl->developerMode();
}
-
} /* namespace WRT */
#include <EWebKit2.h>
namespace WRT {
-
class CoreModuleImpl; // forward declaration
class CoreModule
* @return NULL on fail
*/
RunnableWidgetObjectPtr getRunnableWidgetObject(
- const std::string& tizenId);
+ const std::string& tizenId);
/**
* Gets from database global property of homeNetworkAccess
* @return homeNetworkAccess value
};
typedef DPL::Singleton<CoreModule> CoreModuleSingleton;
-
} /* namespace WRT */
#endif /* CORE_MODULE_H_ */
#include <dpl/exception.h>
namespace WRT {
-
typedef DPL::FastDelegate0<void> ProgressFinishCB;
typedef DPL::FastDelegate1<Evas_Object*, void> LoadStartCB;
typedef DPL::FastDelegate1<Evas_Object*, void> LoadFinishCB;
typedef DPL::FastDelegate0<void> WebCrashCB;
typedef DPL::FastDelegate2<Evas**, Evas_Object*, void> WindowCreateBeforeCB;
-typedef DPL::FastDelegate2<Evas_Object*, Evas_Object*, void> WindowCreateAfterCB;
+typedef DPL::FastDelegate2<Evas_Object*, Evas_Object*,
+ void> WindowCreateAfterCB;
typedef DPL::FastDelegate1<Evas_Object*, void> WindowCloseCB;
typedef DPL::FastDelegate0<void> WebkitExitCB;
typedef DPL::FastDelegate1<bool, void> ResumeCB;
* \-------------(HIDDEN)
*
*/
-class IRunnableWidgetObject {
-public:
+class IRunnableWidgetObject
+{
+ public:
// IRunnableWidgetObject base exception
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
*/
virtual void FireJavascriptEvent(int event, void* data) = 0;
-
- virtual ~IRunnableWidgetObject() {};
+ virtual ~IRunnableWidgetObject() {}
};
typedef std::shared_ptr<IRunnableWidgetObject> RunnableWidgetObjectPtr;
-
}
#endif /* RUNNABLE_WIDGET_OBJECT_INTERFACE_H_ */
const std::string INVALID_LOCALE = _("IDS_IM_POP_INVALID_WIDGET_LOCALE");
const std::string STILL_AUTHORIZING = _("IDS_IM_POP_AUTHORIZING_ING_ATNT");
const unsigned int UID_ROOT = 0;
-
} // namespace anonymous
namespace WRT {
-
-RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context) :
- m_widgetModel(model),
- m_view(ViewModule::createView()),
- m_ewkContext(context)
+RunnableWidgetObject::RunnableWidgetObject(WidgetModelPtr &model,
+ Ewk_Context* context) :
+ m_widgetModel(model),
+ m_view(ViewModule::createView()),
+ m_ewkContext(context)
{
//set initial state of runnable object
- m_guardstate = std::shared_ptr<State::RunnableWidgetObjectState>(new State::InitialState(*this));
+ m_guardstate = std::shared_ptr<State::RunnableWidgetObjectState>(
+ new State::InitialState(*this));
// If current uid is 'root', change privilege to apps
if (UID_ROOT == getuid()) {
// Set privilege by tizen id
wrt_ocsp_widget_verification_status_t response;
if (m_widgetModel->Type.Get().appType == WrtDB::APP_TYPE_WAC20) {
-
wrt_ocsp_initialize();
- wrt_ocsp_verify_widget(WrtDB::WidgetDAOReadOnly::getHandle(m_widgetModel->TizenId), &response);
+ wrt_ocsp_verify_widget(WrtDB::WidgetDAOReadOnly::getHandle(
+ m_widgetModel->TizenId), &response);
wrt_ocsp_shutdown();
-
} else {
response = WRT_OCSP_WIDGET_VERIFICATION_STATUS_GOOD;
}
}
bool RunnableWidgetObject::PrepareView(const std::string &startUrl,
- Evas_Object *window)
+ Evas_Object *window)
{
State::StateChange change = m_guardstate->allowPrepareView();
Assert(window);
ADD_PROFILING_POINT("view_logic_init", "start");
- if(!m_view->createWebView(m_ewkContext, window))
- {
+ if (!m_view->createWebView(m_ewkContext, window)) {
return false;
}
m_view->initialize();
return cww;
}
-void RunnableWidgetObject::SetUserDelegates(const UserDelegatesPtr& cbs) {
+void RunnableWidgetObject::SetUserDelegates(const UserDelegatesPtr& cbs)
+{
State::StateChange change = m_guardstate->allowSetUserDelegates();
m_view->setUserCallbacks(cbs);
change.commit();
change.commit();
}
-void RunnableWidgetObject::setNewState(std::shared_ptr<State::RunnableWidgetObjectState> sptr)
+void RunnableWidgetObject::setNewState(
+ std::shared_ptr<State::RunnableWidgetObjectState> sptr)
{
LogInfo("RunnableWidgetObject changes state to: " << sptr->toString());
m_guardstate = sptr;
LogDebug("");
PluginModuleSupport::shutdown(m_ewkContext);
}
-
} /* namespace WRT */
#include <EWebKit2.h>
namespace WRT {
-
class RunnableWidgetObject : public IRunnableWidgetObject
{
-public:
+ public:
RunnableWidgetObject(WidgetModelPtr &model, Ewk_Context* context);
virtual ~RunnableWidgetObject();
bool CheckBeforeLaunch();
bool PrepareView(const std::string &startUrl,
- Evas_Object *window);
+ Evas_Object *window);
void Show(); //asynchronous function
void Hide();
void Suspend();
void Backward();
void FireJavascriptEvent(int event, void* data);
-private:
+ private:
bool CheckWACTestCertififedWidget();
WidgetModelPtr m_widgetModel;
ViewModule::IViewModulePtr m_view;
Ewk_Context* m_ewkContext;
- void setNewState(std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
+ void setNewState(
+ std::shared_ptr<WRT::State::RunnableWidgetObjectState> sptr);
std::shared_ptr<State::RunnableWidgetObjectState> m_guardstate;
friend class State::StateChange;
};
-
} /* namespace WRT */
#endif /* RUNNABLE_WIDGET_OBJECT_H_ */
namespace WRT {
namespace State {
-
const StateChange StateChange::NoChange = StateChange();
StateChange::StateChange()
-{
-}
+{}
-StateChange::StateChange(RunnableWidgetObjectStatePtr sptr)
- : m_sptr(sptr)
-{
-}
+StateChange::StateChange(RunnableWidgetObjectStatePtr sptr) :
+ m_sptr(sptr)
+{}
void StateChange::commit()
{
- if(m_sptr)
- {
+ if (m_sptr) {
m_sptr->getObject().setNewState(m_sptr);
}
}
-RunnableWidgetObjectState::RunnableWidgetObjectState(RunnableWidgetObject & object)
- : m_object(object)
-{
-}
+RunnableWidgetObjectState::RunnableWidgetObjectState(
+ RunnableWidgetObject & object) :
+ m_object(object)
+{}
RunnableWidgetObjectState::~RunnableWidgetObjectState()
-{
-}
+{}
RunnableWidgetObject & RunnableWidgetObjectState::getObject() const
{
"FireJavascriptEvent cannot be called in current state ");
}
-InitialState::InitialState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+InitialState::InitialState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
std::string InitialState::toString() const
{
StateChange InitialState::allowGetCurrentWebview()
{
- ThrowMsg(IRunnableWidgetObject::MethodInvocationForbidden,
- "Cannot call GetCurrentWebview before RunnableWidgetObject initialization");
+ ThrowMsg(
+ IRunnableWidgetObject::MethodInvocationForbidden,
+ "Cannot call GetCurrentWebview before RunnableWidgetObject initialization");
}
-PreparedState::PreparedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+PreparedState::PreparedState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
StateChange PreparedState::allowCheckBeforeLaunch()
{
- return StateChange(RunnableWidgetObjectStatePtr(new SecurityCheckedState(m_object)));
+ return StateChange(RunnableWidgetObjectStatePtr(new SecurityCheckedState(
+ m_object)));
}
std::string PreparedState::toString() const
return "PREPARED";
}
-SecurityCheckedState::SecurityCheckedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+SecurityCheckedState::SecurityCheckedState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
std::string SecurityCheckedState::toString() const
{
return StateChange::NoChange;
}
-ShowedState::ShowedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+ShowedState::ShowedState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
std::string ShowedState::toString() const
{
return StateChange::NoChange;
}
-SuspendedState::SuspendedState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+SuspendedState::SuspendedState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
std::string SuspendedState::toString() const
{
return StateChange(RunnableWidgetObjectStatePtr(new ShowedState(m_object)));
}
-HiddenState::HiddenState(RunnableWidgetObject & object) : RunnableWidgetObjectState(object)
-{
-}
+HiddenState::HiddenState(RunnableWidgetObject & object) :
+ RunnableWidgetObjectState(object)
+{}
std::string HiddenState::toString() const
{
ThrowMsg(IRunnableWidgetObject::MethodInvocationForbidden,
"Hide cannot be called in current state" << toString());
}
-
}
}
namespace State {
class RunnableWidgetObjectState;
}
-
}
#include <dpl/exception.h>
namespace WRT {
namespace State {
-
typedef std::shared_ptr<RunnableWidgetObjectState> RunnableWidgetObjectStatePtr;
/**
*/
class StateChange
{
-public:
+ public:
static const StateChange NoChange;
StateChange();
* @brief commit actually performs change of state
*/
void commit();
-private:
+
+ private:
RunnableWidgetObjectStatePtr m_sptr;
};
*/
class RunnableWidgetObjectState
{
-public:
+ public:
explicit RunnableWidgetObjectState(RunnableWidgetObject & object);
virtual ~RunnableWidgetObjectState();
virtual std::string toString() const = 0;
virtual RunnableWidgetObject & getObject() const;
-protected:
+ protected:
RunnableWidgetObject & m_object;
};
*/
class InitialState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit InitialState(RunnableWidgetObject & object);
std::string toString() const;
*/
class PreparedState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit PreparedState(RunnableWidgetObject & object);
std::string toString() const;
*/
class SecurityCheckedState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit SecurityCheckedState(RunnableWidgetObject & object);
std::string toString() const;
*/
class ShowedState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit ShowedState(RunnableWidgetObject & object);
std::string toString() const;
*/
class SuspendedState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit SuspendedState(RunnableWidgetObject & object);
std::string toString() const;
*/
class HiddenState : public RunnableWidgetObjectState
{
-public:
+ public:
explicit HiddenState(RunnableWidgetObject & object);
std::string toString() const;
StateChange allowHide();
};
-
}
}
WrtLaunchData() :
wrtClientContext(NULL),
sdkDebugData(NULL)
- {
- }
+ {}
};
struct SDKDebugData
pid(NULL),
portnum(-1),
debugMode(false)
- {
- }
+ {}
SDKDebugData(unsigned long *pidNum,
int portNum,
pid(pidNum),
portnum(portNum),
debugMode(currentDebugMode)
- {
- }
+ {}
};
#endif // WRT_LAUNCH_USER_DATA_H_
#include <appcore-efl.h>
-namespace LocalizationSetting{
-
+namespace LocalizationSetting {
void SetLanguageChangedCallback(LanguageChangedCallback cb, void *data)
{
LogDebug("Set language changed callback");
#define LOCALIZATION_SETTING_H_
namespace LocalizationSetting {
-
typedef int (*LanguageChangedCallback)(void *data);
void SetLanguageChangedCallback(LanguageChangedCallback cb, void *data);
-
} //LocalizationSetting
#endif // ifndef LOCALIZATION_SETTING_H_
using namespace WrtDB;
-MainThread::MainThread() : m_attached(false) {
-}
+MainThread::MainThread() : m_attached(false) {}
MainThread::~MainThread()
{
#include <dpl/singleton.h>
-class MainThread {
+class MainThread
+{
public:
void AttachDatabases();
void DetachDatabases();
/**
* @file widget_data_types.cpp
* @author Krzysztof Jackiewicz (k.jackiewicz@samsung.com)
- * @author Tomasz Iwanek (t.iwanek@samsung.com) (implementation moved to cpp)
+ * @author Tomasz Iwanek (t.iwanek@samsung.com) (implementation moved to
+ * cpp)
* @version 0.1
* @brief
*/
#include <dpl/foreach.h>
WidgetAccessList::WidgetAccessList() : m_isAccessAll(false)
-{
-}
+{}
-WidgetAccessList::WidgetAccessList(const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
+WidgetAccessList::WidgetAccessList(
+ const WrtDB::WidgetAccessInfoList &widgetAccessInfoList) :
m_isAccessAll(false)
{
FOREACH(it, widgetAccessInfoList)
m_ContextMenu(ContextMenu_Enable),
m_Encryption(Encryption_Disable),
m_BackgroundSupport(BackgroundSupport_Disable)
-{
-}
+{}
WidgetSettingList::WidgetSettingList(WidgetSettings &widgetSettings)
{
m_IndicatorPresence = Indicator_Disable;
} else {
LogError("Invalid indicator presence value!! [" <<
- value << "]");
+ value << "]");
m_IndicatorPresence = Indicator_Enable;
}
} else if (name == SETTING_NAME_BACKBUTTON_PRESENCE) {
if (value == SETTING_VALUE_BACKBUTTON_PRESENCE_ENALBE) {
m_BackButtonPresence = BackButton_Enable;
} else if (value ==
- SETTING_VALUE_BACKBUTTON_PRESENCE_DISABLE) {
+ SETTING_VALUE_BACKBUTTON_PRESENCE_DISABLE)
+ {
m_BackButtonPresence = BackButton_Disable;
} else {
LogError("Invalid backbutton presence value!! [" <<
- value << "]");
+ value << "]");
m_BackButtonPresence = BackButton_Disable;
}
- } else if ( name == SETTING_NAME_CONTEXT_MENU
+ } else if (name == SETTING_NAME_CONTEXT_MENU
#ifndef DEPRECATED_SETTING_STRING
- || name == SETTING_NAME_CONTEXTMENU
+ || name == SETTING_NAME_CONTEXTMENU
#endif
- ) {
+ )
+ {
if (value == SETTING_VALUE_ENABLE) {
m_ContextMenu = ContextMenu_Enable;
} else if (value == SETTING_VALUE_DISABLE) {
m_ContextMenu = ContextMenu_Disable;
} else {
LogError("Invalid contextmenu value!! [" <<
- value << "]");
+ value << "]");
m_ContextMenu = ContextMenu_Enable;
}
} else if (name == SETTING_NAME_ENCRYPTION) {
if (value == SETTING_VALUE_ENCRYPTION_ENABLE) {
m_Encryption = Encryption_Enable;
} else if (value ==
- SETTING_VALUE_ENCRYPTION_DISABLE) {
+ SETTING_VALUE_ENCRYPTION_DISABLE)
+ {
m_Encryption = Encryption_Disable;
} else {
LogError("Invalid encryption value!! [" <<
- value << "]");
+ value << "]");
m_Encryption = Encryption_Disable;
}
} else if (name == SETTING_NAME_BACKGROUND_SUPPORT) {
m_BackgroundSupport = BackgroundSupport_Disable;
} else {
LogError("Invalid background-support value!! [" <<
- value << "]");
+ value << "]");
m_BackgroundSupport = BackgroundSupport_Disable;
}
} else if (name == SETTING_NAME_USER_AGENT) {
return m_IndicatorPresence;
}
-WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence() const
+WidgetSettingBackButtonPresence WidgetSettingList::getBackButtonPresence()
+const
{
return m_BackButtonPresence;
}
bool WidgetSettingList::operator ==(const WidgetSettingList& other) const
{
return m_RotationLock == other.m_RotationLock &&
- m_IndicatorPresence == other.m_IndicatorPresence &&
- m_BackButtonPresence == other.m_BackButtonPresence &&
- m_ContextMenu == other.m_ContextMenu &&
- m_Encryption == other.m_Encryption &&
- m_BackgroundSupport == other.m_BackgroundSupport &&
- m_UserAgent == other.m_UserAgent;
+ m_IndicatorPresence == other.m_IndicatorPresence &&
+ m_BackButtonPresence == other.m_BackButtonPresence &&
+ m_ContextMenu == other.m_ContextMenu &&
+ m_Encryption == other.m_Encryption &&
+ m_BackgroundSupport == other.m_BackgroundSupport &&
+ m_UserAgent == other.m_UserAgent;
}
L"enable";
static const DPL::String SETTING_VALUE_DISABLE =
L"disable";
-static const DPL::String SETTING_NAME_ENCRYPTION=
+static const DPL::String SETTING_NAME_ENCRYPTION =
L"encryption";
static const DPL::String SETTING_VALUE_SCREEN_ORIENTATION_PORTRAIT =
L"portrait";
// to apply widget default locales instead of calling localizeWidgetModel()
#include <dpl/localization/LanguageTagsProvider.h>
-
namespace Domain {
-
std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId)
{
std::shared_ptr<WidgetModel> model;
WrtDB::WidgetDAOReadOnly dao(dplTizenId);
DPL::Optional<DPL::String> defloc = model->defaultlocale.Get();
- if(!defloc.IsNull())
- {
- LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ if (!defloc.IsNull()) {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+ *defloc);
}
WrtDB::WidgetAccessInfoList widgetAccessInfoList;
}
return model;
}
-
} //Namespace Domain
#include <dpl/wrt-dao-ro/wrt_db_types.h>
namespace Domain {
-
/**
* @brief Creates widget model associated with selected
* @param[in] tizenId
* @retval WidgetModel
*/
std::shared_ptr<WidgetModel> deserializeWidgetModel(const std::string& tizenId);
-
} //Namespace Domain
#endif // ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_DESERIALIZE_MODEL_H_
using namespace WrtDB;
-template <typename RetType, RetType (WidgetDAOReadOnly::*extFun)() const >
+template <typename RetType, RetType(WidgetDAOReadOnly::*extFun) () const >
struct BindToWidgetDAO :
DPL::Event::BindToDAO<WidgetModel,
RetType,
WidgetDAOReadOnly,
&WidgetModel::getTizenId,
extFun>
-{
-};
+{};
template <typename RetType, RetType(*extFun) (DPL::String)>
struct BindToWidgetDAOStatic :
DPL::String,
&WidgetModel::getTizenId,
extFun>
-{
-};
+{};
WidgetModel::WidgetModel(const std::string &tizenId) :
TizenId(DPL::FromASCIIString(tizenId)),
TzPkgId(this, &BindToWidgetDAO<WrtDB::TizenPkgId,
&WidgetDAOReadOnly::getTizenPkgId>::Get),
Type(this, &BindToWidgetDAO<WidgetType,
- &WidgetDAOReadOnly::getWidgetType>::Get),
+ &WidgetDAOReadOnly::getWidgetType>::Get),
ActualSize(this),
PreferredSize(this,
&BindToWidgetDAO<WidgetSize,
&BindToWidgetDAO<WindowModeList,
&WidgetDAOReadOnly::getWindowModes>::Get),
//localized, so not binded
-// AccessNetwork(this, false),
-// WarpDefinitionEmpty(this),
+ // AccessNetwork(this, false),
+ // WarpDefinitionEmpty(this),
BackSupported(
this,
//TODO this type has to be here now, as Property constructor is wrongly
//chosen
(DPL::Event::Property<bool,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>::
+ ReadDelegateType) &
BindToWidgetDAO<bool, &WidgetDAOReadOnly::getBackSupported>::Get),
AccessList(this),
IsTestWidget(
//TODO this type has to be here now, as Property constructor is wrongly
//chosen
(DPL::Event::Property<bool,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached>::ReadDelegateType) &
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>::
+ ReadDelegateType) &
BindToWidgetDAO<bool, &WidgetDAOReadOnly::isTestWidget>::Get),
SettingList(this),
AppServiceList(this)
-{
-}
+{}
DPL::String WidgetModel::getTizenId() const
{
*/
DPL::String TizenId;
DPL::Event::Property<WrtDB::TizenPkgId,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> TzPkgId;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> TzPkgId;
/**
* @brief Widget type
* Note: This is a readonly property
*/
DPL::Event::Property<WrtDB::WidgetType,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> Type;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> Type;
/**
* @brief Current widget actual size
* @brief Current widget preferred size
*/
DPL::Event::Property<WidgetSize,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> PreferredSize;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>
+ PreferredSize;
/**
* @brief Start URL for widget
* Gets path in which files of widget are being kept
*/
DPL::Event::Property<DPL::String,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> InstallPath;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> InstallPath;
/**
* @brief Path to widget's persistent storage.
*
* Gets path in which widget may store its persistent private data.
*/
- DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> PersistentStoragePath;
+ DPL::Event::Property<DPL::String,
+ DPL::Event::PropertyReadOnly> PersistentStoragePath;
/**
* @brief Path to widget's temporary storage.
*
* Gets path in which widget may store its temporary private data.
*/
- DPL::Event::Property<DPL::String, DPL::Event::PropertyReadOnly> TemporaryStoragePath;
+ DPL::Event::Property<DPL::String,
+ DPL::Event::PropertyReadOnly> TemporaryStoragePath;
/**
* @brief Widget defaultlocale
*/
DPL::Event::Property<DPL::OptionalString,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> defaultlocale;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>
+ defaultlocale;
/**
* @brief Widget name
* @brief Widget splash image src
*/
DPL::Event::Property<DPL::OptionalString,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> SplashImg;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> SplashImg;
/**
* @brief window mode
*/
DPL::Event::Property<WrtDB::WindowModeList,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamic> WindowModes;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamic> WindowModes;
// /**
// * @brief Value of network element.
* @brief Is back supported
*/
DPL::Event::Property<bool,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> BackSupported;
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached>
+ BackSupported;
/**
* @brief Widget access list
* @brief Is this DeveloperWidget
*/
DPL::Event::Property<bool,
- DPL::Event::PropertyReadOnly,
- DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
-
+ DPL::Event::PropertyReadOnly,
+ DPL::Event::PropertyStorageDynamicCached> IsTestWidget;
DPL::Event::Property<WidgetSettingList> SettingList;
#include <js_overlay_types.h>
namespace PluginModule {
-
void init(int widgetHandle)
{
LogDebug("initializing plugins module");
LogDebug("unload frame from web page (context:" << context << ")");
PluginLogicSingleton::Instance().unloadFrame(context);
}
-
} // PluginModule
#include <js_overlay_types.h>
extern "C" {
- typedef struct OpaqueJSContext* JSGlobalContextRef;
+typedef struct OpaqueJSContext* JSGlobalContextRef;
}
namespace PluginModule {
-
//forward declaration
void init(int widgetHandle);
void start(int widgetHandle,
name(0),
prefix(0),
description(0)
- {
- }
+ {}
PacketResult(unsigned long long t,
- const char* n,
- const char* p,
- const char* d) :
+ const char* n,
+ const char* p,
+ const char* d) :
time(t),
name(n),
prefix(p),
description(d)
- {
- }
+ {}
void Print(FILE *filePtr)
{
- if (!prefix) { prefix = ""; }
- if (!description) { description = ""; }
+ if (!prefix) {
+ prefix = "";
+ }
+ if (!description) {
+ description = "";
+ }
fprintf(filePtr, "%s#%s#%llu#[%s]\n", prefix, name, time, description);
}
};
localtime_r(&tv.tv_sec, &localNowTime);
char format[64];
- snprintf(format, sizeof(format), "%02i:%02i:%02i.%03i", localNowTime.tm_hour, localNowTime.tm_min, localNowTime.tm_sec, static_cast<int>(tv.tv_usec / 1000));
+ snprintf(format,
+ sizeof(format),
+ "%02i:%02i:%02i.%03i",
+ localNowTime.tm_hour,
+ localNowTime.tm_min,
+ localNowTime.tm_sec,
+ static_cast<int>(tv.tv_usec / 1000));
return format;
}
-
} // namespace anonymous
void AddStdoutProfilingMeasurment(const char* name, bool start)
{
std::ostringstream output;
- output << "[" << GetFormattedTime() << "] [](): " << name << " ";
+ output << "[" << GetFormattedTime() << "] [](): " << name << " ";
output << (start ? "profiling##start" : "profiling##stop");
fprintf(stdout, "%s\n", output.str().c_str());
}
extern "C"
void AddProfilingMeasurment(const char* name,
- const char* prefix,
- const char* description)
+ const char* prefix,
+ const char* description)
{
DPL::Mutex::ScopedLock lock(m_mutex);
struct timeval value;
#ifdef __cplusplus
extern "C"
void AddProfilingMeasurment(const char* name,
- const char* prefix = 0,
- const char* description = 0);
+ const char* prefix = 0,
+ const char* description = 0);
#define ADD_PROFILING_POINT(name, ...) AddProfilingMeasurment(name, \
- ## __VA_ARGS__)
+ ##__VA_ARGS__)
#else //__cplusplus
void AddProfilingMeasurment(const char* name,
- const char* prefix,
- const char* description);
+ const char* prefix,
+ const char* description);
#define ADD_PROFILING_POINT(name, prefix, desc) AddProfilingMeasurment(name, \
prefix, \
desc)
ApplicationData::ApplicationData() :
m_originBundle(NULL),
m_encodedBundle(NULL)
-{
-}
+{}
ApplicationData::~ApplicationData()
-{
-}
+{}
bundle* ApplicationData::getBundle() const
{
bool ApplicationData::setBundle(bundle *originBundle)
{
- if (!originBundle)
- {
+ if (!originBundle) {
LogError("Bundle is empty!");
return false;
}
bool ApplicationData::setEncodedBundle(bundle* originBundle)
{
int len, ret;
- if (!originBundle)
- {
+ if (!originBundle) {
LogError("Bundle is empty!");
return false;
}
freeEncodedBundle();
ret = bundle_encode(originBundle, &m_encodedBundle, &len);
- if(ret == -1)
- {
+ if (ret == -1) {
LogError("Failed to encode bundle data");
return false;
}
void ApplicationData::freeBundle()
{
- if (!m_originBundle)
- {
+ if (!m_originBundle) {
return;
}
- if(!bundle_free(m_originBundle))
- {
+ if (!bundle_free(m_originBundle)) {
LogDebug("Bundle data freed for new bundle data");
m_originBundle = NULL;
}
void ApplicationData::freeEncodedBundle()
{
- if (!m_encodedBundle)
- {
+ if (!m_encodedBundle) {
return;
}
- if(m_encodedBundle)
- {
- if(!bundle_free_encoded_rawdata(
- &m_encodedBundle))
+ if (m_encodedBundle) {
+ if (!bundle_free_encoded_rawdata(
+ &m_encodedBundle))
{
LogDebug("Bundle data freed for new bundle data");
m_encodedBundle = NULL;
class ApplicationData
{
- public:
- bundle* getBundle() const;
- const char* getEncodedBundle() const;
- bool setBundle(bundle *originBundle);
- bool setEncodedBundle(bundle* originBundle);
- void freeBundle();
- void freeEncodedBundle();
-
- private:
- ApplicationData();
- ~ApplicationData();
-
- bundle* m_originBundle;
- bundle_raw* m_encodedBundle;
-
- friend class DPL::Singleton<ApplicationData>;
+ public:
+ bundle* getBundle() const;
+ const char* getEncodedBundle() const;
+ bool setBundle(bundle *originBundle);
+ bool setEncodedBundle(bundle* originBundle);
+ void freeBundle();
+ void freeEncodedBundle();
+
+ private:
+ ApplicationData();
+ ~ApplicationData();
+
+ bundle* m_originBundle;
+ bundle_raw* m_encodedBundle;
+
+ friend class DPL::Singleton<ApplicationData>;
};
typedef DPL::Singleton<ApplicationData> ApplicationDataSingleton;
}
ApplicationLauncher::ApplicationLauncher()
-{
-}
+{}
ApplicationLauncher::~ApplicationLauncher()
-{
-}
+{}
void ApplicationLauncher::OnEventReceived(
- const ApplicationLauncherEvents::LaunchApplicationByAppService &event)
+ const ApplicationLauncherEvents::LaunchApplicationByAppService &event)
{
int result;
bundle *args = event.GetArg0();
void *userData = event.GetArg2();
result = appsvc_run_service(args, 0, responseCallback, userData);
- if (result < 0)
+ if (result < 0) {
LogError("Failed to run AppService : " << result);
+ }
}
void ApplicationLauncher::OnEventReceived(
- const ApplicationLauncherEvents::LaunchApplicationByPkgname &event)
+ const ApplicationLauncherEvents::LaunchApplicationByPkgname &event)
{
using namespace ApplicationLauncherPkgname;
LogDebug("LaunchApplicationByPkgname");
url = youtube->getYouTubeHD(uri.c_str());
delete youtube;
} else if (SCHEME_TYPE_RTSP == scheme ||
- (SCHEME_TYPE_HTML5_VIDEO == scheme))
+ (SCHEME_TYPE_HTML5_VIDEO == scheme))
{
url = uri.c_str();
} else {
namespace ApplicationLauncherEvents {
DECLARE_GENERIC_EVENT_3(LaunchApplicationByAppService,
- bundle*,
+ bundle *,
appsvc_res_fn,
void*)
DECLARE_GENERIC_EVENT_4(LaunchApplicationByPkgname,
} //namespace ApplicationLauncherEvents
namespace ApplicationLauncherPkgname {
- const std::string PKG_NAME_PREFIX = "com.samsung.";
- const std::string PKG_NAME_DOWNLOAD_PROVIDER = PKG_NAME_PREFIX + "download-provider";
- const std::string PKG_NAME_VIDEO_PLAYER = PKG_NAME_PREFIX + "video-player";
- const std::string PKG_NAME_VT_MAIN = PKG_NAME_PREFIX + "vtmain";
+const std::string PKG_NAME_PREFIX = "com.samsung.";
+const std::string PKG_NAME_DOWNLOAD_PROVIDER = PKG_NAME_PREFIX +
+ "download-provider";
+const std::string PKG_NAME_VIDEO_PLAYER = PKG_NAME_PREFIX + "video-player";
+const std::string PKG_NAME_VT_MAIN = PKG_NAME_PREFIX + "vtmain";
} // namespace ApplicationLauncherPkgname
class ApplicationLauncher :
- public DPL::Event::Controller<DPL::TypeListDecl<
- ApplicationLauncherEvents::LaunchApplicationByPkgname,
- ApplicationLauncherEvents::LaunchApplicationByAppService
- >::Type>
+ public DPL::Event::Controller<DPL::TypeListDecl<
+ ApplicationLauncherEvents::
+ LaunchApplicationByPkgname,
+ ApplicationLauncherEvents::
+ LaunchApplicationByAppService
+ >::Type>
{
public:
ApplicationLauncher();
protected:
virtual void OnEventReceived(
- const ApplicationLauncherEvents::
+ const ApplicationLauncherEvents::
LaunchApplicationByPkgname &event);
virtual void OnEventReceived(
- const ApplicationLauncherEvents::
+ const ApplicationLauncherEvents::
LaunchApplicationByAppService &event);
private:
* @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"
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)
{
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);
#include <dpl/log/log.h>
namespace ViewModule {
-
namespace {
-
const char * const type2name[Scheme::COUNT] = {
- "file",
- "sms",
- "mmsto",
- "mailto",
- "data",
- "tel",
- "http",
- "https",
- "widget",
- "vnd.youtube",
- "rtsp" };
+ "file",
+ "sms",
+ "mmsto",
+ "mailto",
+ "data",
+ "tel",
+ "http",
+ "https",
+ "widget",
+ "vnd.youtube",
+ "rtsp"
+};
typedef std::map<std::string, Scheme::Type> SchemeMap;
{
LogInfo("Populating scheme map...");
SchemeMap map;
- for(size_t st = Scheme::FILE; st<Scheme::COUNT;++st) {
+ for (size_t st = Scheme::FILE; st < Scheme::COUNT; ++st) {
LogInfo(" * " << type2name[st] << "->" << st);
map[type2name[st]] = static_cast<Scheme::Type>(st);
}
}
const SchemeMap name2type = PopulateMap();
-
} // namespace
-Scheme::Scheme(const std::string& name) : m_name(name), m_type(INVALID) {
+Scheme::Scheme(const std::string& name) : m_name(name), m_type(INVALID)
+{
m_type = GetType(name);
}
Scheme::Type Scheme::GetType(const std::string& name)
{
auto it = name2type.find(name);
- if(it == name2type.end()) {
+ if (it == name2type.end()) {
LogError("Invalid scheme: " << name);
return INVALID;
}
return it->second;
}
-
} /* namespace ViewModule */
#include <string>
namespace ViewModule {
-
-class Scheme {
-public:
+class Scheme
+{
+ public:
enum Type {
INVALID = -1,
FILE = 0,
explicit Scheme(const std::string& name);
virtual ~Scheme() {}
- std::string GetName() const { return m_name; }
- Type GetType() const { return m_type; }
+ std::string GetName() const
+ {
+ return m_name;
+ }
+ Type GetType() const
+ {
+ return m_type;
+ }
static std::string GetName (Type type);
static std::string GetName (size_t type)
}
static Type GetType(const std::string& name);
-private:
+ private:
std::string m_name;
Type m_type;
};
-
} /* namespace ViewModule */
#endif /* SCHEME_H_ */
#include "scheme_action_map_data.h"
namespace ViewModule {
-
namespace {
-
/*
* Lazy construction pattern.
* TODO Make it more general. Use variadic template/tuples/lambdas or sth. Move
template <typename T, typename Arg1>
class Lazy
{
-public:
+ public:
explicit Lazy(const Arg1& arg1) :
m_arg1(arg1),
m_object(new std::unique_ptr<T>())
- {
- }
+ {}
Lazy(const Lazy<T, Arg1>& other) :
m_arg1(other.m_arg1),
m_object(other.m_object)
+ {}
+
+ T& operator*()
{
+ return GetObject();
+ }
+ const T& operator*() const
+ {
+ return GetObject();
+ }
+ const T* operator->() const
+ {
+ return &GetObject();
+ }
+ T* operator->()
+ {
+ return &GetObject();
}
-
- T& operator*() { return GetObject(); }
- const T& operator*() const { return GetObject(); }
- const T* operator->() const { return &GetObject(); }
- T* operator->() { return &GetObject(); }
Lazy<T, Arg1>& operator=(const Lazy<T, Arg1>& other)
{
m_object = other.m_object;
return *this;
}
-private:
+
+ private:
T& GetObject() const
{
if (!(*m_object)) {
* sms:5551212?body=expected%20text => APPSVC_DATA_TEXT + expected%20text
*/
struct AppSvcConversion {
- AppSvcConversion(char const * const keyValue, const std::string& regexStr):
+ AppSvcConversion(char const * const keyValue,
+ const std::string& regexStr) :
key(keyValue),
- regex(regexStr) {
- }
+ regex(regexStr) {}
char const * const key;
- Lazy<pcrecpp::RE,std::string> regex;
+ Lazy<pcrecpp::RE, std::string> regex;
};
/*
// Regular expressions used to extract appsvc data from scheme
// TODO what about multiple recipients?
-char const * const REGEX_BODY = ".*[?&]body=([^&]+).*";
-char const * const REGEX_SMS = "sms:([^&]+).*";
-char const * const REGEX_MMSTO = "mmsto:([^&]+).*";
-char const * const REGEX_MAILTO = "mailto:([^&]+).*";
-char const * const REGEX_TO = ".*[?&]to=([^&]+).*";
-char const * const REGEX_CC = ".*[?&]cc=([^&]+).*";
-char const * const REGEX_BCC = ".*[?&]bcc=([^&]+).*";
-char const * const REGEX_SUBJECT = ".*[?&]subject=([^&]+).*";
+char const * const REGEX_BODY = ".*[?&]body=([^&]+).*";
+char const * const REGEX_SMS = "sms:([^&]+).*";
+char const * const REGEX_MMSTO = "mmsto:([^&]+).*";
+char const * const REGEX_MAILTO = "mailto:([^&]+).*";
+char const * const REGEX_TO = ".*[?&]to=([^&]+).*";
+char const * const REGEX_CC = ".*[?&]cc=([^&]+).*";
+char const * const REGEX_BCC = ".*[?&]bcc=([^&]+).*";
+char const * const REGEX_SUBJECT = ".*[?&]subject=([^&]+).*";
char const * const REGEX_DATA_CONTEXT = ".*;phone-context=([^:]+).*";
AppSvcOperationMap initializeAppSvcOperations()
sendOp.conversions.push_back(AppSvcConversion(APPSVC_DATA_TO, REGEX_MAILTO));
sendOp.conversions.push_back(AppSvcConversion(APPSVC_DATA_CC, REGEX_CC));
sendOp.conversions.push_back(
- AppSvcConversion(APPSVC_DATA_BCC, REGEX_BCC));
+ AppSvcConversion(APPSVC_DATA_BCC, REGEX_BCC));
sendOp.conversions.push_back(
- AppSvcConversion(APPSVC_DATA_SUBJECT, REGEX_SUBJECT));
+ AppSvcConversion(APPSVC_DATA_SUBJECT, REGEX_SUBJECT));
sendOp.conversions.push_back(
- AppSvcConversion(APPSVC_DATA_TEXT, REGEX_BODY));
+ AppSvcConversion(APPSVC_DATA_TEXT, REGEX_BODY));
ret.insert(std::make_pair(Scheme::MMSTO, sendOp));
ret.insert(std::make_pair(Scheme::MAILTO, sendOp));
}
AppSvcOperationMap g_appSvcOperationMap = initializeAppSvcOperations();
-
} // namespace
-
namespace SchemeActionMap {
-
bool HandleUri(const char* uri,
NavigationContext context,
WrtDB::AppType appType)
// TODO do we need a callback?
CONTROLLER_POST_EVENT(
- ApplicationLauncher,
- ApplicationLauncherEvents::LaunchApplicationByAppService(
- bundleData,
- NULL,
- NULL));
+ ApplicationLauncher,
+ ApplicationLauncherEvents::LaunchApplicationByAppService(
+ bundleData,
+ NULL,
+ NULL));
break;
}
case URI_ACTION_VIDEO:
CONTROLLER_POST_EVENT(
- ApplicationLauncher,
- ApplicationLauncherEvents::LaunchApplicationByPkgname(
- ApplicationLauncherPkgname::PKG_NAME_VIDEO_PLAYER,
- name,
- uri,
- "null"));
+ ApplicationLauncher,
+ ApplicationLauncherEvents::LaunchApplicationByPkgname(
+ ApplicationLauncherPkgname::PKG_NAME_VIDEO_PLAYER,
+ name,
+ uri,
+ "null"));
break;
default:
break;
}
return (action == URI_ACTION_WRT);
}
-
} // namespace SchemeActionMap
-
} /* namespace ViewModule */
#include <dpl/wrt-dao-ro/common_dao_types.h>
namespace ViewModule {
-
namespace SchemeActionMap {
- bool HandleUri(const char* uri, NavigationContext context, WrtDB::AppType appType);
+bool HandleUri(const char* uri,
+ NavigationContext context,
+ WrtDB::AppType appType);
};
-
} /* namespace ViewModule */
#endif /* SCHEME_ACTION_MAP_H_ */
#include <scheme.h>
namespace ViewModule {
-
namespace {
-
enum UriAction {
URI_ACTION_WRT, // load in WRT
URI_ACTION_APPSVC, // launch in APPSVC
// TIZEN
const UriAction g_tizenActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = {
-
-// TOP_LEVEL FRAME_LEVEL NEW_WINDOW
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // FILE
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // SMS
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // MMSTO
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // MAILTO
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // DATA
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // TEL
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // HTTP
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // HTTPS
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // WIDGET
- {URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO}, // YOUTUBE
- {URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO} // RTSP
+ // TOP_LEVEL FRAME_LEVEL NEW_WINDOW
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // FILE
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMS
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MMSTO
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MAILTO
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // DATA
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // TEL
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // HTTP
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // HTTPS
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // WIDGET
+ { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO }, // YOUTUBE
+ { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO } // RTSP
};
// WAC
const UriAction g_wacActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = {
-
-// TOP_LEVEL FRAME_LEVEL NEW_WINDOW
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC}, // FILE
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // SMS
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // MMSTO
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // MAILTO
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT}, // DATA
- {URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC}, // TEL
- {URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC}, // HTTP
- {URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC}, // HTTPS
- {URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC}, // WIDGET
- {URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO}, // YOUTUBE
- {URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO} // RTSP
+ // TOP_LEVEL FRAME_LEVEL NEW_WINDOW
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC }, // FILE
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMS
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MMSTO
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MAILTO
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // DATA
+ { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // TEL
+ { URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC }, // HTTP
+ { URI_ACTION_APPSVC, URI_ACTION_WRT, URI_ACTION_APPSVC }, // HTTPS
+ { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC }, // WIDGET
+ { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO }, // YOUTUBE
+ { URI_ACTION_VIDEO, URI_ACTION_VIDEO, URI_ACTION_VIDEO } // RTSP
};
-
}
-
}
namespace ViewModule {
namespace SchemeActionMap {
- enum NavigationContext {
- TOP_LEVEL = 0,
- FRAME_LEVEL,
- NEW_WINDOW,
+enum NavigationContext {
+ TOP_LEVEL = 0,
+ FRAME_LEVEL,
+ NEW_WINDOW,
- COUNT
- };
+ COUNT
+};
} // namespace SchemeActionMap
} // namespace ViewModule
#endif /* SCHEME_ACTION_MAP_TYPE_H_ */
#include <application_launcher.h>
namespace ViewModule {
-
namespace {
const char* const SCHEME_TYPE_HTML5_VIDEO = "html5video";
const char* const HTTP_STREAMING_MPEG_MIMETYPE = "application/x-mpegurl";
AppsSupportImplementation() :
m_widgetModel(NULL),
m_initialized(false)
- {
- }
+ {}
~AppsSupportImplementation()
{
ApplicationLauncherSingleton::Instance().Touch();
ApplicationLauncherSingleton::Instance().setWidgetTizenId(
- DPL::ToUTF8String(m_widgetModel->TizenId));
+ DPL::ToUTF8String(m_widgetModel->TizenId));
LogDebug("Initialized");
m_initialized = true;
// ignore case match of string of mime type
int isAppServiceable = httpMultimediaRequest(
- mimeType ? std::string(mimeType) : "null",
- url ? std::string(url) : "null");
+ mimeType ? std::string(mimeType) : "null",
+ url ? std::string(url) : "null");
if (isAppServiceable) {
LogInfo("Application Service start");
}
};
-AppsSupport::AppsSupport(): m_impl(new AppsSupportImplementation)
-{
-}
+AppsSupport::AppsSupport() : m_impl(new AppsSupportImplementation)
+{}
AppsSupport::~AppsSupport()
-{
-}
+{}
void AppsSupport::initialize(WidgetModel *widgetModel)
{
{
m_impl->downloadRequest(url, mimeType, userParam);
}
-
-}//namespace
+} //namespace
class WidgetModel; //Forward declaration
namespace ViewModule {
-
class AppsSupportImplementation; //Forward declaration
class AppsSupport
void deinitialize();
void html5VideoRequest(void* event_info);
void downloadRequest(
- const char *url,
- const char *mimeType,
- const char *userParam);
+ const char *url,
+ const char *mimeType,
+ const char *userParam);
private:
std::unique_ptr<AppsSupportImplementation> m_impl;
};
-
} //namespace
#endif /* VIEW_LOGIC_APPS_SUPPORT_H_ */
namespace ViewModule {
namespace CustomHeaderSupport {
-
std::string getValueByField(const std::string field)
{
LogDebug("Field : " << field);
namespace ViewModule {
namespace CustomHeaderSupport {
- const std::string ACCEPT_LANGUAGE = "Accept-Language";
+const std::string ACCEPT_LANGUAGE = "Accept-Language";
- std::string getValueByField(const std::string field);
+std::string getValueByField(const std::string field);
} // namespace UserAgentSupport
} // namespace CustomHeaderSupport
namespace ViewModule {
namespace GeolocationSupport {
-
bool askUserForPermission()
{
return Wrt::Popup::PopupInvoker().askYesNo(
- GEOLOCATION_ASK_TITLE,
- GEOLOCATION_ASK_MSG);
+ GEOLOCATION_ASK_TITLE,
+ GEOLOCATION_ASK_MSG);
}
bool checkRequestedStateOfGeolocationFeature(WrtDB::WidgetDAOReadOnlyPtr dao)
{
WrtDB::DbWidgetFeature geolocationFeature;
geolocationFeature.name = DPL::FromASCIIString(
- WrtDB::GlobalConfig::GetW3CGeolocationFeatureName() );
+ WrtDB::GlobalConfig::GetW3CGeolocationFeatureName() );
auto features = dao->getFeaturesList();
auto it = features.find(geolocationFeature);
- if ( it != features.end() )
- {
- if(it->rejected){
+ if (it != features.end() ) {
+ if (it->rejected) {
LogInfo("Feature rejected by ACE");
return false;
}
bool getLocalizationState(const DPL::String& tizenId, bool enableHighAccuracy)
{
- LogDebug ("Get localization state");
+ LogDebug("Get localization state");
WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
- if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
- {
+ if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
return askUserForPermission();
}
return checkRequestedStateOfGeolocationFeature(dao) &&
- ViewModule::SecuritySupport::geolocationACECheck(tizenId,
- enableHighAccuracy);
+ ViewModule::SecuritySupport::geolocationACECheck(tizenId,
+ enableHighAccuracy);
}
bool getGeolocationModuleState(const DPL::String& tizenId)
{
- LogDebug ("Get geolocation state");
+ LogDebug("Get geolocation state");
WrtDB::WidgetDAOReadOnlyPtr dao(new WrtDB::WidgetDAOReadOnly(tizenId));
- if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP)
- {
+ if (dao->getWidgetType() == WrtDB::APP_TYPE_TIZENWEBAPP) {
LogInfo("Geolocation enable for tizen app");
return true;
}
return checkRequestedStateOfGeolocationFeature(dao);
}
-
} // namespace GeolocationSupport
} // namespace ViewModule
namespace ViewModule {
namespace GeolocationSupport {
-
/*
* @returns true if user allowed for share current position
* @returns false otherwise
/*
* The function returns requested state of geolocation module
*
- * @returns true if geolocation module(navigator.geolocation object) should be enabled
- * false if geolocation module(navigator.geolocation object) should be disabled
+ * @returns true if geolocation module(navigator.geolocation object) should be
+ * enabled
+ * false if geolocation module(navigator.geolocation object) should be
+ * disabled
*/
bool getGeolocationModuleState(const DPL::String& tizenId);
-
}
} // namespace ViewModule
namespace ViewModule {
namespace PasswordSupport {
-
namespace {
const char *SCHEME_TYPE_HTTP = "http";
const char *SCHEME_TYPE_HTTPS = "https";
-const char *AUTOSAVEIDPASS_OFF = "OFF";
-const char *AUTOSAVEIDPASS_ON = "ON";
-const char *AUTOSAVEIDPASS_ALWAYS_ASK = "ALWAYS_ASK";
+const char *AUTOSAVEIDPASS_OFF = "OFF";
+const char *AUTOSAVEIDPASS_ON = "ON";
+const char *AUTOSAVEIDPASS_ALWAYS_ASK = "ALWAYS_ASK";
// This message isn't confirmed by UX guide
// It should be change to use IDS for translate
const char AUTOSAVE_ASK_MSG[] = "Do you want to remember the password on ";
return EINA_TRUE;
}
-
}
void submitClicked(std::string uri, Eina_Hash* data)
FOREACH(iterator, submitData) {
keyOstring << DOUBLE_QUOTES << iterator->key << DOUBLE_QUOTES;
valueOstring << DOUBLE_QUOTES << iterator->value << DOUBLE_QUOTES;
- if (*iterator != submitData.back()) {
+ if (*iterator != submitData.back()) {
keyOstring << COMMA;
valueOstring << COMMA;
}
return DPL::FromUTF8String(jsStr);
}
-
} // namespaec PasswordSupport
} // namespaec ViewModule
namespace ViewModule {
namespace PasswordSupport {
-
void submitClicked(std::string uri, Eina_Hash* data);
DPL::Optional<DPL::String> jsForAutoFillData(const char *uri);
-
} // namespace PasswordSupport
} // namespace ViewModule
}
~SecurityOriginSupportImplementation()
- {
- }
+ {}
SecurityOriginDB::SecurityOriginDAO* getSecurityOriginDAO(void)
{
LogDebug("initialize securityOriginDAO");
m_securityOriginDAO =
SecurityOriginDB::SecurityOriginDAOPtr(
- new SecurityOriginDB::SecurityOriginDAO(m_model->TzPkgId.Get()));
+ new SecurityOriginDB::SecurityOriginDAO(m_model->TzPkgId.
+ Get()));
// initialize security result data. Remove allow, deny for
m_securityOriginDAO->removeSecurityOriginData(
SecurityOriginDB::RESULT_ALLOW_ONCE);
std::string key;
if (feature == FEATURE_GEOLOCATION) {
key = WrtDB::VconfConfig::GetVconfKeyGeolocationUsage(
- m_model->TizenId);
+ m_model->TizenId);
} else if (feature == FEATURE_WEB_NOTIFICATION) {
key = WrtDB::VconfConfig::GetVconfKeyWebNotificationUsage(
- m_model->TizenId);
+ m_model->TizenId);
} else if (feature == FEATURE_WEB_DATABASE) {
key = WrtDB::VconfConfig::GetVconfKeyWebDatabaseUsage(
- m_model->TizenId);
+ m_model->TizenId);
} else if (feature == FEATURE_FILE_SYSTEM_ACCESS) {
key = WrtDB::VconfConfig::GetVconfKeyFilesystemUsage(
- m_model->TizenId);
+ m_model->TizenId);
} else {
Assert("Wrong feature argument is input");
}
SecurityOriginSupport::SecurityOriginSupport(WidgetModel* widgetModel) :
m_impl(new SecurityOriginSupportImplementation(widgetModel))
-{
-}
+{}
SecurityOriginSupport::~SecurityOriginSupport()
-{
-}
+{}
-SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::getSecurityOriginDAO(void)
+SecurityOriginDB::SecurityOriginDAO* SecurityOriginSupport::
+ getSecurityOriginDAO(void)
{
return m_impl->getSecurityOriginDAO();
}
return m_impl->isNeedPermissionCheck(feature);
}
-Evas_Object* SecurityOriginSupportUtil::createPopup(Evas_Object* window,
- const char* bodyText,
- const char* checkText,
- Evas_Smart_Cb buttonCallback,
- void* data)
+Evas_Object* SecurityOriginSupportUtil::createPopup(
+ Evas_Object* window,
+ const char* bodyText,
+ const char* checkText,
+ Evas_Smart_Cb
+ buttonCallback,
+ void* data)
{
LogDebug("createPopup");
Evas_Object* popup = elm_popup_add(window);
return NULL;
}
Evas_Object* check = elm_object_part_content_get(
- elm_object_content_get(popup),
- "elm.swallow.end");
+ elm_object_content_get(popup),
+ "elm.swallow.end");
return check;
}
-SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(Evas_Object* button)
+SecurityOriginDB::Result SecurityOriginSupportUtil::getResult(
+ Evas_Object* button)
{
using namespace SecurityOriginDB;
return RESULT_UNKNOWN;
}
if (allow) {
- return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS : RESULT_ALLOW_ONCE;
+ return elm_check_state_get(check) ? RESULT_ALLOW_ALWAYS :
+ RESULT_ALLOW_ONCE;
} else {
- return elm_check_state_get(check) ? RESULT_DENY_ALWAYS : RESULT_DENY_ONCE;
+ return elm_check_state_get(check) ? RESULT_DENY_ALWAYS :
+ RESULT_DENY_ONCE;
}
}
} // namespace ViewModule
class WidgetModel;
namespace SecurityOriginDB {
- class SecurityOriginDAO;
+class SecurityOriginDAO;
}
namespace ViewModule {
-
class SecurityOriginSupportImplementation;
class SecurityOriginSupport
SecurityOriginDB::SecurityOriginDAO* originDao,
SecurityOriginDB::SecurityOriginData originData,
void* data) :
- m_originDao(originDao),
- m_originData(originData),
- m_data(data)
- {
- };
+ m_originDao(originDao),
+ m_originData(originData),
+ m_data(data)
+ {}
};
Evas_Object* createPopup(Evas_Object* window,
};
} // namespace ViewModule
-
#endif // VIEW_LOGIC_SECURITY_ORIGIN_SUPPORT_H_
namespace ViewModule {
namespace SecuritySupport {
-
namespace {
-
const char *GEOLOCATION_DEV_CAP = "geolocation.position";
const char *GEOLOCATION_PARAM_NAME = "param:enableHighAccuracy";
const char *GEOLOCATION_PARAM_VALUE = "true";
LogDebug("Result is: " << static_cast<int>(result));
- delete [] aceRequest.dev_cap_list.items[0].param_list.items;
- delete [] aceRequest.dev_cap_list.items;
+ delete[] aceRequest.dev_cap_list.items[0].param_list.items;
+ delete[] aceRequest.dev_cap_list.items;
return ACE_OK == ret && ACE_TRUE == result;
}
-
} //TODO copied from view_logic.cpp
bool checkWhitelist(const char *url)
return whiteURIList.isRequiredIRI(DPL::FromUTF8String(std::string(url)));
}
-bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy) {
+bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy)
+{
const char *paramName = NULL;
const char *paramValue = NULL;
if (highAccuracy) {
paramValue = GEOLOCATION_PARAM_VALUE;
}
return simpleAceCheck(
- tizenId,
- GEOLOCATION_DEV_CAP,
- paramName,
- paramValue);
+ tizenId,
+ GEOLOCATION_DEV_CAP,
+ paramName,
+ paramValue);
}
-
} // namespace SecuritySupport
} //namespace ViewModule
namespace ViewModule {
namespace SecuritySupport {
-
char const * const PARAM_URL = "param:url";
bool checkWhitelist(const char *url);
bool geolocationACECheck(const DPL::String& tizenId, bool highAccuracy);
-
} // namespace SecuritySupport
} // namespace ViewModule
namespace ViewModule {
namespace StorageSupport {
-
-namespace
-{ //anonymous
- const mode_t TEMPORARY_STORAGE_MODE = 0700;
+namespace { //anonymous
+const mode_t TEMPORARY_STORAGE_MODE = 0700;
}
void initializeStorage(WidgetModel *widgetModel)
// create temporary storage
std::string path =
- DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
- if(!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)){
+ DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
+ if (!WrtUtilMakeDir(path, TEMPORARY_STORAGE_MODE)) {
ThrowMsg(DPL::CommonException::InternalError,
- "Fail to initialize temporary storage");
+ "Fail to initialize temporary storage");
}
}
// remove temporary storage
std::string path =
- DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
- if(!WrtUtilRemove(path)){
+ DPL::ToUTF8String(widgetModel->TemporaryStoragePath.Get());
+ if (!WrtUtilRemove(path)) {
ThrowMsg(DPL::CommonException::InternalError,
- "Fail to deinitialize temporary storage");
+ "Fail to deinitialize temporary storage");
}
}
-
} // namespace StorageSupport
} // namespace ViewModule
namespace ViewModule {
namespace StorageSupport {
-
void initializeStorage(WidgetModel *widgetModel);
void deinitializeStorage(WidgetModel *widgetModel);
-
} // namespace StorageSupport
} // namespace ViewModule
namespace ViewModule {
namespace UriSupport {
-
namespace {
enum ServiceDataType
{
if (pos != std::string::npos) {
schemeParts.push_back(scheme.substr(0, pos));
schemeParts.push_back(
- scheme.substr(pos + 1, scheme.length() - pos - 1));
+ scheme.substr(pos + 1, scheme.length() - pos - 1));
}
return schemeParts;
}
}
std::string getCustomHandlerProtocolUri(
- WidgetModel *widgetModel,
- const std::string &schemeType,
- const std::string &schemeValue)
+ WidgetModel *widgetModel,
+ const std::string &schemeType,
+ const std::string &schemeValue)
{
CustomHandlerDB::Interface::attachDatabaseRO();
CustomHandlerDB::CustomHandlerDAOReadOnly handlersDao(widgetModel->TizenId);
CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getActivProtocolHandler(
- DPL::FromASCIIString(schemeType));
+ handlersDao.getActivProtocolHandler(
+ DPL::FromASCIIString(schemeType));
CustomHandlerDB::Interface::detachDatabase();
if (handler) {
LogDebug("Found handler, url: " << handler->url);
return prepareUrl(DPL::ToUTF8String(handler->base_url) +
- DPL::ToUTF8String(handler->url), schemeValue);
+ DPL::ToUTF8String(handler->url), schemeValue);
}
return "";
}
std::string getCustomHandlerContentUri(
- WidgetModel *widgetModel,
- const std::string &mime,
- const std::string &mimeValue)
+ WidgetModel *widgetModel,
+ const std::string &mime,
+ const std::string &mimeValue)
{
CustomHandlerDB::Interface::attachDatabaseRO();
CustomHandlerDB::CustomHandlerDAOReadOnly handlersDao(widgetModel->TizenId);
CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getActivContentHandler(
- DPL::FromASCIIString(mime));
+ handlersDao.getActivContentHandler(
+ DPL::FromASCIIString(mime));
CustomHandlerDB::Interface::detachDatabase();
if (handler) {
LogDebug("Found handler, url: " << handler->url);
return prepareUrl(DPL::ToUTF8String(handler->base_url) +
- DPL::ToUTF8String(handler->url), mimeValue);
+ DPL::ToUTF8String(handler->url), mimeValue);
}
return "";
}
std::string getAppServiceUri(bundle *bundle, WidgetModel *widgetModel)
{
- if(!bundle)
- {
+ if (!bundle) {
LogError("Bundle is empty");
return std::string("");
}
if (schemeParts.size() > 1) {
LogDebug("Scheme parts: " << schemeParts[0] << ", " << schemeParts[1]);
return getCustomHandlerProtocolUri(
- widgetModel, schemeParts[0], schemeParts[1]);
+ widgetModel, schemeParts[0], schemeParts[1]);
}
if (mime != "") {
value = appsvc_get_data(bundle, APPSVC_DATA_SELECTED);
if (value != NULL) {
LogDebug("Use mime type for: " << value);
return getCustomHandlerContentUri(
- widgetModel, mime, std::string(value));
+ widgetModel, mime, std::string(value));
} else {
LogError("Selected file for mime is null, nothind to do");
}
std::string preFix = DPL::ToUTF8String(widgetModel->PrefixURL.Get());
if (strstr(startUri.c_str(), "http") == startUri.c_str() ||
- strstr( startUri.c_str(), preFix.c_str()) == startUri.c_str()) {
+ strstr(startUri.c_str(), preFix.c_str()) == startUri.c_str())
+ {
uri = DPL::FromUTF8String(startUri);
} else {
uri = widgetModel->PrefixURL.Get() +
- DPL::FromUTF8String(startUri);
+ DPL::FromUTF8String(startUri);
}
return DPL::ToUTF8String(uri).c_str();
}
return DPL::OptionalString(uri);
}
}
-
} // namespace UriSupportImplementation
} // namespace ViewModule
namespace ViewModule {
namespace UriSupport {
-
std::string getUri(WidgetModel *widgetModel, const std::string &defaultUri);
DPL::OptionalString localizeURI(const DPL::String& inputURI,
const WidgetModel* model);
-
} // namespace UriSupport
} // namespace ViewModule
namespace ViewModule {
namespace UserAgentSupport {
-
std::string getUserAgentFromVconf()
{
using namespace WrtDB;
}
} else {
DPL::String value =
- GlobalDAOReadOnly::GetUserAgentValue(DPL::FromUTF8String(userAgentName));
+ GlobalDAOReadOnly::GetUserAgentValue(DPL::FromUTF8String(
+ userAgentName));
userAgent = DPL::ToUTF8String(value);
LogDebug("value : " << value);
}
namespace ViewModule {
namespace UserAgentSupport {
- std::string getUserAgentFromVconf();
+std::string getUserAgentFromVconf();
} // namespace UserAgentSupport
} // namespace ViewModule
#include <haptic.h>
namespace ViewModule {
-
-VibrationSupport::VibrationSupport(): m_initialized(false),
- m_handle(NULL),
- m_effect_handle(NULL)
-{
-}
+VibrationSupport::VibrationSupport() : m_initialized(false),
+ m_handle(NULL),
+ m_effect_handle(NULL)
+{}
VibrationSupport::~VibrationSupport()
{
{
LogDebug("deinitialize");
- if( m_initialized )
- {
+ if (m_initialized) {
int ret = haptic_close(m_handle);
- if( HAPTIC_ERROR_NONE == ret )
- {
+ if (HAPTIC_ERROR_NONE == ret) {
m_initialized = false;
LogDebug("deinitialize success");
- }
- else
- {
+ } else {
m_initialized = true;
LogDebug("deinitialize failed - error code : " << ret);
}
{
LogDebug("startVibration called");
- if ( m_initialized == false )
- {
- if ( initializeVibration() == false )
- {
+ if (m_initialized == false) {
+ if (initializeVibration() == false) {
return;
}
}
int time = static_cast<int>(vibrationTime);
int ret = haptic_vibrate_monotone(m_handle, time, &m_effect_handle);
- if( HAPTIC_ERROR_NONE == ret )
- {
+ if (HAPTIC_ERROR_NONE == ret) {
LogDebug("haptic_vibrate_monotone success");
- }
- else
- {
+ } else {
LogDebug("haptic_vibrate_monotone failed - error code : " << ret);
}
void VibrationSupport::stopVibration(void)
{
LogDebug("stopVibration called");
- if ( m_initialized == false )
- {
+ if (m_initialized == false) {
return;
}
int ret = haptic_stop_all_effects(m_handle);
- if( HAPTIC_ERROR_NONE == ret )
- {
+ if (HAPTIC_ERROR_NONE == ret) {
LogDebug("haptic_stop_all_effects success");
- }
- else
- {
+ } else {
LogDebug("haptic_stop_all_effects failed - error code : " << ret);
}
{
LogDebug("initializeVibration called");
-
- if ( m_initialized == false )
- {
+ if (m_initialized == false) {
haptic_device_h handle = NULL;
int ret = haptic_open(HAPTIC_DEVICE_0, &handle);
- if ( ret == HAPTIC_ERROR_NONE )
- {
+ if (ret == HAPTIC_ERROR_NONE) {
LogDebug("initializeVibration success");
m_initialized = true;
m_handle = handle;
- }
- else
- {
+ } else {
LogDebug("initializeVibration failed - error code : " << ret);
m_initialized = false;
m_handle = NULL;
return m_initialized;
}
-
} // namespace ViewModule
#include <haptic.h>
namespace ViewModule {
-
class VibrationSupport
{
public:
bool initializeVibration(void);
};
-
} // namespace ViewModule
#endif // VIEW_LOGIC_VIBRATION_SUPPORT_H_
class WidgetModel; //FORWARD DECLARATION
namespace ViewModule {
-
/** \brief Interface to ViewModule. Object of IViewModule type is returned from
* ViewModuleMgr factory.
*/
class IViewModule
{
-public:
+ public:
virtual bool createWebView(Ewk_Context* context,
Evas_Object* window) = 0;
virtual void destroyWebView() = 0;
virtual void prepareView(WidgetModel *, const std::string &) = 0;
virtual void showWidget() = 0;
virtual void hideWidget() = 0;
- virtual void suspendWidget()= 0;
+ virtual void suspendWidget() = 0;
virtual void resumeWidget() = 0;
virtual void resetWidget() = 0;
virtual void backward() = 0;
* to IViewModule object.
*/
IViewModulePtr createView();
-
} //namespace
#endif /* WRT_SRC_VIEW_I_VIEW_MODULE_H_ */
#include "i_view_module.h"
#include <view_logic.h>
-namespace ViewModule
-{
-
+namespace ViewModule {
IViewModulePtr createView()
{
IViewModulePtr ptr(new ViewLogic());
return ptr;
}
-
} //namespace
#include <WKType.h>
namespace {
-
char const * const SCHEME_TYPE_FILE = "file";
char const * const SCHEME_TYPE_WIDGET = "widget";
char const * const WARP_ERROR_MSG =
- "file:///usr/etc/wrt/warp_security_error.msg";
+ "file:///usr/etc/wrt/warp_security_error.msg";
char const * const PARAM_URL = "param:url";
char const * const ACE_IGNORED_SCHEMA[] = { "file://", "widget://", "data:",
- "tel:", "sms:", "mmsto:", "mailto:", 0 };
+ "tel:", "sms:", "mmsto:", "mailto:",
+ 0 };
WKStringRef block_message = WKStringCreateWithUTF8CString("uri_block_msg");
-
bool checkWARP(const char *url, const DPL::String& tizenId)
{
// ignore WARP in test mode
dao.getWidgetAccessInfo(widgetAccessInfoList);
return (static_cast<WidgetAccessList>(widgetAccessInfoList)).isRequiredIRI(
- DPL::FromUTF8String(std::string(url)));
+ DPL::FromUTF8String(std::string(url)));
}
bool checkACE(const char* url, bool xhr, const DPL::String& tizenId)
if (xhr) {
aceRequest.dev_cap_list.items[0].name =
- const_cast<ace_string_t>(devCapNamesXHR);
+ const_cast<ace_string_t>(devCapNamesXHR);
} else {
aceRequest.dev_cap_list.items[0].name =
- const_cast<ace_string_t>(devCapNamesMarkup);
+ const_cast<ace_string_t>(devCapNamesMarkup);
}
aceRequest.dev_cap_list.items[0].param_list.count = 1;
aceRequest.dev_cap_list.items[0].param_list.items = new ace_param_t[1];
aceRequest.dev_cap_list.items[0].param_list.items[0].name =
- const_cast<ace_string_t>(PARAM_URL);
+ const_cast<ace_string_t>(PARAM_URL);
aceRequest.dev_cap_list.items[0].param_list.items[0].value =
- const_cast<ace_string_t>(url);
-
+ const_cast<ace_string_t>(url);
ace_bool_t result = ACE_FALSE;
LogDebug("Result is: " << static_cast<int>(result));
- delete [] aceRequest.dev_cap_list.items[0].param_list.items;
- delete [] aceRequest.dev_cap_list.items;
+ delete[] aceRequest.dev_cap_list.items[0].param_list.items;
+ delete[] aceRequest.dev_cap_list.items;
return ACE_OK == ret && ACE_TRUE == result;
}
-
bool filterURIBySecurity(DPL::OptionalString &op_uri,
- bool is_xhr,
- const DPL::String& tizenId)
+ bool is_xhr,
+ const DPL::String& tizenId)
{
- if (!op_uri)
- {
+ if (!op_uri) {
return true; //accept empty uri
}
auto uri = DPL::ToUTF8String(*op_uri);
- if (!checkWARP(uri.c_str(), tizenId))
- {
+ if (!checkWARP(uri.c_str(), tizenId)) {
LogDebug("Request was blocked by WARP: " << uri);
return false;
}
- if (!checkACE(uri.c_str(), is_xhr, tizenId))
- {
+ if (!checkACE(uri.c_str(), is_xhr, tizenId)) {
LogDebug("Request was blocked by ACE: " << uri);
return false;
}
} // namespace (anonymous)
namespace BundleURIHandling {
-
DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
- bool is_xhr, const DPL::String& tizenId, WKBundleRef bundle)
+ bool is_xhr,
+ const DPL::String& tizenId,
+ WKBundleRef bundle)
{
DPL::Optional<DPL::String> uri = localizeURI(inputURI, tizenId);
- if (uri.IsNull())
- {
+ if (uri.IsNull()) {
LogDebug("uri is empty");
return uri;
}
// check ACE, WARP
- if (!filterURIBySecurity(uri, is_xhr, tizenId))
- {
+ if (!filterURIBySecurity(uri, is_xhr, tizenId)) {
WKStringRef urlStr = WKStringCreateWithUTF8CString(
DPL::ToUTF8String(*uri).c_str());
WKTypeRef retVal = NULL;
// Send information about blocked URI to view_logic
LogInfo("Sent blocked uri to open browser later : " << uri);
WKBundlePostSynchronousMessage(bundle, block_message,
- urlStr, &retVal);
+ urlStr, &retVal);
WKRelease(urlStr);
WKRelease(retVal);
return DPL::Optional<DPL::String>::Null;
}
DPL::OptionalString localizeURI(const DPL::String& inputURI,
- const DPL::String& tizenId)
+ const DPL::String& tizenId)
{
auto uri = DPL::ToUTF8String(inputURI);
LogDebug("localizing url: " << uri);
return DPL::OptionalString(uri);
}
}
-
} // namespace BundleURIHandling
#include <WKBundle.h>
namespace BundleURIHandling {
- DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
- bool is_xhr, const DPL::String& tizenId, WKBundleRef bundle);
- DPL::OptionalString localizeURI(const DPL::String& inputURI,
- const DPL::String& tizenId);
+DPL::Optional<DPL::String> processURI(const DPL::String& inputURI,
+ bool is_xhr,
+ const DPL::String& tizenId,
+ WKBundleRef bundle);
+DPL::OptionalString localizeURI(const DPL::String& inputURI,
+ const DPL::String& tizenId);
}
-
#endif /* BUNDLE_URI_HANDLING_H_ */
#include <js_overlay_types.h>
namespace PluginModuleSupport {
-
void init(Ewk_Context* ewkContext, const std::string& tizenId)
{
const char* name = BundleMessages::INIT;
ssMsg << "_" << scale << " ";
- if(encodedBundle)
- {
+ if (encodedBundle) {
ssMsg << "_" << encodedBundle << " ";
- }
- else
- {
+ } else {
ssMsg << "null" << " ";
}
- if(theme)
- {
+ if (theme) {
ssMsg << "_" << theme << " ";
- }
- else
- {
+ } else {
ssMsg << "null" << " ";
}
}
void setCustomProperties(
- Ewk_Context* ewkContext,
- double* scale,
- const char* encodedBundle,
- const char* theme )
+ Ewk_Context* ewkContext,
+ double* scale,
+ const char* encodedBundle,
+ const char* theme)
{
std::stringstream ssMsg;
- if(scale)
- {
+ if (scale) {
ssMsg << "_" << *scale << " ";
- }
- else
- {
+ } else {
ssMsg << "null" << " ";
}
- if(encodedBundle)
- {
+ if (encodedBundle) {
ssMsg << "_" << encodedBundle << " ";
- }
- else
- {
+ } else {
ssMsg << "null" << " ";
}
- if(theme)
- {
+ if (theme) {
ssMsg << "_" << theme;
- }
- else
- {
+ } else {
ssMsg << "null";
}
}
void dispatchJavaScriptEvent(
- Ewk_Context* ewkContext,
- WrtPlugins::W3C::CustomEventType eventType,
- void *data)
+ Ewk_Context* ewkContext,
+ WrtPlugins::W3C::CustomEventType eventType,
+ void *data)
{
using namespace WrtPlugins::W3C;
std::stringstream str;
const char* name = BundleMessages::RESUME;
ewk_context_message_post_to_injected_bundle(ewkContext, name, name);
}
-
-}//namespace PluginModuleSupport
+} //namespace PluginModuleSupport
void resume(Ewk_Context* ewkContext);
void setCustomProperties(
- Ewk_Context* ewkContext,
- double* scale = NULL,
- const char* encodedBundle = NULL,
- const char* theme = NULL);
+ Ewk_Context* ewkContext,
+ double* scale = NULL,
+ const char* encodedBundle = NULL,
+ const char* theme = NULL);
void dispatchJavaScriptEvent(
- Ewk_Context* ewkContext,
- WrtPlugins::W3C::CustomEventType eventType,
- void* data);
+ Ewk_Context* ewkContext,
+ WrtPlugins::W3C::CustomEventType eventType,
+ void* data);
} // namespace PluginModuleSupport
#endif /* WRT_SRC_VIEW_WEBKIT2_PLUGIN_MODULE_SUPPORT_H_ */
{
WrtDB::WrtDatabase::detachFromThread();
- if (!m_pagesList.empty())
- {
+ if (!m_pagesList.empty()) {
LogError("There are not closed pages!");
}
}
void Bundle::didCreatePageCallback(
- WKBundleRef /*bundle*/,
- WKBundlePageRef page,
- const void* clientInfo)
+ WKBundleRef /*bundle*/,
+ WKBundlePageRef page,
+ const void* clientInfo)
{
LOG_PROFILE_START("didCreatePageCallback");
LogDebug("didCreatePageCallback called");
}
void Bundle::didReceiveMessageCallback(
- WKBundleRef /*bundle*/,
- WKStringRef messageName,
- WKTypeRef messageBody,
- const void *clientInfo)
+ WKBundleRef /*bundle*/,
+ WKStringRef messageName,
+ WKTypeRef messageBody,
+ const void *clientInfo)
{
LogDebug("didReceiveMessageCallback called");
Bundle* bundle = static_cast<Bundle*>(const_cast<void*>(clientInfo));
}
void Bundle::willDestroyPageCallback(
- WKBundleRef /*bundle*/,
- WKBundlePageRef page,
- const void* clientInfo)
+ WKBundleRef /*bundle*/,
+ WKBundlePageRef page,
+ const void* clientInfo)
{
LogDebug("willDestroyPageCallback called");
Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
m_pageGlobalContext[page] = context;
LogDebug("created Page : " << page << " created JSContext : " << context);
- WKBundlePageResourceLoadClient resourceLoadClient = {
+ WKBundlePageResourceLoadClient resourceLoadClient = {
kWKBundlePageResourceLoadClientCurrentVersion, /* version */
this, /* clientinfo */
0, /* didInitiateLoadForResource */
WKBundlePagePolicyClient policyClient = {
kWKBundlePagePolicyClientCurrentVersion, /* version */
this, /* clientInfo */
- pageDecidePolicyForNavigationActionCallback, /* decidePolicyForNavigationAction */
- 0, /* decidePolicyForNewWindowAction */
- pageDecidePolicyForResponseCallback, /* decidePolicyForResponse */
- 0, /* unableToImplementPolicy */
+ pageDecidePolicyForNavigationActionCallback, /**/
+ 0, /* decidePolicyForNewWindowAction */
+ pageDecidePolicyForResponseCallback, /* decidePolicyForResponse */
+ 0, /* unableToImplementPolicy */
};
WKBundlePageSetPolicyClient(page, &policyClient);
-
-};
+}
void Bundle::willDestroyPage(WKBundlePageRef page)
{
PluginModule::stop(context);
}
-void Bundle::fixWKMessageArgs(std::string & argScale, std::string & argEncodedBundle, std::string & argTheme)
+void Bundle::fixWKMessageArgs(std::string & argScale,
+ std::string & argEncodedBundle,
+ std::string & argTheme)
{
- if (argScale != "null" && argScale[0] == '_')
- {
+ if (argScale != "null" && argScale[0] == '_') {
argScale.erase(0, 1);
std::stringstream ssScale(argScale);
ssScale >> m_scale;
}
- if (argEncodedBundle != "null" && argEncodedBundle[0] == '_')
- {
+ if (argEncodedBundle != "null" && argEncodedBundle[0] == '_') {
argEncodedBundle.erase(0, 1);
m_encodedBundle = argEncodedBundle;
}
- if (argTheme != "null" && argTheme[0] == '_')
- {
+ if (argTheme != "null" && argTheme[0] == '_') {
argTheme.erase(0, 1);
m_theme = argTheme;
// ** Language tags setting completed **
fixWKMessageArgs(argScale, argEncodedBundle, argTheme);
- }
- else if (WKStringIsEqualToUTF8CString(messageName,
- BundleMessages::SHUTDOWN))
+ } else if (WKStringIsEqualToUTF8CString(messageName,
+ BundleMessages::SHUTDOWN))
{
LogDebug("shutdown plugins");
- if (m_pagesList.empty())
- {
+ if (m_pagesList.empty()) {
PluginModule::shutdown();
+ } else {
+ LogInfo(
+ "PluginModule shutdown ignored, there are still alive pages!");
}
- else
- {
- LogInfo("PluginModule shutdown ignored, there are still alive pages!");
- }
- }
- else if (WKStringIsEqualToUTF8CString(messageName,
- BundleMessages::SUSPEND))
+ } else if (WKStringIsEqualToUTF8CString(messageName,
+ BundleMessages::SUSPEND))
{
LogDebug("suspend plugins");
requestSuspend();
- }
- else if (WKStringIsEqualToUTF8CString(messageName,
- BundleMessages::RESUME))
+ } else if (WKStringIsEqualToUTF8CString(messageName,
+ BundleMessages::RESUME))
{
LogDebug("resume plugins");
requestResume();
- }
- else if (WKStringIsEqualToUTF8CString(messageName,
- BundleMessages::SET_CUSTOM_PROPERTIES))
+ } else if (WKStringIsEqualToUTF8CString(messageName,
+ BundleMessages::
+ SET_CUSTOM_PROPERTIES))
{
LogDebug("reset custom properties of window objects");
// set information from ui process
//apply for each context
PageGlobalContext::iterator it = m_pageGlobalContext.begin();
- for (; it != m_pageGlobalContext.end(); ++it)
- {
+ for (; it != m_pageGlobalContext.end(); ++it) {
PluginModule::setCustomProperties(it->second,
m_scale,
m_encodedBundle.c_str(),
m_theme.c_str());
}
- }
- else if (WKStringIsEqualToUTF8CString(
- messageName,
- BundleMessages::DISPATCH_JAVASCRIPT_EVENT))
+ } else if (WKStringIsEqualToUTF8CString(
+ messageName,
+ BundleMessages::DISPATCH_JAVASCRIPT_EVENT))
{
LogDebug("dispatch javascript event to created frames");
// set information from ui process
//apply for each context
PageGlobalContext::iterator it = m_pageGlobalContext.begin();
- for (; it != m_pageGlobalContext.end(); ++it)
- {
+ for (; it != m_pageGlobalContext.end(); ++it) {
PluginModule::dispatchJavaScriptEvent(
- it->second,
- static_cast<WrtPlugins::W3C::CustomEventType>(eventType),
- args);
+ it->second,
+ static_cast<WrtPlugins::W3C::CustomEventType>(eventType),
+ args);
}
if (args) {
delete static_cast<SoftKeyboardChangeArgs *>(args);
}
- }
- else if (WKStringIsEqualToUTF8CString(
- messageName,
- BundleMessages::INIT))
+ } else if (WKStringIsEqualToUTF8CString(
+ messageName,
+ BundleMessages::INIT))
{
LogDebug("initializing plugins");
auto msgString = toString(static_cast<WKStringRef>(messageBody));
// reset language tags (create new tags based on system locales)
LanguageTagsProviderSingleton::Instance().resetLanguageTags();
DPL::OptionalString defaultLocale = dao.getDefaultlocale();
- if(!defaultLocale.IsNull())
- {
- LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defaultLocale);
+ if (!defaultLocale.IsNull()) {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+ *defaultLocale);
}
- LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
+ LanguageTags tags =
+ LanguageTagsProviderSingleton::Instance().getLanguageTags();
LogDebug("Current widget locales (language tags):");
FOREACH(it, tags) {
LogDebug("Locale: " << *it);
}
WKURLRequestRef Bundle::willSendRequestForFrameCallback(
- WKBundlePageRef /*page*/,
- WKBundleFrameRef /*frame*/,
- uint64_t /*resourceIdentifier*/,
- WKURLRequestRef request,
- WKURLResponseRef /*response*/,
- const void *clientInfo)
+ WKBundlePageRef /*page*/,
+ WKBundleFrameRef /*frame*/,
+ uint64_t /*resourceIdentifier*/,
+ WKURLRequestRef request,
+ WKURLResponseRef /*response*/,
+ const void *clientInfo)
{
LogDebug("willSendRequestForFrameCallback called");
Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
}
void Bundle::didStartProvisionalLoadForFrameCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef* /*userData*/,
- const void *clientInfo)
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef* /*userData*/,
+ const void *clientInfo)
{
LogDebug("didStartProvisionalLoadForFrameCallback called");
Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
}
void Bundle::didRemoveFrameFromHierarchyCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef* /*userData*/,
- const void *clientInfo)
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef* /*userData*/,
+ const void *clientInfo)
{
LogDebug("didFinishLoadForResourceCallback called");
Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
- if (This->m_pageGlobalContext.count(page) == 0)
- {
+ if (This->m_pageGlobalContext.count(page) == 0) {
return;
}
- if (This->m_pageContext.count(page) == 0)
- {
+ if (This->m_pageContext.count(page) == 0) {
return;
}
ContextSet::iterator i = This->m_pageContext[page].find(context);
- if (i == This->m_pageContext[page].end())
- {
+ if (i == This->m_pageContext[page].end()) {
LogWarning("Tried to unload frame which has never been loaded");
return;
}
}
void Bundle::didFinishLoadForResourceCallback(
- WKBundlePageRef /*page*/,
- WKBundleFrameRef frame,
- uint64_t /*resourceIdentifier*/,
- const void* clientInfo)
+ WKBundlePageRef /*page*/,
+ WKBundleFrameRef frame,
+ uint64_t /*resourceIdentifier*/,
+ const void* clientInfo)
{
LogDebug("didFinishLoadForResourceCallback called");
Bundle* This = static_cast<Bundle*>(const_cast<void*>(clientInfo));
// If url is NULL, this url has been already blocked by willsend
// So current page should be moved to previous page
- if (url == NULL)
- {
- if (WKBundleFrameIsMainFrame(frame))
- {
+ if (url == NULL) {
+ if (WKBundleFrameIsMainFrame(frame)) {
LogInfo("url is NULL. Go back to previous view");
WKStringRef blockedURL =
WKStringCreateWithUTF8CString(URICHANGE_BLOCKED_URL);
WKBundlePostSynchronousMessage(This->m_bundle,
- This->m_uriChangedMessage,
- blockedURL,
- &retVal);
- }
- else
- {
+ This->m_uriChangedMessage,
+ blockedURL,
+ &retVal);
+ } else {
LogInfo("Blocked uri in IFrame.");
}
return;
}
void Bundle::didCommitLoadForFrameCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef* /*userData*/,
- const void *clientInfo)
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef* /*userData*/,
+ const void *clientInfo)
{
LogInfo("didCommitLoadForFrameCallback called");
LOG_PROFILE_START("didCommitLoadForFrameCallback");
This->m_pageContext[page].insert(context);
- if (!WKBundleFrameIsMainFrame(frame))
- {
+ if (!WKBundleFrameIsMainFrame(frame)) {
LogInfo("frame isn't main frame");
PluginModule::start(
- WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
- context,
- This->m_scale,
- This->m_encodedBundle.c_str(),
- This->m_theme.c_str());
+ WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
+ context,
+ This->m_scale,
+ This->m_encodedBundle.c_str(),
+ This->m_theme.c_str());
PluginModule::loadFrame(context);
return;
}
std::string scheme = getScheme(toString(url));
std::string result = URICHANGE_PLUGIN_RESTART;
- if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS)
- {
+ if (scheme == SCHEME_HTTP || scheme == SCHEME_HTTPS) {
WKStringRef urlStr = WKURLCopyString(url);
WKBundlePostSynchronousMessage(This->m_bundle,
This->m_uriChangedMessage,
}
LogInfo("result from UI process : " << result);
- if (result == URICHANGE_PLUGIN_STOP_ONLY)
- {
+ if (result == URICHANGE_PLUGIN_STOP_ONLY) {
PluginModule::stop(context);
- }
- else if (result == URICHANGE_PLUGIN_RESTART)
- {
+ } else if (result == URICHANGE_PLUGIN_RESTART) {
PluginModule::stop(context);
This->m_pageGlobalContext[page] = context;
LOG_PROFILE_START("PluginModule start");
PluginModule::start(
- WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
- context,
- This->m_scale,
- This->m_encodedBundle.c_str(),
- This->m_theme.c_str() );
+ WrtDB::WidgetDAOReadOnly::getHandle(This->m_widgetTizenId),
+ context,
+ This->m_scale,
+ This->m_encodedBundle.c_str(),
+ This->m_theme.c_str() );
LOG_PROFILE_STOP("PluginModule start");
PluginModule::loadFrame(context);
}
WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationActionCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKBundleNavigationActionRef navigationAction,
- WKURLRequestRef request,
- WKTypeRef* userData,
- const void* clientInfo)
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKBundleNavigationActionRef navigationAction,
+ WKURLRequestRef request,
+ WKTypeRef* userData,
+ const void* clientInfo)
{
LogDebug("pageDecidePolicyForNavigationActionCallback called");
}
WKBundlePagePolicyAction Bundle::pageDecidePolicyForResponseCallback(
- WKBundlePageRef /* page */,
- WKBundleFrameRef /* frame */,
- WKURLResponseRef response,
- WKURLRequestRef /* request */,
- WKTypeRef* /* userData */,
- const void* /* clientInfo */)
+ WKBundlePageRef /* page */,
+ WKBundleFrameRef /* frame */,
+ WKURLResponseRef response,
+ WKURLRequestRef /* request */,
+ WKTypeRef* /* userData */,
+ const void* /* clientInfo */)
{
LogDebug("pageDecidePolicyForResponseCallback called");
LogDebug("contentTypeRef : " << contentType);
WKRelease(contentTypeRef);
- if (contentType == HTML_MIME)
- {
+ if (contentType == HTML_MIME) {
LogDebug("Accepting HTML_MIME type");
return WKBundlePagePolicyActionUse;
}
- if (contentType == PHP_MIME)
- {
+ if (contentType == PHP_MIME) {
LogDebug("Accepting php type");
return WKBundlePagePolicyActionUse;
}
bool is_xhr = true; // Webkit should inform if it's XHR
DPL::String dplurl = DPL::FromUTF8String(toString(urlStr));
WKRelease(urlStr);
- DPL::Optional<DPL::String> newurl = BundleURIHandling::processURI(dplurl,
- is_xhr, m_widgetTizenId, m_bundle);
+ DPL::Optional<DPL::String> newurl = BundleURIHandling::processURI(
+ dplurl,
+ is_xhr,
+ m_widgetTizenId,
+ m_bundle);
if (newurl.IsNull()) {
LogDebug("URI is blocked");
WKRelease(url);
return NULL;
} else {
- LogDebug("URI processing result: " << *newurl );
+ LogDebug("URI processing result: " << *newurl);
std::string tmpUrlStr = DPL::ToUTF8String(*newurl);
if (tmpUrlStr.empty()) {
LogDebug("uri is blocked");
std::string checkUrl = toString(tmpUrl);
int getFileSize;
- if(m_encrypted) {
- if(isEncryptedResource(checkUrl, getFileSize)) {
+ if (m_encrypted) {
+ if (isEncryptedResource(checkUrl, getFileSize)) {
std::string decryptString = DecryptResource(checkUrl,
- getFileSize);
+ getFileSize);
if (!decryptString.empty()) {
std::string destString = DATA_STRING;
std::string mimeString =
- DPL::ToUTF8String(MimeTypeUtils::identifyFileMimeType(
- DPL::FromUTF8String(checkUrl)));
+ DPL::ToUTF8String(
+ MimeTypeUtils::identifyFileMimeType(
+ DPL::FromUTF8String(checkUrl)));
destString += mimeString;
destString += BASE64_STRING;
WKURLRef destUrl =
WKURLCreateWithUTF8CString(decryptString.c_str());
- WKURLRequestRef req = WKURLRequestCreateWithWKURL(destUrl);
+ WKURLRequestRef req = WKURLRequestCreateWithWKURL(
+ destUrl);
WKRelease(destUrl);
LogDebug("return value " << decryptString << "]]");
return req;
}
WKBundlePagePolicyAction Bundle::pageDecidePolicyForNavigationAction(
- WKBundlePageRef /* page */,
- WKBundleFrameRef frame,
- WKBundleNavigationActionRef /* navigationAction */,
- WKURLRequestRef request,
- WKTypeRef* /* userData */)
+ WKBundlePageRef /* page */,
+ WKBundleFrameRef frame,
+ WKBundleNavigationActionRef /* navigationAction */,
+ WKURLRequestRef request,
+ WKTypeRef* /* userData */)
{
using namespace ViewModule;
using namespace ViewModule::SchemeActionMap;
LogInfo("Uri being checked: " << request_uri);
// exception uri
- if( request_uri == BLANK_PAGE_URL )
- {
+ if (request_uri == BLANK_PAGE_URL) {
return WKBundlePagePolicyActionUse;
}
std::string request_scheme = getScheme(request_uri);
// is tizen schem?
- if ( request_scheme == TIZEN_SCHEME )
- {
+ if (request_scheme == TIZEN_SCHEME) {
return WKBundlePagePolicyActionPassThrough;
}
UriAction action;
- if (m_widgetType == WrtDB::APP_TYPE_WAC20)
- {
+ if (m_widgetType == WrtDB::APP_TYPE_WAC20) {
action = g_wacActionMap[type][ctx];
- }
- else if (m_widgetType == WrtDB::APP_TYPE_TIZENWEBAPP)
- {
+ } else if (m_widgetType == WrtDB::APP_TYPE_TIZENWEBAPP) {
action = g_tizenActionMap[type][ctx];
- }
- else
- {
+ } else {
LogError("Unsupported application type: " << type);
return WKBundlePagePolicyActionPassThrough;
}
LogDebug("Uri action: " << action);
- if (action == URI_ACTION_WRT)
- {
+ if (action == URI_ACTION_WRT) {
return WKBundlePagePolicyActionUse;
}
return WKBundlePagePolicyActionPassThrough;
-
}
std::string Bundle::toString(WKStringRef str)
std::size_t found = uri.find(':');
std::string str;
- if (found != std::string::npos)
- {
+ if (found != std::string::npos) {
str = uri.substr(0, found);
}
std::string filePath;
size_t pos = Url.find_first_not_of(SCHEME_FILE);
- if ( std::string::npos != pos) {
- filePath = Url.substr(pos-1);
+ if (std::string::npos != pos) {
+ filePath = Url.substr(pos - 1);
}
if (m_encryptedFiles.empty()) {
info.fileName = DPL::FromUTF8String(filePath);
if ((0 == strncmp(Url.c_str(), SCHEME_FILE, strlen(SCHEME_FILE))) &&
- (m_encryptedFiles.end() != (it =
- m_encryptedFiles.find(info)))) {
+ (m_encryptedFiles.end() != (it =
+ m_encryptedFiles.find(info))))
+ {
LogDebug(" info file name : " << it->fileName);
LogDebug(" info file size : " << it->fileSize);
size = it->fileSize;
std::string filePath;
size_t pos = resource.find_first_not_of(SCHEME_FILE);
- if ( std::string::npos != pos) {
- filePath = resource.substr(pos-1);
+ if (std::string::npos != pos) {
+ filePath = resource.substr(pos - 1);
}
struct stat buf;
if (NULL == m_resDec) {
using namespace WrtDB;
m_resDec = new
- WRTDecryptor::ResourceDecryptor(DPL::ToUTF8String(m_widgetTizenId));
+ WRTDecryptor::ResourceDecryptor(DPL::ToUTF8String(
+ m_widgetTizenId));
WrtDB::WidgetDAOReadOnly(m_widgetTizenId).
getEncryptedFileList(m_encryptedFiles);
}
memset(contents, 0, bufSize);
FILE* fp = fopen(filePath.c_str(), "rb");
- if ( NULL == fp) {
+ if (NULL == fp) {
LogDebug("Couldnot open file : " << filePath);
return std::string();
}
size_t ret = fread(contents, sizeof(unsigned char), buf.st_size, fp);
- if (ret < static_cast<size_t>(buf.st_size) ){
+ if (ret < static_cast<size_t>(buf.st_size) ) {
LogDebug("Couldnot read file : " << filePath);
fclose(fp);
return std::string();
unsigned char outDecBuf[bufSize];
memset(outDecBuf, 0, bufSize);
m_resDec->GetDecryptedChunk(contents, outDecBuf, bufSize);
- memset(outDecBuf+size, '\n', bufSize - size);
+ memset(outDecBuf + size, '\n', bufSize - size);
LogDebug("resource need to encoding base64");
BIO *bmem, *b64;
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);
- std::string base64Enc((char *)bptr->data, bptr->length-1);
+ std::string base64Enc((char *)bptr->data, bptr->length - 1);
BIO_free_all(b64);
return base64Enc;
LogDebug("Unregister callbacks");
FOREACH(page, m_pagesList)
{
- WKBundlePageSetPageLoaderClient(*page,NULL);
+ WKBundlePageSetPageLoaderClient(*page, NULL);
}
}
WKBundlePageLoaderClient loaderClient = {
kWKBundlePageLoaderClientCurrentVersion,
this, /* clientinfo */
- didStartProvisionalLoadForFrameCallback, /* didStartProvisionalLoadForFrame */
+ didStartProvisionalLoadForFrameCallback, /* StartProvisionLoadForFrm */
0, /* didReceiveServerRedirectForProvisionalLoadForFrame */
0, /* didFailProvisionalLoadWithErrorForFrame */
didCommitLoadForFrameCallback, /* didCommitLoadForFrame */
WKBundlePageSetPageLoaderClient(page, &loaderClient);
}
-
extern "C"
{
- WK_EXPORT
- void WKBundleInitialize(WKBundleRef bundle,
- WKTypeRef)
- {
- DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-BUNDLE");
- LogDebug("Bundle initialized");
-
- DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler();
- LogDebug("ResetCrossEventCallHandler()");
-
- static Bundle s_bundle = Bundle(bundle);
-
- WKBundleClient client = {
- kWKBundleClientCurrentVersion,
- &s_bundle,
- &Bundle::didCreatePageCallback,
- &Bundle::willDestroyPageCallback,
- 0, /* didInitializePageGroup */
- &Bundle::didReceiveMessageCallback
- };
- WKBundleSetClient(bundle, &client);
+WK_EXPORT
+void WKBundleInitialize(WKBundleRef bundle,
+ WKTypeRef)
+{
+ DPL::Log::LogSystemSingleton::Instance().SetTag("WRT-BUNDLE");
+ LogDebug("Bundle initialized");
+
+ DPL::Event::GetMainEventDispatcherInstance().ResetCrossEventCallHandler();
+ LogDebug("ResetCrossEventCallHandler()");
+
+ static Bundle s_bundle = Bundle(bundle);
+
+ WKBundleClient client = {
+ kWKBundleClientCurrentVersion,
+ &s_bundle,
+ &Bundle::didCreatePageCallback,
+ &Bundle::willDestroyPageCallback,
+ 0, /* didInitializePageGroup */
+ &Bundle::didReceiveMessageCallback
+ };
+ WKBundleSetClient(bundle, &client);
}
}
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
extern "C" {
- WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
+WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef);
}
-class Bundle {
+class Bundle
+{
public:
Bundle(WKBundleRef bundle);
~Bundle();
// WKBundleClient callback
static void didCreatePageCallback(
- WKBundleRef bundle,
- WKBundlePageRef page,
- const void* clientInfo);
+ WKBundleRef bundle,
+ WKBundlePageRef page,
+ const void* clientInfo);
static void willDestroyPageCallback(
- WKBundleRef bundle,
- WKBundlePageRef page,
- const void* clientInfo);
+ WKBundleRef bundle,
+ WKBundlePageRef page,
+ const void* clientInfo);
static void didReceiveMessageCallback(
- WKBundleRef,
- WKStringRef messageName,
- WKTypeRef messageBody,
- const void *clientInfo);
+ WKBundleRef,
+ WKStringRef messageName,
+ WKTypeRef messageBody,
+ const void *clientInfo);
private:
WKStringRef m_uriChangedMessage;
// WKBundlePageResourceLoadClient callback
static WKURLRequestRef willSendRequestForFrameCallback(
- WKBundlePageRef,
- WKBundleFrameRef,
- uint64_t resourceIdentifier,
- WKURLRequestRef request,
- WKURLResponseRef,
- const void *clientInfo);
+ WKBundlePageRef,
+ WKBundleFrameRef,
+ uint64_t resourceIdentifier,
+ WKURLRequestRef request,
+ WKURLResponseRef,
+ const void *clientInfo);
static void didFinishLoadForResourceCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- uint64_t resourceIdentifier,
- const void* clientInfo);
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ uint64_t resourceIdentifier,
+ const void* clientInfo);
// WKBundlePageDidStartProvisionalLoadForFrame callback
static void didStartProvisionalLoadForFrameCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef* userData,
- const void *clientInfo);
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef* userData,
+ const void *clientInfo);
// WKBundlePageDidRemoveFrameFromHierarchy callback
static void didRemoveFrameFromHierarchyCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef* userData,
- const void *clientInfo);
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef* userData,
+ const void *clientInfo);
// WKBundlePageLoaderClient callback
static void didCommitLoadForFrameCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKTypeRef*,
- const void *clientInfo);
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKTypeRef*,
+ const void *clientInfo);
// WKBundlePageDecidePolicyForNavigationActionCallback
static WKBundlePagePolicyAction pageDecidePolicyForNavigationActionCallback(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
- WKBundleNavigationActionRef navigationAction,
- WKURLRequestRef request,
- WKTypeRef* userData,
- const void* clientInfo);
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
+ WKBundleNavigationActionRef navigationAction,
+ WKURLRequestRef request,
+ WKTypeRef* userData,
+ const void* clientInfo);
// WKBundlePageDecidePolicyForResponseCallback
static WKBundlePagePolicyAction pageDecidePolicyForResponseCallback(
void didCreatePage(WKBundlePageRef page);
void willDestroyPage(WKBundlePageRef page);
void didReceiveMessage(
- WKStringRef messageName,
- WKTypeRef messageBody);
+ WKStringRef messageName,
+ WKTypeRef messageBody);
// WKBundlePageResourceLoadClient
WKURLRequestRef willSendRequestForFrame(WKURLRequestRef request);
WKBundlePagePolicyAction pageDecidePolicyForNavigationAction(
- WKBundlePageRef page,
- WKBundleFrameRef frame,
+ WKBundlePageRef page,
+ WKBundleFrameRef frame,
WKBundleNavigationActionRef navigationAction,
- WKURLRequestRef request,
+ WKURLRequestRef request,
WKTypeRef* userData);
// basic
std::string DecryptResource(std::string resource, int size);
void fixWKMessageArgs(std::string & argScale,
- std::string & argEncodedBundle, std::string & argTheme);
+ std::string & argEncodedBundle,
+ std::string & argTheme);
void requestSuspend();
void requestResume();
void connectLoaderClientCallbacksToPage(WKBundlePageRef page);
-
-
};
#endif /* WRT_SRC_VIEW_WEBKIT2_WRT_WK2_BUNDLE_H_ */
const char * const CERTIFICATE_CONFIRM_REQUEST_ASK_BODY =
"This site's security certificate is not trusted! Do you acess this site?";
-const wchar_t* BACKGROUND_ENABLED = L"background_enabled" ;
-
+const wchar_t* BACKGROUND_ENABLED = L"background_enabled";
} // anonymous namespace
-std::map<const std::string, const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap =
-{
- {"load,started", &ViewLogic::loadStartedCallback},
- {"load,finished", &ViewLogic::loadFinishedCallback},
- {"title,changed", &ViewLogic::titleChangedCallback},
- {"load,progress", &ViewLogic::loadProgressCallback},
- {"load,progress,finished", &ViewLogic::loadProgressFinishedCallback},
- {"process,crashed", &ViewLogic::processCrashedCallback},
+std::map<const std::string,
+ const Evas_Smart_Cb> ViewLogic::m_ewkCallbacksMap = {
+ { "load,started", &ViewLogic::loadStartedCallback },
+ { "load,finished", &ViewLogic::loadFinishedCallback },
+ { "title,changed", &ViewLogic::titleChangedCallback },
+ { "load,progress", &ViewLogic::loadProgressCallback },
+ { "load,progress,finished", &ViewLogic::loadProgressFinishedCallback },
+ { "process,crashed", &ViewLogic::processCrashedCallback },
// WKPageUIClient
- {"create,window", &ViewLogic::createWindowCallback},
- {"close,window", &ViewLogic::closeWindowCallback},
+ { "create,window", &ViewLogic::createWindowCallback },
+ { "close,window", &ViewLogic::closeWindowCallback },
// WKPagePolicyClient
- {"policy,navigation,decide", &ViewLogic::policyNavigationDecideCallback},
- {"policy,newwindow,decide", &ViewLogic::policyNewWindowDecideCallback},
- {"policy,response,decide", &ViewLogic::pageResponseDecideCallback},
+ { "policy,navigation,decide", &ViewLogic::policyNavigationDecideCallback },
+ { "policy,newwindow,decide", &ViewLogic::policyNewWindowDecideCallback },
+ { "policy,response,decide", &ViewLogic::pageResponseDecideCallback },
// WKPageContextMenuClient
- {"contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback},
+ { "contextmenu,customize", &ViewLogic::contextmenuCustomizeCallback },
// WKPageFormClient
- {"form,submit", &ViewLogic::formSubmitCallback},
+ { "form,submit", &ViewLogic::formSubmitCallback },
// EWK Geolocation Callback
- {"request,geolocation,permission", &ViewLogic::geolocationPermissionRequestCallback},
+ { "request,geolocation,permission",
+ &ViewLogic::geolocationPermissionRequestCallback },
// EWK Notification Callback
- {"notification,show", &ViewLogic::notificationShowCallback},
- {"notification,cancel", &ViewLogic::notificationCancelCallback},
- {"notification,permission,request", &ViewLogic::notificationPermissionRequestCallback},
-
- {"database,quota,exceeded", &ViewLogic::databaseUsagePermissionRequestCallback},
- {"filesystem,permission,request", &ViewLogic::fileSystemPermissionRequestCallback},
- {"fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback},
- {"fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback},
+ { "notification,show", &ViewLogic::notificationShowCallback },
+ { "notification,cancel", &ViewLogic::notificationCancelCallback },
+ { "notification,permission,request",
+ &ViewLogic::notificationPermissionRequestCallback },
+
+ { "database,quota,exceeded",
+ &ViewLogic::databaseUsagePermissionRequestCallback },
+ { "filesystem,permission,request",
+ &ViewLogic::fileSystemPermissionRequestCallback },
+ { "fullscreen,enterfullscreen", &ViewLogic::enterFullscreenCallback },
+ { "fullscreen,exitfullscreen", &ViewLogic::exitFullscreenCallback },
// IME Callback
// when ime start to be showed on the webview,
// this callback will be called
- {"inputmethod,changed", &ViewLogic::imeChangedCallback},
+ { "inputmethod,changed", &ViewLogic::imeChangedCallback },
// this callback will be called
// when ime finishes to be showed on the webview
// "event_info" arg of this callback is always NULL point
// if web content should know size of ime,
// use "inputmethod,changed" instead of this.
//
- {"editorclient,ime,opened", &ViewLogic::imeOpenedCallback},
+ { "editorclient,ime,opened", &ViewLogic::imeOpenedCallback },
// when ime finished to be hidden,
// this callback will be called
- {"editorclient,ime,closed", &ViewLogic::imeClosedCallback},
+ { "editorclient,ime,closed", &ViewLogic::imeClosedCallback },
// EWK Usermedia Callback
- {"usermedia,permission,request", &ViewLogic::usermediaPermissionRequestCallback},
+ { "usermedia,permission,request",
+ &ViewLogic::usermediaPermissionRequestCallback },
// Custom handlers
- {"protocolhandler,registration,requested", &ViewLogic::protocolHandlerRegistrationCallback},
- {"protocolhandler,isregistered", &ViewLogic::protocolHandlerIsRegisteredCallback},
- {"protocolhandler,unregistration,requested", &ViewLogic::protocolHandlerUnregistrationCallback},
- {"contenthandler,registration,requested", &ViewLogic::contentHandlerRegistrationCallback},
- {"contenthandler,isregistered", &ViewLogic::contentHandlerIsRegisteredCallback},
- {"contenthandler,unregistration,requested", &ViewLogic::contentHandlerUnregistrationCallback},
- {"request,certificate,confirm", &ViewLogic::certificateConfirmRequestCallback}
+ { "protocolhandler,registration,requested",
+ &ViewLogic::protocolHandlerRegistrationCallback },
+ { "protocolhandler,isregistered",
+ &ViewLogic::protocolHandlerIsRegisteredCallback },
+ { "protocolhandler,unregistration,requested",
+ &ViewLogic::protocolHandlerUnregistrationCallback },
+ { "contenthandler,registration,requested",
+ &ViewLogic::contentHandlerRegistrationCallback },
+ { "contenthandler,isregistered",
+ &ViewLogic::contentHandlerIsRegisteredCallback },
+ { "contenthandler,unregistration,requested",
+ &ViewLogic::contentHandlerUnregistrationCallback },
+ { "request,certificate,confirm",
+ &ViewLogic::certificateConfirmRequestCallback }
};
-ViewLogic::ViewLogic():
+ViewLogic::ViewLogic() :
m_ewkContext(0),
m_currentEwkView(0),
m_window(NULL),
m_appsSupport(new ViewModule::AppsSupport()),
m_vibrationSupport(new ViewModule::VibrationSupport()),
m_attachedToCustomHandlerDao(false)
-{
-}
+{}
-ViewLogic::~ViewLogic ()
+ViewLogic::~ViewLogic()
{
detachFromCustomHandlersDao();
}
Assert(NULL != m_ewkContext);
Assert(window);
m_window = window;
- if(!createEwkView(evas_object_evas_get(m_window)))
- {
+ if (!createEwkView(evas_object_evas_get(m_window))) {
return false;
}
return true;
if (!m_cbs->suspend.empty()) {
m_cbs->suspend(true);
}
-};
+}
void ViewLogic::resumeWidget()
{
}
}
- /* window system team recomend removing this win_raise code. */
+ /* window system team recomend removing this win_raise code. */
/*
- if (m_window) {
- elm_win_raise(m_window);
- }
- */
+ * if (m_window) {
+ * elm_win_raise(m_window);
+ * }
+ */
evas_object_focus_set(m_currentEwkView, EINA_TRUE);
// call user callback
if (!m_cbs->resume.empty()) {
m_cbs->resume(true);
}
-};
+}
void ViewLogic::resetWidget()
{
// check if current url is service url for this tizen service
std::string requestedUri =
- ViewModule::UriSupport::getUri(m_model, m_startUrl);
+ ViewModule::UriSupport::getUri(m_model, m_startUrl);
DPL::OptionalString servicedUri = ViewModule::UriSupport::localizeURI(
DPL::FromUTF8String(requestedUri.c_str()),
m_model);
ewk_context_proxy_uri_set(newEwkContext, NULL);
} else {
LogInfo("proxy address [" << proxyAddress << "]");
- ewk_context_proxy_uri_set(newEwkContext, proxyAddress);
+ ewk_context_proxy_uri_set(newEwkContext, proxyAddress);
}
if (proxyAddress) {
this);
ewk_context_certificate_file_set(m_ewkContext,
- "/opt/usr/share/certs/ca-certificate.crt");
+ "/opt/usr/share/certs/ca-certificate.crt");
// set to member value
m_ewkContext = newEwkContext;
{
LogInfo("finalizeEwkContext called");
ewk_context_message_from_injected_bundle_callback_set(
- m_ewkContext,
- NULL,
- NULL);
+ m_ewkContext,
+ NULL,
+ NULL);
ewk_context_did_start_download_callback_set(
- m_ewkContext,
- NULL,
- NULL);
+ m_ewkContext,
+ NULL,
+ NULL);
ewk_context_vibration_client_callbacks_set(
- m_ewkContext,
- NULL,
- NULL,
- NULL);
-// ewk_context_delete(m_ewkContext);
-// m_ewkContext = 0;
+ m_ewkContext,
+ NULL,
+ NULL,
+ NULL);
+ // ewk_context_delete(m_ewkContext);
+ // m_ewkContext = 0;
}
void ViewLogic::initializeSupport()
{
// background support
- if( m_model->SettingList.Get().getBackgroundSupport()
- == BackgroundSupport_Enable ) {
+ if (m_model->SettingList.Get().getBackgroundSupport()
+ == BackgroundSupport_Enable)
+ {
LogDebug("Background support enabled, set process active");
pid_t pid = getpid();
sysman_inform_active(pid);
WrtDB::PropertyDAOReadOnly::WidgetPropertyValue bgEnableValue =
dao.getPropertyValue(DPL::String(BACKGROUND_ENABLED));
- if(!bgEnableValue.IsNull() && !bgEnableValue->compare(L"true")) {
+ if (!bgEnableValue.IsNull() && !bgEnableValue->compare(L"true")) {
//skip suspendWidget
LogDebug("Background support enabled, set process active");
pid_t pid = getpid();
ewk_context_memory_saving_mode_set(
m_ewkContext,
static_cast<WrtDB::SettingsType>(result) ==
- WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE);
+ WrtDB::SETTINGS_TYPE_ON ? EINA_TRUE : EINA_FALSE);
m_schemeSupport.reset(new SchemeSupport(m_model->Type.Get().appType));
ViewModule::StorageSupport::initializeStorage(m_model);
m_appsSupport->initialize(m_model);
m_model->SettingList.Get().isEncrypted());
}
-void ViewLogic::ewkClientInit(Evas_Object *wkView) {
+void ViewLogic::ewkClientInit(Evas_Object *wkView)
+{
Assert(NULL != wkView && "ewk_view not created at this point");
FOREACH(it, m_ewkCallbacksMap) {
this);
}
-void ViewLogic::ewkClientDeinit(Evas_Object *wkView) {
+void ViewLogic::ewkClientDeinit(Evas_Object *wkView)
+{
LogDebug("ewkClientDeinit");
Assert(NULL != wkView && "ewk_view not created at this point");
Assert(canvas);
ADD_PROFILING_POINT("ewk_view_add_with_context", "start");
Evas_Object* newEwkView = ewk_view_add_with_context(
- canvas,
- m_ewkContext);
+ canvas,
+ m_ewkContext);
ADD_PROFILING_POINT("ewk_view_add_with_context", "stop");
if (!newEwkView) {
LogError("View creation failed");
Wrt::Popup::PopupInvoker().showInfo(
- "Info", "View creation failed","close");
+ "Info", "View creation failed", "close");
return false;
}
ewkCookieManager =
ewk_context_cookie_manager_get(m_ewkContext);
ewk_cookie_manager_accept_policy_set(ewkCookieManager,
- EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
+ EWK_COOKIE_ACCEPT_POLICY_ALWAYS);
LogInfo("push webview: " << newEwkView);
m_ewkViewList.push_back(newEwkView);
// The followings are not implemeted yet by webkit2
// ewk_view_setting_accelerated_compositing_enable_set(EINA_TRUE);
// ewk_view_mode_set();
- // ewk_view_setting_enable_specified_plugin_set(EINA_TRUE, FLASH_MIME_TYPE);
+ // ewk_view_setting_enable_specified_plugin_set(EINA_TRUE,
+ // FLASH_MIME_TYPE);
// ewk_view_setting_html5video_external_player_enable_set(EINA_FALSE);
// ewk_view_show_ime_on_autofocus_set(EINA_TRUE);
// elm_webview_show_magnifier_set(EINA_FALSE);
}
void ViewLogic::contextMessageFromInjectedBundleCallback(
- const char* name,
- const char* body,
- char** returnData,
- void* clientInfo)
+ const char* name,
+ const char* body,
+ char** returnData,
+ void* clientInfo)
{
LogDebug("contextMessageFromInjectedBundleCallback called");
Assert(clientInfo);
}
void ViewLogic::didStartDownloadCallback(
- const char* downloadUrl,
- void* data)
+ const char* downloadUrl,
+ void* data)
{
LogDebug("didStartDownloadCallback called");
Assert(data);
}
void ViewLogic::loadStartedCallback(
- void* data,
- Evas_Object* obj,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
{
LogDebug("loadStartedCallback called");
Assert(data);
if (!This->m_cbs->loadStart.empty()) {
This->m_cbs->loadStart(obj);
}
-
}
void ViewLogic::loadFinishedCallback(
- void* data,
- Evas_Object* obj,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
{
LogDebug("loadFinishedCallback called");
Assert(data);
} else {
std::string jsStr = DPL::ToUTF8String(*jsOptionalString).c_str();
- if(EINA_FALSE == ewk_view_script_execute(
- This->m_currentEwkView,
- jsStr.c_str(),
- didRunJavaScriptCallback,
- This))
+ if (EINA_FALSE == ewk_view_script_execute(
+ This->m_currentEwkView,
+ jsStr.c_str(),
+ didRunJavaScriptCallback,
+ This))
{
LogError("JS for auto fill data failed.");
}
}
void ViewLogic::titleChangedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("titleChangedCallback called");
Assert(data);
}
void ViewLogic::loadProgressCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* /*data*/,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
double* progress = static_cast<double*>(eventInfo);
LogDebug("didChangeProgressCallback progress = " << *progress);
}
void ViewLogic::loadProgressFinishedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogDebug("didFinishProgressCallback");
Assert(data);
}
void ViewLogic::processCrashedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogInfo("processCrashedCallback");
Assert(data);
ViewLogic const * const view =
- static_cast<ViewLogic const * const>(data);
+ static_cast<ViewLogic const * const>(data);
if (!view->m_cbs->webCrash.empty()) {
view->m_cbs->webCrash();
}
}
void ViewLogic::createWindowCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo)
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo)
{
LogDebug("createWindowCallback");
Assert(data);
}
void ViewLogic::closeWindowCallback(
- void* data,
- Evas_Object* obj,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* obj,
+ void* /*eventInfo*/)
{
LogDebug("closeWindowCallback");
ViewLogic* This = static_cast<ViewLogic*>(data);
}
void ViewLogic::policyNavigationDecideCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("policyNavigationDecideCallback called");
Assert(data);
} else {
// check whether this is new empty window
const char* activeUrl = ewk_view_url_get(This->m_currentEwkView);
- if(!activeUrl || 0 == strlen(activeUrl)) {
+ if (!activeUrl || 0 == strlen(activeUrl)) {
/*
* The view is empty and scheme has been handled externally. When
* user gets back from the external application he'd see blank page
}
void ViewLogic::policyNewWindowDecideCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("policyNewWindowDecideCallback called");
Assert(data);
}
void ViewLogic::pageResponseDecideCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("pageResponseDecideCallback called");
Assert(data);
ewk_policy_decision_suspend(policyDecision);
// get uri information
- const char* url = ewk_policy_decision_url_get(policyDecision);
+ const char* url = ewk_policy_decision_url_get(policyDecision);
if (NULL == url || strlen(url) == 0) {
LogDebug("url data is empty");
ewk_policy_decision_use(policyDecision);
}
void ViewLogic::contextmenuCustomizeCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("contextmenuCustomizeCallback called");
Assert(data);
Ewk_Context_Menu* menu = static_cast<Ewk_Context_Menu*>(eventInfo);
if ((This->m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) &&
(This->m_model->SettingList.Get().getContextMenu()
- == ContextMenu_Disable))
+ == ContextMenu_Disable))
{
LogDebug("ContextMenu Disable!!");
for (unsigned int idx = 0; idx < ewk_context_menu_item_count(menu);) {
- Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu, idx);
+ Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu,
+ idx);
Assert(item);
ewk_context_menu_item_remove(menu, item);
}
int menu_num = ewk_context_menu_item_count(menu);
unsigned int idx = 0;
do {
- Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu, idx);
+ Ewk_Context_Menu_Item* item = ewk_context_menu_nth_item_get(menu,
+ idx);
if (!item) {
idx++;
continue;
Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item);
switch (tag) {
- case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
- ewk_context_menu_item_remove(menu, item);
- continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
- case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
- ewk_context_menu_item_remove(menu, item);
- continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
- case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW:
- ewk_context_menu_item_remove(menu, item);
- continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_FRAME_IN_NEW_WINDOW:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
- case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_MEDIA_IN_NEW_WINDOW:
- ewk_context_menu_item_remove(menu, item);
- continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_OPEN_MEDIA_IN_NEW_WINDOW:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
- case EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB:
- ewk_context_menu_item_remove(menu, item);
- continue;
+ case EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB:
+ ewk_context_menu_item_remove(menu, item);
+ continue;
- default:
- idx++;
- break;
+ default:
+ idx++;
+ break;
}
} while (idx < menu_num);
}
}
void ViewLogic::formSubmitCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* /*data*/,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("formSubmitCallback called");
Assert(eventInfo);
}
void ViewLogic::geolocationPermissionRequestCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
Assert(eventInfo);
Ewk_Geolocation_Permission_Data* permissionRequest =
- static_cast<Ewk_Geolocation_Permission_Data*>(eventInfo);
+ static_cast<Ewk_Geolocation_Permission_Data*>(eventInfo);
if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_GEOLOCATION)
+ SecurityOriginDB::FEATURE_GEOLOCATION)
== WrtDB::SETTINGS_TYPE_OFF)
{
ewk_geolocation_permission_request_allow_set(
}
void ViewLogic::notificationShowCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("notificationShowCallback called");
Assert(data);
using namespace ViewModule::WebNotification;
WebNotificationDataPtr notiData(
- new WebNotificationData(
- This->m_model,
- ewk_notification_id_get(noti)));
+ new WebNotificationData(
+ This->m_model,
+ ewk_notification_id_get(noti)));
DPL::OptionalString string =
DPL::FromUTF8String(ewk_notification_icon_url_get(noti));
}
void ViewLogic::notificationCancelCallback(
- void* /*data*/,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* /*data*/,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogDebug("notificationCancelCallback called");
}
void ViewLogic::notificationPermissionRequestCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("notificationPermissionRequestCallback called");
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_WEB_NOTIFICATION)
+ SecurityOriginDB::FEATURE_WEB_NOTIFICATION)
== WrtDB::SETTINGS_TYPE_OFF)
{
Ewk_Notification_Permission_Request* request =
// EWK Orientation Callback
Eina_Bool ViewLogic::orientationLockCallback(
- Evas_Object* obj,
- Eina_Bool /*needLock*/,
- int orientation,
- void* data)
+ Evas_Object* obj,
+ Eina_Bool /*needLock*/,
+ int orientation,
+ void* data)
{
LogDebug("orientationLockCallback called");
Assert(data);
LogDebug("orientation is portrait-primary");
elm_win_rotation_with_resize_set(This->m_window, 0);
ewk_view_orientation_send(obj, 0);
- } else if(orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
+ } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) {
LogDebug("orientation is landscape-primary");
elm_win_rotation_with_resize_set(This->m_window, 270);
ewk_view_orientation_send(obj, 90);
- } else if(orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
+ } else if (orientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) {
LogDebug("orientation is portrait-secondary");
elm_win_rotation_with_resize_set(This->m_window, 180);
ewk_view_orientation_send(obj, 180);
- } else if(orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
+ } else if (orientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) {
LogDebug("orientation is landscape-secondary");
elm_win_rotation_with_resize_set(This->m_window, 90);
ewk_view_orientation_send(obj, -90);
return EINA_TRUE;
}
-
// Fullscreen API callbacks
void ViewLogic::enterFullscreenCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogInfo("enterFullscreenCallback called");
Assert(data);
}
}
void ViewLogic::exitFullscreenCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogInfo("exitFullscreenCallback called");
Assert(data);
}
void ViewLogic::imeChangedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("enter");
Assert(data);
}
void ViewLogic::imeOpenedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogDebug("enter");
Assert(data);
args.width = This->m_imeWidth;
args.height = This->m_imeHeight;
This->fireJavascriptEvent(
- static_cast<int>(SoftKeyboardChangeCustomEvent),
- &args);
+ static_cast<int>(SoftKeyboardChangeCustomEvent),
+ &args);
}
void ViewLogic::imeClosedCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* /*eventInfo*/)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* /*eventInfo*/)
{
LogDebug("enter");
Assert(data);
args.state = IME_STATE_OFF;
This->fireJavascriptEvent(
- static_cast<int>(SoftKeyboardChangeCustomEvent),
- &args);
+ static_cast<int>(SoftKeyboardChangeCustomEvent),
+ &args);
}
void ViewLogic::usermediaPermissionRequestCallback(
- void* data,
- Evas_Object* /*obj*/,
- void* eventInfo)
+ void* data,
+ Evas_Object* /*obj*/,
+ void* eventInfo)
{
LogDebug("usermediaPermissionRequestCallback called");
Assert(data);
eventInfo);
}
-
// helper method
CustomHandlerDB::CustomHandlerPtr getCustomHandlerFromData(void* data)
{
Assert(data);
Ewk_Custom_Handlers_Data* handler =
- static_cast<Ewk_Custom_Handlers_Data*>(data);
- CustomHandlerDB::CustomHandlerPtr customHandler(new CustomHandlerDB::CustomHandler());
+ static_cast<Ewk_Custom_Handlers_Data*>(data);
+ CustomHandlerDB::CustomHandlerPtr customHandler(
+ new CustomHandlerDB::CustomHandler());
const char* base_url = ewk_custom_handlers_data_base_url_get(handler);
if (base_url) {
LogDebug("base url: " << base_url);
* @param customHandler
*/
void saveUserResponse(Wrt::Popup::PopupResponse response,
- CustomHandlerDB::CustomHandlerPtr customHandler)
+ CustomHandlerDB::CustomHandlerPtr customHandler)
{
switch (response) {
- case Wrt::Popup::YES_DO_REMEMBER:
- LogDebug("User allowed, remember");
- customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
- (CustomHandlerDB::Agreed | CustomHandlerDB::DecisionSaved);
- break;
- case Wrt::Popup::YES_DONT_REMEMBER:
- LogDebug("User allowed, don't remember");
- customHandler->user_decision = CustomHandlerDB::Agreed;
- break;
- case Wrt::Popup::NO_DO_REMEMBER:
- LogDebug("User didn't allow, remember");
- customHandler->user_decision = static_cast<CustomHandlerDB::HandlerState>
- (CustomHandlerDB::Declined | CustomHandlerDB::DecisionSaved);
- break;
- case Wrt::Popup::NO_DONT_REMEMBER:
- LogDebug("User didn't allow, don't remember");
- customHandler->user_decision = CustomHandlerDB::Declined;
- break;
+ case Wrt::Popup::YES_DO_REMEMBER:
+ LogDebug("User allowed, remember");
+ customHandler->user_decision =
+ static_cast<CustomHandlerDB::HandlerState>
+ (CustomHandlerDB::Agreed | CustomHandlerDB::DecisionSaved);
+ break;
+ case Wrt::Popup::YES_DONT_REMEMBER:
+ LogDebug("User allowed, don't remember");
+ customHandler->user_decision = CustomHandlerDB::Agreed;
+ break;
+ case Wrt::Popup::NO_DO_REMEMBER:
+ LogDebug("User didn't allow, remember");
+ customHandler->user_decision =
+ static_cast<CustomHandlerDB::HandlerState>
+ (CustomHandlerDB::Declined | CustomHandlerDB::DecisionSaved);
+ break;
+ case Wrt::Popup::NO_DONT_REMEMBER:
+ LogDebug("User didn't allow, don't remember");
+ customHandler->user_decision = CustomHandlerDB::Declined;
+ break;
}
}
Assert(data);
LogDebug("enter");
CustomHandlerDB::CustomHandlerPtr customHandler =
- getCustomHandlerFromData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
std::string scheme = DPL::ToUTF8String(customHandler->target);
if (scheme.empty()) {
bool matched = false;
//scheme on whiteList
for (int i = 0; i < protocolWhiteListLenth; ++i) {
- if (0 == strcmp(protocolWhiteList[i], scheme.c_str()))
- {
+ if (0 == strcmp(protocolWhiteList[i], scheme.c_str())) {
LogDebug("Match found, protocol can be handled");
matched = true;
}
}
int l = 4;
char c = scheme[l];
- while (c != '\0')
- {
+ while (c != '\0') {
if (c < 'a' || c > 'z') {
LogWarning("Wrong char inside scheme. "
<< "Only lowercase ASCII letters accepted");
This->attachToCustomHandlersDao();
CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getProtocolHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
+ handlersDao.getProtocolHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
if (handler && (handler->user_decision & CustomHandlerDB::DecisionSaved)) {
LogDebug("Protocol already registered - nothing to do");
} else {
LogDebug("Protocol handler not found");
Wrt::Popup::PopupResponse response =
- GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
- Wrt::Popup::PopupInvoker().askYesNoCheckbox(
- PROTOCOL_HANDLER_ASK_TITLE,
- PROTOCOL_HANDLER_ASK_MSG,
- PROTOCOL_HANDLER_ASK_REMEMBER);
+ GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::
+ YES_DO_REMEMBER :
+ Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+ PROTOCOL_HANDLER_ASK_TITLE,
+ PROTOCOL_HANDLER_ASK_MSG,
+ PROTOCOL_HANDLER_ASK_REMEMBER);
saveUserResponse(response, customHandler);
- if (customHandler->user_decision == CustomHandlerDB::Declined)
+ if (customHandler->user_decision == CustomHandlerDB::Declined) {
return;
+ }
handlersDao.registerProtocolHandler(*(customHandler.get()));
if (customHandler->user_decision & CustomHandlerDB::Agreed) {
//TODO remove old default handler somehow from appsvc
LogDebug("Registering appservice entry");
int ret = appsvc_set_defapp(APPSVC_OPERATION_VIEW,
- NULL,
- DPL::ToUTF8String(customHandler->target).c_str(),
- DPL::ToUTF8String(This->m_model->TizenId).c_str());
- if (APPSVC_RET_OK != ret)
- {
+ NULL,
+ DPL::ToUTF8String(
+ customHandler->target).c_str(),
+ DPL::ToUTF8String(This->m_model->
+ TizenId).c_str());
+ if (APPSVC_RET_OK != ret) {
LogWarning("Appsvc entry failed: " << ret);
}
}
void* eventInfo)
{
LogDebug("enter");
- CustomHandlerDB::CustomHandlerPtr customHandler = getCustomHandlerFromData(eventInfo);
+ CustomHandlerDB::CustomHandlerPtr customHandler = getCustomHandlerFromData(
+ eventInfo);
ViewLogic* This = static_cast<ViewLogic*>(data);
LogDebug("Creating handlers dao");
This->attachToCustomHandlersDao();
CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
- CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getProtocolHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getProtocolHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
if (handler) {
- if (handler->user_decision & CustomHandlerDB::Agreed)
+ if (handler->user_decision & CustomHandlerDB::Agreed) {
ewk_custom_handlers_data_result_set(
static_cast<Ewk_Custom_Handlers_Data*>(data),
EWK_CUSTOM_HANDLERS_REGISTERED);
- else
+ } else {
ewk_custom_handlers_data_result_set(
static_cast<Ewk_Custom_Handlers_Data*>(data),
EWK_CUSTOM_HANDLERS_DECLINED);
- } else
- ewk_custom_handlers_data_result_set(
- static_cast<Ewk_Custom_Handlers_Data*>(data),
- EWK_CUSTOM_HANDLERS_NEW);
+ }
+ } else {
+ ewk_custom_handlers_data_result_set(
+ static_cast<Ewk_Custom_Handlers_Data*>(data),
+ EWK_CUSTOM_HANDLERS_NEW);
+ }
This->detachFromCustomHandlersDao();
}
{
LogDebug("enter");
CustomHandlerDB::CustomHandlerPtr customHandler =
- getCustomHandlerFromData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
ViewLogic* This = static_cast<ViewLogic*>(data);
LogDebug("Creating handlers dao");
This->attachToCustomHandlersDao();
customHandler->url,
customHandler->base_url);
if (handlerCheck) {
- if (handlerCheck->user_decision & CustomHandlerDB::Agreed)
+ if (handlerCheck->user_decision & CustomHandlerDB::Agreed) {
appsvc_unset_defapp(DPL::ToUTF8String(This->m_model->TizenId).c_str());
+ }
handlersDao.unregisterProtocolHandler(customHandler->target,
customHandler->url,
customHandler->base_url);
- } else
+ } else {
LogDebug("Nothing to unregister");
+ }
This->detachFromCustomHandlersDao();
}
Assert(data);
LogDebug("enter");
CustomHandlerDB::CustomHandlerPtr customHandler =
- getCustomHandlerFromData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
std::string mimeType = DPL::ToUTF8String(customHandler->target);
if (mimeType.empty()) {
LogError("No mimeType provided.");
return;
}
- for (int i = 0; i < contentBlackListLenth; ++i)
- {
- if (0 == strcmp(contentBlackList[i], mimeType.c_str()))
- {
+ for (int i = 0; i < contentBlackListLenth; ++i) {
+ if (0 == strcmp(contentBlackList[i], mimeType.c_str())) {
LogWarning("mimeType blacklisted");
//throw SecurityException
return;
LogDebug("Creating handlers dao");
This->attachToCustomHandlersDao();
CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
- CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getContentHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getContentHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
if (handler && (handler->user_decision & CustomHandlerDB::DecisionSaved)) {
LogDebug("Protocol already registered - nothing to do");
} else {
LogDebug("Protocol handler not found");
Wrt::Popup::PopupResponse response =
- GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::YES_DO_REMEMBER :
- Wrt::Popup::PopupInvoker().askYesNoCheckbox(
- CONTENT_HANDLER_ASK_TITLE,
- CONTENT_HANDLER_ASK_MSG,
- CONTENT_HANDLER_AKS_REMEMBER);
+ GlobalSettings::PopupsTestModeEnabled() ? Wrt::Popup::
+ YES_DO_REMEMBER :
+ Wrt::Popup::PopupInvoker().askYesNoCheckbox(
+ CONTENT_HANDLER_ASK_TITLE,
+ CONTENT_HANDLER_ASK_MSG,
+ CONTENT_HANDLER_AKS_REMEMBER);
saveUserResponse(response, customHandler);
- if (customHandler->user_decision == CustomHandlerDB::Declined)
+ if (customHandler->user_decision == CustomHandlerDB::Declined) {
return;
+ }
handlersDao.registerContentHandler(*(customHandler.get()));
if (customHandler->user_decision & CustomHandlerDB::Agreed) {
//TODO remove old default handler somehow from appsvc
LogDebug("Registering appservice entry");
int ret = appsvc_set_defapp(APPSVC_OPERATION_VIEW,
- DPL::ToUTF8String(customHandler->target).c_str(),
- NULL,
- DPL::ToUTF8String(This->m_model->TizenId).c_str());
- if (APPSVC_RET_OK != ret)
- {
+ DPL::ToUTF8String(
+ customHandler->target).c_str(),
+ NULL,
+ DPL::ToUTF8String(This->m_model->
+ TizenId).c_str());
+ if (APPSVC_RET_OK != ret) {
LogWarning("Appsvc entry failed: " << ret);
}
}
This->attachToCustomHandlersDao();
CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
- CustomHandlerDB::CustomHandlerPtr handler =
- handlersDao.getContentHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
+ CustomHandlerDB::CustomHandlerPtr handler =
+ handlersDao.getContentHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
if (handler) {
- if (handler->user_decision & CustomHandlerDB::Agreed)
+ if (handler->user_decision & CustomHandlerDB::Agreed) {
ewk_custom_handlers_data_result_set(
static_cast<Ewk_Custom_Handlers_Data*>(data),
EWK_CUSTOM_HANDLERS_REGISTERED);
- else
+ } else {
ewk_custom_handlers_data_result_set(
static_cast<Ewk_Custom_Handlers_Data*>(data),
EWK_CUSTOM_HANDLERS_DECLINED);
- } else
- ewk_custom_handlers_data_result_set(
- static_cast<Ewk_Custom_Handlers_Data*>(data),
- EWK_CUSTOM_HANDLERS_NEW);
+ }
+ } else {
+ ewk_custom_handlers_data_result_set(
+ static_cast<Ewk_Custom_Handlers_Data*>(data),
+ EWK_CUSTOM_HANDLERS_NEW);
+ }
This->detachFromCustomHandlersDao();
}
{
LogDebug("enter");
CustomHandlerDB::CustomHandlerPtr customHandler =
- getCustomHandlerFromData(eventInfo);
+ getCustomHandlerFromData(eventInfo);
ViewLogic* This = static_cast<ViewLogic*>(data);
LogDebug("Creating handlers dao");
This->attachToCustomHandlersDao();
CustomHandlerDB::CustomHandlerDAO handlersDao(This->m_model->TizenId);
- CustomHandlerDB::CustomHandlerPtr handlerCheck =
- handlersDao.getContentHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
- if (handlerCheck) {
- if (handlerCheck->user_decision & CustomHandlerDB::Agreed)
- appsvc_unset_defapp(DPL::ToUTF8String(This->m_model->TizenId).c_str());
-
- handlersDao.unregisterContentHandler(customHandler->target,
- customHandler->url,
- customHandler->base_url);
- } else
- LogDebug("Nothing to unregister");
+ CustomHandlerDB::CustomHandlerPtr handlerCheck =
+ handlersDao.getContentHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
+ if (handlerCheck) {
+ if (handlerCheck->user_decision & CustomHandlerDB::Agreed) {
+ appsvc_unset_defapp(DPL::ToUTF8String(This->m_model->TizenId).c_str());
+ }
+
+ handlersDao.unregisterContentHandler(customHandler->target,
+ customHandler->url,
+ customHandler->base_url);
+ } else {
+ LogDebug("Nothing to unregister");
+ }
This->detachFromCustomHandlersDao();
}
void ViewLogic::didRunJavaScriptCallback(
- Evas_Object* /*obj*/,
- const char* result,
- void* /*userData*/)
+ Evas_Object* /*obj*/,
+ const char* result,
+ void* /*userData*/)
{
LogInfo("didRunJavaScriptCallback called");
LogInfo("result = " << result);
Assert(eventInfo);
if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_WEB_DATABASE)
+ SecurityOriginDB::FEATURE_WEB_DATABASE)
== WrtDB::SETTINGS_TYPE_OFF)
{
// default value is deny
This->m_securityOriginSupport->getSecurityOriginDAO(),
eventInfo);
return;
- }
+}
void ViewLogic::fileSystemPermissionRequestCallback(
void* data,
ViewLogic* This = static_cast<ViewLogic*>(data);
if (This->m_securityOriginSupport->isNeedPermissionCheck(
- SecurityOriginDB::FEATURE_FILE_SYSTEM_ACCESS)
+ SecurityOriginDB::FEATURE_FILE_SYSTEM_ACCESS)
== WrtDB::SETTINGS_TYPE_OFF)
{
Ewk_Context_File_System_Permission* fileSystemPermission =
- static_cast<Ewk_Context_File_System_Permission*>(eventInfo);
+ static_cast<Ewk_Context_File_System_Permission*>(eventInfo);
ewk_context_file_system_permission_allow_set(fileSystemPermission,
EINA_FALSE);
return;
Assert(data);
ViewLogic* This = static_cast<ViewLogic*>(data);
Assert(eventInfo);
- Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
+ Ewk_Certificate_Policy_Decision* certificatePolicyDecision =
static_cast<Ewk_Certificate_Policy_Decision*>(eventInfo);
bool status = This->askUserForCertificateConfirm();
- if(!status) {
+ if (!status) {
ewk_certificate_policy_decision_allowed_set(
certificatePolicyDecision,
EINA_FALSE);
- }
- else {
+ } else {
ewk_certificate_policy_decision_allowed_set(
certificatePolicyDecision,
EINA_TRUE);
bool ViewLogic::askUserForCertificateConfirm()
{
return Wrt::Popup::PopupInvoker().askYesNo(
- CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE,
- CERTIFICATE_CONFIRM_REQUEST_ASK_BODY);
+ CERTIFICATE_CONFIRM_REQUEST_ASK_TITLE,
+ CERTIFICATE_CONFIRM_REQUEST_ASK_BODY);
}
void ViewLogic::didRecieveMessageFromInjectedBundle(
- const char* name,
- const char* /*body*/)
+ const char* name,
+ const char* /*body*/)
{
LogDebug("did recive message " << name);
}
void ViewLogic::didReceiveSynchronousMessage(
- const char* name,
- const char* body,
- char** returnData)
+ const char* name,
+ const char* body,
+ char** returnData)
{
LogDebug("didReceiveSynchronousMessage called");
Assert(name);
} else if (!strcmp(name, uriChangedMessageName)) {
LogDebug("received : " << uriChangedMessageName);
std::string ret = requestUriChanged(DPL::FromUTF8String(body));
- *returnData = strdup(ret.c_str());
+ *returnData = strdup(ret.c_str());
}
}
// If url is same to URICHANGE_BLOCKED_URL,
// this url has been already blocked by willsend.
// So current page should be moved to previous page
- if (url == URICHANGE_BLOCKED_URL)
- {
- if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP)
- {
+ if (url == URICHANGE_BLOCKED_URL) {
+ if (m_model->Type.Get().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
// block this page and open it in browser
LogDebug("Request was blocked by WARP: " << url.c_str());
if (!m_blockedUri.empty()) {
// resume ewkView
/* In case we support many pages in parallel
- then view is not suspended*/
+ * then view is not suspended*/
//resumeEwkView(m_currentEwkView);
// show ewkView
// message from injected bundle Callback
static void contextMessageFromInjectedBundleCallback(
- const char* name,
- const char* body,
- char** returnData,
- void* userData);
+ const char* name,
+ const char* body,
+ char** returnData,
+ void* userData);
// EWK Context Callback
static void didStartDownloadCallback(
- const char* downloadUrl,
- void* data);
+ const char* downloadUrl,
+ void* data);
// WKPageLoaderClient
static void loadStartedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void loadFinishedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void titleChangedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void loadProgressCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void loadProgressFinishedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void processCrashedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK Callback
static void createWindowCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void closeWindowCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK PolicyDecide Callback
static void policyNavigationDecideCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void policyNewWindowDecideCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void pageResponseDecideCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK ContextMenu Callback
static void contextmenuCustomizeCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK FormClient Callback
static void formSubmitCallback(
- void *data,
- Evas_Object *obj,
- void *eventInfo);
+ void *data,
+ Evas_Object *obj,
+ void *eventInfo);
// EWK Geolocation Callback
static void geolocationPermissionRequestCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK Notification Callback
static void notificationShowCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void notificationCancelCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void notificationPermissionRequestCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK Vibration Callback
static void vibrationVibrateCallback(uint64_t time, void* data);
// EWK Orientation Callback
static Eina_Bool orientationLockCallback(
- Evas_Object* obj,
- Eina_Bool needLock,
- int orientation,
- void* data);
+ Evas_Object* obj,
+ Eina_Bool needLock,
+ int orientation,
+ void* data);
// EWK Fullscreen API callbacks
static void enterFullscreenCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void exitFullscreenCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK IME Change/Show/Hide Callback
static void imeChangedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void imeOpenedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
static void imeClosedCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// EWK Usermedia Callback
static void usermediaPermissionRequestCallback(
- void* data,
- Evas_Object* obj,
- void* eventInfo);
+ void* data,
+ Evas_Object* obj,
+ void* eventInfo);
// custom content/scheme handlers
static void protocolHandlerRegistrationCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
static void protocolHandlerIsRegisteredCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
static void protocolHandlerUnregistrationCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
static void contentHandlerRegistrationCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
static void contentHandlerIsRegisteredCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
static void contentHandlerUnregistrationCallback(void* data,
- Evas_Object* obj,
- void* eventInfo);
+ Evas_Object* obj,
+ void* eventInfo);
// database usage permission request callback
static void databaseUsagePermissionRequestCallback(
// JS execute callback
static void didRunJavaScriptCallback(
- Evas_Object* obj,
- const char* result,
- void* userData);
+ Evas_Object* obj,
+ const char* result,
+ void* userData);
// idler callback
static Eina_Bool windowCloseIdlerCallback(void *data);
//bundle
void didRecieveMessageFromInjectedBundle(
- const char* name,
- const char* body);
+ const char* name,
+ const char* body);
void didReceiveSynchronousMessage(
- const char* name,
- const char* body,
- char** returnData);
+ const char* name,
+ const char* body,
+ char** returnData);
// security
void rememberBlockedURI(const DPL::String& str);
#include <Elementary.h>
namespace ViewModule {
-
using namespace SecurityOriginDB;
using namespace ViewModule::SecurityOriginSupportUtil;
Assert(data);
PermissionData* permData = static_cast<PermissionData*>(data);
Ewk_Context_File_System_Permission* fileSystemPermission =
- static_cast<Ewk_Context_File_System_Permission*>(permData->m_data);
+ static_cast<Ewk_Context_File_System_Permission*>(permData->m_data);
Evas_Object* popup = getPopup(obj);
Result result = getResult(obj);
if (result != RESULT_UNKNOWN) {
- permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+ permData->m_originDao->setSecurityOriginData(permData->m_originData,
+ result);
}
Eina_Bool ret =
(result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
- EINA_TRUE : EINA_FALSE;
+ EINA_TRUE : EINA_FALSE;
ewk_context_file_system_permission_allow_set(fileSystemPermission,
ret);
delete permData;
static_cast<Ewk_Context_File_System_Permission*>(data);
Ewk_Security_Origin* ewkOrigin =
ewk_context_file_system_permission_origin_get(
- fileSystemPermission);
+ fileSystemPermission);
Assert(ewkOrigin);
SecurityOriginData securityOriginData(
#include <Elementary.h>
namespace SecurityOriginDB {
- class SecurityOriginDAO;
+class SecurityOriginDAO;
}
namespace ViewModule {
namespace FileSystemSupport {
-
void fileSystemPermissionRequest(
- Evas_Object* window,
- SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
- void* data);
-
+ Evas_Object* window,
+ SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+ void* data);
} // namespace FileSystemSupport
} // namespace ViewModule
namespace ViewModule {
namespace GeolocationSupport {
namespace Webkit2 {
-
using namespace SecurityOriginDB;
using namespace ViewModule::SecurityOriginSupportUtil;
Assert(data);
PermissionData* permData = static_cast<PermissionData*>(data);
Ewk_Geolocation_Permission_Data* permissionRequest =
- static_cast<Ewk_Geolocation_Permission_Data*>(permData->m_data);
+ static_cast<Ewk_Geolocation_Permission_Data*>(permData->m_data);
Evas_Object* popup = getPopup(obj);
Result result = getResult(obj);
if (result != RESULT_UNKNOWN) {
- permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+ permData->m_originDao->setSecurityOriginData(permData->m_originData,
+ result);
}
Eina_Bool ret =
(result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
- EINA_TRUE : EINA_FALSE;
+ EINA_TRUE : EINA_FALSE;
ewk_geolocation_permission_request_allow_set(
- ewk_geolocation_permission_request_get(permissionRequest),
- ret);
+ ewk_geolocation_permission_request_get(permissionRequest),
+ ret);
delete permData;
evas_object_hide(popup);
evas_object_del(popup);
} // namespace
void geolocationPermissionRequest(
- Evas_Object* window,
- SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
- void* data)
+ Evas_Object* window,
+ SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+ void* data)
{
LogDebug("geolocationPermissionRequest called");
Assert(securityOriginDAO);
return;
}
}
-
} // namespace GeolocationSupport
} // namespace ViewModule
#include <Elementary.h>
namespace SecurityOriginDB {
- class SecurityOriginDAO;
+class SecurityOriginDAO;
}
namespace ViewModule {
namespace GeolocationSupport {
namespace Webkit2 {
-
void geolocationPermissionRequest(
- Evas_Object* window,
- SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
- void* data);
-
+ Evas_Object* window,
+ SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+ void* data);
}
} // namespace GeolocationSupport
} // namespace ViewModule
// webapp termination
ewk_shutdown();
elm_exit();
- return ECORE_CALLBACK_CANCEL;}
-
+ return ECORE_CALLBACK_CANCEL;
+}
} // namespace
bool SchemeSupport::HandleUri(
- const char* uri,
- ViewModule::SchemeActionMap::NavigationContext context)
+ const char* uri,
+ ViewModule::SchemeActionMap::NavigationContext context)
{
return ViewModule::SchemeActionMap::HandleUri(uri,
context,
ewk_frame_is_main_frame(ewk_policy_decision_frame_get(policyDecision));
using namespace ViewModule::SchemeActionMap;
- if (HandleTizenScheme(url, window, wkView))
- {
+ if (HandleTizenScheme(url, window, wkView)) {
LogDebug("Scheme is tizen scheme");
return false;
}
class WindowData;
class WidgetModel;
-class SchemeSupport {
+class SchemeSupport
+{
public:
explicit SchemeSupport(WrtDB::AppType type) : m_type(type) {}
bool HandleTizenScheme(const char* uri,
WidgetModel* model,
Evas_Object* window,
Evas_Object* wkView);
+
private:
WrtDB::AppType m_type;
};
#include <EWebKit2.h>
namespace ViewModule {
-
namespace {
const char* const USERMEDIA_USE_ASK_BODY =
"This application wants to use your media";
} // namespace
void UsermediaSupport::usermediaPermissionRequest(Evas_Object* window,
- void* data)
+ void* data)
{
LogDebug("usermediaPermissionRequest called");
Assert(window);
namespace ViewModule {
namespace UsermediaSupport {
-
void usermediaPermissionRequest(
- Evas_Object* window,
- void* data);
-
+ Evas_Object* window,
+ void* data);
} // namespace UsermediaSupport
} // namespace ViewModule
namespace ViewModule {
namespace Utils {
-
DPL::OptionalString toString(WKStringRef str)
{
if (WKStringIsEmpty(str)) {
WKRelease(desc);
return str;
}
-
} // namespace Utils
} // namespace ViewModule
namespace ViewModule {
namespace Utils {
-
DPL::OptionalString toString(WKStringRef str);
DPL::OptionalString toString(WKURLRef url);
DPL::OptionalString toString(WKURLRequestRef req);
DPL::OptionalString toString(WKFrameRef req);
DPL::OptionalString toString(WKErrorRef err);
-
} // namespace Utils
} // namespace ViewModule
const char* const WEB_NOTIFICATION_ASK_BODY_POSTFIX =
" to use web notificaion?";
const char* const WEB_NOTIFICATION_ASK_CHECK = "Don't ask again";
-
}
namespace ViewModule {
namespace WebNotification {
-
using namespace SecurityOriginDB;
using namespace ViewModule::SecurityOriginSupportUtil;
-class WebNotificationPermissionData
- : public ViewModule::SecurityOriginSupportUtil::PermissionData
+class WebNotificationPermissionData :
+ public ViewModule::SecurityOriginSupportUtil::PermissionData
{
public:
Ewk_Context* m_ewkContext;
SecurityOriginDB::SecurityOriginData originData,
Ewk_Context* ewkContext,
void* data) :
- ViewModule::SecurityOriginSupportUtil::PermissionData(
- originDao,
- originData,
- data),
- m_ewkContext(ewkContext)
- {
- };
+ ViewModule::SecurityOriginSupportUtil::PermissionData(
+ originDao,
+ originData,
+ data),
+ m_ewkContext(ewkContext)
+ {}
};
bool notificationShow(WebNotificationDataPtr notiData);
}
WebNotificationData::~WebNotificationData()
-{
-}
+{}
void webNotificationPermissionRequest(
Evas_Object* window,
// ask to user
WebNotificationPermissionData* permissionData =
new WebNotificationPermissionData(securityOriginDAO,
- securityOriginData,
- ewkContext,
- data);
+ securityOriginData,
+ ewkContext,
+ data);
// suspend notification
ewk_notification_permission_request_suspend(request);
Try {
// create notification
noti_h = notification_new(
- NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, notiData->m_id);
+ NOTIFICATION_TYPE_NOTI,
+ NOTIFICATION_GROUP_ID_NONE,
+ notiData->m_id);
if (!noti_h) {
LogError("Fail to notification_new");
return false;
// set notification title
error = notification_set_text(
- noti_h,
- NOTIFICATION_TEXT_TYPE_TITLE,
- notiData->m_title.c_str(),
- NULL,
- NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_h,
+ NOTIFICATION_TEXT_TYPE_TITLE,
+ notiData->m_title.c_str(),
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE);
if (error != NOTIFICATION_ERROR_NONE) {
ThrowMsg(Exception::NotificationShowError, "Fail to set title");
}
// set notification content
error = notification_set_text(
- noti_h,
- NOTIFICATION_TEXT_TYPE_CONTENT,
- notiData->m_body.c_str(),
- NULL,
- NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_h,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ notiData->m_body.c_str(),
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE);
if (error != NOTIFICATION_ERROR_NONE) {
ThrowMsg(Exception::NotificationShowError,
"Fail to set content:" << error);
// In this case, set to default package image.
if (true == validIconURL) {
error = notification_set_image(
- noti_h,
- NOTIFICATION_IMAGE_TYPE_ICON,
- notiData->m_iconURL.c_str());
+ noti_h,
+ NOTIFICATION_IMAGE_TYPE_ICON,
+ notiData->m_iconURL.c_str());
if (error != NOTIFICATION_ERROR_NONE) {
ThrowMsg(Exception::NotificationShowError,
"Fail to free notification: " << error);
if (noti_h) {
error = notification_free(noti_h);
if (error != NOTIFICATION_ERROR_NONE) {
- ThrowMsg(Exception::NotificationShowError,
- "Fail to free notification: " << error);
+ ThrowMsg(Exception::NotificationShowError,
+ "Fail to free notification: " << error);
}
noti_h = NULL;
}
// download path is
// /opt/apps/tizen_id/data + '/' + filename
std::string downloadPath =
- DPL::ToUTF8String(
- notiData->m_widgetModel->PersistentStoragePath.Get()) + "/";
+ DPL::ToUTF8String(
+ notiData->m_widgetModel->PersistentStoragePath.Get()) + "/";
LogDebug("downloadPath " << downloadPath);
// Make valid filename
}
fclose(fp);
curl_easy_cleanup(curl);
- } Catch (DPL::Exception) {
+ } Catch(DPL::Exception) {
LogError(_rethrown_exception.GetMessage());
fclose(fp);
curl_easy_cleanup(curl);
Result result = getResult(obj);
if (result != RESULT_UNKNOWN) {
- permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+ permData->m_originDao->setSecurityOriginData(permData->m_originData,
+ result);
}
Eina_Bool ret =
(result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) ?
- EINA_TRUE : EINA_FALSE;
+ EINA_TRUE : EINA_FALSE;
ewk_notification_permission_request_response(permData->m_ewkContext,
request,
ret);
evas_object_hide(popup);
evas_object_del(popup);
}
-
-
} // namespace WebNotification
} //namespace ViewModule
//Forward declarations
class WidgetModel;
namespace SecurityOriginDB {
- class SecurityOriginDAO;
+class SecurityOriginDAO;
}
namespace ViewModule {
namespace WebNotification {
-
-class WebNotificationData {
+class WebNotificationData
+{
public:
WebNotificationData(WidgetModel* widgetModel, uint64_t id);
virtual ~WebNotificationData();
typedef std::shared_ptr<WebNotificationData> WebNotificationDataPtr;
-class Exception {
+class Exception
+{
public:
DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
DECLARE_EXCEPTION_TYPE(Base, InitError)
Ewk_Context* ewkContext,
void* data);
bool showWebNotification(WebNotificationDataPtr notiData);
-
} // namespace SecuritySupport
} // namespace WebNotification
#include <Elementary.h>
namespace ViewModule {
-
using namespace SecurityOriginDB;
using namespace ViewModule::SecurityOriginSupportUtil;
LogDebug("askUserForWebStorageCreatePermission called");
PermissionData* permData = static_cast<PermissionData*>(data);
Ewk_Context_Exceeded_Quota* exceededQuota =
- static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
+ static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
std::ostringstream size;
- size << ewk_context_web_database_exceeded_quota_expected_usage_get(exceededQuota) /
- (1024 * 1024);
+ size << ewk_context_web_database_exceeded_quota_expected_usage_get(
+ exceededQuota) /
+ (1024 * 1024);
std::string body =
WEB_STORAGE_CREATE_ASK_BODY_PREFIX +
Assert(data);
PermissionData* permData = static_cast<PermissionData*>(data);
Ewk_Context_Exceeded_Quota* exceededQuota =
- static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
+ static_cast<Ewk_Context_Exceeded_Quota*>(permData->m_data);
Evas_Object* popup = getPopup(obj);
Result result = getResult(obj);
if (result != RESULT_UNKNOWN) {
- permData->m_originDao->setSecurityOriginData(permData->m_originData, result);
+ permData->m_originDao->setSecurityOriginData(permData->m_originData,
+ result);
}
- if (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) {
+ if (result == RESULT_ALLOW_ALWAYS || result == RESULT_ALLOW_ONCE) {
ewk_context_web_database_exceeded_quota_new_quota_set(
exceededQuota,
ewk_context_web_database_exceeded_quota_expected_usage_get(
exceededQuota) +
- 10*(1024*1024)); //10MB
+ 10 * (1024 * 1024)); //10MB
}
delete permData;
if (RESULT_ALLOW_ONCE == result || RESULT_ALLOW_ALWAYS == result) {
LogDebug("allow");
ewk_context_web_database_exceeded_quota_new_quota_set(
- exceededQuota,
- ewk_context_web_database_exceeded_quota_expected_usage_get(
- exceededQuota) +
- 10*(1024*1024)); //10MB
+ exceededQuota,
+ ewk_context_web_database_exceeded_quota_expected_usage_get(
+ exceededQuota) +
+ 10 * (1024 * 1024)); //10MB
return;
} else if (RESULT_DENY_ONCE == result || RESULT_DENY_ALWAYS == result) {
LogDebug("deny");
#include <Elementary.h>
namespace SecurityOriginDB {
- class SecurityOriginDAO;
+class SecurityOriginDAO;
}
namespace ViewModule {
namespace WebStorageSupport {
-
void webStorageCreatePermissionRequest(
- Evas_Object* window,
- SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
- void* data);
-
+ Evas_Object* window,
+ SecurityOriginDB::SecurityOriginDAO* securityOriginDAO,
+ void* data);
} // namespace WebStorageSupport
} // namespace ViewModule
#include <dpl/log/log.h>
#include <Elementary.h>
-
SplashScreenSupport::SplashScreenSupport(Evas_Object* parent)
{
LogDebug("enter");
LogDebug("enter");
}
-bool SplashScreenSupport::createSplashScreen(const DPL::OptionalString imagePath)
+bool SplashScreenSupport::createSplashScreen(
+ const DPL::OptionalString imagePath)
{
LogDebug("initializing splash screen");
#include <Evas.h>
#include <memory>
-
class SplashScreenSupport
{
public:
bool createSplashScreen(const DPL::OptionalString imagePath);
void startSplashScreen();
void stopSplashScreen();
+
private:
void setSplashImagePath(const char * image_path);
char const* const NOINDICATOR = "noindicator";
char const* const INTERNAL_LAYOUT = "internal_layout";
char const* const FLOATBACKWARD_BUTTON_STYLE = "wrt/backward";
-
} // anonymous namespace
WindowData::WindowData(unsigned long pid, bool manualInit) :
{
m_win = createWindow(pid);
- if (!manualInit)
- {
+ if (!manualInit) {
init();
}
}
void WindowData::toggleIndicator(bool fullscreen)
{
- LogDebug("fullscreen=" << (fullscreen?"true":"false"));
+ LogDebug("fullscreen=" << (fullscreen ? "true" : "false"));
if (!fullscreen) {
elm_win_indicator_mode_set(m_win, ELM_WIN_INDICATOR_SHOW);
}
void WindowData::setViewMode(
- bool fullscreen,
- bool backbutton)
+ bool fullscreen,
+ bool backbutton)
{
LogDebug("setViewMode");
LogDebug("fullscreen: " << fullscreen);
if (backbutton) {
createFloatBackButton();
}
-
}
void WindowData::createFloatBackButton()
Evas_Object* conformant = elm_conformant_add(parent);
evas_object_size_hint_weight_set(
- conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(parent, conformant);
return conformant;
ADD_PROFILING_POINT("elm_layout_theme_set", "stop");
evas_object_size_hint_align_set(platform_layout,
- EVAS_HINT_FILL,
- EVAS_HINT_FILL);
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
evas_object_size_hint_weight_set(platform_layout,
- EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
elm_object_content_set(parent, platform_layout);
edje_object_signal_emit(
- elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
+ elm_layout_edje_get(platform_layout), ELM_STATE_SHOW_CONTENT, ELM);
return platform_layout;
}
Evas_Object* navigation = elm_naviframe_add(parent);
evas_object_size_hint_align_set(navigation,
- EVAS_HINT_FILL,
- EVAS_HINT_FILL);
+ EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
evas_object_size_hint_weight_set(navigation,
- EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
+ EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
elm_object_part_content_set(parent, ELM_SWALLOW_CONTENT, navigation);
//elm_object_content_set(parent, navigation);
return navigation;
Evas_Object* layout = elm_layout_add(parent);
elm_layout_file_set(layout, DAEMON_EDJ_PATH, "client");
evas_object_size_hint_weight_set(
- layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
ADD_PROFILING_POINT("elm_naviframe_item_push", "start");
Elm_Object_Item* naviIt = elm_naviframe_item_push(
- /* Evas_Object *obj */
- parent,
- /* const char *title_label */
- "",
- /* Evas_Object *prev_btn */
- NULL,
- /* Evas_Object *next_btn */
- NULL,
- /* Evas_Object *content */
- layout,
- /* const char *item_style */
- NULL);
+ /* Evas_Object *obj */
+ parent,
+ /* const char *title_label */
+ "",
+ /* Evas_Object *prev_btn */
+ NULL,
+ /* Evas_Object *next_btn */
+ NULL,
+ /* Evas_Object *content */
+ layout,
+ /* const char *item_style */
+ NULL);
elm_naviframe_item_title_visible_set(naviIt, EINA_FALSE);
}
void WindowData::addNaviBackButtonCallback(
- const char* event,
- CallbackType callback,
- const void* data)
+ const char* event,
+ CallbackType callback,
+ const void* data)
{
Assert(m_naviBackButton != NULL && "m_naviBackButton is null");
evas_object_smart_callback_add(m_naviBackButton, event, callback, data);
}
void* WindowData::delNaviBackButtonCallback(
- const char* event,
- CallbackType callBack)
+ const char* event,
+ CallbackType callBack)
{
Assert(m_naviBackButton != NULL && "m_naviBackButton is null");
return evas_object_smart_callback_del(m_naviBackButton, event, callBack);
}
void WindowData::addFloatBackButtonCallback(
- const char* event,
- CallbackType callback,
- const void* data)
+ const char* event,
+ CallbackType callback,
+ const void* data)
{
Assert(m_floatBackButton != NULL && "m_floatBackButton is null");
evas_object_smart_callback_add(m_floatBackButton, event, callback, data);
}
void* WindowData::delFloatBackButtonCallback(
- const char* event,
- CallbackType callBack)
+ const char* event,
+ CallbackType callBack)
{
Assert(m_floatBackButton != NULL && "m_floatBackButton is null");
return evas_object_smart_callback_del(m_floatBackButton, event, callBack);
}
void WindowData::userlayoutCallbackAdd(
- const Evas_Callback_Type event,
- EvasCallbackType callback,
- const void* data)
+ const Evas_Callback_Type event,
+ EvasCallbackType callback,
+ const void* data)
{
Assert(m_user_layout != NULL && "m_user_layout is null");
evas_object_event_callback_add(m_user_layout, event, callback, data);
}
void* WindowData::userlayoutCallbackDel(
- const Evas_Callback_Type event,
- EvasCallbackType callBack)
+ const Evas_Callback_Type event,
+ EvasCallbackType callBack)
{
Assert(m_user_layout != NULL && "m_user_layout is null");
return evas_object_event_callback_del(m_user_layout, event, callBack);
}
void WindowData::emitSignalForUserLayout(
- const char* emission, const char* source)
+ const char* emission, const char* source)
{
LogInfo("emitSignalForUserLayout called");
Assert(m_user_layout != NULL && "m_user_layout is null");
Assert(source != NULL && "source is null");
edje_object_signal_emit(
- elm_layout_edje_get(m_user_layout), emission, source);
+ elm_layout_edje_get(m_user_layout), emission, source);
}
void WindowData::toggleFullscreen(bool fullscreen)
return;
}
- if (!m_fullscreen) //If ViewMode is not fullscreen, toggle indicator
+ if (!m_fullscreen) { //If ViewMode is not fullscreen, toggle indicator
toggleIndicator(fullscreen);
+ }
alreadyFullscreen = !alreadyFullscreen;
}
{
private:
typedef void (*CallbackType)(
- void* data, Evas_Object* obj, void* event_info);
+ void* data, Evas_Object* obj, void* event_info);
typedef void (*EvasCallbackType)(
- void* data, Evas* evas, Evas_Object* obj, void* event_info);
+ void* data, Evas* evas, Evas_Object* obj, void* event_info);
struct EventWithFunction
{
const char * a_eventName) :
function(a_function),
eventName(a_eventName)
- {
- }
+ {}
};
typedef std::vector<EventWithFunction> EventWithFunctionVector;
Evas_Object* m_win;
Evas_Object* m_user_layout;
- explicit WindowData(unsigned long pid, bool manualInit=false);
+ explicit WindowData(unsigned long pid, bool manualInit = false);
virtual ~WindowData();
void init();
void setEvasObjectForLayout(Evas_Object* evas_object);
void unsetEvasObjectForLayout();
void addNaviBackButtonCallback(
- const char* event,
- CallbackType callback,
- const void* data);
+ const char* event,
+ CallbackType callback,
+ const void* data);
void* delNaviBackButtonCallback(
- const char* event,
- CallbackType callBack);
+ const char* event,
+ CallbackType callBack);
void addFloatBackButtonCallback(
- const char* event,
- CallbackType callback,
- const void* data);
+ const char* event,
+ CallbackType callback,
+ const void* data);
void* delFloatBackButtonCallback(
- const char* event,
- CallbackType callBack);
+ const char* event,
+ CallbackType callBack);
void userlayoutCallbackAdd(
- const Evas_Callback_Type event,
- EvasCallbackType callback,
- const void* data);
+ const Evas_Callback_Type event,
+ EvasCallbackType callback,
+ const void* data);
void* userlayoutCallbackDel(
- const Evas_Callback_Type event,
- EvasCallbackType callback);
+ const Evas_Callback_Type event,
+ EvasCallbackType callback);
void emitSignalForUserLayout(
- const char* emission,
- const char* source);
+ const char* emission,
+ const char* source);
void setViewMode(
- bool fullscreen,
- bool backbutton);
+ bool fullscreen,
+ bool backbutton);
void toggleFullscreen(bool fullscreen);
LogInfo("Stopping Dummy Client");
}
-
void WrtClient::OnCreate()
{
LogInfo("On Create");
ewk_init();
}
-
void WrtClient::OnResume()
{
if (m_widgetState != WidgetState_Suspended) {
m_widgetState = WidgetState_Running;
}
-
void WrtClient::OnPause()
{
LogDebug("On pause");
m_windowData->emitSignalForUserLayout(EDJE_SHOW_BACKWARD_SIGNAL, "");
m_widgetState = WidgetState_Running;
} else {
- if (true == checkArgument())
- {
+ if (true == checkArgument()) {
setStep();
- }
- else
- {
+ } else {
showHelpAndQuit();
}
}
{
std::string tizenId = getTizenIdFromArgument(m_argc, m_argv);
- if(tizenId.empty()){
+ if (tizenId.empty()) {
// Just show help
return false;
} else {
if (arg == "-h" || arg == "--help") {
return "";
} else if (arg == "-l" || arg == "--launch" ||
- arg == "-t" || arg == "--tizen") {
+ arg == "-t" || arg == "--tizen")
+ {
if (argc != 3) {
return "";
}
// In WAC widget, only test widgets can use web inspector.
// In TIZEN widget,
// every launched widgets as debug mode can use it.
- if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_WAC20)
- {
- bool developerMode = WRT::CoreModuleSingleton::Instance().developerMode();
+ if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_WAC20) {
+ bool developerMode =
+ WRT::CoreModuleSingleton::Instance().developerMode();
//This code will be activated
//after WAC test certificate is used by SDK
//bool isTestWidget = view->m_widgetModel->IsTestWidget.Get();
// other type events. To give a chance of execute to other events,
// ecore_timer_add was used.
DPL::Event::ControllerEventHandler<NextStepEvent>::PostTimedEvent(
- NextStepEvent(),0.001);
+ NextStepEvent(), 0.001);
}
bool WrtClient::checkWACTestCertififedWidget()
LogDebug("Is developer Mode: " << developerMode);
if (developerWidget) {
- if(!developerMode)
- {
+ if (!developerMode) {
LogError("WAC test certified developer widget is needed for " <<
- "developer mode");
+ "developer mode");
return false;
- }else{
+ } else {
//TODO: WR-4660 (show popup about developer widget
// during launch
LogInfo("POPUP: THIS IS TEST WIDGET!");
// Start inspector server, if current mode is debugger mode.
// In the WK2 case, ewk_view_inspector_server_start should
// be called after WebProcess is created.
- if (checkDebugMode(debug))
- {
+ if (checkDebugMode(debug)) {
debug->portnum =
ewk_view_inspector_server_start(m_widget->GetCurrentWebview(), 0);
if (debug->portnum == 0) {
//w3c packaging test debug (message on 4>)
const char * makeScreen = getenv(W3C_DEBUG_ENV_VARIABLE);
- if(makeScreen != NULL && strcmp(makeScreen, "1") == 0)
- {
+ if (makeScreen != NULL && strcmp(makeScreen, "1") == 0) {
FILE* doutput = fdopen(4, "w");
- fprintf(doutput,"didFinishLoadForFrameCallback: ready\n");
+ fprintf(doutput, "didFinishLoadForFrameCallback: ready\n");
fclose(doutput);
}
m_returnStatus = ReturnStatus::Failed;
//shutdownStep
DPL::Event::ControllerEventHandler<NextStepEvent>::
- PostEvent(NextStepEvent());
+ PostEvent(NextStepEvent());
}
- if(debug->debugMode)
- {
+ if (debug->debugMode) {
LogDebug("Send RT signal to wrt-launcher(pid: " << m_sdkLauncherPid);
union sigval sv;
/* send real time signal with result to wrt-launcher */
- if(webview) {
+ if (webview) {
LogDebug("userData->portnum : " << debug->portnum);
sv.sival_int = debug->portnum;
} else {
- sv.sival_int = -1;
+ sv.sival_int = -1;
}
sigqueue(m_sdkLauncherPid, SIGRTMIN, sv);
}
LogDebug("window close called, terminating app");
SwitchToStep(&WrtClient::shutdownStep);
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
}
void WrtClient::webCrashCallback()
LogError("webProcess crashed");
SwitchToStep(&WrtClient::shutdownStep);
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
}
-
void WrtClient::launchStep()
{
ADD_PROFILING_POINT("launchStep", "start");
ADD_PROFILING_POINT("getRunnableWidgetObject", "start");
m_widget = WRT::CoreModuleSingleton::Instance()
- .getRunnableWidgetObject(m_tizenId);
+ .getRunnableWidgetObject(m_tizenId);
ADD_PROFILING_POINT("getRunnableWidgetObject", "stop");
if (!m_widget) {
LogError("RunnableWidgetObject is NULL, stop launchStep");
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
return;
}
if (m_widgetState == WidgetState_Running) {
LogWarning("Widget already running, stop launchStep");
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
return;
}
if (m_widgetState == WidgetState_Authorizing) {
LogWarning("Widget already authorizing, stop launchStep");
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
return;
}
m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
- if(!defloc.IsNull())
- {
- LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ if (!defloc.IsNull()) {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+ *defloc);
}
// For localizationsetting not changed on widget running
// languageChangedCallback, this);
ADD_PROFILING_POINT("CreateWindow", "start");
- m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()), true));
+ m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()),
+ true));
ADD_PROFILING_POINT("CreateWindow", "stop");
WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
ADD_PROFILING_POINT("Create splash screen", "start");
m_splashScreen.reset(
- new SplashScreenSupport(m_windowData->m_win));
+ new SplashScreenSupport(m_windowData->m_win));
if (m_splashScreen->createSplashScreen(m_dao->getSplashImgSrc())) {
m_splashScreen->startSplashScreen();
- cbs->progressFinish = DPL::MakeDelegate(this, &WrtClient::progressFinishCallback);
+ cbs->progressFinish = DPL::MakeDelegate(
+ this,
+ &WrtClient::
+ progressFinishCallback);
}
ADD_PROFILING_POINT("Create splash screen", "stop");
DPL::OptionalString startUrl = W3CFileLocalization::getStartFile(m_dao);
if (!m_widget->PrepareView(DPL::ToUTF8String(*startUrl),
- m_windowData->m_win))
+ m_windowData->m_win))
{
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
return;
- }
+ }
//you can't show window with splash screen before PrepareView
//ewk_view_add_with_context() in viewLogic breaks window
WrtDB::WidgetLocalizedInfo localizedInfo =
W3CFileLocalization::getLocalizedInfo(m_dao);
- std:: string name = "";
+ std::string name = "";
if (!(localizedInfo.name.IsNull())) {
name = DPL::ToUTF8String(*(localizedInfo.name));
}
initializeWindowModes();
connectElmCallback();
- if (!checkWACTestCertififedWidget())
- {
+ if (!checkWACTestCertififedWidget()) {
LogWarning("WAC Certificate failed, stop launchStep");
return;
}
if (!m_widget->CheckBeforeLaunch()) {
LogError("CheckBeforeLaunch failed, stop launchStep");
DPL::Event::ControllerEventHandler<NextStepEvent>::PostEvent(
- NextStepEvent());
+ NextStepEvent());
return;
}
LogInfo("Widget launch accepted. Entering running state");
cbs->bufferUnset = DPL::MakeDelegate(this, &WrtClient::unsetLayout);
cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback);
cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback);
- cbs->toggleFullscreen = DPL::MakeDelegate(m_windowData.get(), &WindowData::toggleFullscreen);
+ cbs->toggleFullscreen = DPL::MakeDelegate(
+ m_windowData.get(), &WindowData::toggleFullscreen);
m_widget->SetUserDelegates(cbs);
m_widget->Show();
auto windowModes = m_dao->getWindowModes();
bool fullscreen = false;
bool backbutton = false;
- if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
- WidgetSettings widgetSettings;
- m_dao->getWidgetSettings(widgetSettings);
- WidgetSettingList settings(widgetSettings);
+ if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
+ WidgetSettings widgetSettings;
+ m_dao->getWidgetSettings(widgetSettings);
+ WidgetSettingList settings(widgetSettings);
backbutton =
(settings.getBackButtonPresence() == BackButton_Enable);
- }
+ }
FOREACH(it, windowModes)
{
}
m_windowData->setViewMode(fullscreen,
- backbutton);
+ backbutton);
}
void WrtClient::backButtonCallback(void* data,
- Evas_Object * /*obj*/,
- void * /*event_info*/)
+ Evas_Object * /*obj*/,
+ void * /*event_info*/)
{
LogInfo("BackButtonCallback");
Assert(data);
WidgetSettingList settings(widgetSettings);
if (settings.getBackButtonPresence() == BackButton_Enable) {
m_windowData->addFloatBackButtonCallback(
- "clicked",
- &WrtClient::backButtonCallback,
- this);
+ "clicked",
+ &WrtClient::backButtonCallback,
+ this);
}
WidgetSettingScreenLock rotationValue = settings.getRotationValue();
}
}
-void WrtClient::setLayout(Evas_Object* newBuffer) {
+void WrtClient::setLayout(Evas_Object* newBuffer)
+{
LogDebug("add new webkit buffer to window");
Assert(newBuffer);
- elm_object_part_content_set(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT, newBuffer);
+ elm_object_part_content_set(m_windowData->m_user_layout,
+ ELM_SWALLOW_CONTENT,
+ newBuffer);
evas_object_show(newBuffer);
}
-void WrtClient::unsetLayout(Evas_Object* currentBuffer) {
+void WrtClient::unsetLayout(Evas_Object* currentBuffer)
+{
LogDebug("remove current webkit buffer from window");
Assert(currentBuffer);
evas_object_hide(currentBuffer);
- elm_object_part_content_unset(m_windowData->m_user_layout, ELM_SWALLOW_CONTENT);
+ elm_object_part_content_unset(m_windowData->m_user_layout,
+ ELM_SWALLOW_CONTENT);
}
void WrtClient::shutdownStep()
{
LogDebug("Closing Wrt connection ...");
- if (m_widget && m_widgetState)
- {
+ if (m_widget && m_widgetState) {
m_widgetState = WidgetState_Stopped;
m_widget->Hide();
m_widget.reset();
WRT::CoreModuleSingleton::Instance().Terminate();
}
- if (m_initialized)
- {
+ if (m_initialized) {
m_initialized = false;
}
m_windowData.reset();
int WrtClient::languageChangedCallback(void *data)
{
LogDebug("Language Changed");
- if(!data)
+ if (!data) {
return 0;
+ }
WrtClient* wrtClient = static_cast<WrtClient*>(data);
- if(!(wrtClient->m_dao))
+ if (!(wrtClient->m_dao)) {
return 0;
+ }
// reset function fetches system locales and recreates language tags
LanguageTagsProviderSingleton::Instance().resetLanguageTags();
// widget default locales are added to language tags below
DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale();
- if(!defloc.IsNull())
- {
- LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ if (!defloc.IsNull()) {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(
+ *defloc);
}
if (wrtClient->m_launched &&
- wrtClient->m_widgetState != WidgetState_Stopped) {
+ wrtClient->m_widgetState != WidgetState_Stopped)
+ {
wrtClient->m_widget->ReloadStartPage();
}
return 0;
// set evas backend type
if (!getenv("ELM_ENGINE")) {
if (!setenv("ELM_ENGINE", "gl", 1)) {
- LogDebug("Enable backend");
+ LogDebug("Enable backend");
}
- }
- else {
+ } else {
LogDebug("ELM_ENGINE : " << getenv("ELM_ENGINE"));
}
// This code is to fork a web process without exec.
std::string tizenId = WrtClient::getTizenIdFromArgument(argc, argv);
- if (!tizenId.empty())
- {
+ if (!tizenId.empty()) {
LogDebug("Launching by fork mode");
// Language env setup
appcore_set_i18n("wrt-client", NULL);
ewk_init();
ewk_set_arguments(argc, argv);
setenv("WRT_LAUNCHING_PERFORMANCE", "1", 1);
- s_ewk_context = ewk_context_new_with_injected_bundle_path(BUNDLE_PATH);
+ s_ewk_context = ewk_context_new_with_injected_bundle_path(
+ BUNDLE_PATH);
}
// Output on stdout will be flushed after every newline character,
// the output may not be flushed).
setlinebuf(stdout);
-
WrtClient app(argc, argv);
ADD_PROFILING_POINT("Before appExec", "point");
DECLARE_GENERIC_EVENT_0(NextStepEvent)
class WrtClient :
- public DPL::Application,
- private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
- public DPL::TaskDecl<WrtClient>
+ public DPL::Application,
+ private DPL::Event::Controller<DPL::TypeListDecl<NextStepEvent>::Type>,
+ public DPL::TaskDecl<WrtClient>
{
public:
WrtClient(int argc,
typedef struct
{
char* guid; /**< the widget's id
- (read from its config.xml during installation)*/
+ * (read from its config.xml during installation)*/
char* name; /**< the widget's name
- (read from its config.xml during installation)*/
+ * (read from its config.xml during installation)*/
char* version; /**< the widget's varsion
- (read from its config.xml during installation)*/
+ * (read from its config.xml during installation)*/
char* pkg_name; /**< the widget's pkg name */
} widget_info;
g_dbConnection.reset(new DBConnection());
g_dbConnection->AttachDatabase();
}
- Catch (DPL::DB::SqlConnection::Exception::Base) {
+ Catch(DPL::DB::SqlConnection::Exception::Base) {
LogDebug("Fail to connect DB");
return FALSE;
}
static bool display_widget_info()
{
- if(!attachDbConnection()) return FALSE;
+ if (!attachDbConnection()) {
+ return FALSE;
+ }
WidgetDAOReadOnlyList widgetList =
- WrtDB::WidgetDAOReadOnly::getWidgetList();
+ WrtDB::WidgetDAOReadOnly::getWidgetList();
printf("%3s %32s %16s %64s %16s\n",
"No", "Name", "Version", "GUID", "Package Name");
info->pkg_name = new_strdup(DPL::ToUTF8String(package_name).c_str());
-
printf("%3i %32s %16s %64s %16s\n",
number++,
!info->name ? "[NULL]" : info->name,
static void print_help(FILE *stream, int /*exit_code*/)
{
fprintf(stream, "Usage : %s [ ... ]\n", program);
- fprintf(stream,
- " -h --help Display this usage information.\n"
- " -l --list Display installed widgets list\n"
- " -s [GUID]or[PkgName] --start Launch widget with package name or GUID\n"
- " -k [GUID]or[PkgName] --kill Kill widget with package name or GUID\n"
- " -r [GUID]or[PkgName] --is-running Check whether widget is running by package name or GUID,\n"
- " If widget is running, 0(zero) will be returned.\n"
- " -d --debug Activate debug mode\n"
- " -t [second] --timeout Set timeout of response from widget in debug mode\n"
- " -v [1]or[0] --developer-mode Set developermode\n"
- " -c [1]or[0] --compliance-mode Set compliancemode\n"
- " -i [imei] --fake-imei Set fakeimei\n"
- " -m [meid] --fake-meid Set fakemeid\n"
- " if you emit this option, 5 seconds is set in debug mode\n"
- );
+ fprintf(
+ stream,
+ " -h --help Display this usage information.\n"
+ " -l --list Display installed widgets list\n"
+ " -s [GUID]or[PkgName] --start Launch widget with package name or GUID\n"
+ " -k [GUID]or[PkgName] --kill Kill widget with package name or GUID\n"
+ " -r [GUID]or[PkgName] --is-running Check whether widget is running by package name or GUID,\n"
+ " If widget is running, 0(zero) will be returned.\n"
+ " -d --debug Activate debug mode\n"
+ " -t [second] --timeout Set timeout of response from widget in debug mode\n"
+ " -v [1]or[0] --developer-mode Set developermode\n"
+ " -c [1]or[0] --compliance-mode Set compliancemode\n"
+ " -i [imei] --fake-imei Set fakeimei\n"
+ " -m [meid] --fake-meid Set fakemeid\n"
+ " if you emit this option, 5 seconds is set in debug mode\n"
+ );
}
static void sighandler(int signo, siginfo_t *si, void *data);
program = argv[0];
static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"list", no_argument, 0, 'l'},
- {"start", required_argument, 0, 's'},
- {"kill", required_argument, 0, 'k'},
- {"is-running", required_argument, 0, 'r'},
- {"debug", no_argument, 0, 'd'},
- {"timeout", required_argument, 0, 't'},
- {"developer-mode", required_argument, 0, 'v'},
- {"compliance-mode", required_argument, 0, 'c'},
- {"fake-imei", required_argument, 0, 'i'},
- {"fake-meid", required_argument, 0, 'm'},
- {0, 0, 0, 0}
+ { "help", no_argument, 0, 'h' },
+ { "list", no_argument, 0, 'l' },
+ { "start", required_argument, 0, 's' },
+ { "kill", required_argument, 0, 'k' },
+ { "is-running", required_argument, 0, 'r' },
+ { "debug", no_argument, 0, 'd' },
+ { "timeout", required_argument, 0, 't' },
+ { "developer-mode", required_argument, 0, 'v' },
+ { "compliance-mode", required_argument, 0, 'c' },
+ { "fake-imei", required_argument, 0, 'i' },
+ { "fake-meid", required_argument, 0, 'm' },
+ { 0, 0, 0, 0 }
};
if (argv[1] == NULL) {
switch (next_opt) {
case 'h':
- if(!dispHelp){
+ if (!dispHelp) {
print_help(stdout, 0);
dispHelp = true;
- }
+ }
break;
case 'l':
- if(dispList)
+ if (dispList) {
break;
+ }
if (!display_widget_info()) {
printf("Fail to display the list of installed widgets");
return -1;
case 't':
timeout = atoi(optarg);
- if (timeout < 0 ) {
+ if (timeout < 0) {
timeout = TIMEOUT_DEFAULT;
}
break;
case 'v':
strncpy(temp_arg, optarg, strlen(optarg));
- if(!attachDbConnection()) return FALSE;
+ if (!attachDbConnection()) {
+ return FALSE;
+ }
if (!strcmp("1", temp_arg)) {
WrtDB::GlobalDAO::SetDeveloperMode(true);
} else {
break;
case 'c':
strncpy(temp_arg, optarg, strlen(optarg));
- if(!attachDbConnection()) return FALSE;
- if(!strcmp("1", temp_arg)) {
+ if (!attachDbConnection()) {
+ return FALSE;
+ }
+ if (!strcmp("1", temp_arg)) {
WrtDB::GlobalDAO::setComplianceMode(true);
} else {
WrtDB::GlobalDAO::setComplianceMode(false);
break;
case 'i':
strncpy(temp_arg, optarg, strlen(optarg));
- if(!attachDbConnection()) return FALSE;
+ if (!attachDbConnection()) {
+ return FALSE;
+ }
WrtDB::GlobalDAO::setComplianceFakeImei(temp_arg);
break;
case 'm':
strncpy(temp_arg, optarg, strlen(optarg));
- if(!attachDbConnection()) return FALSE;
+ if (!attachDbConnection()) {
+ return FALSE;
+ }
WrtDB::GlobalDAO::setComplianceFakeMeid(temp_arg);
break;
}
} while (next_opt != -1);
- if ((op == 's') || (op == 'k') || (op =='r')) {
+ if ((op == 's') || (op == 'k') || (op == 'r')) {
std::string temp;
if (NULL == g_dbConnection.get()) {
g_dbConnection.reset(new DBConnection());
g_dbConnection->AttachDatabase();
}
- Catch (DPL::DB::SqlConnection::Exception::Base) {
+ Catch(DPL::DB::SqlConnection::Exception::Base) {
LogDebug("Fail to connect DB");
return FALSE;
}
std::string normal_arg = DPL::ToUTF8String(*normal_str);
WidgetDAOReadOnlyList widgetList =
- WrtDB::WidgetDAOReadOnly::getWidgetList();
+ WrtDB::WidgetDAOReadOnly::getWidgetList();
FOREACH(dao, widgetList) {
WrtDB::WidgetGUID d_guid = (*dao)->getGUID();
WrtDB::WidgetPkgName d_pkgname = (*dao)->getPkgName();
break;
}
if (!strcmp(DPL::ToUTF8String(d_pkgname).c_str(),
- normal_arg.c_str())) {
+ normal_arg.c_str()))
+ {
WrtDB::WidgetPkgName package_name = (*dao)->getPkgName();
temp = DPL::ToUTF8String(package_name);
break;
gid_t group_list[1];
group_list[0] = LOGGING_DEFAULT_GID;
- if(setgroups(sizeof(group_list), group_list) < 0) {
+ if (setgroups(sizeof(group_list), group_list) < 0) {
printf("result: %s\n", "failed");
return -1;
}
- if(setreuid(WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) < 0) {
+ if (setreuid(WEBAPP_DEFAULT_UID, WEBAPP_DEFAULT_GID) < 0) {
printf("result: %s\n", "failed");
return -1;
}
} else {
printf("Not RT signal : %d\n", signo);
}
- exit (0);
+ exit(0);
}
#include <dlfcn.h>
#include <glib.h>
-#define PREEXEC_FILE SHARE_PREFIX"/preexec_list.txt"
+#define PREEXEC_FILE SHARE_PREFIX "/preexec_list.txt"
static int preexec_initialized = 0;
GSList *preexec_list = NULL;
typedef struct _preexec_list_t {
- char *pkg_type;
- char *so_path;
- int (*dl_do_pre_exe) (char *, char *);
+ char *pkg_type;
+ char *so_path;
+ int (*dl_do_pre_exe)(char *, char *);
} preexec_list_t;
static void __preexec_list_free()
{
- GSList *iter = NULL;
- preexec_list_t *type_t;
-
- for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
- type_t = iter->data;
- if (type_t) {
- if (type_t->pkg_type)
- free(type_t->pkg_type);
- if (type_t->so_path)
- free(type_t->so_path);
- free(type_t);
- }
- }
- g_slist_free(preexec_list);
- return;
+ GSList *iter = NULL;
+ preexec_list_t *type_t;
+
+ for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+ type_t = iter->data;
+ if (type_t) {
+ if (type_t->pkg_type) {
+ free(type_t->pkg_type);
+ }
+ if (type_t->so_path) {
+ free(type_t->so_path);
+ }
+ free(type_t);
+ }
+ }
+ g_slist_free(preexec_list);
+ return;
}
static inline void __preexec_init(int argc, char **argv)
{
- void *handle = NULL;
- FILE *preexec_file;
- char *saveptr = NULL;
- char line[MAX_LOCAL_BUFSZ] = {0, };
- char *type = NULL;
- char *sopath = NULL;
- char *symbol = NULL;
- int (*func) (char *, char *) = NULL;
- preexec_list_t *type_t = NULL;
-
- // warning: unused parameter
- argc = argc;
- argv = argv;
-
- preexec_file = fopen(PREEXEC_FILE, "rt");
- if (preexec_file == NULL) {
- _E("no preexec\n");
- return;
- }
-
- _D("preexec start\n");
-
- while (fgets(line, MAX_LOCAL_BUFSZ, preexec_file) > (char*)0) {
- /* Parse each line */
- if (line[0] == '#' || line[0] == '\0')
- continue;
-
- type = strtok_r(line, ":\f\n\r\t\v ", &saveptr);
- if (type == NULL)
- continue;
- sopath = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
- if (sopath == NULL)
- continue;
- symbol = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
- if (symbol == NULL)
- continue;
-
- type_t = (preexec_list_t *) calloc(1, sizeof(preexec_list_t));
- if (type_t == NULL) {
- _E("no available memory\n");
- __preexec_list_free();
+ void *handle = NULL;
+ FILE *preexec_file;
+ char *saveptr = NULL;
+ char line[MAX_LOCAL_BUFSZ] = { 0, };
+ char *type = NULL;
+ char *sopath = NULL;
+ char *symbol = NULL;
+ int (*func)(char *, char *) = NULL;
+ preexec_list_t *type_t = NULL;
+
+ // warning: unused parameter
+ argc = argc;
+ argv = argv;
+
+ preexec_file = fopen(PREEXEC_FILE, "rt");
+ if (preexec_file == NULL) {
+ _E("no preexec\n");
+ return;
+ }
+
+ _D("preexec start\n");
+
+ while (fgets(line, MAX_LOCAL_BUFSZ, preexec_file) > (char*)0) {
+ /* Parse each line */
+ if (line[0] == '#' || line[0] == '\0') {
+ continue;
+ }
+
+ type = strtok_r(line, ":\f\n\r\t\v ", &saveptr);
+ if (type == NULL) {
+ continue;
+ }
+ sopath = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+ if (sopath == NULL) {
+ continue;
+ }
+ symbol = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+ if (symbol == NULL) {
+ continue;
+ }
+
+ type_t = (preexec_list_t *) calloc(1, sizeof(preexec_list_t));
+ if (type_t == NULL) {
+ _E("no available memory\n");
+ __preexec_list_free();
fclose(preexec_file);
- return;
- }
-
- handle = dlopen(sopath, RTLD_NOW);
- if (handle == NULL) {
- free(type_t);
- continue;
- }
- _D("preexec %s %s# - handle : %x\n", type, sopath, handle);
-
- func = dlsym(handle, symbol);
- if (func == NULL) {
- _E("failed to get symbol type:%s path:%s\n",
- type, sopath);
- free(type_t);
- dlclose(handle);
- handle = NULL;
- continue;
- }
-
- type_t->pkg_type = strdup(type);
- if (type_t->pkg_type == NULL) {
- _E("no available memory\n");
- free(type_t);
- __preexec_list_free();
+ return;
+ }
+
+ handle = dlopen(sopath, RTLD_NOW);
+ if (handle == NULL) {
+ free(type_t);
+ continue;
+ }
+ _D("preexec %s %s# - handle : %x\n", type, sopath, handle);
+
+ func = dlsym(handle, symbol);
+ if (func == NULL) {
+ _E("failed to get symbol type:%s path:%s\n",
+ type, sopath);
+ free(type_t);
+ dlclose(handle);
+ handle = NULL;
+ continue;
+ }
+
+ type_t->pkg_type = strdup(type);
+ if (type_t->pkg_type == NULL) {
+ _E("no available memory\n");
+ free(type_t);
+ __preexec_list_free();
fclose(preexec_file);
- return;
- }
- type_t->so_path = strdup(sopath);
- if (type_t->so_path == NULL) {
- _E("no available memory\n");
- free(type_t->pkg_type);
- free(type_t);
- __preexec_list_free();
+ return;
+ }
+ type_t->so_path = strdup(sopath);
+ if (type_t->so_path == NULL) {
+ _E("no available memory\n");
+ free(type_t->pkg_type);
+ free(type_t);
+ __preexec_list_free();
fclose(preexec_file);
- return;
- }
- type_t->dl_do_pre_exe = func;
+ return;
+ }
+ type_t->dl_do_pre_exe = func;
- preexec_list = g_slist_append(preexec_list, (void *)type_t);
- }
+ preexec_list = g_slist_append(preexec_list, (void *)type_t);
+ }
- fclose(preexec_file);
- preexec_initialized = 1;
+ fclose(preexec_file);
+ preexec_initialized = 1;
}
static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
- const char *app_path)
+ const char *app_path)
{
- GSList *iter = NULL;
- preexec_list_t *type_t;
-
- if (!preexec_initialized)
- return;
-
- for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
- type_t = iter->data;
- if (type_t) {
- if (!strcmp(pkg_type, type_t->pkg_type)) {
- if (type_t->dl_do_pre_exe != NULL) {
- type_t->dl_do_pre_exe((char *)pkg_name,
- (char *)app_path);
- _D("called dl_do_pre_exe() type: %s",
- pkg_type);
- } else {
- _E("no symbol for this type: %s",
- pkg_type);
- }
- }
- }
- }
-
+ GSList *iter = NULL;
+ preexec_list_t *type_t;
+
+ if (!preexec_initialized) {
+ return;
+ }
+
+ for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+ type_t = iter->data;
+ if (type_t) {
+ if (!strcmp(pkg_type, type_t->pkg_type)) {
+ if (type_t->dl_do_pre_exe != NULL) {
+ type_t->dl_do_pre_exe((char *)pkg_name,
+ (char *)app_path);
+ _D("called dl_do_pre_exe() type: %s",
+ pkg_type);
+ } else {
+ _E("no symbol for this type: %s",
+ pkg_type);
+ }
+ }
+ }
+ }
}
#else
static inline void __preexec_init(int argc, char **argv)
-{
-}
+{}
static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
- const char *app_path)
-{
-}
+ const char *app_path)
+{}
#endif
* limitations under the License.
*/
-
#ifndef __APP_DBUS_H__
#define __APP_DBUS_H__
#define AUL_DBUS_PATH "/aul/dbus_handler"
#define AUL_DBUS_SIGNAL_INTERFACE "org.tizen.aul.signal"
-#define AUL_DBUS_APPDEAD_SIGNAL "app_dead"
-#define AUL_DBUS_APPLAUNCH_SIGNAL "app_launch"
+#define AUL_DBUS_APPDEAD_SIGNAL "app_dead"
+#define AUL_DBUS_APPLAUNCH_SIGNAL "app_launch"
#endif
* limitations under the License.
*/
-
#ifndef __APP_PKT_H_
#define __APP_PKT_H_
#include <linux/un.h>
enum app_cmd {
- APP_START,
- APP_OPEN,
- APP_RESUME,
- APP_RESUME_BY_PID,
- APP_TERM_BY_PID,
- APP_RESULT,
- APP_START_RES,
- APP_CANCEL,
- APP_KILL_BY_PID,
- APP_ADD_HISTORY,
- APP_RUNNING_INFO,
- APP_RUNNING_INFO_RESULT,
- APP_IS_RUNNING,
- APP_KEY_EVENT,
- APP_KEY_RESERVE,
- APP_KEY_RELEASE,
- APP_STATUS_UPDATE,
- APP_RELEASED,
- APP_RUNNING_LIST_UPDATE
+ APP_START,
+ APP_OPEN,
+ APP_RESUME,
+ APP_RESUME_BY_PID,
+ APP_TERM_BY_PID,
+ APP_RESULT,
+ APP_START_RES,
+ APP_CANCEL,
+ APP_KILL_BY_PID,
+ APP_ADD_HISTORY,
+ APP_RUNNING_INFO,
+ APP_RUNNING_INFO_RESULT,
+ APP_IS_RUNNING,
+ APP_KEY_EVENT,
+ APP_KEY_RESERVE,
+ APP_KEY_RELEASE,
+ APP_STATUS_UPDATE,
+ APP_RELEASED,
+ APP_RUNNING_LIST_UPDATE
};
#define AUL_SOCK_PREFIX "/tmp/alaunch"
#define ELOCALLAUNCH_ID 128
typedef struct _app_pkt_t {
- int cmd;
- int len;
- unsigned char data[1];
+ int cmd;
+ int len;
+ unsigned char data[1];
} app_pkt_t;
int __create_server_sock(int pid);
* limitations under the License.
*/
-
#ifndef __AUL_UTIL_H_
#define __AUL_UTIL_H_
#define MAX_PACKAGE_APP_PATH_SIZE 512
#define MAX_RUNNING_APP_INFO 512
-typedef struct _app_status_info_t{
- char appid[MAX_PACKAGE_STR_SIZE];
- char app_path[MAX_PACKAGE_APP_PATH_SIZE];
- int status;
- int pid;
+typedef struct _app_status_info_t {
+ char appid[MAX_PACKAGE_STR_SIZE];
+ char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+ int status;
+ int pid;
} app_status_info_t;
struct amdmgr {
- struct appinfomgr *af; /* appinfo manager */
- struct cginfo *cg; /* cgroup infomation */
+ struct appinfomgr *af; /* appinfo manager */
+ struct cginfo *cg; /* cgroup infomation */
};
int _add_app_status_info_list(char *appid, int pid);
#endif
-
-
* limitations under the License.
*/
-
#include <ail.h>
#include <string.h>
#include "simple_util.h"
-#define MAX_PATH_LEN 1024
+#define MAX_PATH_LEN 1024
-#define AUL_APP_INFO_FLD_PKG_NAME "package"
-#define AUL_APP_INFO_FLD_APP_PATH "exec"
-#define AUL_APP_INFO_FLD_APP_TYPE "x_slp_packagetype"
-#define AUL_APP_INFO_FLD_WIDTH "x_slp_baselayoutwidth"
-#define AUL_APP_INFO_FLD_HEIGHT "x_slp_baselayoutheight"
-#define AUL_APP_INFO_FLD_VERTICAL "x_slp_ishorizontalscale"
-#define AUL_APP_INFO_FLD_MULTIPLE "x_slp_multiple"
-#define AUL_APP_INFO_FLD_TASK_MANAGE "x_slp_taskmanage"
-#define AUL_APP_INFO_FLD_MIMETYPE "mimetype"
-#define AUL_APP_INFO_FLD_SERVICE "x_slp_service"
+#define AUL_APP_INFO_FLD_PKG_NAME "package"
+#define AUL_APP_INFO_FLD_APP_PATH "exec"
+#define AUL_APP_INFO_FLD_APP_TYPE "x_slp_packagetype"
+#define AUL_APP_INFO_FLD_WIDTH "x_slp_baselayoutwidth"
+#define AUL_APP_INFO_FLD_HEIGHT "x_slp_baselayoutheight"
+#define AUL_APP_INFO_FLD_VERTICAL "x_slp_ishorizontalscale"
+#define AUL_APP_INFO_FLD_MULTIPLE "x_slp_multiple"
+#define AUL_APP_INFO_FLD_TASK_MANAGE "x_slp_taskmanage"
+#define AUL_APP_INFO_FLD_MIMETYPE "mimetype"
+#define AUL_APP_INFO_FLD_SERVICE "x_slp_service"
-#define AUL_RETRIEVE_PKG_NAME "package = '?'"
-#define AUL_RETRIEVE_APP_PATH "exec = '?'"
-#define AUL_RETRIEVE_MIMETYPE "mimetype like '?'"
-#define AUL_RETRIEVE_SERVICE "x_slp_service like '?'"
+#define AUL_RETRIEVE_PKG_NAME "package = '?'"
+#define AUL_RETRIEVE_APP_PATH "exec = '?'"
+#define AUL_RETRIEVE_MIMETYPE "mimetype like '?'"
+#define AUL_RETRIEVE_SERVICE "x_slp_service like '?'"
typedef struct {
- char *pkg_name; /* package */
- char *app_path; /* exec */
- char *original_app_path; /* exec */
- char *pkg_type; /* x_slp_packagetype */
- char *hwacc; /* hwacceleration */
+ char *pkg_name; /* package */
+ char *app_path; /* exec */
+ char *original_app_path; /* exec */
+ char *pkg_type; /* x_slp_packagetype */
+ char *hwacc; /* hwacceleration */
} app_info_from_db;
static inline char *_get_pkgname(app_info_from_db *menu_info)
{
- if (menu_info->pkg_name == NULL)
- return NULL;
- return menu_info->pkg_name;
+ if (menu_info->pkg_name == NULL) {
+ return NULL;
+ }
+ return menu_info->pkg_name;
}
static inline char *_get_app_path(app_info_from_db *menu_info)
{
- int i = 0;
- int path_len = -1;
-
- if (menu_info->app_path == NULL)
- return NULL;
-
- while (menu_info->app_path[i] != 0) {
- if (menu_info->app_path[i] == ' '
- || menu_info->app_path[i] == '\t') {
- path_len = i;
- break;
- }
- i++;
- }
-
- if (path_len == 0) {
- free(menu_info->app_path);
- menu_info->app_path = NULL;
- } else if (path_len > 0) {
- char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
- if(tmp_app_path == NULL)
- return NULL;
- snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
- free(menu_info->app_path);
- menu_info->app_path = tmp_app_path;
- }
-
- return menu_info->app_path;
+ int i = 0;
+ int path_len = -1;
+
+ if (menu_info->app_path == NULL) {
+ return NULL;
+ }
+
+ while (menu_info->app_path[i] != 0) {
+ if (menu_info->app_path[i] == ' '
+ || menu_info->app_path[i] == '\t')
+ {
+ path_len = i;
+ break;
+ }
+ i++;
+ }
+
+ if (path_len == 0) {
+ free(menu_info->app_path);
+ menu_info->app_path = NULL;
+ } else if (path_len > 0) {
+ char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
+ if (tmp_app_path == NULL) {
+ return NULL;
+ }
+ snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
+ free(menu_info->app_path);
+ menu_info->app_path = tmp_app_path;
+ }
+
+ return menu_info->app_path;
}
static inline char *_get_original_app_path(app_info_from_db *menu_info)
{
- if (menu_info->original_app_path == NULL)
- return NULL;
- return menu_info->original_app_path;
+ if (menu_info->original_app_path == NULL) {
+ return NULL;
+ }
+ return menu_info->original_app_path;
}
static inline void _free_app_info_from_db(app_info_from_db *menu_info)
{
- if (menu_info != NULL) {
- if (menu_info->pkg_name != NULL)
- free(menu_info->pkg_name);
- if (menu_info->app_path != NULL)
- free(menu_info->app_path);
- if (menu_info->original_app_path != NULL)
- free(menu_info->original_app_path);
- if (menu_info->hwacc != NULL)
- free(menu_info->hwacc);
- free(menu_info);
- }
+ if (menu_info != NULL) {
+ if (menu_info->pkg_name != NULL) {
+ free(menu_info->pkg_name);
+ }
+ if (menu_info->app_path != NULL) {
+ free(menu_info->app_path);
+ }
+ if (menu_info->original_app_path != NULL) {
+ free(menu_info->original_app_path);
+ }
+ if (menu_info->hwacc != NULL) {
+ free(menu_info->hwacc);
+ }
+ free(menu_info);
+ }
}
static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
- const char *pkgname)
+ const char *pkgname)
{
- app_info_from_db *menu_info;
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str = NULL;
-
- menu_info = calloc(1, sizeof(app_info_from_db));
- if (menu_info == NULL) {
- return NULL;
- }
-
- ret = ail_get_appinfo(pkgname, &handle);
- if (ret != AIL_ERROR_OK) {
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
- if (str) {
- menu_info->pkg_name = strdup(str);
- str = NULL;
- }
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
- if (str) {
- menu_info->app_path = strdup(str);
- str = NULL;
- }
-
- if (menu_info->app_path != NULL)
- menu_info->original_app_path = strdup(menu_info->app_path);
-
- ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
- if (str) {
- menu_info->pkg_type = strdup(str);
- str = NULL;
- }
-
- ret = ail_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- _E("ail_destroy_appinfo failed");
- }
-
- if (!_get_app_path(menu_info)) {
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- return menu_info;
+ app_info_from_db *menu_info;
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str = NULL;
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL) {
+ return NULL;
+ }
+
+ ret = ail_get_appinfo(pkgname, &handle);
+ if (ret != AIL_ERROR_OK) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
+ if (str) {
+ menu_info->pkg_name = strdup(str);
+ str = NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
+ if (str) {
+ menu_info->app_path = strdup(str);
+ str = NULL;
+ }
+
+ if (menu_info->app_path != NULL) {
+ menu_info->original_app_path = strdup(menu_info->app_path);
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+ if (str) {
+ menu_info->pkg_type = strdup(str);
+ str = NULL;
+ }
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ _E("ail_destroy_appinfo failed");
+ }
+
+ if (!_get_app_path(menu_info)) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ return menu_info;
}
-static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo,
+ void *user_data)
{
- app_info_from_db *menu_info = (app_info_from_db *)user_data;
- char *package;
+ app_info_from_db *menu_info = (app_info_from_db *)user_data;
+ char *package;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
- ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ menu_info->pkg_name = strdup(package);
- menu_info->pkg_name = strdup(package);
-
- return AIL_CB_RET_CANCEL; /*return AIL_CB_RET_CONTINUE;*/
+ return AIL_CB_RET_CANCEL; /*return AIL_CB_RET_CONTINUE;*/
}
static inline app_info_from_db *_get_app_info_from_db_by_apppath(
- const char *apppath)
+ const char *apppath)
{
- app_info_from_db *menu_info = NULL;
- ail_filter_h filter;
- ail_error_e ret;
- int count;
-
- if (apppath == NULL)
- return NULL;
-
- menu_info = calloc(1, sizeof(app_info_from_db));
- if (menu_info == NULL)
- return NULL;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- ret = ail_filter_count_appinfo(filter, &count);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- _free_app_info_from_db(menu_info);
- return NULL;
- }
- if (count < 1) {
- ail_filter_destroy(filter);
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
-
- ail_filter_destroy(filter);
-
- menu_info->app_path = strdup(apppath);
- menu_info->original_app_path = strdup(apppath);
-
- return menu_info;
-
+ app_info_from_db *menu_info = NULL;
+ ail_filter_h filter;
+ ail_error_e ret;
+ int count;
+
+ if (apppath == NULL) {
+ return NULL;
+ }
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL) {
+ return NULL;
+ }
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &count);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+ if (count < 1) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
+
+ ail_filter_destroy(filter);
+
+ menu_info->app_path = strdup(apppath);
+ menu_info->original_app_path = strdup(apppath);
+
+ return menu_info;
}
* limitations under the License.
*/
-
#ifndef __PERF_H__
#define __PERF_H__
#include <sys/time.h>
static struct timeval __g_base_time = {
- .tv_sec = 0,
- .tv_usec = 0
+ .tv_sec = 0,
+ .tv_usec = 0
};
-#define INIT_PERF(kb)\
-do {\
- const char *tmp;\
- struct timeval tv;\
- tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
- if (tmp != NULL)\
- sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
- else\
- gettimeofday(&tv, NULL);\
- __g_base_time.tv_sec = tv.tv_sec;\
- __g_base_time.tv_usec = tv.tv_usec;\
-} while (0);
-
-#define PERF(fmt, arg...)\
-do {\
- struct timeval cur;\
- struct timeval res;\
- gettimeofday(&cur, NULL);\
- if (__g_base_time.tv_sec != 0) {\
- timersub(&cur, &__g_base_time, &res);\
- printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt" %c[0m\n",\
- 27, __FUNCTION__, __LINE__, \
- res.tv_sec, res.tv_usec/1000, ##arg, 27);\
- } \
-} while (0);
+#define INIT_PERF(kb) \
+ do { \
+ const char *tmp; \
+ struct timeval tv; \
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME); \
+ if (tmp != NULL) { \
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec); } \
+ else { \
+ gettimeofday(&tv, NULL); } \
+ __g_base_time.tv_sec = tv.tv_sec; \
+ __g_base_time.tv_usec = tv.tv_usec; \
+ } while (0);
+
+#define PERF(fmt, arg ...) \
+ do { \
+ struct timeval cur; \
+ struct timeval res; \
+ gettimeofday(&cur, NULL); \
+ if (__g_base_time.tv_sec != 0) { \
+ timersub(&cur, &__g_base_time, &res); \
+ printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt " %c[0m\n", \
+ 27, __FUNCTION__, __LINE__, \
+ res.tv_sec, res.tv_usec / 1000,##arg, 27); \
+ } \
+ } while (0);
#else
#define INIT_PERF(kb)
-#define PERF(fmt, arg...)
+#define PERF(fmt, arg ...)
#endif
* limitations under the License.
*/
-
#ifndef __SIMPLE_UTIL__
#define __SIMPLE_UTIL__
#define LOG_TAG "AUL_AMD"
#endif
-
#define MAX_LOCAL_BUFSZ 128
#define MAX_PID_STR_BUFSZ 20
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _E(fmt, arg ...) LOGE(fmt,##arg)
+#define _D(fmt, arg ...) LOGD(fmt,##arg)
-#define retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- _E(fmt, ##arg); \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
+#define retvm_if(expr, val, fmt, arg ...) do { \
+ if (expr) { \
+ _E(fmt,##arg); \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
} while (0)
#define retv_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
+ if (expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
} while (0)
int __proc_iter_cmdline(int (*iterfunc)
- (const char *dname, const char *cmdline, void *priv),
- void *priv);
-int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
- void *priv);
+ (const char *dname, const char *cmdline, void *priv),
+ void *priv);
+int __proc_iter_pgid(int pgid, int (*iterfunc)(int pid, void *priv),
+ void *priv);
char *__proc_get_cmdline_bypid(int pid);
static inline const char *FILENAME(const char *filename)
{
- const char *p;
- const char *r;
+ const char *p;
+ const char *r;
- if (!filename)
- return NULL;
+ if (!filename) {
+ return NULL;
+ }
- r = p = filename;
- while (*p) {
- if (*p == '/')
- r = p + 1;
- p++;
- }
+ r = p = filename;
+ while (*p) {
+ if (*p == '/') {
+ r = p + 1;
+ }
+ p++;
+ }
- return r;
+ return r;
}
#endif
* limitations under the License.
*/
-
#ifdef DAC_ACTIVATE
#include <privilege-control.h>
#define INHOUSE_UID 5000
-static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+static inline int __set_access(const char* pkg_name,
+ const char* pkg_type,
+ const char* app_path)
{
- return set_app_privilege(pkg_name, pkg_type, app_path);
+ return set_app_privilege(pkg_name, pkg_type, app_path);
}
#else
-static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+static inline int __set_access(const char* pkg_name,
+ const char* pkg_type,
+ const char* app_path)
{
- return 0;
+ return 0;
}
#endif
-
* limitations under the License.
*/
-
#define LAUNCHPAD_LOG
#define DAC_ACTIVATE
#define PRELOAD_ACTIVATE
* limitations under the License.
*/
-
#ifdef GL_ACTIVATE
#define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
* limitations under the License.
*/
-
/*
- * simple AUL daemon - launchpad
+ * simple AUL daemon - launchpad
*/
#include <stdio.h>
#define _static_ static inline
#define POLLFD_MAX 1
-#define SQLITE_FLUSH_MAX (1048576) /* (1024*1024) */
-#define AUL_POLL_CNT 15
-#define AUL_PR_NAME 16
+#define SQLITE_FLUSH_MAX (1048576) /* (1024*1024) */
+#define AUL_POLL_CNT 15
+#define AUL_PR_NAME 16
#define PATH_APP_ROOT "/opt/usr/apps"
#define PATH_DATA "/data"
#define SDK_CODE_COVERAGE "CODE_COVERAGE"
#define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
#define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
-
static char *launchpad_cmdline;
static int initialized = 0;
-
_static_ void __set_oom();
_static_ void __set_env(app_info_from_db * menu_info, bundle * kb);
_static_ int __prepare_exec(const char *pkg_name,
- const char *app_path, app_info_from_db * menu_info,
- bundle * kb);
+ const char *app_path, app_info_from_db * menu_info,
+ bundle * kb);
_static_ int __fake_launch_app(int cmd, int pid, bundle * kb);
_static_ char **__create_argc_argv(bundle * kb, int *margc);
_static_ int __normal_fork_exec(int argc, char **argv);
_static_ void __real_launch(const char *app_path, bundle * kb);
static inline int __parser(const char *arg, char *out, int out_size);
_static_ void __modify_bundle(bundle * kb, int caller_pid,
- app_info_from_db * menu_info, int cmd);
+ app_info_from_db * menu_info, int cmd);
_static_ int __child_raise_win_by_x(int pid, void *priv);
_static_ int __raise_win_by_x(int pid);
_static_ int __send_to_sigkill(int pid);
extern ail_error_e ail_db_close(void);
-
-
_static_ void __set_oom()
{
- char buf[MAX_LOCAL_BUFSZ];
- FILE *fp;
-
- /* we should reset oomadj value as default because child
- inherits from parent oom_adj*/
- snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
- fp = fopen(buf, "w");
- if (fp == NULL)
- return;
- fprintf(fp, "%d", -16);
- fclose(fp);
+ char buf[MAX_LOCAL_BUFSZ];
+ FILE *fp;
+
+ /* we should reset oomadj value as default because child
+ * inherits from parent oom_adj*/
+ snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
+ fp = fopen(buf, "w");
+ if (fp == NULL) {
+ return;
+ }
+ fprintf(fp, "%d", -16);
+ fclose(fp);
}
-_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str) {
- char buf[MAX_LOCAL_BUFSZ];
- int ret;
-
- _D("key : %s / value : %s", AUL_K_SDK, str);
- /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
- /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
- /* Prefix can be absolute, or relative. The default is no prefix. */
- /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
- /* to stripoff the hardwired absolute paths. Default value is 0. */
- if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
- snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, _get_pkgname(menu_info));
- ret = setenv("GCOV_PREFIX", buf, 1);
- _D("GCOV_PREFIX : %d", ret);
- ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
- _D("GCOV_PREFIX_STRIP : %d", ret);
- } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
- ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
- _D("LD_PRELOAD : %d", ret);
- }
+_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str)
+{
+ char buf[MAX_LOCAL_BUFSZ];
+ int ret;
+
+ _D("key : %s / value : %s", AUL_K_SDK, str);
+ /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
+ /* GCOV_PREFIX contains the prefix to add to the absolute paths in the
+ *object file. */
+ /* Prefix can be absolute, or relative. The default is no prefix.
+ * */
+ /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
+ /* to stripoff the hardwired absolute paths. Default value is 0. */
+ if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
+ snprintf(buf,
+ MAX_LOCAL_BUFSZ,
+ PATH_APP_ROOT "/%s"PATH_DATA,
+ _get_pkgname(menu_info));
+ ret = setenv("GCOV_PREFIX", buf, 1);
+ _D("GCOV_PREFIX : %d", ret);
+ ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
+ _D("GCOV_PREFIX_STRIP : %d", ret);
+ } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
+ ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
+ _D("LD_PRELOAD : %d", ret);
+ }
}
-
_static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
{
- const char *str;
- const char **str_array;
- int len;
- int i;
-
- setenv("PKG_NAME", _get_pkgname(menu_info), 1);
-
- USE_ENGINE("gl")
-
- str = bundle_get_val(kb, AUL_K_STARTTIME);
- if (str != NULL)
- setenv("APP_START_TIME", str, 1);
-
- if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
- str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
- if(str_array != NULL) {
- for (i = 0; i < len; i++) {
- _D("index : [%d]", i);
- __set_sdk_env(menu_info, (char *)str_array[i]);
- }
- }
- } else {
- str = bundle_get_val(kb, AUL_K_SDK);
- if(str != NULL) {
- __set_sdk_env(menu_info, (char *)str);
- }
- }
- if (menu_info->hwacc != NULL)
- setenv("HWACC", menu_info->hwacc, 1);
+ const char *str;
+ const char **str_array;
+ int len;
+ int i;
+
+ setenv("PKG_NAME", _get_pkgname(menu_info), 1);
+
+ USE_ENGINE("gl")
+
+ str = bundle_get_val(kb, AUL_K_STARTTIME);
+ if (str != NULL) {
+ setenv("APP_START_TIME", str, 1);
+ }
+
+ if (bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
+ str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
+ if (str_array != NULL) {
+ for (i = 0; i < len; i++) {
+ _D("index : [%d]", i);
+ __set_sdk_env(menu_info, (char *)str_array[i]);
+ }
+ }
+ } else {
+ str = bundle_get_val(kb, AUL_K_SDK);
+ if (str != NULL) {
+ __set_sdk_env(menu_info, (char *)str);
+ }
+ }
+ if (menu_info->hwacc != NULL) {
+ setenv("HWACC", menu_info->hwacc, 1);
+ }
}
_static_ int __prepare_exec(const char *pkg_name,
- const char *app_path, app_info_from_db * menu_info,
- bundle * kb)
+ const char *app_path, app_info_from_db * menu_info,
+ bundle * kb)
{
- char *file_name;
- char process_name[AUL_PR_NAME];
-
- /* Set new session ID & new process group ID*/
- /* In linux, child can set new session ID without check permission */
- /* TODO : should be add to check permission in the kernel*/
- setsid();
-
- __preexec_run(menu_info->pkg_type, pkg_name, app_path);
-
- /* SET OOM*/
- __set_oom();
-
- /* SET PRIVILEGES*/
- if (__set_access(pkg_name, menu_info->pkg_type, app_path) < 0) {
- _D("fail to set privileges - check your package's credential\n");
- return -1;
- }
- /* SET DUMPABLE - for coredump*/
- prctl(PR_SET_DUMPABLE, 1);
-
- /* SET PROCESS NAME*/
- if (app_path == NULL) {
- _D("app_path should not be NULL - check menu db");
- return -1;
- }
- file_name = strrchr(app_path, '/') + 1;
- if (file_name == NULL) {
- _D("can't locate file name to execute");
- return -1;
- }
- memset(process_name, '\0', AUL_PR_NAME);
- snprintf(process_name, AUL_PR_NAME, "%s", file_name);
- prctl(PR_SET_NAME, process_name);
-
- /* SET ENVIROMENT*/
- __set_env(menu_info, kb);
-
- return 0;
+ char *file_name;
+ char process_name[AUL_PR_NAME];
+
+ /* Set new session ID & new process group ID*/
+ /* In linux, child can set new session ID without check permission */
+ /* TODO : should be add to check permission in the kernel*/
+ setsid();
+
+ __preexec_run(menu_info->pkg_type, pkg_name, app_path);
+
+ /* SET OOM*/
+ __set_oom();
+
+ /* SET PRIVILEGES*/
+ if (__set_access(pkg_name, menu_info->pkg_type, app_path) < 0) {
+ _D("fail to set privileges - check your package's credential\n");
+ return -1;
+ }
+ /* SET DUMPABLE - for coredump*/
+ prctl(PR_SET_DUMPABLE, 1);
+
+ /* SET PROCESS NAME*/
+ if (app_path == NULL) {
+ _D("app_path should not be NULL - check menu db");
+ return -1;
+ }
+ file_name = strrchr(app_path, '/') + 1;
+ if (file_name == NULL) {
+ _D("can't locate file name to execute");
+ return -1;
+ }
+ memset(process_name, '\0', AUL_PR_NAME);
+ snprintf(process_name, AUL_PR_NAME, "%s", file_name);
+ prctl(PR_SET_NAME, process_name);
+
+ /* SET ENVIROMENT*/
+ __set_env(menu_info, kb);
+
+ return 0;
}
_static_ int __fake_launch_app(int cmd, int pid, bundle * kb)
{
- int datalen;
- int ret;
- bundle_raw *kb_data;
-
- bundle_encode(kb, &kb_data, &datalen);
- if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
- _E("error request fake launch - error code = %d", ret);
- free(kb_data);
- return ret;
+ int datalen;
+ int ret;
+ bundle_raw *kb_data;
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0) {
+ _E("error request fake launch - error code = %d", ret);
+ }
+ free(kb_data);
+ return ret;
}
_static_ char **__create_argc_argv(bundle * kb, int *margc)
{
- char **argv;
- int argc;
+ char **argv;
+ int argc;
- argc = bundle_export_to_argv(kb, &argv);
+ argc = bundle_export_to_argv(kb, &argv);
- *margc = argc;
- return argv;
+ *margc = argc;
+ return argv;
}
_static_ int __normal_fork_exec(int argc, char **argv)
{
- _D("start real fork and exec\n");
-
- // warning: unused parameter
- argc = argc;
-
- if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
- if (errno == EACCES)
- _E("such a file is no executable - %s", argv[0]);
- else
- _E("unknown executable error - %s", argv[0]);
- return -1;
- }
- /* never reach*/
- return 0;
+ _D("start real fork and exec\n");
+
+ // warning: unused parameter
+ argc = argc;
+
+ if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
+ if (errno == EACCES) {
+ _E("such a file is no executable - %s", argv[0]);
+ } else {
+ _E("unknown executable error - %s", argv[0]);
+ }
+ return -1;
+ }
+ /* never reach*/
+ return 0;
}
_static_ void __real_launch(const char *app_path, bundle * kb)
{
- int app_argc;
- char **app_argv;
- int i;
+ int app_argc;
+ char **app_argv;
+ int i;
- app_argv = __create_argc_argv(kb, &app_argc);
+ app_argv = __create_argc_argv(kb, &app_argc);
#ifndef NATIVE_LAUNCHPAD
if (__change_cmdline(app_path) < 0) {
app_argv[0] = g_argv[0];
#else
- app_argv[0] = strdup(app_path);
+ app_argv[0] = strdup(app_path);
#endif
- for (i = 0; i < app_argc; i++)
- _D("input argument %d : %s##", i, app_argv[i]);
+ for (i = 0; i < app_argc; i++) {
+ _D("input argument %d : %s##", i, app_argv[i]);
+ }
- PERF("setup argument done");
- _E("lock up test log(no error) : setup argument done");
+ PERF("setup argument done");
+ _E("lock up test log(no error) : setup argument done");
- /* Temporary log: launch time checking */
- LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
+ /* Temporary log: launch time checking */
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
- __preload_exec(app_argc, app_argv);
+ __preload_exec(app_argc, app_argv);
- __normal_fork_exec(app_argc, app_argv);
+ __normal_fork_exec(app_argc, app_argv);
}
/*
*/
static inline int __parser(const char *arg, char *out, int out_size)
{
- register int i;
- int state = 1;
- char *start_out = out;
-
- if (arg == NULL || out == NULL) {
- /* Handles null buffer*/
- return 0;
- }
-
- for (i = 0; out_size > 1; i++) {
- switch (state) {
- case 1:
- switch (arg[i]) {
- case ' ':
- case '\t':
- state = 5;
- break;
- case '\0':
- state = 7;
- break;
- case '\"':
- state = 2;
- break;
- case '\\':
- state = 4;
- break;
- default:
- *out = arg[i];
- out++;
- out_size--;
- break;
- }
- break;
- case 2: /* escape start*/
- switch (arg[i]) {
- case '\0':
- state = 6;
- break;
- case '\"':
- state = 1;
- break;
- default:
- *out = arg[i];
- out++;
- out_size--;
- break;
- }
- break;
- case 4: /* character escape*/
- if (arg[i] == '\0') {
- state = 6;
- } else {
- *out = arg[i];
- out++;
- out_size--;
- state = 1;
- }
- break;
- case 5: /* token*/
- if (out != start_out) {
- *out = '\0';
- out_size--;
- return i;
- }
- i--;
- state = 1;
- break;
- case 6:
- return -1; /* error*/
- case 7: /* terminate*/
- *out = '\0';
- out_size--;
- return 0;
- default:
- state = 6;
- break; /* error*/
- }
- }
-
- if (out_size == 1) {
- *out = '\0';
- }
- /* Buffer overflow*/
- return -2;
+ register int i;
+ int state = 1;
+ char *start_out = out;
+
+ if (arg == NULL || out == NULL) {
+ /* Handles null buffer*/
+ return 0;
+ }
+
+ for (i = 0; out_size > 1; i++) {
+ switch (state) {
+ case 1:
+ switch (arg[i]) {
+ case ' ':
+ case '\t':
+ state = 5;
+ break;
+ case '\0':
+ state = 7;
+ break;
+ case '\"':
+ state = 2;
+ break;
+ case '\\':
+ state = 4;
+ break;
+ default:
+ *out = arg[i];
+ out++;
+ out_size--;
+ break;
+ }
+ break;
+ case 2: /* escape start*/
+ switch (arg[i]) {
+ case '\0':
+ state = 6;
+ break;
+ case '\"':
+ state = 1;
+ break;
+ default:
+ *out = arg[i];
+ out++;
+ out_size--;
+ break;
+ }
+ break;
+ case 4: /* character escape*/
+ if (arg[i] == '\0') {
+ state = 6;
+ } else {
+ *out = arg[i];
+ out++;
+ out_size--;
+ state = 1;
+ }
+ break;
+ case 5: /* token*/
+ if (out != start_out) {
+ *out = '\0';
+ out_size--;
+ return i;
+ }
+ i--;
+ state = 1;
+ break;
+ case 6:
+ return -1; /* error*/
+ case 7: /* terminate*/
+ *out = '\0';
+ out_size--;
+ return 0;
+ default:
+ state = 6;
+ break; /* error*/
+ }
+ }
+
+ if (out_size == 1) {
+ *out = '\0';
+ }
+ /* Buffer overflow*/
+ return -2;
}
_static_ void __modify_bundle(bundle * kb, int caller_pid,
- app_info_from_db * menu_info, int cmd)
+ app_info_from_db * menu_info, int cmd)
{
- // warning: unused parameter
- caller_pid = caller_pid;
-
- bundle_del(kb, AUL_K_PKG_NAME);
- bundle_del(kb, AUL_K_EXEC);
- bundle_del(kb, AUL_K_PACKAGETYPE);
- bundle_del(kb, AUL_K_HWACC);
-
- /* Parse app_path to retrieve default bundle*/
- if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN || cmd == APP_RESUME) {
- char *ptr;
- char exe[MAX_PATH_LEN];
- int flag;
-
- ptr = _get_original_app_path(menu_info);
-
- flag = __parser(ptr, exe, sizeof(exe));
- if (flag > 0) {
- char key[256];
- char value[256];
-
- ptr += flag;
- _D("parsing app_path: EXEC - %s\n", exe);
-
- do {
- flag = __parser(ptr, key, sizeof(key));
- if (flag <= 0)
- break;
- ptr += flag;
-
- flag = __parser(ptr, value, sizeof(value));
- if (flag < 0)
- break;
- ptr += flag;
-
- /*bundle_del(kb, key);*/
- bundle_add(kb, key, value);
- } while (flag > 0);
- } else if (flag == 0) {
- _D("parsing app_path: No arguments\n");
- } else {
- _D("parsing app_path: Invalid argument\n");
- }
- }
+ // warning: unused parameter
+ caller_pid = caller_pid;
+
+ bundle_del(kb, AUL_K_PKG_NAME);
+ bundle_del(kb, AUL_K_EXEC);
+ bundle_del(kb, AUL_K_PACKAGETYPE);
+ bundle_del(kb, AUL_K_HWACC);
+
+ /* Parse app_path to retrieve default bundle*/
+ if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN || cmd ==
+ APP_RESUME)
+ {
+ char *ptr;
+ char exe[MAX_PATH_LEN];
+ int flag;
+
+ ptr = _get_original_app_path(menu_info);
+
+ flag = __parser(ptr, exe, sizeof(exe));
+ if (flag > 0) {
+ char key[256];
+ char value[256];
+
+ ptr += flag;
+ _D("parsing app_path: EXEC - %s\n", exe);
+
+ do {
+ flag = __parser(ptr, key, sizeof(key));
+ if (flag <= 0) {
+ break;
+ }
+ ptr += flag;
+
+ flag = __parser(ptr, value, sizeof(value));
+ if (flag < 0) {
+ break;
+ }
+ ptr += flag;
+
+ /*bundle_del(kb, key);*/
+ bundle_add(kb, key, value);
+ } while (flag > 0);
+ } else if (flag == 0) {
+ _D("parsing app_path: No arguments\n");
+ } else {
+ _D("parsing app_path: Invalid argument\n");
+ }
+ }
}
_static_ int __child_raise_win_by_x(int pid, void *priv)
{
- // warning: unused parameter
- priv = priv;
+ // warning: unused parameter
+ priv = priv;
- return x_util_raise_win(pid);
+ return x_util_raise_win(pid);
}
_static_ int __raise_win_by_x(int pid)
{
- int pgid;
- if (x_util_raise_win(pid) == 0)
- return 0;
+ int pgid;
+ if (x_util_raise_win(pid) == 0) {
+ return 0;
+ }
- /* support app launched by shell script*/
- pgid = getpgid(pid);
- _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
- pgid, pid);
+ /* support app launched by shell script*/
+ pgid = getpgid(pid);
+ _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
+ pgid, pid);
- if (pgid <= 1)
- return -1;
- if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0)
- return -1;
+ if (pgid <= 1) {
+ return -1;
+ }
+ if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0) {
+ return -1;
+ }
- return 0;
+ return 0;
}
_static_ int __send_to_sigkill(int pid)
{
- int pgid;
+ int pgid;
- pgid = getpgid(pid);
- if (pgid <= 1)
- return -1;
+ pgid = getpgid(pid);
+ if (pgid <= 1) {
+ return -1;
+ }
- if (killpg(pgid, SIGKILL) < 0)
- return -1;
+ if (killpg(pgid, SIGKILL) < 0) {
+ return -1;
+ }
- return 0;
+ return 0;
}
_static_ int __term_app(int pid)
{
- int dummy;
- if (__app_send_raw
- (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0) {
- _D("terminate packet send error - use SIGKILL");
- if (__send_to_sigkill(pid) < 0) {
- _E("fail to killing - %d\n", pid);
- return -1;
- }
- }
- _D("term done\n");
- return 0;
+ int dummy;
+ if (__app_send_raw
+ (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0)
+ {
+ _D("terminate packet send error - use SIGKILL");
+ if (__send_to_sigkill(pid) < 0) {
+ _E("fail to killing - %d\n", pid);
+ return -1;
+ }
+ }
+ _D("term done\n");
+ return 0;
}
_static_ int __resume_app(int pid)
{
- int dummy;
- int ret;
- if ((ret =
- __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
- sizeof(int))) < 0) {
- if (ret == -EAGAIN)
- _E("resume packet timeout error");
- else {
- _D("resume packet send error - use raise win");
- if (__raise_win_by_x(pid) < 0) {
- _E("raise failed - %d resume fail\n", pid);
- _E("we will term the app - %d\n", pid);
- __send_to_sigkill(pid);
- ret = -1;
- } else
- ret = 0;
- }
- }
- _D("resume done\n");
- return ret;
+ int dummy;
+ int ret;
+ if ((ret =
+ __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+ sizeof(int))) < 0)
+ {
+ if (ret == -EAGAIN) {
+ _E("resume packet timeout error");
+ } else {
+ _D("resume packet send error - use raise win");
+ if (__raise_win_by_x(pid) < 0) {
+ _E("raise failed - %d resume fail\n", pid);
+ _E("we will term the app - %d\n", pid);
+ __send_to_sigkill(pid);
+ ret = -1;
+ } else {
+ ret = 0;
+ }
+ }
+ }
+ _D("resume done\n");
+ return ret;
}
static int __get_caller_pid(bundle *kb)
{
- const char *pid_str;
- int pid;
+ const char *pid_str;
+ int pid;
- pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
- if(pid_str)
- goto end;
+ pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
+ if (pid_str) {
+ goto end;
+ }
- pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
- if (pid_str == NULL)
- return -1;
+ pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
+ if (pid_str == NULL) {
+ return -1;
+ }
end:
- pid = atoi(pid_str);
- if (pid <= 1)
- return -1;
+ pid = atoi(pid_str);
+ if (pid <= 1) {
+ return -1;
+ }
- return pid;
+ return pid;
}
_static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
{
- int pid;
- char tmp_pid[MAX_PID_STR_BUFSZ];
- int datalen;
- bundle_raw *kb_data;
- int res;
-
- if ((pid = __get_caller_pid(kb)) < 0)
- return AUL_R_ERROR;
+ int pid;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+ int datalen;
+ bundle_raw *kb_data;
+ int res;
+
+ if ((pid = __get_caller_pid(kb)) < 0) {
+ return AUL_R_ERROR;
+ }
- snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
- bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
+ bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
- bundle_encode(kb, &kb_data, &datalen);
- if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
- res = AUL_R_ERROR;
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0) {
+ res = AUL_R_ERROR;
+ }
- free(kb_data);
+ free(kb_data);
- return res;
+ return res;
}
_static_ void __real_send(int clifd, int ret)
{
- if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
- if (errno == EPIPE) {
- _E("send failed due to EPIPE.\n");
- }
- _E("send fail to client");
- }
-
- close(clifd);
+ if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE) {
+ _E("send failed due to EPIPE.\n");
+ }
+ _E("send fail to client");
+ }
+
+ close(clifd);
}
_static_ void __send_result_to_caller(int clifd, int ret)
{
- char *cmdline;
- int wait_count;
- int cmdline_changed = 0;
- int cmdline_exist = 0;
-
- if (clifd == -1)
- return;
-
- if (ret <= 1) {
- __real_send(clifd, ret);
- return;
- }
- /* check normally was launched?*/
- wait_count = 1;
- do {
- cmdline = __proc_get_cmdline_bypid(ret);
- if (cmdline == NULL) {
- _E("error founded when being launched with %d", ret);
-
- } else if (strcmp(cmdline, launchpad_cmdline)) {
- free(cmdline);
- cmdline_changed = 1;
- break;
- } else {
- cmdline_exist = 1;
- free(cmdline);
- }
-
- _D("-- now wait to change cmdline --");
- usleep(50 * 1000); /* 50ms sleep*/
- wait_count++;
- } while (wait_count <= 20); /* max 50*20ms will be sleep*/
-
- if ((!cmdline_exist) && (!cmdline_changed)) {
- __real_send(clifd, -1); /* abnormally launched*/
- return;
- }
-
- if (!cmdline_changed)
- _E("process launched, but cmdline not changed");
-
- __real_send(clifd, ret);
- return;
+ char *cmdline;
+ int wait_count;
+ int cmdline_changed = 0;
+ int cmdline_exist = 0;
+
+ if (clifd == -1) {
+ return;
+ }
+
+ if (ret <= 1) {
+ __real_send(clifd, ret);
+ return;
+ }
+ /* check normally was launched?*/
+ wait_count = 1;
+ do {
+ cmdline = __proc_get_cmdline_bypid(ret);
+ if (cmdline == NULL) {
+ _E("error founded when being launched with %d", ret);
+ } else if (strcmp(cmdline, launchpad_cmdline)) {
+ free(cmdline);
+ cmdline_changed = 1;
+ break;
+ } else {
+ cmdline_exist = 1;
+ free(cmdline);
+ }
+
+ _D("-- now wait to change cmdline --");
+ usleep(50 * 1000); /* 50ms sleep*/
+ wait_count++;
+ } while (wait_count <= 20); /* max 50*20ms will be sleep*/
+
+ if ((!cmdline_exist) && (!cmdline_changed)) {
+ __real_send(clifd, -1); /* abnormally launched*/
+ return;
+ }
+
+ if (!cmdline_changed) {
+ _E("process launched, but cmdline not changed");
+ }
+
+ __real_send(clifd, ret);
+ return;
}
static app_info_from_db *_get_app_info_from_bundle_by_pkgname(
- const char *pkgname, bundle *kb)
+ const char *pkgname, bundle *kb)
{
- app_info_from_db *menu_info;
-
- menu_info = calloc(1, sizeof(app_info_from_db));
- if (menu_info == NULL) {
- return NULL;
- }
-
- menu_info->pkg_name = strdup(pkgname);
- menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
- if (menu_info->app_path != NULL)
- menu_info->original_app_path = strdup(menu_info->app_path);
- menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
- menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
-
- if (!_get_app_path(menu_info)) {
- _free_app_info_from_db(menu_info);
- return NULL;
- }
-
- return menu_info;
+ app_info_from_db *menu_info;
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL) {
+ return NULL;
+ }
+
+ menu_info->pkg_name = strdup(pkgname);
+ menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
+ if (menu_info->app_path != NULL) {
+ menu_info->original_app_path = strdup(menu_info->app_path);
+ }
+ menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
+ menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
+
+ if (!_get_app_path(menu_info)) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ return menu_info;
}
_static_ void __launchpad_main_loop(int main_fd)
{
- bundle *kb = NULL;
- app_pkt_t *pkt = NULL;
- app_info_from_db *menu_info = NULL;
-
- const char *pkg_name = NULL;
- const char *app_path = NULL;
- int pid = -1;
- int clifd = -1;
- struct ucred cr;
- int is_real_launch = 0;
-
- char sock_path[UNIX_PATH_MAX] = {0,};
-
- pkt = __app_recv_raw(main_fd, &clifd, &cr);
- if (!pkt) {
- _D("packet is NULL");
- goto end;
- }
-
- kb = bundle_decode(pkt->data, pkt->len);
- if (!kb) {
- _D("bundle decode error");
- goto end;
- }
-
- INIT_PERF(kb);
- PERF("packet processing start");
-
- pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
- _D("pkg name : %s\n", pkg_name);
-
- menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
- if (menu_info == NULL) {
- _D("such pkg no found");
- goto end;
- }
-
- app_path = _get_app_path(menu_info);
- if(app_path == NULL) {
- _E("app_path is NULL");
- goto end;
- }
- if (app_path[0] != '/') {
- _D("app_path is not absolute path");
- goto end;
- }
-
- __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
- pkg_name = _get_pkgname(menu_info);
-
- PERF("get package information & modify bundle done");
-
- {
- pid = fork();
- if (pid == 0) {
- PERF("fork done");
- _E("lock up test log(no error) : fork done");
-
- close(clifd);
- close(main_fd);
- __signal_unset_sigchld();
- __signal_fini();
-
- snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
- unlink(sock_path);
-
- PERF("prepare exec - first done");
- _E("lock up test log(no error) : prepare exec - first done");
-
- if (__prepare_exec(pkg_name, app_path,
- menu_info, kb) < 0) {
- _E("preparing work fail to launch - "
- "can not launch %s\n", pkg_name);
- exit(-1);
- }
-
- PERF("prepare exec - second done");
- _E("lock up test log(no error) : prepare exec - second done");
-
- __real_launch(app_path, kb);
-
- exit(-1);
- }
- _D("==> real launch pid : %d %s\n", pid, app_path);
- is_real_launch = 1;
- }
-
- end:
- __send_result_to_caller(clifd, pid);
-
- if (pid > 0) {
- if (is_real_launch) {
- /*TODO: retry*/
- __signal_block_sigchld();
- __send_app_launch_signal(pid);
- __signal_unblock_sigchld();
- }
- }
-
- if (menu_info != NULL)
- _free_app_info_from_db(menu_info);
-
- if (kb != NULL)
- bundle_free(kb);
- if (pkt != NULL)
- free(pkt);
-
- /* Active Flusing for Daemon */
- if (initialized > AUL_POLL_CNT) {
- sqlite3_release_memory(SQLITE_FLUSH_MAX);
- malloc_trim(0);
- initialized = 1;
- }
+ bundle *kb = NULL;
+ app_pkt_t *pkt = NULL;
+ app_info_from_db *menu_info = NULL;
+
+ const char *pkg_name = NULL;
+ const char *app_path = NULL;
+ int pid = -1;
+ int clifd = -1;
+ struct ucred cr;
+ int is_real_launch = 0;
+
+ char sock_path[UNIX_PATH_MAX] = { 0, };
+
+ pkt = __app_recv_raw(main_fd, &clifd, &cr);
+ if (!pkt) {
+ _D("packet is NULL");
+ goto end;
+ }
+
+ kb = bundle_decode(pkt->data, pkt->len);
+ if (!kb) {
+ _D("bundle decode error");
+ goto end;
+ }
+
+ INIT_PERF(kb);
+ PERF("packet processing start");
+
+ pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
+ _D("pkg name : %s\n", pkg_name);
+
+ menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
+ if (menu_info == NULL) {
+ _D("such pkg no found");
+ goto end;
+ }
+
+ app_path = _get_app_path(menu_info);
+ if (app_path == NULL) {
+ _E("app_path is NULL");
+ goto end;
+ }
+ if (app_path[0] != '/') {
+ _D("app_path is not absolute path");
+ goto end;
+ }
+ __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
+ pkg_name = _get_pkgname(menu_info);
+
+ PERF("get package information & modify bundle done");
+
+ {
+ pid = fork();
+ if (pid == 0) {
+ PERF("fork done");
+ _E("lock up test log(no error) : fork done");
+
+ close(clifd);
+ close(main_fd);
+ __signal_unset_sigchld();
+ __signal_fini();
+
+ snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
+ unlink(sock_path);
+
+ PERF("prepare exec - first done");
+ _E("lock up test log(no error) : prepare exec - first done");
+
+ if (__prepare_exec(pkg_name, app_path,
+ menu_info, kb) < 0)
+ {
+ _E("preparing work fail to launch - "
+ "can not launch %s\n", pkg_name);
+ exit(-1);
+ }
+
+ PERF("prepare exec - second done");
+ _E("lock up test log(no error) : prepare exec - second done");
+
+ __real_launch(app_path, kb);
+
+ exit(-1);
+ }
+ _D("==> real launch pid : %d %s\n", pid, app_path);
+ is_real_launch = 1;
+ }
+
+end:
+ __send_result_to_caller(clifd, pid);
+
+ if (pid > 0) {
+ if (is_real_launch) {
+ /*TODO: retry*/
+ __signal_block_sigchld();
+ __send_app_launch_signal(pid);
+ __signal_unblock_sigchld();
+ }
+ }
+
+ if (menu_info != NULL) {
+ _free_app_info_from_db(menu_info);
+ }
+
+ if (kb != NULL) {
+ bundle_free(kb);
+ }
+ if (pkt != NULL) {
+ free(pkt);
+ }
+
+ /* Active Flusing for Daemon */
+ if (initialized > AUL_POLL_CNT) {
+ sqlite3_release_memory(SQLITE_FLUSH_MAX);
+ malloc_trim(0);
+ initialized = 1;
+ }
}
_static_ int __launchpad_pre_init(int argc, char **argv)
{
- int fd;
+ int fd;
- /* signal init*/
- __signal_init();
+ /* signal init*/
+ __signal_init();
- /* get my(launchpad) command line*/
- launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
- if (launchpad_cmdline == NULL) {
- _E("launchpad cmdline fail to get");
- return -1;
- }
- _D("launchpad cmdline = %s", launchpad_cmdline);
+ /* get my(launchpad) command line*/
+ launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
+ if (launchpad_cmdline == NULL) {
+ _E("launchpad cmdline fail to get");
+ return -1;
+ }
+ _D("launchpad cmdline = %s", launchpad_cmdline);
- /* create launchpad sock */
- fd = __create_server_sock(WRT_LAUNCHPAD_PID);
- if (fd < 0) {
- _E("server sock error");
- return -1;
- }
+ /* create launchpad sock */
+ fd = __create_server_sock(WRT_LAUNCHPAD_PID);
+ if (fd < 0) {
+ _E("server sock error");
+ return -1;
+ }
- __preload_init(argc, argv);
+ __preload_init(argc, argv);
__preload_init_for_wrt();
- __preexec_init(argc, argv);
+ __preexec_init(argc, argv);
- return fd;
+ return fd;
}
_static_ int __launchpad_post_init()
{
- /* Setting this as a global variable to keep track
- of launchpad poll cnt */
- /* static int initialized = 0;*/
+ /* Setting this as a global variable to keep track
+ * of launchpad poll cnt */
+ /* static int initialized = 0;*/
- if (initialized) {
- initialized++;
- return 0;
- }
+ if (initialized) {
+ initialized++;
+ return 0;
+ }
- if (__signal_set_sigchld() < 0)
- return -1;
+ if (__signal_set_sigchld() < 0) {
+ return -1;
+ }
- initialized++;
+ initialized++;
- return 0;
+ return 0;
}
int main(int argc, char **argv)
{
- int main_fd;
- struct pollfd pfds[POLLFD_MAX];
- int i;
-
- /* init without concerning X & EFL*/
- main_fd = __launchpad_pre_init(argc, argv);
- if (main_fd < 0) {
- _E("launchpad pre init failed");
- exit(-1);
- }
-
- pfds[0].fd = main_fd;
- pfds[0].events = POLLIN;
- pfds[0].revents = 0;
-
- while (1) {
- if (poll(pfds, POLLFD_MAX, -1) < 0)
- continue;
-
- /* init with concerning X & EFL (because of booting
- sequence problem)*/
- if (__launchpad_post_init() < 0) {
- _E("launcpad post init failed");
- exit(-1);
- }
-
- for (i = 0; i < POLLFD_MAX; i++) {
- if ((pfds[i].revents & POLLIN) != 0) {
- __launchpad_main_loop(pfds[i].fd);
- }
- }
- }
+ int main_fd;
+ struct pollfd pfds[POLLFD_MAX];
+ int i;
+
+ /* init without concerning X & EFL*/
+ main_fd = __launchpad_pre_init(argc, argv);
+ if (main_fd < 0) {
+ _E("launchpad pre init failed");
+ exit(-1);
+ }
+
+ pfds[0].fd = main_fd;
+ pfds[0].events = POLLIN;
+ pfds[0].revents = 0;
+
+ while (1) {
+ if (poll(pfds, POLLFD_MAX, -1) < 0) {
+ continue;
+ }
+
+ /* init with concerning X & EFL (because of booting
+ * sequence problem)*/
+ if (__launchpad_post_init() < 0) {
+ _E("launcpad post init failed");
+ exit(-1);
+ }
+
+ for (i = 0; i < POLLFD_MAX; i++) {
+ if ((pfds[i].revents & POLLIN) != 0) {
+ __launchpad_main_loop(pfds[i].fd);
+ }
+ }
+ }
}
* limitations under the License.
*/
-
#include <pthread.h>
#include "app_signal.h"
static inline void __socket_garbage_collector()
{
- DIR *dp;
- struct dirent *dentry;
- char tmp[MAX_LOCAL_BUFSZ];
-
- dp = opendir(AUL_SOCK_PREFIX);
- if (dp == NULL)
- return;
-
- while ((dentry = readdir(dp)) != NULL) {
- if (!isdigit(dentry->d_name[0]))
- continue;
-
- snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
- if (access(tmp, F_OK) < 0) { /* Flawfinder: ignore */
- snprintf(tmp, MAX_LOCAL_BUFSZ, "%s/%s", AUL_SOCK_PREFIX,
- dentry->d_name);
- unlink(tmp);
- continue;
- }
- }
- closedir(dp);
+ DIR *dp;
+ struct dirent *dentry;
+ char tmp[MAX_LOCAL_BUFSZ];
+
+ dp = opendir(AUL_SOCK_PREFIX);
+ if (dp == NULL) {
+ return;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0])) {
+ continue;
+ }
+
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
+ if (access(tmp, F_OK) < 0) { /* Flawfinder: ignore */
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "%s/%s", AUL_SOCK_PREFIX,
+ dentry->d_name);
+ unlink(tmp);
+ continue;
+ }
+ }
+ closedir(dp);
}
static inline int __send_app_dead_signal(int dead_pid)
{
- DBusMessage *message;
+ DBusMessage *message;
- if (bus == NULL)
- return -1;
+ if (bus == NULL) {
+ return -1;
+ }
- message = dbus_message_new_signal(AUL_DBUS_PATH,
- AUL_DBUS_SIGNAL_INTERFACE,
- AUL_DBUS_APPDEAD_SIGNAL);
+ message = dbus_message_new_signal(AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE,
+ AUL_DBUS_APPDEAD_SIGNAL);
- if (dbus_message_append_args(message,
- DBUS_TYPE_UINT32, &dead_pid,
- DBUS_TYPE_INVALID) == FALSE) {
- _E("Failed to load data error");
- return -1;
- }
+ if (dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &dead_pid,
+ DBUS_TYPE_INVALID) == FALSE)
+ {
+ _E("Failed to load data error");
+ return -1;
+ }
- if (dbus_connection_send(bus, message, NULL) == FALSE) {
- _E("dbus send error");
- return -1;
- }
+ if (dbus_connection_send(bus, message, NULL) == FALSE) {
+ _E("dbus send error");
+ return -1;
+ }
- dbus_connection_flush(bus);
- dbus_message_unref(message);
+ dbus_connection_flush(bus);
+ dbus_message_unref(message);
- _D("send dead signal done\n");
+ _D("send dead signal done\n");
- return 0;
+ return 0;
}
static inline int __send_app_launch_signal(int launch_pid)
{
- DBusMessage *message;
+ DBusMessage *message;
- if (bus == NULL)
- return -1;
+ if (bus == NULL) {
+ return -1;
+ }
- message = dbus_message_new_signal(AUL_DBUS_PATH,
- AUL_DBUS_SIGNAL_INTERFACE,
- AUL_DBUS_APPLAUNCH_SIGNAL);
+ message = dbus_message_new_signal(AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE,
+ AUL_DBUS_APPLAUNCH_SIGNAL);
- if (dbus_message_append_args(message,
- DBUS_TYPE_UINT32, &launch_pid,
- DBUS_TYPE_INVALID) == FALSE) {
- _E("Failed to load data error");
- return -1;
- }
+ if (dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &launch_pid,
+ DBUS_TYPE_INVALID) == FALSE)
+ {
+ _E("Failed to load data error");
+ return -1;
+ }
- if (dbus_connection_send(bus, message, NULL) == FALSE) {
- _E("dbus send error");
- return -1;
- }
+ if (dbus_connection_send(bus, message, NULL) == FALSE) {
+ _E("dbus send error");
+ return -1;
+ }
- dbus_connection_flush(bus);
- dbus_message_unref(message);
+ dbus_connection_flush(bus);
+ dbus_message_unref(message);
- _D("send launch signal done\n");
+ _D("send launch signal done\n");
- return 0;
+ return 0;
}
static int __sigchild_action(void *data)
{
- pid_t dead_pid;
- char buf[MAX_LOCAL_BUFSZ];
+ pid_t dead_pid;
+ char buf[MAX_LOCAL_BUFSZ];
- dead_pid = (pid_t) data;
- if (dead_pid <= 0)
- goto end;
+ dead_pid = (pid_t) data;
+ if (dead_pid <= 0) {
+ goto end;
+ }
- __send_app_dead_signal(dead_pid);
+ __send_app_dead_signal(dead_pid);
- snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
- unlink(buf);
+ snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
+ unlink(buf);
- __socket_garbage_collector();
- end:
- return 0;
+ __socket_garbage_collector();
+end:
+ return 0;
}
static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
{
- int status;
- pid_t child_pid;
- pid_t child_pgid;
+ int status;
+ pid_t child_pid;
+ pid_t child_pgid;
- // warning: unused parameter
- signo = signo;
- data = data;
+ // warning: unused parameter
+ signo = signo;
+ data = data;
- child_pgid = getpgid(info->si_pid);
- _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
+ child_pgid = getpgid(info->si_pid);
+ _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
- while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
- if (child_pid == child_pgid)
- killpg(child_pgid, SIGKILL);
- __sigchild_action((void *)child_pid);
- }
+ while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
+ if (child_pid == child_pgid) {
+ killpg(child_pgid, SIGKILL);
+ }
+ __sigchild_action((void *)child_pid);
+ }
- return;
+ return;
}
static inline int __signal_init(void)
{
- int i;
- for (i = 0; i < _NSIG; i++) {
- switch (i) {
- /* controlled by sys-assert package*/
- case SIGQUIT:
- case SIGILL:
- case SIGABRT:
- case SIGBUS:
- case SIGFPE:
- case SIGSEGV:
- case SIGPIPE:
- break;
- default:
- signal(i, SIG_DFL);
- break;
- }
- }
-
- return 0;
+ int i;
+ for (i = 0; i < _NSIG; i++) {
+ switch (i) {
+ /* controlled by sys-assert package*/
+ case SIGQUIT:
+ case SIGILL:
+ case SIGABRT:
+ case SIGBUS:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGPIPE:
+ break;
+ default:
+ signal(i, SIG_DFL);
+ break;
+ }
+ }
+
+ return 0;
}
static inline int __signal_set_sigchld(void)
{
- struct sigaction act;
- DBusError error;
-
- dbus_error_init(&error);
- dbus_threads_init_default();
- bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- if (!bus) {
- _E("Failed to connect to the D-BUS daemon: %s", error.message);
- dbus_error_free(&error);
- return -1;
- }
- /* TODO: if process stop mechanism is included,
- should be modified (SA_NOCLDSTOP)*/
- act.sa_handler = NULL;
- act.sa_sigaction = __launchpad_sig_child;
- sigemptyset(&act.sa_mask);
- act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
-
- if (sigaction(SIGCHLD, &act, &old_sigchild) < 0)
- return -1;
-
- return 0;
+ struct sigaction act;
+ DBusError error;
+
+ dbus_error_init(&error);
+ dbus_threads_init_default();
+ bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ _E("Failed to connect to the D-BUS daemon: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+ /* TODO: if process stop mechanism is included,
+ * should be modified (SA_NOCLDSTOP)*/
+ act.sa_handler = NULL;
+ act.sa_sigaction = __launchpad_sig_child;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
+
+ if (sigaction(SIGCHLD, &act, &old_sigchild) < 0) {
+ return -1;
+ }
+
+ return 0;
}
static inline int __signal_unset_sigchld(void)
{
- struct sigaction dummy;
+ struct sigaction dummy;
- if (bus == NULL)
- return 0;
+ if (bus == NULL) {
+ return 0;
+ }
- dbus_connection_close(bus);
- if (sigaction(SIGCHLD, &old_sigchild, &dummy) < 0)
- return -1;
+ dbus_connection_close(bus);
+ if (sigaction(SIGCHLD, &old_sigchild, &dummy) < 0) {
+ return -1;
+ }
- return 0;
+ return 0;
}
static inline int __signal_block_sigchld(void)
{
- sigset_t newmask;
+ sigset_t newmask;
- sigemptyset(&newmask);
- sigaddset(&newmask, SIGCHLD);
+ sigemptyset(&newmask);
+ sigaddset(&newmask, SIGCHLD);
- if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
- _E("SIG_BLOCK error");
- return -1;
- }
+ if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
+ _E("SIG_BLOCK error");
+ return -1;
+ }
- _D("SIGCHLD blocked");
+ _D("SIGCHLD blocked");
- return 0;
+ return 0;
}
static inline int __signal_unblock_sigchld(void)
{
- if(sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
- _E("SIG_SETMASK error");
- return -1;
- }
+ if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
+ _E("SIG_SETMASK error");
+ return -1;
+ }
- _D("SIGCHLD unblocked");
- return 0;
+ _D("SIGCHLD unblocked");
+ return 0;
}
static inline int __signal_fini(void)
{
#ifndef PRELOAD_ACTIVATE
- int i;
- for (i = 0; i < _NSIG; i++)
- signal(i, SIG_DFL);
+ int i;
+ for (i = 0; i < _NSIG; i++) {
+ signal(i, SIG_DFL);
+ }
#endif
- return 0;
+ return 0;
}
* limitations under the License.
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "simple_util.h"
static Atom a_pid;
-static int (*x_old_error) (Display *, XErrorEvent *);
-
+static int (*x_old_error)(Display *, XErrorEvent *);
static pid_t __get_win_pid(Display *d, Window win);
static int __find_win(Display *d, Window *win, pid_t pid);
static pid_t __get_win_pid(Display *d, Window win)
{
- int r;
- pid_t pid;
+ int r;
+ pid_t pid;
- Atom a_type;
- int format;
- unsigned long nitems;
- unsigned long bytes_after;
- unsigned char *prop_ret;
+ Atom a_type;
+ int format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop_ret;
- retv_if(d == NULL || !a_pid, -1);
+ retv_if(d == NULL || !a_pid, -1);
- prop_ret = NULL;
- r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
- &a_type, &format, &nitems, &bytes_after, &prop_ret);
- if (r != Success || prop_ret == NULL)
- return -1;
+ prop_ret = NULL;
+ r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
+ &a_type, &format, &nitems, &bytes_after, &prop_ret);
+ if (r != Success || prop_ret == NULL) {
+ return -1;
+ }
- if (a_type == XA_CARDINAL && format == 32)
- pid = *(unsigned long *)prop_ret;
- else
- pid = -1;
+ if (a_type == XA_CARDINAL && format == 32) {
+ pid = *(unsigned long *)prop_ret;
+ } else {
+ pid = -1;
+ }
- XFree(prop_ret);
+ XFree(prop_ret);
- return pid;
+ return pid;
}
static int __find_win(Display *d, Window *win, pid_t pid)
{
- int r;
- pid_t p;
- unsigned int n;
- Window root, parent, *child;
-
- p = __get_win_pid(d, *win);
- if (p == pid)
- return 1;
-
- r = XQueryTree(d, *win, &root, &parent, &child, &n);
- if (r) {
- int i;
- int found = 0;
-
- for (i = 0; i < n; i++) {
- found = __find_win(d, &child[i], pid);
- if (found) {
- *win = child[i];
- break;
- }
- }
- XFree(child);
-
- if (found)
- return 1;
- }
-
- return 0;
+ int r;
+ pid_t p;
+ unsigned int n;
+ Window root, parent, *child;
+
+ p = __get_win_pid(d, *win);
+ if (p == pid) {
+ return 1;
+ }
+
+ r = XQueryTree(d, *win, &root, &parent, &child, &n);
+ if (r) {
+ int i;
+ int found = 0;
+
+ for (i = 0; i < n; i++) {
+ found = __find_win(d, &child[i], pid);
+ if (found) {
+ *win = child[i];
+ break;
+ }
+ }
+ XFree(child);
+
+ if (found) {
+ return 1;
+ }
+ }
+
+ return 0;
}
static int __raise_win(Display *d, Window win)
{
- XWindowAttributes attr;
- attr.map_state = IsUnmapped;
+ XWindowAttributes attr;
+ attr.map_state = IsUnmapped;
- XMapRaised(d, win);
+ XMapRaised(d, win);
- XGetWindowAttributes(d, win, &attr);
+ XGetWindowAttributes(d, win, &attr);
- if (attr.map_state == IsUnmapped)
- _D("unmapped");
- else if (attr.map_state == IsUnviewable)
- _D("unviewable");
- else if (attr.map_state == IsViewable)
- _D("viewable");
+ if (attr.map_state == IsUnmapped) {
+ _D("unmapped");
+ } else if (attr.map_state == IsUnviewable) {
+ _D("unviewable");
+ } else if (attr.map_state == IsViewable) {
+ _D("viewable");
+ }
- retv_if(attr.map_state != IsViewable, -1);
+ retv_if(attr.map_state != IsViewable, -1);
- XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
- return 0;
+ return 0;
}
int x_util_raise_win(pid_t pid)
{
- int r;
- int found;
- Display *d;
- Window win;
+ int r;
+ int found;
+ Display *d;
+ Window win;
- if (pid < 1)
- return -1;
+ if (pid < 1) {
+ return -1;
+ }
- r = kill(pid, 0);
- if (r == -1)
- return -1;
+ r = kill(pid, 0);
+ if (r == -1) {
+ return -1;
+ }
- d = XOpenDisplay(NULL);
- retv_if(d == NULL, -1);
+ d = XOpenDisplay(NULL);
+ retv_if(d == NULL, -1);
- win = XDefaultRootWindow(d);
+ win = XDefaultRootWindow(d);
- if (!a_pid)
- a_pid = XInternAtom(d, "X_CLIENT_PID", True);
+ if (!a_pid) {
+ a_pid = XInternAtom(d, "X_CLIENT_PID", True);
+ }
- found = __find_win(d, &win, pid);
- if (!found) {
- XCloseDisplay(d);
- _E("cannot found window with pid - %d", pid);
- return -1;
- }
+ found = __find_win(d, &win, pid);
+ if (!found) {
+ XCloseDisplay(d);
+ _E("cannot found window with pid - %d", pid);
+ return -1;
+ }
- r = __raise_win(d, win);
- if (r < 0)
- _E("fail to raise win");
+ r = __raise_win(d, win);
+ if (r < 0) {
+ _E("fail to raise win");
+ }
- XCloseDisplay(d);
+ XCloseDisplay(d);
- return r;
+ return r;
}
int x_util_get_default_size(double *w, double *h)
{
- Display *d;
- int screen_num;
+ Display *d;
+ int screen_num;
- d = XOpenDisplay(NULL);
- if (d == NULL)
- return -1;
+ d = XOpenDisplay(NULL);
+ if (d == NULL) {
+ return -1;
+ }
- screen_num = DefaultScreen(d);
+ screen_num = DefaultScreen(d);
- *w = DisplayWidth(d, screen_num);
- *h = DisplayHeight(d, screen_num);
+ *w = DisplayWidth(d, screen_num);
+ *h = DisplayHeight(d, screen_num);
- _D("Root Width = %lf, Height = %lf\n", *w, *h);
+ _D("Root Width = %lf, Height = %lf\n", *w, *h);
- XCloseDisplay(d);
+ XCloseDisplay(d);
- return 0;
+ return 0;
}
static int __cb_x_error(Display *disp, XErrorEvent *ev)
{
- _E("X error received - Error Code = %d", ev->error_code);
- return 0;
+ _E("X error received - Error Code = %d", ev->error_code);
+ return 0;
}
int x_util_init()
{
- x_old_error = XSetErrorHandler(__cb_x_error);
- return 0;
+ x_old_error = XSetErrorHandler(__cb_x_error);
+ return 0;
}
int x_util_fini()
{
- XSetErrorHandler(x_old_error);
- return 0;
+ XSetErrorHandler(x_old_error);
+ return 0;
}
* limitations under the License.
*/
-
#ifndef __UTIL_X_H_
#define __UTIL_X_H_
* limitations under the License.
*/
-
#ifdef PRELOAD_ACTIVATE
#include <dlfcn.h>
-#define PRELOAD_FILE SHARE_PREFIX"/preload_list.txt"
-#define PRELOAD_FILE_WRT SHARE_PREFIX"/preload_list_wrt.txt"
+#define PRELOAD_FILE SHARE_PREFIX "/preload_list.txt"
+#define PRELOAD_FILE_WRT SHARE_PREFIX "/preload_list_wrt.txt"
#define EFL_PREINIT_FUNC "elm_quicklaunch_init"
#define EFL_SHUTDOWN_FUNC "elm_quicklaunch_shutdown"
static char **g_argv;
static size_t max_cmdline_size = 0;
-static int (*dl_einit) () = NULL;
-static int (*dl_efini) () = NULL;
+static int (*dl_einit)() = NULL;
+static int (*dl_efini)() = NULL;
static inline void __preload_init(int argc, char **argv)
{
- void *handle = NULL;
- char soname[MAX_LOCAL_BUFSZ] = {0, };
- FILE *preload_list;
- int (*func)() = NULL;
- int i;
-
- g_argc = argc;
- g_argv = argv;
- for (i = 0; i < argc; i++) {
- max_cmdline_size += (strlen(argv[i]) + 1);
- }
- _D("max_cmdline_size = %d", max_cmdline_size);
+ void *handle = NULL;
+ char soname[MAX_LOCAL_BUFSZ] = { 0, };
+ FILE *preload_list;
+ int (*func)() = NULL;
+ int i;
+
+ g_argc = argc;
+ g_argv = argv;
+ for (i = 0; i < argc; i++) {
+ max_cmdline_size += (strlen(argv[i]) + 1);
+ }
+ _D("max_cmdline_size = %d", max_cmdline_size);
+
+ preload_list = fopen(PRELOAD_FILE, "rt");
+ if (preload_list == NULL) {
+ _E("no preload\n");
+ return;
+ }
- preload_list = fopen(PRELOAD_FILE, "rt");
- if (preload_list == NULL) {
- _E("no preload\n");
- return;
+ while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > (char*)0) {
+ soname[MAX_LOCAL_BUFSZ - 1] = 0;
+ handle = dlopen(soname, RTLD_NOW);
+ if (handle == NULL) {
+ continue;
}
+ _D("preload %s# - handle : %x\n", soname, handle);
- while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > (char*)0) {
- soname[MAX_LOCAL_BUFSZ-1] = 0;
- handle = dlopen(soname, RTLD_NOW);
- if (handle == NULL)
- continue;
- _D("preload %s# - handle : %x\n", soname, handle);
-
- func = dlsym(handle, EFL_PREINIT_FUNC);
- if (func != NULL) {
- _D("get pre-initialization function\n");
- dl_einit = func;
- func = dlsym(handle, EFL_SHUTDOWN_FUNC);
- if (func != NULL) {
- _D("get shutdown function\n");
- dl_efini = func;
- }
- }
+ func = dlsym(handle, EFL_PREINIT_FUNC);
+ if (func != NULL) {
+ _D("get pre-initialization function\n");
+ dl_einit = func;
+ func = dlsym(handle, EFL_SHUTDOWN_FUNC);
+ if (func != NULL) {
+ _D("get shutdown function\n");
+ dl_efini = func;
+ }
}
+ }
- fclose(preload_list);
- preload_initialized = 1;
+ fclose(preload_list);
+ preload_initialized = 1;
}
static inline int preinit_init()
{
- if (dl_einit != NULL)
- dl_einit(0, NULL);
- _D("pre-initialzation on");
- return 0;
+ if (dl_einit != NULL) {
+ dl_einit(0, NULL);
+ }
+ _D("pre-initialzation on");
+ return 0;
}
static inline int preinit_fini()
{
- if (dl_efini != NULL)
- dl_efini();
- _D("pre-initialization off");
- return 0;
+ if (dl_efini != NULL) {
+ dl_efini();
+ }
+ _D("pre-initialization off");
+ return 0;
}
/* TODO : how to set cmdline gracefully ?? */
static inline int __change_cmdline(char *cmdline)
{
- if (strlen(cmdline) > max_cmdline_size + 1) {
- _E("cmdline exceed max size : %d", max_cmdline_size);
- return -1;
- }
+ if (strlen(cmdline) > max_cmdline_size + 1) {
+ _E("cmdline exceed max size : %d", max_cmdline_size);
+ return -1;
+ }
- memset(g_argv[0], '\0', max_cmdline_size);
- snprintf(g_argv[0], max_cmdline_size, "%s", cmdline);
+ memset(g_argv[0], '\0', max_cmdline_size);
+ snprintf(g_argv[0], max_cmdline_size, "%s", cmdline);
- return 0;
+ return 0;
}
static inline void __preload_exec(int argc, char **argv)
{
- void *handle = NULL;
- int (*dl_main) (int, char **);
+ void *handle = NULL;
+ int (*dl_main)(int, char **);
- if (!preload_initialized)
- return;
+ if (!preload_initialized) {
+ return;
+ }
- handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
- if (handle == NULL) {
- return;
- }
+ handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
+ if (handle == NULL) {
+ return;
+ }
- dl_main = dlsym(handle, "main");
- if (dl_main != NULL) {
+ dl_main = dlsym(handle, "main");
+ if (dl_main != NULL) {
#ifndef NATIVE_LAUNCHPAD
/* do nothing */
#else
- if (__change_cmdline(argv[0]) < 0) {
- _E("change cmdline fail");
- return;
- }
-#endif
- dl_main(argc, argv);
- } else {
- _E("dlsym not founded. bad preloaded app - check fpie pie");
+ if (__change_cmdline(argv[0]) < 0) {
+ _E("change cmdline fail");
+ return;
}
+#endif
+ dl_main(argc, argv);
+ } else {
+ _E("dlsym not founded. bad preloaded app - check fpie pie");
+ }
- exit(0);
+ exit(0);
}
static int g_dlopen_size = 5;
return 1;
}
if (g_dlopen_count == g_dlopen_size || !g_dlopen_handle_list) {
- void** tmp = realloc(g_dlopen_handle_list, 2 * g_dlopen_size * sizeof(void *));
+ void** tmp =
+ realloc(g_dlopen_handle_list, 2 * g_dlopen_size * sizeof(void *));
if (NULL == tmp) {
_E("out of memory\n");
dlclose(handle);
static inline void __preload_fini_for_wrt()
{
int i = 0;
- if (!g_dlopen_handle_list)
+ if (!g_dlopen_handle_list) {
return;
- for (i = 0; i < g_dlopen_count; ++i)
- {
+ }
+ for (i = 0; i < g_dlopen_count; ++i) {
void *handle = g_dlopen_handle_list[i];
if (handle) {
if (0 != dlclose(handle)) {
while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) != NULL) {
size_t len = strnlen(soname, MAX_LOCAL_BUFSZ);
- if (len > 0)
+ if (len > 0) {
soname[len - 1] = '\0';
- handle = dlopen(soname, RTLD_NOW|RTLD_GLOBAL);
- if (handle == NULL)
+ }
+ handle = dlopen(soname, RTLD_NOW | RTLD_GLOBAL);
+ if (handle == NULL) {
continue;
+ }
if (0 != __preload_save_dlopen_handle(handle)) {
_E("Cannot save handle, no more preloads");
break;
* limitations under the License.
*/
-
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include "app_sock.h"
#include "simple_util.h"
-static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, socklen_t salen,
- int nsec);
-
+static int __connect_client_sock(int sockfd,
+ const struct sockaddr *saptr,
+ socklen_t salen,
+ int nsec);
static inline void __set_sock_option(int fd, int cli)
{
- int size;
- struct timeval tv = { 3, 200 * 1000 }; /* 3.2 sec */
-
- size = AUL_SOCK_MAXBUFF;
- setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
- setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
- if (cli)
- setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ int size;
+ struct timeval tv = { 3, 200 * 1000 }; /* 3.2 sec */
+
+ size = AUL_SOCK_MAXBUFF;
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+ setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+ if (cli) {
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ }
}
int __create_server_sock(int pid)
{
- struct sockaddr_un saddr;
- struct sockaddr_un p_saddr;
- int fd;
- mode_t orig_mask;
-
- /* Create basedir for our sockets */
- orig_mask = umask(0);
- (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
- umask(orig_mask);
-
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- /* support above version 2.6.27*/
- if (fd < 0) {
- if (errno == EINVAL) {
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- _E("second chance - socket create error");
- return -1;
- }
- } else {
- _E("socket error");
- return -1;
- }
- }
-
- bzero(&saddr, sizeof(saddr));
- saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
- unlink(saddr.sun_path);
-
- /* labeling to socket for SMACK */
- if(getuid() == 0) { // this is meaningful iff current user is ROOT
- if(smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
- /* in case of unsupported filesystem on 'socket' */
- /* or permission error by using 'emulator', bypass*/
- if((errno != EOPNOTSUPP) && (errno != EPERM)) {
- _E("labeling to socket(IPOUT) error");
+ struct sockaddr_un saddr;
+ struct sockaddr_un p_saddr;
+ int fd;
+ mode_t orig_mask;
+
+ /* Create basedir for our sockets */
+ orig_mask = umask(0);
+ (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
+ umask(orig_mask);
+
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ /* support above version 2.6.27*/
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ _E("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ _E("socket error");
+ return -1;
+ }
+ }
+
+ bzero(&saddr, sizeof(saddr));
+ saddr.sun_family = AF_UNIX;
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+ unlink(saddr.sun_path);
+
+ /* labeling to socket for SMACK */
+ if (getuid() == 0) { // this is meaningful iff current user is ROOT
+ if (smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
+ /* in case of unsupported filesystem on 'socket' */
+ /* or permission error by using 'emulator', bypass*/
+ if ((errno != EOPNOTSUPP) && (errno != EPERM)) {
+ _E("labeling to socket(IPOUT) error");
close(fd);
- return -1;
- }
- }
- if(smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
- /* in case of unsupported filesystem on 'socket' */
- /* or permission error by using 'emulator', bypass*/
- if((errno != EOPNOTSUPP) && (errno != EPERM)) {
- _E("labeling to socket(IPIN) error");
+ return -1;
+ }
+ }
+ if (smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
+ /* in case of unsupported filesystem on 'socket' */
+ /* or permission error by using 'emulator', bypass*/
+ if ((errno != EOPNOTSUPP) && (errno != EPERM)) {
+ _E("labeling to socket(IPIN) error");
close(fd);
- return -1;
- }
- }
- }
+ return -1;
+ }
+ }
+ }
+
+ if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+ _E("bind error");
+ close(fd);
+ return -1;
+ }
- if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
- _E("bind error");
+ if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ /* Flawfinder: ignore*/
+ _E("failed to change the socket permission");
close(fd);
- return -1;
- }
+ return -1;
+ }
- if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
- /* Flawfinder: ignore*/
- _E("failed to change the socket permission");
+ __set_sock_option(fd, 0);
+
+ if (listen(fd, 10) == -1) {
+ _E("listen error");
close(fd);
- return -1;
- }
-
- __set_sock_option(fd, 0);
-
- if (listen(fd, 10) == -1) {
- _E("listen error");
- close(fd);
- return -1;
- }
-
- /* support app launched by shell script */
- if (pid != WRT_LAUNCHPAD_PID) {
- int pgid;
- pgid = getpgid(pid);
- if (pgid > 1) {
- snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "%s/%d",
- AUL_SOCK_PREFIX, pgid);
- if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
- if (errno == EEXIST)
- _D("pg path - already exists");
- else
- _E("pg path - unknown create error");
- }
- }
- }
-
- return fd;
+ return -1;
+ }
+
+ /* support app launched by shell script */
+ if (pid != WRT_LAUNCHPAD_PID) {
+ int pgid;
+ pgid = getpgid(pid);
+ if (pgid > 1) {
+ snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "%s/%d",
+ AUL_SOCK_PREFIX, pgid);
+ if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
+ if (errno == EEXIST) {
+ _D("pg path - already exists");
+ } else {
+ _E("pg path - unknown create error");
+ }
+ }
+ }
+ }
+
+ return fd;
}
int __create_client_sock(int pid)
{
- int fd = -1;
- struct sockaddr_un saddr = { 0, };
- int retry = 1;
- int ret = -1;
-
- fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
- /* support above version 2.6.27*/
- if (fd < 0) {
- if (errno == EINVAL) {
- fd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- _E("second chance - socket create error");
- return -1;
- }
- } else {
- _E("socket error");
- return -1;
- }
- }
-
- saddr.sun_family = AF_UNIX;
- snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
- retry_con:
- ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
- 100 * 1000);
- if (ret < -1) {
- _E("maybe peer not launched or peer daed\n");
- if (retry > 0) {
- usleep(100 * 1000);
- retry--;
- goto retry_con;
- }
- }
- if (ret < 0) {
- close(fd);
- return -1;
- }
-
- __set_sock_option(fd, 1);
-
- return fd;
+ int fd = -1;
+ struct sockaddr_un saddr = { 0, };
+ int retry = 1;
+ int ret = -1;
+
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ /* support above version 2.6.27*/
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ _E("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ _E("socket error");
+ return -1;
+ }
+ }
+
+ saddr.sun_family = AF_UNIX;
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+retry_con:
+ ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
+ 100 * 1000);
+ if (ret < -1) {
+ _E("maybe peer not launched or peer daed\n");
+ if (retry > 0) {
+ usleep(100 * 1000);
+ retry--;
+ goto retry_con;
+ }
+ }
+ if (ret < 0) {
+ close(fd);
+ return -1;
+ }
+
+ __set_sock_option(fd, 1);
+
+ return fd;
}
-static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t salen,
- int nsec)
+static int __connect_client_sock(int fd,
+ const struct sockaddr *saptr,
+ socklen_t salen,
+ int nsec)
{
- int flags;
- int ret;
- int error;
- socklen_t len;
- fd_set readfds;
- fd_set writefds;
- struct timeval timeout;
-
- flags = fcntl(fd, F_GETFL, 0);
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- error = 0;
- if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
- if (errno != EAGAIN && errno != EINPROGRESS) {
- fcntl(fd, F_SETFL, flags);
- return (-2);
- }
- }
-
- /* Do whatever we want while the connect is taking place. */
- if (ret == 0)
- goto done; /* connect completed immediately */
-
- FD_ZERO(&readfds);
- FD_SET(fd, &readfds);
- writefds = readfds;
- timeout.tv_sec = 0;
- timeout.tv_usec = nsec;
-
- if ((ret = select(fd + 1, &readfds, &writefds, NULL,
- nsec ? &timeout : NULL)) == 0) {
- close(fd); /* timeout */
- errno = ETIMEDOUT;
- return (-1);
- }
-
- if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {
- len = sizeof(error);
- if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
- return (-1); /* Solaris pending error */
- } else
- return (-1); /* select error: sockfd not set*/
-
- done:
- (void) fcntl(fd, F_SETFL, flags);
- if (error) {
- close(fd);
- errno = error;
- return (-1);
- }
- return (0);
+ int flags;
+ int ret;
+ int error;
+ socklen_t len;
+ fd_set readfds;
+ fd_set writefds;
+ struct timeval timeout;
+
+ flags = fcntl(fd, F_GETFL, 0);
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+ error = 0;
+ if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
+ if (errno != EAGAIN && errno != EINPROGRESS) {
+ fcntl(fd, F_SETFL, flags);
+ return (-2);
+ }
+ }
+
+ /* Do whatever we want while the connect is taking place. */
+ if (ret == 0) {
+ goto done; /* connect completed immediately */
+ }
+ FD_ZERO(&readfds);
+ FD_SET(fd, &readfds);
+ writefds = readfds;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = nsec;
+
+ if ((ret = select(fd + 1, &readfds, &writefds, NULL,
+ nsec ? &timeout : NULL)) == 0)
+ {
+ close(fd); /* timeout */
+ errno = ETIMEDOUT;
+ return (-1);
+ }
+
+ if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {
+ len = sizeof(error);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) {
+ return (-1); /* Solaris pending error */
+ }
+ } else {
+ return (-1); /* select error: sockfd not set*/
+ }
+done:
+ (void) fcntl(fd, F_SETFL, flags);
+ if (error) {
+ close(fd);
+ errno = error;
+ return (-1);
+ }
+ return (0);
}
/**
*/
int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
{
- int fd;
- int len;
- int res = 0;
- app_pkt_t *pkt = NULL;
-
- if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
- _E("keybundle error\n");
- return -EINVAL;
- }
-
- fd = __create_client_sock(pid);
- if (fd < 0)
- return -ECOMM;
-
- pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return -ENOMEM;
- }
- memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
- pkt->cmd = cmd;
- pkt->len = datalen;
- memcpy(pkt->data, kb_data, datalen);
-
- if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
- _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
- if (errno == EPIPE) {
- _E("pid:%d, fd:%d\n", pid, fd);
- }
- close(fd);
- if (pkt) {
- free(pkt);
- pkt = NULL;
- }
- return -ECOMM;
- }
- if (pkt) {
- free(pkt);
- pkt = NULL;
- }
-
- len = recv(fd, &res, sizeof(int), 0);
- if (len == -1) {
- if (errno == EAGAIN) {
- _E("recv timeout \n");
- res = -EAGAIN;
- } else {
- _E("recv error\n");
- res = -ECOMM;
- }
- }
- close(fd);
-
- return res;
+ int fd;
+ int len;
+ int res = 0;
+ app_pkt_t *pkt = NULL;
+
+ if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+ _E("keybundle error\n");
+ return -EINVAL;
+ }
+
+ fd = __create_client_sock(pid);
+ if (fd < 0) {
+ return -ECOMM;
+ }
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (NULL == pkt) {
+ _E("Malloc Failed!");
+ return -ENOMEM;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ pkt->cmd = cmd;
+ pkt->len = datalen;
+ memcpy(pkt->data, kb_data, datalen);
+
+ if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+ _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+ if (errno == EPIPE) {
+ _E("pid:%d, fd:%d\n", pid, fd);
+ }
+ close(fd);
+ if (pkt) {
+ free(pkt);
+ pkt = NULL;
+ }
+ return -ECOMM;
+ }
+ if (pkt) {
+ free(pkt);
+ pkt = NULL;
+ }
+
+ len = recv(fd, &res, sizeof(int), 0);
+ if (len == -1) {
+ if (errno == EAGAIN) {
+ _E("recv timeout \n");
+ res = -EAGAIN;
+ } else {
+ _E("recv error\n");
+ res = -ECOMM;
+ }
+ }
+ close(fd);
+
+ return res;
}
app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
{
- int len;
- struct sockaddr_un aul_addr = { 0, };
- int sun_size;
- app_pkt_t *pkt = NULL;
- int cl = sizeof(struct ucred);
-
- sun_size = sizeof(struct sockaddr_un);
-
- if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
- (socklen_t *) &sun_size)) == -1) {
- if (errno != EINTR)
- _E("accept error");
- return NULL;
- }
-
- if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
- (socklen_t *) &cl) < 0) {
- _E("peer information error");
- close(*clifd);
- return NULL;
- }
-
- pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
- if(pkt == NULL) {
- close(*clifd);
- return NULL;
- }
- memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
- __set_sock_option(*clifd, 1);
-
- retry_recv:
- /* receive single packet from socket */
- len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
- if (len < 0)
- if (errno == EINTR)
- goto retry_recv;
-
- if ((len < 8) || (len != (pkt->len + 8))) {
- _E("recv error %d %d", len, pkt->len);
- free(pkt);
- close(*clifd);
- return NULL;
- }
-
- return pkt;
+ int len;
+ struct sockaddr_un aul_addr = { 0, };
+ int sun_size;
+ app_pkt_t *pkt = NULL;
+ int cl = sizeof(struct ucred);
+
+ sun_size = sizeof(struct sockaddr_un);
+
+ if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
+ (socklen_t *) &sun_size)) == -1)
+ {
+ if (errno != EINTR) {
+ _E("accept error");
+ }
+ return NULL;
+ }
+
+ if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
+ (socklen_t *) &cl) < 0)
+ {
+ _E("peer information error");
+ close(*clifd);
+ return NULL;
+ }
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (pkt == NULL) {
+ close(*clifd);
+ return NULL;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ __set_sock_option(*clifd, 1);
+
+retry_recv:
+ /* receive single packet from socket */
+ len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
+ if (len < 0) {
+ if (errno == EINTR) {
+ goto retry_recv;
+ }
+ }
+
+ if ((len < 8) || (len != (pkt->len + 8))) {
+ _E("recv error %d %d", len, pkt->len);
+ free(pkt);
+ close(*clifd);
+ return NULL;
+ }
+
+ return pkt;
}
app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
{
- int fd;
- int len;
- app_pkt_t *pkt = NULL;
-
- fd = __create_client_sock(pid);
- if (fd < 0)
- return NULL;
-
- pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
- if (NULL == pkt) {
- _E("Malloc Failed!");
- return NULL;
- }
- memset(pkt, 0, AUL_SOCK_MAXBUFF);
-
- pkt->cmd = cmd;
- pkt->len = 0;
-
- if ((len = send(fd, pkt, 8, 0)) != 8) {
- _E("sendto() failed - %d", len);
- if (errno == EPIPE) {
- _E("pid:%d, fd:%d\n", pid, fd);
- }
- close(fd);
-
- free(pkt);
- return NULL;
- }
+ int fd;
+ int len;
+ app_pkt_t *pkt = NULL;
+
+ fd = __create_client_sock(pid);
+ if (fd < 0) {
+ return NULL;
+ }
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (NULL == pkt) {
+ _E("Malloc Failed!");
+ return NULL;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ pkt->cmd = cmd;
+ pkt->len = 0;
+
+ if ((len = send(fd, pkt, 8, 0)) != 8) {
+ _E("sendto() failed - %d", len);
+ if (errno == EPIPE) {
+ _E("pid:%d, fd:%d\n", pid, fd);
+ }
+ close(fd);
+
+ free(pkt);
+ return NULL;
+ }
retry_recv:
- /* receive single packet from socket */
- len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
- if (len == -1) {
- if (errno == EAGAIN) {
- _E("recv timeout \n");
- free(pkt);
- return NULL;
- } else if (errno == EINTR) {
- goto retry_recv;
- } else {
- _E("recv error %s\n", strerror(errno));
- free(pkt);
- return NULL;
- }
- } else
- _D("recv result = %d", len);
- close(fd);
-
- return pkt;
+ /* receive single packet from socket */
+ len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
+ if (len == -1) {
+ if (errno == EAGAIN) {
+ _E("recv timeout \n");
+ free(pkt);
+ return NULL;
+ } else if (errno == EINTR) {
+ goto retry_recv;
+ } else {
+ _E("recv error %s\n", strerror(errno));
+ free(pkt);
+ return NULL;
+ }
+ } else {
+ _D("recv result = %d", len);
+ }
+ close(fd);
+
+ return pkt;
}
-
* limitations under the License.
*/
-
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include "simple_util.h"
-#define BINSH_NAME "/bin/sh"
-#define BINSH_SIZE 7
-
-#define PROC_STAT_GID_POS 5
+#define BINSH_NAME "/bin/sh"
+#define BINSH_SIZE 7
+#define PROC_STAT_GID_POS 5
static inline int __read_proc(const char *path, char *buf, int size);
static inline int __find_pid_by_cmdline(const char *dname,
- const char *cmdline, void *priv);
+ const char *cmdline, void *priv);
static inline int __get_pgid_from_stat(int pid);
-
static inline int __read_proc(const char *path, char *buf, int size)
{
- int fd;
- int ret;
+ int fd;
+ int ret;
- if (buf == NULL || path == NULL)
- return -1;
+ if (buf == NULL || path == NULL) {
+ return -1;
+ }
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -1;
+ fd = open(path, O_RDONLY);
+ if (fd < 0) {
+ return -1;
+ }
- ret = read(fd, buf, size - 1);
- if (ret <= 0) {
- close(fd);
- return -1;
- } else
- buf[ret] = 0;
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else {
+ buf[ret] = 0;
+ }
- close(fd);
+ close(fd);
- return ret;
+ return ret;
}
static inline int __find_pid_by_cmdline(const char *dname,
- const char *cmdline, void *priv)
+ const char *cmdline, void *priv)
{
- char *apppath;
- int pid = 0;
-
- apppath = (char *)priv;
- if (strncmp(cmdline, apppath, MAX_LOCAL_BUFSZ-1) == 0) {
- pid = atoi(dname);
- if (pid != getpgid(pid))
- pid = 0;
- }
-
- return pid;
+ char *apppath;
+ int pid = 0;
+
+ apppath = (char *)priv;
+ if (strncmp(cmdline, apppath, MAX_LOCAL_BUFSZ - 1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid)) {
+ pid = 0;
+ }
+ }
+
+ return pid;
}
int __proc_iter_cmdline(
- int (*iterfunc)(const char *dname, const char *cmdline, void *priv),
- void *priv)
+ int (*iterfunc)(const char *dname, const char *cmdline, void *priv),
+ void *priv)
{
- DIR *dp;
- struct dirent *dentry;
- int pid;
- int ret;
- char buf[MAX_LOCAL_BUFSZ];
-
- dp = opendir("/proc");
- if (dp == NULL) {
- return -1;
- }
-
- if (iterfunc == NULL)
- iterfunc = __find_pid_by_cmdline;
-
- while ((dentry = readdir(dp)) != NULL) {
- if (!isdigit(dentry->d_name[0]))
- continue;
-
- snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- continue;
-
- /* support app launched by shell script*/
- if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
- pid =
- iterfunc(dentry->d_name, &buf[BINSH_SIZE + 1],
- priv);
- else
- pid = iterfunc(dentry->d_name, buf, priv);
-
- if (pid > 0) {
- closedir(dp);
- return pid;
- }
- }
-
- closedir(dp);
- return -1;
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ if (iterfunc == NULL) {
+ iterfunc = __find_pid_by_cmdline;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0])) {
+ continue;
+ }
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0) {
+ continue;
+ }
+
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
+ pid =
+ iterfunc(dentry->d_name, &buf[BINSH_SIZE + 1],
+ priv);
+ } else {
+ pid = iterfunc(dentry->d_name, buf, priv);
+ }
+
+ if (pid > 0) {
+ closedir(dp);
+ return pid;
+ }
+ }
+
+ closedir(dp);
+ return -1;
}
char *__proc_get_cmdline_bypid(int pid)
{
- char buf[MAX_LOCAL_BUFSZ];
- int ret;
-
- snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- return NULL;
-
- /* support app launched by shell script*/
- if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
- return strdup(&buf[BINSH_SIZE + 1]);
- else
- return strdup(buf);
+ char buf[MAX_LOCAL_BUFSZ];
+ int ret;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0) {
+ return NULL;
+ }
+
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
+ return strdup(&buf[BINSH_SIZE + 1]);
+ } else {
+ return strdup(buf);
+ }
}
static inline int __get_pgid_from_stat(int pid)
{
- char buf[MAX_LOCAL_BUFSZ];
- char *str;
- int ret;
- int i;
- int count = 0;
-
- if (pid <= 1)
- return -1;
-
- snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret < 0)
- return -1;
-
- for (i = 0; i < (ret - 1); i++) {
- if (buf[i] == ' ') {
- count++;
- if (count == PROC_STAT_GID_POS - 1)
- str = &(buf[i + 1]);
- else if (count == PROC_STAT_GID_POS) {
- buf[i] = 0;
- break;
- }
- }
- }
-
- if (count == PROC_STAT_GID_POS)
- pid = atoi(str);
- else
- pid = -1;
-
- return pid;
+ char buf[MAX_LOCAL_BUFSZ];
+ char *str;
+ int ret;
+ int i;
+ int count = 0;
+
+ if (pid <= 1) {
+ return -1;
+ }
+
+ snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret < 0) {
+ return -1;
+ }
+
+ for (i = 0; i < (ret - 1); i++) {
+ if (buf[i] == ' ') {
+ count++;
+ if (count == PROC_STAT_GID_POS - 1) {
+ str = &(buf[i + 1]);
+ } else if (count == PROC_STAT_GID_POS) {
+ buf[i] = 0;
+ break;
+ }
+ }
+ }
+
+ if (count == PROC_STAT_GID_POS) {
+ pid = atoi(str);
+ } else {
+ pid = -1;
+ }
+
+ return pid;
}
-int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
- void *priv)
+int __proc_iter_pgid(int pgid, int (*iterfunc)(int pid, void *priv),
+ void *priv)
{
- DIR *dp;
- struct dirent *dentry;
- int _pgid;
- int ret = -1;
-
- dp = opendir("/proc");
- if (dp == NULL) {
- return -1;
- }
-
- while ((dentry = readdir(dp)) != NULL) {
- if (!isdigit(dentry->d_name[0]))
- continue;
-
- _pgid = __get_pgid_from_stat(atoi(dentry->d_name));
- if (pgid == _pgid) {
- ret = iterfunc(atoi(dentry->d_name), priv);
- if (ret >= 0)
- break;
- }
- }
-
- closedir(dp);
- return ret;
+ DIR *dp;
+ struct dirent *dentry;
+ int _pgid;
+ int ret = -1;
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0])) {
+ continue;
+ }
+
+ _pgid = __get_pgid_from_stat(atoi(dentry->d_name));
+ if (pgid == _pgid) {
+ ret = iterfunc(atoi(dentry->d_name), priv);
+ if (ret >= 0) {
+ break;
+ }
+ }
+ }
+
+ closedir(dp);
+ return ret;
}
--- /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"`