diff options
author | cookie <cookie@samsung.com> | 2017-09-14 02:15:26 +0000 |
---|---|---|
committer | cookie <cookie@samsung.com> | 2017-09-14 03:00:52 +0000 |
commit | 498ae8d78ff6605bd42f6ed10296cf8c4114e8a5 (patch) | |
tree | fee1c2c3b8b1062d9d1c13602e35ee8dee86e80d | |
parent | 19391fc48cea2373a6154e156f7d0951697210ed (diff) | |
download | browser-tizen_4.0.tar.gz browser-tizen_4.0.tar.bz2 browser-tizen_4.0.zip |
Fix the Coding Ruletizen_4.0.m2_releasetizen_4.0.IoT.p2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_4.0/20170914.031353accepted/tizen/4.0/unified/20170915.201026tizen_4.0_tvtizen_4.0accepted/tizen_4.0_unified
Change-Id: I8b8f0590531b05ae47c9c95f1f92ee4d4e7435c0
Signed-off-by: cookie <cookie@samsung.com>
208 files changed, 13919 insertions, 11658 deletions
diff --git a/core/AbstractInterfaces/AbstractFavoriteService.h b/core/AbstractInterfaces/AbstractFavoriteService.h index 39a52a74..4478a1fe 100644..100755 --- a/core/AbstractInterfaces/AbstractFavoriteService.h +++ b/core/AbstractInterfaces/AbstractFavoriteService.h @@ -54,7 +54,7 @@ public: virtual std::shared_ptr<tizen_browser::services::BookmarkItem> addBookmark(const std::string & address, const std::string & title, const std::string & note = std::string(), - std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>(), + std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail = std::shared_ptr<tizen_browser::tools::BrowserImage>(), std::shared_ptr<tizen_browser::tools::BrowserImage> favicon = std::shared_ptr<tizen_browser::tools::BrowserImage>(), unsigned int dirId = 0) = 0; @@ -110,10 +110,9 @@ public: */ virtual bool getItem(const std::string & url, tizen_browser::services::BookmarkItem *item) = 0; - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkAdded; - boost::signals2::signal<void (const std::string& uri)> bookmarkDeleted; - boost::signals2::signal<void ()> bookmarksDeleted; - + boost::signals2::signal<void(std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkAdded; + boost::signals2::signal<void(const std::string& uri)> bookmarkDeleted; + boost::signals2::signal<void()> bookmarksDeleted; }; } diff --git a/core/AbstractInterfaces/AbstractPopup.h b/core/AbstractInterfaces/AbstractPopup.h index 9d513204..4aea93f5 100644..100755 --- a/core/AbstractInterfaces/AbstractPopup.h +++ b/core/AbstractInterfaces/AbstractPopup.h @@ -45,7 +45,7 @@ public: /** * @brief show notification signal */ - boost::signals2::signal<void (interfaces::AbstractPopup*)> popupShown; + boost::signals2::signal<void(interfaces::AbstractPopup*)> popupShown; /** * @brief virtual method to close popup @@ -56,7 +56,7 @@ public: /** * @brief dismiss notification signal */ - boost::signals2::signal<void (interfaces::AbstractPopup*)> popupDismissed; + boost::signals2::signal<void(interfaces::AbstractPopup*)> popupDismissed; /** * @brief virtual method to handle back key pressed diff --git a/core/AbstractInterfaces/AbstractRotatable.h b/core/AbstractInterfaces/AbstractRotatable.h index f8f7d164..568e2cae 100644..100755 --- a/core/AbstractInterfaces/AbstractRotatable.h +++ b/core/AbstractInterfaces/AbstractRotatable.h @@ -40,14 +40,14 @@ public: * Class which implements AbstractRotatable has to connect this signal in SimpleUI class. * @returns True if rotation is portrait, false if rotation is landscape. */ - boost::signals2::signal<bool ()> isLandscape; + boost::signals2::signal<bool()> isLandscape; /** * @brief Boost signal, get what is current rotation angle. * Class which implements AbstractRotatable has to connect this signal in SimpleUI class. * @returns rotation angle. */ - boost::signals2::signal<int ()> getRotation; + boost::signals2::signal<int()> getRotation; }; }//namespace interfaces diff --git a/core/AbstractWebEngine/AbstractWebEngine.h b/core/AbstractWebEngine/AbstractWebEngine.h index f5b86dc5..b2f3aba0 100644..100755 --- a/core/AbstractWebEngine/AbstractWebEngine.h +++ b/core/AbstractWebEngine/AbstractWebEngine.h @@ -253,12 +253,12 @@ public: /** * \brief Sets Focus to URI entry. */ - virtual void setFocus()=0; + virtual void setFocus() = 0; /** * @brief Remove focus form URI */ - virtual void clearFocus()=0; + virtual void clearFocus() = 0; /** * @brief check if URI is focused @@ -400,7 +400,7 @@ public: /** * Ask browser to minimize itself */ - boost::signals2::signal<void ()> minimizeBrowser; + boost::signals2::signal<void()> minimizeBrowser; /** * Switch fullscreenmode. @@ -410,120 +410,120 @@ public: /** * FavIcon of current page changed */ - boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged; /** * Title of current page changed * \param new title */ - boost::signals2::signal<void (const std::string&)> titleChanged; + boost::signals2::signal<void(const std::string&)> titleChanged; /** * URI of current page changed * \param new URI */ - boost::signals2::signal<void (const std::string &)> uriChanged; + boost::signals2::signal<void(const std::string &)> uriChanged; /** * Possibility of go forward changed * \param bool true if it is possible to go forward, false otherwise */ - boost::signals2::signal<void (bool)> forwardEnableChanged; + boost::signals2::signal<void(bool)> forwardEnableChanged; /** * Possibility of go back changed * \param bool true if it is possible to go back, false otherwise */ - boost::signals2::signal<void (bool)> backwardEnableChanged; + boost::signals2::signal<void(bool)> backwardEnableChanged; /** * File downoad started */ - boost::signals2::signal<void (int)> downloadStarted; + boost::signals2::signal<void(int)> downloadStarted; /** * Page load finished */ - boost::signals2::signal<void ()> loadFinished; + boost::signals2::signal<void()> loadFinished; /** * Page load started */ - boost::signals2::signal<void ()> loadStarted; + boost::signals2::signal<void()> loadStarted; /** * Load progress changed * \param double 0..1 of progress */ - boost::signals2::signal<void (double)> loadProgress; + boost::signals2::signal<void(double)> loadProgress; /** * Page load stopped. */ - boost::signals2::signal<void ()> loadStop; + boost::signals2::signal<void()> loadStop; /** * Page load error. */ - boost::signals2::signal<void ()> loadError; + boost::signals2::signal<void()> loadError; /** * Current tab changed * \param TabId of new tab */ - boost::signals2::signal<void (TabId)> currentTabChanged; + boost::signals2::signal<void(TabId)> currentTabChanged; /** * New tab was created. It could be explicit call (by user) or tab could be opened from JavaScript. */ - boost::signals2::signal<void ()> tabCreated; + boost::signals2::signal<void()> tabCreated; /** * Checks if tab can be created. */ - boost::signals2::signal<bool ()> checkIfCreate; + boost::signals2::signal<bool()> checkIfCreate; /** * Tab closed * \param TabId of closed tab */ - boost::signals2::signal<void (TabId)> tabClosed; + boost::signals2::signal<void(TabId)> tabClosed; /** * Open find on page */ - boost::signals2::signal<void (const std::string&)> openFindOnPage; + boost::signals2::signal<void(const std::string&)> openFindOnPage; /** * Close find on page */ - boost::signals2::signal<void ()> closeFindOnPage; + boost::signals2::signal<void()> closeFindOnPage; /** * Confirmation Request */ - boost::signals2::signal<void (basic_webengine::WebConfirmationPtr)> confirmationRequest; + boost::signals2::signal<void(basic_webengine::WebConfirmationPtr)> confirmationRequest; /** * All links to RSS/Atom channels were gathered from webpage. */ - boost::signals2::signal<void (std::vector<std::string>)> gotFeedLinks; + boost::signals2::signal<void(std::vector<std::string>)> gotFeedLinks; /** * Status of IME * \param bool true if IME is opened, false otherwise */ - boost::signals2::signal<void (bool)> IMEStateChanged; + boost::signals2::signal<void(bool)> IMEStateChanged; /** * Switch view to actual web page */ - boost::signals2::signal<void ()> switchToWebPage; + boost::signals2::signal<void()> switchToWebPage; /** * Signal to switch to window after it is created */ - boost::signals2::signal<void ()> windowCreated; + boost::signals2::signal<void()> windowCreated; /** * Generate id for the new tab. @@ -533,12 +533,12 @@ public: /** * Set valid certificate for host. */ - boost::signals2::signal<void (const std::string&, const std::string&)> setCertificatePem; + boost::signals2::signal<void(const std::string&, const std::string&)> setCertificatePem; /** * Set invalid certificate for host. */ - boost::signals2::signal<void (const std::string&, const std::string&)> setWrongCertificatePem; + boost::signals2::signal<void(const std::string&, const std::string&)> setWrongCertificatePem; /** * Async signal to save snapshot after it is generated. @@ -549,7 +549,7 @@ public: /** * Async signal to inform the redirection has started. */ - boost::signals2::signal<void (const std::string&, const std::string&)> redirectedWebPage; + boost::signals2::signal<void(const std::string&, const std::string&)> redirectedWebPage; /** * Switch to quick access when tere is no page to witch we can return on back keys. @@ -575,7 +575,7 @@ public: /** Async signal to inform browser to finish rotation. */ - boost::signals2::signal<void ()> rotatePrepared; + boost::signals2::signal<void()> rotatePrepared; /** * Unsecure connection to https host, do not even ask to confirm, just inform. diff --git a/core/AbstractWebEngine/TabId.cpp b/core/AbstractWebEngine/TabId.cpp index b455a22b..b455a22b 100644..100755 --- a/core/AbstractWebEngine/TabId.cpp +++ b/core/AbstractWebEngine/TabId.cpp diff --git a/core/AbstractWebEngine/TabId.h b/core/AbstractWebEngine/TabId.h index 01440821..f88da8a5 100644..100755 --- a/core/AbstractWebEngine/TabId.h +++ b/core/AbstractWebEngine/TabId.h @@ -85,7 +85,6 @@ private: std::string m_title; TabOrigin m_origin; tools::BrowserImagePtr m_thumbnail; - }; } /* end of basic_webengine */ } /* end of tizen_browser */ diff --git a/core/AbstractWebEngine/TabIdTypedef.h b/core/AbstractWebEngine/TabIdTypedef.h index cab2da14..cab2da14 100644..100755 --- a/core/AbstractWebEngine/TabIdTypedef.h +++ b/core/AbstractWebEngine/TabIdTypedef.h diff --git a/core/AbstractWebEngine/TabOrigin.h b/core/AbstractWebEngine/TabOrigin.h index 513ab9c0..2d80b0fe 100644..100755 --- a/core/AbstractWebEngine/TabOrigin.h +++ b/core/AbstractWebEngine/TabOrigin.h @@ -36,7 +36,6 @@ public: bool isFromQuickAccess() const { return m_value == QUICKACCESS; } private: int m_value; - }; diff --git a/core/BasicUI/AbstractMainWindow.h b/core/BasicUI/AbstractMainWindow.h index 29baf9f4..b8224021 100644..100755 --- a/core/BasicUI/AbstractMainWindow.h +++ b/core/BasicUI/AbstractMainWindow.h @@ -54,7 +54,7 @@ public: * \todo: * Extend API of main window placeholder class. */ - void setMainWindow(T *rawPtr){ m_window=std::shared_ptr<T>(rawPtr);} + void setMainWindow(T *rawPtr){ m_window = std::shared_ptr<T>(rawPtr);} virtual void destroyUI() { } virtual void suspend() = 0; diff --git a/core/BasicUI/Action.cpp b/core/BasicUI/Action.cpp index c440f1be..9e6981d5 100644..100755 --- a/core/BasicUI/Action.cpp +++ b/core/BasicUI/Action.cpp @@ -19,190 +19,186 @@ namespace tizen_browser { -namespace base_ui -{ + namespace base_ui + { -Action::Action() + Action::Action() :m_enabled(true) - ,m_checkable(false) - ,m_checked(false) - ,m_iconVisibleInMenu(true) -{ + , m_checkable(false) + , m_checked(false) + , m_iconVisibleInMenu(true) + { + } + Action::Action(const std::string & text) + : m_text(text) + , m_enabled(true) + , m_checkable(false) + , m_checked(false) + , m_iconVisibleInMenu(true) + { + } -} -Action::Action(const std::string& text) - :m_text(text) - ,m_enabled(true) - ,m_checkable(false) - ,m_checked(false) - ,m_iconVisibleInMenu(true) -{ -} - -Action::Action(const std::string& icon, const std::string& text) - :m_text(text) - ,m_icon(icon) - ,m_enabled(true) - ,m_checkable(false) - ,m_checked(false) - ,m_iconVisibleInMenu(true) -{ -} - - -Action::Action(const Action& other) - :m_iconText(other.m_iconText) - ,m_text(other.m_text) - ,m_statusTip(other.m_statusTip) - ,m_toolTip(other.m_toolTip) - ,m_icon(other.m_icon) - ,m_selIcon(other.m_selIcon) - ,m_disIcon(other.m_disIcon) - ,m_enabled(other.m_enabled) - ,m_checkable(other.m_checkable) - ,m_checked(other.m_checked) - ,m_iconVisibleInMenu(other.m_iconVisibleInMenu) -{ + Action::Action(const std::string & icon, const std::string & text) + : m_text(text) + , m_icon(icon) + , m_enabled(true) + , m_checkable(false) + , m_checked(false) + , m_iconVisibleInMenu(true) + { + } -} -Action::~Action() -{ + Action::Action(const Action & other) + : m_iconText(other.m_iconText) + , m_text(other.m_text) + , m_statusTip(other.m_statusTip) + , m_toolTip(other.m_toolTip) + , m_icon(other.m_icon) + , m_selIcon(other.m_selIcon) + , m_disIcon(other.m_disIcon) + , m_enabled(other.m_enabled) + , m_checkable(other.m_checkable) + , m_checked(other.m_checked) + , m_iconVisibleInMenu(other.m_iconVisibleInMenu) + { + } -} + Action::~Action() { + } -std::string Action::getDisIcon() const -{ - return m_disIcon; -} + std::string Action::getDisIcon()const + { + return m_disIcon; + } -std::string Action::getIcon() const -{ - return m_icon; -} + std::string Action::getIcon() const + { + return m_icon; + } -std::string Action::getIconText() const -{ - return m_iconText; -} + std::string Action::getIconText() const + { + return m_iconText; + } -std::string Action::getSelIcon() const -{ - return m_selIcon; -} + std::string Action::getSelIcon() const + { + return m_selIcon; + } -std::string Action::getStatusTip() const -{ - return m_statusTip; -} + std::string Action::getStatusTip() const + { + return m_statusTip; + } -std::string Action::getText() const -{ - return m_text; -} + std::string Action::getText() const + { + return m_text; + } -std::string Action::getToolTip() const -{ - return m_toolTip; -} + std::string Action::getToolTip() const + { + return m_toolTip; + } -void Action::setDisIcon(const std::string& disIcon) -{ - m_disIcon = disIcon; -} + void Action::setDisIcon(const std::string & disIcon) + { + m_disIcon = disIcon; + } -void Action::setIcon(const std::string& icon) -{ - m_icon = icon; -} + void Action::setIcon(const std::string & icon) + { + m_icon = icon; + } -void Action::setIconText(const std::string& iconText) -{ - m_iconText = iconText; -} + void Action::setIconText(const std::string & iconText) + { + m_iconText = iconText; + } -void Action::setSelIcon(const std::string& selIcon) -{ - m_selIcon = selIcon; -} + void Action::setSelIcon(const std::string & selIcon) + { + m_selIcon = selIcon; + } -void Action::setStatusTip(const std::string& statusTip) -{ - m_statusTip = statusTip; -} + void Action::setStatusTip(const std::string & statusTip) + { + m_statusTip = statusTip; + } -void Action::setText(const std::string& text) -{ - m_text = text; -} + void Action::setText(const std::string & text) + { + m_text = text; + } -void Action::setToolTip(const std::string& toolTip) -{ - m_toolTip = toolTip; -} + void Action::setToolTip(const std::string & toolTip) + { + m_toolTip = toolTip; + } -bool Action::isCheckable() const -{ - return m_checkable; -} + bool Action::isCheckable() const + { + return m_checkable; + } -bool Action::isEnabled() const -{ - return m_enabled; -} + bool Action::isEnabled() const + { + return m_enabled; + } -bool Action::isIconVisibleInMenu() const -{ - return m_iconVisibleInMenu; -} + bool Action::isIconVisibleInMenu() const + { + return m_iconVisibleInMenu; + } -void Action::setCheckable(bool checkable) -{ - m_checkable = checkable; -} + void Action::setCheckable(bool checkable) + { + m_checkable = checkable; + } -void Action::setEnabled(bool enabled) -{ - if(m_enabled != enabled){ - m_enabled = enabled; - enabledChanged(); - } -} + void Action::setEnabled(bool enabled) + { + if (m_enabled != enabled) { + m_enabled = enabled; + enabledChanged(); + } + } -void Action::setIconVisibleInMenu(bool visible) -{ - m_iconVisibleInMenu = visible; -} + void Action::setIconVisibleInMenu(bool visible) + { + m_iconVisibleInMenu = visible; + } -bool Action::isChecked() const -{ - return m_checked; -} + bool Action::isChecked() const + { + return m_checked; + } -void Action::setChecked(bool checked) -{ - if(m_checkable){ - if(m_checked != checked){ - m_checked = checked; - toggled(m_checkable); - } + void Action::setChecked(bool checked) + { + if (m_checkable) { + if (m_checked != checked) { + m_checked = checked; + toggled(m_checkable); + } + } } -} -void Action::toggle() -{ - if(m_checkable){ - m_checked = !m_checked; - toggled(m_checked); + void Action::toggle() + { + if (m_checkable) { + m_checked = !m_checked; + toggled(m_checked); + } } -} -void Action::trigger() -{ - if(m_enabled){ - triggered(); + void Action::trigger() + { + if (m_enabled) { + triggered(); + } } -} -} /* end of namespace base_ui */ -} /* end of namespace tizen_browser */ + } /* end of namespace base_ui */ +} /* end of namespace tizen_browser */ diff --git a/core/BasicUI/Action.h b/core/BasicUI/Action.h index 6e597c24..52e01fca 100644..100755 --- a/core/BasicUI/Action.h +++ b/core/BasicUI/Action.h @@ -22,8 +22,8 @@ namespace tizen_browser { -namespace base_ui -{ + namespace base_ui + { /** * \brief Action provides an abstract user interface that can be inserted into toolbars or menubars. @@ -78,59 +78,59 @@ namespace base_ui * * ~~~ */ -class Action -{ -public: - Action(); - Action(const std::string& text); - Action(const std::string& icon, const std::string& text); - - Action(const Action& other); - ~Action(); - std::string getIconText()const; - std::string getText()const; - std::string getStatusTip()const; - std::string getToolTip()const; - std::string getIcon()const; - std::string getSelIcon()const; - std::string getDisIcon()const; - - void setIconText(const std::string& iconText); - void setText(const std::string& text); - void setStatusTip(const std::string& statusTip); - void setToolTip(const std::string& toolTip); - void setIcon(const std::string& icon); - void setSelIcon(const std::string& selIcon); - void setDisIcon(const std::string& disIcon); - - bool isEnabled()const; - bool isCheckable()const; - bool isChecked()const; - bool isIconVisibleInMenu()const; - - void setEnabled(bool enabled); - void setCheckable(bool checkable); - void setChecked(bool checked); - void setIconVisibleInMenu(bool visible); + class Action + { + public: + Action(); + Action(const std::string & text); + Action(const std::string & icon, const std::string & text); + + Action(const Action & other); + ~Action(); + std::string getIconText() const; + std::string getText() const; + std::string getStatusTip() const; + std::string getToolTip() const; + std::string getIcon() const; + std::string getSelIcon() const; + std::string getDisIcon() const; + + void setIconText(const std::string & iconText); + void setText(const std::string & text); + void setStatusTip(const std::string & statusTip); + void setToolTip(const std::string & toolTip); + void setIcon(const std::string & icon); + void setSelIcon(const std::string & selIcon); + void setDisIcon(const std::string & disIcon); + + bool isEnabled() const; + bool isCheckable() const; + bool isChecked() const; + bool isIconVisibleInMenu() const; + + void setEnabled(bool enabled); + void setCheckable(bool checkable); + void setChecked(bool checked); + void setIconVisibleInMenu(bool visible); /** * @brief Convenience function, switch state of checkable Actions. * */ - void toggle(); + void toggle(); /** * @brief Convenience function, manually call \see triggered() signal * */ - void trigger(); + void trigger(); /** * \brief Signale is emitted when the given action is activated by user. * * Action may be activated when user click a menu option, boolbar button */ - boost::signals2::signal<void ()> triggered; + boost::signals2::signal < void() > triggered; /** @@ -138,30 +138,30 @@ public: * * This signal is valid only for checkable actions */ - boost::signals2::signal<void (bool checked)> toggled; + boost::signals2::signal < void(bool checked) > toggled; /** * @brief Signal is emitted if Action 'enabled' state is changed. */ - boost::signals2::signal<void ()> enabledChanged; - -private: - std::string m_iconText; ///< Text displayed under the icon. - std::string m_text; ///< Text displayed in menu. - std::string m_statusTip;///< Text displayed in status bar. - std::string m_toolTip; ///< Text displayed "on mouse over" in tool tip box. - std::string m_icon; ///< Path to icon path. - std::string m_selIcon; ///< Path to selected (mouse over) icon. - std::string m_disIcon; ///< Path to disabled icon. - bool m_enabled; ///< Is action enabled. - bool m_checkable; ///< Is action checkable. - bool m_checked; ///< Is action checked, only checkable Actions can be checked. By default is false. - bool m_iconVisibleInMenu; ///<Shoud icon be displayed in menu. -}; - -typedef std::shared_ptr<Action> sharedAction; - -} /* end of namespace base_ui */ -} /* end of namespace tizen_browser */ - -#endif // ACTION_H + boost::signals2::signal < void() > enabledChanged; + + private: + std::string m_iconText; ///< Text displayed under the icon. + std::string m_text; ///< Text displayed in menu. + std::string m_statusTip; ///< Text displayed in status bar. + std::string m_toolTip; ///< Text displayed "on mouse over" in tool tip box. + std::string m_icon; ///< Path to icon path. + std::string m_selIcon; ///< Path to selected (mouse over) icon. + std::string m_disIcon; ///< Path to disabled icon. + bool m_enabled; ///< Is action enabled. + bool m_checkable; ///< Is action checkable. + bool m_checked; ///< Is action checked, only checkable Actions can be checked. By default is false. + bool m_iconVisibleInMenu; ///<Shoud icon be displayed in menu. + }; + + typedef std::shared_ptr < Action > sharedAction; + + } /* end of namespace base_ui */ +} /* end of namespace tizen_browser */ + +#endif // ACTION_H diff --git a/core/BasicUI/MenuButton.cpp b/core/BasicUI/MenuButton.cpp index 7624c085..7dffc681 100644..100755 --- a/core/BasicUI/MenuButton.cpp +++ b/core/BasicUI/MenuButton.cpp @@ -22,120 +22,132 @@ namespace tizen_browser { -namespace base_ui -{ + namespace base_ui + { -MenuButton * MenuButton::previousPopup = 0; + MenuButton *MenuButton::previousPopup = 0; -MenuButton::MenuButton(std::shared_ptr< Evas_Object > mainWindow, Evas_Object* parentButton) + MenuButton::MenuButton(std::shared_ptr < Evas_Object > mainWindow, + Evas_Object * parentButton) : m_ctxPopup(0) - , m_window(mainWindow) - , m_parentButton(parentButton) - , m_isShown(false) -{ - -} - -MenuButton::~MenuButton() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - hidePopup(); -} - - -void MenuButton::showPopup() -{ - BROWSER_LOGD("[%s:%d] this: %x ", __PRETTY_FUNCTION__, __LINE__, this); - hidePopup(); - - if (isShown()){ - m_isShown = false; - unbindFocus(); - evas_object_hide(m_ctxPopup); - onPopupDismissed(); - return; + , m_window(mainWindow) + , m_parentButton(parentButton) + , m_isShown(false) + { } - if(!m_ctxPopup) { - m_ctxPopup = elm_ctxpopup_add(m_window.get()); - BROWSER_LOGD("[%s:%d] - new popup: %x ", __PRETTY_FUNCTION__, __LINE__, m_ctxPopup); - evas_object_smart_callback_add(m_ctxPopup, "dismissed", dismissedCtxPopup, this); - elm_object_content_set(m_ctxPopup, getContent()); - elm_ctxpopup_direction_priority_set(m_ctxPopup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN); - - Evas_Coord w,h,x,y; - evas_object_geometry_get(m_window.get(), &x, &y, &w, &h); - evas_object_size_hint_max_set(m_ctxPopup, w, h); - evas_object_move(m_ctxPopup, 1650, 130); - - elm_object_style_set(m_ctxPopup, "message_popup"); + MenuButton::~MenuButton() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + hidePopup(); } - realShow(m_ctxPopup); - previousPopup = this; -} -void MenuButton::realShow(Evas_Object* popup) -{ - elm_object_focus_next_object_set(m_parentButton, getFirstFocus(), ELM_FOCUS_DOWN); - elm_object_focus_next_object_set(getFirstFocus(), m_parentButton, ELM_FOCUS_UP); - ListSize listSize = calculateSize(); - evas_object_size_hint_min_set(m_ctxPopup, listSize.width, listSize.height); - evas_object_size_hint_max_set(m_ctxPopup, listSize.width, listSize.height); + void MenuButton::showPopup() + { + BROWSER_LOGD("[%s:%d] this: %x ", __PRETTY_FUNCTION__, __LINE__, this); + hidePopup(); + + if (isShown()) { + m_isShown = false; + unbindFocus(); + evas_object_hide(m_ctxPopup); + onPopupDismissed(); + return; + } + + if (!m_ctxPopup) { + m_ctxPopup = elm_ctxpopup_add(m_window.get()); + BROWSER_LOGD("[%s:%d] - new popup: %x ", __PRETTY_FUNCTION__, + __LINE__, m_ctxPopup); + evas_object_smart_callback_add(m_ctxPopup, "dismissed", + dismissedCtxPopup, this); + elm_object_content_set(m_ctxPopup, getContent()); + elm_ctxpopup_direction_priority_set(m_ctxPopup, + ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN, + ELM_CTXPOPUP_DIRECTION_DOWN); + + Evas_Coord w, h, x, y; + evas_object_geometry_get(m_window.get(), &x, &y, &w, &h); + evas_object_size_hint_max_set(m_ctxPopup, w, h); + evas_object_move(m_ctxPopup, 1650, 130); + + elm_object_style_set(m_ctxPopup, "message_popup"); + } + realShow(m_ctxPopup); + previousPopup = this; + } - evas_object_show(popup); - m_isShown=true; - onPopupShow(); -} + void MenuButton::realShow(Evas_Object * popup) + { + elm_object_focus_next_object_set(m_parentButton, getFirstFocus(), + ELM_FOCUS_DOWN); + elm_object_focus_next_object_set(getFirstFocus(), m_parentButton, + ELM_FOCUS_UP); + + ListSize listSize = calculateSize(); + evas_object_size_hint_min_set(m_ctxPopup, listSize.width, + listSize.height); + evas_object_size_hint_max_set(m_ctxPopup, listSize.width, + listSize.height); + + evas_object_show(popup); + m_isShown = true; + onPopupShow(); + } -void MenuButton::unbindFocus() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_focus_next_object_set(m_parentButton, NULL, ELM_FOCUS_DOWN); -} + void MenuButton::unbindFocus() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_focus_next_object_set(m_parentButton, NULL, ELM_FOCUS_DOWN); + } -bool MenuButton::isShown() -{ - return m_isShown; -} + bool MenuButton::isShown() + { + return m_isShown; + } -void MenuButton::hidePopup() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(previousPopup && previousPopup->isShown() && previousPopup->canBeDismissed()) { - elm_ctxpopup_dismiss(previousPopup->m_ctxPopup); - return; + void MenuButton::hidePopup() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (previousPopup && previousPopup->isShown() + && previousPopup->canBeDismissed()) { + elm_ctxpopup_dismiss(previousPopup->m_ctxPopup); + return; + } + elm_ctxpopup_dismiss(m_ctxPopup); + m_isShown = false; } - elm_ctxpopup_dismiss(m_ctxPopup); - m_isShown = false; -} -void MenuButton::dismissedCtxPopup(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d]: data*: %x", __PRETTY_FUNCTION__, __LINE__, data); - MenuButton* self = reinterpret_cast<MenuButton*>(data); - self->m_isShown = false; - self->unbindFocus(); - evas_object_hide(self->m_ctxPopup); - self->onPopupDismissed(); -} + void MenuButton::dismissedCtxPopup(void *data, Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d]: data*: %x", __PRETTY_FUNCTION__, __LINE__, data); + MenuButton *self = reinterpret_cast < MenuButton * >(data); + self->m_isShown = false; + self->unbindFocus(); + evas_object_hide(self->m_ctxPopup); + self->onPopupDismissed(); + } -void MenuButton::onPopupShow() -{ - //default implementation does nothing -} + void MenuButton::onPopupShow() + { + //default implementation does nothing + } -void MenuButton::onPopupDismissed() -{ - //default implementation does nothing -} + void MenuButton::onPopupDismissed() + { + //default implementation does nothing + } -bool MenuButton::canBeDismissed() -{ - return true; -} + bool MenuButton::canBeDismissed() + { + return true; + } -} /* end of namespace base_ui */ -} /* end of namespace tizen_browser */ + } /* end of namespace base_ui */ +} /* end of namespace tizen_browser */ diff --git a/core/BasicUI/PopupButtons.h b/core/BasicUI/PopupButtons.h index d815745d..670f2921 100644..100755 --- a/core/BasicUI/PopupButtons.h +++ b/core/BasicUI/PopupButtons.h @@ -22,48 +22,40 @@ namespace tizen_browser { -namespace base_ui -{ + namespace base_ui + { enum PopupButtons { - NONE = 0 - ,OK = 1 << 1 - ,CANCEL = 1 << 2 - ,YES = 1 << 3 - ,NO = 1 << 4 - ,CLOSE = 1 << 5 - ,CONNECT = 1 << 6 - ,CONTINUE= 1 << 7 - ,CLOSE_TAB = 1 << 8 - ,RESET = 1 << 9 - ,DELETE = 1 << 10 - ,BACK_TO_SAFETY = 1 << 11 - ,VIEW_CERTIFICATE = 1 << 12 + NONE = 0, OK = 1 << 1, CANCEL = 1 << 2, YES = 1 << 3, NO = + 1 << 4, CLOSE = 1 << 5, CONNECT = 1 << 6, CONTINUE = + 1 << 7, CLOSE_TAB = 1 << 8, RESET = 1 << 9, DELETE = + 1 << 10, BACK_TO_SAFETY = 1 << 11, VIEW_CERTIFICATE = 1 << 12 }; - static std::map<PopupButtons, std::string> createTranslations() + static std::map < PopupButtons, std::string > createTranslations() { - std::map<PopupButtons, std::string> m; - m[OK] = "IDS_BR_SK_OK"; - m[CANCEL] = "IDS_BR_BUTTON_CANCEL"; - m[YES] = "IDS_BR_SK_YES"; - m[NO] = "IDS_BR_SK_NO"; - m[CLOSE] = "IDS_BR_BUTTON_CLOSE"; - m[CONNECT] = "Connect"; - m[CONTINUE] = "IDS_BR_BUTTON_CONTINUE"; - m[CLOSE_TAB] = "Close tab"; - m[RESET] = "IDS_BR_BUTTON_RESET_ABB"; - m[DELETE] = "IDS_BR_SK_DELETE_ABB"; - m[BACK_TO_SAFETY] = "Back to safety"; - m[VIEW_CERTIFICATE] = "IDS_BR_OPT_VIEW_CERTIFICATE"; - - return m; + std::map < PopupButtons, std::string > m; + m[OK] = "IDS_BR_SK_OK"; + m[CANCEL] = "IDS_BR_BUTTON_CANCEL"; + m[YES] = "IDS_BR_SK_YES"; + m[NO] = "IDS_BR_SK_NO"; + m[CLOSE] = "IDS_BR_BUTTON_CLOSE"; + m[CONNECT] = "Connect"; + m[CONTINUE] = "IDS_BR_BUTTON_CONTINUE"; + m[CLOSE_TAB] = "Close tab"; + m[RESET] = "IDS_BR_BUTTON_RESET_ABB"; + m[DELETE] = "IDS_BR_SK_DELETE_ABB"; + m[BACK_TO_SAFETY] = "Back to safety"; + m[VIEW_CERTIFICATE] = "IDS_BR_OPT_VIEW_CERTIFICATE"; + + return m; } - static std::map<PopupButtons, std::string> buttonsTranslations = createTranslations(); -} + static std::map < PopupButtons, std::string > buttonsTranslations = + createTranslations(); + } } -#endif //__POPUP_BUTTONS_H__ +#endif //__POPUP_BUTTONS_H__ diff --git a/core/BrowserLogger.h b/core/BrowserLogger.h index ba620f62..1b460b70 100644..100755 --- a/core/BrowserLogger.h +++ b/core/BrowserLogger.h @@ -33,10 +33,10 @@ #else -#define BROWSER_LOGD(fmt, args...) do { } while(0) -#define BROWSER_LOGI(fmt, args...) do { } while(0) -#define BROWSER_LOGW(fmt, args...) do { } while(0) -#define BROWSER_LOGE(fmt, args...) do { } while(0) +#define BROWSER_LOGD(fmt, args...) do { } while (0) +#define BROWSER_LOGI(fmt, args...) do { } while (0) +#define BROWSER_LOGW(fmt, args...) do { } while (0) +#define BROWSER_LOGE(fmt, args...) do { } while (0) #endif diff --git a/core/BrowserServiceManager.h b/core/BrowserServiceManager.h index ace280b4..ace280b4 100644..100755 --- a/core/BrowserServiceManager.h +++ b/core/BrowserServiceManager.h diff --git a/core/DownloadControl/DownloadControl.cpp b/core/DownloadControl/DownloadControl.cpp index c05e6f87..440861cb 100755 --- a/core/DownloadControl/DownloadControl.cpp +++ b/core/DownloadControl/DownloadControl.cpp @@ -35,8 +35,10 @@ static const char *sdp_mime = "application/sdp"; DownloadControl::DownloadControl(void) - : m_download_uri() - , m_parent(nullptr) + : +m_download_uri() + , +m_parent(nullptr) { } @@ -44,443 +46,493 @@ DownloadControl::~DownloadControl(void) { } -void DownloadControl::init(Evas_Object* parent) +void +DownloadControl::init(Evas_Object * parent) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_parent = parent; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_parent = parent; } -Evas_Object *DownloadControl::brui_popup_add(Evas_Object *parent) +Evas_Object * +DownloadControl::brui_popup_add(Evas_Object * parent) { - Evas_Object *popup = NULL; - popup = elm_popup_add(parent); - elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); - return popup; + Evas_Object *popup = NULL; + popup = elm_popup_add(parent); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + return popup; } -Eina_Bool DownloadControl::launch_streaming_player(const char *uri) +Eina_Bool +DownloadControl::launch_streaming_player(const char *uri) { - BROWSER_LOGD("[%s:%d] uri = [%s] ", __PRETTY_FUNCTION__, __LINE__, uri); - - bool vt_call_check = false; - if (app_manager_is_running(sec_vt_app, &vt_call_check) < 0) { - BROWSER_LOGE("[%s:%d] Fail to get app running information", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (vt_call_check) { - return EINA_FALSE; - } - - app_control_h app_control = NULL; - - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("[%s:%d] Fail to create app_control handle", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (!app_control) { - BROWSER_LOGE("[%s:%d] app_control handle is NULL", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) { - BROWSER_LOGE("[%s:%d] app_control_set_operation failed", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } - - if (app_control_set_mime(app_control, "video/") < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_set_mime", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + BROWSER_LOGD("[%s:%d] uri = [%s] ", __PRETTY_FUNCTION__, __LINE__, uri); + + bool vt_call_check = false; + if (app_manager_is_running(sec_vt_app, &vt_call_check) < 0) { + BROWSER_LOGE("[%s:%d] Fail to get app running information", + __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + + if (vt_call_check) { + return EINA_FALSE; + } + + app_control_h app_control = NULL; + + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("[%s:%d] Fail to create app_control handle", + __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + + if (!app_control) { + BROWSER_LOGE("[%s:%d] app_control handle is NULL", __PRETTY_FUNCTION__, + __LINE__); + return EINA_FALSE; + } + + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) { + BROWSER_LOGE("[%s:%d] app_control_set_operation failed", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if (app_control_add_extra_data(app_control, "path", uri) < 0) { - BROWSER_LOGE("[%s:%d] Fail to set extra data", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_set_mime(app_control, "video/") < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_set_mime", __PRETTY_FUNCTION__, + __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("[%s:%d] Fail to launch app_control operation", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_add_extra_data(app_control, "path", uri) < 0) { + BROWSER_LOGE("[%s:%d] Fail to set extra data", __PRETTY_FUNCTION__, + __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("[%s:%d] Fail to launch app_control operation", + __PRETTY_FUNCTION__, __LINE__); app_control_destroy(app_control); + return EINA_FALSE; + } - return EINA_TRUE; + app_control_destroy(app_control); + + return EINA_TRUE; } -void DownloadControl::__sdp_download_finished_cb(const char *file_path, void *data) +void +DownloadControl::__sdp_download_finished_cb(const char *file_path, void *data) { - BROWSER_LOGD("[%s:%d]file_path = [%s]", __PRETTY_FUNCTION__, __LINE__, file_path); - BROWSER_LOGD("[%s:%d]data = [%p] ", __PRETTY_FUNCTION__, __LINE__, data); + BROWSER_LOGD("[%s:%d]file_path = [%s]", __PRETTY_FUNCTION__, __LINE__, + file_path); + BROWSER_LOGD("[%s:%d]data = [%p] ", __PRETTY_FUNCTION__, __LINE__, data); } -char *DownloadControl::get_file_size_str(const char *full_path) +char * +DownloadControl::get_file_size_str(const char *full_path) { - FILE *fp = NULL; - long size = 0; - double size_double = 0.0f; - char size_str[10 + 1] = {0, }; - std::string size_text; - - fp = fopen(full_path, "r"); - if (!fp) - return NULL; - fseek(fp, 0L, SEEK_END); - size = ftell(fp); - fclose(fp); - - if (size >= unit_size) { - size_double = (double)size / (double)unit_size; - if (size_double >= unit_size) { - size_double = (double)size_double / (double)unit_size; - if (size_double >= unit_size) { - size_double = (double)size_double / (double)unit_size; - snprintf(size_str, 10, "%.2f", size_double); - size_text = std::string(size_str) + std::string("GB"); - } else { - snprintf(size_str, 10, "%.2f", size_double); - size_text = std::string(size_str) + std::string("MB"); - } - } else { - snprintf(size_str, 10, "%.2f", size_double); - size_text = std::string(size_str) + std::string("KB"); - } + FILE *fp = NULL; + long size = 0; + double size_double = 0.0f; + char size_str[10 + 1] = { 0, }; + std::string size_text; + + fp = fopen(full_path, "r"); + if (!fp) + return NULL; + fseek(fp, 0L, SEEK_END); + size = ftell(fp); + fclose(fp); + + if (size >= unit_size) { + size_double = (double) size / (double) unit_size; + if (size_double >= unit_size) { + size_double = (double) size_double / (double) unit_size; + if (size_double >= unit_size) { + size_double = (double) size_double / (double) unit_size; + snprintf(size_str, 10, "%.2f", size_double); + size_text = std::string(size_str) + std::string("GB"); + } else { + snprintf(size_str, 10, "%.2f", size_double); + size_text = std::string(size_str) + std::string("MB"); + } } else { - snprintf(size_str, 10, "%u", (int)size); - size_text = std::string(size_str) + std::string("B"); + snprintf(size_str, 10, "%.2f", size_double); + size_text = std::string(size_str) + std::string("KB"); } + } else { + snprintf(size_str, 10, "%u", (int) size); + size_text = std::string(size_str) + std::string("B"); + } - return strdup(size_text.c_str()); + return strdup(size_text.c_str()); } -Eina_Bool DownloadControl::_check_file_exist(const char *path) +Eina_Bool +DownloadControl::_check_file_exist(const char *path) { - BROWSER_LOGD("[%s:%d] path = [%s]", __PRETTY_FUNCTION__, __LINE__, path); + BROWSER_LOGD("[%s:%d] path = [%s]", __PRETTY_FUNCTION__, __LINE__, path); - if (!strlen(path)) { - BROWSER_LOGE("[%s:%d] path has no string", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } + if (!strlen(path)) { + BROWSER_LOGE("[%s:%d] path has no string", __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } - struct stat file_state; - int stat_ret = 0; + struct stat file_state; + int stat_ret = 0; - stat_ret = stat(path, &file_state); - if (stat_ret != 0){ - BROWSER_LOGE("[%s:%d] failed to stat", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } + stat_ret = stat(path, &file_state); + if (stat_ret != 0) { + BROWSER_LOGE("[%s:%d] failed to stat", __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } - if (!S_ISREG(file_state.st_mode)) { - BROWSER_LOGE("[%s:%d] File does not exist", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } + if (!S_ISREG(file_state.st_mode)) { + BROWSER_LOGE("[%s:%d] File does not exist", __PRETTY_FUNCTION__, + __LINE__); + return EINA_FALSE; + } - return EINA_TRUE; + return EINA_TRUE; } -Eina_Bool DownloadControl::_save_file(const char *raw_data, const char *path) +Eina_Bool +DownloadControl::_save_file(const char *raw_data, const char *path) { - int fd = 0; - int write_len = 0; - gsize length = 0; - guchar *decoded_data = NULL; - - decoded_data = g_base64_decode((gchar *)raw_data, &length); - if (!decoded_data) { - BROWSER_LOGE("[%s:%d] failed to decode raw data", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (!strlen((char*)decoded_data)) { - BROWSER_LOGE("[%s:%d] has no data", __PRETTY_FUNCTION__, __LINE__); - g_free(decoded_data); - decoded_data = NULL; - return EINA_FALSE; - } - - if ((fd = open(path, O_CREAT | O_WRONLY, S_IRUSR|S_IWUSR | S_IRGRP | S_IROTH)) < 0) { - BROWSER_LOGE("[%s:%d] failed to file open to save raw data", __PRETTY_FUNCTION__, __LINE__); - g_free(decoded_data); - decoded_data = NULL; - return EINA_FALSE; - } - - write_len = write(fd, decoded_data, length); - close(fd); - - if (write_len != (int)length) { - BROWSER_LOGE("[%s:%d] failed to save raw data normally", __PRETTY_FUNCTION__, __LINE__); - unlink(path); - g_free(decoded_data); - decoded_data = NULL; - return EINA_FALSE; - } - - if (decoded_data){ - g_free(decoded_data); - decoded_data = NULL; - } - - return EINA_TRUE; + int fd = 0; + int write_len = 0; + gsize length = 0; + guchar *decoded_data = NULL; + + decoded_data = g_base64_decode((gchar *) raw_data, &length); + if (!decoded_data) { + BROWSER_LOGE("[%s:%d] failed to decode raw data", __PRETTY_FUNCTION__, + __LINE__); + return EINA_FALSE; + } + + if (!strlen((char *) decoded_data)) { + BROWSER_LOGE("[%s:%d] has no data", __PRETTY_FUNCTION__, __LINE__); + g_free(decoded_data); + decoded_data = NULL; + return EINA_FALSE; + } + + if ((fd = + open(path, O_CREAT | O_WRONLY, + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) { + BROWSER_LOGE("[%s:%d] failed to file open to save raw data", + __PRETTY_FUNCTION__, __LINE__); + g_free(decoded_data); + decoded_data = NULL; + return EINA_FALSE; + } + + write_len = write(fd, decoded_data, length); + close(fd); + + if (write_len != (int) length) { + BROWSER_LOGE("[%s:%d] failed to save raw data normally", + __PRETTY_FUNCTION__, __LINE__); + unlink(path); + g_free(decoded_data); + decoded_data = NULL; + return EINA_FALSE; + } + + if (decoded_data) { + g_free(decoded_data); + decoded_data = NULL; + } + + return EINA_TRUE; } -Eina_Bool DownloadControl::_update_contents_on_media_db(const char *path) +Eina_Bool +DownloadControl::_update_contents_on_media_db(const char *path) { - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - - if (!strlen(path)) { - BROWSER_LOGD("[%s:%d] path has no string", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - int ret = -1; - media_info_h info = NULL; - - ret = media_content_connect(); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - BROWSER_LOGE("[%s:%d] Fail to media_content_connect", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - ret = media_info_insert_to_db(path, &info); - if (ret != MEDIA_CONTENT_ERROR_NONE || info == NULL) { - BROWSER_LOGE("[%s:%d] Fail to media_info_insert_to_db [%d]", __PRETTY_FUNCTION__, __LINE__, ret); - media_content_disconnect(); - if (info) - media_info_destroy(info); - return EINA_FALSE; - } - - media_info_destroy(info); - ret = media_content_disconnect(); - if (ret != MEDIA_CONTENT_ERROR_NONE) { - BROWSER_LOGE("[%s:%d] Fail to media_content_disconnect", __PRETTY_FUNCTION__, __LINE__); - } - - return EINA_TRUE; + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + + if (!strlen(path)) { + BROWSER_LOGD("[%s:%d] path has no string", __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + + int ret = -1; + media_info_h info = NULL; + + ret = media_content_connect(); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + BROWSER_LOGE("[%s:%d] Fail to media_content_connect", __PRETTY_FUNCTION__, + __LINE__); + return EINA_FALSE; + } + + ret = media_info_insert_to_db(path, &info); + if (ret != MEDIA_CONTENT_ERROR_NONE || info == NULL) { + BROWSER_LOGE("[%s:%d] Fail to media_info_insert_to_db [%d]", + __PRETTY_FUNCTION__, __LINE__, ret); + media_content_disconnect(); + if (info) + media_info_destroy(info); + return EINA_FALSE; + } + + media_info_destroy(info); + ret = media_content_disconnect(); + if (ret != MEDIA_CONTENT_ERROR_NONE) { + BROWSER_LOGE("[%s:%d] Fail to media_content_disconnect", + __PRETTY_FUNCTION__, __LINE__); + } + + return EINA_TRUE; } -Eina_Bool DownloadControl::_get_download_path(const char *extension, char **full_path, char **file_name) +Eina_Bool +DownloadControl::_get_download_path(const char *extension, char **full_path, + char **file_name) { - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - char temp_count_str[10] = {0}; - int count = 0; + char temp_count_str[10] = { 0 }; + int count = 0; - std::string storing_path; + std::string storing_path; - storing_path = std::string(default_device_storage_path); + storing_path = std::string(default_device_storage_path); - std::string only_file_name = std::string(default_download_item_name) + std::string(".") + std::string(extension); - std::string entire_path_name = storing_path + std::string(default_download_item_name) + std::string(".") + std::string(extension); + std::string only_file_name = + std::string(default_download_item_name) + std::string(".") + + std::string(extension); + std::string entire_path_name = + storing_path + std::string(default_download_item_name) + + std::string(".") + std::string(extension); - while(_check_file_exist((const char *)entire_path_name.c_str()) == EINA_TRUE) { - count++; - memset(temp_count_str, 0, 10); - snprintf(temp_count_str, 10, "_%d", count); + while (_check_file_exist((const char *) entire_path_name.c_str()) == + EINA_TRUE) { + count++; + memset(temp_count_str, 0, 10); + snprintf(temp_count_str, 10, "_%d", count); - only_file_name.clear(); - only_file_name = std::string(default_download_item_name) - + std::string(temp_count_str) - + std::string(".") - + std::string(extension); + only_file_name.clear(); + only_file_name = std::string(default_download_item_name) + + std::string(temp_count_str) + + std::string(".") + + std::string(extension); - entire_path_name.clear(); - entire_path_name = storing_path - + std::string(default_download_item_name) - + std::string(temp_count_str) - + std::string(".") - + std::string(extension); + entire_path_name.clear(); + entire_path_name = storing_path + std::string(default_download_item_name) + + std::string(temp_count_str) + + std::string(".") + + std::string(extension); - if (count > BROWSER_DATA_SCHEME_DOWNLOAD_ALLOW_MAX_COUNT) { - entire_path_name.clear(); - only_file_name.clear(); - break; - } + if (count > BROWSER_DATA_SCHEME_DOWNLOAD_ALLOW_MAX_COUNT) { + entire_path_name.clear(); + only_file_name.clear(); + break; } + } - Eina_Bool ok = EINA_FALSE; + Eina_Bool ok = EINA_FALSE; - if (!entire_path_name.empty()) - { - *full_path = strdup(entire_path_name.c_str()); - *file_name = strdup(only_file_name.c_str()); - ok = EINA_TRUE; - } + if (!entire_path_name.empty()) { + *full_path = strdup(entire_path_name.c_str()); + *file_name = strdup(only_file_name.c_str()); + ok = EINA_TRUE; + } - return ok; + return ok; } -void DownloadControl::handle_download_request(const char *uri, const char *content_type) +void +DownloadControl::handle_download_request(const char *uri, + const char *content_type) { - BROWSER_LOGD("[%s:%d] uri = [%s], content_type = [%s]", __PRETTY_FUNCTION__, __LINE__, uri, content_type); + BROWSER_LOGD("[%s:%d] uri = [%s], content_type = [%s]", __PRETTY_FUNCTION__, + __LINE__, uri, content_type); - m_download_uri.clear(); + m_download_uri.clear(); - m_download_uri = std::string(uri); + m_download_uri = std::string(uri); - if (!content_type) { - launch_download_app(uri); - return; - } + if (!content_type) { + launch_download_app(uri); + return; + } - if (!strcmp(content_type, sdp_mime)) { - Evas_Object *popup = brui_popup_add(m_parent); - Evas_Object *app_list = elm_list_add(popup); + if (!strcmp(content_type, sdp_mime)) { + Evas_Object *popup = brui_popup_add(m_parent); + Evas_Object *app_list = elm_list_add(popup); - elm_list_mode_set(app_list, ELM_LIST_EXPAND); - evas_object_size_hint_max_set(app_list, -1, APP_LIST_HEIGHT); - } else { - launch_download_app(uri); - } + elm_list_mode_set(app_list, ELM_LIST_EXPAND); + evas_object_size_hint_max_set(app_list, -1, APP_LIST_HEIGHT); + } else { + launch_download_app(uri); + } } -Eina_Bool DownloadControl::handle_data_scheme(const char *uri) +Eina_Bool +DownloadControl::handle_data_scheme(const char *uri) { - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - - const char *encoded_str = NULL; - const char *extension = NULL; - - if (!strncmp(uri, data_scheme_jpeg_base64, strlen(data_scheme_jpeg_base64))) { - encoded_str = uri + strlen(data_scheme_jpeg_base64) + 1; // 1 is reserved for separator ',' - extension = (const char *)"jpeg"; - } else if (!strncmp(uri, data_scheme_jpg_base64, strlen(data_scheme_jpg_base64))) { - encoded_str = uri + strlen(data_scheme_jpg_base64) + 1; // 1 is reserved for separator ',' - extension = (const char *)"jpg"; - } else if (!strncmp(uri, data_scheme_png_base64, strlen(data_scheme_png_base64))) { - encoded_str = uri + strlen(data_scheme_png_base64) + 1; // 1 is reserved for separator ',' - extension = (const char *)"png"; - } else if (!strncmp(uri, data_scheme_gif_base64, strlen(data_scheme_gif_base64))) { - encoded_str = uri + strlen(data_scheme_gif_base64) + 1; // 1 is reserved for separator ',' - extension = (const char *)"gif"; - } else { - BROWSER_LOGD("[%s:%d] Un-recognizable data scheme type", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - char *full_path = NULL; - char *file_name = NULL; - if (_get_download_path(extension, &full_path, &file_name) == EINA_FALSE) { - BROWSER_LOGE("[%s:%d] failed to _get_download_path", __PRETTY_FUNCTION__, __LINE__); - if(full_path){ - free(full_path); - } - if(file_name){ - free(file_name); - } - return EINA_FALSE; - } - - if (!(full_path && strlen(full_path)) || !(file_name && strlen(file_name))) { - BROWSER_LOGE("[%s:%d] has problem to _get_download_path", __PRETTY_FUNCTION__, __LINE__); - if(full_path){ - free(full_path); - } - if(file_name){ - free(file_name); - } - return EINA_FALSE; - } - - if (_save_file(encoded_str, full_path) == EINA_FALSE) { - BROWSER_LOGE("[%s:%d] failed to _save_file with path [%s]", __PRETTY_FUNCTION__, __LINE__, full_path); - if(full_path){ - free(full_path); - } - if(file_name){ - free(file_name); - } - return EINA_FALSE; - } - - if (_update_contents_on_media_db(full_path) == EINA_FALSE) { - BROWSER_LOGE("[%s:%d] failed to _update_contents_on_media_db with path [%s]", __PRETTY_FUNCTION__, __LINE__, full_path); - if(full_path){ - free(full_path); - } - if(file_name){ - free(file_name); - } - return EINA_FALSE; - } - if(full_path){ - free(full_path); - } - if(file_name){ - free(file_name); - } - return EINA_TRUE; + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + + const char *encoded_str = NULL; + const char *extension = NULL; + + if (!strncmp(uri, data_scheme_jpeg_base64, strlen(data_scheme_jpeg_base64))) { + encoded_str = uri + strlen(data_scheme_jpeg_base64) + 1; // 1 is reserved for separator ',' + extension = (const char *) "jpeg"; + } else if (!strncmp(uri, data_scheme_jpg_base64, strlen(data_scheme_jpg_base64))) { + encoded_str = uri + strlen(data_scheme_jpg_base64) + 1; // 1 is reserved for separator ',' + extension = (const char *) "jpg"; + } else if (!strncmp(uri, data_scheme_png_base64, strlen(data_scheme_png_base64))) { + encoded_str = uri + strlen(data_scheme_png_base64) + 1; // 1 is reserved for separator ',' + extension = (const char *) "png"; + } else if (!strncmp(uri, data_scheme_gif_base64, strlen(data_scheme_gif_base64))) { + encoded_str = uri + strlen(data_scheme_gif_base64) + 1; // 1 is reserved for separator ',' + extension = (const char *) "gif"; + } else { + BROWSER_LOGD("[%s:%d] Un-recognizable data scheme type", + __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + + char *full_path = NULL; + char *file_name = NULL; + if (_get_download_path(extension, &full_path, &file_name) == EINA_FALSE) { + BROWSER_LOGE("[%s:%d] failed to _get_download_path", __PRETTY_FUNCTION__, + __LINE__); + if (full_path) { + free(full_path); + } + if (file_name) { + free(file_name); + } + return EINA_FALSE; + } + + if (!(full_path && strlen(full_path)) || !(file_name && strlen(file_name))) { + BROWSER_LOGE("[%s:%d] has problem to _get_download_path", + __PRETTY_FUNCTION__, __LINE__); + if (full_path) { + free(full_path); + } + if (file_name) { + free(file_name); + } + return EINA_FALSE; + } + + if (_save_file(encoded_str, full_path) == EINA_FALSE) { + BROWSER_LOGE("[%s:%d] failed to _save_file with path [%s]", + __PRETTY_FUNCTION__, __LINE__, full_path); + if (full_path) { + free(full_path); + } + if (file_name) { + free(file_name); + } + return EINA_FALSE; + } + + if (_update_contents_on_media_db(full_path) == EINA_FALSE) { + BROWSER_LOGE + ("[%s:%d] failed to _update_contents_on_media_db with path [%s]", + __PRETTY_FUNCTION__, __LINE__, full_path); + if (full_path) { + free(full_path); + } + if (file_name) { + free(file_name); + } + return EINA_FALSE; + } + if (full_path) { + free(full_path); + } + if (file_name) { + free(file_name); + } + return EINA_TRUE; } -Eina_Bool DownloadControl::launch_download_app(const char *uri) +Eina_Bool +DownloadControl::launch_download_app(const char *uri) { - BROWSER_LOGD("[%s:%d] uri = [%s]", __PRETTY_FUNCTION__, __LINE__, uri); - - app_control_h app_control = NULL; - - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("[%s:%d] Fail to create app_control handle", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (!app_control) { - BROWSER_LOGE("[%s:%d] app_control handle is NULL", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_DOWNLOAD) < 0) { - BROWSER_LOGE("[%s:%d] Fail to set app_control operation", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + BROWSER_LOGD("[%s:%d] uri = [%s]", __PRETTY_FUNCTION__, __LINE__, uri); + + app_control_h app_control = NULL; + + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("[%s:%d] Fail to create app_control handle", + __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + + if (!app_control) { + BROWSER_LOGE("[%s:%d] app_control handle is NULL", __PRETTY_FUNCTION__, + __LINE__); + return EINA_FALSE; + } + + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_DOWNLOAD) < + 0) { + BROWSER_LOGE("[%s:%d] Fail to set app_control operation", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if (app_control_set_uri(app_control, uri) < 0) { - BROWSER_LOGE("[%s:%d] Fail to set uri", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("[%s:%d] Fail to set uri", __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if (app_control_add_extra_data(app_control, "mode", "silent") < 0) { - BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_add_extra_data(app_control, "mode", "silent") < 0) { + BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - const char *storage_type = "0"; //phone memory + const char *storage_type = "0"; //phone memory - if (app_control_add_extra_data(app_control, "default_storage", storage_type) < 0) { - BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_add_extra_data(app_control, "default_storage", storage_type) + < 0) { + BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if (app_control_add_extra_data(app_control, "network_bonding", "true") < 0) { - BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_add_extra_data(app_control, "network_bonding", "true") < 0) { + BROWSER_LOGE("[%s:%d] Fail to set app_control extra data", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return EINA_FALSE; + } - if ( app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("[%s:%d] Fail to launch app_control operation", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return EINA_FALSE; - } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("[%s:%d] Fail to launch app_control operation", + __PRETTY_FUNCTION__, __LINE__); app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); - return EINA_TRUE; + return EINA_TRUE; } -void DownloadControl::show_noti_popup(const char *msg) +void +DownloadControl::show_noti_popup(const char *msg) { - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - notification_status_message_post(msg); - elm_access_say(msg); + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + notification_status_message_post(msg); + elm_access_say(msg); } - diff --git a/core/Logger/AbstractLogger.h b/core/Logger/AbstractLogger.h index 546d5a08..546d5a08 100644..100755 --- a/core/Logger/AbstractLogger.h +++ b/core/Logger/AbstractLogger.h diff --git a/core/Logger/DLOGLogger.cpp b/core/Logger/DLOGLogger.cpp index f3c22533..fc80290f 100644..100755 --- a/core/Logger/DLOGLogger.cpp +++ b/core/Logger/DLOGLogger.cpp @@ -41,7 +41,6 @@ DLOGLogger::~DLOGLogger() { } void DLOGLogger::init() { - } void DLOGLogger::log(const std::string & /*timeStamp*/, const std::string & tag, const std::string & msg, bool /*errorFlag*/) { @@ -70,7 +69,7 @@ void DLOGLogger::log(const std::string & /*timeStamp*/, const std::string & tag, priority = DLOG_DEFAULT; break; } - __dlog_print(LOG_ID_SYSTEM,priority, tag.c_str(), "%s", msg.c_str()); + __dlog_print(LOG_ID_SYSTEM, priority, tag.c_str(), "%s", msg.c_str()); } } /* end namespace logger */ diff --git a/core/Logger/DLOGLogger.h b/core/Logger/DLOGLogger.h index 78a31b91..5960c947 100644..100755 --- a/core/Logger/DLOGLogger.h +++ b/core/Logger/DLOGLogger.h @@ -38,7 +38,7 @@ public: ~DLOGLogger(); virtual void init(); - virtual void log(const std::string &timeStamp, const std::string &tag,const std::string &msg, bool errorFlag = false); + virtual void log(const std::string &timeStamp, const std::string &tag, const std::string &msg, bool errorFlag = false); private: }; diff --git a/core/Logger/Logger.cpp b/core/Logger/Logger.cpp index 1948e12d..0bac037d 100755 --- a/core/Logger/Logger.cpp +++ b/core/Logger/Logger.cpp @@ -150,16 +150,16 @@ int Logger::registerLogger(AbstractLogger *l) { std::string Logger::timeStamp() { time_t initializer = time(NULL); struct tm b; - if(localtime_r(&initializer,&b)==NULL){ + if (localtime_r(&initializer, &b) == NULL) { return std::string(""); } struct timeval detail_time; - gettimeofday(&detail_time,NULL); + gettimeofday(&detail_time, NULL); char buf[80]; // strftime(buf, sizeof(buf), "%d/%m/%y,%T ", brokenTime, detail_time.tv_usec/1000); - snprintf(buf, sizeof(buf),"[%d/%d/%d,%d:%d:%d.%ld]", b.tm_year, b.tm_mon, b.tm_mday, b.tm_hour, b.tm_min, b.tm_sec, detail_time.tv_usec/1000); + snprintf(buf, sizeof(buf), "[%d/%d/%d,%d:%d:%d.%ld]", b.tm_year, b.tm_mon, b.tm_mday, b.tm_hour, b.tm_min, b.tm_sec, detail_time.tv_usec/1000); return std::string(buf); } diff --git a/core/Logger/Logger.h b/core/Logger/Logger.h index d53aa766..d53aa766 100644..100755 --- a/core/Logger/Logger.h +++ b/core/Logger/Logger.h diff --git a/core/Logger/LoggerTools.cpp b/core/Logger/LoggerTools.cpp index ce112750..ce112750 100644..100755 --- a/core/Logger/LoggerTools.cpp +++ b/core/Logger/LoggerTools.cpp diff --git a/core/Logger/TextLogger.cpp b/core/Logger/TextLogger.cpp index f452d03e..f452d03e 100644..100755 --- a/core/Logger/TextLogger.cpp +++ b/core/Logger/TextLogger.cpp diff --git a/core/Logger/TextLogger.h b/core/Logger/TextLogger.h index a2f503e2..a2f503e2 100644..100755 --- a/core/Logger/TextLogger.h +++ b/core/Logger/TextLogger.h diff --git a/core/Logger/Useloggers.cpp b/core/Logger/Useloggers.cpp index c2a1d8e3..c2a1d8e3 100644..100755 --- a/core/Logger/Useloggers.cpp +++ b/core/Logger/Useloggers.cpp diff --git a/core/ServiceManager/AbstractService.h b/core/ServiceManager/AbstractService.h index 75e85f54..75e85f54 100644..100755 --- a/core/ServiceManager/AbstractService.h +++ b/core/ServiceManager/AbstractService.h diff --git a/core/ServiceManager/Debug/BrowserAssert.cpp b/core/ServiceManager/Debug/BrowserAssert.cpp index fc4991e8..fc4991e8 100644..100755 --- a/core/ServiceManager/Debug/BrowserAssert.cpp +++ b/core/ServiceManager/Debug/BrowserAssert.cpp diff --git a/core/ServiceManager/Debug/BrowserAssert.h b/core/ServiceManager/Debug/BrowserAssert.h index c7459022..9d2298b4 100644..100755 --- a/core/ServiceManager/Debug/BrowserAssert.h +++ b/core/ServiceManager/Debug/BrowserAssert.h @@ -25,9 +25,9 @@ * \param condition - condition to be tested. * \post Normal progam flow is continued only if condition is met, otherwise EFailedAssertion exception is thrown. */ -# define M_ASSERT( condition ) do { if ( ! ( condition ) ) tizen_browser::debug::failed_assert( __FILE__, __LINE__, __PRETTY_FUNCTION__, #condition ); } while ( 0 ) +# define M_ASSERT( condition ) do { if ( !( condition ) ) tizen_browser::debug::failed_assert( __FILE__, __LINE__, __PRETTY_FUNCTION__, #condition ); } while ( 0 ) #else /* #ifndef NDEBUG */ -# define M_ASSERT( c ) /**/ +# define M_ASSERT(c) /**/ #endif /* #else #ifndef NDEBUG */ namespace tizen_browser diff --git a/core/ServiceManager/Debug/Lifecycle.h b/core/ServiceManager/Debug/Lifecycle.h index 34041fc7..a97ba8df 100644..100755 --- a/core/ServiceManager/Debug/Lifecycle.h +++ b/core/ServiceManager/Debug/Lifecycle.h @@ -36,7 +36,6 @@ struct ShowLifeCycle { ~ShowLifeCycle() { BROWSER_LOGD("Destroyed object: '%s'", type<T>().c_str()); } - }; #else diff --git a/core/ServiceManager/ServiceFactory.cpp b/core/ServiceManager/ServiceFactory.cpp index 5da7f611..db48505c 100644..100755 --- a/core/ServiceManager/ServiceFactory.cpp +++ b/core/ServiceManager/ServiceFactory.cpp @@ -20,20 +20,18 @@ namespace tizen_browser { -namespace core -{ + namespace core + { //leave this functions to satisfy linker. -ServiceFactory::ServiceFactory() -{ - -} - -ServiceFactory::~ServiceFactory() -{ + ServiceFactory::ServiceFactory() + { + } -} + ServiceFactory::~ServiceFactory() + { + } -} /* end of namespace core */ -} /* end of namespace tizen_browser */ + } /* end of namespace core */ +} /* end of namespace tizen_browser */ diff --git a/core/ServiceManager/ServiceFactory.h b/core/ServiceManager/ServiceFactory.h index 023a09e4..26ae8ebe 100644..100755 --- a/core/ServiceManager/ServiceFactory.h +++ b/core/ServiceManager/ServiceFactory.h @@ -25,8 +25,8 @@ namespace tizen_browser { -namespace core -{ + namespace core + { /** * @brief base service factory class @@ -34,9 +34,9 @@ namespace core * This class shouldn't be used directly. It is used internally by ServiceManager, and * user service factories inherits this class, but you shouldn't have to use it directly. */ -class ServiceFactory -{ -public: + class ServiceFactory + { + public: /** @@ -44,12 +44,12 @@ public: * * */ - ServiceFactory(); + ServiceFactory(); /** * \brief This destroys the ServiceFactory */ - virtual ~ServiceFactory(); + virtual ~ServiceFactory(); /** * \brief Returns service name. @@ -57,17 +57,16 @@ public: * You can use this method to retrieve service name. * \returns Name of the service */ - virtual std::string serviceName() const = 0; + virtual std::string serviceName() const = 0; /** * \brief Returns object instance * \returns Ready to use service object. */ - virtual AbstractService *create()=0; - -}; + virtual AbstractService *create() = 0; + }; -} /* end of namespace core */ -} /* end of namespace tizen_browser */ + } /* end of namespace core */ +} /* end of namespace tizen_browser */ -#endif //__SERVICE_FACTORY_H__ +#endif //__SERVICE_FACTORY_H__ diff --git a/core/ServiceManager/ServiceLib.cpp b/core/ServiceManager/ServiceLib.cpp index 0e3226b4..e6fa091d 100644..100755 --- a/core/ServiceManager/ServiceLib.cpp +++ b/core/ServiceManager/ServiceLib.cpp @@ -21,47 +21,46 @@ namespace tizen_browser { -namespace core -{ + namespace core + { -ServiceLib::ServiceLib(const std::string& libraryFile) + ServiceLib::ServiceLib(const std::string & libraryFile) : libraryFile(libraryFile) - , pHnd(0,0) -{ - load(); -} - -ServiceLib::~ServiceLib() -{ -} - + , pHnd(0, 0) + { + load(); + } -void ServiceLib::load() -{ + ServiceLib::~ServiceLib() + { + } - int flags=0; - flags = //RTLD_NOW //resolve all symbols before dlopen returns - RTLD_LAZY //resolve sybols on ussage - fixes problem with cross linikg services. - | RTLD_GLOBAL; //export or sybols to be used by other libraries. + void ServiceLib::load() + { + int flags = 0; + flags = //RTLD_NOW //resolve all symbols before dlopen returns + RTLD_LAZY //resolve sybols on ussage - fixes problem with cross linikg services. + | RTLD_GLOBAL; //export or sybols to be used by other libraries. - pHnd = unique_library_ptr(dlopen(libraryFile.c_str(), flags), dlclose); - if(!pHnd){ - throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + "Library loading error:" + dlerror()); + pHnd = unique_library_ptr(dlopen(libraryFile.c_str(), flags), dlclose); + if (!pHnd) { + throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + + "Library loading error:" + dlerror()); + } } -} -FunctionPointer ServiceLib::resolveSymbol(const char* symbol) -{ - FunctionPointer address = reinterpret_cast<FunctionPointer>(dlsym(pHnd.get(),symbol)); - if (!address){ - throw std::runtime_error(std::string(__PRETTY_FUNCTION__) - + "Cannot resolve symbol \"" - + symbol + "\" in " - + libraryFile - + ":" + dlerror()); + FunctionPointer ServiceLib::resolveSymbol(const char *symbol) + { + FunctionPointer address = + reinterpret_cast < FunctionPointer > (dlsym(pHnd.get(), symbol)); + if (!address) { + throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + + "Cannot resolve symbol \"" + + symbol + "\" in " + + libraryFile + ":" + dlerror()); + } + return address; } - return address; -} -} /* end of namespace core */ -} /* end of namespace tizen_browser */ + } /* end of namespace core */ +} /* end of namespace tizen_browser */ diff --git a/core/ServiceManager/ServiceLib.h b/core/ServiceManager/ServiceLib.h index 9a519160..9a519160 100644..100755 --- a/core/ServiceManager/ServiceLib.h +++ b/core/ServiceManager/ServiceLib.h diff --git a/core/ServiceManager/ServiceLoader.cpp b/core/ServiceManager/ServiceLoader.cpp index 51ea54fb..58d29393 100644..100755 --- a/core/ServiceManager/ServiceLoader.cpp +++ b/core/ServiceManager/ServiceLoader.cpp @@ -44,7 +44,7 @@ void ServiceLoaderPrivate::loadService() ServiceLoader::ServiceLoader(const std::string& serviceFileName) : d(new ServiceLoaderPrivate(serviceFileName)) { - BROWSER_LOGD( "%s %s", __PRETTY_FUNCTION__ , serviceFileName.c_str() ); + BROWSER_LOGD("%s %s", __PRETTY_FUNCTION__ , serviceFileName.c_str() ); } @@ -61,7 +61,7 @@ std::string ServiceLoader::serviceName() const ServiceFactory* ServiceLoader::getFactory() { - if(d->instance){ + if (d->instance){ return d->instance(); } else{ d->loadService(); diff --git a/core/ServiceManager/ServiceLoader.h b/core/ServiceManager/ServiceLoader.h index a918ecaf..a918ecaf 100644..100755 --- a/core/ServiceManager/ServiceLoader.h +++ b/core/ServiceManager/ServiceLoader.h diff --git a/core/ServiceManager/ServiceLoader_p.h b/core/ServiceManager/ServiceLoader_p.h index 8e365f66..8e365f66 100644..100755 --- a/core/ServiceManager/ServiceLoader_p.h +++ b/core/ServiceManager/ServiceLoader_p.h diff --git a/core/ServiceManager/ServiceManager.cpp b/core/ServiceManager/ServiceManager.cpp index 09666e96..90fb1860 100644..100755 --- a/core/ServiceManager/ServiceManager.cpp +++ b/core/ServiceManager/ServiceManager.cpp @@ -23,91 +23,102 @@ namespace tizen_browser { -namespace core -{ - -ServiceManagerPrivate::ServiceManagerPrivate() -{ - findServiceLibs(); - loadServiceLibs(); - enumerateServices(); -} + namespace core + { -ServiceManagerPrivate::~ServiceManagerPrivate() -{} + ServiceManagerPrivate::ServiceManagerPrivate() + { + findServiceLibs(); + loadServiceLibs(); + enumerateServices(); + } -void ServiceManagerPrivate::findServiceLibs() -{ - try{ - boost::filesystem::path servicesDir(boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get("services/dir"))); - for( boost::filesystem::directory_iterator it(servicesDir); - it != boost::filesystem::directory_iterator(); - ++it){ - boost::filesystem::path item(*it); - if(boost::filesystem::is_regular_file(item)){ - if( (item.extension().string() == ".so" ) - && (item.filename().string().find("lib") == 0)){ - try{ - servicesLoaderMap[item.string()] = std::shared_ptr<ServiceLoader>(new ServiceLoader(item.string())); - } catch (std::runtime_error & e){ - BROWSER_LOGD(e.what() ); - } - } - } - } - } catch (const boost::filesystem::filesystem_error& ex){ - BROWSER_LOGD(ex.what() ); + ServiceManagerPrivate::~ServiceManagerPrivate() + { } -} -void ServiceManagerPrivate::loadServiceLibs() -{ - ///\todo: make shure that librareis are founded. - auto end = servicesLoaderMap.end(); - for(auto slm = servicesLoaderMap.begin(); slm !=end; slm++ ){ - try{ - ServiceFactory* factory=((*slm).second->getFactory()); - servicesMap[factory->serviceName()] = factory;//do not write to map if there's an error. - }catch (std::runtime_error& e){ - BROWSER_LOGD(e.what() ); - } + void ServiceManagerPrivate::findServiceLibs() + { + try { + boost::filesystem::path servicesDir(boost::any_cast < std::string > + (tizen_browser::config::Config:: + getInstance(). + get("services/dir"))); + for (boost::filesystem::directory_iterator it(servicesDir); + it != boost::filesystem::directory_iterator(); ++it) { + boost::filesystem::path item(*it); + if (boost::filesystem::is_regular_file(item)) { + if ((item.extension().string() == ".so") + && (item.filename().string().find("lib") == 0)) { + try { + servicesLoaderMap[item.string()] = + std::shared_ptr < ServiceLoader > + (new ServiceLoader(item.string())); + } + catch(std::runtime_error & e) { + BROWSER_LOGD(e.what()); + } + } + } + } + } + catch(const boost::filesystem::filesystem_error & ex) + { + BROWSER_LOGD(ex.what()); + } } -} -void ServiceManagerPrivate::enumerateServices(){ - auto end = servicesMap.end(); - for( auto sm = servicesMap.begin(); sm != end; sm++){ - BROWSER_LOGD("%s:%p", (*sm).first.c_str(), (*sm).second ); + void ServiceManagerPrivate::loadServiceLibs() + { + ///\todo: make shure that librareis are founded. + auto end = servicesLoaderMap.end(); + for (auto slm = servicesLoaderMap.begin(); slm != end; slm++) { + try { + ServiceFactory *factory = ((*slm).second->getFactory()); + servicesMap[factory->serviceName()] = factory; //do not write to map if there's an error. + } + catch(std::runtime_error & e) { + BROWSER_LOGD(e.what()); + } + } } -} -ServiceManager::ServiceManager() - :d(new ServiceManagerPrivate) -{ + void ServiceManagerPrivate::enumerateServices() + { + auto end = servicesMap.end(); + for (auto sm = servicesMap.begin(); sm != end; sm++) { + BROWSER_LOGD("%s:%p", (*sm).first.c_str(), (*sm).second); + } + } -} + ServiceManager::ServiceManager() + : d(new ServiceManagerPrivate) { + } -ServiceManager& ServiceManager::getInstance(void) -{ - static ServiceManager instance; - return instance; -} + ServiceManager & ServiceManager::getInstance(void) + { + static ServiceManager instance; + return instance; + } -std::shared_ptr< AbstractService > ServiceManager::getService(const std::string& service) -{ - static std::unordered_map<std::string, std::shared_ptr<AbstractService>> cache; - static std::mutex mut; + std::shared_ptr < AbstractService > + ServiceManager::getService(const std::string & service) { + static std::unordered_map < std::string, + std::shared_ptr < AbstractService >> cache; + static std::mutex mut; - std::lock_guard<std::mutex> hold(mut); - auto sp = cache[service]; + std::lock_guard < std::mutex > hold(mut); + auto sp = cache[service]; - if(!sp){ - cache[service] = sp = std::shared_ptr<AbstractService>(d->servicesMap[service]->create()); + if (!sp) { + cache[service] = sp = + std::shared_ptr < AbstractService > + (d->servicesMap[service]->create()); + } + return sp; } - return sp; -} -} /* end of namespace core */ -} /* end of namespace tizen_browser */ + } /* end of namespace core */ +} /* end of namespace tizen_browser */ diff --git a/core/ServiceManager/ServiceManager.h b/core/ServiceManager/ServiceManager.h index b9e61063..b9e61063 100644..100755 --- a/core/ServiceManager/ServiceManager.h +++ b/core/ServiceManager/ServiceManager.h diff --git a/core/ServiceManager/ServiceManager_p.h b/core/ServiceManager/ServiceManager_p.h index 8faeaaea..8faeaaea 100644..100755 --- a/core/ServiceManager/ServiceManager_p.h +++ b/core/ServiceManager/ServiceManager_p.h diff --git a/core/ServiceManager/service_macros.h b/core/ServiceManager/service_macros.h index ea1a0481..b4c794d1 100644..100755 --- a/core/ServiceManager/service_macros.h +++ b/core/ServiceManager/service_macros.h @@ -48,11 +48,11 @@ #endif #ifndef EXTERN_C -# ifdef __cplusplus -# define EXTERN_C extern "C" -# else -# define EXTERN_C extern -# endif +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C extern +#endif #endif @@ -73,15 +73,15 @@ return reinterpret_cast<void*>(&_instance); \ } -#define SERVICE_STRING_INSTANCE(IMPLCLASS,SERVICEIFACE) \ +#define SERVICE_STRING_INSTANCE(IMPLCLASS, SERVICEIFACE) \ inline std::string IMPLCLASS::getName(){return std::string(SERVICEIFACE);} #define FACTORY_NAME(name) name ## Factory -#define EXPORT_SERVICE(SERVICECLASS,SERVICE_STRING) \ +#define EXPORT_SERVICE(SERVICECLASS, SERVICE_STRING) \ SERVICE_FACTORY(FACTORY_NAME(SERVICECLASS), SERVICECLASS, SERVICE_STRING) \ SERVICE_INSTANCE(FACTORY_NAME(SERVICECLASS)) \ - SERVICE_STRING_INSTANCE(SERVICECLASS,SERVICE_STRING) + SERVICE_STRING_INSTANCE(SERVICECLASS, SERVICE_STRING) #endif // __SERVICE_MACROS_H__ diff --git a/core/Tools/Blob.cpp b/core/Tools/Blob.cpp index 6df45ada..d28c831a 100755 --- a/core/Tools/Blob.cpp +++ b/core/Tools/Blob.cpp @@ -45,11 +45,11 @@ Blob::Blob(const void* ptr, unsigned long long length) : m_length(length) { m_data = malloc(length); - if(!m_data && length > 0) { + if (!m_data && length > 0) { BROWSER_LOGE("%s - Failed to allocate %d bytes", length); throw std::bad_alloc(); } - if(m_data) + if (m_data) memcpy(m_data, ptr, length); } diff --git a/core/Tools/Blob.h b/core/Tools/Blob.h index 2777521d..2777521d 100644..100755 --- a/core/Tools/Blob.h +++ b/core/Tools/Blob.h diff --git a/core/Tools/BookmarkFolder.cpp b/core/Tools/BookmarkFolder.cpp index 402938ff..402938ff 100644..100755 --- a/core/Tools/BookmarkFolder.cpp +++ b/core/Tools/BookmarkFolder.cpp diff --git a/core/Tools/BookmarkFolder.h b/core/Tools/BookmarkFolder.h index 3c3f3094..a9448be4 100644..100755 --- a/core/Tools/BookmarkFolder.h +++ b/core/Tools/BookmarkFolder.h @@ -38,8 +38,7 @@ public: BookmarkFolder( unsigned int id, const std::string& name, - unsigned int count - ); + unsigned int count); virtual ~BookmarkFolder(); void setId(int id) { m_id = id; }; diff --git a/core/Tools/BookmarkItem.cpp b/core/Tools/BookmarkItem.cpp index c801ad98..2db32d05 100644..100755 --- a/core/Tools/BookmarkItem.cpp +++ b/core/Tools/BookmarkItem.cpp @@ -55,7 +55,6 @@ BookmarkItem::BookmarkItem( , m_note(note) , m_directory(dir) { - } BookmarkItem::~BookmarkItem() @@ -79,7 +78,6 @@ void BookmarkItem::setThumbnail(std::shared_ptr<tizen_browser::tools::BrowserIma std::shared_ptr<tizen_browser::tools::BrowserImage> BookmarkItem::getThumbnail() const { - return m_thumbnail; }; diff --git a/core/Tools/BookmarkItem.h b/core/Tools/BookmarkItem.h index a5bca8ef..709e8f66 100644..100755 --- a/core/Tools/BookmarkItem.h +++ b/core/Tools/BookmarkItem.h @@ -38,8 +38,7 @@ public: const std::string& title, const std::string& note, unsigned int dir = 0, - unsigned int id = 0 - ); + unsigned int id = 0); virtual ~BookmarkItem(); void setAddress(const std::string & url) { m_url = url; }; diff --git a/core/Tools/BrowserImage.cpp b/core/Tools/BrowserImage.cpp index df9f027a..f3292177 100644..100755 --- a/core/Tools/BrowserImage.cpp +++ b/core/Tools/BrowserImage.cpp @@ -146,7 +146,7 @@ Evas_Object* BrowserImage::getEvas(Evas_Object* parent) const Evas_Object* BrowserImage::getPng(Evas_Object * parent) const { - if(m_dataSize && m_imageData && m_imageType == ImageType::ImageTypePNG) { + if (m_dataSize && m_imageData && m_imageType == ImageType::ImageTypePNG) { Evas * e = evas_object_evas_get(parent); Evas_Object * image = evas_object_image_filled_add(e); char png_format[] = "png"; diff --git a/core/Tools/BrowserImage.h b/core/Tools/BrowserImage.h index b1cb4108..b1cb4108 100644..100755 --- a/core/Tools/BrowserImage.h +++ b/core/Tools/BrowserImage.h diff --git a/core/Tools/BrowserImageTypedef.h b/core/Tools/BrowserImageTypedef.h index 63fd3214..63fd3214 100644..100755 --- a/core/Tools/BrowserImageTypedef.h +++ b/core/Tools/BrowserImageTypedef.h diff --git a/core/Tools/CapiWebErrorCodes.cpp b/core/Tools/CapiWebErrorCodes.cpp index 9fcd4c78..9fcd4c78 100644..100755 --- a/core/Tools/CapiWebErrorCodes.cpp +++ b/core/Tools/CapiWebErrorCodes.cpp diff --git a/core/Tools/CapiWebErrorCodes.h b/core/Tools/CapiWebErrorCodes.h index 29791fb7..29791fb7 100644..100755 --- a/core/Tools/CapiWebErrorCodes.h +++ b/core/Tools/CapiWebErrorCodes.h diff --git a/core/Tools/EcoreTimerCaller.h b/core/Tools/EcoreTimerCaller.h index f9878eca..f9878eca 100644..100755 --- a/core/Tools/EcoreTimerCaller.h +++ b/core/Tools/EcoreTimerCaller.h diff --git a/core/Tools/EflTools.cpp b/core/Tools/EflTools.cpp index 2e3dad2e..2e3dad2e 100644..100755 --- a/core/Tools/EflTools.cpp +++ b/core/Tools/EflTools.cpp diff --git a/core/Tools/EflTools.h b/core/Tools/EflTools.h index 7fea7166..7fea7166 100644..100755 --- a/core/Tools/EflTools.h +++ b/core/Tools/EflTools.h diff --git a/core/Tools/FeedChannel.cpp b/core/Tools/FeedChannel.cpp index df9d94da..df9d94da 100644..100755 --- a/core/Tools/FeedChannel.cpp +++ b/core/Tools/FeedChannel.cpp diff --git a/core/Tools/FeedChannel.h b/core/Tools/FeedChannel.h index a6b496b1..a6b496b1 100644..100755 --- a/core/Tools/FeedChannel.h +++ b/core/Tools/FeedChannel.h diff --git a/core/Tools/FeedItem.cpp b/core/Tools/FeedItem.cpp index d978c579..d978c579 100644..100755 --- a/core/Tools/FeedItem.cpp +++ b/core/Tools/FeedItem.cpp diff --git a/core/Tools/FeedItem.h b/core/Tools/FeedItem.h index 6be57be5..6be57be5 100644..100755 --- a/core/Tools/FeedItem.h +++ b/core/Tools/FeedItem.h diff --git a/core/Tools/FocusManager.cpp b/core/Tools/FocusManager.cpp index 3d1c7b8d..a7bc6cf1 100644..100755 --- a/core/Tools/FocusManager.cpp +++ b/core/Tools/FocusManager.cpp @@ -67,8 +67,7 @@ Eina_Bool FocusManager::_key_down_cb(void* data, int, void* event) --(fm->focusListIterator); elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE); return EINA_TRUE; - } - else if (!keyName.compare("Down")) { + } else if (!keyName.compare("Down")) { BROWSER_LOGD("[%s:%d] Keyname: %s", __PRETTY_FUNCTION__, __LINE__, ev->keyname); if (fm->focusListIterator == fm->verticalFocusVector.end()-1) { elm_object_focus_set(*(fm->focusListIterator), EINA_TRUE); diff --git a/core/Tools/FocusManager.h b/core/Tools/FocusManager.h index 1d4b7dba..1d4b7dba 100644..100755 --- a/core/Tools/FocusManager.h +++ b/core/Tools/FocusManager.h diff --git a/core/Tools/GeneralTools.h b/core/Tools/GeneralTools.h index f0b29176..9ff16d99 100644..100755 --- a/core/Tools/GeneralTools.h +++ b/core/Tools/GeneralTools.h @@ -23,34 +23,41 @@ namespace tizen_browser { -namespace tools -{ + namespace tools + { static const int SUFIX_CHAR_DEL = 1; - static const char * PROTCOL_BEGIN = "://"; + static const char *PROTCOL_BEGIN = "://"; static const char END_SLASH = '/'; // which protocol, when only domain is available? static const std::string PROTOCOL_DEFAULT("http://"); // declaration using 'unused' attribute because in some modules not all functions are used - static std::string fromChar(const char* c) __attribute__ ((unused)); - static std::string clearURL(const std::string & url) __attribute__ ((unused)); - static std::string extractDomain(const std::string & url) __attribute__ ((unused)); - - static std::string fromChar(const char* c) { return c ? std::string(c) : std::string(); } + static std::string fromChar(const char *c) __attribute__((unused)); + static std::string clearURL(const std::string & url) + __attribute__((unused)); + static std::string extractDomain(const std::string & url) + __attribute__((unused)); + + static std::string fromChar(const char *c) + { + return c ? std::string(c) : std::string(); + } - static std::string clearURL(const std::string & url) { - size_t beg = url.find(PROTCOL_BEGIN); + static std::string clearURL(const std::string & url) + { + size_t beg = url.find(PROTCOL_BEGIN); beg += strlen(PROTCOL_BEGIN); return url.substr(beg, url.size() - beg - SUFIX_CHAR_DEL); } - static std::string extractDomain(const std::string & url) { - size_t beg = url.find(PROTCOL_BEGIN); - beg += strlen(PROTCOL_BEGIN); - size_t end = url.find(END_SLASH, beg); - return url.substr(beg, end - beg); + static std::string extractDomain(const std::string & url) + { + size_t beg = url.find(PROTCOL_BEGIN); + beg += strlen(PROTCOL_BEGIN); + size_t end = url.find(END_SLASH, beg); + return url.substr(beg, end - beg); } -} + } } #endif diff --git a/core/Tools/SnapshotType.h b/core/Tools/SnapshotType.h index 6dec090c..6dec090c 100644..100755 --- a/core/Tools/SnapshotType.h +++ b/core/Tools/SnapshotType.h diff --git a/core/Tools/StringTools.cpp b/core/Tools/StringTools.cpp index 20ca8da2..20ca8da2 100644..100755 --- a/core/Tools/StringTools.cpp +++ b/core/Tools/StringTools.cpp diff --git a/core/Tools/StringTools.h b/core/Tools/StringTools.h index 9fbcd572..9fbcd572 100644..100755 --- a/core/Tools/StringTools.h +++ b/core/Tools/StringTools.h diff --git a/core/Tools/URIschemes.h b/core/Tools/URIschemes.h index b847701e..b847701e 100644..100755 --- a/core/Tools/URIschemes.h +++ b/core/Tools/URIschemes.h diff --git a/core/Tools/WorkQueue.h b/core/Tools/WorkQueue.h index df4b3a24..df4b3a24 100644..100755 --- a/core/Tools/WorkQueue.h +++ b/core/Tools/WorkQueue.h diff --git a/core/main.cpp b/core/main.cpp index 8aae1ff8..0810b1a8 100755 --- a/core/main.cpp +++ b/core/main.cpp @@ -45,198 +45,273 @@ const char *engineCommandLineFlags[] = { }; ///\note Odroid platform modification -const std::string DEFAULT_URL = ""; -const std::string DEFAULT_CALLER = "org.tizen.homescreen-efl"; -const int WEB_INSPECTOR_PORT = 9222; - -using BrowserDataPtr = std::shared_ptr<tizen_browser::base_ui::AbstractMainWindow<Evas_Object>>; +const + std::string + DEFAULT_URL = ""; +const + std::string + DEFAULT_CALLER = "org.tizen.homescreen-efl"; +const int + WEB_INSPECTOR_PORT = 9222; + +using + BrowserDataPtr = + std::shared_ptr < tizen_browser::base_ui::AbstractMainWindow < + Evas_Object >>; #if WEB_INSPECTOR -static void start_webInspectorServer() +static void +start_webInspectorServer() { - Ewk_Context *context = ewk_context_default_get(); - unsigned int port = ewk_context_inspector_server_start(context, WEB_INSPECTOR_PORT); - if (port == 0) - BROWSER_LOGI("Failed to start WebInspector Server"); - else - BROWSER_LOGI("WebInspector server started at port: %d \n", port); + Ewk_Context * + context = ewk_context_default_get(); + unsigned int + port = ewk_context_inspector_server_start(context, WEB_INSPECTOR_PORT); + if (port == 0) + BROWSER_LOGI("Failed to start WebInspector Server"); + else + BROWSER_LOGI("WebInspector server started at port: %d \n", port); } #endif -static void set_arguments(char **argv) +static void +set_arguments(char **argv) { - std::vector<char*> browser_argv; - browser_argv.push_back(argv[0]); - for (auto arg: engineCommandLineFlags) - browser_argv.push_back(const_cast<char*>(arg)); + std::vector < char *> + browser_argv; + browser_argv.push_back(argv[0]); +for (auto arg:engineCommandLineFlags) + browser_argv.push_back(const_cast < char *>(arg)); - ewk_set_arguments(browser_argv.size(), browser_argv.data()); + ewk_set_arguments(browser_argv.size(), browser_argv.data()); } -static bool app_create(void* app_data) +static bool +app_create(void *app_data) { - elm_config_accel_preference_set("opengl:depth24:stencil8"); + elm_config_accel_preference_set("opengl:depth24:stencil8"); - elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK); - // Enabling focus + elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK); + // Enabling focus #if PROFILE_MOBILE - elm_config_focus_highlight_enabled_set(EINA_FALSE); + elm_config_focus_highlight_enabled_set(EINA_FALSE); #else - elm_config_focus_highlight_enabled_set(EINA_TRUE); + elm_config_focus_highlight_enabled_set(EINA_TRUE); #endif - elm_config_cache_flush_enabled_set(boost::any_cast <Eina_Bool>(tizen_browser::config::Config::getInstance().get(CONFIG_KEY::CACHE_ENABLE_VALUE))); - elm_config_cache_flush_interval_set(boost::any_cast <int>(tizen_browser::config::Config::getInstance().get(CONFIG_KEY::CACHE_INTERVAL_VALUE))); - elm_config_cache_font_cache_size_set(boost::any_cast <int>(tizen_browser::config::Config::getInstance().get(CONFIG_KEY::CACHE_INTERVAL_VALUE))); - elm_config_cache_image_cache_size_set(boost::any_cast <int>(tizen_browser::config::Config::getInstance().get(CONFIG_KEY::CACHE_IMAGE_VALUE))); - - auto bd = static_cast<BrowserDataPtr*>(app_data); - *bd = std::dynamic_pointer_cast - < - tizen_browser::base_ui::AbstractMainWindow<Evas_Object>, - tizen_browser::core::AbstractService - > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.simpleui")); - elm_app_base_scale_set(boost::any_cast<double>(tizen_browser::config::Config::getInstance().get("scale"))); - return true; + elm_config_cache_flush_enabled_set(boost::any_cast < Eina_Bool > + (tizen_browser::config::Config:: + getInstance(). + get(CONFIG_KEY::CACHE_ENABLE_VALUE))); + elm_config_cache_flush_interval_set(boost::any_cast < + int >(tizen_browser::config::Config:: + getInstance(). + get(CONFIG_KEY:: + CACHE_INTERVAL_VALUE))); + elm_config_cache_font_cache_size_set(boost::any_cast < + int >(tizen_browser::config::Config:: + getInstance(). + get(CONFIG_KEY:: + CACHE_INTERVAL_VALUE))); + elm_config_cache_image_cache_size_set(boost::any_cast < + int >(tizen_browser::config::Config:: + getInstance(). + get(CONFIG_KEY:: + CACHE_IMAGE_VALUE))); + + auto + bd = static_cast < BrowserDataPtr * >(app_data); + *bd = std::dynamic_pointer_cast + < + tizen_browser::base_ui::AbstractMainWindow < Evas_Object >, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.simpleui")); + elm_app_base_scale_set(boost::any_cast < + double >(tizen_browser::config::Config:: + getInstance().get("scale"))); + return true; } -static void app_terminate(void* app_data) +static void +app_terminate(void *app_data) { - BROWSER_LOGD("%s\n", __func__); - auto bd = static_cast<BrowserDataPtr*>(app_data); - (*bd)->destroyUI(); + BROWSER_LOGD("%s\n", __func__); + auto + bd = static_cast < BrowserDataPtr * >(app_data); + (*bd)->destroyUI(); } -static void app_control(app_control_h app_control, void* app_data){ - /* to test this functionality please use aul_test command on target: - * $aul_test org.tizen.browser __APP_SVC_URI__ <http://full.url.com/> - */ - BROWSER_LOGD("%s\n", __func__); - - char *operation = NULL; - char *request_uri = NULL; - char *request_mime_type = NULL; - char *request_caller = NULL; - - if (app_control_get_operation(app_control, &operation) != APP_CONTROL_ERROR_NONE) { - BROWSER_LOGD("get app_control operation failed"); - return; - } - - if (app_control_get_uri(app_control, &request_uri) != APP_CONTROL_ERROR_NONE) - BROWSER_LOGD("get app_control uri failed"); - - if (app_control_get_mime(app_control, &request_mime_type) != APP_CONTROL_ERROR_NONE) - BROWSER_LOGD("get app_control mime failed"); - - if (app_control_get_caller(app_control, &request_caller) != APP_CONTROL_ERROR_NONE) - BROWSER_LOGD("get app_control caller failed"); - - BROWSER_LOGD("operation = [%s], request_uri = [%s], request_caller = [%s] request_mime_type = [%s]" - , operation, request_uri, request_caller, request_mime_type); - - std::string uri = request_uri != NULL ? std::string(request_uri) : DEFAULT_URL; - std::string caller = request_caller != NULL ? std::string(request_caller) : DEFAULT_CALLER; - - if((operation && !strcmp(operation, "http://tizen.org/appcontrol/operation/view")) && (request_uri != NULL)) { - if (request_uri) { - if (!strncmp(request_uri, "/opt/", strlen("/opt/"))) { - uri = std::string("file://") + uri; - } - } +static void +app_control(app_control_h app_control, void *app_data) +{ + /* to test this functionality please use aul_test command on target: + * $aul_test org.tizen.browser __APP_SVC_URI__ <http://full.url.com/> + */ + BROWSER_LOGD("%s\n", __func__); + + char * + operation = NULL; + char * + request_uri = NULL; + char * + request_mime_type = NULL; + char * + request_caller = NULL; + + if (app_control_get_operation(app_control, &operation) != + APP_CONTROL_ERROR_NONE) { + BROWSER_LOGD("get app_control operation failed"); + return; + } + + if (app_control_get_uri(app_control, &request_uri) != + APP_CONTROL_ERROR_NONE) + BROWSER_LOGD("get app_control uri failed"); + + if (app_control_get_mime(app_control, &request_mime_type) != + APP_CONTROL_ERROR_NONE) + BROWSER_LOGD("get app_control mime failed"); + + if (app_control_get_caller(app_control, &request_caller) != + APP_CONTROL_ERROR_NONE) + BROWSER_LOGD("get app_control caller failed"); + + BROWSER_LOGD + ("operation = [%s], request_uri = [%s], request_caller = [%s] request_mime_type = [%s]", + operation, request_uri, request_caller, request_mime_type); + + std::string uri = + request_uri != NULL ? std::string(request_uri) : DEFAULT_URL; + std::string caller = + request_caller != NULL ? std::string(request_caller) : DEFAULT_CALLER; + + if ((operation + && !strcmp(operation, "http://tizen.org/appcontrol/operation/view")) + && (request_uri != NULL)) { + if (request_uri) { + if (!strncmp(request_uri, "/opt/", strlen("/opt/"))) { + uri = std::string("file://") + uri; + } } - - BROWSER_LOGD("[%s] uri=%s", __func__, uri.c_str()); - free(request_uri); - free(request_mime_type); - free(request_caller); - free(operation); - - auto bd = static_cast<BrowserDataPtr*>(app_data); - (*bd)->exec(uri, caller); - evas_object_show((*bd)->getMainWindow().get()); - elm_win_activate((*bd)->getMainWindow().get()); + } + + BROWSER_LOGD("[%s] uri=%s", __func__, uri.c_str()); + free(request_uri); + free(request_mime_type); + free(request_caller); + free(operation); + + auto + bd = static_cast < BrowserDataPtr * >(app_data); + (*bd)->exec(uri, caller); + evas_object_show((*bd)->getMainWindow().get()); + elm_win_activate((*bd)->getMainWindow().get()); } -static void app_pause(void* app_data){ - BROWSER_LOGD("%s", __PRETTY_FUNCTION__); +static void +app_pause(void *app_data) +{ + BROWSER_LOGD("%s", __PRETTY_FUNCTION__); - auto bd = static_cast<BrowserDataPtr*>(app_data); - (*bd)->suspend(); + auto + bd = static_cast < BrowserDataPtr * >(app_data); + (*bd)->suspend(); } -static void app_resume(void* app_data){ - BROWSER_LOGD("%s", __PRETTY_FUNCTION__); +static void +app_resume(void *app_data) +{ + BROWSER_LOGD("%s", __PRETTY_FUNCTION__); - auto bd = static_cast<BrowserDataPtr*>(app_data); - (*bd)->resume(); + auto + bd = static_cast < BrowserDataPtr * >(app_data); + (*bd)->resume(); } #if PROFILE_MOBILE -static void app_language_changed(app_event_info*, void *) +static void +app_language_changed(app_event_info *, void *) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - char *language; - // Retrieve the current system language - system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &language); - if (language) { - BROWSER_LOGD("[%s:%d] new lang: %s", __PRETTY_FUNCTION__, __LINE__, language); - // Set the language in elementary - elm_language_set(language); - free(language); - } else { - BROWSER_LOGD("[%s:%d] Warning, failed to set new language!", __PRETTY_FUNCTION__, __LINE__); - } + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char * + language; + // Retrieve the current system language + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, + &language); + if (language) { + BROWSER_LOGD("[%s:%d] new lang: %s", __PRETTY_FUNCTION__, __LINE__, + language); + // Set the language in elementary + elm_language_set(language); + free(language); + } else { + BROWSER_LOGD("[%s:%d] Warning, failed to set new language!", + __PRETTY_FUNCTION__, __LINE__); + } } #endif -int main(int argc, char* argv[])try +int +main(int argc, char *argv[]) + try { - BEGIN() + BEGIN() ewk_init(); - set_arguments(argv); + set_arguments(argv); //#if !defined(NDEBUG) - //Initialization of logger module - tizen_browser::logger::Logger::getInstance().init(); - tizen_browser::logger::Logger::getInstance().setLogTag("browser"); + //Initialization of logger module + tizen_browser::logger::Logger::getInstance().init(); + tizen_browser::logger::Logger::getInstance().setLogTag("browser"); //#endif - BROWSER_LOGD("BROWSER IS SAYING HELLO"); - BROWSER_LOGD("BROWSER TAG: %s",tizen_browser::logger::Logger::getInstance().getLogTag().c_str()); - BROWSER_LOGD("BROWSER REGISTERED LOGGERS COUNT: %d",tizen_browser::logger::Logger::getInstance().getLoggersCount()); + BROWSER_LOGD("BROWSER IS SAYING HELLO"); + BROWSER_LOGD("BROWSER TAG: %s", + tizen_browser::logger::Logger::getInstance().getLogTag(). + c_str()); + BROWSER_LOGD("BROWSER REGISTERED LOGGERS COUNT: %d", + tizen_browser::logger::Logger::getInstance(). + getLoggersCount()); - setenv("COREGL_FASTPATH", "1", 1); + setenv("COREGL_FASTPATH", "1", 1); - ui_app_lifecycle_callback_s ops; - memset(&ops, 0x00, sizeof(ui_app_lifecycle_callback_s)); + ui_app_lifecycle_callback_s + ops; + memset(&ops, 0x00, sizeof(ui_app_lifecycle_callback_s)); - ops.create = app_create; - ops.terminate = app_terminate; - ops.app_control = app_control; - ops.pause = app_pause; - ops.resume = app_resume; + ops.create = app_create; + ops.terminate = app_terminate; + ops.app_control = app_control; + ops.pause = app_pause; + ops.resume = app_resume; - BrowserDataPtr bd; + BrowserDataPtr + bd; #if PROFILE_MOBILE - app_event_handler_h lang_changed_handler; - ui_app_add_event_handler(&lang_changed_handler, APP_EVENT_LANGUAGE_CHANGED, app_language_changed, NULL); + app_event_handler_h + lang_changed_handler; + ui_app_add_event_handler(&lang_changed_handler, APP_EVENT_LANGUAGE_CHANGED, + app_language_changed, NULL); #endif #if WEB_INSPECTOR - start_webInspectorServer(); + start_webInspectorServer(); #endif - ui_app_main(argc, argv, &ops, &bd); + ui_app_main(argc, argv, &ops, &bd); - ewk_shutdown(); - END() + ewk_shutdown(); + END() +} -} catch (std::exception & e) +catch(std::exception & e) { - std::cerr << "UNHANDLED EXCEPTION " << e.what() << std::endl; -} catch (...) + std::cerr << "UNHANDLED EXCEPTION " << e.what() << std::endl; +} + +catch( ...) { - std::cerr << "UNHANDLED EXCEPTION" << std::endl; + std::cerr << "UNHANDLED EXCEPTION" << std::endl; } diff --git a/packaging/org.tizen.browser.spec b/packaging/org.tizen.browser.spec index 7c349d6f..f18ccb1d 100755 --- a/packaging/org.tizen.browser.spec +++ b/packaging/org.tizen.browser.spec @@ -2,7 +2,7 @@ Name: org.tizen.browser-profile_common Summary: Tizen TV Open Browser -Version: 1.6.4 +Version: 1.6.5 Release: 0 Provides: org.tizen.browser = %{version}-%{release} Conflicts: org.tizen.browser-profile_mobile diff --git a/services/BookmarkDetailsUI/BookmarkDetailsUI.cpp b/services/BookmarkDetailsUI/BookmarkDetailsUI.cpp index 7562cf15..c5ab19ae 100644..100755 --- a/services/BookmarkDetailsUI/BookmarkDetailsUI.cpp +++ b/services/BookmarkDetailsUI/BookmarkDetailsUI.cpp @@ -33,636 +33,765 @@ #include "Tools/EflTools.h" #include "../Tools/BrowserImage.h" -namespace tizen_browser { -namespace base_ui { +namespace tizen_browser +{ + namespace base_ui + { -EXPORT_SERVICE(BookmarkDetailsUI, "org.tizen.browser.bookmarkdetailsui") + EXPORT_SERVICE(BookmarkDetailsUI, "org.tizen.browser.bookmarkdetailsui") -struct ItemData -{ - tizen_browser::base_ui::BookmarkDetailsUI * m_bookmarkDetails; - tizen_browser::services::BookmarkItem * h_item; - Elm_Object_Item * e_item; -}; + struct ItemData + { + tizen_browser::base_ui::BookmarkDetailsUI * m_bookmarkDetails; + tizen_browser::services::BookmarkItem * h_item; + Elm_Object_Item *e_item; + }; -typedef struct -{ - std::shared_ptr<tizen_browser::services::BookmarkItem> item; - BookmarkDetailsUI* bookmarkDetailsUI; -} BookmarkItemData; + typedef struct + { + std::shared_ptr < tizen_browser::services::BookmarkItem > item; + BookmarkDetailsUI *bookmarkDetailsUI; + } BookmarkItemData; -BookmarkDetailsUI::BookmarkDetailsUI() + BookmarkDetailsUI::BookmarkDetailsUI() : m_parent(nullptr) - , m_layout(nullptr) - , m_top_content(nullptr) - , m_gengrid(nullptr) + , m_layout(nullptr) + , m_top_content(nullptr) + , m_gengrid(nullptr) #if !PROFILE_MOBILE - , m_bottom_content(nullptr) + , m_bottom_content(nullptr) #else - , m_more_button(nullptr) - , m_menu_bg_button(nullptr) - , m_menu(nullptr) - , m_edit_button(nullptr) - , m_delete_button(nullptr) - , m_remove_button(nullptr) - , m_cancel_top_button(nullptr) - , m_remove_top_button(nullptr) - , m_delete_count(0) - , m_remove_bookmark_mode(false) + , m_more_button(nullptr) + , m_menu_bg_button(nullptr) + , m_menu(nullptr) + , m_edit_button(nullptr) + , m_delete_button(nullptr) + , m_remove_button(nullptr) + , m_cancel_top_button(nullptr) + , m_remove_top_button(nullptr) + , m_delete_count(0) + , m_remove_bookmark_mode(false) #endif - , m_close_button(nullptr) - , m_bookmark_item_class(nullptr) - , m_rotation_state(0) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("BookmarkDetailsUI/BookmarkDetailsUI.edj"); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - createGengridItemClasses(); -} + , m_close_button(nullptr) + , m_bookmark_item_class(nullptr) + , m_rotation_state(0) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("BookmarkDetailsUI/BookmarkDetailsUI.edj"); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + createGengridItemClasses(); + } -BookmarkDetailsUI::~BookmarkDetailsUI() -{ - elm_gengrid_clear(m_gengrid); + BookmarkDetailsUI::~BookmarkDetailsUI() + { + elm_gengrid_clear(m_gengrid); - evas_object_smart_callback_del(m_close_button, "clicked", _close_button_clicked); + evas_object_smart_callback_del(m_close_button, "clicked", + _close_button_clicked); #if PROFILE_MOBILE - evas_object_smart_callback_del(m_more_button, "clicked", _more_button_clicked); - evas_object_smart_callback_del(m_menu_bg_button, "clicked", _menu_bg_button_clicked); - evas_object_smart_callback_del(m_edit_button, "clicked", _edit_button_clicked); - evas_object_smart_callback_del(m_delete_button, "clicked", _delete_button_clicked); - evas_object_smart_callback_del(m_remove_button, "clicked", _remove_button_clicked); - evas_object_smart_callback_del(m_cancel_top_button, "clicked", _cancel_top_button_clicked); - evas_object_smart_callback_del(m_remove_top_button, "clicked", _remove_top_button_clicked); + evas_object_smart_callback_del(m_more_button, "clicked", + _more_button_clicked); + evas_object_smart_callback_del(m_menu_bg_button, "clicked", + _menu_bg_button_clicked); + evas_object_smart_callback_del(m_edit_button, "clicked", + _edit_button_clicked); + evas_object_smart_callback_del(m_delete_button, "clicked", + _delete_button_clicked); + evas_object_smart_callback_del(m_remove_button, "clicked", + _remove_button_clicked); + evas_object_smart_callback_del(m_cancel_top_button, "clicked", + _cancel_top_button_clicked); + evas_object_smart_callback_del(m_remove_top_button, "clicked", + _remove_top_button_clicked); #endif - evas_object_del(m_top_content); - evas_object_del(m_close_button); - evas_object_del(m_layout); - evas_object_del(m_gengrid); + evas_object_del(m_top_content); + evas_object_del(m_close_button); + evas_object_del(m_layout); + evas_object_del(m_gengrid); #if PROFILE_MOBILE - evas_object_del(m_more_button); - evas_object_del(m_menu_bg_button); - evas_object_del(m_menu); - evas_object_del(m_edit_button); - evas_object_del(m_delete_button); - evas_object_del(m_remove_button); - evas_object_del(m_cancel_top_button); - evas_object_del(m_remove_top_button); + evas_object_del(m_more_button); + evas_object_del(m_menu_bg_button); + evas_object_del(m_menu); + evas_object_del(m_edit_button); + evas_object_del(m_delete_button); + evas_object_del(m_remove_button); + evas_object_del(m_cancel_top_button); + evas_object_del(m_remove_top_button); #endif - if (m_bookmark_item_class) - elm_gengrid_item_class_free(m_bookmark_item_class); -} + if (m_bookmark_item_class) + elm_gengrid_item_class_free(m_bookmark_item_class); + } -void BookmarkDetailsUI::createGengridItemClasses() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_bookmark_item_class = elm_gengrid_item_class_new(); - m_bookmark_item_class->item_style = "grid_bookmark_item"; - m_bookmark_item_class->func.text_get = _grid_bookmark_text_get; - m_bookmark_item_class->func.content_get = _grid_bookmark_content_get; - m_bookmark_item_class->func.state_get = nullptr; - m_bookmark_item_class->func.del = _grid_content_delete; -} + void BookmarkDetailsUI::createGengridItemClasses() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_bookmark_item_class = elm_gengrid_item_class_new(); + m_bookmark_item_class->item_style = "grid_bookmark_item"; + m_bookmark_item_class->func.text_get = _grid_bookmark_text_get; + m_bookmark_item_class->func.content_get = _grid_bookmark_content_get; + m_bookmark_item_class->func.state_get = nullptr; + m_bookmark_item_class->func.del = _grid_content_delete; + } -void BookmarkDetailsUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} + void BookmarkDetailsUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } -void BookmarkDetailsUI::showUI() -{ + void BookmarkDetailsUI::showUI() + { #if !PROFILE_MOBILE - m_focusManager.startFocusManager(m_gengrid); + m_focusManager.startFocusManager(m_gengrid); #endif - elm_object_signal_emit(m_layout, "hide_menu", "ui"); + elm_object_signal_emit(m_layout, "hide_menu", "ui"); #if PROFILE_MOBILE - evas_object_hide(m_menu); - evas_object_hide(elm_object_part_content_get(m_layout, "more_swallow")); - evas_object_hide(m_menu_bg_button); - evas_object_hide(elm_object_part_content_get(m_layout, "more_bg")); + evas_object_hide(m_menu); + evas_object_hide(elm_object_part_content_get(m_layout, "more_swallow")); + evas_object_hide(m_menu_bg_button); + evas_object_hide(elm_object_part_content_get(m_layout, "more_bg")); #endif - evas_object_show(m_layout); -} + evas_object_show(m_layout); + } -void BookmarkDetailsUI::hideUI() -{ - evas_object_hide(m_layout); - evas_object_hide(m_gengrid); - elm_gengrid_clear(m_gengrid); + void BookmarkDetailsUI::hideUI() + { + evas_object_hide(m_layout); + evas_object_hide(m_gengrid); + elm_gengrid_clear(m_gengrid); #if PROFILE_MOBILE - elm_object_signal_emit(m_top_content, "icon_less", "ui"); - m_map_bookmark.clear(); + elm_object_signal_emit(m_top_content, "icon_less", "ui"); + m_map_bookmark.clear(); #else - m_focusManager.stopFocusManager(); + m_focusManager.stopFocusManager(); #endif + } -} - -Evas_Object* BookmarkDetailsUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - if (!m_layout) - m_layout = createLayout(m_parent); - setEmpty(true); - return m_layout; -} + Evas_Object *BookmarkDetailsUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if (!m_layout) + m_layout = createLayout(m_parent); + setEmpty(true); + return m_layout; + } -void BookmarkDetailsUI::onBackPressed() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void BookmarkDetailsUI::onBackPressed() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); #if PROFILE_MOBILE - if (m_remove_bookmark_mode) { - updateGengridItems(); - resetRemovalMode(); - } + if (m_remove_bookmark_mode) { + updateGengridItems(); + resetRemovalMode(); + } #endif - closeBookmarkDetailsClicked(); -} + closeBookmarkDetailsClicked(); + } #if PROFILE_MOBILE -void BookmarkDetailsUI::setLandscape(bool state) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_rotation_state = state ? 0 : 1; - resetContent(); -} + void BookmarkDetailsUI::setLandscape(bool state) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_rotation_state = state ? 0 : 1; + resetContent(); + } -void BookmarkDetailsUI::resetContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_rotation_state) { - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(290+18), ELM_SCALE_SIZE(308+18)); - elm_object_signal_emit(m_layout, "switch_landscape", "ui"); - } else { - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(319+18), ELM_SCALE_SIZE(361+18)); - elm_object_signal_emit(m_layout, "switch_vertical", "ui"); + void BookmarkDetailsUI::resetContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_rotation_state) { + elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(290 + 18), + ELM_SCALE_SIZE(308 + 18)); + elm_object_signal_emit(m_layout, "switch_landscape", "ui"); + } else { + elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(319 + 18), + ELM_SCALE_SIZE(361 + 18)); + elm_object_signal_emit(m_layout, "switch_vertical", "ui"); + } } -} #endif -char* BookmarkDetailsUI::_grid_bookmark_text_get(void *data, Evas_Object *, const char *part) -{ - if ((data != nullptr) && (part != nullptr)) { - BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); - BookmarkItemData *itemData = static_cast<BookmarkItemData*>(data); - const char *part_name1 = "page_title"; - const char *part_name2 = "page_url"; - static const int part_name1_len = strlen(part_name1); - static const int part_name2_len = strlen(part_name2); - if (!strncmp(part_name1, part, part_name1_len)) { - return strdup(itemData->item->getTitle().c_str()); - } else if (!strncmp(part_name2, part, part_name2_len)) { - return strdup(itemData->item->getAddress().c_str()); - } + char *BookmarkDetailsUI::_grid_bookmark_text_get(void *data, + Evas_Object *, + const char *part) + { + if ((data != nullptr) && (part != nullptr)) { + BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); + BookmarkItemData *itemData = static_cast < BookmarkItemData * >(data); + const char *part_name1 = "page_title"; + const char *part_name2 = "page_url"; + static const int part_name1_len = strlen(part_name1); + static const int part_name2_len = strlen(part_name2); + if (!strncmp(part_name1, part, part_name1_len)) { + return strdup(itemData->item->getTitle().c_str()); + } else if (!strncmp(part_name2, part, part_name2_len)) { + return strdup(itemData->item->getAddress().c_str()); + } + } + return strdup(""); } - return strdup(""); -} -void BookmarkDetailsUI::_grid_content_delete(void *data, Evas_Object */*obj*/) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - auto itemData = static_cast<BookmarkItemData*>(data); - if (itemData) - delete itemData; -} + void BookmarkDetailsUI::_grid_content_delete(void *data, + Evas_Object * /*obj */ ) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + auto itemData = static_cast < BookmarkItemData * >(data); + if (itemData) + delete itemData; + } -Evas_Object * BookmarkDetailsUI::_grid_bookmark_content_get(void *data, - Evas_Object *obj, const char *part) -{ - if ((data != nullptr) && (obj != nullptr) && (part != nullptr)) { - BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); - BookmarkItemData *itemData = static_cast<BookmarkItemData*>(data); - const char *part_name1 = "elm.thumbnail"; - static const int part_name1_len = strlen(part_name1); - if (!strncmp(part_name1, part, part_name1_len)) { - std::shared_ptr<tizen_browser::tools::BrowserImage> image = itemData->item->getThumbnail(); - if (image) - return image->getEvasImage(itemData->bookmarkDetailsUI->m_parent); - } + Evas_Object *BookmarkDetailsUI::_grid_bookmark_content_get(void *data, + Evas_Object * + obj, + const char + *part) + { + if ((data != nullptr) && (obj != nullptr) && (part != nullptr)) { + BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); + BookmarkItemData *itemData = static_cast < BookmarkItemData * >(data); + const char *part_name1 = "elm.thumbnail"; + static const int part_name1_len = strlen(part_name1); + if (!strncmp(part_name1, part, part_name1_len)) { + std::shared_ptr < tizen_browser::tools::BrowserImage > image = + itemData->item->getThumbnail(); + if (image) + return image->getEvasImage(itemData->bookmarkDetailsUI->m_parent); + } #if PROFILE_MOBILE - const char *part_name2 = "remove_checkbox_swallow"; - static const int part_name2_len = strlen(part_name2); - if (!strncmp(part_name2, part, part_name2_len)) { - if (itemData->bookmarkDetailsUI->m_remove_bookmark_mode) { - Evas_Object* box = elm_check_add(obj); - elm_object_style_set(box, "custom_check"); - evas_object_propagate_events_set(box, EINA_FALSE); - elm_check_state_set(box, itemData->bookmarkDetailsUI->m_map_delete[itemData->item->getId()] - ? EINA_TRUE : EINA_FALSE); - evas_object_show(box); - return box; - } - } + const char *part_name2 = "remove_checkbox_swallow"; + static const int part_name2_len = strlen(part_name2); + if (!strncmp(part_name2, part, part_name2_len)) { + if (itemData->bookmarkDetailsUI->m_remove_bookmark_mode) { + Evas_Object *box = elm_check_add(obj); + elm_object_style_set(box, "custom_check"); + evas_object_propagate_events_set(box, EINA_FALSE); + elm_check_state_set(box, + itemData->bookmarkDetailsUI-> + m_map_delete[itemData->item->getId()] + ? EINA_TRUE : EINA_FALSE); + evas_object_show(box); + return box; + } + } #endif + } + return nullptr; } - return nullptr; -} -void BookmarkDetailsUI::_bookmark_item_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkItemData * itemData = static_cast<BookmarkItemData*>(data); + void BookmarkDetailsUI::_bookmark_item_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkItemData *itemData = static_cast < BookmarkItemData * >(data); #if PROFILE_MOBILE - if (itemData->bookmarkDetailsUI->m_remove_bookmark_mode) { - itemData->bookmarkDetailsUI->m_delete_count -= itemData->bookmarkDetailsUI-> - m_map_delete[itemData->item->getId()] ? 1 : -1; - itemData->bookmarkDetailsUI->m_map_delete[itemData->item->getId()] = - !itemData->bookmarkDetailsUI->m_map_delete[itemData->item->getId()]; - elm_object_signal_emit(itemData->bookmarkDetailsUI->m_top_content, itemData-> - bookmarkDetailsUI->m_delete_count ? "removal_mode" : "removal_mode_dissabled", "ui"); - elm_object_part_text_set(itemData->bookmarkDetailsUI->m_top_content, - "title_text", (boost::format("%d %s") % itemData->bookmarkDetailsUI-> - m_delete_count % _("IDS_BR_OPT_SELECTED")).str().c_str()); - elm_gengrid_item_update(itemData->bookmarkDetailsUI-> - m_map_bookmark[itemData->item->getId()]); - elm_gengrid_realized_items_update(itemData->bookmarkDetailsUI->m_gengrid); + if (itemData->bookmarkDetailsUI->m_remove_bookmark_mode) { + itemData->bookmarkDetailsUI->m_delete_count -= + itemData->bookmarkDetailsUI->m_map_delete[itemData->item-> + getId()]? 1 : -1; + itemData->bookmarkDetailsUI->m_map_delete[itemData->item->getId()] = + !itemData->bookmarkDetailsUI->m_map_delete[itemData->item-> + getId()]; + elm_object_signal_emit(itemData->bookmarkDetailsUI->m_top_content, + itemData->bookmarkDetailsUI-> + m_delete_count ? "removal_mode" : + "removal_mode_dissabled", "ui"); + elm_object_part_text_set(itemData->bookmarkDetailsUI->m_top_content, + "title_text", + (boost::format("%d %s") % + itemData-> + bookmarkDetailsUI->m_delete_count % + _("IDS_BR_OPT_SELECTED")).str().c_str()); + elm_gengrid_item_update(itemData-> + bookmarkDetailsUI->m_map_bookmark[itemData-> + item-> + getId()]); + elm_gengrid_realized_items_update(itemData->bookmarkDetailsUI-> + m_gengrid); + } else { + itemData->bookmarkDetailsUI->bookmarkItemClicked(itemData->item); } - else - itemData->bookmarkDetailsUI->bookmarkItemClicked(itemData->item); #else - itemData->bookmarkDetailsUI->bookmarkItemClicked(itemData->item); + itemData->bookmarkDetailsUI->bookmarkItemClicked(itemData->item); #endif - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } #if !PROFILE_MOBILE -void BookmarkDetailsUI::createFocusVector() -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - m_focusManager.addItem(m_close_button); - m_focusManager.addItem(m_gengrid); - m_focusManager.setIterator(); -} + void BookmarkDetailsUI::createFocusVector() + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + m_focusManager.addItem(m_close_button); + m_focusManager.addItem(m_gengrid); + m_focusManager.setIterator(); + } #endif -void BookmarkDetailsUI::_close_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - bookmarkDetailsUI->onBackPressed(); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_close_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + bookmarkDetailsUI->onBackPressed(); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } #if PROFILE_MOBILE -void BookmarkDetailsUI::_more_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - if (evas_object_visible_get(bookmarkDetailsUI->m_menu) == EINA_FALSE) { - elm_object_signal_emit(bookmarkDetailsUI->m_layout, "show_menu", "ui"); - elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_more", "ui"); - evas_object_show(bookmarkDetailsUI->m_menu); - evas_object_show(elm_object_part_content_get(bookmarkDetailsUI->m_layout, "more_swallow")); - } else { - elm_object_signal_emit(bookmarkDetailsUI->m_layout, "hide_menu", "ui"); - elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_less", "ui"); - evas_object_hide(bookmarkDetailsUI->m_menu); - evas_object_hide(elm_object_part_content_get(bookmarkDetailsUI->m_layout, "more_swallow")); - } - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_more_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + if (evas_object_visible_get(bookmarkDetailsUI->m_menu) == EINA_FALSE) { + elm_object_signal_emit(bookmarkDetailsUI->m_layout, "show_menu", + "ui"); + elm_object_signal_emit(bookmarkDetailsUI->m_top_content, + "icon_more", "ui"); + evas_object_show(bookmarkDetailsUI->m_menu); + evas_object_show(elm_object_part_content_get + (bookmarkDetailsUI->m_layout, "more_swallow")); + } else { + elm_object_signal_emit(bookmarkDetailsUI->m_layout, "hide_menu", + "ui"); + elm_object_signal_emit(bookmarkDetailsUI->m_top_content, + "icon_less", "ui"); + evas_object_hide(bookmarkDetailsUI->m_menu); + evas_object_hide(elm_object_part_content_get + (bookmarkDetailsUI->m_layout, "more_swallow")); + } + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_menu_bg_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_less", "ui"); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_menu_bg_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_less", + "ui"); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_edit_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - bookmarkDetailsUI->editFolderButtonClicked(bookmarkDetailsUI->getFolderName()); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_edit_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + bookmarkDetailsUI->editFolderButtonClicked(bookmarkDetailsUI-> + getFolderName()); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_delete_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - bookmarkDetailsUI->deleteFolderButtonClicked(bookmarkDetailsUI->getFolderName()); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_delete_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + bookmarkDetailsUI->deleteFolderButtonClicked(bookmarkDetailsUI-> + getFolderName()); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_remove_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - bookmarkDetailsUI->m_map_delete.clear(); - bookmarkDetailsUI->m_remove_bookmark_mode = true; - for (auto it = bookmarkDetailsUI->m_map_bookmark.begin(); it != bookmarkDetailsUI->m_map_bookmark.end(); ++it) - bookmarkDetailsUI->m_map_delete.insert(std::pair<unsigned int, bool>(it->first, false)); - elm_gengrid_realized_items_update(bookmarkDetailsUI->m_gengrid); - elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_less", "ui"); - elm_object_signal_emit(bookmarkDetailsUI->m_layout, "hide_menu", "ui"); - elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "removal_mode_dissabled", "ui"); - elm_object_part_text_set(bookmarkDetailsUI->m_top_content, "title_text", (boost::format("%d %s") - % bookmarkDetailsUI->m_delete_count % _("IDS_BR_OPT_SELECTED")).str().c_str()); - evas_object_hide(bookmarkDetailsUI->m_menu); - evas_object_hide(elm_object_part_content_get(bookmarkDetailsUI->m_layout, "more_swallow")); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_remove_button_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + bookmarkDetailsUI->m_map_delete.clear(); + bookmarkDetailsUI->m_remove_bookmark_mode = true; + for (auto it = bookmarkDetailsUI->m_map_bookmark.begin(); + it != bookmarkDetailsUI->m_map_bookmark.end(); ++it) + bookmarkDetailsUI->m_map_delete.insert(std::pair < unsigned int, + bool > (it->first, false)); + elm_gengrid_realized_items_update(bookmarkDetailsUI->m_gengrid); + elm_object_signal_emit(bookmarkDetailsUI->m_top_content, "icon_less", + "ui"); + elm_object_signal_emit(bookmarkDetailsUI->m_layout, "hide_menu", + "ui"); + elm_object_signal_emit(bookmarkDetailsUI->m_top_content, + "removal_mode_dissabled", "ui"); + elm_object_part_text_set(bookmarkDetailsUI->m_top_content, + "title_text", (boost::format("%d %s") + % + bookmarkDetailsUI-> + m_delete_count % + _("IDS_BR_OPT_SELECTED")). + str().c_str()); + evas_object_hide(bookmarkDetailsUI->m_menu); + evas_object_hide(elm_object_part_content_get + (bookmarkDetailsUI->m_layout, "more_swallow")); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_cancel_top_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - bookmarkDetailsUI->updateGengridItems(); - bookmarkDetailsUI->resetRemovalMode(); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_cancel_top_button_clicked(void *data, + Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + bookmarkDetailsUI->updateGengridItems(); + bookmarkDetailsUI->resetRemovalMode(); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } -void BookmarkDetailsUI::_remove_top_button_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - BookmarkDetailsUI* bookmarkDetailsUI = static_cast<BookmarkDetailsUI*>(data); - - std::vector<std::shared_ptr<services::BookmarkItem>> bookmarks; - bookmarks.clear(); - - for (auto it = bookmarkDetailsUI->m_map_delete.begin(); it != bookmarkDetailsUI->m_map_delete.end(); ++it) - if (it->second) { - BookmarkItemData * itemData = static_cast<BookmarkItemData*>(elm_object_item_data_get( - bookmarkDetailsUI->m_map_bookmark[it->first])); - bookmarks.push_back(itemData->item); - elm_object_item_del(bookmarkDetailsUI->m_map_bookmark[it->first]); - bookmarkDetailsUI->m_map_bookmark.erase(it->first); - } - bookmarkDetailsUI->resetRemovalMode(); - bookmarkDetailsUI->removeFoldersButtonClicked(bookmarks); - } else - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); -} + void BookmarkDetailsUI::_remove_top_button_clicked(void *data, + Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + BookmarkDetailsUI *bookmarkDetailsUI = + static_cast < BookmarkDetailsUI * >(data); + + std::vector < std::shared_ptr < services::BookmarkItem >> bookmarks; + bookmarks.clear(); + + for (auto it = bookmarkDetailsUI->m_map_delete.begin(); + it != bookmarkDetailsUI->m_map_delete.end(); ++it) + if (it->second) { + BookmarkItemData *itemData = + static_cast < + BookmarkItemData * + >(elm_object_item_data_get + (bookmarkDetailsUI->m_map_bookmark[it->first])); + bookmarks.push_back(itemData->item); + elm_object_item_del(bookmarkDetailsUI->m_map_bookmark[it->first]); + bookmarkDetailsUI->m_map_bookmark.erase(it->first); + } + bookmarkDetailsUI->resetRemovalMode(); + bookmarkDetailsUI->removeFoldersButtonClicked(bookmarks); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } #endif -std::string BookmarkDetailsUI::getFolderName() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::string title = elm_object_part_text_get(m_top_content, "title_text"); - auto i = 0; - auto pos = title.find_last_of("("); - return title.substr(i, pos-i); -} + std::string BookmarkDetailsUI::getFolderName() { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::string title = + elm_object_part_text_get(m_top_content, "title_text"); + auto i = 0; + auto pos = title.find_last_of("("); + return title.substr(i, pos - i); + } -void BookmarkDetailsUI::setEmpty(bool isEmpty) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (isEmpty) - elm_object_signal_emit(m_layout, "show_no_favorites", "ui"); - else - elm_object_signal_emit(m_layout, "hide_no_favorites", "ui"); -} + void BookmarkDetailsUI::setEmpty(bool isEmpty) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (isEmpty) + elm_object_signal_emit(m_layout, "show_no_favorites", "ui"); + else + elm_object_signal_emit(m_layout, "hide_no_favorites", "ui"); + } -void BookmarkDetailsUI::createTopContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_top_content = elm_layout_add(m_layout); - elm_object_part_content_set(m_layout, "top_content", m_top_content); - evas_object_size_hint_weight_set(m_top_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_top_content, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(m_top_content); - - elm_layout_file_set(m_top_content, m_edjFilePath.c_str(), "top-content"); - - m_close_button = elm_button_add(m_top_content); - elm_object_style_set(m_close_button, "invisible_button"); - evas_object_smart_callback_add(m_close_button, "clicked", _close_button_clicked, this); - evas_object_show(m_close_button); - elm_object_part_content_set(m_top_content, "close_click", m_close_button); - - elm_object_focus_custom_chain_append(m_top_content, m_close_button, nullptr); - elm_object_focus_set(m_close_button, EINA_TRUE); - elm_object_tree_focus_allow_set(m_layout, EINA_TRUE); - elm_object_focus_allow_set(m_close_button, EINA_TRUE); + void BookmarkDetailsUI::createTopContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_top_content = elm_layout_add(m_layout); + elm_object_part_content_set(m_layout, "top_content", m_top_content); + evas_object_size_hint_weight_set(m_top_content, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_top_content, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_show(m_top_content); + + elm_layout_file_set(m_top_content, m_edjFilePath.c_str(), + "top-content"); + + m_close_button = elm_button_add(m_top_content); + elm_object_style_set(m_close_button, "invisible_button"); + evas_object_smart_callback_add(m_close_button, "clicked", + _close_button_clicked, this); + evas_object_show(m_close_button); + elm_object_part_content_set(m_top_content, "close_click", + m_close_button); + + elm_object_focus_custom_chain_append(m_top_content, m_close_button, + nullptr); + elm_object_focus_set(m_close_button, EINA_TRUE); + elm_object_tree_focus_allow_set(m_layout, EINA_TRUE); + elm_object_focus_allow_set(m_close_button, EINA_TRUE); #if PROFILE_MOBILE - m_more_button = elm_button_add(m_top_content); - elm_object_style_set(m_more_button, "invisible_button"); - evas_object_smart_callback_add(m_more_button, "clicked", _more_button_clicked, this); - elm_object_part_content_set(m_top_content, "more_click", m_more_button); - evas_object_show(m_more_button); - - elm_object_focus_custom_chain_append(m_top_content, m_more_button, nullptr); - elm_object_focus_set(m_more_button, EINA_TRUE); - elm_object_tree_focus_allow_set(m_layout, EINA_TRUE); - elm_object_focus_allow_set(m_more_button, EINA_TRUE); - - m_cancel_top_button = elm_button_add(m_top_content); - elm_object_style_set(m_cancel_top_button, "invisible_button"); - evas_object_smart_callback_add(m_cancel_top_button, "clicked", _cancel_top_button_clicked, this); - elm_object_part_content_set(m_top_content, "cancel_click_2", m_cancel_top_button); - - m_remove_top_button = elm_button_add(m_top_content); - elm_object_style_set(m_remove_top_button, "invisible_button"); - evas_object_smart_callback_add(m_remove_top_button, "clicked", _remove_top_button_clicked, this); - elm_object_part_content_set(m_top_content, "remove_click_2", m_remove_top_button); + m_more_button = elm_button_add(m_top_content); + elm_object_style_set(m_more_button, "invisible_button"); + evas_object_smart_callback_add(m_more_button, "clicked", + _more_button_clicked, this); + elm_object_part_content_set(m_top_content, "more_click", m_more_button); + evas_object_show(m_more_button); + + elm_object_focus_custom_chain_append(m_top_content, m_more_button, + nullptr); + elm_object_focus_set(m_more_button, EINA_TRUE); + elm_object_tree_focus_allow_set(m_layout, EINA_TRUE); + elm_object_focus_allow_set(m_more_button, EINA_TRUE); + + m_cancel_top_button = elm_button_add(m_top_content); + elm_object_style_set(m_cancel_top_button, "invisible_button"); + evas_object_smart_callback_add(m_cancel_top_button, "clicked", + _cancel_top_button_clicked, this); + elm_object_part_content_set(m_top_content, "cancel_click_2", + m_cancel_top_button); + + m_remove_top_button = elm_button_add(m_top_content); + elm_object_style_set(m_remove_top_button, "invisible_button"); + evas_object_smart_callback_add(m_remove_top_button, "clicked", + _remove_top_button_clicked, this); + elm_object_part_content_set(m_top_content, "remove_click_2", + m_remove_top_button); #endif -} + } -void BookmarkDetailsUI::createGengrid() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_gengrid = elm_gengrid_add(m_layout); - edje_object_update_hints_set(m_gengrid, EINA_TRUE); - elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); - elm_gengrid_align_set(m_gengrid, 0, 0); - elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); + void BookmarkDetailsUI::createGengrid() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_gengrid = elm_gengrid_add(m_layout); + edje_object_update_hints_set(m_gengrid, EINA_TRUE); + elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); + elm_gengrid_align_set(m_gengrid, 0, 0); + elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); #if PROFILE_MOBILE - elm_scroller_bounce_set(m_gengrid, EINA_FALSE, EINA_TRUE); - elm_object_scroll_lock_x_set(m_gengrid, EINA_TRUE); + elm_scroller_bounce_set(m_gengrid, EINA_FALSE, EINA_TRUE); + elm_object_scroll_lock_x_set(m_gengrid, EINA_TRUE); #else - elm_object_style_set(m_gengrid, "back_ground"); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scroller_page_size_set(m_gengrid, 0, 327); - evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_gengrid_horizontal_set(m_gengrid, EINA_TRUE); - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(404), ELM_SCALE_SIZE(320)); + elm_object_style_set(m_gengrid, "back_ground"); + elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + elm_scroller_page_size_set(m_gengrid, 0, 327); + evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_gengrid_horizontal_set(m_gengrid, EINA_TRUE); + elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(404), + ELM_SCALE_SIZE(320)); #endif -} + } #if PROFILE_MOBILE -void BookmarkDetailsUI::createMenuDetails() -{ - m_menu_bg_button = elm_button_add(m_layout); - elm_object_style_set(m_menu_bg_button, "invisible_button"); - evas_object_smart_callback_add(m_menu_bg_button, "clicked", _menu_bg_button_clicked, this); - elm_object_part_content_set(m_layout, "more_bg_click", m_menu_bg_button); - - m_menu = elm_box_add(m_layout); - evas_object_size_hint_weight_set(m_menu, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_menu, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_edit_button = elm_button_add(m_menu); - elm_object_style_set(m_edit_button, "more-button"); - evas_object_size_hint_weight_set(m_edit_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_edit_button, 0.0, 0.0); - elm_object_part_text_set(m_edit_button, "elm.text", "Edit folder name"); - elm_box_pack_end(m_menu, m_edit_button); - evas_object_smart_callback_add(m_edit_button, "clicked", _edit_button_clicked, this); - - evas_object_show(m_edit_button); - elm_object_tree_focus_allow_set(m_edit_button, EINA_FALSE); - - m_delete_button = elm_button_add(m_menu); - elm_object_style_set(m_delete_button, "more-button"); - evas_object_size_hint_weight_set(m_delete_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_delete_button, 0.0, 0.0); - elm_object_part_text_set(m_delete_button, "elm.text", "Delete folder"); - elm_box_pack_end(m_menu, m_delete_button); - evas_object_smart_callback_add(m_delete_button, "clicked", _delete_button_clicked, this); - - evas_object_show(m_delete_button); - elm_object_tree_focus_allow_set(m_delete_button, EINA_FALSE); - - m_remove_button = elm_button_add(m_menu); - elm_object_style_set(m_remove_button, "more-shadow-button"); - evas_object_size_hint_weight_set(m_remove_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_remove_button, 0.0, 0.0); - elm_object_part_text_set(m_remove_button, "elm.text", "Remove Bookmarks"); - elm_box_pack_end(m_menu, m_remove_button); - evas_object_smart_callback_add(m_remove_button, "clicked", _remove_button_clicked, this); - - evas_object_show(m_remove_button); - elm_object_tree_focus_allow_set(m_remove_button, EINA_FALSE); - - elm_object_part_content_set(m_layout, "more_swallow", m_menu); - evas_object_show(m_menu); -} + void BookmarkDetailsUI::createMenuDetails() + { + m_menu_bg_button = elm_button_add(m_layout); + elm_object_style_set(m_menu_bg_button, "invisible_button"); + evas_object_smart_callback_add(m_menu_bg_button, "clicked", + _menu_bg_button_clicked, this); + elm_object_part_content_set(m_layout, "more_bg_click", + m_menu_bg_button); + + m_menu = elm_box_add(m_layout); + evas_object_size_hint_weight_set(m_menu, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_menu, EVAS_HINT_FILL, EVAS_HINT_FILL); + + m_edit_button = elm_button_add(m_menu); + elm_object_style_set(m_edit_button, "more-button"); + evas_object_size_hint_weight_set(m_edit_button, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_edit_button, 0.0, 0.0); + elm_object_part_text_set(m_edit_button, "elm.text", "Edit folder name"); + elm_box_pack_end(m_menu, m_edit_button); + evas_object_smart_callback_add(m_edit_button, "clicked", + _edit_button_clicked, this); + + evas_object_show(m_edit_button); + elm_object_tree_focus_allow_set(m_edit_button, EINA_FALSE); + + m_delete_button = elm_button_add(m_menu); + elm_object_style_set(m_delete_button, "more-button"); + evas_object_size_hint_weight_set(m_delete_button, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_delete_button, 0.0, 0.0); + elm_object_part_text_set(m_delete_button, "elm.text", "Delete folder"); + elm_box_pack_end(m_menu, m_delete_button); + evas_object_smart_callback_add(m_delete_button, "clicked", + _delete_button_clicked, this); + + evas_object_show(m_delete_button); + elm_object_tree_focus_allow_set(m_delete_button, EINA_FALSE); + + m_remove_button = elm_button_add(m_menu); + elm_object_style_set(m_remove_button, "more-shadow-button"); + evas_object_size_hint_weight_set(m_remove_button, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_remove_button, 0.0, 0.0); + elm_object_part_text_set(m_remove_button, "elm.text", + "Remove Bookmarks"); + elm_box_pack_end(m_menu, m_remove_button); + evas_object_smart_callback_add(m_remove_button, "clicked", + _remove_button_clicked, this); + + evas_object_show(m_remove_button); + elm_object_tree_focus_allow_set(m_remove_button, EINA_FALSE); + + elm_object_part_content_set(m_layout, "more_swallow", m_menu); + evas_object_show(m_menu); + } -void BookmarkDetailsUI::updateGengridItems() -{ - for (auto it = m_map_delete.begin(); it != m_map_delete.end(); ++it) - if (it->second) { - it->second = false; - elm_gengrid_item_update(m_map_bookmark[it->first]); - } -} + void BookmarkDetailsUI::updateGengridItems() + { + for (auto it = m_map_delete.begin(); it != m_map_delete.end(); ++it) + if (it->second) { + it->second = false; + elm_gengrid_item_update(m_map_bookmark[it->first]); + } + } -void BookmarkDetailsUI::resetRemovalMode() -{ - m_map_delete.clear(); - m_delete_count = 0; - m_remove_bookmark_mode = false; - elm_object_signal_emit(m_top_content, "default_mode", "ui"); - elm_object_part_text_set(m_top_content, "title_text", (boost::format("%s(%d)") % m_folder_name.c_str() - % elm_gengrid_items_count(m_gengrid)).str().c_str()); - elm_gengrid_realized_items_update(m_gengrid); -} + void BookmarkDetailsUI::resetRemovalMode() + { + m_map_delete.clear(); + m_delete_count = 0; + m_remove_bookmark_mode = false; + elm_object_signal_emit(m_top_content, "default_mode", "ui"); + elm_object_part_text_set(m_top_content, "title_text", + (boost::format("%s(%d)") % + m_folder_name.c_str() + % + elm_gengrid_items_count(m_gengrid)).str(). + c_str()); + elm_gengrid_realized_items_update(m_gengrid); + } #else -void BookmarkDetailsUI::createBottomContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_layout); - - m_bottom_content = elm_layout_add(m_layout); - elm_object_part_content_set(m_layout, "bottom_content", m_bottom_content); - evas_object_size_hint_weight_set(m_bottom_content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_bottom_content, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(m_bottom_content); - - elm_layout_file_set(m_bottom_content, m_edjFilePath.c_str(), - "bottom-content"); -} + void BookmarkDetailsUI::createBottomContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_layout); + + m_bottom_content = elm_layout_add(m_layout); + elm_object_part_content_set(m_layout, "bottom_content", + m_bottom_content); + evas_object_size_hint_weight_set(m_bottom_content, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_bottom_content, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_show(m_bottom_content); + + elm_layout_file_set(m_bottom_content, m_edjFilePath.c_str(), + "bottom-content"); + } #endif -Evas_Object* BookmarkDetailsUI::createLayout(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_layout = elm_layout_add(parent); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), - "bookmark-details-layout"); - evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - createTopContent(); - createGengrid(); + Evas_Object *BookmarkDetailsUI::createLayout(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_layout = elm_layout_add(parent); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), + "bookmark-details-layout"); + evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + createTopContent(); + createGengrid(); #if PROFILE_MOBILE - resetContent(); - createMenuDetails(); + resetContent(); + createMenuDetails(); #else - createBottomContent(); - createFocusVector(); + createBottomContent(); + createFocusVector(); #endif - return m_layout; -} + return m_layout; + } -void BookmarkDetailsUI::addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem> hi) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BookmarkItemData *itemData = new BookmarkItemData(); - itemData->item = hi; - itemData->bookmarkDetailsUI = this; - Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, - m_bookmark_item_class, itemData, _bookmark_item_clicked, itemData); + void BookmarkDetailsUI::addBookmarkItem(std::shared_ptr < + tizen_browser::services:: + BookmarkItem > hi) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BookmarkItemData *itemData = new BookmarkItemData(); + itemData->item = hi; + itemData->bookmarkDetailsUI = this; + Elm_Object_Item *bookmarkView = elm_gengrid_item_append(m_gengrid, + m_bookmark_item_class, + itemData, + _bookmark_item_clicked, + itemData); #if PROFILE_MOBILE - m_map_bookmark.insert(std::pair<unsigned int,Elm_Object_Item*>(hi->getId(), bookmarkView)); + m_map_bookmark.insert(std::pair < unsigned int, + Elm_Object_Item * >(hi->getId(), bookmarkView)); #endif - elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); -} - -void BookmarkDetailsUI::addBookmarks(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> > items, std::string folder_name) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); + } - elm_gengrid_clear(m_gengrid); - m_folder_name = folder_name; - for (auto it = items.begin(); it != items.end(); ++it) - addBookmarkItem(*it); - elm_object_part_text_set(m_top_content, "title_text", + void BookmarkDetailsUI::addBookmarks(std::vector < std::shared_ptr < + tizen_browser::services:: + BookmarkItem > >items, + std::string folder_name) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + elm_gengrid_clear(m_gengrid); + m_folder_name = folder_name; + for (auto it = items.begin(); it != items.end(); ++it) + addBookmarkItem(*it); + elm_object_part_text_set(m_top_content, "title_text", #if PROFILE_MOBILE - (boost::format("%s(%d)") % m_folder_name.c_str() % items.size()).str().c_str()); + (boost::format("%s(%d)") % + m_folder_name.c_str() % + items.size()).str().c_str()); #else - (boost::format("Bookmark Manager > %s") % m_folder_name.c_str()).str().c_str()); + (boost::format("Bookmark Manager > %s") % + m_folder_name.c_str()).str().c_str()); #endif - elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); + elm_object_part_content_set(m_layout, "elm.swallow.grid", m_gengrid); #if PROFILE_MOBILE - elm_box_unpack_all(m_menu); - if (m_folder_name != _("IDS_BR_BODY_ALL") && m_folder_name != "Mobile") { - evas_object_show(m_edit_button); - evas_object_show(m_delete_button); - elm_box_pack_end(m_menu, m_edit_button); - elm_box_pack_end(m_menu, m_delete_button); - } else { - evas_object_hide(m_edit_button); - evas_object_hide(m_delete_button); - } - elm_box_pack_end(m_menu, m_remove_button); + elm_box_unpack_all(m_menu); + if (m_folder_name != _("IDS_BR_BODY_ALL") && m_folder_name != "Mobile") { + evas_object_show(m_edit_button); + evas_object_show(m_delete_button); + elm_box_pack_end(m_menu, m_edit_button); + elm_box_pack_end(m_menu, m_delete_button); + } else { + evas_object_hide(m_edit_button); + evas_object_hide(m_delete_button); + } + elm_box_pack_end(m_menu, m_remove_button); #else - elm_object_part_text_set(m_bottom_content, "text", (boost::format("%d %s") % elm_gengrid_items_count(m_gengrid) % - (elm_gengrid_items_count(m_gengrid) == 1 ? "bookmark" : "bookmarks")).str().c_str()); + elm_object_part_text_set(m_bottom_content, "text", + (boost::format("%d %s") % + elm_gengrid_items_count(m_gengrid) % + (elm_gengrid_items_count(m_gengrid) == + 1 ? "bookmark" : "bookmarks")).str(). + c_str()); #endif - if (items.size() != 0) - setEmpty(false); - evas_object_show(m_gengrid); - items.clear(); -} + if (items.size() != 0) + setEmpty(false); + evas_object_show(m_gengrid); + items.clear(); + } + } } -} - diff --git a/services/BookmarkDetailsUI/BookmarkDetailsUI.h b/services/BookmarkDetailsUI/BookmarkDetailsUI.h index 4b8a8eac..7c5982ef 100644..100755 --- a/services/BookmarkDetailsUI/BookmarkDetailsUI.h +++ b/services/BookmarkDetailsUI/BookmarkDetailsUI.h @@ -41,101 +41,118 @@ #include "FocusManager.h" #endif -namespace tizen_browser{ -namespace base_ui{ - -class BROWSER_EXPORT BookmarkDetailsUI - : public tizen_browser::interfaces::AbstractUIComponent - , public tizen_browser::core::AbstractService +namespace tizen_browser { -public: - BookmarkDetailsUI(); - ~BookmarkDetailsUI(); - //AbstractUIComponent interface methods - void init(Evas_Object *parent); - void showUI(); - void hideUI(); - void hide(); - Evas_Object *getContent(); - virtual std::string getName(); - void onBackPressed(); - - void addBookmarks(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >, std::string); - - boost::signals2::signal<void ()> closeBookmarkDetailsClicked; - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkItemClicked; + namespace base_ui + { + + class BROWSER_EXPORT BookmarkDetailsUI:public tizen_browser::interfaces:: + AbstractUIComponent, public tizen_browser::core::AbstractService + { + public: + BookmarkDetailsUI(); + ~BookmarkDetailsUI(); + //AbstractUIComponent interface methods + void init(Evas_Object * parent); + void showUI(); + void hideUI(); + void hide(); + Evas_Object *getContent(); + virtual std::string getName(); + void onBackPressed(); + + void addBookmarks(std::vector < std::shared_ptr < + tizen_browser::services::BookmarkItem > >, + std::string); + + boost::signals2::signal < void() > closeBookmarkDetailsClicked; + boost::signals2::signal < void(std::shared_ptr < + tizen_browser::services:: + BookmarkItem >) > bookmarkItemClicked; #if PROFILE_MOBILE - boost::signals2::signal<void (std::string)> editFolderButtonClicked; - boost::signals2::signal<void (std::string)> deleteFolderButtonClicked; - boost::signals2::signal<void (std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem>>)> removeFoldersButtonClicked; - - void setLandscape(bool state); + boost::signals2::signal < void(std::string) > + editFolderButtonClicked; + boost::signals2::signal < void(std::string) > + deleteFolderButtonClicked; + boost::signals2::signal < void(std::vector < std::shared_ptr < + tizen_browser::services:: + BookmarkItem >>) > + removeFoldersButtonClicked; + + void setLandscape(bool state); #endif -private: - void addBookmarkItem(std::shared_ptr<tizen_browser::services::BookmarkItem>); + private: + void addBookmarkItem(std::shared_ptr < + tizen_browser::services::BookmarkItem >); #if !PROFILE_MOBILE - void createFocusVector(); + void createFocusVector(); #endif - void createGengridItemClasses(); - std::string getFolderName(); - void setEmpty(bool isEmpty); - - Evas_Object* createLayout(Evas_Object* parent); - void createTopContent(); - void createGengrid(); - void createBottomContent(); + void createGengridItemClasses(); + std::string getFolderName(); + void setEmpty(bool isEmpty); + + Evas_Object *createLayout(Evas_Object * parent); + void createTopContent(); + void createGengrid(); + void createBottomContent(); #if PROFILE_MOBILE - void resetContent(); - void createMenuDetails(); - void updateGengridItems(); - void resetRemovalMode(); - static void _more_button_clicked(void *data, Evas_Object *, void *); - static void _menu_bg_button_clicked(void *data, Evas_Object *, void *); - static void _edit_button_clicked(void *data, Evas_Object *, void *); - static void _delete_button_clicked(void *data, Evas_Object *, void *); - static void _remove_button_clicked(void *data, Evas_Object *, void *); - static void _cancel_top_button_clicked(void *data, Evas_Object *, void *); - static void _remove_top_button_clicked(void *data, Evas_Object *, void *); + void resetContent(); + void createMenuDetails(); + void updateGengridItems(); + void resetRemovalMode(); + static void _more_button_clicked(void *data, Evas_Object *, void *); + static void _menu_bg_button_clicked(void *data, Evas_Object *, void *); + static void _edit_button_clicked(void *data, Evas_Object *, void *); + static void _delete_button_clicked(void *data, Evas_Object *, void *); + static void _remove_button_clicked(void *data, Evas_Object *, void *); + static void _cancel_top_button_clicked(void *data, Evas_Object *, + void *); + static void _remove_top_button_clicked(void *data, Evas_Object *, + void *); #endif - static void _grid_content_delete(void *data, Evas_Object *obj); - static char* _grid_bookmark_text_get(void *data, Evas_Object *obj, const char *part); - static Evas_Object* _grid_bookmark_content_get(void *data, Evas_Object *obj, const char *part); - static void _bookmark_item_clicked(void * data, Evas_Object * obj, void * event_info); - static void _bookmark_thumbSelected(void * data, Evas_Object *, void *); - static void _close_button_clicked(void *data, Evas_Object *, void *); - - Evas_Object *m_parent; - std::string m_edjFilePath; - Evas_Object *m_layout; - Evas_Object *m_top_content; - Evas_Object *m_gengrid; + static void _grid_content_delete(void *data, Evas_Object * obj); + static char *_grid_bookmark_text_get(void *data, Evas_Object * obj, + const char *part); + static Evas_Object *_grid_bookmark_content_get(void *data, + Evas_Object * obj, + const char *part); + static void _bookmark_item_clicked(void *data, Evas_Object * obj, + void *event_info); + static void _bookmark_thumbSelected(void *data, Evas_Object *, void *); + static void _close_button_clicked(void *data, Evas_Object *, void *); + + Evas_Object *m_parent; + std::string m_edjFilePath; + Evas_Object *m_layout; + Evas_Object *m_top_content; + Evas_Object *m_gengrid; #if !PROFILE_MOBILE - Evas_Object *m_bottom_content; - FocusManager m_focusManager; + Evas_Object *m_bottom_content; + FocusManager m_focusManager; #else - std::map<unsigned int, Elm_Object_Item*> m_map_bookmark; - std::map<unsigned int, bool> m_map_delete; - - Evas_Object *m_more_button; - Evas_Object *m_menu_bg_button; - Evas_Object *m_menu; - Evas_Object *m_edit_button; - Evas_Object *m_delete_button; - Evas_Object *m_remove_button; - Evas_Object *m_cancel_top_button; - Evas_Object *m_remove_top_button; - unsigned int m_delete_count; - bool m_remove_bookmark_mode; + std::map < unsigned int, Elm_Object_Item * >m_map_bookmark; + std::map < unsigned int, bool > m_map_delete; + + Evas_Object *m_more_button; + Evas_Object *m_menu_bg_button; + Evas_Object *m_menu; + Evas_Object *m_edit_button; + Evas_Object *m_delete_button; + Evas_Object *m_remove_button; + Evas_Object *m_cancel_top_button; + Evas_Object *m_remove_top_button; + unsigned int m_delete_count; + bool m_remove_bookmark_mode; #endif - Evas_Object *m_close_button; + Evas_Object *m_close_button; - Elm_Gengrid_Item_Class * m_bookmark_item_class; - std::string m_folder_name; - unsigned int m_rotation_state; -}; + Elm_Gengrid_Item_Class *m_bookmark_item_class; + std::string m_folder_name; + unsigned int m_rotation_state; + }; -} + } } -#endif // BOOKMARKDETAILSUI_H +#endif // BOOKMARKDETAILSUI_H diff --git a/services/BookmarkFlowUI/BookmarkFlowUI.h b/services/BookmarkFlowUI/BookmarkFlowUI.h index 08a48327..f8fce5c5 100644..100755 --- a/services/BookmarkFlowUI/BookmarkFlowUI.h +++ b/services/BookmarkFlowUI/BookmarkFlowUI.h @@ -44,140 +44,145 @@ #define BOOKMARK_FLOW_SERVICE "org.tizen.browser.bookmarkflowui" #define M_UNUSED(x) (void)(x) -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -struct BookmarkUpdate { - unsigned int folder_id; - std::string title; -}; + struct BookmarkUpdate + { + unsigned int folder_id; + std::string title; + }; -class BROWSER_EXPORT BookmarkFlowUI + class BROWSER_EXPORT BookmarkFlowUI #if PROFILE_MOBILE - : public tizen_browser::interfaces::AbstractUIComponent + : public tizen_browser::interfaces::AbstractUIComponent #else - : public interfaces::AbstractPopup + : public interfaces::AbstractPopup #endif - , public tizen_browser::core::AbstractService -{ -public: - BookmarkFlowUI(); - ~BookmarkFlowUI(); - //AbstractUIComponent interface methods - void init(Evas_Object *parent); - Evas_Object *getContent(); - void addCustomFolders(services::SharedBookmarkFolderList folders); + , public tizen_browser::core::AbstractService + { + public: + BookmarkFlowUI(); + ~BookmarkFlowUI(); + //AbstractUIComponent interface methods + void init(Evas_Object * parent); + Evas_Object *getContent(); + void addCustomFolders(services::SharedBookmarkFolderList folders); #if PROFILE_MOBILE - void showUI(); - void hideUI(); - void setState(bool state); - void setTitle(const std::string& title); - void setURL(const std::string& title); - void setFolder(unsigned int folder_id, const std::string& folder_name); - void setFoldersId(unsigned int all, unsigned int special); - void resetContent(); + void showUI(); + void hideUI(); + void setState(bool state); + void setTitle(const std::string & title); + void setURL(const std::string & title); + void setFolder(unsigned int folder_id, const std::string & folder_name); + void setFoldersId(unsigned int all, unsigned int special); + void resetContent(); #else - static BookmarkFlowUI* createPopup(Evas_Object* parent); - void show(); - void dismiss(); - void onBackPressed(); - void addNewFolder(); + static BookmarkFlowUI *createPopup(Evas_Object * parent); + void show(); + void dismiss(); + void onBackPressed(); + void addNewFolder(); #endif - virtual std::string getName(); - void hide(); - - boost::signals2::signal<void ()> closeBookmarkFlowClicked; - boost::signals2::signal<void (BookmarkUpdate)> saveBookmark; - boost::signals2::signal<void (BookmarkUpdate)> editBookmark; - boost::signals2::signal<void ()> removeBookmark; - boost::signals2::signal<void ()> addFolder; + virtual std::string getName(); + void hide(); + + boost::signals2::signal < void() > closeBookmarkFlowClicked; + boost::signals2::signal < void(BookmarkUpdate) > saveBookmark; + boost::signals2::signal < void(BookmarkUpdate) > editBookmark; + boost::signals2::signal < void() > removeBookmark; + boost::signals2::signal < void() > addFolder; #if PROFILE_MOBILE - boost::signals2::signal<bool ()> isRotated; + boost::signals2::signal < bool() > isRotated; #endif -private: - typedef struct - { - std::string name; - unsigned int folder_id; - std::shared_ptr<tizen_browser::base_ui::BookmarkFlowUI> bookmarkFlowUI; - } FolderData; - - Evas_Object* createBookmarkFlowLayout(); - void createTitleArea(); - - Evas_Object *m_parent; - Evas_Object *m_layout; - Evas_Object *m_title_area; - std::string m_edjFilePath; - bool m_state; - unsigned int m_all_folder_id; - - static char* _folder_title_text_get(void* data, Evas_Object*, const char* part); + private: + typedef struct + { + std::string name; + unsigned int folder_id; + std::shared_ptr < tizen_browser::base_ui::BookmarkFlowUI > + bookmarkFlowUI; + } FolderData; + + Evas_Object *createBookmarkFlowLayout(); + void createTitleArea(); + + Evas_Object *m_parent; + Evas_Object *m_layout; + Evas_Object *m_title_area; + std::string m_edjFilePath; + bool m_state; + unsigned int m_all_folder_id; + + static char *_folder_title_text_get(void *data, Evas_Object *, + const char *part); #if PROFILE_MOBILE - void createContentsArea(); - void createGenlistItemClasses(); - void createGenlist(); - void listAddCustomFolder(FolderData* item); - - static void _save_clicked(void* data, Evas_Object*, void*); - static void _cancel_clicked(void* data, Evas_Object*, void*); - static void _entry_focused(void* data, Evas_Object*, void*); - static void _entry_unfocused(void* data, Evas_Object*, void*); - static void _entry_changed(void* data, Evas_Object*, void*); - static void _inputCancel_clicked(void* data, Evas_Object*, void*); - static void _folder_clicked(void* data, Evas_Object*, void*); - static void _folder_dropdown_clicked(void* data, Evas_Object*, void*); - static void _remove_clicked(void* data, Evas_Object*, void*); - static void _listCustomFolderClicked(void* data, Evas_Object*, void*); - - Evas_Object *m_contents_area; - Evas_Object *m_remove_button; - Evas_Object *m_entry; - Evas_Object *m_save_box; - Evas_Object *m_save; - Evas_Object *m_save_button; - Evas_Object *m_cancel_box; - Evas_Object *m_cancel; - Evas_Object *m_cancel_button; - Evas_Object *m_input_cancel_button; - Evas_Object *m_folder_button; - Evas_Object *m_folder_dropdown_button; - Evas_Object *m_genlist; - - Elm_Genlist_Item_Class *m_folder_custom_item_class; - Elm_Genlist_Item_Class *m_folder_selected_item_class; - std::map<unsigned int, Elm_Object_Item*> m_map_folders; - unsigned int m_folder_id; - unsigned int m_special_folder_id; - unsigned int m_max_items; - const unsigned int MAX_ITEMS = 4; - const unsigned int MAX_ITEMS_LANDSCAPE = 2; - const unsigned int GENLIST_HEIGHT = 384; - const unsigned int GENLIST_HEIGHT_LANDSCAPE = 192; + void createContentsArea(); + void createGenlistItemClasses(); + void createGenlist(); + void listAddCustomFolder(FolderData * item); + + static void _save_clicked(void *data, Evas_Object *, void *); + static void _cancel_clicked(void *data, Evas_Object *, void *); + static void _entry_focused(void *data, Evas_Object *, void *); + static void _entry_unfocused(void *data, Evas_Object *, void *); + static void _entry_changed(void *data, Evas_Object *, void *); + static void _inputCancel_clicked(void *data, Evas_Object *, void *); + static void _folder_clicked(void *data, Evas_Object *, void *); + static void _folder_dropdown_clicked(void *data, Evas_Object *, void *); + static void _remove_clicked(void *data, Evas_Object *, void *); + static void _listCustomFolderClicked(void *data, Evas_Object *, void *); + + Evas_Object *m_contents_area; + Evas_Object *m_remove_button; + Evas_Object *m_entry; + Evas_Object *m_save_box; + Evas_Object *m_save; + Evas_Object *m_save_button; + Evas_Object *m_cancel_box; + Evas_Object *m_cancel; + Evas_Object *m_cancel_button; + Evas_Object *m_input_cancel_button; + Evas_Object *m_folder_button; + Evas_Object *m_folder_dropdown_button; + Evas_Object *m_genlist; + + Elm_Genlist_Item_Class *m_folder_custom_item_class; + Elm_Genlist_Item_Class *m_folder_selected_item_class; + std::map < unsigned int, Elm_Object_Item * >m_map_folders; + unsigned int m_folder_id; + unsigned int m_special_folder_id; + unsigned int m_max_items; + const unsigned int MAX_ITEMS = 4; + const unsigned int MAX_ITEMS_LANDSCAPE = 2; + const unsigned int GENLIST_HEIGHT = 384; + const unsigned int GENLIST_HEIGHT_LANDSCAPE = 192; #else - void createGengridItemClasses(); - void createGengrid(); - void gridAddCustomFolder(FolderData* item); - void createFocusVector(); - - static void _gridNewFolderClicked(void* data, Evas_Object*, void*); - static void _gridCustomFolderClicked(void* data, Evas_Object*, void*); - static void _bg_clicked(void* data, Evas_Object*, void*); - - Evas_Object *m_gengrid; - Evas_Object *m_bg; - Elm_Gengrid_Item_Class *m_folder_new_item_class; - Elm_Gengrid_Item_Class *m_folder_custom_item_class; - - FocusManager m_focusManager; - const unsigned int upto9 = 10; - const unsigned int upto6 = 7; + void createGengridItemClasses(); + void createGengrid(); + void gridAddCustomFolder(FolderData * item); + void createFocusVector(); + + static void _gridNewFolderClicked(void *data, Evas_Object *, void *); + static void _gridCustomFolderClicked(void *data, Evas_Object *, void *); + static void _bg_clicked(void *data, Evas_Object *, void *); + + Evas_Object *m_gengrid; + Evas_Object *m_bg; + Elm_Gengrid_Item_Class *m_folder_new_item_class; + Elm_Gengrid_Item_Class *m_folder_custom_item_class; + + FocusManager m_focusManager; + const unsigned int upto9 = 10; + const unsigned int upto6 = 7; #endif -}; + }; -} + } } -#endif // BOOKMARKFLOWUI_H +#endif // BOOKMARKFLOWUI_H diff --git a/services/BookmarkManagerUI/BookmarkManagerUI.h b/services/BookmarkManagerUI/BookmarkManagerUI.h index 4aeee1e0..8d258b15 100644..100755 --- a/services/BookmarkManagerUI/BookmarkManagerUI.h +++ b/services/BookmarkManagerUI/BookmarkManagerUI.h @@ -62,14 +62,14 @@ public: void addCustomFolders(services::SharedBookmarkFolderList folders); void addCustomFolders(std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem> >); - boost::signals2::signal<void ()> closeBookmarkManagerClicked; - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkItemClicked; - boost::signals2::signal<void (int)> customFolderClicked; - boost::signals2::signal<void ()> allFolderClicked; + boost::signals2::signal<void()> closeBookmarkManagerClicked; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::services::BookmarkItem>)> bookmarkItemClicked; + boost::signals2::signal<void(int)> customFolderClicked; + boost::signals2::signal<void()> allFolderClicked; //Special folder - Bookmark Bar on tv and Mobile on odroid - boost::signals2::signal<void ()> specialFolderClicked; + boost::signals2::signal<void()> specialFolderClicked; #if PROFILE_MOBILE - boost::signals2::signal<void ()> newFolderItemClicked; + boost::signals2::signal<void()> newFolderItemClicked; #endif private: @@ -104,7 +104,7 @@ private: static char* _grid_all_folder_title_text_get(void *data, Evas_Object *obj, const char *part); static char* _grid_folder_title_text_get(void *data, Evas_Object *obj, const char *part); - std::map<std::string,Elm_Object_Item*> m_map_bookmark; + std::map<std::string, Elm_Object_Item*> m_map_bookmark; std::string m_edjFilePath; Evas_Object *m_parent; diff --git a/services/BookmarkService/BookmarkService.cpp b/services/BookmarkService/BookmarkService.cpp index 0236aa7f..53eaaecb 100644..100755 --- a/services/BookmarkService/BookmarkService.cpp +++ b/services/BookmarkService/BookmarkService.cpp @@ -39,439 +39,499 @@ #include <web/web_bookmark.h> #include "Tools/CapiWebErrorCodes.h" -namespace tizen_browser{ -namespace services{ - -EXPORT_SERVICE(BookmarkService, "org.tizen.browser.favoriteservice") - -BookmarkService::BookmarkService() +namespace tizen_browser { - if(bp_bookmark_adaptor_initialize() < 0) { - errorPrint("bp_bookmark_adaptor_initialize"); - return; - } -} + namespace services + { -BookmarkService::~BookmarkService() -{ - bp_bookmark_adaptor_deinitialize(); -} + EXPORT_SERVICE(BookmarkService, "org.tizen.browser.favoriteservice") -void BookmarkService::errorPrint(std::string method) const -{ - int error_code = bp_bookmark_adaptor_get_errorcode(); - BROWSER_LOGE("%s error: %d (%s)", method.c_str(), error_code, - tools::capiWebError::bookmarkErrorToString(error_code).c_str()); -} - -std::shared_ptr<BookmarkItem> BookmarkService::addBookmark( - const std::string & address, - const std::string & title, - const std::string & note, - std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail, - std::shared_ptr<tizen_browser::tools::BrowserImage> favicon, - unsigned int dirId) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - bp_bookmark_property_cond_fmt properties; - properties.parent = -1; - properties.type = 0; - properties.is_operator = -1; - properties.is_editable = -1; - //conditions for querying - bp_bookmark_rows_cond_fmt conds; - conds.limit = 1; - conds.offset = 0; - conds.order_offset = BP_BOOKMARK_O_SEQUENCE; - conds.ordering = 0; - conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.period_type = BP_BOOKMARK_DATE_ALL; - - int id = -1; - int *ids = nullptr; - int ids_count = -1; - int ret = bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, address.c_str(), 0); - free(ids); - if (ret < 0){ - BROWSER_LOGE("Error! Could not get ids!"); - return std::make_shared<BookmarkItem>(); + BookmarkService::BookmarkService() + { + if (bp_bookmark_adaptor_initialize() < 0) { + errorPrint("bp_bookmark_adaptor_initialize"); + return; + } } - bp_bookmark_info_fmt info; - - std::memset(&info, 0, sizeof(bp_bookmark_info_fmt)); - info.type = 0; - info.parent = dirId; - info.sequence = -1; - info.access_count = -1; - info.editable = 1; - - if (!address.empty()) { - info.url = (char*) address.c_str(); + BookmarkService::~BookmarkService() + { + bp_bookmark_adaptor_deinitialize(); } - if (!title.empty()) - info.title = (char*) title.c_str(); - if (bp_bookmark_adaptor_easy_create(&id, &info) < 0) { - errorPrint("bp_bookmark_adaptor_easy_create"); - bp_bookmark_adaptor_easy_free(&info); - return std::make_shared<BookmarkItem>(); - } - // max sequence - if (bp_bookmark_adaptor_set_sequence(id, -1) < 0){ - BROWSER_LOGE("Error! Could not set sequence!"); - return std::make_shared<BookmarkItem>(); + void BookmarkService::errorPrint(std::string method) const + { + int error_code = bp_bookmark_adaptor_get_errorcode(); + BROWSER_LOGE("%s error: %d (%s)", method.c_str(), error_code, + tools::capiWebError::bookmarkErrorToString(error_code). + c_str()); } - std::shared_ptr<BookmarkItem> bookmark = std::make_shared<BookmarkItem>(address, title, note, dirId, id); - if (thumbnail && thumbnail->getSize() > 0){ - std::unique_ptr<tizen_browser::tools::Blob> thumb_blob = tizen_browser::tools::EflTools::getBlobPNG(thumbnail); - if (thumb_blob){ - unsigned char * thumb = std::move((unsigned char*)thumb_blob->getData()); - bp_bookmark_adaptor_set_snapshot(id, thumbnail->getWidth(), thumbnail->getHeight(), thumb, thumb_blob->getLength()); - bookmark->setThumbnail(thumbnail); - } else - BROWSER_LOGW("Could not create thumbnail!"); - } else - BROWSER_LOGW("Thumbnail object does not exist!"); - - if (favicon && favicon->getSize() > 0){ - std::unique_ptr<tizen_browser::tools::Blob> favicon_blob = tizen_browser::tools::EflTools::getBlobPNG(favicon); - if (favicon_blob){ - unsigned char * fav = std::move((unsigned char*)favicon_blob->getData()); - bp_bookmark_adaptor_set_icon(id, favicon->getWidth(), favicon->getHeight(), fav, favicon_blob->getLength()); - bookmark->setFavicon(favicon); - } else - BROWSER_LOGW("Could not create favicon!"); - } else - BROWSER_LOGW("Favicon object does not exist!"); + std::shared_ptr < BookmarkItem > + BookmarkService::addBookmark(const std::string & address, + const std::string & title, + const std::string & note, + std::shared_ptr < + tizen_browser::tools::BrowserImage > + thumbnail, + std::shared_ptr < + tizen_browser::tools::BrowserImage > + favicon, unsigned int dirId) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + bp_bookmark_property_cond_fmt properties; + properties.parent = -1; + properties.type = 0; + properties.is_operator = -1; + properties.is_editable = -1; + //conditions for querying + bp_bookmark_rows_cond_fmt conds; + conds.limit = 1; + conds.offset = 0; + conds.order_offset = BP_BOOKMARK_O_SEQUENCE; + conds.ordering = 0; + conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.period_type = BP_BOOKMARK_DATE_ALL; + + int id = -1; + int *ids = nullptr; + int ids_count = -1; + int ret = + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, + &conds, BP_BOOKMARK_O_URL, + address.c_str(), 0); + free(ids); + if (ret < 0) { + BROWSER_LOGE("Error! Could not get ids!"); + return std::make_shared < BookmarkItem > (); + } + + bp_bookmark_info_fmt info; + + std::memset(&info, 0, sizeof(bp_bookmark_info_fmt)); + info.type = 0; + info.parent = dirId; + info.sequence = -1; + info.access_count = -1; + info.editable = 1; + + if (!address.empty()) { + info.url = (char *) address.c_str(); + } + if (!title.empty()) + info.title = (char *) title.c_str(); + + if (bp_bookmark_adaptor_easy_create(&id, &info) < 0) { + errorPrint("bp_bookmark_adaptor_easy_create"); + bp_bookmark_adaptor_easy_free(&info); + return std::make_shared < BookmarkItem > (); + } + // max sequence + if (bp_bookmark_adaptor_set_sequence(id, -1) < 0) { + BROWSER_LOGE("Error! Could not set sequence!"); + return std::make_shared < BookmarkItem > (); + } + + std::shared_ptr < BookmarkItem > bookmark = + std::make_shared < BookmarkItem > (address, title, note, dirId, id); + if (thumbnail && thumbnail->getSize() > 0) { + std::unique_ptr < tizen_browser::tools::Blob > thumb_blob = + tizen_browser::tools::EflTools::getBlobPNG(thumbnail); + if (thumb_blob) { + unsigned char *thumb = + std::move((unsigned char *) thumb_blob->getData()); + bp_bookmark_adaptor_set_snapshot(id, thumbnail->getWidth(), + thumbnail->getHeight(), thumb, + thumb_blob->getLength()); + bookmark->setThumbnail(thumbnail); + } else { + BROWSER_LOGW("Could not create thumbnail!"); + } + } else { + BROWSER_LOGW("Thumbnail object does not exist!"); + } + + if (favicon && favicon->getSize() > 0) { + std::unique_ptr < tizen_browser::tools::Blob > favicon_blob = + tizen_browser::tools::EflTools::getBlobPNG(favicon); + if (favicon_blob) { + unsigned char *fav = + std::move((unsigned char *) favicon_blob->getData()); + bp_bookmark_adaptor_set_icon(id, favicon->getWidth(), + favicon->getHeight(), fav, + favicon_blob->getLength()); + bookmark->setFavicon(favicon); + } else { + BROWSER_LOGW("Could not create favicon!"); + } + } else { + BROWSER_LOGW("Favicon object does not exist!"); + } #if PROFILE_MOBILE - bookmark->set_folder_flag(EINA_FALSE); + bookmark->set_folder_flag(EINA_FALSE); #endif - bookmarkAdded(bookmark); - return bookmark; -} + bookmarkAdded(bookmark); + return bookmark; + } -void BookmarkService::updateBookmarkItemSnapshot(const std::string & url, tools::BrowserImagePtr snapshot) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - int id = getBookmarkId(url); - if (id != 0 && snapshot) { - std::unique_ptr<tools::Blob> snapshot_blob = tools::EflTools::getBlobPNG(snapshot); - unsigned char * snap = std::move((unsigned char*)snapshot_blob->getData()); - if (bp_bookmark_adaptor_set_snapshot(id, snapshot->getWidth(), snapshot->getHeight(), snap, - snapshot_blob->getLength()) < 0) - errorPrint("bp_history_adaptor_set_snapshot"); - } else - BROWSER_LOGW("Snapshot update not handled properly"); -} - -bool BookmarkService::editBookmark(const std::string & url, const std::string & title, unsigned int folder_id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - return (update_bookmark_notify(getBookmarkId(url), title.c_str(), url.c_str(), folder_id, -1) == 1); -} + void BookmarkService::updateBookmarkItemSnapshot(const std::string & url, + tools:: + BrowserImagePtr snapshot) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int id = getBookmarkId(url); + if (id != 0 && snapshot) { + std::unique_ptr < tools::Blob > snapshot_blob = + tools::EflTools::getBlobPNG(snapshot); + unsigned char *snap = + std::move((unsigned char *) snapshot_blob->getData()); + if (bp_bookmark_adaptor_set_snapshot + (id, snapshot->getWidth(), snapshot->getHeight(), snap, + snapshot_blob->getLength()) < 0) + errorPrint("bp_history_adaptor_set_snapshot"); + } else { + BROWSER_LOGW("Snapshot update not handled properly"); + } + } -bool BookmarkService::deleteBookmark(const std::string & url) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - int id = getBookmarkId(url); - if (id!=0) - bp_bookmark_adaptor_delete(id); - bookmarkDeleted(url); - return true; -} - -bool BookmarkService::getItem(const std::string &url, BookmarkItem *item) -{ - int id; - if ((id = getBookmarkId(url)) == 0) - return false; - return get_item_by_id(id, item); -} + bool BookmarkService::editBookmark(const std::string & url, + const std::string & title, + unsigned int folder_id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + return (update_bookmark_notify + (getBookmarkId(url), title.c_str(), url.c_str(), folder_id, + -1) == 1); + } -bool BookmarkService::bookmarkExists(const std::string & url) -{ - return 0 != getBookmarkId(url); -} + bool BookmarkService::deleteBookmark(const std::string & url) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int id = getBookmarkId(url); + if (id != 0) + bp_bookmark_adaptor_delete(id); + bookmarkDeleted(url); + return true; + } -int BookmarkService::getBookmarkId(const std::string & url) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - bp_bookmark_property_cond_fmt properties; - properties.parent = -1; - properties.type = 0; - properties.is_operator = 0; - properties.is_editable = -1; - bp_bookmark_rows_cond_fmt conds; - conds.limit = -1; - conds.offset = 0; - conds.order_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.ordering = 0; - conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.period_type = BP_BOOKMARK_DATE_ALL; - int *ids = nullptr; - int ids_count = 0; - int i = 0; - bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, url.c_str(), 0); - if (ids_count > 0){ - i = *ids; + bool BookmarkService::getItem(const std::string & url, + BookmarkItem * item) + { + int id; + if ((id = getBookmarkId(url)) == 0) + return false; + return get_item_by_id(id, item); } - free(ids); - return i; -} -std::vector<std::shared_ptr<BookmarkItem> > BookmarkService::getBookmarks(int folder_id) -{ - BROWSER_LOGD("[%s:%d] folder_id = %d", __func__, __LINE__, folder_id); - std::vector<std::shared_ptr<BookmarkItem> > bookmarks; - int *ids = nullptr; - int ids_count = 0; + bool BookmarkService::bookmarkExists(const std::string & url) + { + return 0 != getBookmarkId(url); + } + + int BookmarkService::getBookmarkId(const std::string & url) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + bp_bookmark_property_cond_fmt properties; + properties.parent = -1; + properties.type = 0; + properties.is_operator = 0; + properties.is_editable = -1; + bp_bookmark_rows_cond_fmt conds; + conds.limit = -1; + conds.offset = 0; + conds.order_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.ordering = 0; + conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.period_type = BP_BOOKMARK_DATE_ALL; + int *ids = nullptr; + int ids_count = 0; + int i = 0; + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, + &conds, BP_BOOKMARK_O_URL, + url.c_str(), 0); + if (ids_count > 0) { + i = *ids; + } + free(ids); + return i; + } + + std::vector < std::shared_ptr < BookmarkItem > + >BookmarkService::getBookmarks(int folder_id) { + BROWSER_LOGD("[%s:%d] folder_id = %d", __func__, __LINE__, folder_id); + std::vector < std::shared_ptr < BookmarkItem > >bookmarks; + int *ids = nullptr; + int ids_count = 0; #if PROFILE_MOBILE - if (bp_bookmark_adaptor_get_ids_p(&ids, &ids_count, -1, 0, folder_id, - ALL_TYPE, -1, -1, BP_BOOKMARK_O_SEQUENCE, 0) < 0) { + if (bp_bookmark_adaptor_get_ids_p(&ids, &ids_count, -1, 0, folder_id, + ALL_TYPE, -1, -1, + BP_BOOKMARK_O_SEQUENCE, 0) < 0) { #else - if (bp_bookmark_adaptor_get_ids_p(&ids, &ids_count, -1, 0, folder_id, - BOOKMARK_TYPE, -1, -1, BP_BOOKMARK_O_SEQUENCE, 0) < 0) { + if (bp_bookmark_adaptor_get_ids_p(&ids, &ids_count, -1, 0, folder_id, + BOOKMARK_TYPE, -1, -1, + BP_BOOKMARK_O_SEQUENCE, 0) < 0) { #endif - errorPrint("bp_bookmark_adaptor_get_ids_p"); - return std::vector<std::shared_ptr<BookmarkItem>>(); + errorPrint("bp_bookmark_adaptor_get_ids_p"); + return std::vector < std::shared_ptr < BookmarkItem >> (); + } + BROWSER_LOGD("Bookmark items: %d", ids_count); + + for (int i = 0; i < ids_count; i++) { + bp_bookmark_info_fmt bookmark_info; + if (bp_bookmark_adaptor_get_easy_all(ids[i], &bookmark_info) == 0) { + std::string url = (bookmark_info.url ? bookmark_info.url : ""); + std::string title = + (bookmark_info.title ? bookmark_info.title : ""); + + std::shared_ptr < BookmarkItem > bookmark = + std::make_shared < BookmarkItem > (url, title, std::string(""), + (int) bookmark_info.parent, + ids[i]); + + if (bookmark_info.thumbnail_length != -1) { + tools::BrowserImagePtr bi = + std::make_shared < tizen_browser::tools::BrowserImage > + (bookmark_info.thumbnail_width, bookmark_info.thumbnail_height, + bookmark_info.thumbnail_length); + bi->setData((void *) bookmark_info.thumbnail, false, + tools::ImageType::ImageTypePNG); + bookmark->setThumbnail(bi); + } else { + BROWSER_LOGD("bookmark thumbnail size is -1"); + } + + if (bookmark_info.favicon_length != -1) { + tools::BrowserImagePtr fav = + std::make_shared < tools::BrowserImage > + (bookmark_info.favicon_width, bookmark_info.favicon_height, + bookmark_info.favicon_length); + fav->setData((void *) bookmark_info.favicon, false, + tools::ImageType::ImageTypePNG); + bookmark->setFavicon(fav); + } else { + BROWSER_LOGD("bookmark favicon size is -1"); + } + bookmarks.push_back(bookmark); + } else { + BROWSER_LOGD("bp_bookmark_adaptor_get_easy_all error"); + } + bp_bookmark_adaptor_easy_free(&bookmark_info); + } + free(ids); + return bookmarks; } - BROWSER_LOGD("Bookmark items: %d", ids_count); - for(int i = 0; i<ids_count; i++) + bool BookmarkService::deleteAllBookmarks() { - bp_bookmark_info_fmt bookmark_info; - if (bp_bookmark_adaptor_get_easy_all(ids[i], &bookmark_info) == 0) { - std::string url = (bookmark_info.url ? bookmark_info.url : ""); - std::string title = (bookmark_info.title ? bookmark_info.title : ""); - - std::shared_ptr<BookmarkItem> bookmark = std::make_shared<BookmarkItem>(url, title, std::string(""),(int) bookmark_info.parent, ids[i]); - - if (bookmark_info.thumbnail_length != -1) { - tools::BrowserImagePtr bi = std::make_shared<tizen_browser::tools::BrowserImage>( - bookmark_info.thumbnail_width, - bookmark_info.thumbnail_height, - bookmark_info.thumbnail_length); - bi->setData((void*)bookmark_info.thumbnail, false, tools::ImageType::ImageTypePNG); - bookmark->setThumbnail(bi); - } else { - BROWSER_LOGD("bookmark thumbnail size is -1"); - } - - if (bookmark_info.favicon_length != -1) { - tools::BrowserImagePtr fav = std::make_shared<tools::BrowserImage>( - bookmark_info.favicon_width, - bookmark_info.favicon_height, - bookmark_info.favicon_length); - fav->setData((void*)bookmark_info.favicon, false, tools::ImageType::ImageTypePNG); - bookmark->setFavicon(fav); - } else { - BROWSER_LOGD("bookmark favicon size is -1"); - } - bookmarks.push_back(bookmark); - } else { - BROWSER_LOGD("bp_bookmark_adaptor_get_easy_all error"); - } - bp_bookmark_adaptor_easy_free(&bookmark_info); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + bp_bookmark_adaptor_reset(); + bookmarksDeleted(); + return true; } - free(ids); - return bookmarks; -} - -bool BookmarkService::deleteAllBookmarks() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - bp_bookmark_adaptor_reset(); - bookmarksDeleted(); - return true; -} -bool BookmarkService::delete_by_id(int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("id[%d]", id); - if (bp_bookmark_adaptor_delete(id) < 0) - return false; - else { - bp_bookmark_adaptor_publish_notification(); - return true; + bool BookmarkService::delete_by_id(int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("id[%d]", id); + if (bp_bookmark_adaptor_delete(id) < 0) { + return false; + } else { + bp_bookmark_adaptor_publish_notification(); + return true; + } } -} -bool BookmarkService::delete_by_id_notify(int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("id[%d]", id); + bool BookmarkService::delete_by_id_notify(int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("id[%d]", id); - BookmarkItem item; - get_item_by_id(id, &item); - return delete_by_id(id); -} + BookmarkItem item; + get_item_by_id(id, &item); + return delete_by_id(id); + } -bool BookmarkService::delete_by_uri(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("uri[%s]", uri); - bp_bookmark_property_cond_fmt properties; - properties.parent = -1; - properties.type = 0; - properties.is_operator = -1; - properties.is_editable = -1; - //conditions for querying - bp_bookmark_rows_cond_fmt conds; - conds.limit = 1; - conds.offset = 0; - conds.order_offset = BP_BOOKMARK_O_SEQUENCE; - conds.ordering = 0; - conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.period_type = BP_BOOKMARK_DATE_ALL; - - int *ids = nullptr; - int ids_count = -1; - int ret = bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, uri, 0); - bool result = false; - if (ret >= 0 && ids_count > 0) + bool BookmarkService::delete_by_uri(const char *uri) { - result = delete_by_id_notify(ids[0]); - free(ids); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("uri[%s]", uri); + bp_bookmark_property_cond_fmt properties; + properties.parent = -1; + properties.type = 0; + properties.is_operator = -1; + properties.is_editable = -1; + //conditions for querying + bp_bookmark_rows_cond_fmt conds; + conds.limit = 1; + conds.offset = 0; + conds.order_offset = BP_BOOKMARK_O_SEQUENCE; + conds.ordering = 0; + conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.period_type = BP_BOOKMARK_DATE_ALL; + + int *ids = nullptr; + int ids_count = -1; + int ret = + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, + &conds, BP_BOOKMARK_O_URL, uri, 0); + bool result = false; + if (ret >= 0 && ids_count > 0) { + result = delete_by_id_notify(ids[0]); + free(ids); + } + + return result; } - return result; -} - -int BookmarkService::update_bookmark(int id, const char *title, const char *uri, int parent_id, int order, - bool is_duplicate_check_needed, bool is_URI_check_needed) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - bool is_URI_exist = (uri != nullptr && strlen(uri) > 0); - bool is_title_exist = (title != nullptr && strlen(title) > 0); - int ret = -1; - if (is_duplicate_check_needed) { - bp_bookmark_property_cond_fmt properties; - properties.parent = -1; - properties.type = 0; - properties.is_operator = -1; - properties.is_editable = -1; - //conditions for querying - bp_bookmark_rows_cond_fmt conds; - conds.limit = 1; - conds.offset = 0; - conds.order_offset = BP_BOOKMARK_O_SEQUENCE; - conds.ordering = 0; - conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.period_type = BP_BOOKMARK_DATE_ALL; - int *ids = nullptr; - int ids_count = -1; - //This is a bookmark item so check for any such URL already exists - if (is_URI_exist && is_URI_check_needed) { - ret = bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, uri, 0); - free(ids); - if (ret < 0) { - errorPrint("bp_bookmark_adaptor_get_cond_ids_p"); - return -1; - } - } - - if (ids_count > 0) { - BROWSER_LOGD("same bookmark already exist"); - return 0; - } + int BookmarkService::update_bookmark(int id, const char *title, + const char *uri, int parent_id, + int order, + bool is_duplicate_check_needed, + bool is_URI_check_needed) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + bool is_URI_exist = (uri != nullptr && strlen(uri) > 0); + bool is_title_exist = (title != nullptr && strlen(title) > 0); + int ret = -1; + if (is_duplicate_check_needed) { + bp_bookmark_property_cond_fmt properties; + properties.parent = -1; + properties.type = 0; + properties.is_operator = -1; + properties.is_editable = -1; + //conditions for querying + bp_bookmark_rows_cond_fmt conds; + conds.limit = 1; + conds.offset = 0; + conds.order_offset = BP_BOOKMARK_O_SEQUENCE; + conds.ordering = 0; + conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.period_type = BP_BOOKMARK_DATE_ALL; + int *ids = nullptr; + int ids_count = -1; + //This is a bookmark item so check for any such URL already exists + if (is_URI_exist && is_URI_check_needed) { + ret = + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, + &conds, BP_BOOKMARK_O_URL, uri, + 0); + free(ids); + if (ret < 0) { + errorPrint("bp_bookmark_adaptor_get_cond_ids_p"); + return -1; + } + } + + if (ids_count > 0) { + BROWSER_LOGD("same bookmark already exist"); + return 0; + } + } + + bp_bookmark_adaptor_set_parent_id(id, parent_id); + bp_bookmark_adaptor_set_sequence(id, order); + if (is_URI_exist) + bp_bookmark_adaptor_set_url(id, uri); + if (is_title_exist) + bp_bookmark_adaptor_set_title(id, title); + bp_bookmark_adaptor_publish_notification(); + + return 1; } - bp_bookmark_adaptor_set_parent_id(id, parent_id); - bp_bookmark_adaptor_set_sequence(id, order); - if (is_URI_exist) - bp_bookmark_adaptor_set_url(id, uri); - if (is_title_exist) - bp_bookmark_adaptor_set_title(id, title); - bp_bookmark_adaptor_publish_notification(); - - return 1; -} - -int BookmarkService::update_bookmark_notify(int id, const char *title, const char *uri, int parent_id, int order, - bool is_duplicate_check_needed, bool is_URI_check_needed) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD(""); - int ret = update_bookmark(id, title, uri, parent_id, order, is_duplicate_check_needed, is_URI_check_needed); - return ret; -} - -bool BookmarkService::is_in_bookmark(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("uri[%s]", uri); - - int id = 0; - return get_id(uri, &id); -} - -bool BookmarkService::get_id(const char *uri, int *bookmark_id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - bp_bookmark_property_cond_fmt properties; - properties.parent = -1; - properties.type = 0; - properties.is_operator = -1; - properties.is_editable = -1; - //conditions for querying - bp_bookmark_rows_cond_fmt conds; - conds.limit = 1; - conds.offset = 0; - conds.order_offset = BP_BOOKMARK_O_SEQUENCE; - conds.ordering = 0; - conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; - conds.period_type = BP_BOOKMARK_DATE_ALL; - - int *ids = nullptr; - int ids_count = -1; - int ret = bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, &conds, BP_BOOKMARK_O_URL, uri, 0); - bool result = ((ret >= 0) && (ids_count > 0)); - if (result) { - *bookmark_id = ids[0]; + int BookmarkService::update_bookmark_notify(int id, const char *title, + const char *uri, + int parent_id, int order, + bool + is_duplicate_check_needed, + bool is_URI_check_needed) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD(""); + int ret = + update_bookmark(id, title, uri, parent_id, order, + is_duplicate_check_needed, is_URI_check_needed); + return ret; } - free(ids); - return result; -} -bool BookmarkService::get_item_by_id(int id, BookmarkItem *item) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("ID: %d", id); - if (!item) { - BROWSER_LOGE("item is nullptr"); - return false; - } + bool BookmarkService::is_in_bookmark(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("uri[%s]", uri); - if (id == 0) { - item->setTitle(_("IDS_BR_BODY_BOOKMARKS")); - item->setAddress(""); - item->setId(id); - item->setDir(-1); - return true; + int id = 0; + return get_id(uri, &id); } - bp_bookmark_info_fmt info; - if (bp_bookmark_adaptor_get_info(id, (BP_BOOKMARK_O_TYPE | BP_BOOKMARK_O_PARENT | BP_BOOKMARK_O_SEQUENCE | - BP_BOOKMARK_O_IS_EDITABLE | BP_BOOKMARK_O_URL |BP_BOOKMARK_O_TITLE), &info) == 0) { - item->setId(id); - item->setDir(info.parent); - if (info.url != nullptr && strlen(info.url) > 0) - item->setAddress(info.url); - - if (info.title != nullptr && strlen(info.title) > 0) - item->setTitle(info.title); + bool BookmarkService::get_id(const char *uri, int *bookmark_id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + bp_bookmark_property_cond_fmt properties; + properties.parent = -1; + properties.type = 0; + properties.is_operator = -1; + properties.is_editable = -1; + //conditions for querying + bp_bookmark_rows_cond_fmt conds; + conds.limit = 1; + conds.offset = 0; + conds.order_offset = BP_BOOKMARK_O_SEQUENCE; + conds.ordering = 0; + conds.period_offset = BP_BOOKMARK_O_DATE_CREATED; + conds.period_type = BP_BOOKMARK_DATE_ALL; + + int *ids = nullptr; + int ids_count = -1; + int ret = + bp_bookmark_adaptor_get_cond_ids_p(&ids, &ids_count, &properties, + &conds, BP_BOOKMARK_O_URL, uri, 0); + bool result = ((ret >= 0) && (ids_count > 0)); + if (result) { + *bookmark_id = ids[0]; + } + free(ids); + return result; + } - bp_bookmark_adaptor_easy_free(&info); - return true; + bool BookmarkService::get_item_by_id(int id, BookmarkItem * item) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("ID: %d", id); + if (!item) { + BROWSER_LOGE("item is nullptr"); + return false; + } + + if (id == 0) { + item->setTitle(_("IDS_BR_BODY_BOOKMARKS")); + item->setAddress(""); + item->setId(id); + item->setDir(-1); + return true; + } + bp_bookmark_info_fmt info; + if (bp_bookmark_adaptor_get_info + (id, + (BP_BOOKMARK_O_TYPE | BP_BOOKMARK_O_PARENT | BP_BOOKMARK_O_SEQUENCE + | BP_BOOKMARK_O_IS_EDITABLE | BP_BOOKMARK_O_URL | + BP_BOOKMARK_O_TITLE), &info) == 0) { + item->setId(id); + item->setDir(info.parent); + + if (info.url != nullptr && strlen(info.url) > 0) + item->setAddress(info.url); + + if (info.title != nullptr && strlen(info.title) > 0) + item->setTitle(info.title); + + bp_bookmark_adaptor_easy_free(&info); + return true; + } + BROWSER_LOGD("bp_bookmark_adaptor_get_easy_all is failed"); + return false; } - BROWSER_LOGD("bp_bookmark_adaptor_get_easy_all is failed"); - return false; -} -} /* end of namespace services*/ -} /* end of namespace tizen_browser */ + } /* end of namespace services */ +} /* end of namespace tizen_browser */ diff --git a/services/BookmarkService/BookmarkService.h b/services/BookmarkService/BookmarkService.h index dce269c9..b82d4cc4 100644..100755 --- a/services/BookmarkService/BookmarkService.h +++ b/services/BookmarkService/BookmarkService.h @@ -34,16 +34,18 @@ #include "BrowserImage.h" #include "AbstractFavoriteService.h" -namespace tizen_browser{ -namespace services{ - -class BROWSER_EXPORT BookmarkService - : public tizen_browser::interfaces::AbstractFavoriteService +namespace tizen_browser { -public: - BookmarkService(); - virtual ~BookmarkService(); - virtual std::string getName(); + namespace services + { + + class BROWSER_EXPORT BookmarkService:public tizen_browser::interfaces:: + AbstractFavoriteService + { + public: + BookmarkService(); + virtual ~BookmarkService(); + virtual std::string getName(); /** * @brief Add page to bookmarks @@ -57,19 +59,27 @@ public: * * @return BookmarkItem class */ - std::shared_ptr<BookmarkItem> addBookmark(const std::string & address, - const std::string & title, - const std::string & note = std::string(), - std::shared_ptr<tizen_browser::tools::BrowserImage> thumbnail=std::shared_ptr<tizen_browser::tools::BrowserImage>(), - std::shared_ptr<tizen_browser::tools::BrowserImage> favicon = std::shared_ptr<tizen_browser::tools::BrowserImage>(), - unsigned int dirId = 0); + std::shared_ptr < BookmarkItem > + addBookmark(const std::string & address, const std::string & title, + const std::string & note = + std::string(), + std::shared_ptr < tizen_browser::tools::BrowserImage > + thumbnail = + std::shared_ptr < tizen_browser::tools::BrowserImage > (), + std::shared_ptr < tizen_browser::tools::BrowserImage > + favicon = + std::shared_ptr < tizen_browser::tools::BrowserImage > (), + unsigned int dirId = 0); /** * @brief Update bookmark snapshot by given url * * @param url of bookmark to delete */ - void updateBookmarkItemSnapshot(const std::string & url, std::shared_ptr<tizen_browser::tools::BrowserImage> snapshot); + void updateBookmarkItemSnapshot(const std::string & url, + std::shared_ptr < + tizen_browser::tools::BrowserImage > + snapshot); /** \todo Need to change this callback function for finding stored bookmark, check getBookmarkId function * @brief Check if bookmark exists @@ -77,28 +87,30 @@ public: * @param url url to find * @return true if exists, false if not */ - bool bookmarkExists(const std::string & url); + bool bookmarkExists(const std::string & url); /** * @brief Get bookmarks from platform service and store it in private m_bookmarksList * * @return list of bookmark items, bookmark items in a folder & bookmark folders */ - std::vector<std::shared_ptr<BookmarkItem> > getBookmarks(int folder_id = -1); + std::vector < std::shared_ptr < BookmarkItem > + >getBookmarks(int folder_id = -1); /** * @brief Delete all bookmarks * * @return true if success, false on error */ - bool deleteAllBookmarks(); + bool deleteAllBookmarks(); /** * @brief Edit bookmark title and folder by given url * * @return true if success, false on error */ - bool editBookmark(const std::string & url, const std::string & title, unsigned int folder_id = 0); + bool editBookmark(const std::string & url, const std::string & title, + unsigned int folder_id = 0); /** * @brief Delete bookmark by given url @@ -106,7 +118,7 @@ public: * @param url of bookmark to delete * @return true if success, false on error of not found bookmark */ - bool deleteBookmark(const std::string & url); + bool deleteBookmark(const std::string & url); /** * @brief Gets bookmark item @@ -114,38 +126,43 @@ public: * @param url of bookmark, pointer to item * @return true if success, false on error of not found bookmark */ - bool getItem(const std::string & url, BookmarkItem *item); - - bool delete_by_id(int id); - bool delete_by_id_notify(int id); - bool delete_by_uri(const char *uri); - int update_bookmark(int id, const char *title, const char *uri, int parent_id, int order, - bool is_duplicate_check_needed = false, bool is_URI_check_needed = false); - int update_bookmark_notify(int id, const char *title, const char *uri, int parent_id, int order, - bool is_duplicate_check_needed = false, bool is_URI_check_needed = false); - bool delete_all(void); - bool get_item_by_id(int id, BookmarkItem *item); - int get_count(void); - bool get_id(const char *uri, int *bookmark_id); - bool is_in_bookmark(const char *uri); - -private: + bool getItem(const std::string & url, BookmarkItem * item); + + bool delete_by_id(int id); + bool delete_by_id_notify(int id); + bool delete_by_uri(const char *uri); + int update_bookmark(int id, const char *title, const char *uri, + int parent_id, int order, + bool is_duplicate_check_needed = + false, bool is_URI_check_needed = false); + int update_bookmark_notify(int id, const char *title, const char *uri, + int parent_id, int order, + bool is_duplicate_check_needed = + false, bool is_URI_check_needed = false); + bool delete_all(void); + bool get_item_by_id(int id, BookmarkItem * item); + int get_count(void); + bool get_id(const char *uri, int *bookmark_id); + bool is_in_bookmark(const char *uri); + + private: /** * Help method printing last bp_bookmark_error_defs error. */ - void errorPrint(std::string method) const; - - enum ItemType{ - BOOKMARK_TYPE = 0 - , ALL_TYPE = -1 - }; - std::vector<BookmarkItem *> m_bookmark_list; - std::shared_ptr<tizen_browser::services::StorageService> m_storageManager; + void errorPrint(std::string method) const; + + enum ItemType + { + BOOKMARK_TYPE = 0, ALL_TYPE = -1 + }; + std::vector < BookmarkItem * >m_bookmark_list; + std::shared_ptr < tizen_browser::services::StorageService > + m_storageManager; /// \todo Need to change getBookmarkId function for finding stored bookmark - check getBookmarkExists function - int getBookmarkId(const std::string & url); -}; + int getBookmarkId(const std::string & url); + }; -} + } } -#endif // FAVORITESERVICE_H +#endif // FAVORITESERVICE_H diff --git a/services/CertificateService/CertificateContents.cpp b/services/CertificateService/CertificateContents.cpp index 4a33fb37..b6eefdaf 100644..100755 --- a/services/CertificateService/CertificateContents.cpp +++ b/services/CertificateService/CertificateContents.cpp @@ -50,504 +50,575 @@ namespace tizen_browser { -namespace services -{ + namespace services + { -EXPORT_SERVICE(CertificateContents, "org.tizen.browser.certificateservice") + EXPORT_SERVICE(CertificateContents, + "org.tizen.browser.certificateservice") -CertificateContents::CertificateContents() - : m_mainLayout(nullptr) + CertificateContents::CertificateContents() + :m_mainLayout(nullptr) , m_parent(nullptr) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("CertificateService/CertificatePopup.edj"); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); -} - -CertificateContents::~CertificateContents() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_genlist) - evas_object_del(m_genlist); - if (m_mainLayout) - evas_object_del(m_mainLayout); - m_genlist_callback_data_list.clear(); -} - -void CertificateContents::init() -{ - auto certList = getHostCertList(); - if (certList) { - for (auto it = (*certList)->begin(); it != (*certList)->end(); ++it) { - addToHostCertList(it->first, static_cast<HOST_TYPE>(it->second)); - } - } else { - BROWSER_LOGW("[%s:%d] wrong certList value!", __PRETTY_FUNCTION__, __LINE__); + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("CertificateService/CertificatePopup.edj"); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); } -} - -void CertificateContents::setCurrentTabCertData(std::string host, std::string pem, HOST_TYPE type) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_genlist) { - elm_genlist_clear(m_genlist); - evas_object_del(m_genlist); + CertificateContents::~CertificateContents() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_genlist) + evas_object_del(m_genlist); + if (m_mainLayout) + evas_object_del(m_mainLayout); + m_genlist_callback_data_list.clear(); } - m_genlist_callback_data_list.clear(); - m_hostType = type; - - if (!createCertificate(pem.c_str())) - m_hostType = UNSECURE_HOST_UNKNOWN; - - addToHostCertList(host, m_hostType); - m_genlist = createGenlist(m_parent); -} -bool CertificateContents::isValidCertificate(const std::string& uri) -{ - HOST_TYPE type = isCertExistForHost(tools::extractDomain(uri)); - return type == SECURE_HOST; -} + void CertificateContents::init() + { + auto certList = getHostCertList(); + if (certList) { + for (auto it = (*certList)->begin(); it != (*certList)->end(); ++it) { + addToHostCertList(it->first, + static_cast < HOST_TYPE > (it->second)); + } + } else { + BROWSER_LOGW("[%s:%d] wrong certList value!", __PRETTY_FUNCTION__, + __LINE__); + } + } -CertificateContents::HOST_TYPE CertificateContents::isCertExistForHost(const std::string& host) -{ - /*Returns the host type if a cert. exists for the host */ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void CertificateContents::setCurrentTabCertData(std::string host, + std::string pem, + HOST_TYPE type) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_host_cert_info.find(host) == m_host_cert_info.end()) - return HOST_ABSENT; - else - return m_host_cert_info[host]; -} + if (m_genlist) { + elm_genlist_clear(m_genlist); + evas_object_del(m_genlist); + } + m_genlist_callback_data_list.clear(); + m_hostType = type; -void CertificateContents::addToHostCertList(const std::string& host, HOST_TYPE type) -{ - BROWSER_LOGD("[%s:%d] host: %s type: %d", __PRETTY_FUNCTION__, __LINE__, host.c_str(), type); - m_host_cert_info[host] = type; -} + if (!createCertificate(pem.c_str())) + m_hostType = UNSECURE_HOST_UNKNOWN; -void CertificateContents::saveCertificateInfo(const std::string& host, const std::string& pem) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - HOST_TYPE savedType = isCertExistForHost(host); - if (savedType == HOST_ABSENT) - savedType = SECURE_HOST; - - setCurrentTabCertData(host, pem, savedType); - addOrUpdateCertificateEntry(pem, host, static_cast<int>(savedType)); -} + addToHostCertList(host, m_hostType); + m_genlist = createGenlist(m_parent); + } -void CertificateContents::saveWrongCertificateInfo(const std::string& host, const std::string& pem) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - HOST_TYPE savedType = UNSECURE_HOST_ALLOWED; - setCurrentTabCertData(host, pem, savedType); - addOrUpdateCertificateEntry(pem, host, static_cast<int>(savedType)); -} + bool CertificateContents::isValidCertificate(const std::string & uri) + { + HOST_TYPE type = isCertExistForHost(tools::extractDomain(uri)); + return type == SECURE_HOST; + } -void CertificateContents::clear() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_host_cert_info.clear(); -} + CertificateContents::HOST_TYPE CertificateContents:: + isCertExistForHost(const std::string & host) { + /*Returns the host type if a cert. exists for the host */ + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -void CertificateContents::initUI(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_parent = parent; -} - -Evas_Object* CertificateContents::createLabel(Evas_Object* parent, const std::string& msg) -{ - Evas_Object* layout = elm_layout_add(parent); - elm_layout_file_set(layout, m_edjFilePath.c_str(), "label_layout"); - elm_layout_text_set(layout, "auth_text", msg.c_str()); - evas_object_show(layout); + if (m_host_cert_info.find(host) == m_host_cert_info.end()) + return HOST_ABSENT; + else + return m_host_cert_info[host]; + } - return layout; -} + void CertificateContents::addToHostCertList(const std::string & host, + HOST_TYPE type) + { + BROWSER_LOGD("[%s:%d] host: %s type: %d", __PRETTY_FUNCTION__, __LINE__, + host.c_str(), type); + m_host_cert_info[host] = type; + } -Evas_Object* CertificateContents::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void CertificateContents::saveCertificateInfo(const std::string & host, + const std::string & pem) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + HOST_TYPE savedType = isCertExistForHost(host); + if (savedType == HOST_ABSENT) + savedType = SECURE_HOST; - if (m_hostType == HOST_ABSENT) { - return createLabel(m_parent, BR_STRING_CERTI_MESSAGE); - } else { - return m_genlist; + setCurrentTabCertData(host, pem, savedType); + addOrUpdateCertificateEntry(pem, host, static_cast < int >(savedType)); } -} -bool CertificateContents::createCertificate(const char* certificate_data) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - /* - *Bring the PEM cert. data into an OpenSSL memory BIO - *This memory BIO will be used to convert the PEM cert - *data to X509 format - */ - BIO *cert_mem_bio = nullptr; - cert_mem_bio = BIO_new(BIO_s_mem()); - if (cert_mem_bio == nullptr) { - BROWSER_LOGE("[%s:%d] Failed to create OpenSSL memory BIO", __PRETTY_FUNCTION__, __LINE__); - BIO_free(cert_mem_bio); - return false; + void CertificateContents::saveWrongCertificateInfo(const std:: + string & host, + const std:: + string & pem) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + HOST_TYPE savedType = UNSECURE_HOST_ALLOWED; + setCurrentTabCertData(host, pem, savedType); + addOrUpdateCertificateEntry(pem, host, static_cast < int >(savedType)); } - BIO_puts(cert_mem_bio, certificate_data); - /* - *Convert from PEM to x509 - */ - m_certificate = PEM_read_bio_X509(cert_mem_bio, nullptr, 0 , nullptr); - BIO_free(cert_mem_bio); + void CertificateContents::clear() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_host_cert_info.clear(); + } - if (!m_certificate) { - BROWSER_LOGE("[%s:%d] PEM to x509 conversion failed", __PRETTY_FUNCTION__, __LINE__); - return false; + void CertificateContents::initUI(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_parent = parent; } - _parse_certificate(); - return true; -} + Evas_Object *CertificateContents::createLabel(Evas_Object * parent, + const std::string & msg) + { + Evas_Object *layout = elm_layout_add(parent); + elm_layout_file_set(layout, m_edjFilePath.c_str(), "label_layout"); + elm_layout_text_set(layout, "auth_text", msg.c_str()); + evas_object_show(layout); -Evas_Object* CertificateContents::createGenlist(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_genlist) { - elm_genlist_clear(m_genlist); - evas_object_del(m_genlist); + return layout; } - m_genlist = elm_genlist_add(parent); - - elm_scroller_policy_set(m_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON); - elm_genlist_mode_set(m_genlist, ELM_LIST_COMPRESS); - evas_object_size_hint_weight_set(m_genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(m_genlist); + Evas_Object *CertificateContents::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Genlist_Item_Class *auth_item_class = elm_genlist_item_class_new(); - if (!auth_item_class) { - BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); - return m_genlist; - } - auth_item_class->item_style = "cert_auth_text"; - auth_item_class->func.text_get = __auth_text_get_cb; - auth_item_class->func.content_get = nullptr; - auth_item_class->func.state_get = nullptr; - auth_item_class->func.del = nullptr; - Elm_Object_Item *it = elm_genlist_item_append(m_genlist, auth_item_class, this, nullptr, ELM_GENLIST_ITEM_NONE, nullptr, nullptr); - elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - Elm_Genlist_Item_Class *field_item_class = elm_genlist_item_class_new(); - if (!field_item_class) { - BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); - return m_genlist; - } - field_item_class->item_style = "cert_field_text"; - field_item_class->decorate_item_style = nullptr; - field_item_class->func.text_get = __field_text_get_cb; - field_item_class->func.content_get = nullptr; - field_item_class->func.state_get = nullptr; - field_item_class->func.del = nullptr; - - Elm_Genlist_Item_Class *item_class = elm_genlist_item_class_new(); - if (!item_class) { - BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); - return m_genlist; - } - item_class->item_style = "cert_title_value_text"; - item_class->decorate_item_style = nullptr; - item_class->func.text_get = __title_value_text_get_cb; - item_class->func.content_get = nullptr; - item_class->func.state_get = nullptr; - item_class->func.del = nullptr; - - int no_of_items = m_genlist_callback_data_list.size(); - for (int i = 0; i < no_of_items; i++) { - Elm_Object_Item *item = nullptr; - auto callback_data = m_genlist_callback_data_list[i]; - if (callback_data->type == ISSUED_BY_HEADER || callback_data->type == ISSUED_TO_HEADER || - callback_data->type == VALIDITY_HEADER || callback_data->type == FINGERPRINTS_HEADER) { - item = elm_genlist_item_append(m_genlist, field_item_class, callback_data.get(), nullptr, ELM_GENLIST_ITEM_NONE, nullptr, nullptr); - } else - item = elm_genlist_item_append(m_genlist, item_class, callback_data.get(), nullptr, ELM_GENLIST_ITEM_NONE, nullptr, nullptr); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + if (m_hostType == HOST_ABSENT) { + return createLabel(m_parent, BR_STRING_CERTI_MESSAGE); + } else { + return m_genlist; + } } - return m_genlist; -} - -char* CertificateContents::__auth_text_get_cb(void* data, Evas_Object* /*obj*/, const char* part) -{ - CertificateContents* cc = static_cast<CertificateContents*>(data); - if (!strcmp(part, "auth_text")) { - if (cc->isValidCertificate()) - return strdup(BR_STRING_TRUSTED_AUTHORITY); - else - return strdup(BR_STRING_UNTRUSTED_AUTHORITY); + bool CertificateContents::createCertificate(const char *certificate_data) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + /* + *Bring the PEM cert. data into an OpenSSL memory BIO + *This memory BIO will be used to convert the PEM cert + *data to X509 format + */ + BIO *cert_mem_bio = nullptr; + cert_mem_bio = BIO_new(BIO_s_mem()); + if (cert_mem_bio == nullptr) { + BROWSER_LOGE("[%s:%d] Failed to create OpenSSL memory BIO", + __PRETTY_FUNCTION__, __LINE__); + BIO_free(cert_mem_bio); + return false; + } + BIO_puts(cert_mem_bio, certificate_data); + + /* + *Convert from PEM to x509 + */ + m_certificate = PEM_read_bio_X509(cert_mem_bio, nullptr, 0, nullptr); + BIO_free(cert_mem_bio); + + if (!m_certificate) { + BROWSER_LOGE("[%s:%d] PEM to x509 conversion failed", + __PRETTY_FUNCTION__, __LINE__); + return false; + } + + _parse_certificate(); + return true; } - return strdup(""); -} -char* CertificateContents::__field_text_get_cb(void* data, Evas_Object* /*obj*/, const char* part) -{ - auto callback_data = static_cast<genlist_callback_data* >(data); + Evas_Object *CertificateContents::createGenlist(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_genlist) { + elm_genlist_clear(m_genlist); + evas_object_del(m_genlist); + } + m_genlist = elm_genlist_add(parent); + + elm_scroller_policy_set(m_genlist, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_ON); + elm_genlist_mode_set(m_genlist, ELM_LIST_COMPRESS); + evas_object_size_hint_weight_set(m_genlist, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_genlist, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + evas_object_show(m_genlist); + + Elm_Genlist_Item_Class *auth_item_class = elm_genlist_item_class_new(); + if (!auth_item_class) { + BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); + return m_genlist; + } + auth_item_class->item_style = "cert_auth_text"; + auth_item_class->func.text_get = __auth_text_get_cb; + auth_item_class->func.content_get = nullptr; + auth_item_class->func.state_get = nullptr; + auth_item_class->func.del = nullptr; + Elm_Object_Item *it = + elm_genlist_item_append(m_genlist, auth_item_class, this, nullptr, + ELM_GENLIST_ITEM_NONE, nullptr, nullptr); + elm_genlist_item_select_mode_set(it, + ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + Elm_Genlist_Item_Class *field_item_class = elm_genlist_item_class_new(); + if (!field_item_class) { + BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); + return m_genlist; + } + field_item_class->item_style = "cert_field_text"; + field_item_class->decorate_item_style = nullptr; + field_item_class->func.text_get = __field_text_get_cb; + field_item_class->func.content_get = nullptr; + field_item_class->func.state_get = nullptr; + field_item_class->func.del = nullptr; + + Elm_Genlist_Item_Class *item_class = elm_genlist_item_class_new(); + if (!item_class) { + BROWSER_LOGE("elm_genlist_item_class_new for item_class failed"); + return m_genlist; + } + item_class->item_style = "cert_title_value_text"; + item_class->decorate_item_style = nullptr; + item_class->func.text_get = __title_value_text_get_cb; + item_class->func.content_get = nullptr; + item_class->func.state_get = nullptr; + item_class->func.del = nullptr; + + int no_of_items = m_genlist_callback_data_list.size(); + for (int i = 0; i < no_of_items; i++) { + Elm_Object_Item *item = nullptr; + auto callback_data = m_genlist_callback_data_list[i]; + if (callback_data->type == ISSUED_BY_HEADER + || callback_data->type == ISSUED_TO_HEADER + || callback_data->type == VALIDITY_HEADER + || callback_data->type == FINGERPRINTS_HEADER) { + item = + elm_genlist_item_append(m_genlist, field_item_class, + callback_data.get(), nullptr, + ELM_GENLIST_ITEM_NONE, nullptr, nullptr); + } else { + item = + elm_genlist_item_append(m_genlist, item_class, + callback_data.get(), nullptr, + ELM_GENLIST_ITEM_NONE, nullptr, nullptr); + } + elm_genlist_item_select_mode_set(item, + ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } - if (callback_data && !strcmp(part, "field_text")) { - return strdup(callback_data->title); + return m_genlist; } - BROWSER_LOGW("[%s:%d] callback_data is empty!", __PRETTY_FUNCTION__, __LINE__); - return strdup(""); -} + char *CertificateContents::__auth_text_get_cb(void *data, + Evas_Object * /*obj */ , + const char *part) + { + CertificateContents *cc = static_cast < CertificateContents * >(data); + if (!strcmp(part, "auth_text")) { + if (cc->isValidCertificate()) + return strdup(BR_STRING_TRUSTED_AUTHORITY); + else + return strdup(BR_STRING_UNTRUSTED_AUTHORITY); + } + return strdup(""); + } -char* CertificateContents::__title_value_text_get_cb(void* data, Evas_Object* /*obj*/, const char* part) -{ - auto callback_data = static_cast<genlist_callback_data* >(data); + char *CertificateContents::__field_text_get_cb(void *data, + Evas_Object * /*obj */ , + const char *part) + { + auto callback_data = static_cast < genlist_callback_data * >(data); - if (callback_data) { - if (!strcmp(part, "title_text")) { - return strdup(callback_data->title); - } else if (!strcmp(part,"value_text")) { - return strdup(callback_data->value); - } + if (callback_data && !strcmp(part, "field_text")) { + return strdup(callback_data->title); + } - BROWSER_LOGW("[%s:%d] unknown part: \"%s\"!", __PRETTY_FUNCTION__, __LINE__, part); - return strdup(""); + BROWSER_LOGW("[%s:%d] callback_data is empty!", __PRETTY_FUNCTION__, + __LINE__); + return strdup(""); } - BROWSER_LOGW("[%s:%d] callback_data is empty!", __PRETTY_FUNCTION__, __LINE__); - return strdup(""); -} + char *CertificateContents::__title_value_text_get_cb(void *data, + Evas_Object * + /*obj */ , + const char *part) + { + auto callback_data = static_cast < genlist_callback_data * >(data); + + if (callback_data) { + if (!strcmp(part, "title_text")) { + return strdup(callback_data->title); + } else if (!strcmp(part, "value_text")) { + return strdup(callback_data->value); + } + + BROWSER_LOGW("[%s:%d] unknown part: \"%s\"!", __PRETTY_FUNCTION__, + __LINE__, part); + return strdup(""); + } + + BROWSER_LOGW("[%s:%d] callback_data is empty!", __PRETTY_FUNCTION__, + __LINE__); + return strdup(""); + } /* *This method will parse the string and fetch the data *which is inbetween '=' and '/' or '\0'. */ -static const char* _get_value(char* token) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!token) - return nullptr; - - BROWSER_LOGD("token %s", token); - int start = 0; - int end = 0; - int len = strlen(token); - - while (start < len && token[start] != '=') - start++; - start++; //to skip '=' char - if (start >= len) return nullptr; //couldnt find the proper value so dont add this item in genlist - - for (int i = start; i < len; i++) { - if ((token[i] == '/') || (token[i] == '\0')) - break; - end++; //If no string found return the whole string + static const char *_get_value(char *token) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!token) + return nullptr; + + BROWSER_LOGD("token %s", token); + int start = 0; + int end = 0; + int len = strlen(token); + + while (start < len && token[start] != '=') + start++; + start++; //to skip '=' char + if (start >= len) + return nullptr; //couldnt find the proper value so dont add this item in genlist + + for (int i = start; i < len; i++) { + if ((token[i] == '/') || (token[i] == '\0')) + break; + end++; //If no string found return the whole string + } + std::string token_str = token; + std::string value = token_str.substr(start, end); + return strdup(value.c_str()); } - std::string token_str = token; - std::string value = token_str.substr(start, end); - return strdup(value.c_str()); -} /* *This method will format the ANS1_TIME struct to readable time format */ -static const char* _get_formatted_time(ASN1_TIME* tm) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - char timeBuf[128] = {'\0', }; - BIO *sBio = BIO_new(BIO_s_mem()); - if (sBio) { - int retVal = ASN1_TIME_print(sBio, tm); - if (retVal <= 0) { - BROWSER_LOGE("ASN1_TIME_print failed or wrote no data.\n"); - BIO_free(sBio); - return nullptr; - } - retVal = BIO_gets(sBio, timeBuf, 128); - if (retVal <= 0) { - BROWSER_LOGE("Failed to transfer contents to TimeBuffer"); - BIO_free(sBio); - return nullptr; - } - BIO_free(sBio); + static const char *_get_formatted_time(ASN1_TIME * tm) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char timeBuf[128] = { '\0', }; + BIO *sBio = BIO_new(BIO_s_mem()); + if (sBio) { + int retVal = ASN1_TIME_print(sBio, tm); + if (retVal <= 0) { + BROWSER_LOGE("ASN1_TIME_print failed or wrote no data.\n"); + BIO_free(sBio); + return nullptr; + } + retVal = BIO_gets(sBio, timeBuf, 128); + if (retVal <= 0) { + BROWSER_LOGE("Failed to transfer contents to TimeBuffer"); + BIO_free(sBio); + return nullptr; + } + BIO_free(sBio); + } + return strdup(timeBuf); } - return strdup(timeBuf); -} /* *This method will convert the serial number in required format. */ -static const char* _get_formatted_serial_no(ASN1_INTEGER *bs ) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - char printable[100]={'\0',}; - BIGNUM *bn = ASN1_INTEGER_to_BN(bs, nullptr); - unsigned char* binSerial = nullptr; - unsigned int outsz; - outsz = BN_num_bytes(bn); - if(bn){ - if (BN_is_negative(bn)) { - outsz++; - if (!(binSerial = (unsigned char* )malloc(outsz))) return 0; - BN_bn2bin(bn, binSerial + 1); - binSerial[0] = 0x80; - } else { - if (!(binSerial = (unsigned char* )malloc(outsz))) return 0; - BN_bn2bin(bn, binSerial); - } + static const char *_get_formatted_serial_no(ASN1_INTEGER * bs) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char printable[100] = { '\0', }; + BIGNUM *bn = ASN1_INTEGER_to_BN(bs, nullptr); + unsigned char *binSerial = nullptr; + unsigned int outsz; + outsz = BN_num_bytes(bn); + if (bn) { + if (BN_is_negative(bn)) { + outsz++; + if (!(binSerial = (unsigned char *) malloc(outsz))) + return 0; + BN_bn2bin(bn, binSerial + 1); + binSerial[0] = 0x80; + } else { + if (!(binSerial = (unsigned char *) malloc(outsz))) + return 0; + BN_bn2bin(bn, binSerial); + } + } + + for (size_t i = 0; i < outsz; i++) { + char *l = (char *) (3 * i + ((intptr_t) printable)); + + if (i < (outsz - 1)) { + if (binSerial != nullptr) { + snprintf(l, 4, "%02x%c", binSerial[i], ':'); + } + } else { + if (binSerial != nullptr) { + snprintf(l, 3, "%02x", binSerial[i]); + } + } + } + free(binSerial); + BN_free(bn); + BROWSER_LOGD(" New Serial Number : %s", printable); + return strdup(printable); } - for (size_t i=0; i < outsz; i++) { - char* l = (char*) (3*i + ((intptr_t) printable)); - - if (i < (outsz -1)) { - if(binSerial != nullptr) { - snprintf(l, 4, "%02x%c", binSerial[i],':'); - } - } - else { - if(binSerial != nullptr) { - snprintf(l, 3, "%02x", binSerial[i]); - } - } - } - free(binSerial); - BN_free(bn); - BROWSER_LOGD(" New Serial Number : %s",printable); - return strdup(printable); -} - /* *This method is to convert binary data to hexa decimal */ -static const char* _bin2hex(unsigned char*bin, size_t bin_size , char delimiter) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - char printable[100]={'\0',}; - for (size_t i=0; i < bin_size; i++) { - char* l = (char*) (3*i + ((intptr_t) printable)); - snprintf(l, 4, "%02x%c", bin[i],delimiter); + static const char *_bin2hex(unsigned char *bin, size_t bin_size, + char delimiter) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char printable[100] = { '\0', }; + for (size_t i = 0; i < bin_size; i++) { + char *l = (char *) (3 * i + ((intptr_t) printable)); + snprintf(l, 4, "%02x%c", bin[i], delimiter); + } + + return strdup(printable); } - return strdup(printable); -} - -void CertificateContents::_parse_certificate() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - char issued_to[1024] = {'\0', }; - char issued_by[1024] = {'\0', }; - char sha256[SHA256LEN] = {'\0', }; - char sha1[SHA1LEN] = {'\0', }; - size_t size; - - for (int field_count = 0; field_count < FIELD_END; field_count++) { - if (field_count == ISSUED_TO_HEADER) { - //Issued to - size = sizeof(issued_to); - X509_NAME_oneline(X509_get_subject_name(m_certificate), issued_to, size); - _populate_certificate_field_data(issued_to, ISSUED_TO_HEADER); - //Serial no: - ASN1_INTEGER *bs = X509_get_serialNumber(m_certificate); - _generate_genlist_data(ISSUED_TO_SERIAL_NO, BR_STRING_CERTIFICATE_SERIAL_NUMBER,_get_formatted_serial_no(bs)); - field_count += 4; - } else if (field_count == ISSUED_BY_HEADER) { - //Issued by - size = sizeof(issued_by); - X509_NAME_oneline(X509_get_issuer_name(m_certificate), issued_by, size); - _populate_certificate_field_data(issued_by, ISSUED_BY_HEADER); - field_count += 3; - } else if (field_count == VALIDITY_HEADER) { - _populate_certificate_field_data(nullptr, VALIDITY_HEADER); - //Issued On - ASN1_TIME *issuedTime = X509_get_notBefore(m_certificate); - _generate_genlist_data(VALIDITY_ISSUED_ON, BR_STRING_ISSUED_ON, _get_formatted_time(issuedTime)); - //Expires on - ASN1_TIME *expiresTime = X509_get_notAfter(m_certificate); - _generate_genlist_data(VALIDITY_EXPIRES_ON, BR_STRING_EXPIRES_ON_C, _get_formatted_time(expiresTime)); - field_count += 2; - } else if (field_count == FINGERPRINTS_HEADER) { - _populate_certificate_field_data(nullptr, FINGERPRINTS_HEADER); - const EVP_MD *digestSHA256 = EVP_sha256(); - unsigned len1; - int retVal = X509_digest(m_certificate, digestSHA256,(unsigned char*) sha256, &len1); - if (retVal == 0 || len1 != SHA256LEN) { - BROWSER_LOGE("Getting SHA256 cryptographic fingerprint failed %d",len1); - continue; - } - _generate_genlist_data(FINGERPRINTS_SHA_256_FP, BR_STRING_FINGERPRINTS_SHA256, _bin2hex((unsigned char*)sha256, SHA256LEN,' ')); - const EVP_MD *digestSHA1 = EVP_sha1(); - unsigned len2; - retVal = X509_digest(m_certificate, digestSHA1,(unsigned char*) sha1, &len2); - if (retVal == 0 || len2 != SHA1LEN) { - BROWSER_LOGE("Getting SHA1 cryptographic fingerprint failed %d",len2); - continue; - } - _generate_genlist_data(FINGERPRINTS_SHA_1_FP, BR_STRING_FINGERPRINTS_SHA1, _bin2hex((unsigned char*)sha1, SHA1LEN,' ')); - field_count += 2; - } + void CertificateContents::_parse_certificate() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char issued_to[1024] = { '\0', }; + char issued_by[1024] = { '\0', }; + char sha256[SHA256LEN] = { '\0', }; + char sha1[SHA1LEN] = { '\0', }; + size_t size; + + for (int field_count = 0; field_count < FIELD_END; field_count++) { + if (field_count == ISSUED_TO_HEADER) { + //Issued to + size = sizeof(issued_to); + X509_NAME_oneline(X509_get_subject_name(m_certificate), issued_to, + size); + _populate_certificate_field_data(issued_to, ISSUED_TO_HEADER); + //Serial no: + ASN1_INTEGER *bs = X509_get_serialNumber(m_certificate); + _generate_genlist_data(ISSUED_TO_SERIAL_NO, + BR_STRING_CERTIFICATE_SERIAL_NUMBER, + _get_formatted_serial_no(bs)); + field_count += 4; + } else if (field_count == ISSUED_BY_HEADER) { + //Issued by + size = sizeof(issued_by); + X509_NAME_oneline(X509_get_issuer_name(m_certificate), issued_by, + size); + _populate_certificate_field_data(issued_by, ISSUED_BY_HEADER); + field_count += 3; + } else if (field_count == VALIDITY_HEADER) { + _populate_certificate_field_data(nullptr, VALIDITY_HEADER); + //Issued On + ASN1_TIME *issuedTime = X509_get_notBefore(m_certificate); + _generate_genlist_data(VALIDITY_ISSUED_ON, BR_STRING_ISSUED_ON, + _get_formatted_time(issuedTime)); + //Expires on + ASN1_TIME *expiresTime = X509_get_notAfter(m_certificate); + _generate_genlist_data(VALIDITY_EXPIRES_ON, BR_STRING_EXPIRES_ON_C, + _get_formatted_time(expiresTime)); + field_count += 2; + } else if (field_count == FINGERPRINTS_HEADER) { + _populate_certificate_field_data(nullptr, FINGERPRINTS_HEADER); + const EVP_MD *digestSHA256 = EVP_sha256(); + unsigned len1; + int retVal = + X509_digest(m_certificate, digestSHA256, (unsigned char *) sha256, + &len1); + if (retVal == 0 || len1 != SHA256LEN) { + BROWSER_LOGE("Getting SHA256 cryptographic fingerprint failed %d", + len1); + continue; + } + _generate_genlist_data(FINGERPRINTS_SHA_256_FP, + BR_STRING_FINGERPRINTS_SHA256, + _bin2hex((unsigned char *) sha256, SHA256LEN, + ' ')); + const EVP_MD *digestSHA1 = EVP_sha1(); + unsigned len2; + retVal = + X509_digest(m_certificate, digestSHA1, (unsigned char *) sha1, + &len2); + if (retVal == 0 || len2 != SHA1LEN) { + BROWSER_LOGE("Getting SHA1 cryptographic fingerprint failed %d", + len2); + continue; + } + _generate_genlist_data(FINGERPRINTS_SHA_1_FP, + BR_STRING_FINGERPRINTS_SHA1, + _bin2hex((unsigned char *) sha1, SHA1LEN, + ' ')); + field_count += 2; + } + } } -} -void CertificateContents::_populate_certificate_field_data(char* data, certificate_field field) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - const char* value = nullptr; - switch (field) { - case ISSUED_BY_HEADER: - _generate_genlist_data(ISSUED_BY_HEADER , BR_STRING_ISSUED_BY_C, strdup(BR_STRING_ISSUED_BY_C)); - //Get Common name - value = _get_value(strstr(data, "CN=")); - _generate_genlist_data(ISSUED_BY_CN, BR_STRING_COMMON_NAME, value); - //Get Orgnization - value = _get_value(strstr(data, "O=")); - _generate_genlist_data(ISSUED_BY_ORG, BR_STRING_ORGANIZATION, value); - //Get Orgnization UNIT - value = _get_value(strstr(data, "OU=")); - _generate_genlist_data(ISSUED_BY_ORG_UNIT, BR_STRING_ORGANIZATION_UNIT, value); - break; - - case ISSUED_TO_HEADER: - _generate_genlist_data(ISSUED_TO_HEADER , BR_STRING_ISSUED_TO_C, strdup(BR_STRING_ISSUED_TO_C)); - //Get Common name - value = _get_value(strstr(data, "CN=")); - _generate_genlist_data(ISSUED_TO_CN, BR_STRING_COMMON_NAME, value); - //Get Orgnization - value = _get_value(strstr(data, "O=")); - _generate_genlist_data(ISSUED_TO_ORG, BR_STRING_ORGANIZATION, value); - //Get Orgnization UNIT - value = _get_value(strstr(data, "OU=")); - _generate_genlist_data(ISSUED_TO_ORG_UNIT, BR_STRING_ORGANIZATION_UNIT, value); - break; - - case VALIDITY_HEADER: - _generate_genlist_data(VALIDITY_HEADER , BR_STRING_VALIDITY_C, strdup(BR_STRING_VALIDITY_C)); - break; - - case FINGERPRINTS_HEADER: - _generate_genlist_data(FINGERPRINTS_HEADER , BR_STRING_FINGERPRINTS, strdup(BR_STRING_FINGERPRINTS)); - break; - - default: - break; + void CertificateContents::_populate_certificate_field_data(char *data, + certificate_field + field) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + const char *value = nullptr; + switch (field) { + case ISSUED_BY_HEADER: + _generate_genlist_data(ISSUED_BY_HEADER, BR_STRING_ISSUED_BY_C, + strdup(BR_STRING_ISSUED_BY_C)); + //Get Common name + value = _get_value(strstr(data, "CN=")); + _generate_genlist_data(ISSUED_BY_CN, BR_STRING_COMMON_NAME, value); + //Get Orgnization + value = _get_value(strstr(data, "O=")); + _generate_genlist_data(ISSUED_BY_ORG, BR_STRING_ORGANIZATION, value); + //Get Orgnization UNIT + value = _get_value(strstr(data, "OU=")); + _generate_genlist_data(ISSUED_BY_ORG_UNIT, + BR_STRING_ORGANIZATION_UNIT, value); + break; + + case ISSUED_TO_HEADER: + _generate_genlist_data(ISSUED_TO_HEADER, BR_STRING_ISSUED_TO_C, + strdup(BR_STRING_ISSUED_TO_C)); + //Get Common name + value = _get_value(strstr(data, "CN=")); + _generate_genlist_data(ISSUED_TO_CN, BR_STRING_COMMON_NAME, value); + //Get Orgnization + value = _get_value(strstr(data, "O=")); + _generate_genlist_data(ISSUED_TO_ORG, BR_STRING_ORGANIZATION, value); + //Get Orgnization UNIT + value = _get_value(strstr(data, "OU=")); + _generate_genlist_data(ISSUED_TO_ORG_UNIT, + BR_STRING_ORGANIZATION_UNIT, value); + break; + + case VALIDITY_HEADER: + _generate_genlist_data(VALIDITY_HEADER, BR_STRING_VALIDITY_C, + strdup(BR_STRING_VALIDITY_C)); + break; + + case FINGERPRINTS_HEADER: + _generate_genlist_data(FINGERPRINTS_HEADER, BR_STRING_FINGERPRINTS, + strdup(BR_STRING_FINGERPRINTS)); + break; + + default: + break; + } } -} -void CertificateContents::_generate_genlist_data(certificate_field field_type, const char* title, const char* value) -{ - if (!value) - return; - auto gl_data = std::make_shared<genlist_callback_data>(); - gl_data->type = field_type; - gl_data->title = title; - gl_data->value = value; - m_genlist_callback_data_list.push_back(gl_data); -} + void CertificateContents:: + _generate_genlist_data(certificate_field field_type, const char *title, + const char *value) + { + if (!value) + return; + auto gl_data = std::make_shared < genlist_callback_data > (); + gl_data->type = field_type; + gl_data->title = title; + gl_data->value = value; + m_genlist_callback_data_list.push_back(gl_data); + } -} + } } diff --git a/services/CertificateService/CertificateContents.h b/services/CertificateService/CertificateContents.h index b044c875..d2cd9706 100644..100755 --- a/services/CertificateService/CertificateContents.h +++ b/services/CertificateService/CertificateContents.h @@ -38,96 +38,114 @@ namespace tizen_browser { -namespace services -{ + namespace services + { -class BROWSER_EXPORT CertificateContents : public tizen_browser::core::AbstractService -{ -public: - CertificateContents(); - ~CertificateContents(); + class BROWSER_EXPORT CertificateContents:public tizen_browser::core:: + AbstractService + { + public: + CertificateContents(); + ~CertificateContents(); /** * @brief Returns current service's name. */ - virtual std::string getName(); - - enum HOST_TYPE { - SECURE_HOST = 1, - UNSECURE_HOST_ALLOWED, - UNSECURE_HOST_UNKNOWN, - HOST_ABSENT = -1 + virtual std::string getName(); + + enum HOST_TYPE + { + SECURE_HOST = 1, + UNSECURE_HOST_ALLOWED, + UNSECURE_HOST_UNKNOWN, + HOST_ABSENT = -1 + }; + + void init(); + void initUI(Evas_Object * parent); + Evas_Object *getContent(); + void unsecureHostAllowed(); + + void setCurrentTabCertData(std::string host, std::string pem, + HOST_TYPE type); + Eina_Bool isValidCertificate() const + { + return m_hostType == SECURE_HOST; + } + bool isValidCertificate(const std::string & uri); + + HOST_TYPE isCertExistForHost(const std::string & host); + void saveCertificateInfo(const std::string & host, + const std::string & pem); + void saveWrongCertificateInfo(const std::string & host, + const std::string & pem); + void clear(); + + boost::signals2::signal < std::shared_ptr < std::vector < std::pair < + std::string, int >>>() > getHostCertList; + boost::signals2::signal < void(const std::string &, + const std::string &, + int) > addOrUpdateCertificateEntry; + + private: + + typedef enum _certificate_field + { + ISSUED_TO_HEADER = 0, + ISSUED_TO_CN, + ISSUED_TO_ORG, + ISSUED_TO_ORG_UNIT, + ISSUED_TO_SERIAL_NO, + ISSUED_BY_HEADER, + ISSUED_BY_CN, + ISSUED_BY_ORG, + ISSUED_BY_ORG_UNIT, + VALIDITY_HEADER, + VALIDITY_ISSUED_ON, + VALIDITY_EXPIRES_ON, + FINGERPRINTS_HEADER, + FINGERPRINTS_SHA_256_FP, + FINGERPRINTS_SHA_1_FP, + FIELD_END + } certificate_field; + + struct genlist_callback_data + { + certificate_field type; + const char *title; + const char *value; + }; + + void addToHostCertList(const std::string & host, HOST_TYPE type); + bool createCertificate(const char *cert_data); + Evas_Object *createGenlist(Evas_Object * parent); + Evas_Object *createLabel(Evas_Object * parent, const std::string & msg); + void _parse_certificate(); + void _populate_certificate_field_data(char *data, + certificate_field field); + void _generate_genlist_data(certificate_field type, const char *title, + const char *value); + + static char *__auth_text_get_cb(void *data, Evas_Object * obj, + const char *part); + static char *__field_text_get_cb(void *data, Evas_Object * obj, + const char *part); + static char *__title_value_text_get_cb(void *data, Evas_Object * obj, + const char *part); + + Evas_Object *m_mainLayout; + Evas_Object *m_genlist; + Evas_Object *m_parent; + std::vector < std::shared_ptr < genlist_callback_data > + >m_genlist_callback_data_list; + std::string m_edjFilePath; + std::map < std::string, HOST_TYPE > m_host_cert_info; + + X509 *m_certificate; + HOST_TYPE m_hostType; }; - void init(); - void initUI(Evas_Object* parent); - Evas_Object* getContent(); - void unsecureHostAllowed(); - - void setCurrentTabCertData(std::string host, std::string pem, HOST_TYPE type); - Eina_Bool isValidCertificate() const { return m_hostType == SECURE_HOST; } - bool isValidCertificate(const std::string& uri); - - HOST_TYPE isCertExistForHost(const std::string& host); - void saveCertificateInfo(const std::string& host, const std::string& pem); - void saveWrongCertificateInfo(const std::string& host, const std::string& pem); - void clear(); - - boost::signals2::signal<std::shared_ptr<std::vector<std::pair<std::string, int> > > ()> getHostCertList; - boost::signals2::signal<void (const std::string&, const std::string&, int)> addOrUpdateCertificateEntry; - -private: - - typedef enum _certificate_field{ - ISSUED_TO_HEADER = 0, - ISSUED_TO_CN, - ISSUED_TO_ORG, - ISSUED_TO_ORG_UNIT, - ISSUED_TO_SERIAL_NO, - ISSUED_BY_HEADER, - ISSUED_BY_CN, - ISSUED_BY_ORG, - ISSUED_BY_ORG_UNIT, - VALIDITY_HEADER, - VALIDITY_ISSUED_ON, - VALIDITY_EXPIRES_ON, - FINGERPRINTS_HEADER, - FINGERPRINTS_SHA_256_FP, - FINGERPRINTS_SHA_1_FP, - FIELD_END - } certificate_field; - - struct genlist_callback_data { - certificate_field type; - const char *title; - const char *value; - }; - - void addToHostCertList(const std::string& host, HOST_TYPE type); - bool createCertificate(const char *cert_data); - Evas_Object* createGenlist(Evas_Object* parent); - Evas_Object* createLabel(Evas_Object* parent, const std::string& msg); - void _parse_certificate(); - void _populate_certificate_field_data(char *data, certificate_field field); - void _generate_genlist_data(certificate_field type, const char *title, const char *value); - - static char* __auth_text_get_cb(void* data, Evas_Object* obj, const char *part); - static char* __field_text_get_cb(void* data, Evas_Object* obj, const char *part); - static char* __title_value_text_get_cb(void* data, Evas_Object* obj, const char *part); - - Evas_Object* m_mainLayout; - Evas_Object* m_genlist; - Evas_Object* m_parent; - std::vector<std::shared_ptr<genlist_callback_data> > m_genlist_callback_data_list; - std::string m_edjFilePath; - std::map<std::string, HOST_TYPE> m_host_cert_info; - - X509 *m_certificate; - HOST_TYPE m_hostType; - -}; - -} + } } -#endif // CERTIFICATECONTENTS_H +#endif // CERTIFICATECONTENTS_H diff --git a/services/FindOnPageUI/FindOnPageUI.cpp b/services/FindOnPageUI/FindOnPageUI.cpp index 3ddd1741..c919e8c2 100755 --- a/services/FindOnPageUI/FindOnPageUI.cpp +++ b/services/FindOnPageUI/FindOnPageUI.cpp @@ -30,13 +30,15 @@ #include "BrowserLogger.h" #include "Tools/EflTools.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -EXPORT_SERVICE(FindOnPageUI, "org.tizen.browser.findonpageui") + EXPORT_SERVICE(FindOnPageUI, "org.tizen.browser.findonpageui") -FindOnPageUI::FindOnPageUI() - : m_fop_layout(NULL) + FindOnPageUI::FindOnPageUI() + :m_fop_layout(NULL) , m_entry(NULL) , m_down_button(NULL) , m_up_button(NULL) @@ -46,393 +48,427 @@ FindOnPageUI::FindOnPageUI() , m_current_index(0) , m_input_word(NULL) , m_isVisible(false) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("FindOnPageUI/FindOnPage.edj"); -} - -FindOnPageUI::~FindOnPageUI(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - evas_object_smart_callback_del(m_down_button, "clicked", __down_clicked_cb); - evas_object_smart_callback_del(m_up_button, "clicked", __up_clicked_cb); - - evas_object_smart_callback_del(m_entry, "activated", __enter_key_cb); - evas_object_smart_callback_del(m_entry, "changed", __entry_changed_cb); - evas_object_smart_callback_del(m_entry, "clicked", __entry_clicked_cb); - - evas_object_del(m_fop_layout); - eina_stringshare_del(m_input_word); -} - -void FindOnPageUI::show() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!m_fop_layout) - m_fop_layout = createFindOnPageUILayout(); - showUI(); - show_ime(); -} - -void FindOnPageUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} - -Evas_Object* FindOnPageUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - if (!m_fop_layout) - m_fop_layout = createFindOnPageUILayout(); - return m_fop_layout; -} - -void FindOnPageUI::show_ime(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (elm_object_focus_get(m_entry) == EINA_TRUE) - elm_object_focus_set(m_entry, EINA_FALSE); - elm_object_focus_set(m_entry, EINA_TRUE); -} + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("FindOnPageUI/FindOnPage.edj"); + } -void FindOnPageUI::set_text(const char *text) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_entry_entry_set(m_entry, ""); - char *markup_text = elm_entry_utf8_to_markup(text); - elm_entry_entry_append(m_entry, markup_text); - if (markup_text) - free(markup_text); -} + FindOnPageUI::~FindOnPageUI(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -void FindOnPageUI::clear_text(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_total_count = 0; - m_current_index = 0; - _set_count(0, 0); - elm_entry_entry_set(m_entry, ""); -} + evas_object_smart_callback_del(m_down_button, "clicked", + __down_clicked_cb); + evas_object_smart_callback_del(m_up_button, "clicked", __up_clicked_cb); -void FindOnPageUI::unset_focus(void) -{ - elm_object_focus_set(m_entry, EINA_FALSE); -} + evas_object_smart_callback_del(m_entry, "activated", __enter_key_cb); + evas_object_smart_callback_del(m_entry, "changed", __entry_changed_cb); + evas_object_smart_callback_del(m_entry, "clicked", __entry_clicked_cb); -Evas_Object* FindOnPageUI::createFindOnPageUILayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - // Find on page layout. - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - m_fop_layout = elm_layout_add(m_parent); - if (!m_fop_layout) { - BROWSER_LOGD("elm_layout_add failed"); - return NULL; + evas_object_del(m_fop_layout); + eina_stringshare_del(m_input_word); } - elm_layout_file_set(m_fop_layout, m_edjFilePath.c_str(), "find-on-page-layout"); - evas_object_size_hint_weight_set(m_fop_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - // Entry. - m_entry = elm_entry_add(m_fop_layout); - elm_object_style_set(m_entry, "fop_entry"); - elm_entry_single_line_set(m_entry, EINA_TRUE); - elm_entry_scrollable_set(m_entry, EINA_TRUE); - elm_entry_autocapital_type_set(m_entry, ELM_AUTOCAPITAL_TYPE_NONE); - elm_entry_cnp_mode_set(m_entry, ELM_CNP_MODE_PLAINTEXT); - elm_entry_input_panel_enabled_set(m_entry, EINA_TRUE); - elm_entry_input_panel_return_key_type_set(m_entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); - - evas_object_size_hint_weight_set(m_entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - evas_object_smart_callback_add(m_entry, "activated", __enter_key_cb, this); - evas_object_smart_callback_add(m_entry, "changed", __entry_changed_cb, this); - evas_object_smart_callback_add(m_entry, "clicked", __entry_clicked_cb, this); - - elm_object_translatable_part_text_set(m_entry, "elm.guide", "IDS_BR_OPT_FIND_ON_PAGE"); - - Evas_Object *access = elm_access_object_get(elm_entry_textblock_get(m_entry)); - elm_access_info_set(access, ELM_ACCESS_TYPE, _("IDS_BR_BODY_TEXT_FIELD_T_TTS")); - - static Elm_Entry_Filter_Limit_Size limit_filter_data; - limit_filter_data.max_byte_count = 0; - limit_filter_data.max_char_count = FIND_ON_PAGE_MAX_TEXT; - elm_entry_markup_filter_append(m_entry, elm_entry_filter_limit_size, &limit_filter_data); - - elm_object_part_content_set(m_fop_layout, "elm.swallow.entry", m_entry); - - // Clear button - m_clear_button = elm_button_add(m_fop_layout); - elm_object_style_set(m_clear_button, "basic_button"); - elm_access_info_set(m_clear_button, ELM_ACCESS_INFO, _("IDS_BR_OPT_CLEAR_ALL")); - evas_object_smart_callback_add(m_clear_button, "clicked", __clear_clicked_cb, this); - elm_object_part_content_set(m_fop_layout, "clear_button_click", m_clear_button); - - // Down button. - m_down_button = elm_button_add(m_fop_layout); - elm_object_style_set(m_down_button, "basic_button"); - elm_access_info_set(m_down_button, ELM_ACCESS_INFO, _("IDS_BR_SK_NEXT")); - evas_object_smart_callback_add(m_down_button, "clicked", __down_clicked_cb, this); - elm_object_part_content_set(m_fop_layout, "down_button_click", m_down_button); - - // Up button. - m_up_button = elm_button_add(m_fop_layout); - elm_object_style_set(m_up_button, "basic_button"); - elm_access_info_set(m_up_button, ELM_ACCESS_INFO, _("IDS_BR_SK_PREVIOUS")); - evas_object_smart_callback_add(m_up_button, "clicked", __up_clicked_cb, this); - elm_object_part_content_set(m_fop_layout, "up_button_click", m_up_button); - - Evas_Object *close_click = elm_button_add(m_fop_layout); - elm_object_style_set(close_click, "basic_button"); - evas_object_smart_callback_add(close_click, "clicked", __close_clicked_cb, this); - elm_object_part_content_set(m_fop_layout, "close_click", close_click); - - elm_object_part_content_set(m_parent, "findonpage", m_fop_layout); - _set_count(0, 0); - return m_fop_layout; -} - -void FindOnPageUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_parent, "show_findonpage", "ui"); - evas_object_show(m_fop_layout); - m_isVisible = true; -} - -void FindOnPageUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_parent, "hide_findonpage", "ui"); - clear_text(); - unset_focus(); - evas_object_hide(m_fop_layout); - m_isVisible = false; -} - -void FindOnPageUI::__close_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); - fop->closeFindOnPageUIClicked(); -} -void FindOnPageUI::_set_count(int index, int total) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("%d/%d", index, total); - - char text_buffer[16] = { 0, }; - int digit_count = 0; - if (total > 999) - digit_count = 4; - else if (total > 99) - digit_count = 3; - else if (total > 9) - digit_count = 2; - else - digit_count = 1; - - const char *elm_text = elm_entry_entry_get(m_entry); - if (elm_text == NULL || strlen(elm_text) == 0) { - // Show 0/0 - elm_object_signal_emit(m_fop_layout, "digit_1,signal", ""); - } else { - // Change count layout size. - snprintf(text_buffer,sizeof(text_buffer), "digit_%d,signal", digit_count); - elm_object_signal_emit(m_fop_layout, text_buffer, ""); + void FindOnPageUI::show() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!m_fop_layout) + m_fop_layout = createFindOnPageUILayout(); + showUI(); + show_ime(); } - snprintf(text_buffer, sizeof(text_buffer),"%d/%d", index, total); - elm_object_part_text_set(m_fop_layout, "elm.text.count", text_buffer); + void FindOnPageUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } - if (total <= 1) { - BROWSER_LOGD("total %d", total); - _disable_up_button(EINA_TRUE); - _disable_down_button(EINA_TRUE); - return; + Evas_Object *FindOnPageUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if (!m_fop_layout) + m_fop_layout = createFindOnPageUILayout(); + return m_fop_layout; } - _disable_up_button(EINA_FALSE); - _disable_down_button(EINA_FALSE); -} + void FindOnPageUI::show_ime(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (elm_object_focus_get(m_entry) == EINA_TRUE) + elm_object_focus_set(m_entry, EINA_FALSE); + elm_object_focus_set(m_entry, EINA_TRUE); + } -void FindOnPageUI::_disable_down_button(Eina_Bool disable) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_disabled_set(m_down_button, disable); -} + void FindOnPageUI::set_text(const char *text) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_entry_entry_set(m_entry, ""); + char *markup_text = elm_entry_utf8_to_markup(text); + elm_entry_entry_append(m_entry, markup_text); + if (markup_text) + free(markup_text); + } -void FindOnPageUI::_disable_up_button(Eina_Bool disable) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_disabled_set(m_up_button, disable); -} + void FindOnPageUI::clear_text(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_total_count = 0; + m_current_index = 0; + _set_count(0, 0); + elm_entry_entry_set(m_entry, ""); + } -void FindOnPageUI::__text_found_cb(void *data, Evas_Object* /*obj*/, void *event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!data) - return; + void FindOnPageUI::unset_focus(void) + { + elm_object_focus_set(m_entry, EINA_FALSE); + } - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); + Evas_Object *FindOnPageUI::createFindOnPageUILayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + // Find on page layout. + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + m_fop_layout = elm_layout_add(m_parent); + if (!m_fop_layout) { + BROWSER_LOGD("elm_layout_add failed"); + return NULL; + } + elm_layout_file_set(m_fop_layout, m_edjFilePath.c_str(), + "find-on-page-layout"); + evas_object_size_hint_weight_set(m_fop_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + // Entry. + m_entry = elm_entry_add(m_fop_layout); + elm_object_style_set(m_entry, "fop_entry"); + elm_entry_single_line_set(m_entry, EINA_TRUE); + elm_entry_scrollable_set(m_entry, EINA_TRUE); + elm_entry_autocapital_type_set(m_entry, ELM_AUTOCAPITAL_TYPE_NONE); + elm_entry_cnp_mode_set(m_entry, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_enabled_set(m_entry, EINA_TRUE); + elm_entry_input_panel_return_key_type_set(m_entry, + ELM_INPUT_PANEL_RETURN_KEY_TYPE_SEARCH); + + evas_object_size_hint_weight_set(m_entry, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + + evas_object_smart_callback_add(m_entry, "activated", __enter_key_cb, + this); + evas_object_smart_callback_add(m_entry, "changed", __entry_changed_cb, + this); + evas_object_smart_callback_add(m_entry, "clicked", __entry_clicked_cb, + this); + + elm_object_translatable_part_text_set(m_entry, "elm.guide", + "IDS_BR_OPT_FIND_ON_PAGE"); + + Evas_Object *access = + elm_access_object_get(elm_entry_textblock_get(m_entry)); + elm_access_info_set(access, ELM_ACCESS_TYPE, + _("IDS_BR_BODY_TEXT_FIELD_T_TTS")); + + static Elm_Entry_Filter_Limit_Size limit_filter_data; + limit_filter_data.max_byte_count = 0; + limit_filter_data.max_char_count = FIND_ON_PAGE_MAX_TEXT; + elm_entry_markup_filter_append(m_entry, elm_entry_filter_limit_size, + &limit_filter_data); + + elm_object_part_content_set(m_fop_layout, "elm.swallow.entry", m_entry); + + // Clear button + m_clear_button = elm_button_add(m_fop_layout); + elm_object_style_set(m_clear_button, "basic_button"); + elm_access_info_set(m_clear_button, ELM_ACCESS_INFO, + _("IDS_BR_OPT_CLEAR_ALL")); + evas_object_smart_callback_add(m_clear_button, "clicked", + __clear_clicked_cb, this); + elm_object_part_content_set(m_fop_layout, "clear_button_click", + m_clear_button); + + // Down button. + m_down_button = elm_button_add(m_fop_layout); + elm_object_style_set(m_down_button, "basic_button"); + elm_access_info_set(m_down_button, ELM_ACCESS_INFO, + _("IDS_BR_SK_NEXT")); + evas_object_smart_callback_add(m_down_button, "clicked", + __down_clicked_cb, this); + elm_object_part_content_set(m_fop_layout, "down_button_click", + m_down_button); + + // Up button. + m_up_button = elm_button_add(m_fop_layout); + elm_object_style_set(m_up_button, "basic_button"); + elm_access_info_set(m_up_button, ELM_ACCESS_INFO, + _("IDS_BR_SK_PREVIOUS")); + evas_object_smart_callback_add(m_up_button, "clicked", __up_clicked_cb, + this); + elm_object_part_content_set(m_fop_layout, "up_button_click", + m_up_button); + + Evas_Object *close_click = elm_button_add(m_fop_layout); + elm_object_style_set(close_click, "basic_button"); + evas_object_smart_callback_add(close_click, "clicked", + __close_clicked_cb, this); + elm_object_part_content_set(m_fop_layout, "close_click", close_click); + + elm_object_part_content_set(m_parent, "findonpage", m_fop_layout); + _set_count(0, 0); + return m_fop_layout; + } - int match_count = *(static_cast<int*>(event_info)); - BROWSER_LOGD("match_count=%d", match_count); - fop->m_total_count = match_count; - if (fop->m_current_index == 0) - fop->m_current_index = 1; + void FindOnPageUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_parent, "show_findonpage", "ui"); + evas_object_show(m_fop_layout); + m_isVisible = true; + } - if (match_count == -1 || match_count >= FIND_WORD_MAX_COUNT) - fop->m_total_count = FIND_WORD_MAX_COUNT-1; - else - fop->m_total_count = match_count; + void FindOnPageUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_parent, "hide_findonpage", "ui"); + clear_text(); + unset_focus(); + evas_object_hide(m_fop_layout); + m_isVisible = false; + } - if (match_count == 0) - fop->m_current_index = 0; + void FindOnPageUI::__close_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); + fop->closeFindOnPageUIClicked(); + } - if (fop->m_current_index > fop->m_total_count) - fop->m_current_index = fop->m_total_count; - fop->_set_count(fop->m_current_index, fop->m_total_count); -} -void FindOnPageUI::__entry_clicked_cb(void *data, Evas_Object*/*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - auto fop = static_cast<FindOnPageUI*>(data); - if (fop) - fop->show_ime(); -} + void FindOnPageUI::_set_count(int index, int total) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("%d/%d", index, total); + + char text_buffer[16] = { 0, }; + int digit_count = 0; + if (total > 999) + digit_count = 4; + else if (total > 99) + digit_count = 3; + else if (total > 9) + digit_count = 2; + else + digit_count = 1; + + const char *elm_text = elm_entry_entry_get(m_entry); + if (elm_text == NULL || strlen(elm_text) == 0) { + // Show 0/0 + elm_object_signal_emit(m_fop_layout, "digit_1,signal", ""); + } else { + // Change count layout size. + snprintf(text_buffer, sizeof(text_buffer), "digit_%d,signal", + digit_count); + elm_object_signal_emit(m_fop_layout, text_buffer, ""); + } + + snprintf(text_buffer, sizeof(text_buffer), "%d/%d", index, total); + elm_object_part_text_set(m_fop_layout, "elm.text.count", text_buffer); + + if (total <= 1) { + BROWSER_LOGD("total %d", total); + _disable_up_button(EINA_TRUE); + _disable_down_button(EINA_TRUE); + return; + } + + _disable_up_button(EINA_FALSE); + _disable_down_button(EINA_FALSE); + } -void FindOnPageUI::__entry_changed_cb(void *data, Evas_Object *obj, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); - fop->m_current_index = 1; - - const char *elm_text = elm_entry_entry_get(obj); - if (!elm_text || strlen(elm_text) == 0) { - fop->_set_count(0, 0); - elm_object_signal_emit(fop->m_fop_layout, "hide,clear,button,signal", ""); - eina_stringshare_replace(&fop->m_input_word, ""); - // On deleting last character, send empty string to clear the highlight. - struct FindData fd = {"", EINA_FALSE, NULL, NULL}; - fop->startFindingWord(fd); - return; + void FindOnPageUI::_disable_down_button(Eina_Bool disable) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_disabled_set(m_down_button, disable); } - char *text = elm_entry_markup_to_utf8(elm_text); - BROWSER_LOGD("Previous text=[%s], Current text[%s]", fop->m_input_word ? fop->m_input_word : "", text); + void FindOnPageUI::_disable_up_button(Eina_Bool disable) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_disabled_set(m_up_button, disable); + } - elm_object_signal_emit(fop->m_fop_layout, "show,clear,button,signal", ""); + void FindOnPageUI::__text_found_cb(void *data, Evas_Object * /*obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!data) + return; - if (strlen(text) >= FIND_ON_PAGE_MAX_TEXT) { + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); - // TODO : Show Notification. + int match_count = *(static_cast < int *>(event_info)); + BROWSER_LOGD("match_count=%d", match_count); + fop->m_total_count = match_count; + if (fop->m_current_index == 0) + fop->m_current_index = 1; - char buf[FIND_ON_PAGE_MAX_TEXT + 1] = {0, }; - snprintf(buf, sizeof(buf) - 1, "%s", text); + if (match_count == -1 || match_count >= FIND_WORD_MAX_COUNT) + fop->m_total_count = FIND_WORD_MAX_COUNT - 1; + else + fop->m_total_count = match_count; - fop->set_text(buf); + if (match_count == 0) + fop->m_current_index = 0; - elm_entry_cursor_end_set(obj); - free(text); - return; + if (fop->m_current_index > fop->m_total_count) + fop->m_current_index = fop->m_total_count; + fop->_set_count(fop->m_current_index, fop->m_total_count); + } + void FindOnPageUI::__entry_clicked_cb(void *data, Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + auto fop = static_cast < FindOnPageUI * >(data); + if (fop) + fop->show_ime(); } - std::string input_uri_str; - - input_uri_str = std::string(text); - std::size_t pos = input_uri_str.find("<preedit>"); - if (pos != std::string::npos) - input_uri_str.erase(pos, strlen("<preedit>")); - pos = input_uri_str.find("</preedit>"); - if (pos != std::string::npos) - input_uri_str.erase(pos, strlen("</preedit>")); - - free(text); - - if ((!fop->m_input_word) || (input_uri_str.c_str() && strcmp(fop->m_input_word, input_uri_str.c_str()))) { - eina_stringshare_replace(&fop->m_input_word, input_uri_str.c_str()); - struct FindData fd = { - input_uri_str.c_str(), - EINA_TRUE, - __text_found_cb, - data, - }; - fop->startFindingWord(fd); + void FindOnPageUI::__entry_changed_cb(void *data, Evas_Object * obj, + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); + fop->m_current_index = 1; + + const char *elm_text = elm_entry_entry_get(obj); + if (!elm_text || strlen(elm_text) == 0) { + fop->_set_count(0, 0); + elm_object_signal_emit(fop->m_fop_layout, "hide,clear,button,signal", + ""); + eina_stringshare_replace(&fop->m_input_word, ""); + // On deleting last character, send empty string to clear the highlight. + struct FindData fd = { "", EINA_FALSE, NULL, NULL }; + fop->startFindingWord(fd); + return; + } + + char *text = elm_entry_markup_to_utf8(elm_text); + BROWSER_LOGD("Previous text=[%s], Current text[%s]", + fop->m_input_word ? fop->m_input_word : "", text); + + elm_object_signal_emit(fop->m_fop_layout, "show,clear,button,signal", + ""); + + if (strlen(text) >= FIND_ON_PAGE_MAX_TEXT) { + // TODO : Show Notification. + char buf[FIND_ON_PAGE_MAX_TEXT + 1] = { 0, }; + snprintf(buf, sizeof(buf) - 1, "%s", text); + + fop->set_text(buf); + + elm_entry_cursor_end_set(obj); + free(text); + return; + } + + std::string input_uri_str; + + input_uri_str = std::string(text); + std::size_t pos = input_uri_str.find("<preedit>"); + if (pos != std::string::npos) + input_uri_str.erase(pos, strlen("<preedit>")); + pos = input_uri_str.find("</preedit>"); + if (pos != std::string::npos) + input_uri_str.erase(pos, strlen("</preedit>")); + + free(text); + + if ((!fop->m_input_word) + || (input_uri_str.c_str() + && strcmp(fop->m_input_word, input_uri_str.c_str()))) { + eina_stringshare_replace(&fop->m_input_word, input_uri_str.c_str()); + struct FindData fd = { + input_uri_str.c_str(), + EINA_TRUE, + __text_found_cb, + data, + }; + fop->startFindingWord(fd); + } } -} -void FindOnPageUI::__enter_key_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void FindOnPageUI::__enter_key_cb(void *data, Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - // Unfocus the entry to hide IME when Done/Search key is pressed. - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); - // TODO : Check if IME is shown. - elm_object_focus_set(fop->m_entry, EINA_FALSE); -} + // Unfocus the entry to hide IME when Done/Search key is pressed. + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); + // TODO : Check if IME is shown. + elm_object_focus_set(fop->m_entry, EINA_FALSE); + } -void FindOnPageUI::__clear_clicked_cb(void *data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); - elm_entry_entry_set(fop->m_entry, ""); - fop->_set_count(0, 0); - elm_object_focus_set(fop->m_entry, EINA_TRUE); - elm_object_signal_emit(fop->m_fop_layout, "hide,clear,button,signal", ""); -} + void FindOnPageUI::__clear_clicked_cb(void *data, Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); + elm_entry_entry_set(fop->m_entry, ""); + fop->_set_count(0, 0); + elm_object_focus_set(fop->m_entry, EINA_TRUE); + elm_object_signal_emit(fop->m_fop_layout, "hide,clear,button,signal", + ""); + } -void FindOnPageUI::__down_clicked_cb(void *data, Evas_Object *obj, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); + void FindOnPageUI::__down_clicked_cb(void *data, Evas_Object * obj, + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); - if (fop->m_total_count == 0) - return; + if (fop->m_total_count == 0) + return; - fop->m_current_index++; - if (fop->m_current_index > fop->m_total_count) - fop->m_current_index = 1; + fop->m_current_index++; + if (fop->m_current_index > fop->m_total_count) + fop->m_current_index = 1; - struct FindData fd = { - fop->m_input_word, - EINA_TRUE, - __text_found_cb, - data, - }; - fop->startFindingWord(fd); + struct FindData fd = { + fop->m_input_word, + EINA_TRUE, + __text_found_cb, + data, + }; + fop->startFindingWord(fd); - elm_object_focus_set(obj, EINA_TRUE); -} + elm_object_focus_set(obj, EINA_TRUE); + } -void FindOnPageUI::__up_clicked_cb(void *data, Evas_Object *obj, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - FindOnPageUI *fop = static_cast<FindOnPageUI*>(data); + void FindOnPageUI::__up_clicked_cb(void *data, Evas_Object * obj, + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + FindOnPageUI *fop = static_cast < FindOnPageUI * >(data); - if (fop->m_total_count == 0) - return; + if (fop->m_total_count == 0) + return; - fop->m_current_index--; - if (fop->m_current_index < 1) - fop->m_current_index = fop->m_total_count; + fop->m_current_index--; + if (fop->m_current_index < 1) + fop->m_current_index = fop->m_total_count; - struct FindData fd = { - fop->m_input_word, - EINA_FALSE, - __text_found_cb, - data, - }; - fop->startFindingWord(fd); + struct FindData fd = { + fop->m_input_word, + EINA_FALSE, + __text_found_cb, + data, + }; + fop->startFindingWord(fd); - elm_object_focus_set(obj, EINA_TRUE); -} + elm_object_focus_set(obj, EINA_TRUE); + } -} + } } diff --git a/services/FindOnPageUI/FindOnPageUI.h b/services/FindOnPageUI/FindOnPageUI.h index 87d94cd2..7690ab52 100644..100755 --- a/services/FindOnPageUI/FindOnPageUI.h +++ b/services/FindOnPageUI/FindOnPageUI.h @@ -25,73 +25,92 @@ #include "ServiceFactory.h" #include "service_macros.h" -namespace tizen_browser{ -namespace base_ui{ - -struct FindData { - const char* input_str; - bool forward; - Evas_Smart_Cb func; - void* data; -}; - -class BROWSER_EXPORT FindOnPageUI - : public tizen_browser::interfaces::AbstractUIComponent - , public tizen_browser::core::AbstractService +namespace tizen_browser { -public: - virtual std::string getName(); - - FindOnPageUI(); - ~FindOnPageUI(void); - - Evas_Object* getContent(); - void init(Evas_Object* parent); - Evas_Object *get_layout(void) { return m_fop_layout; } - Evas_Object* createFindOnPageUILayout(); - void show(); - void showUI(); - void hideUI(); - bool isVisible() { return m_isVisible; } - - void show_ime(void); - void clear_text(void); - void set_text(const char *text); - Evas_Object* get_entry(void) { return m_entry; } - void unset_focus(void); - - boost::signals2::signal<void ()> closeFindOnPageUIClicked; - boost::signals2::signal<void (const struct FindData& )> startFindingWord; - -private: - void _set_count(int index, int total); - void _disable_down_button(Eina_Bool disable); - void _disable_up_button(Eina_Bool disable); - - static void __clear_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void __down_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void __up_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void __enter_key_cb(void *data, Evas_Object *obj, void *event_info); - static void __entry_clicked_cb(void *data, Evas_Object *obj, void *event_info); - static void __entry_changed_cb(void *data, Evas_Object *obj, void *event_info); - static void __text_found_cb(void *data, Evas_Object *obj, void *event_info); - static void __close_clicked_cb(void *data, Evas_Object *obj, void *event_info); - - Evas_Object *m_fop_layout; - Evas_Object *m_entry; - Evas_Object *m_down_button; - Evas_Object *m_up_button; - Evas_Object *m_clear_button; - Evas_Object *m_parent; - - int m_total_count; - int m_current_index; - const char *m_input_word; - std::string m_edjFilePath; - bool m_isVisible; -}; - -} + namespace base_ui + { + + struct FindData + { + const char *input_str; + bool forward; + Evas_Smart_Cb func; + void *data; + }; + + class BROWSER_EXPORT FindOnPageUI:public tizen_browser::interfaces:: + AbstractUIComponent, public tizen_browser::core::AbstractService + { + public: + virtual std::string getName(); + + FindOnPageUI(); + ~FindOnPageUI(void); + + Evas_Object *getContent(); + void init(Evas_Object * parent); + Evas_Object *get_layout(void) + { + return m_fop_layout; + } + Evas_Object *createFindOnPageUILayout(); + void show(); + void showUI(); + void hideUI(); + bool isVisible() + { + return m_isVisible; + } + + void show_ime(void); + void clear_text(void); + void set_text(const char *text); + Evas_Object *get_entry(void) + { + return m_entry; + } + void unset_focus(void); + + boost::signals2::signal < void() > closeFindOnPageUIClicked; + boost::signals2::signal < void(const struct FindData &) > + startFindingWord; + + private: + void _set_count(int index, int total); + void _disable_down_button(Eina_Bool disable); + void _disable_up_button(Eina_Bool disable); + + static void __clear_clicked_cb(void *data, Evas_Object * obj, + void *event_info); + static void __down_clicked_cb(void *data, Evas_Object * obj, + void *event_info); + static void __up_clicked_cb(void *data, Evas_Object * obj, + void *event_info); + static void __enter_key_cb(void *data, Evas_Object * obj, + void *event_info); + static void __entry_clicked_cb(void *data, Evas_Object * obj, + void *event_info); + static void __entry_changed_cb(void *data, Evas_Object * obj, + void *event_info); + static void __text_found_cb(void *data, Evas_Object * obj, + void *event_info); + static void __close_clicked_cb(void *data, Evas_Object * obj, + void *event_info); + + Evas_Object *m_fop_layout; + Evas_Object *m_entry; + Evas_Object *m_down_button; + Evas_Object *m_up_button; + Evas_Object *m_clear_button; + Evas_Object *m_parent; + + int m_total_count; + int m_current_index; + const char *m_input_word; + std::string m_edjFilePath; + bool m_isVisible; + }; + + } } #endif /* FIND_ON_PAGE_H */ - diff --git a/services/HistoryService/HistoryItem.cpp b/services/HistoryService/HistoryItem.cpp index ec5cbad6..9260ae2b 100644..100755 --- a/services/HistoryService/HistoryItem.cpp +++ b/services/HistoryService/HistoryItem.cpp @@ -19,165 +19,163 @@ namespace tizen_browser { -namespace services -{ - -HistoryItem::HistoryItem(HistoryItem && other) noexcept -{ - try { - if (this != &other) { - *this = std::move(other); - } - } catch(...) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + namespace services + { + + HistoryItem::HistoryItem(HistoryItem && other) noexcept + { + try { + if (this != &other) { + *this = std::move(other); + } + } + catch(...) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + } } -} -HistoryItem::HistoryItem(int id, - const std::string & url, - const std::string & title, - tools::BrowserImagePtr favicon, - tools::BrowserImagePtr thumbnail) + HistoryItem::HistoryItem(int id, + const std::string & url, + const std::string & title, + tools::BrowserImagePtr favicon, + tools::BrowserImagePtr thumbnail) : m_primaryKey(id) - , m_url(url) - , m_title(title) - , m_lastVisit() - , m_favIcon(favicon) -{ - if (thumbnail) - m_thumbnail = thumbnail; - else - m_thumbnail = favicon; -} + , m_url(url) + , m_title(title) + , m_lastVisit() + , m_favIcon(favicon) + { + if (thumbnail) + m_thumbnail = thumbnail; + else + m_thumbnail = favicon; + } -HistoryItem::HistoryItem(int id, const std::string & url) + HistoryItem::HistoryItem(int id, const std::string & url) : m_primaryKey(id) - , m_url(url) - , m_title() - , m_lastVisit() - , m_favIcon(std::make_shared<tizen_browser::tools::BrowserImage>()) -{ - -} + , m_url(url) + , m_title() + , m_lastVisit() + , m_favIcon(std::make_shared < tizen_browser::tools::BrowserImage > ()) + { + } -HistoryItem::HistoryItem(const HistoryItem& source) + HistoryItem::HistoryItem(const HistoryItem & source) : m_primaryKey(source.m_primaryKey) - , m_url(source.m_url) - , m_title(source.m_title) - , m_lastVisit(source.m_lastVisit) - , m_favIcon(source.m_favIcon) - , m_visitCounter(source.m_visitCounter) -{ - -} - -HistoryItem::~HistoryItem() -{ + , m_url(source.m_url) + , m_title(source.m_title) + , m_lastVisit(source.m_lastVisit) + , m_favIcon(source.m_favIcon) + , m_visitCounter(source.m_visitCounter) + { + } -} + HistoryItem::~HistoryItem() { + } -HistoryItem & HistoryItem::operator=(HistoryItem && other) noexcept -{ - if (this != &other) { - m_url = std::move(other.m_url); - m_title = std::move(other.m_title); - m_visitDate = std::move(other.m_visitDate); - m_visitCounter = std::move(other.m_visitCounter); - m_favIcon = std::move(other.m_favIcon); - } - return *this; -} + HistoryItem & HistoryItem::operator=(HistoryItem && other) noexcept { + if (this != &other) { + m_url = std::move(other.m_url); + m_title = std::move(other.m_title); + m_visitDate = std::move(other.m_visitDate); + m_visitCounter = std::move(other.m_visitCounter); + m_favIcon = std::move(other.m_favIcon); + } + return *this; + } -bool HistoryItem::operator==(const HistoryItem& other) -{ - return (m_url == other.m_url); -} + bool HistoryItem::operator==(const HistoryItem & other) + { + return (m_url == other.m_url); + } -bool HistoryItem::operator!=(const HistoryItem& other) -{ - return (m_url != other.m_url); -} + bool HistoryItem::operator!=(const HistoryItem & other) + { + return (m_url != other.m_url); + } -void HistoryItem::setUrl(const std::string & url) -{ - m_url = url; -} + void HistoryItem::setUrl(const std::string & url) + { + m_url = url; + } -std::string HistoryItem::getUrl() const -{ - return m_url; -} + std::string HistoryItem::getUrl()const + { + return m_url; + } -void HistoryItem::setTitle(const std::string & title) -{ - m_title = title; -} + void HistoryItem::setTitle(const std::string & title) + { + m_title = title; + } -std::string HistoryItem::getTitle() const -{ - return m_title; -} + std::string HistoryItem::getTitle()const + { + return m_title; + } -void HistoryItem::setLastVisit(boost::posix_time::ptime visitDate) -{ - m_lastVisit = visitDate; -} + void HistoryItem::setLastVisit(boost::posix_time::ptime visitDate) + { + m_lastVisit = visitDate; + } -boost::posix_time::ptime HistoryItem::getLastVisit() const -{ - return m_lastVisit; -} + boost::posix_time::ptime HistoryItem::getLastVisit()const + { + return m_lastVisit; + } // TODO Replace with std::time_t to_time_t(ptime pt) from boost/date_time/posix_time/conversion.hpp after migration // to boost ver. 1.58 -time_t HistoryItem::getLastVisitAsTimeT() const -{ - const boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1)); - const boost::posix_time::time_duration::sec_type x = (m_lastVisit - epoch).total_seconds(); - std::time_t rawtime(x); - - return rawtime; -} - -void HistoryItem::setVisitCounter(int visitCounter) -{ - m_visitCounter = visitCounter; -} + time_t HistoryItem::getLastVisitAsTimeT() const + { + const boost::posix_time::ptime epoch(boost::gregorian:: + date(1970, 1, 1)); + const boost::posix_time::time_duration::sec_type x = + (m_lastVisit - epoch).total_seconds(); + std::time_t rawtime(x); + + return rawtime; + } -int HistoryItem::getVisitCounter() -{ - return m_visitCounter; -} + void HistoryItem::setVisitCounter(int visitCounter) + { + m_visitCounter = visitCounter; + } -void HistoryItem::setFavIcon(tools::BrowserImagePtr favIcon) -{ - m_favIcon = favIcon; -} + int HistoryItem::getVisitCounter() + { + return m_visitCounter; + } -tools::BrowserImagePtr HistoryItem::getFavIcon() -{ - return m_favIcon; -} + void HistoryItem::setFavIcon(tools::BrowserImagePtr favIcon) + { + m_favIcon = favIcon; + } -void HistoryItem::setThumbnail(tools::BrowserImagePtr thumbnail) -{ - m_thumbnail = thumbnail; -}; + tools::BrowserImagePtr HistoryItem::getFavIcon() { + return m_favIcon; + } -tools::BrowserImagePtr HistoryItem::getThumbnail() const -{ + void HistoryItem::setThumbnail(tools::BrowserImagePtr thumbnail) + { + m_thumbnail = thumbnail; + }; - return m_thumbnail; -}; + tools::BrowserImagePtr HistoryItem::getThumbnail()const + { + return m_thumbnail; + }; -void HistoryItem::setUriFavicon(const std::string & uri) { - m_urifavicon = uri; -} + void HistoryItem::setUriFavicon(const std::string & uri) + { + m_urifavicon = uri; + } -std::string HistoryItem::getUriFavicon() { - return m_urifavicon; -} + std::string HistoryItem::getUriFavicon() { + return m_urifavicon; + } -} + } } diff --git a/services/HistoryService/HistoryItem.h b/services/HistoryService/HistoryItem.h index a76eba68..a76eba68 100644..100755 --- a/services/HistoryService/HistoryItem.h +++ b/services/HistoryService/HistoryItem.h diff --git a/services/HistoryService/HistoryItemTypedef.h b/services/HistoryService/HistoryItemTypedef.h index 91aa0b2e..91aa0b2e 100644..100755 --- a/services/HistoryService/HistoryItemTypedef.h +++ b/services/HistoryService/HistoryItemTypedef.h diff --git a/services/HistoryService/HistoryService.cpp b/services/HistoryService/HistoryService.cpp index d1085e12..310d5770 100755 --- a/services/HistoryService/HistoryService.cpp +++ b/services/HistoryService/HistoryService.cpp @@ -35,545 +35,608 @@ namespace tizen_browser { -namespace services -{ - -EXPORT_SERVICE(HistoryService, DOMAIN_HISTORY_SERVICE) + namespace services + { -const int SEARCH_LIKE = 1; + EXPORT_SERVICE(HistoryService, DOMAIN_HISTORY_SERVICE) -HistoryService::HistoryService() : m_testDbMod(false) -{ - BROWSER_LOGD("HistoryService"); -} + const int SEARCH_LIKE = 1; -HistoryService::~HistoryService() -{ -} - -void HistoryService::setStorageServiceTestMode(bool testmode) { - m_testDbMod = testmode; -} - -void HistoryService::errorPrint(std::string method) const -{ - int error_code = bp_history_adaptor_get_errorcode(); - BROWSER_LOGE("[%s:%d] %s error: %d (%s)", __PRETTY_FUNCTION__, __LINE__, - method.c_str(), error_code, - tools::capiWebError::historyErrorToString(error_code).c_str()); -} - -int HistoryService::getHistoryItemsCount(){ - int *ids = nullptr; - int count=0; - bp_history_rows_cond_fmt conds; - conds.limit = -1; //no of rows to get negative means no limitation - conds.offset = -1; //the first row's index - conds.order_offset =BP_HISTORY_O_DATE_CREATED; // property to sort - conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - conds.period_type = BP_HISTORY_DATE_TODAY; - if (bp_history_adaptor_get_cond_ids_p(&ids, &count, &conds, 0, nullptr, 0) - < 0) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); + HistoryService::HistoryService():m_testDbMod(false) + { + BROWSER_LOGD("HistoryService"); } - BROWSER_LOGD("[%s:%d] History Count %d", __PRETTY_FUNCTION__, __LINE__, count); - return count; -} - -bool HistoryService::isDuplicate(const char* url) const -{ - M_ASSERT(url); - int *ids=nullptr; - int count=0; - bp_history_rows_cond_fmt conds; - conds.limit = -1; //no of rows to get negative means no limitation - conds.offset = -1; //the first row's index - conds.order_offset =BP_HISTORY_O_DATE_CREATED; // property to sort - conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - conds.period_type = BP_HISTORY_DATE_TODAY; - if(bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0) < 0 ) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); + HistoryService::~HistoryService() + { } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_DATE_CREATED); - - for (int i = 0; i < count; i++) { - bp_history_info_fmt history_info; - if (bp_history_adaptor_get_info(ids[i], offset, &history_info) < 0) { - BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", - __PRETTY_FUNCTION__, __LINE__); - return false; - } - if (!history_info.url) { - BROWSER_LOGD("Warning: history entry without url!"); - } else if (!strcmp(history_info.url, url)) { - int freq; - bp_history_adaptor_get_frequency(ids[i], &freq); - bp_history_adaptor_set_frequency(ids[i], freq + 1); - bp_history_adaptor_set_date_visited(ids[i],-1); - bp_history_adaptor_easy_free(&history_info); - return true; - } - bp_history_adaptor_easy_free(&history_info); + void HistoryService::setStorageServiceTestMode(bool testmode) + { + m_testDbMod = testmode; } - return false; -} -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryAll() -{ - return getHistoryItems(BP_HISTORY_DATE_ALL); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryToday() -{ - return getHistoryItems(BP_HISTORY_DATE_TODAY); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryYesterday() -{ - return getHistoryItems(BP_HISTORY_DATE_YESTERDAY); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryLastWeek() -{ - return getHistoryItems(BP_HISTORY_DATE_LAST_7_DAYS); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryLastMonth() -{ - return getHistoryItems(BP_HISTORY_DATE_LAST_MONTH); -} -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryOlder() -{ - return getHistoryItems(BP_HISTORY_DATE_OLDER); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getMostVisitedHistoryItems() -{ - std::shared_ptr<HistoryItemVector> ret_history_list(new HistoryItemVector); - - int *ids=nullptr; - int count=-1; - bp_history_rows_cond_fmt conds; - conds.limit = 5; //no of rows to get negative means no limitation - conds.offset = -1; //the first row's index - conds.order_offset = BP_HISTORY_O_FREQUENCY; // property to sort - conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - //TODO: consider to change below line to BP_HISTORY_DATE_LAST_MONTH - conds.period_type = BP_HISTORY_DATE_ALL; // set from which period most visited sites are generated - - if(bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0) < 0 ) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); + void HistoryService::errorPrint(std::string method) const + { + int error_code = bp_history_adaptor_get_errorcode(); + BROWSER_LOGE("[%s:%d] %s error: %d (%s)", __PRETTY_FUNCTION__, + __LINE__, method.c_str(), error_code, + tools::capiWebError::historyErrorToString(error_code). + c_str()); } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FREQUENCY | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED | BP_HISTORY_O_THUMBNAIL); - - int freq_arr[1000] = {0, }; - for(int i = 0; i< count; i++){ - int freq; - if (0 == bp_history_adaptor_get_frequency(ids[i], &freq)) - { - freq_arr[i] = freq; - } + int HistoryService::getHistoryItemsCount() + { + int *ids = nullptr; + int count = 0; + bp_history_rows_cond_fmt conds; + conds.limit = -1; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_CREATED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_type = BP_HISTORY_DATE_TODAY; + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, 0, nullptr, 0) + < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + } + + BROWSER_LOGD("[%s:%d] History Count %d", __PRETTY_FUNCTION__, __LINE__, + count); + return count; } - int index_array[6] = {0, }; - int j=0; - int maximum = freq_arr[0]; - int position = 0; - - for(int k=1; k<=5;k++){ - if(k > count || count == 0) - break; - - maximum = freq_arr[0]; - position = 0; - - for(int i =1;i<count;i++){ - if (freq_arr[i] > maximum) - { - maximum = freq_arr[i]; - position = i; - } - } - index_array[j++] = position; - freq_arr[position] = -1; + bool HistoryService::isDuplicate(const char *url) const + { + M_ASSERT(url); + int *ids = nullptr; + int count = 0; + bp_history_rows_cond_fmt conds; + conds.limit = -1; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_CREATED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_type = BP_HISTORY_DATE_TODAY; + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, 0, nullptr, 0) < 0) + { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + } + + bp_history_offset offset = + (BP_HISTORY_O_URL | BP_HISTORY_O_DATE_CREATED); + + for (int i = 0; i < count; i++) { + bp_history_info_fmt history_info; + if (bp_history_adaptor_get_info(ids[i], offset, &history_info) < 0) { + BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", + __PRETTY_FUNCTION__, __LINE__); + return false; + } + if (!history_info.url) { + BROWSER_LOGD("Warning: history entry without url!"); + } else if (!strcmp(history_info.url, url)) { + int freq; + bp_history_adaptor_get_frequency(ids[i], &freq); + bp_history_adaptor_set_frequency(ids[i], freq + 1); + bp_history_adaptor_set_date_visited(ids[i], -1); + bp_history_adaptor_easy_free(&history_info); + return true; + } + bp_history_adaptor_easy_free(&history_info); + } + return false; } - for(int i = 0; i < j; i++){ - bp_history_info_fmt history_info; - if (bp_history_adaptor_get_info(ids[index_array[i]], offset, - &history_info) < 0) { - BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", - __PRETTY_FUNCTION__, __LINE__); - return ret_history_list; - } - - if (!history_info.url) { - BROWSER_LOGW("[%s:%d] history_info.url is empty! Wrong DB entry found! ", __PRETTY_FUNCTION__, __LINE__); - continue; - } - std::shared_ptr<HistoryItem> history = std::make_shared<HistoryItem>(ids[index_array[i]], std::string(history_info.url)); - history->setUrl(std::string(history_info.url)); - history->setTitle(std::string(history_info.title ? history_info.title : "")); - - //thumbnail - if (history_info.thumbnail_length != -1) { - tools::BrowserImagePtr hi = std::make_shared<tools::BrowserImage>( - history_info.thumbnail_width, - history_info.thumbnail_height, - history_info.thumbnail_length); - hi->setData((void*)history_info.thumbnail, false, tools::ImageType::ImageTypePNG); - history->setThumbnail(hi); - } else { - BROWSER_LOGD("history thumbnail lenght is -1"); - } - if(history_info.frequency > 0) - ret_history_list->push_back(history); - bp_history_adaptor_easy_free(&history_info); + std::shared_ptr < HistoryItemVector > HistoryService::getHistoryAll() { + return getHistoryItems(BP_HISTORY_DATE_ALL); } - free(ids); - return ret_history_list; -} - -void HistoryService::cleanMostVisitedHistoryItems() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int *ids=nullptr; - int count=-1; - bp_history_rows_cond_fmt conds; - conds.limit = -1; // no of rows to get negative means no limitation - conds.offset = -1; // the first row's index - conds.order_offset = BP_HISTORY_O_ALL; // property to sort - conds.ordering = 1; // way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - conds.period_type = BP_HISTORY_DATE_ALL; // set from which period most visited sites are generated - - if(bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0) < 0 ) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); - return; + std::shared_ptr < HistoryItemVector > HistoryService::getHistoryToday() { + return getHistoryItems(BP_HISTORY_DATE_TODAY); } - for(int i = 0; i < count; i++){ - bp_history_adaptor_set_frequency(ids[i], 0); + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryYesterday() { + return getHistoryItems(BP_HISTORY_DATE_YESTERDAY); } - BROWSER_LOGD("Deleted Most Visited Sites!"); -} -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryItemsByKeyword( - const std::string & keyword, int maxItems) -{ - std::string search("%" + keyword + "%"); // add SQL 'any character' signs - - std::shared_ptr<HistoryItemVector> items(new HistoryItemVector); - int *ids=nullptr; - int count=-1; - bp_history_rows_cond_fmt conds; - conds.limit = maxItems; //no of rows to get negative means no limitation - conds.offset = -1; //the first row's index - conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort - conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_VISITED; - conds.period_type = BP_HISTORY_DATE_ALL; - - if(bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, BP_HISTORY_O_URL, search.c_str(), SEARCH_LIKE) < 0) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); - return items; + std::shared_ptr < HistoryItemVector > HistoryService::getHistoryLastWeek() { + return getHistoryItems(BP_HISTORY_DATE_LAST_7_DAYS); } - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_DATE_VISITED); - for(int i = 0; i < count; i++) { - bp_history_info_fmt history_info; - if (bp_history_adaptor_get_info(ids[i], offset, &history_info) < 0) { - BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", - __PRETTY_FUNCTION__, __LINE__); - return items; - } - - if (!history_info.url) { - BROWSER_LOGW("[%s:%d] history_info.url is empty! Wrong DB entry found! ", __PRETTY_FUNCTION__, __LINE__); - continue; - } - std::shared_ptr<HistoryItem> history = std::make_shared<HistoryItem>(ids[i], std::string(history_info.url)); - history->setTitle(std::string(history_info.title ? history_info.title : "")); - - items->push_back(history); - bp_history_adaptor_easy_free(&history_info); + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryLastMonth() { + return getHistoryItems(BP_HISTORY_DATE_LAST_MONTH); } - - free(ids); - return items; -} - -void HistoryService::addHistoryItem(const std::string & url, - const std::string & title, - tools::BrowserImagePtr favicon) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (url.empty()) { - BROWSER_LOGW("[%s:%d] prevented writing empty history item!", __PRETTY_FUNCTION__, __LINE__); - return; + std::shared_ptr < HistoryItemVector > HistoryService::getHistoryOlder() { + return getHistoryItems(BP_HISTORY_DATE_OLDER); } - if (isDuplicate(url.c_str())) - return; - - int id = -1; - if(bp_history_adaptor_create(&id) < 0) { - errorPrint("bp_history_adaptor_create"); - } - if (bp_history_adaptor_set_url(id, url.c_str()) < 0) { - errorPrint("bp_history_adaptor_set_url"); - } - if (bp_history_adaptor_set_title(id, title.c_str()) < 0) { - errorPrint("bp_history_adaptor_set_title"); - } - if (bp_history_adaptor_set_date_visited(id,-1) < 0) { - errorPrint("bp_history_adaptor_set_date_visited"); - } - if (bp_history_adaptor_set_frequency(id, 1) < 0) { - errorPrint("bp_history_adaptor_set_frequency"); + std::shared_ptr < HistoryItemVector > + HistoryService::getMostVisitedHistoryItems() { + std::shared_ptr < HistoryItemVector > + ret_history_list(new HistoryItemVector); + + int *ids = nullptr; + int count = -1; + bp_history_rows_cond_fmt conds; + conds.limit = 5; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_FREQUENCY; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + //TODO: consider to change below line to BP_HISTORY_DATE_LAST_MONTH + conds.period_type = BP_HISTORY_DATE_ALL; // set from which period most visited sites are generated + + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, 0, nullptr, 0) < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + } + + bp_history_offset offset = + (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FREQUENCY | + BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_CREATED | + BP_HISTORY_O_THUMBNAIL); + + int freq_arr[1000] = { 0, }; + for (int i = 0; i < count; i++) { + int freq; + if (0 == bp_history_adaptor_get_frequency(ids[i], &freq)) { + freq_arr[i] = freq; + } + } + + int index_array[6] = { 0, }; + int j = 0; + int maximum = freq_arr[0]; + int position = 0; + + for (int k = 1; k <= 5; k++) { + if (k > count || count == 0) + break; + + maximum = freq_arr[0]; + position = 0; + + for (int i = 1; i < count; i++) { + if (freq_arr[i] > maximum) { + maximum = freq_arr[i]; + position = i; + } + } + index_array[j++] = position; + freq_arr[position] = -1; + } + + for (int i = 0; i < j; i++) { + bp_history_info_fmt history_info; + if (bp_history_adaptor_get_info(ids[index_array[i]], offset, + &history_info) < 0) { + BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", + __PRETTY_FUNCTION__, __LINE__); + return ret_history_list; + } + + if (!history_info.url) { + BROWSER_LOGW + ("[%s:%d] history_info.url is empty! Wrong DB entry found! ", + __PRETTY_FUNCTION__, __LINE__); + continue; + } + std::shared_ptr < HistoryItem > history = + std::make_shared < HistoryItem > (ids[index_array[i]], + std::string(history_info.url)); + history->setUrl(std::string(history_info.url)); + history-> + setTitle(std::string(history_info.title ? history_info.title : "")); + + //thumbnail + if (history_info.thumbnail_length != -1) { + tools::BrowserImagePtr hi = + std::make_shared < tools::BrowserImage > + (history_info.thumbnail_width, history_info.thumbnail_height, + history_info.thumbnail_length); + hi->setData((void *) history_info.thumbnail, false, + tools::ImageType::ImageTypePNG); + history->setThumbnail(hi); + } else { + BROWSER_LOGD("history thumbnail lenght is -1"); + } + if (history_info.frequency > 0) + ret_history_list->push_back(history); + bp_history_adaptor_easy_free(&history_info); + } + + free(ids); + return ret_history_list; } - if (favicon) { - std::unique_ptr<tools::Blob> favicon_blob = tools::EflTools::getBlobPNG(favicon); - if (!favicon_blob){ - BROWSER_LOGW("getBlobPNG failed"); - return; - } - unsigned char * fav = std::move((unsigned char*)favicon_blob->getData()); - if (bp_history_adaptor_set_icon(id, favicon->getWidth(), favicon->getHeight(), fav, favicon_blob->getLength()) < 0) { - errorPrint("bp_history_adaptor_set_icon"); - } + void HistoryService::cleanMostVisitedHistoryItems() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int *ids = nullptr; + int count = -1; + bp_history_rows_cond_fmt conds; + conds.limit = -1; // no of rows to get negative means no limitation + conds.offset = -1; // the first row's index + conds.order_offset = BP_HISTORY_O_ALL; // property to sort + conds.ordering = 1; // way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_type = BP_HISTORY_DATE_ALL; // set from which period most visited sites are generated + + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, 0, nullptr, 0) < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + return; + } + + for (int i = 0; i < count; i++) { + bp_history_adaptor_set_frequency(ids[i], 0); + } + BROWSER_LOGD("Deleted Most Visited Sites!"); } -} -void HistoryService::updateHistoryItemFavicon(const std::string & url, tools::BrowserImagePtr favicon) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - int id = getHistoryId(url); - if (id!=0) { - if (favicon) { - std::unique_ptr<tools::Blob> favicon_blob = tools::EflTools::getBlobPNG(favicon); - if (!favicon_blob){ - BROWSER_LOGW("getBlobPNG failed"); - return; - } - unsigned char * fav = std::move((unsigned char*)favicon_blob->getData()); - if (bp_history_adaptor_set_icon(id, favicon->getWidth(), favicon->getHeight(), fav, favicon_blob->getLength()) < 0) { - errorPrint("bp_history_adaptor_set_icon"); - } - } - } else { - BROWSER_LOGW("Cannot update favicon, there is no such history item!"); + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryItemsByKeyword(const std::string & keyword, + int maxItems) + { + std::string search("%" + keyword + "%"); // add SQL 'any character' signs + + std::shared_ptr < HistoryItemVector > items(new HistoryItemVector); + int *ids = nullptr; + int count = -1; + bp_history_rows_cond_fmt conds; + conds.limit = maxItems; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_VISITED; + conds.period_type = BP_HISTORY_DATE_ALL; + + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, BP_HISTORY_O_URL, search.c_str(), + SEARCH_LIKE) < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + return items; + } + + bp_history_offset offset = + (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_DATE_VISITED); + for (int i = 0; i < count; i++) { + bp_history_info_fmt history_info; + if (bp_history_adaptor_get_info(ids[i], offset, &history_info) < 0) { + BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", + __PRETTY_FUNCTION__, __LINE__); + return items; + } + + if (!history_info.url) { + BROWSER_LOGW + ("[%s:%d] history_info.url is empty! Wrong DB entry found! ", + __PRETTY_FUNCTION__, __LINE__); + continue; + } + std::shared_ptr < HistoryItem > history = + std::make_shared < HistoryItem > (ids[i], + std::string(history_info.url)); + history-> + setTitle(std::string(history_info.title ? history_info.title : "")); + + items->push_back(history); + bp_history_adaptor_easy_free(&history_info); + } + + free(ids); + return items; } -} -void HistoryService::updateHistoryItemSnapshot(const std::string & url, tools::BrowserImagePtr snapshot) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - int id = getHistoryId(url); - if (id != 0 && snapshot) { - std::unique_ptr<tools::Blob> snapshot_blob = tools::EflTools::getBlobPNG(snapshot); - if (!snapshot_blob){ - BROWSER_LOGW("getBlobPNG failed"); - return; - } - unsigned char * snap = std::move((unsigned char*)snapshot_blob->getData()); - if (bp_history_adaptor_set_snapshot(id, snapshot->getWidth(), snapshot->getHeight(), snap, - snapshot_blob->getLength()) < 0) - errorPrint("bp_history_adaptor_set_snapshot"); + void HistoryService::addHistoryItem(const std::string & url, + const std::string & title, + tools::BrowserImagePtr favicon) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (url.empty()) { + BROWSER_LOGW("[%s:%d] prevented writing empty history item!", + __PRETTY_FUNCTION__, __LINE__); + return; + } + + if (isDuplicate(url.c_str())) + return; + + int id = -1; + if (bp_history_adaptor_create(&id) < 0) { + errorPrint("bp_history_adaptor_create"); + } + if (bp_history_adaptor_set_url(id, url.c_str()) < 0) { + errorPrint("bp_history_adaptor_set_url"); + } + if (bp_history_adaptor_set_title(id, title.c_str()) < 0) { + errorPrint("bp_history_adaptor_set_title"); + } + if (bp_history_adaptor_set_date_visited(id, -1) < 0) { + errorPrint("bp_history_adaptor_set_date_visited"); + } + if (bp_history_adaptor_set_frequency(id, 1) < 0) { + errorPrint("bp_history_adaptor_set_frequency"); + } + + if (favicon) { + std::unique_ptr < tools::Blob > favicon_blob = + tools::EflTools::getBlobPNG(favicon); + if (!favicon_blob) { + BROWSER_LOGW("getBlobPNG failed"); + return; + } + unsigned char *fav = + std::move((unsigned char *) favicon_blob->getData()); + if (bp_history_adaptor_set_icon + (id, favicon->getWidth(), favicon->getHeight(), fav, + favicon_blob->getLength()) < 0) { + errorPrint("bp_history_adaptor_set_icon"); + } + } } -} - -void HistoryService::clearAllHistory() -{ - bp_history_adaptor_reset(); - history_list.clear(); - historyAllDeleted(); -} -int HistoryService::getHistoryId(const std::string & url) -{ - bp_history_rows_cond_fmt conds; - conds.limit = -1; - conds.offset = 0; - conds.order_offset = BP_HISTORY_O_DATE_CREATED; - conds.ordering = 0; - conds.period_offset = BP_HISTORY_O_DATE_CREATED; - conds.period_type = BP_HISTORY_DATE_ALL; - int *ids = nullptr; - int ids_count = 0; - if(bp_history_adaptor_get_cond_ids_p(&ids ,&ids_count, &conds, BP_HISTORY_O_URL, url.c_str(), 0) < 0) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); - } else if (ids_count != 0) { - int i = *ids; - free(ids); - return i; + void HistoryService::updateHistoryItemFavicon(const std::string & url, + tools:: + BrowserImagePtr favicon) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int id = getHistoryId(url); + if (id != 0) { + if (favicon) { + std::unique_ptr < tools::Blob > favicon_blob = + tools::EflTools::getBlobPNG(favicon); + if (!favicon_blob) { + BROWSER_LOGW("getBlobPNG failed"); + return; + } + unsigned char *fav = + std::move((unsigned char *) favicon_blob->getData()); + if (bp_history_adaptor_set_icon + (id, favicon->getWidth(), favicon->getHeight(), fav, + favicon_blob->getLength()) < 0) { + errorPrint("bp_history_adaptor_set_icon"); + } + } + } else { + BROWSER_LOGW("Cannot update favicon, there is no such history item!"); + } } - return 0; -} - -void HistoryService::clearURLHistory(const std::string & url) -{ - int id = getHistoryId(url); - if (id!=0) - bp_history_adaptor_delete(id); - if(0 == getHistoryItemsCount()) - historyEmpty(true); - historyDeleted(url); -} -void HistoryService::deleteHistoryItem(int id) { - if (bp_history_adaptor_delete(id) < 0) { - errorPrint("bp_history_adaptor_delete"); + void HistoryService::updateHistoryItemSnapshot(const std::string & url, + tools:: + BrowserImagePtr snapshot) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + int id = getHistoryId(url); + if (id != 0 && snapshot) { + std::unique_ptr < tools::Blob > snapshot_blob = + tools::EflTools::getBlobPNG(snapshot); + if (!snapshot_blob) { + BROWSER_LOGW("getBlobPNG failed"); + return; + } + unsigned char *snap = + std::move((unsigned char *) snapshot_blob->getData()); + if (bp_history_adaptor_set_snapshot + (id, snapshot->getWidth(), snapshot->getHeight(), snap, + snapshot_blob->getLength()) < 0) + errorPrint("bp_history_adaptor_set_snapshot"); + } } -} -std::shared_ptr<HistoryItem> HistoryService::getHistoryItem(int * ids, int idNumber) -{ - bp_history_offset offset = (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | BP_HISTORY_O_DATE_VISITED); - bp_history_info_fmt history_info; - if (bp_history_adaptor_get_info(ids[idNumber], offset, &history_info) < 0) { - BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", - __PRETTY_FUNCTION__, __LINE__); - return std::shared_ptr<HistoryItem>(); + void HistoryService::clearAllHistory() + { + bp_history_adaptor_reset(); + history_list.clear(); + historyAllDeleted(); } - if (!history_info.url) { - BROWSER_LOGW("[%s:%d] history_info.url is empty! Wrong DB entry found! ", __PRETTY_FUNCTION__, __LINE__); - return std::shared_ptr<HistoryItem>(); + int HistoryService::getHistoryId(const std::string & url) + { + bp_history_rows_cond_fmt conds; + conds.limit = -1; + conds.offset = 0; + conds.order_offset = BP_HISTORY_O_DATE_CREATED; + conds.ordering = 0; + conds.period_offset = BP_HISTORY_O_DATE_CREATED; + conds.period_type = BP_HISTORY_DATE_ALL; + int *ids = nullptr; + int ids_count = 0; + if (bp_history_adaptor_get_cond_ids_p + (&ids, &ids_count, &conds, BP_HISTORY_O_URL, url.c_str(), 0) < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + } else if (ids_count != 0) { + int i = *ids; + free(ids); + return i; + } + return 0; } - int date; - bp_history_adaptor_get_date_created(ids[idNumber], &date); - - time_t item_time = (time_t) date; - struct tm item_time_info; - if (gmtime_r(&item_time,&item_time_info) == NULL) { - BROWSER_LOGE("[%s:%d] History localtime_r error ", __PRETTY_FUNCTION__, __LINE__); - return std::shared_ptr<HistoryItem>(); + void HistoryService::clearURLHistory(const std::string & url) + { + int id = getHistoryId(url); + if (id != 0) + bp_history_adaptor_delete(id); + if (0 == getHistoryItemsCount()) + historyEmpty(true); + historyDeleted(url); } - int m_year = item_time_info.tm_year; - int m_month = item_time_info.tm_mon + 1; - int m_month_day = item_time_info.tm_mday; - int min = item_time_info.tm_min; - int hour = item_time_info.tm_hour; - int sec = item_time_info.tm_sec; - - m_year = 2000 + m_year % 100; - - std::shared_ptr<HistoryItem> history = std::make_shared <HistoryItem> (ids[idNumber], std::string(history_info.url)); - boost::gregorian::date d(m_year, m_month, m_month_day); - boost::posix_time::ptime t(d, boost::posix_time::time_duration(hour, min, sec)); - history->setLastVisit(t); - history->setUrl(std::string(history_info.url ? history_info.url : "")); - history->setTitle(std::string(history_info.title ? history_info.title : "")); - - tools::BrowserImagePtr thumbnail = std::make_shared<tools::BrowserImage>( - history_info.thumbnail_width, - history_info.thumbnail_height, - history_info.thumbnail_length); - thumbnail->setData((void*)history_info.thumbnail, false, tools::ImageType::ImageTypePNG); - tools::BrowserImagePtr favIcon = std::make_shared<tools::BrowserImage>( - history_info.favicon_width, - history_info.favicon_height, - history_info.favicon_length); - favIcon->setData((void*)history_info.favicon, false, tools::ImageType::ImageTypePNG); - history->setThumbnail(thumbnail); - history->setFavIcon(favIcon); - - bp_history_adaptor_easy_free(&history_info); - - return history; -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryItems(bp_history_date_defs period) -{ - std::shared_ptr<HistoryItemVector> ret_history_list(new HistoryItemVector); - - int *ids=nullptr; - int count=-1; - bp_history_rows_cond_fmt conds; - conds.limit = -1; //no of rows to get negative means no limitation - conds.offset = -1; //the first row's index - conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort - conds.ordering = 1; //way of ordering 0 asc 1 desc - conds.period_offset = BP_HISTORY_O_DATE_VISITED; - conds.period_type = period; - - if(bp_history_adaptor_get_cond_ids_p(&ids ,&count, &conds, 0, nullptr, 0) < 0) { - errorPrint("bp_history_adaptor_get_cond_ids_p"); + void HistoryService::deleteHistoryItem(int id) + { + if (bp_history_adaptor_delete(id) < 0) { + errorPrint("bp_history_adaptor_delete"); + } } - for(int i = 0; i< count; i++) { - std::shared_ptr<HistoryItem> item = getHistoryItem(ids, i); - if (!item) - BROWSER_LOGW("[%s:%d] empty history item! ", __PRETTY_FUNCTION__, __LINE__); - else - ret_history_list->push_back(item); + std::shared_ptr < HistoryItem > HistoryService::getHistoryItem(int *ids, + int + idNumber) + { + bp_history_offset offset = + (BP_HISTORY_O_URL | BP_HISTORY_O_TITLE | BP_HISTORY_O_FAVICON | + BP_HISTORY_O_DATE_VISITED); + bp_history_info_fmt history_info; + if (bp_history_adaptor_get_info(ids[idNumber], offset, &history_info) < + 0) { + BROWSER_LOGE("[%s:%d] bp_history_adaptor_get_info error ", + __PRETTY_FUNCTION__, __LINE__); + return std::shared_ptr < HistoryItem > (); + } + + if (!history_info.url) { + BROWSER_LOGW + ("[%s:%d] history_info.url is empty! Wrong DB entry found! ", + __PRETTY_FUNCTION__, __LINE__); + return std::shared_ptr < HistoryItem > (); + } + + int date; + bp_history_adaptor_get_date_created(ids[idNumber], &date); + + time_t item_time = (time_t) date; + struct tm item_time_info; + if (gmtime_r(&item_time, &item_time_info) == NULL) { + BROWSER_LOGE("[%s:%d] History localtime_r error ", + __PRETTY_FUNCTION__, __LINE__); + return std::shared_ptr < HistoryItem > (); + } + + int m_year = item_time_info.tm_year; + int m_month = item_time_info.tm_mon + 1; + int m_month_day = item_time_info.tm_mday; + int min = item_time_info.tm_min; + int hour = item_time_info.tm_hour; + int sec = item_time_info.tm_sec; + + m_year = 2000 + m_year % 100; + + std::shared_ptr < HistoryItem > history = + std::make_shared < HistoryItem > (ids[idNumber], + std::string(history_info.url)); + boost::gregorian::date d(m_year, m_month, m_month_day); + boost::posix_time::ptime t(d, + boost::posix_time::time_duration(hour, min, + sec)); + history->setLastVisit(t); + history->setUrl(std::string(history_info.url ? history_info.url : "")); + history-> + setTitle(std::string(history_info.title ? history_info.title : "")); + + tools::BrowserImagePtr thumbnail = + std::make_shared < tools::BrowserImage > + (history_info.thumbnail_width, history_info.thumbnail_height, + history_info.thumbnail_length); + thumbnail->setData((void *) history_info.thumbnail, false, + tools::ImageType::ImageTypePNG); + tools::BrowserImagePtr favIcon = + std::make_shared < tools::BrowserImage > (history_info.favicon_width, + history_info.favicon_height, + history_info. + favicon_length); + favIcon->setData((void *) history_info.favicon, false, + tools::ImageType::ImageTypePNG); + history->setThumbnail(thumbnail); + history->setFavIcon(favIcon); + + bp_history_adaptor_easy_free(&history_info); + + return history; } - free(ids); - return ret_history_list; -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryItemsByURL( - const std::string& url, int maxItems) -{ - return getHistoryItemsByKeyword(tools::extractDomain(url), maxItems); -} - -std::shared_ptr<HistoryItemVector> HistoryService::getHistoryItemsByKeywordsString( - const std::string& keywordsString, const int maxItems, - const unsigned int minKeywordLength, bool uniqueUrls) -{ - if (keywordsString.empty()) - return std::make_shared<HistoryItemVector>(); - - std::vector<std::string> keywords; - tools::string_tools::splitString(keywordsString, keywords); - // the longer the keyword is, the faster search will be - const unsigned longestKeywordPos = tools::string_tools::getLongest(keywords); - std::string longestKeyword = keywords.at(longestKeywordPos); - boost::algorithm::to_lower(longestKeyword); - - // assumption: search starts when longest keyword is at least - // minKeywordLength characters long - if (longestKeyword.length() < minKeywordLength) { - return std::make_shared<HistoryItemVector>(); + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryItems(bp_history_date_defs period) { + std::shared_ptr < HistoryItemVector > + ret_history_list(new HistoryItemVector); + + int *ids = nullptr; + int count = -1; + bp_history_rows_cond_fmt conds; + conds.limit = -1; //no of rows to get negative means no limitation + conds.offset = -1; //the first row's index + conds.order_offset = BP_HISTORY_O_DATE_VISITED; // property to sort + conds.ordering = 1; //way of ordering 0 asc 1 desc + conds.period_offset = BP_HISTORY_O_DATE_VISITED; + conds.period_type = period; + + if (bp_history_adaptor_get_cond_ids_p + (&ids, &count, &conds, 0, nullptr, 0) < 0) { + errorPrint("bp_history_adaptor_get_cond_ids_p"); + } + + for (int i = 0; i < count; i++) { + std::shared_ptr < HistoryItem > item = getHistoryItem(ids, i); + if (!item) + BROWSER_LOGW("[%s:%d] empty history item! ", __PRETTY_FUNCTION__, + __LINE__); + else + ret_history_list->push_back(item); + } + free(ids); + return ret_history_list; } - // get all results for the longest keyword - std::shared_ptr<HistoryItemVector> historyItems = getHistoryItemsByKeyword( - longestKeyword, -1); - - if (keywords.size() > 1) { - // longestKeywordPos is already handled - keywords.erase(keywords.begin() + longestKeywordPos); - tools::string_tools::downcase(keywords); - removeMismatches(historyItems, keywords); + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryItemsByURL(const std::string & url, + int maxItems) { + return getHistoryItemsByKeyword(tools::extractDomain(url), maxItems); } - if (maxItems != -1) { - if (historyItems->size() > static_cast<unsigned int>(maxItems)) { - historyItems->erase(historyItems->begin() + maxItems, - historyItems->end()); - } + std::shared_ptr < HistoryItemVector > + HistoryService::getHistoryItemsByKeywordsString(const std:: + string & keywordsString, + const int maxItems, + const unsigned int + minKeywordLength, + bool uniqueUrls) { + if (keywordsString.empty()) + return std::make_shared < HistoryItemVector > (); + + std::vector < std::string > keywords; + tools::string_tools::splitString(keywordsString, keywords); + + // the longer the keyword is, the faster search will be + const unsigned longestKeywordPos = + tools::string_tools::getLongest(keywords); + std::string longestKeyword = keywords.at(longestKeywordPos); + boost::algorithm::to_lower(longestKeyword); + + // assumption: search starts when longest keyword is at least + // minKeywordLength characters long + if (longestKeyword.length() < minKeywordLength) { + return std::make_shared < HistoryItemVector > (); + } + // get all results for the longest keyword + std::shared_ptr < HistoryItemVector > historyItems = + getHistoryItemsByKeyword(longestKeyword, -1); + + if (keywords.size() > 1) { + // longestKeywordPos is already handled + keywords.erase(keywords.begin() + longestKeywordPos); + tools::string_tools::downcase(keywords); + removeMismatches(historyItems, keywords); + } + + if (maxItems != -1) { + if (historyItems->size() > static_cast < unsigned int >(maxItems)) { + historyItems->erase(historyItems->begin() + maxItems, + historyItems->end()); + } + } + + if (uniqueUrls) + removeUrlDuplicates(historyItems); + return historyItems; } - if (uniqueUrls) - removeUrlDuplicates(historyItems); - return historyItems; -} - -} + } } diff --git a/services/HistoryService/HistoryService.h b/services/HistoryService/HistoryService.h index 83b24f02..51034949 100644..100755 --- a/services/HistoryService/HistoryService.h +++ b/services/HistoryService/HistoryService.h @@ -89,9 +89,9 @@ public: int getHistoryItemsCount(); void setStorageServiceTestMode(bool testmode = true); - boost::signals2::signal<void (bool)>historyEmpty; - boost::signals2::signal<void (const std::string& uri)> historyDeleted; - boost::signals2::signal<void ()> historyAllDeleted; + boost::signals2::signal<void(bool)>historyEmpty; + boost::signals2::signal<void(const std::string& uri)> historyDeleted; + boost::signals2::signal<void()> historyAllDeleted; private: bool m_testDbMod;; diff --git a/services/HistoryService/HistoryServiceTools.cpp b/services/HistoryService/HistoryServiceTools.cpp index 020742cb..020742cb 100644..100755 --- a/services/HistoryService/HistoryServiceTools.cpp +++ b/services/HistoryService/HistoryServiceTools.cpp diff --git a/services/HistoryService/HistoryServiceTools.h b/services/HistoryService/HistoryServiceTools.h index d2370b17..d2370b17 100644..100755 --- a/services/HistoryService/HistoryServiceTools.h +++ b/services/HistoryService/HistoryServiceTools.h diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDayItemData.h b/services/HistoryUI/HistoryDaysListManager/HistoryDayItemData.h index 595eb2e4..595eb2e4 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDayItemData.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDayItemData.h diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDayItemDataTypedef.h b/services/HistoryUI/HistoryDaysListManager/HistoryDayItemDataTypedef.h index ab2b4945..ab2b4945 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDayItemDataTypedef.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDayItemDataTypedef.h diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManager.h b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManager.h index adf93bbb..ef98cde0 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManager.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManager.h @@ -39,8 +39,8 @@ public: // clear everything including efl objects (result: empty list) virtual void clear() = 0; virtual void setFocusChain(Evas_Object* obj) = 0; - boost::signals2::signal<void (std::string url, std::string title)> signalHistoryItemClicked; - boost::signals2::signal<void (std::shared_ptr<const std::vector<int>> itemIds)> signalDeleteHistoryItems; + boost::signals2::signal<void(std::string url, std::string title)> signalHistoryItemClicked; + boost::signals2::signal<void(std::shared_ptr<const std::vector<int>> itemIds)> signalDeleteHistoryItems; }; } diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerEdje.h b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerEdje.h index 39555aba..39555aba 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerEdje.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerEdje.h diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.cpp b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.cpp index c7983512..12d97626 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.cpp +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.cpp @@ -28,249 +28,270 @@ #include <GeneralTools.h> #include <EflTools.h> -namespace tizen_browser { -namespace base_ui { +namespace tizen_browser +{ + namespace base_ui + { -HistoryDaysListManagerMob::HistoryDaysListManagerMob() - : m_edjeFiles(std::make_shared<HistoryDaysListManagerEdje>()) + HistoryDaysListManagerMob::HistoryDaysListManagerMob() + :m_edjeFiles(std::make_shared < HistoryDaysListManagerEdje > ()) , m_parent(nullptr) , m_scrollerDays(nullptr) , m_layoutScrollerDays(nullptr) , m_boxDays(nullptr) -{ - connectSignals(); -} - -HistoryDaysListManagerMob::~HistoryDaysListManagerMob() -{ - for (auto& dayItem : m_dayItems) - dayItem->setEflObjectsAsDeleted(); -} + { + connectSignals(); + } -Evas_Object* HistoryDaysListManagerMob::createDaysList( - Evas_Object* parent) -{ - m_parent = parent; - m_scrollerDays = elm_scroller_add(parent); - tools::EflTools::setExpandHints(m_scrollerDays); - - m_layoutScrollerDays = elm_layout_add(parent); - evas_object_size_hint_weight_set(m_layoutScrollerDays, EVAS_HINT_EXPAND, - 0.0); - evas_object_size_hint_align_set(m_layoutScrollerDays, EVAS_HINT_FILL, 0.0); - elm_layout_file_set(m_layoutScrollerDays, - m_edjeFiles->historyDaysList.c_str(), "layoutScrollerDays"); - - elm_object_content_set(m_scrollerDays, m_layoutScrollerDays); - - m_boxDays = elm_box_add(m_layoutScrollerDays); - tools::EflTools::setExpandHints(m_boxDays); - elm_box_horizontal_set(m_boxDays, EINA_FALSE); - elm_object_part_content_set(m_layoutScrollerDays, "boxDays", - m_boxDays); - - return m_scrollerDays; -} - -void HistoryDaysListManagerMob::addHistoryItems( - const std::map<std::string, services::HistoryItemVector>& items, - HistoryPeriod period) -{ - std::vector<WebsiteHistoryItemDataPtr> historyItems; - for (auto& itemPair : items) { - std::vector<WebsiteVisitItemDataPtr> pageViewItems; - std::shared_ptr<tools::BrowserImage> websiteFavicon = nullptr; - for (auto& hi : itemPair.second) { - pageViewItems.push_back( - std::make_shared<WebsiteVisitItemData>(hi)); - if (!websiteFavicon && hi->getFavIcon()->getSize() > 0) - websiteFavicon = hi->getFavIcon(); - } - historyItems.push_back( - std::make_shared<WebsiteHistoryItemData> - (itemPair.first, itemPair.first, websiteFavicon, pageViewItems)); + HistoryDaysListManagerMob::~HistoryDaysListManagerMob() + { + for (auto & dayItem:m_dayItems) + dayItem->setEflObjectsAsDeleted(); } - sortDayItems(historyItems); - HistoryDayItemDataPtr dayItem = std::make_shared < HistoryDayItemData - > (toString(period), historyItems); - appendDayItem(dayItem); - showNoHistoryMessage(isHistoryDayListEmpty()); -} + Evas_Object *HistoryDaysListManagerMob::createDaysList(Evas_Object * + parent) + { + m_parent = parent; + m_scrollerDays = elm_scroller_add(parent); + tools::EflTools::setExpandHints(m_scrollerDays); + + m_layoutScrollerDays = elm_layout_add(parent); + evas_object_size_hint_weight_set(m_layoutScrollerDays, EVAS_HINT_EXPAND, + 0.0); + evas_object_size_hint_align_set(m_layoutScrollerDays, EVAS_HINT_FILL, + 0.0); + elm_layout_file_set(m_layoutScrollerDays, + m_edjeFiles->historyDaysList.c_str(), + "layoutScrollerDays"); + + elm_object_content_set(m_scrollerDays, m_layoutScrollerDays); + + m_boxDays = elm_box_add(m_layoutScrollerDays); + tools::EflTools::setExpandHints(m_boxDays); + elm_box_horizontal_set(m_boxDays, EINA_FALSE); + elm_object_part_content_set(m_layoutScrollerDays, "boxDays", m_boxDays); + + return m_scrollerDays; + } -void HistoryDaysListManagerMob::sortDayItems(std::vector<WebsiteHistoryItemDataPtr>& historyItems) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - std::vector<std::pair<time_t, WebsiteHistoryItemDataPtr>> sitesWithTime; - - for(auto& domainGroup : historyItems) { - time_t lastVisitTime = 0; - - // Get time determinant from multiple URLs inside one domain group - std::vector<WebsiteVisitItemDataPtr> visitedURLs = domainGroup->websiteVisitItems; - for(auto& item : visitedURLs) { - time_t visitTime = item->historyItem->getLastVisitAsTimeT(); - if(visitTime > lastVisitTime) - lastVisitTime = visitTime; - } - auto pair = std::make_pair(lastVisitTime, domainGroup); - sitesWithTime.push_back(pair); + void HistoryDaysListManagerMob::addHistoryItems(const std::map < + std::string, + services:: + HistoryItemVector > + &items, + HistoryPeriod period) + { + std::vector < WebsiteHistoryItemDataPtr > historyItems; + for (auto & itemPair:items) { + std::vector < WebsiteVisitItemDataPtr > pageViewItems; + std::shared_ptr < tools::BrowserImage > websiteFavicon = nullptr; + for (auto & hi:itemPair.second) { + pageViewItems.push_back(std::make_shared < WebsiteVisitItemData > + (hi)); + if (!websiteFavicon && hi->getFavIcon()->getSize() > 0) + websiteFavicon = hi->getFavIcon(); + } + historyItems.push_back(std::make_shared < WebsiteHistoryItemData > + (itemPair.first, itemPair.first, + websiteFavicon, pageViewItems)); + } + + sortDayItems(historyItems); + HistoryDayItemDataPtr dayItem = std::make_shared < HistoryDayItemData + > (toString(period), historyItems); + appendDayItem(dayItem); + showNoHistoryMessage(isHistoryDayListEmpty()); } - // time descending order - std::sort(sitesWithTime.begin(), sitesWithTime.end(), []( - const std::pair<time_t, WebsiteHistoryItemDataPtr>& lhs, - const std::pair<time_t, WebsiteHistoryItemDataPtr>& rhs){ - return lhs.first > rhs.first; - }); + void HistoryDaysListManagerMob::sortDayItems(std::vector < + WebsiteHistoryItemDataPtr > + &historyItems) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + std::vector < std::pair < time_t, + WebsiteHistoryItemDataPtr >> sitesWithTime; + + for (auto & domainGroup:historyItems) { + time_t lastVisitTime = 0; + + // Get time determinant from multiple URLs inside one domain group + std::vector < WebsiteVisitItemDataPtr > visitedURLs = + domainGroup->websiteVisitItems; + for (auto & item:visitedURLs) { + time_t visitTime = item->historyItem->getLastVisitAsTimeT(); + if (visitTime > lastVisitTime) + lastVisitTime = visitTime; + } + auto pair = std::make_pair(lastVisitTime, domainGroup); + sitesWithTime.push_back(pair); + } + + // time descending order + std::sort(sitesWithTime.begin(), sitesWithTime.end(), + [](const std::pair < time_t, WebsiteHistoryItemDataPtr > &lhs, + const std::pair < time_t, + WebsiteHistoryItemDataPtr > &rhs) { + return lhs.first > rhs.first;}); + + historyItems.clear(); + for (auto & item:sitesWithTime) { + historyItems.push_back(item.second); + } + } - historyItems.clear(); - for(auto& item : sitesWithTime) { - historyItems.push_back(item.second); + void HistoryDaysListManagerMob::clear() + { + elm_box_clear(m_boxDays); + m_dayItems.clear(); + showNoHistoryMessage(isHistoryDayListEmpty()); } -} -void HistoryDaysListManagerMob::clear() -{ - elm_box_clear(m_boxDays); - m_dayItems.clear(); - showNoHistoryMessage(isHistoryDayListEmpty()); -} + HistoryDayItemMobPtr HistoryDaysListManagerMob:: + getItem(HistoryDayItemDataPtrConst historyDayItemData) + { + for (auto & historyDayItem:m_dayItems) { + if (historyDayItem->getData() == historyDayItemData) + return historyDayItem; + } + return nullptr; + } -HistoryDayItemMobPtr HistoryDaysListManagerMob::getItem( - HistoryDayItemDataPtrConst historyDayItemData) -{ - for (auto& historyDayItem : m_dayItems) { - if (historyDayItem->getData() == historyDayItemData) - return historyDayItem; + void HistoryDaysListManagerMob::connectSignals() + { + HistoryDayItemMob::signaButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerMob:: + onHistoryDayItemButtonClicked, this, _1, _2)); + WebsiteHistoryItemTitleMob::signalButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerMob::onWebsiteHistoryItemClicked, + this, _1, _2)); + WebsiteHistoryItemVisitItemsMob::signalButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerMob:: + onWebsiteHistoryItemVisitItemClicked, this, _1, _2)); } - return nullptr; -} -void HistoryDaysListManagerMob::connectSignals() -{ - HistoryDayItemMob::signaButtonClicked.connect( - boost::bind(&HistoryDaysListManagerMob::onHistoryDayItemButtonClicked, - this, _1, _2)); - WebsiteHistoryItemTitleMob::signalButtonClicked.connect( - boost::bind(&HistoryDaysListManagerMob::onWebsiteHistoryItemClicked, - this, _1, _2)); - WebsiteHistoryItemVisitItemsMob::signalButtonClicked.connect( - boost::bind( - &HistoryDaysListManagerMob::onWebsiteHistoryItemVisitItemClicked, - this, _1, _2)); -} - - -void HistoryDaysListManagerMob::appendDayItem(HistoryDayItemDataPtr dayItemData) -{ - auto item = std::make_shared<HistoryDayItemMob>(dayItemData); - m_dayItems.push_back(item); - Evas_Object* dayItemLayout = item->init(m_parent, m_edjeFiles); - elm_box_pack_end(m_boxDays, dayItemLayout); -} + void HistoryDaysListManagerMob:: + appendDayItem(HistoryDayItemDataPtr dayItemData) + { + auto item = std::make_shared < HistoryDayItemMob > (dayItemData); + m_dayItems.push_back(item); -void HistoryDaysListManagerMob::showNoHistoryMessage(bool show) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (show) - elm_object_signal_emit(m_layoutScrollerDays, "show_empty_message", "ui"); - else - elm_object_signal_emit(m_layoutScrollerDays, "hide_empty_message", "ui"); -} - -void HistoryDaysListManagerMob::onHistoryDayItemButtonClicked( - const HistoryDayItemDataPtrConst clickedItem, bool remove) -{ - if (remove) - removeItem(clickedItem); -} + Evas_Object *dayItemLayout = item->init(m_parent, m_edjeFiles); + elm_box_pack_end(m_boxDays, dayItemLayout); + } -void HistoryDaysListManagerMob::onWebsiteHistoryItemClicked( - const WebsiteHistoryItemDataPtrConst clickedItem, bool remove) -{ - if (remove) - removeItem(clickedItem); - else - signalHistoryItemClicked( - tools::PROTOCOL_DEFAULT + clickedItem->websiteDomain, - clickedItem->websiteTitle); -} - -void HistoryDaysListManagerMob::onWebsiteHistoryItemVisitItemClicked( - const WebsiteVisitItemDataPtrConst clickedItem, bool remove) -{ - if (remove) { - removeItem(clickedItem); - signalDeleteHistoryItems( - std::make_shared<std::vector<int>>(std::initializer_list<int> { - clickedItem->historyItem->getId() })); - } else - signalHistoryItemClicked(clickedItem->historyItem->getUrl(), - clickedItem->historyItem->getTitle()); -} - -void HistoryDaysListManagerMob::removeItem( - HistoryDayItemDataPtrConst historyDayItemData) -{ - if (!historyDayItemData) { - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); - return; + void HistoryDaysListManagerMob::showNoHistoryMessage(bool show) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (show) + elm_object_signal_emit(m_layoutScrollerDays, "show_empty_message", + "ui"); + else + elm_object_signal_emit(m_layoutScrollerDays, "hide_empty_message", + "ui"); } - auto item = getItem(historyDayItemData); - if (!item) - return; - // remove day item from vector, destructor will clear efl objects - remove(item); - elm_box_unpack(m_boxDays, item->getLayoutMain()); - showNoHistoryMessage(isHistoryDayListEmpty()); -} - -void HistoryDaysListManagerMob::removeItem( - WebsiteHistoryItemDataPtrConst websiteHistoryItemData) -{ - if (!websiteHistoryItemData) { - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); - return; + + void HistoryDaysListManagerMob:: + onHistoryDayItemButtonClicked(const HistoryDayItemDataPtrConst + clickedItem, bool remove) + { + if (remove) + removeItem(clickedItem); } - for (auto& dayItem : m_dayItems) { - auto websiteHistoryItem = dayItem->getItem(websiteHistoryItemData); - if (websiteHistoryItem) { - signalDeleteHistoryItems(websiteHistoryItem->getVisitItemsIds()); - dayItem->removeItem(websiteHistoryItemData); - return; - } + + void HistoryDaysListManagerMob:: + onWebsiteHistoryItemClicked(const WebsiteHistoryItemDataPtrConst + clickedItem, bool remove) + { + if (remove) + removeItem(clickedItem); + else + signalHistoryItemClicked(tools::PROTOCOL_DEFAULT + + clickedItem->websiteDomain, + clickedItem->websiteTitle); } -} -void HistoryDaysListManagerMob::removeItem( - WebsiteVisitItemDataPtrConst websiteVisitItemData) -{ - if (!websiteVisitItemData) { - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); - return; + void HistoryDaysListManagerMob:: + onWebsiteHistoryItemVisitItemClicked(const WebsiteVisitItemDataPtrConst + clickedItem, bool remove) + { + if (remove) { + removeItem(clickedItem); + signalDeleteHistoryItems(std::make_shared < std::vector < + int >>(std::initializer_list < int > + { + clickedItem->historyItem->getId()})); + } else { + signalHistoryItemClicked(clickedItem->historyItem->getUrl(), + clickedItem->historyItem->getTitle()); + } } - for (auto& dayItem : m_dayItems) { - if (dayItem->getItem(websiteVisitItemData)) { - dayItem->removeItem(websiteVisitItemData); - return; - } + + void HistoryDaysListManagerMob:: + removeItem(HistoryDayItemDataPtrConst historyDayItemData) + { + if (!historyDayItemData) { + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); + return; + } + auto item = getItem(historyDayItemData); + if (!item) + return; + // remove day item from vector, destructor will clear efl objects + remove(item); + elm_box_unpack(m_boxDays, item->getLayoutMain()); + showNoHistoryMessage(isHistoryDayListEmpty()); } -} -void HistoryDaysListManagerMob::remove(HistoryDayItemMobPtr historyDayItem) -{ - for (auto it = m_dayItems.begin(); it != m_dayItems.end();) { - if ((*it) == historyDayItem) { - m_dayItems.erase(it); - return; - } else { - ++it; - } + void HistoryDaysListManagerMob:: + removeItem(WebsiteHistoryItemDataPtrConst websiteHistoryItemData) + { + if (!websiteHistoryItemData) { + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); + return; + } + for (auto & dayItem:m_dayItems) { + auto websiteHistoryItem = dayItem->getItem(websiteHistoryItemData); + if (websiteHistoryItem) { + signalDeleteHistoryItems(websiteHistoryItem->getVisitItemsIds()); + dayItem->removeItem(websiteHistoryItemData); + return; + } + } + } + + void HistoryDaysListManagerMob:: + removeItem(WebsiteVisitItemDataPtrConst websiteVisitItemData) + { + if (!websiteVisitItemData) { + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); + return; + } + for (auto & dayItem:m_dayItems) { + if (dayItem->getItem(websiteVisitItemData)) { + dayItem->removeItem(websiteVisitItemData); + return; + } + } + } + + void HistoryDaysListManagerMob:: + remove(HistoryDayItemMobPtr historyDayItem) + { + for (auto it = m_dayItems.begin(); it != m_dayItems.end();) { + if ((*it) == historyDayItem) { + m_dayItems.erase(it); + return; + } else { + ++it; + } + } } -} -} /* namespace base_ui */ -} /* namespace tizen_browser */ + } /* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.h b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.h index 1c9e73b7..1c9e73b7 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerMob.h diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.cpp b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.cpp index cffa41d5..5f6d7254 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.cpp +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.cpp @@ -29,233 +29,255 @@ #include <GeneralTools.h> #include <EflTools.h> -namespace tizen_browser { -namespace base_ui { +namespace tizen_browser +{ + namespace base_ui + { -HistoryDaysListManagerTv::HistoryDaysListManagerTv(HistoryDeleteManagerPtrConst deleteManager) - : m_edjeFiles(std::make_shared<HistoryDaysListManagerEdje>()) + HistoryDaysListManagerTv:: + HistoryDaysListManagerTv(HistoryDeleteManagerPtrConst deleteManager) + :m_edjeFiles(std::make_shared < HistoryDaysListManagerEdje > ()) , m_scrollerDaysColumns(nullptr) , m_layoutScrollerDaysColumns(nullptr) , m_boxDaysColumns(nullptr) , m_historyDeleteManager(deleteManager) -{ - connectSignals(); -} - -HistoryDaysListManagerTv::~HistoryDaysListManagerTv() -{ - for (auto& dayItem : m_dayItems) - dayItem->setEflObjectsAsDeleted(); -} - -Evas_Object* HistoryDaysListManagerTv::createDaysList(Evas_Object* parent) -{ - m_scrollerDaysColumns = elm_scroller_add(parent); - elm_scroller_bounce_set(m_scrollerDaysColumns, EINA_FALSE, EINA_FALSE); - tools::EflTools::setExpandHints(m_scrollerDaysColumns); - elm_scroller_policy_set(m_scrollerDaysColumns, ELM_SCROLLER_POLICY_OFF, - ELM_SCROLLER_POLICY_OFF); - elm_scroller_movement_block_set(m_scrollerDaysColumns, - ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL); + { + connectSignals(); + } - m_layoutScrollerDaysColumns = elm_layout_add(parent); - tools::EflTools::setExpandHints(m_layoutScrollerDaysColumns); - elm_layout_file_set(m_layoutScrollerDaysColumns, - m_edjeFiles->historyDaysList.c_str(), "historyDaysList"); + HistoryDaysListManagerTv::~HistoryDaysListManagerTv() + { + for (auto & dayItem:m_dayItems) + dayItem->setEflObjectsAsDeleted(); + } - elm_object_content_set(m_scrollerDaysColumns, m_layoutScrollerDaysColumns); + Evas_Object *HistoryDaysListManagerTv::createDaysList(Evas_Object * + parent) + { + m_scrollerDaysColumns = elm_scroller_add(parent); + elm_scroller_bounce_set(m_scrollerDaysColumns, EINA_FALSE, EINA_FALSE); + tools::EflTools::setExpandHints(m_scrollerDaysColumns); + elm_scroller_policy_set(m_scrollerDaysColumns, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + elm_scroller_movement_block_set(m_scrollerDaysColumns, + ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL); - m_boxDaysColumns = elm_box_add(parent); - tools::EflTools::setExpandHints(m_boxDaysColumns); - elm_box_horizontal_set(m_boxDaysColumns, EINA_TRUE); - elm_object_part_content_set(m_layoutScrollerDaysColumns, "daysColumns", - m_boxDaysColumns); - elm_box_padding_set(m_boxDaysColumns, 65, 0.0); + m_layoutScrollerDaysColumns = elm_layout_add(parent); + tools::EflTools::setExpandHints(m_layoutScrollerDaysColumns); + elm_layout_file_set(m_layoutScrollerDaysColumns, + m_edjeFiles->historyDaysList.c_str(), + "historyDaysList"); - return m_scrollerDaysColumns; -} + elm_object_content_set(m_scrollerDaysColumns, + m_layoutScrollerDaysColumns); -void HistoryDaysListManagerTv::connectSignals() -{ - HistoryDayItemTv::signaButtonClicked.connect( - boost::bind(&HistoryDaysListManagerTv::onHistoryDayItemClicked, - this, _1)); - WebsiteHistoryItemTitleTv::signalButtonClicked.connect( - boost::bind(&HistoryDaysListManagerTv::onWebsiteHistoryItemClicked, - this, _1)); - WebsiteHistoryItemVisitItemsTv::signalButtonClicked.connect( - boost::bind( - &HistoryDaysListManagerTv::onWebsiteHistoryItemVisitItemClicked, - this, _1)); -} + m_boxDaysColumns = elm_box_add(parent); + tools::EflTools::setExpandHints(m_boxDaysColumns); + elm_box_horizontal_set(m_boxDaysColumns, EINA_TRUE); + elm_object_part_content_set(m_layoutScrollerDaysColumns, "daysColumns", + m_boxDaysColumns); + elm_box_padding_set(m_boxDaysColumns, 65, 0.0); -void HistoryDaysListManagerTv::addHistoryItems( - const std::map<std::string, services::HistoryItemVector>& items, - HistoryPeriod period) -{ - std::vector<WebsiteHistoryItemDataPtr> historyItems; - for (auto& itemPair : items) { - std::vector<WebsiteVisitItemDataPtr> pageViewItems; - std::shared_ptr<tools::BrowserImage> websiteFavicon = nullptr; - for (auto& hi : itemPair.second) { - pageViewItems.push_back( - std::make_shared<WebsiteVisitItemData>(hi)); - if (!websiteFavicon && hi->getFavIcon()->getSize() > 0) - websiteFavicon = hi->getFavIcon(); - } - historyItems.push_back( - std::make_shared<WebsiteHistoryItemData> - (_("IDS_BR_BODY_TITLE"), itemPair.first, websiteFavicon, pageViewItems)); + return m_scrollerDaysColumns; } - HistoryDayItemDataPtr dayItem = std::make_shared < HistoryDayItemData - > (toString(period), historyItems); - appendDayItem(dayItem); -} -int HistoryDaysListManagerTv::getHistoryItemIndex(const HistoryDayItemTv* item) -{ - int index = 0; - for (auto& dayItem : m_dayItems) { - if (dayItem.get() == item) - return index; - index++; + void HistoryDaysListManagerTv::connectSignals() + { + HistoryDayItemTv::signaButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerTv::onHistoryDayItemClicked, this, + _1)); + WebsiteHistoryItemTitleTv::signalButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerTv::onWebsiteHistoryItemClicked, + this, _1)); + WebsiteHistoryItemVisitItemsTv::signalButtonClicked. + connect(boost:: + bind(&HistoryDaysListManagerTv:: + onWebsiteHistoryItemVisitItemClicked, this, _1)); } - return -1; -} -HistoryDayItemTvPtr HistoryDaysListManagerTv::getItem( - HistoryDayItemDataPtrConst historyDayItemData) -{ - for (auto& historyDayItem : m_dayItems) - if (historyDayItem->getData() == historyDayItemData) - return historyDayItem; - BROWSER_LOGE("%s no item", __PRETTY_FUNCTION__); - return nullptr; -} + void HistoryDaysListManagerTv::addHistoryItems(const std::map < + std::string, + services:: + HistoryItemVector > &items, + HistoryPeriod period) + { + std::vector < WebsiteHistoryItemDataPtr > historyItems; + for (auto & itemPair:items) { + std::vector < WebsiteVisitItemDataPtr > pageViewItems; + std::shared_ptr < tools::BrowserImage > websiteFavicon = nullptr; + for (auto & hi:itemPair.second) { + pageViewItems.push_back(std::make_shared < WebsiteVisitItemData > + (hi)); + if (!websiteFavicon && hi->getFavIcon()->getSize() > 0) + websiteFavicon = hi->getFavIcon(); + } + historyItems.push_back(std::make_shared < WebsiteHistoryItemData > + (_("IDS_BR_BODY_TITLE"), itemPair.first, + websiteFavicon, pageViewItems)); + } + HistoryDayItemDataPtr dayItem = std::make_shared < HistoryDayItemData + > (toString(period), historyItems); + appendDayItem(dayItem); + } -void HistoryDaysListManagerTv::clear() -{ - // clear days items main layouts - elm_box_clear(m_boxDaysColumns); - m_dayItems.clear(); -} + int HistoryDaysListManagerTv::getHistoryItemIndex(const HistoryDayItemTv * + item) + { + int index = 0; + for (auto & dayItem:m_dayItems) { + if (dayItem.get() == item) + return index; + index++; + } + return -1; + } -void HistoryDaysListManagerTv::appendDayItem(HistoryDayItemDataPtr dayItemData) -{ - auto item = std::make_shared<HistoryDayItemTv>(dayItemData, m_historyDeleteManager); - m_dayItems.push_back(item); - elm_box_pack_end(m_boxDaysColumns, item->init(m_boxDaysColumns, m_edjeFiles)); -} + HistoryDayItemTvPtr HistoryDaysListManagerTv:: + getItem(HistoryDayItemDataPtrConst historyDayItemData) + { + for (auto & historyDayItem:m_dayItems) + if (historyDayItem->getData() == historyDayItemData) + return historyDayItem; + BROWSER_LOGE("%s no item", __PRETTY_FUNCTION__); + return nullptr; + } -void HistoryDaysListManagerTv::setFocusChain(Evas_Object* obj) -{ - for (auto& dayItem : m_dayItems) - dayItem->setFocusChain(obj); -} + void HistoryDaysListManagerTv::clear() + { + // clear days items main layouts + elm_box_clear(m_boxDaysColumns); + m_dayItems.clear(); + } -void HistoryDaysListManagerTv::onHistoryDayItemFocused( - const HistoryDayItemTv* focusedItem) -{ - scrollToDayItem(focusedItem); -} + void HistoryDaysListManagerTv:: + appendDayItem(HistoryDayItemDataPtr dayItemData) + { + auto item = + std::make_shared < HistoryDayItemTv > (dayItemData, + m_historyDeleteManager); + m_dayItems.push_back(item); + elm_box_pack_end(m_boxDaysColumns, + item->init(m_boxDaysColumns, m_edjeFiles)); + } -void HistoryDaysListManagerTv::onHistoryDayItemClicked( - const HistoryDayItemDataPtrConst clickedItem) -{ - if (m_historyDeleteManager->getDeleteMode()) - removeItem(clickedItem); -} + void HistoryDaysListManagerTv::setFocusChain(Evas_Object * obj) + { + for (auto & dayItem:m_dayItems) + dayItem->setFocusChain(obj); + } -void HistoryDaysListManagerTv::onWebsiteHistoryItemClicked( - const WebsiteHistoryItemDataPtrConst clickedItem) -{ - if (m_historyDeleteManager->getDeleteMode()) - removeItem(clickedItem); - else - signalHistoryItemClicked( - tools::PROTOCOL_DEFAULT + clickedItem->websiteDomain, - clickedItem->websiteTitle); -} + void HistoryDaysListManagerTv:: + onHistoryDayItemFocused(const HistoryDayItemTv * focusedItem) + { + scrollToDayItem(focusedItem); + } -void HistoryDaysListManagerTv::removeItem( - HistoryDayItemDataPtrConst historyDayItemData) -{ - auto item = getItem(historyDayItemData); - if (!item) - return; - signalDeleteHistoryItems(item->getVisitItemsIds()); - // remove day item from vector, destructor will clear efl objects - remove(item); - elm_box_unpack(m_boxDaysColumns, item->getLayoutMain()); -} + void HistoryDaysListManagerTv:: + onHistoryDayItemClicked(const HistoryDayItemDataPtrConst clickedItem) + { + if (m_historyDeleteManager->getDeleteMode()) + removeItem(clickedItem); + } -void HistoryDaysListManagerTv::removeItem( - WebsiteHistoryItemDataPtrConst websiteHistoryItemData) -{ - if (!websiteHistoryItemData) { - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); - return; + void HistoryDaysListManagerTv:: + onWebsiteHistoryItemClicked(const WebsiteHistoryItemDataPtrConst + clickedItem) + { + if (m_historyDeleteManager->getDeleteMode()) + removeItem(clickedItem); + else + signalHistoryItemClicked(tools::PROTOCOL_DEFAULT + + clickedItem->websiteDomain, + clickedItem->websiteTitle); } - for (auto& dayItem : m_dayItems) { - auto websiteHistoryItem = dayItem->getItem(websiteHistoryItemData); - if (websiteHistoryItem) { - signalDeleteHistoryItems(websiteHistoryItem->getVisitItemsIds()); - dayItem->removeItem(websiteHistoryItemData); - return; - } + + void HistoryDaysListManagerTv:: + removeItem(HistoryDayItemDataPtrConst historyDayItemData) + { + auto item = getItem(historyDayItemData); + if (!item) + return; + signalDeleteHistoryItems(item->getVisitItemsIds()); + // remove day item from vector, destructor will clear efl objects + remove(item); + elm_box_unpack(m_boxDaysColumns, item->getLayoutMain()); } - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); -} -void HistoryDaysListManagerTv::removeItem( - WebsiteVisitItemDataPtrConst websiteVisitItemData) -{ - if (!websiteVisitItemData) { - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); - return; + void HistoryDaysListManagerTv:: + removeItem(WebsiteHistoryItemDataPtrConst websiteHistoryItemData) + { + if (!websiteHistoryItemData) { + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); + return; + } + for (auto & dayItem:m_dayItems) { + auto websiteHistoryItem = dayItem->getItem(websiteHistoryItemData); + if (websiteHistoryItem) { + signalDeleteHistoryItems(websiteHistoryItem->getVisitItemsIds()); + dayItem->removeItem(websiteHistoryItemData); + return; + } + } + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); } - for (auto& dayItem : m_dayItems) { - if (dayItem->getItem(websiteVisitItemData)) { - dayItem->removeItem(websiteVisitItemData); - return; - } + + void HistoryDaysListManagerTv:: + removeItem(WebsiteVisitItemDataPtrConst websiteVisitItemData) + { + if (!websiteVisitItemData) { + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); + return; + } + for (auto & dayItem:m_dayItems) { + if (dayItem->getItem(websiteVisitItemData)) { + dayItem->removeItem(websiteVisitItemData); + return; + } + } + BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); } - BROWSER_LOGE("%s remove error", __PRETTY_FUNCTION__); -} -void HistoryDaysListManagerTv::onWebsiteHistoryItemVisitItemClicked( - const WebsiteVisitItemDataPtrConst clickedItem) -{ - if (m_historyDeleteManager->getDeleteMode()) { - removeItem(clickedItem); - signalDeleteHistoryItems( - std::make_shared<std::vector<int>>(std::initializer_list<int> { - clickedItem->historyItem->getId() })); - } else { - signalHistoryItemClicked(clickedItem->historyItem->getUrl(), - clickedItem->historyItem->getTitle()); + void HistoryDaysListManagerTv:: + onWebsiteHistoryItemVisitItemClicked(const WebsiteVisitItemDataPtrConst + clickedItem) + { + if (m_historyDeleteManager->getDeleteMode()) { + removeItem(clickedItem); + signalDeleteHistoryItems(std::make_shared < std::vector < + int >>(std::initializer_list < int > + { + clickedItem->historyItem->getId()})); + } else { + signalHistoryItemClicked(clickedItem->historyItem->getUrl(), + clickedItem->historyItem->getTitle()); + } } -} -void HistoryDaysListManagerTv::remove(HistoryDayItemTvPtr historyDayItem) -{ - for (auto it = m_dayItems.begin(); it != m_dayItems.end();) { - if ((*it) == historyDayItem) { - m_dayItems.erase(it); - return; - } else - ++it; + void HistoryDaysListManagerTv::remove(HistoryDayItemTvPtr historyDayItem) + { + for (auto it = m_dayItems.begin(); it != m_dayItems.end();) { + if ((*it) == historyDayItem) { + m_dayItems.erase(it); + return; + } else { + ++it; + } + } } -} -void HistoryDaysListManagerTv::scrollToDayItem(const HistoryDayItemTv* item) -{ - int itemX, itemY, itemW, itemH; - itemX = itemY = itemW = itemH = 0; - evas_object_geometry_get(item->getLayoutMain(), &itemX, &itemY, &itemW, &itemH); - int index = getHistoryItemIndex(item); - elm_scroller_region_show(m_scrollerDaysColumns, index*itemW, 1, 2*itemW, 1); -} + void HistoryDaysListManagerTv::scrollToDayItem(const HistoryDayItemTv * + item) + { + int itemX, itemY, itemW, itemH; + itemX = itemY = itemW = itemH = 0; + evas_object_geometry_get(item->getLayoutMain(), &itemX, &itemY, &itemW, + &itemH); + int index = getHistoryItemIndex(item); + elm_scroller_region_show(m_scrollerDaysColumns, index * itemW, 1, + 2 * itemW, 1); + } -} + } } diff --git a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.h b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.h index 0a9fbe33..0a9fbe33 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.h +++ b/services/HistoryUI/HistoryDaysListManager/HistoryDaysListManagerTv.h diff --git a/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.cpp b/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.cpp index 32b3c7d9..2ce286bf 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.cpp +++ b/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.cpp @@ -154,8 +154,9 @@ void HistoryDayItemMob::remove(WebsiteHistoryItemMobPtr websiteHistoryItem) if ((*it) == websiteHistoryItem) { m_websiteHistoryItems.erase(it); return; - } else + } else { ++it; + } } } diff --git a/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.h b/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.h index 77b818da..77b818da 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.h +++ b/services/HistoryUI/HistoryDaysListManager/mob/HistoryDayItemMob.h diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.cpp b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.cpp index c4f933cb..c4f933cb 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.cpp +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.cpp diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.h b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.h index 6eaae1c4..6eaae1c4 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.h +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemMob.h diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.cpp b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.cpp index c1d552ec..c1d552ec 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.cpp +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.cpp diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.h b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.h index 23080560..23080560 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.h +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemTitleMob.h diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.cpp b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.cpp index 0c8d803e..c1347d61 100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.cpp +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.cpp @@ -108,9 +108,9 @@ WebsiteHistoryItemVisitItemsMob::createLayoutVisitItem( ret.layout = layout; ret.buttonSelect = elm_object_part_content_get(layoutContent, "buttonSelect"); ret.layerGesture = layerGesture; - ret.boxMain= boxMain; + ret.boxMain = boxMain; ret.layoutButtonDelete = layoutButtonDelete; - ret.buttonDelete= elm_object_part_content_get(layoutButtonDelete, "buttonSelect"); + ret.buttonDelete = elm_object_part_content_get(layoutButtonDelete, "buttonSelect"); ret.clickBlocked = false; return ret; } @@ -134,11 +134,11 @@ Evas_Object* WebsiteHistoryItemVisitItemsMob::createLayoutContent(Evas_Object* p char buffer[80]; struct tm ts_ret; - if(localtime_r(&rawtime, &ts_ret)==NULL){ + if (localtime_r(&rawtime, &ts_ret) == NULL) { BROWSER_LOGE("[%s:%d] Warning: Unhandled localtime_r", __PRETTY_FUNCTION__, __LINE__); return nullptr; } - std::strftime(buffer,80,"%R",&ts_ret); + std::strftime(buffer, 80, "%R", &ts_ret); elm_object_part_text_set(layoutContent, "textTime", buffer); diff --git a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.h b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.h index 18257633..18257633 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.h +++ b/services/HistoryUI/HistoryDaysListManager/mob/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsMob.h diff --git a/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.cpp b/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.cpp index a43d8bea..ef8bcd27 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.cpp +++ b/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.cpp @@ -44,7 +44,7 @@ HistoryDayItemTv::HistoryDayItemTv(HistoryDayItemDataPtr dayItemData, , m_boxWebsites(nullptr) , m_historyDeleteManager(deleteManager) { - for(auto& websiteHistoryItemData : dayItemData->websiteHistoryItems) { + for (auto& websiteHistoryItemData : dayItemData->websiteHistoryItems) { auto websiteHistoryItem = std::make_shared<WebsiteHistoryItemTv>( websiteHistoryItemData, m_historyDeleteManager); m_websiteHistoryItems.push_back(websiteHistoryItem); @@ -126,7 +126,7 @@ void HistoryDayItemTv::setFocusChain(Evas_Object* obj) elm_object_focus_allow_set(m_buttonSelect, EINA_TRUE); elm_object_focus_custom_chain_append(obj, m_buttonSelect, NULL); - for(auto& websiteHistoryItem : m_websiteHistoryItems) { + for (auto& websiteHistoryItem : m_websiteHistoryItems) { websiteHistoryItem->setFocusChain(obj); } } @@ -276,8 +276,9 @@ void HistoryDayItemTv::remove(WebsiteHistoryItemTvPtr websiteHistoryItem) if ((*it) == websiteHistoryItem) { m_websiteHistoryItems.erase(it); return; - } else + } else { ++it; + } } } diff --git a/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.h b/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.h index e678efbb..e678efbb 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.h +++ b/services/HistoryUI/HistoryDaysListManager/tv/HistoryDayItemTv.h diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.cpp b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.cpp index a0445386..a0445386 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.cpp +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.cpp diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.h b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.h index d3d050ec..d3d050ec 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.h +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTitleTv.h diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.cpp b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.cpp index ff9f232b..ff9f232b 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.cpp +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.cpp diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.h b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.h index 9857514e..9857514e 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.h +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemTv.h diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.cpp b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.cpp index d9bba0b2..3396333e 100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.cpp +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.cpp @@ -152,11 +152,11 @@ Evas_Object* WebsiteHistoryItemVisitItemsTv::createLayoutVisitItemDate( char buffer[80]; struct tm ts_ret; - if(localtime_r(&rawtime, &ts_ret)==NULL){ + if (localtime_r(&rawtime, &ts_ret) == NULL){ BROWSER_LOGD("[%s:%d] Warning: Unhandled localtime_r", __PRETTY_FUNCTION__, __LINE__); return nullptr; } - std::strftime(buffer,80,"%R",&ts_ret); + std::strftime(buffer, 80, "%R", &ts_ret); elm_object_text_set(layoutDate, buffer); return layoutDate; @@ -202,7 +202,7 @@ void WebsiteHistoryItemVisitItemsTv::_buttonSelectClicked(void* data, if (!data) return; VisitItemObjects* visitItemObject = static_cast<VisitItemObjects*>(data); - signalButtonClicked((*visitItemObject).websiteVisitItemData ); + signalButtonClicked((*visitItemObject).websiteVisitItemData); } void WebsiteHistoryItemVisitItemsTv::_buttonSelectFocused(void* data, diff --git a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.h b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.h index 2c8c84b3..2c8c84b3 100644..100755 --- a/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.h +++ b/services/HistoryUI/HistoryDaysListManager/tv/WebsiteHistoryItem/WebsiteHistoryItemVisitItemsTv.h diff --git a/services/HistoryUI/HistoryDeleteManager.h b/services/HistoryUI/HistoryDeleteManager.h index 4c36760f..4c36760f 100644..100755 --- a/services/HistoryUI/HistoryDeleteManager.h +++ b/services/HistoryUI/HistoryDeleteManager.h diff --git a/services/HistoryUI/HistoryPeriod.cpp b/services/HistoryUI/HistoryPeriod.cpp index 1b6f831e..1b6f831e 100644..100755 --- a/services/HistoryUI/HistoryPeriod.cpp +++ b/services/HistoryUI/HistoryPeriod.cpp diff --git a/services/HistoryUI/HistoryPeriod.h b/services/HistoryUI/HistoryPeriod.h index 2f78553b..2f78553b 100644..100755 --- a/services/HistoryUI/HistoryPeriod.h +++ b/services/HistoryUI/HistoryPeriod.h diff --git a/services/HistoryUI/HistoryUI.cpp b/services/HistoryUI/HistoryUI.cpp index ee8b226a..65b6e73d 100644..100755 --- a/services/HistoryUI/HistoryUI.cpp +++ b/services/HistoryUI/HistoryUI.cpp @@ -34,205 +34,230 @@ #endif #include "HistoryDeleteManager.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -EXPORT_SERVICE(HistoryUI, "org.tizen.browser.historyui") + EXPORT_SERVICE(HistoryUI, "org.tizen.browser.historyui") -typedef struct _HistoryItemData -{ - std::shared_ptr<tizen_browser::services::HistoryItem> item; - std::shared_ptr<tizen_browser::base_ui::HistoryUI> historyUI; -} HistoryItemData; + typedef struct _HistoryItemData + { + std::shared_ptr < tizen_browser::services::HistoryItem > item; + std::shared_ptr < tizen_browser::base_ui::HistoryUI > historyUI; + } HistoryItemData; -struct ItemData{ - tizen_browser::base_ui::HistoryUI* historyUI; - Elm_Object_Item * e_item; -}; + struct ItemData + { + tizen_browser::base_ui::HistoryUI * historyUI; + Elm_Object_Item *e_item; + }; -static std::vector<HistoryItemData*> _history_item_data; + static std::vector < HistoryItemData * >_history_item_data; -HistoryUI::HistoryUI() + HistoryUI::HistoryUI() : m_parent(nullptr) - , m_main_layout(nullptr) - , m_actionBar(nullptr) - , m_buttonClose(nullptr) - , m_buttonClear(nullptr) - , m_daysList(nullptr) - , m_historyDeleteManager(std::make_shared<HistoryDeleteManager>()) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("HistoryUI/History.edj"); + , m_main_layout(nullptr) + , m_actionBar(nullptr) + , m_buttonClose(nullptr) + , m_buttonClear(nullptr) + , m_daysList(nullptr) + , m_historyDeleteManager(std::make_shared < HistoryDeleteManager > ()) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("HistoryUI/History.edj"); #if PROFILE_MOBILE - m_historyDaysListManager = std::make_shared<HistoryDaysListManagerMob>(); + m_historyDaysListManager = + std::make_shared < HistoryDaysListManagerMob > (); #else - m_historyDaysListManager = std::make_shared<HistoryDaysListManagerTv>(m_historyDeleteManager); + m_historyDaysListManager = + std::make_shared < HistoryDaysListManagerTv > + (m_historyDeleteManager); #endif - m_historyDaysListManager->signalHistoryItemClicked.connect(signalHistoryItemClicked); - m_historyDaysListManager->signalDeleteHistoryItems.connect(signalDeleteHistoryItems); + m_historyDaysListManager->signalHistoryItemClicked. + connect(signalHistoryItemClicked); + m_historyDaysListManager->signalDeleteHistoryItems. + connect(signalDeleteHistoryItems); #if !PROFILE_MOBILE - m_focusManager = std::unique_ptr<HistoryUIFocusManager>( - new HistoryUIFocusManager(m_historyDaysListManager)); + m_focusManager = + std::unique_ptr < HistoryUIFocusManager > + (new HistoryUIFocusManager(m_historyDaysListManager)); #endif -} + } -HistoryUI::~HistoryUI() -{ -} + HistoryUI::~HistoryUI() + { + } -void HistoryUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_main_layout); - evas_object_show(m_actionBar); - evas_object_show(m_main_layout); + void HistoryUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_main_layout); + evas_object_show(m_actionBar); + evas_object_show(m_main_layout); #if !PROFILE_MOBILE - m_focusManager->refreshFocusChain(); + m_focusManager->refreshFocusChain(); #endif -} + } -void HistoryUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_main_layout); - evas_object_hide(m_actionBar); - evas_object_hide(m_main_layout); - clearItems(); + void HistoryUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_main_layout); + evas_object_hide(m_actionBar); + evas_object_hide(m_main_layout); + clearItems(); #if !PROFILE_MOBILE - m_focusManager->unsetFocusChain(); + m_focusManager->unsetFocusChain(); #endif - m_historyDeleteManager->setDeleteMode(false); -} - - -void HistoryUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} + m_historyDeleteManager->setDeleteMode(false); + } -Evas_Object* HistoryUI::getContent() -{ - M_ASSERT(m_parent); - if (!m_main_layout) - createHistoryUILayout(m_parent); - return m_main_layout; -} -void HistoryUI::createHistoryUILayout(Evas_Object* parent) -{ - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - m_main_layout = elm_layout_add(parent); + void HistoryUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } - elm_layout_file_set(m_main_layout, m_edjFilePath.c_str(), "history-layout"); - evas_object_size_hint_weight_set(m_main_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_main_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + Evas_Object *HistoryUI::getContent() + { + M_ASSERT(m_parent); + if (!m_main_layout) + createHistoryUILayout(m_parent); + return m_main_layout; + } - m_actionBar = createActionBar(m_main_layout); - m_daysList = createDaysList(m_main_layout); - clearItems(); + void HistoryUI::createHistoryUILayout(Evas_Object * parent) + { + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + m_main_layout = elm_layout_add(parent); + + elm_layout_file_set(m_main_layout, m_edjFilePath.c_str(), + "history-layout"); + evas_object_size_hint_weight_set(m_main_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_main_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + m_actionBar = createActionBar(m_main_layout); + m_daysList = createDaysList(m_main_layout); + clearItems(); #if !PROFILE_MOBILE - m_focusManager->setFocusObj(m_main_layout); + m_focusManager->setFocusObj(m_main_layout); #endif -} + } -std::map<std::string, services::HistoryItemVector> -HistoryUI::groupItemsByDomain(const services::HistoryItemVector& historyItems) { - std::map<std::string, services::HistoryItemVector> groupedMap; - for(auto& item : historyItems) { - std::string domain = tools::extractDomain(item->getUrl()); - if(groupedMap.find(domain) == groupedMap.end()) { - groupedMap.insert(std::pair<std::string, services::HistoryItemVector>(domain, {})); - } - groupedMap.find(domain)->second.push_back(item); + std::map < std::string, services::HistoryItemVector > + HistoryUI::groupItemsByDomain(const services:: + HistoryItemVector & historyItems) + { + std::map < std::string, services::HistoryItemVector > groupedMap; + for (auto & item:historyItems) { + std::string domain = tools::extractDomain(item->getUrl()); + if (groupedMap.find(domain) == groupedMap.end()) { + groupedMap.insert(std::pair < std::string, + services::HistoryItemVector > (domain, { + })); + } + groupedMap.find(domain)->second.push_back(item); + } + return groupedMap; } - return groupedMap; -} -Evas_Object *HistoryUI::createDaysList(Evas_Object *history_layout) -{ - M_ASSERT(history_layout); + Evas_Object *HistoryUI::createDaysList(Evas_Object * history_layout) + { + M_ASSERT(history_layout); - Evas_Object* list = m_historyDaysListManager->createDaysList( - history_layout); + Evas_Object *list = + m_historyDaysListManager->createDaysList(history_layout); - elm_object_part_content_set(history_layout, "history_list", list); + elm_object_part_content_set(history_layout, "history_list", list); - evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL); - return list; -} + return list; + } -Evas_Object* HistoryUI::createActionBar(Evas_Object* history_layout) -{ - Evas_Object* actionBar = elm_layout_add(history_layout); - elm_object_part_content_set(history_layout, "action_bar_history", actionBar); - evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); - - m_buttonClear = elm_button_add(actionBar); - elm_object_style_set(m_buttonClear, "history_button"); - evas_object_smart_callback_add(m_buttonClear, "clicked", HistoryUI::_clearHistory_clicked, this); - elm_object_part_content_set(actionBar, "clearhistory_click", m_buttonClear); - - m_buttonClose = elm_button_add(actionBar); - elm_object_style_set(m_buttonClose, "close_history_button"); - evas_object_smart_callback_add(m_buttonClose, "clicked", HistoryUI::_close_clicked_cb, this); - elm_object_part_content_set(actionBar, "close_click", m_buttonClose); + Evas_Object *HistoryUI::createActionBar(Evas_Object * history_layout) + { + Evas_Object *actionBar = elm_layout_add(history_layout); + elm_object_part_content_set(history_layout, "action_bar_history", + actionBar); + evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); + + m_buttonClear = elm_button_add(actionBar); + elm_object_style_set(m_buttonClear, "history_button"); + evas_object_smart_callback_add(m_buttonClear, "clicked", + HistoryUI::_clearHistory_clicked, this); + elm_object_part_content_set(actionBar, "clearhistory_click", + m_buttonClear); + + m_buttonClose = elm_button_add(actionBar); + elm_object_style_set(m_buttonClose, "close_history_button"); + evas_object_smart_callback_add(m_buttonClose, "clicked", + HistoryUI::_close_clicked_cb, this); + elm_object_part_content_set(actionBar, "close_click", m_buttonClose); #if !PROFILE_MOBILE - m_focusManager->setHistoryUIButtons(m_buttonClose, m_buttonClear); + m_focusManager->setHistoryUIButtons(m_buttonClose, m_buttonClear); #endif - return actionBar; -} + return actionBar; + } -void HistoryUI::_close_clicked_cb(void * data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - HistoryUI *historyUI = static_cast<HistoryUI*>(data); - historyUI->closeHistoryUIClicked(); + void HistoryUI::_close_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + HistoryUI *historyUI = static_cast < HistoryUI * >(data); + historyUI->closeHistoryUIClicked(); + } } -} -void HistoryUI::_clearHistory_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!data) return; - HistoryUI *historyUI = static_cast<HistoryUI*>(data); + void HistoryUI::_clearHistory_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!data) + return; + HistoryUI *historyUI = static_cast < HistoryUI * >(data); #if PROFILE_MOBILE - historyUI->clearItems(); - historyUI->clearHistoryClicked(); + historyUI->clearItems(); + historyUI->clearHistoryClicked(); #else - historyUI->getHistoryDeleteManager()->toggleDeleteMode(); + historyUI->getHistoryDeleteManager()->toggleDeleteMode(); #endif + } -} - -void HistoryUI::addHistoryItems(std::shared_ptr<services::HistoryItemVector> items, - HistoryPeriod period) -{ - if(items->size() == 0) return; - auto grouped = groupItemsByDomain(*items); - m_historyDaysListManager->addHistoryItems(grouped, period); -} + void HistoryUI::addHistoryItems(std::shared_ptr < + services::HistoryItemVector > items, + HistoryPeriod period) + { + if (items->size() == 0) + return; + auto grouped = groupItemsByDomain(*items); + m_historyDaysListManager->addHistoryItems(grouped, period); + } -void HistoryUI::removeHistoryItem(const std::string& uri) -{ - BROWSER_LOGD("[%s] uri=%s", __func__, uri.c_str()); -} + void HistoryUI::removeHistoryItem(const std::string & uri) + { + BROWSER_LOGD("[%s] uri=%s", __func__, uri.c_str()); + } -void HistoryUI::clearItems() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_historyDaysListManager->clear(); -} + void HistoryUI::clearItems() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_historyDaysListManager->clear(); + } -} + } } diff --git a/services/HistoryUI/HistoryUI.h b/services/HistoryUI/HistoryUI.h index 6d086444..9ff17b72 100755 --- a/services/HistoryUI/HistoryUI.h +++ b/services/HistoryUI/HistoryUI.h @@ -58,10 +58,10 @@ public: void removeHistoryItem(const std::string& uri); Evas_Object* createActionBar(Evas_Object* history_layout); void addItems(); - boost::signals2::signal<void ()> closeHistoryUIClicked; - boost::signals2::signal<void ()> clearHistoryClicked; - boost::signals2::signal<void (std::shared_ptr<const std::vector<int>> itemIds)> signalDeleteHistoryItems; - boost::signals2::signal<void (std::string url, std::string title)> signalHistoryItemClicked; + boost::signals2::signal<void()> closeHistoryUIClicked; + boost::signals2::signal<void()> clearHistoryClicked; + boost::signals2::signal<void(std::shared_ptr<const std::vector<int>> itemIds)> signalDeleteHistoryItems; + boost::signals2::signal<void(std::string url, std::string title)> signalHistoryItemClicked; private: void clearItems(); void createHistoryUILayout(Evas_Object* parent); @@ -92,7 +92,6 @@ private: HistoryUIFocusManagerPtrUnique m_focusManager; #endif HistoryDeleteManagerPtr m_historyDeleteManager; - }; } diff --git a/services/HistoryUI/HistoryUIFocusManager.cpp b/services/HistoryUI/HistoryUIFocusManager.cpp index ecec8577..ecec8577 100644..100755 --- a/services/HistoryUI/HistoryUIFocusManager.cpp +++ b/services/HistoryUI/HistoryUIFocusManager.cpp diff --git a/services/HistoryUI/HistoryUIFocusManager.h b/services/HistoryUI/HistoryUIFocusManager.h index 9924d31d..9924d31d 100644..100755 --- a/services/HistoryUI/HistoryUIFocusManager.h +++ b/services/HistoryUI/HistoryUIFocusManager.h diff --git a/services/MoreMenuUI/MoreMenuUI.cpp b/services/MoreMenuUI/MoreMenuUI.cpp index d58ea1dc..6269f1f9 100755 --- a/services/MoreMenuUI/MoreMenuUI.cpp +++ b/services/MoreMenuUI/MoreMenuUI.cpp @@ -25,752 +25,856 @@ #include "BrowserLogger.h" #include "BrowserImage.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -EXPORT_SERVICE(MoreMenuUI, "org.tizen.browser.moremenuui") + EXPORT_SERVICE(MoreMenuUI, "org.tizen.browser.moremenuui") -struct ItemData{ - tizen_browser::base_ui::MoreMenuUI * m_moreMenu; - std::shared_ptr<tizen_browser::services::HistoryItem> h_item; - Elm_Object_Item * e_item; + struct ItemData + { + tizen_browser::base_ui::MoreMenuUI * m_moreMenu; + std::shared_ptr < tizen_browser::services::HistoryItem > h_item; + Elm_Object_Item *e_item; }; -typedef struct _MoreItemData -{ - ItemType item; - std::shared_ptr<tizen_browser::base_ui::MoreMenuUI> moreMenuUI; -} MoreMenuItemData; + typedef struct _MoreItemData + { + ItemType item; + std::shared_ptr < tizen_browser::base_ui::MoreMenuUI > moreMenuUI; + } MoreMenuItemData; -MoreMenuUI::MoreMenuUI() + MoreMenuUI::MoreMenuUI() : m_current_tab_bar(nullptr) - , m_mm_layout(nullptr) - , m_gengrid(nullptr) - , m_parent(nullptr) - , m_toastPopup(nullptr) - , m_icon(nullptr) - , m_bookmarkIcon(nullptr) - , m_item_class(nullptr) - , m_desktopMode(true) + , m_mm_layout(nullptr) + , m_gengrid(nullptr) + , m_parent(nullptr) + , m_toastPopup(nullptr) + , m_icon(nullptr) + , m_bookmarkIcon(nullptr) + , m_item_class(nullptr) + , m_desktopMode(true) #if PROFILE_MOBILE - , m_shouldShowFindOnPage(false) - , m_blockThumbnails(false) + , m_shouldShowFindOnPage(false) + , m_blockThumbnails(false) #endif - , m_isVisible(false) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("MoreMenuUI/MoreMenu.edj"); - m_item_class = createItemClass(); -} + , m_isVisible(false) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("MoreMenuUI/MoreMenu.edj"); + m_item_class = createItemClass(); + } -MoreMenuUI::~MoreMenuUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_item_class) - elm_gengrid_item_class_free(m_item_class); - evas_object_del(m_gengrid); -} + MoreMenuUI::~MoreMenuUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_item_class) + elm_gengrid_item_class_free(m_item_class); + evas_object_del(m_gengrid); + } -Elm_Gengrid_Item_Class* MoreMenuUI::createItemClass() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Elm_Gengrid_Item_Class* item_class = elm_gengrid_item_class_new(); - item_class->item_style = "menu_item"; - item_class->func.text_get = _grid_text_get; - item_class->func.content_get = _grid_content_get; - item_class->func.state_get = NULL; - item_class->func.del = NULL; - return item_class; -} + Elm_Gengrid_Item_Class *MoreMenuUI::createItemClass() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Elm_Gengrid_Item_Class *item_class = elm_gengrid_item_class_new(); + item_class->item_style = "menu_item"; + item_class->func.text_get = _grid_text_get; + item_class->func.content_get = _grid_content_get; + item_class->func.state_get = NULL; + item_class->func.del = NULL; + return item_class; + } -void MoreMenuUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} + void MoreMenuUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } #if PROFILE_MOBILE -void MoreMenuUI::updateBookmarkButton() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_gengrid_item_update(m_map_menu_views[ADD_TO_BOOKMARK]); -} + void MoreMenuUI::updateBookmarkButton() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_gengrid_item_update(m_map_menu_views[ADD_TO_BOOKMARK]); + } #endif -void MoreMenuUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!m_mm_layout) - createMoreMenuLayout(); - createGengrid(); // recreate gengrid because icons could have changed - addItems(); + void MoreMenuUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!m_mm_layout) + createMoreMenuLayout(); + createGengrid(); // recreate gengrid because icons could have changed + addItems(); #if !PROFILE_MOBILE - m_focusManager.startFocusManager(m_gengrid); - setFocus(EINA_TRUE); + m_focusManager.startFocusManager(m_gengrid); + setFocus(EINA_TRUE); #endif - evas_object_show(m_mm_layout); - evas_object_show(elm_object_part_content_get(m_mm_layout,"current_tab_bar")); + evas_object_show(m_mm_layout); + evas_object_show(elm_object_part_content_get + (m_mm_layout, "current_tab_bar")); #if PROFILE_MOBILE - resetContent(); + resetContent(); #endif - m_isVisible = true; -} + m_isVisible = true; + } -void MoreMenuUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_mm_layout); + void MoreMenuUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_mm_layout); - evas_object_hide(m_mm_layout); - evas_object_hide(elm_object_part_content_get(m_mm_layout,"current_tab_bar")); - clearItems(); - evas_object_del(m_gengrid); + evas_object_hide(m_mm_layout); + evas_object_hide(elm_object_part_content_get + (m_mm_layout, "current_tab_bar")); + clearItems(); + evas_object_del(m_gengrid); #if PROFILE_MOBILE - elm_object_signal_emit(m_parent, "hide_moremenu", "ui"); - deleteMoreMenuLayout(); + elm_object_signal_emit(m_parent, "hide_moremenu", "ui"); + deleteMoreMenuLayout(); #else - setFocus(EINA_FALSE); - m_focusManager.stopFocusManager(); + setFocus(EINA_FALSE); + m_focusManager.stopFocusManager(); #endif - m_isVisible = false; -} + m_isVisible = false; + } -Evas_Object* MoreMenuUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *MoreMenuUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(!m_mm_layout) - createMoreMenuLayout(); - return m_mm_layout; -} + if (!m_mm_layout) + createMoreMenuLayout(); + return m_mm_layout; + } #if PROFILE_MOBILE -void MoreMenuUI::resetContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::optional<bool> rotated = isRotated(); - if (rotated) { - if (*rotated) { - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(GENGRID_ITEM_WIDTH_LANDSCAPE), - ELM_SCALE_SIZE(GENGRID_ITEM_HEIGHT_LANDSCAPE)); - elm_object_signal_emit(m_mm_layout, "switch_landscape", "ui"); - if (evas_object_visible_get(m_mm_layout)) - elm_object_signal_emit(m_parent, "show_moremenu_landscape", "ui"); - } else { - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(GENGRID_ITEM_WIDTH), - ELM_SCALE_SIZE(GENGRID_ITEM_HEIGHT)); - elm_object_signal_emit(m_mm_layout, "switch_vertical", "ui"); - if (evas_object_visible_get(m_mm_layout)) - elm_object_signal_emit(m_parent, "show_moremenu_vertical", "ui"); - } - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); -} + void MoreMenuUI::resetContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::optional < bool > rotated = isRotated(); + if (rotated) { + if (*rotated) { + elm_gengrid_item_size_set(m_gengrid, + ELM_SCALE_SIZE + (GENGRID_ITEM_WIDTH_LANDSCAPE), + ELM_SCALE_SIZE + (GENGRID_ITEM_HEIGHT_LANDSCAPE)); + elm_object_signal_emit(m_mm_layout, "switch_landscape", "ui"); + if (evas_object_visible_get(m_mm_layout)) + elm_object_signal_emit(m_parent, "show_moremenu_landscape", "ui"); + } else { + elm_gengrid_item_size_set(m_gengrid, + ELM_SCALE_SIZE(GENGRID_ITEM_WIDTH), + ELM_SCALE_SIZE(GENGRID_ITEM_HEIGHT)); + elm_object_signal_emit(m_mm_layout, "switch_vertical", "ui"); + if (evas_object_visible_get(m_mm_layout)) + elm_object_signal_emit(m_parent, "show_moremenu_vertical", "ui"); + } + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } #endif -void MoreMenuUI::createMoreMenuLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - elm_theme_extension_add(NULL, m_edjFilePath.c_str()); - m_mm_layout = elm_layout_add(m_parent); - elm_layout_file_set(m_mm_layout, m_edjFilePath.c_str(), "moremenu-layout"); - evas_object_size_hint_weight_set(m_mm_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_mm_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + void MoreMenuUI::createMoreMenuLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + elm_theme_extension_add(NULL, m_edjFilePath.c_str()); + m_mm_layout = elm_layout_add(m_parent); + elm_layout_file_set(m_mm_layout, m_edjFilePath.c_str(), + "moremenu-layout"); + evas_object_size_hint_weight_set(m_mm_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_mm_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); #if PROFILE_MOBILE - elm_object_part_content_set(m_parent, "moremenu", m_mm_layout); - elm_object_tree_focus_allow_set(m_mm_layout, EINA_FALSE); + elm_object_part_content_set(m_parent, "moremenu", m_mm_layout); + elm_object_tree_focus_allow_set(m_mm_layout, EINA_FALSE); #endif -} + } #if PROFILE_MOBILE -void MoreMenuUI::deleteMoreMenuLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void MoreMenuUI::deleteMoreMenuLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - M_ASSERT(m_mm_layout); + M_ASSERT(m_parent); + M_ASSERT(m_mm_layout); - evas_object_del(m_gengrid); - evas_object_hide(m_mm_layout); - elm_object_signal_emit(m_parent, "hide_moremenu", "ui"); - evas_object_del(m_mm_layout); + evas_object_del(m_gengrid); + evas_object_hide(m_mm_layout); + elm_object_signal_emit(m_parent, "hide_moremenu", "ui"); + evas_object_del(m_mm_layout); - m_mm_layout = nullptr; -} + m_mm_layout = nullptr; + } #endif -void MoreMenuUI::createGengrid() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_gengrid = elm_gengrid_add(m_mm_layout); - elm_object_part_content_set(m_mm_layout, "elm.swallow.grid", m_gengrid); - elm_gengrid_align_set(m_gengrid, 0, 0); - elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); - elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); - elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + void MoreMenuUI::createGengrid() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_gengrid = elm_gengrid_add(m_mm_layout); + elm_object_part_content_set(m_mm_layout, "elm.swallow.grid", m_gengrid); + elm_gengrid_align_set(m_gengrid, 0, 0); + elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE); + elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE); + elm_scroller_policy_set(m_gengrid, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); #if PROFILE_MOBILE - elm_scroller_bounce_set(m_gengrid, EINA_FALSE, EINA_FALSE); - elm_object_scroll_lock_x_set(m_gengrid, EINA_TRUE); + elm_scroller_bounce_set(m_gengrid, EINA_FALSE, EINA_FALSE); + elm_object_scroll_lock_x_set(m_gengrid, EINA_TRUE); #else - elm_scroller_page_size_set(m_gengrid, 0, 327); - elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(GENGRID_ITEM_WIDTH), ELM_SCALE_SIZE(GENGRID_ITEM_HEIGHT)); + elm_scroller_page_size_set(m_gengrid, 0, 327); + elm_gengrid_item_size_set(m_gengrid, ELM_SCALE_SIZE(GENGRID_ITEM_WIDTH), + ELM_SCALE_SIZE(GENGRID_ITEM_HEIGHT)); #endif - evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL); -} + evas_object_size_hint_weight_set(m_gengrid, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_gengrid, EVAS_HINT_FILL, + EVAS_HINT_FILL); + } -void MoreMenuUI::showCurrentTab() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_current_tab_bar = elm_layout_add(m_mm_layout); - elm_layout_file_set(m_current_tab_bar, m_edjFilePath.c_str(), "current_tab_layout"); - evas_object_size_hint_weight_set(m_current_tab_bar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_part_content_set(m_mm_layout, "current_tab_bar", m_current_tab_bar); - - Evas_Object* button = elm_button_add(m_current_tab_bar); - elm_object_style_set(button, "hidden_button"); - evas_object_smart_callback_add(button, "clicked", _close_clicked, this); - elm_object_part_content_set(m_current_tab_bar, "close_click", button); - evas_object_show(button); - elm_object_focus_set(button, EINA_TRUE); - - m_bookmarkButton = elm_button_add(m_mm_layout); - elm_object_style_set(m_bookmarkButton, "hidden_button"); - evas_object_show(m_bookmarkButton); - evas_object_smart_callback_add(m_bookmarkButton, "clicked", _bookmarkButton_clicked, this); - - m_bookmarkIcon = elm_icon_add(m_mm_layout); - elm_object_part_content_set(m_current_tab_bar, "bookmark_ico", m_bookmarkIcon); - elm_object_part_content_set(m_current_tab_bar, "star_click", m_bookmarkButton); + void MoreMenuUI::showCurrentTab() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_current_tab_bar = elm_layout_add(m_mm_layout); + elm_layout_file_set(m_current_tab_bar, m_edjFilePath.c_str(), + "current_tab_layout"); + evas_object_size_hint_weight_set(m_current_tab_bar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_part_content_set(m_mm_layout, "current_tab_bar", + m_current_tab_bar); + + Evas_Object *button = elm_button_add(m_current_tab_bar); + elm_object_style_set(button, "hidden_button"); + evas_object_smart_callback_add(button, "clicked", _close_clicked, this); + elm_object_part_content_set(m_current_tab_bar, "close_click", button); + evas_object_show(button); + elm_object_focus_set(button, EINA_TRUE); + + m_bookmarkButton = elm_button_add(m_mm_layout); + elm_object_style_set(m_bookmarkButton, "hidden_button"); + evas_object_show(m_bookmarkButton); + evas_object_smart_callback_add(m_bookmarkButton, "clicked", + _bookmarkButton_clicked, this); + + m_bookmarkIcon = elm_icon_add(m_mm_layout); + elm_object_part_content_set(m_current_tab_bar, "bookmark_ico", + m_bookmarkIcon); + elm_object_part_content_set(m_current_tab_bar, "star_click", + m_bookmarkButton); #if !PROFILE_MOBILE - createFocusVector(); + createFocusVector(); #endif -} - -void MoreMenuUI::setFavIcon(tools::BrowserImagePtr favicon) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(favicon && favicon->getSize() > 0) { - if(m_icon) - evas_object_del(m_icon); - - m_icon = favicon->getEvasImage(m_current_tab_bar); - if(m_icon) { - evas_object_size_hint_weight_set(m_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_icon, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_current_tab_bar, "favicon", m_icon); - evas_object_show(m_icon); - } } - else { - setDocIcon(); - } -} -void MoreMenuUI::setDocIcon() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(m_icon) - evas_object_del(m_icon); - - m_icon = elm_icon_add(m_mm_layout); - elm_image_file_set(m_icon, m_edjFilePath.c_str(), "ico_url.png"); - evas_object_size_hint_weight_set(m_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_icon, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_current_tab_bar, "favicon", m_icon); -} + void MoreMenuUI::setFavIcon(tools::BrowserImagePtr favicon) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (favicon && favicon->getSize() > 0) { + if (m_icon) + evas_object_del(m_icon); + + m_icon = favicon->getEvasImage(m_current_tab_bar); + if (m_icon) { + evas_object_size_hint_weight_set(m_icon, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_icon, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_object_part_content_set(m_current_tab_bar, "favicon", m_icon); + evas_object_show(m_icon); + } + } else { + setDocIcon(); + } + } -void MoreMenuUI::setWebTitle(const std::string& title) -{ - BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, title.c_str()); - elm_object_part_text_set(m_current_tab_bar, "webpage_title", title.c_str()); -} + void MoreMenuUI::setDocIcon() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_icon) + evas_object_del(m_icon); + + m_icon = elm_icon_add(m_mm_layout); + elm_image_file_set(m_icon, m_edjFilePath.c_str(), "ico_url.png"); + evas_object_size_hint_weight_set(m_icon, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_icon, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(m_current_tab_bar, "favicon", m_icon); + } -void MoreMenuUI::setURL(const std::string& url) -{ - BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, url.c_str()); - - boost::optional<bool> bookmark = isBookmark(); - if (bookmark) { - if (!url.empty()) { - elm_object_part_text_set(m_current_tab_bar, "webpage_url", url.c_str()); - if (*bookmark) { - changeBookmarkStatus(true); - enableAddToBookmarkButton(true); - } else { - changeBookmarkStatus(false); - enableAddToBookmarkButton(true); - } - } else { - elm_object_part_text_set(m_current_tab_bar, "webpage_url", ""); - elm_object_part_text_set(m_current_tab_bar, "webpage_title", "No Content"); - changeBookmarkStatus(false); - enableAddToBookmarkButton(false); - } - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); -} + void MoreMenuUI::setWebTitle(const std::string & title) + { + BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, + title.c_str()); + elm_object_part_text_set(m_current_tab_bar, "webpage_title", + title.c_str()); + } -void MoreMenuUI::setHomePageInfo() -{ - setDocIcon(); - setURL(""); -} + void MoreMenuUI::setURL(const std::string & url) + { + BROWSER_LOGD("[%s:%d] %s", __PRETTY_FUNCTION__, __LINE__, url.c_str()); + + boost::optional < bool > bookmark = isBookmark(); + if (bookmark) { + if (!url.empty()) { + elm_object_part_text_set(m_current_tab_bar, "webpage_url", + url.c_str()); + if (*bookmark) { + changeBookmarkStatus(true); + enableAddToBookmarkButton(true); + } else { + changeBookmarkStatus(false); + enableAddToBookmarkButton(true); + } + } else { + elm_object_part_text_set(m_current_tab_bar, "webpage_url", ""); + elm_object_part_text_set(m_current_tab_bar, "webpage_title", + "No Content"); + changeBookmarkStatus(false); + enableAddToBookmarkButton(false); + } + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } -void MoreMenuUI::changeBookmarkStatus(bool data) -{ - if (data) { - elm_object_part_text_set(m_current_tab_bar, "add_to_bookmark_text", "Remove Bookmark"); - elm_image_file_set(m_bookmarkIcon, m_edjFilePath.c_str(), "ic_add_bookmark.png"); + void MoreMenuUI::setHomePageInfo() + { + setDocIcon(); + setURL(""); } - else { - elm_object_part_text_set(m_current_tab_bar, "add_to_bookmark_text", "Add to Bookmark"); - elm_image_file_set(m_bookmarkIcon, m_edjFilePath.c_str(), "ic_add_bookmark_new.png"); + + void MoreMenuUI::changeBookmarkStatus(bool data) + { + if (data) { + elm_object_part_text_set(m_current_tab_bar, "add_to_bookmark_text", + "Remove Bookmark"); + elm_image_file_set(m_bookmarkIcon, m_edjFilePath.c_str(), + "ic_add_bookmark.png"); + } else { + elm_object_part_text_set(m_current_tab_bar, "add_to_bookmark_text", + "Add to Bookmark"); + elm_image_file_set(m_bookmarkIcon, m_edjFilePath.c_str(), + "ic_add_bookmark_new.png"); + } } -} -void MoreMenuUI::enableAddToBookmarkButton(bool data) -{ - if (m_bookmarkButton) { - elm_object_disabled_set(m_bookmarkButton, data ? EINA_FALSE : EINA_TRUE); - elm_object_style_set(m_bookmarkButton, data ? "hidden_button" : "dimmed_button"); + void MoreMenuUI::enableAddToBookmarkButton(bool data) + { + if (m_bookmarkButton) { + elm_object_disabled_set(m_bookmarkButton, + data ? EINA_FALSE : EINA_TRUE); + elm_object_style_set(m_bookmarkButton, + data ? "hidden_button" : "dimmed_button"); + } } -} -void MoreMenuUI::createToastPopup(const char* text) -{ - m_toastPopup = elm_popup_add(m_mm_layout); - elm_object_style_set(m_toastPopup, "toast"); - evas_object_size_hint_weight_set(m_toastPopup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_toastPopup, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_content_set(m_current_tab_bar, "toast_popup", m_toastPopup); - elm_object_part_text_set(m_current_tab_bar, "toast_text", text); - evas_object_smart_callback_add(m_toastPopup, "timeout", _timeout, this); - elm_popup_timeout_set(m_toastPopup, 3.0); -} + void MoreMenuUI::createToastPopup(const char *text) + { + m_toastPopup = elm_popup_add(m_mm_layout); + elm_object_style_set(m_toastPopup, "toast"); + evas_object_size_hint_weight_set(m_toastPopup, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_toastPopup, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_object_part_content_set(m_current_tab_bar, "toast_popup", + m_toastPopup); + elm_object_part_text_set(m_current_tab_bar, "toast_text", text); + evas_object_smart_callback_add(m_toastPopup, "timeout", _timeout, this); + elm_popup_timeout_set(m_toastPopup, 3.0); + } -void MoreMenuUI::_timeout(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - MoreMenuUI *moreMenuUI = static_cast<MoreMenuUI*>(data); - elm_object_part_text_set(moreMenuUI->m_current_tab_bar, "toast_text", ""); - evas_object_del(moreMenuUI->m_toastPopup); -} + void MoreMenuUI::_timeout(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + MoreMenuUI *moreMenuUI = static_cast < MoreMenuUI * >(data); + elm_object_part_text_set(moreMenuUI->m_current_tab_bar, "toast_text", + ""); + evas_object_del(moreMenuUI->m_toastPopup); + } -void MoreMenuUI::_bookmarkButton_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(data) { - MoreMenuUI *moreMenuUI = static_cast<MoreMenuUI*>(data); - boost::optional<bool> bookmark = moreMenuUI->isBookmark(); - if (bookmark) - moreMenuUI->bookmarkFlowClicked(*bookmark); - else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); + void MoreMenuUI::_bookmarkButton_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + MoreMenuUI *moreMenuUI = static_cast < MoreMenuUI * >(data); + boost::optional < bool > bookmark = moreMenuUI->isBookmark(); + if (bookmark) + moreMenuUI->bookmarkFlowClicked(*bookmark); + else + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } } -} -void MoreMenuUI::_close_clicked(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - MoreMenuUI *moreMenuUI = static_cast<MoreMenuUI*>(data); - moreMenuUI->closeMoreMenuClicked(); + void MoreMenuUI::_close_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + MoreMenuUI *moreMenuUI = static_cast < MoreMenuUI * >(data); + moreMenuUI->closeMoreMenuClicked(); + } } -} -void MoreMenuUI::addItems() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void MoreMenuUI::addItems() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); #if PROFILE_MOBILE - for (int i = 0; i <= FIND_ON_PAGE; i++) { - ItemType type = static_cast<ItemType>(i); - if (type == ItemType::FIND_ON_PAGE && !m_shouldShowFindOnPage) - continue; - addItem(type); - } + for (int i = 0; i <= FIND_ON_PAGE; i++) { + ItemType type = static_cast < ItemType > (i); + if (type == ItemType::FIND_ON_PAGE && !m_shouldShowFindOnPage) + continue; + addItem(type); + } #else - for (int i = 0; i <= EXIT_BROWSER; i++) { - ItemType type = static_cast<ItemType>(i); - // take proper image for desktop/mobile view - if (type == ItemType::VIEW_DESKTOP_WEB && m_desktopMode) - continue; - if (type == ItemType::VIEW_MOBILE_WEB && !m_desktopMode) - continue; - addItem(type); - } + for (int i = 0; i <= EXIT_BROWSER; i++) { + ItemType type = static_cast < ItemType > (i); + // take proper image for desktop/mobile view + if (type == ItemType::VIEW_DESKTOP_WEB && m_desktopMode) + continue; + if (type == ItemType::VIEW_MOBILE_WEB && !m_desktopMode) + continue; + addItem(type); + } #endif -} - -void MoreMenuUI::addItem(ItemType type) -{ - MoreMenuItemData *itemData = new MoreMenuItemData(); - itemData->item = type; - itemData->moreMenuUI = std::shared_ptr<tizen_browser::base_ui::MoreMenuUI>(this); - Elm_Object_Item* bookmarkView = elm_gengrid_item_append(m_gengrid, m_item_class, itemData, _thumbSelected, itemData); - m_map_menu_views.insert(std::pair<ItemType, Elm_Object_Item*>(itemData->item, bookmarkView)); - elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); -} + } -void MoreMenuUI::clearItems() -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - for (auto it = m_map_menu_views.begin(); it != m_map_menu_views.end(); ++it) { - Elm_Object_Item* bookmarkView = it->second; - Evas_Object *button = elm_object_item_part_content_get(bookmarkView, "thumbbutton_item"); - evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_IN, __cb_mouse_in); - evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_OUT, __cb_mouse_out); + void MoreMenuUI::addItem(ItemType type) + { + MoreMenuItemData *itemData = new MoreMenuItemData(); + itemData->item = type; + itemData->moreMenuUI = + std::shared_ptr < tizen_browser::base_ui::MoreMenuUI > (this); + Elm_Object_Item *bookmarkView = + elm_gengrid_item_append(m_gengrid, m_item_class, itemData, + _thumbSelected, itemData); + m_map_menu_views.insert(std::pair < ItemType, + Elm_Object_Item * >(itemData->item, + bookmarkView)); + elm_gengrid_item_selected_set(bookmarkView, EINA_FALSE); } - elm_gengrid_clear(m_gengrid); - m_map_menu_views.clear(); -} + void MoreMenuUI::clearItems() + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + for (auto it = m_map_menu_views.begin(); it != m_map_menu_views.end(); + ++it) { + Elm_Object_Item *bookmarkView = it->second; + Evas_Object *button = + elm_object_item_part_content_get(bookmarkView, "thumbbutton_item"); + evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_IN, + __cb_mouse_in); + evas_object_event_callback_del(button, EVAS_CALLBACK_MOUSE_OUT, + __cb_mouse_out); + } + + elm_gengrid_clear(m_gengrid); + m_map_menu_views.clear(); + } -char* MoreMenuUI::_grid_text_get(void* data, Evas_Object*, const char* part) -{ - BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); - if (data && part) { - MoreMenuItemData *itemData = static_cast<MoreMenuItemData*>(data); + char *MoreMenuUI::_grid_text_get(void *data, Evas_Object *, + const char *part) + { + BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); + if (data && part) { + MoreMenuItemData *itemData = static_cast < MoreMenuItemData * >(data); #if PROFILE_MOBILE - const char *part_name = "thumbnail_text"; + const char *part_name = "thumbnail_text"; #else - const char *part_name = "menu_label"; + const char *part_name = "menu_label"; #endif - static const int part_name_len = strlen(part_name); - - if (!strncmp(part_name, part, part_name_len)) { - const char* item_name = NULL; - switch (itemData->item) { - case HISTORY: - item_name = "History Manager"; - break; - case BOOKMARK_MANAGER: - item_name = "Bookmark Manager"; - break; - case SETTINGS: - item_name = _("IDS_BR_OPT_SETTINGS"); - break; + static const int part_name_len = strlen(part_name); + + if (!strncmp(part_name, part, part_name_len)) { + const char *item_name = NULL; + switch (itemData->item) { + case HISTORY: + item_name = "History Manager"; + break; + case BOOKMARK_MANAGER: + item_name = "Bookmark Manager"; + break; + case SETTINGS: + item_name = _("IDS_BR_OPT_SETTINGS"); + break; #if PROFILE_MOBILE - case ADD_TO_BOOKMARK: { - boost::optional<bool> bookmark = itemData->moreMenuUI->isBookmark(); - if (bookmark) - item_name = *bookmark ? "Edit Bookmark" : "Add to Bookmark"; - else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - } - break; + case ADD_TO_BOOKMARK:{ + boost::optional < bool > bookmark = + itemData->moreMenuUI->isBookmark(); + if (bookmark) + item_name = *bookmark ? "Edit Bookmark" : "Add to Bookmark"; + else + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + break; #ifdef READER_MODE_ENABLED - case READER_MODE: - item_name = _("IDS_BR_OPT_READER_MODE_TTS"); - break; + case READER_MODE: + item_name = _("IDS_BR_OPT_READER_MODE_TTS"); + break; #endif - case FIND_ON_PAGE: - item_name = _("IDS_BR_OPT_FIND_ON_PAGE"); - break; + case FIND_ON_PAGE: + item_name = _("IDS_BR_OPT_FIND_ON_PAGE"); + break; #else #ifdef READER_MODE_ENABLED - case READER_MODE: - item_name = _("IDS_BR_OPT_READER_MODE_TTS"); - break; + case READER_MODE: + item_name = _("IDS_BR_OPT_READER_MODE_TTS"); + break; #endif - case SCREEN_ZOOM: - item_name = "Screen Zoom"; - break; + case SCREEN_ZOOM: + item_name = "Screen Zoom"; + break; #ifdef START_MINIBROWSER_ENABLED - case START_MINIBROWSER: - item_name = "Start Mini Browser"; - break; + case START_MINIBROWSER: + item_name = "Start Mini Browser"; + break; #endif - case VIEW_MOBILE_WEB: - item_name = "View Mobile Web"; - break; - case VIEW_DESKTOP_WEB: - item_name = "View Desktop Web"; - break; - case EXIT_BROWSER: - item_name = "Exit Browser"; - break; + case VIEW_MOBILE_WEB: + item_name = "View Mobile Web"; + break; + case VIEW_DESKTOP_WEB: + item_name = "View Desktop Web"; + break; + case EXIT_BROWSER: + item_name = "Exit Browser"; + break; #endif - default: - item_name = ""; - } - return strdup(item_name); - } + default: + item_name = ""; + } + return strdup(item_name); + } + } + return NULL; } - return NULL; -} -static const char* getImageFileNameForType(ItemType type, bool focused, Eina_Bool bookmarked) -{ + static const char *getImageFileNameForType(ItemType type, bool focused, + Eina_Bool bookmarked) + { #if PROFILE_MOBILE - M_UNUSED(focused); + M_UNUSED(focused); #else - M_UNUSED(bookmarked); + M_UNUSED(bookmarked); #endif - const char* file_name = NULL; - switch (type) { + const char *file_name = NULL; + switch (type) { #if PROFILE_MOBILE - case ADD_TO_BOOKMARK: - file_name = bookmarked == EINA_TRUE ? "moremenu_ic_01_edit.png" : "moremenu_ic_01.png"; - break; + case ADD_TO_BOOKMARK: + file_name = + bookmarked == + EINA_TRUE ? "moremenu_ic_01_edit.png" : "moremenu_ic_01.png"; + break; #ifdef READER_MODE_ENABLED - case READER_MODE: - file_name = "moremenu_ic_02.png"; - break; + case READER_MODE: + file_name = "moremenu_ic_02.png"; + break; #endif - case HISTORY: - file_name = "moremenu_ic_04.png"; - break; - case BOOKMARK_MANAGER: - file_name = "moremenu_ic_05.png"; - break; - case SETTINGS: - file_name = "moremenu_ic_06.png"; - break; - case FIND_ON_PAGE: - file_name = "moremenu_ic_07.png"; - break; + case HISTORY: + file_name = "moremenu_ic_04.png"; + break; + case BOOKMARK_MANAGER: + file_name = "moremenu_ic_05.png"; + break; + case SETTINGS: + file_name = "moremenu_ic_06.png"; + break; + case FIND_ON_PAGE: + file_name = "moremenu_ic_07.png"; + break; #else - #ifdef READER_MODE_ENABLED - case READER_MODE: - file_name = focused ? "ic_more_readermode_foc.png" : "ic_more_readermode_nor.png"; - break; - #endif - case BOOKMARK_MANAGER: - file_name = focused ? "ic_more_bookmark_foc.png" : "ic_more_bookmark_nor.png"; - break; - case HISTORY: - file_name = focused ? "ic_more_history_foc.png" : "ic_more_history_nor.png"; - break; - case SCREEN_ZOOM: - file_name = focused ? "ic_more_zoom_foc.png" : "ic_more_zoom_nor.png"; - break; - #ifdef START_MINIBROWSER_ENABLED - case START_MINIBROWSER: - file_name = focused ? "ic_more_minibrowser_foc.png" : "ic_more_minibrowser_nor.png"; - break; - #endif - case VIEW_MOBILE_WEB: - file_name = focused ? "ic_more_mobileview_foc.png" : "ic_more_mobileview_nor.png"; - break; - case VIEW_DESKTOP_WEB: - file_name = focused ? "ic_more_desktopview_foc.png" : "ic_more_desktopview_nor.png"; - break; - case SETTINGS: - file_name = focused ? "ic_more_setting_foc.png" : "ic_more_setting_nor.png"; - break; - case EXIT_BROWSER: - file_name = focused ? "ic_more_exit_foc.png" : "ic_more_exit_nor.png"; - break; +#ifdef READER_MODE_ENABLED + case READER_MODE: + file_name = + focused ? "ic_more_readermode_foc.png" : + "ic_more_readermode_nor.png"; + break; +#endif + case BOOKMARK_MANAGER: + file_name = + focused ? "ic_more_bookmark_foc.png" : "ic_more_bookmark_nor.png"; + break; + case HISTORY: + file_name = + focused ? "ic_more_history_foc.png" : "ic_more_history_nor.png"; + break; + case SCREEN_ZOOM: + file_name = focused ? "ic_more_zoom_foc.png" : "ic_more_zoom_nor.png"; + break; +#ifdef START_MINIBROWSER_ENABLED + case START_MINIBROWSER: + file_name = + focused ? "ic_more_minibrowser_foc.png" : + "ic_more_minibrowser_nor.png"; + break; +#endif + case VIEW_MOBILE_WEB: + file_name = + focused ? "ic_more_mobileview_foc.png" : + "ic_more_mobileview_nor.png"; + break; + case VIEW_DESKTOP_WEB: + file_name = + focused ? "ic_more_desktopview_foc.png" : + "ic_more_desktopview_nor.png"; + break; + case SETTINGS: + file_name = + focused ? "ic_more_setting_foc.png" : "ic_more_setting_nor.png"; + break; + case EXIT_BROWSER: + file_name = focused ? "ic_more_exit_foc.png" : "ic_more_exit_nor.png"; + break; #endif - default: - file_name = ""; + default: + file_name = ""; + } + return file_name; } - return file_name; -} -Evas_Object * MoreMenuUI::_grid_content_get(void *data, Evas_Object *obj, const char *part) -{ - BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); - if (data && obj && part) { - MoreMenuItemData *itemData = static_cast<MoreMenuItemData*>(data); + Evas_Object *MoreMenuUI::_grid_content_get(void *data, Evas_Object * obj, + const char *part) + { + BROWSER_LOGD("[%s:%d] part=%s", __PRETTY_FUNCTION__, __LINE__, part); + if (data && obj && part) { + MoreMenuItemData *itemData = static_cast < MoreMenuItemData * >(data); #if PROFILE_MOBILE - const char *part_name1 = "thumbnail_icon"; + const char *part_name1 = "thumbnail_icon"; #else - const char *part_name1 = "thumbnail_item"; + const char *part_name1 = "thumbnail_item"; #endif - static const int part_name1_len = strlen(part_name1); - const char *part_name2 = "thumbbutton_item"; - static const int part_name2_len = strlen(part_name2); - - if (!strncmp(part_name1, part, part_name1_len)) { - Evas_Object* thumb_nail = elm_icon_add(obj); - boost::optional<bool> bookmark = itemData->moreMenuUI->isBookmark(); - if (bookmark) { - const char* file_name = getImageFileNameForType(itemData->item, false, *bookmark); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); - return thumb_nail; - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - } - - if (!strncmp(part_name2, part, part_name2_len)) { - Evas_Object *thumbButton = elm_button_add(obj); + static const int part_name1_len = strlen(part_name1); + const char *part_name2 = "thumbbutton_item"; + static const int part_name2_len = strlen(part_name2); + + if (!strncmp(part_name1, part, part_name1_len)) { + Evas_Object *thumb_nail = elm_icon_add(obj); + boost::optional < bool > bookmark = + itemData->moreMenuUI->isBookmark(); + if (bookmark) { + const char *file_name = + getImageFileNameForType(itemData->item, false, *bookmark); + elm_image_file_set(thumb_nail, + itemData->moreMenuUI->m_edjFilePath.c_str(), + file_name); + return thumb_nail; + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } + + if (!strncmp(part_name2, part, part_name2_len)) { + Evas_Object *thumbButton = elm_button_add(obj); #if PROFILE_MOBILE - elm_object_style_set(thumbButton, "invisible_button"); - evas_object_smart_callback_add(thumbButton, "clicked", _thumbSelected, data); - elm_object_part_content_set(obj, "thumbnail_click", thumbButton); + elm_object_style_set(thumbButton, "invisible_button"); + evas_object_smart_callback_add(thumbButton, "clicked", + _thumbSelected, data); + elm_object_part_content_set(obj, "thumbnail_click", thumbButton); #else - elm_object_style_set(thumbButton, "clickButton"); - evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_IN, __cb_mouse_in, data); - evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_OUT, __cb_mouse_out, data); + elm_object_style_set(thumbButton, "clickButton"); + evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_IN, + __cb_mouse_in, data); + evas_object_event_callback_add(thumbButton, EVAS_CALLBACK_MOUSE_OUT, + __cb_mouse_out, data); #endif - return thumbButton; - } + return thumbButton; + } + } + return NULL; } - return NULL; -} -void MoreMenuUI::__cb_mouse_in(void * data, Evas *, Evas_Object *obj, void *) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + void MoreMenuUI::__cb_mouse_in(void *data, Evas *, Evas_Object * obj, + void *) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); #if PROFILE_MOBILE - M_UNUSED(data); - M_UNUSED(obj); + M_UNUSED(data); + M_UNUSED(obj); #else - if (data && obj) { - elm_object_focus_set(obj, EINA_TRUE); - MoreMenuItemData *itemData = static_cast<MoreMenuItemData*>(data); - Elm_Object_Item *selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; - Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); - boost::optional<bool> bookmark = itemData->moreMenuUI->isBookmark(); - if (bookmark) { - const char *file_name = getImageFileNameForType(itemData->item, true, *bookmark); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - } + if (data && obj) { + elm_object_focus_set(obj, EINA_TRUE); + MoreMenuItemData *itemData = static_cast < MoreMenuItemData * >(data); + Elm_Object_Item *selected = + itemData->moreMenuUI->m_map_menu_views[itemData->item]; + Evas_Object *thumb_nail = + elm_object_item_part_content_get(selected, "thumbnail_item"); + boost::optional < bool > bookmark = + itemData->moreMenuUI->isBookmark(); + if (bookmark) { + const char *file_name = + getImageFileNameForType(itemData->item, true, *bookmark); + elm_image_file_set(thumb_nail, + itemData->moreMenuUI->m_edjFilePath.c_str(), + file_name); + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } #endif -} + } -void MoreMenuUI::__cb_mouse_out(void * data, Evas *, Evas_Object *obj, void *) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + void MoreMenuUI::__cb_mouse_out(void *data, Evas *, Evas_Object * obj, + void *) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); #if PROFILE_MOBILE - M_UNUSED(data); - M_UNUSED(obj); + M_UNUSED(data); + M_UNUSED(obj); #else - if (data && obj) { - elm_object_focus_set(obj, EINA_FALSE); - MoreMenuItemData *itemData = static_cast<MoreMenuItemData*>(data); - Elm_Object_Item *selected = itemData->moreMenuUI->m_map_menu_views[itemData->item]; - Evas_Object *thumb_nail = elm_object_item_part_content_get(selected, "thumbnail_item"); - boost::optional<bool> bookmark = itemData->moreMenuUI->isBookmark(); - if (bookmark) { - const char *file_name = getImageFileNameForType(itemData->item, false, *bookmark); - elm_image_file_set(thumb_nail, itemData->moreMenuUI->m_edjFilePath.c_str(), file_name); - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - } + if (data && obj) { + elm_object_focus_set(obj, EINA_FALSE); + MoreMenuItemData *itemData = static_cast < MoreMenuItemData * >(data); + Elm_Object_Item *selected = + itemData->moreMenuUI->m_map_menu_views[itemData->item]; + Evas_Object *thumb_nail = + elm_object_item_part_content_get(selected, "thumbnail_item"); + boost::optional < bool > bookmark = + itemData->moreMenuUI->isBookmark(); + if (bookmark) { + const char *file_name = + getImageFileNameForType(itemData->item, false, *bookmark); + elm_image_file_set(thumb_nail, + itemData->moreMenuUI->m_edjFilePath.c_str(), + file_name); + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } #endif -} + } -void MoreMenuUI::_thumbSelected(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - if (data) { - MoreMenuItemData *itemData = static_cast<MoreMenuItemData*>(data); - BROWSER_LOGD("type: %d", itemData->item); - switch (itemData->item) { - case HISTORY: - itemData->moreMenuUI->historyUIClicked(); - break; - case SETTINGS: - itemData->moreMenuUI->settingsClicked(); - break; - case BOOKMARK_MANAGER: - itemData->moreMenuUI->bookmarkManagerClicked(); - break; + void MoreMenuUI::_thumbSelected(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + if (data) { + MoreMenuItemData *itemData = static_cast < MoreMenuItemData * >(data); + BROWSER_LOGD("type: %d", itemData->item); + switch (itemData->item) { + case HISTORY: + itemData->moreMenuUI->historyUIClicked(); + break; + case SETTINGS: + itemData->moreMenuUI->settingsClicked(); + break; + case BOOKMARK_MANAGER: + itemData->moreMenuUI->bookmarkManagerClicked(); + break; #if PROFILE_MOBILE - case FIND_ON_PAGE: - itemData->moreMenuUI->closeMoreMenuClicked(); - itemData->moreMenuUI->findOnPageClicked(); - break; - case ADD_TO_BOOKMARK: - if (!itemData->moreMenuUI->m_blockThumbnails) { - elm_object_focus_allow_set(itemData->moreMenuUI->m_gengrid, EINA_FALSE); - boost::optional<bool> bookmark = itemData->moreMenuUI->isBookmark(); - if (bookmark) - itemData->moreMenuUI->bookmarkFlowClicked(*bookmark); - else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - } - break; + case FIND_ON_PAGE: + itemData->moreMenuUI->closeMoreMenuClicked(); + itemData->moreMenuUI->findOnPageClicked(); + break; + case ADD_TO_BOOKMARK: + if (!itemData->moreMenuUI->m_blockThumbnails) { + elm_object_focus_allow_set(itemData->moreMenuUI->m_gengrid, + EINA_FALSE); + boost::optional < bool > bookmark = + itemData->moreMenuUI->isBookmark(); + if (bookmark) + itemData->moreMenuUI->bookmarkFlowClicked(*bookmark); + else + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + break; #ifdef READER_MODE_ENABLED - case READER_MODE: - //TODO: Implement reader mode - break; + case READER_MODE: + //TODO: Implement reader mode + break; #endif #else #ifdef READER_MODE_ENABLED - case READER_MODE: - //TODO: Implement reader mode - break; + case READER_MODE: + //TODO: Implement reader mode + break; #endif - case SCREEN_ZOOM: - itemData->moreMenuUI->zoomUIClicked(); - break; + case SCREEN_ZOOM: + itemData->moreMenuUI->zoomUIClicked(); + break; #ifdef START_MINIBROWSER_ENABLED - case START_MINIBROWSER: - //TODO: Implement minibrowser launching - break; + case START_MINIBROWSER: + //TODO: Implement minibrowser launching + break; #endif - case VIEW_MOBILE_WEB: - itemData->moreMenuUI->switchToMobileMode(); - itemData->moreMenuUI->m_desktopMode = false; - itemData->moreMenuUI->closeMoreMenuClicked(); - break; - case VIEW_DESKTOP_WEB: - itemData->moreMenuUI->switchToDesktopMode(); - itemData->moreMenuUI->m_desktopMode = true; - itemData->moreMenuUI->closeMoreMenuClicked(); - break; - case EXIT_BROWSER: - _exitClicked(); - break; + case VIEW_MOBILE_WEB: + itemData->moreMenuUI->switchToMobileMode(); + itemData->moreMenuUI->m_desktopMode = false; + itemData->moreMenuUI->closeMoreMenuClicked(); + break; + case VIEW_DESKTOP_WEB: + itemData->moreMenuUI->switchToDesktopMode(); + itemData->moreMenuUI->m_desktopMode = true; + itemData->moreMenuUI->closeMoreMenuClicked(); + break; + case EXIT_BROWSER: + _exitClicked(); + break; #endif - default: - BROWSER_LOGD("[%s:%d] Warning: Unhandled button.", __PRETTY_FUNCTION__, __LINE__); - break; - } + default: + BROWSER_LOGD("[%s:%d] Warning: Unhandled button.", + __PRETTY_FUNCTION__, __LINE__); + break; + } + } } -} -void MoreMenuUI::_exitClicked() -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - elm_exit(); -} + void MoreMenuUI::_exitClicked() + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + elm_exit(); + } -void MoreMenuUI::setFocus(Eina_Bool focusable) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - elm_object_tree_focus_allow_set(getContent(), focusable); - if (focusable == EINA_TRUE) - elm_object_focus_set(elm_object_part_content_get(m_current_tab_bar, "close_click"), focusable); -} + void MoreMenuUI::setFocus(Eina_Bool focusable) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + elm_object_tree_focus_allow_set(getContent(), focusable); + if (focusable == EINA_TRUE) + elm_object_focus_set(elm_object_part_content_get + (m_current_tab_bar, "close_click"), focusable); + } #if PROFILE_MOBILE -void MoreMenuUI::shouldShowFindOnPage(bool show) -{ - m_shouldShowFindOnPage = show; -} + void MoreMenuUI::shouldShowFindOnPage(bool show) + { + m_shouldShowFindOnPage = show; + } -void MoreMenuUI::blockThumbnails(bool blockThumbnails) -{ - m_blockThumbnails = blockThumbnails; -} + void MoreMenuUI::blockThumbnails(bool blockThumbnails) + { + m_blockThumbnails = blockThumbnails; + } #endif #if !PROFILE_MOBILE -void MoreMenuUI::createFocusVector() -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - m_focusManager.addItem(elm_object_part_content_get(m_current_tab_bar, "close_click")); - m_focusManager.addItem(m_bookmarkButton); - m_focusManager.addItem(m_gengrid); - m_focusManager.setIterator(); -} + void MoreMenuUI::createFocusVector() + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + m_focusManager. + addItem(elm_object_part_content_get + (m_current_tab_bar, "close_click")); + m_focusManager.addItem(m_bookmarkButton); + m_focusManager.addItem(m_gengrid); + m_focusManager.setIterator(); + } #endif -} + } } diff --git a/services/MoreMenuUI/MoreMenuUI.h b/services/MoreMenuUI/MoreMenuUI.h index 2433d1f2..1eb49b7e 100755 --- a/services/MoreMenuUI/MoreMenuUI.h +++ b/services/MoreMenuUI/MoreMenuUI.h @@ -39,140 +39,155 @@ #define M_UNUSED(x) (void)(x) -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -class SimpleUI; -enum ItemType { + class SimpleUI; + enum ItemType + { #if PROFILE_MOBILE - ADD_TO_BOOKMARK, + ADD_TO_BOOKMARK, #ifdef READER_MODE_ENABLED - READER_MODE, + READER_MODE, #endif - HISTORY, - BOOKMARK_MANAGER, - SETTINGS, - FIND_ON_PAGE + HISTORY, + BOOKMARK_MANAGER, + SETTINGS, + FIND_ON_PAGE #else #ifdef READER_MODE_ENABLED - READER_MODE, + READER_MODE, #endif - BOOKMARK_MANAGER, - HISTORY, - SCREEN_ZOOM, + BOOKMARK_MANAGER, + HISTORY, + SCREEN_ZOOM, #ifdef START_MINIBROWSER_ENABLED - START_MINIBROWSER, + START_MINIBROWSER, #endif - VIEW_MOBILE_WEB, - VIEW_DESKTOP_WEB, - SETTINGS, - EXIT_BROWSER + VIEW_MOBILE_WEB, + VIEW_DESKTOP_WEB, + SETTINGS, + EXIT_BROWSER #endif -} item; - -class BROWSER_EXPORT MoreMenuUI - : public tizen_browser::interfaces::AbstractUIComponent - , public tizen_browser::core::AbstractService -{ -public: - MoreMenuUI(); - ~MoreMenuUI(); - - //AbstractUIComponent interface methods - void init(Evas_Object* parent); - Evas_Object* getContent(); - void showUI(); - void hideUI(); - bool isVisible() { return m_isVisible; } - - void setDesktopMode(bool desktopMode) {m_desktopMode = desktopMode;} - - void showCurrentTab(); - virtual std::string getName(); - void setFavIcon(tools::BrowserImagePtr favicon); - void setWebTitle(const std::string& title); - void setURL(const std::string& url); - void setHomePageInfo(); - - void changeBookmarkStatus(bool data); - void enableAddToBookmarkButton(bool data); - void createToastPopup(const char* text); - void setFocus(Eina_Bool focusable); + } item; + + class BROWSER_EXPORT MoreMenuUI:public tizen_browser::interfaces:: + AbstractUIComponent, public tizen_browser::core::AbstractService + { + public: + MoreMenuUI(); + ~MoreMenuUI(); + + //AbstractUIComponent interface methods + void init(Evas_Object * parent); + Evas_Object *getContent(); + void showUI(); + void hideUI(); + bool isVisible() + { + return m_isVisible; + } + + void setDesktopMode(bool desktopMode) + { + m_desktopMode = desktopMode; + } + + void showCurrentTab(); + virtual std::string getName(); + void setFavIcon(tools::BrowserImagePtr favicon); + void setWebTitle(const std::string & title); + void setURL(const std::string & url); + void setHomePageInfo(); + + void changeBookmarkStatus(bool data); + void enableAddToBookmarkButton(bool data); + void createToastPopup(const char *text); + void setFocus(Eina_Bool focusable); #if PROFILE_MOBILE - void updateBookmarkButton(); - void blockThumbnails(bool blockThumbnails); - void shouldShowFindOnPage(bool show); - void resetContent(); + void updateBookmarkButton(); + void blockThumbnails(bool blockThumbnails); + void shouldShowFindOnPage(bool show); + void resetContent(); - boost::signals2::signal<void ()> findOnPageClicked; - boost::signals2::signal<bool ()> isRotated; + boost::signals2::signal < void() > findOnPageClicked; + boost::signals2::signal < bool() > isRotated; #endif - boost::signals2::signal<void (int)> addToBookmarkClicked; - boost::signals2::signal<void ()> bookmarkManagerClicked; - boost::signals2::signal<void ()> historyUIClicked; - boost::signals2::signal<void ()> settingsClicked; - boost::signals2::signal<void ()> closeMoreMenuClicked; - boost::signals2::signal<void ()> zoomUIClicked; - boost::signals2::signal<void ()> switchToMobileMode; - boost::signals2::signal<void ()> switchToDesktopMode; - boost::signals2::signal<bool ()> isBookmark; - boost::signals2::signal<void (bool)> bookmarkFlowClicked; -private: - Elm_Gengrid_Item_Class* createItemClass(); - void createMoreMenuLayout(); + boost::signals2::signal < void(int) > addToBookmarkClicked; + boost::signals2::signal < void() > bookmarkManagerClicked; + boost::signals2::signal < void() > historyUIClicked; + boost::signals2::signal < void() > settingsClicked; + boost::signals2::signal < void() > closeMoreMenuClicked; + boost::signals2::signal < void() > zoomUIClicked; + boost::signals2::signal < void() > switchToMobileMode; + boost::signals2::signal < void() > switchToDesktopMode; + boost::signals2::signal < bool() > isBookmark; + boost::signals2::signal < void(bool) > bookmarkFlowClicked; + private: + Elm_Gengrid_Item_Class * createItemClass(); + void createMoreMenuLayout(); #if PROFILE_MOBILE - void deleteMoreMenuLayout(); + void deleteMoreMenuLayout(); #endif - void createGengrid(); - void addItems(); - void addItem(ItemType item); - void clearItems(); - static char* _grid_text_get(void *data, Evas_Object *obj, const char *part); - static Evas_Object * _grid_content_get(void *data, Evas_Object *obj, const char *part); - static void _thumbSelected(void * data, Evas_Object * obj, void * event_info); - static void _exitClicked(); + void createGengrid(); + void addItems(); + void addItem(ItemType item); + void clearItems(); + static char *_grid_text_get(void *data, Evas_Object * obj, + const char *part); + static Evas_Object *_grid_content_get(void *data, Evas_Object * obj, + const char *part); + static void _thumbSelected(void *data, Evas_Object * obj, + void *event_info); + static void _exitClicked(); #if !PROFILE_MOBILE - void createFocusVector(); + void createFocusVector(); #endif - void setDocIcon(); - - static void _bookmarkButton_clicked(void *data, Evas_Object *obj, void *event_info); - static void _close_clicked(void *data, Evas_Object *obj, void *event_info); - - static void _timeout(void *data, Evas_Object *obj, void *event_info); - - static void __cb_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void __cb_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info); - Evas_Object *m_current_tab_bar; - Evas_Object *m_mm_layout; - Evas_Object *m_gengrid; - Evas_Object *m_parent; - Evas_Object *m_toastPopup; - Evas_Object *m_icon; - Evas_Object *m_bookmarkIcon; - Evas_Object *m_bookmarkButton; - Elm_Gengrid_Item_Class * m_item_class; - std::map<ItemType,Elm_Object_Item*> m_map_menu_views; - std::string m_edjFilePath; - bool m_gengridSetup; - bool m_desktopMode; + void setDocIcon(); + + static void _bookmarkButton_clicked(void *data, Evas_Object * obj, + void *event_info); + static void _close_clicked(void *data, Evas_Object * obj, + void *event_info); + + static void _timeout(void *data, Evas_Object * obj, void *event_info); + + static void __cb_mouse_in(void *data, Evas * e, Evas_Object * obj, + void *event_info); + static void __cb_mouse_out(void *data, Evas * e, Evas_Object * obj, + void *event_info); + Evas_Object *m_current_tab_bar; + Evas_Object *m_mm_layout; + Evas_Object *m_gengrid; + Evas_Object *m_parent; + Evas_Object *m_toastPopup; + Evas_Object *m_icon; + Evas_Object *m_bookmarkIcon; + Evas_Object *m_bookmarkButton; + Elm_Gengrid_Item_Class *m_item_class; + std::map < ItemType, Elm_Object_Item * >m_map_menu_views; + std::string m_edjFilePath; + bool m_gengridSetup; + bool m_desktopMode; #if PROFILE_MOBILE - bool m_shouldShowFindOnPage; - bool m_blockThumbnails; - const unsigned int GENGRID_ITEM_WIDTH = 228; - const unsigned int GENGRID_ITEM_HEIGHT = 213; - const unsigned int GENGRID_ITEM_WIDTH_LANDSCAPE = 208; - const unsigned int GENGRID_ITEM_HEIGHT_LANDSCAPE = 213; + bool m_shouldShowFindOnPage; + bool m_blockThumbnails; + const unsigned int GENGRID_ITEM_WIDTH = 228; + const unsigned int GENGRID_ITEM_HEIGHT = 213; + const unsigned int GENGRID_ITEM_WIDTH_LANDSCAPE = 208; + const unsigned int GENGRID_ITEM_HEIGHT_LANDSCAPE = 213; #else - FocusManager m_focusManager; - const unsigned int GENGRID_ITEM_WIDTH = 364; - const unsigned int GENGRID_ITEM_HEIGHT = 320; + FocusManager m_focusManager; + const unsigned int GENGRID_ITEM_WIDTH = 364; + const unsigned int GENGRID_ITEM_HEIGHT = 320; #endif - bool m_isVisible; -}; + bool m_isVisible; + }; -} + } } #endif // BOOKMARKSUI_H diff --git a/services/PlatformInputManager/PlatformInputManager.cpp b/services/PlatformInputManager/PlatformInputManager.cpp index 49126dcd..b03eb66c 100644..100755 --- a/services/PlatformInputManager/PlatformInputManager.cpp +++ b/services/PlatformInputManager/PlatformInputManager.cpp @@ -37,128 +37,136 @@ namespace tizen_browser { -namespace services -{ + namespace services + { -EXPORT_SERVICE(PlatformInputManager, "org.tizen.browser.platforminputmanager") + EXPORT_SERVICE(PlatformInputManager, + "org.tizen.browser.platforminputmanager") -PlatformInputManager::PlatformInputManager() + PlatformInputManager::PlatformInputManager() #if PROFILE_MOBILE - : m_HWKeyCallbackRegistered(false) + :m_HWKeyCallbackRegistered(false) #endif -{ - -} + { + } -void PlatformInputManager::init(Evas_Object* mainWindow) -{ - M_ASSERT(mainWindow); - //Suppress compilation warning - (void) mainWindow; - ecore_event_filter_add(NULL, __filter, NULL, this); -} + void PlatformInputManager::init(Evas_Object * mainWindow) + { + M_ASSERT(mainWindow); + //Suppress compilation warning + (void) mainWindow; + ecore_event_filter_add(NULL, __filter, NULL, this); + } #if PROFILE_MOBILE -void PlatformInputManager::registerHWKeyCallback(Evas_Object* view) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(view); - if (m_HWKeyCallbackRegistered) - return; - eext_object_event_callback_add(view, EEXT_CALLBACK_BACK, onHWBack, this); - eext_object_event_callback_add(view, EEXT_CALLBACK_MORE, onHWMore, this); - m_HWKeyCallbackRegistered = true; -} + void PlatformInputManager::registerHWKeyCallback(Evas_Object * view) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(view); + if (m_HWKeyCallbackRegistered) + return; + eext_object_event_callback_add(view, EEXT_CALLBACK_BACK, onHWBack, + this); + eext_object_event_callback_add(view, EEXT_CALLBACK_MORE, onHWMore, + this); + m_HWKeyCallbackRegistered = true; + } -void PlatformInputManager::unregisterHWKeyCallback(Evas_Object* view) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(view); - if (!m_HWKeyCallbackRegistered) - return; - eext_object_event_callback_del(view, EEXT_CALLBACK_BACK, onHWBack); - eext_object_event_callback_del(view, EEXT_CALLBACK_MORE, onHWMore); - m_HWKeyCallbackRegistered = false; -} + void PlatformInputManager::unregisterHWKeyCallback(Evas_Object * view) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(view); + if (!m_HWKeyCallbackRegistered) + return; + eext_object_event_callback_del(view, EEXT_CALLBACK_BACK, onHWBack); + eext_object_event_callback_del(view, EEXT_CALLBACK_MORE, onHWMore); + m_HWKeyCallbackRegistered = false; + } -void PlatformInputManager::onHWBack(void* data, Evas_Object*, void*) -{ - PlatformInputManager *self = static_cast<PlatformInputManager*>(data); - self->backPressed(); -} + void PlatformInputManager::onHWBack(void *data, Evas_Object *, void *) + { + PlatformInputManager *self = + static_cast < PlatformInputManager * >(data); + self->backPressed(); + } -void PlatformInputManager::onHWMore(void* data, Evas_Object*, void*) -{ - PlatformInputManager *self = static_cast<PlatformInputManager*>(data); - self->menuButtonPressed(); -} + void PlatformInputManager::onHWMore(void *data, Evas_Object *, void *) + { + PlatformInputManager *self = + static_cast < PlatformInputManager * >(data); + self->menuButtonPressed(); + } #endif -Eina_Bool PlatformInputManager::__filter(void *data, void */*loop_data*/, int type, void *event) -{ - PlatformInputManager *self = static_cast<PlatformInputManager*>(data); + Eina_Bool PlatformInputManager::__filter(void *data, + void * /*loop_data */ , int type, + void *event) + { + PlatformInputManager *self = + static_cast < PlatformInputManager * >(data); - if (type == ECORE_EVENT_KEY_DOWN) { - M_ASSERT(event); - Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event); + if (type == ECORE_EVENT_KEY_DOWN) { + M_ASSERT(event); + Ecore_Event_Key *ev = static_cast < Ecore_Event_Key * >(event); - if(!ev->keyname) - return EINA_TRUE; + if (!ev->keyname) + return EINA_TRUE; - BROWSER_LOGD("Pressed key: %s", ev->keyname); - const std::string keyName = ev->keyname; + BROWSER_LOGD("Pressed key: %s", ev->keyname); + const std::string keyName = ev->keyname; - /** + /** * Because MENU button launches org.tizen.menu * we use blue 'D' button on remote control or F4 on keyboard as substitution of MENU button */ - if(!keyName.compare("KEY_MENU") || !keyName.compare("KEY_BLUE")) { - self->menuPressed(); - return EINA_FALSE; - } - - if(!keyName.compare("KEY_RETURN")) - self->returnPressed(); - else if(!keyName.compare("KEY_LEFT")) - self->leftPressed(); - else if(!keyName.compare("KEY_RIGHT")) - self->rightPressed(); - else if(!keyName.compare("KEY_ENTER")) - self->enterPressed(); + if (!keyName.compare("KEY_MENU") || !keyName.compare("KEY_BLUE")) { + self->menuPressed(); + return EINA_FALSE; + } + + if (!keyName.compare("KEY_RETURN")) + self->returnPressed(); + else if (!keyName.compare("KEY_LEFT")) + self->leftPressed(); + else if (!keyName.compare("KEY_RIGHT")) + self->rightPressed(); + else if (!keyName.compare("KEY_ENTER")) + self->enterPressed(); #if PROFILE_MOBILE - else if(!keyName.compare("XF86Back")) - self->XF86BackPressed(); + else if (!keyName.compare("XF86Back")) + self->XF86BackPressed(); #else - else if(!keyName.compare("F11") || !keyName.compare("XF86Back")) - self->backPressed(); - else if(!keyName.compare("XF86Red")) // F4 - Red - self->redPressed(); - else if(!keyName.compare("XF86Green")) // F5 - Green - self->greenPressed(); - else if(!keyName.compare("XF86Yellow")) // F6 - Yellow - self->yellowPressed(); - else if(!keyName.compare("XF86Blue")) // F7 - Blue - self->bluePressed(); + else if (!keyName.compare("F11") || !keyName.compare("XF86Back")) + self->backPressed(); + else if (!keyName.compare("XF86Red")) // F4 - Red + self->redPressed(); + else if (!keyName.compare("XF86Green")) // F5 - Green + self->greenPressed(); + else if (!keyName.compare("XF86Yellow")) // F6 - Yellow + self->yellowPressed(); + else if (!keyName.compare("XF86Blue")) // F7 - Blue + self->bluePressed(); #endif - else if(!keyName.compare("Escape")) - self->escapePressed(); + else if (!keyName.compare("Escape")) + self->escapePressed(); - } else if(type == ECORE_EVENT_KEY_UP) { - M_ASSERT(event); - Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event); + } else if (type == ECORE_EVENT_KEY_UP) { + M_ASSERT(event); + Ecore_Event_Key *ev = static_cast < Ecore_Event_Key * >(event); - if(!ev->keyname) - return EINA_TRUE; + if (!ev->keyname) + return EINA_TRUE; - BROWSER_LOGD("Released key: %s", ev->keyname); - } else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { - M_ASSERT(event); - Ecore_Event_Mouse_Button *ev = static_cast<Ecore_Event_Mouse_Button *>(event); - self->mouseClicked(ev->x, ev->y); + BROWSER_LOGD("Released key: %s", ev->keyname); + } else if (type == ECORE_EVENT_MOUSE_BUTTON_DOWN) { + M_ASSERT(event); + Ecore_Event_Mouse_Button *ev = + static_cast < Ecore_Event_Mouse_Button * >(event); + self->mouseClicked(ev->x, ev->y); + } + return EINA_TRUE; } - return EINA_TRUE; -} -} + } } diff --git a/services/PlatformInputManager/PlatformInputManager.h b/services/PlatformInputManager/PlatformInputManager.h index a2a8e107..0d956ecb 100644..100755 --- a/services/PlatformInputManager/PlatformInputManager.h +++ b/services/PlatformInputManager/PlatformInputManager.h @@ -29,77 +29,80 @@ namespace tizen_browser { -namespace services -{ + namespace services + { -class BROWSER_EXPORT PlatformInputManager : public tizen_browser::core::AbstractService -{ -public: + class BROWSER_EXPORT PlatformInputManager:public tizen_browser::core:: + AbstractService + { + public: /** * @brief Default constructor with variable initialization. */ - PlatformInputManager(); + PlatformInputManager(); /** * @brief Initialization of the object, adding event filter, setting cursor to be always visible. */ - void init(Evas_Object *mainWindow); + void init(Evas_Object * mainWindow); /** * Signals emitted after certain button on keyboard/remote controller press. */ - boost::signals2::signal<void ()> menuPressed; - boost::signals2::signal<void ()> returnPressed; - boost::signals2::signal<void ()> enterPressed; - boost::signals2::signal<void ()> leftPressed; - boost::signals2::signal<void ()> rightPressed; - boost::signals2::signal<void ()> backPressed; - boost::signals2::signal<void ()> escapePressed; + boost::signals2::signal < void() > menuPressed; + boost::signals2::signal < void() > returnPressed; + boost::signals2::signal < void() > enterPressed; + boost::signals2::signal < void() > leftPressed; + boost::signals2::signal < void() > rightPressed; + boost::signals2::signal < void() > backPressed; + boost::signals2::signal < void() > escapePressed; #if PROFILE_MOBILE - boost::signals2::signal<void ()> XF86BackPressed; - boost::signals2::signal<void ()> menuButtonPressed; + boost::signals2::signal < void() > XF86BackPressed; + boost::signals2::signal < void() > menuButtonPressed; #else - boost::signals2::signal<void ()> redPressed; - boost::signals2::signal<void ()> greenPressed; - boost::signals2::signal<void ()> yellowPressed; - boost::signals2::signal<void ()> bluePressed; + boost::signals2::signal < void() > redPressed; + boost::signals2::signal < void() > greenPressed; + boost::signals2::signal < void() > yellowPressed; + boost::signals2::signal < void() > bluePressed; #endif - boost::signals2::signal<void (int, int)> mouseClicked; + boost::signals2::signal < void(int, int) > mouseClicked; /** * @brief Returns current service's name. */ - virtual std::string getName(); + virtual std::string getName(); #if PROFILE_MOBILE - void unregisterHWKeyCallback(Evas_Object* view); - void registerHWKeyCallback(Evas_Object* view); + void unregisterHWKeyCallback(Evas_Object * view); + void registerHWKeyCallback(Evas_Object * view); #endif -private: + private: /** * @brief Struct holding parameters of mouse movement. * It is used in pointer mode to simulate mouse move after pressing arrows. */ - struct MouseMovementParams { - bool moveMousePointer; - int xMod, yMod; - int counter, speed; - }; + struct MouseMovementParams + { + bool moveMousePointer; + int xMod, yMod; + int counter, speed; + }; #if PROFILE_MOBILE - bool m_HWKeyCallbackRegistered; - static void onHWBack(void* data, Evas_Object*, void*); - static void onHWMore(void* data, Evas_Object*, void*); + bool m_HWKeyCallbackRegistered; + static void onHWBack(void *data, Evas_Object *, void *); + static void onHWMore(void *data, Evas_Object *, void *); #endif /** * @brief It process every input event and handles it if necessary. */ - static Eina_Bool __filter(void */*data*/, void */*loop_data*/, int /*type*/, void */*event*/); -}; + static Eina_Bool __filter(void * /*data */ , void * /*loop_data */ , + int /*type */ , void * /*event */); + }; -} + } } -#endif // PLATFORMINPUTMANAGER_H +#endif // PLATFORMINPUTMANAGER_H diff --git a/services/QuickAccess/DetailPopup.h b/services/QuickAccess/DetailPopup.h index 3b8670b1..9e7d406e 100644..100755 --- a/services/QuickAccess/DetailPopup.h +++ b/services/QuickAccess/DetailPopup.h @@ -45,7 +45,7 @@ namespace base_ui{ bool isVisible() { return m_layout; } - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURL; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURL; static const int HISTORY_ITEMS_NO; private: diff --git a/services/QuickAccess/QuickAccess.h b/services/QuickAccess/QuickAccess.h index 7b80c996..d24900bc 100644..100755 --- a/services/QuickAccess/QuickAccess.h +++ b/services/QuickAccess/QuickAccess.h @@ -64,12 +64,12 @@ public: void refreshFocusChain(); #endif - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, int)> mostVisitedTileClicked; - boost::signals2::signal<void (std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURL; - boost::signals2::signal<void ()> getMostVisitedItems; - boost::signals2::signal<void ()> getBookmarksItems; - boost::signals2::signal<void ()> bookmarkManagerClicked; - boost::signals2::signal<void ()> switchViewToWebPage; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::services::HistoryItem>, int)> mostVisitedTileClicked; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::services::HistoryItem>, bool)> openURL; + boost::signals2::signal<void()> getMostVisitedItems; + boost::signals2::signal<void()> getBookmarksItems; + boost::signals2::signal<void()> bookmarkManagerClicked; + boost::signals2::signal<void()> switchViewToWebPage; static const int MAX_THUMBNAIL_WIDTH; static const int MAX_THUMBNAIL_HEIGHT; diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.cpp b/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.cpp index 81e001d8..01f78fa8 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.cpp +++ b/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.cpp @@ -338,9 +338,9 @@ Eina_Bool AutoFillFormComposeView::applyEntryData(void) full_name_str = _trim(full_name_str); full_name = full_name_str.c_str(); - if (full_name && strlen(full_name) && !isEntryHasOnlySpace(full_name)) + if (full_name && strlen(full_name) && !isEntryHasOnlySpace(full_name)) { m_itemForCompose->setName(full_name); - else { + } else { elm_object_focus_set(m_cancelButton, EINA_TRUE); // Closing virtual keyboard by changing the focus*/ return EINA_FALSE; } @@ -364,7 +364,6 @@ Eina_Bool AutoFillFormComposeView::applyEntryData(void) m_itemForCompose->setEmailAddress(email); if (m_itemForCompose->getItemComposeMode() == profile_edit) { - m_editErrorcode = m_itemForCompose->updateItem(); if (m_editErrorcode == profile_edit_failed || m_editErrorcode == profile_already_exist) { BROWSER_LOGD("Update failed!"); @@ -432,8 +431,7 @@ void AutoFillFormComposeView::__entry_changed_cb(void* data, Evas_Object* obj, v const char* text = elm_entry_entry_get(obj); if (text && strlen(text) > 0) { elm_object_signal_emit(cb_data->editfield, "show,clear,button,signal", ""); - } - else { + } else { elm_object_signal_emit(cb_data->editfield, "hide,clear,button,signal", ""); } @@ -444,7 +442,6 @@ void AutoFillFormComposeView::__entry_changed_cb(void* data, Evas_Object* obj, v elm_object_signal_emit(view->m_action_bar, "dim,done,button,signal", "but_vis"); elm_object_disabled_set(view->m_doneButton, EINA_TRUE); } - } void AutoFillFormComposeView::__entry_clicked_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.h b/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.h index d47f1ace..d47f1ace 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.h +++ b/services/SettingsUI/AutoFillForm/AutoFillFormComposeView.h diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormItem.cpp b/services/SettingsUI/AutoFillForm/AutoFillFormItem.cpp index cd0753f8..070a06b5 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormItem.cpp +++ b/services/SettingsUI/AutoFillForm/AutoFillFormItem.cpp @@ -30,7 +30,7 @@ AutoFillFormItem::AutoFillFormItem(AutoFillFormItemData *item_data) m_itemData.profile_id = -1; if (item_data) { - m_itemData.profile_id= item_data->profile_id; + m_itemData.profile_id = item_data->profile_id; m_itemData.name = item_data->name; m_itemData.company = item_data->company; m_itemData.primary_address = item_data->primary_address; diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormItem.h b/services/SettingsUI/AutoFillForm/AutoFillFormItem.h index d9ce0594..d9ce0594 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormItem.h +++ b/services/SettingsUI/AutoFillForm/AutoFillFormItem.h diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormListView.cpp b/services/SettingsUI/AutoFillForm/AutoFillFormListView.cpp index fe202325..ea4acc87 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormListView.cpp +++ b/services/SettingsUI/AutoFillForm/AutoFillFormListView.cpp @@ -20,11 +20,13 @@ #include "AutoProfileDeleteView.h" #include "BrowserLogger.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -AutoFillFormListView::AutoFillFormListView(AutoFillFormManager *affm) - : m_manager(affm) + AutoFillFormListView::AutoFillFormListView(AutoFillFormManager * affm) + :m_manager(affm) , m_parent(nullptr) , m_mainLayout(nullptr) , m_add_btn(nullptr) @@ -32,220 +34,267 @@ AutoFillFormListView::AutoFillFormListView(AutoFillFormManager *affm) , m_genlist(nullptr) , m_action_bar(nullptr) , m_itemClass(nullptr) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("SettingsUI/SettingsMobileUI.edj"); -} - -AutoFillFormListView::~AutoFillFormListView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - evas_object_smart_callback_del(m_add_btn, "clicked", __add_profile_button_cb); - evas_object_smart_callback_del(m_del_btn, "clicked", __delete_profile_button_cb); - - if (m_genlist) { - elm_genlist_clear(m_genlist); - evas_object_del(m_genlist); - } - if (m_mainLayout) { - evas_object_hide(m_mainLayout); - evas_object_del(m_mainLayout); + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SettingsUI/SettingsMobileUI.edj"); } - m_mainLayout = nullptr; - m_genlist = nullptr; -} - -Evas_Object* AutoFillFormListView::show(Evas_Object* parent, Evas_Object* action_bar) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - m_action_bar = action_bar; - elm_object_translatable_part_text_set(m_action_bar, "settings_title", "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); - - m_mainLayout = createMainLayout(parent); - evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_mainLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (!m_mainLayout) { - BROWSER_LOGE("createMainLayout failed"); - return EINA_FALSE; + AutoFillFormListView::~AutoFillFormListView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + evas_object_smart_callback_del(m_add_btn, "clicked", + __add_profile_button_cb); + evas_object_smart_callback_del(m_del_btn, "clicked", + __delete_profile_button_cb); + + if (m_genlist) + { + elm_genlist_clear(m_genlist); + evas_object_del(m_genlist); + } + if (m_mainLayout) + { + evas_object_hide(m_mainLayout); + evas_object_del(m_mainLayout); + } + m_mainLayout = nullptr; + m_genlist = nullptr; } - m_add_btn = elm_button_add(m_mainLayout); - elm_object_style_set(m_add_btn, "basic_button"); - evas_object_smart_callback_add(m_add_btn, "clicked", __add_profile_button_cb, this); - elm_object_part_content_set(m_mainLayout, "add_profile_button", m_add_btn); - - m_del_btn = elm_button_add(m_mainLayout); - elm_object_style_set(m_del_btn, "basic_button"); - evas_object_smart_callback_add(m_del_btn, "clicked", __delete_profile_button_cb, this); - elm_object_part_content_set(m_mainLayout, "delete_profile_button", m_del_btn); - - evas_object_show(m_mainLayout); - elm_layout_content_set(parent, "autofill_sub_swallow", m_mainLayout); - m_parent = parent; - - return m_mainLayout; -} - -void AutoFillFormListView::refreshView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_genlist_clear(m_genlist); - appendGenlist(m_genlist); -} - -Evas_Object *AutoFillFormListView::createMainLayout(Evas_Object *parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Evas_Object *layout = elm_layout_add(parent); - if (!layout) { - BROWSER_LOGD("elm_layout_add failed"); - return nullptr; - } - elm_layout_file_set(layout, m_edjFilePath.c_str(), "afflv-layout"); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_object_translatable_part_text_set(layout, "title_text", "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); - elm_object_translatable_part_text_set(layout, "profile_text", "IDS_BR_HEADER_PROFILES"); - elm_object_translatable_part_text_set(layout, "add_profile_text", "IDS_BR_OPT_ADD"); - elm_object_translatable_part_text_set(layout, "delete_profile_text", "IDS_BR_SK_DELETE_ABB"); - - m_genlist = createGenlist(layout); - if (!m_genlist) { - BROWSER_LOGE("elm_genlist_add failed"); - return nullptr; + Evas_Object *AutoFillFormListView::show(Evas_Object * parent, + Evas_Object * action_bar) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + + m_action_bar = action_bar; + elm_object_translatable_part_text_set(m_action_bar, "settings_title", + "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); + + m_mainLayout = createMainLayout(parent); + evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_mainLayout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + if (!m_mainLayout) { + BROWSER_LOGE("createMainLayout failed"); + return EINA_FALSE; + } + + m_add_btn = elm_button_add(m_mainLayout); + elm_object_style_set(m_add_btn, "basic_button"); + evas_object_smart_callback_add(m_add_btn, "clicked", + __add_profile_button_cb, this); + elm_object_part_content_set(m_mainLayout, "add_profile_button", + m_add_btn); + + m_del_btn = elm_button_add(m_mainLayout); + elm_object_style_set(m_del_btn, "basic_button"); + evas_object_smart_callback_add(m_del_btn, "clicked", + __delete_profile_button_cb, this); + elm_object_part_content_set(m_mainLayout, "delete_profile_button", + m_del_btn); + + evas_object_show(m_mainLayout); + elm_layout_content_set(parent, "autofill_sub_swallow", m_mainLayout); + m_parent = parent; + + return m_mainLayout; } - evas_object_show(m_genlist); - elm_object_part_content_set(layout, "afflv_genlist", m_genlist); - return layout; -} -Evas_Object *AutoFillFormListView::createGenlist(Evas_Object *parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Evas_Object *genlist = elm_genlist_add(parent); - evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (!genlist) { - BROWSER_LOGE("elm_genlist_add failed"); - return nullptr; + void AutoFillFormListView::refreshView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_genlist_clear(m_genlist); + appendGenlist(m_genlist); } - m_itemClass = elm_genlist_item_class_new(); - if (!m_itemClass) { - BROWSER_LOGE("elm_genlist_item_class_new for description_item_class failed"); - return EINA_FALSE; + Evas_Object *AutoFillFormListView::createMainLayout(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(parent); + if (!layout) { + BROWSER_LOGD("elm_layout_add failed"); + return nullptr; + } + elm_layout_file_set(layout, m_edjFilePath.c_str(), "afflv-layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_translatable_part_text_set(layout, "title_text", + "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); + elm_object_translatable_part_text_set(layout, "profile_text", + "IDS_BR_HEADER_PROFILES"); + elm_object_translatable_part_text_set(layout, "add_profile_text", + "IDS_BR_OPT_ADD"); + elm_object_translatable_part_text_set(layout, "delete_profile_text", + "IDS_BR_SK_DELETE_ABB"); + + m_genlist = createGenlist(layout); + if (!m_genlist) { + BROWSER_LOGE("elm_genlist_add failed"); + return nullptr; + } + evas_object_show(m_genlist); + elm_object_part_content_set(layout, "afflv_genlist", m_genlist); + return layout; } - m_itemClass->item_style = "afflv_item"; - m_itemClass->func.content_get = nullptr; - - m_itemClass->func.text_get = __text_get_cb; - m_itemClass->func.state_get = nullptr; - m_itemClass->func.del = nullptr; - - m_manager->refreshListView(); - return genlist; -} - -const char *AutoFillFormListView::getEachItemFullName(unsigned int index) -{ - if (m_manager->getAutoFillFormItemCount() == 0) - return nullptr; - return (m_manager->getItemList())[index]->getName(); -} - -Eina_Bool AutoFillFormListView::appendGenlist(Evas_Object *genlist) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - unsigned int item_count = m_manager->getAutoFillFormItemCount(); - BROWSER_LOGD("Item count : [%d]", item_count); - if (item_count > 0) { - for (unsigned int i = 0; i < item_count; i++) { - genlistCallbackData* item_callback_data = new genlistCallbackData; - item_callback_data->menu_index = i; - item_callback_data->user_data = this; - item_callback_data->it = elm_genlist_item_append(genlist, m_itemClass, - item_callback_data, NULL, ELM_GENLIST_ITEM_NONE, __genlist_item_clicked_cb, item_callback_data); - } - if (m_mainLayout) { - elm_object_signal_emit(m_mainLayout, "show,del,button,signal", ""); - elm_object_disabled_set(m_del_btn, false); - } - } - else { - if (m_mainLayout) { - elm_object_signal_emit(m_mainLayout, "dim,del,button,signal", ""); - elm_object_disabled_set(m_del_btn, true); - } + Evas_Object *AutoFillFormListView::createGenlist(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *genlist = elm_genlist_add(parent); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, + EVAS_HINT_FILL); + if (!genlist) { + BROWSER_LOGE("elm_genlist_add failed"); + return nullptr; + } + + m_itemClass = elm_genlist_item_class_new(); + if (!m_itemClass) { + BROWSER_LOGE + ("elm_genlist_item_class_new for description_item_class failed"); + return EINA_FALSE; + } + m_itemClass->item_style = "afflv_item"; + m_itemClass->func.content_get = nullptr; + + m_itemClass->func.text_get = __text_get_cb; + m_itemClass->func.state_get = nullptr; + m_itemClass->func.del = nullptr; + + m_manager->refreshListView(); + + return genlist; } - return EINA_TRUE; -} - -char *AutoFillFormListView::__text_get_cb(void* data, Evas_Object* /*obj*/, const char *part) -{ - BROWSER_LOGD("part[%s]", part); - - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); - AutoFillFormListView *view = static_cast<AutoFillFormListView*>(callback_data->user_data); - - if (!strcmp(part, "item_title")) { - const char *item_full_name = view->getEachItemFullName((unsigned int)callback_data->menu_index); - if (item_full_name) - return strdup(item_full_name); + const char *AutoFillFormListView::getEachItemFullName(unsigned int index) + { + if (m_manager->getAutoFillFormItemCount() == 0) + return nullptr; + return (m_manager->getItemList())[index]->getName(); } - return nullptr; - -} -void AutoFillFormListView::__add_profile_button_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - /* create new profile */ - AutoFillFormListView *list_view = static_cast<AutoFillFormListView*>(data); - list_view->m_manager->showComposeView(); -} + Eina_Bool AutoFillFormListView::appendGenlist(Evas_Object * genlist) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + unsigned int item_count = m_manager->getAutoFillFormItemCount(); + BROWSER_LOGD("Item count : [%d]", item_count); + if (item_count > 0) { + for (unsigned int i = 0; i < item_count; i++) { + genlistCallbackData *item_callback_data = new genlistCallbackData; + item_callback_data->menu_index = i; + item_callback_data->user_data = this; + item_callback_data->it = + elm_genlist_item_append(genlist, m_itemClass, item_callback_data, + NULL, ELM_GENLIST_ITEM_NONE, + __genlist_item_clicked_cb, + item_callback_data); + } + if (m_mainLayout) { + elm_object_signal_emit(m_mainLayout, "show,del,button,signal", ""); + elm_object_disabled_set(m_del_btn, false); + } + } else { + if (m_mainLayout) { + elm_object_signal_emit(m_mainLayout, "dim,del,button,signal", ""); + elm_object_disabled_set(m_del_btn, true); + } + } + + return EINA_TRUE; + } -void AutoFillFormListView::__delete_profile_button_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoFillFormListView *afflv = static_cast<AutoFillFormListView*>(data); - afflv->m_manager->showDeleteView(); -} + char *AutoFillFormListView::__text_get_cb(void *data, + Evas_Object * /*obj */ , + const char *part) + { + BROWSER_LOGD("part[%s]", part); + + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + AutoFillFormListView *view = + static_cast < AutoFillFormListView * >(callback_data->user_data); + + if (!strcmp(part, "item_title")) { + const char *item_full_name = + view->getEachItemFullName((unsigned int) callback_data->menu_index); + if (item_full_name) + return strdup(item_full_name); + } + return nullptr; + } -void AutoFillFormListView::__back_button_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoFillFormListView *list_view = static_cast<AutoFillFormListView*>(data); - list_view->hide(); -} + void AutoFillFormListView::__add_profile_button_cb(void *data, + Evas_Object * /*obj */ + , + void * /*event_info */ + ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + /* create new profile */ + AutoFillFormListView *list_view = + static_cast < AutoFillFormListView * >(data); + list_view->m_manager->showComposeView(); + } -void AutoFillFormListView::__genlist_item_clicked_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void AutoFillFormListView::__delete_profile_button_cb(void *data, + Evas_Object * + /*obj */ , + void * + /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoFillFormListView *afflv = + static_cast < AutoFillFormListView * >(data); + afflv->m_manager->showDeleteView(); + } - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); - AutoFillFormListView *view = static_cast<AutoFillFormListView*>(callback_data->user_data); + void AutoFillFormListView::__back_button_cb(void *data, + Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoFillFormListView *list_view = + static_cast < AutoFillFormListView * >(data); + list_view->hide(); + } - elm_genlist_item_selected_set(callback_data->it, EINA_FALSE); - view->m_manager->showComposeView((view->m_manager->getItemList())[callback_data->menu_index]); -} + void AutoFillFormListView::__genlist_item_clicked_cb(void *data, + Evas_Object * + /*obj */ , + void * + /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + AutoFillFormListView *view = + static_cast < AutoFillFormListView * >(callback_data->user_data); + + elm_genlist_item_selected_set(callback_data->it, EINA_FALSE); + view->m_manager-> + showComposeView((view->m_manager->getItemList())[callback_data-> + menu_index]); + } -void AutoFillFormListView::hide() -{ - evas_object_hide(m_mainLayout); - m_manager->listViewBackClicked(); -} + void AutoFillFormListView::hide() + { + evas_object_hide(m_mainLayout); + m_manager->listViewBackClicked(); + } -} + } } diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormListView.h b/services/SettingsUI/AutoFillForm/AutoFillFormListView.h index 382c2f96..382c2f96 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormListView.h +++ b/services/SettingsUI/AutoFillForm/AutoFillFormListView.h diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormManager.cpp b/services/SettingsUI/AutoFillForm/AutoFillFormManager.cpp index b733f787..5b074e07 100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormManager.cpp +++ b/services/SettingsUI/AutoFillForm/AutoFillFormManager.cpp @@ -21,41 +21,43 @@ #include "AutoFillFormComposeView.h" #include "BrowserLogger.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -AutoFillFormManager::AutoFillFormManager(void) + AutoFillFormManager::AutoFillFormManager(void) : m_listView(nullptr) - , m_composer(nullptr) - , m_deleteView(nullptr) - , m_ewkContext(ewk_context_default_get()) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + , m_composer(nullptr) + , m_deleteView(nullptr) + , m_ewkContext(ewk_context_default_get()) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_AutoFillFormItemList = loadEntireItemList(); -} + m_AutoFillFormItemList = loadEntireItemList(); + } -AutoFillFormManager::~AutoFillFormManager(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoFillFormManager::~AutoFillFormManager(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_listView) - delete m_listView; - m_listView = nullptr; + if (m_listView) + delete m_listView; + m_listView = nullptr; - if (m_deleteView) - delete m_deleteView; - m_deleteView = nullptr; + if (m_deleteView) + delete m_deleteView; + m_deleteView = nullptr; - if(m_composer) - delete m_composer; - m_composer = nullptr; -} + if (m_composer) + delete m_composer; + m_composer = nullptr; + } -void AutoFillFormManager::refreshListView() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_timer = ecore_timer_add(0.3, load_list_timer, this); + void AutoFillFormManager::refreshListView() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_timer = ecore_timer_add(0.3, load_list_timer, this); // TODO: Delete above workaround and uncomment bellow when task is fixed. // http://165.213.149.170/jira/browse/TWF-471 // http://165.213.149.170/jira/browse/TWF-541 @@ -63,229 +65,265 @@ void AutoFillFormManager::refreshListView() // loadEntireItemList(); // if (m_listView) // m_listView->refreshView(); -} + } -Eina_Bool AutoFillFormManager::load_list_timer(void *data) -{ - BROWSER_LOGD("[%s,%d]", __func__, __LINE__); - AutoFillFormManager * aff = static_cast<AutoFillFormManager*>(data); + Eina_Bool AutoFillFormManager::load_list_timer(void *data) + { + BROWSER_LOGD("[%s,%d]", __func__, __LINE__); + AutoFillFormManager *aff = static_cast < AutoFillFormManager * >(data); - aff->loadEntireItemList(); - if (aff->m_listView) - aff->m_listView->refreshView(); - if (aff->m_deleteView) - aff->m_deleteView->refreshView(); + aff->loadEntireItemList(); + if (aff->m_listView) + aff->m_listView->refreshView(); + if (aff->m_deleteView) + aff->m_deleteView->refreshView(); - ecore_timer_del(aff->m_timer); - return ECORE_CALLBACK_CANCEL; -} + ecore_timer_del(aff->m_timer); + return ECORE_CALLBACK_CANCEL; + } -std::vector<AutoFillFormItem *> AutoFillFormManager::loadEntireItemList(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::vector < + AutoFillFormItem * >AutoFillFormManager::loadEntireItemList(void) { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_AutoFillFormItemList.clear(); - m_AutoFillFormItemList.clear(); + Eina_List *entire_item_list = + ewk_context_form_autofill_profile_get_all(m_ewkContext); - Eina_List *entire_item_list = ewk_context_form_autofill_profile_get_all(m_ewkContext); + Eina_List *list = nullptr; + void *item_data = nullptr; - Eina_List *list = nullptr; - void *item_data = nullptr; + EINA_LIST_FOREACH(entire_item_list, list, item_data) { + if (item_data) { + Ewk_Autofill_Profile *profile = + static_cast < Ewk_Autofill_Profile * >(item_data); + AutoFillFormItem *item = createNewAutoFillFormItem(profile); + if (item) + m_AutoFillFormItemList.push_back(item); + } + } - EINA_LIST_FOREACH(entire_item_list, list, item_data) { - if (item_data) { - Ewk_Autofill_Profile *profile = static_cast<Ewk_Autofill_Profile*>(item_data); - AutoFillFormItem *item = createNewAutoFillFormItem(profile); - if (item) - m_AutoFillFormItemList.push_back(item); - } + BROWSER_LOGD("----------- List size : [%d] ---------", + m_AutoFillFormItemList.size()); + return m_AutoFillFormItemList; } - BROWSER_LOGD("----------- List size : [%d] ---------", m_AutoFillFormItemList.size()); - return m_AutoFillFormItemList; -} + Eina_Bool AutoFillFormManager::addItemToList(AutoFillFormItem * item) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_AutoFillFormItemList.push_back(item); + return EINA_TRUE; + } -Eina_Bool AutoFillFormManager::addItemToList(AutoFillFormItem *item) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_AutoFillFormItemList.push_back(item); - return EINA_TRUE; -} + Eina_Bool AutoFillFormManager::deleteAutoFillFormItem(AutoFillFormItem * + item) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_AutoFillFormItemList. + erase(std:: + remove_if(m_AutoFillFormItemList.begin(), + m_AutoFillFormItemList.end(), + [&](AutoFillFormItem * el)->Eina_Bool { + return (el->getProfileId() == + item-> + getProfileId())? + ewk_context_form_autofill_profile_remove(m_ewkContext, + item-> + getProfileId + ()) : + EINA_FALSE;}), m_AutoFillFormItemList.end() + ); + return EINA_TRUE; + } -Eina_Bool AutoFillFormManager::deleteAutoFillFormItem(AutoFillFormItem *item) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_AutoFillFormItemList.erase( - std::remove_if( - m_AutoFillFormItemList.begin(), - m_AutoFillFormItemList.end(), - [&](AutoFillFormItem* el) -> Eina_Bool { - return (el->getProfileId() == item->getProfileId()) ? - ewk_context_form_autofill_profile_remove(m_ewkContext, item->getProfileId()) : - EINA_FALSE; - } - ), - m_AutoFillFormItemList.end() - ); - return EINA_TRUE; -} + Eina_Bool AutoFillFormManager::deleteAllAutoFillFormItems(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_AutoFillFormItemList.clear(); -Eina_Bool AutoFillFormManager::deleteAllAutoFillFormItems(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_AutoFillFormItemList.clear(); + Eina_List *entire_item_list = + ewk_context_form_autofill_profile_get_all(m_ewkContext); - Eina_List *entire_item_list = ewk_context_form_autofill_profile_get_all(m_ewkContext); + Eina_List *list = nullptr; + void *item_data = nullptr; - Eina_List *list = nullptr; - void *item_data = nullptr; + EINA_LIST_FOREACH(entire_item_list, list, item_data) { + if (item_data) { + Ewk_Autofill_Profile *profile = + static_cast < Ewk_Autofill_Profile * >(item_data); + ewk_context_form_autofill_profile_remove(m_ewkContext, + ewk_autofill_profile_id_get + (profile)); + } + } - EINA_LIST_FOREACH(entire_item_list, list, item_data) { - if (item_data) { - Ewk_Autofill_Profile *profile = static_cast<Ewk_Autofill_Profile*>(item_data); - ewk_context_form_autofill_profile_remove(m_ewkContext, ewk_autofill_profile_id_get(profile)); - } + return EINA_TRUE; } - return EINA_TRUE; -} - -unsigned int AutoFillFormManager::getAutoFillFormItemCount(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - return m_AutoFillFormItemList.size(); -} - -AutoFillFormItem *AutoFillFormManager::createNewAutoFillFormItem(Ewk_Autofill_Profile *profile) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoFillFormItem *item = nullptr; - if (!profile) - item = new AutoFillFormItem(nullptr); - else { - AutoFillFormItemData *item_data = new AutoFillFormItemData; - if (!item_data) { - BROWSER_LOGE("Malloc failed to get item_data"); - return nullptr; - } - memset(item_data, 0x00, sizeof(AutoFillFormItemData)); - item_data->profile_id = ewk_autofill_profile_id_get(profile); - item_data->name = ewk_autofill_profile_data_get(profile, EWK_PROFILE_NAME); - item_data->company = ewk_autofill_profile_data_get(profile, EWK_PROFILE_COMPANY); - item_data->primary_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS1); - item_data->secondary_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS2); - item_data->city_town = ewk_autofill_profile_data_get(profile, EWK_PROFILE_CITY_TOWN); - item_data->state_province_region = ewk_autofill_profile_data_get(profile, EWK_PROFILE_STATE_PROVINCE_REGION); - item_data->post_code = ewk_autofill_profile_data_get(profile, EWK_PROFILE_ZIPCODE); - item_data->country = ewk_autofill_profile_data_get(profile, EWK_PROFILE_COUNTRY); - item_data->phone_number = ewk_autofill_profile_data_get(profile, EWK_PROFILE_PHONE); - item_data->email_address = ewk_autofill_profile_data_get(profile, EWK_PROFILE_EMAIL); - item_data->activation = false; - item_data->compose_mode = profile_edit; - - item = new AutoFillFormItem(item_data); - delete item_data; - item_data= nullptr; + unsigned int AutoFillFormManager::getAutoFillFormItemCount(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + return m_AutoFillFormItemList.size(); } - return item; -} + AutoFillFormItem *AutoFillFormManager:: + createNewAutoFillFormItem(Ewk_Autofill_Profile * profile) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoFillFormItem *item = nullptr; + if (!profile) { + item = new AutoFillFormItem(nullptr); + } else { + AutoFillFormItemData *item_data = new AutoFillFormItemData; + if (!item_data) { + BROWSER_LOGE("Malloc failed to get item_data"); + return nullptr; + } + memset(item_data, 0x00, sizeof(AutoFillFormItemData)); + item_data->profile_id = ewk_autofill_profile_id_get(profile); + item_data->name = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_NAME); + item_data->company = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_COMPANY); + item_data->primary_address = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS1); + item_data->secondary_address = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_ADDRESS2); + item_data->city_town = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_CITY_TOWN); + item_data->state_province_region = + ewk_autofill_profile_data_get(profile, + EWK_PROFILE_STATE_PROVINCE_REGION); + item_data->post_code = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_ZIPCODE); + item_data->country = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_COUNTRY); + item_data->phone_number = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_PHONE); + item_data->email_address = + ewk_autofill_profile_data_get(profile, EWK_PROFILE_EMAIL); + item_data->activation = false; + item_data->compose_mode = profile_edit; + + item = new AutoFillFormItem(item_data); + delete item_data; + item_data = nullptr; + } + + return item; + } -Evas_Object* AutoFillFormManager::showListView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *AutoFillFormManager::showListView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_listView) - deleteListView(); + if (m_listView) + deleteListView(); - m_listView = new AutoFillFormListView(this); - elm_object_signal_emit(m_action_bar,"back,icon,change", "del_but"); - return m_listView->show(m_parent, m_action_bar); -} + m_listView = new AutoFillFormListView(this); + elm_object_signal_emit(m_action_bar, "back,icon,change", "del_but"); + return m_listView->show(m_parent, m_action_bar); + } -Evas_Object* AutoFillFormManager::showComposeView(AutoFillFormItem *item) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *AutoFillFormManager::showComposeView(AutoFillFormItem * item) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_composer) - deleteComposer(); + if (m_composer) + deleteComposer(); - m_composer = new AutoFillFormComposeView(this, item); + m_composer = new AutoFillFormComposeView(this, item); - return m_composer->show(m_parent, m_action_bar); -} + return m_composer->show(m_parent, m_action_bar); + } -Evas_Object* AutoFillFormManager::showDeleteView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *AutoFillFormManager::showDeleteView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_deleteView) - deleteDeleteView(); + if (m_deleteView) + deleteDeleteView(); - elm_object_signal_emit(m_action_bar,"back,icon,change", "del_but"); - m_deleteView = new AutoProfileDeleteView(this); + elm_object_signal_emit(m_action_bar, "back,icon,change", "del_but"); + m_deleteView = new AutoProfileDeleteView(this); - return m_deleteView->show(m_parent, m_action_bar); -} + return m_deleteView->show(m_parent, m_action_bar); + } -Eina_Bool AutoFillFormManager::deleteListView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_listView) { - delete m_listView; - m_listView = nullptr; + Eina_Bool AutoFillFormManager::deleteListView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_listView) { + delete m_listView; + m_listView = nullptr; + } + return EINA_TRUE; } - return EINA_TRUE; -} -Eina_Bool AutoFillFormManager::deleteComposer(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Eina_Bool AutoFillFormManager::deleteComposer(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_composer) { - delete m_composer; - m_composer = nullptr; + if (m_composer) { + delete m_composer; + m_composer = nullptr; + } + return EINA_TRUE; } - return EINA_TRUE; -} -Eina_Bool AutoFillFormManager::deleteDeleteView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_deleteView) { - delete m_deleteView; - m_deleteView = nullptr; + Eina_Bool AutoFillFormManager::deleteDeleteView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_deleteView) { + delete m_deleteView; + m_deleteView = nullptr; + } + elm_object_signal_emit(m_action_bar, "back,icon,change", "del_but"); + return EINA_TRUE; } - elm_object_signal_emit(m_action_bar, "back,icon,change", "del_but"); - return EINA_TRUE; -} -void AutoFillFormManager::seeAllData(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - for (unsigned int i = 0; i < m_AutoFillFormItemList.size(); i++) { - BROWSER_LOGD("m_AutoFillFormItemList[%d] item - start", i); - BROWSER_LOGD("************************************************************************************"); - BROWSER_LOGD("m_AutoFillFormItemList[%d].id[%d]", i, m_AutoFillFormItemList[i]->getProfileId()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_name[%s]", i, m_AutoFillFormItemList[i]->getName()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_company[%s]", i, m_AutoFillFormItemList[i]->getCompany()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_primary_address[%s]", i, m_AutoFillFormItemList[i]->getPrimaryAddress()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_secondary_address[%s]", i, m_AutoFillFormItemList[i]->getSecondaryAddress2()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_city_town[%s]", i, m_AutoFillFormItemList[i]->getCityTown()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_state_province_region[%s]", i, m_AutoFillFormItemList[i]->getStateProvince()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_post_code[%s]", i, m_AutoFillFormItemList[i]->getPostCode()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_country_region[%s]", i, m_AutoFillFormItemList[i]->getCountry()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_phone_number[%s]", i, m_AutoFillFormItemList[i]->getPhoneNumber()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_email_address[%s]", i, m_AutoFillFormItemList[i]->getEmailAddress()); - BROWSER_LOGD("m_AutoFillFormItemList[%d].m_activation[%d]", i, m_AutoFillFormItemList[i]->getActivation()); - BROWSER_LOGD("************************************************************************************"); - BROWSER_LOGD("m_AutoFillFormItemList[%d] item - end", i); + void AutoFillFormManager::seeAllData(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + for (unsigned int i = 0; i < m_AutoFillFormItemList.size(); i++) { + BROWSER_LOGD("m_AutoFillFormItemList[%d] item - start", i); + BROWSER_LOGD + ("************************************************************************************"); + BROWSER_LOGD("m_AutoFillFormItemList[%d].id[%d]", i, + m_AutoFillFormItemList[i]->getProfileId()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_name[%s]", i, + m_AutoFillFormItemList[i]->getName()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_company[%s]", i, + m_AutoFillFormItemList[i]->getCompany()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_primary_address[%s]", i, + m_AutoFillFormItemList[i]->getPrimaryAddress()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_secondary_address[%s]", i, + m_AutoFillFormItemList[i]->getSecondaryAddress2()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_city_town[%s]", i, + m_AutoFillFormItemList[i]->getCityTown()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_state_province_region[%s]", + i, m_AutoFillFormItemList[i]->getStateProvince()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_post_code[%s]", i, + m_AutoFillFormItemList[i]->getPostCode()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_country_region[%s]", i, + m_AutoFillFormItemList[i]->getCountry()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_phone_number[%s]", i, + m_AutoFillFormItemList[i]->getPhoneNumber()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_email_address[%s]", i, + m_AutoFillFormItemList[i]->getEmailAddress()); + BROWSER_LOGD("m_AutoFillFormItemList[%d].m_activation[%d]", i, + m_AutoFillFormItemList[i]->getActivation()); + BROWSER_LOGD + ("************************************************************************************"); + BROWSER_LOGD("m_AutoFillFormItemList[%d] item - end", i); + } + + return; } - return; -} - -} + } } diff --git a/services/SettingsUI/AutoFillForm/AutoFillFormManager.h b/services/SettingsUI/AutoFillForm/AutoFillFormManager.h index 822d7966..7d40afb7 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoFillFormManager.h +++ b/services/SettingsUI/AutoFillForm/AutoFillFormManager.h @@ -71,7 +71,7 @@ public: static Eina_Bool load_list_timer(void *data); - boost::signals2::signal<void ()> listViewBackClicked; + boost::signals2::signal<void()> listViewBackClicked; /* test */ void seeAllData(void); diff --git a/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.cpp b/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.cpp index dbf944c3..38a82758 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.cpp +++ b/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.cpp @@ -20,11 +20,14 @@ #include "AutoFillFormItem.h" #include "BrowserLogger.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -AutoProfileDeleteView::AutoProfileDeleteView(AutoFillFormManager* manager) - : m_manager(manager) + AutoProfileDeleteView::AutoProfileDeleteView(AutoFillFormManager * + manager) + :m_manager(manager) , m_parent(nullptr) , m_back_button(nullptr) , m_del_button(nullptr) @@ -34,353 +37,429 @@ AutoProfileDeleteView::AutoProfileDeleteView(AutoFillFormManager* manager) , m_action_bar(nullptr) , m_itemClass(nullptr) , m_checked_count(0) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("SettingsUI/AutoFillMobileUI.edj"); -} - -AutoProfileDeleteView::~AutoProfileDeleteView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - evas_object_smart_callback_del(m_back_button, "clicked", __back_button_cb); - evas_object_smart_callback_del(m_del_button, "clicked", __delete_button_cb); - evas_object_smart_callback_del(m_checkbox, "clicked", __select_all_checkbox_changed_cb); - - elm_object_signal_emit(m_action_bar, "hide,autofill,close,icon", "del_but"); - elm_object_signal_emit(m_action_bar, "show,close,icon", "del_but"); - - if (m_genlist) { - elm_genlist_clear(m_genlist); - evas_object_del(m_genlist); + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SettingsUI/AutoFillMobileUI.edj"); } - if (m_mainLayout) { - evas_object_hide(m_mainLayout); - evas_object_del(m_mainLayout); - } - m_mainLayout = nullptr; - m_genlist = nullptr; -} - -Evas_Object* AutoProfileDeleteView::show(Evas_Object* parent, Evas_Object* action_bar) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - - m_action_bar = action_bar; - elm_object_translatable_part_text_set(m_action_bar, "settings_title", "Auto Fill Delete"); - - m_mainLayout = createMainLayout(parent); - if (!m_mainLayout) { - BROWSER_LOGE("createMainLayout failed"); - return nullptr; + AutoProfileDeleteView::~AutoProfileDeleteView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + evas_object_smart_callback_del(m_back_button, "clicked", + __back_button_cb); + evas_object_smart_callback_del(m_del_button, "clicked", + __delete_button_cb); + evas_object_smart_callback_del(m_checkbox, "clicked", + __select_all_checkbox_changed_cb); + + elm_object_signal_emit(m_action_bar, "hide,autofill,close,icon", + "del_but"); + elm_object_signal_emit(m_action_bar, "show,close,icon", "del_but"); + + if (m_genlist) + { + elm_genlist_clear(m_genlist); + evas_object_del(m_genlist); + } + if (m_mainLayout) + { + evas_object_hide(m_mainLayout); + evas_object_del(m_mainLayout); + } + m_mainLayout = nullptr; + m_genlist = nullptr; } - m_back_button = elm_button_add(m_mainLayout); - elm_object_style_set(m_back_button, "basic_button"); - evas_object_smart_callback_add(m_back_button, "clicked", __back_button_cb, this); - elm_object_part_content_set(m_action_bar, "close_autofill_del_click", m_back_button); - elm_object_signal_emit(m_action_bar, "hide,close,icon", "del_but"); - elm_object_signal_emit(m_action_bar, "show,autofill,close,icon", "del_but"); - - m_del_button = elm_button_add(m_mainLayout); - elm_object_style_set(m_del_button, "basic_button"); - evas_object_smart_callback_add(m_del_button, "clicked", __delete_button_cb, this); - elm_object_part_content_set(m_mainLayout, "del_button", m_del_button); - elm_object_signal_emit(m_mainLayout, "dim,del,button,signal", ""); - elm_object_disabled_set(m_del_button, true); - - evas_object_show(m_mainLayout); - elm_layout_content_set(parent, "autofill_del_swallow", m_mainLayout); - m_parent = parent; - return m_mainLayout; -} - -Evas_Object *AutoProfileDeleteView::createMainLayout(Evas_Object *parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Evas_Object *layout = elm_layout_add(parent); - if (!layout) { - BROWSER_LOGD("elm_layout_add failed"); - return nullptr; + Evas_Object *AutoProfileDeleteView::show(Evas_Object * parent, + Evas_Object * action_bar) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + + m_action_bar = action_bar; + elm_object_translatable_part_text_set(m_action_bar, "settings_title", + "Auto Fill Delete"); + + m_mainLayout = createMainLayout(parent); + if (!m_mainLayout) { + BROWSER_LOGE("createMainLayout failed"); + return nullptr; + } + + m_back_button = elm_button_add(m_mainLayout); + elm_object_style_set(m_back_button, "basic_button"); + evas_object_smart_callback_add(m_back_button, "clicked", + __back_button_cb, this); + elm_object_part_content_set(m_action_bar, "close_autofill_del_click", + m_back_button); + elm_object_signal_emit(m_action_bar, "hide,close,icon", "del_but"); + elm_object_signal_emit(m_action_bar, "show,autofill,close,icon", + "del_but"); + + m_del_button = elm_button_add(m_mainLayout); + elm_object_style_set(m_del_button, "basic_button"); + evas_object_smart_callback_add(m_del_button, "clicked", + __delete_button_cb, this); + elm_object_part_content_set(m_mainLayout, "del_button", m_del_button); + elm_object_signal_emit(m_mainLayout, "dim,del,button,signal", ""); + elm_object_disabled_set(m_del_button, true); + + evas_object_show(m_mainLayout); + elm_layout_content_set(parent, "autofill_del_swallow", m_mainLayout); + m_parent = parent; + return m_mainLayout; } - elm_layout_file_set(layout, m_edjFilePath.c_str(), "affdv-layout"); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_translatable_part_text_set(layout, "select_all_text", "IDS_BR_OPT_SELECT_ALL"); - elm_object_translatable_part_text_set(layout, "del_text", "IDS_BR_SK_DELETE"); - - Evas_Object* checkbox = elm_check_add(layout); - if (!checkbox) { - BROWSER_LOGE("Failed to add check"); - return nullptr; - } - elm_object_style_set(checkbox, "custom_check"); - Eina_Bool checked = false; - elm_check_state_pointer_set(checkbox, &checked); - evas_object_propagate_events_set(checkbox, EINA_FALSE); - elm_object_part_content_set(layout, "select_all_checkbox", checkbox); - - m_checkbox = elm_button_add(layout); - if (!m_checkbox) { - BROWSER_LOGE("Failed to add button"); - return nullptr; + Evas_Object *AutoProfileDeleteView::createMainLayout(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(parent); + if (!layout) { + BROWSER_LOGD("elm_layout_add failed"); + return nullptr; + } + elm_layout_file_set(layout, m_edjFilePath.c_str(), "affdv-layout"); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_translatable_part_text_set(layout, "select_all_text", + "IDS_BR_OPT_SELECT_ALL"); + elm_object_translatable_part_text_set(layout, "del_text", + "IDS_BR_SK_DELETE"); + + Evas_Object *checkbox = elm_check_add(layout); + if (!checkbox) { + BROWSER_LOGE("Failed to add check"); + return nullptr; + } + elm_object_style_set(checkbox, "custom_check"); + Eina_Bool checked = false; + elm_check_state_pointer_set(checkbox, &checked); + evas_object_propagate_events_set(checkbox, EINA_FALSE); + elm_object_part_content_set(layout, "select_all_checkbox", checkbox); + + m_checkbox = elm_button_add(layout); + if (!m_checkbox) { + BROWSER_LOGE("Failed to add button"); + return nullptr; + } + elm_object_style_set(m_checkbox, "basic_button"); + evas_object_smart_callback_add(m_checkbox, "clicked", + __select_all_checkbox_changed_cb, this); + elm_object_part_content_set(layout, "select_all_checkbox_button", + m_checkbox); + + m_genlist = createGenlist(layout); + if (!m_genlist) { + BROWSER_LOGE("elm_genlist_add failed"); + return nullptr; + } + evas_object_show(m_genlist); + elm_object_part_content_set(layout, "affdv_genlist", m_genlist); + + return layout; } - elm_object_style_set(m_checkbox, "basic_button"); - evas_object_smart_callback_add(m_checkbox, "clicked", __select_all_checkbox_changed_cb, this); - elm_object_part_content_set(layout, "select_all_checkbox_button", m_checkbox); - - m_genlist = createGenlist(layout); - if (!m_genlist) { - BROWSER_LOGE("elm_genlist_add failed"); - return nullptr; - } - evas_object_show(m_genlist); - elm_object_part_content_set(layout, "affdv_genlist", m_genlist); - - return layout; -} - -Evas_Object *AutoProfileDeleteView::createGenlist(Evas_Object *parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object *genlist = elm_genlist_add(parent); - if (!genlist) { - BROWSER_LOGE("elm_genlist_add failed"); - return nullptr; + Evas_Object *AutoProfileDeleteView::createGenlist(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *genlist = elm_genlist_add(parent); + if (!genlist) { + BROWSER_LOGE("elm_genlist_add failed"); + return nullptr; + } + + elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + elm_genlist_homogeneous_set(genlist, EINA_TRUE); + elm_genlist_multi_select_set(genlist, EINA_FALSE); + elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); + evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + m_itemClass = elm_genlist_item_class_new(); + if (!m_itemClass) { + BROWSER_LOGE + ("elm_genlist_item_class_new for description_item_class failed"); + return nullptr; + } + m_itemClass->item_style = "affdv_item"; + m_itemClass->func.content_get = __content_get_cb; + + m_itemClass->func.text_get = __text_get_cb; + m_itemClass->func.state_get = NULL; + m_itemClass->func.del = NULL; + + appendGenlist(genlist); + + return genlist; } - elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_genlist_homogeneous_set(genlist, EINA_TRUE); - elm_genlist_multi_select_set(genlist, EINA_FALSE); - elm_genlist_select_mode_set(genlist, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); - evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_itemClass = elm_genlist_item_class_new(); - if (!m_itemClass) { - BROWSER_LOGE("elm_genlist_item_class_new for description_item_class failed"); - return nullptr; + Eina_Bool AutoProfileDeleteView::appendGenlist(Evas_Object * genlist) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_checkbox_delete_state_map.clear(); + unsigned int item_count = m_manager->getAutoFillFormItemCount(); + if (item_count > 0) { + for (unsigned int i = 0; i < item_count; i++) { + genlistCallbackData *item_callback_data = new genlistCallbackData; + item_callback_data->menu_index = i; + item_callback_data->user_data = this; + item_callback_data->it = + elm_genlist_item_append(genlist, m_itemClass, item_callback_data, + NULL, ELM_GENLIST_ITEM_NONE, + __genlist_item_selected_cb, + item_callback_data); + m_checkbox_delete_state_map.insert(std::pair < Elm_Object_Item *, + bool > (item_callback_data->it, + false)); + } + } + + return EINA_TRUE; } - m_itemClass->item_style = "affdv_item"; - m_itemClass->func.content_get = __content_get_cb; - - m_itemClass->func.text_get = __text_get_cb; - m_itemClass->func.state_get = NULL; - m_itemClass->func.del = NULL; - - appendGenlist(genlist); - - return genlist; -} -Eina_Bool AutoProfileDeleteView::appendGenlist(Evas_Object *genlist) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_checkbox_delete_state_map.clear(); - unsigned int item_count = m_manager->getAutoFillFormItemCount(); - if (item_count > 0) { - for (unsigned int i = 0; i < item_count; i++) { - genlistCallbackData* item_callback_data = new genlistCallbackData; - item_callback_data->menu_index = i; - item_callback_data->user_data = this; - item_callback_data->it = elm_genlist_item_append(genlist, m_itemClass, - item_callback_data, NULL, ELM_GENLIST_ITEM_NONE, - __genlist_item_selected_cb, item_callback_data); - m_checkbox_delete_state_map.insert(std::pair<Elm_Object_Item*, bool>(item_callback_data->it, false)); - } + void AutoProfileDeleteView::__select_all_checkbox_changed_cb(void *data, + Evas_Object * + /*obj */ , + void * + /*event_info */ + ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoProfileDeleteView *apdv = + static_cast < AutoProfileDeleteView * >(data); + Evas_Object *sel_all_checkbox = + elm_object_part_content_get(apdv->m_mainLayout, + "select_all_checkbox"); + bool sel_all_state = elm_check_state_get(sel_all_checkbox) == EINA_TRUE; + elm_check_state_set(sel_all_checkbox, !sel_all_state); + + for (auto it = apdv->m_checkbox_delete_state_map.begin(); + it != apdv->m_checkbox_delete_state_map.end(); ++it) + if (it->second == sel_all_state) { + it->second = !sel_all_state; + elm_genlist_item_update(it->first); + } + + elm_genlist_realized_items_update(apdv->m_genlist); + + if (sel_all_state) + apdv->m_checked_count = 0; + else + apdv->m_checked_count = elm_genlist_items_count(apdv->m_genlist); + + if (apdv->m_checked_count >= 1) { + elm_object_signal_emit(apdv->m_mainLayout, "show,del,button,signal", + ""); + elm_object_disabled_set(elm_object_part_content_get + (apdv->m_mainLayout, "del_button"), false); + } else { + elm_object_signal_emit(apdv->m_mainLayout, "dim,del,button,signal", + ""); + elm_object_disabled_set(elm_object_part_content_get + (apdv->m_mainLayout, "del_button"), true); + } } - return EINA_TRUE; -} - -void AutoProfileDeleteView::__select_all_checkbox_changed_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoProfileDeleteView *apdv = static_cast<AutoProfileDeleteView*>(data); - Evas_Object* sel_all_checkbox = elm_object_part_content_get(apdv->m_mainLayout, "select_all_checkbox"); - bool sel_all_state = elm_check_state_get(sel_all_checkbox) == EINA_TRUE; - elm_check_state_set(sel_all_checkbox, !sel_all_state); - - for (auto it = apdv->m_checkbox_delete_state_map.begin(); it != apdv->m_checkbox_delete_state_map.end(); ++it) - if (it->second == sel_all_state) { - it->second = !sel_all_state; - elm_genlist_item_update(it->first); - } - - elm_genlist_realized_items_update(apdv->m_genlist); - - if (sel_all_state) - apdv->m_checked_count = 0; - else - apdv->m_checked_count = elm_genlist_items_count(apdv->m_genlist); - - if (apdv->m_checked_count >= 1) { - elm_object_signal_emit(apdv->m_mainLayout, "show,del,button,signal", ""); - elm_object_disabled_set(elm_object_part_content_get(apdv->m_mainLayout, "del_button"), false); - } - else { - elm_object_signal_emit(apdv->m_mainLayout, "dim,del,button,signal", ""); - elm_object_disabled_set(elm_object_part_content_get(apdv->m_mainLayout, "del_button"), true); + void AutoProfileDeleteView::__back_button_cb(void *data, + Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoProfileDeleteView *view = + static_cast < AutoProfileDeleteView * >(data); + elm_object_translatable_part_text_set(view->m_action_bar, + "settings_title", + "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); + view->hide(); } -} - -void AutoProfileDeleteView::__back_button_cb(void* data, Evas_Object* /*obj*/, void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoProfileDeleteView *view = static_cast<AutoProfileDeleteView*>(data); - elm_object_translatable_part_text_set(view->m_action_bar, "settings_title", "IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); - view->hide(); -} -void AutoProfileDeleteView::__genlist_item_selected_cb(void* data, Evas_Object* /*obj*/, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); - - Elm_Object_Item *item = static_cast<Elm_Object_Item*>(event_info); - elm_genlist_item_selected_set(item, EINA_FALSE); - Evas_Object *checkbox = elm_object_item_part_content_get(item, "checkbox"); - Eina_Bool state = elm_check_state_get(checkbox); - elm_check_state_set(checkbox, !state); - callback_data->user_data->m_checkbox_delete_state_map[item] = !callback_data->user_data->m_checkbox_delete_state_map[item]; - elm_genlist_item_update(item); - - if (state) - callback_data->user_data->m_checked_count--; - else - callback_data->user_data->m_checked_count++; - - BROWSER_LOGD("----Checked count : [%d]---- ", callback_data->user_data->m_checked_count); - Evas_Object* sel_all_checkbox = elm_object_part_content_get(callback_data->user_data->m_mainLayout, "select_all_checkbox"); - if (callback_data->user_data->m_checked_count == elm_genlist_items_count(callback_data->user_data->m_genlist)) - elm_check_state_set(sel_all_checkbox, true); - else - elm_check_state_set(sel_all_checkbox, false); - - if (callback_data->user_data->m_checked_count == 0) { - elm_object_signal_emit(callback_data->user_data->m_mainLayout, "dim,del,button,signal", ""); - elm_object_disabled_set(elm_object_part_content_get(callback_data->user_data->m_mainLayout, "del_button"), true); - } else { - elm_object_signal_emit(callback_data->user_data->m_mainLayout, "show,del,button,signal", ""); - elm_object_disabled_set(elm_object_part_content_get(callback_data->user_data->m_mainLayout, "del_button"), false); + void AutoProfileDeleteView::__genlist_item_selected_cb(void *data, + Evas_Object * + /*obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + + Elm_Object_Item *item = static_cast < Elm_Object_Item * >(event_info); + elm_genlist_item_selected_set(item, EINA_FALSE); + Evas_Object *checkbox = + elm_object_item_part_content_get(item, "checkbox"); + Eina_Bool state = elm_check_state_get(checkbox); + elm_check_state_set(checkbox, !state); + callback_data->user_data->m_checkbox_delete_state_map[item] = + !callback_data->user_data->m_checkbox_delete_state_map[item]; + elm_genlist_item_update(item); + + if (state) + callback_data->user_data->m_checked_count--; + else + callback_data->user_data->m_checked_count++; + + BROWSER_LOGD("----Checked count : [%d]---- ", + callback_data->user_data->m_checked_count); + Evas_Object *sel_all_checkbox = + elm_object_part_content_get(callback_data->user_data->m_mainLayout, + "select_all_checkbox"); + if (callback_data->user_data->m_checked_count == + elm_genlist_items_count(callback_data->user_data->m_genlist)) + elm_check_state_set(sel_all_checkbox, true); + else + elm_check_state_set(sel_all_checkbox, false); + + if (callback_data->user_data->m_checked_count == 0) { + elm_object_signal_emit(callback_data->user_data->m_mainLayout, + "dim,del,button,signal", ""); + elm_object_disabled_set(elm_object_part_content_get + (callback_data->user_data->m_mainLayout, + "del_button"), true); + } else { + elm_object_signal_emit(callback_data->user_data->m_mainLayout, + "show,del,button,signal", ""); + elm_object_disabled_set(elm_object_part_content_get + (callback_data->user_data->m_mainLayout, + "del_button"), false); + } } -} -void AutoProfileDeleteView::refreshView(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_genlist_clear(m_genlist); - appendGenlist(m_genlist); -} - -void AutoProfileDeleteView::__delete_button_cb(void* data, Evas_Object* /*obj*/,void* /*event_info*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - AutoProfileDeleteView *apdv = static_cast<AutoProfileDeleteView*>(data); - if (apdv->m_checked_count == elm_genlist_items_count(apdv->m_genlist)) - apdv->deleteAllItems(); - else - apdv->deleteSelectedItems(); - elm_genlist_realized_items_update(apdv->m_genlist); - auto sel_all_checkbox = elm_object_part_content_get(apdv->m_mainLayout, "select_all_checkbox"); - if (elm_check_state_get(sel_all_checkbox) == EINA_TRUE) { - elm_check_state_set(sel_all_checkbox, EINA_FALSE); - elm_object_signal_emit(apdv->m_mainLayout, "dim,del,button,signal", ""); - elm_object_disabled_set(elm_object_part_content_get(apdv->m_mainLayout, "del_button"), true); + void AutoProfileDeleteView::refreshView(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_genlist_clear(m_genlist); + appendGenlist(m_genlist); } -} -void AutoProfileDeleteView::deleteAllItems(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void AutoProfileDeleteView::__delete_button_cb(void *data, + Evas_Object * /*obj */ , + void * /*event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + AutoProfileDeleteView *apdv = + static_cast < AutoProfileDeleteView * >(data); + if (apdv->m_checked_count == elm_genlist_items_count(apdv->m_genlist)) + apdv->deleteAllItems(); + else + apdv->deleteSelectedItems(); + elm_genlist_realized_items_update(apdv->m_genlist); + auto sel_all_checkbox = + elm_object_part_content_get(apdv->m_mainLayout, + "select_all_checkbox"); + if (elm_check_state_get(sel_all_checkbox) == EINA_TRUE) { + elm_check_state_set(sel_all_checkbox, EINA_FALSE); + elm_object_signal_emit(apdv->m_mainLayout, "dim,del,button,signal", + ""); + elm_object_disabled_set(elm_object_part_content_get + (apdv->m_mainLayout, "del_button"), true); + } + } - m_checkbox_delete_state_map.clear(); - m_manager->deleteAllAutoFillFormItems(); - m_manager->refreshListView(); -} + void AutoProfileDeleteView::deleteAllItems(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -void AutoProfileDeleteView::deleteSelectedItems(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - genlistCallbackData *cb_data = nullptr; - Elm_Object_Item *it = elm_genlist_first_item_get(m_genlist); - Evas_Object *checkbox; - int del_count = 0; - - while (it) { - checkbox = elm_object_item_part_content_get(it, "checkbox"); - cb_data = static_cast<genlistCallbackData*>(elm_object_item_data_get(it)); - if (elm_check_state_get(checkbox)) { - AutoFillFormItem *item = m_manager->getItem(cb_data->menu_index - del_count); - m_manager->deleteAutoFillFormItem(item); - del_count++; - m_checkbox_delete_state_map.erase(it); - } - it = elm_genlist_item_next_get(it); + m_checkbox_delete_state_map.clear(); + m_manager->deleteAllAutoFillFormItems(); + m_manager->refreshListView(); } - BROWSER_LOGD("Total items deleted %d",del_count); - m_manager->refreshListView(); -} - -char *AutoProfileDeleteView::__text_get_cb(void* data, Evas_Object* /*obj*/, const char *part) -{ - BROWSER_LOGD("part[%s]", part); - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); + void AutoProfileDeleteView::deleteSelectedItems(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + genlistCallbackData *cb_data = nullptr; + Elm_Object_Item *it = elm_genlist_first_item_get(m_genlist); + Evas_Object *checkbox; + int del_count = 0; + + while (it) { + checkbox = elm_object_item_part_content_get(it, "checkbox"); + cb_data = + static_cast < genlistCallbackData * >(elm_object_item_data_get(it)); + if (elm_check_state_get(checkbox)) { + AutoFillFormItem *item = + m_manager->getItem(cb_data->menu_index - del_count); + m_manager->deleteAutoFillFormItem(item); + del_count++; + m_checkbox_delete_state_map.erase(it); + } + it = elm_genlist_item_next_get(it); + } + BROWSER_LOGD("Total items deleted %d", del_count); + m_manager->refreshListView(); + } - if (!strcmp(part, "item_title")) { - const char *item_full_name = callback_data->user_data->getEachItemFullName( - (unsigned int)callback_data->menu_index); - if (item_full_name) - return strdup(item_full_name); + char *AutoProfileDeleteView::__text_get_cb(void *data, + Evas_Object * /*obj */ , + const char *part) + { + BROWSER_LOGD("part[%s]", part); + + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + + if (!strcmp(part, "item_title")) { + const char *item_full_name = + callback_data->user_data-> + getEachItemFullName((unsigned int) callback_data->menu_index); + if (item_full_name) + return strdup(item_full_name); + } + return NULL; } - return NULL; -} -const char *AutoProfileDeleteView::getEachItemFullName(unsigned int index) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_manager->getAutoFillFormItemCount() == 0) - return NULL; - return (m_manager->getItem(index))->getName(); -} + const char *AutoProfileDeleteView::getEachItemFullName(unsigned int index) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_manager->getAutoFillFormItemCount() == 0) + return NULL; + return (m_manager->getItem(index))->getName(); + } -Evas_Object *AutoProfileDeleteView::__content_get_cb(void* data, Evas_Object* obj, const char *part) -{ - BROWSER_LOGD("part[%s]", part); - - if (!strcmp(part, "checkbox")) { - Evas_Object *checkbox = elm_check_add(obj); - if (!checkbox) { - BROWSER_LOGE("Failed to add check"); - return NULL; - } - - genlistCallbackData *itemData = static_cast<genlistCallbackData*>(data); - elm_object_style_set(checkbox, "custom_check"); - elm_check_state_set(checkbox, itemData->user_data->m_checkbox_delete_state_map[itemData->it] - ? EINA_TRUE : EINA_FALSE); - evas_object_propagate_events_set(checkbox, EINA_FALSE); - return checkbox; + Evas_Object *AutoProfileDeleteView::__content_get_cb(void *data, + Evas_Object * obj, + const char *part) + { + BROWSER_LOGD("part[%s]", part); + + if (!strcmp(part, "checkbox")) { + Evas_Object *checkbox = elm_check_add(obj); + if (!checkbox) { + BROWSER_LOGE("Failed to add check"); + return NULL; + } + + genlistCallbackData *itemData = + static_cast < genlistCallbackData * >(data); + elm_object_style_set(checkbox, "custom_check"); + elm_check_state_set(checkbox, + itemData->user_data-> + m_checkbox_delete_state_map[itemData->it] + ? EINA_TRUE : EINA_FALSE); + evas_object_propagate_events_set(checkbox, EINA_FALSE); + return checkbox; + } + return NULL; } - return NULL; -} -void AutoProfileDeleteView::hide(void) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_manager) - m_manager->deleteDeleteView(); -} + void AutoProfileDeleteView::hide(void) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_manager) + m_manager->deleteDeleteView(); + } -} + } } diff --git a/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.h b/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.h index 3ad4eb64..6af1502b 100644..100755 --- a/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.h +++ b/services/SettingsUI/AutoFillForm/AutoProfileDeleteView.h @@ -22,7 +22,6 @@ namespace base_ui{ class AutoFillFormManager; class AutoProfileDeleteView { - public: AutoProfileDeleteView(AutoFillFormManager* manager); ~AutoProfileDeleteView(void); diff --git a/services/SettingsUI/SettingsUI.cpp b/services/SettingsUI/SettingsUI.cpp index 8d16a2b6..f0e50ff9 100644..100755 --- a/services/SettingsUI/SettingsUI.cpp +++ b/services/SettingsUI/SettingsUI.cpp @@ -25,283 +25,337 @@ #include "BrowserLogger.h" #include "Tools/EflTools.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { -EXPORT_SERVICE(SettingsUI, "org.tizen.browser.settingsui") + EXPORT_SERVICE(SettingsUI, "org.tizen.browser.settingsui") -struct ItemData { - tizen_browser::base_ui::SettingsUI* settingsUI; - Elm_Object_Item * e_item; -}; + struct ItemData + { + tizen_browser::base_ui::SettingsUI * settingsUI; + Elm_Object_Item *e_item; + }; -SettingsUI::SettingsUI() + SettingsUI::SettingsUI() : m_settings_layout(nullptr) - , m_actionBar(nullptr) - , m_scroller(nullptr) - , m_items_layout(nullptr) - , m_parent(nullptr) - , m_item_class(nullptr) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("SettingsUI/SettingsUI.edj"); -} - -SettingsUI::~SettingsUI() -{ + , m_actionBar(nullptr) + , m_scroller(nullptr) + , m_items_layout(nullptr) + , m_parent(nullptr) + , m_item_class(nullptr) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SettingsUI/SettingsUI.edj"); + } -} + SettingsUI::~SettingsUI() + { + } -void SettingsUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} + void SettingsUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } -Evas_Object* SettingsUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - if (!m_settings_layout) - m_settings_layout = createSettingsUILayout(m_parent); - return m_settings_layout; -} + Evas_Object *SettingsUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if (!m_settings_layout) + m_settings_layout = createSettingsUILayout(m_parent); + return m_settings_layout; + } -void SettingsUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_show(m_scroller); - evas_object_show(m_items_layout); - evas_object_show(m_settings_layout); - evas_object_show(m_actionBar); - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); -} + void SettingsUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_show(m_scroller); + evas_object_show(m_items_layout); + evas_object_show(m_settings_layout); + evas_object_show(m_actionBar); + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + } -void SettingsUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_hide(m_scroller); - evas_object_hide(m_items_layout); - evas_object_hide(m_settings_layout); - evas_object_hide(m_actionBar); -} + void SettingsUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_hide(m_scroller); + evas_object_hide(m_items_layout); + evas_object_hide(m_settings_layout); + evas_object_hide(m_actionBar); + } -Evas_Object* SettingsUI::createSettingsUILayout(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - Evas_Object* settings_layout = elm_layout_add(parent); - elm_layout_file_set(settings_layout, m_edjFilePath.c_str(), "settings-layout"); - evas_object_size_hint_weight_set(settings_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(settings_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_actionBar = createActionBar(settings_layout); - m_scroller = createSettingsPage(settings_layout); - return settings_layout; -} + Evas_Object *SettingsUI::createSettingsUILayout(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + Evas_Object *settings_layout = elm_layout_add(parent); + elm_layout_file_set(settings_layout, m_edjFilePath.c_str(), + "settings-layout"); + evas_object_size_hint_weight_set(settings_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(settings_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + m_actionBar = createActionBar(settings_layout); + m_scroller = createSettingsPage(settings_layout); + return settings_layout; + } -Evas_Object* SettingsUI::createActionBar(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object* actionBar = elm_layout_add(settings_layout); - elm_object_part_content_set(settings_layout, "actionbar_swallow", actionBar); - evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); - Evas_Object *close_click_btn = elm_button_add(actionBar); - elm_object_style_set(close_click_btn, "basic_button"); - evas_object_smart_callback_add(close_click_btn, "clicked", SettingsUI::close_clicked_cb, this); - elm_object_part_content_set(actionBar, "close_click", close_click_btn); - elm_object_translatable_part_text_set(actionBar, "settings_title", "IDS_BR_BODY_SETTINGS"); - - return actionBar; -} + Evas_Object *SettingsUI::createActionBar(Evas_Object * settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *actionBar = elm_layout_add(settings_layout); + elm_object_part_content_set(settings_layout, "actionbar_swallow", + actionBar); + evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); + Evas_Object *close_click_btn = elm_button_add(actionBar); + elm_object_style_set(close_click_btn, "basic_button"); + evas_object_smart_callback_add(close_click_btn, "clicked", + SettingsUI::close_clicked_cb, this); + elm_object_part_content_set(actionBar, "close_click", close_click_btn); + elm_object_translatable_part_text_set(actionBar, "settings_title", + "IDS_BR_BODY_SETTINGS"); + + return actionBar; + } -Evas_Object* SettingsUI::createSettingsPage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - ItemData *id = new ItemData; - id->settingsUI = this; - - Evas_Object* scroller = elm_scroller_add(settings_layout); - m_items_layout = elm_layout_add(scroller); - elm_object_content_set(scroller, m_items_layout); - elm_layout_file_set(m_items_layout, m_edjFilePath.c_str(), "settings_items"); - elm_object_part_content_set(settings_layout, "settings_scroller_swallow", scroller); - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_scroller_policy_set(m_items_layout, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO); - elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_FALSE); - elm_scroller_propagate_events_set(scroller, EINA_TRUE); - - Evas_Object *del_selected_data_button = elm_button_add(m_items_layout); - elm_object_style_set(del_selected_data_button, "basic_button"); - evas_object_smart_callback_add(del_selected_data_button, "clicked", _del_selected_data_clicked_cb, (void*)id); - elm_layout_content_set(m_items_layout, "del_selected_data_click", del_selected_data_button); - - Evas_Object *reset_mv_button = elm_button_add(m_items_layout); - elm_object_style_set(reset_mv_button, "basic_button"); - evas_object_smart_callback_add(reset_mv_button, "clicked", _reset_mv_clicked_cb, (void*)id); - elm_layout_content_set(m_items_layout, "reset_mv_click", reset_mv_button); - - Evas_Object *reset_browser_button = elm_button_add(m_items_layout); - elm_object_style_set(reset_browser_button, "basic_button"); - evas_object_smart_callback_add(reset_browser_button, "clicked", _reset_browser_clicked_cb, (void*)id); - elm_layout_content_set(m_items_layout, "reset_browser_click", reset_browser_button); - - - Evas_Object *cache_checkbox = elm_check_add(m_items_layout); - elm_layout_content_set(m_items_layout, "cache_cb", cache_checkbox); - elm_check_state_set(cache_checkbox, EINA_TRUE); - edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "cache_cb_text", __checkbox_label_click_cb, (void*)id); - elm_object_translatable_part_text_set(m_items_layout, "cache_cb_text", "IDS_BR_OPT_CACHE"); - - Evas_Object *cookies_checkbox = elm_check_add(m_items_layout); - elm_layout_content_set(m_items_layout, "cookies_cb", cookies_checkbox); - elm_check_state_set(cookies_checkbox, EINA_TRUE); - edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "cookies_cb_text", __checkbox_label_click_cb, (void*)id); - elm_object_translatable_part_text_set(m_items_layout, "cookies_cb_text", "IDS_BR_BODY_COOKIES"); - - Evas_Object *history_checkbox = elm_check_add(m_items_layout); - elm_layout_content_set(m_items_layout, "history_cb", history_checkbox); - elm_check_state_set(history_checkbox, EINA_TRUE); - edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), "mouse,clicked,1", "history_cb_text", __checkbox_label_click_cb, (void*)id); - elm_object_translatable_part_text_set(m_items_layout, "history_cb_text", "IDS_BR_MBODY_HISTORY"); - - Evas_Object *accept_all_rb = elm_radio_add(m_items_layout); - elm_object_style_set(accept_all_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "accept_all_rb", accept_all_rb); - Evas_Object *sharingRequestGroup = accept_all_rb; - elm_radio_state_value_set(accept_all_rb, SR_ACCEPT_ALL); - - Evas_Object *ask_rb = elm_radio_add(m_items_layout); - elm_object_style_set(ask_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "ask_rb", ask_rb); - elm_radio_group_add(ask_rb, sharingRequestGroup); - elm_radio_state_value_set(ask_rb, SR_ASK); - - Evas_Object *sr_disable_rb = elm_radio_add(m_items_layout); - elm_object_style_set(sr_disable_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "sr_disable_rb", sr_disable_rb); - elm_radio_group_add(sr_disable_rb, sharingRequestGroup); - elm_radio_state_value_set(sr_disable_rb, SR_DISABLE); - - Evas_Object *bs_enable_rb = elm_radio_add(m_items_layout); - elm_object_style_set(bs_enable_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "bs_enable_rb", bs_enable_rb); - Evas_Object *bookmarkSyncGroup = bs_enable_rb; - elm_radio_state_value_set(bs_enable_rb, BS_ENABLE); - elm_object_translatable_part_text_set(m_items_layout, "bs_enable_rb_text", "IDS_BR_BUTTON_ENABLE_ABB"); - - Evas_Object *bs_disable_rb = elm_radio_add(m_items_layout); - elm_object_style_set(bs_disable_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "bs_disable_rb", bs_disable_rb); - elm_radio_group_add(bs_disable_rb, bookmarkSyncGroup); - elm_radio_state_value_set(bs_disable_rb, BS_DISABLE); - - Evas_Object *ts_enable_rb = elm_radio_add(m_items_layout); - elm_object_style_set(ts_enable_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "ts_enable_rb", ts_enable_rb); - Evas_Object *tabSyncGroup = ts_enable_rb; - elm_radio_state_value_set(ts_enable_rb, TS_ENABLE); - elm_object_translatable_part_text_set(m_items_layout, "ts_enable_rb_text", "IDS_BR_BUTTON_ENABLE_ABB"); - - Evas_Object *ts_disable_rb = elm_radio_add(m_items_layout); - elm_object_style_set(ts_disable_rb, "settings_radio"); - elm_layout_content_set(m_items_layout, "ts_disable_rb", ts_disable_rb); - elm_radio_group_add(ts_disable_rb, tabSyncGroup); - elm_radio_state_value_set(ts_disable_rb, TS_DISABLE); - - return scroller; -} + Evas_Object *SettingsUI::createSettingsPage(Evas_Object * settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + ItemData *id = new ItemData; + id->settingsUI = this; + + Evas_Object *scroller = elm_scroller_add(settings_layout); + m_items_layout = elm_layout_add(scroller); + elm_object_content_set(scroller, m_items_layout); + elm_layout_file_set(m_items_layout, m_edjFilePath.c_str(), + "settings_items"); + elm_object_part_content_set(settings_layout, + "settings_scroller_swallow", scroller); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_scroller_policy_set(m_items_layout, ELM_SCROLLER_POLICY_ON, + ELM_SCROLLER_POLICY_AUTO); + elm_scroller_bounce_set(scroller, EINA_TRUE, EINA_FALSE); + elm_scroller_propagate_events_set(scroller, EINA_TRUE); + + Evas_Object *del_selected_data_button = elm_button_add(m_items_layout); + elm_object_style_set(del_selected_data_button, "basic_button"); + evas_object_smart_callback_add(del_selected_data_button, "clicked", + _del_selected_data_clicked_cb, + (void *) id); + elm_layout_content_set(m_items_layout, "del_selected_data_click", + del_selected_data_button); + + Evas_Object *reset_mv_button = elm_button_add(m_items_layout); + elm_object_style_set(reset_mv_button, "basic_button"); + evas_object_smart_callback_add(reset_mv_button, "clicked", + _reset_mv_clicked_cb, (void *) id); + elm_layout_content_set(m_items_layout, "reset_mv_click", + reset_mv_button); + + Evas_Object *reset_browser_button = elm_button_add(m_items_layout); + elm_object_style_set(reset_browser_button, "basic_button"); + evas_object_smart_callback_add(reset_browser_button, "clicked", + _reset_browser_clicked_cb, (void *) id); + elm_layout_content_set(m_items_layout, "reset_browser_click", + reset_browser_button); + + + Evas_Object *cache_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "cache_cb", cache_checkbox); + elm_check_state_set(cache_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), + "mouse,clicked,1", "cache_cb_text", + __checkbox_label_click_cb, (void *) id); + elm_object_translatable_part_text_set(m_items_layout, "cache_cb_text", + "IDS_BR_OPT_CACHE"); + + Evas_Object *cookies_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "cookies_cb", cookies_checkbox); + elm_check_state_set(cookies_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), + "mouse,clicked,1", "cookies_cb_text", + __checkbox_label_click_cb, (void *) id); + elm_object_translatable_part_text_set(m_items_layout, "cookies_cb_text", + "IDS_BR_BODY_COOKIES"); + + Evas_Object *history_checkbox = elm_check_add(m_items_layout); + elm_layout_content_set(m_items_layout, "history_cb", history_checkbox); + elm_check_state_set(history_checkbox, EINA_TRUE); + edje_object_signal_callback_add(elm_layout_edje_get(m_items_layout), + "mouse,clicked,1", "history_cb_text", + __checkbox_label_click_cb, (void *) id); + elm_object_translatable_part_text_set(m_items_layout, "history_cb_text", + "IDS_BR_MBODY_HISTORY"); + + Evas_Object *accept_all_rb = elm_radio_add(m_items_layout); + elm_object_style_set(accept_all_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "accept_all_rb", accept_all_rb); + Evas_Object *sharingRequestGroup = accept_all_rb; + elm_radio_state_value_set(accept_all_rb, SR_ACCEPT_ALL); + + Evas_Object *ask_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ask_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ask_rb", ask_rb); + elm_radio_group_add(ask_rb, sharingRequestGroup); + elm_radio_state_value_set(ask_rb, SR_ASK); + + Evas_Object *sr_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(sr_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "sr_disable_rb", sr_disable_rb); + elm_radio_group_add(sr_disable_rb, sharingRequestGroup); + elm_radio_state_value_set(sr_disable_rb, SR_DISABLE); + + Evas_Object *bs_enable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(bs_enable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "bs_enable_rb", bs_enable_rb); + Evas_Object *bookmarkSyncGroup = bs_enable_rb; + elm_radio_state_value_set(bs_enable_rb, BS_ENABLE); + elm_object_translatable_part_text_set(m_items_layout, + "bs_enable_rb_text", + "IDS_BR_BUTTON_ENABLE_ABB"); + + Evas_Object *bs_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(bs_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "bs_disable_rb", bs_disable_rb); + elm_radio_group_add(bs_disable_rb, bookmarkSyncGroup); + elm_radio_state_value_set(bs_disable_rb, BS_DISABLE); + + Evas_Object *ts_enable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ts_enable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ts_enable_rb", ts_enable_rb); + Evas_Object *tabSyncGroup = ts_enable_rb; + elm_radio_state_value_set(ts_enable_rb, TS_ENABLE); + elm_object_translatable_part_text_set(m_items_layout, + "ts_enable_rb_text", + "IDS_BR_BUTTON_ENABLE_ABB"); + + Evas_Object *ts_disable_rb = elm_radio_add(m_items_layout); + elm_object_style_set(ts_disable_rb, "settings_radio"); + elm_layout_content_set(m_items_layout, "ts_disable_rb", ts_disable_rb); + elm_radio_group_add(ts_disable_rb, tabSyncGroup); + elm_radio_state_value_set(ts_disable_rb, TS_DISABLE); + + return scroller; + } -Evas_Object* SettingsUI::listActionBarContentGet(void* data, Evas_Object* obj , const char* part) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (obj && part) { - const char *part_name = "close_click"; - static const int part_name_len = strlen(part_name); - if (!strncmp(part_name, part, part_name_len)) { - Evas_Object *close_click = elm_button_add(obj); - elm_object_style_set(close_click, "basic_button"); - evas_object_smart_callback_add(close_click, "clicked", SettingsUI::close_clicked_cb, data); - return close_click; - } + Evas_Object *SettingsUI::listActionBarContentGet(void *data, + Evas_Object * obj, + const char *part) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (obj && part) { + const char *part_name = "close_click"; + static const int part_name_len = strlen(part_name); + if (!strncmp(part_name, part, part_name_len)) { + Evas_Object *close_click = elm_button_add(obj); + elm_object_style_set(close_click, "basic_button"); + evas_object_smart_callback_add(close_click, "clicked", + SettingsUI::close_clicked_cb, data); + return close_click; + } + } + return nullptr; } - return nullptr; -} -void SettingsUI::__checkbox_label_click_cb(void *data, Evas_Object*, const char*, const char *source) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - ItemData *id = static_cast<ItemData*>(data); - - if(strcmp(source, "cache_cb_text") == 0 ){ - Evas_Object *cache_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cache_cb"); - elm_check_state_set(cache_check, !elm_check_state_get(cache_check)); - } - else if (strcmp(source, "cookies_cb_text") == 0 ){ - Evas_Object *cookies_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cookies_cb"); - elm_check_state_set(cookies_check, !elm_check_state_get(cookies_check)); - } - else if (strcmp(source, "history_cb_text") == 0 ){ - Evas_Object *history_check = elm_layout_content_get(id->settingsUI->m_items_layout, "history_cb"); - elm_check_state_set(history_check, !elm_check_state_get(history_check)); - } - else{ - BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, __LINE__); - } + void SettingsUI::__checkbox_label_click_cb(void *data, Evas_Object *, + const char *, + const char *source) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *id = static_cast < ItemData * >(data); + + if (strcmp(source, "cache_cb_text") == 0) { + Evas_Object *cache_check = + elm_layout_content_get(id->settingsUI->m_items_layout, + "cache_cb"); + elm_check_state_set(cache_check, !elm_check_state_get(cache_check)); + } else if (strcmp(source, "cookies_cb_text") == 0) { + Evas_Object *cookies_check = + elm_layout_content_get(id->settingsUI->m_items_layout, + "cookies_cb"); + elm_check_state_set(cookies_check, + !elm_check_state_get(cookies_check)); + } else if (strcmp(source, "history_cb_text") == 0) { + Evas_Object *history_check = + elm_layout_content_get(id->settingsUI->m_items_layout, + "history_cb"); + elm_check_state_set(history_check, + !elm_check_state_get(history_check)); + } else { + BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, + __LINE__); + } + } } -} -void SettingsUI::close_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI * s_ui = static_cast<SettingsUI*>(data); - s_ui->closeSettingsUIClicked(); + void SettingsUI::close_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *s_ui = static_cast < SettingsUI * >(data); + s_ui->closeSettingsUIClicked(); + } } -} -void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - ItemData *id = static_cast<ItemData*>(data); - Evas_Object *cache_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cache_cb"); - Evas_Object *cookies_check = elm_layout_content_get(id->settingsUI->m_items_layout, "cookies_cb"); - Evas_Object *history_check = elm_layout_content_get(id->settingsUI->m_items_layout, "history_cb"); - std::string type; - elm_check_state_get(cache_check) ? type += "_CACHE" : ""; - elm_check_state_get(cookies_check) ? type += "_COOKIES" : ""; - elm_check_state_get(history_check) ? type += "_HISTORY" : ""; - id->settingsUI->deleteSelectedDataClicked(type); + void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *id = static_cast < ItemData * >(data); + Evas_Object *cache_check = + elm_layout_content_get(id->settingsUI->m_items_layout, "cache_cb"); + Evas_Object *cookies_check = + elm_layout_content_get(id->settingsUI->m_items_layout, + "cookies_cb"); + Evas_Object *history_check = + elm_layout_content_get(id->settingsUI->m_items_layout, + "history_cb"); + std::string type; + elm_check_state_get(cache_check) ? type += "_CACHE" : ""; + elm_check_state_get(cookies_check) ? type += "_COOKIES" : ""; + elm_check_state_get(history_check) ? type += "_HISTORY" : ""; + id->settingsUI->deleteSelectedDataClicked(type); + } } -} -void SettingsUI::_reset_mv_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - ItemData* itemData = static_cast<ItemData*>(data); - itemData->settingsUI->resetMostVisitedClicked(); + void SettingsUI::_reset_mv_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *itemData = static_cast < ItemData * >(data); + itemData->settingsUI->resetMostVisitedClicked(); + } } -} -void SettingsUI::_reset_browser_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - ItemData* itemData = static_cast<ItemData*>(data); - itemData->settingsUI->resetBrowserClicked(); + void SettingsUI::_reset_browser_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + ItemData *itemData = static_cast < ItemData * >(data); + itemData->settingsUI->resetBrowserClicked(); + } } -} -} + } } diff --git a/services/SettingsUI/SettingsUI.h b/services/SettingsUI/SettingsUI.h index 2561000b..49c96e81 100644..100755 --- a/services/SettingsUI/SettingsUI.h +++ b/services/SettingsUI/SettingsUI.h @@ -44,10 +44,10 @@ public: Evas_Object* createActionBar(Evas_Object* settings_layout); Evas_Object* createSettingsPage(Evas_Object* settings_layout); - boost::signals2::signal<void ()> resetBrowserClicked; - boost::signals2::signal<void ()> resetMostVisitedClicked; - boost::signals2::signal<void (std::string&)> deleteSelectedDataClicked; - boost::signals2::signal<void ()> closeSettingsUIClicked; + boost::signals2::signal<void()> resetBrowserClicked; + boost::signals2::signal<void()> resetMostVisitedClicked; + boost::signals2::signal<void(std::string&)> deleteSelectedDataClicked; + boost::signals2::signal<void()> closeSettingsUIClicked; private: Evas_Object* createSettingsUILayout(Evas_Object* parent); diff --git a/services/SettingsUI/SettingsUI_mob.cpp b/services/SettingsUI/SettingsUI_mob.cpp index 40680e04..674867d5 100755 --- a/services/SettingsUI/SettingsUI_mob.cpp +++ b/services/SettingsUI/SettingsUI_mob.cpp @@ -28,904 +28,1146 @@ #include "AutoFillForm/AutoFillFormManager.h" #include "UserAgentStrings.h" -namespace tizen_browser{ -namespace base_ui{ - -enum SettingsOptions { - BASIC, - ADVANCED, - DEL_WEB_BRO, - RESET_MOST_VIS, - RESET_BRO, - AUTO_FILL, - CONTENT, - PRIVACY, - DEVELOPER -}; - -typedef struct _genlistCallbackData { - UserAgentItem uaItem; - void *user_data; - Elm_Object_Item *it; -} genlistCallbackData; - -EXPORT_SERVICE(SettingsUI, "org.tizen.browser.settingsui") - -SettingsUI::SettingsUI() - : m_settings_layout(nullptr) - , m_subpage_layout(nullptr) - , m_items_layout(nullptr) - , m_parent(nullptr) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("SettingsUI/SettingsMobileUI.edj"); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - - m_setting_item_class = elm_genlist_item_class_new(); - m_setting_item_class->item_style = "settings_button"; - m_setting_item_class->func.text_get = _gengrid_item_text_get; - m_setting_item_class->func.content_get = nullptr; - m_setting_item_class->func.state_get = nullptr; - m_setting_item_class->func.del = nullptr; - - m_setting_parent_item_class = elm_genlist_item_class_new(); - m_setting_parent_item_class->item_style = "settings_parent_button"; - m_setting_parent_item_class->func.text_get = _gengrid_item_text_get; - m_setting_parent_item_class->func.content_get = nullptr; - m_setting_parent_item_class->func.state_get = nullptr; - m_setting_parent_item_class->func.del = nullptr; - - updateButtonMap(); -} - -SettingsUI::~SettingsUI() -{ - if(m_setting_item_class) - elm_genlist_item_class_free(m_setting_item_class); - if(m_setting_parent_item_class) - elm_genlist_item_class_free(m_setting_parent_item_class); -} - -void SettingsUI::init(Evas_Object* parent) +namespace tizen_browser { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} - -void SettingsUI::updateButtonMap() { - ItemData deleteWebBrowsing; - //TODO Add translation API - deleteWebBrowsing.buttonText="Delete Web Browsing Data"; - - ItemData resetMostVisited; - resetMostVisited.buttonText="Reset Most Visited Site"; - - ItemData resetBrowser; - resetBrowser.buttonText="Reset Browser"; - - ItemData autoFill; - autoFill.buttonText=_("IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); - - ItemData content; - content.buttonText="Content Settings"; - - ItemData privacy; - privacy.buttonText="Privacy"; - - ItemData developer; - developer.buttonText="Developer Options"; - - ItemData basic; - basic.buttonText="<b>Basic</b>"; - - ItemData advanced; - advanced.buttonText="<b>Advanced</b>"; - - m_buttonsMap[SettingsOptions::BASIC]=basic; - m_buttonsMap[SettingsOptions::ADVANCED]=advanced; - m_buttonsMap[SettingsOptions::DEL_WEB_BRO]=deleteWebBrowsing; - m_buttonsMap[SettingsOptions::RESET_MOST_VIS]=resetMostVisited; - m_buttonsMap[SettingsOptions::RESET_BRO]=resetBrowser; - m_buttonsMap[SettingsOptions::AUTO_FILL]=autoFill; - m_buttonsMap[SettingsOptions::CONTENT]=content; - m_buttonsMap[SettingsOptions::PRIVACY]=privacy; - m_buttonsMap[SettingsOptions::DEVELOPER]=developer; -} - -Evas_Object* SettingsUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - if (!m_settings_layout) - m_settings_layout = createSettingsUILayout(m_parent); - return m_settings_layout; -} - -void SettingsUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_show(m_settings_layout); - evas_object_show(m_actionBar); -} - -void SettingsUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_hide(m_settings_layout); - evas_object_hide(m_actionBar); -} - -Evas_Object* SettingsUI::createSettingsUILayout(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - Evas_Object* settings_layout = elm_layout_add(parent); - elm_layout_file_set(settings_layout, m_edjFilePath.c_str(), "settings-layout"); - evas_object_size_hint_weight_set(settings_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(settings_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_actionBar = createActionBar(settings_layout); - m_items_layout = createSettingsMobilePage(settings_layout); - elm_object_tree_focus_allow_set(settings_layout, EINA_FALSE); - - orientationChanged(); - - return settings_layout; -} - -void SettingsUI::orientationChanged(){ - auto rot = isLandscape(); - if (rot && *rot) { - if (m_actionBar) - elm_object_signal_emit(m_actionBar,"rotation,landscape", "rot"); - if (m_items_layout) { - elm_object_signal_emit(m_items_layout, "rotation,landscape,main", "rot"); - } - if (m_subpage_layout) - elm_object_signal_emit(m_subpage_layout,"rotation,landscape,sub", "rot"); - } else { - if (m_actionBar) - elm_object_signal_emit(m_actionBar,"rotation,portrait", "rot"); - if (m_items_layout) { - elm_object_signal_emit(m_items_layout,"rotation,portrait,main", "rot"); - } - if (m_subpage_layout) - elm_object_signal_emit(m_subpage_layout, "rotation,portrait,sub", "rot"); + namespace base_ui + { + + enum SettingsOptions + { + BASIC, + ADVANCED, + DEL_WEB_BRO, + RESET_MOST_VIS, + RESET_BRO, + AUTO_FILL, + CONTENT, + PRIVACY, + DEVELOPER + }; + + typedef struct _genlistCallbackData + { + UserAgentItem uaItem; + void *user_data; + Elm_Object_Item *it; + } genlistCallbackData; + + EXPORT_SERVICE(SettingsUI, "org.tizen.browser.settingsui") + + SettingsUI::SettingsUI() + : m_settings_layout(nullptr) + , m_subpage_layout(nullptr) + , m_items_layout(nullptr) + , m_parent(nullptr) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SettingsUI/SettingsMobileUI.edj"); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + + m_setting_item_class = elm_genlist_item_class_new(); + m_setting_item_class->item_style = "settings_button"; + m_setting_item_class->func.text_get = _gengrid_item_text_get; + m_setting_item_class->func.content_get = nullptr; + m_setting_item_class->func.state_get = nullptr; + m_setting_item_class->func.del = nullptr; + + m_setting_parent_item_class = elm_genlist_item_class_new(); + m_setting_parent_item_class->item_style = "settings_parent_button"; + m_setting_parent_item_class->func.text_get = _gengrid_item_text_get; + m_setting_parent_item_class->func.content_get = nullptr; + m_setting_parent_item_class->func.state_get = nullptr; + m_setting_parent_item_class->func.del = nullptr; + + updateButtonMap(); } -} -Evas_Object* SettingsUI::createActionBar(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object* actionBar = elm_layout_add(settings_layout); - elm_object_part_content_set(settings_layout, "actionbar_swallow", actionBar); - evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); - Evas_Object *close_click_btn = elm_button_add(actionBar); - elm_object_style_set(close_click_btn, "basic_button"); - evas_object_smart_callback_add(close_click_btn, "clicked", SettingsUI::close_clicked_cb, this); - elm_object_part_content_set(actionBar, "close_click", close_click_btn); - elm_object_translatable_part_text_set(actionBar, "settings_title", "IDS_BR_BODY_SETTINGS"); - - return actionBar; -} - -Evas_Object* SettingsUI::createBackActionBar(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object* actionBar = elm_layout_add(settings_layout); - elm_object_part_content_set(settings_layout, "actionbar_swallow", actionBar); - evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); - Evas_Object *close_click_btn = elm_button_add(actionBar); - elm_object_style_set(close_click_btn, "basic_button"); - evas_object_smart_callback_add(close_click_btn, "clicked", SettingsUI::back_clicked_cb, this); - elm_object_part_content_set(actionBar, "close_click", close_click_btn); - - return actionBar; -} - -char* SettingsUI::_gengrid_item_text_get(void* data, Evas_Object* /*obj*/, const char* part) -{ - M_ASSERT(data); - if (!data) - return nullptr; - - ItemData* it = static_cast<ItemData*>(data); - - if (strcmp(part, "button_text") == 0) { - //TODO Implement translation API - const char* item_name = it->buttonText.c_str(); - if (item_name) - return strdup(item_name); - } - return nullptr; -} - -void SettingsUI::_language_changed(void *data, Evas_Object* obj, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->updateButtonMap(); - elm_genlist_realized_items_update(obj); + SettingsUI::~SettingsUI() + { + if (m_setting_item_class) + elm_genlist_item_class_free(m_setting_item_class); + if (m_setting_parent_item_class) + elm_genlist_item_class_free(m_setting_parent_item_class); } -} -Evas_Object* SettingsUI::createSettingsMobilePage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Evas_Object* layout = createMainView(settings_layout); + void SettingsUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); + void SettingsUI::updateButtonMap() + { + ItemData deleteWebBrowsing; + //TODO Add translation API + deleteWebBrowsing.buttonText = "Delete Web Browsing Data"; - Evas_Object* scroller = elm_genlist_add(layout); - elm_genlist_homogeneous_set(scroller, EINA_TRUE); - elm_scroller_movement_block_set(scroller, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL); + ItemData resetMostVisited; + resetMostVisited.buttonText = "Reset Most Visited Site"; - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, 0.0); - evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, 0.0); - elm_genlist_select_mode_set(scroller, ELM_OBJECT_SELECT_MODE_ALWAYS); - elm_genlist_multi_select_set(scroller, EINA_FALSE); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); - evas_object_smart_callback_add(scroller, "language,changed", _language_changed, this); + ItemData resetBrowser; + resetBrowser.buttonText = "Reset Browser"; - auto it = elm_genlist_item_append(scroller, m_setting_parent_item_class, &m_buttonsMap[SettingsOptions::BASIC], nullptr, ELM_GENLIST_ITEM_GROUP, nullptr, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::AUTO_FILL], it, ELM_GENLIST_ITEM_NONE,_auto_fill_data_menu_clicked_cb, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::RESET_MOST_VIS], it, ELM_GENLIST_ITEM_NONE, _reset_mv_menu_clicked_cb, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::DEL_WEB_BRO], it, ELM_GENLIST_ITEM_NONE, _del_selected_data_menu_clicked_cb, this); + ItemData autoFill; + autoFill.buttonText = _("IDS_BR_BODY_AUTO_FILL_FORMS_T_TTS"); - it = elm_genlist_item_append(scroller, m_setting_parent_item_class, &m_buttonsMap[SettingsOptions::ADVANCED], nullptr, ELM_GENLIST_ITEM_GROUP, nullptr, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::PRIVACY], it, ELM_GENLIST_ITEM_NONE,_privacy_menu_clicked_cb, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::CONTENT], it, ELM_GENLIST_ITEM_NONE,_content_settings_menu_clicked_cb, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::RESET_BRO], it, ELM_GENLIST_ITEM_NONE,_reset_browser_menu_clicked_cb, this); - elm_genlist_item_append(scroller, m_setting_item_class, &m_buttonsMap[SettingsOptions::DEVELOPER], it, ELM_GENLIST_ITEM_NONE,_developer_menu_clicked_cb, this); + ItemData content; + content.buttonText = "Content Settings"; - elm_object_part_content_set(layout, "options_swallow", scroller); - evas_object_show(scroller); + ItemData privacy; + privacy.buttonText = "Privacy"; - return layout; -} - -Evas_Object* SettingsUI::createMainView(Evas_Object* settings_layout) -{ - auto main = elm_layout_add(settings_layout); - elm_layout_file_set(main, m_edjFilePath.c_str(), "settings_items"); - elm_object_part_content_set(settings_layout, "settings_subpage_swallow", main); - evas_object_size_hint_weight_set(main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(main, EVAS_HINT_FILL, EVAS_HINT_FILL); - - return main; -} - -Evas_Object* SettingsUI::createInfoField(const char* name, const char* text, Evas_Object* parent) -{ - auto info_field = elm_button_add(parent); - elm_object_style_set(info_field, name); - elm_layout_content_set(parent, "info_swallow", info_field); + ItemData developer; + developer.buttonText = "Developer Options"; - elm_object_translatable_part_text_set(info_field, "text", text); // TODO Add translation API - return info_field; -} + ItemData basic; + basic.buttonText = "<b>Basic</b>"; -Evas_Object* SettingsUI::createDelDataMobilePage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + ItemData advanced; + advanced.buttonText = "<b>Advanced</b>"; - auto main = createMainView(settings_layout); + m_buttonsMap[SettingsOptions::BASIC] = basic; + m_buttonsMap[SettingsOptions::ADVANCED] = advanced; + m_buttonsMap[SettingsOptions::DEL_WEB_BRO] = deleteWebBrowsing; + m_buttonsMap[SettingsOptions::RESET_MOST_VIS] = resetMostVisited; + m_buttonsMap[SettingsOptions::RESET_BRO] = resetBrowser; + m_buttonsMap[SettingsOptions::AUTO_FILL] = autoFill; + m_buttonsMap[SettingsOptions::CONTENT] = content; + m_buttonsMap[SettingsOptions::PRIVACY] = privacy; + m_buttonsMap[SettingsOptions::DEVELOPER] = developer; + } - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Delete Web Browsing Data"); + Evas_Object *SettingsUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if (!m_settings_layout) + m_settings_layout = createSettingsUILayout(m_parent); + return m_settings_layout; + } - createInfoField("info_field", "You can delete Web Browsing Data optionally.", main); + void SettingsUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_show(m_settings_layout); + evas_object_show(m_actionBar); + } - auto check_boxes = createDelDataMobileCheckBoxes(main); + void SettingsUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_hide(m_settings_layout); + evas_object_hide(m_actionBar); + } - auto scroller = elm_scroller_add(main); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); - elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); - elm_scroller_propagate_events_set(scroller, EINA_TRUE); - elm_scroller_page_relative_set(scroller, 0, 1); - elm_object_content_set(scroller, check_boxes); - evas_object_show(scroller); + Evas_Object *SettingsUI::createSettingsUILayout(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + Evas_Object *settings_layout = elm_layout_add(parent); + elm_layout_file_set(settings_layout, m_edjFilePath.c_str(), + "settings-layout"); + evas_object_size_hint_weight_set(settings_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(settings_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + m_actionBar = createActionBar(settings_layout); + m_items_layout = createSettingsMobilePage(settings_layout); + elm_object_tree_focus_allow_set(settings_layout, EINA_FALSE); + + orientationChanged(); + + return settings_layout; + } - elm_object_part_content_set(main, "options_swallow", scroller); + void SettingsUI::orientationChanged() + { + auto rot = isLandscape(); + if (rot && *rot) { + if (m_actionBar) + elm_object_signal_emit(m_actionBar, "rotation,landscape", "rot"); + if (m_items_layout) { + elm_object_signal_emit(m_items_layout, "rotation,landscape,main", + "rot"); + } + if (m_subpage_layout) + elm_object_signal_emit(m_subpage_layout, "rotation,landscape,sub", + "rot"); + } else { + if (m_actionBar) + elm_object_signal_emit(m_actionBar, "rotation,portrait", "rot"); + if (m_items_layout) { + elm_object_signal_emit(m_items_layout, "rotation,portrait,main", + "rot"); + } + if (m_subpage_layout) + elm_object_signal_emit(m_subpage_layout, "rotation,portrait,sub", + "rot"); + } + } - return main; -} + Evas_Object *SettingsUI::createActionBar(Evas_Object * settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *actionBar = elm_layout_add(settings_layout); + elm_object_part_content_set(settings_layout, "actionbar_swallow", + actionBar); + evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); + Evas_Object *close_click_btn = elm_button_add(actionBar); + elm_object_style_set(close_click_btn, "basic_button"); + evas_object_smart_callback_add(close_click_btn, "clicked", + SettingsUI::close_clicked_cb, this); + elm_object_part_content_set(actionBar, "close_click", close_click_btn); + elm_object_translatable_part_text_set(actionBar, "settings_title", + "IDS_BR_BODY_SETTINGS"); + + return actionBar; + } -Evas_Object* SettingsUI::createDelDataMobileCheckBoxes(Evas_Object* parent) -{ - auto box = elm_box_add(parent); - elm_box_horizontal_set(box, EINA_FALSE); - elm_object_content_set(parent, box); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(box); - - m_checkbox_layout = elm_layout_add(box); - evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), "delete_browsing_data_mobile"); - - auto cache_checkbox = createCheckBox(m_checkbox_layout, "cache", __checkbox_label_click_cb, this); - auto cookies_checkbox = createCheckBox(m_checkbox_layout, "cookies", __checkbox_label_click_cb, this); - auto history_checkbox = createCheckBox(m_checkbox_layout, "history", __checkbox_label_click_cb, this); - auto password_checkbox = createCheckBox(m_checkbox_layout, "password", __checkbox_label_click_cb, this); - auto formdata_checkbox = createCheckBox(m_checkbox_layout, "formdata", __checkbox_label_click_cb, this); - - elm_check_state_set(cache_checkbox, EINA_TRUE); - elm_check_state_set(cookies_checkbox, EINA_TRUE); - elm_check_state_set(history_checkbox, EINA_TRUE); - elm_check_state_set(password_checkbox, EINA_TRUE); - elm_check_state_set(formdata_checkbox, EINA_TRUE); - - evas_object_show(m_checkbox_layout); - elm_box_pack_end(box, m_checkbox_layout); - - auto button_layout = elm_layout_add(box); - elm_layout_file_set(button_layout, m_edjFilePath.c_str(), "delete_browsing_data_button"); - evas_object_size_hint_weight_set(button_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(button_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - auto del_selected_data_button = elm_button_add(button_layout); - elm_object_style_set(del_selected_data_button, "custom_button"); - elm_layout_content_set(button_layout, "del_selected_data_click", del_selected_data_button); - evas_object_show(del_selected_data_button); - - evas_object_smart_callback_add(del_selected_data_button, "clicked", _del_selected_data_clicked_cb, this); - elm_object_translatable_part_text_set(del_selected_data_button, "button_text", "Delete Selected Data"); // TODO Add translation API - evas_object_show(button_layout); - elm_box_pack_end(box, button_layout); - - return box; -} + Evas_Object *SettingsUI::createBackActionBar(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *actionBar = elm_layout_add(settings_layout); + elm_object_part_content_set(settings_layout, "actionbar_swallow", + actionBar); + evas_object_size_hint_weight_set(actionBar, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(actionBar, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + elm_layout_file_set(actionBar, m_edjFilePath.c_str(), "action_bar"); + Evas_Object *close_click_btn = elm_button_add(actionBar); + elm_object_style_set(close_click_btn, "basic_button"); + evas_object_smart_callback_add(close_click_btn, "clicked", + SettingsUI::back_clicked_cb, this); + elm_object_part_content_set(actionBar, "close_click", close_click_btn); + + return actionBar; + } -Evas_Object* SettingsUI::createRemoveMostVisitedMobilePage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + char *SettingsUI::_gengrid_item_text_get(void *data, + Evas_Object * /*obj */ , + const char *part) + { + M_ASSERT(data); + if (!data) + return nullptr; + + ItemData *it = static_cast < ItemData * >(data); + + if (strcmp(part, "button_text") == 0) { + //TODO Implement translation API + const char *item_name = it->buttonText.c_str(); + if (item_name) + return strdup(item_name); + } + return nullptr; + } - Evas_Object* layout = elm_layout_add(settings_layout); - elm_layout_file_set(layout, m_edjFilePath.c_str(), "reset_most_visited"); - elm_object_part_content_set(settings_layout, "settings_subpage_swallow", layout); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + void SettingsUI::_language_changed(void *data, Evas_Object * obj, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->updateButtonMap(); + elm_genlist_realized_items_update(obj); + } + } - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Reset Most Visited Site"); - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); + Evas_Object *SettingsUI::createSettingsMobilePage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = createMainView(settings_layout); + + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + + Evas_Object *scroller = elm_genlist_add(layout); + elm_genlist_homogeneous_set(scroller, EINA_TRUE); + elm_scroller_movement_block_set(scroller, + ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL); + + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, 0.0); + elm_genlist_select_mode_set(scroller, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_genlist_multi_select_set(scroller, EINA_FALSE); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); + evas_object_smart_callback_add(scroller, "language,changed", + _language_changed, this); + + auto it = + elm_genlist_item_append(scroller, m_setting_parent_item_class, + &m_buttonsMap[SettingsOptions::BASIC], + nullptr, ELM_GENLIST_ITEM_GROUP, nullptr, + this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::AUTO_FILL], it, + ELM_GENLIST_ITEM_NONE, + _auto_fill_data_menu_clicked_cb, this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::RESET_MOST_VIS], + it, ELM_GENLIST_ITEM_NONE, + _reset_mv_menu_clicked_cb, this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::DEL_WEB_BRO], it, + ELM_GENLIST_ITEM_NONE, + _del_selected_data_menu_clicked_cb, this); + + it = + elm_genlist_item_append(scroller, m_setting_parent_item_class, + &m_buttonsMap[SettingsOptions::ADVANCED], + nullptr, ELM_GENLIST_ITEM_GROUP, nullptr, + this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::PRIVACY], it, + ELM_GENLIST_ITEM_NONE, _privacy_menu_clicked_cb, + this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::CONTENT], it, + ELM_GENLIST_ITEM_NONE, + _content_settings_menu_clicked_cb, this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::RESET_BRO], it, + ELM_GENLIST_ITEM_NONE, + _reset_browser_menu_clicked_cb, this); + elm_genlist_item_append(scroller, m_setting_item_class, + &m_buttonsMap[SettingsOptions::DEVELOPER], it, + ELM_GENLIST_ITEM_NONE, + _developer_menu_clicked_cb, this); + + elm_object_part_content_set(layout, "options_swallow", scroller); + evas_object_show(scroller); + + return layout; + } - Evas_Object *reset_mv_button = elm_button_add(layout); - elm_object_style_set(reset_mv_button, "basic_button"); - evas_object_smart_callback_add(reset_mv_button, "clicked", _reset_mv_clicked_cb, this); - elm_layout_content_set(layout, "reset_most_visited_click", reset_mv_button); + Evas_Object *SettingsUI::createMainView(Evas_Object * settings_layout) + { + auto main = elm_layout_add(settings_layout); + elm_layout_file_set(main, m_edjFilePath.c_str(), "settings_items"); + elm_object_part_content_set(settings_layout, "settings_subpage_swallow", + main); + evas_object_size_hint_weight_set(main, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(main, EVAS_HINT_FILL, EVAS_HINT_FILL); + + return main; + } - elm_object_translatable_part_text_set(layout, "reset_most_visited_sub_text", "You can delete all items of Most Visited Site."); + Evas_Object *SettingsUI::createInfoField(const char *name, + const char *text, + Evas_Object * parent) + { + auto info_field = elm_button_add(parent); + elm_object_style_set(info_field, name); + elm_layout_content_set(parent, "info_swallow", info_field); - return layout; -} + elm_object_translatable_part_text_set(info_field, "text", text); // TODO Add translation API + return info_field; + } -Evas_Object* SettingsUI::createRemoveBrowserDataMobilePage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *SettingsUI::createDelDataMobilePage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - Evas_Object* layout = elm_layout_add(settings_layout); - elm_layout_file_set(layout, m_edjFilePath.c_str(), "reset_browser"); - elm_object_part_content_set(settings_layout, "settings_swallow", layout); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + auto main = createMainView(settings_layout); - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Reset Browser"); - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Delete Web Browsing Data"); - Evas_Object *reset_browser_button = elm_button_add(layout); - elm_object_style_set(reset_browser_button, "basic_button"); - evas_object_smart_callback_add(reset_browser_button, "clicked", _reset_browser_clicked_cb, this); - elm_layout_content_set(layout, "reset_browser_click", reset_browser_button); + createInfoField("info_field", + "You can delete Web Browsing Data optionally.", main); - elm_object_translatable_part_text_set(layout, "reset_browser_sub_text", "You can delete all data and return to initial setting."); + auto check_boxes = createDelDataMobileCheckBoxes(main); - return layout; -} - -Evas_Object* SettingsUI::createDeveloperOptionsMobilePage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + auto scroller = elm_scroller_add(main); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); + elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_propagate_events_set(scroller, EINA_TRUE); + elm_scroller_page_relative_set(scroller, 0, 1); + elm_object_content_set(scroller, check_boxes); + evas_object_show(scroller); - Evas_Object* layout = elm_layout_add(settings_layout); - elm_layout_file_set(layout, m_edjFilePath.c_str(), "developer_options"); - elm_object_part_content_set(settings_layout, "settings_swallow", layout); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(main, "options_swallow", scroller); - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Developer Options"); - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); + return main; + } - Evas_Object *override_ua_button = elm_button_add(layout); - elm_object_style_set(override_ua_button, "basic_button"); - evas_object_smart_callback_add(override_ua_button, "clicked", _override_useragent_clicked_cb, this); - elm_layout_content_set(layout, "override_useragent_click", override_ua_button); + Evas_Object *SettingsUI::createDelDataMobileCheckBoxes(Evas_Object * + parent) + { + auto box = elm_box_add(parent); + elm_box_horizontal_set(box, EINA_FALSE); + elm_object_content_set(parent, box); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + + m_checkbox_layout = elm_layout_add(box); + evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), + "delete_browsing_data_mobile"); + + auto cache_checkbox = + createCheckBox(m_checkbox_layout, "cache", __checkbox_label_click_cb, + this); + auto cookies_checkbox = + createCheckBox(m_checkbox_layout, "cookies", + __checkbox_label_click_cb, this); + auto history_checkbox = + createCheckBox(m_checkbox_layout, "history", + __checkbox_label_click_cb, this); + auto password_checkbox = + createCheckBox(m_checkbox_layout, "password", + __checkbox_label_click_cb, this); + auto formdata_checkbox = + createCheckBox(m_checkbox_layout, "formdata", + __checkbox_label_click_cb, this); + + elm_check_state_set(cache_checkbox, EINA_TRUE); + elm_check_state_set(cookies_checkbox, EINA_TRUE); + elm_check_state_set(history_checkbox, EINA_TRUE); + elm_check_state_set(password_checkbox, EINA_TRUE); + elm_check_state_set(formdata_checkbox, EINA_TRUE); + + evas_object_show(m_checkbox_layout); + elm_box_pack_end(box, m_checkbox_layout); + + auto button_layout = elm_layout_add(box); + elm_layout_file_set(button_layout, m_edjFilePath.c_str(), + "delete_browsing_data_button"); + evas_object_size_hint_weight_set(button_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(button_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + auto del_selected_data_button = elm_button_add(button_layout); + elm_object_style_set(del_selected_data_button, "custom_button"); + elm_layout_content_set(button_layout, "del_selected_data_click", + del_selected_data_button); + evas_object_show(del_selected_data_button); + + evas_object_smart_callback_add(del_selected_data_button, "clicked", + _del_selected_data_clicked_cb, this); + elm_object_translatable_part_text_set(del_selected_data_button, "button_text", "Delete Selected Data"); // TODO Add translation API + evas_object_show(button_layout); + elm_box_pack_end(box, button_layout); + + return box; + } - elm_object_translatable_part_text_set(layout, "developer_options_sub_text", "You can override the Browser's UserAgent to desired string."); + Evas_Object *SettingsUI::createRemoveMostVisitedMobilePage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(settings_layout); + elm_layout_file_set(layout, m_edjFilePath.c_str(), + "reset_most_visited"); + elm_object_part_content_set(settings_layout, "settings_subpage_swallow", + layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Reset Most Visited Site"); + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + + Evas_Object *reset_mv_button = elm_button_add(layout); + elm_object_style_set(reset_mv_button, "basic_button"); + evas_object_smart_callback_add(reset_mv_button, "clicked", + _reset_mv_clicked_cb, this); + elm_layout_content_set(layout, "reset_most_visited_click", + reset_mv_button); + + elm_object_translatable_part_text_set(layout, + "reset_most_visited_sub_text", + "You can delete all items of Most Visited Site."); + + return layout; + } - return layout; -} + Evas_Object *SettingsUI::createRemoveBrowserDataMobilePage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(settings_layout); + elm_layout_file_set(layout, m_edjFilePath.c_str(), "reset_browser"); + elm_object_part_content_set(settings_layout, "settings_swallow", + layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Reset Browser"); + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + + Evas_Object *reset_browser_button = elm_button_add(layout); + elm_object_style_set(reset_browser_button, "basic_button"); + evas_object_smart_callback_add(reset_browser_button, "clicked", + _reset_browser_clicked_cb, this); + elm_layout_content_set(layout, "reset_browser_click", + reset_browser_button); + + elm_object_translatable_part_text_set(layout, "reset_browser_sub_text", + "You can delete all data and return to initial setting."); + + return layout; + } -Evas_Object* SettingsUI::createCheckBox(Evas_Object* layout, const std::string name, Edje_Signal_Cb func, void* data) -{ - Evas_Object* edje = elm_layout_edje_get(layout); - Evas_Object* checkbox = elm_check_add(layout); - elm_object_style_set(checkbox, "custom_check"); - elm_layout_content_set(layout, (name + "_cb").c_str(), checkbox); - edje_object_signal_callback_add(edje, "mouse,clicked,1", (name + "_cb_text_bg").c_str(), func, data); - evas_object_show(checkbox); - return checkbox; -} + Evas_Object *SettingsUI::createDeveloperOptionsMobilePage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(settings_layout); + elm_layout_file_set(layout, m_edjFilePath.c_str(), "developer_options"); + elm_object_part_content_set(settings_layout, "settings_swallow", + layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Developer Options"); + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + + Evas_Object *override_ua_button = elm_button_add(layout); + elm_object_style_set(override_ua_button, "basic_button"); + evas_object_smart_callback_add(override_ua_button, "clicked", + _override_useragent_clicked_cb, this); + elm_layout_content_set(layout, "override_useragent_click", + override_ua_button); + + elm_object_translatable_part_text_set(layout, + "developer_options_sub_text", + "You can override the Browser's UserAgent to desired string."); + + return layout; + } -void SettingsUI::__checkbox_label_click_cb(void *data, Evas_Object*, const char*, const char *source) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - - if (strcmp(source, "cache_cb_text_bg") == 0 ){ - Evas_Object *cache_check = elm_layout_content_get(self->m_checkbox_layout, "cache_cb"); - elm_check_state_set(cache_check, !elm_check_state_get(cache_check)); - } - else if (strcmp(source, "cookies_cb_text_bg") == 0 ){ - Evas_Object *cookies_check = elm_layout_content_get(self->m_checkbox_layout, "cookies_cb"); - elm_check_state_set(cookies_check, !elm_check_state_get(cookies_check)); - } - else if (strcmp(source, "history_cb_text_bg") == 0 ){ - Evas_Object *history_check = elm_layout_content_get(self->m_checkbox_layout, "history_cb"); - elm_check_state_set(history_check, !elm_check_state_get(history_check)); - } - else if (strcmp(source, "password_cb_text_bg") == 0 ){ - Evas_Object *password_check = elm_layout_content_get(self->m_checkbox_layout, "password_cb"); - elm_check_state_set(password_check, !elm_check_state_get(password_check)); - } - else if (strcmp(source, "formdata_cb_text_bg") == 0 ){ - Evas_Object *formdata_check = elm_layout_content_get(self->m_checkbox_layout, "formdata_cb"); - elm_check_state_set(formdata_check, !elm_check_state_get(formdata_check)); - } - else{ - BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, __LINE__); - } + Evas_Object *SettingsUI::createCheckBox(Evas_Object * layout, + const std::string name, + Edje_Signal_Cb func, void *data) + { + Evas_Object *edje = elm_layout_edje_get(layout); + Evas_Object *checkbox = elm_check_add(layout); + elm_object_style_set(checkbox, "custom_check"); + elm_layout_content_set(layout, (name + "_cb").c_str(), checkbox); + edje_object_signal_callback_add(edje, "mouse,clicked,1", + (name + "_cb_text_bg").c_str(), func, + data); + evas_object_show(checkbox); + return checkbox; } -} -Evas_Object* SettingsUI::createContentSettingsPage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - auto main = createMainView(settings_layout); - - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Content Settings"); - - createInfoField("info_field", "Choose web page content", main); - - auto box = elm_box_add(main); - elm_box_horizontal_set(box, EINA_FALSE); - elm_object_content_set(main, box); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(box); - - m_checkbox_layout = elm_layout_add(box); - evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), "content_settings_mobile"); - - boost::optional<bool> sig = getWebEngineSettingsParam(basic_webengine::WebEngineSettings::PAGE_OVERVIEW); - Eina_Bool flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; - Evas_Object* overview_checkbox = createCheckBox(m_checkbox_layout, "overview", __checkbox_content_settings_label_click_cb, this); - elm_check_state_set(overview_checkbox, flag); - - sig = getWebEngineSettingsParam(basic_webengine::WebEngineSettings::LOAD_IMAGES); - flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; - Evas_Object* images_checkbox = createCheckBox(m_checkbox_layout, "images", __checkbox_content_settings_label_click_cb, this); - elm_check_state_set(images_checkbox, flag); - - sig = getWebEngineSettingsParam(basic_webengine::WebEngineSettings::ENABLE_JAVASCRIPT); - flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; - Evas_Object* javascript_checkbox = createCheckBox(m_checkbox_layout, "javascript", __checkbox_content_settings_label_click_cb, this); - elm_check_state_set(javascript_checkbox, flag); - - evas_object_show(m_checkbox_layout); - elm_box_pack_end(box, m_checkbox_layout); - - auto scroller = elm_scroller_add(main); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); - elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); - elm_scroller_propagate_events_set(scroller, EINA_TRUE); - elm_scroller_page_relative_set(scroller, 0, 1); - elm_object_content_set(scroller, box); - evas_object_show(scroller); - - elm_object_part_content_set(main, "options_swallow", scroller); - - return main; -} + void SettingsUI::__checkbox_label_click_cb(void *data, Evas_Object *, + const char *, + const char *source) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + + if (strcmp(source, "cache_cb_text_bg") == 0) { + Evas_Object *cache_check = + elm_layout_content_get(self->m_checkbox_layout, "cache_cb"); + elm_check_state_set(cache_check, !elm_check_state_get(cache_check)); + } else if (strcmp(source, "cookies_cb_text_bg") == 0) { + Evas_Object *cookies_check = + elm_layout_content_get(self->m_checkbox_layout, "cookies_cb"); + elm_check_state_set(cookies_check, + !elm_check_state_get(cookies_check)); + } else if (strcmp(source, "history_cb_text_bg") == 0) { + Evas_Object *history_check = + elm_layout_content_get(self->m_checkbox_layout, "history_cb"); + elm_check_state_set(history_check, + !elm_check_state_get(history_check)); + } else if (strcmp(source, "password_cb_text_bg") == 0) { + Evas_Object *password_check = + elm_layout_content_get(self->m_checkbox_layout, "password_cb"); + elm_check_state_set(password_check, + !elm_check_state_get(password_check)); + } else if (strcmp(source, "formdata_cb_text_bg") == 0) { + Evas_Object *formdata_check = + elm_layout_content_get(self->m_checkbox_layout, "formdata_cb"); + elm_check_state_set(formdata_check, + !elm_check_state_get(formdata_check)); + } else { + BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, + __LINE__); + } + } + } -Evas_Object* SettingsUI::createPrivacyPage(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - auto main = createMainView(settings_layout); - - elm_object_signal_emit(m_actionBar,"back,icon,change", "del_but"); - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Privacy"); - - createInfoField("info_field", "Choose privacy settings", main); - - auto box = elm_box_add(main); - elm_box_horizontal_set(box, EINA_FALSE); - elm_object_content_set(main, box); - evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(box); - - m_checkbox_layout = elm_layout_add(box); - elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), "privacy_mobile"); - evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - boost::optional<bool> sig = getWebEngineSettingsParam(basic_webengine::WebEngineSettings::REMEMBER_FROM_DATA); - Eina_Bool flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; - Evas_Object* form_data_checkbox = createCheckBox(m_checkbox_layout, "form_data", __checkbox_privacy_label_click_cb, this); - elm_check_state_set(form_data_checkbox, flag); - - sig = getWebEngineSettingsParam(basic_webengine::WebEngineSettings::REMEMBER_PASSWORDS); - flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; - Evas_Object* passwd_checkbox = createCheckBox(m_checkbox_layout, "passwords", __checkbox_privacy_label_click_cb, this); - elm_check_state_set(passwd_checkbox, flag); - - evas_object_show(m_checkbox_layout); - elm_box_pack_end(box, m_checkbox_layout); - - auto scroller = elm_scroller_add(main); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); - elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); - elm_scroller_propagate_events_set(scroller, EINA_TRUE); - elm_scroller_page_relative_set(scroller, 0, 1); - elm_object_content_set(scroller, box); - evas_object_show(scroller); - - elm_object_part_content_set(main, "options_swallow", scroller); - - return main; -} + Evas_Object *SettingsUI::createContentSettingsPage(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + auto main = createMainView(settings_layout); + + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Content Settings"); + + createInfoField("info_field", "Choose web page content", main); + + auto box = elm_box_add(main); + elm_box_horizontal_set(box, EINA_FALSE); + elm_object_content_set(main, box); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + + m_checkbox_layout = elm_layout_add(box); + evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), + "content_settings_mobile"); + + boost::optional < bool > sig = + getWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + PAGE_OVERVIEW); + Eina_Bool flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; + Evas_Object *overview_checkbox = + createCheckBox(m_checkbox_layout, "overview", + __checkbox_content_settings_label_click_cb, this); + elm_check_state_set(overview_checkbox, flag); + + sig = + getWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + LOAD_IMAGES); + flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; + Evas_Object *images_checkbox = + createCheckBox(m_checkbox_layout, "images", + __checkbox_content_settings_label_click_cb, this); + elm_check_state_set(images_checkbox, flag); + + sig = + getWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + ENABLE_JAVASCRIPT); + flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; + Evas_Object *javascript_checkbox = + createCheckBox(m_checkbox_layout, "javascript", + __checkbox_content_settings_label_click_cb, this); + elm_check_state_set(javascript_checkbox, flag); + + evas_object_show(m_checkbox_layout); + elm_box_pack_end(box, m_checkbox_layout); + + auto scroller = elm_scroller_add(main); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); + elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_propagate_events_set(scroller, EINA_TRUE); + elm_scroller_page_relative_set(scroller, 0, 1); + elm_object_content_set(scroller, box); + evas_object_show(scroller); + + elm_object_part_content_set(main, "options_swallow", scroller); + + return main; + } -void SettingsUI::__checkbox_content_settings_label_click_cb(void* data, Evas_Object*, const char*, const char* source) -{ - if (data) { - auto self = static_cast<SettingsUI*>(data); - - if (strcmp(source, "overview_cb_text_bg") == 0 ) { - Evas_Object *checkbox = elm_layout_content_get(self->m_checkbox_layout, "overview_cb"); - Eina_Bool value = !elm_check_state_get(checkbox); - elm_check_state_set(checkbox, value); - self->setWebEngineSettingsParam(basic_webengine::WebEngineSettings::PAGE_OVERVIEW, static_cast<bool>(value)); - } else if (strcmp(source, "images_cb_text_bg") == 0 ) { - Evas_Object *checkbox = elm_layout_content_get(self->m_checkbox_layout, "images_cb"); - Eina_Bool value = !elm_check_state_get(checkbox); - elm_check_state_set(checkbox, value); - self->setWebEngineSettingsParam(basic_webengine::WebEngineSettings::LOAD_IMAGES, static_cast<bool>(value)); - } else if (strcmp(source, "javascript_cb_text_bg") == 0 ) { - Evas_Object *checkbox = elm_layout_content_get(self->m_checkbox_layout, "javascript_cb"); - Eina_Bool value = !elm_check_state_get(checkbox); - elm_check_state_set(checkbox, value); - self->setWebEngineSettingsParam(basic_webengine::WebEngineSettings::ENABLE_JAVASCRIPT, static_cast<bool>(value)); - } else { - BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, __LINE__); - } - } else { - BROWSER_LOGD("[%s:%d] Warning no data specified!", __PRETTY_FUNCTION__, __LINE__); + Evas_Object *SettingsUI::createPrivacyPage(Evas_Object * settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + auto main = createMainView(settings_layout); + + elm_object_signal_emit(m_actionBar, "back,icon,change", "del_but"); + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Privacy"); + + createInfoField("info_field", "Choose privacy settings", main); + + auto box = elm_box_add(main); + elm_box_horizontal_set(box, EINA_FALSE); + elm_object_content_set(main, box); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(box); + + m_checkbox_layout = elm_layout_add(box); + elm_layout_file_set(m_checkbox_layout, m_edjFilePath.c_str(), + "privacy_mobile"); + evas_object_size_hint_weight_set(m_checkbox_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_checkbox_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + boost::optional < bool > sig = + getWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + REMEMBER_FROM_DATA); + Eina_Bool flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; + Evas_Object *form_data_checkbox = + createCheckBox(m_checkbox_layout, "form_data", + __checkbox_privacy_label_click_cb, this); + elm_check_state_set(form_data_checkbox, flag); + + sig = + getWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + REMEMBER_PASSWORDS); + flag = (sig && *sig) ? EINA_TRUE : EINA_FALSE; + Evas_Object *passwd_checkbox = + createCheckBox(m_checkbox_layout, "passwords", + __checkbox_privacy_label_click_cb, this); + elm_check_state_set(passwd_checkbox, flag); + + evas_object_show(m_checkbox_layout); + elm_box_pack_end(box, m_checkbox_layout); + + auto scroller = elm_scroller_add(main); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE); + elm_scroller_loop_set(scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_propagate_events_set(scroller, EINA_TRUE); + elm_scroller_page_relative_set(scroller, 0, 1); + elm_object_content_set(scroller, box); + evas_object_show(scroller); + + elm_object_part_content_set(main, "options_swallow", scroller); + + return main; } -} -void SettingsUI::__checkbox_privacy_label_click_cb(void* data, Evas_Object*, const char*, const char* source) -{ - if (data) { - auto self = static_cast<SettingsUI*>(data); - - if (strcmp(source, "form_data_cb_text_bg") == 0 ) { - Evas_Object *checkbox = elm_layout_content_get(self->m_checkbox_layout, "form_data_cb"); - Eina_Bool value = !elm_check_state_get(checkbox); - elm_check_state_set(checkbox, value); - self->setWebEngineSettingsParam(basic_webengine::WebEngineSettings::REMEMBER_FROM_DATA, static_cast<bool>(value)); - } else if (strcmp(source, "passwords_cb_text_bg") == 0 ) { - Evas_Object *checkbox = elm_layout_content_get(self->m_checkbox_layout, "passwords_cb"); - Eina_Bool value = !elm_check_state_get(checkbox); - elm_check_state_set(checkbox, value); - self->setWebEngineSettingsParam(basic_webengine::WebEngineSettings::REMEMBER_PASSWORDS, static_cast<bool>(value)); - } else { - BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, __LINE__); - } - } else { - BROWSER_LOGD("[%s:%d] Warning no data specified!", __PRETTY_FUNCTION__, __LINE__); + void SettingsUI::__checkbox_content_settings_label_click_cb(void *data, + Evas_Object *, + const char *, + const char + *source) + { + if (data) { + auto self = static_cast < SettingsUI * >(data); + + if (strcmp(source, "overview_cb_text_bg") == 0) { + Evas_Object *checkbox = + elm_layout_content_get(self->m_checkbox_layout, "overview_cb"); + Eina_Bool value = !elm_check_state_get(checkbox); + elm_check_state_set(checkbox, value); + self-> + setWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + PAGE_OVERVIEW, + static_cast < bool > (value)); + } else if (strcmp(source, "images_cb_text_bg") == 0) { + Evas_Object *checkbox = + elm_layout_content_get(self->m_checkbox_layout, "images_cb"); + Eina_Bool value = !elm_check_state_get(checkbox); + elm_check_state_set(checkbox, value); + self-> + setWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + LOAD_IMAGES, + static_cast < bool > (value)); + } else if (strcmp(source, "javascript_cb_text_bg") == 0) { + Evas_Object *checkbox = + elm_layout_content_get(self->m_checkbox_layout, "javascript_cb"); + Eina_Bool value = !elm_check_state_get(checkbox); + elm_check_state_set(checkbox, value); + self-> + setWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + ENABLE_JAVASCRIPT, + static_cast < bool > (value)); + } else { + BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, + __LINE__); + } + } else { + BROWSER_LOGD("[%s:%d] Warning no data specified!", + __PRETTY_FUNCTION__, __LINE__); + } } -} -void SettingsUI::close_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI * s_ui = static_cast<SettingsUI*>(data); - s_ui->closeSettingsUIClicked(); + void SettingsUI::__checkbox_privacy_label_click_cb(void *data, + Evas_Object *, + const char *, + const char *source) + { + if (data) { + auto self = static_cast < SettingsUI * >(data); + + if (strcmp(source, "form_data_cb_text_bg") == 0) { + Evas_Object *checkbox = + elm_layout_content_get(self->m_checkbox_layout, "form_data_cb"); + Eina_Bool value = !elm_check_state_get(checkbox); + elm_check_state_set(checkbox, value); + self-> + setWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + REMEMBER_FROM_DATA, + static_cast < bool > (value)); + } else if (strcmp(source, "passwords_cb_text_bg") == 0) { + Evas_Object *checkbox = + elm_layout_content_get(self->m_checkbox_layout, "passwords_cb"); + Eina_Bool value = !elm_check_state_get(checkbox); + elm_check_state_set(checkbox, value); + self-> + setWebEngineSettingsParam(basic_webengine::WebEngineSettings:: + REMEMBER_PASSWORDS, + static_cast < bool > (value)); + } else { + BROWSER_LOGD("[%s:%d] - no matched source", __PRETTY_FUNCTION__, + __LINE__); + } + } else { + BROWSER_LOGD("[%s:%d] Warning no data specified!", + __PRETTY_FUNCTION__, __LINE__); + } } -} -void SettingsUI::back_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI * s_ui = static_cast<SettingsUI*>(data); - s_ui->onBackKey(); + void SettingsUI::close_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *s_ui = static_cast < SettingsUI * >(data); + s_ui->closeSettingsUIClicked(); + } } -} -void SettingsUI::initializeAutoFillManager() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - resetItemsLayoutContent(); - - m_actionBar = createBackActionBar(m_settings_layout); - auto main = createMainView(m_settings_layout); - m_autoFillManager = std::unique_ptr<AutoFillFormManager>(new AutoFillFormManager()); - m_autoFillManager->listViewBackClicked.connect(boost::bind(&SettingsUI::destroyAutoFillManager, this)); - m_autoFillManager->init(main, m_actionBar); - - m_subpage_layout = m_autoFillManager->showListView(); - elm_object_tree_focus_allow_set(m_settings_layout, EINA_TRUE); -} + void SettingsUI::back_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *s_ui = static_cast < SettingsUI * >(data); + s_ui->onBackKey(); + } + } -void SettingsUI::destroyAutoFillManager() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_tree_focus_allow_set(m_settings_layout, EINA_FALSE); -} + void SettingsUI::initializeAutoFillManager() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + resetItemsLayoutContent(); + + m_actionBar = createBackActionBar(m_settings_layout); + auto main = createMainView(m_settings_layout); + m_autoFillManager = + std::unique_ptr < AutoFillFormManager > (new AutoFillFormManager()); + m_autoFillManager->listViewBackClicked. + connect(boost::bind(&SettingsUI::destroyAutoFillManager, this)); + m_autoFillManager->init(main, m_actionBar); + + m_subpage_layout = m_autoFillManager->showListView(); + elm_object_tree_focus_allow_set(m_settings_layout, EINA_TRUE); + } -void SettingsUI::_auto_fill_data_menu_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->initializeAutoFillManager(); + void SettingsUI::destroyAutoFillManager() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_tree_focus_allow_set(m_settings_layout, EINA_FALSE); } -} -void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - Evas_Object *cache_check = elm_layout_content_get(self->m_checkbox_layout, "cache_cb"); - Evas_Object *cookies_check = elm_layout_content_get(self->m_checkbox_layout, "cookies_cb"); - Evas_Object *history_check = elm_layout_content_get(self->m_checkbox_layout, "history_cb"); - Evas_Object *password_check = elm_layout_content_get(self->m_checkbox_layout, "password_cb"); - Evas_Object *formdata_check = elm_layout_content_get(self->m_checkbox_layout, "formdata_cb"); - std::string type; - elm_check_state_get(cache_check) ? type += "_CACHE" : ""; - elm_check_state_get(cookies_check) ? type += "_COOKIES" : ""; - elm_check_state_get(history_check) ? type += "_HISTORY" : ""; - elm_check_state_get(password_check) ? type += "_PASSWORD" : ""; - elm_check_state_get(formdata_check) ? type += "_FORMDATA" : ""; - - self->deleteSelectedDataClicked(type); + void SettingsUI::_auto_fill_data_menu_clicked_cb(void *data, + Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->initializeAutoFillManager(); + } } -} -void SettingsUI::_del_selected_data_menu_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createDelDataMobilePage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_del_selected_data_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + Evas_Object *cache_check = + elm_layout_content_get(self->m_checkbox_layout, "cache_cb"); + Evas_Object *cookies_check = + elm_layout_content_get(self->m_checkbox_layout, "cookies_cb"); + Evas_Object *history_check = + elm_layout_content_get(self->m_checkbox_layout, "history_cb"); + Evas_Object *password_check = + elm_layout_content_get(self->m_checkbox_layout, "password_cb"); + Evas_Object *formdata_check = + elm_layout_content_get(self->m_checkbox_layout, "formdata_cb"); + std::string type; + elm_check_state_get(cache_check) ? type += "_CACHE" : ""; + elm_check_state_get(cookies_check) ? type += "_COOKIES" : ""; + elm_check_state_get(history_check) ? type += "_HISTORY" : ""; + elm_check_state_get(password_check) ? type += "_PASSWORD" : ""; + elm_check_state_get(formdata_check) ? type += "_FORMDATA" : ""; + + self->deleteSelectedDataClicked(type); + } } -} -void SettingsUI::_reset_mv_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetMostVisitedClicked(); - self->orientationChanged(); + void SettingsUI::_del_selected_data_menu_clicked_cb(void *data, + Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createDelDataMobilePage(self->m_settings_layout); + self->orientationChanged(); + } } -} -void SettingsUI::_reset_mv_menu_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createRemoveMostVisitedMobilePage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_reset_mv_clicked_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetMostVisitedClicked(); + self->orientationChanged(); + } } -} -void SettingsUI::_reset_browser_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetBrowserClicked(); - self->orientationChanged(); + void SettingsUI::_reset_mv_menu_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createRemoveMostVisitedMobilePage(self->m_settings_layout); + self->orientationChanged(); + } } -} -void SettingsUI::_reset_browser_menu_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createRemoveBrowserDataMobilePage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_reset_browser_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetBrowserClicked(); + self->orientationChanged(); + } } -} -void SettingsUI::_content_settings_menu_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - auto self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createContentSettingsPage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_reset_browser_menu_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createRemoveBrowserDataMobilePage(self->m_settings_layout); + self->orientationChanged(); + } } -} -void SettingsUI::_privacy_menu_clicked_cb(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - auto self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createPrivacyPage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_content_settings_menu_clicked_cb(void *data, + Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + auto self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createContentSettingsPage(self->m_settings_layout); + self->orientationChanged(); + } } -} -void SettingsUI::_developer_menu_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createDeveloperOptionsMobilePage(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_privacy_menu_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + auto self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createPrivacyPage(self->m_settings_layout); + self->orientationChanged(); + } } -} -void SettingsUI::_override_useragent_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - SettingsUI* self = static_cast<SettingsUI*>(data); - self->resetItemsLayoutContent(); - self->m_actionBar = self->createBackActionBar(self->m_settings_layout); - self->m_subpage_layout = self->createUserAgentGenList(self->m_settings_layout); - self->orientationChanged(); + void SettingsUI::_developer_menu_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createDeveloperOptionsMobilePage(self->m_settings_layout); + self->orientationChanged(); + } } -} -Evas_Object* SettingsUI::createUserAgentGenList(Evas_Object* settings_layout) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Evas_Object* layout = elm_layout_add(settings_layout); - elm_layout_file_set(layout, m_edjFilePath.c_str(), "useragent_list"); - elm_object_part_content_set(settings_layout, "settings_swallow", layout); - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - elm_object_translatable_part_text_set(m_actionBar, "settings_title", "Override UserAgent"); - elm_object_focus_set(elm_object_part_content_get(m_actionBar, "close_click"), EINA_TRUE); - - Evas_Object *genlist = elm_genlist_add(layout); - if (!genlist) { - BROWSER_LOGE("elm_genlist_add failed"); - return NULL; - } - Elm_Genlist_Item_Class* itemClass = elm_genlist_item_class_new(); - itemClass->item_style = "useragent_item"; - itemClass->func.content_get = NULL; - itemClass->func.text_get = _ua_text_get_cb; - itemClass->func.state_get = NULL; - itemClass->func.del = NULL; - - for (unsigned int i = 0; i < UA_ITEMS_COUNT; i++) { - genlistCallbackData* item_callback_data = new genlistCallbackData; - item_callback_data->uaItem = {uaList[i].name, uaList[i].uaString}; - item_callback_data->user_data = this; - item_callback_data->it = elm_genlist_item_append(genlist, itemClass, item_callback_data, NULL, - ELM_GENLIST_ITEM_NONE, _useragent_item_clicked_cb, item_callback_data); - } - evas_object_show(genlist); - elm_object_part_content_set(layout, "ua_genlist_swallow", genlist); - - return layout; -} + void SettingsUI::_override_useragent_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + SettingsUI *self = static_cast < SettingsUI * >(data); + self->resetItemsLayoutContent(); + self->m_actionBar = + self->createBackActionBar(self->m_settings_layout); + self->m_subpage_layout = + self->createUserAgentGenList(self->m_settings_layout); + self->orientationChanged(); + } + } -void SettingsUI::_useragent_item_clicked_cb(void *data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); - SettingsUI *self = static_cast<SettingsUI*>(callback_data->user_data); - self->userAgentItemClicked(std::string(callback_data->uaItem.uaString)); + Evas_Object *SettingsUI::createUserAgentGenList(Evas_Object * + settings_layout) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Evas_Object *layout = elm_layout_add(settings_layout); + elm_layout_file_set(layout, m_edjFilePath.c_str(), "useragent_list"); + elm_object_part_content_set(settings_layout, "settings_swallow", + layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_object_translatable_part_text_set(m_actionBar, "settings_title", + "Override UserAgent"); + elm_object_focus_set(elm_object_part_content_get + (m_actionBar, "close_click"), EINA_TRUE); + + Evas_Object *genlist = elm_genlist_add(layout); + if (!genlist) { + BROWSER_LOGE("elm_genlist_add failed"); + return NULL; + } + Elm_Genlist_Item_Class *itemClass = elm_genlist_item_class_new(); + itemClass->item_style = "useragent_item"; + itemClass->func.content_get = NULL; + itemClass->func.text_get = _ua_text_get_cb; + itemClass->func.state_get = NULL; + itemClass->func.del = NULL; + + for (unsigned int i = 0; i < UA_ITEMS_COUNT; i++) { + genlistCallbackData *item_callback_data = new genlistCallbackData; + item_callback_data->uaItem = { + uaList[i].name, uaList[i].uaString}; + item_callback_data->user_data = this; + item_callback_data->it = + elm_genlist_item_append(genlist, itemClass, item_callback_data, + NULL, ELM_GENLIST_ITEM_NONE, + _useragent_item_clicked_cb, + item_callback_data); + } + evas_object_show(genlist); + elm_object_part_content_set(layout, "ua_genlist_swallow", genlist); + + return layout; } -} -char* SettingsUI::_ua_text_get_cb(void* data, Evas_Object* /*obj*/, const char *part) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - BROWSER_LOGD("part[%s]", part); + void SettingsUI::_useragent_item_clicked_cb(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + SettingsUI *self = + static_cast < SettingsUI * >(callback_data->user_data); + self-> + userAgentItemClicked(std::string(callback_data->uaItem.uaString)); + } + } - genlistCallbackData *callback_data = static_cast<genlistCallbackData*>(data); - if (!strcmp(part, "item_title")) - return strdup(callback_data->uaItem.name); - return NULL; -} + char *SettingsUI::_ua_text_get_cb(void *data, Evas_Object * /*obj */ , + const char *part) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + BROWSER_LOGD("part[%s]", part); + + genlistCallbackData *callback_data = + static_cast < genlistCallbackData * >(data); + if (!strcmp(part, "item_title")) + return strdup(callback_data->uaItem.name); + return NULL; + } -void SettingsUI::resetItemsLayoutContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_part_content_unset(this->m_settings_layout, "settings_swallow"); - evas_object_del(this->m_actionBar); - evas_object_del(this->m_items_layout); - evas_object_del(this->m_subpage_layout); - evas_object_del(this->m_checkbox_layout); - this->destroyAutoFillManager(); - this->m_subpage_layout = nullptr; - this->m_checkbox_layout = nullptr; - this->m_items_layout = nullptr; - this->m_actionBar = nullptr; -} + void SettingsUI::resetItemsLayoutContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_part_content_unset(this->m_settings_layout, + "settings_swallow"); + evas_object_del(this->m_actionBar); + evas_object_del(this->m_items_layout); + evas_object_del(this->m_subpage_layout); + evas_object_del(this->m_checkbox_layout); + this->destroyAutoFillManager(); + this->m_subpage_layout = nullptr; + this->m_checkbox_layout = nullptr; + this->m_items_layout = nullptr; + this->m_actionBar = nullptr; + } -bool SettingsUI::isSubpage() -{ - return (m_subpage_layout != nullptr); -} + bool SettingsUI::isSubpage() + { + return (m_subpage_layout != nullptr); + } -void SettingsUI::onBackKey() -{ - resetItemsLayoutContent(); - m_actionBar = createActionBar(m_settings_layout); - m_items_layout = createSettingsMobilePage(m_settings_layout); - this->orientationChanged(); -} -} + void SettingsUI::onBackKey() + { + resetItemsLayoutContent(); + m_actionBar = createActionBar(m_settings_layout); + m_items_layout = createSettingsMobilePage(m_settings_layout); + this->orientationChanged(); + } + } } diff --git a/services/SettingsUI/SettingsUI_mob.h b/services/SettingsUI/SettingsUI_mob.h index c0a8a2e8..2fca421e 100644..100755 --- a/services/SettingsUI/SettingsUI_mob.h +++ b/services/SettingsUI/SettingsUI_mob.h @@ -68,13 +68,13 @@ public: Evas_Object* createDeveloperOptionsMobilePage(Evas_Object* settings_layout); Evas_Object* createUserAgentGenList(Evas_Object* settings_layout); - boost::signals2::signal<void ()> resetBrowserClicked; - boost::signals2::signal<void ()> resetMostVisitedClicked; - boost::signals2::signal<void (std::string&)> deleteSelectedDataClicked; - boost::signals2::signal<void (const std::string&)> userAgentItemClicked; - boost::signals2::signal<void ()> closeSettingsUIClicked; - boost::signals2::signal<bool (basic_webengine::WebEngineSettings)> getWebEngineSettingsParam; - boost::signals2::signal<void (basic_webengine::WebEngineSettings, bool)> setWebEngineSettingsParam; + boost::signals2::signal<void()> resetBrowserClicked; + boost::signals2::signal<void()> resetMostVisitedClicked; + boost::signals2::signal<void(std::string&)> deleteSelectedDataClicked; + boost::signals2::signal<void(const std::string&)> userAgentItemClicked; + boost::signals2::signal<void()> closeSettingsUIClicked; + boost::signals2::signal<bool(basic_webengine::WebEngineSettings)> getWebEngineSettingsParam; + boost::signals2::signal<void(basic_webengine::WebEngineSettings, bool)> setWebEngineSettingsParam; private: Evas_Object* createSettingsUILayout(Evas_Object* parent); diff --git a/services/SimpleUI/ContentPopup_mob.h b/services/SimpleUI/ContentPopup_mob.h index b46955e1..0d494e84 100644..100755 --- a/services/SimpleUI/ContentPopup_mob.h +++ b/services/SimpleUI/ContentPopup_mob.h @@ -30,61 +30,71 @@ namespace tizen_browser { -namespace base_ui -{ - -class ContentPopup : public interfaces::AbstractPopup -{ -public: - static ContentPopup* createPopup(Evas_Object* parent); - static ContentPopup* createPopup(Evas_Object* parent, const std::string& title); - - void show(); - void dismiss(); - void onBackPressed(); - void orientationChanged() override { } - - void setTitle(const std::string& title); - void setContent(Evas_Object* content); - void addButton(const PopupButtons& button, bool dismissOnClick = true); - boost::signals2::signal<void (PopupButtons)> buttonClicked; - boost::signals2::signal<bool ()> isLandscape; - - ~ContentPopup(); - - Evas_Object* getMainLayout() { return m_scroller; } -private: - ContentPopup(Evas_Object* parent); - ContentPopup(Evas_Object* parent, const std::string& title); - void createLayout(); - - static void _layout_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); - static void _response_cb(void* data, Evas_Object* obj, void* event_info); - - struct Button { - Button(PopupButtons type, bool dismissOnClick, Evas_Object* object) - : m_type(type) - , m_dismissOnClick(dismissOnClick) - , m_evasObject(object) - {}; - PopupButtons m_type; - bool m_dismissOnClick; - Evas_Object* m_evasObject; + namespace base_ui + { + + class ContentPopup:public interfaces::AbstractPopup + { + public: + static ContentPopup *createPopup(Evas_Object * parent); + static ContentPopup *createPopup(Evas_Object * parent, + const std::string & title); + + void show(); + void dismiss(); + void onBackPressed(); + void orientationChanged() override + { + } + + void setTitle(const std::string & title); + void setContent(Evas_Object * content); + void addButton(const PopupButtons & button, bool dismissOnClick = true); + boost::signals2::signal < void(PopupButtons) > buttonClicked; + boost::signals2::signal < bool() > isLandscape; + + ~ContentPopup(); + + Evas_Object *getMainLayout() + { + return m_scroller; + } + private: + ContentPopup(Evas_Object * parent); + ContentPopup(Evas_Object * parent, const std::string & title); + void createLayout(); + + static void _layout_resize_cb(void *data, Evas * e, Evas_Object * obj, + void *event_info); + static void _response_cb(void *data, Evas_Object * obj, + void *event_info); + + struct Button + { + Button(PopupButtons type, bool dismissOnClick, Evas_Object * object) + :m_type(type) + , m_dismissOnClick(dismissOnClick) + , m_evasObject(object) + { + }; + PopupButtons m_type; + bool m_dismissOnClick; + Evas_Object *m_evasObject; + }; + + Evas_Object *m_parent; + Evas_Object *m_layout; + Evas_Object *m_buttons_box; + Evas_Object *m_scroller; + Evas_Object *m_content; + std::vector < Button > m_buttons; + std::string m_title; + std::string m_message; + std::string m_edjFilePath; + static const int MARGIN = 44; }; - Evas_Object* m_parent; - Evas_Object* m_layout; - Evas_Object* m_buttons_box; - Evas_Object* m_scroller; - Evas_Object* m_content; - std::vector<Button> m_buttons; - std::string m_title; - std::string m_message; - std::string m_edjFilePath; - static const int MARGIN = 44; -}; - -} + } } diff --git a/services/SimpleUI/InputPopup.cpp b/services/SimpleUI/InputPopup.cpp index 6d55c35a..aa59ec2a 100644..100755 --- a/services/SimpleUI/InputPopup.cpp +++ b/services/SimpleUI/InputPopup.cpp @@ -1,281 +1,338 @@ #include "InputPopup.h" -namespace tizen_browser { -namespace base_ui { - -InputPopup::InputPopup() : - m_parent(nullptr), - m_layout(nullptr), - m_buttons_box(nullptr), - m_button_left(nullptr), - m_button_right(nullptr), - m_input_area(nullptr), - m_input_cancel(nullptr), - m_entry(nullptr), - m_accept_right_left(false) +namespace tizen_browser { - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("SimpleUI/InputPopup.edj"); - elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); - m_bad_words.push_back(""); -} - -InputPopup::~InputPopup() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - evas_object_smart_callback_del(m_entry, "focused", _entry_focused); - evas_object_smart_callback_del(m_entry, "unfocused", _entry_unfocused); - evas_object_smart_callback_del(m_entry, "changed,user", _entry_changed); - evas_object_smart_callback_del(m_input_cancel, "clicked", _input_cancel_clicked); - evas_object_smart_callback_del(m_button_right, "clicked", _right_button_clicked); - evas_object_smart_callback_del(m_button_left, "clicked", _left_button_clicked); - evas_object_del(m_input_cancel); - evas_object_del(m_entry); - evas_object_del(m_input_area); - evas_object_del(m_button_right); - evas_object_del(m_button_left); - evas_object_del(m_buttons_box); - evas_object_del(m_layout); - button_clicked.disconnect_all_slots(); - popupDismissed.disconnect_all_slots(); - popupShown.disconnect_all_slots(); - m_bad_words.clear(); -} + namespace base_ui + { + + InputPopup::InputPopup():m_parent(nullptr), + m_layout(nullptr), + m_buttons_box(nullptr), + m_button_left(nullptr), + m_button_right(nullptr), + m_input_area(nullptr), + m_input_cancel(nullptr), m_entry(nullptr), m_accept_right_left(false) + { + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("SimpleUI/InputPopup.edj"); + elm_theme_extension_add(nullptr, m_edjFilePath.c_str()); + m_bad_words.push_back(""); + } -InputPopup* InputPopup::createPopup(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - InputPopup *inputPopup = new InputPopup(); - inputPopup->m_parent = parent; - return inputPopup; -} + InputPopup::~InputPopup() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + evas_object_smart_callback_del(m_entry, "focused", _entry_focused); + evas_object_smart_callback_del(m_entry, "unfocused", _entry_unfocused); + evas_object_smart_callback_del(m_entry, "changed,user", _entry_changed); + evas_object_smart_callback_del(m_input_cancel, "clicked", + _input_cancel_clicked); + evas_object_smart_callback_del(m_button_right, "clicked", + _right_button_clicked); + evas_object_smart_callback_del(m_button_left, "clicked", + _left_button_clicked); + evas_object_del(m_input_cancel); + evas_object_del(m_entry); + evas_object_del(m_input_area); + evas_object_del(m_button_right); + evas_object_del(m_button_left); + evas_object_del(m_buttons_box); + evas_object_del(m_layout); + button_clicked.disconnect_all_slots(); + popupDismissed.disconnect_all_slots(); + popupShown.disconnect_all_slots(); + m_bad_words.clear(); + } -InputPopup* InputPopup::createPopup(Evas_Object *parent, const std::string& title, const std::string& message, const std::string& input, - const std::string& rightButtonText, const std::string& leftButtonText, bool accept_right_left) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - InputPopup *inputPopup = new InputPopup(); - inputPopup->m_parent = parent; - inputPopup->m_title = title; - inputPopup->m_message = message; - inputPopup->m_input = input; - inputPopup->m_ok_button_text = rightButtonText; - inputPopup->m_cancel_button_text = leftButtonText; - inputPopup->m_accept_right_left = accept_right_left; - return inputPopup; -} + InputPopup *InputPopup::createPopup(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + InputPopup *inputPopup = new InputPopup(); + inputPopup->m_parent = parent; + return inputPopup; + } -void InputPopup::setInput(const std::string& input) -{ - m_input = input; -} + InputPopup *InputPopup::createPopup(Evas_Object * parent, + const std::string & title, + const std::string & message, + const std::string & input, + const std::string & rightButtonText, + const std::string & leftButtonText, + bool accept_right_left) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + InputPopup *inputPopup = new InputPopup(); + inputPopup->m_parent = parent; + inputPopup->m_title = title; + inputPopup->m_message = message; + inputPopup->m_input = input; + inputPopup->m_ok_button_text = rightButtonText; + inputPopup->m_cancel_button_text = leftButtonText; + inputPopup->m_accept_right_left = accept_right_left; + return inputPopup; + } -void InputPopup::setTitle(const std::string& title) -{ - m_title = title; -} + void InputPopup::setInput(const std::string & input) + { + m_input = input; + } -void InputPopup::setMessage(const std::string& message) -{ - m_message = message; -} + void InputPopup::setTitle(const std::string & title) + { + m_title = title; + } -void InputPopup::setOkButtonText(const std::string& okButtonText) -{ - m_ok_button_text = okButtonText; -} + void InputPopup::setMessage(const std::string & message) + { + m_message = message; + } -void InputPopup::setCancelButtonText(const std::string& cancelButtonText) -{ - m_cancel_button_text = cancelButtonText; -} + void InputPopup::setOkButtonText(const std::string & okButtonText) + { + m_ok_button_text = okButtonText; + } -void InputPopup::setAcceptRightLeft(bool right_left) -{ - m_accept_right_left = right_left; -} + void InputPopup::setCancelButtonText(const std::string & cancelButtonText) + { + m_cancel_button_text = cancelButtonText; + } -void InputPopup::addBadWord(const std::string &word) -{ - m_bad_words.push_back(word); -} + void InputPopup::setAcceptRightLeft(bool right_left) + { + m_accept_right_left = right_left; + } -void InputPopup::show() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - createLayout(); - popupShown(this); -} + void InputPopup::addBadWord(const std::string & word) + { + m_bad_words.push_back(word); + } -void InputPopup::dismiss() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - popupDismissed(this); -} + void InputPopup::show() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + createLayout(); + popupShown(this); + } -void InputPopup::onBackPressed() -{ - dismiss(); -} + void InputPopup::dismiss() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + popupDismissed(this); + } -void InputPopup::createLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_layout = elm_layout_add(m_parent); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "input-popup-layout"); - evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_text_set(m_layout, "title_text", m_title.c_str()); - - m_input_area = elm_layout_add(m_layout); - elm_object_part_content_set(m_layout, "input_swallow", m_input_area); - - evas_object_size_hint_weight_set(m_input_area, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_input_area, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(m_input_area); - - elm_layout_file_set(m_input_area, m_edjFilePath.c_str(), "input-area-layout"); - elm_object_part_text_set(m_input_area, "input_message_text", m_message.c_str()); - - m_entry = elm_entry_add(m_input_area); - elm_object_style_set(m_entry, "popup-input-entry"); - - elm_entry_single_line_set(m_entry, EINA_TRUE); - elm_entry_scrollable_set(m_entry, EINA_TRUE); - elm_entry_input_panel_layout_set(m_entry, ELM_INPUT_PANEL_LAYOUT_URL); - elm_object_part_content_set(m_input_area, "input_text_swallow", m_entry); - elm_object_part_text_set(m_entry, "elm.text", elm_entry_utf8_to_markup(m_input.c_str())); - - evas_object_smart_callback_add(m_entry, "focused", _entry_focused, (void*)this); - evas_object_smart_callback_add(m_entry, "unfocused", _entry_unfocused, (void*)this); - evas_object_smart_callback_add(m_entry, "changed,user", _entry_changed, (void*)this); - - m_input_cancel = elm_button_add(m_input_area); - elm_object_style_set(m_input_cancel, "invisible_button"); - evas_object_smart_callback_add(m_input_cancel, "clicked", _input_cancel_clicked, this); - - evas_object_show(m_input_cancel); - elm_object_part_content_set(m_input_area, "input_cancel_click", m_input_cancel); - - m_buttons_box = elm_box_add(m_layout); - elm_box_horizontal_set(m_buttons_box, EINA_TRUE); - evas_object_size_hint_weight_set(m_buttons_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_buttons_box, EVAS_HINT_FILL, EVAS_HINT_FILL); - - m_button_left = elm_button_add(m_buttons_box); - elm_object_style_set(m_button_left, "input-popup-button"); - evas_object_size_hint_weight_set(m_button_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_button_left, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_text_set(m_button_left, "elm.text", m_cancel_button_text.c_str()); - elm_box_pack_end(m_buttons_box, m_button_left); - evas_object_smart_callback_add(m_button_left, "clicked", _left_button_clicked, (void*)this); - - evas_object_show(m_button_left); - - m_button_right = elm_button_add(m_buttons_box); - elm_object_style_set(m_button_right, "input-popup-button"); - evas_object_size_hint_weight_set(m_button_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_button_right, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_part_text_set(m_button_right, "elm.text", m_ok_button_text.c_str()); - elm_box_pack_end(m_buttons_box, m_button_right); - evas_object_smart_callback_add(m_button_right, "clicked", _right_button_clicked, (void*)this); - - evas_object_show(m_button_right); - elm_object_signal_emit(m_button_right, "visible", "ui"); - - evas_object_show(m_buttons_box); - elm_object_part_content_set(m_layout, "buttons_swallow", m_buttons_box); - - evas_object_show(m_layout); - elm_object_part_content_set(m_parent, "popup_content", m_layout); - - if (std::find(m_bad_words.begin(), m_bad_words.end(), m_input) != m_bad_words.end()) { - elm_object_disabled_set(m_accept_right_left ? m_button_right : m_button_left, EINA_TRUE); - elm_object_signal_emit(m_accept_right_left ? m_button_right : m_button_left, "dissabled", "ui"); + void InputPopup::onBackPressed() + { + dismiss(); } - elm_object_signal_emit(m_input_area, "close_icon_show", "ui"); -} + void InputPopup::createLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_layout = elm_layout_add(m_parent); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), + "input-popup-layout"); + evas_object_size_hint_weight_set(m_layout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_layout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_object_part_text_set(m_layout, "title_text", m_title.c_str()); + + m_input_area = elm_layout_add(m_layout); + elm_object_part_content_set(m_layout, "input_swallow", m_input_area); + + evas_object_size_hint_weight_set(m_input_area, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_input_area, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_show(m_input_area); + + elm_layout_file_set(m_input_area, m_edjFilePath.c_str(), + "input-area-layout"); + elm_object_part_text_set(m_input_area, "input_message_text", + m_message.c_str()); + + m_entry = elm_entry_add(m_input_area); + elm_object_style_set(m_entry, "popup-input-entry"); + + elm_entry_single_line_set(m_entry, EINA_TRUE); + elm_entry_scrollable_set(m_entry, EINA_TRUE); + elm_entry_input_panel_layout_set(m_entry, ELM_INPUT_PANEL_LAYOUT_URL); + elm_object_part_content_set(m_input_area, "input_text_swallow", + m_entry); + elm_object_part_text_set(m_entry, "elm.text", + elm_entry_utf8_to_markup(m_input.c_str())); + + evas_object_smart_callback_add(m_entry, "focused", _entry_focused, + (void *) this); + evas_object_smart_callback_add(m_entry, "unfocused", _entry_unfocused, + (void *) this); + evas_object_smart_callback_add(m_entry, "changed,user", _entry_changed, + (void *) this); + + m_input_cancel = elm_button_add(m_input_area); + elm_object_style_set(m_input_cancel, "invisible_button"); + evas_object_smart_callback_add(m_input_cancel, "clicked", + _input_cancel_clicked, this); + + evas_object_show(m_input_cancel); + elm_object_part_content_set(m_input_area, "input_cancel_click", + m_input_cancel); + + m_buttons_box = elm_box_add(m_layout); + elm_box_horizontal_set(m_buttons_box, EINA_TRUE); + evas_object_size_hint_weight_set(m_buttons_box, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_buttons_box, EVAS_HINT_FILL, + EVAS_HINT_FILL); + + m_button_left = elm_button_add(m_buttons_box); + elm_object_style_set(m_button_left, "input-popup-button"); + evas_object_size_hint_weight_set(m_button_left, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_button_left, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_object_part_text_set(m_button_left, "elm.text", + m_cancel_button_text.c_str()); + elm_box_pack_end(m_buttons_box, m_button_left); + evas_object_smart_callback_add(m_button_left, "clicked", + _left_button_clicked, (void *) this); + + evas_object_show(m_button_left); + + m_button_right = elm_button_add(m_buttons_box); + elm_object_style_set(m_button_right, "input-popup-button"); + evas_object_size_hint_weight_set(m_button_right, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_button_right, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_object_part_text_set(m_button_right, "elm.text", + m_ok_button_text.c_str()); + elm_box_pack_end(m_buttons_box, m_button_right); + evas_object_smart_callback_add(m_button_right, "clicked", + _right_button_clicked, (void *) this); + + evas_object_show(m_button_right); + elm_object_signal_emit(m_button_right, "visible", "ui"); + + evas_object_show(m_buttons_box); + elm_object_part_content_set(m_layout, "buttons_swallow", m_buttons_box); + + evas_object_show(m_layout); + elm_object_part_content_set(m_parent, "popup_content", m_layout); + + if (std::find(m_bad_words.begin(), m_bad_words.end(), m_input) != + m_bad_words.end()) { + elm_object_disabled_set(m_accept_right_left ? m_button_right : + m_button_left, EINA_TRUE); + elm_object_signal_emit(m_accept_right_left ? m_button_right : + m_button_left, "dissabled", "ui"); + } + + elm_object_signal_emit(m_input_area, "close_icon_show", "ui"); + } -void InputPopup::_entry_focused(void* data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - InputPopup* inputPopup = static_cast<InputPopup*>(data); - elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_TRUE); - elm_object_signal_emit(inputPopup->m_entry, "focused", "ui"); + void InputPopup::_entry_focused(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + InputPopup *inputPopup = static_cast < InputPopup * >(data); + elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_TRUE); + elm_object_signal_emit(inputPopup->m_entry, "focused", "ui"); + } } -} -void InputPopup::_entry_unfocused(void* data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - InputPopup* inputPopup = static_cast<InputPopup*>(data); - elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_FALSE); - elm_object_signal_emit(inputPopup->m_entry, "unfocused", "ui"); + void InputPopup::_entry_unfocused(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + InputPopup *inputPopup = static_cast < InputPopup * >(data); + elm_object_focus_allow_set(inputPopup->m_input_cancel, EINA_FALSE); + elm_object_signal_emit(inputPopup->m_entry, "unfocused", "ui"); + } } -} -void InputPopup::_entry_changed(void* data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - InputPopup* inputPopup = static_cast<InputPopup*>(data); - std::string text = elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text")); - - if (text.empty()) - elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", "ui"); - else - elm_object_signal_emit(inputPopup->m_input_area, "close_icon_show", "ui"); - - if (std::find(inputPopup->m_bad_words.begin(), inputPopup->m_bad_words.end(), text) - != inputPopup->m_bad_words.end()) { - elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, EINA_TRUE); - elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, "dissabled", "ui"); - } else { - elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, EINA_FALSE); - elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, "enabled", "ui"); - } + void InputPopup::_entry_changed(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + InputPopup *inputPopup = static_cast < InputPopup * >(data); + std::string text = + elm_entry_markup_to_utf8(elm_object_part_text_get + (inputPopup->m_entry, "elm.text")); + + if (text.empty()) + elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", + "ui"); + else + elm_object_signal_emit(inputPopup->m_input_area, "close_icon_show", + "ui"); + + if (std:: + find(inputPopup->m_bad_words.begin(), + inputPopup->m_bad_words.end(), text) + != inputPopup->m_bad_words.end()) { + elm_object_disabled_set(inputPopup-> + m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + EINA_TRUE); + elm_object_signal_emit(inputPopup-> + m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + "dissabled", "ui"); + } else { + elm_object_disabled_set(inputPopup-> + m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + EINA_FALSE); + elm_object_signal_emit(inputPopup-> + m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + "enabled", "ui"); + } + } } -} -void InputPopup::_input_cancel_clicked(void * data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - InputPopup* inputPopup = static_cast<InputPopup*>(data); - elm_object_part_text_set(inputPopup->m_entry, "elm.text", ""); - elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, EINA_TRUE); - elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup->m_button_right : - inputPopup->m_button_left, "dissabled", "ui"); - elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", "ui"); + void InputPopup::_input_cancel_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + InputPopup *inputPopup = static_cast < InputPopup * >(data); + elm_object_part_text_set(inputPopup->m_entry, "elm.text", ""); + elm_object_disabled_set(inputPopup->m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + EINA_TRUE); + elm_object_signal_emit(inputPopup->m_accept_right_left ? inputPopup-> + m_button_right : inputPopup->m_button_left, + "dissabled", "ui"); + elm_object_signal_emit(inputPopup->m_input_area, "close_icon_hide", + "ui"); + } } -} -void InputPopup::_right_button_clicked(void *data, Evas_Object *, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - InputPopup *inputPopup = static_cast<InputPopup*>(data); - if (inputPopup->m_accept_right_left) - inputPopup->button_clicked(elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text"))); - inputPopup->dismiss(); -} + void InputPopup::_right_button_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + InputPopup *inputPopup = static_cast < InputPopup * >(data); + if (inputPopup->m_accept_right_left) + inputPopup-> + button_clicked(elm_entry_markup_to_utf8 + (elm_object_part_text_get + (inputPopup->m_entry, "elm.text"))); + inputPopup->dismiss(); + } -void InputPopup::_left_button_clicked(void* data, Evas_Object *, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - InputPopup *inputPopup = static_cast<InputPopup*>(data); - if (!inputPopup->m_accept_right_left) - inputPopup->button_clicked(elm_entry_markup_to_utf8(elm_object_part_text_get(inputPopup->m_entry, "elm.text"))); - inputPopup->dismiss(); -} + void InputPopup::_left_button_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + InputPopup *inputPopup = static_cast < InputPopup * >(data); + if (!inputPopup->m_accept_right_left) + inputPopup-> + button_clicked(elm_entry_markup_to_utf8 + (elm_object_part_text_get + (inputPopup->m_entry, "elm.text"))); + inputPopup->dismiss(); + } -} + } } diff --git a/services/SimpleUI/InputPopup.h b/services/SimpleUI/InputPopup.h index 18eaab65..5b745504 100644..100755 --- a/services/SimpleUI/InputPopup.h +++ b/services/SimpleUI/InputPopup.h @@ -32,65 +32,74 @@ #include "AbstractPopup.h" #include "ServiceManager.h" -namespace tizen_browser { -namespace base_ui { - -class InputPopup : public interfaces::AbstractPopup +namespace tizen_browser { + namespace base_ui + { -public: - static InputPopup* createPopup(Evas_Object *parent); - static InputPopup* createPopup(Evas_Object *parent,const std::string& title,const std::string& message,const std::string& input, - const std::string& rightButtonText, const std::string& leftButtonText, bool accept_right_left); + class InputPopup:public interfaces::AbstractPopup + { + public: + static InputPopup *createPopup(Evas_Object * parent); + static InputPopup *createPopup(Evas_Object * parent, + const std::string & title, + const std::string & message, + const std::string & input, + const std::string & rightButtonText, + const std::string & leftButtonText, + bool accept_right_left); - void show(); - void dismiss(); - void onBackPressed(); + void show(); + void dismiss(); + void onBackPressed(); #if PROFILE_MOBILE - void orientationChanged() {}; + void orientationChanged() + { + }; #endif - void setContent(Evas_Object *content); - void setInput(const std::string &input); - void setTitle(const std::string &title); - void setMessage(const std::string &message); - void setOkButtonText(const std::string &okButtonText); - void setCancelButtonText(const std::string &cancelButtonText); - void setAcceptRightLeft(bool right_left); - void addBadWord(const std::string &word); + void setContent(Evas_Object * content); + void setInput(const std::string & input); + void setTitle(const std::string & title); + void setMessage(const std::string & message); + void setOkButtonText(const std::string & okButtonText); + void setCancelButtonText(const std::string & cancelButtonText); + void setAcceptRightLeft(bool right_left); + void addBadWord(const std::string & word); - boost::signals2::signal<void (const std::string&)> button_clicked; + boost::signals2::signal < void(const std::string &) > button_clicked; -private: - InputPopup(); - ~InputPopup(); - void createLayout(); + private: + InputPopup(); + ~InputPopup(); + void createLayout(); - std::string m_edjFilePath; - static void _right_button_clicked(void *data, Evas_Object *btn, void*); - static void _left_button_clicked(void *data, Evas_Object *btn, void*); - static void _entry_changed(void * data, Evas_Object *, void*); - static void _entry_unfocused(void * data, Evas_Object *, void*); - static void _entry_focused(void * data, Evas_Object *, void*); - static void _input_cancel_clicked(void * data, Evas_Object *, void *); + std::string m_edjFilePath; + static void _right_button_clicked(void *data, Evas_Object * btn, + void *); + static void _left_button_clicked(void *data, Evas_Object * btn, void *); + static void _entry_changed(void *data, Evas_Object *, void *); + static void _entry_unfocused(void *data, Evas_Object *, void *); + static void _entry_focused(void *data, Evas_Object *, void *); + static void _input_cancel_clicked(void *data, Evas_Object *, void *); - Evas_Object *m_parent; - Evas_Object *m_layout; - Evas_Object *m_buttons_box; - Evas_Object *m_button_left; - Evas_Object *m_button_right; - Evas_Object *m_input_area; - Evas_Object *m_input_cancel; - Evas_Object *m_entry; - std::string m_input; - std::string m_title; - std::string m_message; - std::string m_ok_button_text; - std::string m_cancel_button_text; - std::vector<std::string> m_bad_words; - bool m_accept_right_left; -}; + Evas_Object *m_parent; + Evas_Object *m_layout; + Evas_Object *m_buttons_box; + Evas_Object *m_button_left; + Evas_Object *m_button_right; + Evas_Object *m_input_area; + Evas_Object *m_input_cancel; + Evas_Object *m_entry; + std::string m_input; + std::string m_title; + std::string m_message; + std::string m_ok_button_text; + std::string m_cancel_button_text; + std::vector < std::string > m_bad_words; + bool m_accept_right_left; + }; + } } -} -#endif //__INPUT_POPUP_H__ +#endif //__INPUT_POPUP_H__ diff --git a/services/SimpleUI/NotificationPopup.h b/services/SimpleUI/NotificationPopup.h index 570019b7..570019b7 100644..100755 --- a/services/SimpleUI/NotificationPopup.h +++ b/services/SimpleUI/NotificationPopup.h diff --git a/services/SimpleUI/SimplePopup.h b/services/SimpleUI/SimplePopup.h index d19cd0f4..54518a25 100644..100755 --- a/services/SimpleUI/SimplePopup.h +++ b/services/SimpleUI/SimplePopup.h @@ -30,61 +30,74 @@ namespace tizen_browser { -namespace base_ui -{ - -struct PopupData { - virtual ~PopupData() {}; -}; - -struct CertificatePopupData : public PopupData { - basic_webengine::CertificateConfirmationPtr cert; -}; - -struct EntryPopupData : public PopupData { - std::string text; - Evas_Object * entry; -}; - -class SimplePopup : public interfaces::AbstractPopup -{ -public: - static SimplePopup* createPopup(Evas_Object* parent); - static SimplePopup* createPopup(Evas_Object* parent, const std::string &title, const std::string &message); - - void show(); - void dismiss(); - void onBackPressed(); + namespace base_ui + { + + struct PopupData + { + virtual ~PopupData() + { + }; + }; + + struct CertificatePopupData:public PopupData + { + basic_webengine::CertificateConfirmationPtr cert; + }; + + struct EntryPopupData:public PopupData + { + std::string text; + Evas_Object *entry; + }; + + class SimplePopup:public interfaces::AbstractPopup + { + public: + static SimplePopup *createPopup(Evas_Object * parent); + static SimplePopup *createPopup(Evas_Object * parent, + const std::string & title, + const std::string & message); + + void show(); + void dismiss(); + void onBackPressed(); #if PROFILE_MOBILE - void orientationChanged() {}; + void orientationChanged() + { + }; #endif - void setTitle(const std::string &title); - void setMessage(const std::string &message); - void setContent(Evas_Object *content); - void setData(std::shared_ptr<PopupData> popupData); - void addButton(PopupButtons buttonId); - - boost::signals2::signal<void (PopupButtons, std::shared_ptr<PopupData>)> buttonClicked; - - ~SimplePopup(); - -private: - SimplePopup(Evas_Object* parent); - SimplePopup(Evas_Object* parent, const std::string &title, const std::string &message); - - Evas_Object *m_parent; - Evas_Object *popup; - Evas_Object *content; - std::string title; - std::string message; - std::list<PopupButtons> buttons; - static void _response_cb(void *data, Evas_Object *obj, void *event_info); - std::map<Evas_Object *, PopupButtons> addedButtons; - std::shared_ptr<PopupData> popupData; -}; - -} + void setTitle(const std::string & title); + void setMessage(const std::string & message); + void setContent(Evas_Object * content); + void setData(std::shared_ptr < PopupData > popupData); + void addButton(PopupButtons buttonId); + + boost::signals2::signal < void(PopupButtons, + std::shared_ptr < PopupData >) > + buttonClicked; + + ~SimplePopup(); + + private: + SimplePopup(Evas_Object * parent); + SimplePopup(Evas_Object * parent, const std::string & title, + const std::string & message); + + Evas_Object *m_parent; + Evas_Object *popup; + Evas_Object *content; + std::string title; + std::string message; + std::list < PopupButtons > buttons; + static void _response_cb(void *data, Evas_Object * obj, + void *event_info); + std::map < Evas_Object *, PopupButtons > addedButtons; + std::shared_ptr < PopupData > popupData; + }; + + } } diff --git a/services/SimpleUI/TextPopup_mob.h b/services/SimpleUI/TextPopup_mob.h index ed43c960..0eaffc78 100644..100755 --- a/services/SimpleUI/TextPopup_mob.h +++ b/services/SimpleUI/TextPopup_mob.h @@ -30,58 +30,67 @@ namespace tizen_browser { -namespace base_ui -{ + namespace base_ui + { -class TextPopup : public interfaces::AbstractPopup -{ -public: - static TextPopup* createPopup(Evas_Object* parent); - static TextPopup* createPopup(Evas_Object* parent, const std::string& title, const std::string& message); + class TextPopup:public interfaces::AbstractPopup + { + public: + static TextPopup *createPopup(Evas_Object * parent); + static TextPopup *createPopup(Evas_Object * parent, + const std::string & title, + const std::string & message); - void show(); - void dismiss(); - void onBackPressed(); + void show(); + void dismiss(); + void onBackPressed(); #if PROFILE_MOBILE - void orientationChanged() {}; + void orientationChanged() + { + }; #endif - void setTitle(const std::string& title); - void setMessage(const std::string& message); - void setContent(Evas_Object* content); - void addButton(const PopupButtons& button, bool dismissOnClick = true, bool defaultBackButton = false); - void createLayout(); - boost::signals2::signal<void (PopupButtons)> buttonClicked; + void setTitle(const std::string & title); + void setMessage(const std::string & message); + void setContent(Evas_Object * content); + void addButton(const PopupButtons & button, bool dismissOnClick = + true, bool defaultBackButton = false); + void createLayout(); + boost::signals2::signal < void(PopupButtons) > buttonClicked; - ~TextPopup(); + ~TextPopup(); -private: - TextPopup(Evas_Object* parent); - TextPopup(Evas_Object* parent, const std::string& title, const std::string& message); + private: + TextPopup(Evas_Object * parent); + TextPopup(Evas_Object * parent, const std::string & title, + const std::string & message); - struct Button { - Button(PopupButtons type, bool dismissOnClick) - : m_type(type) - , m_dismissOnClick(dismissOnClick) - , m_evasObject(nullptr) - {}; - PopupButtons m_type; - bool m_dismissOnClick; - Evas_Object* m_evasObject; - }; + struct Button + { + Button(PopupButtons type, bool dismissOnClick) + :m_type(type) + , m_dismissOnClick(dismissOnClick) + , m_evasObject(nullptr) + { + }; + PopupButtons m_type; + bool m_dismissOnClick; + Evas_Object *m_evasObject; + }; - Evas_Object* m_parent; - Evas_Object* m_layout; - Evas_Object* m_buttons_box; - std::vector<Button> m_buttons; - std::string m_title; - std::string m_message; - static void _response_cb(void* data, Evas_Object* obj, void* event_info); - std::string m_edjFilePath; - PopupButtons m_defaultBackButton = NONE; -}; + Evas_Object *m_parent; + Evas_Object *m_layout; + Evas_Object *m_buttons_box; + std::vector < Button > m_buttons; + std::string m_title; + std::string m_message; + static void _response_cb(void *data, Evas_Object * obj, + void *event_info); + std::string m_edjFilePath; + PopupButtons m_defaultBackButton = NONE; + }; -} + } } diff --git a/services/SimpleUI/ViewManager.h b/services/SimpleUI/ViewManager.h index 51082d9b..accfeb1b 100644..100755 --- a/services/SimpleUI/ViewManager.h +++ b/services/SimpleUI/ViewManager.h @@ -31,34 +31,36 @@ #include "core/AbstractInterfaces/AbstractUIComponent.h" -namespace tizen_browser{ -namespace base_ui{ +namespace tizen_browser +{ + namespace base_ui + { /** * @brief This class simplifies UI component management. It is a views stack. * It handles all widget framework issues related to changing active view. */ -class ViewManager -{ -public: + class ViewManager + { + public: /** * @brief constructor. */ - ViewManager(); + ViewManager(); /** * @brief initialization method * * @param A window which will contatin ViewManager's main layout. */ - void init(Evas_Object* parentWindow); + void init(Evas_Object * parentWindow); /** * @brief destructor * */ - ~ViewManager(); + ~ViewManager(); /** * @brief Pops stack to specified view. Hides actual view (if there is any) and @@ -67,13 +69,13 @@ public: * * @param A view which stack should be popped to. Do not use nullptr. */ - void popStackTo(interfaces::AbstractUIComponent* view); + void popStackTo(interfaces::AbstractUIComponent * view); /** * @brief Pops actual view from the stack, hides it and if there is any view * under it makes it visible. */ - void popTheStack(); + void popTheStack(); /** * @brief Pushes view to the stack, hides if any wiew was visible hides it and @@ -81,7 +83,7 @@ public: * * @param View pushed to stack. Do not use nullptr. */ - void pushViewToStack(interfaces::AbstractUIComponent* view); + void pushViewToStack(interfaces::AbstractUIComponent * view); /** * @brief Function returns elm layout used in view management. It's parent is @@ -89,14 +91,14 @@ public: * * @return ViewManager's main layout. */ - Evas_Object* getContent(); + Evas_Object *getContent(); /** * @brief Function returns conformant used in view management. * * @return ViewManager's conformant. */ - Evas_Object* getConformant(); + Evas_Object *getConformant(); /** * @brief Returns actual top of stack which is dispalyed. It stack is empty @@ -104,24 +106,24 @@ public: * * @return actual dispalyed view */ - interfaces::AbstractUIComponent* topOfStack(); + interfaces::AbstractUIComponent * topOfStack(); /** * @brief Signal checks if browser is in landscape mode. * * @return Returnes true when app is in landscape mode. */ - boost::signals2::signal<bool ()> isLandscape; - -private: - void updateLayout(interfaces::AbstractUIComponent* previousView); -private: - Evas_Object* m_mainLayout; - Evas_Object* m_conformant; - Evas_Object* m_parentWindow; - std::stack<interfaces::AbstractUIComponent*> m_viewStack; -}; - -}//namespace base_ui -}//namespace tizen_browser -#endif //VIEWMANAGER_H_ + boost::signals2::signal < bool() > isLandscape; + + private: + void updateLayout(interfaces::AbstractUIComponent * previousView); + private: + Evas_Object * m_mainLayout; + Evas_Object *m_conformant; + Evas_Object *m_parentWindow; + std::stack < interfaces::AbstractUIComponent * >m_viewStack; + }; + + } //namespace base_ui +} //namespace tizen_browser +#endif //VIEWMANAGER_H_ diff --git a/services/StorageService/CMakeLists.txt b/services/StorageService/CMakeLists.txt index 9d511975..9d511975 100644..100755 --- a/services/StorageService/CMakeLists.txt +++ b/services/StorageService/CMakeLists.txt diff --git a/services/StorageService/CertificateStorage.cpp b/services/StorageService/CertificateStorage.cpp index 8f45f7ff..8f45f7ff 100644..100755 --- a/services/StorageService/CertificateStorage.cpp +++ b/services/StorageService/CertificateStorage.cpp diff --git a/services/StorageService/CertificateStorage.h b/services/StorageService/CertificateStorage.h index 54c4cd27..54c4cd27 100644..100755 --- a/services/StorageService/CertificateStorage.h +++ b/services/StorageService/CertificateStorage.h diff --git a/services/StorageService/DBTools.cpp b/services/StorageService/DBTools.cpp index 453181d5..453181d5 100644..100755 --- a/services/StorageService/DBTools.cpp +++ b/services/StorageService/DBTools.cpp diff --git a/services/StorageService/DBTools.h b/services/StorageService/DBTools.h index 9e2278a4..9e2278a4 100644..100755 --- a/services/StorageService/DBTools.h +++ b/services/StorageService/DBTools.h diff --git a/services/StorageService/DriverManager.cpp b/services/StorageService/DriverManager.cpp index 9231532e..aef08e6f 100644..100755 --- a/services/StorageService/DriverManager.cpp +++ b/services/StorageService/DriverManager.cpp @@ -46,7 +46,6 @@ std::shared_ptr<SQLDatabase> DriverManagerInstance::getDatabase(const std::strin DriverManager::DriverManager() { - } DriverManager::~DriverManager() diff --git a/services/StorageService/DriverManager.h b/services/StorageService/DriverManager.h index 63127154..63127154 100644..100755 --- a/services/StorageService/DriverManager.h +++ b/services/StorageService/DriverManager.h diff --git a/services/StorageService/Field.cpp b/services/StorageService/Field.cpp index 912235c0..912235c0 100644..100755 --- a/services/StorageService/Field.cpp +++ b/services/StorageService/Field.cpp diff --git a/services/StorageService/Field.h b/services/StorageService/Field.h index 81b73ac0..81b73ac0 100644..100755 --- a/services/StorageService/Field.h +++ b/services/StorageService/Field.h diff --git a/services/StorageService/FoldersStorage.cpp b/services/StorageService/FoldersStorage.cpp index e84ec7b4..411bbb6f 100644..100755 --- a/services/StorageService/FoldersStorage.cpp +++ b/services/StorageService/FoldersStorage.cpp @@ -38,350 +38,443 @@ #include "StorageExceptionInitialization.h" namespace { - const std::string TABLE_FOLDER = "FOLDER_TABLE"; - const std::string COL_FOLDER_ID = "folder_id"; - const std::string COL_FOLDER_NAME = "name"; - const std::string COL_FOLDER_NUMBER = "number"; - const std::string CONSTRAINT_TABLE_PK = TABLE_FOLDER + "_PK"; - const std::string DDL_CREATE_TABLE_FOLDER - = " CREATE TABLE " + TABLE_FOLDER - + " ( " + COL_FOLDER_ID + " INTEGER, " - + " " + COL_FOLDER_NAME + " TEXT," - + " " + COL_FOLDER_NUMBER + " INTEGER," - + " CONSTRAINT " + CONSTRAINT_TABLE_PK - + " PRIMARY KEY ( " + COL_FOLDER_ID + " ) " - + " ON CONFLICT REPLACE " - + " ); "; + const std::string TABLE_FOLDER = "FOLDER_TABLE"; + const std::string COL_FOLDER_ID = "folder_id"; + const std::string COL_FOLDER_NAME = "name"; + const std::string COL_FOLDER_NUMBER = "number"; + const std::string CONSTRAINT_TABLE_PK = TABLE_FOLDER + "_PK"; + const std::string DDL_CREATE_TABLE_FOLDER + = " CREATE TABLE " + TABLE_FOLDER + + " ( " + COL_FOLDER_ID + " INTEGER, " + + " " + COL_FOLDER_NAME + " TEXT," + + " " + COL_FOLDER_NUMBER + " INTEGER," + + " CONSTRAINT " + CONSTRAINT_TABLE_PK + + " PRIMARY KEY ( " + COL_FOLDER_ID + " ) " + + " ON CONFLICT REPLACE " + " ); "; } -namespace tizen_browser { -namespace storage { +namespace tizen_browser +{ + namespace storage + { -FoldersStorage::FoldersStorage() - : m_isInitialized(false) + FoldersStorage::FoldersStorage() + :m_isInitialized(false) , m_dbFoldersInitialised(false) -{ - init(); -} + { + init(); + } -FoldersStorage::~FoldersStorage() -{ -} + FoldersStorage::~FoldersStorage() + { + } -void FoldersStorage::init() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(m_isInitialized) - return; + void FoldersStorage::init() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_isInitialized) + return; + + std::string resourceDbDir(boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get("resourcedb/dir"))); + std::string sessionDb(boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get("DB_FOLDERS"))); - std::string resourceDbDir(boost::any_cast < std::string > (tizen_browser::config::Config::getInstance().get("resourcedb/dir"))); - std::string sessionDb(boost::any_cast < std::string > (tizen_browser::config::Config::getInstance().get("DB_FOLDERS"))); + DB_FOLDERS = resourceDbDir + sessionDb; - DB_FOLDERS = resourceDbDir + sessionDb; + BROWSER_LOGD("[%s:%d] DB_FOLDERS=%s", __PRETTY_FUNCTION__, __LINE__, + DB_FOLDERS.c_str()); - BROWSER_LOGD("[%s:%d] DB_FOLDERS=%s", __PRETTY_FUNCTION__, __LINE__, DB_FOLDERS.c_str()); + try { + initDatabaseFolders(DB_FOLDERS); + } + catch(storage::StorageExceptionInitialization & e) { + BROWSER_LOGE("[%s:%d] Cannot initialize database %s!", + __PRETTY_FUNCTION__, __LINE__, DB_FOLDERS.c_str()); + } - try { - initDatabaseFolders(DB_FOLDERS); - } catch (storage::StorageExceptionInitialization & e) { - BROWSER_LOGE("[%s:%d] Cannot initialize database %s!", __PRETTY_FUNCTION__, __LINE__, DB_FOLDERS.c_str()); + m_isInitialized = true; } - m_isInitialized = true; -} + void FoldersStorage::initDatabaseFolders(const std::string & db_str) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -void FoldersStorage::initDatabaseFolders(const std::string& db_str) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (!m_dbFoldersInitialised) { - try { - dbtools::checkAndCreateTable(db_str, TABLE_FOLDER, DDL_CREATE_TABLE_FOLDER); - const std::string all = "All"; - if (ifFolderExists(all)) - AllFolder = getFolderId(all); - else - AllFolder = addFolder(all); + if (!m_dbFoldersInitialised) { + try { + dbtools::checkAndCreateTable(db_str, TABLE_FOLDER, + DDL_CREATE_TABLE_FOLDER); + const std::string all = "All"; + if (ifFolderExists(all)) + AllFolder = getFolderId(all); + else + AllFolder = addFolder(all); #if PROFILE_MOBILE - const std::string special = "Mobile"; //TODO: missing translation + const std::string special = "Mobile"; //TODO: missing translation #else - const std::string special = "Bookmark Bar"; //TODO: missing translation + const std::string special = "Bookmark Bar"; //TODO: missing translation #endif - if (ifFolderExists(special)) - SpecialFolder = getFolderId(special); - else - SpecialFolder = addFolder(special); - } catch (storage::StorageException & e) { - throw storage::StorageExceptionInitialization(e.getMessage(), - e.getErrorCode()); - } - - m_dbFoldersInitialised = true; + if (ifFolderExists(special)) + SpecialFolder = getFolderId(special); + else + SpecialFolder = addFolder(special); + } + catch(storage::StorageException & e) { + throw storage::StorageExceptionInitialization(e.getMessage(), + e.getErrorCode()); + } + + m_dbFoldersInitialised = true; + } + + M_ASSERT(m_dbFoldersInitialised); } - M_ASSERT(m_dbFoldersInitialised); -} - -services::SharedBookmarkFolder FoldersStorage::getFolder(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::string name = getFolderName(id); - unsigned int count = getFolderNumber(id); - services::SharedBookmarkFolder folder; - if (name != "") - folder = std::make_shared<services::BookmarkFolder>(id, name, count); - return folder; -} - -services::SharedBookmarkFolderList FoldersStorage::getFolders() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - services::SharedBookmarkFolderList folders; - int foldersCount = getFoldersCount(); - if (foldersCount != 0) { - boost::format getFoldersString("SELECT %1%, %2%, %3% FROM %4% ;"); - getFoldersString % COL_FOLDER_ID % COL_FOLDER_NAME % COL_FOLDER_NUMBER % TABLE_FOLDER; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getFoldersQuery(connection->prepare(getFoldersString.str())); - getFoldersQuery.exec(); - for (int i = 0; i < foldersCount; ++i) { - services::SharedBookmarkFolder bookmark = std::make_shared<services::BookmarkFolder>( - getFoldersQuery.getInt(0), getFoldersQuery.getString(1), getFoldersQuery.getInt(2)); - folders.push_back(bookmark); - getFoldersQuery.next(); - } - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); - } + services::SharedBookmarkFolder FoldersStorage::getFolder(unsigned int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::string name = getFolderName(id); + unsigned int count = getFolderNumber(id); + services::SharedBookmarkFolder folder; + if (name != "") + folder = + std::make_shared < services::BookmarkFolder > (id, name, count); + return folder; } - return folders; -} -unsigned int FoldersStorage::getFoldersCount() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format getCountString("SELECT COUNT (*) FROM %1% ;"); - getCountString % TABLE_FOLDER; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getCountQuery(connection->prepare(getCountString.str())); - getCountQuery.exec(); - return getCountQuery.getInt(0); - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + services::SharedBookmarkFolderList FoldersStorage::getFolders() { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + services::SharedBookmarkFolderList folders; + int foldersCount = getFoldersCount(); + if (foldersCount != 0) { + boost::format getFoldersString("SELECT %1%, %2%, %3% FROM %4% ;"); + getFoldersString % COL_FOLDER_ID % COL_FOLDER_NAME % + COL_FOLDER_NUMBER % TABLE_FOLDER; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getFoldersQuery(connection-> + prepare(getFoldersString.str())); + getFoldersQuery.exec(); + for (int i = 0; i < foldersCount; ++i) { + services::SharedBookmarkFolder bookmark = + std::make_shared < services::BookmarkFolder > + (getFoldersQuery.getInt(0), getFoldersQuery.getString(1), + getFoldersQuery.getInt(2)); + folders.push_back(bookmark); + getFoldersQuery.next(); + } + } catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + } + return folders; } - return 0; -} -unsigned int FoldersStorage::addFolder(const std::string& name) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format addFolderQueryString("INSERT OR REPLACE INTO %1% ( %2% ) VALUES ( ? );"); - addFolderQueryString % TABLE_FOLDER % COL_FOLDER_NAME; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> db = scope.database(); - storage::SQLQuery addFolderQuery(db->prepare(addFolderQueryString.str())); - addFolderQuery.bindText(1, name); - addFolderQuery.exec(); - return db->lastInsertId(); - } catch (storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + unsigned int FoldersStorage::getFoldersCount() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::format getCountString("SELECT COUNT (*) FROM %1% ;"); + getCountString % TABLE_FOLDER; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getCountQuery(connection-> + prepare(getCountString.str())); + getCountQuery.exec(); + return getCountQuery.getInt(0); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return 0; } - return 0; -} -void FoldersStorage::updateFolderName(unsigned int id, const std::string& newName) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (id == AllFolder) - return; - boost::format updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?" ); - updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NAME % COL_FOLDER_ID; - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - try { - storage::SQLQuery updateFolderNameQuery(connection->prepare(updateFolderNameString.str())); - updateFolderNameQuery.bindText(1, newName); - updateFolderNameQuery.bindInt(2, id); - updateFolderNameQuery.exec(); - } catch (storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + unsigned int FoldersStorage::addFolder(const std::string & name) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost:: + format + addFolderQueryString + ("INSERT OR REPLACE INTO %1% ( %2% ) VALUES ( ? );"); + addFolderQueryString % TABLE_FOLDER % COL_FOLDER_NAME; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > db = scope.database(); + storage::SQLQuery addFolderQuery(db-> + prepare(addFolderQueryString.str())); + addFolderQuery.bindText(1, name); + addFolderQuery.exec(); + return db->lastInsertId(); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return 0; } -} -void FoldersStorage::addNumberInFolder(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (id != AllFolder) - addNumberInFolder(AllFolder); - boost::format updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?" ); - updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NUMBER % COL_FOLDER_ID; - int count = getFolderNumber(id); - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - try { - storage::SQLQuery updateFolderNameQuery(connection->prepare(updateFolderNameString.str())); - updateFolderNameQuery.bindInt(1, count+1); - updateFolderNameQuery.bindInt(2, id); - updateFolderNameQuery.exec(); - } catch (storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + void FoldersStorage::updateFolderName(unsigned int id, + const std::string & newName) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (id == AllFolder) + return; + boost:: + format + updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?"); + updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NAME % COL_FOLDER_ID; + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = scope.database(); + try { + storage::SQLQuery updateFolderNameQuery(connection-> + prepare + (updateFolderNameString. + str())); + updateFolderNameQuery.bindText(1, newName); + updateFolderNameQuery.bindInt(2, id); + updateFolderNameQuery.exec(); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } } -} -void FoldersStorage::removeNumberInFolder(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (id != AllFolder) - removeNumberInFolder(AllFolder); - boost::format updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?" ); - updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NUMBER % COL_FOLDER_ID; - int count = getFolderNumber(id); - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - try { - storage::SQLQuery updateFolderNameQuery(connection->prepare(updateFolderNameString.str())); - updateFolderNameQuery.bindInt(1, count-1); - updateFolderNameQuery.bindInt(2, id); - updateFolderNameQuery.exec(); - } catch (storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + void FoldersStorage::addNumberInFolder(unsigned int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (id != AllFolder) + addNumberInFolder(AllFolder); + boost:: + format updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?"); + updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NUMBER % + COL_FOLDER_ID; + int count = getFolderNumber(id); + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = scope.database(); + try { + storage::SQLQuery updateFolderNameQuery(connection-> + prepare + (updateFolderNameString. + str())); + updateFolderNameQuery.bindInt(1, count + 1); + updateFolderNameQuery.bindInt(2, id); + updateFolderNameQuery.exec(); + } catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } } -} -void FoldersStorage::deleteAllFolders() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format deleteFoldersString("DELETE FROM %1% WHERE %2% != ? AND %3% != ? ;"); - deleteFoldersString % TABLE_FOLDER % COL_FOLDER_ID % COL_FOLDER_ID; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - - storage::SQLQuery deleteFoldersQuery(connection->prepare(deleteFoldersString.str())); - deleteFoldersQuery.bindInt(1, AllFolder); - deleteFoldersQuery.bindInt(2, SpecialFolder); - deleteFoldersQuery.exec(); - } catch( storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + void FoldersStorage::removeNumberInFolder(unsigned int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (id != AllFolder) + removeNumberInFolder(AllFolder); + boost:: + format updateFolderNameString("UPDATE %1% SET %2% = ? WHERE %3% = ?"); + updateFolderNameString % TABLE_FOLDER % COL_FOLDER_NUMBER % + COL_FOLDER_ID; + int count = getFolderNumber(id); + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = scope.database(); + try { + storage::SQLQuery updateFolderNameQuery(connection-> + prepare + (updateFolderNameString. + str())); + updateFolderNameQuery.bindInt(1, count - 1); + updateFolderNameQuery.bindInt(2, id); + updateFolderNameQuery.exec(); + } catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } } - boost::format updateFoldersCountString("UPDATE %1% SET %2% = ? WHERE %3% = ? OR %4% = ?"); - updateFoldersCountString % TABLE_FOLDER % COL_FOLDER_NUMBER % COL_FOLDER_ID % COL_FOLDER_ID; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - - storage::SQLQuery updateFoldersCountQuery(connection->prepare(updateFoldersCountString.str())); - updateFoldersCountQuery.bindInt(1, 0); - updateFoldersCountQuery.bindInt(2, AllFolder); - updateFoldersCountQuery.bindInt(3, SpecialFolder); - updateFoldersCountQuery.exec(); - } catch( storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + void FoldersStorage::deleteAllFolders() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost:: + format + deleteFoldersString("DELETE FROM %1% WHERE %2% != ? AND %3% != ? ;"); + deleteFoldersString % TABLE_FOLDER % COL_FOLDER_ID % COL_FOLDER_ID; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + + storage::SQLQuery deleteFoldersQuery(connection-> + prepare(deleteFoldersString. + str())); + deleteFoldersQuery.bindInt(1, AllFolder); + deleteFoldersQuery.bindInt(2, SpecialFolder); + deleteFoldersQuery.exec(); + } catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + + boost:: + format + updateFoldersCountString + ("UPDATE %1% SET %2% = ? WHERE %3% = ? OR %4% = ?"); + updateFoldersCountString % TABLE_FOLDER % COL_FOLDER_NUMBER % + COL_FOLDER_ID % COL_FOLDER_ID; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + + storage::SQLQuery updateFoldersCountQuery(connection-> + prepare + (updateFoldersCountString. + str())); + updateFoldersCountQuery.bindInt(1, 0); + updateFoldersCountQuery.bindInt(2, AllFolder); + updateFoldersCountQuery.bindInt(3, SpecialFolder); + updateFoldersCountQuery.exec(); + } catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } } -} -void FoldersStorage::deleteFolder(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (id == AllFolder || id == SpecialFolder) - return; - boost::format deleteFolderString("DELETE FROM %1% WHERE %2% = ?;"); - deleteFolderString % TABLE_FOLDER % COL_FOLDER_ID; - - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - try { - storage::SQLQuery deleteFolderQurey(connection->prepare(deleteFolderString.str())); - deleteFolderQurey.bindInt(1, id); - deleteFolderQurey.exec(); - } catch (storage::StorageException &e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + void FoldersStorage::deleteFolder(unsigned int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (id == AllFolder || id == SpecialFolder) + return; + boost::format deleteFolderString("DELETE FROM %1% WHERE %2% = ?;"); + deleteFolderString % TABLE_FOLDER % COL_FOLDER_ID; + + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = scope.database(); + try { + storage::SQLQuery deleteFolderQurey(connection-> + prepare(deleteFolderString. + str())); + deleteFolderQurey.bindInt(1, id); + deleteFolderQurey.exec(); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } } -} -bool FoldersStorage::ifFolderExists(const std::string& name) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format getCountString("SELECT COUNT (*) FROM %1% WHERE %2% = ?;"); - getCountString % TABLE_FOLDER % COL_FOLDER_NAME; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getCountQuery(connection->prepare(getCountString.str())); - getCountQuery.bindText(1, name); - getCountQuery.exec(); - int number = getCountQuery.getInt(0); - return number != 0; - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + bool FoldersStorage::ifFolderExists(const std::string & name) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost:: + format getCountString("SELECT COUNT (*) FROM %1% WHERE %2% = ?;"); + getCountString % TABLE_FOLDER % COL_FOLDER_NAME; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getCountQuery(connection-> + prepare(getCountString.str())); + getCountQuery.bindText(1, name); + getCountQuery.exec(); + int number = getCountQuery.getInt(0); + return number != 0; + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return true; } - return true; -} -unsigned int FoldersStorage::getFolderId(const std::string& name) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format getIdString("SELECT %1% FROM %2% WHERE %3% = ?;"); - getIdString % COL_FOLDER_ID % TABLE_FOLDER % COL_FOLDER_NAME; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getIdQuery(connection->prepare(getIdString.str())); - getIdQuery.bindText(1, name); - getIdQuery.exec(); - return getIdQuery.getInt(0); - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + unsigned int FoldersStorage::getFolderId(const std::string & name) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::format getIdString("SELECT %1% FROM %2% WHERE %3% = ?;"); + getIdString % COL_FOLDER_ID % TABLE_FOLDER % COL_FOLDER_NAME; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getIdQuery(connection->prepare(getIdString.str())); + getIdQuery.bindText(1, name); + getIdQuery.exec(); + return getIdQuery.getInt(0); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return 0; } - return 0; -} -std::string FoldersStorage::getFolderName(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format getNameString("SELECT %1% FROM %2% WHERE %3% = ?;"); - getNameString % COL_FOLDER_NAME % TABLE_FOLDER % COL_FOLDER_ID; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getNameQuery(connection->prepare(getNameString.str())); - getNameQuery.bindInt(1, id); - getNameQuery.exec(); - - return getNameQuery.getString(0); - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + std::string FoldersStorage::getFolderName(unsigned int id) { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::format getNameString("SELECT %1% FROM %2% WHERE %3% = ?;"); + getNameString % COL_FOLDER_NAME % TABLE_FOLDER % COL_FOLDER_ID; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getNameQuery(connection-> + prepare(getNameString.str())); + getNameQuery.bindInt(1, id); + getNameQuery.exec(); + + return getNameQuery.getString(0); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return std::string(); } - return std::string(); -} -unsigned int FoldersStorage::getFolderNumber(unsigned int id) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::format getNameString("SELECT %1% FROM %2% WHERE %3% = ?;"); - getNameString % COL_FOLDER_NUMBER % TABLE_FOLDER % COL_FOLDER_ID; - try { - storage::SQLTransactionScope scope(storage::DriverManager::getDatabase(DB_FOLDERS)); - std::shared_ptr<storage::SQLDatabase> connection = scope.database(); - storage::SQLQuery getNameQuery(connection->prepare(getNameString.str())); - getNameQuery.bindInt(1, id); - getNameQuery.exec(); - - return getNameQuery.getInt(0); - } catch (storage::StorageException& e) { - BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, __LINE__, e.getErrorCode(), e.getMessage()); + unsigned int FoldersStorage::getFolderNumber(unsigned int id) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::format getNameString("SELECT %1% FROM %2% WHERE %3% = ?;"); + getNameString % COL_FOLDER_NUMBER % TABLE_FOLDER % COL_FOLDER_ID; + try { + storage::SQLTransactionScope scope(storage::DriverManager:: + getDatabase(DB_FOLDERS)); + std::shared_ptr < storage::SQLDatabase > connection = + scope.database(); + storage::SQLQuery getNameQuery(connection-> + prepare(getNameString.str())); + getNameQuery.bindInt(1, id); + getNameQuery.exec(); + + return getNameQuery.getInt(0); + } + catch(storage::StorageException & e) { + BROWSER_LOGD("[%s:%d] SQLException (%d): %s ", __PRETTY_FUNCTION__, + __LINE__, e.getErrorCode(), e.getMessage()); + } + return 0; } - return 0; -} -}//end namespace storage -}//end namespace tizen_browser + } //end namespace storage +} //end namespace tizen_browser diff --git a/services/StorageService/FoldersStorage.h b/services/StorageService/FoldersStorage.h index 72b8061b..72b8061b 100644..100755 --- a/services/StorageService/FoldersStorage.h +++ b/services/StorageService/FoldersStorage.h diff --git a/services/StorageService/SQLDatabase.cpp b/services/StorageService/SQLDatabase.cpp index 7c04dc0c..30834454 100755 --- a/services/StorageService/SQLDatabase.cpp +++ b/services/StorageService/SQLDatabase.cpp @@ -27,715 +27,732 @@ #include <Eina.h> -namespace tizen_browser { -namespace storage { +namespace tizen_browser +{ + namespace storage + { #define SQL_RETRY_TIME_US 100000 #define SQL_RETRY_COUNT 200 -static FieldPtr _null_field(new Field()); + static FieldPtr _null_field(new Field()); -static inline int sql_prepare(sqlite3 * db, sqlite3_stmt ** stmt, const char * query) -{ - int retry = 0; - int rc; + static inline int sql_prepare(sqlite3 * db, sqlite3_stmt ** stmt, + const char *query) + { + int retry = 0; + int rc; - do { - rc = sqlite3_prepare_v2(db, query, -1, stmt, NULL); - if(rc == SQLITE_BUSY || rc == SQLITE_LOCKED) { - ++retry; - std::this_thread::sleep_for(std::chrono::milliseconds(SQL_RETRY_TIME_US)); - } - } while(retry < SQL_RETRY_COUNT && (rc == SQLITE_BUSY || rc == SQLITE_LOCKED)); + do + { + rc = sqlite3_prepare_v2(db, query, -1, stmt, NULL); + if (rc == SQLITE_BUSY || rc == SQLITE_LOCKED) { + ++retry; + std::this_thread::sleep_for(std::chrono:: + milliseconds(SQL_RETRY_TIME_US)); + } + } while (retry < SQL_RETRY_COUNT + && (rc == SQLITE_BUSY || rc == SQLITE_LOCKED)); - if(rc != SQLITE_OK) { - BROWSER_LOGE("[sql_db] Can't prepare query from string '%s' with result %d (%s)", - query, - rc, - sqlite3_errmsg(db)); + if (rc != SQLITE_OK) { + BROWSER_LOGE + ("[sql_db] Can't prepare query from string '%s' with result %d (%s)", + query, rc, sqlite3_errmsg(db)); - return rc; + return rc; + } + + return rc; } - return rc; -} + static inline int sql_step(sqlite3_stmt * stmt) + { + int rc; + int retry = 0; -static inline int sql_step(sqlite3_stmt * stmt) -{ - int rc; - int retry = 0; + do { + rc = sqlite3_step(stmt); - do { - rc = sqlite3_step(stmt); + if (rc == SQLITE_LOCKED) { + rc = sqlite3_reset(stmt); + ++retry; + std::this_thread::sleep_for(std::chrono:: + milliseconds(SQL_RETRY_TIME_US)); + } else if (rc == SQLITE_BUSY) { + ++retry; + std::this_thread::sleep_for(std::chrono:: + milliseconds(SQL_RETRY_TIME_US)); + } + } while (retry < SQL_RETRY_COUNT + && (rc == SQLITE_BUSY || rc == SQLITE_LOCKED)); - if(rc == SQLITE_LOCKED) { - rc = sqlite3_reset(stmt); - ++retry; - std::this_thread::sleep_for(std::chrono::milliseconds(SQL_RETRY_TIME_US)); - } else if(rc == SQLITE_BUSY) { - ++retry; - std::this_thread::sleep_for(std::chrono::milliseconds(SQL_RETRY_TIME_US)); - } - } while(retry < SQL_RETRY_COUNT && (rc == SQLITE_BUSY || rc == SQLITE_LOCKED)); + if (retry == SQL_RETRY_COUNT) { + BROWSER_LOGE("[sql_db] Database timeout"); + } - if(retry == SQL_RETRY_COUNT) { - BROWSER_LOGE("[sql_db] Database timeout"); - } + if (rc == SQLITE_MISUSE) { + BROWSER_LOGE("[sql_db] Sqlite misuse"); + } - if(rc == SQLITE_MISUSE) { - BROWSER_LOGE("[sql_db] Sqlite misuse"); + return rc; } - return rc; -} + static inline bool sql_begin(sqlite3 * db) + { + sqlite3_stmt *stmt = 0; + if (sql_prepare(db, &stmt, "BEGIN EXCLUSIVE TRANSACTION")) { + BROWSER_LOGE("[sql_db] Can't begin SQL transaction"); + return false; + } -static inline bool sql_begin(sqlite3 * db) -{ - sqlite3_stmt * stmt = 0; - if(sql_prepare(db, &stmt, "BEGIN EXCLUSIVE TRANSACTION")) { - BROWSER_LOGE("[sql_db] Can't begin SQL transaction"); - return false; - } + int result = sql_step(stmt); + sqlite3_finalize(stmt); - int result = sql_step(stmt); - sqlite3_finalize(stmt); + if (result && result != SQLITE_DONE) { + BROWSER_LOGE("[sql_db] Error while starting transaction"); + return false; + } - if(result && result != SQLITE_DONE) { - BROWSER_LOGE("[sql_db] Error while starting transaction"); - return false; + return true; } - return true; -} + static inline bool sql_commit(sqlite3 * db) + { + sqlite3_stmt *stmt = 0; + if (sql_prepare(db, &stmt, "COMMIT")) { + BROWSER_LOGE("[sql_db] Can't commit SQL transaction"); + return false; + } -static inline bool sql_commit(sqlite3 * db) -{ - sqlite3_stmt * stmt = 0; - if(sql_prepare(db, &stmt, "COMMIT")) { - BROWSER_LOGE("[sql_db] Can't commit SQL transaction"); - return false; - } + int result = sql_step(stmt); + sqlite3_finalize(stmt); - int result = sql_step(stmt); - sqlite3_finalize(stmt); + if (result && result != SQLITE_DONE) { + BROWSER_LOGD("[sql_db] Error while commiting transaction"); + return false; + } - if(result && result != SQLITE_DONE) { - BROWSER_LOGD("[sql_db] Error while commiting transaction"); - return false; + return true; } - return true; -} + static inline bool sql_rollback(sqlite3 * db) + { + sqlite3_stmt *stmt = 0; + if (sql_prepare(db, &stmt, "ROLLBACK")) { + BROWSER_LOGE("[sql_db] Can't rollback SQL transaction"); + return false; + } -static inline bool sql_rollback(sqlite3 * db) -{ - sqlite3_stmt * stmt = 0; - if(sql_prepare(db, &stmt, "ROLLBACK")) { - BROWSER_LOGE("[sql_db] Can't rollback SQL transaction"); - return false; - } + int result = sql_step(stmt); + sqlite3_finalize(stmt); - int result = sql_step(stmt); - sqlite3_finalize(stmt); + if (result && result != SQLITE_DONE) { + BROWSER_LOGD("[sql_db] Error while rolling transaction back"); + return false; + } - if(result && result != SQLITE_DONE) { - BROWSER_LOGD("[sql_db] Error while rolling transaction back"); - return false; + return true; } - return true; -} - -SQLQueryPrivate::SQLQueryPrivate(std::shared_ptr<SQLDatabase> db_ref, - sqlite3 * db, - sqlite3_stmt * stmt, - const std::string& query) : + SQLQueryPrivate::SQLQueryPrivate(std::shared_ptr < SQLDatabase > db_ref, sqlite3 * db, sqlite3_stmt * stmt, const std::string & query): _db_ref(db_ref), - _db(db), - _stmt(stmt), - _hasNext(false), - _query(query) -{ -} - -SQLQueryPrivate::SQLQueryPrivate(const SQLQueryPrivate& other) : - _db_ref(other._db_ref), - _db(other._db), - _stmt(other._stmt), - _hasNext(other._hasNext), - _query(other._query) -{ - const_cast<SQLQueryPrivate &>(other)._stmt = NULL; -} - -SQLQueryPrivate::~SQLQueryPrivate() -{ - if(_stmt) - sqlite3_finalize(_stmt); -} - -SQLDatabasePrivate::SQLDatabasePrivate() : - _db(NULL) -{ -} - -SQLDatabasePrivate::~SQLDatabasePrivate() -{ - close(); -} - -void SQLDatabasePrivate::close() -{ - if(_db) { - sqlite3_close(_db); - _db = NULL; + _db(db), _stmt(stmt), _hasNext(false), _query(query) { } -} - -SQLQuery::SQLQuery() : - d(NULL) -{ -} -SQLQuery::SQLQuery(const SQLQuery& other) -{ - if(other.d) - d = new SQLQueryPrivate(*other.d); - else - d = NULL; -} + SQLQueryPrivate:: + SQLQueryPrivate(const SQLQueryPrivate & other):_db_ref(other._db_ref), + _db(other._db), _stmt(other._stmt), _hasNext(other._hasNext), + _query(other._query) + { + const_cast < SQLQueryPrivate & >(other)._stmt = NULL; + } -SQLQuery::~SQLQuery() -{ - delete d; -} + SQLQueryPrivate::~SQLQueryPrivate() { + if (_stmt) + sqlite3_finalize(_stmt); + } -SQLQuery& SQLQuery::operator = (const SQLQuery& other) -{ - if(d != other.d) { - if(other.d) { - SQLQueryPrivate * new_d = new SQLQueryPrivate(*other.d); - delete d; - d = new_d; - } else { - delete d; - d = NULL; - } - } - return *this; -} - -bool SQLQuery::isValid() const -{ - return d && d->_stmt && !d->_db_ref.expired(); -} + SQLDatabasePrivate::SQLDatabasePrivate(): + _db(NULL) { + } -void SQLQuery::bindText(int paramNo, const char * text, int length) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + SQLDatabasePrivate::~SQLDatabasePrivate() { + close(); + } - int error = sqlite3_bind_text(d->_stmt, paramNo, text, length, NULL); + void SQLDatabasePrivate::close() + { + if (_db) { + sqlite3_close(_db); + _db = NULL; + } + } - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + SQLQuery::SQLQuery(): + d(NULL) { } -} -void SQLQuery::bindText(int paramNo, const std::string& text) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + SQLQuery::SQLQuery(const SQLQuery & other) + { + if (other.d) + d = new SQLQueryPrivate(*other.d); + else + d = NULL; + } - int error = sqlite3_bind_text(d->_stmt, paramNo, text.c_str(), text.length(), NULL); + SQLQuery::~SQLQuery() { + delete d; + } - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + SQLQuery & SQLQuery::operator =(const SQLQuery & other) + { + if (d != other.d) { + if (other.d) { + SQLQueryPrivate *new_d = new SQLQueryPrivate(*other.d); + delete d; + d = new_d; + } else { + delete d; + d = NULL; + } + } + return *this; + } + + bool SQLQuery::isValid() const + { + return d && d->_stmt && !d->_db_ref.expired(); } -} -void SQLQuery::bindBlob(int paramNo, std::unique_ptr<tizen_browser::tools::Blob> blob) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindText(int paramNo, const char *text, int length) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_blob(d->_stmt, paramNo, blob->getData(), blob->getLength(), - SQLITE_TRANSIENT); + int error = sqlite3_bind_text(d->_stmt, paramNo, text, length, NULL); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} -void SQLQuery::bindBlob(int paramNo, const void * data, size_t length) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindText(int paramNo, const std::string & text) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_blob(d->_stmt, paramNo, data, length, SQLITE_TRANSIENT); + int error = + sqlite3_bind_text(d->_stmt, paramNo, text.c_str(), text.length(), + NULL); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} -void SQLQuery::bindInt(int paramNo, int value) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindBlob(int paramNo, + std::unique_ptr < tizen_browser::tools::Blob > + blob) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_int(d->_stmt, paramNo, value); + int error = + sqlite3_bind_blob(d->_stmt, paramNo, blob->getData(), + blob->getLength(), + SQLITE_TRANSIENT); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} -void SQLQuery::bindInt64(int paramNo, long long value) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindBlob(int paramNo, const void *data, size_t length) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_int64(d->_stmt, paramNo, value); + int error = + sqlite3_bind_blob(d->_stmt, paramNo, data, length, SQLITE_TRANSIENT); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} -void SQLQuery::bindDouble(int paramNo, double value) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindInt(int paramNo, int value) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_double(d->_stmt, paramNo, value); + int error = sqlite3_bind_int(d->_stmt, paramNo, value); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} -void SQLQuery::bindNull(int paramNo) -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindInt64(int paramNo, long long value) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - int error = sqlite3_bind_null(d->_stmt, paramNo); + int error = sqlite3_bind_int64(d->_stmt, paramNo, value); - if (error != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), error); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } } -} - -const char * SQLQuery::getCString(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); - return (const char *)sqlite3_column_text(d->_stmt, column); -} - -std::string SQLQuery::getString(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + void SQLQuery::bindDouble(int paramNo, double value) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - const char * str = (const char *)sqlite3_column_text(d->_stmt, column); + int error = sqlite3_bind_double(d->_stmt, paramNo, value); - if(!str) - return std::string(); + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } + } - return str; -} + void SQLQuery::bindNull(int paramNo) + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); -int SQLQuery::getInt(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + int error = sqlite3_bind_null(d->_stmt, paramNo); - return sqlite3_column_int(d->_stmt, column); -} + if (error != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), error); + } + } -long long SQLQuery::getInt64(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + const char *SQLQuery::getCString(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - return sqlite3_column_int64(d->_stmt, column); -} + return (const char *) sqlite3_column_text(d->_stmt, column); + } -double SQLQuery::getDouble(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + std::string SQLQuery::getString(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - return sqlite3_column_double(d->_stmt, column); -} + const char *str = (const char *) sqlite3_column_text(d->_stmt, column); -std::shared_ptr<tizen_browser::tools::Blob> SQLQuery::getBlob(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + if (!str) + return std::string(); - const void * blob = sqlite3_column_blob(d->_stmt, column); - - if(blob == NULL) { - return std::shared_ptr<tizen_browser::tools::Blob>(); + return str; } - int length = sqlite3_column_bytes(d->_stmt, column); - - return std::make_shared<tizen_browser::tools::Blob>(blob, length); -} + int SQLQuery::getInt(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); -size_t SQLQuery::getDataLength(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + return sqlite3_column_int(d->_stmt, column); + } - int result = sqlite3_column_bytes(d->_stmt, column); + long long SQLQuery::getInt64(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - if(result <= 0) { - if(sqlite3_errcode(d->_db) != SQLITE_OK) { - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); - } + return sqlite3_column_int64(d->_stmt, column); } - return result; -} + double SQLQuery::getDouble(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); -int SQLQuery::fieldType(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + return sqlite3_column_double(d->_stmt, column); + } - return sqlite3_column_type(d->_stmt, column); -} + std::shared_ptr < tizen_browser::tools::Blob > + SQLQuery::getBlob(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); -FieldPtr SQLQuery::getField(int column) const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + const void *blob = sqlite3_column_blob(d->_stmt, column); - int col_type = sqlite3_column_type(d->_stmt, column); + if (blob == NULL) { + return std::shared_ptr < tizen_browser::tools::Blob > (); + } - if(col_type == 0) - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); + int length = sqlite3_column_bytes(d->_stmt, column); - switch(col_type) - { - case SQLITE_INTEGER: - return std::make_shared<Field>(sqlite3_column_int(d->_stmt, column)); - case SQLITE_BLOB: - return std::make_shared<Field>(getBlob(column)); - case SQLITE_NULL: - return _null_field; - case SQLITE_TEXT: - return std::make_shared<Field>(getString(column)); - case SQLITE_FLOAT: - return std::make_shared<Field>(getDouble(column)); - default: - throw _null_field; + return std::make_shared < tizen_browser::tools::Blob > (blob, length); } -} -int SQLQuery::columnCount() const -{ - M_ASSERT(d); - M_ASSERT(d->_stmt); - M_ASSERT(!d->_db_ref.expired()); + size_t SQLQuery::getDataLength(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - return sqlite3_column_count(d->_stmt); -} + int result = sqlite3_column_bytes(d->_stmt, column); -bool SQLQuery::hasNext() const -{ - M_ASSERT(d); + if (result <= 0) + { + if (sqlite3_errcode(d->_db) != SQLITE_OK) { + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } + } - return d->_hasNext; -} - -bool SQLQuery::next() -{ - M_ASSERT(d); - M_ASSERT(!d->_db_ref.expired()); + return result; + } - if(d->_hasNext) { - int error = sql_step(d->_stmt); + int SQLQuery::fieldType(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - if (error == SQLITE_DONE) { - d->_hasNext = false; - return true; - } else if (error == SQLITE_ROW) { - d->_hasNext = true; - return true; - } else { - d->_hasNext = false; - BROWSER_LOGE("[SQLQuery] Unknown result received while executing query - %d - %s", error, d->_query.c_str()); - return false; - } + return sqlite3_column_type(d->_stmt, column); } - return false; -} - -void SQLQuery::reset() -{ - M_ASSERT(d); + FieldPtr SQLQuery::getField(int column) const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); + + int col_type = sqlite3_column_type(d->_stmt, column); + + if (col_type == 0) + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + + switch (col_type) { + case SQLITE_INTEGER: + return std::make_shared < Field > + (sqlite3_column_int(d->_stmt, column)); + case SQLITE_BLOB:return std::make_shared < Field > (getBlob(column)); + case SQLITE_NULL:return _null_field; + case SQLITE_TEXT:return std::make_shared < Field > + (getString(column)); + case SQLITE_FLOAT:return std::make_shared < Field > + (getDouble(column)); + default:throw _null_field; + } + } + + int SQLQuery::columnCount() const + { + M_ASSERT(d); + M_ASSERT(d->_stmt); + M_ASSERT(!d->_db_ref.expired()); - if(d->_stmt) { - M_ASSERT(!d->_db_ref.expired()); - sqlite3_reset(d->_stmt); + return sqlite3_column_count(d->_stmt); } -} -void SQLQuery::clearBindings() -{ - M_ASSERT(d); + bool SQLQuery::hasNext() const + { + M_ASSERT(d); - if(d->_stmt) { - M_ASSERT(!d->_db_ref.expired()); - sqlite3_clear_bindings(d->_stmt); + return d->_hasNext; } -} -void SQLQuery::exec() -{ - M_ASSERT(d); - M_ASSERT(!d->_db_ref.expired()); + bool SQLQuery::next() + { + M_ASSERT(d); + M_ASSERT(!d->_db_ref.expired()); + + if (d->_hasNext) { + int error = sql_step(d->_stmt); + + if (error == SQLITE_DONE) { + d->_hasNext = false; + return true; + } else if (error == SQLITE_ROW) { + d->_hasNext = true; + return true; + } else { + d->_hasNext = false; + BROWSER_LOGE + ("[SQLQuery] Unknown result received while executing query - %d - %s", + error, d->_query.c_str()); + return false; + } + } + + return false; + } + + void SQLQuery::reset() + { + M_ASSERT(d); - if(!d->_stmt) { - throw StorageException("[SQLQuery] Statement not active", 0); + if (d->_stmt) { + M_ASSERT(!d->_db_ref.expired()); + sqlite3_reset(d->_stmt); + } } - int error = sql_step(d->_stmt); + void SQLQuery::clearBindings() + { + M_ASSERT(d); - if (error == SQLITE_DONE) { - // No more data available - d->_hasNext= false; - } else if (error == SQLITE_ROW) { - // Data is available - d->_hasNext = true; - } else if (error == SQLITE_ERROR) { - BROWSER_LOGE("[SQLQuery] Can't execute SELECT query because of error '%s' - %s", sqlite3_errmsg(d->_db), d->_query.c_str()); - d->_hasNext = false; - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); - } else { - BROWSER_LOGE("[SQLQuery] Can't execute SELECT query because of result %d - %s", error, d->_query.c_str()); - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); + if (d->_stmt) { + M_ASSERT(!d->_db_ref.expired()); + sqlite3_clear_bindings(d->_stmt); + } } -} -std::vector<std::string> SQLQuery::columnNames() const -{ - M_ASSERT(d); - M_ASSERT(!d->_db_ref.expired()); - M_ASSERT(d->_stmt); + void SQLQuery::exec() + { + M_ASSERT(d); + M_ASSERT(!d->_db_ref.expired()); + + if (!d->_stmt) { + throw StorageException("[SQLQuery] Statement not active", 0); + } + + int error = sql_step(d->_stmt); + + if (error == SQLITE_DONE) { + // No more data available + d->_hasNext = false; + } else if (error == SQLITE_ROW) { + // Data is available + d->_hasNext = true; + } else if (error == SQLITE_ERROR) { + BROWSER_LOGE + ("[SQLQuery] Can't execute SELECT query because of error '%s' - %s", + sqlite3_errmsg(d->_db), d->_query.c_str()); + d->_hasNext = false; + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } else { + BROWSER_LOGE + ("[SQLQuery] Can't execute SELECT query because of result %d - %s", + error, d->_query.c_str()); + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } + } + + std::vector < std::string > SQLQuery::columnNames()const + { + M_ASSERT(d); + M_ASSERT(!d->_db_ref.expired()); + M_ASSERT(d->_stmt); + + std::vector < std::string > result; - std::vector<std::string> result; + int cols = sqlite3_column_count(d->_stmt); + result.reserve(cols); - int cols = sqlite3_column_count(d->_stmt); - result.reserve(cols); + for (int i = 0; i < cols; ++i) + { + result.push_back(std::string(sqlite3_column_name(d->_stmt, i))); + } - for(int i = 0 ; i < cols ; ++i) { - result.push_back(std::string(sqlite3_column_name(d->_stmt, i))); + return result; } - return result; -} + std::shared_ptr < SQLDatabase > SQLDatabase::make_shared() { + return std::shared_ptr < SQLDatabase > (new SQLDatabase()); + } -std::shared_ptr<SQLDatabase> SQLDatabase::make_shared() -{ - return std::shared_ptr<SQLDatabase>(new SQLDatabase()); -} + SQLDatabase::SQLDatabase(): + d(new SQLDatabasePrivate()) { + } -SQLDatabase::SQLDatabase() : - d(new SQLDatabasePrivate()) -{ -} + SQLDatabase::~SQLDatabase() { + delete d; + } -SQLDatabase::~SQLDatabase() -{ - delete d; -} + std::shared_ptr < SQLDatabase > SQLDatabase::newInstance() { + std::shared_ptr < SQLDatabase > db = make_shared(); + db->d->_db_self_weak = db; + return db; + } -std::shared_ptr<SQLDatabase> SQLDatabase::newInstance() -{ - std::shared_ptr<SQLDatabase> db = make_shared(); - db->d->_db_self_weak = db; - return db; -} + void SQLDatabase::open(const std::string & path) + { + M_ASSERT(!d->_db); -void SQLDatabase::open(const std::string& path) -{ - M_ASSERT(!d->_db); + int error = + sqlite3_open_v2(path.c_str(), &d->_db, + SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); - int error = sqlite3_open_v2(path.c_str(), &d->_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); + if (error != SQLITE_OK) { + BROWSER_LOGE + ("[SQLDatabase] Can't open sqlite database from file '%s' with error %d", + path.c_str(), error); - if(error != SQLITE_OK) { - BROWSER_LOGE("[SQLDatabase] Can't open sqlite database from file '%s' with error %d", - path.c_str(), - error); + throw StorageException(sqlite3_errmsg(d->_db), error); + } - throw StorageException(sqlite3_errmsg(d->_db), error); + SQLQuery query(prepare("PRAGMA foreign_keys = ON")); + query.exec(); } - SQLQuery query(prepare("PRAGMA foreign_keys = ON")); - query.exec(); -} + void SQLDatabase::close() + { + d->close(); + } -void SQLDatabase::close() -{ - d->close(); -} + SQLQuery SQLDatabase::prepare(const std::string & query) const + { + EINA_SAFETY_ON_NULL_RETURN_VAL(d->_db, SQLQuery()); -SQLQuery SQLDatabase::prepare(const std::string& query) const -{ - EINA_SAFETY_ON_NULL_RETURN_VAL(d->_db, SQLQuery()); + sqlite3_stmt *stmt = NULL; + int rc = sql_prepare(d->_db, &stmt, query.c_str()); - sqlite3_stmt * stmt = NULL; - int rc = sql_prepare(d->_db, &stmt, query.c_str()); + if (rc != SQLITE_OK) + { + BROWSER_LOGE + ("[SQLDatabase] Can't prepare query from string '%s' with result %d (%s)", + query.c_str(), rc, sqlite3_errmsg(d->_db)); - if(rc != SQLITE_OK) { - BROWSER_LOGE("[SQLDatabase] Can't prepare query from string '%s' with result %d (%s)", - query.c_str(), - rc, - sqlite3_errmsg(d->_db)); + return SQLQuery(); + } - return SQLQuery(); - } + SQLQuery result; - SQLQuery result; + try { + result.d = + new SQLQueryPrivate(d->_db_self_weak.lock(), d->_db, stmt, query); + } + catch( ...) { + sqlite3_finalize(stmt); + throw; + } - try { - result.d = new SQLQueryPrivate(d->_db_self_weak.lock(), d->_db, stmt, query); - } catch(...) { - sqlite3_finalize(stmt); - throw; + return result; } - return result; -} - -bool SQLDatabase::tableExists(const std::string& name) const -{ - if(!d->_db) - return false; + bool SQLDatabase::tableExists(const std::string & name) const + { + if (!d->_db) + return false; - SQLQuery query(prepare("select count(*) from sqlite_master where type='table' and name=?")); - query.bindText(1, name); - query.exec(); + SQLQuery + query(prepare + ("select count(*) from sqlite_master where type='table' and name=?")); + query.bindText(1, name); + query.exec(); - return query.getInt(0) > 0; -} + return query.getInt(0) > 0; + } -long long SQLDatabase::lastInsertId() const -{ - BROWSER_LOGD("lastInsertId"); - if(!d->_db) - return -1; + long long SQLDatabase::lastInsertId() const + { + BROWSER_LOGD("lastInsertId"); + if (!d->_db) + return -1; - long long id = sqlite3_last_insert_rowid(d->_db); + long long id = sqlite3_last_insert_rowid(d->_db); - BROWSER_LOGD("lastInsertId: %d", id); - return id; -} + BROWSER_LOGD("lastInsertId: %d", id); + return id; + } -bool SQLDatabase::exec(const std::string& command) const -{ - if(!d->_db) - return false; - - sqlite3_stmt * stmt = NULL; - int rc = sql_prepare(d->_db, &stmt, command.c_str()); - - if(rc != SQLITE_OK) { - const char * errorMessage = sqlite3_errmsg(d->_db); - int errorCode = sqlite3_errcode(d->_db); - std::string error( errorMessage ? errorMessage : "" ); - BROWSER_LOGE("[SQLDatabase] Can't prepare query from string '%s' with result %d (%s)", - command.c_str(), - rc, - error.c_str()); - throw StorageException(error, errorCode); + bool SQLDatabase::exec(const std::string & command) const + { + if (!d->_db) + return false; + + sqlite3_stmt *stmt = NULL; + int rc = sql_prepare(d->_db, &stmt, command.c_str()); + + if (rc != SQLITE_OK) + { + const char *errorMessage = sqlite3_errmsg(d->_db); + int errorCode = sqlite3_errcode(d->_db); + std::string error(errorMessage ? errorMessage : ""); + BROWSER_LOGE + ("[SQLDatabase] Can't prepare query from string '%s' with result %d (%s)", + command.c_str(), rc, error.c_str()); + throw StorageException(error, errorCode); // return false; - } + } + + rc = sql_step(stmt); + sqlite3_finalize(stmt); - rc = sql_step(stmt); - sqlite3_finalize(stmt); + if (rc != SQLITE_DONE && rc != SQLITE_ROW) { + BROWSER_LOGE + ("[SQLDatabase] Can't execute query from string '%s' with result %d (%s)", + command.c_str(), rc, sqlite3_errmsg(d->_db)); + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } - if(rc != SQLITE_DONE && rc != SQLITE_ROW) { - BROWSER_LOGE("[SQLDatabase] Can't execute query from string '%s' with result %d (%s)", - command.c_str(), - rc, - sqlite3_errmsg(d->_db)); - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); + return true; } - return true; -} + std::vector < std::string > + SQLDatabase::tableColumnNames(const std::string & table) const + { + std::string query_str("PRAGMA table_info("); + query_str.append(table); + query_str.append(")"); -std::vector<std::string> SQLDatabase::tableColumnNames(const std::string& table) const -{ - std::string query_str("PRAGMA table_info("); - query_str.append(table); - query_str.append(")"); + std::vector < std::string > result; - std::vector<std::string> result; + SQLQuery query(prepare(query_str)); + query.exec(); - SQLQuery query(prepare(query_str)); - query.exec(); + while (query.hasNext()) + { + result.push_back(query.getString(1)); + query.next(); + } - while(query.hasNext()) { - result.push_back(query.getString(1)); - query.next(); + return result; } - return result; -} - -void SQLDatabase::begin() -{ - if(!sql_begin(d->_db)) { - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); + void SQLDatabase::begin() + { + if (!sql_begin(d->_db)) { + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } } -} -void SQLDatabase::commit() -{ - if(!sql_commit(d->_db)) { - throw StorageException(sqlite3_errmsg(d->_db), sqlite3_errcode(d->_db)); + void SQLDatabase::commit() + { + if (!sql_commit(d->_db)) { + throw StorageException(sqlite3_errmsg(d->_db), + sqlite3_errcode(d->_db)); + } } -} -void SQLDatabase::rollback() -{ - sql_rollback(d->_db); -} + void SQLDatabase::rollback() + { + sql_rollback(d->_db); + } -std::shared_ptr<SQLDatabase> SQLDatabase::cloneForThread(void) -{ - std::shared_ptr<SQLDatabase> result(newInstance()); - result->open(d->_path); - return result; -} + std::shared_ptr < SQLDatabase > SQLDatabase::cloneForThread(void) + { + std::shared_ptr < SQLDatabase > result(newInstance()); + result->open(d->_path); + return result; + } -} /* namespace storage */ -} /* namespace tizen_browser */ + } /* namespace storage */ +} /* namespace tizen_browser */ diff --git a/services/StorageService/SQLDatabase.h b/services/StorageService/SQLDatabase.h index a22fc909..a22fc909 100644..100755 --- a/services/StorageService/SQLDatabase.h +++ b/services/StorageService/SQLDatabase.h diff --git a/services/StorageService/SQLDatabaseImpl.h b/services/StorageService/SQLDatabaseImpl.h index 9af2e04e..9af2e04e 100644..100755 --- a/services/StorageService/SQLDatabaseImpl.h +++ b/services/StorageService/SQLDatabaseImpl.h diff --git a/services/StorageService/SQLTransactionScope.cpp b/services/StorageService/SQLTransactionScope.cpp index 76d0d253..cc66cba9 100644..100755 --- a/services/StorageService/SQLTransactionScope.cpp +++ b/services/StorageService/SQLTransactionScope.cpp @@ -19,43 +19,45 @@ #include "BrowserAssert.h" #include "BrowserLogger.h" -namespace tizen_browser { -namespace storage { - -SQLTransactionScope::SQLTransactionScope(std::shared_ptr<SQLDatabase> db) : - _db(db), - _inTransaction(false) +namespace tizen_browser { - M_ASSERT(db); + namespace storage + { - db->begin(); - _inTransaction = true; -} + SQLTransactionScope::SQLTransactionScope(std::shared_ptr < SQLDatabase > + db):_db(db), + _inTransaction(false) + { + M_ASSERT(db); -SQLTransactionScope::~SQLTransactionScope() -{ - if(std::uncaught_exception()) { - if(_inTransaction) - _db->rollback(); - } else { - if(_inTransaction) - _db->commit(); + db->begin(); + _inTransaction = true; } -} -void SQLTransactionScope::commit() -{ - M_ASSERT(_inTransaction); - _inTransaction = false; - _db->commit(); -} + SQLTransactionScope::~SQLTransactionScope() + { + if (std::uncaught_exception()) { + if (_inTransaction) + _db->rollback(); + } else { + if (_inTransaction) + _db->commit(); + } + } -void SQLTransactionScope::rollback() -{ - _inTransaction = false; - _db->rollback(); -} + void SQLTransactionScope::commit() + { + M_ASSERT(_inTransaction); + _inTransaction = false; + _db->commit(); + } + void SQLTransactionScope::rollback() + { + _inTransaction = false; + _db->rollback(); + } -} + + } } diff --git a/services/StorageService/SQLTransactionScope.h b/services/StorageService/SQLTransactionScope.h index 02c42e24..02c42e24 100644..100755 --- a/services/StorageService/SQLTransactionScope.h +++ b/services/StorageService/SQLTransactionScope.h diff --git a/services/StorageService/SettingsStorage.cpp b/services/StorageService/SettingsStorage.cpp index ac862b95..ac862b95 100644..100755 --- a/services/StorageService/SettingsStorage.cpp +++ b/services/StorageService/SettingsStorage.cpp diff --git a/services/StorageService/SettingsStorage.h b/services/StorageService/SettingsStorage.h index 9ae00a33..bbbb459e 100644..100755 --- a/services/StorageService/SettingsStorage.h +++ b/services/StorageService/SettingsStorage.h @@ -71,7 +71,7 @@ public: void init(bool testmode = false); void initWebEngineSettingsFromDB(); - boost::signals2::signal<void (basic_webengine::WebEngineSettings, bool)> setWebEngineSettingsParam; + boost::signals2::signal<void(basic_webengine::WebEngineSettings, bool)> setWebEngineSettingsParam; private: /** * @throws StorageExceptionInitialization on error diff --git a/services/StorageService/StorageException.cpp b/services/StorageService/StorageException.cpp index df106125..7b2b1400 100644..100755 --- a/services/StorageService/StorageException.cpp +++ b/services/StorageService/StorageException.cpp @@ -16,28 +16,30 @@ #include "StorageException.h" -namespace tizen_browser { -namespace storage { - -StorageException::StorageException(const std::string & message, int code) : - m_code(code), m_message(message) -{ -} - -StorageException::~StorageException() throw () -{ - -} - -int StorageException::getErrorCode() const -{ - return m_code; -} - -const char * StorageException::getMessage() const throw () +namespace tizen_browser { - return m_message.c_str(); -} - -} + namespace storage + { + + StorageException::StorageException(const std::string & message, + int code):m_code(code), + m_message(message) + { + } + + StorageException::~StorageException() throw() + { + } + + int StorageException::getErrorCode() const + { + return m_code; + } + + const char *StorageException::getMessage() const throw() + { + return m_message.c_str(); + } + + } } diff --git a/services/StorageService/StorageException.h b/services/StorageService/StorageException.h index 1522748c..e65710e6 100644..100755 --- a/services/StorageService/StorageException.h +++ b/services/StorageService/StorageException.h @@ -31,9 +31,9 @@ class BROWSER_EXPORT StorageException: public std::exception { public: explicit StorageException(const std::string & message, int code = SQLITE_ERROR); - virtual ~StorageException() throw (); + virtual ~StorageException() throw(); virtual int getErrorCode() const; - virtual const char * getMessage() const throw (); + virtual const char * getMessage() const throw(); virtual const char* what() const throw() {return m_message.c_str();}; protected: int m_code; diff --git a/services/StorageService/StorageExceptionInitialization.cpp b/services/StorageService/StorageExceptionInitialization.cpp index df9d7d77..ba09abe7 100644..100755 --- a/services/StorageService/StorageExceptionInitialization.cpp +++ b/services/StorageService/StorageExceptionInitialization.cpp @@ -16,28 +16,33 @@ #include "StorageExceptionInitialization.h" -namespace tizen_browser { -namespace storage { - -StorageExceptionInitialization::StorageExceptionInitialization(const std::string & message, int code) : - StorageException(message, code) -{ -} - -StorageExceptionInitialization::~StorageExceptionInitialization() throw () -{ - -} - -int StorageExceptionInitialization::getErrorCode() const -{ - return m_code; -} - -const char * StorageExceptionInitialization::getMessage() const throw () +namespace tizen_browser { - return m_message.c_str(); -} - -} + namespace storage + { + + StorageExceptionInitialization::StorageExceptionInitialization(const std:: + string & + message, + int + code):StorageException + (message, code) + { + } + + StorageExceptionInitialization::~StorageExceptionInitialization() throw() + { + } + + int StorageExceptionInitialization::getErrorCode() const + { + return m_code; + } + + const char *StorageExceptionInitialization::getMessage() const throw() + { + return m_message.c_str(); + } + + } } diff --git a/services/StorageService/StorageExceptionInitialization.h b/services/StorageService/StorageExceptionInitialization.h index 8abc20ee..1698c777 100644..100755 --- a/services/StorageService/StorageExceptionInitialization.h +++ b/services/StorageService/StorageExceptionInitialization.h @@ -32,9 +32,9 @@ class BROWSER_EXPORT StorageExceptionInitialization: public StorageException { public: explicit StorageExceptionInitialization(const std::string & message, int code = SQLITE_ERROR); - virtual ~StorageExceptionInitialization() throw (); + virtual ~StorageExceptionInitialization() throw(); virtual int getErrorCode() const; - virtual const char * getMessage() const throw (); + virtual const char * getMessage() const throw(); }; } diff --git a/services/StorageService/StorageService.cpp b/services/StorageService/StorageService.cpp index bdd1ad5d..c35d689c 100644..100755 --- a/services/StorageService/StorageService.cpp +++ b/services/StorageService/StorageService.cpp @@ -31,7 +31,6 @@ StorageService::StorageService() StorageService::~StorageService() { - } } diff --git a/services/StorageService/StorageService.h b/services/StorageService/StorageService.h index f73c1243..f73c1243 100644..100755 --- a/services/StorageService/StorageService.h +++ b/services/StorageService/StorageService.h diff --git a/services/TabService/TabService.cpp b/services/TabService/TabService.cpp index 19eccbcc..bc6fe534 100644..100755 --- a/services/TabService/TabService.cpp +++ b/services/TabService/TabService.cpp @@ -119,7 +119,7 @@ tools::BrowserImagePtr TabService::getThumb(const basic_webengine::TabId& tabId) } auto imageDatabase = getThumbDatabase(tabId); - if(imageDatabase) { + if (imageDatabase) { saveThumbCache(tabId, *imageDatabase); return *imageDatabase; } diff --git a/services/TabService/TabService.h b/services/TabService/TabService.h index b998e4e2..b998e4e2 100644..100755 --- a/services/TabService/TabService.h +++ b/services/TabService/TabService.h diff --git a/services/TabService/TabServiceTypedef.h b/services/TabService/TabServiceTypedef.h index 8ce67dc8..8ce67dc8 100644..100755 --- a/services/TabService/TabServiceTypedef.h +++ b/services/TabService/TabServiceTypedef.h diff --git a/services/TabUI/TabUI.h b/services/TabUI/TabUI.h index 0563baec..8a710aea 100644..100755 --- a/services/TabUI/TabUI.h +++ b/services/TabUI/TabUI.h @@ -57,17 +57,17 @@ public: virtual void orientationChanged() override; #endif - boost::signals2::signal<void (const tizen_browser::basic_webengine::TabId&)> tabClicked; - boost::signals2::signal<void ()> newTabClicked; - boost::signals2::signal<void ()> newIncognitoTabClicked; - boost::signals2::signal<void (const tizen_browser::basic_webengine::TabId&)> closeTabsClicked; - boost::signals2::signal<void (const std::string & )> openedTabsClicked; + boost::signals2::signal<void(const tizen_browser::basic_webengine::TabId&)> tabClicked; + boost::signals2::signal<void()> newTabClicked; + boost::signals2::signal<void()> newIncognitoTabClicked; + boost::signals2::signal<void(const tizen_browser::basic_webengine::TabId&)> closeTabsClicked; + boost::signals2::signal<void(const std::string &)> openedTabsClicked; #if ON_OTHER_DEVICES - boost::signals2::signal<void (const std::string & )> onOtherDevicesClicked; + boost::signals2::signal<void(const std::string &)> onOtherDevicesClicked; #endif - boost::signals2::signal<void ()> closeTabUIClicked; - boost::signals2::signal<int () > tabsCount; - boost::signals2::signal<bool (const tizen_browser::basic_webengine::TabId& )> isIncognito; + boost::signals2::signal<void()> closeTabUIClicked; + boost::signals2::signal<int() > tabsCount; + boost::signals2::signal<bool(const tizen_browser::basic_webengine::TabId&)> isIncognito; private: diff --git a/services/WebEngineService/WebEngineService.h b/services/WebEngineService/WebEngineService.h index 2d21c5b7..2d21c5b7 100644..100755 --- a/services/WebEngineService/WebEngineService.h +++ b/services/WebEngineService/WebEngineService.h diff --git a/services/WebEngineService/WebView.cpp b/services/WebEngineService/WebView.cpp index 6315af99..0e024ccc 100755 --- a/services/WebEngineService/WebView.cpp +++ b/services/WebEngineService/WebView.cpp @@ -56,1686 +56,2229 @@ #define APPLICATION_NAME_FOR_USER_AGENT_MOBILE "Mozilla/5.0 (Linux; Tizen 3.0; tm1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.69 Mobile safari/537.36" #if PROFILE_MOBILE -Ecore_Timer* m_haptic_timer_id = NULL; +Ecore_Timer *m_haptic_timer_id = NULL; haptic_device_h m_haptic_handle; haptic_effect_h m_haptic_effect; #define FIND_WORD_MAX_COUNT 1000 #endif -using namespace tizen_browser::tools; - -namespace tizen_browser { -namespace basic_webengine { -namespace webengine_service { - -const std::string WebView::COOKIES_PATH = "cookies"; - -struct SnapshotItemData { - WebView * web_view; - tizen_browser::tools::SnapshotType snapshot_type; -}; +using namespace + tizen_browser::tools; +namespace + tizen_browser +{ + namespace + basic_webengine + { + namespace + webengine_service + { -WebView::WebView(Evas_Object * obj, TabId tabId, const std::string& title, bool incognitoMode) - : m_parent(obj) - , m_tabId(tabId) - , m_ewkView(nullptr) - , m_ewkContext(nullptr) - , m_title(title) - , m_redirectedURL("") - , m_isLoading(false) - , m_loadError(false) - , m_suspended(false) - , m_private(incognitoMode) - , m_fullscreen(false) + const + std::string + WebView::COOKIES_PATH = "cookies"; + + struct SnapshotItemData + { + WebView * + web_view; + tizen_browser::tools::SnapshotType + snapshot_type; + }; + + + WebView::WebView(Evas_Object * obj, TabId tabId, + const std::string & title, bool incognitoMode) + : + m_parent(obj) + , + m_tabId(tabId) + , + m_ewkView(nullptr) + , + m_ewkContext(nullptr) + , + m_title(title) + , + m_redirectedURL("") + , + m_isLoading(false) + , + m_loadError(false) + , + m_suspended(false) + , + m_private(incognitoMode) + , + m_fullscreen(false) #if PROFILE_MOBILE - , m_downloadControl(nullptr) + , + m_downloadControl(nullptr) #endif -{ -} - -WebView::~WebView() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (m_ewkView) { - unregisterCallbacks(); - evas_object_del(m_ewkView); - } + { + } + + WebView::~ + WebView() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (m_ewkView) + { + unregisterCallbacks(); + evas_object_del(m_ewkView); + } #if PROFILE_MOBILE - delete m_downloadControl; + delete + m_downloadControl; #endif -} - -void WebView::init(bool desktopMode, TabOrigin origin, Evas_Object*) -{ - m_ewkView = m_private ? ewk_view_add_in_incognito_mode(evas_object_evas_get(m_parent)) : - ewk_view_add_with_context(evas_object_evas_get(m_parent), ewk_context_default_get()); - - m_ewkContext = ewk_view_context_get(m_ewkView); - if (m_ewkContext) - m_private ? ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(m_ewkContext), EWK_COOKIE_ACCEPT_POLICY_NEVER) : - ewk_cookie_manager_accept_policy_set(ewk_context_cookie_manager_get(m_ewkContext), EWK_COOKIE_ACCEPT_POLICY_ALWAYS); - - evas_object_data_set(m_ewkView, "_container", this); - BROWSER_LOGD("[%s:%d] self=%p", __PRETTY_FUNCTION__, __LINE__, this); - - evas_object_color_set(m_ewkView, 255, 255, 255, 255); - evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, EVAS_HINT_FILL); - if (desktopMode) { - switchToDesktopMode(); - } else { - switchToMobileMode(); - } - m_origin = origin; - - ewk_context_cache_model_set(m_ewkContext, EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); - std::string path = app_get_data_path() + COOKIES_PATH; - ewk_cookie_manager_persistent_storage_set(ewk_context_cookie_manager_get(m_ewkContext), path.c_str(), EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); - - setupEwkSettings(); - registerCallbacks(); + } + + void + WebView::init(bool desktopMode, TabOrigin origin, Evas_Object *) + { + m_ewkView = + m_private ? + ewk_view_add_in_incognito_mode(evas_object_evas_get(m_parent)) : + ewk_view_add_with_context(evas_object_evas_get(m_parent), + ewk_context_default_get()); + + m_ewkContext = ewk_view_context_get(m_ewkView); + if (m_ewkContext) + m_private ? + ewk_cookie_manager_accept_policy_set + (ewk_context_cookie_manager_get(m_ewkContext), + EWK_COOKIE_ACCEPT_POLICY_NEVER) : + ewk_cookie_manager_accept_policy_set + (ewk_context_cookie_manager_get(m_ewkContext), + EWK_COOKIE_ACCEPT_POLICY_ALWAYS); + + evas_object_data_set(m_ewkView, "_container", this); + BROWSER_LOGD("[%s:%d] self=%p", __PRETTY_FUNCTION__, __LINE__, this); + + evas_object_color_set(m_ewkView, 255, 255, 255, 255); + evas_object_size_hint_weight_set(m_ewkView, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_ewkView, EVAS_HINT_FILL, + EVAS_HINT_FILL); + if (desktopMode) { + switchToDesktopMode(); + } else { + switchToMobileMode(); + } + m_origin = origin; + + ewk_context_cache_model_set(m_ewkContext, + EWK_CACHE_MODEL_PRIMARY_WEBBROWSER); + std::string path = app_get_data_path() + COOKIES_PATH; + ewk_cookie_manager_persistent_storage_set + (ewk_context_cookie_manager_get(m_ewkContext), path.c_str(), + EWK_COOKIE_PERSISTENT_STORAGE_SQLITE); + + setupEwkSettings(); + registerCallbacks(); #if PROFILE_MOBILE - m_downloadControl = new DownloadControl(); - orientationChanged(); + m_downloadControl = new DownloadControl(); + orientationChanged(); #endif - resume(); -} + resume(); + } #if PROFILE_MOBILE -void WebView::orientationChanged() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - boost::optional<int> signal = getRotation(); - if (signal && *signal != -1) { - int angle = *signal; - if ((angle % 180)== 90) - angle -= 180; - ewk_view_orientation_send(m_ewkView, angle); - } -} - -void cancel_vibration() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (m_haptic_timer_id) { - ecore_timer_del(m_haptic_timer_id); - m_haptic_timer_id = NULL; - } - - if (m_haptic_handle) { - device_haptic_stop(m_haptic_handle, m_haptic_effect); - device_haptic_close(m_haptic_handle); - m_haptic_handle = NULL; - } -} - -Eina_Bool __vibration_timeout_cb(void * /*data*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_haptic_timer_id = NULL; - cancel_vibration(); - - return ECORE_CALLBACK_CANCEL; -} - -void __vibration_cb(uint64_t vibration_time, void * /*data*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - cancel_vibration(); - - if (device_haptic_open(0, &m_haptic_handle) != DEVICE_ERROR_NONE) { - return; - } - - const uint64_t duration = vibration_time; - device_haptic_vibrate(m_haptic_handle, duration, 100, &m_haptic_effect); - double in = (double)((double)(duration) / (double)(1000)); - m_haptic_timer_id = ecore_timer_add(in, __vibration_timeout_cb, NULL); -} - -void __vibration_cancel_cb(void * /*data*/) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - cancel_vibration(); -} + void + WebView::orientationChanged() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + boost::optional < int > + signal = getRotation(); + if (signal && *signal != -1) { + int + angle = *signal; + if ((angle % 180) == 90) + angle -= 180; + ewk_view_orientation_send(m_ewkView, angle); + } + } + + void + cancel_vibration() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (m_haptic_timer_id) { + ecore_timer_del(m_haptic_timer_id); + m_haptic_timer_id = NULL; + } + + if (m_haptic_handle) { + device_haptic_stop(m_haptic_handle, m_haptic_effect); + device_haptic_close(m_haptic_handle); + m_haptic_handle = NULL; + } + } + + Eina_Bool + __vibration_timeout_cb(void * /*data */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_haptic_timer_id = NULL; + cancel_vibration(); + + return ECORE_CALLBACK_CANCEL; + } + + void + __vibration_cb(uint64_t vibration_time, void * /*data */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + cancel_vibration(); + + if (device_haptic_open(0, &m_haptic_handle) != DEVICE_ERROR_NONE) { + return; + } + + const uint64_t + duration = vibration_time; + device_haptic_vibrate(m_haptic_handle, duration, 100, + &m_haptic_effect); + double + in = (double) ((double) (duration) / (double) (1000)); + m_haptic_timer_id = ecore_timer_add(in, __vibration_timeout_cb, NULL); + } + + void + __vibration_cancel_cb(void * /*data */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + cancel_vibration(); + } #endif -void WebView::registerCallbacks() -{ - evas_object_smart_callback_add(m_ewkView, "load,started", __loadStarted, this); - evas_object_smart_callback_add(m_ewkView, "load,stop", __loadStop, this); - evas_object_smart_callback_add(m_ewkView, "load,finished", __loadFinished, this); - evas_object_smart_callback_add(m_ewkView, "load,progress", __loadProgress, this); - evas_object_smart_callback_add(m_ewkView, "load,error", __loadError, this); - - evas_object_smart_callback_add(m_ewkView, "title,changed", __titleChanged, this); - evas_object_smart_callback_add(m_ewkView, "url,changed", __urlChanged, this); - - evas_object_smart_callback_add(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this); - - evas_object_smart_callback_add(m_ewkView, "create,window", __newWindowRequest, this); - evas_object_smart_callback_add(m_ewkView, "close,window", __closeWindowRequest, this); + void + WebView::registerCallbacks() + { + evas_object_smart_callback_add(m_ewkView, "load,started", + __loadStarted, this); + evas_object_smart_callback_add(m_ewkView, "load,stop", __loadStop, + this); + evas_object_smart_callback_add(m_ewkView, "load,finished", + __loadFinished, this); + evas_object_smart_callback_add(m_ewkView, "load,progress", + __loadProgress, this); + evas_object_smart_callback_add(m_ewkView, "load,error", __loadError, + this); + + evas_object_smart_callback_add(m_ewkView, "title,changed", + __titleChanged, this); + evas_object_smart_callback_add(m_ewkView, "url,changed", __urlChanged, + this); + + evas_object_smart_callback_add(m_ewkView, "back,forward,list,changed", + __backForwardListChanged, this); + + evas_object_smart_callback_add(m_ewkView, "create,window", + __newWindowRequest, this); + evas_object_smart_callback_add(m_ewkView, "close,window", + __closeWindowRequest, this); #if PROFILE_MOBILE - evas_object_smart_callback_add(m_ewkView, "policy,response,decide", __policy_response_decide_cb, this); - evas_object_smart_callback_add(m_ewkView, "policy,navigation,decide", __policy_navigation_decide_cb, this); + evas_object_smart_callback_add(m_ewkView, "policy,response,decide", + __policy_response_decide_cb, this); + evas_object_smart_callback_add(m_ewkView, "policy,navigation,decide", + __policy_navigation_decide_cb, this); #endif - evas_object_smart_callback_add(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this); - evas_object_smart_callback_add(m_ewkView, "ssl,certificate,changed", __setCertificatePem, this); + evas_object_smart_callback_add(m_ewkView, + "request,certificate,confirm", + __requestCertificationConfirm, this); + evas_object_smart_callback_add(m_ewkView, "ssl,certificate,changed", + __setCertificatePem, this); - evas_object_smart_callback_add(m_ewkView, "icon,received", __faviconChanged, this); + evas_object_smart_callback_add(m_ewkView, "icon,received", + __faviconChanged, this); - evas_object_smart_callback_add(m_ewkView, "editorclient,ime,closed", __IMEClosed, this); - evas_object_smart_callback_add(m_ewkView, "editorclient,ime,opened", __IMEOpened, this); + evas_object_smart_callback_add(m_ewkView, "editorclient,ime,closed", + __IMEClosed, this); + evas_object_smart_callback_add(m_ewkView, "editorclient,ime,opened", + __IMEOpened, this); - evas_object_smart_callback_add(m_ewkView, "load,provisional,started", __load_provisional_started, this); - evas_object_smart_callback_add(m_ewkView, "load,provisional,redirect", __load_provisional_redirect, this); + evas_object_smart_callback_add(m_ewkView, "load,provisional,started", + __load_provisional_started, this); + evas_object_smart_callback_add(m_ewkView, "load,provisional,redirect", + __load_provisional_redirect, this); #if PROFILE_MOBILE - evas_object_smart_callback_add(m_ewkView, "contextmenu,customize", __contextmenu_customize_cb, this); - evas_object_smart_callback_add(m_ewkView, "contextmenu,selected", __contextmenu_selected_cb, this); - evas_object_smart_callback_add(m_ewkView, "fullscreen,enterfullscreen", __fullscreen_enter_cb, this); - evas_object_smart_callback_add(m_ewkView, "fullscreen,exitfullscreen", __fullscreen_exit_cb, this); - ewk_context_vibration_client_callbacks_set(m_ewkContext, __vibration_cb, __vibration_cancel_cb, this); - - evas_object_smart_callback_add(m_ewkView, "rotate,prepared", __rotate_prepared_cb, this); + evas_object_smart_callback_add(m_ewkView, "contextmenu,customize", + __contextmenu_customize_cb, this); + evas_object_smart_callback_add(m_ewkView, "contextmenu,selected", + __contextmenu_selected_cb, this); + evas_object_smart_callback_add(m_ewkView, + "fullscreen,enterfullscreen", + __fullscreen_enter_cb, this); + evas_object_smart_callback_add(m_ewkView, "fullscreen,exitfullscreen", + __fullscreen_exit_cb, this); + ewk_context_vibration_client_callbacks_set(m_ewkContext, + __vibration_cb, + __vibration_cancel_cb, + this); + + evas_object_smart_callback_add(m_ewkView, "rotate,prepared", + __rotate_prepared_cb, this); #endif -} - -void WebView::unregisterCallbacks() -{ - evas_object_smart_callback_del_full(m_ewkView, "load,started", __loadStarted, this); - evas_object_smart_callback_del_full(m_ewkView, "load,stop", __loadStop, this); - evas_object_smart_callback_del_full(m_ewkView, "load,finished", __loadFinished, this); - evas_object_smart_callback_del_full(m_ewkView, "load,progress", __loadProgress, this); - evas_object_smart_callback_del_full(m_ewkView, "load,error", __loadError, this); - - evas_object_smart_callback_del_full(m_ewkView, "title,changed", __titleChanged, this); - evas_object_smart_callback_del_full(m_ewkView, "url,changed", __urlChanged, this); - - evas_object_smart_callback_del_full(m_ewkView, "back,forward,list,changed", __backForwardListChanged, this); - - evas_object_smart_callback_del_full(m_ewkView, "create,window", __newWindowRequest, this); - evas_object_smart_callback_del_full(m_ewkView, "close,window", __closeWindowRequest, this); + } + + void + WebView::unregisterCallbacks() + { + evas_object_smart_callback_del_full(m_ewkView, "load,started", + __loadStarted, this); + evas_object_smart_callback_del_full(m_ewkView, "load,stop", + __loadStop, this); + evas_object_smart_callback_del_full(m_ewkView, "load,finished", + __loadFinished, this); + evas_object_smart_callback_del_full(m_ewkView, "load,progress", + __loadProgress, this); + evas_object_smart_callback_del_full(m_ewkView, "load,error", + __loadError, this); + + evas_object_smart_callback_del_full(m_ewkView, "title,changed", + __titleChanged, this); + evas_object_smart_callback_del_full(m_ewkView, "url,changed", + __urlChanged, this); + + evas_object_smart_callback_del_full(m_ewkView, + "back,forward,list,changed", + __backForwardListChanged, this); + + evas_object_smart_callback_del_full(m_ewkView, "create,window", + __newWindowRequest, this); + evas_object_smart_callback_del_full(m_ewkView, "close,window", + __closeWindowRequest, this); #if PROFILE_MOBILE - evas_object_smart_callback_del_full(m_ewkView, "policy,response,decide", __policy_response_decide_cb, this); - evas_object_smart_callback_del_full(m_ewkView, "policy,navigation,decide", __policy_navigation_decide_cb, this); + evas_object_smart_callback_del_full(m_ewkView, + "policy,response,decide", + __policy_response_decide_cb, + this); + evas_object_smart_callback_del_full(m_ewkView, + "policy,navigation,decide", + __policy_navigation_decide_cb, + this); #endif - evas_object_smart_callback_del_full(m_ewkView, "request,certificate,confirm", __requestCertificationConfirm, this); - - evas_object_smart_callback_del_full(m_ewkView, "icon,received", __faviconChanged, this); - - evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,closed", __IMEClosed, this); - evas_object_smart_callback_del_full(m_ewkView, "editorclient,ime,opened", __IMEOpened, this); - - evas_object_smart_callback_del_full(m_ewkView, "load,provisional,started", __load_provisional_started, this); - evas_object_smart_callback_del_full(m_ewkView, "load,provisional,redirect", __load_provisional_redirect, this); + evas_object_smart_callback_del_full(m_ewkView, + "request,certificate,confirm", + __requestCertificationConfirm, + this); + + evas_object_smart_callback_del_full(m_ewkView, "icon,received", + __faviconChanged, this); + + evas_object_smart_callback_del_full(m_ewkView, + "editorclient,ime,closed", + __IMEClosed, this); + evas_object_smart_callback_del_full(m_ewkView, + "editorclient,ime,opened", + __IMEOpened, this); + + evas_object_smart_callback_del_full(m_ewkView, + "load,provisional,started", + __load_provisional_started, this); + evas_object_smart_callback_del_full(m_ewkView, + "load,provisional,redirect", + __load_provisional_redirect, + this); #if PROFILE_MOBILE - evas_object_smart_callback_del_full(m_ewkView, "contextmenu,customize", __contextmenu_customize_cb, this); - evas_object_smart_callback_del_full(m_ewkView, "contextmenu,selected", __contextmenu_selected_cb, this); - evas_object_smart_callback_del_full(m_ewkView, "fullscreen,enterfullscreen", __fullscreen_enter_cb, this); - evas_object_smart_callback_del_full(m_ewkView, "fullscreen,exitfullscreen", __fullscreen_exit_cb, this); - ewk_context_vibration_client_callbacks_set(m_ewkContext, NULL, NULL, this); - - evas_object_smart_callback_del_full(m_ewkView, "rotate,prepared", __rotate_prepared_cb, this); + evas_object_smart_callback_del_full(m_ewkView, + "contextmenu,customize", + __contextmenu_customize_cb, this); + evas_object_smart_callback_del_full(m_ewkView, "contextmenu,selected", + __contextmenu_selected_cb, this); + evas_object_smart_callback_del_full(m_ewkView, + "fullscreen,enterfullscreen", + __fullscreen_enter_cb, this); + evas_object_smart_callback_del_full(m_ewkView, + "fullscreen,exitfullscreen", + __fullscreen_exit_cb, this); + ewk_context_vibration_client_callbacks_set(m_ewkContext, NULL, NULL, + this); + + evas_object_smart_callback_del_full(m_ewkView, "rotate,prepared", + __rotate_prepared_cb, this); #endif -} - -void WebView::setupEwkSettings() -{ - Ewk_Settings * settings = ewk_view_settings_get(m_ewkView); - ewk_settings_uses_keypad_without_user_action_set(settings, EINA_FALSE); -} - -std::map<std::string, std::vector<std::string> > WebView::parse_uri(const char *uriToParse) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::string uri = uriToParse; - std::map<std::string, std::vector<std::string> > uri_parts; - std::string::size_type mainDelimiter; - mainDelimiter = uri.find_first_of("?"); - if (mainDelimiter != std::string::npos) { - uri_parts["url"].push_back(uri.substr(0, mainDelimiter)); - std::string argsString = uri.substr(mainDelimiter+1, std::string::npos); - const char *delimiter = "&"; - std::vector<std::string> argsVector; - auto i = 0; - auto pos = argsString.find(delimiter); - if (pos != std::string::npos) { - while (pos != std::string::npos) { - argsVector.push_back(argsString.substr(i, pos-i)); - i = ++pos; - pos = argsString.find(delimiter, pos); - if (pos == std::string::npos) - argsVector.push_back(argsString.substr(i, argsString.length())); - } - } else { - argsVector.push_back(argsString.substr(i, argsString.length())); - } - - const char *valueDelimiter = "="; - const char *itemsDelimiter = ";"; - for (auto item : argsVector) { - pos = item.find(valueDelimiter); - if (pos != std::string::npos) { - std::string key = item.substr(0, pos); - std::string value = item.substr(pos+1, std::string::npos); - - auto pos2 = value.find(itemsDelimiter); - auto j = 0; - if (pos2 != std::string::npos) { - while (pos2 != std::string::npos) { - uri_parts[key].push_back(value.substr(j, pos2-j)); - j = ++pos2; - pos2 = value.find(itemsDelimiter, pos2); - if (pos2 == std::string::npos) - uri_parts[key].push_back(value.substr(j, value.length())); - } - } else { - uri_parts[key].push_back(value); - } - } - } - } else { - uri_parts["url"].push_back(uri.substr(0, mainDelimiter)); - } - return uri_parts; -} + } + + void + WebView::setupEwkSettings() + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_uses_keypad_without_user_action_set(settings, + EINA_FALSE); + } + + std::map < std::string, + std::vector < std::string > + >WebView::parse_uri(const char *uriToParse) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::string uri = uriToParse; + std::map < std::string, std::vector < std::string > >uri_parts; + std::string::size_type mainDelimiter; + mainDelimiter = uri.find_first_of("?"); + if (mainDelimiter != std::string::npos) { + uri_parts["url"].push_back(uri.substr(0, mainDelimiter)); + std::string argsString = + uri.substr(mainDelimiter + 1, std::string::npos); + const char * + delimiter = "&"; + std::vector < std::string > argsVector; + auto + i = 0; + auto + pos = argsString.find(delimiter); + if (pos != std::string::npos) { + while (pos != std::string::npos) { + argsVector.push_back(argsString.substr(i, pos - i)); + i = ++pos; + pos = argsString.find(delimiter, pos); + if (pos == std::string::npos) + argsVector.push_back(argsString. + substr(i, argsString.length())); + } + } else { + argsVector.push_back(argsString.substr(i, argsString.length())); + } + + const char * + valueDelimiter = "="; + const char * + itemsDelimiter = ";"; + for (auto item:argsVector) { + pos = item.find(valueDelimiter); + if (pos != std::string::npos) { + std::string key = item.substr(0, pos); + std::string value = item.substr(pos + 1, std::string::npos); + + auto + pos2 = value.find(itemsDelimiter); + auto + j = 0; + if (pos2 != std::string::npos) { + while (pos2 != std::string::npos) { + uri_parts[key].push_back(value.substr(j, pos2 - j)); + j = ++pos2; + pos2 = value.find(itemsDelimiter, pos2); + if (pos2 == std::string::npos) + uri_parts[key].push_back(value.substr(j, value.length())); + } + } else { + uri_parts[key].push_back(value); + } + } + } + } else { + uri_parts["url"].push_back(uri.substr(0, mainDelimiter)); + } + return uri_parts; + } #if PROFILE_MOBILE -Eina_Bool WebView::handle_scheme(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (!strncmp(uri, HTTP_SCHEME, strlen(HTTP_SCHEME))) { - return EINA_FALSE; - } else if (!strncmp(uri, HTTPS_SCHEME, strlen(HTTPS_SCHEME))) { - return EINA_FALSE; - } else if (!strncmp(uri, FILE_SCHEME, strlen(FILE_SCHEME))) { - return EINA_FALSE; - } else if (!strncmp(uri, TIZENSTORE_SCHEME, strlen(TIZENSTORE_SCHEME))) { - launch_tizenstore(uri); - return EINA_TRUE; - } else if (!strncmp(uri, MAILTO_SCHEME, strlen(MAILTO_SCHEME))) { - launch_email(uri); - return EINA_TRUE; - } else if (!strncmp(uri, TEL_SCHEME, strlen(TEL_SCHEME))) { - launch_dialer(uri); - return EINA_TRUE; - } else if (!strncmp(uri, TELTO_SCHEME, strlen(TELTO_SCHEME))) { - std::string request_uri = std::string(TEL_SCHEME) + std::string(uri + strlen(TELTO_SCHEME)); - launch_dialer(request_uri.c_str()); - return EINA_TRUE; - } else if (!strncmp(uri, CALLTO_SCHEME, strlen(CALLTO_SCHEME))) { - std::string request_uri = std::string(TEL_SCHEME) + std::string(uri + strlen(CALLTO_SCHEME)); - launch_dialer(request_uri.c_str()); - return EINA_TRUE; - } else if (!strncmp(uri, SMS_SCHEME, strlen(SMS_SCHEME))) { - launch_message(uri); - return EINA_TRUE; - } else if (!strncmp(uri, SMSTO_SCHEME, strlen(SMSTO_SCHEME))) { - std::string request_uri = std::string(SMS_SCHEME) + std::string(uri + strlen(SMSTO_SCHEME)); - launch_message(request_uri.c_str()); - return EINA_TRUE; - } - return EINA_FALSE; -} - -Eina_Bool WebView::launch_email(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::map<std::string, std::vector<std::string> >uri_parts = this->parse_uri(uri); - - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_create", __PRETTY_FUNCTION__, __LINE__); - return EINA_FALSE; - } - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { - BROWSER_LOGE("Fail to app_control_set_operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - auto it = uri_parts.find("url"); - if (it != uri_parts.end()) { - if (app_control_set_uri(app_control, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_set_uri"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } else { - return EINA_FALSE; - } - - it = uri_parts.find("subject"); - if (it != uri_parts.end()) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_SUBJECT, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - it = uri_parts.find("body"); - if (it != uri_parts.end()) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - it = uri_parts.find("cc"); - if (it != uri_parts.end()) { - size_t size = it->second.size(); - const char* cc[size]; - int i = 0; - for (auto item : it->second) { - cc[i] = item.c_str(); - ++i; - } - if (app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_CC, cc, size) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data_array"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - it = uri_parts.find("bcc"); - if (it != uri_parts.end()) { - size_t size = it->second.size(); - const char* bcc[size]; - int i = 0; - for (auto item : it->second) { - bcc[i] = item.c_str(); - ++i; - } - if (app_control_add_extra_data_array(app_control, APP_CONTROL_DATA_BCC, bcc, size) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data_array"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("Fail to app_control_send_launch_request"); - app_control_destroy(app_control); - return EINA_FALSE; - } - app_control_destroy(app_control); - - return EINA_TRUE; -} - -Eina_Bool WebView::launch_contact(const char *uri, const char *protocol) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::map<std::string, std::vector<std::string> >uri_parts = this->parse_uri(uri); - - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("Fail to create app_control handle"); - return EINA_FALSE; - } - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_ADD) < 0) { - BROWSER_LOGE("Fail to app_control_set_operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_set_mime(app_control, "application/vnd.tizen.contact") < 0) { - BROWSER_LOGE("Fail to app_control_set_mime"); - app_control_destroy(app_control); - return EINA_FALSE; - } - auto it = uri_parts.find("url"); - if (it != uri_parts.end()) { - if (!strcmp(protocol, "tel")) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_PHONE, - it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } else if (strcmp(protocol, "mailto") == 0) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_EMAIL, - it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } else { - BROWSER_LOGE("Not supported protocol!"); - } - } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("Fail to launch app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - app_control_destroy(app_control); - - return EINA_TRUE; -} - -Eina_Bool WebView::launch_dialer(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("Fail to create app_control handle"); - return EINA_FALSE; - } - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_DIAL) < 0) { - BROWSER_LOGE("Fail to app_control_set_operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_set_uri(app_control, uri) < 0) { - BROWSER_LOGE("app_control_set_uri is failed."); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("Fail to launch app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - app_control_destroy(app_control); - - return EINA_TRUE; -} - -Eina_Bool WebView::launch_message(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - std::map<std::string, std::vector<std::string> >uri_parts = this->parse_uri(uri); - - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("Fail to create app_control handle"); - return EINA_FALSE; - } - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { - BROWSER_LOGE("Fail to set app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - auto it = uri_parts.find("url"); - if (it != uri_parts.end()) { - if (app_control_set_uri(app_control, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_set_uri"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - else { - return EINA_FALSE; - } - - it = uri_parts.find("subject"); - if (it != uri_parts.end()) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_SUBJECT, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - it = uri_parts.find("body"); - if (it != uri_parts.end()) { - if (app_control_add_extra_data(app_control, APP_CONTROL_DATA_TEXT, it->second.front().c_str()) < 0) { - BROWSER_LOGE("Fail to app_control_add_extra_data"); - app_control_destroy(app_control); - return EINA_FALSE; - } - } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("Fail to launch app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - app_control_destroy(app_control); - - return EINA_TRUE; -} - -Eina_Bool WebView::launch_tizenstore(const char *uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("Fail to create app_control handle"); - return EINA_FALSE; - } - if (!app_control) { - BROWSER_LOGE("Fail to create app_control handle"); - return EINA_FALSE; - } - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) { - BROWSER_LOGE("Fail to set app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_set_uri(app_control, uri) < 0) { - BROWSER_LOGE("Fail to set uri operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_set_app_id(app_control, TIZENSTORE_APP_ID) < 0) { - BROWSER_LOGE("Fail to app_control_set_app_id"); - app_control_destroy(app_control); - return EINA_FALSE; - } - if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { - BROWSER_LOGE("Fail to launch app_control operation"); - app_control_destroy(app_control); - return EINA_FALSE; - } - app_control_destroy(app_control); - - return EINA_TRUE; -} + Eina_Bool + WebView::handle_scheme(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (!strncmp(uri, HTTP_SCHEME, strlen(HTTP_SCHEME))) { + return EINA_FALSE; + } else if (!strncmp(uri, HTTPS_SCHEME, strlen(HTTPS_SCHEME))) { + return EINA_FALSE; + } else if (!strncmp(uri, FILE_SCHEME, strlen(FILE_SCHEME))) { + return EINA_FALSE; + } else if (!strncmp(uri, TIZENSTORE_SCHEME, strlen(TIZENSTORE_SCHEME))) { + launch_tizenstore(uri); + return EINA_TRUE; + } else if (!strncmp(uri, MAILTO_SCHEME, strlen(MAILTO_SCHEME))) { + launch_email(uri); + return EINA_TRUE; + } else if (!strncmp(uri, TEL_SCHEME, strlen(TEL_SCHEME))) { + launch_dialer(uri); + return EINA_TRUE; + } else if (!strncmp(uri, TELTO_SCHEME, strlen(TELTO_SCHEME))) { + std::string request_uri = + std::string(TEL_SCHEME) + std::string(uri + strlen(TELTO_SCHEME)); + launch_dialer(request_uri.c_str()); + return EINA_TRUE; + } else if (!strncmp(uri, CALLTO_SCHEME, strlen(CALLTO_SCHEME))) { + std::string request_uri = + std::string(TEL_SCHEME) + std::string(uri + + strlen(CALLTO_SCHEME)); + launch_dialer(request_uri.c_str()); + return EINA_TRUE; + } else if (!strncmp(uri, SMS_SCHEME, strlen(SMS_SCHEME))) { + launch_message(uri); + return EINA_TRUE; + } else if (!strncmp(uri, SMSTO_SCHEME, strlen(SMSTO_SCHEME))) { + std::string request_uri = + std::string(SMS_SCHEME) + std::string(uri + strlen(SMSTO_SCHEME)); + launch_message(request_uri.c_str()); + return EINA_TRUE; + } + return EINA_FALSE; + } + + Eina_Bool + WebView::launch_email(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::map < std::string, std::vector < std::string > >uri_parts = + this->parse_uri(uri); + + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_create", + __PRETTY_FUNCTION__, __LINE__); + return EINA_FALSE; + } + if (app_control_set_operation + (app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { + BROWSER_LOGE("Fail to app_control_set_operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + auto + it = uri_parts.find("url"); + if (it != uri_parts.end()) { + if (app_control_set_uri(app_control, it->second.front().c_str()) < + 0) { + BROWSER_LOGE("Fail to app_control_set_uri"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } else { + return EINA_FALSE; + } + + it = uri_parts.find("subject"); + if (it != uri_parts.end()) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_SUBJECT, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + it = uri_parts.find("body"); + if (it != uri_parts.end()) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_TEXT, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + it = uri_parts.find("cc"); + if (it != uri_parts.end()) { + size_t + size = it->second.size(); + const char * + cc[size]; + int + i = 0; + for (auto item:it->second) { + cc[i] = item.c_str(); + ++i; + } + if (app_control_add_extra_data_array + (app_control, APP_CONTROL_DATA_CC, cc, size) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data_array"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + it = uri_parts.find("bcc"); + if (it != uri_parts.end()) { + size_t + size = it->second.size(); + const char * + bcc[size]; + int + i = 0; + for (auto item:it->second) { + bcc[i] = item.c_str(); + ++i; + } + if (app_control_add_extra_data_array + (app_control, APP_CONTROL_DATA_BCC, bcc, size) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data_array"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to app_control_send_launch_request"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; + } + + Eina_Bool + WebView::launch_contact(const char *uri, const char *protocol) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::map < std::string, std::vector < std::string > >uri_parts = + this->parse_uri(uri); + + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_ADD) + < 0) { + BROWSER_LOGE("Fail to app_control_set_operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_mime(app_control, "application/vnd.tizen.contact") + < 0) { + BROWSER_LOGE("Fail to app_control_set_mime"); + app_control_destroy(app_control); + return EINA_FALSE; + } + auto + it = uri_parts.find("url"); + if (it != uri_parts.end()) { + if (!strcmp(protocol, "tel")) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_PHONE, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } else if (strcmp(protocol, "mailto") == 0) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_EMAIL, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } else { + BROWSER_LOGE("Not supported protocol!"); + } + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; + } + + Eina_Bool + WebView::launch_dialer(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_DIAL) + < 0) { + BROWSER_LOGE("Fail to app_control_set_operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("app_control_set_uri is failed."); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; + } + + Eina_Bool + WebView::launch_message(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + std::map < std::string, std::vector < std::string > >uri_parts = + this->parse_uri(uri); + + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation + (app_control, APP_CONTROL_OPERATION_COMPOSE) < 0) { + BROWSER_LOGE("Fail to set app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + auto + it = uri_parts.find("url"); + if (it != uri_parts.end()) { + if (app_control_set_uri(app_control, it->second.front().c_str()) < + 0) { + BROWSER_LOGE("Fail to app_control_set_uri"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } else { + return EINA_FALSE; + } + + it = uri_parts.find("subject"); + if (it != uri_parts.end()) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_SUBJECT, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + it = uri_parts.find("body"); + if (it != uri_parts.end()) { + if (app_control_add_extra_data + (app_control, APP_CONTROL_DATA_TEXT, + it->second.front().c_str()) < 0) { + BROWSER_LOGE("Fail to app_control_add_extra_data"); + app_control_destroy(app_control); + return EINA_FALSE; + } + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; + } + + Eina_Bool + WebView::launch_tizenstore(const char *uri) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (!app_control) { + BROWSER_LOGE("Fail to create app_control handle"); + return EINA_FALSE; + } + if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) + < 0) { + BROWSER_LOGE("Fail to set app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("Fail to set uri operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_set_app_id(app_control, TIZENSTORE_APP_ID) < 0) { + BROWSER_LOGE("Fail to app_control_set_app_id"); + app_control_destroy(app_control); + return EINA_FALSE; + } + if (app_control_send_launch_request(app_control, NULL, NULL) < 0) { + BROWSER_LOGE("Fail to launch app_control operation"); + app_control_destroy(app_control); + return EINA_FALSE; + } + app_control_destroy(app_control); + + return EINA_TRUE; + } #endif -Evas_Object * WebView::getLayout() -{ - return m_ewkView; -} + Evas_Object * + WebView::getLayout() + { + return m_ewkView; + } #if !DUMMY_BUTTON -Evas_Object * WebView::getWidget() -{ - return ewk_view_widget_get(m_ewkView); -} + Evas_Object * + WebView::getWidget() + { + return ewk_view_widget_get(m_ewkView); + } #endif -void WebView::setURI(const std::string & uri) -{ - BROWSER_LOGD("[%s:%d] uri=%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); - m_faviconImage.reset(); - ewk_view_url_set(m_ewkView, uri.c_str()); - m_loadError = false; -} - -std::string WebView::getURI(void) -{ - BROWSER_LOGD("[%s:%d] uri=%s", __PRETTY_FUNCTION__, __LINE__, ewk_view_url_get(m_ewkView)); - return fromChar(ewk_view_url_get(m_ewkView)); -} - -std::string WebView::getTitle(void) -{ - return m_title; -} - -std::string WebView::getUserAgent() -{ - return fromChar(ewk_view_user_agent_get(m_ewkView)); -} - -void WebView::setUserAgent(const std::string& ua) -{ - ewk_view_user_agent_set(m_ewkView, ua.c_str()); -} - -void WebView::suspend() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkView); - - ewk_view_suspend(m_ewkView); - m_suspended = true; -} - -void WebView::resume() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkView); - - ewk_view_resume(m_ewkView); - m_suspended = false; -} - -void WebView::stopLoading(void) -{ - m_isLoading = false; - ewk_view_stop(m_ewkView); - loadStop(); -} - -void WebView::reload(void) -{ - m_isLoading = true; - if (m_loadError) { - m_loadError = false; - ewk_view_url_set(m_ewkView, ewk_view_url_get(m_ewkView)); - } else { - ewk_view_reload(m_ewkView); - } -} - -void WebView::back(void) -{ - m_loadError = false; - ewk_view_back(m_ewkView); -} - -void WebView::forward(void) -{ - m_loadError = false; - ewk_view_forward(m_ewkView); -} - -bool WebView::isBackEnabled(void) -{ - return ewk_view_back_possible(m_ewkView); -} - -bool WebView::isForwardEnabled(void) -{ - return ewk_view_forward_possible(m_ewkView); -} - -bool WebView::isLoading() -{ - return m_isLoading; -} - -bool WebView::isLoadError() const -{ - return m_loadError; -} - -void WebView::confirmationResult(WebConfirmationPtr confirmation) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - if (confirmation->getConfirmationType() == WebConfirmation::ConfirmationType::CertificateConfirmation) { - //FIXME: https://bugs.tizen.org/jira/browse/TT-229 - CertificateConfirmationPtr cert = std::dynamic_pointer_cast<CertificateConfirmation, WebConfirmation>(confirmation); - - // The below line doesn't serve any purpose now, but it may become - // relevant when implementing https://bugs.tizen.org/jira/browse/TT-229 - Ewk_Certificate_Policy_Decision *request = m_confirmationCertificatenMap[cert]; - Eina_Bool result; - - if (cert->getResult() == WebConfirmation::ConfirmationResult::Confirmed) { - result = EINA_TRUE; - } else if (cert->getResult() == WebConfirmation::ConfirmationResult::Rejected) { - result = EINA_FALSE; - } else { - BROWSER_LOGE("Wrong ConfirmationResult"); - return; - } - - // set certificate confirmation - ewk_certificate_policy_decision_allowed_set(request, result); - resume(); - - // remove from map - m_confirmationCertificatenMap.erase(cert); - } else { - BROWSER_LOGW("[%s:%d] Unknown WebConfirmation::ConfirmationType!", __PRETTY_FUNCTION__, __LINE__); - } -} - -tools::BrowserImagePtr WebView::captureSnapshot(int targetWidth, int targetHeight, bool async, - tizen_browser::tools::SnapshotType snapshot_type) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkView); - M_ASSERT(targetWidth); - M_ASSERT(targetHeight); - Evas_Coord vw, vh; - evas_object_geometry_get(m_ewkView, nullptr, nullptr, &vw, &vh); - if (vw == 0 || vh == 0) - return std::make_shared<BrowserImage>(); - - double scale = targetWidth / (double)(vw * getZoomFactor()); - double scale_max, scale_min; - ewk_view_scale_range_get(m_ewkView, &scale_min, &scale_max); - if (scale < scale_min) - scale = scale_min; - else if (scale > scale_max) - scale = scale_max; - - Eina_Rectangle area; - double snapshotProportions = (double)(targetWidth) /(double)(targetHeight); - double webkitProportions = (double)(vw) /(double)(vh); - if (webkitProportions >= snapshotProportions) { - // centring position of screenshot - area.x = (vw*getZoomFactor()/2) - (vh*getZoomFactor()*snapshotProportions/2); - area.y = 0; - area.w = vh*getZoomFactor()*snapshotProportions; - area.h = vh*getZoomFactor(); - } else { - area.x = 0; - area.y = 0; - area.w = vw*getZoomFactor(); - area.h = vw*getZoomFactor()/snapshotProportions; - } - if (area.w == 0 || area.h == 0) - return std::make_shared<BrowserImage>(); - - BROWSER_LOGD("[%s:%d] Before snapshot (screenshot) - look at the time of taking snapshot below",__func__, __LINE__); - - if (async) { - SnapshotItemData *snapshot_data = new SnapshotItemData(); - snapshot_data->web_view = this; - snapshot_data->snapshot_type = snapshot_type; - bool result = ewk_view_screenshot_contents_get_async(m_ewkView, area, scale, evas_object_evas_get(m_ewkView), __screenshotCaptured, snapshot_data); - if (!result) - BROWSER_LOGD("[%s:%d] ewk_view_screenshot_contents_get_async API failed", __func__, __LINE__); - } else { - Evas_Object *snapshot = ewk_view_screenshot_contents_get(m_ewkView, area, scale, evas_object_evas_get(m_ewkView)); - BROWSER_LOGD("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p", __func__, __LINE__, snapshot); - if (snapshot) - return std::make_shared<tools::BrowserImage>(snapshot); - } - - return std::make_shared<BrowserImage>(); -} - -void WebView::__screenshotCaptured(Evas_Object* image, void* data) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - SnapshotItemData *snapshot_data = static_cast<SnapshotItemData*>(data); - snapshot_data->web_view->snapshotCaptured(std::make_shared<tools::BrowserImage>(image), snapshot_data->snapshot_type); -} - -void WebView::__newWindowRequest(void *data, Evas_Object *, void *out) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - BROWSER_LOGD("[%s:%d] self=%p", __PRETTY_FUNCTION__, __LINE__, self); - BROWSER_LOGD("Window creating in tab: %s", self->getTabId().toString().c_str()); - std::shared_ptr<basic_webengine::AbstractWebEngine<Evas_Object>> m_webEngine; - m_webEngine = std::dynamic_pointer_cast - < - basic_webengine::AbstractWebEngine<Evas_Object>, tizen_browser::core::AbstractService - > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); - M_ASSERT(m_webEngine); - - /// \todo: Choose newly created tab. - TabId id(TabId::NONE); - TabId currentTabId = m_webEngine->currentTabId(); - if (currentTabId != (id = m_webEngine->addTab(std::string(), - &self->getTabId(), - boost::none, - std::string(), - self->isDesktopMode(), - self->isPrivateMode(), - currentTabId.get()))) { - BROWSER_LOGD("Created tab: %s", id.toString().c_str()); - Evas_Object* tab_ewk_view = m_webEngine->getTabView(id); - *static_cast<Evas_Object**>(out) = tab_ewk_view; - - // switch to a new tab - m_webEngine->switchToTab(id); - m_webEngine->windowCreated(); - } -} - -void WebView::__closeWindowRequest(void *data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebView * self = reinterpret_cast<WebView *>(data); - std::shared_ptr<AbstractWebEngine<Evas_Object>> m_webEngine = - std::dynamic_pointer_cast - <basic_webengine::AbstractWebEngine<Evas_Object>, tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); - m_webEngine->closeTab(self->getTabId()); -} - -void WebView::__loadStarted(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - WebView * self = reinterpret_cast<WebView *>(data); - - BROWSER_LOGD("%s:%d\n\t %s", __func__, __LINE__, ewk_view_url_get(self->m_ewkView)); - - self->m_isLoading = true; - self->loadStarted(); -} - -void WebView::__loadStop(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - self->m_isLoading = false; - - self->loadStop(); -} - -void WebView::__loadFinished(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - - self->m_isLoading = false; - self->m_loadProgress = 1; - - self->loadFinished(); - self->loadProgress(self->m_loadProgress); - - self->captureSnapshot(boost::any_cast<int>(config::Config::getInstance().get(CONFIG_KEY::HISTORY_TAB_SERVICE_THUMB_WIDTH)), - boost::any_cast<int>(tizen_browser::config::Config::getInstance().get(CONFIG_KEY::HISTORY_TAB_SERVICE_THUMB_HEIGHT)), - true, tools::SnapshotType::ASYNC_LOAD_FINISHED); - - self->setFocus(); -} - -void WebView::__loadProgress(void * data, Evas_Object * /* obj */, void * event_info) -{ - WebView * self = reinterpret_cast<WebView *>(data); - if (!self->isLoading()) - return; - - self->m_loadProgress = *(double *)event_info; - self->loadProgress(self->m_loadProgress); -} - -void WebView::__loadError(void* data, Evas_Object * obj, void* ewkError) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView *self = reinterpret_cast<WebView*>(data); - Ewk_Error *error = reinterpret_cast<Ewk_Error*>(ewkError); - Ewk_Error_Type errorType = ewk_error_type_get(error); - - BROWSER_LOGD("[%s:%d] ewk_error_type: %d ", - __PRETTY_FUNCTION__, __LINE__, errorType); - - BROWSER_LOGD("[%s:%d] emiting signal ", __PRETTY_FUNCTION__, __LINE__); - int errorCode = ewk_error_code_get(error); - if (errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED) { - BROWSER_LOGD("Stop signal emitted"); - BROWSER_LOGD("Error description: %s", ewk_error_description_get(error)); - evas_object_smart_callback_call(obj, "load,stop", nullptr); - } else { - self->loadError(); - self->m_loadError=true; - } -} - -void WebView::__titleChanged(void * data, Evas_Object * obj, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - self->m_title = fromChar(ewk_view_title_get(obj)); - self->titleChanged(self->m_title); -} - -void WebView::__urlChanged(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - BROWSER_LOGD("URL changed for tab: %s", self->getTabId().toString().c_str()); - self->uriChanged(self->getURI()); -} - -void WebView::__backForwardListChanged(void * data, Evas_Object * /* obj */, void * /* event_info */) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - self->backwardEnableChanged(self->isBackEnabled()); - self->forwardEnableChanged(self->isForwardEnabled()); -} - -void WebView::__faviconChanged(void* data, Evas_Object*, void*) -{ - if (data) - { - WebView * self = static_cast<WebView *>(data); - Evas_Object * favicon = ewk_context_icon_database_icon_object_add(self->m_ewkContext, ewk_view_url_get(self->m_ewkView), evas_object_evas_get(self->m_ewkView)); - if (favicon) { - BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, __LINE__); - self->m_faviconImage = std::make_shared<tools::BrowserImage>(favicon); - evas_object_del(favicon); - self->favIconChanged(self->m_faviconImage); - } - } -} - -void WebView::__IMEClosed(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("%s", __func__); - WebView * self = reinterpret_cast<WebView *>(data); - self->IMEStateChanged(false); -} - -void WebView::__IMEOpened(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("%s", __func__); - WebView * self = reinterpret_cast<WebView *>(data); - self->IMEStateChanged(true); -} - -void WebView::__load_provisional_started(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebView * self = reinterpret_cast<WebView*>(data); - self->setRedirectedURL(self->getURI()); -} - -void WebView::__load_provisional_redirect(void* data, Evas_Object*, void*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebView * self = reinterpret_cast<WebView*>(data); - if (!self->getRedirectedURL().empty()) - self->redirectedWebPage(self->getRedirectedURL(), self->getURI()); - self->setRedirectedURL(""); -} - -void WebView::__requestCertificationConfirm(void * data , Evas_Object * /* obj */, void * event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - Ewk_Certificate_Policy_Decision *request = reinterpret_cast<Ewk_Certificate_Policy_Decision *>(event_info); - if (!request) { - BROWSER_LOGW("[%s:%d] Wrong event_info!", __PRETTY_FUNCTION__, __LINE__); - return; - } - - int error = ewk_certificate_policy_decision_error_get(request); - if (error == EWK_CERTIFICATE_POLICY_DECISION_ERROR_PINNED_KEY_NOT_IN_CHAIN) { - ewk_certificate_policy_decision_allowed_set(request, EINA_FALSE); - BROWSER_LOGW("[%s:%d] EWK_CERTIFICATE_POLICY_DECISION_ERROR_PINNED_KEY_NOT_IN_CHAIN", __PRETTY_FUNCTION__, __LINE__); - self->unsecureConnection(); - return; - } - - self->suspend(); - ewk_certificate_policy_decision_suspend(request); - - std::string url = tools::extractDomain(self->m_loadingURL); - - ///\todo add translations - std::string message = (boost::format("There are problems with the security certificate for this site.<br>%1%") % url).str(); - - CertificateConfirmationPtr c = std::make_shared<CertificateConfirmation>(self->m_tabId, url, message); - const char *pem = ewk_certificate_policy_decision_certificate_pem_get(request); - c->setPem(std::string(pem)); - c->setData(reinterpret_cast<void*>(request)); - - // store - self->m_confirmationCertificatenMap[c] = request; - self->confirmationRequest(c); -} - -void WebView::__setCertificatePem(void* data , Evas_Object* /* obj */, void* event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - auto self = reinterpret_cast<WebView *>(data); - auto certInfo = static_cast<const Ewk_Certificate_Info*>(event_info); - if (!certInfo) { - BROWSER_LOGW("[%s:%d] Wrong event_info!", __PRETTY_FUNCTION__, __LINE__); - return; - } - - std::string url = tools::extractDomain(self->getURI()); - const char* pem = ewk_certificate_info_pem_get(certInfo); - if (pem) { - Eina_Bool valid = ewk_certificate_info_is_context_secure(certInfo); - if (valid) - self->setCertificatePem(url, std::string(pem)); - else - self->setWrongCertificatePem(url, std::string(pem)); - } -} + void + WebView::setURI(const std::string & uri) + { + BROWSER_LOGD("[%s:%d] uri=%s", __PRETTY_FUNCTION__, __LINE__, + uri.c_str()); + m_faviconImage.reset(); + ewk_view_url_set(m_ewkView, uri.c_str()); + m_loadError = false; + } + + std::string WebView::getURI(void) + { + BROWSER_LOGD("[%s:%d] uri=%s", __PRETTY_FUNCTION__, __LINE__, + ewk_view_url_get(m_ewkView)); + return fromChar(ewk_view_url_get(m_ewkView)); + } + + std::string WebView::getTitle(void) { + return m_title; + } + + std::string WebView::getUserAgent() { + return fromChar(ewk_view_user_agent_get(m_ewkView)); + } + + void + WebView::setUserAgent(const std::string & ua) + { + ewk_view_user_agent_set(m_ewkView, ua.c_str()); + } + + void + WebView::suspend() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkView); + + ewk_view_suspend(m_ewkView); + m_suspended = true; + } + + void + WebView::resume() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkView); + + ewk_view_resume(m_ewkView); + m_suspended = false; + } + + void + WebView::stopLoading(void) + { + m_isLoading = false; + ewk_view_stop(m_ewkView); + loadStop(); + } + + void + WebView::reload(void) + { + m_isLoading = true; + if (m_loadError) { + m_loadError = false; + ewk_view_url_set(m_ewkView, ewk_view_url_get(m_ewkView)); + } else { + ewk_view_reload(m_ewkView); + } + } + + void + WebView::back(void) + { + m_loadError = false; + ewk_view_back(m_ewkView); + } + + void + WebView::forward(void) + { + m_loadError = false; + ewk_view_forward(m_ewkView); + } + + bool + WebView::isBackEnabled(void) + { + return ewk_view_back_possible(m_ewkView); + } + + bool + WebView::isForwardEnabled(void) + { + return ewk_view_forward_possible(m_ewkView); + } + + bool + WebView::isLoading() + { + return m_isLoading; + } + + bool + WebView::isLoadError() const + { + return + m_loadError; + } + + void + WebView::confirmationResult(WebConfirmationPtr confirmation) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + if (confirmation->getConfirmationType() == + WebConfirmation::ConfirmationType::CertificateConfirmation) { + //FIXME: https://bugs.tizen.org/jira/browse/TT-229 + CertificateConfirmationPtr + cert = + std::dynamic_pointer_cast < CertificateConfirmation, + WebConfirmation > (confirmation); + + // The below line doesn't serve any purpose now, but it may become + // relevant when implementing https://bugs.tizen.org/jira/browse/TT-229 + Ewk_Certificate_Policy_Decision * + request = m_confirmationCertificatenMap[cert]; + Eina_Bool + result; + + if (cert->getResult() == + WebConfirmation::ConfirmationResult::Confirmed) { + result = EINA_TRUE; + } else if (cert->getResult() == + WebConfirmation::ConfirmationResult::Rejected) { + result = EINA_FALSE; + } else { + BROWSER_LOGE("Wrong ConfirmationResult"); + return; + } + + // set certificate confirmation + ewk_certificate_policy_decision_allowed_set(request, result); + resume(); + + // remove from map + m_confirmationCertificatenMap.erase(cert); + } else { + BROWSER_LOGW("[%s:%d] Unknown WebConfirmation::ConfirmationType!", + __PRETTY_FUNCTION__, __LINE__); + } + } + + tools::BrowserImagePtr WebView::captureSnapshot(int targetWidth, + int targetHeight, + bool async, + tizen_browser::tools:: + SnapshotType + snapshot_type) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkView); + M_ASSERT(targetWidth); + M_ASSERT(targetHeight); + Evas_Coord + vw, + vh; + evas_object_geometry_get(m_ewkView, nullptr, nullptr, &vw, &vh); + if (vw == 0 || vh == 0) + return std::make_shared < BrowserImage > (); + + double + scale = targetWidth / (double) (vw * getZoomFactor()); + double + scale_max, + scale_min; + ewk_view_scale_range_get(m_ewkView, &scale_min, &scale_max); + if (scale < scale_min) + scale = scale_min; + else if (scale > scale_max) + scale = scale_max; + + Eina_Rectangle + area; + double + snapshotProportions = + (double) (targetWidth) / (double) (targetHeight); + double + webkitProportions = (double) (vw) / (double) (vh); + if (webkitProportions >= snapshotProportions) { + // centring position of screenshot + area.x = + (vw * getZoomFactor() / 2) - + (vh * getZoomFactor() * snapshotProportions / 2); + area.y = 0; + area.w = vh * getZoomFactor() * snapshotProportions; + area.h = vh * getZoomFactor(); + } else { + area.x = 0; + area.y = 0; + area.w = vw * getZoomFactor(); + area.h = vw * getZoomFactor() / snapshotProportions; + } + if (area.w == 0 || area.h == 0) + return std::make_shared < BrowserImage > (); + + BROWSER_LOGD + ("[%s:%d] Before snapshot (screenshot) - look at the time of taking snapshot below", + __func__, __LINE__); + + if (async) { + SnapshotItemData * + snapshot_data = new SnapshotItemData(); + snapshot_data->web_view = this; + snapshot_data->snapshot_type = snapshot_type; + bool + result = + ewk_view_screenshot_contents_get_async(m_ewkView, area, scale, + evas_object_evas_get + (m_ewkView), + __screenshotCaptured, + snapshot_data); + if (!result) + BROWSER_LOGD + ("[%s:%d] ewk_view_screenshot_contents_get_async API failed", + __func__, __LINE__); + } else { + Evas_Object * + snapshot = + ewk_view_screenshot_contents_get(m_ewkView, area, scale, + evas_object_evas_get(m_ewkView)); + BROWSER_LOGD + ("[%s:%d] Snapshot (screenshot) catched, evas pointer: %p", + __func__, __LINE__, snapshot); + if (snapshot) + return std::make_shared < tools::BrowserImage > (snapshot); + } + + return std::make_shared < BrowserImage > (); + } + + void + WebView::__screenshotCaptured(Evas_Object * image, void *data) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + SnapshotItemData * + snapshot_data = static_cast < SnapshotItemData * >(data); + snapshot_data->web_view->snapshotCaptured(std::make_shared < + tools::BrowserImage > + (image), + snapshot_data-> + snapshot_type); + } + + void + WebView::__newWindowRequest(void *data, Evas_Object *, void *out) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + BROWSER_LOGD("[%s:%d] self=%p", __PRETTY_FUNCTION__, __LINE__, self); + BROWSER_LOGD("Window creating in tab: %s", + self->getTabId().toString().c_str()); + std::shared_ptr < basic_webengine::AbstractWebEngine < + Evas_Object >> m_webEngine; + m_webEngine = + std::dynamic_pointer_cast < basic_webengine::AbstractWebEngine < + Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); + M_ASSERT(m_webEngine); + + /// \todo: Choose newly created tab. + TabId + id(TabId::NONE); + TabId + currentTabId = m_webEngine->currentTabId(); + if (currentTabId != (id = m_webEngine->addTab(std::string(), + &self->getTabId(), + boost::none, + std::string(), + self->isDesktopMode(), + self->isPrivateMode(), + currentTabId.get()))) { + BROWSER_LOGD("Created tab: %s", id.toString().c_str()); + Evas_Object * + tab_ewk_view = m_webEngine->getTabView(id); + *static_cast < Evas_Object ** >(out) = tab_ewk_view; + + // switch to a new tab + m_webEngine->switchToTab(id); + m_webEngine->windowCreated(); + } + } + + void + WebView::__closeWindowRequest(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebView * + self = reinterpret_cast < WebView * >(data); + std::shared_ptr < AbstractWebEngine < Evas_Object >> m_webEngine = + std::dynamic_pointer_cast + < basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); + m_webEngine->closeTab(self->getTabId()); + } + + void + WebView::__loadStarted(void *data, Evas_Object * /* obj */ , + void * /* event_info */ ) + { + WebView * + self = reinterpret_cast < WebView * >(data); + + BROWSER_LOGD("%s:%d\n\t %s", __func__, __LINE__, + ewk_view_url_get(self->m_ewkView)); + + self->m_isLoading = true; + self->loadStarted(); + } + + void + WebView::__loadStop(void *data, Evas_Object * /* obj */ , + void * /* event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + self->m_isLoading = false; + + self->loadStop(); + } + + void + WebView::__loadFinished(void *data, Evas_Object * /* obj */ , + void * /* event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + + self->m_isLoading = false; + self->m_loadProgress = 1; + + self->loadFinished(); + self->loadProgress(self->m_loadProgress); + + self->captureSnapshot(boost::any_cast < + int >(config::Config::getInstance(). + get(CONFIG_KEY:: + HISTORY_TAB_SERVICE_THUMB_WIDTH)), + boost::any_cast < + int >(tizen_browser::config::Config:: + getInstance(). + get(CONFIG_KEY:: + HISTORY_TAB_SERVICE_THUMB_HEIGHT)), + true, tools::SnapshotType::ASYNC_LOAD_FINISHED); + + self->setFocus(); + } + + void + WebView::__loadProgress(void *data, Evas_Object * /* obj */ , + void *event_info) + { + WebView * + self = reinterpret_cast < WebView * >(data); + if (!self->isLoading()) + return; + + self->m_loadProgress = *(double *) event_info; + self->loadProgress(self->m_loadProgress); + } + + void + WebView::__loadError(void *data, Evas_Object * obj, void *ewkError) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + Ewk_Error * + error = reinterpret_cast < Ewk_Error * >(ewkError); + Ewk_Error_Type + errorType = ewk_error_type_get(error); + + BROWSER_LOGD("[%s:%d] ewk_error_type: %d ", + __PRETTY_FUNCTION__, __LINE__, errorType); + + BROWSER_LOGD("[%s:%d] emiting signal ", __PRETTY_FUNCTION__, + __LINE__); + int + errorCode = ewk_error_code_get(error); + if (errorCode == EWK_ERROR_NETWORK_STATUS_CANCELLED) { + BROWSER_LOGD("Stop signal emitted"); + BROWSER_LOGD("Error description: %s", + ewk_error_description_get(error)); + evas_object_smart_callback_call(obj, "load,stop", nullptr); + } else { + self->loadError(); + self->m_loadError = true; + } + } + + void + WebView::__titleChanged(void *data, Evas_Object * obj, + void * /* event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + self->m_title = fromChar(ewk_view_title_get(obj)); + self->titleChanged(self->m_title); + } + + void + WebView::__urlChanged(void *data, Evas_Object * /* obj */ , + void * /* event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + BROWSER_LOGD("URL changed for tab: %s", + self->getTabId().toString().c_str()); + self->uriChanged(self->getURI()); + } + + void + WebView::__backForwardListChanged(void *data, Evas_Object * /* obj */ , + void * /* event_info */ ) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + self->backwardEnableChanged(self->isBackEnabled()); + self->forwardEnableChanged(self->isForwardEnabled()); + } + + void + WebView::__faviconChanged(void *data, Evas_Object *, void *) + { + if (data) { + WebView * + self = static_cast < WebView * >(data); + Evas_Object * + favicon = + ewk_context_icon_database_icon_object_add(self->m_ewkContext, + ewk_view_url_get(self-> + m_ewkView), + evas_object_evas_get + (self->m_ewkView)); + if (favicon) { + BROWSER_LOGD("[%s:%d] Favicon received", __PRETTY_FUNCTION__, + __LINE__); + self->m_faviconImage = + std::make_shared < tools::BrowserImage > (favicon); + evas_object_del(favicon); + self->favIconChanged(self->m_faviconImage); + } + } + } + + void + WebView::__IMEClosed(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("%s", __func__); + WebView * + self = reinterpret_cast < WebView * >(data); + self->IMEStateChanged(false); + } + + void + WebView::__IMEOpened(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("%s", __func__); + WebView * + self = reinterpret_cast < WebView * >(data); + self->IMEStateChanged(true); + } + + void + WebView::__load_provisional_started(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebView * + self = reinterpret_cast < WebView * >(data); + self->setRedirectedURL(self->getURI()); + } + + void + WebView::__load_provisional_redirect(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebView * + self = reinterpret_cast < WebView * >(data); + if (!self->getRedirectedURL().empty()) + self->redirectedWebPage(self->getRedirectedURL(), self->getURI()); + self->setRedirectedURL(""); + } + + void + WebView::__requestCertificationConfirm(void *data, + Evas_Object * /* obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + Ewk_Certificate_Policy_Decision * + request = + reinterpret_cast < Ewk_Certificate_Policy_Decision * >(event_info); + if (!request) { + BROWSER_LOGW("[%s:%d] Wrong event_info!", __PRETTY_FUNCTION__, + __LINE__); + return; + } + + int + error = ewk_certificate_policy_decision_error_get(request); + if (error == + EWK_CERTIFICATE_POLICY_DECISION_ERROR_PINNED_KEY_NOT_IN_CHAIN) { + ewk_certificate_policy_decision_allowed_set(request, EINA_FALSE); + BROWSER_LOGW + ("[%s:%d] EWK_CERTIFICATE_POLICY_DECISION_ERROR_PINNED_KEY_NOT_IN_CHAIN", + __PRETTY_FUNCTION__, __LINE__); + self->unsecureConnection(); + return; + } + + self->suspend(); + ewk_certificate_policy_decision_suspend(request); + + std::string url = tools::extractDomain(self->m_loadingURL); + + ///\todo add translations + std::string message = + (boost:: + format + ("There are problems with the security certificate for this site.<br>%1%") + % url).str(); + + CertificateConfirmationPtr + c = + std::make_shared < CertificateConfirmation > (self->m_tabId, url, + message); + const char * + pem = ewk_certificate_policy_decision_certificate_pem_get(request); + c->setPem(std::string(pem)); + c->setData(reinterpret_cast < void *>(request)); + + // store + self->m_confirmationCertificatenMap[c] = request; + self->confirmationRequest(c); + } + + void + WebView::__setCertificatePem(void *data, Evas_Object * /* obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + auto + self = reinterpret_cast < WebView * >(data); + auto + certInfo = static_cast < const + Ewk_Certificate_Info * >(event_info); + if (!certInfo) { + BROWSER_LOGW("[%s:%d] Wrong event_info!", __PRETTY_FUNCTION__, + __LINE__); + return; + } + + std::string url = tools::extractDomain(self->getURI()); + const char * + pem = ewk_certificate_info_pem_get(certInfo); + if (pem) { + Eina_Bool + valid = ewk_certificate_info_is_context_secure(certInfo); + if (valid) + self->setCertificatePem(url, std::string(pem)); + else + self->setWrongCertificatePem(url, std::string(pem)); + } + } #if PROFILE_MOBILE -context_menu_type WebView::_get_menu_type(Ewk_Context_Menu *menu) -{ - int count = ewk_context_menu_item_count(menu); - bool text = false; - bool link = false; - bool image = false; - bool selection_mode = false; - bool call_number = false; - bool email_address = false; - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item *item = ewk_context_menu_nth_item_get(menu, i); - Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item); - const char *link_url = ewk_context_menu_item_image_url_get(item); - BROWSER_LOGD("tag=%d", tag); - - if (link_url && !strncmp(MAILTO_SCHEME, link_url, strlen(MAILTO_SCHEME))) - email_address = true; - if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) - call_number = true; - if (tag == EWK_CONTEXT_MENU_ITEM_TAG_TEXT_SELECTION_MODE) - selection_mode = true; - if (tag == EWK_CONTEXT_MENU_ITEM_TAG_CLIPBOARD) - return INPUT_FIELD; - if (tag == EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB) - text = true; - if (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW || tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD) - link = true; - if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD) - image = true; - } - - if (email_address && selection_mode) - return EMAIL_LINK; - if (call_number && selection_mode) - return TEL_LINK; - if (text && !link) - return TEXT_ONLY; - if (link && !image) - return TEXT_LINK; - if (image && !link) - return IMAGE_ONLY; - if (selection_mode && image && link) - return TEXT_IMAGE_LINK; - if (image && link) - return IMAGE_LINK; - - return UNKNOWN_MENU; -} - -void WebView::_show_context_menu_text_link(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item * item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Open */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK, _("IDS_BR_OPT_OPEN"), true); - /* Open in new window */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, _("IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation - /* Copy link text */ - //ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_DATA, _("IDS_BR_OPT_COPY_TO_CLIPBOARD"), true); //TODO: missing translation - /* Copy link address */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation - ///* Share Link */ - //ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SHARE_LINK, "Share Link", true); //TODO: missing translation - /* Save link */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, _("IDS_BR_OPT_SAVE_LINK"), true); -} - -void WebView::_show_context_menu_email_address(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item * item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Send email */ - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_EMAIL, "Send email", true); //TODO: missing translation - /* Add to contact */ - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT, "Add to contacts", true); //TODO: missing translation - /* Copy link address */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation -} - -void WebView::_show_context_menu_call_number(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item * item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Call */ - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_CALL, "Call", true); //TODO: missing translation - /* Send message */ - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_MESSAGE, "Send message", true); //TODO: missing translation - /* Add to contact */ - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT, "Add to contacts", true); //TODO: missing translation - /* Copy link address */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation -} - -void WebView::_show_context_menu_text_only(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - const char *selected_text = ewk_view_text_selection_text_get(m_ewkView); - bool text_selected = false; - if (selected_text && strlen(selected_text) > 0) - text_selected = true; - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item *item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Select all */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, _("IDS_BR_OPT_SELECT_ALL"), true); - /* Copy */ - if (text_selected == true) { - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY, _("IDS_BR_OPT_COPY"), true); - } - /* Share*/ - if (text_selected == true) { - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SHARE, _("IDS_BR_OPT_SHARE"), true); - } - /* Web Search*/ - if (text_selected == true) { - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB, _("IDS_BR_OPT_WEB_SEARCH"), true); - } - /* Find on page*/ - if (text_selected == true) { - ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_PAGE, _("IDS_BR_OPT_FIND_ON_PAGE_ABB"), true); - } -} - -void WebView::_show_context_menu_image_only(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item *item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - /* Save image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, _("IDS_BR_OPT_SAVE_IMAGE"), true); //TODO: missing translation - /* Copy image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_IMAGE"), true); - /* View Image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation -} - -void WebView::_show_context_menu_text_image_link(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - const char *selected_text = ewk_view_text_selection_text_get(m_ewkView); - bool text_selected = false; - if (selected_text && strlen(selected_text) > 0) - text_selected = true; - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item *item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Open in current Tab */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation - /* Open in New Tab */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW,_( "IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation - /* Select all */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, _("IDS_BR_OPT_SELECT_ALL"), true); - /* Copy */ - if (text_selected == true) - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY, _("IDS_BR_OPT_COPY"), true); - /* Share*/ - if (text_selected == true) - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SMART_LINKS, _("IDS_BR_OPT_SHARE"), true); - /* Copy link */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation - /* Save link */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, _("IDS_BR_OPT_SAVE_LINK"), true); - /* Copy image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_IMAGE"), true); - /* Downlad image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, _("IDS_BR_OPT_SAVE_IMAGE"), true); -} - -void WebView::_show_context_menu_image_link(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - int count = ewk_context_menu_item_count(menu); - - for (int i = 0 ; i < count ; i++) { - Ewk_Context_Menu_Item *item = ewk_context_menu_nth_item_get(menu, 0); - ewk_context_menu_item_remove(menu, item); - } - - /* Open link in new window */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, _("IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation - /* Save link */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, _("IDS_BR_OPT_SAVE_LINK"), true); - /* Copy link */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation - /* Save image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, _("IDS_BR_OPT_SAVE_IMAGE"), true); //TODO: missing translation - /* copy image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_IMAGE"), true); - /* View image */ - ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation -} - -void WebView::_customize_context_menu(Ewk_Context_Menu *menu) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - context_menu_type menu_type = _get_menu_type(menu); - BROWSER_LOGD("menu_type=%d", menu_type); - - if (menu_type == UNKNOWN_MENU || menu_type == INPUT_FIELD) - return; - - switch (menu_type) { - case TEXT_ONLY: - _show_context_menu_text_only(menu); - break; - - case TEXT_LINK: - _show_context_menu_text_link(menu); - break; - - case EMAIL_LINK: - _show_context_menu_email_address(menu); - break; - - case TEL_LINK: - _show_context_menu_call_number(menu); - break; - - case IMAGE_ONLY: - _show_context_menu_image_only(menu); - break; - - case IMAGE_LINK: - _show_context_menu_image_link(menu); - break; - - case TEXT_IMAGE_LINK: - _show_context_menu_text_image_link(menu); - break; - - default: - BROWSER_LOGD("[%s:%d] Warning: Unhandled button.", __PRETTY_FUNCTION__, __LINE__); - break; - } -} - -void WebView::__contextmenu_customize_cb(void *data, Evas_Object * /* obj */, void *event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - Ewk_Context_Menu *menu = reinterpret_cast<Ewk_Context_Menu*>(event_info); - WebView * self = reinterpret_cast<WebView *>(data); - - self->_customize_context_menu(menu); -} - -void WebView::__contextmenu_selected_cb(void *data, Evas_Object */*obj*/, void *event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - WebView * self = reinterpret_cast<WebView *>(data); - Ewk_Context_Menu_Item *item = reinterpret_cast<Ewk_Context_Menu_Item*>(event_info); - Ewk_Context_Menu_Item_Tag tag = ewk_context_menu_item_tag_get(item); - - const char *link_url = ewk_context_menu_item_link_url_get(item); - const char *selected_text = ewk_view_text_selection_text_get(self->m_ewkView); - - if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_EMAIL) { - self->handle_scheme(link_url); - } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_CALL) { - self->handle_scheme(link_url); - } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_PAGE) { - self->findOnPage(selected_text); - } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_MESSAGE) { - if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) { - std::string::size_type pos = std::string::npos; - std::string source = std::string(link_url); - while ((pos = source.find(TEL_SCHEME)) != std::string::npos) - source.replace(pos, strlen(TEL_SCHEME), SMS_SCHEME); - self->handle_scheme(source.c_str()); - } - } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT) { - if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) { - self->launch_contact(link_url + strlen(TEL_SCHEME), "tel"); - } else if (link_url && !strncmp(MAILTO_SCHEME, link_url, strlen(MAILTO_SCHEME))) { - size_t source_end_pos = 0; - std::string source = std::string(link_url); - if (source.find("?") != std::string::npos) { - source_end_pos = source.find("?"); - source = source.substr(0, source_end_pos); - } - self->launch_contact(source.c_str() + strlen(MAILTO_SCHEME), "mailto"); - } - } -} - -void WebView::__fullscreen_enter_cb(void *data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - auto self = static_cast<WebView*>(data); - self->m_fullscreen = true; - self->fullscreenModeSet(self->m_fullscreen); -} - -void WebView::__fullscreen_exit_cb(void *data, Evas_Object*, void*) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - auto self = static_cast<WebView*>(data); - self->m_fullscreen = false; - self->fullscreenModeSet(self->m_fullscreen); -} - -void WebView::__rotate_prepared_cb(void * data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data) { - auto *self = static_cast<WebView *>(data); - self->rotatePrepared(); - } else { - BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); - } -} + context_menu_type + WebView::_get_menu_type(Ewk_Context_Menu * menu) + { + int + count = ewk_context_menu_item_count(menu); + bool + text = false; + bool + link = false; + bool + image = false; + bool + selection_mode = false; + bool + call_number = false; + bool + email_address = false; + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, i); + Ewk_Context_Menu_Item_Tag + tag = ewk_context_menu_item_tag_get(item); + const char * + link_url = ewk_context_menu_item_image_url_get(item); + BROWSER_LOGD("tag=%d", tag); + + if (link_url + && !strncmp(MAILTO_SCHEME, link_url, strlen(MAILTO_SCHEME))) + email_address = true; + if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) + call_number = true; + if (tag == EWK_CONTEXT_MENU_ITEM_TAG_TEXT_SELECTION_MODE) + selection_mode = true; + if (tag == EWK_CONTEXT_MENU_ITEM_TAG_CLIPBOARD) + return INPUT_FIELD; + if (tag == EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB) + text = true; + if (tag == EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW + || tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD) + link = true; + if (tag == EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD) + image = true; + } + + if (email_address && selection_mode) + return EMAIL_LINK; + if (call_number && selection_mode) + return TEL_LINK; + if (text && !link) + return TEXT_ONLY; + if (link && !image) + return TEXT_LINK; + if (image && !link) + return IMAGE_ONLY; + if (selection_mode && image && link) + return TEXT_IMAGE_LINK; + if (image && link) + return IMAGE_LINK; + + return UNKNOWN_MENU; + } + + void + WebView::_show_context_menu_text_link(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Open */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK, + _("IDS_BR_OPT_OPEN"), true); + /* Open in new window */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, _("IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation + /* Copy link text */ + //ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_DATA, _("IDS_BR_OPT_COPY_TO_CLIPBOARD"), true); //TODO: missing translation + /* Copy link address */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation + ///* Share Link */ + //ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_SHARE_LINK, "Share Link", true); //TODO: missing translation + /* Save link */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, + _("IDS_BR_OPT_SAVE_LINK"), + true); + } + + void + WebView::_show_context_menu_email_address(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Send email */ + ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_EMAIL, "Send email", true); //TODO: missing translation + /* Add to contact */ + ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT, "Add to contacts", true); //TODO: missing translation + /* Copy link address */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation + } + + void + WebView::_show_context_menu_call_number(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Call */ + ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_CALL, "Call", true); //TODO: missing translation + /* Send message */ + ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_MESSAGE, "Send message", true); //TODO: missing translation + /* Add to contact */ + ewk_context_menu_item_append_as_action(menu, CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT, "Add to contacts", true); //TODO: missing translation + /* Copy link address */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation + } + + void + WebView::_show_context_menu_text_only(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + const char * + selected_text = ewk_view_text_selection_text_get(m_ewkView); + bool + text_selected = false; + if (selected_text && strlen(selected_text) > 0) + text_selected = true; + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Select all */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, + _("IDS_BR_OPT_SELECT_ALL"), + true); + /* Copy */ + if (text_selected == true) { + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_COPY, + _("IDS_BR_OPT_COPY"), true); + } + /* Share */ + if (text_selected == true) { + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_SHARE, + _("IDS_BR_OPT_SHARE"), true); + } + /* Web Search */ + if (text_selected == true) { + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB, + _("IDS_BR_OPT_WEB_SEARCH"), + true); + } + /* Find on page */ + if (text_selected == true) { + ewk_context_menu_item_append_as_action(menu, + CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_PAGE, + _ + ("IDS_BR_OPT_FIND_ON_PAGE_ABB"), + true); + } + } + + void + WebView::_show_context_menu_image_only(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + /* Save image */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, _("IDS_BR_OPT_SAVE_IMAGE"), true); //TODO: missing translation + /* Copy image */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, + _("IDS_BR_OPT_COPY_IMAGE"), + true); + /* View Image */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation + } + + void + WebView::_show_context_menu_text_image_link(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + const char * + selected_text = ewk_view_text_selection_text_get(m_ewkView); + bool + text_selected = false; + if (selected_text && strlen(selected_text) > 0) + text_selected = true; + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Open in current Tab */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation + /* Open in New Tab */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_NEW_WINDOW, _("IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation + /* Select all */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, + _("IDS_BR_OPT_SELECT_ALL"), + true); + /* Copy */ + if (text_selected == true) + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_COPY, + _("IDS_BR_OPT_COPY"), true); + /* Share */ + if (text_selected == true) + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_SMART_LINKS, + _("IDS_BR_OPT_SHARE"), true); + /* Copy link */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation + /* Save link */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, + _("IDS_BR_OPT_SAVE_LINK"), + true); + /* Copy image */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, + _("IDS_BR_OPT_COPY_IMAGE"), + true); + /* Downlad image */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, + _("IDS_BR_OPT_SAVE_IMAGE"), + true); + } + + void + WebView::_show_context_menu_image_link(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + int + count = ewk_context_menu_item_count(menu); + + for (int i = 0; i < count; i++) { + Ewk_Context_Menu_Item * + item = ewk_context_menu_nth_item_get(menu, 0); + ewk_context_menu_item_remove(menu, item); + } + + /* Open link in new window */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_LINK_IN_NEW_WINDOW, _("IDS_BR_OPT_OPEN_IN_NEW_WINDOW_ABB"), true); //TODO: missing translation + /* Save link */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_LINK_TO_DISK, + _("IDS_BR_OPT_SAVE_LINK"), + true); + /* Copy link */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_COPY_LINK_TO_CLIPBOARD, _("IDS_BR_OPT_COPY_LINK_URL"), true); //TODO: missing translation + /* Save image */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_DOWNLOAD_IMAGE_TO_DISK, _("IDS_BR_OPT_SAVE_IMAGE"), true); //TODO: missing translation + /* copy image */ + ewk_context_menu_item_append_as_action(menu, + EWK_CONTEXT_MENU_ITEM_TAG_COPY_IMAGE_TO_CLIPBOARD, + _("IDS_BR_OPT_COPY_IMAGE"), + true); + /* View image */ + ewk_context_menu_item_append_as_action(menu, EWK_CONTEXT_MENU_ITEM_TAG_OPEN_IMAGE_IN_CURRENT_WINDOW, _("IDS_BR_BODY_VIEW_IMAGE"), true); //TODO: missing translation + } + + void + WebView::_customize_context_menu(Ewk_Context_Menu * menu) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + context_menu_type + menu_type = _get_menu_type(menu); + BROWSER_LOGD("menu_type=%d", menu_type); + + if (menu_type == UNKNOWN_MENU || menu_type == INPUT_FIELD) + return; + + switch (menu_type) { + case TEXT_ONLY: + _show_context_menu_text_only(menu); + break; + + case TEXT_LINK: + _show_context_menu_text_link(menu); + break; + + case EMAIL_LINK: + _show_context_menu_email_address(menu); + break; + + case TEL_LINK: + _show_context_menu_call_number(menu); + break; + + case IMAGE_ONLY: + _show_context_menu_image_only(menu); + break; + + case IMAGE_LINK: + _show_context_menu_image_link(menu); + break; + + case TEXT_IMAGE_LINK: + _show_context_menu_text_image_link(menu); + break; + + default: + BROWSER_LOGD("[%s:%d] Warning: Unhandled button.", + __PRETTY_FUNCTION__, __LINE__); + break; + } + } + + void + WebView::__contextmenu_customize_cb(void *data, + Evas_Object * /* obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + Ewk_Context_Menu * + menu = reinterpret_cast < Ewk_Context_Menu * >(event_info); + WebView * + self = reinterpret_cast < WebView * >(data); + + self->_customize_context_menu(menu); + } + + void + WebView::__contextmenu_selected_cb(void *data, Evas_Object * /*obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + WebView * + self = reinterpret_cast < WebView * >(data); + Ewk_Context_Menu_Item * + item = reinterpret_cast < Ewk_Context_Menu_Item * >(event_info); + Ewk_Context_Menu_Item_Tag + tag = ewk_context_menu_item_tag_get(item); + + const char * + link_url = ewk_context_menu_item_link_url_get(item); + const char * + selected_text = ewk_view_text_selection_text_get(self->m_ewkView); + + if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_EMAIL) { + self->handle_scheme(link_url); + } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_CALL) { + self->handle_scheme(link_url); + } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_FIND_ON_PAGE) { + self->findOnPage(selected_text); + } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_MESSAGE) { + if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) { + std::string::size_type pos = std::string::npos; + std::string source = std::string(link_url); + while ((pos = source.find(TEL_SCHEME)) != std::string::npos) + source.replace(pos, strlen(TEL_SCHEME), SMS_SCHEME); + self->handle_scheme(source.c_str()); + } + } else if (tag == CUSTOM_CONTEXT_MENU_ITEM_SEND_ADD_TO_CONTACT) { + if (link_url && !strncmp(TEL_SCHEME, link_url, strlen(TEL_SCHEME))) { + self->launch_contact(link_url + strlen(TEL_SCHEME), "tel"); + } else if (link_url + && !strncmp(MAILTO_SCHEME, link_url, + strlen(MAILTO_SCHEME))) { + size_t + source_end_pos = 0; + std::string source = std::string(link_url); + if (source.find("?") != std::string::npos) { + source_end_pos = source.find("?"); + source = source.substr(0, source_end_pos); + } + self->launch_contact(source.c_str() + strlen(MAILTO_SCHEME), + "mailto"); + } + } + } + + void + WebView::__fullscreen_enter_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + auto + self = static_cast < WebView * >(data); + self->m_fullscreen = true; + self->fullscreenModeSet(self->m_fullscreen); + } + + void + WebView::__fullscreen_exit_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + auto + self = static_cast < WebView * >(data); + self->m_fullscreen = false; + self->fullscreenModeSet(self->m_fullscreen); + } + + void + WebView::__rotate_prepared_cb(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data) { + auto * + self = static_cast < WebView * >(data); + self->rotatePrepared(); + } else { + BROWSER_LOGW("[%s] data = nullptr", __PRETTY_FUNCTION__); + } + } #endif -void WebView::setFocus() -{ - ewk_view_focus_set(m_ewkView, EINA_TRUE); -} - -void WebView::clearFocus() -{ - ewk_view_focus_set(m_ewkView, EINA_FALSE); -} - -bool WebView::hasFocus() const -{ - return ewk_view_focus_get(m_ewkView) == EINA_TRUE ? true : false; -} - -double WebView::getZoomFactor() const -{ - if(EINA_UNLIKELY(m_ewkView == nullptr)) { - return 1.0; - } - - return ewk_view_page_zoom_get(m_ewkView); -} - -void WebView::setZoomFactor(double zoomFactor) -{ - if (m_ewkView) { - //using zoomFactor = 0 sets zoom "fit to screen" - - if (zoomFactor != getZoomFactor()) - ewk_view_page_zoom_set(m_ewkView, zoomFactor); - } -} - -void WebView::scrollView(const int& dx, const int& dy) -{ - ewk_view_scroll_by(m_ewkView, dx, dy); -} + void + WebView::setFocus() + { + ewk_view_focus_set(m_ewkView, EINA_TRUE); + } + + void + WebView::clearFocus() + { + ewk_view_focus_set(m_ewkView, EINA_FALSE); + } + + bool + WebView::hasFocus() const + { + return + ewk_view_focus_get(m_ewkView) == EINA_TRUE ? true : false; + } + + double + WebView::getZoomFactor() const + { + if (EINA_UNLIKELY(m_ewkView == nullptr)) { + return 1.0; + } + + return + ewk_view_page_zoom_get(m_ewkView); + } + + void + WebView::setZoomFactor(double zoomFactor) + { + if (m_ewkView) { + //using zoomFactor = 0 sets zoom "fit to screen" + + if (zoomFactor != getZoomFactor()) + ewk_view_page_zoom_set(m_ewkView, zoomFactor); + } + } + + void + WebView::scrollView(const int &dx, const int &dy) + { + ewk_view_scroll_by(m_ewkView, dx, dy); + } #if PROFILE_MOBILE -void WebView::findWord(const char *word, Eina_Bool forward, Evas_Smart_Cb found_cb, void *data) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!word || strlen(word) == 0) { - ewk_view_text_find_highlight_clear(m_ewkView); - return; - } - - evas_object_smart_callback_del(m_ewkView, "text,found", found_cb); - evas_object_smart_callback_add(m_ewkView, "text,found", found_cb, data); - - Ewk_Find_Options find_option = (Ewk_Find_Options)(EWK_FIND_OPTIONS_CASE_INSENSITIVE | EWK_FIND_OPTIONS_WRAP_AROUND - | EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR | EWK_FIND_OPTIONS_SHOW_HIGHLIGHT); - - if (!forward) - find_option = (Ewk_Find_Options)(find_option | EWK_FIND_OPTIONS_BACKWARDS); - - ewk_view_text_find(m_ewkView, word, find_option, FIND_WORD_MAX_COUNT); -} - -void WebView::ewkSettingsAutoFittingSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_auto_fitting_set(settings, value); -} - -void WebView::ewkSettingsLoadsImagesSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_loads_images_automatically_set(settings, value); -} - -void WebView::ewkSettingsJavascriptEnabledSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_javascript_enabled_set(settings, value); -} - -void WebView::ewkSettingsFormCandidateDataEnabledSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_form_candidate_data_enabled_set(settings, value); -} - -void WebView::ewkSettingsAutofillPasswordFormEnabledSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_autofill_password_form_enabled_set(settings, value); -} - -bool WebView::clearTextSelection() const { - return ewk_view_text_selection_clear(m_ewkView); -} - -bool WebView::exitFullScreen() const { - return ewk_view_fullscreen_exit(m_ewkView); -} - -void WebView::ewkSettingsFormProfileDataEnabledSet(bool value) -{ - Ewk_Settings* settings = ewk_view_settings_get(m_ewkView); - ewk_settings_form_profile_data_enabled_set(settings, value); -} + void + WebView::findWord(const char *word, Eina_Bool forward, + Evas_Smart_Cb found_cb, void *data) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!word || strlen(word) == 0) { + ewk_view_text_find_highlight_clear(m_ewkView); + return; + } + + evas_object_smart_callback_del(m_ewkView, "text,found", found_cb); + evas_object_smart_callback_add(m_ewkView, "text,found", found_cb, + data); + + Ewk_Find_Options + find_option = + (Ewk_Find_Options) (EWK_FIND_OPTIONS_CASE_INSENSITIVE | + EWK_FIND_OPTIONS_WRAP_AROUND | + EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR | + EWK_FIND_OPTIONS_SHOW_HIGHLIGHT); + + if (!forward) + find_option = + (Ewk_Find_Options) (find_option | EWK_FIND_OPTIONS_BACKWARDS); + + ewk_view_text_find(m_ewkView, word, find_option, FIND_WORD_MAX_COUNT); + } + + void + WebView::ewkSettingsAutoFittingSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_auto_fitting_set(settings, value); + } + + void + WebView::ewkSettingsLoadsImagesSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_loads_images_automatically_set(settings, value); + } + + void + WebView::ewkSettingsJavascriptEnabledSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_javascript_enabled_set(settings, value); + } + + void + WebView::ewkSettingsFormCandidateDataEnabledSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_form_candidate_data_enabled_set(settings, value); + } + + void + WebView::ewkSettingsAutofillPasswordFormEnabledSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_autofill_password_form_enabled_set(settings, value); + } + + bool + WebView::clearTextSelection() const + { + return + ewk_view_text_selection_clear(m_ewkView); + } + + bool + WebView::exitFullScreen() const + { + return + ewk_view_fullscreen_exit(m_ewkView); + } + + void + WebView::ewkSettingsFormProfileDataEnabledSet(bool value) + { + Ewk_Settings * + settings = ewk_view_settings_get(m_ewkView); + ewk_settings_form_profile_data_enabled_set(settings, value); + } #endif -const TabId& WebView::getTabId() { - return m_tabId; -} - - -tools::BrowserImagePtr WebView::getFavicon() -{ - BROWSER_LOGD("%s:%d, TabId: %s", __PRETTY_FUNCTION__, __LINE__, m_tabId.toString().c_str()); - return m_faviconImage; -} - -void WebView::clearCache() -{ - BROWSER_LOGD("Clearing cache"); - M_ASSERT(m_ewkContext); - if (m_ewkContext) { - ewk_context_cache_clear(m_ewkContext); - ewk_context_application_cache_delete_all(m_ewkContext); - } -} - -void WebView::clearCookies() -{ - BROWSER_LOGD("Clearing cookies"); - M_ASSERT(m_ewkContext); - if (m_ewkContext) - ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(m_ewkContext)); -} - -void WebView::clearPrivateData() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkContext); - if (m_ewkContext) { - ewk_context_cache_clear(m_ewkContext); - ewk_context_web_storage_delete_all(m_ewkContext); - ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get(m_ewkContext)); - ewk_context_application_cache_delete_all(m_ewkContext); - } -} - -void WebView::clearPasswordData() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkContext); - if (m_ewkContext) - ewk_context_form_password_data_delete_all(m_ewkContext); - else - BROWSER_LOGD("[%s:%d] Warning: no context", __PRETTY_FUNCTION__, __LINE__); -} - -void WebView::clearFormData() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_ewkContext); - if (m_ewkContext) - ewk_context_form_candidate_data_delete_all(m_ewkContext); - else - BROWSER_LOGD("[%s:%d] Warning: no context", __PRETTY_FUNCTION__, __LINE__); -} - -void WebView::searchOnWebsite(const std::string & searchString, int flags) -{ - ///\todo: it should be "0" instead of "1024" for unlimited match count but it doesn't work properly in WebKit - Eina_Bool result = ewk_view_text_find(m_ewkView, searchString.c_str(), static_cast<Ewk_Find_Options>(flags), 1024); - BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), result); -} - -void WebView::switchToDesktopMode() { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT); - m_desktopMode = true; -} - -void WebView::switchToMobileMode() { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT_MOBILE); - m_desktopMode = false; -} - -bool WebView::isDesktopMode() const { - return m_desktopMode; -} + const + TabId & + WebView::getTabId() + { + return m_tabId; + } + + + tools::BrowserImagePtr WebView::getFavicon() { + BROWSER_LOGD("%s:%d, TabId: %s", __PRETTY_FUNCTION__, __LINE__, + m_tabId.toString().c_str()); + return m_faviconImage; + } + + void + WebView::clearCache() + { + BROWSER_LOGD("Clearing cache"); + M_ASSERT(m_ewkContext); + if (m_ewkContext) { + ewk_context_cache_clear(m_ewkContext); + ewk_context_application_cache_delete_all(m_ewkContext); + } + } + + void + WebView::clearCookies() + { + BROWSER_LOGD("Clearing cookies"); + M_ASSERT(m_ewkContext); + if (m_ewkContext) + ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get + (m_ewkContext)); + } + + void + WebView::clearPrivateData() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkContext); + if (m_ewkContext) { + ewk_context_cache_clear(m_ewkContext); + ewk_context_web_storage_delete_all(m_ewkContext); + ewk_cookie_manager_cookies_clear(ewk_context_cookie_manager_get + (m_ewkContext)); + ewk_context_application_cache_delete_all(m_ewkContext); + } + } + + void + WebView::clearPasswordData() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkContext); + if (m_ewkContext) + ewk_context_form_password_data_delete_all(m_ewkContext); + else + BROWSER_LOGD("[%s:%d] Warning: no context", __PRETTY_FUNCTION__, + __LINE__); + } + + void + WebView::clearFormData() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_ewkContext); + if (m_ewkContext) + ewk_context_form_candidate_data_delete_all(m_ewkContext); + else + BROWSER_LOGD("[%s:%d] Warning: no context", __PRETTY_FUNCTION__, + __LINE__); + } + + void + WebView::searchOnWebsite(const std::string & searchString, int flags) + { + ///\todo: it should be "0" instead of "1024" for unlimited match count but it doesn't work properly in WebKit + Eina_Bool + result = + ewk_view_text_find(m_ewkView, searchString.c_str(), + static_cast < Ewk_Find_Options > (flags), 1024); + BROWSER_LOGD("Ewk search; word: %s, result: %d", searchString.c_str(), + result); + } + + void + WebView::switchToDesktopMode() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + ewk_view_user_agent_set(m_ewkView, APPLICATION_NAME_FOR_USER_AGENT); + m_desktopMode = true; + } + + void + WebView::switchToMobileMode() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + ewk_view_user_agent_set(m_ewkView, + APPLICATION_NAME_FOR_USER_AGENT_MOBILE); + m_desktopMode = false; + } + + bool + WebView::isDesktopMode() const + { + return + m_desktopMode; + } #if PROFILE_MOBILE -void WebView::__policy_response_decide_cb(void *data, Evas_Object * /* obj */, void *event_info) -{ - WebView *wv = (WebView *)data; - - Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info; - Ewk_Policy_Decision_Type policy_type = ewk_policy_decision_type_get(policy_decision); - - wv->m_status_code = ewk_policy_decision_response_status_code_get(policy_decision); - wv->m_is_error_page = EINA_FALSE; - - switch (policy_type) { - case EWK_POLICY_DECISION_USE: - BROWSER_LOGD("[%s:%d] policy_use", __PRETTY_FUNCTION__, __LINE__); - ewk_policy_decision_use(policy_decision); - break; - - case EWK_POLICY_DECISION_DOWNLOAD: { - BROWSER_LOGD("[%s:%d] policy_download", __PRETTY_FUNCTION__, __LINE__); - const char *uri = ewk_policy_decision_url_get(policy_decision); - const char *content_type = ewk_policy_decision_response_mime_get(policy_decision); - const Eina_Hash *headers = ewk_policy_decision_response_headers_get(policy_decision); - app_control_h app_control = NULL; - if (app_control_create(&app_control) < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_create", __PRETTY_FUNCTION__, __LINE__); - return; - } - - if (app_control_set_operation(app_control, APP_CONTROL_OPERATION_VIEW) < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_set_operation", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return; - } - - BROWSER_LOGD("[%s:%d] uri: %s", __PRETTY_FUNCTION__, __LINE__, uri); - if (app_control_set_uri(app_control, uri) < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_set_uri", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return; - } - - BROWSER_LOGD("[%s:%d] content_type: %s", __PRETTY_FUNCTION__, __LINE__, content_type); - if (app_control_set_mime(app_control, content_type) < 0) { - BROWSER_LOGE("[%s:%d] Fail to app_control_set_mime", __PRETTY_FUNCTION__, __LINE__); - app_control_destroy(app_control); - return; - } - - const char *content_dispotision = (const char *)eina_hash_find(headers, "Content-Disposition"); - BROWSER_LOGD("[%s:%d] Content-disposition: %s", __PRETTY_FUNCTION__, __LINE__, content_dispotision); - if (content_dispotision && (strstr(content_dispotision, "attachment") != NULL)){ - wv->m_downloadControl->handle_download_request(uri, content_type); - app_control_destroy(app_control); - ewk_policy_decision_ignore(policy_decision); - break; - } - - if (app_control_send_launch_request(app_control, NULL, NULL) == APP_CONTROL_ERROR_APP_NOT_FOUND) { - BROWSER_LOGD("[%s:%d] app_control_send_launch_request returns APP_CONTROL_ERROR_APP_NOT_FOUND", __PRETTY_FUNCTION__, __LINE__); - wv->m_downloadControl->handle_download_request(uri, content_type); - } - app_control_destroy(app_control); - ewk_policy_decision_ignore(policy_decision); - break; - } - case EWK_POLICY_DECISION_IGNORE: - default: - BROWSER_LOGD("[%s:%d] policy_ignore", __PRETTY_FUNCTION__, __LINE__); - ewk_policy_decision_ignore(policy_decision); - break; - } -} - -void WebView::__policy_navigation_decide_cb(void *data, Evas_Object * /*obj*/, void *event_info) -{ - BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); - WebView *wv = (WebView *)data; - - Ewk_Policy_Decision *policy_decision = (Ewk_Policy_Decision *)event_info; - const char *uri = ewk_policy_decision_url_get(policy_decision); - wv->m_loadingURL = std::string(uri); - BROWSER_LOGD("uri = [%s]", uri); - - Eina_Bool is_scheme_handled = wv->handle_scheme(uri); - - if (is_scheme_handled) { - BROWSER_LOGD("Scheme handled"); - ewk_policy_decision_ignore(policy_decision); - if (!wv->isBackEnabled()) - wv = NULL; - return; - } - ewk_policy_decision_use(policy_decision); -} + void + WebView::__policy_response_decide_cb(void *data, + Evas_Object * /* obj */ , + void *event_info) + { + WebView * + wv = (WebView *) data; + + Ewk_Policy_Decision * + policy_decision = (Ewk_Policy_Decision *) event_info; + Ewk_Policy_Decision_Type + policy_type = ewk_policy_decision_type_get(policy_decision); + + wv->m_status_code = + ewk_policy_decision_response_status_code_get(policy_decision); + wv->m_is_error_page = EINA_FALSE; + + switch (policy_type) { + case EWK_POLICY_DECISION_USE: + BROWSER_LOGD("[%s:%d] policy_use", __PRETTY_FUNCTION__, __LINE__); + ewk_policy_decision_use(policy_decision); + break; + + case EWK_POLICY_DECISION_DOWNLOAD:{ + BROWSER_LOGD("[%s:%d] policy_download", __PRETTY_FUNCTION__, + __LINE__); + const char * + uri = ewk_policy_decision_url_get(policy_decision); + const char * + content_type = + ewk_policy_decision_response_mime_get(policy_decision); + const Eina_Hash * + headers = + ewk_policy_decision_response_headers_get(policy_decision); + app_control_h + app_control = NULL; + if (app_control_create(&app_control) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_create", + __PRETTY_FUNCTION__, __LINE__); + return; + } + + if (app_control_set_operation + (app_control, APP_CONTROL_OPERATION_VIEW) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_set_operation", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return; + } + + BROWSER_LOGD("[%s:%d] uri: %s", __PRETTY_FUNCTION__, __LINE__, + uri); + if (app_control_set_uri(app_control, uri) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_set_uri", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return; + } + + BROWSER_LOGD("[%s:%d] content_type: %s", __PRETTY_FUNCTION__, + __LINE__, content_type); + if (app_control_set_mime(app_control, content_type) < 0) { + BROWSER_LOGE("[%s:%d] Fail to app_control_set_mime", + __PRETTY_FUNCTION__, __LINE__); + app_control_destroy(app_control); + return; + } + + const char * + content_dispotision = + (const char *) eina_hash_find(headers, "Content-Disposition"); + BROWSER_LOGD("[%s:%d] Content-disposition: %s", + __PRETTY_FUNCTION__, __LINE__, content_dispotision); + if (content_dispotision + && (strstr(content_dispotision, "attachment") != NULL)) { + wv->m_downloadControl->handle_download_request(uri, + content_type); + app_control_destroy(app_control); + ewk_policy_decision_ignore(policy_decision); + break; + } + + if (app_control_send_launch_request(app_control, NULL, NULL) == + APP_CONTROL_ERROR_APP_NOT_FOUND) { + BROWSER_LOGD + ("[%s:%d] app_control_send_launch_request returns APP_CONTROL_ERROR_APP_NOT_FOUND", + __PRETTY_FUNCTION__, __LINE__); + wv->m_downloadControl->handle_download_request(uri, + content_type); + } + app_control_destroy(app_control); + ewk_policy_decision_ignore(policy_decision); + break; + } + case EWK_POLICY_DECISION_IGNORE: + default: + BROWSER_LOGD("[%s:%d] policy_ignore", __PRETTY_FUNCTION__, + __LINE__); + ewk_policy_decision_ignore(policy_decision); + break; + } + } + + void + WebView::__policy_navigation_decide_cb(void *data, + Evas_Object * /*obj */ , + void *event_info) + { + BROWSER_LOGD("[%s:%d]", __PRETTY_FUNCTION__, __LINE__); + WebView * + wv = (WebView *) data; + + Ewk_Policy_Decision * + policy_decision = (Ewk_Policy_Decision *) event_info; + const char * + uri = ewk_policy_decision_url_get(policy_decision); + wv->m_loadingURL = std::string(uri); + BROWSER_LOGD("uri = [%s]", uri); + + Eina_Bool + is_scheme_handled = wv->handle_scheme(uri); + + if (is_scheme_handled) { + BROWSER_LOGD("Scheme handled"); + ewk_policy_decision_ignore(policy_decision); + if (!wv->isBackEnabled()) + wv = NULL; + return; + } + ewk_policy_decision_use(policy_decision); + } #endif -} /* namespace webengine_service */ -} /* end of basic_webengine */ -} /* end of tizen_browser */ - + } /* namespace webengine_service */ + } /* end of basic_webengine */ +} /* end of tizen_browser */ diff --git a/services/WebEngineService/WebView.h b/services/WebEngineService/WebView.h index 9bedaabe..e0a8c66c 100755 --- a/services/WebEngineService/WebView.h +++ b/services/WebEngineService/WebView.h @@ -261,32 +261,32 @@ public: #endif // signals - boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged; - boost::signals2::signal<void (std::shared_ptr<tizen_browser::tools::BrowserImage>, tizen_browser::tools::SnapshotType snapshot_type)> snapshotCaptured; - boost::signals2::signal<void (const std::string&)> titleChanged; - boost::signals2::signal<void (const std::string)> uriChanged; - boost::signals2::signal<void (const std::string&)> findOnPage; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::tools::BrowserImage>)> favIconChanged; + boost::signals2::signal<void(std::shared_ptr<tizen_browser::tools::BrowserImage>, tizen_browser::tools::SnapshotType snapshot_type)> snapshotCaptured; + boost::signals2::signal<void(const std::string&)> titleChanged; + boost::signals2::signal<void(const std::string)> uriChanged; + boost::signals2::signal<void(const std::string&)> findOnPage; - boost::signals2::signal<void ()> loadFinished; - boost::signals2::signal<void ()> loadStarted; - boost::signals2::signal<void ()> loadStop; - boost::signals2::signal<void ()> loadError; - boost::signals2::signal<void (double)> loadProgress; + boost::signals2::signal<void()> loadFinished; + boost::signals2::signal<void()> loadStarted; + boost::signals2::signal<void()> loadStop; + boost::signals2::signal<void()> loadError; + boost::signals2::signal<void(double)> loadProgress; - boost::signals2::signal<void (bool)> forwardEnableChanged; - boost::signals2::signal<void (bool)> backwardEnableChanged; + boost::signals2::signal<void(bool)> forwardEnableChanged; + boost::signals2::signal<void(bool)> backwardEnableChanged; - boost::signals2::signal<void (WebConfirmationPtr)> confirmationRequest; + boost::signals2::signal<void(WebConfirmationPtr)> confirmationRequest; - boost::signals2::signal<void (bool)> IMEStateChanged; + boost::signals2::signal<void(bool)> IMEStateChanged; - boost::signals2::signal<void ()> switchToWebPage; - boost::signals2::signal<void (const std::string&, const std::string&)> setCertificatePem; - boost::signals2::signal<void (const std::string&, const std::string&)> setWrongCertificatePem; + boost::signals2::signal<void()> switchToWebPage; + boost::signals2::signal<void(const std::string&, const std::string&)> setCertificatePem; + boost::signals2::signal<void(const std::string&, const std::string&)> setWrongCertificatePem; #if PROFILE_MOBILE - boost::signals2::signal<void ()> rotatePrepared; + boost::signals2::signal<void()> rotatePrepared; #endif - boost::signals2::signal<void (const std::string&, const std::string&)> redirectedWebPage; + boost::signals2::signal<void(const std::string&, const std::string&)> redirectedWebPage; boost::signals2::signal<void()> unsecureConnection; boost::signals2::signal<void(bool)> fullscreenModeSet; diff --git a/services/WebPageUI/ButtonBar.cpp b/services/WebPageUI/ButtonBar.cpp index b5d4b443..221abf14 100644..100755 --- a/services/WebPageUI/ButtonBar.cpp +++ b/services/WebPageUI/ButtonBar.cpp @@ -108,7 +108,6 @@ void ButtonBar::onEnabledChanged(const std::string& buttonName, sharedAction act if (m_actionsMap[buttonName] == action) { refreshButton(buttonName); } - } void ButtonBar::setActionForButton(const std::string& buttonName, sharedAction newAction) @@ -131,7 +130,6 @@ void ButtonBar::setActionForButton(const std::string& buttonName, sharedAction n m_actionsMap[buttonName] = newAction; refreshButton(buttonName); - } void ButtonBar::refreshButton(const std::string& buttonName) diff --git a/services/WebPageUI/ButtonBar.h b/services/WebPageUI/ButtonBar.h index 0491354d..fcb14169 100644..100755 --- a/services/WebPageUI/ButtonBar.h +++ b/services/WebPageUI/ButtonBar.h @@ -77,7 +77,6 @@ private: static Eina_Bool __cb_tooltip_hide_timeout(void* data); static Eina_Bool __cb_tooltip_show_delay(void* data); #endif - }; } diff --git a/services/WebPageUI/URIEntry.cpp b/services/WebPageUI/URIEntry.cpp index 1c857529..25d64b9b 100644..100755 --- a/services/WebPageUI/URIEntry.cpp +++ b/services/WebPageUI/URIEntry.cpp @@ -124,8 +124,9 @@ void URIEntry::changeUri(const std::string& newUri) #if PROFILE_MOBILE m_rightIconType = RightIconType::NONE; #endif - } else + } else { elm_entry_entry_set(m_entry, elm_entry_utf8_to_markup("")); + } } #if PROFILE_MOBILE updateSecureIcon(); @@ -216,7 +217,7 @@ void URIEntry::_uri_entry_editing_changed_user(void* data, Evas_Object* /* obj * #if PROFILE_MOBILE self->showCancelIcon(); #endif - if(entry.find(" ") != std::string::npos) + if (entry.find(" ") != std::string::npos) return; self->uriEntryEditingChangedByUser(std::make_shared<std::string>(entry)); } @@ -260,7 +261,7 @@ void URIEntry::focused(void* data, Evas_Object* /* obj */, void* /* event_info * } else { self->m_entryContextMenuOpen = false; } - if(self->m_first_click) { + if (self->m_first_click) { elm_entry_select_all(self->m_entry); self->m_first_click = false; self->m_entrySelectionState = SelectionState::SELECTION_NONE; @@ -317,11 +318,11 @@ std::string URIEntry::rewriteURI(const std::string& url) boost::regex fileRegex(R"(^file:///[^\s]*$)"); if (!url.empty() && url != "about:blank" && url != "about:home") { - if (boost::regex_match(url, urlRegex) || boost::regex_match(url, fileRegex)) + if (boost::regex_match(url, urlRegex) || boost::regex_match(url, fileRegex)) { return url; - else if (boost::regex_match(std::string("http://") + url, urlRegex) && url.find(".") != std::string::npos) + } else if (boost::regex_match(std::string("http://") + url, urlRegex) && url.find(".") != std::string::npos) { return std::string("http://") + url; - else { + } else { std::string searchString("http://www.google.com/search?q="); searchString += url; std::replace(searchString.begin(), searchString.end(), ' ', '+'); @@ -392,7 +393,6 @@ void URIEntry::_uri_entry_longpressed(void* data, Evas_Object* /*obj*/, void* /* URIEntry* self = static_cast<URIEntry*>(data); self->m_entryContextMenuOpen = true; self->m_entrySelectionState = SelectionState::SELECTION_KEEP; - } #if PROFILE_MOBILE @@ -418,7 +418,7 @@ void URIEntry::showCancelIcon() BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); m_rightIconType = RightIconType::CANCEL; bool isEntryEmpty = elm_entry_is_empty(m_entry); - if(!isEntryEmpty) + if (!isEntryEmpty) elm_object_signal_emit(m_entry_layout, "show_cancel_icon", "ui"); else elm_object_signal_emit(m_entry_layout, "hide_icon", "ui"); @@ -452,8 +452,7 @@ void URIEntry::showSecureIcon(bool show, bool secure) elm_object_signal_emit(m_entry_layout, "show,secure,icon", ""); else elm_object_signal_emit(m_entry_layout, "show,unsecure,icon", ""); - } - else { + } else { elm_object_signal_emit(m_entry_layout, "hide_icon", "ui"); } } diff --git a/services/WebPageUI/URIEntry.h b/services/WebPageUI/URIEntry.h index 3684a2b7..5501fa2f 100644..100755 --- a/services/WebPageUI/URIEntry.h +++ b/services/WebPageUI/URIEntry.h @@ -49,16 +49,16 @@ public: Evas_Object* getEntryWidget(); void changeUri(const std::string&); - boost::signals2::signal<void (const std::string&)> uriChanged; + boost::signals2::signal<void(const std::string&)> uriChanged; // uri edition change (by a user) - boost::signals2::signal<void (const std::shared_ptr<std::string>)> uriEntryEditingChangedByUser; + boost::signals2::signal<void(const std::shared_ptr<std::string>)> uriEntryEditingChangedByUser; #if PROFILE_MOBILE - boost::signals2::signal<void ()> mobileEntryFocused; - boost::signals2::signal<void ()> mobileEntryUnfocused; - boost::signals2::signal<void ()> secureIconClicked; - boost::signals2::signal<bool (const std::string&)> isValidCert; + boost::signals2::signal<void()> mobileEntryFocused; + boost::signals2::signal<void()> mobileEntryUnfocused; + boost::signals2::signal<void()> secureIconClicked; + boost::signals2::signal<bool(const std::string&)> isValidCert; void updateSecureIcon(); void showSecureIcon(bool show, bool secure); #endif diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp index ee18444b..a08b525b 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.cpp @@ -17,93 +17,111 @@ #include "GenlistItemsManager.h" #include "BrowserLogger.h" -namespace tizen_browser { -namespace base_ui { - -GenlistItemsManager::GenlistItemsManager() +namespace tizen_browser { - ptrMap = { - { GenlistItemType::ITEM_CURRENT, - make_shared<Elm_Object_Item*>()}, - { GenlistItemType::ITEM_FIRST, - make_shared<Elm_Object_Item*>()}, - { GenlistItemType::ITEM_LAST, - make_shared<Elm_Object_Item*>()} - }; - namesMap = { - { GenlistItemType::ITEM_CURRENT, "ITEM_CURRENT" }, - { GenlistItemType::ITEM_FIRST, "ITEM_FIRST" }, - { GenlistItemType::ITEM_LAST, "ITEM_LAST" } - }; -} + namespace base_ui + { -GenlistItemsManager::~GenlistItemsManager() -{ -} + GenlistItemsManager::GenlistItemsManager() + { + ptrMap = { + { + GenlistItemType::ITEM_CURRENT, make_shared < Elm_Object_Item * >()} + , + { + GenlistItemType::ITEM_FIRST, make_shared < Elm_Object_Item * >()} + , + { + GenlistItemType::ITEM_LAST, make_shared < Elm_Object_Item * >()} + }; + namesMap = { + { + GenlistItemType::ITEM_CURRENT, "ITEM_CURRENT"} + , { + GenlistItemType::ITEM_FIRST, "ITEM_FIRST"} + , { + GenlistItemType::ITEM_LAST, "ITEM_LAST"} + }; + } -Elm_Object_Item* GenlistItemsManager::getItem(GenlistItemType type) const -{ - return *ptrMap.at(type); -} + GenlistItemsManager::~GenlistItemsManager() { + } -void GenlistItemsManager::setItems(std::initializer_list<GenlistItemType> types, - Elm_Object_Item* item) -{ - for (auto i : types) { - *ptrMap.at(i) = item; + Elm_Object_Item *GenlistItemsManager::getItem(GenlistItemType type) const + { + return *ptrMap.at(type); } -} -void GenlistItemsManager::setItemsIfNullptr( - std::initializer_list<GenlistItemType> types, Elm_Object_Item* item) -{ - for (auto i : types) { - if (!getItem(i)) { - setItems( { i }, item); - } + void GenlistItemsManager::setItems(std::initializer_list < + GenlistItemType > types, + Elm_Object_Item * item) + { + for (auto i:types) { + *ptrMap.at(i) = item; + } } -} -void GenlistItemsManager::assignItem(GenlistItemType dst, GenlistItemType src) -{ - setItems( { dst }, getItem(src)); -} + void GenlistItemsManager::setItemsIfNullptr(std::initializer_list < + GenlistItemType > types, + Elm_Object_Item * item) + { + for (auto i:types) { + if (!getItem(i)) { + setItems({ + i} + , item); + } + } + } -bool GenlistItemsManager::shiftItemDown(GenlistItemType item) -{ - if (!getItem(item)) - return false; - Elm_Object_Item* item_next = elm_genlist_item_next_get(getItem(item)); - if (item_next) { - setItems( { item }, item_next); - return true; + void GenlistItemsManager::assignItem(GenlistItemType dst, + GenlistItemType src) + { + setItems({ + dst}, getItem(src)); } - return false; -} -bool GenlistItemsManager::shiftItemUp(GenlistItemType item) -{ - if (!getItem(item)) - return false; - Elm_Object_Item* item_prev = elm_genlist_item_prev_get(getItem(item)); - if (item_prev) { - setItems( { item }, item_prev); - return true; + bool GenlistItemsManager::shiftItemDown(GenlistItemType item) + { + if (!getItem(item)) + return false; + Elm_Object_Item *item_next = elm_genlist_item_next_get(getItem(item)); + if (item_next) { + setItems({ + item} + , item_next); + return true; + } + return false; } - return false; -} -void GenlistItemsManager::clear() -{ - for (auto pair : ptrMap) { - setItems({pair.first}, nullptr); + bool GenlistItemsManager::shiftItemUp(GenlistItemType item) + { + if (!getItem(item)) + return false; + Elm_Object_Item *item_prev = elm_genlist_item_prev_get(getItem(item)); + if (item_prev) { + setItems({ + item} + , item_prev); + return true; + } + return false; } -} -std::string GenlistItemsManager::toString(GenlistItemType item) const -{ - return namesMap.find(item)->second; -} + void GenlistItemsManager::clear() + { + for (auto pair:ptrMap) { + setItems({ + pair.first} + , nullptr); + } + } + + std::string GenlistItemsManager::toString(GenlistItemType item) const + { + return namesMap.find(item)->second; + } -} /* namespace base_ui */ -} /* namespace tizen_browser */ + } /* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h index 59a94411..8642ae3c 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h +++ b/services/WebPageUI/UrlHistoryList/GenlistItemsManager.h @@ -71,7 +71,6 @@ public: private: map<GenlistItemType, shared_ptr<Elm_Object_Item*>> ptrMap; std::map<GenlistItemType, std::string> namesMap; - }; } /* namespace base_ui */ diff --git a/services/WebPageUI/UrlHistoryList/GenlistManager.cpp b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp index 93808696..5b9da734 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistManager.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.cpp @@ -88,17 +88,17 @@ void GenlistManager::show(const string& editedUrl, prepareUrlsVector(editedUrl, matchedEntries); - m_itemsManager->setItems( { GenlistItemType::ITEM_FIRST, + m_itemsManager->setItems({ GenlistItemType::ITEM_FIRST, GenlistItemType::ITEM_LAST }, nullptr); Elm_Object_Item* itemAppended = nullptr; for (auto it : m_readyUrlPairs) { itemAppended = elm_genlist_item_append(m_genlist, m_historyItemClass, it.get(), nullptr, ELM_GENLIST_ITEM_NONE, GenlistManagerCallbacks::_item_selected, it.get()); - m_itemsManager->setItemsIfNullptr( { GenlistItemType::ITEM_FIRST }, + m_itemsManager->setItemsIfNullptr({ GenlistItemType::ITEM_FIRST }, itemAppended); } - m_itemsManager->setItems( { GenlistItemType::ITEM_LAST }, itemAppended); + m_itemsManager->setItems({ GenlistItemType::ITEM_LAST }, itemAppended); const int list_items_number = elm_genlist_items_count(m_genlist); if (list_items_number != 0) { @@ -136,7 +136,7 @@ string GenlistManager::getItemUrl( for (auto t : types) { if (!m_itemsManager->getItem( { t })) continue; - void* data = elm_object_item_data_get(m_itemsManager->getItem( { t })); + void* data = elm_object_item_data_get(m_itemsManager->getItem({ t })); if (!data) continue; const UrlPair* const urlPair = reinterpret_cast<UrlPair*>(data); diff --git a/services/WebPageUI/UrlHistoryList/GenlistManager.h b/services/WebPageUI/UrlHistoryList/GenlistManager.h index 7784a822..7784a822 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistManager.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManager.h diff --git a/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp index 7f98300f..40271c50 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.cpp @@ -47,7 +47,7 @@ Eina_Bool GenlistManagerCallbacks::_object_event(void* /*data*/, Evas_Object* /*obj*/, Evas_Object* /*src*/, Evas_Callback_Type type, void* event_info) { - if(type != EVAS_CALLBACK_KEY_UP) + if (type != EVAS_CALLBACK_KEY_UP) return EINA_FALSE; if (!genlistManager) diff --git a/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h index dbba9eea..dbba9eea 100644..100755 --- a/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h +++ b/services/WebPageUI/UrlHistoryList/GenlistManagerCallbacks.h diff --git a/services/WebPageUI/UrlHistoryList/TimerCallbacks.cpp b/services/WebPageUI/UrlHistoryList/TimerCallbacks.cpp index 1a585f05..1a585f05 100644..100755 --- a/services/WebPageUI/UrlHistoryList/TimerCallbacks.cpp +++ b/services/WebPageUI/UrlHistoryList/TimerCallbacks.cpp diff --git a/services/WebPageUI/UrlHistoryList/TimerCallbacks.h b/services/WebPageUI/UrlHistoryList/TimerCallbacks.h index 43afde0c..43afde0c 100644..100755 --- a/services/WebPageUI/UrlHistoryList/TimerCallbacks.h +++ b/services/WebPageUI/UrlHistoryList/TimerCallbacks.h diff --git a/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp index ac28b49c..57ee21da 100644..100755 --- a/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.cpp @@ -24,156 +24,177 @@ #include "Config.h" #include <EflTools.h> -namespace tizen_browser { -namespace base_ui { +namespace tizen_browser +{ + namespace base_ui + { -UrlHistoryList::UrlHistoryList(WPUStatesManagerPtrConst webPageUiStatesMgr) - : m_genlistManager(make_shared<GenlistManager>()) + UrlHistoryList:: + UrlHistoryList(WPUStatesManagerPtrConst webPageUiStatesMgr) + :m_genlistManager(make_shared < GenlistManager > ()) , m_webPageUiStatesMgr(webPageUiStatesMgr) - , ITEMS_NUMBER_MAX(boost::any_cast<int>(config::Config:: - getInstance().get(CONFIG_KEY::URLHISTORYLIST_ITEMS_NUMBER_MAX))) - , KEYWORD_LENGTH_MIN(boost::any_cast<int>(tizen_browser::config::Config:: - getInstance().get(CONFIG_KEY::URLHISTORYLIST_KEYWORD_LENGTH_MIN))) - , m_parent(nullptr) - , m_entry(nullptr) - , m_layout(nullptr) - , m_widgetFocused(false) -{ - m_edjFilePath = EDJE_DIR; - m_edjFilePath.append("WebPageUI/UrlHistoryList.edj"); - m_genlistManager->signalItemSelected.connect( - boost::bind(&UrlHistoryList::onItemSelect, this, _1)); - m_genlistManager->signalItemFocusChange.connect( - boost::bind(&UrlHistoryList::onItemFocusChange, this)); - m_genlistManager->signalGenlistCreated.connect( - boost::bind(&UrlHistoryList::onGenlistCreated, this, _1)); - m_genlistFocusedCallback.set(this); -} - -UrlHistoryList::~UrlHistoryList() -{ -} + , ITEMS_NUMBER_MAX(boost::any_cast < + int >(config::Config::getInstance(). + get(CONFIG_KEY:: + URLHISTORYLIST_ITEMS_NUMBER_MAX))) + , KEYWORD_LENGTH_MIN(boost::any_cast < + int >(tizen_browser::config::Config::getInstance(). + get(CONFIG_KEY:: + URLHISTORYLIST_KEYWORD_LENGTH_MIN))) + , m_parent(nullptr) + , m_entry(nullptr) + , m_layout(nullptr) + , m_widgetFocused(false) + { + m_edjFilePath = EDJE_DIR; + m_edjFilePath.append("WebPageUI/UrlHistoryList.edj"); + m_genlistManager->signalItemSelected. + connect(boost::bind(&UrlHistoryList::onItemSelect, this, _1)); + m_genlistManager->signalItemFocusChange. + connect(boost::bind(&UrlHistoryList::onItemFocusChange, this)); + m_genlistManager->signalGenlistCreated. + connect(boost::bind(&UrlHistoryList::onGenlistCreated, this, _1)); + m_genlistFocusedCallback.set(this); + } -void UrlHistoryList::setMembers(Evas_Object* parent, Evas_Object* editedEntry) -{ - m_parent = parent; - m_entry = editedEntry; - evas_object_smart_callback_add(m_entry, "changed,user", - UrlHistoryList::_uri_entry_editing_changed_user, this); -} + UrlHistoryList::~UrlHistoryList() + { + } -void UrlHistoryList::createLayout(Evas_Object* parentLayout) -{ - m_layout = elm_layout_add(parentLayout); - tools::EflTools::setExpandHints(m_layout); - elm_layout_file_set(m_layout, m_edjFilePath.c_str(), "url_history_list"); - m_genlistManager->setParentLayout(m_layout); -} + void UrlHistoryList::setMembers(Evas_Object * parent, + Evas_Object * editedEntry) + { + m_parent = parent; + m_entry = editedEntry; + evas_object_smart_callback_add(m_entry, "changed,user", + UrlHistoryList:: + _uri_entry_editing_changed_user, this); + } -Evas_Object* UrlHistoryList::getLayout() -{ - if (!m_layout) - createLayout(m_parent); - return m_layout; -} + void UrlHistoryList::createLayout(Evas_Object * parentLayout) + { + m_layout = elm_layout_add(parentLayout); + tools::EflTools::setExpandHints(m_layout); + elm_layout_file_set(m_layout, m_edjFilePath.c_str(), + "url_history_list"); + m_genlistManager->setParentLayout(m_layout); + } -void UrlHistoryList::saveEntryAsEditedContent() -{ - m_entryEditedContent = elm_entry_entry_get(m_entry); -} + Evas_Object *UrlHistoryList::getLayout() + { + if (!m_layout) + createLayout(m_parent); + return m_layout; + } -void UrlHistoryList::restoreEntryEditedContent() -{ - elm_entry_entry_set(m_entry, m_entryEditedContent.c_str()); - elm_entry_cursor_end_set(m_entry); -} + void UrlHistoryList::saveEntryAsEditedContent() + { + m_entryEditedContent = elm_entry_entry_get(m_entry); + } -int UrlHistoryList::getItemsNumberMax() const -{ - return ITEMS_NUMBER_MAX; -} + void UrlHistoryList::restoreEntryEditedContent() + { + elm_entry_entry_set(m_entry, m_entryEditedContent.c_str()); + elm_entry_cursor_end_set(m_entry); + } -int UrlHistoryList::getKeywordLengthMin() const -{ - return KEYWORD_LENGTH_MIN; -} + int UrlHistoryList::getItemsNumberMax() const + { + return ITEMS_NUMBER_MAX; + } -bool UrlHistoryList::getGenlistVisible() -{ - return evas_object_visible_get(m_genlistManager->getGenlist()); -} + int UrlHistoryList::getKeywordLengthMin() const + { + return KEYWORD_LENGTH_MIN; + } -void UrlHistoryList::hideWidget() -{ - m_genlistManager->hide(); -} + bool UrlHistoryList::getGenlistVisible() + { + return evas_object_visible_get(m_genlistManager->getGenlist()); + } -void UrlHistoryList::onBackPressed() -{ - hideWidget(); -} + void UrlHistoryList::hideWidget() + { + m_genlistManager->hide(); + } -bool UrlHistoryList::getWidgetFocused() const -{ - return m_widgetFocused; -} + void UrlHistoryList::onBackPressed() + { + hideWidget(); + } -void UrlHistoryList::onURLEntryEditedByUser(const string& editedUrl, - shared_ptr<services::HistoryItemVector> matchedEntries) -{ - if (matchedEntries->size() == 0) { - hideWidget(); - } else { - m_genlistManager->show(editedUrl, matchedEntries); - evas_object_show(m_layout); + bool UrlHistoryList::getWidgetFocused() const + { + return m_widgetFocused; } -} -void UrlHistoryList::onItemFocusChange() -{ - elm_entry_entry_set(m_entry, m_genlistManager->getItemUrl( { - GenlistItemType::ITEM_CURRENT }).c_str()); -} + void UrlHistoryList::onURLEntryEditedByUser(const string & editedUrl, + shared_ptr < + services::HistoryItemVector > + matchedEntries) + { + if (matchedEntries->size() == 0) { + hideWidget(); + } else { + m_genlistManager->show(editedUrl, matchedEntries); + evas_object_show(m_layout); + } + } -void UrlHistoryList::onGenlistCreated(Evas_Object* genlist) -{ - elm_object_part_content_set(m_layout, "list_swallow", genlist); - evas_object_show(m_layout); -} + void UrlHistoryList::onItemFocusChange() + { + elm_entry_entry_set(m_entry, m_genlistManager->getItemUrl({ + GenlistItemType::ITEM_CURRENT}). + c_str()); + } -void UrlHistoryList::onItemSelect(std::string content) -{ - if (m_webPageUiStatesMgr->equals(WPUState::QUICK_ACCESS)) { - openURL(content); - } else { - uriChanged(content); + void UrlHistoryList::onGenlistCreated(Evas_Object * genlist) + { + elm_object_part_content_set(m_layout, "list_swallow", genlist); + evas_object_show(m_layout); } -} -void UrlHistoryList::onListWidgetFocusChange(bool focused) -{ - m_widgetFocused = focused; - if (focused) { - string itemUrl = m_genlistManager->getItemUrl( { - GenlistItemType::ITEM_CURRENT, GenlistItemType::ITEM_FIRST }); - elm_entry_entry_set(m_entry, itemUrl.c_str()); - } else { - restoreEntryEditedContent(); + void UrlHistoryList::onItemSelect(std::string content) + { + if (m_webPageUiStatesMgr->equals(WPUState::QUICK_ACCESS)) { + openURL(content); + } else { + uriChanged(content); + } } -} -void UrlHistoryList::listWidgetFocusedFromUri() -{ - m_widgetFocused = true; - m_timerGenlistFocused.addTimer(m_genlistFocusedCallback); -} + void UrlHistoryList::onListWidgetFocusChange(bool focused) + { + m_widgetFocused = focused; + if (focused) { + string itemUrl = m_genlistManager->getItemUrl({ + GenlistItemType:: + ITEM_CURRENT, + GenlistItemType:: + ITEM_FIRST + } + ); + elm_entry_entry_set(m_entry, itemUrl.c_str()); + } else { + restoreEntryEditedContent(); + } + } -void UrlHistoryList::_uri_entry_editing_changed_user(void* data, - Evas_Object* /* obj */, void* /* event_info */) -{ - UrlHistoryList* self = reinterpret_cast<UrlHistoryList*>(data); - self->saveEntryAsEditedContent(); -} + void UrlHistoryList::listWidgetFocusedFromUri() + { + m_widgetFocused = true; + m_timerGenlistFocused.addTimer(m_genlistFocusedCallback); + } + + void UrlHistoryList::_uri_entry_editing_changed_user(void *data, + Evas_Object * + /* obj */ , + void * + /* event_info */ ) + { + UrlHistoryList *self = reinterpret_cast < UrlHistoryList * >(data); + self->saveEntryAsEditedContent(); + } -}/* namespace base_ui */ -} /* namespace tizen_browser */ + } /* namespace base_ui */ +} /* namespace tizen_browser */ diff --git a/services/WebPageUI/UrlHistoryList/UrlHistoryList.h b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h index c02197fa..44b38192 100644..100755 --- a/services/WebPageUI/UrlHistoryList/UrlHistoryList.h +++ b/services/WebPageUI/UrlHistoryList/UrlHistoryList.h @@ -70,8 +70,8 @@ public: void restoreEntryURLContent(); int getItemsNumberMax() const; int getKeywordLengthMin() const; - boost::signals2::signal<void (const std::string&)> openURL; - boost::signals2::signal<void (const std::string&)> uriChanged; + boost::signals2::signal<void(const std::string&)> openURL; + boost::signals2::signal<void(const std::string&)> uriChanged; private: void createLayout(Evas_Object* parentLayout); diff --git a/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp index 508951bc..e0293d44 100644..100755 --- a/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp +++ b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.cpp @@ -88,7 +88,7 @@ void UrlMatchesStyler::fillOccuranceRanges(const string& _checkedString, vector<int> positions; getMatchesPositions(checkedString, searchedMatch, positions); for (auto pos : positions) { - resultRanges.push_back( { pos, pos + len - 1 }); + resultRanges.push_back({ pos, pos + len - 1 }); } } diff --git a/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h index 2be211f5..6923deb6 100644..100755 --- a/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h +++ b/services/WebPageUI/UrlHistoryList/UrlMatchesStyler.h @@ -101,7 +101,6 @@ private: */ string getTaggedString(const string& strToHighlight, const int_pairs& ranges) const; - }; } /* namespace base_ui */ diff --git a/services/WebPageUI/WebPageUI.cpp b/services/WebPageUI/WebPageUI.cpp index f0248420..bf055ea1 100755 --- a/services/WebPageUI/WebPageUI.cpp +++ b/services/WebPageUI/WebPageUI.cpp @@ -25,17 +25,17 @@ #include "UrlHistoryList/UrlHistoryList.h" #include "WebPageUIStatesManager.h" -namespace tizen_browser { -namespace base_ui { - -EXPORT_SERVICE(WebPageUI, "org.tizen.browser.webpageui") +namespace tizen_browser +{ + namespace base_ui + { + EXPORT_SERVICE(WebPageUI, "org.tizen.browser.webpageui") #define MAX_SIGNAL_NAME 32 #define MAX_PROGRESS_LEVEL 20 #define PROGRESS_STEP 0.05 - -WebPageUI::WebPageUI() - : m_parent(nullptr) + WebPageUI::WebPageUI() + :m_parent(nullptr) , m_mainLayout(nullptr) #if DUMMY_BUTTON , m_dummy_button(nullptr) @@ -44,8 +44,9 @@ WebPageUI::WebPageUI() , m_privateLayout(nullptr) , m_bookmarkManagerButton(nullptr) , m_URIEntry(new URIEntry()) - , m_statesMgr(std::make_shared<WebPageUIStatesManager>(WPUState::MAIN_WEB_PAGE)) - , m_urlHistoryList(std::make_shared<UrlHistoryList>(getStatesMgr())) + , m_statesMgr(std::make_shared < WebPageUIStatesManager > + (WPUState::MAIN_WEB_PAGE)) + , m_urlHistoryList(std::make_shared < UrlHistoryList > (getStatesMgr())) , m_webviewLocked(false) , m_WebPageUIvisible(false) #if PROFILE_MOBILE && GESTURE @@ -55,753 +56,855 @@ WebPageUI::WebPageUI() , m_uriBarHidden(false) , m_fullscreen(false) #endif -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -} + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + } -WebPageUI::~WebPageUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI::~WebPageUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); #if DUMMY_BUTTON - evas_object_smart_callback_del(m_dummy_button, "focused", _dummy_button_focused); - evas_object_smart_callback_del(m_dummy_button, "unfocused", _dummy_button_unfocused); + evas_object_smart_callback_del(m_dummy_button, "focused", + _dummy_button_focused); + evas_object_smart_callback_del(m_dummy_button, "unfocused", + _dummy_button_unfocused); #endif -} - -void WebPageUI::init(Evas_Object* parent) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(parent); - m_parent = parent; -} - -Evas_Object* WebPageUI::getContent() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - if (!m_mainLayout) { - createLayout(); } - return m_mainLayout; -} -UrlHistoryPtr WebPageUI::getUrlHistoryList() -{ - return m_urlHistoryList; -} - -void WebPageUI::showUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_mainLayout); - evas_object_show(m_mainLayout); - - evas_object_show(elm_object_part_content_get(m_mainLayout, "web_view")); - evas_object_show(m_URIEntry->getContent()); - evas_object_show(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_left")); - evas_object_show(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_right")); + void WebPageUI::init(Evas_Object * parent) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(parent); + m_parent = parent; + } - if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { - evas_object_hide(m_leftButtonBar->getContent()); - elm_object_signal_emit(m_mainLayout, "shiftback_uri", "ui"); - showQuickAccess(); + Evas_Object *WebPageUI::getContent() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + if (!m_mainLayout) { + createLayout(); + } + return m_mainLayout; } - m_WebPageUIvisible = true; + UrlHistoryPtr WebPageUI::getUrlHistoryList() + { + return m_urlHistoryList; + } - elm_object_event_callback_add(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); - elm_object_event_callback_add(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); - elm_object_event_callback_add(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); + void WebPageUI::showUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_mainLayout); + evas_object_show(m_mainLayout); + + evas_object_show(elm_object_part_content_get(m_mainLayout, "web_view")); + evas_object_show(m_URIEntry->getContent()); + evas_object_show(elm_object_part_content_get + (m_mainLayout, "uri_bar_buttons_left")); + evas_object_show(elm_object_part_content_get + (m_mainLayout, "uri_bar_buttons_right")); + + if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { + evas_object_hide(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftback_uri", "ui"); + showQuickAccess(); + } + + m_WebPageUIvisible = true; + + elm_object_event_callback_add(m_leftButtonBar->getContent(), + _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_rightButtonBar->getContent(), + _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_add(m_URIEntry->getContent(), + _cb_down_pressed_on_urlbar, this); #if PROFILE_MOBILE && GESTURE - elm_gesture_layer_cb_add(m_gestureLayer, ELM_GESTURE_N_LINES, ELM_GESTURE_STATE_MOVE, _gesture_move, this); - elm_gesture_layer_line_min_length_set(m_gestureLayer, SWIPE_MOMENTUM_TRESHOLD); - elm_gesture_layer_line_distance_tolerance_set(m_gestureLayer, SWIPE_MOMENTUM_TRESHOLD); + elm_gesture_layer_cb_add(m_gestureLayer, ELM_GESTURE_N_LINES, + ELM_GESTURE_STATE_MOVE, _gesture_move, this); + elm_gesture_layer_line_min_length_set(m_gestureLayer, + SWIPE_MOMENTUM_TRESHOLD); + elm_gesture_layer_line_distance_tolerance_set(m_gestureLayer, + SWIPE_MOMENTUM_TRESHOLD); #endif -} - - -void WebPageUI::hideUI() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_mainLayout); - elm_object_focus_custom_chain_unset(m_mainLayout); - evas_object_hide(m_mainLayout); - - if(m_statesMgr->equals(WPUState::QUICK_ACCESS)) - hideQuickAccess(); - - evas_object_hide(elm_object_part_content_get(m_mainLayout, "web_view")); - evas_object_hide(m_URIEntry->getContent()); - evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_left")); - evas_object_hide(elm_object_part_content_get(m_mainLayout, "uri_bar_buttons_right")); + } - m_WebPageUIvisible = false; - elm_object_event_callback_del(m_leftButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); - elm_object_event_callback_del(m_rightButtonBar->getContent(), _cb_down_pressed_on_urlbar, this); - elm_object_event_callback_del(m_URIEntry->getContent(), _cb_down_pressed_on_urlbar, this); + void WebPageUI::hideUI() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_mainLayout); + elm_object_focus_custom_chain_unset(m_mainLayout); + evas_object_hide(m_mainLayout); + + if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) + hideQuickAccess(); + + evas_object_hide(elm_object_part_content_get(m_mainLayout, "web_view")); + evas_object_hide(m_URIEntry->getContent()); + evas_object_hide(elm_object_part_content_get + (m_mainLayout, "uri_bar_buttons_left")); + evas_object_hide(elm_object_part_content_get + (m_mainLayout, "uri_bar_buttons_right")); + + m_WebPageUIvisible = false; + + elm_object_event_callback_del(m_leftButtonBar->getContent(), + _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_rightButtonBar->getContent(), + _cb_down_pressed_on_urlbar, this); + elm_object_event_callback_del(m_URIEntry->getContent(), + _cb_down_pressed_on_urlbar, this); #if PROFILE_MOBILE && GESTURE - elm_gesture_layer_cb_del(m_gestureLayer, ELM_GESTURE_N_LINES, ELM_GESTURE_STATE_MOVE, _gesture_move, this); + elm_gesture_layer_cb_del(m_gestureLayer, ELM_GESTURE_N_LINES, + ELM_GESTURE_STATE_MOVE, _gesture_move, this); #endif #if PROFILE_MOBILE - hideMoreMenu(); - hideFindOnPage(); + hideMoreMenu(); + hideFindOnPage(); #endif -} + } -void WebPageUI::loadStarted() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - showProgressBar(); - elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); - elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); - m_leftButtonBar->setActionForButton("refresh_stop_button", m_stopLoading); -} - -void WebPageUI::progressChanged(double progress) -{ - if (progress == 1.0) { - hideProgressBar(); - } else { - int level = (int)(progress * MAX_PROGRESS_LEVEL); - char signal_name[MAX_SIGNAL_NAME] = { 0 }; - snprintf(signal_name, MAX_SIGNAL_NAME, "update,progress,%.02f,signal", ((double)level * PROGRESS_STEP)); - elm_object_signal_emit(m_mainLayout, signal_name, ""); + void WebPageUI::loadStarted() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + showProgressBar(); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", + "ui"); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + m_leftButtonBar->setActionForButton("refresh_stop_button", + m_stopLoading); } -} -bool WebPageUI::stateEquals(WPUState state) const -{ - return m_statesMgr->equals(state); -} + void WebPageUI::progressChanged(double progress) + { + if (progress == 1.0) { + hideProgressBar(); + } else { + int level = (int) (progress * MAX_PROGRESS_LEVEL); + char signal_name[MAX_SIGNAL_NAME] = { 0 }; + snprintf(signal_name, MAX_SIGNAL_NAME, "update,progress,%.02f,signal", + ((double) level * PROGRESS_STEP)); + elm_object_signal_emit(m_mainLayout, signal_name, ""); + } + } -bool WebPageUI::stateEquals(std::initializer_list<WPUState> states) const -{ - return m_statesMgr->equals(states); -} + bool WebPageUI::stateEquals(WPUState state) const + { + return m_statesMgr->equals(state); + } -void WebPageUI::loadFinished() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); - hideProgressBar(); + bool WebPageUI::stateEquals(std::initializer_list < WPUState > states) const + { + return m_statesMgr->equals(states); + } + + void WebPageUI::loadFinished() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); + hideProgressBar(); #if PROFILE_MOBILE - m_URIEntry->updateSecureIcon(); + m_URIEntry->updateSecureIcon(); #endif -} - -void WebPageUI::toIncognito(bool incognito) -{ - BROWSER_LOGD("[%s:%d,%d] ", __PRETTY_FUNCTION__, __LINE__, incognito); - if (incognito) { - elm_object_signal_emit(m_mainLayout, "incognito,true", "ui"); - elm_object_signal_emit(m_URIEntry->getEntryWidget(), "uri_entry_incognito", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "uri_entry_incognito", "ui"); } - else { - elm_object_signal_emit(m_mainLayout, "incognito,false", "ui"); - elm_object_signal_emit(m_URIEntry->getEntryWidget(), "uri_entry_normal", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "uri_entry_normal", "ui"); + + void WebPageUI::toIncognito(bool incognito) + { + BROWSER_LOGD("[%s:%d,%d] ", __PRETTY_FUNCTION__, __LINE__, incognito); + if (incognito) { + elm_object_signal_emit(m_mainLayout, "incognito,true", "ui"); + elm_object_signal_emit(m_URIEntry->getEntryWidget(), + "uri_entry_incognito", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), + "uri_entry_incognito", "ui"); + } else { + elm_object_signal_emit(m_mainLayout, "incognito,false", "ui"); + elm_object_signal_emit(m_URIEntry->getEntryWidget(), + "uri_entry_normal", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "uri_entry_normal", + "ui"); + } } -} -void WebPageUI::setMainContent(Evas_Object* content) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(content); - hideWebView(); - elm_object_part_content_set(m_mainLayout, "web_view", content); + void WebPageUI::setMainContent(Evas_Object * content) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(content); + hideWebView(); + elm_object_part_content_set(m_mainLayout, "web_view", content); #if PROFILE_MOBILE && GESTURE - elm_gesture_layer_attach(m_gestureLayer, content); + elm_gesture_layer_attach(m_gestureLayer, content); #endif #if PROFILE_MOBILE && !DUMMY_BUTTON - evas_object_smart_callback_add(content, "mouse,down", _content_clicked, this); + evas_object_smart_callback_add(content, "mouse,down", _content_clicked, + this); #endif #if PROFILE_MOBILE - updateManualRotation(); + updateManualRotation(); #endif - evas_object_show(content); -} + evas_object_show(content); + } -void WebPageUI::switchViewToErrorPage() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_statesMgr->set(WPUState::MAIN_ERROR_PAGE); - if (!m_errorLayout) - createErrorLayout(); - setMainContent(m_errorLayout); - evas_object_show(m_leftButtonBar->getContent()); - elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); - setErrorButtons(); + void WebPageUI::switchViewToErrorPage() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_statesMgr->set(WPUState::MAIN_ERROR_PAGE); + if (!m_errorLayout) + createErrorLayout(); + setMainContent(m_errorLayout); + evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", + "ui"); + setErrorButtons(); #if !PROFILE_MOBILE - refreshFocusChain(); + refreshFocusChain(); #endif -} + } -void WebPageUI::switchViewToIncognitoPage() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_statesMgr->set(WPUState::MAIN_INCOGNITO_PAGE); - toIncognito(true); - if (!m_privateLayout) - createPrivateLayout(); - setMainContent(m_privateLayout); + void WebPageUI::switchViewToIncognitoPage() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_statesMgr->set(WPUState::MAIN_INCOGNITO_PAGE); + toIncognito(true); + if (!m_privateLayout) + createPrivateLayout(); + setMainContent(m_privateLayout); #if PROFILE_MOBILE - orientationChanged(); + orientationChanged(); #endif - evas_object_show(m_leftButtonBar->getContent()); - elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); - setPrivateButtons(); + evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", + "ui"); + setPrivateButtons(); #if !PROFILE_MOBILE - refreshFocusChain(); + refreshFocusChain(); #endif - m_URIEntry->changeUri(""); - m_URIEntry->setFocus(); -} + m_URIEntry->changeUri(""); + m_URIEntry->setFocus(); + } -void WebPageUI::switchViewToWebPage(Evas_Object* content, const std::string uri) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(m_statesMgr->equals(WPUState::QUICK_ACCESS)) + void WebPageUI::switchViewToWebPage(Evas_Object * content, + const std::string uri) { - hideQuickAccess(); - m_statesMgr->set(WPUState::MAIN_WEB_PAGE); - } - setMainContent(content); + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { + hideQuickAccess(); + m_statesMgr->set(WPUState::MAIN_WEB_PAGE); + } + setMainContent(content); #if !PROFILE_MOBILE - refreshFocusChain(); - elm_object_focus_custom_chain_append(m_mainLayout, content, NULL); + refreshFocusChain(); + elm_object_focus_custom_chain_append(m_mainLayout, content, NULL); #endif - evas_object_show(m_leftButtonBar->getContent()); - elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", "ui"); - updateURIBar(uri); -} + evas_object_show(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftright_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftright_uribg", + "ui"); + updateURIBar(uri); + } -void WebPageUI::switchViewToQuickAccess(Evas_Object* content) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - m_statesMgr->set(WPUState::QUICK_ACCESS); - toIncognito(false); - setMainContent(content); - evas_object_hide(m_leftButtonBar->getContent()); - elm_object_signal_emit(m_mainLayout, "shiftback_uri", "ui"); - elm_object_signal_emit(m_URIEntry->getContent(), "shiftback_uribg", "ui"); - hideProgressBar(); + void WebPageUI::switchViewToQuickAccess(Evas_Object * content) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + m_statesMgr->set(WPUState::QUICK_ACCESS); + toIncognito(false); + setMainContent(content); + evas_object_hide(m_leftButtonBar->getContent()); + elm_object_signal_emit(m_mainLayout, "shiftback_uri", "ui"); + elm_object_signal_emit(m_URIEntry->getContent(), "shiftback_uribg", + "ui"); + hideProgressBar(); #if !PROFILE_MOBILE - refreshFocusChain(); + refreshFocusChain(); #endif - m_URIEntry->changeUri(""); + m_URIEntry->changeUri(""); #if PROFILE_MOBILE - m_URIEntry->showSecureIcon(false, false); + m_URIEntry->showSecureIcon(false, false); #endif - m_URIEntry->setFocus(); - showQuickAccess(); -} + m_URIEntry->setFocus(); + showQuickAccess(); + } -void WebPageUI::faviconClicked(void* data, Evas_Object*, const char*, const char*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebPageUI* self = reinterpret_cast<WebPageUI*>(data); - if(!self->stateEquals({ WPUState::QUICK_ACCESS, WPUState::MAIN_ERROR_PAGE })) { - self->getURIEntry().clearFocus(); + void WebPageUI::faviconClicked(void *data, Evas_Object *, const char *, + const char *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI *self = reinterpret_cast < WebPageUI * >(data); + if (!self->stateEquals({ + WPUState::QUICK_ACCESS, WPUState::MAIN_ERROR_PAGE})) { + self->getURIEntry().clearFocus(); + } } -} -Eina_Bool WebPageUI::_cb_down_pressed_on_urlbar(void *data, Evas_Object */*obj*/, Evas_Object */*src*/, Evas_Callback_Type type, void *event_info) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebPageUI* self = reinterpret_cast<WebPageUI*>(data); - if(type == EVAS_CALLBACK_KEY_DOWN) { - Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event_info); - const std::string keyName = ev->keyname; - if(!keyName.compare("Down")){ - self->lockWebview(); - } + Eina_Bool WebPageUI::_cb_down_pressed_on_urlbar(void *data, + Evas_Object * /*obj */ , + Evas_Object * /*src */ , + Evas_Callback_Type type, + void *event_info) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI *self = reinterpret_cast < WebPageUI * >(data); + if (type == EVAS_CALLBACK_KEY_DOWN) { + Ecore_Event_Key *ev = static_cast < Ecore_Event_Key * >(event_info); + const std::string keyName = ev->keyname; + if (!keyName.compare("Down")) { + self->lockWebview(); + } + } + return EINA_FALSE; } - return EINA_FALSE; -} -void WebPageUI::setTabsNumber(int tabs) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (tabs == 0) { - elm_object_part_text_set(m_rightButtonBar->getContent(), "tabs_number", ""); - } else { - elm_object_part_text_set(m_rightButtonBar->getContent(), "tabs_number", (boost::format("%1%") % tabs).str().c_str()); + void WebPageUI::setTabsNumber(int tabs) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (tabs == 0) { + elm_object_part_text_set(m_rightButtonBar->getContent(), + "tabs_number", ""); + } else { + elm_object_part_text_set(m_rightButtonBar->getContent(), + "tabs_number", + (boost::format("%1%") % tabs).str().c_str()); + } } -} -void WebPageUI::lockWebview() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(isWebPageUIvisible()) { - if(m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) { - elm_object_focus_custom_chain_unset(m_mainLayout); - elm_object_focus_custom_chain_append(m_mainLayout, elm_object_part_content_get(m_mainLayout, "web_view"), NULL); - m_webviewLocked = true; - } + void WebPageUI::lockWebview() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (isWebPageUIvisible()) { + if (m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) { + elm_object_focus_custom_chain_unset(m_mainLayout); + elm_object_focus_custom_chain_append(m_mainLayout, + elm_object_part_content_get + (m_mainLayout, "web_view"), + NULL); + m_webviewLocked = true; + } + } } -} -void WebPageUI::lockUrlHistoryList() -{ - elm_object_focus_custom_chain_unset(m_mainLayout); - elm_object_focus_custom_chain_append(m_mainLayout, - getUrlHistoryList()->getLayout(), NULL); - getUrlHistoryList()->listWidgetFocusedFromUri(); - elm_object_focus_set(getUrlHistoryList()->getLayout(), EINA_TRUE); -} - -void WebPageUI::unlockUrlHistoryList() -{ + void WebPageUI::lockUrlHistoryList() + { + elm_object_focus_custom_chain_unset(m_mainLayout); + elm_object_focus_custom_chain_append(m_mainLayout, + getUrlHistoryList()->getLayout(), + NULL); + getUrlHistoryList()->listWidgetFocusedFromUri(); + elm_object_focus_set(getUrlHistoryList()->getLayout(), EINA_TRUE); + } + + void WebPageUI::unlockUrlHistoryList() + { #if !PROFILE_MOBILE - refreshFocusChain(); + refreshFocusChain(); #endif - elm_object_focus_set(m_URIEntry->getEntryWidget(), EINA_TRUE); - getUrlHistoryList()->onListWidgetFocusChange(false); -} + elm_object_focus_set(m_URIEntry->getEntryWidget(), EINA_TRUE); + getUrlHistoryList()->onListWidgetFocusChange(false); + } -void WebPageUI::setFocusOnSuspend() -{ - elm_object_focus_set(m_rightButtonBar->getButton("tab_button"), EINA_TRUE); -} + void WebPageUI::setFocusOnSuspend() + { + elm_object_focus_set(m_rightButtonBar->getButton("tab_button"), + EINA_TRUE); + } #if !PROFILE_MOBILE -void WebPageUI::onRedKeyPressed() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(isWebPageUIvisible()) { - if(m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) { - if(m_webviewLocked) { - refreshFocusChain(); - m_URIEntry->setFocus(); - m_webviewLocked = false; - } - } + void WebPageUI::onRedKeyPressed() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (isWebPageUIvisible()) { + if (m_statesMgr->equals(WPUState::MAIN_WEB_PAGE)) { + if (m_webviewLocked) { + refreshFocusChain(); + m_URIEntry->setFocus(); + m_webviewLocked = false; + } + } + } } -} -void WebPageUI::onYellowKeyPressed() -{ - if (!isWebPageUIvisible()) - return; - if (!getUrlHistoryList()->getGenlistVisible()) - return; - if (getUrlHistoryList()->getWidgetFocused()) { - unlockUrlHistoryList(); - } else { - lockUrlHistoryList(); - } -} + void WebPageUI::onYellowKeyPressed() + { + if (!isWebPageUIvisible()) + return; + if (!getUrlHistoryList()->getGenlistVisible()) + return; + if (getUrlHistoryList()->getWidgetFocused()) { + unlockUrlHistoryList(); + } else { + lockUrlHistoryList(); + } + } #endif #if PROFILE_MOBILE -void WebPageUI::orientationChanged() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void WebPageUI::orientationChanged() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - auto landscape = isLandscape(); + auto landscape = isLandscape(); - if (landscape) { - if (*landscape) { - elm_object_signal_emit(m_privateLayout, "show_incognito_landscape", "ui"); + if (landscape) { + if (*landscape) { + elm_object_signal_emit(m_privateLayout, "show_incognito_landscape", + "ui"); #if GESTURE - if (m_uriBarHidden) - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", "ui"); + if (m_uriBarHidden) + elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", + "ui"); #endif - } - else { - elm_object_signal_emit(m_privateLayout, "show_incognito_vertical", "ui"); + } else { + elm_object_signal_emit(m_privateLayout, "show_incognito_vertical", + "ui"); #if GESTURE - if (m_uriBarHidden) - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_vertical", "ui"); + if (m_uriBarHidden) + elm_object_signal_emit(m_mainLayout, "hide_uri_bar_vertical", + "ui"); #endif - } + } + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + + if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { + qaOrientationChanged(); + } } - else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); - if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { - qaOrientationChanged(); + void WebPageUI::fullscreenModeSet(bool state) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + auto landscape = isLandscape(); + auto findonpage = isFindOnPageVisible(); + m_fullscreen = state; + if (!state) { + elm_object_signal_emit(m_mainLayout, "show_uri_bar", "ui"); + if (findonpage && *findonpage) + elm_object_signal_emit(m_mainLayout, "show_findonpage", "ui"); + } else if (landscape && state) { + (*landscape) ? + elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", + "ui") : elm_object_signal_emit(m_mainLayout, + "hide_uri_bar_vertical", + "ui"); + if (findonpage && *findonpage) + hideFindOnPage(); + } } -} - -void WebPageUI::fullscreenModeSet(bool state) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - auto landscape = isLandscape(); - auto findonpage = isFindOnPageVisible(); - m_fullscreen = state; - if (!state) { - elm_object_signal_emit(m_mainLayout, "show_uri_bar", "ui"); - if (findonpage && *findonpage) - elm_object_signal_emit(m_mainLayout, "show_findonpage", "ui"); - } else if (landscape && state) { - (*landscape) ? - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", "ui") : - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_vertical", "ui"); - if (findonpage && *findonpage) - hideFindOnPage(); - } -} #endif -void WebPageUI::createLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - M_ASSERT(m_parent); - // create web layout - m_mainLayout = elm_layout_add(m_parent); - evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_layout_file_set(m_mainLayout, edjePath("WebPageUI/WebPageUI.edj").c_str(), "main_layout"); - - createActions(); - - // left buttons - m_leftButtonBar = std::unique_ptr<ButtonBar>(new ButtonBar(m_mainLayout, "WebPageUI/LeftButtonBar.edj", "left_button_bar")); - m_leftButtonBar->addAction(m_back, "prev_button"); - m_leftButtonBar->addAction(m_forward, "next_button"); - m_leftButtonBar->addAction(m_reload, "refresh_stop_button"); - - //register action that will be used later by buttons" - m_leftButtonBar->registerEnabledChangedCallback(m_stopLoading, "refresh_stop_button"); - - // right buttons - m_rightButtonBar = std::unique_ptr<ButtonBar>(new ButtonBar(m_mainLayout, "WebPageUI/RightButtonBar.edj", "right_button_bar")); - m_rightButtonBar->addAction(m_tab, "tab_button"); - m_rightButtonBar->addAction(m_showMoreMenu, "setting_button"); - - //URL bar (Evas Object is shipped by URIEntry object) - m_URIEntry->init(m_mainLayout); - elm_object_part_content_set(m_mainLayout, "uri_entry", m_URIEntry->getContent()); - elm_object_part_content_set(m_mainLayout, "uri_bar_buttons_left", m_leftButtonBar->getContent()); - elm_object_part_content_set(m_mainLayout, "uri_bar_buttons_right", m_rightButtonBar->getContent()); - - elm_layout_signal_callback_add(m_URIEntry->getContent(), "slide_websearch", "elm", faviconClicked, this); + void WebPageUI::createLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + M_ASSERT(m_parent); + // create web layout + m_mainLayout = elm_layout_add(m_parent); + evas_object_size_hint_weight_set(m_mainLayout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_layout_file_set(m_mainLayout, + edjePath("WebPageUI/WebPageUI.edj").c_str(), + "main_layout"); + + createActions(); + + // left buttons + m_leftButtonBar = + std::unique_ptr < ButtonBar > + (new + ButtonBar(m_mainLayout, "WebPageUI/LeftButtonBar.edj", + "left_button_bar")); + m_leftButtonBar->addAction(m_back, "prev_button"); + m_leftButtonBar->addAction(m_forward, "next_button"); + m_leftButtonBar->addAction(m_reload, "refresh_stop_button"); + + //register action that will be used later by buttons" + m_leftButtonBar->registerEnabledChangedCallback(m_stopLoading, + "refresh_stop_button"); + + // right buttons + m_rightButtonBar = + std::unique_ptr < ButtonBar > + (new + ButtonBar(m_mainLayout, "WebPageUI/RightButtonBar.edj", + "right_button_bar")); + m_rightButtonBar->addAction(m_tab, "tab_button"); + m_rightButtonBar->addAction(m_showMoreMenu, "setting_button"); + + //URL bar (Evas Object is shipped by URIEntry object) + m_URIEntry->init(m_mainLayout); + elm_object_part_content_set(m_mainLayout, "uri_entry", + m_URIEntry->getContent()); + elm_object_part_content_set(m_mainLayout, "uri_bar_buttons_left", + m_leftButtonBar->getContent()); + elm_object_part_content_set(m_mainLayout, "uri_bar_buttons_right", + m_rightButtonBar->getContent()); + + elm_layout_signal_callback_add(m_URIEntry->getContent(), + "slide_websearch", "elm", faviconClicked, + this); #if PROFILE_MOBILE - edje_object_signal_callback_add(elm_layout_edje_get(m_mainLayout), "mouse,clicked,1", "moremenu_dimmed_bg", _more_menu_background_clicked, this); + edje_object_signal_callback_add(elm_layout_edje_get(m_mainLayout), + "mouse,clicked,1", "moremenu_dimmed_bg", + _more_menu_background_clicked, this); #endif // elm_theme_extension_add(nullptr, edjePath("WebPageUI/UrlHistoryList.edj").c_str()); // m_urlHistoryList->setMembers(m_mainLayout, m_URIEntry->getEntryWidget()); // elm_object_part_content_set(m_mainLayout, "url_history_list", m_urlHistoryList->getLayout()); - connectActions(); + connectActions(); #if PROFILE_MOBILE && GESTURE - // will be attatch on every 'setMainContent' - m_gestureLayer = elm_gesture_layer_add(m_mainLayout); + // will be attatch on every 'setMainContent' + m_gestureLayer = elm_gesture_layer_add(m_mainLayout); #endif -} + } #if DUMMY_BUTTON -void WebPageUI::createDummyButton() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (!m_dummy_button) { - M_ASSERT(m_mainLayout); - m_dummy_button = elm_button_add(m_mainLayout); - elm_object_style_set(m_dummy_button, "invisible_button"); - evas_object_size_hint_align_set(m_dummy_button, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_size_hint_weight_set(m_dummy_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_focus_allow_set(m_dummy_button, EINA_TRUE); - elm_object_focus_set(m_dummy_button, EINA_TRUE); - evas_object_show(m_dummy_button); - elm_object_part_content_set(m_mainLayout, "web_view_dummy_button", m_dummy_button); - - evas_object_smart_callback_add(m_dummy_button, "focused", _dummy_button_focused, this); - evas_object_smart_callback_add(m_dummy_button, "unfocused", _dummy_button_unfocused, this); - } -} - -void WebPageUI::_dummy_button_focused(void *data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - WebPageUI* webPageUI = static_cast<WebPageUI*>(data); - webPageUI->focusWebView(); + void WebPageUI::createDummyButton() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (!m_dummy_button) { + M_ASSERT(m_mainLayout); + m_dummy_button = elm_button_add(m_mainLayout); + elm_object_style_set(m_dummy_button, "invisible_button"); + evas_object_size_hint_align_set(m_dummy_button, EVAS_HINT_FILL, + EVAS_HINT_FILL); + evas_object_size_hint_weight_set(m_dummy_button, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + elm_object_focus_allow_set(m_dummy_button, EINA_TRUE); + elm_object_focus_set(m_dummy_button, EINA_TRUE); + evas_object_show(m_dummy_button); + elm_object_part_content_set(m_mainLayout, "web_view_dummy_button", + m_dummy_button); + + evas_object_smart_callback_add(m_dummy_button, "focused", + _dummy_button_focused, this); + evas_object_smart_callback_add(m_dummy_button, "unfocused", + _dummy_button_unfocused, this); + } } -} -void WebPageUI::_dummy_button_unfocused(void *data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (data != nullptr) { - WebPageUI* webPageUI = static_cast<WebPageUI*>(data); - webPageUI->unfocusWebView(); + void WebPageUI::_dummy_button_focused(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + WebPageUI *webPageUI = static_cast < WebPageUI * >(data); + webPageUI->focusWebView(); + } } -} -#endif -void WebPageUI::createErrorLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_errorLayout = elm_layout_add(m_mainLayout); - evas_object_size_hint_weight_set(m_errorLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_errorLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_layout_file_set(m_errorLayout, edjePath("WebPageUI/ErrorMessage.edj").c_str(), "error_message"); -} - -void WebPageUI::createPrivateLayout() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_privateLayout = elm_layout_add(m_mainLayout); - evas_object_size_hint_weight_set(m_privateLayout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(m_privateLayout, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_layout_file_set(m_privateLayout, edjePath("WebPageUI/PrivateMode.edj").c_str(), "inco_message"); + void WebPageUI::_dummy_button_unfocused(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (data != nullptr) { + WebPageUI *webPageUI = static_cast < WebPageUI * >(data); + webPageUI->unfocusWebView(); + } + } - m_bookmarkManagerButton = elm_button_add(m_privateLayout); - elm_object_style_set(m_bookmarkManagerButton, "invisible_button"); - evas_object_smart_callback_add(m_bookmarkManagerButton, "clicked", _bookmark_manager_clicked, this); - evas_object_show(m_bookmarkManagerButton); +#endif + void WebPageUI::createErrorLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_errorLayout = elm_layout_add(m_mainLayout); + evas_object_size_hint_weight_set(m_errorLayout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_errorLayout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_file_set(m_errorLayout, + edjePath("WebPageUI/ErrorMessage.edj").c_str(), + "error_message"); + } - elm_object_part_content_set(m_privateLayout, "bookmarkmanager_click", m_bookmarkManagerButton); -} + void WebPageUI::createPrivateLayout() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_privateLayout = elm_layout_add(m_mainLayout); + evas_object_size_hint_weight_set(m_privateLayout, EVAS_HINT_EXPAND, + EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(m_privateLayout, EVAS_HINT_FILL, + EVAS_HINT_FILL); + elm_layout_file_set(m_privateLayout, + edjePath("WebPageUI/PrivateMode.edj").c_str(), + "inco_message"); + + m_bookmarkManagerButton = elm_button_add(m_privateLayout); + elm_object_style_set(m_bookmarkManagerButton, "invisible_button"); + evas_object_smart_callback_add(m_bookmarkManagerButton, "clicked", + _bookmark_manager_clicked, this); + evas_object_show(m_bookmarkManagerButton); + + elm_object_part_content_set(m_privateLayout, "bookmarkmanager_click", + m_bookmarkManagerButton); + } -void WebPageUI::_bookmark_manager_clicked(void * data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebPageUI* webpageUI = static_cast<WebPageUI*>(data); - webpageUI->bookmarkManagerClicked(); -} + void WebPageUI::_bookmark_manager_clicked(void *data, Evas_Object *, + void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI *webpageUI = static_cast < WebPageUI * >(data); + webpageUI->bookmarkManagerClicked(); + } #if PROFILE_MOBILE -void WebPageUI::setContentFocus() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (getURIEntry().hasFocus()) { - getURIEntry().clearFocus(); - mobileEntryUnfocused(); + void WebPageUI::setContentFocus() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (getURIEntry().hasFocus()) { + getURIEntry().clearFocus(); + mobileEntryUnfocused(); + } } -} -void WebPageUI::_content_clicked(void *data, Evas_Object *, void *) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebPageUI* webpageUI = static_cast<WebPageUI*>(data); - webpageUI->setContentFocus(); -} + void WebPageUI::_content_clicked(void *data, Evas_Object *, void *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI *webpageUI = static_cast < WebPageUI * >(data); + webpageUI->setContentFocus(); + } -void WebPageUI::_more_menu_background_clicked(void* data, Evas_Object*, const char*, const char*) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - WebPageUI* webPageUI = static_cast<WebPageUI*>(data); - webPageUI->hideMoreMenu(); -} + void WebPageUI::_more_menu_background_clicked(void *data, Evas_Object *, + const char *, const char *) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + WebPageUI *webPageUI = static_cast < WebPageUI * >(data); + webPageUI->hideMoreMenu(); + } #endif -void WebPageUI::createActions() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_back = sharedAction(new Action(_("IDS_BR_BUTTON_BACK_ABB"))); - m_back->setIcon("browser/toolbar_prev"); + void WebPageUI::createActions() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_back = sharedAction(new Action(_("IDS_BR_BUTTON_BACK_ABB"))); + m_back->setIcon("browser/toolbar_prev"); - m_forward = sharedAction(new Action(_("IDS_BR_SK_NEXT"))); - m_forward->setIcon("browser/toolbar_next"); + m_forward = sharedAction(new Action(_("IDS_BR_SK_NEXT"))); + m_forward->setIcon("browser/toolbar_next"); - m_stopLoading = sharedAction(new Action(_("IDS_BR_OPT_STOP"))); - m_stopLoading->setIcon("browser/toolbar_stop"); + m_stopLoading = sharedAction(new Action(_("IDS_BR_OPT_STOP"))); + m_stopLoading->setIcon("browser/toolbar_stop"); - m_reload = sharedAction(new Action("Reload")); - m_reload->setIcon("browser/toolbar_reload"); - m_tab = sharedAction(new Action(_("IDS_BR_SK_TABS"))); - m_tab->setIcon("browser/toolbar_tab"); + m_reload = sharedAction(new Action("Reload")); + m_reload->setIcon("browser/toolbar_reload"); + m_tab = sharedAction(new Action(_("IDS_BR_SK_TABS"))); + m_tab->setIcon("browser/toolbar_tab"); - m_showMoreMenu = sharedAction(new Action("More_Menu")); - m_showMoreMenu->setIcon("browser/toolbar_setting"); + m_showMoreMenu = sharedAction(new Action("More_Menu")); + m_showMoreMenu->setIcon("browser/toolbar_setting"); #if !PROFILE_MOBILE - m_back->setToolTip(_("IDS_BR_SK_PREVIOUS")); - m_forward->setToolTip(_("IDS_BR_SK_NEXT")); - m_stopLoading->setToolTip(_("IDS_BR_OPT_STOP")); - m_reload->setToolTip("Reload"); - m_tab->setToolTip("Tab Manager"); - m_showMoreMenu->setToolTip("More Menu"); + m_back->setToolTip(_("IDS_BR_SK_PREVIOUS")); + m_forward->setToolTip(_("IDS_BR_SK_NEXT")); + m_stopLoading->setToolTip(_("IDS_BR_OPT_STOP")); + m_reload->setToolTip("Reload"); + m_tab->setToolTip("Tab Manager"); + m_showMoreMenu->setToolTip("More Menu"); #endif -} + } -void WebPageUI::connectActions() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - //left bar - m_back->triggered.connect(boost::bind(&WebPageUI::backPageConnect, this)); - m_forward->triggered.connect(boost::bind(&WebPageUI::forwardPageConnect, this)); - m_stopLoading->triggered.connect(boost::bind(&WebPageUI::stopLoadingPageConnect, this)); - m_reload->triggered.connect(boost::bind(&WebPageUI::reloadPageConnect, this)); - - //right bar - m_tab->triggered.connect(boost::bind(&WebPageUI::showTabUIConnect, this)); - m_showMoreMenu->triggered.connect(boost::bind(&WebPageUI::showMoreMenuConnect, this)); -} - -void WebPageUI::showProgressBar() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_mainLayout, "show,progress,signal", ""); - elm_object_signal_emit(m_mainLayout, "update,progress,0.00,signal", ""); -} + void WebPageUI::connectActions() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + //left bar + m_back->triggered. + connect(boost::bind(&WebPageUI::backPageConnect, this)); + m_forward->triggered. + connect(boost::bind(&WebPageUI::forwardPageConnect, this)); + m_stopLoading->triggered. + connect(boost::bind(&WebPageUI::stopLoadingPageConnect, this)); + m_reload->triggered. + connect(boost::bind(&WebPageUI::reloadPageConnect, this)); + + //right bar + m_tab->triggered. + connect(boost::bind(&WebPageUI::showTabUIConnect, this)); + m_showMoreMenu->triggered. + connect(boost::bind(&WebPageUI::showMoreMenuConnect, this)); + } -void WebPageUI::hideProgressBar() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_mainLayout, "hide,progress,signal", ""); -} + void WebPageUI::showProgressBar() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_mainLayout, "show,progress,signal", ""); + elm_object_signal_emit(m_mainLayout, "update,progress,0.00,signal", ""); + } -void WebPageUI::hideFindOnPage() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_mainLayout, "hide_findonpage", "ui"); -} + void WebPageUI::hideProgressBar() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_mainLayout, "hide,progress,signal", ""); + } -void WebPageUI::hideWebView() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + void WebPageUI::hideFindOnPage() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_mainLayout, "hide_findonpage", "ui"); + } - evas_object_hide(elm_object_part_content_unset(m_mainLayout, "web_view")); -} + void WebPageUI::hideWebView() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); -void WebPageUI::setErrorButtons() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); - m_stopLoading->setEnabled(false); - m_reload->setEnabled(true); - m_forward->setEnabled(false); -} - -void WebPageUI::setPrivateButtons() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - m_stopLoading->setEnabled(false); - m_reload->setEnabled(false); - m_forward->setEnabled(false); -} + evas_object_hide(elm_object_part_content_unset + (m_mainLayout, "web_view")); + } -void WebPageUI::updateURIBar(const std::string& uri) -{ - BROWSER_LOGD("[%s:%d] URI:%s", __PRETTY_FUNCTION__, __LINE__, uri.c_str()); - m_URIEntry->changeUri(uri); - m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); + void WebPageUI::setErrorButtons() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); + m_stopLoading->setEnabled(false); + m_reload->setEnabled(true); + m_forward->setEnabled(false); + } - m_stopLoading->setEnabled(true); - m_reload->setEnabled(true); - hideProgressBar(); -} + void WebPageUI::setPrivateButtons() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + m_stopLoading->setEnabled(false); + m_reload->setEnabled(false); + m_forward->setEnabled(false); + } -std::string WebPageUI::edjePath(const std::string& file) -{ - return std::string(EDJE_DIR) + file; -} + void WebPageUI::updateURIBar(const std::string & uri) + { + BROWSER_LOGD("[%s:%d] URI:%s", __PRETTY_FUNCTION__, __LINE__, + uri.c_str()); + m_URIEntry->changeUri(uri); + m_leftButtonBar->setActionForButton("refresh_stop_button", m_reload); + + m_stopLoading->setEnabled(true); + m_reload->setEnabled(true); + hideProgressBar(); + } -void WebPageUI::showTabUIConnect() -{ - hideUI(); - showTabUI(); -} -void WebPageUI::showMoreMenuConnect() -{ + std::string WebPageUI::edjePath(const std::string & file) + { + return std::string(EDJE_DIR) + file; + } + + void WebPageUI::showTabUIConnect() + { + hideUI(); + showTabUI(); + } + void WebPageUI::showMoreMenuConnect() + { #if !PROFILE_MOBILE - hideUI(); + hideUI(); #else - hideFindOnPage(); + hideFindOnPage(); #endif - showMoreMenu(); -} + showMoreMenu(); + } #if !PROFILE_MOBILE -void WebPageUI::refreshFocusChain() -{ - // set custom focus chain - elm_object_focus_custom_chain_unset(m_mainLayout); - elm_object_focus_custom_chain_append(m_mainLayout, m_rightButtonBar->getContent(), NULL); - if(!m_statesMgr->equals(WPUState::QUICK_ACCESS)) { - elm_object_focus_custom_chain_append(m_mainLayout, m_leftButtonBar->getContent(), NULL); - elm_object_focus_custom_chain_append(m_mainLayout, m_bookmarkManagerButton, NULL); - } else { - m_reload->setEnabled(false); - } - elm_object_focus_custom_chain_append(m_mainLayout, m_URIEntry->getContent(), NULL); -} + void WebPageUI::refreshFocusChain() + { + // set custom focus chain + elm_object_focus_custom_chain_unset(m_mainLayout); + elm_object_focus_custom_chain_append(m_mainLayout, + m_rightButtonBar->getContent(), + NULL); + if (!m_statesMgr->equals(WPUState::QUICK_ACCESS)) { + elm_object_focus_custom_chain_append(m_mainLayout, + m_leftButtonBar->getContent(), + NULL); + elm_object_focus_custom_chain_append(m_mainLayout, + m_bookmarkManagerButton, NULL); + } else { + m_reload->setEnabled(false); + } + elm_object_focus_custom_chain_append(m_mainLayout, + m_URIEntry->getContent(), NULL); + } #endif #if PROFILE_MOBILE && GESTURE -Evas_Event_Flags WebPageUI::_gesture_move(void* data , void* event_info) -{ - auto info = static_cast<Elm_Gesture_Line_Info*>(event_info); - if (info->momentum.n == WebPageUI::SINGLE_FINGER) { - if ((info->angle > 330 || info->angle < 30) && info->momentum.my < -WebPageUI::SWIPE_MOMENTUM_TRESHOLD) { // top direction - auto self = static_cast<WebPageUI*>(data); - self->gestureUp(); - } else if (info->angle > 150 && info->angle < 210 && info->momentum.my > WebPageUI::SWIPE_MOMENTUM_TRESHOLD) { // bottom direction - auto self = static_cast<WebPageUI*>(data); - self->gestureDown(); - } + Evas_Event_Flags WebPageUI::_gesture_move(void *data, void *event_info) + { + auto info = static_cast < Elm_Gesture_Line_Info * >(event_info); + if (info->momentum.n == WebPageUI::SINGLE_FINGER) { + if ((info->angle > 330 || info->angle < 30) && info->momentum.my < -WebPageUI::SWIPE_MOMENTUM_TRESHOLD) { // top direction + auto self = static_cast < WebPageUI * >(data); + self->gestureUp(); + } else if (info->angle > 150 && info->angle < 210 && info->momentum.my > WebPageUI::SWIPE_MOMENTUM_TRESHOLD) { // bottom direction + auto self = static_cast < WebPageUI * >(data); + self->gestureDown(); + } + } + + return EVAS_EVENT_FLAG_NONE; } - return EVAS_EVENT_FLAG_NONE; -} - -void WebPageUI::gestureUp() -{ - if (!m_uriBarHidden) { - m_uriBarHidden = true; - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - - boost::optional<bool> landscape = isLandscape(); - - if (landscape) { - if (*landscape) - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", "ui"); - else - elm_object_signal_emit(m_mainLayout, "hide_uri_bar_vertical", "ui"); - } else - BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, __LINE__); + void WebPageUI::gestureUp() + { + if (!m_uriBarHidden) { + m_uriBarHidden = true; + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + + boost::optional < bool > landscape = isLandscape(); + + if (landscape) { + if (*landscape) + elm_object_signal_emit(m_mainLayout, "hide_uri_bar_landscape", + "ui"); + else + elm_object_signal_emit(m_mainLayout, "hide_uri_bar_vertical", + "ui"); + } else { + BROWSER_LOGE("[%s:%d] Signal not found", __PRETTY_FUNCTION__, + __LINE__); + } + } } -} -void WebPageUI::gestureDown() -{ - if (m_uriBarHidden) { - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_mainLayout, "show_uri_bar", "ui"); - m_uriBarHidden = false; + void WebPageUI::gestureDown() + { + if (m_uriBarHidden) { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_mainLayout, "show_uri_bar", "ui"); + m_uriBarHidden = false; + } } -} #endif #if PROFILE_MOBILE -void WebPageUI::mobileEntryFocused() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - elm_object_signal_emit(m_mainLayout, "enlarge_focused_uri", "ui"); -} - -void WebPageUI::mobileEntryUnfocused() -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { - elm_object_signal_emit(m_mainLayout, "decrease_unfocused_uri", "ui"); - } else { - elm_object_signal_emit(m_mainLayout, "decrease_unfocused_uri_wp", "ui"); + void WebPageUI::mobileEntryFocused() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + elm_object_signal_emit(m_mainLayout, "enlarge_focused_uri", "ui"); } - // delay hiding on one efl loop iteration to enable genlist item selected callback to come - ecore_timer_add(0.0, _hideDelay, this); -} + void WebPageUI::mobileEntryUnfocused() + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + if (m_statesMgr->equals(WPUState::QUICK_ACCESS)) { + elm_object_signal_emit(m_mainLayout, "decrease_unfocused_uri", "ui"); + } else { + elm_object_signal_emit(m_mainLayout, "decrease_unfocused_uri_wp", + "ui"); + } + + // delay hiding on one efl loop iteration to enable genlist item selected callback to come + ecore_timer_add(0.0, _hideDelay, this); + } -Eina_Bool WebPageUI::_hideDelay(void *data) -{ - BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - auto self = static_cast<WebPageUI*>(data); - self->m_urlHistoryList->hideWidget(); - return ECORE_CALLBACK_CANCEL; -} + Eina_Bool WebPageUI::_hideDelay(void *data) + { + BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); + auto self = static_cast < WebPageUI * >(data); + self->m_urlHistoryList->hideWidget(); + return ECORE_CALLBACK_CANCEL; + } #endif -} // namespace tizen_browser -} // namespace base_ui + } // namespace tizen_browser +} // namespace base_ui diff --git a/services/WebPageUI/WebPageUI.h b/services/WebPageUI/WebPageUI.h index 89a6b1e7..ce1170ec 100644..100755 --- a/services/WebPageUI/WebPageUI.h +++ b/services/WebPageUI/WebPageUI.h @@ -101,25 +101,25 @@ public: void onYellowKeyPressed(); #endif - boost::signals2::signal<void ()> backPage; - boost::signals2::signal<void ()> forwardPage; - boost::signals2::signal<void ()> stopLoadingPage; - boost::signals2::signal<void ()> reloadPage; - boost::signals2::signal<void ()> showTabUI; + boost::signals2::signal<void()> backPage; + boost::signals2::signal<void()> forwardPage; + boost::signals2::signal<void()> stopLoadingPage; + boost::signals2::signal<void()> reloadPage; + boost::signals2::signal<void()> showTabUI; #if PROFILE_MOBILE - boost::signals2::signal<void ()> updateManualRotation; - boost::signals2::signal<void ()> hideMoreMenu; - boost::signals2::signal<void ()> qaOrientationChanged; - boost::signals2::signal<bool ()> isFindOnPageVisible; + boost::signals2::signal<void()> updateManualRotation; + boost::signals2::signal<void()> hideMoreMenu; + boost::signals2::signal<void()> qaOrientationChanged; + boost::signals2::signal<bool()> isFindOnPageVisible; #else - boost::signals2::signal<void ()> showZoomNavigation; + boost::signals2::signal<void()> showZoomNavigation; #endif - boost::signals2::signal<void ()> showMoreMenu; - boost::signals2::signal<void ()> hideQuickAccess; - boost::signals2::signal<void ()> showQuickAccess; - boost::signals2::signal<void ()> bookmarkManagerClicked; - boost::signals2::signal<void ()> focusWebView; - boost::signals2::signal<void ()> unfocusWebView; + boost::signals2::signal<void()> showMoreMenu; + boost::signals2::signal<void()> hideQuickAccess; + boost::signals2::signal<void()> showQuickAccess; + boost::signals2::signal<void()> bookmarkManagerClicked; + boost::signals2::signal<void()> focusWebView; + boost::signals2::signal<void()> unfocusWebView; private: static void faviconClicked(void* data, Evas_Object* obj, const char* emission, const char* source); diff --git a/services/WebPageUI/WebPageUIStatesManager.cpp b/services/WebPageUI/WebPageUIStatesManager.cpp index 4c22e6fa..4c22e6fa 100644..100755 --- a/services/WebPageUI/WebPageUIStatesManager.cpp +++ b/services/WebPageUI/WebPageUIStatesManager.cpp diff --git a/services/WebPageUI/WebPageUIStatesManager.h b/services/WebPageUI/WebPageUIStatesManager.h index 05099774..3b49cbf5 100644..100755 --- a/services/WebPageUI/WebPageUIStatesManager.h +++ b/services/WebPageUI/WebPageUIStatesManager.h @@ -58,7 +58,6 @@ public: private: WPUState m_state; std::map<WPUState, std::string> namesMap; - }; } /* namespace base_ui */ diff --git a/services/ZoomUI/ZoomUI.cpp b/services/ZoomUI/ZoomUI.cpp index 76827deb..71804e26 100644..100755 --- a/services/ZoomUI/ZoomUI.cpp +++ b/services/ZoomUI/ZoomUI.cpp @@ -59,7 +59,7 @@ Evas_Object* ZoomUI::getContent() { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); M_ASSERT(m_parent); - if(!m_layout) + if (!m_layout) createLayout(m_parent); return m_layout; } @@ -143,9 +143,9 @@ void ZoomUI::clearItems() void ZoomUI::_zoom_slider_changed(void *data, Evas_Object *obj, void*) { BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__); - if(data && obj) { + if (data && obj) { int val = elm_slider_value_get(obj); - int zoomLevel = ZOOM_DEFAULT; + int zoomLevel = ZOOM_DEFAULT; ZoomUI *zoomUI = static_cast<ZoomUI*>(data); switch (val) { diff --git a/services/ZoomUI/ZoomUI.h b/services/ZoomUI/ZoomUI.h index 63c451f0..eebd8c64 100644..100755 --- a/services/ZoomUI/ZoomUI.h +++ b/services/ZoomUI/ZoomUI.h @@ -48,10 +48,10 @@ public: bool isVisible(); void escapeZoom(); - boost::signals2::signal<void ()> closeZoomUI; - boost::signals2::signal<void (int)> setZoom; - boost::signals2::signal<int ()> getZoom; - boost::signals2::signal<void (const int&, const int&)> scrollView; + boost::signals2::signal<void()> closeZoomUI; + boost::signals2::signal<void(int)> setZoom; + boost::signals2::signal<int()> getZoom; + boost::signals2::signal<void(const int&, const int&)> scrollView; private: void createLayout(Evas_Object* parent); void createZoomSlider(); @@ -75,7 +75,7 @@ private: ZOOM_100 = 100, ZOOM_150 = 150, ZOOM_200 = 200, - ZOOM_300 = 300, + ZOOM_300 = 300, ZOOM_MIN = ZOOM_50, ZOOM_DEFAULT = ZOOM_100, diff --git a/unit_tests/ut_Action.cpp b/unit_tests/ut_Action.cpp index 093cf49f..f6eaf03a 100644..100755 --- a/unit_tests/ut_Action.cpp +++ b/unit_tests/ut_Action.cpp @@ -26,157 +26,161 @@ BOOST_AUTO_TEST_SUITE(action) -BOOST_AUTO_TEST_CASE(action_constructors) + BOOST_AUTO_TEST_CASE(action_constructors) { - BROWSER_LOGI("[UT] Action - action_constructor - START --> "); - - tizen_browser::base_ui::Action action_01; - BOOST_CHECK_EQUAL(action_01.isEnabled(), true); - BOOST_CHECK_EQUAL(action_01.isCheckable(), false); - BOOST_CHECK_EQUAL(action_01.isChecked(), false); - BOOST_CHECK_EQUAL(action_01.isIconVisibleInMenu(), true); - - std::string a02_text("test02"); - tizen_browser::base_ui::Action action_02(a02_text); - BOOST_CHECK_EQUAL(action_02.isEnabled(), true); - BOOST_CHECK_EQUAL(action_02.isCheckable(), false); - BOOST_CHECK_EQUAL(action_02.isChecked(), false); - BOOST_CHECK_EQUAL(action_02.isIconVisibleInMenu(), true); - BOOST_CHECK_EQUAL(action_02.getText(), a02_text); - - std::string a03_text("test02"); - tizen_browser::base_ui::Action action_03(a03_text); - BOOST_CHECK_EQUAL(action_03.isEnabled(), true); - BOOST_CHECK_EQUAL(action_03.isCheckable(), false); - BOOST_CHECK_EQUAL(action_03.isChecked(), false); - BOOST_CHECK_EQUAL(action_03.isIconVisibleInMenu(), true); - BOOST_CHECK_EQUAL(action_03.getText(), a03_text); - - std::string a04_text("test04"); - std::string a04_icon("test04Icon"); - tizen_browser::base_ui::Action action_04(a04_icon, a04_text); - BOOST_CHECK_EQUAL(action_04.isEnabled(), true); - BOOST_CHECK_EQUAL(action_04.isCheckable(), false); - BOOST_CHECK_EQUAL(action_04.isChecked(), false); - BOOST_CHECK_EQUAL(action_04.isIconVisibleInMenu(), true); - BOOST_CHECK_EQUAL(action_04.getText(), a04_text); - BOOST_CHECK_EQUAL(action_04.getIcon(), a04_icon); - - BROWSER_LOGI("[UT] --> END - Action - action_constructor"); + BROWSER_LOGI("[UT] Action - action_constructor - START --> "); + + tizen_browser::base_ui::Action action_01; + BOOST_CHECK_EQUAL(action_01.isEnabled(), true); + BOOST_CHECK_EQUAL(action_01.isCheckable(), false); + BOOST_CHECK_EQUAL(action_01.isChecked(), false); + BOOST_CHECK_EQUAL(action_01.isIconVisibleInMenu(), true); + + std::string a02_text("test02"); + tizen_browser::base_ui::Action action_02(a02_text); + BOOST_CHECK_EQUAL(action_02.isEnabled(), true); + BOOST_CHECK_EQUAL(action_02.isCheckable(), false); + BOOST_CHECK_EQUAL(action_02.isChecked(), false); + BOOST_CHECK_EQUAL(action_02.isIconVisibleInMenu(), true); + BOOST_CHECK_EQUAL(action_02.getText(), a02_text); + + std::string a03_text("test02"); + tizen_browser::base_ui::Action action_03(a03_text); + BOOST_CHECK_EQUAL(action_03.isEnabled(), true); + BOOST_CHECK_EQUAL(action_03.isCheckable(), false); + BOOST_CHECK_EQUAL(action_03.isChecked(), false); + BOOST_CHECK_EQUAL(action_03.isIconVisibleInMenu(), true); + BOOST_CHECK_EQUAL(action_03.getText(), a03_text); + + std::string a04_text("test04"); + std::string a04_icon("test04Icon"); + tizen_browser::base_ui::Action action_04(a04_icon, a04_text); + BOOST_CHECK_EQUAL(action_04.isEnabled(), true); + BOOST_CHECK_EQUAL(action_04.isCheckable(), false); + BOOST_CHECK_EQUAL(action_04.isChecked(), false); + BOOST_CHECK_EQUAL(action_04.isIconVisibleInMenu(), true); + BOOST_CHECK_EQUAL(action_04.getText(), a04_text); + BOOST_CHECK_EQUAL(action_04.getIcon(), a04_icon); + + BROWSER_LOGI("[UT] --> END - Action - action_constructor"); } -BOOST_AUTO_TEST_CASE(action_get_and_set){ - - BROWSER_LOGI("[UT] Action - action_get_and_set - START --> "); - - std::string iconText("iconText"); - std::string text("text"); - std::string statusTip("statusTip"); - std::string toolTip("toolTip"); - std::string icon("icon"); - std::string selIcon("selIcon"); - std::string disIcon("disabledIcon"); - - tizen_browser::base_ui::Action action; - - action.setIconText(iconText); - action.setText(text); - action.setStatusTip(statusTip); - action.setToolTip(toolTip); - action.setIcon(icon); - action.setSelIcon(selIcon); - action.setDisIcon(disIcon); - - BOOST_CHECK_EQUAL(action.getIconText(), iconText); - BOOST_CHECK_EQUAL(action.getText(), text); - BOOST_CHECK_EQUAL(action.getStatusTip(), statusTip); - BOOST_CHECK_EQUAL(action.getToolTip(), toolTip); - BOOST_CHECK_EQUAL(action.getIcon(), icon); - BOOST_CHECK_EQUAL(action.getSelIcon(), selIcon); - BOOST_CHECK_EQUAL(action.getDisIcon(), disIcon); - - BROWSER_LOGI("[UT] --> END - Action - action_get_and_set"); +BOOST_AUTO_TEST_CASE(action_get_and_set) +{ + BROWSER_LOGI("[UT] Action - action_get_and_set - START --> "); + std::string iconText("iconText"); + std::string text("text"); + std::string statusTip("statusTip"); + std::string toolTip("toolTip"); + std::string icon("icon"); + std::string selIcon("selIcon"); + std::string disIcon("disabledIcon"); + + tizen_browser::base_ui::Action action; + + action.setIconText(iconText); + action.setText(text); + action.setStatusTip(statusTip); + action.setToolTip(toolTip); + action.setIcon(icon); + action.setSelIcon(selIcon); + action.setDisIcon(disIcon); + + BOOST_CHECK_EQUAL(action.getIconText(), iconText); + BOOST_CHECK_EQUAL(action.getText(), text); + BOOST_CHECK_EQUAL(action.getStatusTip(), statusTip); + BOOST_CHECK_EQUAL(action.getToolTip(), toolTip); + BOOST_CHECK_EQUAL(action.getIcon(), icon); + BOOST_CHECK_EQUAL(action.getSelIcon(), selIcon); + BOOST_CHECK_EQUAL(action.getDisIcon(), disIcon); + + BROWSER_LOGI("[UT] --> END - Action - action_get_and_set"); } -BOOST_AUTO_TEST_CASE(action_bool_behaviour){ - - BROWSER_LOGI("[UT] Action - action_bool_behaviour - START --> "); - - tizen_browser::base_ui::Action action_01; - //action is not checkable by defalut, - //this call should be ignored. - action_01.setChecked(true); - BOOST_CHECK_EQUAL(action_01.isCheckable(), false); - BOOST_CHECK_EQUAL(action_01.isChecked(), false); - - tizen_browser::base_ui::Action action_02; - action_02.setCheckable(true); - action_02.setChecked(true); - BOOST_CHECK_EQUAL(action_02.isCheckable(), true); - BOOST_CHECK_EQUAL(action_02.isChecked(), true); - - //toggle test - action_02.toggle(); - BOOST_CHECK_EQUAL(action_02.isChecked(), false); - - BROWSER_LOGI("[UT] --> END - Action - action_bool_behaviour"); +BOOST_AUTO_TEST_CASE(action_bool_behaviour) +{ + BROWSER_LOGI("[UT] Action - action_bool_behaviour - START --> "); + tizen_browser::base_ui::Action action_01; + //action is not checkable by defalut, + //this call should be ignored. + action_01.setChecked(true); + BOOST_CHECK_EQUAL(action_01.isCheckable(), false); + BOOST_CHECK_EQUAL(action_01.isChecked(), false); + + tizen_browser::base_ui::Action action_02; + action_02.setCheckable(true); + action_02.setChecked(true); + BOOST_CHECK_EQUAL(action_02.isCheckable(), true); + BOOST_CHECK_EQUAL(action_02.isChecked(), true); + + //toggle test + action_02.toggle(); + BOOST_CHECK_EQUAL(action_02.isChecked(), false); + + BROWSER_LOGI("[UT] --> END - Action - action_bool_behaviour"); } -BOOST_AUTO_TEST_CASE(action_trigger_test){ - - BROWSER_LOGI("[UT] Action - action_trigger_test - START --> "); - - struct TriggerHandler{ - TriggerHandler() - :beenCalled(false){}; - ~TriggerHandler(){ - BOOST_CHECK_EQUAL(beenCalled, true); - }; - void operator()(){ - beenCalled = true; - }; -// private: - bool beenCalled; +BOOST_AUTO_TEST_CASE(action_trigger_test) +{ + BROWSER_LOGI("[UT] Action - action_trigger_test - START --> "); + struct TriggerHandler + { + TriggerHandler() + :beenCalled(false) + { + }; + ~TriggerHandler() { + BOOST_CHECK_EQUAL(beenCalled, true); + }; + void operator() () + { + beenCalled = true; }; +// private: + bool beenCalled; + }; - TriggerHandler triggered; - tizen_browser::base_ui::Action action_01; - action_01.triggered.connect(boost::ref(triggered)); - action_01.trigger(); - BOOST_CHECK_EQUAL(triggered.beenCalled, true); + TriggerHandler triggered; + tizen_browser::base_ui::Action action_01; + action_01.triggered.connect(boost::ref(triggered)); + action_01.trigger(); + BOOST_CHECK_EQUAL(triggered.beenCalled, true); - BROWSER_LOGI("[UT] --> END - Action - action_trigger_test"); + BROWSER_LOGI("[UT] --> END - Action - action_trigger_test"); } -BOOST_AUTO_TEST_CASE(action_togle_test){ - - BROWSER_LOGI("[UT] Action - action_togle_test - START --> "); - - struct ToggleHandler{ - ToggleHandler() - :isChecked(false),beenCalled(false){}; - ~ToggleHandler(){ - }; - void operator()(bool checked){ - isChecked = checked; - beenCalled = true; - }; - bool isChecked; - bool beenCalled; +BOOST_AUTO_TEST_CASE(action_togle_test) +{ + BROWSER_LOGI("[UT] Action - action_togle_test - START --> "); + struct ToggleHandler + { + ToggleHandler() + :isChecked(false), beenCalled(false) + { + }; + ~ToggleHandler() { + }; + void operator() (bool checked) + { + isChecked = checked; + beenCalled = true; }; + bool isChecked; + bool beenCalled; + }; - ToggleHandler toggelHandler; - tizen_browser::base_ui::Action action; + ToggleHandler toggelHandler; + tizen_browser::base_ui::Action action; - action.setCheckable(true); - action.toggled.connect(boost::ref(toggelHandler)); + action.setCheckable(true); + action.toggled.connect(boost::ref(toggelHandler)); - action.toggle(); - BOOST_CHECK_EQUAL(toggelHandler.beenCalled, true); - BOOST_CHECK_EQUAL(action.isChecked(), toggelHandler.isChecked); + action.toggle(); + BOOST_CHECK_EQUAL(toggelHandler.beenCalled, true); + BOOST_CHECK_EQUAL(action.isChecked(), toggelHandler.isChecked); - BROWSER_LOGI("[UT] --> END - Action - action_togle_test"); + BROWSER_LOGI("[UT] --> END - Action - action_togle_test"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_BookmarkItem.cpp b/unit_tests/ut_BookmarkItem.cpp index 57741b2b..c3b74457 100644..100755 --- a/unit_tests/ut_BookmarkItem.cpp +++ b/unit_tests/ut_BookmarkItem.cpp @@ -25,62 +25,61 @@ BOOST_AUTO_TEST_SUITE(bookmark_item) -BOOST_AUTO_TEST_CASE(bookm_item_set_get) + BOOST_AUTO_TEST_CASE(bookm_item_set_get) { - BROWSER_LOGI("[UT] BookmarkItem - bookm_item_set_get - START --> "); - - std::string retstr = ""; - std::unique_ptr<tizen_browser::services::BookmarkItem> - bitem(new tizen_browser::services::BookmarkItem()); - - //Check empty address and title - bitem->setAddress(""); - retstr= bitem->getAddress(); - BOOST_CHECK_EQUAL("",retstr); - bitem->setTitle(""); - retstr= bitem->getTitle(); - BOOST_CHECK_EQUAL("",retstr); - - //Check non empty address and title - bitem->setAddress("www.address.com"); - retstr= bitem->getAddress(); - BOOST_CHECK_EQUAL("www.address.com",retstr); - bitem->setTitle("Page Title"); - retstr= bitem->getTitle(); - BOOST_CHECK_EQUAL("Page Title",retstr); - - //Check set/get id - bitem->setId(0); - BOOST_CHECK_EQUAL(0, bitem->getId()); - bitem->setId(9999); - BOOST_CHECK_EQUAL(9999, bitem->getId()); - - BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_set_get"); + BROWSER_LOGI("[UT] BookmarkItem - bookm_item_set_get - START --> "); + + std::string retstr = ""; + std::unique_ptr < tizen_browser::services::BookmarkItem > + bitem(new tizen_browser::services::BookmarkItem()); + + //Check empty address and title + bitem->setAddress(""); + retstr = bitem->getAddress(); + BOOST_CHECK_EQUAL("", retstr); + bitem->setTitle(""); + retstr = bitem->getTitle(); + BOOST_CHECK_EQUAL("", retstr); + + //Check non empty address and title + bitem->setAddress("www.address.com"); + retstr = bitem->getAddress(); + BOOST_CHECK_EQUAL("www.address.com", retstr); + bitem->setTitle("Page Title"); + retstr = bitem->getTitle(); + BOOST_CHECK_EQUAL("Page Title", retstr); + + //Check set/get id + bitem->setId(0); + BOOST_CHECK_EQUAL(0, bitem->getId()); + bitem->setId(9999); + BOOST_CHECK_EQUAL(9999, bitem->getId()); + + BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_set_get"); } BOOST_AUTO_TEST_CASE(bookm_item_favicon_thumb) { - BROWSER_LOGI("[UT] BookmarkItem - bookm_item_favicon_thumb - START --> "); + BROWSER_LOGI("[UT] BookmarkItem - bookm_item_favicon_thumb - START --> "); - const int w = 10, h = 10, s = 500; + const int w = 10, h = 10, s = 500; - std::unique_ptr<tizen_browser::services::BookmarkItem> - bitem(new tizen_browser::services::BookmarkItem()); - std::shared_ptr<tizen_browser::tools::BrowserImage> bimg - = std::make_shared<tizen_browser::tools::BrowserImage>(w, h, s); + std::unique_ptr < tizen_browser::services::BookmarkItem > + bitem(new tizen_browser::services::BookmarkItem()); + std::shared_ptr < tizen_browser::tools::BrowserImage > bimg + = std::make_shared < tizen_browser::tools::BrowserImage > (w, h, s); - bitem->setFavicon(bimg); - BOOST_CHECK_EQUAL(w, bitem->getFavicon()->getWidth()); - BOOST_CHECK_EQUAL(h, bitem->getFavicon()->getHeight()); - BOOST_CHECK_EQUAL(s, bitem->getFavicon()->getSize()); + bitem->setFavicon(bimg); + BOOST_CHECK_EQUAL(w, bitem->getFavicon()->getWidth()); + BOOST_CHECK_EQUAL(h, bitem->getFavicon()->getHeight()); + BOOST_CHECK_EQUAL(s, bitem->getFavicon()->getSize()); - bitem->setThumbnail(bimg); - BOOST_CHECK_EQUAL(w, bitem->getThumbnail()->width); - BOOST_CHECK_EQUAL(h, bitem->getThumbnail()->height); - BOOST_CHECK_EQUAL(s, bitem->getThumbnail()->dataSize); + bitem->setThumbnail(bimg); + BOOST_CHECK_EQUAL(w, bitem->getThumbnail()->width); + BOOST_CHECK_EQUAL(h, bitem->getThumbnail()->height); + BOOST_CHECK_EQUAL(s, bitem->getThumbnail()->dataSize); - BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_favicon_thumb"); + BROWSER_LOGI("[UT] --> END - BookmarkItem - bookm_item_favicon_thumb"); } BOOST_AUTO_TEST_SUITE_END() - diff --git a/unit_tests/ut_Config.cpp b/unit_tests/ut_Config.cpp index f5a01602..f6388e00 100644..100755 --- a/unit_tests/ut_Config.cpp +++ b/unit_tests/ut_Config.cpp @@ -34,20 +34,22 @@ BOOST_AUTO_TEST_SUITE(config) -BOOST_AUTO_TEST_CASE(config_simple_get_set) + BOOST_AUTO_TEST_CASE(config_simple_get_set) { - BROWSER_LOGI(TAG "config_simple_get_set - START --> "); + BROWSER_LOGI(TAG "config_simple_get_set - START --> "); - boost::any testvalue = tizen_browser::config::Config::getInstance().get(std::string("testkey")); - BOOST_CHECK(testvalue.empty()); + boost::any testvalue = + tizen_browser::config::Config::getInstance().get(std::string("testkey")); + BOOST_CHECK(testvalue.empty()); - int testval = 100; - tizen_browser::config::Config::getInstance().set("intTestKey", testval); - int retval = boost::any_cast<int>(defconf->get(std::string("intTestKey"))); - BOOST_CHECK_EQUAL(testval, retval); + int testval = 100; + tizen_browser::config::Config::getInstance().set("intTestKey", testval); + int retval = + boost::any_cast < int >(defconf->get(std::string("intTestKey"))); + BOOST_CHECK_EQUAL(testval, retval); - BROWSER_LOGI(TAG "Config - config_simple_get_set"); + BROWSER_LOGI(TAG "Config - config_simple_get_set"); } @@ -56,64 +58,94 @@ BOOST_AUTO_TEST_CASE(config_simple_get_set) */ BOOST_AUTO_TEST_CASE(config_boundary_conditions) { - BROWSER_LOGI(TAG "config_boundary_conditions - START --> "); + BROWSER_LOGI(TAG "config_boundary_conditions - START --> "); - std::string retstring; + std::string retstring; // Wrong keys tests - BOOST_CHECK(retstring.empty()); - boost::any retany; - try{ + BOOST_CHECK(retstring.empty()); + boost::any retany; + try { retany = tizen_browser::config::Config::getInstance().get(NULL); - } catch(std::logic_error & e){ - /// \todo get() function expects string and cannot construct empty string from NULL - BROWSER_LOGI(TAG "[i] Catched error, msg: %s",e.what()); - BROWSER_LOGI(TAG "[i] get() function expects string and cannot construct empty string from NULL\n"); - } - - try{ - retstring = boost::any_cast<std::string>(retany); - BOOST_CHECK(retstring.empty()); - }catch(boost::bad_any_cast & e){ - /// \todo Need to resolve bad type (void *) from boost::any(empty_string)) - BROWSER_LOGI(TAG "[i] Catched error, msg: %s",e.what()); - BROWSER_LOGI(TAG "[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); - } - tizen_browser::config::Config::getInstance().set(std::string(""), std::string("value")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string(""))); - BOOST_CHECK_EQUAL(retstring, std::string("value")); - - tizen_browser::config::Config::getInstance().set(std::string(" "), std::string("anothervalue")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string(" "))); - BOOST_CHECK_EQUAL(retstring, std::string("anothervalue")); - - tizen_browser::config::Config::getInstance().set(std::string(" "), std::string("value3")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string(" "))); - BOOST_CHECK_EQUAL(retstring, std::string("value3")); + } catch(std::logic_error & e) { + /// \todo get() function expects string and cannot construct empty string from NULL + BROWSER_LOGI(TAG "[i] Catched error, msg: %s", e.what()); + BROWSER_LOGI(TAG + "[i] get() function expects string and cannot construct empty string from NULL\n"); + } + + try { + retstring = boost::any_cast < std::string > (retany); + BOOST_CHECK(retstring.empty()); + } catch(boost::bad_any_cast & e) { + /// \todo Need to resolve bad type (void *) from boost::any(empty_string)) + BROWSER_LOGI(TAG "[i] Catched error, msg: %s", e.what()); + BROWSER_LOGI(TAG + "[i] std::map not found map[key] and returns NULL to boost::any_cast as type (void*) instead of std::string (this case)\n"); + } + tizen_browser::config::Config::getInstance().set(std::string(""), + std::string("value")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance().get(std::string(""))); + BOOST_CHECK_EQUAL(retstring, std::string("value")); + + tizen_browser::config::Config::getInstance().set(std::string(" "), + std:: + string("anothervalue")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance().get(std::string(" "))); + BOOST_CHECK_EQUAL(retstring, std::string("anothervalue")); + + tizen_browser::config::Config::getInstance().set(std::string(" "), + std::string("value3")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance().get(std::string(" "))); + BOOST_CHECK_EQUAL(retstring, std::string("value3")); // Wrong value tests // NOTE Check that value is allowed to be empty. - tizen_browser::config::Config::getInstance().set(std::string("TestKey"), std::string("")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string("TestKey"))); - BOOST_CHECK(retstring.empty()); - - tizen_browser::config::Config::getInstance().set(std::string("TestKey"), std::string(" ")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string("TestKey"))); - BOOST_CHECK(!retstring.empty()); - - tizen_browser::config::Config::getInstance().set(std::string("AnotherTestKey"), std::string(" ")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string("AnotherTestKey"))); - BOOST_CHECK(!retstring.empty()); + tizen_browser::config::Config::getInstance().set(std::string("TestKey"), + std::string("")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get(std::string("TestKey"))); + BOOST_CHECK(retstring.empty()); + + tizen_browser::config::Config::getInstance().set(std::string("TestKey"), + std::string(" ")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get(std::string("TestKey"))); + BOOST_CHECK(!retstring.empty()); + + tizen_browser::config::Config::getInstance(). + set(std::string("AnotherTestKey"), std::string(" ")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get(std::string("AnotherTestKey"))); + BOOST_CHECK(!retstring.empty()); // Set two the same keys or values // NOTE Check that key or value are allowed have duplicates. This test case not allowed duplicates - tizen_browser::config::Config::getInstance().set(std::string("SameTestKey"), std::string("valueA")); - tizen_browser::config::Config::getInstance().set(std::string("SameTestKey"), std::string("valueB")); - retstring = boost::any_cast<std::string>(tizen_browser::config::Config::getInstance().get(std::string("SameTestKey"))); - BOOST_CHECK_EQUAL(std::string("valueB"), retstring); - BOOST_CHECK_PREDICATE( std::not_equal_to<std::string>(), (retstring)(std::string("valueA")) ); - - BROWSER_LOGI(TAG "--> END - config_boundary_conditions"); + tizen_browser::config::Config::getInstance().set(std::string("SameTestKey"), + std::string("valueA")); + tizen_browser::config::Config::getInstance().set(std::string("SameTestKey"), + std::string("valueB")); + retstring = + boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get(std::string("SameTestKey"))); + BOOST_CHECK_EQUAL(std::string("valueB"), retstring); + BOOST_CHECK_PREDICATE(std::not_equal_to < std::string > (), + (retstring) (std::string("valueA"))); + + BROWSER_LOGI(TAG "--> END - config_boundary_conditions"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_FavoriteService.cpp b/unit_tests/ut_FavoriteService.cpp index 53eaab64..b4bcba3e 100644..100755 --- a/unit_tests/ut_FavoriteService.cpp +++ b/unit_tests/ut_FavoriteService.cpp @@ -34,100 +34,118 @@ BOOST_AUTO_TEST_SUITE(bookmarks) -bool item_is_empty(std::shared_ptr<tizen_browser::services::BookmarkItem> item) { return item->getAddress() == std::string(); }; + bool item_is_empty(std::shared_ptr < + tizen_browser::services::BookmarkItem > item) +{ + return item->getAddress() == std::string(); +}; BOOST_AUTO_TEST_CASE(bookmark_add_remove) { - BROWSER_LOGI(TAG "bookmark_add_remove - START --> "); + BROWSER_LOGI(TAG "bookmark_add_remove - START --> "); - /// \todo: clean casts, depends on ServiceManager - std::shared_ptr<tizen_browser::services::BookmarkService> fs = + /// \todo: clean casts, depends on ServiceManager + std::shared_ptr < tizen_browser::services::BookmarkService > fs = std::dynamic_pointer_cast < - tizen_browser::services::BookmarkService, - tizen_browser::core::AbstractService + tizen_browser::services::BookmarkService, + tizen_browser::core::AbstractService > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.favoriteservice")); // fs->setStorageServiceTestMode(); - int bookcount = -1; - int bookcount2 = -1; - bool resultflag = false; + int bookcount = -1; + int bookcount2 = -1; + bool resultflag = false; // getBookmarks method test - std::shared_ptr<tizen_browser::services::BookmarkItem> bitem; - std::vector<std::shared_ptr<tizen_browser::services::BookmarkItem>> bookmarks_list = fs->getBookmarks(); - while(!bookmarks_list.empty()) { - bitem = bookmarks_list.back(); - BROWSER_LOGI(TAG "Element from cached bookmark list: id: %d, title: %s, URL: %s", bitem->getId(), - bitem->getTitle().c_str(), bitem->getAddress().c_str()); - bookmarks_list.pop_back(); - } + std::shared_ptr < tizen_browser::services::BookmarkItem > bitem; + std::vector < std::shared_ptr < + tizen_browser::services::BookmarkItem >> bookmarks_list = + fs->getBookmarks(); + while (!bookmarks_list.empty()) { + bitem = bookmarks_list.back(); + BROWSER_LOGI(TAG + "Element from cached bookmark list: id: %d, title: %s, URL: %s", + bitem->getId(), bitem->getTitle().c_str(), + bitem->getAddress().c_str()); + bookmarks_list.pop_back(); + } - BROWSER_LOGI(TAG "Above - current stored bookmarks (recently adder order"); + BROWSER_LOGI(TAG "Above - current stored bookmarks (recently adder order"); // clean all bookmarks - resultflag = fs->deleteAllBookmarks(); - BOOST_CHECK(resultflag); - fs->getBookmarks(); - BROWSER_LOGI(TAG "Above - current stored bookmarks after deleteAll, deleting resultflag: %d", resultflag); + resultflag = fs->deleteAllBookmarks(); + BOOST_CHECK(resultflag); + fs->getBookmarks(); + BROWSER_LOGI(TAG + "Above - current stored bookmarks after deleteAll, deleting resultflag: %d", + resultflag); // Empty bookmark test - bookcount = fs->countBookmarks(); - BOOST_CHECK(item_is_empty(fs->addToBookmarks("",""))); - bookcount2 = fs->countBookmarks(); - BOOST_CHECK_EQUAL(bookcount, bookcount2); - BROWSER_LOGI(TAG "Add empty bookmark test summary - number of bookmarks before: %d, after: %d", bookcount ,bookcount2); - fs->getBookmarks(); + bookcount = fs->countBookmarks(); + BOOST_CHECK(item_is_empty(fs->addToBookmarks("", ""))); + bookcount2 = fs->countBookmarks(); + BOOST_CHECK_EQUAL(bookcount, bookcount2); + BROWSER_LOGI(TAG + "Add empty bookmark test summary - number of bookmarks before: %d, after: %d", + bookcount, bookcount2); + fs->getBookmarks(); // Add bookmark with the same title - BOOST_CHECK(!item_is_empty(fs->addToBookmarks("www.thisis.url1","Title"))); - BOOST_CHECK(!item_is_empty(fs->addToBookmarks("www.thisis.url4","Title"))); - std::shared_ptr<tizen_browser::services::BookmarkItem> item_to_delete = fs->addToBookmarks("www.thisis.url5","Title"); - BOOST_CHECK(!item_is_empty(item_to_delete)); - fs->getBookmarks(); - BROWSER_LOGI(TAG "Before delete last bookmark (%s)", item_to_delete->getAddress().c_str()); - BOOST_CHECK(fs->deleteBookmark(item_to_delete->getAddress())); - BROWSER_LOGI(TAG "After delete bookmark"); - fs->getBookmarks(); + BOOST_CHECK(!item_is_empty(fs->addToBookmarks("www.thisis.url1", "Title"))); + BOOST_CHECK(!item_is_empty(fs->addToBookmarks("www.thisis.url4", "Title"))); + std::shared_ptr < tizen_browser::services::BookmarkItem > item_to_delete = + fs->addToBookmarks("www.thisis.url5", "Title"); + BOOST_CHECK(!item_is_empty(item_to_delete)); + fs->getBookmarks(); + BROWSER_LOGI(TAG "Before delete last bookmark (%s)", + item_to_delete->getAddress().c_str()); + BOOST_CHECK(fs->deleteBookmark(item_to_delete->getAddress())); + BROWSER_LOGI(TAG "After delete bookmark"); + fs->getBookmarks(); // Add duplicated url - BROWSER_LOGI(TAG "Add duplicated url"); - BOOST_CHECK(item_is_empty(fs->addToBookmarks("www.thisis.url4","Not duplicateTitle"))); - fs->getBookmarks(); + BROWSER_LOGI(TAG "Add duplicated url"); + BOOST_CHECK(item_is_empty + (fs->addToBookmarks("www.thisis.url4", "Not duplicateTitle"))); + fs->getBookmarks(); // check existing url - resultflag = fs->bookmarkExists("www.not_existing.url"); - BROWSER_LOGI(TAG "Check not existing url (%s) resultflag: %d", "www.not_existing.url", resultflag); - BOOST_CHECK(!resultflag); - resultflag = fs->bookmarkExists("www.thisis.url4"); - BROWSER_LOGI(TAG "Check existing url (%s) resultflag: %d", "www.thisis.url4", resultflag); - BOOST_CHECK(resultflag); - - BROWSER_LOGI(TAG "--> END - bookmark_add_remove"); + resultflag = fs->bookmarkExists("www.not_existing.url"); + BROWSER_LOGI(TAG "Check not existing url (%s) resultflag: %d", + "www.not_existing.url", resultflag); + BOOST_CHECK(!resultflag); + resultflag = fs->bookmarkExists("www.thisis.url4"); + BROWSER_LOGI(TAG "Check existing url (%s) resultflag: %d", + "www.thisis.url4", resultflag); + BOOST_CHECK(resultflag); + + BROWSER_LOGI(TAG "--> END - bookmark_add_remove"); } BOOST_AUTO_TEST_CASE(bookmark_synchro) { - /// \todo: clean casts, depends on ServiceManager - BROWSER_LOGI(TAG "bookmark_synchro - START --> "); + /// \todo: clean casts, depends on ServiceManager + BROWSER_LOGI(TAG "bookmark_synchro - START --> "); - std::shared_ptr<tizen_browser::services::BookmarkService> fs = + std::shared_ptr < tizen_browser::services::BookmarkService > fs = std::dynamic_pointer_cast < - tizen_browser::services::BookmarkService, - tizen_browser::core::AbstractService + tizen_browser::services::BookmarkService, + tizen_browser::core::AbstractService > - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.favoriteservice")); + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.favoriteservice")); - BROWSER_LOGI(TAG "Bookmarks synchronize test"); - fs->synchronizeBookmarks(); - BOOST_CHECK(!fs->getBookmarks().empty()); + BROWSER_LOGI(TAG "Bookmarks synchronize test"); + fs->synchronizeBookmarks(); + BOOST_CHECK(!fs->getBookmarks().empty()); - BROWSER_LOGI(TAG "--> END - bookmark_synchro"); + BROWSER_LOGI(TAG "--> END - bookmark_synchro"); } BOOST_AUTO_TEST_SUITE_END() - diff --git a/unit_tests/ut_HomeGenerator.cpp b/unit_tests/ut_HomeGenerator.cpp index 82c2a1e6..82c2a1e6 100644..100755 --- a/unit_tests/ut_HomeGenerator.cpp +++ b/unit_tests/ut_HomeGenerator.cpp diff --git a/unit_tests/ut_PlatformInputManager.cpp b/unit_tests/ut_PlatformInputManager.cpp index 728e0a42..728e0a42 100644..100755 --- a/unit_tests/ut_PlatformInputManager.cpp +++ b/unit_tests/ut_PlatformInputManager.cpp diff --git a/unit_tests/ut_SessionStorage.cpp b/unit_tests/ut_SessionStorage.cpp index b56901a3..be06856e 100644..100755 --- a/unit_tests/ut_SessionStorage.cpp +++ b/unit_tests/ut_SessionStorage.cpp @@ -29,252 +29,280 @@ BOOST_AUTO_TEST_SUITE(SessionStorage) -BOOST_AUTO_TEST_CASE(InitSession) + BOOST_AUTO_TEST_CASE(InitSession) { - BROWSER_LOGI("[UT] SessionStorage - InitSession - START --> "); + BROWSER_LOGI("[UT] SessionStorage - InitSession - START --> "); - std::string resourceDbDir(boost::any_cast < std::string > (tizen_browser::config::Config::getInstance().get("resourcedb/dir"))); - std::string sessionDb(boost::any_cast < std::string > (tizen_browser::config::Config::getInstance().get("DB_SESSION"))); + std::string resourceDbDir(boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get("resourcedb/dir"))); + std::string sessionDb(boost::any_cast < std::string > + (tizen_browser::config::Config::getInstance(). + get("DB_SESSION"))); - boost::filesystem::path dbFile(resourceDbDir + sessionDb); - boost::filesystem::remove(dbFile); + boost::filesystem::path dbFile(resourceDbDir + sessionDb); + boost::filesystem::remove(dbFile); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - BOOST_REQUIRE(sessionService); - BOOST_CHECK_EQUAL(sessionService->getName(), DOMAIN_SESSION_STORAE_SERVICE); + BOOST_REQUIRE(sessionService); + BOOST_CHECK_EQUAL(sessionService->getName(), DOMAIN_SESSION_STORAE_SERVICE); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - BOOST_REQUIRE(storage); + BOOST_REQUIRE(storage); - BROWSER_LOGI("[UT] --> END - SessionStorage - InitSession"); + BROWSER_LOGI("[UT] --> END - SessionStorage - InitSession"); } BOOST_AUTO_TEST_CASE(CreateAndPopulateSession) { - BROWSER_LOGI("[UT] SessionStorage - CreateAndPopulateSession - START --> "); + BROWSER_LOGI("[UT] SessionStorage - CreateAndPopulateSession - START --> "); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - BOOST_REQUIRE(sessionService); + BOOST_REQUIRE(sessionService); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - BOOST_REQUIRE(storage); + BOOST_REQUIRE(storage); - tizen_browser::Session::Session session(storage->createSession()); + tizen_browser::Session::Session session(storage->createSession()); - BOOST_CHECK(session.isValid()); + BOOST_CHECK(session.isValid()); - std::map<std::string, std::pair<std::string, std::string>> urls; + std::map < std::string, std::pair < std::string, std::string >> urls; - urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = std::pair<std::string, std::string>("http://www.calligra.org", "Title"); - urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = std::pair<std::string, std::string>("http://www.kde.org", "Title"); - urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = std::pair<std::string, std::string>("http://www.krita.org", "Title"); + urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = + std::pair < std::string, std::string > ("http://www.calligra.org", + "Title"); + urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = + std::pair < std::string, std::string > ("http://www.kde.org", "Title"); + urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = + std::pair < std::string, std::string > ("http://www.krita.org", "Title"); - for(auto iter = urls.begin(), end = urls.end(); iter != end; iter++){ - session.updateItem(iter->first, iter->second.first, iter->second.second); - } + for (auto iter = urls.begin(), end = urls.end(); iter != end; iter++) { + session.updateItem(iter->first, iter->second.first, iter->second.second); + } - BOOST_CHECK_EQUAL(session.items().size(), 3); + BOOST_CHECK_EQUAL(session.items().size(), 3); - std::string replaceUrl("https://marble.kde.org/"); + std::string replaceUrl("https://marble.kde.org/"); - session.updateItem(std::next(urls.begin(), 2)->first, replaceUrl, std::next(urls.begin(), 2)->second.second); - BOOST_CHECK_EQUAL_COLLECTIONS( - replaceUrl.begin(), - replaceUrl.end(), - session.items().at(std::next(urls.begin(),2)->first).first.begin(), - session.items().at(std::next(urls.begin(),2)->first).first.end() - ); + session.updateItem(std::next(urls.begin(), 2)->first, replaceUrl, + std::next(urls.begin(), 2)->second.second); + BOOST_CHECK_EQUAL_COLLECTIONS(replaceUrl.begin(), replaceUrl.end(), + session.items(). + at(std::next(urls.begin(), 2)->first).first. + begin(), + session.items(). + at(std::next(urls.begin(), 2)->first).first. + end()); + session.removeItem(std::next(urls.begin(), 1)->first); - session.removeItem(std::next(urls.begin(),1)->first); + BOOST_CHECK_EQUAL(session.items().size(), 2); - BOOST_CHECK_EQUAL(session.items().size(), 2); - - BROWSER_LOGI("[UT] --> END - SessionStorage - CreateAndPopulateSession"); + BROWSER_LOGI("[UT] --> END - SessionStorage - CreateAndPopulateSession"); } BOOST_AUTO_TEST_CASE(getLastSession) { - BROWSER_LOGI("[UT] SessionStorage - getLastSession - START --> "); + BROWSER_LOGI("[UT] SessionStorage - getLastSession - START --> "); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); - - BOOST_REQUIRE(sessionService); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + BOOST_REQUIRE(sessionService); - BOOST_REQUIRE(storage); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - sleep(2); - tizen_browser::Session::Session session(storage->createSession()); - const std::string newSessionName("theLastOfUs"); + BOOST_REQUIRE(storage); - session.setSessionName("theLastOfUs"); + sleep(2); + tizen_browser::Session::Session session(storage->createSession()); + const std::string newSessionName("theLastOfUs"); - BOOST_CHECK(session.isValid()); + session.setSessionName("theLastOfUs"); - std::map<std::string, std::pair<std::string, std::string>> urls; + BOOST_CHECK(session.isValid()); - urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = std::pair<std::string, std::string>("http://www.calligra.org", "Title"); - urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = std::pair<std::string, std::string>("http://www.kde.org", "Title"); - urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = std::pair<std::string, std::string>("http://www.krita.org", "Title"); + std::map < std::string, std::pair < std::string, std::string >> urls; - for(auto iter = urls.begin(), end = urls.end(); iter != end; iter++){ - session.updateItem(iter->first, iter->second.first, iter->second.second); - } + urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = + std::pair < std::string, std::string > ("http://www.calligra.org", + "Title"); + urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = + std::pair < std::string, std::string > ("http://www.kde.org", "Title"); + urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = + std::pair < std::string, std::string > ("http://www.krita.org", "Title"); - BOOST_CHECK_EQUAL(session.items().size(), 3); + for (auto iter = urls.begin(), end = urls.end(); iter != end; iter++) { + session.updateItem(iter->first, iter->second.first, iter->second.second); + } - tizen_browser::Session::Session lastSession(storage->getLastSession()); + BOOST_CHECK_EQUAL(session.items().size(), 3); - BOOST_REQUIRE(lastSession.isValid()); + tizen_browser::Session::Session lastSession(storage->getLastSession()); - BOOST_CHECK_EQUAL_COLLECTIONS( - newSessionName.begin(), - newSessionName.end(), - lastSession.sessionName().begin(), - lastSession.sessionName().end() - ); + BOOST_REQUIRE(lastSession.isValid()); - BOOST_CHECK_EQUAL(lastSession.items().size(), 3); + BOOST_CHECK_EQUAL_COLLECTIONS(newSessionName.begin(), + newSessionName.end(), + lastSession.sessionName().begin(), + lastSession.sessionName().end()); + BOOST_CHECK_EQUAL(lastSession.items().size(), 3); - BROWSER_LOGI("[UT] --> END - SessionStorage - getLastSession"); + BROWSER_LOGI("[UT] --> END - SessionStorage - getLastSession"); } BOOST_AUTO_TEST_CASE(getAllSessions) { - BROWSER_LOGI("[UT] SessionStorage - getAllSessions - START --> "); + BROWSER_LOGI("[UT] SessionStorage - getAllSessions - START --> "); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - BOOST_REQUIRE(sessionService); + BOOST_REQUIRE(sessionService); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - BOOST_REQUIRE(storage); + BOOST_REQUIRE(storage); - //new session should be newer then previous one. - tizen_browser::Session::SessionsVector sessions(storage->getAllSessions()); + //new session should be newer then previous one. + tizen_browser::Session::SessionsVector sessions(storage->getAllSessions()); - BOOST_CHECK_EQUAL(sessions.size(), 2); + BOOST_CHECK_EQUAL(sessions.size(), 2); - BROWSER_LOGI("[UT] --> END - SessionStorage - getAllSessions"); + BROWSER_LOGI("[UT] --> END - SessionStorage - getAllSessions"); } BOOST_AUTO_TEST_CASE(deleteSession) { - BROWSER_LOGI("[UT] SessionStorage - deleteSession - START --> "); + BROWSER_LOGI("[UT] SessionStorage - deleteSession - START --> "); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - BOOST_REQUIRE(sessionService); + BOOST_REQUIRE(sessionService); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - BOOST_REQUIRE(storage); + BOOST_REQUIRE(storage); - //new session should be newer then previous one. - tizen_browser::Session::SessionsVector sessions(storage->getAllSessions()); + //new session should be newer then previous one. + tizen_browser::Session::SessionsVector sessions(storage->getAllSessions()); - storage->deleteSession(sessions.at(0)); + storage->deleteSession(sessions.at(0)); - tizen_browser::Session::SessionsVector sessionsBucket(storage->getAllSessions()); + tizen_browser::Session::SessionsVector sessionsBucket(storage-> + getAllSessions()); - BOOST_CHECK_EQUAL(sessionsBucket.size(),1); + BOOST_CHECK_EQUAL(sessionsBucket.size(), 1); - BROWSER_LOGI("[UT] --> END - SessionStorage - deleteSession"); + BROWSER_LOGI("[UT] --> END - SessionStorage - deleteSession"); } BOOST_AUTO_TEST_CASE(deleteAllSessions) { - BROWSER_LOGI("[UT] SessionStorage - deleteAllSessions - START --> "); + BROWSER_LOGI("[UT] SessionStorage - deleteAllSessions - START --> "); - std::shared_ptr<tizen_browser::services::SessionStorage> sessionService = + std::shared_ptr < tizen_browser::services::SessionStorage > sessionService = std::dynamic_pointer_cast < - tizen_browser::services::SessionStorage, - tizen_browser::core::AbstractService - >(tizen_browser::core::ServiceManager::getInstance().getService(DOMAIN_SESSION_STORAE_SERVICE)); + tizen_browser::services::SessionStorage, + tizen_browser::core::AbstractService + > + (tizen_browser::core::ServiceManager::getInstance(). + getService(DOMAIN_SESSION_STORAE_SERVICE)); - BOOST_REQUIRE(sessionService); + BOOST_REQUIRE(sessionService); - tizen_browser::storage::SessionStorage* storage=0; - storage = sessionService->getStorage(); + tizen_browser::storage::SessionStorage * storage = 0; + storage = sessionService->getStorage(); - BOOST_REQUIRE(storage); + BOOST_REQUIRE(storage); - //new session should be newer then previous one. - sleep(1); - tizen_browser::Session::Session session2(storage->createSession()); - sleep(1); - tizen_browser::Session::Session session3(storage->createSession()); - sleep(1); - tizen_browser::Session::Session session4(storage->createSession()); + //new session should be newer then previous one. + sleep(1); + tizen_browser::Session::Session session2(storage->createSession()); + sleep(1); + tizen_browser::Session::Session session3(storage->createSession()); + sleep(1); + tizen_browser::Session::Session session4(storage->createSession()); - std::map<std::string, std::pair<std::string, std::string>> urls; + std::map < std::string, std::pair < std::string, std::string >> urls; - urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = std::pair<std::string, std::string>("http://www.calligra.org", "Title"); - urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = std::pair<std::string, std::string>("http://www.kde.org", "Title"); - urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = std::pair<std::string, std::string>("http://www.krita.org", "Title"); + urls["54379ff6-f9ff-4ef3-99b0-a0de00edd473"] = + std::pair < std::string, std::string > ("http://www.calligra.org", + "Title"); + urls["7b5719d4-c2f5-4d87-89ff-9cd70da1710f"] = + std::pair < std::string, std::string > ("http://www.kde.org", "Title"); + urls["ce18e8e2-8d33-4ba7-9fc4-d602cdf3fa36"] = + std::pair < std::string, std::string > ("http://www.krita.org", "Title"); - for(auto iter = urls.begin(), end = urls.end(); iter != end; iter++){ - session2.updateItem(iter->first, iter->second.first, iter->second.second); - sleep(1); - session3.updateItem(iter->first, iter->second.first, iter->second.second); - sleep(1); - session4.updateItem(iter->first, iter->second.first, iter->second.second); - } + for (auto iter = urls.begin(), end = urls.end(); iter != end; iter++) { + session2.updateItem(iter->first, iter->second.first, iter->second.second); + sleep(1); + session3.updateItem(iter->first, iter->second.first, iter->second.second); + sleep(1); + session4.updateItem(iter->first, iter->second.first, iter->second.second); + } - tizen_browser::Session::SessionsVector sessionsBucket(storage->getAllSessions()); + tizen_browser::Session::SessionsVector sessionsBucket(storage-> + getAllSessions()); - BOOST_CHECK_EQUAL(sessionsBucket.size(), 4); + BOOST_CHECK_EQUAL(sessionsBucket.size(), 4); - storage->deleteAllSessions(); + storage->deleteAllSessions(); - sessionsBucket = storage->getAllSessions(); + sessionsBucket = storage->getAllSessions(); - BOOST_CHECK_EQUAL(sessionsBucket.size(), 0); + BOOST_CHECK_EQUAL(sessionsBucket.size(), 0); - BROWSER_LOGI("[UT] --> END - SessionStorage - deleteAllSessions"); + BROWSER_LOGI("[UT] --> END - SessionStorage - deleteAllSessions"); } BOOST_AUTO_TEST_SUITE_END() diff --git a/unit_tests/ut_StorageService.cpp b/unit_tests/ut_StorageService.cpp index 95c88431..95c88431 100644..100755 --- a/unit_tests/ut_StorageService.cpp +++ b/unit_tests/ut_StorageService.cpp diff --git a/unit_tests/ut_WebEngineService.cpp b/unit_tests/ut_WebEngineService.cpp index 07c97e07..a7d27a2e 100644..100755 --- a/unit_tests/ut_WebEngineService.cpp +++ b/unit_tests/ut_WebEngineService.cpp @@ -28,372 +28,436 @@ BOOST_AUTO_TEST_SUITE(WebEngineService) -BOOST_AUTO_TEST_CASE(EwkInit) + BOOST_AUTO_TEST_CASE(EwkInit) { - BROWSER_LOGI(TAG "EwkInit - START --> "); - BOOST_REQUIRE(ewk_init() > 0); - BROWSER_LOGI(TAG "--> END - EwkInit"); + BROWSER_LOGI(TAG "EwkInit - START --> "); + BOOST_REQUIRE(ewk_init() > 0); + BROWSER_LOGI(TAG "--> END - EwkInit"); } BOOST_AUTO_TEST_CASE(UriSetGet) { - BROWSER_LOGI(TAG "UriSetGet - START --> "); + BROWSER_LOGI(TAG "UriSetGet - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); // elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); // Evas_Object *main_window = elm_win_util_standard_add("browserApp-ut", "browserApp-ut"); // if (main_window == nullptr) // BROWSER_LOGE(TAG "Failed to create main window"); // elm_win_autodel_set(main_window, EINA_TRUE); - Evas_Object *main_window = nullptr; + Evas_Object *main_window = nullptr; - webEngineService->init(main_window); + webEngineService->init(main_window); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - BOOST_CHECK(!(webEngineService->getLayout())); + BOOST_CHECK(!(webEngineService->getLayout())); - webEngineService->setURI("www.test2.com"); + webEngineService->setURI("www.test2.com"); - // URIs are different because of WebKit didn't load webpage (lack of initialization) - BOOST_TEST_MESSAGE(TAG "Print getURI():" << webEngineService->getURI()); + // URIs are different because of WebKit didn't load webpage (lack of initialization) + BOOST_TEST_MESSAGE(TAG "Print getURI():" << webEngineService->getURI()); - BOOST_TEST_MESSAGE(TAG "Print getTitle():" << webEngineService->getTitle()); + BOOST_TEST_MESSAGE(TAG "Print getTitle():" << webEngineService->getTitle()); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - UriSetGet"); + BROWSER_LOGI(TAG "--> END - UriSetGet"); } BOOST_AUTO_TEST_CASE(NavigationTest) { - BROWSER_LOGI(TAG "NavigationTest - START --> "); + BROWSER_LOGI(TAG "NavigationTest - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test2.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test2.com"); - webEngineService->stopLoading(); + webEngineService->stopLoading(); - webEngineService->reload(); + webEngineService->reload(); - webEngineService->setURI("www.nextpage.com"); + webEngineService->setURI("www.nextpage.com"); - BOOST_TEST_MESSAGE(TAG "Is back enabled: " << webEngineService->isBackEnabled()); + BOOST_TEST_MESSAGE(TAG "Is back enabled: " << webEngineService-> + isBackEnabled()); - webEngineService->back(); + webEngineService->back(); - BOOST_TEST_MESSAGE(TAG "Is forward enabled: " << webEngineService->isForwardEnabled()); + BOOST_TEST_MESSAGE(TAG "Is forward enabled: " << webEngineService-> + isForwardEnabled()); - webEngineService->forward(); + webEngineService->forward(); - BOOST_TEST_MESSAGE(TAG "Is loading: " << webEngineService->isLoading()); + BOOST_TEST_MESSAGE(TAG "Is loading: " << webEngineService->isLoading()); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - NavigationTest"); + BROWSER_LOGI(TAG "--> END - NavigationTest"); } BOOST_AUTO_TEST_CASE(ClearPrivateData) { - BROWSER_LOGI(TAG "ClearPrivateData - START --> "); + BROWSER_LOGI(TAG "ClearPrivateData - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.clearingdata.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.clearingdata.com"); - webEngineService->clearPrivateData(); + webEngineService->clearPrivateData(); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - ClearPrivateData"); + BROWSER_LOGI(TAG "--> END - ClearPrivateData"); } BOOST_AUTO_TEST_CASE(TabsCreationDeletion) { - BROWSER_LOGI(TAG "TabsCreationDeletion - START --> "); + BROWSER_LOGI(TAG "TabsCreationDeletion - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - BOOST_TEST_MESSAGE(TAG "Tabs count: " << webEngineService->tabsCount()); + BOOST_TEST_MESSAGE(TAG "Tabs count: " << webEngineService->tabsCount()); - tizen_browser::basic_webengine::TabId first = webEngineService->addTab("www.first.com"); + tizen_browser::basic_webengine::TabId first = + webEngineService->addTab("www.first.com"); - BOOST_CHECK(webEngineService->tabsCount() == 1); + BOOST_CHECK(webEngineService->tabsCount() == 1); - tizen_browser::basic_webengine::TabId second = webEngineService->addTab("www.second.com"); + tizen_browser::basic_webengine::TabId second = + webEngineService->addTab("www.second.com"); - BOOST_CHECK(webEngineService->tabsCount() == 2); + BOOST_CHECK(webEngineService->tabsCount() == 2); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab(first)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService-> + closeTab(first)); - BOOST_CHECK(webEngineService->tabsCount() == 1); + BOOST_CHECK(webEngineService->tabsCount() == 1); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab(second)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService-> + closeTab(second)); - BOOST_CHECK(!(webEngineService->tabsCount())); + BOOST_CHECK(!(webEngineService->tabsCount())); - BROWSER_LOGI(TAG "--> END - TabsCreationDeletion"); + BROWSER_LOGI(TAG "--> END - TabsCreationDeletion"); } BOOST_AUTO_TEST_CASE(TabsSwitching) { - BROWSER_LOGI(TAG "TabsSwitching - START --> "); + BROWSER_LOGI(TAG "TabsSwitching - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - BOOST_TEST_MESSAGE(TAG "Tabs count: " << webEngineService->tabsCount()); + BOOST_TEST_MESSAGE(TAG "Tabs count: " << webEngineService->tabsCount()); - BOOST_TEST_MESSAGE(TAG "Initial current tab: " << webEngineService->currentTabId().toString()); + BOOST_TEST_MESSAGE(TAG "Initial current tab: " << webEngineService-> + currentTabId().toString()); - tizen_browser::basic_webengine::TabId first = webEngineService->addTab("www.first.com"); - BOOST_TEST_MESSAGE(TAG "First tab: " << first.toString()); + tizen_browser::basic_webengine::TabId first = + webEngineService->addTab("www.first.com"); + BOOST_TEST_MESSAGE(TAG "First tab: " << first.toString()); - webEngineService->switchToTab(first); + webEngineService->switchToTab(first); - BOOST_CHECK(webEngineService->currentTabId() == first); + BOOST_CHECK(webEngineService->currentTabId() == first); - BOOST_CHECK(webEngineService->tabsCount() == 1); + BOOST_CHECK(webEngineService->tabsCount() == 1); - tizen_browser::basic_webengine::TabId second = webEngineService->addTab("www.second.com"); - BOOST_TEST_MESSAGE(TAG "Second tab: " << second.toString()); + tizen_browser::basic_webengine::TabId second = + webEngineService->addTab("www.second.com"); + BOOST_TEST_MESSAGE(TAG "Second tab: " << second.toString()); - BOOST_CHECK(webEngineService->currentTabId() == first); + BOOST_CHECK(webEngineService->currentTabId() == first); - webEngineService->switchToTab(second); + webEngineService->switchToTab(second); - BOOST_CHECK(webEngineService->currentTabId() == second); + BOOST_CHECK(webEngineService->currentTabId() == second); - BOOST_CHECK(webEngineService->tabsCount() == 2); + BOOST_CHECK(webEngineService->tabsCount() == 2); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab(second)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService-> + closeTab(second)); - BOOST_CHECK(webEngineService->currentTabId() == first); + BOOST_CHECK(webEngineService->currentTabId() == first); - BOOST_CHECK(webEngineService->tabsCount() == 1); + BOOST_CHECK(webEngineService->tabsCount() == 1); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab(first)); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService-> + closeTab(first)); - BOOST_CHECK(!(webEngineService->tabsCount())); + BOOST_CHECK(!(webEngineService->tabsCount())); - BROWSER_LOGI(TAG "--> END - TabsSwitching"); + BROWSER_LOGI(TAG "--> END - TabsSwitching"); } BOOST_AUTO_TEST_CASE(Snapshots) { - BROWSER_LOGI(TAG "Snapshots - START --> "); + BROWSER_LOGI(TAG "Snapshots - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - webEngineService->getSnapshotData(100, 100); + webEngineService->getSnapshotData(100, 100); - webEngineService->getSnapshotData(parentTabId, 100, 100); + webEngineService->getSnapshotData(parentTabId, 100, 100); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - Snapshots"); + BROWSER_LOGI(TAG "--> END - Snapshots"); } BOOST_AUTO_TEST_CASE(PrivateModeOnOff) { - BROWSER_LOGI(TAG "PrivateModeOnOff - START --> "); + BROWSER_LOGI(TAG "PrivateModeOnOff - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - BOOST_CHECK(!(webEngineService->isPrivateMode())); + BOOST_CHECK(!(webEngineService->isPrivateMode())); - webEngineService->setPrivateMode(true); + webEngineService->setPrivateMode(true); - BOOST_CHECK(webEngineService->isPrivateMode()); + BOOST_CHECK(webEngineService->isPrivateMode()); - webEngineService->setPrivateMode(false); + webEngineService->setPrivateMode(false); - BOOST_CHECK(!(webEngineService->isPrivateMode())); + BOOST_CHECK(!(webEngineService->isPrivateMode())); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - PrivateModeOnOff"); + BROWSER_LOGI(TAG "--> END - PrivateModeOnOff"); } BOOST_AUTO_TEST_CASE(LoadErrorDefaultValue) { - BROWSER_LOGI(TAG "LoadErrorDefaultValue - START --> "); + BROWSER_LOGI(TAG "LoadErrorDefaultValue - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - BOOST_CHECK(!(webEngineService->isLoadError())); + BOOST_CHECK(!(webEngineService->isLoadError())); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - LoadErrorDefaultValue"); + BROWSER_LOGI(TAG "--> END - LoadErrorDefaultValue"); } BOOST_AUTO_TEST_CASE(Focus) { - BROWSER_LOGI(TAG "Focus - START --> "); + BROWSER_LOGI(TAG "Focus - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - BOOST_TEST_MESSAGE(TAG "Has focus at start:" << webEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus at start:" << webEngineService-> + hasFocus()); - webEngineService->setFocus(); + webEngineService->setFocus(); - BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << webEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << + webEngineService->hasFocus()); - webEngineService->clearFocus(); + webEngineService->clearFocus(); - BOOST_TEST_MESSAGE(TAG "Has focus after clearing focus:" << webEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after clearing focus:" << + webEngineService->hasFocus()); - webEngineService->setFocus(); + webEngineService->setFocus(); - BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << webEngineService->hasFocus()); + BOOST_TEST_MESSAGE(TAG "Has focus after setting focus:" << + webEngineService->hasFocus()); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - Focus"); + BROWSER_LOGI(TAG "--> END - Focus"); } BOOST_AUTO_TEST_CASE(ZoomAndAutofit) { - BROWSER_LOGI(TAG "ZoomAndAutofit - START --> "); + BROWSER_LOGI(TAG "ZoomAndAutofit - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - BOOST_TEST_MESSAGE(TAG "Zoom factor at start:" << webEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor at start:" << webEngineService-> + getZoomFactor()); - webEngineService->setZoomFactor(200); + webEngineService->setZoomFactor(200); - BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 200:" << webEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 200:" << + webEngineService->getZoomFactor()); - webEngineService->setZoomFactor(100); + webEngineService->setZoomFactor(100); - BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 100:" << webEngineService->getZoomFactor()); + BOOST_TEST_MESSAGE(TAG "Zoom factor after setting 100:" << + webEngineService->getZoomFactor()); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - ZoomAndAutofit"); + BROWSER_LOGI(TAG "--> END - ZoomAndAutofit"); } BOOST_AUTO_TEST_CASE(Favicon) { - BROWSER_LOGI(TAG "Favicon - START --> "); + BROWSER_LOGI(TAG "Favicon - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - webEngineService->getFavicon(); + webEngineService->getFavicon(); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - Favicon"); + BROWSER_LOGI(TAG "--> END - Favicon"); } BOOST_AUTO_TEST_CASE(SearchOnWebsite) { - BROWSER_LOGI(TAG "SearchOnWebsite - START --> "); + BROWSER_LOGI(TAG "SearchOnWebsite - START --> "); - std::shared_ptr<tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>> webEngineService = - std::dynamic_pointer_cast - <tizen_browser::basic_webengine::AbstractWebEngine<Evas_Object>,tizen_browser::core::AbstractService> - (tizen_browser::core::ServiceManager::getInstance().getService("org.tizen.browser.webengineservice")); + std::shared_ptr < tizen_browser::basic_webengine::AbstractWebEngine < + Evas_Object >> webEngineService = + std::dynamic_pointer_cast < + tizen_browser::basic_webengine::AbstractWebEngine < Evas_Object >, + tizen_browser::core::AbstractService > + (tizen_browser::core::ServiceManager::getInstance(). + getService("org.tizen.browser.webengineservice")); - BOOST_CHECK(webEngineService); + BOOST_CHECK(webEngineService); - webEngineService->init(NULL); + webEngineService->init(NULL); - tizen_browser::basic_webengine::TabId parentTabId = webEngineService->addTab("www.test.com"); + tizen_browser::basic_webengine::TabId parentTabId = + webEngineService->addTab("www.test.com"); - webEngineService->searchOnWebsite("test", 0); + webEngineService->searchOnWebsite("test", 0); - webEngineService->searchOnWebsite("test2", 0); + webEngineService->searchOnWebsite("test2", 0); - webEngineService->searchOnWebsite("", 0); + webEngineService->searchOnWebsite("", 0); - BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); + BOOST_TEST_MESSAGE(TAG "Print closeTab():" << webEngineService->closeTab()); - BROWSER_LOGI(TAG "--> END - SearchOnWebsite"); + BROWSER_LOGI(TAG "--> END - SearchOnWebsite"); } //BOOST_AUTO_TEST_CASE(EwkShutdown) diff --git a/unit_tests/ut_coreService.cpp b/unit_tests/ut_coreService.cpp index 135e5534..2700b264 100644..100755 --- a/unit_tests/ut_coreService.cpp +++ b/unit_tests/ut_coreService.cpp @@ -25,7 +25,7 @@ BOOST_AUTO_TEST_SUITE(core_ServiceManager) -namespace tbc=tizen_browser::core; +namespace tbc = tizen_browser::core; BOOST_AUTO_TEST_CASE(singleton) { diff --git a/unit_tests/ut_logger.cpp b/unit_tests/ut_logger.cpp index 2e99124a..2e99124a 100644..100755 --- a/unit_tests/ut_logger.cpp +++ b/unit_tests/ut_logger.cpp diff --git a/unit_tests/ut_main.cpp b/unit_tests/ut_main.cpp index f5c73ed9..f5c73ed9 100644..100755 --- a/unit_tests/ut_main.cpp +++ b/unit_tests/ut_main.cpp |