Remove async APIs same as 2.4
[platform/core/pim/contacts-service.git] / client / ctsvc_client_activity.c
1 /*
2  * Contacts Service
3  *
4  * Copyright (c) 2010 - 2012 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
20 #include <glib.h>
21 #include <pims-ipc-data.h>
22
23 #include "contacts.h"
24 #include "ctsvc_internal.h"
25 #include "ctsvc_ipc_define.h"
26 #include "ctsvc_ipc_marshal.h"
27 #include "ctsvc_client_ipc.h"
28
29 API int contacts_activity_delete_by_contact_id(int contact_id)
30 {
31         int ret = CONTACTS_ERROR_NONE;
32         pims_ipc_data_h indata = NULL;
33         pims_ipc_data_h outdata = NULL;
34
35         RETVM_IF(contact_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
36
37         // make indata
38         indata = pims_ipc_data_create(0);
39         if (indata == NULL)
40         {
41                 CTS_ERR("ipc data created fail!");
42                 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
43                 return ret;
44         }
45
46         ret = ctsvc_ipc_marshal_int( contact_id, indata);
47         if (ret != CONTACTS_ERROR_NONE)
48         {
49                 CTS_ERR("marshal fail");
50                 pims_ipc_data_destroy(indata);
51                 return ret;
52         }
53
54         // ipc call
55         if (ctsvc_ipc_call( CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_CONTACT_ID, indata, &outdata) != 0)
56         {
57                 CTS_ERR("ctsvc_ipc_call failed");
58                 pims_ipc_data_destroy(indata);
59                 return CONTACTS_ERROR_IPC;
60         }
61
62         pims_ipc_data_destroy(indata);
63
64         if (outdata)
65         {
66                 // check result
67                 unsigned int size = 0;
68                 ret = *(int*) pims_ipc_data_get(outdata, &size);
69                 if (CONTACTS_ERROR_NONE == ret) {
70                         int transaction_ver = 0;
71                         transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
72                         ctsvc_client_ipc_set_change_version(transaction_ver);
73                 }
74
75                 pims_ipc_data_destroy(outdata);
76         }
77
78         return ret;
79 }
80
81 API int contacts_activity_delete_by_account_id(int account_id)
82 {
83         int ret = CONTACTS_ERROR_NONE;
84         pims_ipc_data_h indata = NULL;
85         pims_ipc_data_h outdata = NULL;
86
87         RETVM_IF(account_id <= 0,CONTACTS_ERROR_INVALID_PARAMETER,"id should be greater than 0");
88
89         // make indata
90         indata = pims_ipc_data_create(0);
91         if (indata == NULL)
92         {
93                 CTS_ERR("ipc data created fail!");
94                 ret = CONTACTS_ERROR_OUT_OF_MEMORY;
95                 return ret;
96         }
97
98         ret = ctsvc_ipc_marshal_int( account_id, indata);
99         if (ret != CONTACTS_ERROR_NONE)
100         {
101                 CTS_ERR("marshal fail");
102                 pims_ipc_data_destroy(indata);
103                 return ret;
104         }
105
106         // ipc call
107         if (ctsvc_ipc_call( CTSVC_IPC_ACTIVITY_MODULE, CTSVC_IPC_SERVER_ACTIVITY_DELETE_BY_ACCOUNT_ID, indata, &outdata) != 0)
108         {
109                 CTS_ERR("ctsvc_ipc_call failed");
110                 pims_ipc_data_destroy(indata);
111                 return CONTACTS_ERROR_IPC;
112         }
113
114         pims_ipc_data_destroy(indata);
115
116         if (outdata)
117         {
118                 // check result
119                 unsigned int size = 0;
120                 ret = *(int*) pims_ipc_data_get(outdata, &size);
121                 if (CONTACTS_ERROR_NONE == ret) {
122                         int transaction_ver = 0;
123                         transaction_ver = *(int*)pims_ipc_data_get(outdata,&size);
124                         ctsvc_client_ipc_set_change_version(transaction_ver);
125                 }
126
127                 pims_ipc_data_destroy(outdata);
128         }
129
130         return ret;
131 }