1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
/*
* Copyright 2012 Samsung Electronics Co., Ltd
*
* Licensed under the Flora License, Version 1.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://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 "msg.h"
#include "phone.h"
#include "phone-common.h"
char *phone_get_voice_mail_number()
{
int ret;
msg_handle_t handle;
msg_struct_t voice_mail;
char strValue[MAX_PHONE_NUMBER_LEN+1] = {0,};
ret = msg_open_msg_handle(&handle);
p_retvm_if (MSG_SUCCESS != ret, NULL, "msg_open_msg_handle is Failed(%d)", ret);
voice_mail = msg_create_struct(MSG_STRUCT_SETTING_VOICE_MSG_OPT);
ret = msg_get_voice_msg_opt(handle, voice_mail);
if (ret != MSG_SUCCESS) {
ERR("msg_get_confi is faild(%d)", ret);
ret = msg_close_msg_handle(&handle);
p_warn_if (MSG_SUCCESS != ret, "msg_close_msg_handles is Failed(%d)", ret);
return NULL;
}
ret = msg_get_str_value(voice_mail, MSG_VOICEMSG_ADDRESS_STR, strValue, MAX_PHONE_NUMBER_LEN);
p_warn_if (MSG_SUCCESS != ret, "msg_get_str_value is Failed(%d)", ret);
p_warn_if (strlen(strValue) == 0, "voicemail number is none");
PH_DBG("Voicemail Number : %s", strValue);
ret = msg_close_msg_handle(&handle);
p_warn_if (MSG_SUCCESS != ret, "msg_close_msg_handles is Failed(%d)", ret);
return strdup(strValue);
}
Eina_List *phone_load_speeddial_data(int *ref_count)
{
Eina_List *list = NULL;
int count = 0;
contacts_error_e err = CONTACTS_ERROR_NONE;
contacts_list_h spdial_list = NULL;
ph_speeddial_info *voice_mail;
unsigned int record_cnt = 0;
err = contacts_db_get_all_records(_contacts_speeddial._uri, 0, 0, &spdial_list);
contacts_list_get_count( spdial_list, &record_cnt );
PH_DBG("get speeddial records (%d)", record_cnt);
while (CONTACTS_ERROR_NONE == err && record_cnt > 0) {
ph_speeddial_info *speed_info;
speed_info = calloc(1, sizeof(ph_speeddial_info));
err = phone_cts_get_str_from_list(spdial_list, _contacts_speeddial.number, &speed_info->ph_number);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() for number Failed(%d)", err);
err = phone_cts_get_int_from_list(spdial_list, _contacts_speeddial.person_id, &speed_info->contact_id);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_int_from_list() for person_id Failed(%d)", err);
err = phone_cts_get_int_from_list(spdial_list, _contacts_speeddial.speeddial_number, &speed_info->dial_number);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_int_from_list() for speeddial_number Failed(%d)", err);
err = phone_cts_get_int_from_list(spdial_list, _contacts_speeddial.number_type, &speed_info->number_type);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_int_from_list() for speeddial_number Failed(%d)", err);
err = phone_cts_get_str_from_list(spdial_list, _contacts_speeddial.number_label, &speed_info->numtype_label);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() for number_lable Failed(%d)", err);
err = phone_cts_get_str_from_list(spdial_list, _contacts_speeddial.display_name, &speed_info->display);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() for display_name Failed(%d)", err);
err = phone_cts_get_str_from_list(spdial_list, _contacts_speeddial.image_thumbnail_path, &speed_info->img_path);
p_warn_if(CONTACTS_ERROR_NONE != err, "phone_cts_get_str_from_list() for image_thumbnail_path Failed(%d)", err);
list = eina_list_append(list, (void*)speed_info);
count++;
err = contacts_list_next(spdial_list);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_next() Failed(%d)", err);
}
err = contacts_list_destroy(spdial_list, true);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_list_destroy() Failed(%d)", err);
voice_mail = calloc(1, sizeof(ph_speeddial_info));
if (NULL == voice_mail) {
ERR("calloc Failed");
*ref_count = count;
phone_free_speeddial_data(list);
return NULL;
}
voice_mail->ph_number = phone_get_voice_mail_number();
voice_mail->contact_id = 0;
voice_mail->dial_number = 1;
voice_mail->display = strdup(T_(PH_GET_TEXT_BASIC, PHTEXT_VOICE_MAIL));
voice_mail->img_path = strdup(IMG_VOICEMAIL_ICON);
list = eina_list_prepend(list, (void*)voice_mail);
*ref_count = count;
return list;
}
void phone_free_speeddial_data(Eina_List *list)
{
PH_FN_CALL;
Eina_List *l;
ph_speeddial_info *s_info;
p_retm_if(NULL == list, "List is null");
EINA_LIST_FOREACH(list, l, s_info) {
if (NULL == s_info)
continue;
free(s_info->display);
free(s_info->img_path);
free(s_info->ph_number);
free(s_info);
}
eina_list_free(list);
PH_FN_END;
}
|