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;
};
}
}
*
*/
-#ifndef PHONE_DIALER_SEARCH_RESULTS_WIDGET_H
-#define PHONE_DIALER_SEARCH_RESULTS_WIDGET_H
+#ifndef PHONE_DIALER_SEARCH_RESULTS_CONTROL_H
+#define PHONE_DIALER_SEARCH_RESULTS_CONTROL_H
#include "Ui/Control.h"
#include "Phone/Dialer/SearchTypes.h"
/**
* @brief Predictive search result widget.
*/
- class SearchResultsWidget : public Ui::Control
+ class SearchResultsControl : public Ui::Control
{
public:
/**
*/
typedef std::function<void(SearchResultPtr)> SelectedCallback;
- SearchResultsWidget();
+ SearchResultsControl();
/**
* @brief Set search results to be displayed
}
}
-#endif /* PHONE_DIALER_SEARCH_RESULTS_WIDGET_H */
+#endif /* PHONE_DIALER_SEARCH_RESULTS_CONTROL_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
* @param[in] numberId ID of number to assign to @a speedNumber
* @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;
-}
*
*/
-#include "Phone/Dialer/SearchResultsWidget.h"
+#include "Phone/Dialer/SearchResultsControl.h"
#include "Phone/Dialer/SearchResultsPopup.h"
#include "Phone/Dialer/SearchUtils.h"
const std::string layoutFilePath = App::getResourcePath(DIALER_PREDICTIVE_EDJ);
}
-SearchResultsWidget::SearchResultsWidget()
+SearchResultsControl::SearchResultsControl()
: m_Results(nullptr), m_State(ResultsNone),
m_ResultsCount(nullptr)
{
}
-void SearchResultsWidget::setResults(const SearchResults *results)
+void SearchResultsControl::setResults(const SearchResults *results)
{
m_Results = results;
if (!m_Results || m_Results->empty()) {
}
}
-void SearchResultsWidget::clearResults()
+void SearchResultsControl::clearResults()
{
setLayout(nullptr);
m_State = ResultsNone;
m_Results = nullptr;
}
-void SearchResultsWidget::setSelectedCallback(SelectedCallback callback)
+void SearchResultsControl::setSelectedCallback(SelectedCallback callback)
{
m_OnSelected = std::move(callback);
}
-Evas_Object *SearchResultsWidget::onCreate(Evas_Object *parent)
+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(&SearchResultsWidget::onResultPressed), this);
+ (Evas_Object_Event_Cb) makeCallback(&SearchResultsControl::onResultPressed), this);
return layout;
}
-void SearchResultsWidget::setLayout(const char *groupName)
+void SearchResultsControl::setLayout(const char *groupName)
{
clearLayout();
elm_layout_file_set(getEvasObject(), layoutFilePath.c_str(), groupName);
}
-void SearchResultsWidget::clearLayout()
+void SearchResultsControl::clearLayout()
{
Eina_List *list = elm_layout_content_swallow_list_get(getEvasObject());
Eina_List *node = nullptr;
eina_list_free(list);
}
-void SearchResultsWidget::setResultsEmpty()
+void SearchResultsControl::setResultsEmpty()
{
if (m_State != ResultsEmpty) {
m_State = ResultsEmpty;
}
}
-void SearchResultsWidget::setResultsPresent()
+void SearchResultsControl::setResultsPresent()
{
if (m_State != ResultsPresent && m_State != ResultsMany) {
m_State = ResultsPresent;
setResultInfo(m_Results->front());
}
-void SearchResultsWidget::setResultsCount(size_t count)
+void SearchResultsControl::setResultsCount(size_t count)
{
if (count > 1) {
if (m_State != ResultsMany) {
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);
+ (Evas_Object_Event_Cb) makeCallback(&SearchResultsControl::onShowResultsPressed), this);
}
elm_object_part_text_set(m_ResultsCount, PART_TEXT_COUNT,
elm_object_part_content_set(getEvasObject(), PART_SWALLOW_RESULTS, m_ResultsCount);
}
-void SearchResultsWidget::setResultInfo(SearchResultPtr result)
+void SearchResultsControl::setResultInfo(SearchResultPtr result)
{
Evas_Object *layout = getEvasObject();
elm_object_part_content_set(layout, PART_SWALLOW_THUMBNAIL,
}
}
-void SearchResultsWidget::setResultSpeedDial(SearchResultPtr result)
+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_content_set(getEvasObject(), PART_SWALLOW_SPEEDDIAL, speeddialLayout);
}
-void SearchResultsWidget::onResultPressed()
+void SearchResultsControl::onResultPressed()
{
- TRACE;
if (m_OnSelected) {
if (m_Results && !m_Results->empty()) {
m_OnSelected(m_Results->front());
}
}
-void SearchResultsWidget::onShowResultsPressed()
+void SearchResultsControl::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;
+}