diff options
Diffstat (limited to 'lib/dialer')
38 files changed, 0 insertions, 7467 deletions
diff --git a/lib/dialer/CMakeLists.txt b/lib/dialer/CMakeLists.txt deleted file mode 100755 index 31f072d..0000000 --- a/lib/dialer/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -LINK_DIRECTORIES(${CMAKE_BINARY_DIR}) - -SET(TARGET ${PH_DIALER}) - -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) -FILE(GLOB SRCS *.cpp Search/*.cpp) - -INCLUDE(FindPkgConfig) -pkg_check_modules(dialer_pkgs REQUIRED tapi feedback) - -FOREACH(flag ${dialer_pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${TARGET} SHARED ${SRCS}) -SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${VERSION}) -SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS}) -TARGET_LINK_LIBRARIES(${TARGET} ${COMMON_LIB} ${ug_pkgs_LDFLAGS} ${SPEEDDIAL} ${dialer_pkgs_LDFLAGS}) - -ADD_DEPENDENCIES(${TARGET} dialer_edj_build dialer_theme_build) - -INSTALL(TARGETS ${TARGET} DESTINATION ${UGLIBDIR}) - -INSTALL(FILES ${CMAKE_BINARY_DIR}/lib/dialer/dialer-efl.xml DESTINATION "/usr/share/packages") diff --git a/lib/dialer/KeypadTouchManager.cpp b/lib/dialer/KeypadTouchManager.cpp deleted file mode 100644 index 416946a..0000000 --- a/lib/dialer/KeypadTouchManager.cpp +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include "KeypadTouchManager.h" -#include "phone.h" -#include "phone-dialer.h" -#include <assert.h> - -#define DIALER_PADDING_SIZE 3 -#define START_KEYPAD_RESET_TIMER 0.3 -#define MOUSE_UP_SIGNAL "mouse,up,1" -#define MOUSE_DOWN_SIGNAL "mouse,down,1" - -namespace Dialer -{ - KeypadTouchManager::KeypadTouchManager() - : m_lastDown(false), m_lastMultiDown(false), m_keypadResetTimer( - NULL), m_pLayout(NULL) - { - PH_TRACE; - m_digitalButtonNames.reserve(MULTI_TOUCH_SUPPORT_KEY_COUNT); - m_digitalButtonNames.push_back("1"); - m_digitalButtonNames.push_back("2"); - m_digitalButtonNames.push_back("3"); - m_digitalButtonNames.push_back("4"); - m_digitalButtonNames.push_back("5"); - m_digitalButtonNames.push_back("6"); - m_digitalButtonNames.push_back("7"); - m_digitalButtonNames.push_back("8"); - m_digitalButtonNames.push_back("9"); - m_digitalButtonNames.push_back("0"); - m_digitalButtonNames.push_back("star"); - m_digitalButtonNames.push_back("sharp"); - - m_lastDownPt.x = 0; - m_lastDownPt.y = 0; - - memset(&m_background, 0, sizeof(Evas_Coord_Rectangle)); - for (size_t i = 0; i < MULTI_TOUCH_SUPPORT_KEY_COUNT; ++i) - { - memset(&m_dialButtonRects[i], 0, sizeof(Evas_Coord_Rectangle)); - } - } - - KeypadTouchManager::~KeypadTouchManager() - { - PH_TRACE; - m_pLayout = NULL; - } - - void KeypadTouchManager::initKeyPadArea(const Evas_Object* pLayout) - { - PH_TRACE; - assert(pLayout != NULL); - p_retm_if(pLayout == NULL, "pLayout is NULL"); - m_pLayout = const_cast<Evas_Object*>(pLayout); - for (size_t i = 0; i < MULTI_TOUCH_SUPPORT_KEY_COUNT; ++i) - { - Evas_Coord_Rectangle* rect = &m_dialButtonRects[i]; - const char* btnName = m_digitalButtonNames[i].c_str(); - const Evas_Object* evasKeyArea = edje_object_part_object_get(_EDJ(pLayout), btnName); - if (evasKeyArea) - { - evas_object_geometry_get(evasKeyArea, &rect->x, &rect->y, &rect->w, &rect->h); - PH_DBG("edje_object_part_geometry_get : [%s]x %d y %d w %d h %d", - btnName, rect->x, rect->y, rect->w, rect->h); - } - } - - const Evas_Object *evasKpdArea = edje_object_part_object_get(_EDJ(pLayout), "keypad/swallow"); - if (evasKpdArea) - { - Evas_Coord_Rectangle* rect = &m_background; - evas_object_geometry_get(evasKpdArea, &rect->x, &rect->y, &rect->w, &rect->h); - PH_DBG("edje_object_part_geometry_get : x=%d y=%d w=%d h=%d", rect->x, rect->y, rect->w, rect->h); - - // remove bottom line btn area from layout geometry value - rect->h -= m_dialButtonRects[0].h; - - Evas* evas = evas_object_evas_get(pLayout); - if (evas) - { - // Temporary patch for UG slide effect problem - Evas_Coord h, w, x, y; - evas_output_viewport_get(evas, &x, &y, &w, &h); - if (m_background.x >= w - DIALER_PADDING_SIZE) - { - PH_DBG("evas_output_viewport_get : x %d y %d w %d h %d", x, y, w, h); - w -= DIALER_PADDING_SIZE; - m_background.x -= w; - for (size_t i = 0; i < MULTI_TOUCH_SUPPORT_KEY_COUNT; ++i) - { - rect = &m_dialButtonRects[i]; - rect->x -= w; - } - } - - Evas_Object *kpdArea = evas_object_rectangle_add(evas); - if (kpdArea) - { - evas_object_color_set(kpdArea, 0, 0, 0, 0); - elm_object_part_content_set(m_pLayout, "keypad/swallow", kpdArea); - evas_object_show(kpdArea); - - evas_object_event_callback_add(kpdArea, - EVAS_CALLBACK_MOUSE_DOWN, - static_cast<Evas_Object_Event_Cb>(KeypadTouchManager::onKeyDown), - this); - - evas_object_event_callback_add(kpdArea, - EVAS_CALLBACK_MOUSE_UP, - static_cast<Evas_Object_Event_Cb>(KeypadTouchManager::onKeyUp), - this); - - evas_object_event_callback_add(kpdArea, - EVAS_CALLBACK_MULTI_DOWN, - static_cast<Evas_Object_Event_Cb>(KeypadTouchManager::onMultiKeyDown), - this); - - evas_object_event_callback_add(kpdArea, - EVAS_CALLBACK_MULTI_UP, - static_cast<Evas_Object_Event_Cb>(KeypadTouchManager::onMultiKeyUp), - this); - } - } - } - } - - void KeypadTouchManager::stopTimer() - { - PH_TRACE; - if (m_keypadResetTimer) - { - ecore_timer_del(m_keypadResetTimer); - m_keypadResetTimer = NULL; - } - } - - void KeypadTouchManager::storeTouchedKey(int x, int y) - { - PH_TRACE; - const size_t keyIndex = getTouchedKeyRectIndex(x, y); - if (keyIndex != WRONG_KEY_INDEX) - { - DBG("%s was pressed", m_digitalButtonNames[keyIndex].c_str()); - m_touchedBtns.insert(keyIndex); - } - } - - size_t KeypadTouchManager::getTouchedKeyRectIndex(int x, int y) const - { - PH_TRACE; - size_t btnIndex = WRONG_KEY_INDEX; - if (isPtInRect(m_background, x, y)) - { - for (size_t i = 0; i < MULTI_TOUCH_SUPPORT_KEY_COUNT; ++i) - { - if (isPtInRect(m_dialButtonRects[i], x, y)) - { - btnIndex = i; - break; - } - } - } - else - { - DBG("point(%d,%d) is out of keypad", x, y); - } - - return btnIndex; - } - - bool KeypadTouchManager::isPtInRect(const Evas_Coord_Rectangle& rect, int x, - int y) - { - PH_TRACE; - return (x >= rect.x && y >= rect.y && x <= rect.x + rect.w && y <= rect.y + rect.h); - } - - void KeypadTouchManager::sendEdjeSignal(int x, int y, const char* signal) - { - PH_TRACE; - assert(m_pLayout); - if (m_pLayout) - { - const size_t keyIndex = getTouchedKeyRectIndex(x, y); - if (keyIndex != WRONG_KEY_INDEX) - { - PH_DBG("%s, %s", signal, m_digitalButtonNames[keyIndex].c_str()); - edje_object_signal_emit(_EDJ(m_pLayout), signal, m_digitalButtonNames[keyIndex].c_str()); - } - } - } - - void KeypadTouchManager::handleTouchedKeys() - { - PH_TRACE; - assert(m_pLayout); - if (m_pLayout) - { - for (TouchedButtonsIndexes::const_iterator it = m_touchedBtns.begin(); it != m_touchedBtns.end(); ++it) - { - const size_t keyIndex = *it; - edje_object_signal_emit(_EDJ(m_pLayout), MOUSE_UP_SIGNAL, m_digitalButtonNames[keyIndex].c_str()); - } - } - m_touchedBtns.clear(); - m_keypadResetTimer = NULL; - } - - Eina_Bool KeypadTouchManager::onTimer(void* data) - { - PH_TRACE; - KeypadTouchManager* pTouchMgr = static_cast<KeypadTouchManager*>(data); - assert(pTouchMgr); - if (pTouchMgr) - { - pTouchMgr->handleTouchedKeys(); - } - return EINA_FALSE; - } - - void KeypadTouchManager::handleKeyUp(int x, int y) - { - PH_TRACE; - if (m_lastMultiDown) - { - // Multi-key pressed sceanario should reset all dial key - stopTimer(); - m_keypadResetTimer = ecore_timer_add(START_KEYPAD_RESET_TIMER, - static_cast<Ecore_Task_Cb>(KeypadTouchManager::onTimer), - this); - } - else if (m_lastDown && (m_lastDownPt.x != x || m_lastDownPt.y != y)) - { - // normal scenario for touch & drag + release - sendEdjeSignal(m_lastDownPt.x, m_lastDownPt.y, MOUSE_UP_SIGNAL); - } - - m_lastDown = false; - m_lastMultiDown = false; - sendEdjeSignal(x, y, MOUSE_UP_SIGNAL); - } - - void KeypadTouchManager::onKeyUp(void *data, Evas *e, Evas_Object *o, void *event_info) - { - PH_TRACE; - assert(data && event_info); - if (data && event_info) - { - KeypadTouchManager* pTouchMgr = static_cast<KeypadTouchManager*>(data); - Evas_Event_Mouse_Up *ev = static_cast<Evas_Event_Mouse_Up*>(event_info); - PH_DBG("KeypadTouchManager::onKeyUp : x=%d y=%d", ev->output.x, ev->output.y); - pTouchMgr->handleKeyUp(ev->output.x, ev->output.y); - } - } - - void KeypadTouchManager::handleKeyDown(int x, int y) - { - PH_TRACE; - m_lastDownPt.x = x; - m_lastDownPt.y = y; - m_lastDown = true; - sendEdjeSignal(x, y, MOUSE_DOWN_SIGNAL); - } - - void KeypadTouchManager::onKeyDown(void *data, Evas *e, Evas_Object *o, void *event_info) - { - PH_TRACE; - assert(data && event_info); - if (data && event_info) - { - KeypadTouchManager* pTouchMgr = static_cast<KeypadTouchManager*>(data); - Evas_Event_Mouse_Down *ev = static_cast<Evas_Event_Mouse_Down*>(event_info); - PH_DBG("KeypadTouchManager::onKeyDown : x=%d y=%d", ev->output.x, ev->output.y); - pTouchMgr->handleKeyDown(ev->output.x, ev->output.y); - } - } - - void KeypadTouchManager::handleMultiKeyUp(int x, int y) - { - PH_TRACE; - sendEdjeSignal(x, y, MOUSE_UP_SIGNAL); - } - - void KeypadTouchManager::onMultiKeyUp(void *data, Evas *e, Evas_Object *o, void *event_info) - { - PH_TRACE; - assert(data && event_info); - if (data && event_info) - { - KeypadTouchManager* pTouchMgr = static_cast<KeypadTouchManager*>(data); - Evas_Event_Multi_Up *ev = static_cast<Evas_Event_Multi_Up*>(event_info); - PH_DBG("KeypadTouchManager::onMultiKeyUp : x=%d y=%d", ev->output.x, ev->output.y); - pTouchMgr->handleMultiKeyUp(ev->output.x, ev->output.y); - } - } - - void KeypadTouchManager::handleMultiKeyDown(int x, int y) - { - PH_TRACE; - m_lastMultiDown = true; - if (m_lastDown) - { - sendEdjeSignal(m_lastDownPt.x, m_lastDownPt.y, MOUSE_UP_SIGNAL); - m_lastDownPt.x = x; - m_lastDownPt.y = y; - m_lastDown = true; - } - - storeTouchedKey(x, y); - sendEdjeSignal(x, y, MOUSE_DOWN_SIGNAL); - } - - void KeypadTouchManager::onMultiKeyDown(void *data, Evas *e, Evas_Object *o, void *event_info) - { - PH_TRACE; - assert(data && event_info); - if (data && event_info) - { - KeypadTouchManager* pTouchMgr = static_cast<KeypadTouchManager*>(data); - Evas_Event_Multi_Down *ev = static_cast<Evas_Event_Multi_Down*>(event_info); - PH_DBG("KeypadTouchManager::onMultiKeyDown : x=%d y=%d", ev->output.x, ev->output.y); - pTouchMgr->handleMultiKeyDown(ev->output.x, ev->output.y); - } - } -} /* namespace TizenRefApps */ diff --git a/lib/dialer/Search/ContactData.cpp b/lib/dialer/Search/ContactData.cpp deleted file mode 100644 index 7ad0d7e..0000000 --- a/lib/dialer/Search/ContactData.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ContactData.h" - -#include "phone.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - ContactData::ContactData() - { - PH_TRACE; - } - - ContactData::ContactData(const ContactData &other) - { - PH_TRACE; - *this = other; - } - - const std::string & ContactData::getName() const - { - return m_Name; - } - - const std::string & ContactData::getNumber() const - { - return m_Number; - } - - const std::string & ContactData::getImagePath() const - { - return m_ImagePath; - } - - ContactData & ContactData::operator=(const ContactData &other) - { - PH_TRACE; - m_Name = other.m_Name; - m_Number = other.m_Number; - m_ImagePath = other.m_ImagePath; - return *this; - } - } - } -} diff --git a/lib/dialer/Search/ContactData.h b/lib/dialer/Search/ContactData.h deleted file mode 100644 index 57e41bf..0000000 --- a/lib/dialer/Search/ContactData.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_CONTACT_DATA_H__ -#define __PHONE_DIALER_SEARCH_CONTACT_DATA_H__ - -#include "Contact.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Contact data storage class - */ - class ContactData : public Common::Contact - { - public: - ContactData(); - ContactData(const ContactData &other); - - /* - * @see Contact::getName - */ - virtual const std::string & getName() const; - - /* - * @see Contact::getNumber - */ - virtual const std::string & getNumber() const; - - /* - * @see Contact::getImagePath - */ - virtual const std::string & getImagePath() const; - - ContactData & operator=(const ContactData &other); - - protected: - std::string m_Name; - std::string m_Number; - std::string m_ImagePath; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_CONTACT_DATA_H__ */ diff --git a/lib/dialer/Search/ContactItem.cpp b/lib/dialer/Search/ContactItem.cpp deleted file mode 100644 index d492df2..0000000 --- a/lib/dialer/Search/ContactItem.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ContactItem.h" -#include "phone.h" -#include "phone-common.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - ContactItem::ContactItem(const Result &result) - : ResultItem(result) - { - PH_TRACE; - } - - char * ContactItem::getText(const char *part) const - { - PH_TRACE; - if(strcmp(part, "elm.text.1") == 0) - { - if(getResult().getMatchType() == Result::ByName) - { - return strdup(getMatch()); - } - else - { - return strdup(getResult().getContact()->getName().c_str()); - } - } - else - { - return ResultItem::getText(part); - } - } - - Elm_Genlist_Item_Class * ContactItem::getClass() const - { - static Elm_Genlist_Item_Class *itemClass = createClass("2text.1icon.4.tb"); - return itemClass; - } - } - } -} diff --git a/lib/dialer/Search/ContactItem.h b/lib/dialer/Search/ContactItem.h deleted file mode 100644 index a2fcad9..0000000 --- a/lib/dialer/Search/ContactItem.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_CONTACT_ITEM_H__ -#define __PHONE_DIALER_SEARCH_CONTACT_ITEM_H__ - -#include "Search/ResultItem.h" - -namespace Phone -{ - namespace Dialer - { - /* - * @brief Search results list item with Contact name - * @displays Contact name and number and highlights the match. - */ - namespace Search - { - class ContactItem : public ResultItem - { - public: - /* - * @param result Search result associated with the item - */ - ContactItem(const Result &result); - - /* - * @see Genlist::Item::getText - */ - char * getText(const char *part) const; - - /* - * @see Genlist::Item::getClass - */ - Elm_Genlist_Item_Class * getClass() const; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_CONTACT_ITEM_H__ */ diff --git a/lib/dialer/Search/ContactLogRecord.cpp b/lib/dialer/Search/ContactLogRecord.cpp deleted file mode 100644 index d2d70a1..0000000 --- a/lib/dialer/Search/ContactLogRecord.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ContactLogRecord.h" - -#include "phone.h" -#include "phone-common.h" -#include "Database/Database.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - using Database::Database; - - ContactLogRecord::ContactLogRecord() - { - PH_TRACE; - } - - ContactLogRecord::ContactLogRecord(const ContactLogRecord &other) - : ContactData(other) - { - PH_TRACE; - } - - bool ContactLogRecord::initialize(int id) - { - PH_TRACE; - contacts_query_h query = NULL; - contacts_filter_h filter = NULL; - contacts_list_h list = NULL; - contacts_record_h record = NULL; - unsigned ids[] = { - _contacts_person_phone_log.person_id, - _contacts_person_phone_log.address, - }; - - bool success = Database::isSuccess( - contacts_filter_create(_contacts_person_phone_log._uri, &filter)) - && Database::isSuccess( - contacts_filter_add_int(filter, _contacts_person_phone_log.log_id, CONTACTS_MATCH_EQUAL, id)) - && Database::isSuccess( - contacts_query_create(_contacts_person_phone_log._uri, &query)) - && Database::isSuccess( - contacts_query_set_filter(query, filter)) - && Database::isSuccess( - contacts_query_set_projection(query, ids, sizeof(ids) / sizeof(*ids))) - && Database::isSuccess( - contacts_db_get_records_with_query(query, 0, 0, &list)) - && Database::isSuccess( - contacts_list_get_current_record_p(list, &record)) - && initialize(record); - - if(filter) - { - contacts_filter_destroy(filter); - } - - if(query) - { - contacts_query_destroy(query); - } - - if(list) - { - contacts_list_destroy(list, true); - } - - return success; - } - - bool ContactLogRecord::initialize(contacts_record_h record) - { - PH_TRACE; - char *number = NULL; - int id = 0; - - bool success = Database::isSuccess( - contacts_record_get_str_p(record, _contacts_person_phone_log.address, &number)) - && Database::isSuccess( - contacts_record_get_int(record, _contacts_person_phone_log.person_id, &id)); - - if(success) - { - m_Number.clear(); - if(number) - { - m_Number = number; - } - m_PersonId = id; - } - - return success; - } - - int ContactLogRecord::getPersonId() const - { - return m_PersonId; - } - - ContactLogRecord & ContactLogRecord::operator=(const ContactLogRecord &other) - { - PH_TRACE; - ContactData::operator=(other); - return *this; - } - } - } -} diff --git a/lib/dialer/Search/ContactLogRecord.h b/lib/dialer/Search/ContactLogRecord.h deleted file mode 100644 index b64446c..0000000 --- a/lib/dialer/Search/ContactLogRecord.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_CONTACT_LOG_RECORD_H__ -#define __PHONE_DIALER_SEARCH_CONTACT_LOG_RECORD_H__ - -#include <contacts.h> -#include "ContactData.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Contact data access object based on database record - * from _contacts_person_phone_log view. - */ - class ContactLogRecord : public ContactData - { - public: - ContactLogRecord(); - ContactLogRecord(const ContactLogRecord &other); - - /* - * @brief Initialize by fetching contact data from database by Log ID - * @param id Log ID from _contacts_phone_log view - * @return true on success, false otherwise - */ - bool initialize(int id); - - /* - * @brief Initialize with data from database log record - * @param record Record from _contacts_person_phone_log view - */ - bool initialize(contacts_record_h record); - - /* - * @brief Get person ID associated with log record - * @return Person ID or 0 for unsaved number - */ - int getPersonId() const; - - ContactLogRecord & operator=(const ContactLogRecord &other); - - private: - int m_PersonId; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_CONTACT_LOG_RECORD_H__ */ diff --git a/lib/dialer/Search/ContactNumberRecord.cpp b/lib/dialer/Search/ContactNumberRecord.cpp deleted file mode 100644 index 0a399ad..0000000 --- a/lib/dialer/Search/ContactNumberRecord.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ContactNumberRecord.h" - -#include "phone.h" -#include "phone-common.h" -#include "Database/Database.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - using Database::Database; - - ContactNumberRecord::ContactNumberRecord() - { - PH_TRACE; - } - - ContactNumberRecord::ContactNumberRecord(const ContactNumberRecord &other) - : ContactData(other) - { - PH_TRACE; - } - - bool ContactNumberRecord::initialize(int id) - { - PH_TRACE; - contacts_query_h query = NULL; - contacts_filter_h filter = NULL; - contacts_list_h list = NULL; - contacts_record_h record = NULL; - unsigned ids[] = { - _contacts_contact_number.display_name, - _contacts_contact_number.number, - _contacts_contact_number.image_thumbnail_path - }; - - bool success = Database::isSuccess( - contacts_filter_create(_contacts_contact_number._uri, &filter)) - && Database::isSuccess( - contacts_filter_add_int(filter, _contacts_contact_number.number_id, CONTACTS_MATCH_EQUAL, id)) - && Database::isSuccess( - contacts_query_create(_contacts_contact_number._uri, &query)) - && Database::isSuccess( - contacts_query_set_filter(query, filter)) - && Database::isSuccess( - contacts_query_set_projection(query, ids, sizeof(ids) / sizeof(*ids))) - && Database::isSuccess( - contacts_db_get_records_with_query(query, 0, 0, &list)) - && Database::isSuccess( - contacts_list_get_current_record_p(list, &record)) - && initialize(record); - - if(filter) - { - contacts_filter_destroy(filter); - } - - if(query) - { - contacts_query_destroy(query); - } - - if(list) - { - contacts_list_destroy(list, true); - } - - return success; - } - - bool ContactNumberRecord::initialize(contacts_record_h record) - { - PH_TRACE; - char *name = NULL; - char *number = NULL; - char *image = NULL; - - bool success = Database::isSuccess( - contacts_record_get_str_p(record, _contacts_contact_number.display_name, &name)) - && Database::isSuccess( - contacts_record_get_str_p(record, _contacts_contact_number.number, &number)) - && Database::isSuccess( - contacts_record_get_str_p(record, _contacts_contact_number.image_thumbnail_path, &image)); - - if(success) - { - m_Name.clear(); - if(name) - { - m_Name = name; - } - - m_Number.clear(); - if(number) - { - m_Number = number; - } - - m_ImagePath.clear(); - if(image) - { - m_ImagePath = image; - } - } - - return success; - } - - ContactNumberRecord & ContactNumberRecord::operator=(const ContactNumberRecord &other) - { - PH_TRACE; - ContactData::operator=(other); - return *this; - } - } - } -} diff --git a/lib/dialer/Search/ContactNumberRecord.h b/lib/dialer/Search/ContactNumberRecord.h deleted file mode 100644 index bb4eb35..0000000 --- a/lib/dialer/Search/ContactNumberRecord.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_CONTACT_NUMBER_RECORD_H__ -#define __PHONE_DIALER_SEARCH_CONTACT_NUMBER_RECORD_H__ - -#include <contacts.h> -#include "Search/ContactData.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Contact data access object based on database record - * from _contacts_contact_number view. - */ - class ContactNumberRecord : public ContactData - { - public: - ContactNumberRecord(); - ContactNumberRecord(const ContactNumberRecord &other); - - /* - * @brief Initialize by fetching contact data from database by number ID - * @param id Number ID from _contacts_number view - * @return true on success, false otherwise - */ - bool initialize(int id); - - /* - * @brief Initialize with data from database number record - * @param record Record from _contacts_contact_number view - */ - bool initialize(contacts_record_h record); - - ContactNumberRecord & operator=(const ContactNumberRecord &other); - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_CONTACT_NUMBER_RECORD_H__ */ diff --git a/lib/dialer/Search/Controller.cpp b/lib/dialer/Search/Controller.cpp deleted file mode 100644 index 0d55fae..0000000 --- a/lib/dialer/Search/Controller.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/Controller.h" - -#include "phone.h" -#include "phone-dialer.h" -#include "ph-dialer-view.h" -#include "ph-dialer-utils.h" -#include "Search/ContactItem.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - Controller::Controller() - : m_DialerView(NULL) - { - PH_TRACE; - } - - Controller::~Controller() - { - PH_TRACE; - } - - bool Controller::initialize(DialerView *dialer) - { - PH_TRACE; - if(!dialer) - { - return false; - } - - bool success = m_DataProvider.initialize() - && m_Engine.initialize(m_DataProvider) - && m_ResultWidget.initialize(dialer->layout) - && m_ResultPopup.initialize(dialer->navi); - - if(success) - { - m_DialerView = dialer; - m_Engine.setListener(this); - m_ResultWidget.setListener(this); - m_ResultPopup.setListener(this); - evas_object_smart_callback_priority_add(m_DialerView->entry, "changed", EVAS_CALLBACK_PRIORITY_AFTER, onTextChange, this); - } - - return success; - } - - void Controller::onSearchResultsChange(const Results &results) - { - PH_TRACE; - if(!m_Engine.getQuery().empty()) - { - const Results &results = m_Engine.getResults(); - DBG("count: %d", results.size()); - - if(!results.empty()) - { - m_ResultWidget.setResult(results.front()); - } - m_ResultWidget.setResultCount(results.size()); - } - else - { - m_ResultWidget.hide(); - } - } - - void Controller::onSearchResultSelect(const Result &result) - { - PH_TRACE; - ph_dialer_entry_set_number(*m_DialerView, result.getContact()->getNumber(), CURSOR_END); - } - - void Controller::onAddToContacts() - { - PH_TRACE; - dialer_add_contact(m_DialerView); - } - - void Controller::onTopResultSelect() - { - PH_TRACE; - onSearchResultSelect(m_Engine.getResults().front()); - } - - void Controller::onShowMoreResults() - { - PH_TRACE; - m_ResultPopup.setResults(m_Engine.getResults()); - m_ResultPopup.show(); - m_DialerView->popup = m_ResultPopup.getPopup(); - } - - void Controller::onTextChange(void *data, Evas_Object *obj, void *event_info) - { - PH_TRACE; - if(!data || !obj) - { - return; - } - - Controller *pthis = static_cast<Controller*>(data); - char text[PH_TEXT_MAX_LEN]; - ph_dialer_util_get_pure_numstr_with_plus(pthis->m_DialerView, text); - pthis->m_Engine.setQuery(text); - } - } - } -} diff --git a/lib/dialer/Search/Controller.h b/lib/dialer/Search/Controller.h deleted file mode 100644 index eac5f0f..0000000 --- a/lib/dialer/Search/Controller.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_CONTROLLER_H__ -#define __PHONE_DIALER_SEARCH_CONTROLLER_H__ - -#include "Search/Engine.h" -#include "Search/DbDataProvider.h" -#include "Search/ResultWidget.h" -#include "Search/ResultPopup.h" - -struct DialerView; - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Dialer search controller - * @details Controls search result widget and popup, - * initializes data provider and search engine. - * Handles widget events and initiates the search - * using search engine whenever dialer's text is changed. - */ - class Controller : - public EngineListener, - public ResultWidgetListener, - public ResultPopupListener - { - public: - Controller(); - ~Controller(); - - /* - * @brief Initialize dialer search controller - * @param dialer Dialer view - */ - bool initialize(DialerView *dialer); - - private: - void onSearchResultsChange(const Results &results); - void onSearchResultSelect(const Result &result); - - void onAddToContacts(); - void onTopResultSelect(); - void onShowMoreResults(); - - static void onTextChange(void *data, Evas_Object *obj, void *event_info); - - Engine m_Engine; - DbDataProvider m_DataProvider; - - DialerView *m_DialerView; - ResultWidget m_ResultWidget; - ResultPopup m_ResultPopup; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_CONTROLLER_H__ */ diff --git a/lib/dialer/Search/DataProvider.h b/lib/dialer/Search/DataProvider.h deleted file mode 100644 index 576a3f6..0000000 --- a/lib/dialer/Search/DataProvider.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_DATA_PROVIDER_H__ -#define __PHONE_DIALER_SEARCH_DATA_PROVIDER_H__ - -#include "Contact.h" -#include "NonCopyable.h" -#include "SharedPtr.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - typedef Utils::SharedPtr<Common::Contact> ContactPtr; - - /* - * @brief Data provider interface for dialer search engine - */ - class DataProvider : public Utils::NonCopyable - { - public: - virtual ~DataProvider() { } - - /* - * @return The current count of data items that can be provided - */ - virtual size_t getCount() const = 0; - - /* - * @brief Get contact data item by index - * @param index Index of data item - * @return Shared pointer to contact data or NULL if out of range - */ - virtual ContactPtr getData(size_t index) const = 0; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_DATA_PROVIDER_H__ */ diff --git a/lib/dialer/Search/DbDataProvider.cpp b/lib/dialer/Search/DbDataProvider.cpp deleted file mode 100644 index 91906f3..0000000 --- a/lib/dialer/Search/DbDataProvider.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/DbDataProvider.h" - -#include "phone.h" -#include "phone-common.h" -#include "Search/ContactLogRecord.h" -#include "Search/ContactNumberRecord.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - using Database::Database; - - DbDataProvider::DbDataProvider() - : m_Initialized(false) - { - PH_TRACE; - } - - DbDataProvider::~DbDataProvider() - { - PH_TRACE; - contacts_db_remove_changed_cb(_contacts_number._uri, onContactNumberChange, this); - Database::getInstance().removeListener(_contacts_phone_log._uri, this); - } - - bool DbDataProvider::initialize() - { - PH_TRACE; - if(!m_Initialized) - { - bool success = fetchNumbers() && fetchLogs(); - - if(success) - { - success = Database::isSuccess( - contacts_db_add_changed_cb(_contacts_number._uri, onContactNumberChange, this)); - } - - if(success) - { - success = Database::getInstance().addListener(_contacts_phone_log._uri, this); - } - else - { - contacts_db_remove_changed_cb(_contacts_number._uri, onContactNumberChange, this); - } - - if(!success) - { - m_Numbers.clear(); - m_Logs.clear(); - } - else - { - m_Initialized = true; - } - } - - return m_Initialized; - } - - size_t DbDataProvider::getCount() const - { - return m_Numbers.size() + m_Logs.size(); - } - - ContactPtr DbDataProvider::getData(size_t index) const - { - if(index < m_Numbers.size()) - { - return m_Numbers[index]; - } - else - { - index -= m_Numbers.size(); - if (index < m_Logs.size()) - { - return m_Logs[index]; - } - else - { - return ContactPtr(); - } - } - } - - bool DbDataProvider::fetchNumbers() - { - PH_TRACE; - contacts_query_h query = NULL; - contacts_list_h numbers = NULL; - unsigned count = 0; - unsigned ids[] = { - _contacts_contact_number.display_name, - _contacts_contact_number.number, - _contacts_contact_number.image_thumbnail_path - }; - - bool success = Database::isSuccess( - contacts_query_create(_contacts_contact_number._uri, &query)) - && Database::isSuccess( - contacts_query_set_projection(query, ids, sizeof(ids) / sizeof(*ids))) - && Database::isSuccess( - contacts_db_get_records_with_query(query, 0, 0, &numbers)) - && Database::isSuccess( - contacts_list_get_count(numbers, &count)); - - if(query) - { - contacts_query_destroy(query); - } - - m_Numbers.clear(); - DBG("count: %d", count); - while(success && count--) - { - contacts_record_h record = NULL; - success = Database::isSuccess(contacts_list_get_current_record_p(numbers, &record)); - - if(success) - { - ContactNumberRecord *contactNumber = new ContactNumberRecord(); - success = contactNumber->initialize(record); - if(success) - { - m_Numbers.push_back(contactNumber); - } - else - { - delete contactNumber; - } - - if(count) - { - success = Database::isSuccess(contacts_list_next(numbers)); - } - } - } - - if(numbers) - { - contacts_list_destroy(numbers, true); - } - - return success; - } - - bool DbDataProvider::fetchLogs() - { - PH_TRACE; - bool success = true; - unsigned ids[] = { - _contacts_person_phone_log.person_id, - _contacts_person_phone_log.address, - }; - contacts_query_h query = NULL; - contacts_list_h logs = NULL; - unsigned count = 0; - - success = Database::isSuccess( - contacts_query_create(_contacts_person_phone_log._uri, &query)) - && Database::isSuccess( - contacts_query_set_projection(query, ids, sizeof(ids) / sizeof(*ids))) - && Database::isSuccess( - contacts_query_set_distinct(query, true)) - && Database::isSuccess( - contacts_db_get_records_with_query(query, 0, 0, &logs)) - && Database::isSuccess( - contacts_list_get_count(logs, &count)); - - if(query) - { - contacts_query_destroy(query); - } - - DBG("count: %d", count); - while(success && count--) - { - int id = 0; - contacts_record_h record = NULL; - - success = Database::isSuccess( - contacts_list_get_current_record_p(logs, &record)) - && Database::isSuccess( - contacts_record_get_int(record, _contacts_person_phone_log.person_id, &id)); - - if(success) - { - if(id == 0) - { - ContactLogRecord *contactLog = new ContactLogRecord(); - success = contactLog->initialize(record); - if(success) - { - m_Logs.push_back(contactLog); - } - else - { - delete contactLog; - } - } - - if(count) - { - success = Database::isSuccess(contacts_list_next(logs)); - } - } - } - - if(logs) - { - contacts_list_destroy(logs, true); - } - - return success; - } - - void DbDataProvider::onRecordInsert(const char *uri, int id) - { - PH_TRACE; - if(!uri) - { - return; - } - - if(strcmp(uri, _contacts_phone_log._uri) == 0) - { - onLogInsert(id); - } - } - - void DbDataProvider::onNumberInsert(int id) - { - PH_TRACE; - ContactNumberRecord *contactNumber = new ContactNumberRecord(); - if(contactNumber->initialize(id)) - { - m_Numbers.push_back(contactNumber); - } - else - { - delete contactNumber; - } - } - - void DbDataProvider::onLogInsert(int id) - { - PH_TRACE; - ContactLogRecord *contactLog = new ContactLogRecord(); - - if(contactLog->initialize(id)) - { - bool exists = false; - - //check if it's an unsaved number - if(contactLog->getPersonId() == 0) - { - //check if number wasn't already added - for(Contacts::iterator - it = m_Logs.begin(); - it != m_Logs.end(); ++it) - { - if(contactLog->getNumber().compare((*it)->getNumber()) == 0) - { - exists = true; - break; - } - } - } - else - { - exists = true; - } - - if(!exists) - { - m_Logs.push_back(contactLog); - } - else - { - delete contactLog; - } - } - else - { - delete contactLog; - } - } - - - void DbDataProvider::onContactNumberChange(const char *uri, void *data) - { - PH_TRACE; - DbDataProvider *dbDataProvider = static_cast<DbDataProvider*>(data); - if (!uri || !dbDataProvider) - { - return; - } - - DBG("uri = %s", uri); - if (strcmp(uri,_contacts_number._uri) == 0) - { - dbDataProvider->fetchNumbers(); - } - } - } - } -} diff --git a/lib/dialer/Search/DbDataProvider.h b/lib/dialer/Search/DbDataProvider.h deleted file mode 100644 index 1d52082..0000000 --- a/lib/dialer/Search/DbDataProvider.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_DB_DATA_PROVIDER_H__ -#define __PHONE_DIALER_SEARCH_DB_DATA_PROVIDER_H__ - -#include <vector> -#include <contacts.h> - -#include "Contact.h" -#include "Database/Database.h" -#include "Database/Listener.h" -#include "Search/DataProvider.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Database data provider for dialer search engine - * @details The provider fetches numbers from the address book - * and unsaved numbers from call logs and provides - * encapsulated access to this data. - * Provider updates its data based on changes made to the database. - */ - class DbDataProvider : - public DataProvider, - public Database::Listener - { - public: - DbDataProvider(); - virtual ~DbDataProvider(); - - /* - * @brief Initialize data provider and fetch initial data - * @return true on success, false otherwise - */ - bool initialize(); - - /* - * @see DataProvider::getCount - */ - virtual size_t getCount() const; - - /* - * @see DataProvider::getData - */ - virtual ContactPtr getData(size_t index) const; - - private: - bool fetchNumbers(); - bool fetchLogs(); - - void onRecordInsert(const char *uri, int id); - void onNumberInsert(int id); - void onLogInsert(int id); - static void onContactNumberChange(const char *uri, void *data); - - bool m_Initialized; - - typedef std::vector<ContactPtr> Contacts; - Contacts m_Numbers; - Contacts m_Logs; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_DB_DATA_PROVIDER_H__ */ diff --git a/lib/dialer/Search/Engine.cpp b/lib/dialer/Search/Engine.cpp deleted file mode 100644 index a1b1d5d..0000000 --- a/lib/dialer/Search/Engine.cpp +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/Engine.h" - -#include "phone.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - Engine::Engine() - : m_DataProvider(NULL), m_Listener(NULL) - { - PH_TRACE; - } - - Engine::~Engine() - { - PH_TRACE; - clearQuery(); - } - - bool Engine::initialize(const DataProvider &provider) - { - PH_TRACE; - m_DataProvider = &provider; - m_History.resize(1); - return true; - } - - void Engine::setListener(EngineListener *listener) - { - PH_TRACE; - m_Listener = listener; - } - - const std::string & Engine::getQuery() const - { - return m_Query; - } - - void Engine::setQuery(const std::string &query) - { - PH_TRACE; - DBG("old query: %s", m_Query.c_str()); - DBG("new query: %s", query.c_str()); - - std::string::const_iterator it1 = m_Query.begin(); - std::string::const_iterator it2 = query.begin(); - - //find first position where old and new query mismatch - while(it1 != m_Query.end() - && it2 != query.end() - && *it1 == *it2) - { - ++it1; - ++it2; - } - - if(it1 != m_Query.end()) - { - truncateQuery(m_Query.end() - it1); - } - - if(it2 != query.end()) - { - appendQuery(query.substr(it2 - query.begin())); - } - } - - void Engine::appendQuery(const std::string &str) - { - PH_TRACE; - DBG("old query: %s", m_Query.c_str()); - m_Query.append(str); - DBG("new query: %s", m_Query.c_str()); - - //if there are no previous results - if(m_HistoryIndex.empty()) - { - searchInContacts(); - } - else - { - //use previous results for search - int prev = m_HistoryIndex.back(); - if(!m_History.at(prev).empty()) - { - m_History.resize(m_History.size() + 1); - searchInResults(m_History.at(prev)); - } - } - - m_HistoryIndex.resize(m_Query.length(), -1); - m_HistoryIndex.back() = m_History.size() - 1; - } - - void Engine::truncateQuery(unsigned count) - { - PH_TRACE; - DBG("old query: %s", m_Query.c_str()); - - if(count >= m_Query.length()) - { - clearQuery(); - } - else - { - m_Query.erase(m_Query.length() - count); - DBG("new query: %s", m_Query.c_str()); - m_HistoryIndex.resize(m_Query.length(), -1); - - int prev = -1; - //find nearest previous results - for(HistoryIndex::reverse_iterator - it = m_HistoryIndex.rbegin(); - it != m_HistoryIndex.rend(); ++it) - { - if(*it > -1) - { - prev = *it; - break; - } - } - - //previous results found - if(prev > -1) - { - DBG("prev: %d", prev); - //remove all results after found results - m_History.erase(m_History.begin() + prev + 1, m_History.end()); - - //if found results correspond exactly to the new query - if(prev == m_HistoryIndex.back()) - { - notifyChange(); - } - else - { - m_History.resize(m_History.size() + 1); - searchInResults(m_History[prev]); - } - } - else - { - //no previous results found - m_History.back().clear(); - searchInContacts(); - } - - m_HistoryIndex.back() = m_History.size() - 1; - } - } - - void Engine::clearQuery() - { - PH_TRACE; - m_Query.clear(); - m_HistoryIndex.clear(); - m_History.resize(1); - m_History.back().clear(); - notifyChange(); - } - - const Results & Engine::getResults() const - { - return m_History.back(); - } - - bool Engine::match(const ContactPtr &contact, Result &result) - { - return matchByNumber(contact, result) || matchByName(contact, result); - } - - bool Engine::matchByNumber(const ContactPtr &contact, Result &result) - { - PH_TRACE; - size_t pos = contact->getNumber().find(m_Query); - - if(pos != std::string::npos) - { - result = Result(contact, Result::ByNumber, pos, m_Query.length()); - DBG("matched: %s", contact->getNumber().c_str()); - return true; - } - else - { - return false; - } - } - - bool Engine::matchByName(const ContactPtr &contact, Result &result) - { - PH_TRACE; - //TODO: implement match by name - return false; - } - - void Engine::notifyChange() - { - PH_TRACE; - if(m_Listener) - { - m_Listener->onSearchResultsChange(m_History.back()); - } - } - - void Engine::searchInContacts() - { - PH_TRACE; - Result result; - Results ¤t = m_History.back(); - - size_t count = m_DataProvider->getCount(); - for(size_t i = 0; i < count; ++i) - { - const ContactPtr &contact = m_DataProvider->getData(i); - if(contact && match(contact, result)) - { - current.push_back(result); - } - } - - DBG("count: %d", current.size()); - notifyChange(); - } - - void Engine::searchInResults(const Results &results) - { - PH_TRACE; - Result result; - Results ¤t = m_History.back(); - - for(Results::const_iterator - it = results.begin(); - it != results.end(); ++it) - { - if(match(it->getContact(), result)) - { - current.push_back(result); - } - } - - DBG("count: %d", current.size()); - notifyChange(); - } - } - } -} diff --git a/lib/dialer/Search/Engine.h b/lib/dialer/Search/Engine.h deleted file mode 100644 index 0374953..0000000 --- a/lib/dialer/Search/Engine.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_ENGINE_H__ -#define __PHONE_DIALER_SEARCH_ENGINE_H__ - -#include <vector> -#include <string> - -#include "NonCopyable.h" -#include "Search/DataProvider.h" -#include "Search/Result.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Dialer search engine event listener - */ - class EngineListener - { - public: - virtual ~EngineListener() { } - - /* - * @brief Called whenever search results were changed - * @param results Search results - */ - virtual void onSearchResultsChange(const Results &results) = 0; - }; - - /* - * @brief Dialer incremental search engine - * @details Implements incremental search through provided contact data. - * Maintains incremental result history allowing to narrow the search - * for each next input into query and to fall back to previous results - * on query truncation. - */ - class Engine : public Utils::NonCopyable - { - public: - Engine(); - ~Engine(); - - /* - * @brief Initialize search engine - * @param provider Input data provider - * @see DataProvider - */ - bool initialize(const DataProvider &provider); - - /* - * @brief Set listener for search events - * @see EngineListener - */ - void setListener(EngineListener *listener); - - /* - * @return Current search query string - */ - const std::string & getQuery() const; - - /* - * @brief Set new query string and begin search - * @details Calculates the difference between the current query - * and the new query and uses appendQuery and truncateQuery - * as needed - * @param query Query string - */ - void setQuery(const std::string &query); - - /* - * @brief Append string to the current query string - * and begin search - * @details Search is performed through previous results if any - * or data provider is used - * @param str String to append to current query - */ - void appendQuery(const std::string &str); - - /* - * @brief Remove character from the end of current query string - * and begin search - * @details Falls back to previous results and performs search if necessary - * or uses data provider if there are no results to fall back to - * @param count Number of character to remove form the end of query string - */ - void truncateQuery(unsigned count); - - /* - * @brief Clear query string and remove all results - */ - void clearQuery(); - - /* - * @return Current search results - */ - const Results & getResults() const; - - private: - bool match(const ContactPtr &contact, Result &result); - bool matchByNumber(const ContactPtr &contact, Result &result); - bool matchByName(const ContactPtr &contact, Result &result); - - void notifyChange(); - - /* - * @brief Search through contact data using data provider - * @remarks Results are saved into m_History.back() - */ - void searchInContacts(); - - /* - * @brief Search through provided results - * @remarks Results are saved into m_History.back() - * @param results Results to use as input data - */ - void searchInResults(const Results &results); - - typedef std::vector<Results> History; - typedef std::vector<int> HistoryIndex; - - /* - * @brief Current search query - */ - std::string m_Query; - - - /* - * @brief Incremental search history, maintains sets of results - * @details Each call to appendQuery adds one set of results - * to the history if previous results weren't empty. - * Each call to truncateQuery removes one or more - * result sets from the history. - */ - History m_History; - - /* - * @brief Maps each substring of the query string that begins at 0 - * to the corresponding result set in result history. - * @details History index is always the same size as search query. - * Each substring of the query string that begins at 0 - * and ends at N (subquery) has a corresponding element - * in history index at position N that contains the index - * of the result set for this subquery in search history. - * - * If there are no results for a subquery in search history - * then the value of corresponding element in history index - * is -1. - * @example - * @code - * - * DataProvider *provider = new SomeProvider(); - * Engine engine; - * engine.initialize(*provider); - * - * engine.appendQuery("0"); - * engine.appendQuery("9"); - * engine.appendQuery("1"); - * engine.setQuery("0913051032"); - * - * @endcode - * - * Given the appropriate data provided by SomeProvider - * the engine will be in the following internal state: - * - * | 0| 9| 1| 3| 0| 5| 1| 0| 3| 2| <- m_Query - * | 0| 1| 2|-1|-1|-1|-1|-1|-1| 3| <- m_HistoryIndex - * - * | 0| 1| 2| 3| <- m_History indices - * ^ ^ ^ ^ - * | | | 1 result (0913051032) - * | | 10 results - * | 16 results - * 23 results - */ - HistoryIndex m_HistoryIndex; - - const DataProvider *m_DataProvider; - EngineListener *m_Listener; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_ENGINE_H__ */ diff --git a/lib/dialer/Search/Result.cpp b/lib/dialer/Search/Result.cpp deleted file mode 100644 index 60a565a..0000000 --- a/lib/dialer/Search/Result.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/Result.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - Result::Result() - : m_MatchType(ByNumber), m_MatchPos(0), m_MatchLength(0) - { - PH_TRACE; - } - - Result::Result(const Result &result) - { - PH_TRACE; - *this = result; - } - - Result::Result(const ContactPtr &contact, MatchType matchType, - size_t matchPos, size_t matchLength) - : m_Contact(contact), m_MatchType(matchType), - m_MatchPos(matchPos), m_MatchLength(matchLength) - { - PH_TRACE; - } - - Result::MatchType Result::getMatchType() const - { - return m_MatchType; - } - - const ContactPtr & Result::getContact() const - { - return m_Contact; - } - - size_t Result::getMatchPos() const - { - return m_MatchPos; - } - - size_t Result::getMatchLength() const - { - return m_MatchLength; - } - - bool Result::formatMatch(std::string &formattedMatch, - const std::string &matchBegin, - const std::string &matchEnd) const - { - PH_TRACE; - const std::string *match = NULL; - if(m_MatchType == ByNumber) - { - match = &getContact()->getNumber(); - } - else - { - match = &getContact()->getName(); - } - - if(match && match->length() >= m_MatchPos + m_MatchLength) - { - formattedMatch.clear(); - if(m_MatchPos > 0) - { - formattedMatch.append(match->c_str(), m_MatchPos); - } - - formattedMatch - .append(matchBegin) - .append(match->c_str() + m_MatchPos, m_MatchLength) - .append(matchEnd) - .append(match->c_str() + m_MatchPos + m_MatchLength); - - return true; - } - else - { - return false; - } - } - - Result & Result::operator=(const Result &result) - { - PH_TRACE; - m_MatchType = result.m_MatchType; - m_Contact = result.m_Contact; - m_MatchPos = result.m_MatchPos; - m_MatchLength = result.m_MatchLength; - return *this; - } - } - } -} diff --git a/lib/dialer/Search/Result.h b/lib/dialer/Search/Result.h deleted file mode 100644 index 6bc8b1a..0000000 --- a/lib/dialer/Search/Result.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_RESULT_H__ -#define __PHONE_DIALER_SEARCH_RESULT_H__ - -#include <vector> -#include <string> - -#include "Contact.h" -#include "SharedPtr.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - typedef Utils::SharedPtr<Common::Contact> ContactPtr; - - /* - * @brief Dialer search result data - */ - class Result - { - public: - /* - * @brief Specifies by which field contact data matches search query - */ - enum MatchType - { - ByNumber, - ByName - }; - - Result(); - Result(const Result &result); - Result(const ContactPtr &contact, MatchType matchType, - size_t matchPos, size_t matchLength); - - /* - * @return Type of the result - * @see Result::MatchType - */ - MatchType getMatchType() const; - - /* - * @return Contact data associated with result - */ - const ContactPtr & getContact() const; - - /* - * @return Start position of the match in matched string - */ - size_t getMatchPos() const; - - /* - * @return Length of matched substring (i.e. length of search query) - */ - size_t getMatchLength() const; - - /* - * @brief Format matched field by prepending matchBegin - * and appending matchEnd strings to the matching substring. - * @par example - * If contact's number is "1234567" and search query is "34" - * then the following code: - * - * @code - * std::string match; - * result.formatMatch(match, "<match>", "</>"); - * @endcode - * - * will write "12<match>34</>567" in "match" string - * - * @param[out] formattedMatch Formatted match string - * @param[in] matchBegin String to prepend matching substring with - * @param[in] matchEnd String to append to matching substring - * @return true on success, false otherwise - */ - bool formatMatch(std::string &formattedMatch, - const std::string &matchBegin, - const std::string &matchEnd) const; - - Result & operator=(const Result &result); - - private: - ContactPtr m_Contact; - MatchType m_MatchType; - size_t m_MatchPos; - size_t m_MatchLength; - }; - - typedef std::vector<Result> Results; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_RESULT_H__ */ diff --git a/lib/dialer/Search/ResultItem.cpp b/lib/dialer/Search/ResultItem.cpp deleted file mode 100644 index f002fb8..0000000 --- a/lib/dialer/Search/ResultItem.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ResultItem.h" -#include "phone.h" -#include "phone-common.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - ResultItem::ResultItem(const Result &result) - : m_Result(result) - { - PH_TRACE; - getResult().formatMatch(m_Match, "<match>", "</>"); - } - - char * ResultItem::getText(const char *part) const - { - PH_TRACE; - if(getResult().getMatchType() == Result::ByNumber) - { - return strdup(getMatch()); - } - else - { - return strdup(getResult().getContact()->getNumber().c_str()); - } - } - - Evas_Object * ResultItem::getContent(const char *part, Evas_Object *parent) const - { - PH_TRACE; - Evas_Object *icon = elm_icon_add(parent); - if(icon) - { - const char *path = NULL; - if(getResult().getContact()->getImagePath().empty()) - { - path = IMG_DEFAULT; - } - else - { - path = getResult().getContact()->getImagePath().c_str(); - } - - Eina_Bool success = elm_image_file_set(icon, path, NULL); - if(!success) - { - evas_object_del(icon); - ERR("elm_image_file_set failed, path: %s", path); - } - } - else - { - ERR("elm_icon_add failed"); - } - - return icon; - } - - Elm_Genlist_Item_Class * ResultItem::getClass() const - { - static Elm_Genlist_Item_Class *itemClass = createClass("1text.1icon.2.tb"); - return itemClass; - } - - const Result & ResultItem::getResult() const - { - return m_Result; - } - - const char * ResultItem::getMatch() const - { - return m_Match.c_str(); - } - } - } -} diff --git a/lib/dialer/Search/ResultItem.h b/lib/dialer/Search/ResultItem.h deleted file mode 100644 index fcb1ed8..0000000 --- a/lib/dialer/Search/ResultItem.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_RESULT_ITEM_H__ -#define __PHONE_DIALER_SEARCH_RESULT_ITEM_H__ - -#include <string> -#include "Item.h" -#include "Search/Result.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Search results list item without Contact name - * @details Displays matched number and highlights the match. - */ - class ResultItem : public Ui::Genlist::Item - { - public: - /* - * @param result Search result associated with the item - */ - ResultItem(const Result &result); - - /* - * @see Genlist::Item::getText - */ - char * getText(const char *part) const; - - /* - * @see Genlist::Item::getContent - */ - Evas_Object * getContent(const char *part, Evas_Object *parent) const; - - /* - * @see Genlist::Item::getClass - */ - Elm_Genlist_Item_Class * getClass() const; - - /* - * @return Search result associated with item - */ - const Result & getResult() const; - - protected: - /* - * @return Search match string with textblock markup - */ - const char * getMatch() const; - - private: - Result m_Result; - std::string m_Match; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_RESULT_ITEM_H__ */ diff --git a/lib/dialer/Search/ResultPopup.cpp b/lib/dialer/Search/ResultPopup.cpp deleted file mode 100644 index fa06be8..0000000 --- a/lib/dialer/Search/ResultPopup.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ResultPopup.h" - -#include "phone.h" -#include "phone-common.h" -#include "Search/ContactItem.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - ResultPopup::ResultPopup() - : m_Popup(NULL), m_Listener(NULL) - { - PH_TRACE; - } - - ResultPopup::~ResultPopup() - { - PH_TRACE; - if(m_Popup) - { - evas_object_del(m_Popup); - m_Popup = NULL; - } - } - - bool ResultPopup::initialize(Evas_Object *parent) - { - PH_TRACE; - m_Popup = elm_popup_add(parent); - if(!m_Popup) - { - return false; - } - - elm_object_style_set(m_Popup, "min_menustyle"); - evas_object_smart_callback_add(m_Popup, "block,clicked", onHide, this); - evas_object_size_hint_weight_set(m_Popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - Evas_Object *button = elm_button_add(m_Popup); - if(!button) - { - evas_object_del(m_Popup); - m_Popup = NULL; - return false; - } - - elm_object_text_set(button, S_(PH_SYS_SK_CANCEL)); - elm_object_part_content_set(m_Popup, "button1", button); - evas_object_smart_callback_add(button, "clicked", onHide, this); - - if(!m_ResultList.create(m_Popup)) - { - evas_object_del(m_Popup); - m_Popup = NULL; - return false; - } - - elm_object_content_set(m_Popup, m_ResultList.getObject()); - evas_object_smart_callback_add(m_ResultList.getObject(), "selected", onResultSelect, this); - return true; - } - - void ResultPopup::setListener(ResultPopupListener *listener) - { - m_Listener = listener; - } - - Evas_Object * ResultPopup::getPopup() const - { - return m_Popup; - } - - void ResultPopup::setResults(const Results &results) - { - PH_TRACE; - elm_genlist_clear(m_ResultList.getObject()); - for(Results::const_iterator - it = results.begin(); - it != results.end(); ++it) - { - if(!it->getContact()->getName().empty()) - { - m_ResultList.append(new ContactItem(*it)); - } - else - { - m_ResultList.append(new ResultItem(*it)); - } - } - } - - void ResultPopup::show() - { - PH_TRACE; - if(m_Popup) - { - evas_object_show(m_Popup); - } - } - - void ResultPopup::hide() - { - PH_TRACE; - if(m_Popup) - { - evas_object_hide(m_Popup); - } - } - - void ResultPopup::onHide(void *data, Evas_Object *obj, void *event) - { - PH_TRACE; - if(data) - { - static_cast<ResultPopup*>(data)->hide(); - } - } - - void ResultPopup::onResultSelect(void *data, Evas_Object *obj, void *event_info) - { - PH_TRACE; - if(!data || !event_info) - { - return; - } - - ResultPopup *popup = static_cast<ResultPopup*>(data); - Elm_Object_Item *objItem = static_cast<Elm_Object_Item*>(event_info); - ResultItem *item = static_cast<ResultItem*>(elm_object_item_data_get(objItem)); - - popup->hide(); - if(popup->m_Listener) - { - popup->m_Listener->onSearchResultSelect(item->getResult()); - } - } - } - } -} - diff --git a/lib/dialer/Search/ResultPopup.h b/lib/dialer/Search/ResultPopup.h deleted file mode 100644 index e4500c3..0000000 --- a/lib/dialer/Search/ResultPopup.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_RESULT_POPUP_H__ -#define __PHONE_DIALER_SEARCH_RESULT_POPUP_H__ - -#include <Elementary.h> -#include "NonCopyable.h" -#include "Genlist.h" -#include "Search/Result.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Dialer search result popup event listener - */ - class ResultPopupListener - { - public: - virtual ~ResultPopupListener() { } - - /* - * @brief Called when result is selected from result list - * @param result Selected result - */ - virtual void onSearchResultSelect(const Result &result) = 0; - }; - - class ResultPopup : public Utils::NonCopyable - { - public: - ResultPopup(); - ~ResultPopup(); - - /* - * @brief Initialize popup. - * @param parent Parent Evas object for popup - */ - bool initialize(Evas_Object *parent); - - /* - * @param listener Popup events listener - */ - void setListener(ResultPopupListener *listener); - - /* - * @return Popup Evas object - */ - Evas_Object * getPopup() const; - - /* - * @brief Set search results to be displayed in popup. - * @param results Search results - */ - void setResults(const Results &results); - - /* - * @brief Show popup. - */ - void show(); - - /* - * @brief Hide popup. - */ - void hide(); - - private: - static void onHide(void *data, Evas_Object *obj, void *event_info); - static void onResultSelect(void *data, Evas_Object *obj, void *event_info); - - Evas_Object *m_Popup; - Ui::Genlist::Genlist m_ResultList; - ResultPopupListener *m_Listener; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_RESULT_POPUP_H__ */ diff --git a/lib/dialer/Search/ResultWidget.cpp b/lib/dialer/Search/ResultWidget.cpp deleted file mode 100644 index ab89fc2..0000000 --- a/lib/dialer/Search/ResultWidget.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "Search/ResultWidget.h" - -#include "phone.h" -#include "phone-common.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - ResultWidget::ResultWidget() - : m_Layout(NULL), m_Icon(NULL), m_Listener(NULL) - { - PH_TRACE; - } - - ResultWidget::~ResultWidget() - { - PH_TRACE; - if(m_Icon) - { - evas_object_del(m_Icon); - m_Icon = NULL; - } - } - - bool ResultWidget::initialize(Evas_Object *layout) - { - PH_TRACE; - if(!layout) - { - return false; - } - - m_Icon = elm_icon_add(layout); - if(!m_Icon) - { - return false; - } - elm_object_part_content_set(layout, "icon", m_Icon); - edje_object_signal_callback_add(_EDJ(layout), "softkey_clicked", "*", onLayoutEvent, this); - - m_Layout = layout; - return true; - } - - void ResultWidget::setListener(ResultWidgetListener *listener) - { - m_Listener = listener; - } - - void ResultWidget::setResult(const Result &result) - { - PH_TRACE; - - std::string number; - result.formatMatch(number, "<mark>", "</mark>"); - - elm_object_part_text_set(m_Layout, "textName", result.getContact()->getName().c_str()); - elm_object_part_text_set(m_Layout, "textNumber", number.c_str()); - - const char *path = NULL; - if(result.getContact()->getImagePath().empty()) - { - path = IMG_DEFAULT; - } - else - { - path = result.getContact()->getImagePath().c_str(); - } - - elm_image_file_set(m_Icon, path, NULL); - } - - void ResultWidget::setResultCount(unsigned count) - { - PH_TRACE; - if(count == 0) - { - char buffer[PH_TEXT_MAX_LEN] = { 0 }; - sprintf(buffer, "+ %s", T_(PH_GET_TEXT_BASIC, PHTEXT_ADD_TO_CONTACTS)); - elm_object_part_text_set(m_Layout, "textAddToContacts", buffer); - edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showAddToContacts", "suggestion"); - } - else if(count == 1) - { - edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showSingleItemView", "suggestion"); - } - else - { - char matchCount[16]; - sprintf(matchCount, "%d", count); - elm_object_part_text_set(m_Layout, "textNumberOfMatches", matchCount); - edje_object_signal_emit(_EDJ(m_Layout), "suggestion/showMultiItemView", "suggestion"); - } - } - - void ResultWidget::hide() - { - PH_TRACE; - edje_object_signal_emit(_EDJ(m_Layout), "suggestion/hide", "suggestion"); - } - - void ResultWidget::onLayoutEvent(void *data, Evas_Object *obj, const char *emission, const char *source) - { - PH_TRACE; - if(!data || !source) - { - return; - } - - ResultWidgetListener *listener = static_cast<ResultWidget*>(data)->m_Listener; - if(!listener) - { - DBG("no listener"); - return; - } - - if(strcmp(source, "suggestion") == 0) - { - listener->onAddToContacts(); - } - else if(strcmp(source, "suggestionListTopItem") == 0) - { - listener->onTopResultSelect(); - } - else if(strcmp(source, "suggestionListButton") == 0) - { - listener->onShowMoreResults(); - } - } - } - } -} diff --git a/lib/dialer/Search/ResultWidget.h b/lib/dialer/Search/ResultWidget.h deleted file mode 100644 index fda0d2b..0000000 --- a/lib/dialer/Search/ResultWidget.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_SEARCH_RESULT_WIDGET_H__ -#define __PHONE_DIALER_SEARCH_RESULT_WIDGET_H__ - -#include <Elementary.h> -#include "Search/Result.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - /* - * @brief Listener for search result widget events - */ - class ResultWidgetListener - { - public: - virtual ~ResultWidgetListener() { } - - /* - * @brief Called when "Add to Contact" button is pressed - */ - virtual void onAddToContacts() = 0; - - /* - * @brief Called when displayed top search result is selected - */ - virtual void onTopResultSelect() = 0; - - /* - * @brief Called when show more results button is pressed - */ - virtual void onShowMoreResults() = 0; - }; - - /* - * @brief Displays information about last search - * @details Displays top search result and number of results - * on More Results button or "Add to Contacts" button if no results - */ - class ResultWidget - { - public: - ResultWidget(); - ~ResultWidget(); - - /* - * @brief Initialize widget. - * @param layout Widget Edje layout - */ - bool initialize(Evas_Object *layout); - - /* - * @param listener Widget event listener - */ - void setListener(ResultWidgetListener *listener); - - /* - * @brief Set search result to be displayed by widget. - * @param result Top search result - */ - void setResult(const Result &result); - - /* - * @brief Set search results count to be displayed on More Results button. - * @param count Results count - */ - void setResultCount(unsigned count); - - /* - * @brief Hide widget - */ - void hide(); - - private: - static void onLayoutEvent(void *data, Evas_Object *obj, const char *emission, const char *source); - - Evas_Object *m_Layout; - Evas_Object *m_Icon; - ResultWidgetListener *m_Listener; - }; - } - } -} - -#endif /* __PHONE_DIALER_SEARCH_RESULT_WIDGET_H__ */ diff --git a/lib/dialer/dialer-efl.desktop.in b/lib/dialer/dialer-efl.desktop.in deleted file mode 100644 index ea965ed..0000000 --- a/lib/dialer/dialer-efl.desktop.in +++ /dev/null @@ -1,10 +0,0 @@ -Name=dialer-efl
-Exec=/opt/ug/bin/dialer-efl
-Icon=
-Type=Application
-Version=0.1.0-0
-NoDisplay=true
-X-TIZEN-Multiple=true
-X-TIZEN-TaskManage=false
-X-TIZEN-Removable=true
-X-TIZEN-SVC=http://tizen.org/appsvc/operation/test|NULL|NULL
diff --git a/lib/dialer/dialer-efl.xml b/lib/dialer/dialer-efl.xml deleted file mode 100644 index 9d0926d..0000000 --- a/lib/dialer/dialer-efl.xml +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns="http://tizen.org/ns/packages" package="dialer-efl" version="0.1.0-0" install-location="internal-only"> - <label>dialer</label> - <author email="ensung.park@samsung.com" href="www.samsung.com">ensung park</author> - <description>dialer-efl Application</description> - <ui-application appid="dialer-efl" exec="/usr/ug/bin/dialer-efl" nodisplay="true" multiple="true" type="capp" taskmanage="false"> - <icon>org.tizen.phone.png</icon> - <label>dialer</label> - <label xml:lang="en-us">dialer</label> - <label xml:lang="nl-nl">dialer</label> - <label xml:lang="de-de">dialer</label> - <label xml:lang="en-gb">dialer</label> - <label xml:lang="zh-hk">dialer</label> - <label xml:lang="zh-cn">dialer</label> - <label xml:lang="ru-ru">dialer</label> - <label xml:lang="zh-tw">dialer</label> - <label xml:lang="ja-jp">dialer</label> - <label xml:lang="es-es">dialer</label> - <label xml:lang="el-gr">dialer</label> - <label xml:lang="it-it">dialer</label> - <label xml:lang="tr-tr">dialer</label> - <label xml:lang="pt-pt">dialer</label> - <label xml:lang="fr-fr">dialer</label> - <label xml:lang="ko-kr">dialer</label> - <application-service> - <operation name="http://tizen.org/ns/packages"/> - </application-service> - </ui-application> -</manifest> diff --git a/lib/dialer/include/KeypadTouchManager.h b/lib/dialer/include/KeypadTouchManager.h deleted file mode 100644 index 03b02fc..0000000 --- a/lib/dialer/include/KeypadTouchManager.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2012-2013 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifndef KEYPADTOUCHMANAGER_H_ -#define KEYPADTOUCHMANAGER_H_ - -#include <stddef.h> -#include <Ecore.h> -#include <Evas.h> -#include <string> -#include <vector> -#include <set> - -namespace Dialer -{ - /** - * KeypadTouchManager is responsible for managing and handling touch-events on numeric keypad. - * After initialising it start listening the following events: - * - EVAS_CALLBACK_MOUSE_DOWN - * - EVAS_CALLBACK_MOUSE_UP - * - EVAS_CALLBACK_MULTI_DOWN - * - EVAS_CALLBACK_MULTI_UP. - * - * At the moment of multiple down event KeypadTouchManager starts single-tick timer that will - * send key-up for keys that were pressed before. - * */ - class KeypadTouchManager - { - static const size_t ROWS = 4; - static const size_t COLS = 3; - static const size_t MULTI_TOUCH_SUPPORT_KEY_COUNT = ROWS * COLS; - static const size_t WRONG_KEY_INDEX = MULTI_TOUCH_SUPPORT_KEY_COUNT + 1; - public: - KeypadTouchManager(); - virtual ~KeypadTouchManager(); - - /** - * Initialises the manager and key-pad area with numeric buttons. - * @param pLayout is a layout-object keypad will be based on. - * */ - void initKeyPadArea(const Evas_Object* pLayout); - - /** - * Stops timer if it was started otherwise does nothing. - * */ - void stopTimer(); - private: - static Eina_Bool onTimer(void *data); - static void onKeyUp(void *data, Evas *e, Evas_Object *o, void *event_info); - static void onKeyDown(void *data, Evas *e, Evas_Object *o, void *event_info); - static void onMultiKeyUp(void *data, Evas *e, Evas_Object *o, void *event_info); - static void onMultiKeyDown(void *data, Evas *e, Evas_Object *o, void *event_info); - - static bool isPtInRect(const Evas_Coord_Rectangle& rect, int x, int y); - private: - void handleKeyUp(int x, int y); - void handleMultiKeyUp(int x, int y); - void handleKeyDown(int x, int y); - void handleMultiKeyDown(int x, int y); - void storeTouchedKey(int x, int y); - void sendEdjeSignal(int x, int y, const char* sygnal); - void handleTouchedKeys(); - size_t getTouchedKeyRectIndex(int x, int y) const; - - typedef std::vector<std::string> ButtonNameContainer; - ButtonNameContainer m_digitalButtonNames; - - Evas_Coord_Rectangle m_dialButtonRects[MULTI_TOUCH_SUPPORT_KEY_COUNT]; - Evas_Coord_Rectangle m_background; - - _Evas_Point m_lastDownPt; - bool m_lastDown; - bool m_lastMultiDown; - Ecore_Timer *m_keypadResetTimer; - - typedef std::set<size_t> TouchedButtonsIndexes; - TouchedButtonsIndexes m_touchedBtns; - - Evas_Object* m_pLayout; - }; -} /* namespace Dialer */ -#endif /* KEYPADTOUCHMANAGER_H_ */ diff --git a/lib/dialer/include/phone-dialer.h b/lib/dialer/include/phone-dialer.h deleted file mode 100755 index b9fbe96..0000000 --- a/lib/dialer/include/phone-dialer.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PHONE_DIALER_H__ -#define __PHONE_DIALER_H__ - -#include "phone-common.h" - -namespace Phone -{ - namespace Dialer - { - namespace Search - { - class Controller; - } - } -} - -#define MAX_DIAL_NUMBER_FONT_SIZE 100 -#define MIN_DIAL_NUMBER_FONT_SIZE 67 - -#define CURSOR_BEGIN -1 -#define CURSOR_END -2 - -#define PH_TAG_TEXT_MAX_LEN (PH_TEXT_MAX_LEN*2) - -enum PH_DAILER_TYPES -{ - PH_DAILER_NORMAL = 0, - PH_DAILER_DURING_CALL, - PH_DAILER_EMERGENCY -}; - -enum -{ - CONTACT_DATA_CHAGNED = 1 << 0, - LOG_DATA_CHAGNED = 1 << 1, - SPEEDDIAL_DATA_CHAGNED = 1 << 2, -}; - -typedef enum -{ - MODE_DIAL_NUMBER = 0, - MODE_COUNTRY_CODE -} ListMode; - -typedef enum -{ - DASH_REAL = 1, - DASH_PREVIEW = DASH_REAL -} DashMode; - -typedef struct _InputNumber -{ - char num; - - struct _InputNumber *prev; - struct _InputNumber *next; -} InputNumber; - -typedef struct -{ - bool alive; - bool success; - bool completed; - pthread_t thread; - Ecore_Pipe *epipe; -} ph_thread_info; - -typedef struct DialerView : public Common::View -{ - Evas_Object *entry; - Evas_Object *genlist; - Evas_Object *fast_index; - Evas_Object *count_button; - Evas_Object *count_layout; - Ecore_Timer *search_timer; - Ecore_Timer *dash_timer; - Ecore_Timer *longpress_timer; - Ecore_Timer *update_timer; - Ecore_Timer *slide_timer; - Ecore_Job *job; - Ecore_Idler *search_idler; - Ecore_Event_Handler *key_press; - Ecore_Event_Handler *key_release; - char *longpress_source; - char *searched_text; - char* selected_text; - InputNumber number_head; - InputNumber *number_cursor; - int cur_mcc; - int cur_sim_mcc; - int cur_cc_index; - int roaming; - int entry_font_size; - int count_button_status; - int run_mode; - int compare_N; - int show_N; - int searched_speed_id; - int data_dirty_flag; - int touch_x; - int touch_y; - ListMode list_mode; - bool is_background; - bool is_emergency; - bool cursor_changed; - bool is_show_items; - bool has_focus; - bool initialized; - bool searching; - bool loading; - bool slide; - ph_thread_info *t_info; // load contact - Eina_List *search_list; - Eina_List *contact_list; - Eina_List *speeddial_list; - Eina_List *log_list; - Eina_List *cc_list; - Eina_List *cc_list_sorted; - Phone::Dialer::Search::Controller *m_Search; -} ph_dialer_data; - -Evas_Object* phone_create_dialer_view(ph_view_info *view_info); -void phone_dialer_set_navi(Evas_Object *layout); -void phone_dialer_check_focus(Evas_Object *base); -void phone_dialer_view_reset(Evas_Object *base); -void phone_dialer_view_language_changed(Evas_Object *layout); -void phone_dialer_view_resume(Evas_Object *base); -void phone_dialer_set_background(Evas_Object *obj, bool is_background); -void phone_dialer_view_set_num(Evas_Object *layout, char *number); -void phone_dialer_view_send_key(Evas_Object *layout); - -#endif /* __PHONE_DIALER_H__ */ diff --git a/lib/dialer/ph-dialer-main.cpp b/lib/dialer/ph-dialer-main.cpp deleted file mode 100755 index 618623a..0000000 --- a/lib/dialer/ph-dialer-main.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <bundle.h> -#include <ui-gadget-module.h> -#include <efl_assist.h> - -#include "phone.h" -#include "phone-dialer.h" - -#include "ph-dialer-view.h" -#include "ph-dialer-utils.h" -#include "ViewManager.h" - -static bool is_ug_exist = false; - -static bool dialer_create_ug_view(ph_dialer_data *dial_d, Evas_Object *base) -{ - PH_TRACE; - int ret; - const char *title; - p_retvm_if(NULL == dial_d, false, "Parameter is null"); - - if (NULL == dial_d->navi) - { - dial_d->navi = elm_naviframe_add(base); - p_retvm_if(NULL == dial_d->navi, false, "elm_naviframe_add is failed"); - ea_object_event_callback_add(dial_d->navi, EA_CALLBACK_BACK, &Common::ViewManager::onBack, dial_d->win); - ea_object_event_callback_add(dial_d->navi, EA_CALLBACK_MORE, &Common::ViewManager::onMenu, NULL); - elm_object_part_content_set(base, "elm.swallow.content", dial_d->navi); - evas_object_show(dial_d->navi); - } - - ret = ph_dialer_create_content(dial_d); - p_retvm_if(ret < 0, false, "Fail to ph_dialer_create_content"); - if (dial_d->is_emergency) - title = T_(PH_GET_TEXT_BASIC, PHTEXT_EMERGENCY_CALL); - else - title = T_(PH_GET_TEXT_BASIC, PHTEXT_KEYPAD); - - elm_naviframe_item_push(dial_d->navi, title, NULL, NULL, dial_d->layout, - NULL); - - return true; -} - -void* dialer_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, - void *priv) -{ - PH_TRACE; - int ret; - char *val = NULL; - Evas_Object *bg; - Evas_Object *parent; - Evas_Object *base; - ph_dialer_data *dial_d = (ph_dialer_data *) priv; - bundle *data; - - p_retvm_if(true == is_ug_exist, NULL, "dialer_emergency ug already exist"); - is_ug_exist = true; - - p_retvm_if(NULL == ug || NULL == priv, NULL, - "The parameter is invalid(ug=%p, priv=%p)", ug, priv); - - parent = (Evas_Object *) ug_get_parent_layout(ug); - p_retvm_if(NULL == parent, NULL, "ug_get_parent_layout() return NULL"); - dial_d->ug = ug; - dial_d->win = (Evas_Object *) ug_get_window(); - elm_win_wm_rotation_available_rotations_set(dial_d->win, NULL, 0); - elm_win_wm_rotation_preferred_rotation_set(dial_d->win, 0); - - bindtextdomain(PACKAGE, LOCALEDIR); - - service_to_bundle(service, &data); - ret = contacts_connect2(); - if (CONTACTS_ERROR_NONE != ret) - { - bundle_free(data); - p_warn_if(CONTACTS_ERROR_NONE != ret, "contacts_connect2() Failed(%d)", - ret); - return NULL; - } - - val = (char*) bundle_get_val(data, "emergency_dialer"); - if (val && 0 == strcmp(val, "emergency")) - dial_d->is_emergency = true; - else - dial_d->is_emergency = false; - bundle_free(data); - - if (UG_MODE_FULLVIEW == mode) - base = phone_create_base_layout(parent, true); - else - base = phone_create_base_layout(parent, false); - - bg = phone_create_bg(base); - if (NULL == bg) - { - PH_DBG("phone_create_bg() return NULL"); - evas_object_del(base); - ret = contacts_disconnect2(); - p_warn_if(CONTACTS_ERROR_NONE != ret, - "contacts_disconnect2() Failed(%d)", ret); - return NULL; - } - - if (!dialer_create_ug_view(dial_d, base)) - { - evas_object_del(base); - ret = contacts_disconnect2(); - p_warn_if(CONTACTS_ERROR_NONE != ret, - "contacts_disconnect2() Failed(%d)", ret); - base = NULL; - } - return base; -} - -static void dialer_on_event(ui_gadget_h ug, enum ug_event event, - service_h service, void *priv) -{ - PH_TRACE; - ph_dialer_data *dial_d = (ph_dialer_data *) priv; - - switch (event) - { - case UG_EVENT_ROTATE_PORTRAIT: - case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: - case UG_EVENT_ROTATE_LANDSCAPE: - case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: - break; - case UG_EVENT_LANG_CHANGE: - phone_dialer_view_language_changed(dial_d->layout); - break; - default: - break; - } -} - -static void dialer_on_pause(ui_gadget_h ug, service_h service, void *priv) -{ - PH_TRACE; - ph_dialer_data *dial_d = (ph_dialer_data *) priv; - dial_d->is_background = true; -} - -static void dialer_on_resume(ui_gadget_h ug, service_h service, void *priv) -{ - PH_TRACE; - ph_dialer_data *dial_d = (ph_dialer_data *) priv; - dial_d->is_background = false; - if (dial_d->update_timer) - { - ecore_timer_del(dial_d->update_timer); - dial_d->update_timer = NULL; - ph_dialer_reload_data(dial_d); - } -} - -static void dialer_on_destroy(ui_gadget_h ug, service_h service, void *priv) -{ - PH_TRACE; - if (!ug) - return; - elm_win_wm_rotation_preferred_rotation_set((Evas_Object *) ug_get_window(), -1); - evas_object_del((Evas_Object *) ug_get_layout(ug)); - contacts_disconnect2(); -} - -static void dialer_on_message(ui_gadget_h ug, service_h msg, service_h service, - void *priv) -{ - PH_TRACE; -} - -extern "C" API int UG_MODULE_INIT(struct ug_module_ops *ops) -{ - PH_TRACE; - ph_dialer_data *dial_d; - p_retvm_if(NULL == ops, -1, "ops is NULL"); - - dial_d = (ph_dialer_data *) calloc(1, sizeof(ph_dialer_data)); - p_retvm_if(NULL == dial_d, -1, "dial_d is NULL, Not enough memory"); - - ops->create = dialer_on_create; - ops->start = NULL; - ops->pause = dialer_on_pause; - ops->resume = dialer_on_resume; - ops->destroy = dialer_on_destroy; - ops->message = dialer_on_message; - ops->event = dialer_on_event; - ops->priv = dial_d; - ops->opt = UG_OPT_INDICATOR_ENABLE; - - return 0; -} - -extern "C" API void UG_MODULE_EXIT(struct ug_module_ops *ops) -{ - PH_TRACE; - p_retm_if(!ops, "ops is NULL"); - - ops->priv = NULL; -} - -API Evas_Object* phone_create_dialer_view(ph_view_info *view_info) -{ - PH_TRACE; - p_retvm_if(NULL == view_info, NULL, "The parameter(view_info) is NULL"); - - ph_dialer_data *dial_d = (ph_dialer_data *) calloc(1, sizeof(ph_dialer_data)); - p_retvm_if(NULL == dial_d, NULL, "dial_d is NULL, Not enough memory"); - dial_d->ug = view_info->ug; - dial_d->win = view_info->win; - dial_d->navi = view_info->navi; - dial_d->is_emergency = !isSimPresent(); - dial_d->is_background = true; - - if (!ph_dialer_create_content(dial_d)) - { - free(dial_d); - return NULL; - } - return dial_d->layout; -} - diff --git a/lib/dialer/ph-dialer-search.cpp b/lib/dialer/ph-dialer-search.cpp deleted file mode 100755 index b72cc10..0000000 --- a/lib/dialer/ph-dialer-search.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE // for strcasestr -#endif - -#include <feedback.h> -#include <pthread.h> -#include <unistd.h> - -#include <app_manager.h> - -#include "phone.h" -#include "phone-dialer.h" -#include "ph-dialer-utils.h" -#include "ph-dialer-view.h" -#include "ph-dialer-search.h" -#include "ph-dialer-tapi.h" - -void ph_dialer_search_request(void *data, int force_search) -{ - PH_TRACE; - return; -} - diff --git a/lib/dialer/ph-dialer-search.h b/lib/dialer/ph-dialer-search.h deleted file mode 100755 index 66f2a1e..0000000 --- a/lib/dialer/ph-dialer-search.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PH_DIALER_SEARCH_H__ -#define __PH_DIALER_SEARCH_H__ - -void ph_dialer_search_request(void *data, int force_search); -void ph_dialer_search_result_clicked(void *data, Evas_Object *obj, - const char *emission, const char *source); -void ph_dialer_search_free_search_data(ph_dialer_data *dial_d); -void ph_dialer_search_free_log_data(ph_dialer_data *dial_d); -void ph_dialer_search_free_cc_data(ph_dialer_data *dial_d); -void ph_dialer_search_find_cur_sim_cc(ph_dialer_data *dial_d); -void ph_dialer_search_fill_genlist_by_list(ph_dialer_data *dial_d); -void ph_dialer_search_fill_genlist_by_cc_list(ph_dialer_data *dial_d); -void ph_dialer_search_set_genlist_item_style(); - -#endif /* __PH_DIALER_SEARCH_H__ */ diff --git a/lib/dialer/ph-dialer-tapi.cpp b/lib/dialer/ph-dialer-tapi.cpp deleted file mode 100755 index 57cebe6..0000000 --- a/lib/dialer/ph-dialer-tapi.cpp +++ /dev/null @@ -1,533 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <tapi_common.h> -#include <ITapiSim.h> -#include <ITapiPhonebook.h> -#include <TapiUtility.h> -#include <regex.h> - -#include "phone.h" -#include "phone-dialer.h" -#include "ph-dialer-utils.h" - -#ifdef Status -#undef Status -#endif - -static TapiHandle *handle = NULL; - -typedef enum -{ - SIM_INCORRECT_PIN1_CODE, - SIM_INCORRECT_PIN2_CODE, - SIM_PIN1_CHANGE_SUCCESS, - SIM_PIN2_CHANGE_SUCCESS, - SIM_PIN1_BLOCKED, - SIM_PIN2_BLOCKED, -} sim_stat_value; - -typedef enum -{ - TYPE_PIN1 = 0, - TYPE_PIN2, -} pin_type_value; -typedef struct _tapi_receive_info -{ - sim_stat_value stat; - int retry_cnt; -} tapi_receive_info; - -#define PIN1_REGEX "^\\*\\*04\\*[0-9]{4}\\*[0-9]{4}\\*[0-9]{4}#$" -#define PIN2_REGEX "^\\*\\*042\\*[0-9]{4}\\*[0-9]{4}\\*[0-9]{4}#$" -#define PUK_REGEX "\\*\\*05\\*[0-9]{8}\\*[0-9]{4}\\*[0-9]{4}#$" - -int dialer_tapi_init() -{ - PH_TRACE; - handle = tel_init(NULL); - if (NULL == handle) - return FALSE; - return TRUE; -} - -int dialer_tapi_deinit() -{ - PH_TRACE; - int ret = tel_deinit(handle); - handle = NULL; - return ret; -} - -int dialer_check_pin_str(const char* number, char **old_pin, char **new_pin, - char **com_pin, int* pin_type) -{ - PH_TRACE; - regex_t fsm; - regmatch_t str[strlen(number) + 1]; - char* origin_string; - char * str_temp; - - if (regcomp(&fsm, PIN1_REGEX, REG_EXTENDED)) - { - PH_DBG("regular expression fail"); - regfree(&fsm); - return FALSE; - } - else - { - if (regexec(&fsm, number, strlen(number) + 1, str, 0) == REG_NOMATCH) - { - PH_DBG("regular expression 1 matching fail"); - regfree(&fsm); - } - else - { - PH_DBG("regular expression 1 matching success"); - origin_string = strdup(number); - str_temp = origin_string + 5; - *old_pin = strdup(strtok(str_temp, "*")); - *new_pin = strdup(strtok(NULL, "*")); - *com_pin = strdup(strtok(NULL, "#")); - *pin_type = TYPE_PIN1; - free(origin_string); - regfree(&fsm); - return TRUE; - } - } - - if (regcomp(&fsm, PIN2_REGEX, REG_EXTENDED)) - { - PH_DBG("regular expression fail"); - regfree(&fsm); - return FALSE; - } - else - { - if (regexec(&fsm, number, strlen(number) + 1, str, 0) == REG_NOMATCH) - { - PH_DBG("regular expression 2 matching fail"); - regfree(&fsm); - } - else - { - PH_DBG("regular expression 2 matching success"); - origin_string = strdup(number); - str_temp = origin_string + 5; - *old_pin = strdup(strtok(str_temp, "*")); - *new_pin = strdup(strtok(NULL, "*")); - *com_pin = strdup(strtok(NULL, "#")); - *pin_type = TYPE_PIN2; - free(origin_string); - regfree(&fsm); - return TRUE; - } - } - return FALSE; -} - -void dialer_pin_result_popup(tapi_receive_info* result, void* data) -{ - PH_TRACE; - Evas_Object *popup; - ph_dialer_data *dial_d = (ph_dialer_data *) data; - - popup = elm_popup_add(dial_d->win); - evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - - switch (result->stat) - { - case SIM_PIN1_CHANGE_SUCCESS: - case SIM_PIN2_CHANGE_SUCCESS: - phone_show_popup(dial_d->navi, S_(CT_SYS_POP_SUCCESS), 2.0); - break; - case SIM_INCORRECT_PIN1_CODE: - case SIM_INCORRECT_PIN2_CODE: - phone_show_popup(dial_d->navi, S_(PH_SYS_POP_INCORRECT_PASSWORD), - 2.0); - break; - case SIM_PIN1_BLOCKED: - case SIM_PIN2_BLOCKED: - phone_show_popup(dial_d->navi, S_(PH_SYS_SK3_BLOCK), 2.0); - break; - default: - elm_object_text_set(popup, "dafault case called"); - break; - } -} - -void dialer_sim_change_pins_cb(TapiHandle *handle, int result, void *data, - void *user_data) -{ - PH_TRACE; - TelSimPinOperationResult_t sec_rt = (TelSimPinOperationResult_t) result; - TelSimSecResult_t *sim_event_data = (TelSimSecResult_t *) data; - tapi_receive_info result_info = { (sim_stat_value) 0, 0,}; - - PH_DBG("sec_rt[%d]", sec_rt); - PH_DBG("sim_event_data->type:%d", sim_event_data->type); - PH_DBG("sim_event_data->retry_count[%d]", sim_event_data->retry_count); - - if (sec_rt == TAPI_SIM_PIN_OPERATION_SUCCESS) - { - if (sim_event_data->type == TAPI_SIM_PTYPE_PIN1) - result_info.stat = SIM_PIN1_CHANGE_SUCCESS; - else if (sim_event_data->type == TAPI_SIM_PTYPE_PIN2) - result_info.stat = SIM_PIN2_CHANGE_SUCCESS; - } - else if (sec_rt == TAPI_SIM_PIN_INCORRECT_PASSWORD) - { - if (sim_event_data->type == TAPI_SIM_PTYPE_PIN1) - { - result_info.stat = SIM_INCORRECT_PIN1_CODE; - result_info.retry_cnt = sim_event_data->retry_count; - } - else if (sim_event_data->type == TAPI_SIM_PTYPE_PIN2) - { - result_info.stat = SIM_INCORRECT_PIN2_CODE; - result_info.retry_cnt = sim_event_data->retry_count; - } - } - else if (sec_rt == TAPI_SIM_PUK_REQUIRED) - { - if (sim_event_data->type == TAPI_SIM_PTYPE_PIN1) - result_info.stat = SIM_PIN1_BLOCKED; - else if (sim_event_data->type == TAPI_SIM_PTYPE_PIN2) - result_info.stat = SIM_PIN2_BLOCKED; - } - else - { - ERR("INCORRECTED"); - return; - } - dialer_pin_result_popup(&result_info, user_data); -} - -void dialer_pin_operation(int type, const char *old_pin, const char *new_pin, - void* data) -{ - PH_TRACE; - int tapi_ret = -100; - ph_dialer_data *dial_d = (ph_dialer_data *) data; - - char old_pw[PH_TEXT_MAX_LEN] = { 0 }; - char new_pw[PH_TEXT_MAX_LEN] = { 0 }; - - TelSimSecPw_t sim_old_sec_data = { (TelSimPinType_t) 0, 0, 0}; - TelSimSecPw_t sim_new_sec_data = { (TelSimPinType_t) 0, 0, 0}; - - if (handle == NULL) - PH_DBG("tapi handle is null"); - - snprintf(old_pw, sizeof(old_pw), "%s", old_pin); - snprintf(new_pw, sizeof(new_pw), "%s", new_pin); - - switch (type) - { - case TYPE_PIN1: - sim_old_sec_data.type = TAPI_SIM_PTYPE_PIN1; - sim_new_sec_data.type = TAPI_SIM_PTYPE_PIN1; - sim_old_sec_data.pw_len = STRLEN(old_pw); - sim_old_sec_data.pw = (unsigned char *) calloc(1, - sim_old_sec_data.pw_len); - memcpy(sim_old_sec_data.pw, old_pw, sim_old_sec_data.pw_len); - sim_new_sec_data.pw_len = STRLEN(new_pw); - sim_new_sec_data.pw = (unsigned char *) calloc(1, - sim_new_sec_data.pw_len); - memcpy(sim_new_sec_data.pw, new_pw, sim_new_sec_data.pw_len); - break; - case TYPE_PIN2: - sim_old_sec_data.type = TAPI_SIM_PTYPE_PIN2; - sim_new_sec_data.type = TAPI_SIM_PTYPE_PIN2; - sim_old_sec_data.pw_len = STRLEN(old_pw); - sim_old_sec_data.pw = (unsigned char *) calloc(1, - sim_old_sec_data.pw_len); - memcpy(sim_old_sec_data.pw, old_pw, sim_old_sec_data.pw_len); - sim_new_sec_data.pw_len = STRLEN(new_pw); - sim_new_sec_data.pw = (unsigned char *) calloc(1, - sim_new_sec_data.pw_len); - memcpy(sim_new_sec_data.pw, new_pw, sim_new_sec_data.pw_len); - break; - default: - ERR("Never get here(type: %d)", type); - break; - } - - tapi_ret = tel_change_sim_pins(handle, &sim_old_sec_data, &sim_new_sec_data, - dialer_sim_change_pins_cb, data); - PH_DBG("return_num:%d", tapi_ret); - - if (tapi_ret != TAPI_API_SUCCESS) - { - ERR("TelTapiSimChangePIN err=%d ", tapi_ret); - phone_show_popup(dial_d->navi, S_(CT_SYS_POP_ERROR), 2.0); - } - free(sim_old_sec_data.pw); - free(sim_new_sec_data.pw); -} - -int GCF_tapi_init() -{ - PH_TRACE; - int status; - int ret; - TelSimPbList_t pb_list; - - handle = tel_init(NULL); - if (NULL == handle) - return FALSE; - - ret = tel_get_sim_pb_init_info(handle, &status, &pb_list); - if (TAPI_API_SUCCESS != ret) - { - ERR("tel_get_sim_pb_init_info() is failed(%d)", ret); - tel_deinit(handle); - handle = NULL; - return FALSE; - } - - if (!status) - { - ERR("SIM is not available"); - tel_deinit(handle); - handle = NULL; - return FALSE; - } - return TRUE; -} - -int GCF_tapi_deinit() -{ - PH_TRACE; - int ret = tel_deinit(handle); - handle = NULL; - return ret; -} - -static void sim_async_response_verify_puk(TapiHandle *handle, int result, - void *data, void *user_data) -{ - PH_TRACE; - TelSimPinOperationResult_t sec_rt = (TelSimPinOperationResult_t) result; - TelSimSecResult_t *pPinInfo = (TelSimSecResult_t *) data; - - if (sec_rt == TAPI_SIM_PIN_OPERATION_SUCCESS) - { - if (pPinInfo->type == TAPI_SIM_PTYPE_PUK1) - { - ph_dialer_data *dial_d = (ph_dialer_data *) user_data; - phone_show_popup(dial_d->navi, - T_(PH_GET_TEXT_BASIC, PHTEXT_REQUEST_SUCCESS), 2.0); - } - else if (pPinInfo->type == TAPI_SIM_PTYPE_PIN2) - PH_DBG("Unblock PIN2 Success!"); - } - else - { - if (pPinInfo->type == TAPI_SIM_PTYPE_PUK1) - { - ph_dialer_data *dial_d = (ph_dialer_data *) user_data; - phone_show_popup(dial_d->navi, - T_(PH_GET_TEXT_BASIC, PHTEXT_REQUEST_FAIL), 2.0); - } - else if (pPinInfo->type == TAPI_SIM_PTYPE_PIN1 - || pPinInfo->type == TAPI_SIM_PTYPE_PIN2 - || pPinInfo->type == TAPI_SIM_PTYPE_PUK2) - { - ERR("%d Verification Failed! - PIN Required", pPinInfo->type); - PH_DBG("Remainint attempts [%d]", pPinInfo->retry_count); - } - } - - GCF_tapi_deinit(); -} - -void GCF_test_puk_operation(const char *puk1, const char *pin1, void *user_data) -{ - PH_TRACE; - char init_pin_val[PH_TEXT_MAX_LEN] = { 0 }; - char init_puk_val[PH_TEXT_MAX_LEN] = { 0 }; - - TelSimSecPw_t puk_data; - TelSimSecPw_t new_pin_data; - int ret; - - memset(&puk_data, 0, sizeof(TelSimSecPw_t)); - memset(&new_pin_data, 0, sizeof(TelSimSecPw_t)); - - PH_DBG("puk1:%s", puk1); - PH_DBG("pin1: %s", pin1); - - snprintf(init_puk_val, sizeof(init_puk_val), "%s", puk1); - snprintf(init_pin_val, sizeof(init_pin_val), "%s", pin1); - - puk_data.type = TAPI_SIM_PTYPE_PUK1; // 0x00 - puk_data.pw_len = strlen(init_puk_val); - puk_data.pw = (unsigned char*) calloc(1, puk_data.pw_len); - memcpy(puk_data.pw, init_puk_val, puk_data.pw_len); - - new_pin_data.type = TAPI_SIM_PTYPE_PIN1; // 0x00 - new_pin_data.pw_len = strlen(init_pin_val); - new_pin_data.pw = (unsigned char*) calloc(1, new_pin_data.pw_len); - memcpy(new_pin_data.pw, init_pin_val, new_pin_data.pw_len); - - ret = tel_verify_sim_puks(handle, &puk_data, &new_pin_data, - sim_async_response_verify_puk, user_data); - if (ret != TAPI_API_SUCCESS) - { - ERR("TAPI API FAIL: Error Code [0x%x]", ret); - GCF_tapi_deinit(); - } - - free(puk_data.pw); - free(new_pin_data.pw); -} - -static void sim_async_response_read_contact(TapiHandle *handle, int result, - void *data, void *user_data) -{ - PH_TRACE; - TelSimPbAccessResult_t sec_rt = (TelSimPbAccessResult_t) result; - TelSimPbRecord_t *sim_acces_info = (TelSimPbRecord_t *) data; - - if (sec_rt != TAPI_SIM_PB_SUCCESS) - { - ERR("SIM phone book access error [%d]", sec_rt); - GCF_tapi_deinit(); - return; - } - - if (sim_acces_info->phonebook_type == TAPI_SIM_PB_ADN) //KKC - ADN number value! - ph_dialer_util_show_matched_one_number((ph_dialer_data *) user_data, - (char *) sim_acces_info->name, (char *) sim_acces_info->number); - else if (sim_acces_info->phonebook_type == TAPI_SIM_PB_3GSIM) - { - if (strlen((const char *) sim_acces_info->number) > 0) - ph_dialer_util_show_matched_one_number((ph_dialer_data *) user_data, - (char *) sim_acces_info->name, - (char *) (sim_acces_info->number)); - if (sim_acces_info->anr1_ton == TAPI_SIM_TON_ABBREVIATED_NUMBER) //KKC - USIM ADN number value! - ph_dialer_util_show_matched_one_number((ph_dialer_data *) user_data, NULL, - (char *) (sim_acces_info->anr1)); - if (sim_acces_info->anr2_ton == TAPI_SIM_TON_ABBREVIATED_NUMBER) //KKC - USIM ADN number value! - ph_dialer_util_show_matched_one_number((ph_dialer_data *) user_data, NULL, - (char *) (sim_acces_info->anr2)); - if (sim_acces_info->anr3_ton == TAPI_SIM_TON_ABBREVIATED_NUMBER) //KKC - USIM ADN number value! - ph_dialer_util_show_matched_one_number((ph_dialer_data *) user_data, NULL, - (char *) (sim_acces_info->anr3)); - } - GCF_tapi_deinit(); -} - -void GCF_test_read_contact(int index, void *user_data) -{ - PH_TRACE; - TelSimPbType_t pb_type = (TelSimPbType_t) 0; - TelSimCardType_t card_type = (TelSimCardType_t) 0; - int ret; - - tel_get_sim_type(handle, &card_type); - if (card_type == TAPI_SIM_CARD_TYPE_GSM) - pb_type = TAPI_SIM_PB_ADN; - else if (card_type == TAPI_SIM_CARD_TYPE_USIM) - pb_type = TAPI_SIM_PB_3GSIM; - - ret = tel_read_sim_pb_record(handle, pb_type, index, - sim_async_response_read_contact, user_data); - if (ret != TAPI_API_SUCCESS) - { - ERR("TAPI API FAIL: Error Code [0x%x]", ret); - GCF_tapi_deinit(); - } -} - -/* Gcf Puk1*/ -#define GCF_PUK1_PRE_VALUE "**05*" - -int GCF_check_puk_str(const char* number, char **dest_puk, char **dest_pin1, - char **dest_pin2, int size_dest) -{ - PH_TRACE; - regex_t fsm; - regmatch_t str[strlen(number) + 1]; - char* origin_string; - char * str_temp; - - if (regcomp(&fsm, PUK_REGEX, REG_EXTENDED)) - { - PH_DBG("regular expression fail"); - regfree(&fsm); - return FALSE; - } - else - { - if (regexec(&fsm, number, strlen(number) + 1, str, 0) == REG_NOMATCH) - { - PH_DBG("matching fail"); - regfree(&fsm); - } - else - { - PH_DBG("matching success"); - origin_string = strdup(number); - str_temp = origin_string + 5; - *dest_puk = strdup(strtok(str_temp, "*")); - *dest_pin1 = strdup(strtok(NULL, "*")); - *dest_pin2 = strdup(strtok(NULL, "#")); - free(origin_string); - regfree(&fsm); - return TRUE; - } - } - return FALSE; -} - -bool GCF_check_admin_sim(const char *number, int *ret_index) -{ - PH_TRACE; - int count; - char *dest; - bool success; - p_retvm_if(number==NULL || ret_index==NULL, FALSE, "Parameter is null"); - - count = strlen(number); - p_retvm_if(count < 2, FALSE, "number length is too short"); - dest = (char*) calloc(1, count); - - success = true; - if (number[count - 1] == '#') - { - int i = 0; - for (; i < count - 1; i++) - { - if ('0' <= number[i] && number[i] <= '9') - dest[i] = number[i]; - else - { - success = false; - break; - } - } - if (success) - *ret_index = atoi(dest); - } - else - success = false; - free(dest); - - return success; -} - diff --git a/lib/dialer/ph-dialer-tapi.h b/lib/dialer/ph-dialer-tapi.h deleted file mode 100755 index f9f71e4..0000000 --- a/lib/dialer/ph-dialer-tapi.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PH_DIALER_TAPI_H__ -#define __PH_DIALER_TAPI_H__ - -int GCF_tapi_init(); -int GCF_tapi_deinit(); -void GCF_test_puk_operation(const char *puk1, const char *pin1, - void *user_data); -void GCF_test_read_contact(int index, void *user_data); -int GCF_check_puk1_str(const char *number, char *dest_puk, char *dest_pin1, - char *dest_pin2, int size_dest); -bool GCF_check_admin_sim(const char *number, int *ret_index); - -#endif /* __PH_DIALER_TAPI_H__ */ diff --git a/lib/dialer/ph-dialer-utils.cpp b/lib/dialer/ph-dialer-utils.cpp deleted file mode 100755 index 2de38f1..0000000 --- a/lib/dialer/ph-dialer-utils.cpp +++ /dev/null @@ -1,966 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif - -#include <string.h> -#include <vconf.h> -#include <vconf-keys.h> -#include <bundle.h> -#include <aul.h> -#include <tapi_common.h> -#include <ITapiSim.h> -#include <TapiUtility.h> -#include <feedback.h> -#include <ui-gadget-module.h> - -#include "phone.h" -#include "phone-dialer.h" -#include "phone-speed.h" - -#include "ph-dialer-utils.h" -#include "ph-dialer-view.h" -#include "ph-dialer-search.h" - -#define PH_DIALER_KEY_MAX_LEN 256 - -ph_speeddial_info* ph_dialer_util_get_speeddial_by_number(void *data, - int number) -{ - PH_TRACE; - void *v_find_sd = NULL; - ph_dialer_data *dial_d = (ph_dialer_data *) data; - Eina_List *l; - - p_retvm_if(NULL == dial_d->speeddial_list, NULL, - "There is no speeddial list"); - - EINA_LIST_FOREACH(dial_d->speeddial_list, l, v_find_sd) - { - ph_speeddial_info * find_sd = (ph_speeddial_info *) v_find_sd; - if (!find_sd) - continue; - if (number == find_sd->dial_number && find_sd->ph_number) - { - if (number == 1) - { - free(find_sd->ph_number); - find_sd->ph_number = phone_get_voice_mail_number(); - } - break; - } - } - return (ph_speeddial_info *) v_find_sd; -} - -void ph_dialer_util_entry_clear(ph_dialer_data *dial_d) -{ - PH_TRACE; - ph_dialer_util_del_all_number(dial_d); - ph_dialer_entry_set_number(*dial_d, "", 0); - if (dial_d->has_focus) - { - elm_object_focus_set(dial_d->entry, EINA_FALSE); - dial_d->has_focus = false; - } - ph_dialer_search_request(dial_d, FALSE); -} - -void ph_dialer_util_launch_call(ph_dialer_data *dial_d) -{ - PH_TRACE; - char num[PH_TEXT_MAX_LEN] = { 0 }; - int text_len; - bundle* kb; - - p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); - - text_len = ph_dialer_util_get_pure_numstr_with_plus(dial_d, num); - if (0 < text_len) - { - if (PH_DAILER_EMERGENCY == dial_d->run_mode) - { - kb = bundle_create(); - p_retm_if(NULL == kb, "bundle_create() Failed"); - bundle_add(kb, "launch-type", "EMERGENCY"); - bundle_add(kb, "number", num); - aul_launch_app(VOICECALL_PKG, kb); - bundle_free(kb); - } - else - phone_launch_voice_call(-1, num); - } - - ph_dialer_util_entry_clear(dial_d); -} - -int ph_dialer_util_get_cursor_pos(ph_dialer_data *dial_d) -{ - PH_TRACE; - InputNumber *node; - int pos = 0; - p_retvm_if(NULL == dial_d->number_cursor, 0, "cursor of number is null"); - - node = &dial_d->number_head; - while (dial_d->number_cursor != node) - { - node = node->next; - if (!node) - break; - pos++; - } - return pos; -} - -int ph_dialer_util_is_dash(char ch) -{ - PH_TRACE; - if (ch == '-' || ch == '(' || ch == ')' || ch == ' ') - return TRUE; - return FALSE; -} - -static int dialer_util_is_dash_and_plus(char ch) -{ - PH_TRACE; - if (ch == '-' || ch == '+' || ch == '(' || ch == ')' || ch == ' ') - return TRUE; - return FALSE; -} - -int ph_dialer_util_get_pure_numstr(ph_dialer_data *dial_d, char *dest) -{ - PH_TRACE; - InputNumber *node; - int cnt = 0; - p_retvm_if(NULL == dest, 0, "dest is null"); - - node = dial_d->number_head.next; - while (1) - { - if (!node) - break; - if (dialer_util_is_dash_and_plus(node->num) == FALSE) - dest[cnt++] = node->num; - node = node->next; - } - dest[cnt] = '\0'; - return cnt; -} - -InputNumber *ph_dialer_util_get_node_by_index(ph_dialer_data *dial_d, int index) -{ - PH_TRACE; - InputNumber *node; - int i = 0; - - node = &dial_d->number_head; - for (; i < index; i++) - { - if (node->next) - node = node->next; - } - return node; -} - -int ph_dialer_util_get_pure_numstr_with_plus(ph_dialer_data *dial_d, char *dest) -{ - PH_TRACE; - InputNumber *node; - int cnt = 0; - p_retvm_if(NULL == dest, 0, "dest is null"); - - node = dial_d->number_head.next; - while (node) - { - if (ph_dialer_util_is_dash(node->num) == FALSE) - dest[cnt++] = node->num; - node = node->next; - } - dest[cnt] = '\0'; - return cnt; -} - -int ph_dialer_util_get_numstr_from_node(ph_dialer_data *dial_d, char *dest) -{ - PH_TRACE; - InputNumber *node; - int cnt = 0; - p_retvm_if(NULL == dest, 0, "dest is null"); - - node = dial_d->number_head.next; - while (node) - { - dest[cnt++] = node->num; - node = node->next; - } - dest[cnt] = '\0'; - return cnt; -} - -int ph_dialer_util_del_all_number(ph_dialer_data *dial_d) -{ - PH_TRACE; - int len = 0; - InputNumber *node = NULL; - InputNumber *tmp_node = NULL; - p_retvm_if(NULL == dial_d, 0, "dialer data is null"); - - node = dial_d->number_head.next; - while (node) - { - tmp_node = node; - - if (node->next) - node->next->prev = node->prev; - if (node->prev) - node->prev->next = node->next; - - node = node->next; - len++; - - free(tmp_node); - } - dial_d->number_cursor = &dial_d->number_head; - dial_d->entry_font_size = MAX_DIAL_NUMBER_FONT_SIZE; - - return len; -} - -static int dialer_util_is_num_length_over(int len) -{ - PH_TRACE; - if (len >= PH_DIALER_KEY_MAX_LEN) - return TRUE; - return FALSE; -} - -int ph_dialer_util_append_node_from_numstr(ph_dialer_data *dial_d, char *string) -{ - PH_TRACE; - int i = 0; - int j = 0; - int len = 0; - InputNumber *node; - InputNumber *tmp_node = NULL; - char *tmp_string = NULL; - - ph_dialer_util_del_all_number(dial_d); - - p_retvm_if(NULL == string, 0, "string data is null"); - - node = &dial_d->number_head; - - len = strlen(string); - if (dialer_util_is_num_length_over(len - 1) == TRUE) - { - phone_show_popup(dial_d->navi, - T_(PH_GET_TEXT_BASIC, PHTEXT_EXCEED_NUM_MAX_LENGTH), 2.0); - len = PH_DIALER_KEY_MAX_LEN; - string[len] = '\0'; - } - - tmp_string = (char *) calloc(1, len + 1); - memset(tmp_string, 0x00, len + 1); - - for (i = 0; i < len; i++) - { - if ((string[i] >= '0' && string[i] <= '9') || string[i] == '*' - || string[i] == '#' || string[i] == '+') - { - tmp_string[j++] = string[i]; - } - } - - len = strlen(tmp_string); - for (i = 0; i < len; i++) - { - tmp_node = (InputNumber *) calloc(1, sizeof(InputNumber)); - tmp_node->next = NULL; - tmp_node->prev = node; - tmp_node->num = tmp_string[i]; - - node->next = tmp_node; - node = node->next; - } - dial_d->number_cursor = tmp_node; - free(tmp_string); - - return len; -} - -int ph_dialer_util_append_node_from_numstr_with_strip(ph_dialer_data *dial_d, - char *string) -{ - PH_TRACE; - int i = 0, cnt = 0, len = 0; - InputNumber *node; - InputNumber *tmp_node = NULL; - p_retvm_if(NULL == string, 0, "Number string is null"); - ph_dialer_util_del_all_number(dial_d); - - node = &dial_d->number_head; - len = strlen(string); - if (dialer_util_is_num_length_over(len - 1) == TRUE) - { - phone_show_popup(dial_d->navi, - T_(PH_GET_TEXT_BASIC, PHTEXT_EXCEED_NUM_MAX_LENGTH), 2.0); - len = PH_DIALER_KEY_MAX_LEN; - string[len] = '\0'; - } - - for (; i < len; i++) - { - if (ph_dialer_util_is_dash(string[i]) == TRUE) - continue; - - tmp_node = (InputNumber *) calloc(1, sizeof(InputNumber)); - tmp_node->next = NULL; - tmp_node->prev = node; - tmp_node->num = string[i]; - node->next = tmp_node; - - node = node->next; - cnt++; - } - dial_d->number_cursor = tmp_node; - return cnt; -} - -char ph_dialer_util_get_value_word(char in) -{ - PH_TRACE; - switch (in) - { - case '2': - return 'a'; - case '3': - return 'd'; - case '4': - return 'g'; - case '5': - return 'j'; - case '6': - return 'm'; - case '7': - return 'p'; - case '8': - return 't'; - case '9': - return 'w'; - default: - return ' '; - } -} - -char ph_dialer_util_get_next_value_abcmode(char in) -{ - PH_TRACE; - switch (in) - { - case 'a': - return 'b'; - case 'b': - return 'c'; - case 'c': - return 'a'; - case 'd': - return 'e'; - case 'e': - return 'f'; - case 'f': - return 'd'; - case 'g': - return 'h'; - case 'h': - return 'i'; - case 'i': - return 'g'; - case 'j': - return 'k'; - case 'k': - return 'l'; - case 'l': - return 'j'; - case 'm': - return 'n'; - case 'n': - return 'o'; - case 'o': - return 'm'; - case 'p': - return 'q'; - case 'q': - return 'r'; - case 'r': - return 's'; - case 's': - return 'p'; - case 't': - return 'u'; - case 'u': - return 'v'; - case 'v': - return 't'; - case 'w': - return 'x'; - case 'x': - return 'y'; - case 'y': - return 'z'; - case 'z': - return 'w'; - default: - return ' '; - } -} - -static InputNumber* dialer_util_insert_number_after(InputNumber *node, char num) -{ - PH_TRACE; - InputNumber *tmp; - p_retvm_if(NULL == node, NULL, "number node is null"); - - tmp = (InputNumber *) calloc(1, sizeof(InputNumber)); - tmp->next = node->next; - tmp->prev = node; - tmp->num = num; - - if (node->next) - node->next->prev = tmp; - node->next = tmp; - - return tmp; -} - -void ph_dialer_util_insert_number_at_cursor(ph_dialer_data *dial_d, char num) -{ - PH_TRACE; - InputNumber *cursor; - InputNumber *tmp; - char buf[PH_TEXT_MAX_LEN] = { 0 }; - int len; - - if (dial_d->number_cursor) - cursor = dial_d->number_cursor; - else - cursor = &dial_d->number_head; - - /* check length */ - len = ph_dialer_util_get_numstr_from_node(dial_d, buf); - if (dialer_util_is_num_length_over(len) == TRUE) - { - phone_show_popup(dial_d->navi, - T_(PH_GET_TEXT_BASIC, PHTEXT_EXCEED_NUM_MAX_LENGTH), 2.0); - return; - } - - tmp = dialer_util_insert_number_after(cursor, num); - dial_d->number_cursor = tmp; -} - -char ph_dialer_util_get_number_at_cursor(ph_dialer_data *dial_d) -{ - PH_TRACE; - if (dial_d->number_cursor == NULL) - return '\0'; - - return dial_d->number_cursor->num; -} - -int ph_dialer_util_remove_node_at_cursor(ph_dialer_data *dial_d) -{ - PH_TRACE; - InputNumber *cursor = NULL; - InputNumber *node_prev = NULL; - p_retvm_if(NULL == dial_d->number_cursor, 0, "current cursor is null"); - cursor = dial_d->number_cursor; - - if (cursor == &dial_d->number_head) - return 0; - - if (cursor) - node_prev = cursor->prev; - - if (node_prev) - node_prev->next = cursor->next; - - if (cursor->next) - cursor->next->prev = node_prev; - - free(cursor); - dial_d->number_cursor = node_prev; - return ph_dialer_util_get_cursor_pos(dial_d); -} - -void ph_dialer_util_strip_from_number_node(ph_dialer_data *dial_d) -{ - PH_TRACE; - InputNumber *node, *tmp_node; - node = dial_d->number_head.next; - - while (node) - { - if (ph_dialer_util_is_dash(node->num) == TRUE) - { - if (dial_d->number_cursor == node) - dial_d->number_cursor = node->prev; - tmp_node = node; - - if (node->next) - node->next->prev = node->prev; - if (node->prev) - node->prev->next = node->next; - - node = node->next; - free(tmp_node); - } - else - node = node->next; - } -} - -void ph_dialer_util_add_dashes(ph_dialer_data *dial_d, DashMode kMode) -{ - PH_TRACE; - InputNumber *cursor __attribute__ ((unused)), *node; - int len = 0; - int remain = 0; - char numstr[PH_TEXT_MAX_LEN] = { 0 }; - - cursor = dial_d->number_cursor; - node = dial_d->number_head.next; - - len = ph_dialer_util_get_numstr_from_node(dial_d, numstr); - p_retm_if(len < 2, "number is too short"); - p_retm_if(numstr[0] == '*' || numstr[0] == '#', - "the character is reserved string"); - - remain = len; - /* 123 ~ 12345678901(123-4567-8901) */ - if (len > (2 - kMode) && len < (12 + kMode) && node) - { /* 02, 010, 011, ... 0xx */ - if (node->num == '0') - { /* 02, +cc 2 */ - remain--; - node = node->next; - remain--; - - if (node->num == '2') - { /* 02-, +cc 2- */ - node = dialer_util_insert_number_after(node, '-'); - if (node) - { - if (kMode) - { - if (dial_d->number_cursor == node->prev) - { - dial_d->number_cursor = node; - } - } - if (node->next) - node = node->next; - } - } - else - { /* 0xx, +cc xx */ - if (node->next) - { - node = node->next; - remain--; - } - - if (len > 3 - kMode) - { /* 0xx-, +cc xx- */ - node = dialer_util_insert_number_after(node, '-'); - if (node) - { - if (kMode) - { - if (dial_d->number_cursor == node->prev) - { - dial_d->number_cursor = node; - } - } - if (node->next) - node = node->next; - } - } - } - - if (remain == 8) - { /* xxx-1234-1234, +cc xx-1234-1234 */ - node = node->next; - p_ret_if(node == NULL); - node = node->next; - p_ret_if(node == NULL); - node = node->next; - dialer_util_insert_number_after(node, '-'); - } - else if (remain > (int) (3 - kMode) && remain < 8) - { /* xxx-123-1234, +cc xx-123-1234 */ - node = node->next; - p_ret_if(node == NULL); - node = node->next; - node = dialer_util_insert_number_after(node, '-'); - if (node && kMode) - { - if (dial_d->number_cursor == node->prev) - { - dial_d->number_cursor = node; - } - } - } - else if (remain > 8) - { /* not match rule */ - ph_dialer_util_strip_from_number_node(dial_d); - } - } - - else - { /* 02, +cc 2 *//* 1234-1234 */ - if (len > 4 - kMode && len < 9 + kMode) - { - node = node->next; - p_ret_if(node == NULL); - node = node->next; - p_ret_if(node == NULL); - node = node->next; - node = dialer_util_insert_number_after(node, '-'); - if (node && kMode) - { - if (dial_d->number_cursor == node->prev) - { - dial_d->number_cursor = node; - } - } - } - } - } -} - -void ph_dialer_util_highlight_substring(char *dest, int dest_len, char *string, - char *substr) -{ - PH_TRACE; - char middle[PH_TAG_TEXT_MAX_LEN] = { 0 }; - char first[PH_TAG_TEXT_MAX_LEN] = { 0 }; - - p_retm_if(NULL == string, "string is null"); - - if (substr && *substr) - { - int len = strlen(substr); - snprintf(first, sizeof(first), "%s", string); - char *last = strcasestr(first, substr); - if (last) - { - snprintf(middle, strlen(substr) + 1, "%s", last); - *(last) = '\0'; - snprintf(dest, dest_len, "%s<match>%s</>%s", first, middle, - last + len); - } - else - snprintf(dest, dest_len, "%s", string); - } - else - snprintf(dest, dest_len, "%s", string); -} - -void ph_dialer_util_highlight_substring_with_pos(char *dest, int dest_len, - char *string, int position, int length) -{ - PH_TRACE; - char middle[PH_TEXT_MAX_LEN] = { 0 }; - char first[PH_TEXT_MAX_LEN] = { 0 }; - - p_retm_if(NULL == string, "string is null"); - - if (0 < length) - { - snprintf(first, sizeof(first), "%s", string); - snprintf(middle, length + 1, "%s", string + position); - first[position] = '\0'; - snprintf(dest, dest_len, "%s<match>%s</>%s", first, middle, - string + position + length); - } - else - snprintf(dest, dest_len, "%s", string); -} - -int ph_dialer_util_show_matched_one_number(ph_dialer_data *dial_d, char *name, - char *number) -{ - PH_TRACE; - p_retvm_if(dial_d==NULL, 0, "dialer data is null"); - - if (dial_d->slide) - { - edje_object_signal_emit(_EDJ(dial_d->layout), "elm,state,slide,stop", - "elm"); - dial_d->slide = false; - } - - edje_object_signal_emit(_EDJ(dial_d->layout), "viewcontrol/search_result", - "viewcontrol"); - edje_object_part_text_set(_EDJ(dial_d->layout), - "search_result/item/number/textblock", number); - - if (name && *name) - { - edje_object_part_text_set(_EDJ(dial_d->layout), - "search_result/item/name/text", name); - edje_object_signal_emit(_EDJ(dial_d->layout), - "viewobject/search_result/search_number", - "viewobject/search_result"); - } - else - edje_object_signal_emit(_EDJ(dial_d->layout), - "viewobject/search_result/noname", "viewobject/search_result"); - - ph_dialer_update_cnt_btn(dial_d, 1); - dial_d->is_show_items = true; - return 0; -} - -static void __ph_dialer_speed_dial_view_ug_destroy_cb(ui_gadget_h ug, - void *priv) -{ - PH_TRACE; - check_if(!priv, return); - ph_dialer_data *dial_d = static_cast<ph_dialer_data*>(priv); - ug_destroy(dial_d->child_ug); - dial_d->child_ug = NULL; -} - -static void __ph_dialer_speed_dial_view_ug_result_cb(ui_gadget_h ug, - service_h service, void *priv) -{ - PH_TRACE; - ug_destroy(ug); -} - -static void __ph_dialer_speed_dial_view_ug_layout_cb(ui_gadget_h ug, - enum ug_mode mode, void *priv) -{ - PH_TRACE; - Evas_Object *base = (Evas_Object *) ug_get_layout(ug); - p_retm_if(base == NULL, "base == NULL"); - - evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(base); -} - -void ph_dialer_util_speeddial_show_cb(void *data, Evas_Object *obj, - void *event_info) -{ - PH_TRACE; - ph_dialer_data *dial_d = (ph_dialer_data *) data; - - //phone_create_speeddial_view(dial_d->ug, dial_d->win, dial_d->navi); - - struct ug_cbs cbs = { 0, }; - - cbs.priv = (void *) dial_d; - cbs.layout_cb = __ph_dialer_speed_dial_view_ug_layout_cb; - cbs.result_cb = __ph_dialer_speed_dial_view_ug_result_cb; - cbs.destroy_cb = __ph_dialer_speed_dial_view_ug_destroy_cb; - - dial_d->child_ug = ug_create(dial_d->ug, "speeddial-efl", - UG_MODE_FULLVIEW, NULL, &cbs); - - if(dial_d->popup) - { - evas_object_del(dial_d->popup); - dial_d->popup = NULL; - } - if(dial_d->m_Menu) - { - evas_object_del(dial_d->m_Menu); - dial_d->m_Menu = NULL; - } - if(dial_d->m_ContextMenu) - { - evas_object_del(dial_d->m_ContextMenu); - dial_d->m_ContextMenu = NULL; - } -} - -void ph_dialer_speed_add_start_cb(void *data, void *data2) -{ - PH_TRACE; - check_if(!data || !data2, return); - ph_dialer_data *dial_d = static_cast<ph_dialer_data *>(data); - int number_id = *static_cast<int *>(data2); - check_if(number_id < 0, return); - - int result = speed_set_speeddial(dial_d->searched_speed_id, number_id); - if (result < 0) - { - phone_show_popup(dial_d->navi, S_(PH_SYS_POP_ALREDY_EXISTS), 2.0); - } -} - -void ph_dialer_util_speeddial_set_cb(void *data, Evas_Object *obj, - void *event_info) -{ - PH_TRACE; - check_if(!data, return); - ph_dialer_data *dial_d = static_cast<ph_dialer_data *>(data); - - dial_d->child_ug = phone_launch_contact_list_ug(dial_d->ug, - CT_UG_REQUEST_SELECT_NUMBER, ph_dialer_speed_add_start_cb, - NULL, dial_d); - - if(dial_d->popup) - { - evas_object_del(dial_d->popup); - dial_d->popup = NULL; - } -} - -void ph_dialer_util_show_speeddial_msg(ph_dialer_data *dial_d, const char *msg) -{ - PH_TRACE; - char dest[PH_TEXT_MAX_LEN] = { 0 }; - snprintf(dest, sizeof(dest), "%s", msg); - phone_create_confirm_popup(&dial_d->popup, dial_d->win, msg, - ph_dialer_util_speeddial_set_cb, dial_d); -} - -void ph_dialer_util_setup_run_mode(ph_dialer_data& dial_d) -{ - PH_TRACE; - if (dial_d.is_emergency) - { - dial_d.run_mode = PH_DAILER_EMERGENCY; - } - else - { - dial_d.run_mode = PH_DAILER_NORMAL; - } - - /* Check call state */ - int value = 0; - int ret = vconf_get_int(VCONFKEY_CALL_STATE, &value); - if (ret < 0) - ERR("vconf_get_int is failed(%d)", ret); - else - { - if (value == VCONFKEY_CALL_OFF - || value == VCONFKEY_CALL_VOICE_CONNECTING - || value == VCONFKEY_CALL_VIDEO_CONNECTING) - { - if (dial_d.run_mode == PH_DAILER_EMERGENCY) - { - edje_object_signal_emit(_EDJ(dial_d.layout), - "softkey/emergency", "softkey"); - } - else - { - if (dial_d.run_mode == PH_DAILER_NORMAL) - return; - dial_d.run_mode = PH_DAILER_NORMAL; - edje_object_signal_emit(_EDJ(dial_d.layout), "softkey/normal", - "softkey"); - } - } - else - { // VCONFKEY_CALL_VOICE_ACTIVE, VCONFKEY_CALL_VIDEO_ACTIVE - if (dial_d.run_mode == PH_DAILER_DURING_CALL) - return; - dial_d.run_mode = PH_DAILER_DURING_CALL; - edje_object_signal_emit(_EDJ(dial_d.layout), "softkey/dc", "softkey"); - } - PH_DBG("run_mode:%d", dial_d.run_mode); - } -} - -void ph_dialer_util_init_sim_value(ph_dialer_data *dial_d) -{ - PH_TRACE; - /* Network MCC */ - int value = 0; - int ret; - TelSimImsiInfo_t sim_imsi_info; - TapiHandle *handle; - ret = vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &value); - if (ret < 0) - dial_d->cur_mcc = -1; - else - dial_d->cur_mcc = value / 1000; - - /* SIM MCC/MNC */ - dial_d->cur_sim_mcc = -1; - handle = tel_init(NULL); - if (NULL == handle) - { - ERR("tel_init() Failed"); - } - else - { - ret = tel_get_sim_imsi(handle, &sim_imsi_info); - DBG("tel_get_sim_imsi returned %d", ret); - if (0 == ret) - dial_d->cur_sim_mcc = atoi(sim_imsi_info.szMcc); - else - ERR("tel_get_sim_imsi() Failed(%d)", ret); - tel_deinit(handle); - } - dial_d->cur_cc_index = -1; - - ret = vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &value); - if (ret < 0) - dial_d->roaming = 0; - else - dial_d->roaming = value; -} - -void ph_dialer_util_svi_play(int vibration_key, int sound_key) -{ - PH_TRACE; - int effect_status = FALSE; - vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &effect_status); - if (effect_status) - feedback_play_type(FEEDBACK_TYPE_SOUND, (feedback_pattern_e) sound_key); - - vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &effect_status); - if (effect_status) - feedback_play_type(FEEDBACK_TYPE_VIBRATION, (feedback_pattern_e) vibration_key); -} - -bool isSimPresent() -{ - PH_TRACE; - TelSimImsiInfo_t sim_imsi_info; - TapiHandle *handle = tel_init(NULL); - bool simCardFound = true; - int simStatus = tel_get_sim_imsi(handle, &sim_imsi_info); - if (simStatus != TAPI_API_SUCCESS) - { - simCardFound = (TAPI_API_SIM_CARD_ERROR != simStatus) - && (TAPI_API_SIM_NOT_FOUND != simStatus) - && (TAPI_API_SIM_NOT_INITIALIZED != simStatus) - && (TAPI_API_OPERATION_FAILED != simStatus) - && (TAPI_API_SIM_LOCKED != simStatus); - } - - tel_deinit(handle); - DBG("isSimPresent returns %d", simCardFound); - return simCardFound; -} diff --git a/lib/dialer/ph-dialer-utils.h b/lib/dialer/ph-dialer-utils.h deleted file mode 100755 index dc77bae..0000000 --- a/lib/dialer/ph-dialer-utils.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PH_DIALER_UTIL_H__ -#define __PH_DIALER_UTIL_H__ - -#include <stdio.h> - -typedef struct -{ - char *plog_number; -} ph_dial_log_d; - -typedef struct -{ - char *display; - char *number; - char *find_number; - char *img_path; - char *numtype_label; - - int number_type; - int type; - int contact_id; - int position; - int len; -} ph_dial_search_d; - -typedef struct -{ - char *cc; - char *name; - int mcc; -} ph_cc_name_mcc_info; - -void ph_dialer_util_launch_call(ph_dialer_data *dial_d); - -int ph_dialer_util_get_pure_numstr_with_plus(ph_dialer_data *dial_d, - char *dest); -int ph_dialer_util_get_pure_numstr(ph_dialer_data *dial_d, char *dest); -int ph_dialer_util_get_numstr_from_node(ph_dialer_data *dial_d, char *dest); -int ph_dialer_util_del_all_number(ph_dialer_data *dial_d); - -int ph_dialer_util_append_node_from_numstr(ph_dialer_data *dial_d, - char *string); -int ph_dialer_util_append_node_from_numstr_with_strip(ph_dialer_data *dial_d, - char *string); -int ph_dialer_util_remove_node_at_cursor(ph_dialer_data *dial_d); - -void ph_dialer_util_insert_number_at_cursor(ph_dialer_data *dial_d, char num); -char ph_dialer_util_get_number_at_cursor(ph_dialer_data *dial_d); -int ph_dialer_util_get_cursor_pos(ph_dialer_data *dial_d); - -char ph_dialer_util_get_next_value_abcmode(char in); -char ph_dialer_util_get_value_word(char in); -InputNumber *ph_dialer_util_get_node_by_index(ph_dialer_data *dial_d, - int index); -void ph_dialer_util_strip_from_number_node(ph_dialer_data *dial_d); -int ph_dialer_util_is_dash(char ch); -void ph_dialer_util_add_dashes(ph_dialer_data *dial_d, DashMode kMode); -void ph_dialer_util_entry_clear(ph_dialer_data *dial_d); - -void ph_dialer_util_highlight_substring(char *dest, int dest_len, char *allpart, - char *part); -void ph_dialer_util_highlight_substring_with_pos(char *dest, int dest_len, - char *string, int position, int length); - -ph_speeddial_info* ph_dialer_util_get_speeddial_by_number(void *data, - int speednumber); - -int ph_dialer_util_show_matched_one_number(ph_dialer_data *dial_d, char *name, - char *number); -void ph_dialer_util_show_speeddial_msg(ph_dialer_data *dial_d, const char *msg); -void ph_dialer_util_speeddial_show_cb(void *data, Evas_Object *obj, - void *event_info); - -void ph_dialer_util_init_sim_value(ph_dialer_data *dial_d); -void ph_dialer_util_setup_run_mode(ph_dialer_data& dial_d); -void ph_dialer_util_svi_play(int vibration_key, int sound_key); - -/** - * Checks sim-card presence. - * @return true if sim-card is present, false - if not - * */ -bool isSimPresent(); - -#endif //__PH_DIALER_UTIL_H__ diff --git a/lib/dialer/ph-dialer-view.cpp b/lib/dialer/ph-dialer-view.cpp deleted file mode 100755 index 4765728..0000000 --- a/lib/dialer/ph-dialer-view.cpp +++ /dev/null @@ -1,2174 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <string.h> -#include <feedback.h> -#include <Ecore_X.h> -#include <vconf.h> -#include <vconf-keys.h> -#include <Evas.h> -#include <Ecore_X.h> - -#include <string.h> -#include <ui-gadget-module.h> - -#include "phone.h" -#include "ph-front.h" -#include "phone-dialer.h" - -#include "ph-dialer-view.h" -#include "ph-dialer-utils.h" -#include "ph-dialer-search.h" - -#include "KeypadTouchManager.h" -#include "Search/Controller.h" -#include "ct-list.h" - -#define PH_DIALER_ENTRY_DEFAULT_STYLE "<align=left font=Tizen:style=Thin text_class=tizen font_size=%d color=#FFFFFF>%s</>" -#define PH_DIALER_ENTRY_EMPTY_STYLE "" -#define PH_DIALER_ENTRY_STAR "*" -#define PH_PAUSE_CHAR ';' -#define PH_WAIT_CHAR ',' - -static const int displaySize = 1200; -static const int numberMinSize = 40; -static const int minNumberEntry = 12; -static const int maxNumberEntry = 32; -static const char starCharacter = '*'; -static const char *backspaceButton = "normal/backspace"; - -#define PH_DIALER_ENTRY_STYLE_END_TAG "</>" - -static Dialer::KeypadTouchManager touchManager; - -static void dialer_hide_popup_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - if(dial_d->popup) - { - evas_object_del(dial_d->popup); - dial_d->popup = NULL; - } - } -} - -static void dialer_hide_menu_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - if(dial_d->m_Menu) - { - evas_object_del(dial_d->m_Menu); - dial_d->m_Menu = NULL; - } - } -} - -static void dialer_hide_context_menu_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - if(dial_d->m_ContextMenu) - { - evas_object_del(dial_d->m_ContextMenu); - dial_d->m_ContextMenu = NULL; - } - } -} - -void dialer_suggestion_item_sel_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - dialer_hide_popup_cb(data, obj, event_info); - // TODO: fill the number field with the selected number -} - -static void dialer_entry_selection_changed(void *data, Evas_Object *entry, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - dial_d->selected_text = (char *) elm_entry_selection_get(entry); - } -} - -static void dialer_entry_cursor_changed(void *data, Evas_Object *entry, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - dial_d->cursor_changed = true; - } -} - -static void dialer_show_search_list_toggle(ph_dialer_data *dial_d, bool show) -{ - PH_TRACE; - assert(dial_d); - if (NULL != dial_d) - { - if (show) - { - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/show", "viewobject/search_list"); - dial_d->count_button_status = COUNT_BUTTON_OPEN; - edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/closed", "count_button"); - } - else - { - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/hide", "viewobject/search_list"); - dial_d->count_button_status = COUNT_BUTTON_CLOSE; - edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/opened", "count_button"); - } - - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_list/index/hide", "viewobject/search_list/index"); - } -} - -static void dialer_entry_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - if (dial_d->list_mode == MODE_DIAL_NUMBER) - { - if (NULL == dial_d->search_list || eina_list_count(dial_d->search_list) < 2 || !dial_d->is_show_items) - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/hide", "viewobject/search_result/count"); - else - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/show", "viewobject/search_result/count"); - } - else - { - if (NULL == dial_d->cc_list_sorted || eina_list_count(dial_d->cc_list_sorted) < 2 || !dial_d->is_show_items) - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/hide", "viewobject/search_result/count"); - else - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/search_result/count/show", "viewobject/search_result/count"); - } - - dialer_show_search_list_toggle(dial_d, false); - } -} - -static void dialer_entry_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - if (dial_d->cursor_changed) - { - int pos = 0; - dial_d->cursor_changed = false; - pos = elm_entry_cursor_pos_get(dial_d->entry); - dial_d->number_cursor = ph_dialer_util_get_node_by_index( (ph_dialer_data *) data, pos); - } - dial_d->has_focus = true; - } -} - -void dialer_pw_context_menu(void *data); -static void dialer_softkey_longpress(char *source, ph_dialer_data &dial_d) -{ - PH_TRACE; - int pos __attribute__ ((unused)) = 0; - char dest[PH_TEXT_MAX_LEN] = { 0 }; - if (strcmp(source, "star") == 0 || strcmp(source, "*") == 0) - { - if (ph_dialer_util_get_number_at_cursor(&dial_d) == '*') - { - pos = ph_dialer_util_remove_node_at_cursor(&dial_d); - dialer_pw_context_menu(&dial_d); - ph_dialer_util_get_numstr_from_node(&dial_d, dest); - ph_dialer_entry_set_number(dial_d, dest, 0); - } - } - else if (strcmp(source, "sharp") == 0 || strcmp(source, "#") == 0) - { - ph_dialer_util_get_numstr_from_node(&dial_d, dest); - if (strlen(dest) > 1) /* '#' longpress disable after number typed */ - return; - - int value = 1; - vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &value); - - if (!value) - { - vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, TRUE); - phone_show_popup(dial_d.win, T_(PH_GET_TEXT_BASIC, PHTEXT_SOUND_ON), 2.0); - } - else - { - feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_HW_TAP); - vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE); - phone_show_popup(dial_d.win, T_(PH_GET_TEXT_BASIC, PHTEXT_SOUND_OFF), 2.0); - } - - if (ph_dialer_util_get_number_at_cursor(&dial_d) == '#') - { - pos = ph_dialer_util_remove_node_at_cursor(&dial_d); - ph_dialer_util_get_numstr_from_node(&dial_d, dest); - ph_dialer_entry_set_number(dial_d, dest, 0); - ph_dialer_search_request(&dial_d, FALSE); - } - } - else if (strcmp(source, backspaceButton) == 0) - { - ph_dialer_util_entry_clear(&dial_d); - dial_d.entry_font_size = MAX_DIAL_NUMBER_FONT_SIZE; - } -} - -static Eina_Bool dialer_keypad_longpress(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - int text_len = 0; - int pos __attribute__ ((unused)) = 0; - char dest[PH_TEXT_MAX_LEN] = { 0 }; - char *source; - - p_retv_if(NULL == dial_d, -1); - - source = dial_d->longpress_source; - text_len = ph_dialer_util_get_pure_numstr_with_plus(dial_d, dest); - - switch (source[0]) - { - case '0' ... '9': - PH_DBG("number(len=%d):[%s]", text_len, dest); - if (source[0] == '0') - { - pos = ph_dialer_util_remove_node_at_cursor(dial_d); edje_object_signal_emit(_EDJ(dial_d->layout), "pad_clicked", "+"); break; - } - /* speed dial: 2 ~ 9 */ - if (0 < text_len && text_len <= 2) - { - if ('0' <= dest[0] && dest[0] <= '9' && atoi(dest) < 10) - { - ph_speeddial_info * speed_info = NULL; - if ((speed_info = ph_dialer_util_get_speeddial_by_number(dial_d, atoi(dest))) != NULL) - { - ph_dialer_util_append_node_from_numstr_with_strip(dial_d, speed_info->ph_number); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, CURSOR_END); - ph_dialer_util_launch_call(dial_d); - } - else - { - dial_d->searched_speed_id = dest[0] - '0'; - ph_dialer_util_show_speeddial_msg(dial_d, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEED_DIAL_REQUEST)); - } - } - } - break; - - case starCharacter: - if(strcmp(dest, PH_DIALER_ENTRY_STAR)) - { - dialer_softkey_longpress(source,*dial_d); - } - break; - - default: - dialer_softkey_longpress(source,*dial_d); - break; - } - if (dial_d->longpress_source) - { - free(dial_d->longpress_source); - dial_d->longpress_source = NULL; - } - dial_d->longpress_timer = NULL; - return ECORE_CALLBACK_CANCEL; - } - return false; -} - -static void dialer_add_pause_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(NULL == dial_d, "dial_d is null"); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - - dialer_show_search_list_toggle(dial_d, false); - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_insert_number_at_cursor(dial_d, PH_PAUSE_CHAR); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - ph_dialer_search_request(dial_d, FALSE); - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - } -} - -static void dialer_add_wait_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(NULL == dial_d, "dial_d is null"); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - - dialer_show_search_list_toggle(dial_d, false); - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_insert_number_at_cursor(dial_d, PH_WAIT_CHAR); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - ph_dialer_search_request(dial_d, FALSE); - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - } -} - -void dialer_pw_context_menu(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - if (dial_d->m_ContextMenu) - evas_object_del(dial_d->m_ContextMenu); - - dial_d->m_ContextMenu = elm_ctxpopup_add(dial_d->navi); - if (NULL != dial_d->m_ContextMenu) - { - elm_ctxpopup_direction_priority_set(dial_d->m_ContextMenu, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN); - - char buf[PH_TEXT_SHORT_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, buf); - - evas_object_smart_callback_add(dial_d->m_ContextMenu, "dismissed", dialer_hide_context_menu_cb, dial_d); - - snprintf(buf, sizeof(buf), T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_PAUSE), 2); - elm_ctxpopup_item_append(dial_d->m_ContextMenu, buf, NULL, dialer_add_pause_cb, dial_d); - elm_ctxpopup_item_append(dial_d->m_ContextMenu, T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_WAIT), NULL, dialer_add_wait_cb, dial_d); - - int x, y, w, h; - edje_object_part_geometry_get(_EDJ(dial_d->layout), "star_BG", &x, &y, &w, &h); - - evas_object_move(dial_d->m_ContextMenu, x + (w / 2), (y + 167) + (h / 2)); - evas_object_show(dial_d->m_ContextMenu); - } - else - { - PH_DBG("dialer_pw_context_menu failed: %s", "elm_ctxpopup_add() return NULL"); - } - } - else - { - PH_DBG("dialer_pw_context_menu failed: %s", "data is null"); - } -} - -static void dialer_keypad_down(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); - p_retm_if(source == NULL, "source is NULL"); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - int snd_id = 0; - - if (dial_d->count_button_status == COUNT_BUTTON_OPEN) - { - dialer_show_search_list_toggle(dial_d, false); - } - - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - - if (dial_d->dash_timer) - { - ecore_timer_del(dial_d->dash_timer); - dial_d->dash_timer = NULL; - } - - switch (source[0]) - { - case '0' ... '9': - snd_id = FEEDBACK_PATTERN_KEY0 + (source[0] - '0'); - break; - default: - if (0 == strcmp(source, "star")) - { - source = "*"; snd_id = FEEDBACK_PATTERN_KEY_STAR; - } - else if (0 == strcmp(source, "sharp")) - { - source = "#"; snd_id = FEEDBACK_PATTERN_KEY_SHARP; - } - else - { - snd_id = FEEDBACK_PATTERN_TOUCH_KEY; - } - break; - } - - if (PH_DAILER_DURING_CALL != dial_d->run_mode) - ph_dialer_util_svi_play(FEEDBACK_PATTERN_TOUCH_TAP, snd_id); - - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_insert_number_at_cursor(dial_d, source[0]); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - - /* create new longpress timer */ - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - FREEandSTRDUP(dial_d->longpress_source, source); - dial_d->longpress_timer = ecore_timer_add(elm_config_longpress_timeout_get(), dialer_keypad_longpress, dial_d); - ph_dialer_search_request(dial_d, FALSE); - } -} - -static Eina_Bool dialer_dash_add_timer(void *data) -{ - PH_TRACE; - char dest[PH_TEXT_MAX_LEN] = { 0 }; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_add_dashes(dial_d, DASH_PREVIEW); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - - dial_d->dash_timer = NULL; - return ECORE_CALLBACK_CANCEL; - } - return false; -} - -static void dialer_keypad_up(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - p_retm_if(data == NULL, "Invalid argument: ph_dialer_data *is NULL"); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - PH_DBG("(source=%s)", source); - - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - - if (dial_d->dash_timer) - { - ecore_timer_del(dial_d->dash_timer); - dial_d->dash_timer = NULL; - } - dial_d->dash_timer = ecore_timer_add(0.7, dialer_dash_add_timer, dial_d); - } -} - -static void dialer_keypad_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - char dest[PH_TEXT_MAX_LEN] = { 0 }; - - p_retm_if(NULL == source, "source is null"); - p_retm_if(NULL == data, "Invalid argument: ph_dialer_data is NULL"); - - if (0 != strcmp(source, "+") && 0 != strcmp(source, "P") && 0 != strcmp(source, "W")) - return; - - if (dial_d->dash_timer) - { - ecore_timer_del(dial_d->dash_timer); - dial_d->dash_timer = NULL; - } - - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_insert_number_at_cursor(dial_d, source[0]); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - ph_dialer_search_request(dial_d, FALSE); - } -} - -static void dialer_softkey_down(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - - if (0 == strcmp(source, "back_btn") || 0 == strcmp(source, "option_btn")) - return; - - ph_dialer_util_svi_play(FEEDBACK_PATTERN_TOUCH_TAP, FEEDBACK_PATTERN_TOUCH_TAP); - if (0 != strcmp(source, backspaceButton)) - return; - - if (dial_d->dash_timer) - { - ecore_timer_del(dial_d->dash_timer); - dial_d->dash_timer = NULL; - } - - char* entry_raw = strdup(elm_entry_entry_get(dial_d->entry)); - char* tok = strstr(entry_raw, PH_DIALER_ENTRY_STYLE_END_TAG); - if (tok) - tok[0] = '\0'; - - if (dial_d->selected_text && strcmp(dial_d->selected_text, entry_raw) == 0) - { - ph_dialer_util_entry_clear(dial_d); - free(entry_raw); - return; - } - - ph_dialer_util_strip_from_number_node(dial_d); - ph_dialer_util_remove_node_at_cursor(dial_d); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, 0); - - if (!*dest && dial_d->has_focus) - { - elm_object_focus_set(dial_d->entry, EINA_FALSE); - dial_d->has_focus = false; - } - - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - FREEandSTRDUP(dial_d->longpress_source, source); - dial_d->longpress_timer = ecore_timer_add(elm_config_longpress_timeout_get(), dialer_keypad_longpress, dial_d); - - ph_dialer_search_request(dial_d, FALSE); - } -} - -static void dialer_softkey_up(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - if (0 != strcmp(source, backspaceButton)) - return; - - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - - if (dial_d->dash_timer) - { - ecore_timer_del(dial_d->dash_timer); - dial_d->dash_timer = NULL; - } - dial_d->dash_timer = ecore_timer_add(0.7, dialer_dash_add_timer, dial_d); - } -} - -static void dialer_destroy_child_ug(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - dial_d->child_ug = NULL; - } -} - -static bool dialer_get_recent_log_number(char** get_str) -{ - PH_TRACE; - contacts_list_h cts_list = NULL; - contacts_query_h query = NULL; - int err = CONTACTS_ERROR_NONE; - contacts_filter_h filter = NULL; - - do - { - if ((err = contacts_query_create(_contacts_person_phone_log._uri, &query)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_filter_create(_contacts_person_phone_log._uri, &filter)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_filter_add_int(filter, _contacts_person_phone_log.log_type, CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_filter_add_int(filter, _contacts_person_phone_log.log_type, CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_query_set_filter(query, filter)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_query_set_sort(query, _contacts_person_phone_log.log_time, false)) != CONTACTS_ERROR_NONE) - break; - if ((err = contacts_db_get_records_with_query(query, 0, 1, &cts_list)) != CONTACTS_ERROR_NONE) - break; - - unsigned int record_cnt = 0; - contacts_list_get_count(cts_list, &record_cnt); - PH_DBG("get _contacts_person_phone_log table records(%d)", record_cnt); - - err = phone_cts_get_str_from_list(cts_list, _contacts_person_phone_log.address, get_str); - PH_DBG("recent number : %s", *get_str); - p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() Failed(%d)", err); - - contacts_list_destroy(cts_list, true); - contacts_query_destroy(query); - contacts_filter_destroy(filter); - return true; - } - while (0); - - //error case - ERR("contacts_db_query Failed(%d)", err); - if (query != NULL) - contacts_query_destroy(query); - if (filter != NULL) - contacts_filter_destroy(filter); - - return false; -} - -static void dialer_softkey_call_clicked(void *data, int type) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); - - char buf[PH_TEXT_MAX_LEN] = { 0 }; - int len; - - len = ph_dialer_util_get_numstr_from_node(dial_d, buf); - if (len == 0) - { - PH_DBG("text is NULL so input recent number "); - char* get_str = NULL; - if (dialer_get_recent_log_number(&get_str)) - { - if (get_str && strlen(get_str) > 0) - { - ph_dialer_util_append_node_from_numstr(dial_d, get_str); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, buf); - ph_dialer_entry_set_number(*dial_d, buf, CURSOR_END); - ph_dialer_search_request(dial_d, FALSE); - free(get_str); - } - } - return; - } - if (0 == type) - { - ALOG(LOG_DEBUG, "call_start_log", "launch call button pressed"); - ph_dialer_util_launch_call(dial_d); - } - } -} - -static void dialer_back_btn_cb(ph_dialer_data *dial_d) -{ - PH_TRACE; - assert(dial_d); - if (NULL != dial_d) - { - dial_d->initialized = FALSE; - ph_dialer_util_entry_clear(dial_d); - } -} - -void dialer_add_contact(ph_dialer_data *dial_d) -{ - PH_TRACE; - check_if(!dial_d, return); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, dest); - dial_d->child_ug = phone_launch_contact_add_list_edit_ug(dial_d->ug, dest, dialer_destroy_child_ug, dial_d); -} - -static void dialer_add_contact_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - - dialer_add_contact(dial_d); - } -} - -static void dialer_settings_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - - dial_d->child_ug = phone_launch_settings_ug(dial_d->ug, CALL_SETTINGS_UG, dialer_destroy_child_ug, dial_d); - } -} -#ifdef _PHONE_LOCK_ -#define EMERGENCY "emergency" -static void dialer_softkey_emergency_clicked(void *data) -{ - PH_TRACE; - assert(data); - int err = CONTACTS_ERROR_NONE; - if (NULL != data) - { - ph_dialer_data *dial_d = (ph_dialer_data *) data; - contacts_record_h record = NULL; - contacts_list_h group_list = NULL; - phone_cts_get_list(_contacts_group._uri, _contacts_group.address_book_id, 0, &group_list); - CONTACTS_LIST_FOREACH(group_list, record) - { - char* group_system_id = NULL; - int id_grp = 0; - contacts_record_get_int(record, _contacts_group.id, &id_grp); - err = contacts_record_get_str_p(record, _contacts_group.extra_data, &group_system_id); - if (group_system_id != NULL) - { - if (CONTACTS_ERROR_NONE == err) - { - if (strcmp(group_system_id, EMERGENCY) == 0) - { - ph_view_info *view_info = (ph_view_info *) calloc(1, sizeof(ph_view_info)); - phone_set_view_info(view_info, dial_d->win, dial_d->navi, dial_d->ug, 0, 0, NULL); - ct_group_list *info = (ct_group_list *) calloc(1, sizeof(ct_group_list)); - info->id_ab = 0; - info->id_grp = id_grp; - info->name = (char *) (T_(CT_GET_TEXT_BASIC, CTTEXT_EMERGENCY_CONTACTS)); - ctui_list_create_contact_view_with_info(view_info, CT_GET_LIST_PERSON_OF_GROUP_ID, info); - free(info); - free(view_info); - phone_cts_free_list(group_list); - return; - } - } - } - } - phone_cts_free_list(group_list); - } -} -#endif //_PHONE_LOCK_ - -static void dialer_softkey_msg_clicked(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - - char num[PH_TEXT_SHORT_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, num); - dial_d->child_ug = phone_launch_msg_composer_ug(dial_d->ug, num, 0, dialer_destroy_child_ug, dial_d); - } -} - -static void dialer_ctx_message_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - - char num[PH_TEXT_SHORT_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, num); - dial_d->child_ug = phone_launch_msg_composer_ug(dial_d->ug, num, 0, dialer_destroy_child_ug, dial_d); - } -} - -static void dialer_exit_cb(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>(data); - - dialer_hide_popup_cb(dial_d, NULL, NULL); - dialer_hide_menu_cb(dial_d, NULL, NULL); - dialer_hide_context_menu_cb(dial_d, NULL, NULL); - - dialer_back_btn_cb(dial_d); - elm_win_lower(dial_d->win); - - } -} - -static void dialer_contactsearch_btn_cb(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - ph_phoneui_data *phoneui_d = (ph_phoneui_data *) evas_object_data_get(dial_d->layout, "phoneui_d"); - phone_front_view_show_sub_view(phoneui_d); //temp : need to fix as embedding contact search list into dialer layout. (kc.jun) - } - return; -} - -static void dialer_option_btn_cb(ph_dialer_data *dial_d) -{ - PH_TRACE; - assert(dial_d); - if (NULL != dial_d) - { - if (dial_d->m_Menu) - evas_object_del(dial_d->m_Menu); - - dial_d->m_Menu = elm_ctxpopup_add(dial_d->navi); - if (NULL != dial_d->m_Menu) - { - elm_ctxpopup_direction_priority_set(dial_d->m_Menu, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN); - - char buf[PH_TEXT_SHORT_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, buf); - - evas_object_smart_callback_add(dial_d->m_Menu, "dismissed", dialer_hide_menu_cb, dial_d); - - if (!dial_d->ug) - elm_ctxpopup_item_append(dial_d->m_Menu, S_(PH_SYS_BODY_MESSAGE), NULL, dialer_ctx_message_cb, dial_d); - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEEDDIAL), NULL, ph_dialer_util_speeddial_show_cb, dial_d); - snprintf(buf, sizeof(buf), T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_PAUSE), 2); - elm_ctxpopup_item_append(dial_d->m_Menu, buf, NULL, dialer_add_pause_cb, dial_d); - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_WAIT), NULL, dialer_add_wait_cb, dial_d); - - if (!dial_d->ug) - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASE_OP, PHTEXT_EXIT), NULL, dialer_exit_cb, dial_d); - - int x, y, w, h; - edje_object_part_geometry_get(_EDJ(dial_d->layout), "option_btn", &x, &y, &w, &h); - - evas_object_move(dial_d->m_Menu, x + (w / 2), (y + 167) + (h / 2)); - evas_object_show(dial_d->m_Menu); - } - else - { - PH_DBG("dialer_option_btn_cb failed: %s", "elm_ctxpopup_add() return NULL"); - } - } - else - { - PH_DBG("dialer_option_btn_cb failed: %s", "data is null"); - } -} - -static void dialer_number_options_popup(ph_dialer_data *dial_d) -{ - PH_TRACE; - assert(dial_d); - if (NULL != dial_d) - { - // removing current menu if there is any: - if (dial_d->m_Menu) - evas_object_del(dial_d->m_Menu); - - // adding a new menu ("Keypad menu") - dial_d->m_Menu = elm_ctxpopup_add(dial_d->navi); - if (NULL != dial_d->m_Menu) - { - elm_ctxpopup_direction_priority_set(dial_d->m_Menu, ELM_CTXPOPUP_DIRECTION_UP, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN); - - char buf[PH_TEXT_SHORT_LEN] = { 0 }; - ph_dialer_util_get_pure_numstr_with_plus(dial_d, buf); - - evas_object_smart_callback_add(dial_d->m_Menu, "dismissed", dialer_hide_menu_cb, dial_d); - - // setting up the items of menu: - - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASIC, PHTEXT_SPEEDDIAL), NULL, ph_dialer_util_speeddial_show_cb, dial_d); - - int len = ph_dialer_util_get_numstr_from_node(dial_d, buf); - if (len > 0) // In case user inputted at least 1 number - { - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASIC, PHTEXT_ADD_TO_CONTACTS), NULL, dialer_add_contact_cb, dial_d); - - snprintf(buf, sizeof(buf), T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_PAUSE), 2); - elm_ctxpopup_item_append(dial_d->m_Menu, buf, NULL, dialer_add_pause_cb, dial_d); - - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASE_OP, PHTEXT_ADD_WAIT), NULL, dialer_add_wait_cb, dial_d); - } - - if (!dial_d->ug) - elm_ctxpopup_item_append(dial_d->m_Menu, T_(PH_GET_TEXT_BASIC, PHTEXT_SETTINGS), NULL, dialer_settings_cb, dial_d); - - // setting up the position of menu: - int x, y, w, h; - evas_object_geometry_get(dial_d->navi, &x, &y, &w, &h); - - evas_object_move(dial_d->m_Menu, 0, y + h); - evas_object_show(dial_d->m_Menu); - } - else - { - PH_DBG("dialer_number_options_popup failed: %s", "elm_ctxpopup_add() return NULL"); - } - } - else - { - PH_DBG("dialer_number_options_popup failed: %s", "data is null"); - } -} - -static void dialer_softkey_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(dial_d == NULL, "Invalid argument: ph_dialer_data *is NULL"); - - char buf[PH_TEXT_MAX_LEN] = { 0 }; - - PH_DBG("source:[%s]", source); - - /* defense code for long-press */ - /* remove longpress timer */ - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - - if (strstr(source, "call") != NULL) /* normal/call, dc/call */ - dialer_softkey_call_clicked(dial_d, 0); - else if (strcmp(source, "normal/message") == 0) - dialer_softkey_msg_clicked(dial_d); -#ifdef _PHONE_LOCK_ - else if (strcmp(source, "normal/emergency") == 0) - dialer_softkey_emergency_clicked(dial_d); -#endif //_PHONE_LOCK_ - else if (0 == strcmp(source, "return_btn")) - { - if (dial_d->ug) - ug_destroy_me(dial_d->ug); - return; - } - else if (0 == strcmp(source, "option_btn")) - { - dialer_option_btn_cb(dial_d); - return; - } - else if (0 == strcmp(source, "search/inputarea/image")) - { - dialer_contactsearch_btn_cb(dial_d); - return; - } - - ph_dialer_util_get_numstr_from_node(dial_d, buf); - if (strcmp(source, backspaceButton) != 0) - ph_dialer_entry_set_number(*dial_d, buf, CURSOR_END); - else - ph_dialer_entry_set_number(*dial_d, buf, 0); - } -} - -static char* dialer_gl_cc_label_get(ph_dialer_data *dial_d, ph_cc_name_mcc_info *item, Evas_Object *obj, const char *part) -{ - PH_TRACE; - assert(dial_d); - p_retvm_if(NULL == dial_d, NULL, "dial data is null"); - if (NULL != dial_d) - { - char buf[PH_TAG_TEXT_MAX_LEN] = { 0 }; - char text[PH_TAG_TEXT_MAX_LEN] = { 0 }; - int text_len __attribute__ ((unused)); - - if (0 == strcmp(part, "elm.text.left.name")) - { - return strdup(item->name); - } - else if (0 == strcmp(part, "elm.text.left.number")) - { - text_len = ph_dialer_util_get_pure_numstr(dial_d, text); - ph_dialer_util_highlight_substring(buf, sizeof(buf), item->cc, text); - return strdup(buf); - } - else - return NULL; - } - return NULL; -} - -Evas_Object* ph_dialer_gl_icon_get(void *data, Evas_Object *obj, const char *part) -{ - PH_TRACE; - assert(data); - p_retvm_if(NULL == data, NULL, "data is null"); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(obj, KEY_DIALER_DATA) ); - p_retvm_if(NULL == dial_d, NULL, "ph_dialer_data dial_d is null"); - - if (dial_d->list_mode == MODE_COUNTRY_CODE) - return NULL; - - ph_dial_search_d *sd = (ph_dial_search_d *) data; - Evas_Object *ic; - - if (0 == strcmp(part, "elm.icon.1")) - { - if (sd->img_path && *sd->img_path) - { - ic = elm_icon_add(obj); - p_retvm_if(NULL == ic, NULL, "elm_icon_add is failed"); - elm_image_file_set(ic, sd->img_path, NULL); - evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - return ic; - } - } - } - return NULL; -} - -char* ph_dialer_gl_label_get(void *data, Evas_Object *obj, const char *part) -{ - PH_TRACE; - assert(data); - p_retvm_if(NULL == data, NULL, "dialer is null"); - if (NULL != data) - { - ph_dial_search_d* sd = static_cast<ph_dial_search_d*>( data ); - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(obj, KEY_DIALER_DATA) ); - p_retvm_if(NULL == dial_d, NULL, "dialer data is null"); - - char buf[PH_TAG_TEXT_MAX_LEN] = { 0 }; - char resultbuf[PH_TAG_TEXT_MAX_LEN] = { 0 }; - - if (dial_d->list_mode == MODE_COUNTRY_CODE) - return dialer_gl_cc_label_get(dial_d, (ph_cc_name_mcc_info *) data, obj, part); - - if (0 == strcmp(part, "elm.text.left.name")) - { - if (sd->display && *sd->display) - { - if (sd->type == SEARCH_CONTACT_NAME_TYPE) - { - ph_dialer_util_highlight_substring_with_pos(buf, sizeof(buf), sd->display, sd->position, sd->len); - return strdup(buf); - } - else - return strdup(sd->display); - } - return NULL; - } - else if (0 == strcmp(part, "elm.text.left.number")) - { - if (sd->type == SEARCH_LOG_TYPE) - { - ph_dialer_util_highlight_substring(buf, sizeof(buf), sd->number, sd->find_number); - return strdup(buf); - } - else - { - if (sd->number_type & CONTACTS_NUMBER_TYPE_CUSTOM && sd->numtype_label && sd->numtype_label[0]) - snprintf(resultbuf, sizeof(resultbuf), "%s %s", sd->numtype_label, sd->number); - else - snprintf(resultbuf, sizeof(resultbuf), "%s %s", T_(CT_GET_TEXT_NUM_TYPE, phone_detail_log_get_phonenumber_type(sd->number_type)), sd->number); - if (sd->type == SEARCH_CONTACT_NAME_TYPE) - return strdup(resultbuf); - else - { - ph_dialer_util_highlight_substring(buf, sizeof(buf), resultbuf, sd->find_number); - return strdup(buf); - } - } - } - } - return NULL; -} - -static void dialer_fastscroll_level_up(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - int level = elm_index_item_level_get(obj); - const Elm_Object_Item *it; - const Elm_Object_Item *index; - ph_cc_name_mcc_info *item; - char prev_ch[4] = { 0 }; - char prev_ch_first[2] = { 0 }; - p_retm_if(1 != level, "level is not 1"); - - index = elm_index_selected_item_get(obj, level - 1); - elm_index_item_clear(obj); - - it = (const Elm_Object_Item *) elm_object_item_data_get(index); - p_retm_if(NULL == it, "elm_object_item_data_get(%p) returns NULL", index); - - item = (ph_cc_name_mcc_info *) elm_object_item_data_get(it); - prev_ch_first[0] = item->name[0]; - - while (it) - { - item = (ph_cc_name_mcc_info *) elm_object_item_data_get(it); - - if (prev_ch_first[0] != item->name[0]) - break; - - if (prev_ch[0] != item->name[1]) - { - prev_ch[0] = item->name[1]; - elm_index_item_append(obj, prev_ch, NULL, it); - } - it = elm_genlist_item_next_get(it); - } - elm_index_level_go(obj, level); -} - -static void dialer_fastscroll_level_down(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; -} - -static void dialer_fastscroll_index_changed(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - PH_DBG("obj:%x, level:%d", (unsigned int)obj, elm_index_item_level_get(obj)); - elm_genlist_item_bring_in((Elm_Object_Item *) elm_object_item_data_get((const Elm_Object_Item *) event_info), ELM_GENLIST_ITEM_SCROLLTO_TOP); -} - -static void dialer_create_index(ph_dialer_data &dial_d) -{ - PH_TRACE; - dial_d.fast_index = elm_index_add(dial_d.layout); - elm_object_part_content_set(dial_d.layout, "search_list/index", dial_d.fast_index); - edje_object_signal_emit(_EDJ(dial_d.layout), "viewobject/search_list/index/hide", "viewobject/search_list/index"); - - evas_object_smart_callback_add(dial_d.fast_index, "level,up", dialer_fastscroll_level_up, NULL); - evas_object_smart_callback_add(dial_d.fast_index, "level,down", dialer_fastscroll_level_down, NULL); - evas_object_smart_callback_add(dial_d.fast_index, "delay,changed", dialer_fastscroll_index_changed, NULL); - evas_object_smart_callback_add(dial_d.fast_index, "selected", dialer_fastscroll_index_changed, NULL); - elm_index_level_go(dial_d.fast_index, 0); -} - -void ph_dialer_update_cnt_btn(ph_dialer_data *dial_d, int count) -{ - PH_TRACE; - char buf[PH_TEXT_MAX_LEN] = { 0 }; - if (count < 2) - { - elm_object_part_text_set(dial_d->count_layout, "btn_style/number", NULL); -// elm_object_disabled_set(dial_d->count_button, EINA_TRUE); - edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/hide", "count_button"); - } - else - { - snprintf(buf, sizeof(buf), "%d", count); - elm_object_part_text_set(dial_d->count_layout, "btn_style/number", buf); - elm_object_disabled_set(dial_d->count_button, EINA_FALSE); - edje_object_signal_emit(_EDJ(dial_d->count_layout), "count_button/opened", "count_button"); - } -} - -static void dialer_entry_set_number_noresize(ph_dialer_data *dial_d, - const char *text) -{ - PH_TRACE; - int size = MAX_DIAL_NUMBER_FONT_SIZE; - char buf[PH_TEXT_MAX_LEN] = { 0 }; - int pos; - - snprintf(buf, sizeof(buf), "DEFAULT='align=left font=Tizen:style=Thin text_class=tizen font_size=%d color=#FFFFFF'", size); - elm_entry_text_style_user_push(dial_d->entry, buf); - - if (text && *text) - snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); - else - snprintf(buf, sizeof(buf), "%s", PH_DIALER_ENTRY_EMPTY_STYLE); - elm_entry_entry_set(dial_d->entry, buf); - - pos = ph_dialer_util_get_cursor_pos(dial_d); - elm_entry_cursor_pos_set(dial_d->entry, pos); -} - -void ph_dialer_entry_set_number(ph_dialer_data &dial_d, const std::string &orig, int cursor) -{ - PH_TRACE; - char text[PH_TEXT_MAX_LEN] = { 0 }; - - int numberEntry = orig.size(); - DBG("numberEntry %i",numberEntry); - - if((numberEntry-minNumberEntry)>=0) - { - if(dial_d.entry_font_size >=numberMinSize && (displaySize/dial_d.entry_font_size)<numberEntry ) - { - if(numberEntry>=maxNumberEntry) - { - dial_d.entry_font_size = displaySize/maxNumberEntry; - } - else dial_d.entry_font_size = displaySize/numberEntry; - } - else if((displaySize/dial_d.entry_font_size)>numberEntry) - { - dial_d.entry_font_size = displaySize/numberEntry; - } - } - - if (orig.size() != 0) - { - snprintf(text, sizeof(text), PH_DIALER_ENTRY_DEFAULT_STYLE, dial_d.entry_font_size, orig.c_str()); - if (dial_d.run_mode != PH_DAILER_EMERGENCY && strcmp("hide", edje_object_part_state_get(_EDJ(dial_d.layout), "textblock/textarea", NULL))) - edje_object_signal_emit(_EDJ(dial_d.layout), "viewobject/entry/show", "viewobject/entry"); - } - else - { - snprintf(text, sizeof(text), "%s", PH_DIALER_ENTRY_EMPTY_STYLE); -// if (dial_d->run_mode != PH_DAILER_EMERGENCY) -// edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/hide", "viewobject/entry");//temporalily HIDE for contact search implmentation (kc.jun) - } - elm_entry_entry_set(dial_d.entry, text); - - if (cursor == CURSOR_END) - cursor = orig.size(); - else if (cursor == CURSOR_BEGIN) - cursor = 0; - else if (cursor == 0) - cursor = ph_dialer_util_get_cursor_pos(&dial_d); - - dial_d.number_cursor = ph_dialer_util_get_node_by_index(&dial_d, cursor); - elm_entry_cursor_pos_set(dial_d.entry, cursor); - - DBG("number end %i",cursor); -} - -static void dialer_clear_thread(ph_dialer_data *dial_d) -{ - PH_TRACE; - dial_d->t_info->alive = false; - if (dial_d->t_info->epipe) - { - ecore_pipe_write_close(dial_d->t_info->epipe); - ecore_pipe_read_close(dial_d->t_info->epipe); - ecore_pipe_del(dial_d->t_info->epipe); - dial_d->t_info->epipe = NULL; - } - pthread_join(dial_d->t_info->thread, NULL); - free(dial_d->t_info); - dial_d->t_info = NULL; -} - -Eina_Bool ph_dialer_reload_data(void *data) -{ - PH_TRACE; - int count = 0; - assert(data); - p_retvm_if(NULL == data, ECORE_CALLBACK_CANCEL, "data is null"); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retvm_if(!dial_d->data_dirty_flag, ECORE_CALLBACK_CANCEL, "data is not changed"); - - if (dial_d->data_dirty_flag & CONTACT_DATA_CHAGNED) - { - phone_free_speeddial_data(dial_d->speeddial_list); - dial_d->speeddial_list = phone_load_speeddial_data(&count); - - if (dial_d->t_info) - dialer_clear_thread(dial_d); - dial_d->loading = false; - - if (dial_d->contact_list) - { - phone_free_contacts(dial_d->contact_list); - dial_d->contact_list = NULL; - } - } - else if (dial_d->data_dirty_flag & SPEEDDIAL_DATA_CHAGNED) - { - phone_free_speeddial_data(dial_d->speeddial_list); - dial_d->speeddial_list = phone_load_speeddial_data(&count); - } - dial_d->data_dirty_flag = 0; - ph_dialer_search_request(dial_d, TRUE); - dial_d->update_timer = NULL; - return ECORE_CALLBACK_CANCEL; - } - return false; -} - -static void dialer_contact_data_changed_cb(const char* view_uri, void* data) -{ - PH_TRACE; - assert(data); - p_retm_if(NULL == data, "data is null"); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - if (dial_d->update_timer) - { - ecore_timer_del(dial_d->update_timer); - dial_d->update_timer = NULL; - } - - if (dial_d->is_background) - { - dial_d->data_dirty_flag |= CONTACT_DATA_CHAGNED; - dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); - } - else - { - int count = 0; - phone_free_speeddial_data(dial_d->speeddial_list); - dial_d->speeddial_list = phone_load_speeddial_data(&count); - - if (dial_d->t_info) - dialer_clear_thread(dial_d); - dial_d->loading = false; - - if (dial_d->contact_list) - { - phone_free_contacts(dial_d->contact_list); - dial_d->contact_list = NULL; - } - - ph_dialer_search_request(dial_d, TRUE); - } - } -} - -static void dialer_speeddial_data_changed_cb(const char* view_uri, void* data) -{ - PH_TRACE; - p_retm_if(NULL == data, "data is null"); - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - if (dial_d->update_timer) - { - ecore_timer_del(dial_d->update_timer); - dial_d->update_timer = NULL; - } - - if (dial_d->is_background) - { - dial_d->data_dirty_flag |= SPEEDDIAL_DATA_CHAGNED; - dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); - } - else - { - int count = 0; - phone_free_speeddial_data(dial_d->speeddial_list); - dial_d->speeddial_list = phone_load_speeddial_data(&count); - ph_dialer_search_request(dial_d, TRUE); - } - } -} - -static void dialer_log_data_changed_cb(const char* view_uri, void* data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(NULL == dial_d, "dial_d is null"); - - if (dial_d->update_timer) - { - ecore_timer_del(dial_d->update_timer); - dial_d->update_timer = NULL; - } - - if (dial_d->is_background) - { - dial_d->data_dirty_flag |= LOG_DATA_CHAGNED; - dial_d->update_timer = ecore_timer_add(3.0, ph_dialer_reload_data, dial_d); - } - else - ph_dialer_search_request(dial_d, TRUE); - } -} - -static void dialer_view_delete_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retm_if(NULL == dial_d, "dial_d is null"); - - int err = contacts_db_remove_changed_cb(_contacts_person._uri, dialer_contact_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); - err = contacts_db_remove_changed_cb(_contacts_phone_log._uri, dialer_log_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); - err = contacts_db_remove_changed_cb(_contacts_speeddial._uri, dialer_speeddial_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_remove_changed_cb() Failed(%d)", err); - - ph_dialer_util_del_all_number(dial_d); - - if (dial_d->t_info) - dialer_clear_thread(dial_d); - - if (dial_d->search_idler) - ecore_idler_del(dial_d->search_idler); - - if (dial_d->popup) - evas_object_del(dial_d->popup); - - if (dial_d->m_Menu) - evas_object_del(dial_d->m_Menu); - - if (dial_d->m_ContextMenu) - evas_object_del(dial_d->m_ContextMenu); - - if (dial_d->job) - ecore_job_del(dial_d->job); - - if (dial_d->search_timer) - ecore_timer_del(dial_d->search_timer); - - if (dial_d->dash_timer) - ecore_timer_del(dial_d->dash_timer); - - if (dial_d->longpress_timer) - ecore_timer_del(dial_d->longpress_timer); - - if (dial_d->update_timer) - ecore_timer_del(dial_d->update_timer); - - if (dial_d->slide_timer) - ecore_timer_del(dial_d->slide_timer); - - touchManager.stopTimer(); - - if (dial_d->key_press) - ecore_event_handler_del(dial_d->key_press); - - if (dial_d->key_release) - ecore_event_handler_del(dial_d->key_release); - - feedback_deinitialize(); - - if (dial_d->th) - { - elm_theme_extension_del(dial_d->th, DIALER_THEME_EDJ); - elm_theme_free(dial_d->th); - } - - phone_free_speeddial_data(dial_d->speeddial_list); - phone_free_contacts(dial_d->contact_list); - - free(dial_d->longpress_source); - free(dial_d->searched_text); - free(dial_d); - } -} -#ifdef _ADJUST_FONTSIZE -static void dialer_entry_font_check(Evas_Object *entry, ph_dialer_data *dial_d, char *text, int pos) -{ - PH_TRACE; - static int status = 0; - Ecore_X_Window win; - int size; - int win_width; - int max_width; - int entry_width; - char buf[PH_TEXT_MAX_LEN] = { 0 }; - int size_interval = 3; - - win = ecore_x_window_root_get(ecore_x_window_focus_get()); - ecore_x_window_size_get(win, &win_width, NULL); - evas_object_size_hint_min_get(entry, &entry_width, NULL); - max_width = win_width - 142; - - size = dial_d->entry_font_size; -// PH_DBG("BEFORE: fontsize : %d, max_width : %d, entry_width : %d", size, max_width, entry_width); - if (max_width < entry_width) - { - if (MIN_DIAL_NUMBER_FONT_SIZE < size) - { - size -= size_interval; - snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); - status = -1; - dial_d->entry_font_size = size; - elm_entry_entry_set(dial_d->entry, buf); -// PH_DBG("####### elm_entry_entry_set, %s", buf); - elm_entry_cursor_pos_set(dial_d->entry, pos); - } - } - else if (entry_width < max_width) - { - if (status == -1) - { - status = 0; - return; - } - if (size < MAX_DIAL_NUMBER_FONT_SIZE) - { - size += size_interval; - snprintf(buf, sizeof(buf), PH_DIALER_ENTRY_DEFAULT_STYLE, size, text); - status = 1; - dial_d->entry_font_size = size; - elm_entry_entry_set(dial_d->entry, buf); - elm_entry_cursor_pos_set(dial_d->entry, pos); - } - } - else - status = 0; -// evas_object_size_hint_min_get(entry, &entry_width, NULL); -// PH_DBG("AFTER: fontsize : %d, max_width : %d, entry_width : %d", size, max_width, entry_width); -} -#endif - -static int dialer_include_zero_space(char *text) -{ - PH_TRACE; - int len; - int i; - - p_retv_if(NULL == text, -1); - - len = strlen(text); - for (i = 0; i < len - 2; i++) - { - if (text[i] == (char) 0xe2 && text[i + 1] == (char) 0x80 && text[i + 2] == (char) 0x8b) - return i; - } - return -1; -} - -static int dialer_trim_dash_from_numstr(char *src, char *dest_buf, int buf_size, int cursor) -{ - PH_TRACE; - int number_index = 0; - int scan_index = 0; - int zero_pos; - - p_retvm_if(NULL == src || '\0' == *src, -1, "src is NULL"); - p_retvm_if(NULL == dest_buf, -1, "dest_buf is NULL"); - - zero_pos = dialer_include_zero_space(src); - - while (src[scan_index] && number_index < buf_size) - { - if (scan_index == zero_pos) - { - scan_index += 3; - if (number_index < cursor) cursor--; - continue; - } - if (!ph_dialer_util_is_dash(src[scan_index])) - dest_buf[number_index++] = src[scan_index]; - else if (number_index < cursor) - cursor--; - scan_index++; - } - dest_buf[number_index] = '\0'; - return cursor; -} - -static void dialer_entry_text_changed(void *data, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - int pos, cursor; - char node_text[PH_TEXT_MAX_LEN] = { 0 }; - char entry_text[PH_TEXT_MAX_LEN] = { 0 }; - const char *org; - char *text; - int differ = 0; - - org = elm_entry_entry_get(obj); - p_retm_if(NULL == org, "entry text is null"); - text = elm_entry_markup_to_utf8(org); - - // set text when cut/copy/paste - ph_dialer_util_get_pure_numstr_with_plus(dial_d, node_text); - pos = elm_entry_cursor_pos_get(dial_d->entry); - cursor = dialer_trim_dash_from_numstr(text, entry_text, sizeof(entry_text), pos); - differ = strcmp(node_text, entry_text); - - if (0 <= dialer_include_zero_space(text) && strlen(text) == 3 && 0 == differ) - { - free(text); - return; - } - - const char* endtag = strstr(org, PH_DIALER_ENTRY_STYLE_END_TAG); - if (0 != differ || (endtag && endtag[3] != '\0')) - { - PH_DBG("update entry"); - ph_dialer_util_append_node_from_numstr(dial_d, entry_text); - dial_d->number_cursor = ph_dialer_util_get_node_by_index(dial_d, cursor); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, node_text); - ph_dialer_entry_set_number(*dial_d, node_text, 0); - ph_dialer_search_request(dial_d, FALSE); - free(text); - return; - } - -#ifdef _ADJUST_FONTSIZE - if (NULL == strstr(org, "font_size")) - { - if (MAX_DIAL_NUMBER_FONT_SIZE == dial_d->entry_font_size) - dial_d->entry_font_size--; - else if (MIN_DIAL_NUMBER_FONT_SIZE == dial_d->entry_font_size) - dial_d->entry_font_size++; - } - PH_DBG("dial_d->entry_font_size : %d", dial_d->entry_font_size); - dialer_entry_font_check(obj, dial_d, text, pos); -#endif - - free(text); - return; - } -} - -static void dialer_create_entry(ph_dialer_data &dial_d) -{ - PH_TRACE; - Evas_Object *scroller; - Evas_Object *entry; - - scroller = elm_scroller_add(dial_d.layout); - elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); - elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); - elm_scroller_content_min_limit(scroller, EINA_FALSE, EINA_TRUE); - elm_object_part_content_set(dial_d.layout, "textblock/textarea", scroller); - - entry = elm_entry_add(dial_d.layout); - elm_entry_single_line_set(entry, EINA_TRUE); - elm_entry_editable_set(entry, EINA_TRUE); - elm_entry_magnifier_disabled_set(entry, EINA_TRUE); - elm_entry_input_panel_enabled_set(entry, EINA_FALSE); - evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL); - elm_object_content_set(scroller, entry); - dial_d.entry = entry; - - evas_object_smart_callback_add(entry, "selection,changed", dialer_entry_selection_changed, &dial_d); - evas_object_smart_callback_add(entry, "cursor,changed", dialer_entry_cursor_changed, &dial_d); - evas_object_smart_callback_add(entry, "changed", dialer_entry_text_changed, &dial_d); - evas_object_event_callback_add(entry, EVAS_CALLBACK_MOUSE_DOWN, dialer_entry_mouse_down, &dial_d); - evas_object_event_callback_add(entry, EVAS_CALLBACK_MOUSE_UP, dialer_entry_mouse_up, &dial_d); -} - -static void dialer_entry_number_init(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - - p_retm_if(PH_DAILER_EMERGENCY == dial_d->run_mode, "It is Emergency mode"); - - char *buf; - int value = FALSE; - char num[PH_TEXT_MAX_LEN] = { 0 }; - int ret __attribute__ ((unused)) = vconf_get_bool(VCONFKEY_CISSAPPL_PREFIX_DIAL_BOOL, &value); - if (dial_d->searched_text) - { - ph_dialer_util_append_node_from_numstr_with_strip(dial_d, dial_d->searched_text); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, num); - ph_dialer_entry_set_number(*dial_d, num, CURSOR_END); - ph_dialer_search_request(dial_d, TRUE); - } - else if (value == TRUE) - { - ret = vconf_get_int(VCONFKEY_CISSAPPL_PREFIX_DIAL_VALUE_INT, &value); - PH_DBG("prefix dial index: %d", value); - buf = NULL; - switch (value) - { - case 0: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM1_STR); break; - case 1: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM2_STR); break; - case 2: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM3_STR); break; - case 3: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM4_STR); break; - case 4: buf = vconf_get_str(VCONFKEY_CISSAPPL_PREFIX_DIAL_NUM5_STR); break; - default: PH_DBG("wrong prefix index(%d)", value); break; - } - - if (buf && *buf) - { - ph_dialer_util_append_node_from_numstr_with_strip(dial_d, buf); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, num); - ph_dialer_entry_set_number(*dial_d, num, CURSOR_END); - ph_dialer_search_request(dial_d, FALSE); - free(buf); - } - } - else - dialer_entry_set_number_noresize(dial_d, ""); - dial_d->initialized = TRUE; - } -} - -static void dialer_menu_btn_cb(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - dialer_number_options_popup(dial_d); - } -} - -static void dialer_lazy_init(void *data) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - dialer_create_index(*dial_d); - dialer_create_entry(*dial_d); - dial_d->entry_font_size = MAX_DIAL_NUMBER_FONT_SIZE; - dial_d->number_cursor = &(dial_d->number_head); - - feedback_initialize(); - - edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_clicked", "*", dialer_keypad_clicked, dial_d); - edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_down", "*", dialer_keypad_down, dial_d); - edje_object_signal_callback_add(_EDJ(dial_d->layout), "pad_up", "*", dialer_keypad_up, dial_d); - edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_clicked", "*", dialer_softkey_clicked, dial_d); - edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_up", "*", dialer_softkey_up, dial_d); - edje_object_signal_callback_add(_EDJ(dial_d->layout), "softkey_down", "*", dialer_softkey_down, dial_d); - - touchManager.initKeyPadArea(dial_d->layout); - - int count = 0; - dial_d->speeddial_list = phone_load_speeddial_data(&count); - dial_d->job = ecore_job_add(dialer_entry_number_init, dial_d); - - if(!dial_d->is_emergency) - { - if(!dial_d->m_Search->initialize(dial_d)) - { - ERR("Search controller initialization failed"); - } - } - } -} - -static void dialer_layout_flush_post_cb(void *data, Evas *e, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - if (evas_object_visible_get(dial_d->layout)) - { - evas_event_callback_del(evas_object_evas_get(dial_d->layout), EVAS_CALLBACK_RENDER_FLUSH_POST, dialer_layout_flush_post_cb); - dial_d->job = ecore_job_add(dialer_lazy_init, dial_d); - } - } -} - -static void dialer_mousedown(void *data, Evas *evas, Evas_Object *obj, void *event_info) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *) event_info; - dial_d->touch_x = ev->canvas.x; - dial_d->touch_y = ev->canvas.y; - } -} - -static Eina_Bool _key_release_cb(void *data, int type, void *event) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retvm_if(dial_d == NULL, false, "dial_d is NULL"); - p_retvm_if(dial_d->is_background == TRUE, false, "Dialer is not on top"); - p_retvm_if(dial_d->child_ug != NULL, false, "child UG is exist."); - p_retvm_if(elm_object_focus_get(dial_d->entry)== TRUE, false, "Focus already has been set on entry."); - - Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *) event; - if (!ev) - { - PH_DBG("Invalid event object"); - return ECORE_CALLBACK_RENEW; - } - PH_DBG("%d type / %s released.", type, ev->keyname); - - if (dial_d->longpress_timer) - { - ecore_timer_del(dial_d->longpress_timer); - dial_d->longpress_timer = NULL; - } - - return ECORE_CALLBACK_RENEW; - } - return false; -} - -static Eina_Bool _key_press_cb(void* data, int type, void* event) -{ - PH_TRACE; - assert(data); - if (NULL != data) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( data ); - p_retvm_if(dial_d == NULL, false, "dial_d is NULL"); - p_retvm_if(dial_d->is_background == TRUE, false, "Dialer is not on top"); - p_retvm_if(dial_d->child_ug != NULL, false, "child UG is exist."); - p_retvm_if(elm_object_focus_get(dial_d->entry)== TRUE, false, "Focus already has been set on entry."); - - Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *) event; - if (!ev) - { - PH_DBG("Invalid event object"); - return ECORE_CALLBACK_RENEW; - } - PH_DBG("%d type / %s pressed", type, ev->keyname); - - if (!strcmp(ev->keyname, "Return") || !strcmp(ev->keyname, "Phone")) - { - edje_object_signal_emit(_EDJ(dial_d->layout), "softkey_clicked", "call"); - } - else if (!strcmp(ev->keyname, "BackSpace")) - { - edje_object_signal_emit(_EDJ(dial_d->layout), "softkey_down", backspaceButton); - } - else if (ev->keyname[0] >= '0' && ev->keyname[0] <= '9') - { - const Evas_Modifier *mods = evas_key_modifier_get( evas_object_evas_get(dial_d->layout)); - if (evas_key_modifier_is_set(mods, "Shift")) - { - if (ev->keyname[0] == '3') - edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", "#"); - else if (ev->keyname[0] == '8') - edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", "*"); - } - else - edje_object_signal_emit(_EDJ(dial_d->layout), "pad_down", ev->keyname); - } - - return ECORE_CALLBACK_RENEW; - } - return false; -} - -int ph_dialer_create_content(ph_dialer_data *dial_d) -{ - PH_TRACE; - assert(dial_d); - - if (NULL != dial_d) - { - dial_d->layout = elm_layout_add(dial_d->navi); - p_retvm_if(NULL == dial_d->layout, 0, "elm_layout_add() Failed"); - elm_layout_file_set(dial_d->layout, DIALER_EDJ, "dialer/main"); - evas_object_size_hint_weight_set(dial_d->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_event_callback_add(dial_d->layout, EVAS_CALLBACK_MOUSE_DOWN, dialer_mousedown, dial_d); - - ph_dialer_util_setup_run_mode(*dial_d); - - edje_object_signal_emit(_EDJ(dial_d->layout), "main/default", "main"); - - evas_object_data_set(dial_d->layout, KEY_DIALER_DATA, dial_d); - - PH_DBG("run_mode(before emit):%d", dial_d->run_mode); - if (PH_DAILER_NORMAL != dial_d->run_mode) - { - if (PH_DAILER_EMERGENCY == dial_d->run_mode) - { - edje_object_part_text_set(_EDJ(dial_d->layout), "return_btn/text", T_(PH_GET_TEXT_BASIC, PHTEXT_PREVIOUS_SCREEN_ABB)); - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry"); - } - else if (PH_DAILER_DURING_CALL == dial_d->run_mode) - { - edje_object_part_text_set(_EDJ(dial_d->layout), "return_btn/text", T_(PH_GET_TEXT_BASIC, PHTEXT_BACK_TO_CALL)); - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry"); //temporalily HIDE for contact search implmentation (kc.jun) - } - edje_object_signal_emit(_EDJ(dial_d->layout), "return_btn/default", "return_btn"); - } - else - { - edje_object_signal_emit(_EDJ(dial_d->layout), "return_btn/hide", "return_btn"); - edje_object_signal_emit(_EDJ(dial_d->layout), "softkey/normal", "softkey"); - edje_object_signal_emit(_EDJ(dial_d->layout), "viewobject/entry/show", "viewobject/entry"); //temporalily HIDE for contact search implmentation (kc.jun) - } - - evas_object_event_callback_add(dial_d->layout, EVAS_CALLBACK_DEL, dialer_view_delete_cb, dial_d); - - int err = CONTACTS_ERROR_NONE; - - err = contacts_db_add_changed_cb(_contacts_person._uri, dialer_contact_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); - err = contacts_db_add_changed_cb(_contacts_phone_log._uri, dialer_log_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); - err = contacts_db_add_changed_cb(_contacts_speeddial._uri, dialer_speeddial_data_changed_cb, dial_d); - p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_add_changed_cb() Failed(%d)", err); - - evas_event_callback_add(evas_object_evas_get(dial_d->layout), EVAS_CALLBACK_RENDER_FLUSH_POST, dialer_layout_flush_post_cb, dial_d); - - dial_d->key_press = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, dial_d); - if (!dial_d->key_press) - PH_DBG("Failed to register a key down event handler"); - dial_d->key_release = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, dial_d); - if (!dial_d->key_release) - PH_DBG("Failed to register a key up event handler"); - - dial_d->m_Search = new Phone::Dialer::Search::Controller(); - - return 1; - } - return 0; -} - -API void phone_dialer_set_navi(Evas_Object *layout) -{ - PH_TRACE; - assert(layout); - if (NULL != layout) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(layout, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - Elm_Object_Item *navi_it; - navi_it = elm_naviframe_bottom_item_get(dial_d->navi); - - phone_navi_item_reset(navi_it, dial_d); - - if (!dial_d->is_emergency) - { - dial_d->menu_cb = dialer_menu_btn_cb; - } - } -} - -API void phone_dialer_view_reset(Evas_Object *layout) -{ - PH_TRACE; - assert(layout); - if (NULL != layout) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(layout, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - Elm_Object_Item * item; - - if (dial_d->child_ug) - { - ug_destroy(dial_d->child_ug); - dial_d->child_ug = NULL; - } - - item = elm_naviframe_bottom_item_get(dial_d->navi); - if (elm_naviframe_top_item_get(dial_d->navi) != item) - elm_naviframe_item_pop_to(item); - } -} - -API void phone_dialer_view_language_changed(Evas_Object *layout) -{ - PH_TRACE; - // TODO: Fixme -} - -API void phone_dialer_check_focus(Evas_Object *layout) -{ - PH_TRACE; - ph_dialer_data *dial_d; - - dial_d = (ph_dialer_data *) evas_object_data_get(layout, KEY_DIALER_DATA); - p_retm_if(NULL == dial_d, "dialer data is null"); - - char *text = elm_entry_markup_to_utf8(elm_entry_entry_get(dial_d->entry)); - - if (dial_d->has_focus && text && dialer_include_zero_space(text) == -1) - elm_object_focus_set(dial_d->entry, EINA_TRUE); - else - { - elm_object_focus_set(dial_d->entry, EINA_FALSE); - dial_d->has_focus = false; - } - free(text); -} - -API void phone_dialer_view_resume(Evas_Object *layout) -{ - PH_TRACE; - assert(layout); - if (NULL != layout) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(layout, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - if (!dial_d->initialized) - dialer_entry_number_init(dial_d); - } -} - -API void phone_dialer_view_set_num(Evas_Object *layout, char *number) -{ - PH_TRACE; - assert(layout); - if (NULL != layout) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(layout, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - char dest[PH_TEXT_MAX_LEN] = { 0 }; - if (number != NULL) - { - if (dial_d->entry) - { - ph_dialer_util_append_node_from_numstr_with_strip(dial_d, number); - ph_dialer_util_add_dashes(dial_d, DASH_REAL); - ph_dialer_util_get_numstr_from_node(dial_d, dest); - ph_dialer_entry_set_number(*dial_d, dest, CURSOR_END); - ph_dialer_search_request(dial_d, FALSE); - } - else - dial_d->searched_text = SAFE_STRDUP(number); - } - else - ph_dialer_util_entry_clear(dial_d); - } -} - -API void phone_dialer_view_send_key(Evas_Object *layout) -{ - PH_TRACE; - assert(layout); - if (NULL != layout) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(layout, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - dialer_softkey_call_clicked(dial_d, 0); - } -} - -API void phone_dialer_set_background(Evas_Object *obj, bool is_background) -{ - PH_TRACE; - assert(obj); - if (NULL != obj) - { - ph_dialer_data* dial_d = static_cast<ph_dialer_data*>( evas_object_data_get(obj, KEY_DIALER_DATA) ); - p_retm_if(NULL == dial_d, "dialer data is null"); - - dial_d->is_background = is_background; - if (dial_d->update_timer) - { - ecore_timer_del(dial_d->update_timer); - dial_d->update_timer = NULL; - ph_dialer_reload_data(dial_d); - } - } -} diff --git a/lib/dialer/ph-dialer-view.h b/lib/dialer/ph-dialer-view.h deleted file mode 100755 index 4b9b957..0000000 --- a/lib/dialer/ph-dialer-view.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.1 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://floralicense.org/license/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __PH_DIALER_VIEW_H__ -#define __PH_DIALER_VIEW_H__ - -enum -{ - COUNT_BUTTON_CLOSE, - COUNT_BUTTON_OPEN -}; - -typedef enum -{ - SEARCH_LOG_TYPE, - SEARCH_SPEEDDIAL_TYPE, - SEARCH_CONTACT_NUM_TYPE, - SEARCH_CONTACT_NAME_TYPE, -} search_type; - -#define KEY_DIALER_DATA "dialer_data" - -int ph_dialer_create_content(ph_dialer_data *dial_d); -void ph_dialer_entry_set_number(ph_dialer_data &dial_d, const std::string &orig, int cursor); -void ph_dialer_update_cnt_btn(ph_dialer_data *dial_d, int count); -char* ph_dialer_gl_label_get(void *data, Evas_Object *obj, const char *part); -Evas_Object* ph_dialer_gl_icon_get(void *data, Evas_Object *obj, - const char *part); -Eina_Bool ph_dialer_reload_data(void *data); -void dialer_add_contact(ph_dialer_data *dial_d); - -#endif /* __PH_DIALER_VIEW_H__ */ |