void onSysEvent(const ucl::SysEvent sysEvent);
void onPageExitRequest(Page &page);
+ Eina_Bool onKeyUpEventCb(int type, void *event);
+
private:
ucl::SysEventProvider &m_sysEventProvider;
ucl::IInstanceContext *m_context;
ucl::Theme m_theme;
PageWRef m_page;
+
+ Ecore_Event_Handler *m_keyUpEventHandler;
};
}
void stopEndCallTimer();
Eina_Bool onEndCallTimerCb();
+ void onPowerKeyUp(ucl::Widget &widget, void *eventInfo);
+ void processKeyPress();
+
// Presenter
virtual void onActivateBy(const DeactivatorInfo &info) final override;
#include <unordered_set>
-#include "ucl/gui/ElmWidget.h"
+#include "ucl/gui/Window.h"
#include "types.h"
ucl::Result prepare(ucl::ElmWidget &widget);
+ ucl::Window &getWindow();
+
void addDeactivatorSource(ucl::Widget &source);
void addDeactivatorException(void *deactivator);
private:
std::unordered_set<void *> m_deactivatorExceptions;
std::unordered_set<void *> m_deactivators;
- ucl::WidgetWRef m_topWidget;
+ ucl::WindowSRef m_window;
bool m_isPrepared;
};
}
namespace callui {
- constexpr auto TEL_NUMBER_MAX_SIZE = 82;
+ using namespace ucl;
+
+ constexpr SmartEvent WIN_POWER_KEY_UP_EVENT {"callui,powerkey,up"};
+
}
#endif // __CALLUI_COMMON_H__
#include "common.h"
+namespace callui { namespace { namespace impl {
+
+ constexpr auto TEL_NUMBER_MAX_SIZE = 82;
+
+}}}
+
namespace callui {
using namespace ucl;
Result CallManager::dialVoiceCall(const std::string &number)
{
- char buff[TEL_NUMBER_MAX_SIZE] = { 0 };
+ char buff[impl::TEL_NUMBER_MAX_SIZE] = { 0 };
snprintf(buff, sizeof(buff), "%s", number.c_str());
return convertCMResult(
void SoundManager::audioStateChangedCb(cm_audio_state_type_e state)
{
if (state == CM_AUDIO_STATE_NONE_E) {
- ELOG("Unhandled state [%d]", state);
+ ILOG("Ignore. Unhandled state [%d]", state);
return;
}
#include "resources.h"
#include "common.h"
+namespace callui { namespace { namespace impl {
+
+ using namespace ucl;
+
+ const char *STR_POWER_KEY = "XF86PowerOff";
+
+}}}
+
namespace callui {
using namespace ucl;
Instance::Instance(SysEventProvider &sysEventProvider) :
m_sysEventProvider(sysEventProvider),
- m_context(nullptr)
+ m_context(nullptr),
+ m_keyUpEventHandler(nullptr)
{
}
Instance::~Instance()
{
+ elm_win_keygrab_unset(*m_win, impl::STR_POWER_KEY, 0, 0);
+
+ if (m_keyUpEventHandler) {
+ ecore_event_handler_del(m_keyUpEventHandler);
+ }
+
if (m_page) {
m_page->exitNoTransition();
}
m_win = m_context->getWindow();
+ elm_win_keygrab_set(*m_win, impl::STR_POWER_KEY, 0, 0, 0,
+ ELM_WIN_KEYGRAB_EXCLUSIVE);
+
+ m_keyUpEventHandler = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
+ CALLBACK_A(Instance::onKeyUpEventCb), this);
+ if (!m_keyUpEventHandler) {
+ LOG_RETURN(RES_FAIL, "m_eventHandler is NULL");
+ }
+
FAIL_RETURN(setupTheme(), "setupTheme() failed!");
m_call = CallBuilder().build();
return RES_OK;
}
+ Eina_Bool Instance::onKeyUpEventCb(int type, void *event)
+ {
+ if (!event) {
+ LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_DONE, "event is NULL");
+ }
+
+ Ecore_Event_Key *ev = static_cast<Ecore_Event_Key *>(event);
+ if (!strcmp(ev->keyname, impl::STR_POWER_KEY)) {
+ DLOG("Key power [Up]");
+ m_win->callEvent(WIN_POWER_KEY_UP_EVENT, nullptr);
+ }
+ return ECORE_CALLBACK_DONE;
+ }
+
void Instance::onPageExitRequest(Page &page)
{
m_context->exitApp();
Result MainPage::prepare()
{
+ DLOG();
m_cm = m_call->getCallManager();
if (!m_cm) {
LOG_RETURN(RES_FAIL, "Call manager is NULL!");
m_widget->setContent(m_indicator->getWidget().getEo(), impl::PART_SWL_INDICATOR);
+ auto win = m_widget->getWindow();
+ if (!win) {
+ LOG_RETURN(RES_FAIL, "win is NULL!");
+ }
+ win->addEventHandler(WIN_POWER_KEY_UP_EVENT, WEAK_DELEGATE(
+ MainPage::onPowerKeyUp, asWeak(*this)));
+
return Page::prepare([this]() {
return getNaviframe().
push(*m_widget);
}
}
- void MainPage::onBackKey()
+ void MainPage::processKeyPress()
{
- if (m_cm->getAvailableCalls()
- == CALL_FLAG_END) {
+ switch (m_mode) {
+ case CallMode::INCOMING:
+ {
+ auto incom = m_cm->getIncomingCall();
+ if (!incom) {
+ LOG_RETURN_VOID(RES_FAIL, "incom is NULL");
+ }
+ incom->stopAlert();
+ break;
+ }
+ case CallMode::END:
requestExit();
+ break;
+ default:
+ break;
+ }
+ }
+
+ void MainPage::onBackKey()
+ {
+ processKeyPress();
+ }
+
+ void MainPage::onPowerKeyUp(ucl::Widget &widget, void *eventInfo)
+ {
+ if (isActive()) {
+ processKeyPress();
}
}
Result Presenter::prepare(ElmWidget &widget)
{
- m_topWidget = asWeak(asWidget(widget.getTopWidget()));
- if (!m_topWidget) {
- LOG_RETURN(RES_FAIL, "m_topWidget is NULL!");
+ m_window = asShared(widget.getWindow());
+ if (!m_window) {
+ LOG_RETURN(RES_FAIL, "m_window is NULL!");
}
- addDeactivatorSource(*m_topWidget);
+ addDeactivatorSource(*m_window);
m_isPrepared = true;
return RES_OK;
}
+ Window &Presenter::getWindow()
+ {
+ return *m_window;
+ }
+
void Presenter::addDeactivatorSource(Widget &source)
{
source.addEventHandler(impl::ACTIVATE_BY,
void Presenter::broadcastDeactivator(const SmartEvent event,
void *const deactivator)
{
- if (m_topWidget) {
- sendDeactivatorInfo(*m_topWidget, event, {deactivator, true});
- } else {
- ELOG("m_topWidget is NULL!");
- }
+ sendDeactivatorInfo(*m_window, event, {deactivator, true});
}
void Presenter::sendDeactivatorInfo(Widget &sender,
<privilege>http://tizen.org/privilege/notification</privilege>
<privilege>http://tizen.org/privilege/message.read</privilege>
<privilege>http://tizen.org/privilege/display</privilege>
+ <privilege>http://tizen.org/privilege/keygrab</privilege>
</privileges>
</manifest>