summaryrefslogtreecommitdiff
path: root/lib/common/ph-common.c
diff options
context:
space:
mode:
authoryunju06lee <yunju06.lee@samsung.com>2013-04-04 13:04:42 +0900
committeryunju06lee <yunju06.lee@samsung.com>2013-04-04 16:16:57 +0900
commit646d14a8ffeb9a88be70883e1cd20a9160a1a178 (patch)
tree61c47434fdeae30d91d021194731fa9a9752c352 /lib/common/ph-common.c
parent6488cc4fa4fec33a7bafa79c234ff2aa87588f0c (diff)
downloadphone-contacts-646d14a8ffeb9a88be70883e1cd20a9160a1a178.tar.gz
phone-contacts-646d14a8ffeb9a88be70883e1cd20a9160a1a178.tar.bz2
phone-contacts-646d14a8ffeb9a88be70883e1cd20a9160a1a178.zip
add tizen 2.1 appcontrol
Change-Id: I28b9063f4370d834e2a2e61603f9c83c68a3e69d
Diffstat (limited to 'lib/common/ph-common.c')
-rwxr-xr-xlib/common/ph-common.c164
1 files changed, 164 insertions, 0 deletions
diff --git a/lib/common/ph-common.c b/lib/common/ph-common.c
index 92d88f0..adbc85d 100755
--- a/lib/common/ph-common.c
+++ b/lib/common/ph-common.c
@@ -887,6 +887,91 @@ void phone_list_ug_return_ids(ui_gadget_h ug, int *result_list, int cnt, const c
service_destroy(service);
}
+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;
+ service_result_e result = SERVICE_RESULT_SUCCEEDED;
+
+ p_retm_if(result_list == NULL || cnt < 1 || result_type == NULL, "invalid input param");
+
+ service_create(&reply);
+ result_array = calloc(cnt, sizeof(char *));
+
+ if(strcmp(CT_OPERATION_RESULT_TYPE_PHONE, result_type) == 0) {
+ for (i = 0; i < cnt; i++) {
+ contacts_record_h number_record = NULL;
+ char *number = NULL;
+ ct_ret = contacts_db_get_record(_contacts_number._uri, result_list[i], &number_record);
+ if (ct_ret != CONTACTS_ERROR_NONE) {
+ ERR("contacts_db_get_record number failed id %d", result_list[i]);
+ continue;
+ }
+
+ contacts_record_get_str_p(number_record, _contacts_number.number, &number);
+ result_array[i] = strdup(number);
+ PH_DBG("number %s", result_array[i]);
+ contacts_record_destroy(number_record, TRUE);
+ }
+
+ service_add_extra_data_array(reply, CT_OPERATION_PHONE, result_array, i);
+ }
+ else if(strcmp(CT_OPERATION_RESULT_TYPE_EMAIL, result_type) == 0) {
+ for (i = 0; i < cnt; i++) {
+ contacts_record_h email_record = NULL;
+ char *email = NULL;
+ ct_ret = contacts_db_get_record(_contacts_email._uri, result_list[i], &email_record);
+ if (ct_ret != CONTACTS_ERROR_NONE) {
+ ERR("contacts_db_get_record email faile id %d", result_list[i]);
+ continue;
+ }
+
+ contacts_record_get_str_p(email_record, _contacts_email.email, &email);
+ result_array[i] = strdup(email);
+ PH_DBG("email %s", result_array[i]);
+ contacts_record_destroy(email_record, TRUE);
+ }
+
+ service_add_extra_data_array(reply, CT_OPERATION_EMAIL, result_array, i);
+
+ }
+ else if(strcmp(CT_OPERATION_RESULT_TYPE_ITEM_ID, result_type) == 0) {
+ for (i = 0; i < cnt; i++) {
+ char buf[4];
+ snprintf(buf, sizeof(buf), "%d", result_list[i]);
+ result_array[i] = strdup(buf);
+ PH_DBG("person id %s", result_array[i]);
+ }
+
+ service_add_extra_data_array(reply, CT_OPERATION_ITEM_ID, result_array, cnt);
+
+ }
+ else {
+ ERR("wrong result type %s", result_type);
+ result = SERVICE_RESULT_FAILED;
+ }
+
+ service_reply_to_launch_request(reply, service, result);
+ service_destroy(reply);
+
+ for (j = 0; j < i; j++) {
+ free(result_array[j]);
+ }
+ free(result_array);
+}
+
+void phone_service_reply_simple(service_h service, service_result_e result)
+{
+ service_h reply;
+ service_create(&reply);
+ service_reply_to_launch_request(reply, service, result);
+ service_destroy(reply);
+}
+
void phone_list_ug_return_number_email_ids(ui_gadget_h ug, int *result_number_list, int number_list_count, int *result_email_list, int email_list_count)
{
gchar *encoded_str;
@@ -946,6 +1031,85 @@ void phone_ug_return_id(ui_gadget_h ug, int ct_id, int num_id, int email_id)
service_destroy(service);
}
+void phone_ug_return_value(service_h service, int person_id, int num_id, int email_id)
+{
+ service_h reply;
+ char buf[16];
+ contacts_error_e err = CONTACTS_ERROR_NONE;
+ contacts_record_h number_record = NULL;
+ contacts_record_h email_record = NULL;
+
+ service_create(&reply);
+
+ if (person_id) {
+ snprintf(buf, sizeof(buf), "%d", person_id);
+ PH_DBG("person id %s", buf);
+ service_add_extra_data(reply, CT_OPERATION_RESULT_TYPE_ITEM_ID, buf);
+
+ service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
+
+ service_destroy(reply);
+ }
+
+ if (num_id) {
+ const char *number = NULL;
+ 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);
+
+ err = contacts_record_get_str_p(number_record, _contacts_number.number, (char**)&number);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err);
+
+ PH_DBG("number=%d", number);
+
+ service_add_extra_data(reply, CT_OPERATION_RESULT_TYPE_PHONE, number);
+
+ //ug_send_result(ug, service);
+ service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
+
+ err = contacts_record_destroy(number_record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
+
+ service_destroy(reply);
+ }
+
+ if (email_id) {
+ const char *email = NULL;
+ 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);
+
+ err = contacts_record_get_str_p(email_record, _contacts_email.email, (char**)&email);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_get_str_p() Failed(%d)", err);
+
+ PH_DBG("email=%d", email);
+
+ service_add_extra_data(reply, CT_OPERATION_RESULT_TYPE_EMAIL, email);
+
+ service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
+
+ err = contacts_record_destroy(email_record, true);
+ p_warn_if(CONTACTS_ERROR_NONE != err, "contacts_record_destroy() Failed(%d)", err);
+
+ service_destroy(reply);
+ }
+
+}
+
+void phone_ug_operation_return_vcard(service_h service, int ct_id, char *vcard)
+{
+ service_h reply;
+ char buf[16];
+
+ service_create(&reply);
+
+ if (vcard) {
+ service_add_extra_data(reply, CT_OPERATION_PATH, vcard);
+ }
+
+ service_reply_to_launch_request(reply, service, SERVICE_RESULT_SUCCEEDED);
+
+ service_destroy(reply);
+}
+
void phone_ug_return_vcard(ui_gadget_h ug, int ct_id, char *vcard)
{
service_h service;