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.
19 * @author JihwaPark (82-32-3016262, jh7979.park@samsung.com)
20 * @version 1.0(2010.10.05)
21 * @brief This file has internal structure and logging APIs
28 #define LOG_TAG "QUERY_SVC"
35 #include <glib-object.h>
38 #include <sys/types.h>
44 #include "query-service.h"
47 #define PROJECTION_FIELD_LEN 64
51 #endif /* __cplusplus */
53 //#define ADVANCED_USE_DLOG_MESSAGE
54 //#define CHECK_PERFORMANCE
56 #ifdef ADVANCED_USE_DLOG_MESSAGE
57 #define ADVANCED_SVC_TRACE(fmt, arg...) \
58 SLOGD("\n[QUERY_SVC]%s %d: " fmt "", __FUNCTION__, __LINE__, ##arg);
60 #define ADVANCED_SVC_TRACE(fmt, arg...) \
61 // fprintf(stderr, "\n[QUERY_SVC]%s %d: " fmt "", __FUNCTION__, __LINE__, ##arg);
64 #ifdef CHECK_PERFORMANCE
65 #define PERFORMANCE_TRACE(fmt, arg...) \
66 fprintf(stderr, "\n[QUERY_SVC]%s %d: " fmt "", __FUNCTION__, __LINE__, ##arg);
68 #define PERFORMANCE_TRACE(fmt, arg...)
71 #define ADVANCED_SVC_ERROR_TRACE(fmt, arg...) \
72 fprintf(stderr, "\n[AdvancedSvc]%s %d: " fmt "", __FUNCTION__, __LINE__, ##arg);
74 #define ADVANCED_RETURN_VAL(eval, expr, ret_val, X)\
78 {ADVANCED_SVC_TRACE X;}\
82 #define ADVANCED_CATCH_SET_ERROR(eval, expr, error_val, X) \
86 error_code = (error_val);\
87 {ADVANCED_SVC_TRACE X;}\
91 #define ADVANCED_CATCH_SET_ERROR_POINTER(eval, expr, error_val, X) \
95 *error_code = (error_val);\
96 {ADVANCED_SVC_TRACE X;}\
100 #define OBJ_FREE(obj) if(obj != NULL) { free(obj); \
103 /****************************************************************************************************/
104 /* GLOBAL STRUCTURE DECLARATION */
105 /****************************************************************************************************/
106 #define _TABLE_SQLITE_SEQ "sqlite_sequence" // auto generated table
107 #define QUERY_MAX_LEN 2048
108 #define MAX_NUMBER_TYPE 14
109 #define MAX_EMAIL_TYPE 3
110 #define MAX_ADDRESS_TYPE 7
114 EXTRA_INFO_TYPE_FIELD = 0,
115 EXTRA_INFO_TYPE_CONDITION,
152 DATATYPE_INVALID = 0x00000000,
153 DATATYPE_NAME = 0x00000001,
154 DATATYPE_NUMBER = 0x00000002,
155 DATATYPE_EMAIL = 0x00000004,
156 DATATYPE_URL = 0x00000008,
157 DATATYPE_NICK_NAME = 0x00000010,
158 DATATYPE_ADDRESS = 0x00000020,
159 DATATYPE_ORGANIZATION = 0x00000040,
160 DATATYPE_BIRTH_DAY = 0x00000080,
161 DATATYPE_ANNIVERSARY = 0x0000100,
162 DATATYPE_IM_ADDR = 0x0000200,
163 // DATATYPE_LBS_INFO = 0x00000400,
164 DATATYPE_CATEGORY = 0x00000800,
165 DATATYPE_X_ATTRIBUTE = 0x80000000,
170 DB_DATATYPE_INVALID = 0,
176 DB_DATATYPE_ORGANIZATION,
177 DB_DATATYPE_NICK_NAME,
181 // DB_DATATYPE_LBS_INFO,
182 // DB_DATATYPE_CATEGORY,
183 DB_DATATYPE_MAX = 100,
204 static char* number_type_str[MAX_NUMBER_TYPE] =
224 EMAIL_TYPE_NONE = 0x00000000,
225 EMAIL_HOME = 0x00000001,
226 EMAIL_WORK = 0x00000002,
229 static char* email_type_str[MAX_EMAIL_TYPE] =
244 static char* url_type_str[URL_TYPE_MAX] =
258 static char* event_type_str[EVENT_TYPE_MAX] =
266 ADDRESS_TYPE_NONE = 0x00000000,
267 ADDRESS_TYPE_HOME = 0x00000001,
268 ADDRESS_TYPE_WORK = 0x00000002,
269 ADDRESS_TYPE_DOM = 0x00000004,
270 ADDRESS_TYPE_INTL = 0x00000008,
271 ADDRESS_TYPE_POSTAL = 0x00000010,
272 ADDRESS_TYPE_PARCEL = 0x00000020,
275 static char* addr_type_str[MAX_ADDRESS_TYPE] =
286 static char* is_favorite_str[2] =
295 ONLY_CONTACT_ID_FIELD,
300 INVALID_TABLE_LIST = 0,
306 ONLY_DATA_FROM_PERSON_QUERY,
307 // JOIN_PERSON_CONTACT_DATA,
312 INVALID_TABLE = 0x00000000,
313 PERSON_TABLE = 0x00000001,
314 CONTACT_TABLE = 0x00000002,
315 DATA_TABLE = 0x00000004,
322 char* contact_id_for_name;
323 char* contact_id_for_photo;
324 char* contactid_for_ringtone;
332 char* last_updated_timestamp;
334 char* send_to_voicemail;
346 char* last_updated_time_stamp;
348 char* send_to_voice_mail;
374 char* number_label; // not use
381 char* email_label; // not use
388 char* url_label; // not use
405 char* organization_name;
442 person_contact_t* person_info;
443 raw_contact_t* raw_contact_info;
446 GList* nickname_list;
451 GList* organization_list;
453 GList* category_list;
456 nick_name_t* nick_info;
460 address_t* address_info;
461 organization_t* organization_info;
462 event_info_t* event_info;
466 int get_raw_contact_info;
473 contact_t* contact_info;
478 db_datatype datatype;
499 contact_attribute_e attribute;
515 alias_key_e current_alias;
518 db_datatype datatype;
524 }condition_category_t;
537 INVALID_FIELDS = 0x00000000,
538 CATEGORIES = 0x00000001
541 typedef sqlite3_stmt* stmt;
551 query_type_e query_type;
555 int pos; //array index of ordering list
556 int is_optimized_query;
559 predefine_datatype assigned_datatype;
560 GList* datatype_list;
563 GList* new_projection; //use making result set
566 tables_e query_table;
567 target_table_e join_table;
571 result_t* result_set;
573 mapping_list_t* mapping_id_to_result_set;
575 extra_contact_info extra_info;
576 categories_info* category;
577 int category_total_count;
580 int attribute_list[ATTRIBUTE_MAX];
581 int x_attribute_list[X_DATA_MAX];
583 // especially for query to person
587 GString* condition_text;
588 GString* use_normal_field_key;
589 GString* use_contact_table_id;
590 GList* condition_value;
591 alias_key_e current_alias;
592 predefine_datatype condition_datatype;
593 int optimize_condition;
594 GList* condition_list;
595 GList* condition_table_list;
596 char* condition_category;
597 char* condition_category_op;
599 extra_contact_info condition_extra_info;
602 ordering_list_t* ordering_list;
604 contact_attribute_e order_field;
606 mapping_list_t* full_ordered_contact_id;
615 int total_result_set_count;
616 int return_array_pos;
617 predefine_datatype current_datatype;
620 predefine_datatype all_datatype_in_query;
623 fetching_state x_fetching;
627 int is_first_id_in_list;
632 #endif /* __cplusplus */
634 #endif // _QUERY_TYPE_H