namespace Dialer
{
class KeypadEntry;
- class SearchResultsWidget;
+ class SearchResultsControl;
/**
* @brief Dialer main view.
static void launchCall(const std::string &number);
void launchSpeedDial(int digit);
- static std::string getSpeedDialNumber(int digit);
- static std::string getLastNumber();
App::AppControl m_AppControl;
SearchEngine m_SearchEngine;
KeypadEntry *m_Entry;
- SearchResultsWidget *m_SearchWidget;
+ SearchResultsControl *m_SearchWidget;
};
}
}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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_RESULTS_CONTROL_H
+#define PHONE_DIALER_SEARCH_RESULTS_CONTROL_H
+
+#include "Ui/Control.h"
+#include "Phone/Dialer/SearchTypes.h"
+
+namespace Phone
+{
+ namespace Dialer
+ {
+ /**
+ * @brief Predictive search result widget.
+ */
+ class SearchResultsControl : public Ui::Control
+ {
+ public:
+ /**
+ * @brief Result selection callback
+ * @param[in] Selected result
+ */
+ typedef std::function<void(SearchResultPtr)> SelectedCallback;
+
+ SearchResultsControl();
+
+ /**
+ * @brief Set search results to be displayed
+ * @param[in] results Search results
+ */
+ void setResults(const SearchResults *results);
+
+ /**
+ * @brief Clear search results and display nothing
+ */
+ void clearResults();
+
+ /**
+ * @brief Set result selected callback
+ */
+ void setSelectedCallback(SelectedCallback callback);
+
+ private:
+ enum ResultsState
+ {
+ ResultsNone,
+ ResultsEmpty,
+ ResultsPresent,
+ ResultsMany
+ };
+
+ private:
+ virtual Evas_Object *onCreate(Evas_Object *parent) override;
+
+ void setLayout(const char *groupName);
+ void clearLayout();
+
+ void setResultsEmpty();
+ void setResultsPresent();
+ void setResultsCount(size_t count);
+
+ void setResultInfo(SearchResultPtr result);
+ void setResultSpeedDial(SearchResultPtr result);
+
+ void onResultPressed();
+ void onShowResultsPressed();
+
+ const SearchResults *m_Results;
+ ResultsState m_State;
+ SelectedCallback m_OnSelected;
+ Evas_Object *m_ResultsCount;
+ };
+ }
+}
+
+#endif /* PHONE_DIALER_SEARCH_RESULTS_CONTROL_H */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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_RESULTS_WIDGET_H
-#define PHONE_DIALER_SEARCH_RESULTS_WIDGET_H
-
-#include "Ui/Control.h"
-#include "Phone/Dialer/SearchTypes.h"
-
-namespace Phone
-{
- namespace Dialer
- {
- /**
- * @brief Predictive search result widget.
- */
- class SearchResultsWidget : public Ui::Control
- {
- public:
- /**
- * @brief Result selection callback
- * @param[in] Selected result
- */
- typedef std::function<void(SearchResultPtr)> SelectedCallback;
-
- SearchResultsWidget();
-
- /**
- * @brief Set search results to be displayed
- * @param[in] results Search results
- */
- void setResults(const SearchResults *results);
-
- /**
- * @brief Clear search results and display nothing
- */
- void clearResults();
-
- /**
- * @brief Set result selected callback
- */
- void setSelectedCallback(SelectedCallback callback);
-
- private:
- enum ResultsState
- {
- ResultsNone,
- ResultsEmpty,
- ResultsPresent,
- ResultsMany
- };
-
- private:
- virtual Evas_Object *onCreate(Evas_Object *parent) override;
-
- void setLayout(const char *groupName);
- void clearLayout();
-
- void setResultsEmpty();
- void setResultsPresent();
- void setResultsCount(size_t count);
-
- void setResultInfo(SearchResultPtr result);
- void setResultSpeedDial(SearchResultPtr result);
-
- void onResultPressed();
- void onShowResultsPressed();
-
- const SearchResults *m_Results;
- ResultsState m_State;
- SelectedCallback m_OnSelected;
- Evas_Object *m_ResultsCount;
- };
- }
-}
-
-#endif /* PHONE_DIALER_SEARCH_RESULTS_WIDGET_H */
#ifndef PHONE_UTILS_H
#define PHONE_UTILS_H
+#include <string>
+
namespace Phone
{
+ /**
+ * @brief Get phone number assigned to specific speed dial number.
+ * @param[in] speedNumber Number on the dialer
+ * @return Speed dial number or empty string if not assigned.
+ */
+ std::string getSpeedDialNumber(int speedNumber);
+
/**
* @brief Add speed dial number.
* @param[in] speedNumber Number on the dialer
* @return true on success, false if number with this @a numberId already exists.
*/
bool addSpeedDialNumber(int speedNumber, int numberId);
+
+ /**
+ * @return Last incoming or outgoing call number.
+ */
+ std::string getLastCallNumber();
}
#endif /* PHONE_UTILS_H */
#include "Phone/Dialer/AddNumberPopup.h"
#include "Phone/Dialer/KeypadButton.h"
#include "Phone/Dialer/KeypadEntry.h"
-#include "Phone/Dialer/SearchResultsWidget.h"
+#include "Phone/Dialer/SearchResultsControl.h"
#include "Phone/Dialer/SpeedDialPopup.h"
#include "Phone/SpeedDial/SettingsView.h"
+#include "Phone/Utils.h"
#include "App/AppControlRequest.h"
#include "App/Path.h"
Evas_Object *MainView::createSearchWidget(Evas_Object *parent)
{
- m_SearchWidget = new SearchResultsWidget();
+ m_SearchWidget = new SearchResultsControl();
m_SearchWidget->setSelectedCallback(std::bind(&MainView::onResultSelected, this, _1));
return m_SearchWidget->create(parent);
}
Evas_Object *table = elm_table_add(parent);
elm_table_padding_set(table, 2, 2);
- int id = 0;
- for(int i = 0; i < KEYPAD_ROWS; ++i) {
- for(int j = 0; j < KEYPAD_COLS; ++j, ++id) {
+ int id = KeypadButton::ID_1;
+ for (int i = 0; i < KEYPAD_ROWS; ++i) {
+ for (int j = 0; j < KEYPAD_COLS; ++j, ++id) {
KeypadButton *key = new KeypadButton((KeypadButton::Id) id);
key->setPressedCallback(std::bind(&MainView::onKeyPressed, this, _1));
key->setLongpressedCallback(std::bind(&MainView::onKeyLongpressed, this, _1));
launchCall(number);
m_Entry->clear();
} else {
- m_Entry->setNumber(getLastNumber());
+ m_Entry->setNumber(Phone::getLastCallNumber());
}
}
void MainView::launchSpeedDial(int digit)
{
- std::string number = getSpeedDialNumber(digit);
+ std::string number = Phone::getSpeedDialNumber(digit);
if (!number.empty()) {
launchCall(number);
} else {
popup->create(getEvasObject());
}
}
-
-std::string MainView::getSpeedDialNumber(int digit)
-{
- std::string number;
- contacts_filter_h filter = NULL;
- contacts_query_h query = NULL;
- contacts_list_h list = NULL;
-
- contacts_filter_create(_contacts_speeddial._uri, &filter);
- contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number, CONTACTS_MATCH_EQUAL, digit);
-
- contacts_query_create(_contacts_speeddial._uri, &query);
- contacts_query_set_filter(query, filter);
-
- int err = contacts_db_get_records_with_query(query, 0, 1, &list);
- WARN_IF(err != CONTACTS_ERROR_NONE, "contacts_db_get_records_with_query() failed(0x%x)", err);
- if (list) {
- contacts_record_h record = NULL;
- contacts_list_get_current_record_p(list, &record);
- if (record) {
- char *str = NULL;
- contacts_record_get_str_p(record, _contacts_speeddial.number, &str);
- if (str) {
- number = str;
- }
- }
-
- contacts_list_destroy(list, true);
- }
-
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
-
- return number;
-}
-
-std::string MainView::getLastNumber()
-{
- std::string number;
- contacts_list_h list = NULL;
- contacts_query_h query = NULL;
- contacts_filter_h filter = NULL;
-
- contacts_filter_create(_contacts_person_phone_log._uri, &filter);
- contacts_filter_add_int(filter, _contacts_person_phone_log.log_type,
- CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
- contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
- contacts_filter_add_int(filter, _contacts_person_phone_log.log_type,
- CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
-
- contacts_query_create(_contacts_person_phone_log._uri, &query);
- contacts_query_set_filter(query, filter);
- contacts_query_set_sort(query, _contacts_person_phone_log.log_time, false);
-
- int err = contacts_db_get_records_with_query(query, 0, 1, &list);
- WARN_IF(err != CONTACTS_ERROR_NONE, "contacts_db_get_records_with_query() failed(0x%x)", err);
- if (list) {
- contacts_record_h record = NULL;
- contacts_list_get_current_record_p(list, &record);
- if (record) {
- char *str = NULL;
- contacts_record_get_str_p(record, _contacts_person_phone_log.address, &str);
- if (str) {
- number = str;
- }
- }
-
- contacts_list_destroy(list, true);
- }
-
- contacts_query_destroy(query);
- contacts_filter_destroy(filter);
-
- return number;
-}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 "Phone/Dialer/SearchResultsControl.h"
+#include "Phone/Dialer/SearchResultsPopup.h"
+#include "Phone/Dialer/SearchUtils.h"
+
+#include "App/Path.h"
+#include "Utils/Callback.h"
+#include "Utils/Logger.h"
+
+#include "DialerLayout.h"
+
+using namespace Phone::Dialer;
+
+namespace
+{
+ const std::string layoutFilePath = App::getResourcePath(DIALER_PREDICTIVE_EDJ);
+}
+
+SearchResultsControl::SearchResultsControl()
+ : m_Results(nullptr), m_State(ResultsNone),
+ m_ResultsCount(nullptr)
+{
+}
+
+void SearchResultsControl::setResults(const SearchResults *results)
+{
+ m_Results = results;
+ if (!m_Results || m_Results->empty()) {
+ setResultsEmpty();
+ } else {
+ setResultsPresent();
+ setResultsCount(m_Results->size());
+ }
+}
+
+void SearchResultsControl::clearResults()
+{
+ setLayout(nullptr);
+ m_State = ResultsNone;
+ m_Results = nullptr;
+}
+
+void SearchResultsControl::setSelectedCallback(SelectedCallback callback)
+{
+ m_OnSelected = std::move(callback);
+}
+
+Evas_Object *SearchResultsControl::onCreate(Evas_Object *parent)
+{
+ Evas_Object *layout = elm_layout_add(parent);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN,
+ (Evas_Object_Event_Cb) makeCallback(&SearchResultsControl::onResultPressed), this);
+ return layout;
+}
+
+void SearchResultsControl::setLayout(const char *groupName)
+{
+ clearLayout();
+ elm_layout_file_set(getEvasObject(), layoutFilePath.c_str(), groupName);
+}
+
+void SearchResultsControl::clearLayout()
+{
+ Eina_List *list = elm_layout_content_swallow_list_get(getEvasObject());
+ Eina_List *node = nullptr;
+ void *obj = nullptr;
+ EINA_LIST_FOREACH(list, node, obj) {
+ evas_object_del((Evas_Object *) obj);
+ }
+
+ eina_list_free(list);
+}
+
+void SearchResultsControl::setResultsEmpty()
+{
+ if (m_State != ResultsEmpty) {
+ m_State = ResultsEmpty;
+ setLayout(GROUP_PREDICTIVE_NO_RESULTS);
+ elm_object_translatable_part_text_set(getEvasObject(), PART_TEXT_ADD, "IDS_KPD_BUTTON_ADD_TO_CONTACTS_ABB2");
+ }
+}
+
+void SearchResultsControl::setResultsPresent()
+{
+ if (m_State != ResultsPresent && m_State != ResultsMany) {
+ m_State = ResultsPresent;
+ setLayout(GROUP_PREDICTIVE);
+ }
+
+ setResultInfo(m_Results->front());
+}
+
+void SearchResultsControl::setResultsCount(size_t count)
+{
+ if (count > 1) {
+ if (m_State != ResultsMany) {
+ m_State = ResultsMany;
+
+ m_ResultsCount = elm_layout_add(getEvasObject());
+ elm_layout_file_set(m_ResultsCount, layoutFilePath.c_str(), GROUP_PREDICTIVE_RES_COUNT);
+ evas_object_propagate_events_set(m_ResultsCount, EINA_FALSE);
+ evas_object_event_callback_add(m_ResultsCount, EVAS_CALLBACK_MOUSE_DOWN,
+ (Evas_Object_Event_Cb) makeCallback(&SearchResultsControl::onShowResultsPressed), this);
+ }
+
+ elm_object_part_text_set(m_ResultsCount, PART_TEXT_COUNT,
+ std::to_string(count).c_str());
+ } else {
+ m_ResultsCount = nullptr;
+ m_State = ResultsPresent;
+ }
+
+ elm_object_part_content_set(getEvasObject(), PART_SWALLOW_RESULTS, m_ResultsCount);
+}
+
+void SearchResultsControl::setResultInfo(SearchResultPtr result)
+{
+ Evas_Object *layout = getEvasObject();
+ elm_object_part_content_set(layout, PART_SWALLOW_THUMBNAIL,
+ Utils::createThumbnail(layout, result->getId()));
+
+ if (result->getName(false).empty()) {
+ elm_object_part_text_set(layout, PART_TEXT_1_LINE, result->getNumber(true).c_str());
+ elm_object_part_text_set(layout, PART_TEXT_NAME, "");
+ elm_object_part_text_set(layout, PART_TEXT_NUMBER, "");
+ } else {
+ elm_object_part_text_set(layout, PART_TEXT_1_LINE, "");
+ elm_object_part_text_set(layout, PART_TEXT_NAME, result->getName(true).c_str());
+ elm_object_part_text_set(layout, PART_TEXT_NUMBER, result->getNumber(true).c_str());
+ }
+
+ if (result->getType() == ResultSpeedDial) {
+ setResultSpeedDial(result);
+ elm_object_signal_emit(getEvasObject(), "show,speeddial,icon", "");
+ } else {
+ elm_object_signal_emit(getEvasObject(), "hide,speeddial,icon", "");
+ }
+}
+
+void SearchResultsControl::setResultSpeedDial(SearchResultPtr result)
+{
+ Evas_Object *speeddialLayout = elm_layout_add(getEvasObject());
+ elm_layout_file_set(speeddialLayout, layoutFilePath.c_str(), GROUP_SPEEDDIAL_NUMBER);
+ elm_object_part_text_set(speeddialLayout, PART_TEXT_NUMBER, result->getSearchString().c_str());
+ elm_object_part_content_set(getEvasObject(), PART_SWALLOW_SPEEDDIAL, speeddialLayout);
+}
+
+void SearchResultsControl::onResultPressed()
+{
+ if (m_OnSelected) {
+ if (m_Results && !m_Results->empty()) {
+ m_OnSelected(m_Results->front());
+ } else {
+ m_OnSelected(nullptr);
+ }
+ }
+}
+
+void SearchResultsControl::onShowResultsPressed()
+{
+ SearchResultsPopup *popup = new SearchResultsPopup(m_Results);
+ popup->setSelectedCallback(m_OnSelected);
+ popup->create(getEvasObject());
+}
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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 "Phone/Dialer/SearchResultsWidget.h"
-#include "Phone/Dialer/SearchResultsPopup.h"
-#include "Phone/Dialer/SearchUtils.h"
-
-#include "App/Path.h"
-#include "Utils/Callback.h"
-#include "Utils/Logger.h"
-
-#include "DialerLayout.h"
-
-using namespace Phone::Dialer;
-
-namespace
-{
- const std::string layoutFilePath = App::getResourcePath(DIALER_PREDICTIVE_EDJ);
-}
-
-SearchResultsWidget::SearchResultsWidget()
- : m_Results(nullptr), m_State(ResultsNone),
- m_ResultsCount(nullptr)
-{
-}
-
-void SearchResultsWidget::setResults(const SearchResults *results)
-{
- m_Results = results;
- if (!m_Results || m_Results->empty()) {
- setResultsEmpty();
- } else {
- setResultsPresent();
- setResultsCount(m_Results->size());
- }
-}
-
-void SearchResultsWidget::clearResults()
-{
- setLayout(nullptr);
- m_State = ResultsNone;
- m_Results = nullptr;
-}
-
-void SearchResultsWidget::setSelectedCallback(SelectedCallback callback)
-{
- m_OnSelected = std::move(callback);
-}
-
-Evas_Object *SearchResultsWidget::onCreate(Evas_Object *parent)
-{
- Evas_Object *layout = elm_layout_add(parent);
- evas_object_event_callback_add(layout, EVAS_CALLBACK_MOUSE_DOWN,
- (Evas_Object_Event_Cb) makeCallback(&SearchResultsWidget::onResultPressed), this);
- return layout;
-}
-
-void SearchResultsWidget::setLayout(const char *groupName)
-{
- clearLayout();
- elm_layout_file_set(getEvasObject(), layoutFilePath.c_str(), groupName);
-}
-
-void SearchResultsWidget::clearLayout()
-{
- Eina_List *list = elm_layout_content_swallow_list_get(getEvasObject());
- Eina_List *node = nullptr;
- void *obj = nullptr;
- EINA_LIST_FOREACH(list, node, obj) {
- evas_object_del((Evas_Object *) obj);
- }
-
- eina_list_free(list);
-}
-
-void SearchResultsWidget::setResultsEmpty()
-{
- if (m_State != ResultsEmpty) {
- m_State = ResultsEmpty;
- setLayout(GROUP_PREDICTIVE_NO_RESULTS);
- elm_object_translatable_part_text_set(getEvasObject(), PART_TEXT_ADD, "IDS_KPD_BUTTON_ADD_TO_CONTACTS_ABB2");
- }
-}
-
-void SearchResultsWidget::setResultsPresent()
-{
- if (m_State != ResultsPresent && m_State != ResultsMany) {
- m_State = ResultsPresent;
- setLayout(GROUP_PREDICTIVE);
- }
-
- setResultInfo(m_Results->front());
-}
-
-void SearchResultsWidget::setResultsCount(size_t count)
-{
- if (count > 1) {
- if (m_State != ResultsMany) {
- m_State = ResultsMany;
-
- m_ResultsCount = elm_layout_add(getEvasObject());
- elm_layout_file_set(m_ResultsCount, layoutFilePath.c_str(), GROUP_PREDICTIVE_RES_COUNT);
- evas_object_propagate_events_set(m_ResultsCount, EINA_FALSE);
- evas_object_event_callback_add(m_ResultsCount, EVAS_CALLBACK_MOUSE_DOWN,
- (Evas_Object_Event_Cb) makeCallback(&SearchResultsWidget::onShowResultsPressed), this);
- }
-
- elm_object_part_text_set(m_ResultsCount, PART_TEXT_COUNT,
- std::to_string(count).c_str());
- } else {
- m_ResultsCount = nullptr;
- m_State = ResultsPresent;
- }
-
- elm_object_part_content_set(getEvasObject(), PART_SWALLOW_RESULTS, m_ResultsCount);
-}
-
-void SearchResultsWidget::setResultInfo(SearchResultPtr result)
-{
- Evas_Object *layout = getEvasObject();
- elm_object_part_content_set(layout, PART_SWALLOW_THUMBNAIL,
- Utils::createThumbnail(layout, result->getId()));
-
- if (result->getName(false).empty()) {
- elm_object_part_text_set(layout, PART_TEXT_1_LINE, result->getNumber(true).c_str());
- elm_object_part_text_set(layout, PART_TEXT_NAME, "");
- elm_object_part_text_set(layout, PART_TEXT_NUMBER, "");
- } else {
- elm_object_part_text_set(layout, PART_TEXT_1_LINE, "");
- elm_object_part_text_set(layout, PART_TEXT_NAME, result->getName(true).c_str());
- elm_object_part_text_set(layout, PART_TEXT_NUMBER, result->getNumber(true).c_str());
- }
-
- if (result->getType() == ResultSpeedDial) {
- setResultSpeedDial(result);
- elm_object_signal_emit(getEvasObject(), "show,speeddial,icon", "");
- } else {
- elm_object_signal_emit(getEvasObject(), "hide,speeddial,icon", "");
- }
-}
-
-void SearchResultsWidget::setResultSpeedDial(SearchResultPtr result)
-{
- Evas_Object *speeddialLayout = elm_layout_add(getEvasObject());
- elm_layout_file_set(speeddialLayout, layoutFilePath.c_str(), GROUP_SPEEDDIAL_NUMBER);
- elm_object_part_text_set(speeddialLayout, PART_TEXT_NUMBER, result->getSearchString().c_str());
- elm_object_part_content_set(getEvasObject(), PART_SWALLOW_SPEEDDIAL, speeddialLayout);
-}
-
-void SearchResultsWidget::onResultPressed()
-{
- TRACE;
- if (m_OnSelected) {
- if (m_Results && !m_Results->empty()) {
- m_OnSelected(m_Results->front());
- } else {
- m_OnSelected(nullptr);
- }
- }
-}
-
-void SearchResultsWidget::onShowResultsPressed()
-{
- TRACE;
- SearchResultsPopup *popup = new SearchResultsPopup(m_Results);
- popup->setSelectedCallback(m_OnSelected);
- popup->create(getEvasObject());
-}
{
SpeedDialPopup *popup = (SpeedDialPopup*) data;
- char **numberIds = 0;
+ char **numberIds = nullptr;
int count = 0;
int err = app_control_get_extra_data_array(reply, APP_CONTROL_DATA_SELECTED, &numberIds, &count);
#include <contacts.h>
+std::string Phone::getSpeedDialNumber(int speedNumber)
+{
+ std::string number;
+ contacts_filter_h filter = NULL;
+ contacts_query_h query = NULL;
+ contacts_list_h list = NULL;
+
+ contacts_filter_create(_contacts_speeddial._uri, &filter);
+ contacts_filter_add_int(filter, _contacts_speeddial.speeddial_number, CONTACTS_MATCH_EQUAL, speedNumber);
+
+ contacts_query_create(_contacts_speeddial._uri, &query);
+ contacts_query_set_filter(query, filter);
+
+ int err = contacts_db_get_records_with_query(query, 0, 1, &list);
+ WARN_IF(err != CONTACTS_ERROR_NONE, "contacts_db_get_records_with_query() failed(0x%x)", err);
+ if (list) {
+ contacts_record_h record = NULL;
+ contacts_list_get_current_record_p(list, &record);
+ if (record) {
+ char *str = NULL;
+ contacts_record_get_str_p(record, _contacts_speeddial.number, &str);
+ if (str) {
+ number = str;
+ }
+ }
+
+ contacts_list_destroy(list, true);
+ }
+
+ contacts_query_destroy(query);
+ contacts_filter_destroy(filter);
+
+ return number;
+}
+
bool Phone::addSpeedDialNumber(int speedNumber, int numberId)
{
contacts_filter_h filter = nullptr;
return true;
}
+
+std::string Phone::getLastCallNumber()
+{
+ std::string number;
+ contacts_list_h list = NULL;
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+
+ contacts_filter_create(_contacts_person_phone_log._uri, &filter);
+ contacts_filter_add_int(filter, _contacts_person_phone_log.log_type,
+ CONTACTS_MATCH_GREATER_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VOICE_INCOMMING);
+ contacts_filter_add_operator(filter, CONTACTS_FILTER_OPERATOR_AND);
+ contacts_filter_add_int(filter, _contacts_person_phone_log.log_type,
+ CONTACTS_MATCH_LESS_THAN_OR_EQUAL, CONTACTS_PLOG_TYPE_VIDEO_BLOCKED);
+
+ contacts_query_create(_contacts_person_phone_log._uri, &query);
+ contacts_query_set_filter(query, filter);
+ contacts_query_set_sort(query, _contacts_person_phone_log.log_time, false);
+
+ int err = contacts_db_get_records_with_query(query, 0, 1, &list);
+ WARN_IF(err != CONTACTS_ERROR_NONE, "contacts_db_get_records_with_query() failed(0x%x)", err);
+ if (list) {
+ contacts_record_h record = NULL;
+ contacts_list_get_current_record_p(list, &record);
+ if (record) {
+ char *str = NULL;
+ contacts_record_get_str_p(record, _contacts_person_phone_log.address, &str);
+ if (str) {
+ number = str;
+ }
+ }
+
+ contacts_list_destroy(list, true);
+ }
+
+ contacts_query_destroy(query);
+ contacts_filter_destroy(filter);
+
+ return number;
+}