summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryunju06lee <yunju06.lee@samsung.com>2013-04-16 11:45:27 (GMT)
committeryunju06lee <yunju06.lee@samsung.com>2013-04-16 11:45:27 (GMT)
commit09bf78bd0e6a0c974465772ea855110989decd52 (patch)
treefe150e47bb5a4d6d2d571c8693dbb8a99f6726e3
parent6ab11b77d38d9b3cd509e42b4d17706168f38f6b (diff)
downloadphone-contacts-09bf78bd0e6a0c974465772ea855110989decd52.zip
phone-contacts-09bf78bd0e6a0c974465772ea855110989decd52.tar.gz
phone-contacts-09bf78bd0e6a0c974465772ea855110989decd52.tar.bz2
change appcontrol return type as array
Change-Id: Idc5097bb75948e35800a9a15c1b127e00c1098a5
-rwxr-xr-xlib/common/ph-common.c44
1 files changed, 34 insertions, 10 deletions
diff --git a/lib/common/ph-common.c b/lib/common/ph-common.c
index 317a306..fc5ba6c 100755
--- a/lib/common/ph-common.c
+++ b/lib/common/ph-common.c
@@ -889,9 +889,7 @@ void phone_list_ug_return_ids(ui_gadget_h ug, int *result_list, int cnt, const c
void phone_list_ug_return_values(service_h service, int *result_list, int cnt, const char *result_type)
{
- gchar *encoded_str = NULL;
service_h reply;
- Eina_List *list = NULL;
int ct_ret;
int i = 0, j = 0;
char **result_array = NULL;
@@ -918,7 +916,7 @@ void phone_list_ug_return_values(service_h service, int *result_list, int cnt, c
contacts_record_destroy(number_record, TRUE);
}
- service_add_extra_data_array(reply, CT_OPERATION_PHONE, result_array, i);
+ service_add_extra_data_array(reply, CT_OPERATION_PHONE, (const char **)result_array, cnt);
}
else if(strcmp(CT_OPERATION_RESULT_TYPE_EMAIL, result_type) == 0) {
for (i = 0; i < cnt; i++) {
@@ -936,7 +934,7 @@ void phone_list_ug_return_values(service_h service, int *result_list, int cnt, c
contacts_record_destroy(email_record, TRUE);
}
- service_add_extra_data_array(reply, CT_OPERATION_EMAIL, result_array, i);
+ service_add_extra_data_array(reply, CT_OPERATION_EMAIL, (const char **)result_array, cnt);
}
else if(strcmp(CT_OPERATION_RESULT_TYPE_ITEM_ID, result_type) == 0) {
@@ -947,7 +945,7 @@ void phone_list_ug_return_values(service_h service, int *result_list, int cnt, c
PH_DBG("person id %s", result_array[i]);
}
- service_add_extra_data_array(reply, CT_OPERATION_ITEM_ID, result_array, cnt);
+ service_add_extra_data_array(reply, CT_OPERATION_ITEM_ID, (const char **)result_array, cnt);
}
else {
@@ -1042,17 +1040,28 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
service_create(&reply);
if (person_id) {
+ char **result_array = NULL;
+ result_array = calloc(1, sizeof(char *));
+
snprintf(buf, sizeof(buf), "%d", person_id);
PH_DBG("person id %s", buf);
- service_add_extra_data(reply, CT_OPERATION_ITEM_ID, buf);
+
+ result_array[0] = strdup(buf);
+ service_add_extra_data_array(reply, CT_OPERATION_ITEM_ID, (const char **)result_array, 1);
service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
service_destroy(reply);
+
+ free(result_array[0]);
+ free(result_array);
}
if (num_id) {
const char *number = NULL;
+ char **result_array = NULL;
+ result_array = calloc(1, sizeof(char *));
+
err = contacts_db_get_record(_contacts_number._uri, num_id, &number_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err);
@@ -1061,7 +1070,8 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
PH_DBG("number=%d", number);
- service_add_extra_data(reply, CT_OPERATION_RESULT_TYPE_PHONE, number);
+ result_array[0] = strdup(number);
+ service_add_extra_data_array(reply, CT_OPERATION_RESULT_TYPE_PHONE, (const char **)result_array, 1);
service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
@@ -1069,10 +1079,16 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
service_destroy(reply);
+
+ free(result_array[0]);
+ free(result_array);
}
if (email_id) {
const char *email = NULL;
+ char **result_array = NULL;
+ result_array = calloc(1, sizeof(char *));
+
err = contacts_db_get_record(_contacts_email._uri, email_id, &email_record);
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_db_get_record() Failed(%d)", err);
@@ -1081,7 +1097,8 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
PH_DBG("email=%d", email);
- service_add_extra_data(reply, CT_OPERATION_RESULT_TYPE_EMAIL, email);
+ result_array[0] = strdup(email);
+ service_add_extra_data_array(reply, CT_OPERATION_RESULT_TYPE_EMAIL, (const char **)result_array, 1);
service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
@@ -1089,6 +1106,9 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
service_destroy(reply);
+
+ free(result_array[0]);
+ free(result_array);
}
}
@@ -1096,17 +1116,21 @@ void phone_ug_return_value(service_h service, int person_id, int num_id, int ema
void phone_ug_operation_return_vcard(service_h service, int ct_id, char *vcard)
{
service_h reply;
- char buf[16];
+ char **result_array = NULL;
+ result_array = calloc(1, sizeof(char *));
service_create(&reply);
if (vcard) {
- service_add_extra_data(reply, CT_OPERATION_PATH, vcard);
+ result_array[0] = vcard;
+ service_add_extra_data_array(reply, CT_OPERATION_PATH, (const char **)result_array, 1);
}
service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
service_destroy(reply);
+
+ free(result_array);
}
void phone_ug_return_vcard(ui_gadget_h ug, int ct_id, char *vcard)