95805c8d6be4ccf0e066850f9d89f34ef51edbf5
[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_try_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_MINUS_ONE (-1)
36 #define S_INDI_NOT_USED(var) ((var) = (var))
37
38 typedef enum {
39         S_INDI_CELLULAR_UNKNOWN = -1,
40         S_INDI_CELLULAR_OFF = 0x00,
41         S_INDI_CELLULAR_CONNECTED = 0x01,
42         S_INDI_CELLULAR_MMS_CONNECTED = 0x02,
43         S_INDI_CELLULAR_USING = 0x03,
44 } s_indi_cellular_state;
45
46 typedef enum {
47         S_INDI_TRANSFER_UNKNOWN = -1,
48         S_INDI_TRANSFER_NORMAL = 0x00,
49         S_INDI_TRANSFER_RX = 0x01,
50         S_INDI_TRANSFER_TX = 0x02,
51         S_INDI_TRANSFER_RXTX = 0x03,
52 } s_indi_transfer_state;
53
54 typedef enum {
55         S_INDI_LCD_UNKNOWN = -1,
56         S_INDI_LCD_ON = 0x01,
57         S_INDI_LCD_DIM = 0x02,
58         S_INDI_LCD_OFF = 0x03
59 } s_indi_lcd_state;
60
61 typedef enum {
62         S_INDI_PS_CALL_OK = 0x00,
63         S_INDI_PS_CALL_CONNECT = 0x01,
64         S_INDI_PS_CALL_NO_CARRIER = 0x03,
65 } s_indi_ps_call_state;
66
67 typedef struct s_indi_cp_state_info_type_struct s_indi_cp_state_info_type;
68 typedef struct {
69         s_indi_lcd_state lcd_state;
70         s_indi_cp_state_info_type *parent;
71 } s_indi_dormancy_info_type;
72
73 struct s_indi_cp_state_info_type_struct{
74         CoreObject *co_ps;
75         GSource *src;
76         GHashTable *device_info; /* HashTable of s_indi_dev_state_info_type with key = dev_name */
77         s_indi_dormancy_info_type dormant_info;
78         s_indi_cellular_state ps_state;
79         s_indi_transfer_state cp_trans_state;
80         unsigned long long rx_total;
81         unsigned long long tx_total;
82         int no_rx_pckt; /* Last time since packed was received in seconds */
83         gboolean roaming_status;
84         int curr_timer_cp;
85         gboolean curr_fdy_state_cp;
86 };
87
88 typedef struct {
89         CoreObject *ps_context;
90         s_indi_cp_state_info_type *parent;
91         unsigned long prev_rx;
92         unsigned long prev_tx;
93         unsigned long curr_rx;
94         unsigned long curr_tx;
95 } s_indi_dev_state_info_type;