4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
30 #include <communicator.h>
31 #include <core_object.h>
33 #include <user_request.h>
35 #include <co_phonebook.h>
38 #include "generated-code.h"
40 #include "sat_manager.h"
42 static const char* dbg_dbus_pb_type_name[] = {"PB_TYPE_FDN", "PB_TYPE_ADN", "PB_TYPE_SDN",
43 "PB_TYPE_USIM", "PB_TYPE_AAS", "PB_TYPE_GAS", };
44 static const char* dbg_dbus_pb_adf_field_name[] = { "NO VALUE 0", "PB_FIELD_NAME", "PB_FIELD_NUMBER",
45 "PB_FIELD_ANR1", "PB_FIELD_ANR2", "PB_FIELD_ANR3", "PB_FIELD_EMAIL1",
46 "PB_FIELD_EMAIL2", "PB_FIELD_EMAIL3", "PB_FIELD_EMAIL4", "PB_FIELD_SNE",
47 "PB_FIELD_GRP", "PB_FIELD_PBC" };
48 static const char* dbg_dbus_pb_ton_name[] = { "PB_TON_UNKNOWN", "PB_TON_INTERNATIONAL",
49 "PB_TON_NATIONAL", "PB_TON_NETWORK_SPECIFIC", "PB_TON_DEDICATED_ACCESS",
50 "PB_TON_ALPHA_NUMERIC", "PB_TON_ABBREVIATED_NUMBER",
51 "PB_TON_RESERVED_FOR_EXT", };
53 static gboolean on_phonebook_get_init_status(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gpointer user_data)
55 struct custom_data *ctx = user_data;
56 gboolean pb_status = FALSE;
57 struct tel_phonebook_support_list *list = NULL;
58 GSList *co_list = NULL;
59 CoreObject *co_pb = NULL;
60 TcorePlugin *plugin = NULL;
62 if (!check_access_control (invocation, AC_PHONEBOOK, "r"))
65 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
66 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
68 dbg("error- co_list is NULL");
69 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
72 co_pb = (CoreObject *)co_list->data;
73 g_slist_free(co_list);
76 dbg("error- co_pb is NULL");
77 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
81 pb_status = tcore_phonebook_get_status(co_pb);
82 list = tcore_phonebook_get_support_list(co_pb);
85 dbg("Supported phonebook list is NULL");
86 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
90 dbg("fdn[%d],adn[%d],sdn[%d],usim[%d],aas[%d],gas[%d]"
91 ,list->b_fdn,list->b_adn,list->b_sdn,list->b_usim,list->b_aas,list->b_gas);
93 telephony_phonebook_complete_get_init_status(phonebook, invocation,
107 static gboolean on_phonebook_get_count(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gint arg_req_type, gpointer user_data)
109 struct custom_data *ctx = user_data;
110 UserRequest *ur = NULL;
112 struct treq_phonebook_get_count pb_count;
113 TcorePlugin *plugin = NULL;
114 GSList *co_list = NULL;
115 CoreObject *co_pb = NULL;
116 gboolean pb_status = FALSE;
118 if (!check_access_control (invocation, AC_PHONEBOOK, "r"))
121 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
122 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
124 dbg("error- co_list is NULL");
125 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
128 co_pb = (CoreObject *)co_list->data;
129 g_slist_free(co_list);
131 pb_status = tcore_phonebook_get_status(co_pb);
133 if(pb_status == FALSE) {
134 dbg("pb_init is not completed yet.");
135 telephony_phonebook_complete_get_count(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, 0, 0, 0);
139 ur = MAKE_UR(ctx, phonebook, invocation);
140 memset(&pb_count, 0, sizeof(struct treq_phonebook_get_count));
142 pb_count.phonebook_type = arg_req_type;
143 dbg("req phonebook_type[%d][%s]", pb_count.phonebook_type, dbg_dbus_pb_type_name[pb_count.phonebook_type]);
144 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_count), &pb_count);
145 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETCOUNT);
146 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
147 if(ret != TCORE_RETURN_SUCCESS) {
148 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
149 tcore_user_request_unref(ur);
154 static gboolean on_phonebook_get_info(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gint arg_req_type, gpointer user_data)
156 struct custom_data *ctx = user_data;
157 UserRequest *ur = NULL;
159 struct treq_phonebook_get_info pb_info;
160 TcorePlugin *plugin = NULL;
161 GSList *co_list = NULL;
162 CoreObject *co_pb = NULL;
163 gboolean pb_status = FALSE;
165 if (!check_access_control (invocation, AC_PHONEBOOK, "r"))
168 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
169 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
171 dbg("error- co_list is NULL");
172 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
175 co_pb = (CoreObject *)co_list->data;
176 g_slist_free(co_list);
178 pb_status = tcore_phonebook_get_status(co_pb);
180 if(pb_status == FALSE) {
181 dbg("pb_init is not completed yet.");
182 telephony_phonebook_complete_get_info(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, 0, 0, 0, 0, 0, 0);
186 ur = MAKE_UR(ctx, phonebook, invocation);
187 memset(&pb_info, 0, sizeof(struct treq_phonebook_get_info));
189 pb_info.phonebook_type = arg_req_type;
190 dbg("req phonebook_type[%d][%s]", pb_info.phonebook_type, dbg_dbus_pb_type_name[pb_info.phonebook_type]);
191 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_get_info), &pb_info);
192 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETMETAINFO);
193 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
194 if(ret != TCORE_RETURN_SUCCESS) {
195 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
196 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
197 tcore_user_request_unref(ur);
203 static gboolean on_phonebook_get_usim_info(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation, gpointer user_data)
205 struct custom_data *ctx = user_data;
206 UserRequest *ur = NULL;
208 TcorePlugin *plugin = NULL;
209 GSList *co_list = NULL;
210 CoreObject *co_pb = NULL;
211 gboolean pb_status = FALSE;
213 if (!check_access_control (invocation, AC_PHONEBOOK, "r"))
216 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
217 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
219 dbg("error- co_list is NULL");
220 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
223 co_pb = (CoreObject *)co_list->data;
224 g_slist_free(co_list);
226 pb_status = tcore_phonebook_get_status(co_pb);
228 if(pb_status == FALSE) {
231 dbg("pb_init is not completed yet.");
232 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
233 gv = g_variant_builder_end(&b);
234 telephony_phonebook_complete_get_usim_meta_info (phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED, gv);
238 ur = MAKE_UR(ctx, phonebook, invocation);
239 tcore_user_request_set_data(ur, 0, NULL);
240 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_GETUSIMINFO);
241 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
242 if(ret != TCORE_RETURN_SUCCESS) {
243 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
244 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
245 tcore_user_request_unref(ur);
250 static gboolean on_phonebook_read_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation,
251 gint arg_req_type, gint arg_index, gpointer user_data)
253 struct custom_data *ctx = user_data;
254 UserRequest *ur = NULL;
256 struct treq_phonebook_read_record pb_read;
257 TcorePlugin *plugin = NULL;
258 GSList *co_list = NULL;
259 CoreObject *co_pb = NULL;
260 gboolean pb_status = FALSE;
262 if (!check_access_control (invocation, AC_PHONEBOOK, "r"))
265 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
266 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
268 dbg("error- co_list is NULL");
269 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
272 co_pb = (CoreObject *)co_list->data;
273 g_slist_free(co_list);
275 pb_status = tcore_phonebook_get_status(co_pb);
277 if(pb_status == FALSE) {
278 dbg("pb_init is not completed yet.");
279 telephony_phonebook_complete_read_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED,
280 0, 0, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, 0);
284 ur = MAKE_UR(ctx, phonebook, invocation);
285 memset(&pb_read, 0, sizeof(struct treq_phonebook_read_record));
287 pb_read.index = (unsigned short)arg_index;
288 pb_read.phonebook_type = arg_req_type;
289 dbg("req phonebook_type[%d][%s] index[%d]",
290 pb_read.phonebook_type, dbg_dbus_pb_type_name[pb_read.phonebook_type], pb_read.index);
292 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_read_record), &pb_read);
293 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_READRECORD);
294 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
295 if(ret != TCORE_RETURN_SUCCESS) {
296 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
297 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
298 tcore_user_request_unref(ur);
303 static gboolean on_phonebook_update_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation,
304 gint arg_type, gint arg_index, const gchar *arg_name, gint arg_dcs,
305 const gchar *arg_number, gint arg_ton,
306 const gchar *arg_sne, gint arg_sne_dcs,
307 const gchar *arg_number2, gint arg_number2_ton,
308 const gchar *arg_number3,gint arg_number3_ton, const gchar *arg_number4, gint arg_number4_ton,
309 const gchar *arg_email1, const gchar *arg_email2, const gchar *arg_email3, const gchar *arg_email4,
310 gint arg_group_index, gpointer user_data)
312 struct custom_data *ctx = user_data;
313 UserRequest *ur = NULL;
315 struct treq_phonebook_update_record pb_update;
316 TcorePlugin *plugin = NULL;
317 GSList *co_list = NULL;
318 CoreObject *co_pb = NULL;
319 gboolean pb_status = FALSE;
322 if (!check_access_control (invocation, AC_PHONEBOOK, "x"))
325 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
326 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
328 dbg("error- co_list is NULL");
329 FAIL_RESPONSE(invocation, DEFAULT_MSG_REQ_FAILED);
332 co_pb = (CoreObject *)co_list->data;
333 g_slist_free(co_list);
335 pb_status = tcore_phonebook_get_status(co_pb);
337 if(pb_status == FALSE) {
338 dbg("pb_init is not completed yet.");
339 telephony_phonebook_complete_update_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED);
343 memset(&pb_update, 0, sizeof(struct treq_phonebook_update_record));
345 dbg("pb_type[%d] index[%d] name[%s] number[%s] email[%s]",
346 arg_type,arg_index,arg_name, arg_number, arg_email1);
348 pb_update.index = (unsigned short)arg_index;
349 pb_update.phonebook_type = arg_type;
351 if(arg_name != NULL && strlen(arg_name)){
352 pb_update.dcs = PB_TEXT_ASCII;
353 pb_update.name_len = strlen(arg_name);
354 if(pb_update.name_len > PHONEBOOK_NAME_BYTE_MAX)
355 pb_update.name_len = PHONEBOOK_NAME_BYTE_MAX;
356 memcpy(pb_update.name, arg_name, pb_update.name_len);
358 if(arg_sne != NULL && strlen(arg_sne)){
359 pb_update.sne_dcs = PB_TEXT_ASCII;
360 pb_update.sne_len = strlen(arg_sne);
361 if(pb_update.sne_len > PHONEBOOK_NAME_BYTE_MAX)
362 pb_update.sne_len = PHONEBOOK_NAME_BYTE_MAX;
363 memcpy(pb_update.sne, arg_sne, pb_update.sne_len);
365 if(arg_number != NULL && (temp_len=strlen(arg_number))){
366 pb_update.ton = arg_ton;
367 if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX)
368 temp_len = PHONEBOOK_NUMBER_BYTE_MAX;
369 memcpy(pb_update.number, arg_number, temp_len);
371 if(arg_number2 != NULL && (temp_len=strlen(arg_number2))){
372 pb_update.anr1_ton = arg_number2_ton;
373 if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX)
374 temp_len = PHONEBOOK_NUMBER_BYTE_MAX;
375 memcpy(pb_update.anr1, arg_number2, temp_len);
378 if(arg_number3 != NULL && (temp_len=strlen(arg_number3))){
379 pb_update.anr2_ton = arg_number3_ton;
380 if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX)
381 temp_len = PHONEBOOK_NUMBER_BYTE_MAX;
382 memcpy(pb_update.anr2, arg_number3, temp_len);
385 if(arg_number4 != NULL && (temp_len=strlen(arg_number4))){
386 pb_update.anr3_ton = arg_number4_ton;
387 if(temp_len > PHONEBOOK_NUMBER_BYTE_MAX)
388 temp_len = PHONEBOOK_NUMBER_BYTE_MAX;
389 memcpy(pb_update.anr3, arg_number4, temp_len);
392 if(arg_email1 != NULL && strlen(arg_email1)){
393 pb_update.email1_len = strlen(arg_email1);
394 if(pb_update.email1_len > PHONEBOOK_EMAIL_BYTE_MAX)
395 pb_update.email1_len = PHONEBOOK_EMAIL_BYTE_MAX;
396 memcpy(pb_update.email1, arg_email1, pb_update.email1_len);
398 /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/
400 pb_update.group_index = (unsigned short)arg_group_index;
402 ur = MAKE_UR(ctx, phonebook, invocation);
403 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_update_record), &pb_update);
404 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_UPDATERECORD);
405 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
406 if(ret != TCORE_RETURN_SUCCESS) {
407 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
408 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
409 tcore_user_request_unref(ur);
415 static gboolean on_phonebook_delete_record(TelephonyPhonebook *phonebook, GDBusMethodInvocation *invocation,
416 gint arg_type, gint arg_index, gpointer user_data)
418 struct custom_data *ctx = user_data;
419 UserRequest *ur = NULL;
421 struct treq_phonebook_delete_record pb_delete;
422 TcorePlugin *plugin = NULL;
423 GSList *co_list = NULL;
424 CoreObject *co_pb = NULL;
425 gboolean pb_status = FALSE;
427 if (!check_access_control (invocation, AC_PHONEBOOK, "x"))
430 plugin = tcore_server_find_plugin(ctx->server, GET_CP_NAME(invocation));
431 co_list = tcore_plugin_get_core_objects_bytype(plugin, CORE_OBJECT_TYPE_PHONEBOOK);
433 dbg("error- co_list is NULL");
434 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
437 co_pb = (CoreObject *)co_list->data;
438 g_slist_free(co_list);
440 pb_status = tcore_phonebook_get_status(co_pb);
442 if(pb_status == FALSE) {
443 dbg("pb_init is not completed yet.");
444 telephony_phonebook_complete_delete_record(phonebook, invocation, PB_ACCESS_CONDITION_NOT_SATISFIED);
448 ur = MAKE_UR(ctx, phonebook, invocation);
449 memset(&pb_delete, 0, sizeof(struct treq_phonebook_delete_record));
451 pb_delete.index = (unsigned short)arg_index;
452 pb_delete.phonebook_type = arg_type;
453 dbg("req phonebook_type[%d][%s] index[%d]",
454 pb_delete.phonebook_type, dbg_dbus_pb_type_name[pb_delete.phonebook_type], pb_delete.index);
456 tcore_user_request_set_data(ur, sizeof(struct treq_phonebook_delete_record), &pb_delete);
457 tcore_user_request_set_command(ur, TREQ_PHONEBOOK_DELETERECORD);
458 ret = tcore_communicator_dispatch_request(ctx->comm, ur);
459 if(ret != TCORE_RETURN_SUCCESS) {
460 FAIL_RESPONSE (invocation, DEFAULT_MSG_REQ_FAILED);
461 dbg("[ error ] tcore_communicator_dispatch_request() : (0x%x)", ret);
462 tcore_user_request_unref(ur);
468 gboolean dbus_plugin_setup_phonebook_interface(TelephonyObjectSkeleton *object, struct custom_data *ctx)
470 TelephonyPhonebook *phonebook;
472 phonebook = telephony_phonebook_skeleton_new();
473 telephony_object_skeleton_set_phonebook(object, phonebook);
474 g_object_unref(phonebook);
476 dbg("phonebook = %p", phonebook);
478 g_signal_connect (phonebook,
479 "handle-get-init-status",
480 G_CALLBACK (on_phonebook_get_init_status),
483 g_signal_connect (phonebook,
485 G_CALLBACK (on_phonebook_get_count),
488 g_signal_connect (phonebook,
490 G_CALLBACK (on_phonebook_get_info),
493 g_signal_connect (phonebook,
494 "handle-get-usim-meta-info",
495 G_CALLBACK (on_phonebook_get_usim_info),
498 g_signal_connect (phonebook,
499 "handle-read-record",
500 G_CALLBACK (on_phonebook_read_record),
503 g_signal_connect (phonebook,
504 "handle-update-record",
505 G_CALLBACK (on_phonebook_update_record),
508 g_signal_connect (phonebook,
509 "handle-delete-record",
510 G_CALLBACK (on_phonebook_delete_record),
516 gboolean dbus_plugin_phonebook_response(struct custom_data *ctx, UserRequest *ur,
517 struct dbus_request_info *dbus_info, enum tcore_response_command command,
518 unsigned int data_len, const void *data)
520 const struct tresp_phonebook_get_count *resp_pbcnt = data;
521 const struct tresp_phonebook_get_info *resp_entry = data;
522 const struct tresp_phonebook_get_usim_info *resp_capa = data;
523 const struct tresp_phonebook_read_record *resp_pbread = data;
524 const struct tresp_phonebook_update_record *resp_pbupdate = data;
525 const struct tresp_phonebook_delete_record *resp_pbdelete = data;
528 case TRESP_PHONEBOOK_GETCOUNT:
529 dbg("GETCOUNT (type[%d][%s] used[%d]total[%d])",
530 resp_pbcnt->type, dbg_dbus_pb_type_name[resp_pbcnt->type],
531 resp_pbcnt->used_count, resp_pbcnt->total_count);
532 telephony_phonebook_complete_get_count(dbus_info->interface_object, dbus_info->invocation,
533 resp_pbcnt->result, resp_pbcnt->type, resp_pbcnt->used_count, resp_pbcnt->total_count);
536 case TRESP_PHONEBOOK_GETMETAINFO:
537 dbg("GETMETAINFO (type[%d][%s])", resp_entry->type, dbg_dbus_pb_type_name[resp_entry->type]);
538 dbg("index(min[%d]max[%d]), num_max[%d] text(max[%d]used[%d])",
539 resp_entry->index_min, resp_entry->index_max, resp_entry->number_length_max, resp_entry->text_length_max, resp_entry->used_count);
540 telephony_phonebook_complete_get_info(dbus_info->interface_object, dbus_info->invocation,
541 resp_entry->result, resp_entry->type, resp_entry->index_min, resp_entry->index_max,
542 resp_entry->number_length_max, resp_entry->text_length_max, resp_entry->used_count);
545 case TRESP_PHONEBOOK_GETUSIMINFO:{
550 g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}"));
552 for(i=0;i < resp_capa->field_count; i++){
553 g_variant_builder_open(&b,G_VARIANT_TYPE("a{sv}"));
554 dbg("type[%d][%s] index_max[%d] text_max[%d] used_count[%d]",
555 resp_capa->field_list[i].field,
556 dbg_dbus_pb_adf_field_name[resp_capa->field_list[i].field],
557 resp_capa->field_list[i].index_max,
558 resp_capa->field_list[i].text_max,
559 resp_capa->field_list[i].used_count);
560 g_variant_builder_add(&b, "{sv}", "field_type", g_variant_new_int32(resp_capa->field_list[i].field));
561 g_variant_builder_add(&b, "{sv}", "index_max", g_variant_new_int32(resp_capa->field_list[i].index_max));
562 g_variant_builder_add(&b, "{sv}", "text_max", g_variant_new_int32(resp_capa->field_list[i].text_max));
563 g_variant_builder_add(&b, "{sv}", "used_count", g_variant_new_int32(resp_capa->field_list[i].used_count));
564 g_variant_builder_close(&b);
566 gv = g_variant_builder_end(&b);
568 telephony_phonebook_complete_get_usim_meta_info (dbus_info->interface_object, dbus_info->invocation,
574 case TRESP_PHONEBOOK_READRECORD: {
575 unsigned char dest_pb_name[PHONEBOOK_NAME_BYTE_MAX + 1];
576 unsigned char dest_pb_sne[PHONEBOOK_NAME_BYTE_MAX + 1];
577 unsigned char dest_pb_email1[PHONEBOOK_EMAIL_BYTE_MAX + 1];
578 memset(dest_pb_name, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1);
579 memset(dest_pb_sne, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1);
580 memset(dest_pb_email1, 0x00, PHONEBOOK_EMAIL_BYTE_MAX + 1);
581 /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/
583 dbg("READRECORD (type[%d][%s] index[%d][%d])",
584 resp_pbread->phonebook_type, dbg_dbus_pb_type_name[resp_pbread->phonebook_type], resp_pbread->index,resp_pbread->next_index);
586 if (resp_pbread->name_len > 0) {
587 dbg("name:[%s] len:[%d]",resp_pbread->name, resp_pbread->name_len);
588 memcpy(dest_pb_name,resp_pbread->name,resp_pbread->name_len);
591 dbg("number:[%s] ton:[%d][%s])",
592 resp_pbread->number,resp_pbread->ton, dbg_dbus_pb_ton_name[resp_pbread->ton] );
594 if(resp_pbread->phonebook_type == PB_TYPE_USIM) {
595 if (resp_pbread->sne_len > 0) {
596 dbg("sne:[%s] sne_len:[%d]", resp_pbread->sne,resp_pbread->sne_len);
597 memcpy(dest_pb_sne,resp_pbread->sne,resp_pbread->sne_len);
600 if (strlen((const char*)resp_pbread->anr1) != 0 || strlen((const char*)resp_pbread->anr2) != 0 || strlen((const char*)resp_pbread->anr3) != 0) {
601 dbg("anr1:([%s],ton[%d][%s])",resp_pbread->anr1,resp_pbread->anr1_ton, dbg_dbus_pb_ton_name[resp_pbread->anr1_ton]);
602 dbg("anr2:([%s],ton[%d][%s])",resp_pbread->anr2,resp_pbread->anr2_ton, dbg_dbus_pb_ton_name[resp_pbread->anr2_ton]);
603 dbg("anr3:([%s],ton[%d][%s])",resp_pbread->anr3,resp_pbread->anr3_ton, dbg_dbus_pb_ton_name[resp_pbread->anr3_ton]);
605 if (resp_pbread->email1_len > 0) {
606 dbg("email1:[%s] len:[%d]",resp_pbread->email1, resp_pbread->email1_len);
607 memcpy(dest_pb_email1, resp_pbread->email1, resp_pbread->email1_len);
609 /* Additional e-mail fields (email 2,3,4) cannot be used to CP*/
613 * Check whether NAME, SNE string values are invalid utf-8 string or not,
614 * because if invalid it will be converted to "[INVALID UTF-8]" automatically by g_variant_new_string().
616 if (g_utf8_validate((const gchar *)dest_pb_name, -1, NULL) == FALSE) {
617 tcore_util_hex_dump("[INVALID_UTF8_NAME] ", strlen((const char*)dest_pb_name), dest_pb_name);
618 dbg("Empty NAME field.");
619 memset(dest_pb_name, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1);
621 if(resp_pbread->phonebook_type == PB_TYPE_USIM) {
622 if (g_utf8_validate((const gchar *)dest_pb_sne, -1, NULL) == FALSE) {
623 tcore_util_hex_dump("[INVALID_UTF8_SNE] ", strlen((const char*)dest_pb_sne), dest_pb_sne);
624 dbg("Empty SNE field.");
625 memset(dest_pb_sne, 0x00, PHONEBOOK_NAME_BYTE_MAX + 1);
629 telephony_phonebook_complete_read_record(dbus_info->interface_object, dbus_info->invocation,
630 resp_pbread->result, resp_pbread->phonebook_type, resp_pbread->index, resp_pbread->next_index,
631 (const gchar *)dest_pb_name, resp_pbread->dcs,
632 (const gchar *)resp_pbread->number, resp_pbread->ton,
633 (const gchar *)dest_pb_sne, resp_pbread->sne_dcs,
634 (const gchar *)resp_pbread->anr1, resp_pbread->anr1_ton,
635 (const gchar *)resp_pbread->anr2, resp_pbread->anr2_ton,
636 (const gchar *)resp_pbread->anr3, resp_pbread->anr3_ton,
637 (const gchar *)dest_pb_email1,
638 (const gchar *)resp_pbread->email2,
639 (const gchar *)resp_pbread->email3,
640 (const gchar *)resp_pbread->email4,
641 resp_pbread->group_index);
645 case TRESP_PHONEBOOK_UPDATERECORD:
646 dbg("UPDATERECORD (result[%d])", resp_pbupdate->result);
647 telephony_phonebook_complete_update_record(dbus_info->interface_object, dbus_info->invocation,resp_pbupdate->result);
650 case TRESP_PHONEBOOK_DELETERECORD:
651 dbg("DELETERECORD (result[%d])", resp_pbdelete->result);
652 telephony_phonebook_complete_delete_record(dbus_info->interface_object, dbus_info->invocation, resp_pbdelete->result);
656 dbg("not handled cmd[0x%x]", command);
663 gboolean dbus_plugin_phonebook_notification(struct custom_data *ctx, CoreObject *source,
664 TelephonyObjectSkeleton *object, enum tcore_notification_command command,
665 unsigned int data_len, const void *data)
667 TelephonyPhonebook *phonebook;
668 const struct tnoti_phonebook_status *n_pb_status = data;
671 cp_name = tcore_server_get_cp_name_by_plugin(tcore_object_ref_plugin(source));
673 phonebook = telephony_object_peek_phonebook(TELEPHONY_OBJECT(object));
675 case TNOTI_PHONEBOOK_STATUS :
677 #ifdef ENABLE_KPI_LOGS
678 if (n_pb_status->b_init == TRUE)
679 TIME_CHECK("[%s] PBM Service Ready", cp_name);
682 telephony_phonebook_emit_status(phonebook,
684 n_pb_status->support_list.b_fdn,
685 n_pb_status->support_list.b_adn,
686 n_pb_status->support_list.b_sdn,
687 n_pb_status->support_list.b_usim,
688 n_pb_status->support_list.b_aas,
689 n_pb_status->support_list.b_gas);
694 dbg("not handled cmd[0x%x]", command);