Initial refactoring merge
[platform/core/telephony/tel-plugin-imc.git] / include / imc_common.h
1 /*
2  * tel-plugin-imc
3  *
4  * Copyright (c) 2013 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 __IMC_COMMON_H__
20 #define __IMC_COMMON_H__
21
22 #define IMC_SWAP_BYTES_16(x) \
23 { \
24         unsigned short int data = *(unsigned short int *)&(x);  \
25         data = ((data & 0xff00) >> 8) |   \
26                    ((data & 0x00ff) << 8);        \
27         *(unsigned short int *)&(x) = data;      \
28 }
29
30 typedef struct {
31         TcoreObjectResponseCallback cb;
32         void *cb_data;
33         char data[]; /* Additional data */
34 } ImcRespCbData;
35
36 #define IMC_GET_DATA_FROM_RESP_CB_DATA(ptr) (gpointer)ptr->data
37 #define IMC_CHECK_REQUEST_RET(ret, resp_cb_data, request) \
38 do {\
39         if (ret != TEL_RETURN_SUCCESS) { \
40                 err("Failed to process request - [%s]", request); \
41                 imc_destroy_resp_cb_data(resp_cb_data); \
42         } \
43 } while(0)
44
45 ImcRespCbData *imc_create_resp_cb_data(TcoreObjectResponseCallback cb,
46         void *cb_data, void *data, guint data_len);
47 void imc_destroy_resp_cb_data(ImcRespCbData *resp_cb_data);
48
49 void on_send_imc_request(TcorePending *p,
50         TelReturn send_status, void *user_data);
51
52 #endif  /* __IMC_COMMON_H__ */