Code Sync up from tizen_2.4
[platform/core/telephony/tel-plugin-indicator.git] / include / s_indi_util.h
1 /*
2  * tel-plugin-indicator
3  *
4  * Copyright (c) 2014 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 #pragma once
20
21 #include <glib.h>
22 #include <tcore.h>
23
24 #define s_indi_assert(cond) g_assert(cond)
25 #define s_indi_assert_not_reached() g_assert_not_reached()
26 #define s_indi_malloc0(sz) g_malloc0(sz)
27 #define s_indi_free_func g_free
28 #define s_indi_free(p) s_indi_free_func(p)
29 #define s_indi_strdup(str) g_strdup(str)
30 #define s_indi_str_has_suffix(str, pre) g_str_has_suffix(str, pre)
31
32 #define S_INDI_ZERO (0)
33 #define S_INDI_ONE (1)
34 #define S_INDI_FIVE (5)
35 #define S_INDI_SIPC_ITER_START S_INDI_ONE
36 #define S_INDI_SIPC_ITER_END (255)
37 #define S_INDI_MINUS_ONE (-1)
38 #define S_INDI_NOT_USED(var) ((var) = (var))
39 #define S_INDI_SIPC_MSG_ID(hdr)                         ((hdr).main_cmd << 8 | (hdr).sub_cmd)
40
41 typedef enum {
42         S_INDI_CELLULAR_UNKNOWN = -1,
43         S_INDI_CELLULAR_OFF = 0x00,
44         S_INDI_CELLULAR_CONNECTED = 0x01,
45         S_INDI_CELLULAR_MMS_CONNECTED = 0x02,
46         S_INDI_CELLULAR_USING = 0x03,
47 } s_indi_cellular_state;
48
49 typedef enum {
50         S_INDI_TRANSFER_UNKNOWN = -1,
51         S_INDI_TRANSFER_NORMAL = 0x00,
52         S_INDI_TRANSFER_RX = 0x01,
53         S_INDI_TRANSFER_TX = 0x02,
54         S_INDI_TRANSFER_RXTX = 0x03,
55 } s_indi_transfer_state;
56
57 typedef enum {
58         S_INDI_LCD_UNKNOWN = -1,
59         S_INDI_LCD_ON = 0x01,
60         S_INDI_LCD_DIM = 0x02,
61         S_INDI_LCD_OFF = 0x03
62 } s_indi_lcd_state;
63
64 typedef enum {
65         S_INDI_PS_CALL_OK = 0x00,
66         S_INDI_PS_CALL_CONNECT = 0x01,
67         S_INDI_PS_CALL_NO_CARRIER = 0x03,
68 } s_indi_ps_call_state;
69
70 struct global_data {
71         unsigned int id_current;
72         unsigned int id_start;
73         unsigned int id_end;
74 };
75
76 typedef struct s_indi_cp_state_info_type_struct s_indi_cp_state_info_type;
77 typedef struct {
78         gchar *mccmnc;
79         gboolean b_vconf_checker;
80         s_indi_lcd_state lcd_state;
81         int lcd_on_timeout;
82         int lcd_off_timeout;
83         int dormant_cnt;
84         gboolean is_dormant;
85         gboolean is_dormant_set;
86         s_indi_cp_state_info_type *parent;
87 } s_indi_dormancy_info_type;
88
89 struct s_indi_cp_state_info_type_struct{
90         CoreObject *co_ps;
91         GSource *src;
92         GHashTable *device_info; /* HashTable of s_indi_dev_state_info_type with key = dev_name */
93         s_indi_dormancy_info_type dormant_info;
94         s_indi_cellular_state ps_state;
95         s_indi_transfer_state cp_trans_state;
96         unsigned long long rx_total;
97         unsigned long long tx_total;
98         int no_rx_pckt; /* Last time since packed was received in seconds */
99         gboolean roaming_status;
100         int curr_timer_cp;
101         gboolean curr_fdy_state_cp;
102 };
103
104 typedef struct {
105         CoreObject *ps_context;
106         s_indi_cp_state_info_type *parent;
107         unsigned long prev_rx;
108         unsigned long prev_tx;
109         unsigned long curr_rx;
110         unsigned long curr_tx;
111 } s_indi_dev_state_info_type;