[SVACE Issue Fixes]
[platform/core/pim/contacts-service.git] / server / db / ctsvc_db_query.h
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19 #ifndef __CTSVC_DB_QUERY_H__
20 #define __CTSVC_DB_QUERY_H__
21
22 #include "contacts.h"
23 #include "contacts_db_status.h"
24 #include "ctsvc_struct.h"
25 #include "ctsvc_db_sqlite.h"
26
27 int ctsvc_db_insert_record(contacts_record_h record, int *id);
28 int ctsvc_db_get_record(const char *view_uri, int id, contacts_record_h *out_record);
29 int ctsvc_db_update_record(contacts_record_h record);
30 int ctsvc_db_delete_record(const char *view_uri, int id);
31 int ctsvc_db_replace_record(contacts_record_h record, int id);
32 int ctsvc_db_get_all_records(const char *view_uri, int offset, int limit,
33                 contacts_list_h *out_list);
34 int ctsvc_db_get_records_with_query(contacts_query_h query, int offset, int limit,
35                 contacts_list_h *out_list);
36 int ctsvc_db_get_count(const char *view_uri, int *out_count);
37 int ctsvc_db_get_count_with_query(contacts_query_h query, int *out_count);
38 int ctsvc_db_get_changes_by_version(const char *view_uri, int addressbook_id,
39                 int version, contacts_list_h *out_list, int *out_current_version);
40 int ctsvc_db_get_current_version(int *out_current_version);
41 int ctsvc_db_search_records(const char *view_uri, const char *keyword, int offset,
42                 int limit, contacts_list_h *out_list);
43 int ctsvc_db_search_records_with_range(const char *view_uri, const char *keyword,
44                 int offset, int limit, int range, contacts_list_h *out_list);
45 int ctsvc_db_search_records_with_query(contacts_query_h query, const char *keyword,
46                 int offset, int limit, contacts_list_h *out_list);
47 int ctsvc_db_search_records_for_snippet(const char *view_uri,
48                 const char *keyword,
49                 int offset,
50                 int limit,
51                 const char *start_match,
52                 const char *end_match,
53                 int token_number,
54                 contacts_list_h *out_list);
55 int ctsvc_db_search_records_with_range_for_snippet(const char *view_uri,
56                 const char *keyword,
57                 int offset,
58                 int limit,
59                 int range,
60                 const char *start_match,
61                 const char *end_match,
62                 int token_number,
63                 contacts_list_h *out_list);
64 int ctsvc_db_search_records_with_query_for_snippet(contacts_query_h query,
65                 const char *keyword,
66                 int offset,
67                 int limit,
68                 const char *start_match,
69                 const char *end_match,
70                 int token_number,
71                 contacts_list_h *out_list);
72 int ctsvc_db_get_status(contacts_db_status_e *status);
73 int ctsvc_db_insert_records_with_vcard(const char *vcard_stream, int **record_id_array,
74                 int *count);
75 int ctsvc_db_replace_records_with_vcard(const char *vcard_stream, int *record_id_array,
76                 int count);
77
78
79 int ctsvc_db_insert_records(contacts_list_h list, int **ids, int *count);
80 int ctsvc_db_update_records(contacts_list_h list);
81 int ctsvc_db_delete_records(const char *view_uri, int *ids, int count);
82 int ctsvc_db_replace_records(contacts_list_h list, int ids[], int count);
83
84 int ctsvc_db_make_get_records_query_stmt(ctsvc_query_s *s_query, int offset, int limit,
85                 cts_stmt *stmt);
86 int ctsvc_db_create_set_query(contacts_record_h record, char **set, GSList **bind_text);
87 int ctsvc_db_update_record_with_set_query(const char *set, GSList *bind_text,
88                 const char *table, int id);
89
90 void ctsvc_db_set_status(contacts_db_status_e status);
91
92 #endif /*  __CTSVC_DB_QUERY_H__ */
93