merge with master
[platform/core/system/sync-agent.git] / src / fw-plugins / common-public / contact / src / item_change_info.c
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 //#include <contacts-svc.h>
19 #include <contacts.h>
20
21 #include "utility/sync_util.h"
22 #include "item_change_info.h"
23
24 #ifndef SYNC_AGENT_LOG
25 #undef LOG_TAG
26 #define LOG_TAG "PLUGIN_DA_CONTACT"
27 #endif
28
29 static int contact_version = 0;
30
31 int get_contact_version(int mode)
32 {
33         _EXTERN_FUNC_ENTER;
34
35         if (mode == 0) {
36                 return contact_version;
37         }
38
39         contacts_error_e err_connect = contacts_connect2();
40         if (err_connect != CONTACTS_ERROR_NONE) {
41                 _DEBUG_ERROR("contacts_connect2() failed");
42         }
43
44         contacts_error_e err = contacts_db_get_current_version(&contact_version);
45         if (err != CONTACTS_ERROR_NONE) {
46                 _DEBUG_ERROR("contacts_db_get_current_version() failed");
47         }
48         _DEBUG_INFO("contact_version = %d", contact_version);
49
50         err_connect = contacts_disconnect2();
51         if (err_connect != CONTACTS_ERROR_NONE) {
52                 _DEBUG_ERROR("contacts_disconnect2() failed");
53         }
54
55         _EXTERN_FUNC_EXIT;
56         return contact_version;
57 }
58
59 int set_contact_version(int setting_time)
60 {
61         _EXTERN_FUNC_ENTER;
62
63         /* Critical Sectioin Start */
64         contact_version = setting_time;
65         /* Critical Section End */
66
67         _EXTERN_FUNC_EXIT;
68
69         return setting_time;
70 }