return 0;
}
-int _callmgr_util_check_disturbing_setting(gboolean *is_do_not_disturb)
+int _callmgr_util_check_disturbing_setting(const char *number, gboolean *is_do_not_disturb)
{
notification_system_setting_h system_setting = NULL;
- notification_setting_h setting = NULL;
- gboolean do_not_disturb = false;
- bool do_not_disturb_except = false;
- int err = NOTIFICATION_ERROR_NONE;
+ gboolean do_not_disturb = FALSE;
int ret = 0;
+ int allowed_calls = 0;
- ret = _callmgr_vconf_is_do_not_disturb(&do_not_disturb);
- if (ret == -2) {
- err = notification_system_setting_load_system_setting(&system_setting);
- if (err!= NOTIFICATION_ERROR_NONE || system_setting == NULL) {
- err("notification_system_setting_load_system_setting failed [%d]\n", err);
- goto out;
- }
- notification_system_setting_get_do_not_disturb(system_setting, (bool *)&do_not_disturb);
- }
+ *is_do_not_disturb = FALSE;
- info("do_not_disturb [%d]", do_not_disturb);
+ ret = notification_system_setting_load_system_setting(&system_setting);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ err("notification_system_setting_load_system_setting() failed [%d][%s]", ret, get_error_message(ret));
+ return 0;
+ }
- if(do_not_disturb) {
- err = notification_setting_get_setting_by_package_name(CALLUI_PKG_NAME, &setting);
- if(err != NOTIFICATION_ERROR_NONE || setting == NULL) {
- err("notification_setting_get_setting_by_package_name failed [%d]", err);
- goto out;
- }
+ ret = notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb);
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ err("notification_system_setting_get_do_not_disturb() failed [%d][%s]", ret, get_error_message(ret));
+ return 0;
+ }
- notification_setting_get_do_not_disturb_except(setting, &do_not_disturb_except);
- dbg("do_not_disturb_excepted [%d]", do_not_disturb_except);
+ info("Do not disturb [%s]", do_not_disturb ? "ON" : "OFF");
- if (do_not_disturb_except)
+ if (do_not_disturb) {
+ notification_system_setting_get_dnd_allow_exceptions(system_setting,
+ NOTIFICATION_DND_ALLOWED_CALLS, &allowed_calls);
+ dbg("Allowed calls option [%s]",
+ allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_EVERYONE ? "Everyone"
+ : allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_CONTACT ? "Contacts only"
+ : allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_FAVORITE ? "Favorite contacts only"
+ : "Nobody");
+ if (allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_EVERYONE) {
*is_do_not_disturb = FALSE;
- else
+ } else if (allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_CONTACT) {
+ int person_id = -1;
+ _callmgr_ct_get_person_id_by_num(number, &person_id);
+ if (person_id != -1) {
+ dbg("Do not disturb ON. but allow the number stored in contacts");
+ *is_do_not_disturb = FALSE;
+ } else {
+ *is_do_not_disturb = TRUE;
+ }
+ } else if (allowed_calls == NOTIFICATION_DND_ALLOWED_CALLS_FAVORITE) {
+ int is_favorite = -1;
+ _callmgr_ct_get_is_favorite_by_num(number, &is_favorite);
+ if (is_favorite == 1) {
+ dbg("Do not disturb ON. but allow the number stored in favorite contacts");
+ *is_do_not_disturb = FALSE;
+ } else {
+ *is_do_not_disturb = TRUE;
+ }
+ } else {
*is_do_not_disturb = TRUE;
+ }
} else {
*is_do_not_disturb = FALSE;
}
-out:
- if (system_setting)
- notification_system_setting_free_system_setting(system_setting);
- if (setting)
- notification_setting_free_notification(setting);
+ notification_system_setting_free_system_setting(system_setting);
return 0;
}
-
err = contacts_db_get_record(_contacts_group._uri, group_id , &group_record);
if (CONTACTS_ERROR_NONE != err) {
- err("contacts_db_get_record(contact) error %d", err);
+ err("contacts_db_get_record(contact) error %d(%s)", err, get_error_message(err));
} else {
/* Get group ringtone path */
err = contacts_record_get_str(group_record, _contacts_group.ringtone_path, &ringtone_path);
return 0;
}
-static int __callmgr_ct_get_person_id_by_num(const char *phone_number, int *person_id)
+int _callmgr_ct_get_is_favorite_by_num(const char *phone_number, int *is_favorite)
+{
+ contacts_query_h query = NULL;
+ contacts_filter_h filter = NULL;
+ contacts_list_h list = NULL;
+ contacts_record_h record = NULL;
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ bool b_favorite = FALSE;
+ unsigned int projection[] = {
+ _contacts_person_number.is_favorite,
+ };
+ CM_RETURN_VAL_IF_FAIL(phone_number, -1);
+ CM_RETURN_VAL_IF_FAIL(is_favorite, -1);
+
+ if (contacts_query_create(_contacts_person_number._uri, &query) != CONTACTS_ERROR_NONE) {
+ err("contacts_query_create is error");
+ } else if (contacts_filter_create(_contacts_person_number._uri, &filter) != CONTACTS_ERROR_NONE) {
+ err("contacts_filter_create is error");
+ } else if (contacts_filter_add_str(filter, _contacts_person_number.number_filter, CONTACTS_MATCH_EXACTLY, phone_number) != CONTACTS_ERROR_NONE) {
+ err("contacts_filter_add_str is error");
+ } else if (contacts_query_set_filter(query, filter) != CONTACTS_ERROR_NONE) {
+ err("contacts_query_set_filter is error");
+ } else if (contacts_query_set_projection(query, projection, sizeof(projection)/sizeof(unsigned int)) != CONTACTS_ERROR_NONE) {
+ err("contacts_query_set_projection is error");
+ } else if (contacts_query_set_distinct(query, TRUE) != CONTACTS_ERROR_NONE) {
+ err("contacts_query_set_distinct is error");
+ }
+
+ err = contacts_db_get_records_with_query(query, 0, 0, &list);
+
+ if (CONTACTS_ERROR_NONE == err) {
+ contacts_list_first(list);
+
+ while (CONTACTS_ERROR_NONE == contacts_list_get_current_record_p(list, &record)) {
+ contacts_record_get_bool(record, _contacts_person_number.is_favorite, &b_favorite);
+ *is_favorite = b_favorite;
+ info("is_favorite %d", *is_favorite);
+ err = contacts_list_next(list);
+ if (CONTACTS_ERROR_NONE != err)
+ break;
+ }
+ }
+
+ if (list) {
+ err = contacts_list_destroy(list, TRUE);
+ if (err != CONTACTS_ERROR_NONE) {
+ err("contacts_list_destroy is error");
+ }
+ }
+ contacts_filter_destroy(filter);
+ contacts_query_destroy(query);
+
+ return 0;
+}
+
+int _callmgr_ct_get_person_id_by_num(const char *phone_number, int *person_id)
{
contacts_query_h query = NULL;
contacts_filter_h filter = NULL;
{
callmgr_contact_info_t *contact_info = NULL;
int person_id = -1;
- contacts_error_e err = CONTACTS_ERROR_NONE;
contact_info = (callmgr_contact_info_t*)calloc(1, sizeof(callmgr_contact_info_t));
CM_RETURN_VAL_IF_FAIL(contact_info, -1);
_callmgr_ct_delete_ct_info(call_id);
- err = contacts_connect();
- if (CONTACTS_ERROR_NONE != err) {
- err("contacts_connect is error : %d", err);
- g_free(contact_info);
- return -1;
- }
-
- __callmgr_ct_get_person_id_by_num(phone_number, &person_id);
+ _callmgr_ct_get_person_id_by_num(phone_number, &person_id);
if (-1 == person_id) {
err("no contact saved for this number in db");
} else {
contact_info->log_reject_type = CM_CT_PLOG_REJECT_TYPE_NONE_E;
g_ct_list = g_slist_append(g_ct_list, contact_info);
- contacts_disconnect();
*o_contact_out_info = contact_info;
return 0;
}
{
int ret = -1;
time_t current_time;
- int log_ret = CONTACTS_ERROR_NONE;
char service_type[4] = {0, };
gboolean is_datalock = FALSE;
callmgr_contact_info_t *contact_info = NULL;
+ contacts_record_h log_record = NULL;
CM_RETURN_VAL_IF_FAIL(log_data, -1);
dbg("_callmgr_ct_add_log: type(%d)", log_data->log_type);
current_time = time(NULL);
- log_ret = contacts_connect();
- if (log_ret != CONTACTS_ERROR_NONE) {
- err("contacts_connect is failed[%d]", log_ret);
- contacts_disconnect();
- return -1;
+ g_snprintf(service_type, sizeof(service_type), "%03d", log_data->presentation);
+ warn("service_type : %s", service_type);
+
+ dbg("data->active_sim_slot_id %d", log_data->sim_slot);
+ if (contacts_record_create(_contacts_phone_log._uri, &log_record) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_create is failed");
+ } else if (contacts_record_set_str(log_record, _contacts_phone_log.address, contact_info->number) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_str(Number) is failed");
+ } else if (contacts_record_set_int(log_record, _contacts_phone_log.log_time, (current_time)) != CONTACTS_ERROR_NONE) { /* Log time is call end time*/
+ err("contacts_record_set_int(Time) is failed");
+ } else if (contacts_record_set_int(log_record, _contacts_phone_log.log_type, log_data->log_type) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_int(Type) is failed");
+ } else if (contacts_record_set_int(log_record, _contacts_phone_log.extra_data1, log_data->call_duration) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_int(Duration) is failed");
+ } else if (contacts_record_set_int(log_record, _contacts_phone_log.person_id, contact_info->person_id) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_int(person id) is failed");
+ } else if (contacts_record_set_str(log_record, _contacts_phone_log.extra_data2, service_type) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_int(extra_data2) is failed");
+ } else if (contacts_record_set_int(log_record, _contacts_phone_log.sim_slot_no, log_data->sim_slot) != CONTACTS_ERROR_NONE) {
+ err("contacts_record_set_int(person id) is failed");
+ } else if (contacts_db_insert_record(log_record, NULL) != CONTACTS_ERROR_NONE) {
+ err("contacts_db_insert_record is failed");
} else {
- contacts_record_h log_record = NULL;
-
- g_snprintf(service_type, sizeof(service_type), "%03d", log_data->presentation);
- warn("service_type : %s", service_type);
-
- dbg("data->active_sim_slot_id %d", log_data->sim_slot);
- if (contacts_record_create(_contacts_phone_log._uri, &log_record) != CONTACTS_ERROR_NONE) {
- err("contacts_record_create is failed");
- } else if (contacts_record_set_str(log_record, _contacts_phone_log.address, contact_info->number) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_str(Number) is failed");
- } else if (contacts_record_set_int(log_record, _contacts_phone_log.log_time, (current_time)) != CONTACTS_ERROR_NONE) { /* Log time is call end time*/
- err("contacts_record_set_int(Time) is failed");
- } else if (contacts_record_set_int(log_record, _contacts_phone_log.log_type, log_data->log_type) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_int(Type) is failed");
- } else if (contacts_record_set_int(log_record, _contacts_phone_log.extra_data1, log_data->call_duration) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_int(Duration) is failed");
- } else if (contacts_record_set_int(log_record, _contacts_phone_log.person_id, contact_info->person_id) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_int(person id) is failed");
- } else if (contacts_record_set_str(log_record, _contacts_phone_log.extra_data2, service_type) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_int(extra_data2) is failed");
- } else if (contacts_record_set_int(log_record, _contacts_phone_log.sim_slot_no, log_data->sim_slot) != CONTACTS_ERROR_NONE) {
- err("contacts_record_set_int(person id) is failed");
- } else if (contacts_db_insert_record(log_record, NULL) != CONTACTS_ERROR_NONE) {
- err("contacts_db_insert_record is failed");
- } else {
- info("Call log is added successfully");
- }
- contacts_record_destroy(log_record, TRUE);
+ info("Call log is added successfully");
}
-
- contacts_disconnect();
+ contacts_record_destroy(log_record, TRUE);
if ((log_data->log_type == CM_CT_PLOG_TYPE_VOICE_INCOMING_UNSEEN_E)
|| (log_data->log_type == CM_CT_PLOG_TYPE_VIDEO_INCOMING_UNSEEN_E)) {
int missed_cnt = 0;
contacts_query_h query = NULL;
contacts_filter_h filter = NULL;
- int log_ret = CONTACTS_ERROR_NONE;
dbg("__callmgr_ct_get_missed_call_count");
- log_ret = contacts_connect();
- if (log_ret != CONTACTS_ERROR_NONE) {
- err("contacts_connect is failed with err[%d] ", log_ret);
- return -1;
- }
-
if (contacts_query_create(_contacts_phone_log._uri, &query) != CONTACTS_ERROR_NONE) {
err("contacts_query_create failed");
} else if (contacts_filter_create(_contacts_phone_log._uri, &filter) != CONTACTS_ERROR_NONE) {
contacts_filter_destroy(filter);
contacts_query_destroy(query);
- contacts_disconnect();
return missed_cnt;
}
err("Fail to notification_set_led : %d", noti_err);
}
- if (contacts_connect() != CONTACTS_ERROR_NONE) {
- err("contacts_connect is error");
- }
-
if (contacts_query_create(_contacts_phone_log._uri, &query) != CONTACTS_ERROR_NONE) {
err("contacts_query_create is error");
} else if (contacts_filter_create(_contacts_phone_log._uri, &filter) != CONTACTS_ERROR_NONE) {
}
contacts_filter_destroy(filter);
contacts_query_destroy(query);
- contacts_disconnect();
noti_flags = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_LOCK | NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_TICKER;
noti_err = notification_set_display_applist(noti, noti_flags);
}
if (person_id >= 1) {
- contacts_error_e err = CONTACTS_ERROR_NONE;
-
char *disp_str = NULL;
- err = contacts_connect();
- if (err != CONTACTS_ERROR_NONE) {
- err("contacts_connect is failed[%d]", err);
- disp_str = g_strdup(_("IDS_CALL_BODY_UNKNOWN"));
- } else {
- __callmgr_ct_get_caller_info(person_id, &disp_str, &disp_img_path);
- }
-
- contacts_disconnect();
+ __callmgr_ct_get_caller_info(person_id, &disp_str, &disp_img_path);
noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, disp_str, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
g_free(disp_str);
int _callmgr_ct_get_call_name(unsigned int call_id, char **call_name)
{
int person_id = -1;
- contacts_error_e err = CONTACTS_ERROR_NONE;
CM_RETURN_VAL_IF_FAIL(call_name, -1);
- err = contacts_connect();
+ _callmgr_ct_get_person_id(call_id, &person_id);
+ __callmgr_ct_get_caller_name(person_id, call_name);
+
+ return 0;
+}
+int _callmgr_contact_init()
+{
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+
+ err = contacts_connect();
if (err != CONTACTS_ERROR_NONE) {
- err("contacts_connect is failed[%d]", err);
- } else {
- _callmgr_ct_get_person_id(call_id, &person_id);
- __callmgr_ct_get_caller_name(person_id, call_name);
+ err("contacts_connect() failed [%d](%s)", err, get_error_message(err));
+ return FALSE;
}
- contacts_disconnect();
- return 0;
+ dbg("contact init success");
+ return TRUE;
}
+int _callmgr_contact_deinit()
+{
+ contacts_disconnect();
+ return TRUE;
+}