2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file query-utility.c
19 * @author JihwaPark (82-32-3016262, jh7979.park@samsung.com)
20 * @version 1.0(2011.10.05)
21 * @brief This file serves utility for advanced query.
24 #include "query-service.h"
25 #include "query-type.h"
26 #include "query-utility.h"
30 #include <unicode/ucol.h>
31 #include <unicode/ustring.h>
33 static int transaction_count = 0;
34 static int db_connnect_count = 0;
42 gettimeofday(&tv, NULL);
43 curtime = tv.tv_sec * 1000000 + tv.tv_usec;
49 _print_time(clock_t begin, clock_t finish, const char* function_name)
51 double totaltime = 0.0;
52 totaltime=(double) (finish-begin)/CLOCKS_PER_SEC;
54 PERFORMANCE_TRACE("......................................................................... ");
55 PERFORMANCE_TRACE("TEST CASE [%s] ", function_name);
56 // PERFORMANCE_TRACE("start time [%ld us] ", begin);
57 // PERFORMANCE_TRACE("finish time [%ld us] ", finish);
58 PERFORMANCE_TRACE("total time [%f s] ", totaltime);
59 PERFORMANCE_TRACE("......................................................................... ");
62 query_error _contact_db_init()
65 query_error error_code = QUERY_SUCCESS;
70 rc = db_util_open(QUERY_DB_PATH, &g_hDBCt, 0);
72 error_code = QUERY_FAIL;
77 query_error _contact_db_finish()
80 query_error error_code = QUERY_SUCCESS;
83 if(db_connnect_count == 0)
85 rc = db_util_close(g_hDBCt);
87 error_code = QUERY_FAIL;
94 query_error _contact_exec_query(char* query)
97 char* pszErrorMsg = NULL;
98 query_error error_code = QUERY_SUCCESS;
100 ADVANCED_SVC_TRACE("query : %s", query);
102 rc = sqlite3_exec(g_hDBCt, query, NULL, NULL, &pszErrorMsg);
106 ADVANCED_SVC_TRACE("contact_util_query_exec failed(%d).\n", rc);
107 error_code = QUERY_FAIL;
111 sqlite3_free(pszErrorMsg);
116 query_error _trans_begin(void)
119 query_error error_code = QUERY_SUCCESS;
121 if(transaction_count == 0)
123 rc = _contact_exec_query("BEGIN IMMEDIATE TRANSACTION");
126 ADVANCED_SVC_TRACE("contact_util_query_exec failed(%d).\n", rc);
131 ADVANCED_SVC_TRACE("contact transaction_count : %d.\n", transaction_count);
136 query_error _trans_end(int is_success)
139 query_error error_code = QUERY_SUCCESS;
141 if(transaction_count == 1)
144 rc = _contact_exec_query("COMMIT TRANSACTION");
146 rc = _contact_exec_query("ROLLBACK TRANSACTION");
150 ADVANCED_SVC_TRACE("contact_util_query_exec failed(%d).\n", rc);
157 if(transaction_count < 0)
158 transaction_count = 0;
160 ADVANCED_SVC_TRACE("contact transaction_count : %d.\n", transaction_count);
166 int _contact_query_step(stmt pStmt)
168 return sqlite3_step(pStmt);
171 void _ct_query_finalize(stmt pStmt)
178 rc = sqlite3_finalize(pStmt);
184 int _ct_query_column_int(stmt pStmt, int pos)
186 return (int)sqlite3_column_int(pStmt, pos);
189 char* _ct_query_column_text(stmt pStmt, int pos)
191 return (char *)sqlite3_column_text(pStmt, pos);
194 int _contact_query_bind_double(stmt pStmt, int pos, double num)
196 return sqlite3_bind_double(pStmt, pos, num);
199 int _contact_query_bind_int(stmt pStmt, int pos, int num)
201 return sqlite3_bind_int(pStmt, pos, num);
204 int _contact_query_bind_text(stmt pStmt, int pos, char* str)
210 return sqlite3_bind_text(pStmt, pos, (const char*)str, len, SQLITE_STATIC);
215 void _contact_query_stmt_reset(stmt stmt)
218 sqlite3_clear_bindings(stmt);
221 double _contact_query_column_double(stmt pStmt, int pos)
223 return sqlite3_column_double(pStmt, pos);
226 stmt _contact_query_prepare(char *query)
231 ADVANCED_SVC_TRACE("query : %s !!!!\n", query);
232 // printf("\nquery : %s !!!!\n", query);
234 rc = sqlite3_prepare_v2(g_hDBCt, query, strlen(query), &pStmt, NULL);
237 ADVANCED_SVC_TRACE("rc : %d", rc);
244 int _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute)
246 int is_person_attr = 0;
260 ADVANCED_SVC_TRACE("is_person_attr : %d", is_person_attr);
262 return is_person_attr;
265 predefine_datatype _convert_attribute_to_mimetype_id(contact_attribute_e attribute)
267 predefine_datatype data_type = DATATYPE_INVALID;
276 data_type = DATATYPE_NAME;
279 data_type = DATATYPE_NICK_NAME;
283 data_type = DATATYPE_NUMBER;
287 data_type = DATATYPE_EMAIL;
291 data_type = DATATYPE_URL;
295 data_type = DATATYPE_ANNIVERSARY;
298 case ANNIVERSARY_LABEL:
299 data_type = DATATYPE_ANNIVERSARY;
301 case CONTACT_LATITUDE:
302 case CONTACT_LONGITUDE:
303 data_type = DATATYPE_LBS_INFO;
306 case ADDRESS_COUNTRY:
308 // case ADDRESS_COUNTY:
311 case ADDRESS_POSTAL_CODE:
312 case ADDRESS_ADDITIONAL:
314 data_type = DATATYPE_ADDRESS;
317 data_type = DATATYPE_CATEGORY;
319 case ORGANIZATION_NAME:
320 case ORGANIZATION_DEPARTMENT:
321 // case ORGANIZATION_OFFICE:
322 case ORGANIZATION_TITLE:
323 case ORGANIZATION_ROLE:
324 // case ORGANIZATION_LOGO_URI:
325 data_type = DATATYPE_ORGANIZATION;
327 case CONTACT_IS_FAVORITE:
328 case CONTACT_RINGTONE:
330 // case CONTACT_READ_ONLY:
331 // case CONTACT_SEND_TO_VOICE_MAIL:
332 case CONTACT_LAST_UPDATED_TIME_STAMP:
340 ADVANCED_SVC_TRACE("data_type : %d", data_type);
345 char* _convert_person_attribute_to_condition_column_name(contact_attribute_e attribute)
347 char* field_name = NULL;
352 field_name = condition_field_key[FIELD_PERSON_CONTACT_ID];
354 case CONTACT_IS_FAVORITE :
355 field_name = condition_field_key[FIELD_PERSON_IS_FAVORITE];
357 case CONTACT_RINGTONE :
358 field_name = condition_field_key[FIELD_PERSON_RINGTONE];
360 case CONTACT_PHOTO_URI :
361 field_name = condition_field_key[FIELD_PERSON_PHOTO_URI];
363 // case CONTACT_SEND_TO_VOICE_MAIL :
364 // field_name = condition_field_key[FIELD_PERSON_SEND_TO_VOICEMAIL];
367 field_name = condition_field_key[FIELD_PERSON_FIRST_NAME];
370 field_name = condition_field_key[FIELD_PERSON_MIDDLE_NAME];
373 field_name = condition_field_key[FIELD_PERSON_LAST_NAME];
376 field_name = condition_field_key[FIELD_PERSON_PREFIX_NAME];
379 field_name = condition_field_key[FIELD_PERSON_PHONETIC_NAME];
382 field_name = condition_field_key[FIELD_PERSON_DISPLAY_NAME];
390 char* _convert_person_attribute_to_column_name(contact_attribute_e attribute)
392 char* field_name = NULL;
397 field_name = field_key[FIELD_PERSON_CONTACT_ID];
399 case CONTACT_IS_FAVORITE :
400 field_name = field_key[FIELD_PERSON_IS_FAVORITE];
402 case CONTACT_RINGTONE :
403 field_name = field_key[FIELD_PERSON_RINGTONE];
405 case CONTACT_PHOTO_URI :
406 field_name = field_key[FIELD_PERSON_PHOTO_URI];
408 // case CONTACT_SEND_TO_VOICE_MAIL :
409 // field_name = field_key[FIELD_PERSON_SEND_TO_VOICEMAIL];
412 field_name = field_key[FIELD_PERSON_FIRST_NAME];
415 field_name = field_key[FIELD_PERSON_MIDDLE_NAME];
418 field_name = field_key[FIELD_PERSON_LAST_NAME];
421 field_name = field_key[FIELD_PERSON_PREFIX_NAME];
424 field_name = field_key[FIELD_PERSON_PHONETIC_NAME];
427 field_name = field_key[FIELD_PERSON_DISPLAY_NAME];
435 char* _convert_attribute_to_condition_normalize_column(contact_attribute_e attribute)
437 char* field_name = NULL;
442 field_name = condition_field_key[FIELD_DATA8];
450 char* _convert_attribute_to_normalize_column(contact_attribute_e attribute)
452 char* field_name = NULL;
457 field_name = field_key[FIELD_DATA8];
465 char* _convert_attribute_to_condition_column_name(contact_attribute_e attribute)
467 char* field_name = NULL;
471 case CONTACT_RINGTONE :
472 field_name = condition_field_key[FIELD_RINGTONE];
475 field_name = condition_field_key[FIELD_NOTE];
478 field_name = condition_field_key[FIELD_DATA_CONTACT_ID];
481 field_name = condition_field_key[FIELD_UID];
484 field_name = condition_field_key[FIELD_CONTACT_ACCOUNT_ID];
486 case CONTACT_IS_FAVORITE :
487 field_name = condition_field_key[FIELD_IS_FAVORITE];
489 case CONTACT_PHOTO_URI :
490 field_name = condition_field_key[FIELD_PHOTO_URI];
492 case CONTACT_LAST_UPDATED_TIME_STAMP :
493 field_name = condition_field_key[FIELD_CHANGED_TIME];
495 // case CONTACT_READ_ONLY :
496 // field_name = condition_field_key[FIELD_DATA_CONTACT_ID];
498 // case CONTACT_SEND_TO_VOICE_MAIL :
499 // field_name = condition_field_key[FIELD_DATA_CONTACT_ID];
501 // case CONTACT_LATITUDE :
502 // field_name = condition_field_key[FIELD_DATA1];
504 // case CONTACT_LONGITUDE :
505 // field_name = condition_field_key[FIELD_DATA2];
508 field_name = condition_field_key[FIELD_DATA2];
511 field_name = condition_field_key[FIELD_DATA3];
514 field_name = condition_field_key[FIELD_DATA4];
517 field_name = condition_field_key[FIELD_DATA5];
520 field_name = condition_field_key[FIELD_DATA6];
523 field_name = condition_field_key[FIELD_DATA7];
526 field_name = condition_field_key[FIELD_DATA2];
529 field_name = condition_field_key[FIELD_DATA2];
532 field_name = condition_field_key[FIELD_DATA1];
535 field_name = condition_field_key[FIELD_DATA2];
538 field_name = condition_field_key[FIELD_DATA1];
541 field_name = condition_field_key[FIELD_DATA2];
544 field_name = condition_field_key[FIELD_DATA1];
546 case ADDRESS_COUNTRY:
547 field_name = condition_field_key[FIELD_DATA8];
550 field_name = condition_field_key[FIELD_DATA4];
552 // case ADDRESS_COUNTY:
553 // field_name = condition_field_key[FIELD_DATA5];
556 field_name = condition_field_key[FIELD_DATA5];
559 field_name = condition_field_key[FIELD_DATA6];
561 case ADDRESS_POSTAL_CODE:
562 field_name = condition_field_key[FIELD_DATA3];
564 case ADDRESS_ADDITIONAL:
565 field_name = condition_field_key[FIELD_DATA7];
568 field_name = condition_field_key[FIELD_DATA1];
570 // case CATEGORY_INFO:
571 // field_name = condition_field_key[FIELD_DATA1];
574 field_name = condition_field_key[FIELD_DATA1];
577 field_name = condition_field_key[FIELD_DATA2];
579 // case ANNIVERSARY_LABEL:
580 // field_name = condition_field_key[FIELD_DATA2];
582 case ORGANIZATION_NAME:
583 field_name = condition_field_key[FIELD_DATA2];
585 case ORGANIZATION_DEPARTMENT:
586 field_name = condition_field_key[FIELD_DATA3];
588 // case ORGANIZATION_OFFICE:
589 // field_name = condition_field_key[FIELD_DATA3];
591 case ORGANIZATION_TITLE:
592 field_name = condition_field_key[FIELD_DATA4];
594 case ORGANIZATION_ROLE:
595 field_name = condition_field_key[FIELD_DATA5];
597 // case ORGANIZATION_LOGO_URI:
598 // field_name = condition_field_key[FIELD_DATA6];
603 ADVANCED_SVC_TRACE("field_name : %s", field_name);
608 primitive_type _convert_check_attribute_primitive_type(contact_attribute_e attribute)
610 primitive_type type = INTEGER;
616 // case CONTACT_READ_ONLY :
617 // case CONTACT_SEND_TO_VOICE_MAIL :
618 case CONTACT_LAST_UPDATED_TIME_STAMP :
619 case CONTACT_IS_FAVORITE :
627 // case CONTACT_LATITUDE :
628 // case CONTACT_LONGITUDE :
632 case CONTACT_RINGTONE :
634 case CONTACT_PHOTO_URI :
645 case ADDRESS_COUNTRY:
647 // case ADDRESS_COUNTY:
650 case ADDRESS_POSTAL_CODE:
651 case ADDRESS_ADDITIONAL:
652 // case CATEGORY_INFO:
654 // case ANNIVERSARY_LABEL:
655 case ORGANIZATION_NAME:
656 case ORGANIZATION_DEPARTMENT:
657 // case ORGANIZATION_OFFICE:
658 case ORGANIZATION_TITLE:
659 case ORGANIZATION_ROLE:
660 // case ORGANIZATION_LOGO_URI:
666 ADVANCED_SVC_TRACE("primitive type : %d", type);
671 char* _convert_x_attribute_to_condition_column_name(contact_x_attribute_e attribute)
673 char* field_name = NULL;
678 field_name = condition_x_field_key[FIELD_X_DATA1];
681 field_name = condition_x_field_key[FIELD_X_DATA2];
684 field_name = condition_x_field_key[FIELD_X_DATA3];
687 field_name = condition_x_field_key[FIELD_X_DATA4];
690 field_name = condition_x_field_key[FIELD_X_DATA5];
693 field_name = condition_x_field_key[FIELD_X_DATA6];
696 field_name = condition_x_field_key[FIELD_X_DATA7];
699 field_name = condition_x_field_key[FIELD_X_DATA8];
702 field_name = condition_x_field_key[FIELD_X_DATA9];
705 field_name = condition_x_field_key[FIELD_X_DATA10];
710 ADVANCED_SVC_TRACE("field_name : %s", field_name);
715 char* _convert_attribute_to_column_name(contact_attribute_e attribute)
717 char* field_name = NULL;
721 case CONTACT_RINGTONE :
722 field_name = field_key[FIELD_RINGTONE];
725 field_name = field_key[FIELD_NOTE];
728 field_name = field_key[FIELD_UID];
731 field_name = field_key[FIELD_DATA_CONTACT_ID];
734 field_name = field_key[FIELD_CONTACT_ACCOUNT_ID];
736 case CONTACT_IS_FAVORITE :
737 field_name = field_key[FIELD_IS_FAVORITE];
739 case CONTACT_PHOTO_URI :
740 field_name = field_key[FIELD_PHOTO_URI];
742 case CONTACT_LAST_UPDATED_TIME_STAMP :
743 field_name = field_key[FIELD_CHANGED_TIME];
745 // case CONTACT_READ_ONLY :
746 // field_name = field_key[FIELD_DATA_CONTACT_ID];
748 // case CONTACT_SEND_TO_VOICE_MAIL :
749 // field_name = field_key[FIELD_DATA_CONTACT_ID];
752 case CONTACT_LATITUDE :
753 field_name = field_key[FIELD_DATA1];
755 case CONTACT_LONGITUDE :
756 field_name = field_key[FIELD_DATA2];
760 field_name = field_key[FIELD_DATA2];
763 field_name = field_key[FIELD_DATA3];
766 field_name = field_key[FIELD_DATA4];
769 field_name = field_key[FIELD_DATA5];
772 field_name = field_key[FIELD_DATA6];
775 field_name = field_key[FIELD_DATA7];
778 field_name = field_key[FIELD_DATA2];
781 field_name = field_key[FIELD_DATA2];
784 field_name = field_key[FIELD_DATA1];
787 field_name = field_key[FIELD_DATA1];
790 field_name = field_key[FIELD_DATA2];
793 field_name = field_key[FIELD_DATA1];
796 field_name = field_key[FIELD_DATA2];
798 case ADDRESS_COUNTRY:
799 field_name = field_key[FIELD_DATA8];
802 field_name = field_key[FIELD_DATA4];
804 // case ADDRESS_COUNTY:
805 // field_name = field_key[FIELD_DATA5];
808 field_name = field_key[FIELD_DATA5];
811 field_name = field_key[FIELD_DATA6];
813 case ADDRESS_POSTAL_CODE:
814 field_name = field_key[FIELD_DATA3];
816 case ADDRESS_ADDITIONAL:
817 field_name = field_key[FIELD_DATA7];
820 field_name = field_key[FIELD_DATA1];
822 // case CATEGORY_INFO:
823 // field_name = field_key[FIELD_DATA1];
826 field_name = field_key[FIELD_DATA1];
829 field_name = field_key[FIELD_DATA2];
831 // case ANNIVERSARY_LABEL:
832 // field_name = field_key[FIELD_DATA2];
834 case ORGANIZATION_NAME:
835 field_name = field_key[FIELD_DATA2];
837 case ORGANIZATION_DEPARTMENT:
838 field_name = field_key[FIELD_DATA3];
840 // case ORGANIZATION_OFFICE:
841 // field_name = field_key[FIELD_DATA3];
843 case ORGANIZATION_TITLE:
844 field_name = field_key[FIELD_DATA4];
846 case ORGANIZATION_ROLE:
847 field_name = field_key[FIELD_DATA5];
849 // case ORGANIZATION_LOGO_URI:
850 // field_name = field_key[FIELD_DATA6];
855 // ADVANCED_SVC_TRACE("field_name : %s", field_name);
860 char* _convert_x_attribute_to_column_name(contact_x_attribute_e attribute)
862 char* field_name = NULL;
867 field_name = x_field_key[FIELD_X_DATA1];
870 field_name = x_field_key[FIELD_X_DATA2];
873 field_name = x_field_key[FIELD_X_DATA3];
876 field_name = x_field_key[FIELD_X_DATA4];
879 field_name = x_field_key[FIELD_X_DATA5];
882 field_name = x_field_key[FIELD_X_DATA6];
885 field_name = x_field_key[FIELD_X_DATA7];
888 field_name = x_field_key[FIELD_X_DATA8];
891 field_name = x_field_key[FIELD_X_DATA9];
894 field_name = x_field_key[FIELD_X_DATA10];
899 ADVANCED_SVC_TRACE("field_name : %s", field_name);
904 tables_e _contact_table_name_to_table_type(char* table_name)
906 tables_e table_type = INVALID_TABLE;
908 if(strcmp(table_name, table_key[TABLE_CONTACT]) == 0)
909 table_type = CONTACT_TABLE;
910 else if(strcmp(table_name, table_key[TABLE_DATA]) == 0)
911 table_type = DATA_TABLE;
912 else if(strcmp(table_name, table_key[TABLE_PERSON]) == 0)
913 table_type = PERSON_TABLE;
918 char* _convert_person_attribute_to_table_name(contact_attribute_e attribute)
920 char* table_name = NULL;
923 case CONTACT_PHOTO_URI:
924 // case CONTACT_READ_ONLY:
925 // case CONTACT_SEND_TO_VOICE_MAIL:
926 case CONTACT_LAST_UPDATED_TIME_STAMP:
927 case CONTACT_IS_FAVORITE:
928 case CONTACT_RINGTONE :
937 table_name = table_key[TABLE_PERSON];
944 ADVANCED_SVC_TRACE("table_name : %s", table_name);
949 char* _convert_attribute_to_table_name(contact_attribute_e attribute)
951 char* table_name = NULL;
954 case CONTACT_PHOTO_URI:
955 // case CONTACT_READ_ONLY:
956 // case CONTACT_SEND_TO_VOICE_MAIL:
957 case CONTACT_LAST_UPDATED_TIME_STAMP:
958 case CONTACT_IS_FAVORITE:
959 case CONTACT_RINGTONE :
964 table_name = table_key[TABLE_CONTACT];
968 // case CONTACT_LATITUDE:
969 // case CONTACT_LONGITUDE:
983 case ADDRESS_COUNTRY:
985 // case ADDRESS_COUNTY:
988 case ADDRESS_POSTAL_CODE:
989 case ADDRESS_ADDITIONAL:
991 // case CATEGORY_INFO:
994 // case ANNIVERSARY_LABEL:
995 case ORGANIZATION_NAME:
996 case ORGANIZATION_DEPARTMENT:
997 // case ORGANIZATION_OFFICE:
998 case ORGANIZATION_TITLE:
999 case ORGANIZATION_ROLE:
1000 // case ORGANIZATION_LOGO_URI:
1002 table_name = table_key[TABLE_DATA];
1009 // ADVANCED_SVC_TRACE("table_name : %s", table_name);
1013 char* _convert_x_attribute_to_table_name(contact_x_attribute_e attribute)
1015 char* table_name = NULL;
1016 table_name = table_key[TABLE_DATA];
1021 char* _convert_condition_type_to_string(condition_type_e type)
1023 char* string = NULL;
1029 string = condition_type_key[0];
1034 string = condition_type_key[1];
1039 string = condition_type_key[2];
1044 string = condition_type_key[3];
1051 ADVANCED_SVC_TRACE("condition type string : %s", string);
1056 void _query_get_count(const char* table_name, query_type_e query_type, int* count)
1058 char query[128] = {0, };
1064 memset(query, 0x00, sizeof(query));
1068 case QUERY_TO_PERSON:
1069 snprintf(query, sizeof(query) - 1, "select count(%s) from %s", field_key[FIELD_PERSON_CONTACT_ID], table_name);
1071 case QUERY_TO_CONTACT:
1073 if(strcmp(table_key[TABLE_PRESENCE], table_name) == 0)
1074 snprintf(query, sizeof(query) - 1, "select count(%s) from %s", field_key[FIELD_PRESENCE_CONTACT_ID], table_name);
1075 else if(strcmp(table_key[TABLE_CONTACT], table_name) == 0)
1076 snprintf(query, sizeof(query) - 1, "select count(%s) from %s", field_key[FIELD_CONTACT_CONTACT_ID], table_name);
1077 else if(strcmp(table_key[TABLE_GROUP_RELATION], table_name) == 0)
1078 snprintf(query, sizeof(query) - 1, "select count(%s) from %s", relation_field_key[FIELD_GROUP_RELATION_CONTACT_ID], table_name);
1084 ADVANCED_SVC_TRACE("query : %s", query);
1086 rc = sqlite3_prepare_v2(g_hDBCt, query, strlen(query), &pStmt, NULL);
1088 rc = sqlite3_step(pStmt);
1089 if(SQLITE_ROW == rc)
1090 *count = sqlite3_column_int(pStmt, 0);
1094 ADVANCED_SVC_TRACE("*count : %d", *count);
1096 sqlite3_finalize(pStmt);
1099 void __free_datatype_list(gpointer data, gpointer user_data)
1101 ADVANCED_SVC_TRACE("__free_datatype_list");
1102 // ADVANCED_SVC_TRACE("datatype : %d", ((datatype_t*)data)->datatype);
1103 OBJ_FREE(((datatype_t*)data)->field);
1107 void __free_condition_list(gpointer data, gpointer user_data)
1109 ADVANCED_SVC_TRACE("__free_condition_list");
1110 // ADVANCED_SVC_TRACE("field : %s", ((datatype_t*)data)->field);
1111 OBJ_FREE(((condition_list_t*)data)->column_name);
1112 OBJ_FREE(((condition_list_t*)data)->condition);
1116 void __free_condition_table_list(gpointer data, gpointer user_data)
1118 ADVANCED_SVC_TRACE("__free_condition_table_list");
1119 // ADVANCED_SVC_TRACE("field : %s", ((datatype_t*)data)->field);
1120 OBJ_FREE(((condition_table_t*)data)->table);
1124 void __free_projection_list(gpointer data, gpointer user_data)
1126 ADVANCED_SVC_TRACE("__free_projection_list");
1127 // ADVANCED_SVC_TRACE("field : %s", ((datatype_t*)data)->field);
1128 OBJ_FREE(((projection_t*)data)->field);
1132 void __free_condition_value_list(gpointer data, gpointer user_data)
1134 ADVANCED_SVC_TRACE("__free_condition_value_list");
1135 // ADVANCED_SVC_TRACE("field : %s", ((condition_val_t*)data)->value);
1136 OBJ_FREE(((condition_val_t*)data)->value);
1140 void __free_email_list(gpointer data, gpointer user_data)
1142 ADVANCED_SVC_TRACE("__free_email_list");
1143 OBJ_FREE(((email_t*)data)->email_addr);
1144 OBJ_FREE(((email_t*)data)->email_type);
1145 OBJ_FREE(((email_t*)data)->email_label);
1149 void __free_number_list(gpointer data, gpointer user_data)
1151 ADVANCED_SVC_TRACE("__free_email_list");
1152 OBJ_FREE(((number_t*)data)->number);
1153 OBJ_FREE(((number_t*)data)->number_type);
1154 OBJ_FREE(((number_t*)data)->number_label);
1158 void __free_url_list(gpointer data, gpointer user_data)
1160 ADVANCED_SVC_TRACE("__free_url_list");
1161 OBJ_FREE(((url_t*)data)->url_addr);
1162 OBJ_FREE(((url_t*)data)->url_type);
1163 OBJ_FREE(((url_t*)data)->url_label);
1167 void __free_nickname_list(gpointer data, gpointer user_data)
1169 ADVANCED_SVC_TRACE("__free_nickname_list");
1170 OBJ_FREE(((nick_name_t*)data)->nick_name);
1174 void __free_address_list(gpointer data, gpointer user_data)
1176 ADVANCED_SVC_TRACE("__free_address_list");
1177 OBJ_FREE(((address_t*)data)->country);
1178 OBJ_FREE(((address_t*)data)->region);
1179 OBJ_FREE(((address_t*)data)->county);
1180 OBJ_FREE(((address_t*)data)->city);
1181 OBJ_FREE(((address_t*)data)->street);
1182 OBJ_FREE(((address_t*)data)->postal_code);
1183 OBJ_FREE(((address_t*)data)->addtional);
1184 OBJ_FREE(((address_t*)data)->type);
1188 void __free_organization_list(gpointer data, gpointer user_data)
1192 ADVANCED_SVC_TRACE("__free_organization_list");
1193 OBJ_FREE(((organization_t*)data)->organization_name);
1194 OBJ_FREE(((organization_t*)data)->department);
1195 OBJ_FREE(((organization_t*)data)->office);
1196 OBJ_FREE(((organization_t*)data)->title);
1197 OBJ_FREE(((organization_t*)data)->role);
1198 OBJ_FREE(((organization_t*)data)->logo_uri);
1202 void __free_anniversary_list(gpointer data, gpointer user_data)
1204 ADVANCED_SVC_TRACE("__free_anniversary_list");
1205 OBJ_FREE(((event_info_t*)data)->date);
1206 OBJ_FREE(((event_info_t*)data)->label);
1210 void __free_category_list(gpointer data, gpointer user_data)
1212 ADVANCED_SVC_TRACE("__free_category_list");
1213 OBJ_FREE(((category_t*)data)->category);
1217 void __free_x_list(gpointer data, gpointer user_data)
1219 ADVANCED_SVC_TRACE("__free_x_list");
1220 OBJ_FREE(((x_info_t*)data)->data2);
1221 OBJ_FREE(((x_info_t*)data)->data3);
1222 OBJ_FREE(((x_info_t*)data)->data4);
1223 OBJ_FREE(((x_info_t*)data)->data5);
1224 OBJ_FREE(((x_info_t*)data)->data6);
1225 OBJ_FREE(((x_info_t*)data)->data7);
1226 OBJ_FREE(((x_info_t*)data)->data8);
1227 OBJ_FREE(((x_info_t*)data)->data9);
1228 OBJ_FREE(((x_info_t*)data)->data10);
1232 void _free_x_info(x_info_t* x_info)
1237 OBJ_FREE(x_info->data2);
1238 OBJ_FREE(x_info->data3);
1239 OBJ_FREE(x_info->data4);
1240 OBJ_FREE(x_info->data5);
1241 OBJ_FREE(x_info->data6);
1242 OBJ_FREE(x_info->data7);
1243 OBJ_FREE(x_info->data8);
1244 OBJ_FREE(x_info->data9);
1245 OBJ_FREE(x_info->data10);
1249 void _free_category_info(categories_info* category_info)
1251 if(category_info == NULL)
1254 OBJ_FREE(category_info->name);
1255 OBJ_FREE(category_info);
1258 void _free_name_info(name_t* name_info)
1260 if(name_info == NULL)
1263 OBJ_FREE(name_info->first_name);
1264 OBJ_FREE(name_info->middle_name);
1265 OBJ_FREE(name_info->last_name);
1266 OBJ_FREE(name_info->prefix);
1267 OBJ_FREE(name_info->phonetic_name);
1268 OBJ_FREE(name_info->display_name);
1269 OBJ_FREE(name_info);
1272 void _free_raw_contact_info(raw_contact_t* raw_contact_info)
1274 if(raw_contact_info == NULL)
1277 OBJ_FREE(raw_contact_info->contact_id);
1278 OBJ_FREE(raw_contact_info->ringtone);
1279 OBJ_FREE(raw_contact_info->note);
1280 OBJ_FREE(raw_contact_info->is_favorite);
1281 OBJ_FREE(raw_contact_info->photo_uri);
1282 OBJ_FREE(raw_contact_info->birth_day);
1283 OBJ_FREE(raw_contact_info->last_updated_time_stamp);
1284 OBJ_FREE(raw_contact_info->read_only);
1285 OBJ_FREE(raw_contact_info->send_to_voice_mail);
1286 OBJ_FREE(raw_contact_info->latitude);
1287 OBJ_FREE(raw_contact_info->longitude);
1288 OBJ_FREE(raw_contact_info->account_id);
1289 OBJ_FREE(raw_contact_info->uid);
1290 OBJ_FREE(raw_contact_info);
1293 void _free_person_contact_info(person_contact_t* person_info)
1295 if(person_info == NULL)
1298 OBJ_FREE(person_info->contact_id);
1299 OBJ_FREE(person_info->is_self);
1300 OBJ_FREE(person_info->contact_id_for_name);
1301 OBJ_FREE(person_info->contact_id_for_photo);
1302 OBJ_FREE(person_info->contactid_for_ringtone);
1303 OBJ_FREE(person_info->prefix);
1304 OBJ_FREE(person_info->first_name);
1305 OBJ_FREE(person_info->middle_name);
1306 OBJ_FREE(person_info->last_name);
1307 OBJ_FREE(person_info->phonetic_name);
1308 OBJ_FREE(person_info->display_name);
1309 OBJ_FREE(person_info->photo_URI);
1310 OBJ_FREE(person_info->last_updated_timestamp);
1311 OBJ_FREE(person_info->is_favorite);
1312 OBJ_FREE(person_info->send_to_voicemail);
1313 OBJ_FREE(person_info->ringtone);
1314 OBJ_FREE(person_info);
1317 void _free_num_info(number_t* num_info)
1319 if(num_info == NULL)
1322 OBJ_FREE(num_info->number);
1323 OBJ_FREE(num_info->number_type);
1324 OBJ_FREE(num_info->number_label);
1328 void _free_email_info(email_t* email_info)
1330 if(email_info == NULL)
1333 OBJ_FREE(email_info->email_addr);
1334 OBJ_FREE(email_info->email_type);
1335 OBJ_FREE(email_info->email_label);
1336 OBJ_FREE(email_info);
1339 void _free_url_info(url_t* url_info)
1341 if(url_info == NULL)
1344 OBJ_FREE(url_info->url_addr);
1345 OBJ_FREE(url_info->url_type);
1346 OBJ_FREE(url_info->url_label);
1350 void _free_nick_info(nick_name_t* nick_info)
1352 if(nick_info == NULL)
1355 OBJ_FREE(nick_info->nick_name);
1356 OBJ_FREE(nick_info);
1359 void _free_anniversary_info(event_info_t* event_info)
1361 if(event_info == NULL)
1364 OBJ_FREE(event_info->date);
1365 OBJ_FREE(event_info->label);
1366 OBJ_FREE(event_info);
1369 void _free_organization_info(organization_t* organization_info)
1371 if(organization_info == NULL)
1374 OBJ_FREE(organization_info->organization_name);
1375 OBJ_FREE(organization_info->department);
1376 OBJ_FREE(organization_info->office);
1377 OBJ_FREE(organization_info->title);
1378 OBJ_FREE(organization_info->role);
1379 OBJ_FREE(organization_info->logo_uri);
1380 OBJ_FREE(organization_info);
1383 void _free_address_info(address_t* address_info)
1385 if(address_info == NULL)
1388 OBJ_FREE(address_info->country);
1389 OBJ_FREE(address_info->region);
1390 OBJ_FREE(address_info->county);
1391 OBJ_FREE(address_info->city);
1392 OBJ_FREE(address_info->street);
1393 OBJ_FREE(address_info->postal_code);
1394 OBJ_FREE(address_info->addtional);
1395 OBJ_FREE(address_info->type);
1396 OBJ_FREE(address_info);
1399 void _free_projection_list(gpointer data, gpointer user_data)
1401 // ADVANCED_SVC_TRACE("__free_projection_list");
1402 // ADVANCED_SVC_TRACE("field : %s", ((projection_t*)data)->field);
1403 OBJ_FREE(((projection_t*)data)->field);
1407 db_datatype _convert_datatype_to_db_type(predefine_datatype datatype)
1409 db_datatype db_datatype_id = DB_DATATYPE_INVALID;
1414 db_datatype_id = DB_DATATYPE_NAME;
1416 case DATATYPE_NUMBER:
1417 db_datatype_id = DB_DATATYPE_NUMBER;
1419 case DATATYPE_EMAIL:
1420 db_datatype_id = DB_DATATYPE_EMAIL;
1423 db_datatype_id = DB_DATATYPE_URL;
1425 case DATATYPE_NICK_NAME:
1426 db_datatype_id = DB_DATATYPE_NICK_NAME;
1428 case DATATYPE_ADDRESS:
1429 db_datatype_id = DB_DATATYPE_ADDRESS;
1431 case DATATYPE_ORGANIZATION:
1432 db_datatype_id = DB_DATATYPE_ORGANIZATION;
1434 case DATATYPE_BIRTH_DAY:
1435 db_datatype_id = DB_DATATYPE_EVENT;
1437 case DATATYPE_ANNIVERSARY:
1438 db_datatype_id = DB_DATATYPE_EVENT;
1441 case DATATYPE_LBS_INFO:
1442 db_datatype_id = DB_DATATYPE_LBS_INFO;
1444 case DATATYPE_CATEGORY:
1445 db_datatype_id = DB_DATATYPE_CATEGORY;
1452 return db_datatype_id;
1455 query_error _set_person_datatype_list(advanced_handle_t* q_handle, contact_attribute_e attribute)
1457 query_error error_code = QUERY_SUCCESS;
1459 predefine_datatype datatype = DATATYPE_INVALID;
1460 datatype_t* datatype_info = NULL;
1462 datatype = _convert_attribute_to_mimetype_id(attribute);
1463 ADVANCED_CATCH_SET_ERROR(((q_handle->assigned_datatype & datatype) == DATATYPE_INVALID), {}, QUERY_SUCCESS, ("DUPLICATED DATATYPE"));
1465 datatype_info = g_new0(datatype_t, 1);
1466 ADVANCED_CATCH_SET_ERROR((datatype_info != NULL), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
1467 datatype_info->field = g_strdup(field_key[FIELD_DATA_DATATYPE_ID]);
1469 datatype_info->datatype = _convert_datatype_to_db_type(datatype);
1470 q_handle->datatype_list = g_list_append(q_handle->datatype_list, datatype_info);
1471 q_handle->assigned_datatype = (q_handle->assigned_datatype | datatype);
1472 q_handle->all_datatype_in_query = (q_handle->all_datatype_in_query | datatype);
1474 ADVANCED_SVC_TRACE("q_handle->assigned_datatype : %d", q_handle->assigned_datatype);
1480 query_error _set_datatype_list(advanced_handle_t* q_handle, contact_attribute_e attribute)
1482 query_error error_code = QUERY_SUCCESS;
1484 predefine_datatype datatype = DATATYPE_INVALID;
1485 datatype_t* datatype_info = NULL;
1487 datatype = _convert_attribute_to_mimetype_id(attribute);
1488 ADVANCED_CATCH_SET_ERROR((datatype != DATATYPE_INVALID), {}, QUERY_INVALID_ATTRIBUTE, ("INVALID ATTRIBUTE"));
1489 ADVANCED_CATCH_SET_ERROR(((q_handle->assigned_datatype & datatype) == DATATYPE_INVALID), {}, QUERY_SUCCESS, ("DUPLICATED DATATYPE"));
1491 datatype_info = g_new0(datatype_t, 1);
1492 ADVANCED_CATCH_SET_ERROR((datatype_info != NULL), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
1493 datatype_info->field = g_strdup(field_key[FIELD_DATA_DATATYPE_ID]);
1495 datatype_info->datatype = _convert_datatype_to_db_type(datatype);
1496 q_handle->datatype_list = g_list_append(q_handle->datatype_list, datatype_info);
1497 q_handle->assigned_datatype = (q_handle->assigned_datatype | datatype);
1498 q_handle->all_datatype_in_query = (q_handle->all_datatype_in_query | datatype);
1500 // ADVANCED_SVC_TRACE("q_handle->assigned_datatype : %d", q_handle->assigned_datatype);
1506 query_error _set_datatype_list_by_x_attribute(advanced_handle_t* q_handle, int datatype_id, contact_x_attribute_e attribute)
1508 query_error error_code = QUERY_SUCCESS;
1509 datatype_t* datatype_info = NULL;
1511 GList* tmp_list = q_handle->datatype_list;
1514 datatype_t* tmp_info = (datatype_t*)tmp_list->data;
1515 ADVANCED_CATCH_SET_ERROR((tmp_info->datatype != datatype_id), {}, QUERY_SUCCESS, ("DUPLICATED DATATYPE"));
1516 tmp_list = g_list_next(tmp_list);
1519 datatype_info = g_new0(datatype_t, 1);
1520 ADVANCED_CATCH_SET_ERROR((datatype_info != NULL), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
1521 datatype_info->field = g_strdup(field_key[FIELD_DATA_DATATYPE_ID]);
1523 datatype_info->datatype = datatype_id;
1524 q_handle->datatype_list = g_list_append(q_handle->datatype_list, datatype_info);
1525 q_handle->assigned_datatype = (q_handle->assigned_datatype | DATATYPE_X_ATTRIBUTE);
1526 q_handle->all_datatype_in_query = (q_handle->all_datatype_in_query | DATATYPE_X_ATTRIBUTE);
1528 ADVANCED_SVC_TRACE("q_handle->assigned_datatype : %d", q_handle->assigned_datatype);
1534 char* _convert_condition_to_string(condition_e condition)
1536 char* condition_val = NULL;
1542 condition_val = condition_key[EQUAL];
1547 condition_val = condition_key[NOT_EQUAL];
1552 condition_val = condition_key[GREATER_THAN];
1557 condition_val = condition_key[LESS_THAN];
1560 case GREATER_THAN_OR_EQUAL:
1562 condition_val = condition_key[GREATER_THAN_OR_EQUAL];
1565 case LESS_THAN_OR_EQUAL:
1567 condition_val = condition_key[LESS_THAN_OR_EQUAL];
1572 condition_val = condition_key[BITWISE_AND];
1577 condition_val = condition_key[BITWISE_OR];
1582 condition_val = condition_key[LIKE];
1588 ADVANCED_SVC_TRACE("condition_val : %s", condition_val);
1590 return condition_val;
1593 void _free_handle_info(advanced_handle_t* handle)
1597 ADVANCED_SVC_TRACE("HANDLE IS ALREAD FREE");
1604 g_list_foreach(handle->datatype_list, __free_datatype_list, NULL);
1605 g_list_foreach(handle->new_projection, __free_projection_list, NULL);
1606 g_list_foreach(handle->condition_value, __free_condition_value_list, NULL);
1607 g_list_foreach(handle->condition_list, __free_condition_list, NULL);
1608 g_list_foreach(handle->condition_table_list, __free_condition_table_list, NULL);
1610 g_list_free(handle->datatype_list);
1611 g_list_free(handle->new_projection);
1612 g_list_free(handle->condition_value);
1613 g_list_free(handle->condition_list);
1614 g_list_free(handle->condition_table_list);
1617 g_string_free (handle->table_list, TRUE);
1618 g_string_free (handle->condition_text, TRUE);
1619 g_string_free (handle->use_normal_field_key, TRUE);
1620 g_string_free (handle->use_contact_table_id, TRUE);
1621 g_string_free (handle->order, TRUE);
1622 g_string_free (handle->id_list, TRUE);
1625 for(i = 0; i < handle->total_result_set_count; i++)
1627 g_list_foreach(handle->result_set[i].contact_info->number_list, __free_number_list, NULL);
1628 g_list_foreach(handle->result_set[i].contact_info->email_list, __free_email_list, NULL);
1630 g_list_foreach(handle->result_set[i].contact_info->url_list, __free_url_list, NULL);
1631 g_list_foreach(handle->result_set[i].contact_info->nickname_list, __free_nickname_list, NULL);
1632 g_list_foreach(handle->result_set[i].contact_info->address_list, __free_address_list, NULL);
1633 g_list_foreach(handle->result_set[i].contact_info->organization_list, __free_organization_list, NULL);
1634 g_list_foreach(handle->result_set[i].contact_info->event_list, __free_anniversary_list, NULL);
1635 g_list_foreach(handle->result_set[i].contact_info->category_list, __free_category_list, NULL);
1636 g_list_foreach(handle->result_set[i].contact_info->x_list, __free_x_list, NULL);
1638 g_list_free(handle->result_set[i].contact_info->url_list);
1639 g_list_free(handle->result_set[i].contact_info->nickname_list);
1640 g_list_free(handle->result_set[i].contact_info->address_list);
1641 g_list_free(handle->result_set[i].contact_info->organization_list);
1642 g_list_free(handle->result_set[i].contact_info->event_list);
1643 g_list_free(handle->result_set[i].contact_info->category_list);
1644 g_list_free(handle->result_set[i].contact_info->x_list);
1646 _free_person_contact_info(handle->result_set[i].contact_info->person_info);
1647 _free_raw_contact_info(handle->result_set[i].contact_info->raw_contact_info);
1649 _free_name_info(handle->result_set[i].contact_info->name_info);
1650 _free_num_info(handle->result_set[i].contact_info->num_info);
1651 _free_email_info(handle->result_set[i].contact_info->email_info);
1652 _free_url_info(handle->result_set[i].contact_info->url_info);
1653 _free_nick_info(handle->result_set[i].contact_info->nick_info);
1654 _free_address_info(handle->result_set[i].contact_info->address_info);
1655 _free_organization_info(handle->result_set[i].contact_info->organization_info);
1656 _free_anniversary_info(handle->result_set[i].contact_info->event_info);
1657 _free_x_info(handle->result_set[i].contact_info->x_info);
1659 OBJ_FREE(handle->result_set[i].contact_info);
1662 OBJ_FREE(handle->result_set);
1664 for(i = 0; i < handle->total_result_set_count; i++)
1666 OBJ_FREE(handle->mapping_id_to_result_set);
1669 for(i = 0; i < handle->total_result_set_count; i++)
1671 OBJ_FREE(handle->ordering_list);
1674 _free_category_info(handle->category);
1676 OBJ_FREE(handle->query_string);
1677 OBJ_FREE(handle->ordering_list);
1678 OBJ_FREE(handle->full_ordered_contact_id);
1679 OBJ_FREE(handle->condition_category);
1680 OBJ_FREE(handle->condition_category_op);
1684 int _free_for_limit_iter(advanced_handle_t* handle)
1688 char* contact_id = NULL;
1691 for(i = 0; i < handle->total_result_set_count; i++)
1693 if(handle->result_set[i].contact_info->raw_contact_info)
1695 contact_id = handle->result_set[i].contact_info->raw_contact_info->contact_id;
1696 char *value = contact_id;
1697 char *end_ptr = value;
1699 id = (int)strtol(value, &end_ptr, 0);
1700 if(errno == ERANGE || end_ptr == value)
1702 ADVANCED_SVC_TRACE("contact_id is wrong : %s", contact_id);
1705 ADVANCED_SVC_TRACE("id : %d", id);
1708 if(handle->result_set[i].contact_info->person_info)
1710 contact_id = handle->result_set[i].contact_info->person_info->contact_id;
1711 if(handle->result_set[i].contact_info->person_info->contact_id)
1713 char *value = contact_id;
1714 char *end_ptr = value;
1716 id = (int)strtol(value, &end_ptr, 0);
1717 if(errno == ERANGE || end_ptr == value)
1719 ADVANCED_SVC_TRACE("contact_id is wrong : %s", contact_id);
1722 ADVANCED_SVC_TRACE("id : %d", id);
1726 g_list_foreach(handle->result_set[i].contact_info->number_list, __free_number_list, NULL);
1727 g_list_foreach(handle->result_set[i].contact_info->email_list, __free_email_list, NULL);
1729 g_list_foreach(handle->result_set[i].contact_info->url_list, __free_url_list, NULL);
1730 g_list_foreach(handle->result_set[i].contact_info->nickname_list, __free_nickname_list, NULL);
1731 g_list_foreach(handle->result_set[i].contact_info->address_list, __free_address_list, NULL);
1732 g_list_foreach(handle->result_set[i].contact_info->organization_list, __free_organization_list, NULL);
1733 g_list_foreach(handle->result_set[i].contact_info->event_list, __free_anniversary_list, NULL);
1734 g_list_foreach(handle->result_set[i].contact_info->category_list, __free_category_list, NULL);
1736 _free_person_contact_info(handle->result_set[i].contact_info->person_info);
1737 _free_raw_contact_info(handle->result_set[i].contact_info->raw_contact_info);
1739 _free_name_info(handle->result_set[i].contact_info->name_info);
1740 _free_num_info(handle->result_set[i].contact_info->num_info);
1741 _free_email_info(handle->result_set[i].contact_info->email_info);
1742 _free_url_info(handle->result_set[i].contact_info->url_info);
1743 _free_nick_info(handle->result_set[i].contact_info->nick_info);
1744 _free_address_info(handle->result_set[i].contact_info->address_info);
1745 _free_organization_info(handle->result_set[i].contact_info->organization_info);
1746 _free_anniversary_info(handle->result_set[i].contact_info->event_info);
1748 OBJ_FREE(handle->result_set[i].contact_info);
1750 OBJ_FREE(handle->result_set);
1752 for(i = 0; i < handle->total_result_set_count; i++)
1753 OBJ_FREE(handle->mapping_id_to_result_set);
1755 for(i = 0; i < handle->total_result_set_count; i++)
1756 OBJ_FREE(handle->ordering_list);
1761 query_error _normalize_str(const char* src, char* dest, int dest_size)
1763 query_error error_code = QUERY_SUCCESS;
1766 UErrorCode status = 0;
1767 UChar* tmp_result = NULL;
1768 UChar* result = NULL;
1770 tmp_result = g_new0(UChar, (dest_size + 1));
1771 result = g_new0(UChar, (dest_size + 1));
1773 u_strFromUTF8(tmp_result, dest_size, NULL, src, -1, &status);
1774 ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strFromUTF8 FAIL(%s)", u_errorName(status)));
1776 u_strToLower(tmp_result, dest_size, tmp_result, -1, NULL, &status);
1777 ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strToLower FAIL(%s)", u_errorName(status)));
1779 ADVANCED_SVC_TRACE("src : %s", src);
1781 size = unorm_normalize(tmp_result, -1, UNORM_NFD, 0, (UChar *)result, dest_size, &status);
1782 ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("unorm_normalize FAIL(%s)", u_errorName(status)));
1784 u_strToUTF8(dest, dest_size, &size, result, -1, &status);
1785 ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strToUTF8 FAIL(%s)", u_errorName(status)));
1787 ADVANCED_SVC_TRACE("dest : %s", (char *)dest);
1796 query_error _remove_invalid_chars(char *src, char* desc)
1798 ADVANCED_RETURN_VAL((src != NULL), {}, QUERY_NULL_PARAMETER, ("SOURCE STRING IS NULL"));
1799 ADVANCED_SVC_TRACE("%s", src);
1804 query_error error_code = QUERY_SUCCESS;
1808 for(i = 0; i < nSrc; ++i)
1833 ADVANCED_SVC_TRACE("%s", desc);
1838 int _convert_type_string_to_int(contact_attribute_e attribute, const char* value)
1840 int integer_value = 0;
1849 char *end_ptr = value;
1851 integer_value = (int)strtol(value, &end_ptr, 0);
1852 if(errno == ERANGE || end_ptr == value)
1854 ADVANCED_SVC_TRACE("contact_id is wrong : %s", contact_id);
1857 ADVANCED_SVC_TRACE("id : %d", id);
1860 case CONTACT_LAST_UPDATED_TIME_STAMP :
1862 char *end_ptr = value;
1864 integer_value = (int)strtol(value, &end_ptr, 0);
1865 if(errno == ERANGE || end_ptr == value)
1867 ADVANCED_SVC_TRACE("contact_id is wrong : %s", contact_id);
1872 // case CONTACT_READ_ONLY :
1873 // case CONTACT_SEND_TO_VOICE_MAIL :
1874 case CONTACT_IS_FAVORITE :
1876 if(strcmp(value, "TRUE") == 0)
1878 else if(strcmp(value, "FALSE") == 0)
1884 for(i = 1; i <= MAX_NUMBER_TYPE; i++)
1886 loc = strstr(value, number_type_str[i]);
1892 integer_value = (integer_value | HOME);
1895 integer_value = (integer_value | WORK);
1898 integer_value = (integer_value | VOICE);
1901 integer_value = (integer_value | FAX);
1904 integer_value = (integer_value | MSG);
1907 integer_value = (integer_value | CELL);
1910 integer_value = (integer_value | PAGER);
1913 integer_value = (integer_value | BBS);
1916 integer_value = (integer_value | MODEM);
1919 integer_value = (integer_value | CAR);
1922 integer_value = (integer_value | ISDN);
1925 integer_value = (integer_value | VIDEO);
1928 integer_value = (integer_value | PCS);
1939 for(i = 1; i <= MAX_EMAIL_TYPE; i++)
1941 loc = strstr(value, email_type_str[i]);
1947 integer_value = (integer_value | EMAIL_HOME);
1950 integer_value = (integer_value | EMAIL_WORK);
1961 for(i = 1; i < URL_TYPE_MAX; i++)
1963 if(strcmp(url_type_str[i], value) == 0)
1965 integer_value = URL_HOME;
1969 integer_value = URL_WORK;
1977 for(i = 1; i <= MAX_ADDRESS_TYPE; i++)
1979 loc = strstr(value, addr_type_str[i]);
1985 integer_value = (integer_value | ADDRESS_TYPE_HOME);
1988 integer_value = (integer_value | ADDRESS_TYPE_WORK);
1991 integer_value = (integer_value | ADDRESS_TYPE_DOM);
1994 integer_value = (integer_value | ADDRESS_TYPE_INTL);
1997 integer_value = (integer_value | ADDRESS_TYPE_POSTAL);
2000 integer_value = (integer_value | ADDRESS_TYPE_PARCEL);
2011 for(i = 0; i < EVENT_TYPE_MAX; i++)
2013 if(strcmp(event_type_str[i], value) == 0)
2015 integer_value = EVENT_BIRTHDAY;
2019 integer_value = EVENT_ANNIVERSARY;
2028 // ADVANCED_SVC_TRACE("integer_value : %d", integer_value);
2030 return (int)integer_value;
2033 int _is_type_bitwise_int(contact_attribute_e attribute)
2046 // ADVANCED_SVC_TRACE("integer_value : %d", integer_value);