Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Pims.Contacts / Interop / Interop.Database.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Runtime.InteropServices;
19
20 internal static partial class Interop
21 {
22     internal enum ContactsChanged
23     {
24         Inserted,
25         Updated,
26         Deleted
27     }
28
29     internal static partial class Database
30     {
31         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_insert_record")]
32         internal static extern int Insert(IntPtr recordHandle, out int recordId);
33
34         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_record")]
35         internal static extern int Get(string uri, int recordId, out IntPtr recordHandle);
36
37         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_update_record")]
38         internal static extern int Update(IntPtr recordHandle);
39
40         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_delete_record")]
41         internal static extern int Delete(string uri, int recordId);
42
43         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_replace_record")]
44         internal static extern int Replace(IntPtr recordHandle, int recordId);
45
46         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_all_records")]
47         internal static extern int GetRecords(string uri, int offset, int limit, out IntPtr listHandle);
48
49         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_records_with_query")]
50         internal static extern int GetRecords(IntPtr queryHandle, int offset, int limit, out IntPtr listHandle);
51
52         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_insert_records")]
53         internal static extern int InsertRecords(IntPtr listHandle, out IntPtr ids, out int count);
54
55         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_update_records")]
56         internal static extern int UpdateRecords(IntPtr listHandle);
57
58         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_delete_records")]
59         internal static extern int DeleteRecords(string uri, int[] recordIdArray, int count);
60
61         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_replace_records")]
62         internal static extern int ReplaceRecords(IntPtr listHandle, int[] recordIdArray, int count);
63
64         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_current_version")]
65         internal static extern int GetVersion(out int contactsDBVersion);
66
67         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_add_changed_cb")]
68         internal static extern int AddChangedCb(string uri, ContactsDBChangedCallback callback, IntPtr userData);
69
70         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_remove_changed_cb")]
71         internal static extern int RemoveChangedCb(string uri, ContactsDBChangedCallback callback, IntPtr userData);
72
73         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_changes_by_version")]
74         internal static extern int GetChangesByVersion(string uri, int addressBookId, int contactsDBVersion, out IntPtr changeRecordList, out int currentContactsDBVersion);
75
76         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records")]
77         internal static extern int Search(string uri, string keyword, int offset, int limit, out IntPtr listHandle);
78
79         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_query")]
80         internal static extern int Search(IntPtr queryHandle, string keyword, int offset, int limit, out IntPtr listHandle);
81
82         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_range")]
83         internal static extern int Search(string uri, string keyword, int offset, int limit, int range, out IntPtr listHandle);
84
85         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_for_snippet")]
86         internal static extern int Search(string uri, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
87
88         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_query_for_snippet")]
89         internal static extern int Search(IntPtr queryHandle, string keyword, int offset, int limit, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
90
91         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_search_records_with_range_for_snippet")]
92         internal static extern int Search(string uri, string keyword, int offset, int limit, int range, string startMatch, string endMatch, int tokenNumber, out IntPtr listHandle);
93
94         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_count")]
95         internal static extern int GetCount(string uri, out int count);
96
97         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_count_with_query")]
98         internal static extern int GetCount(IntPtr queryHandle, out int count);
99
100         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_last_change_version")]
101         internal static extern int GetLastChangeVersion(out int version);
102
103         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_get_status")]
104         internal static extern int GetStatus(out Tizen.Pims.Contacts.ContactsDatabase.DBStatus status);
105
106         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_add_changed_cb")]
107         internal static extern int AddStatusChangedCb(ContactsDBStatusChangedCallback callback, IntPtr userData);
108
109         [DllImport(Libraries.Contacts, EntryPoint = "contacts_db_remove_changed_cb")]
110         internal static extern int RemoveStatusChangedCb(ContactsDBStatusChangedCallback callback, IntPtr userData);
111
112         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
113         internal delegate void ContactsDBChangedCallback(string uri, IntPtr userData);
114
115         [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
116         internal delegate void ContactsDBStatusChangedCallback(Tizen.Pims.Contacts.ContactsDatabase.DBStatus status, IntPtr userData);
117     }
118 }