2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __VC_CORE_UTIL_H_
19 #define __VC_CORE_UTIL_H_
23 #include <glib-object.h>
28 #include "vc-core-error.h"
29 #include "vc-core-engine-types.h"
31 #include "TelDefines.h"
32 #include "TelNetwork.h"
34 #include "TapiCommon.h"
35 #include "TapiEvent.h"
36 #include "ITapiCall.h"
38 #include "ITapiNetwork.h"
39 #include "ITapiSound.h"
44 #include "vconf-keys.h"
45 #include "contacts-svc.h"
46 #ifdef CALL_DEBUG_ON_DLOG
50 #define CALL_NETWORK_MCC_UK 0xEA /*234*/
51 #define CALL_NETWORK_MCC_IE 0x110 /*272*/
52 #define CALL_NETWORK_MCC_UKRAINE 0xFF /*255*/
53 #define CALL_NETWORK_MCC_SAMSUNG_SUWON_3G 450001 /*450001*/
54 #define CALL_NETWORK_MCC_ITALY 222
56 #define IS_DIGIT(value) ((value) >= '0' && (value) <= '9')
58 #ifdef CALL_DEBUG_ON_DLOG
59 #define ENG_ERR LOG_ERROR
60 #define ENG_WARN LOG_WARN
61 #define ENG_DEBUG LOG_DEBUG
68 #ifdef CALL_DEBUG_ON_DLOG
69 #define CALL_ENG_DEBUG(level, frmt, args...) \
70 do {LOG(level, TAG_CALL, "[VC_ENGINE] [%s:%d] "frmt"\n", __func__, __LINE__, ##args); } while (0)
71 #define CALL_ENG_KPI(frmt, args...) \
72 do {LOG(LOG_DEBUG, TAG_CALL_LAUNCH, "[VC_KPI] [%s:%d] "frmt"\n", __func__, __LINE__, ##args); } while (0)
74 #define CALL_ENG_DEBUG(level, fmt, args...)
77 #define VOICECALL_RETURN_IF_FAIL(check_condition) \
78 if (!(check_condition)) return;
80 #define VOICECALL_RETURN_FALSE_IF_FAIL(check_condition) \
81 if (!(check_condition)) return FALSE;
83 #define VOICECALL_RETURN_VALUE_IF_FAIL(check_condition, value) \
84 if (!(check_condition)) return value;
86 #define VOICECALL_RETURN_NULL_IF_FAIL(check_condition) \
87 if (!(check_condition)) return NULL;
89 #define VOICECALL_RETURN_ZERO_IF_FAIL(check_condition) \
90 if (!(check_condition)) return 0;
92 #define VOICECALL_RETURN_INVALID_IF_FAIL(check_condition) \
93 if (!(check_condition)) return -1;
95 #define VOICECALL_RETURN_VALUE_IF_NOT_IN_RANGE(value, min_value, max_value, ret_val) \
96 if ((value < min_value) || (value > max_value)) return ret_val;
99 #define min(a, b) (((a) < (b)) ? (a) : (b))
100 #endif /*#ifndef min*/
102 typedef unsigned int call_vc_handle;
105 #define GET_CURR_TIME() _vc_core_util_get_curr_time()
106 #define PRINT_DIFF_TIME(start, end, message) _vc_core_util_print_diff_time(start, end, message)
107 #define PRINT_CURRENT_TIME(message) _vc_core_util_print_curr_time(message)
110 #define GET_CURR_TIME() 0
111 #define PRINT_DIFF_TIME(start, end, message)
112 #define PRINT_CURRENT_TIME(message)
116 * This enumeration defines SS's SI vaild types
119 SS_SI_FORMAT_INVALID = -1, /**< SI format is invalid */
120 SS_SI_FORMAT_VALID /**< SI format is valid */
121 } call_vc_ss_si_format;
124 * This enumeration defines the publish types
127 CALL_VC_SAT_RESPONSE /**< SAT response publish type */
128 } call_vc_publish_type_t;
131 * This enum defines the type of power mode.
134 CALL_VC_POWER_NONE = 0,
135 CALL_VC_POWER_GRANT_DIMMING,
136 CALL_VC_POWER_GRANT_LCDOFF,
137 CALL_VC_POWER_GRANT_SLEEP,
138 CALL_VC_POWER_PROHIBIT_DIMMING,
139 CALL_VC_POWER_PROHIBIT_LCDOFF,
140 CALL_VC_POWER_PROHIBIT_SLEEP,
141 CALL_VC_POWER_NORMAL_STATUS
142 } call_vc_power_mode_t;
145 * This function publishes the event of a given publish type
147 * @return Returns TRUE on success and FALSE on failure
148 * @param[in] src Telehone number from which call number needd to be parsed
149 * @param[out] dst Pointer to the buffer to store the parsed number
151 gboolean _vc_core_util_remove_invalid_chars(const char *src, char *dst);
154 * This function publishes the event of a given publish type
156 * @return Returns TRUE on success and FALSE on failure
157 * @param[in] pszTelNumber Telehone number from which call number nned to be extracted
158 * @param[out] pBuffer Pointer to the buffer to store the extracted number
159 * @param[in] nBufSize Size of input buffer
161 gboolean _vc_core_util_extract_call_number(const char *pszTelNumber, char *pBuffer, const int nBufSize);
162 gboolean _vc_core_util_extract_call_number_without_cli(const char *pszTelNumber, char *pBuffer, const int nBufSize);
164 #ifdef TIMER_CHECK /*unused*/
165 void call_vc_print_elapsed_time(char *string, gulong * tim_out);
166 void call_vc_print_diff_time(time_t time1, time_t time2);
170 * This function checks whether the given number is emergency number by verifying with sim emergency numbers
172 * @return TRUE if the number is emergency number, FALSE otherwise
173 * @param[in] card_type simcard type
174 * @param[in] pNumber number to be verified
176 gboolean _vc_core_util_check_emergency_number(TelSimCardType_t card_type, char *pNumber, gboolean b_is_no_sim, int *ecc_category);
179 * This function checks whether the given number is SS string or not
181 * @return TRUE if the number is SS string, FALSE otherwise
182 * @param[in] pNumber number to be verified
184 gboolean _vc_core_util_check_ss_string(const char *pNumber);
187 * This function checks whether the given number is SS string or not
189 * @return TRUE if the number is in call SS string, FALSE otherwise
190 * @param[in] pNumber number to be verified
192 gboolean _vc_core_util_check_incall_ss_string(const char *number);
196 * This function extracts the dtmf number from the given telephone number
198 * @param[in] tel_number source telephone number
199 * @param[out] dtmf_number extracted dtmf number
200 * @param[out] dtmf_buf_len size of dtmf number buffer
202 gboolean _vc_core_util_extract_dtmf_number(const char *tel_number, char *dtmf_number, const int dtmf_buf_len);
206 * This function checks whether the given number ia a valid dtmf number or not
208 * @return TRUE if the number can be used for sending dtmf , FALSE otherwise
209 * @param[in] pnumber number to be verified
211 gboolean _vc_core_util_isvalid_dtmf_number(char *pnumber);
214 * This function checks whether the entire dtmf string is valid or not
216 * @return TRUE if the number can be used for sending dtmf , FALSE otherwise
217 * @param[in] pnumber number to be verified
219 gboolean _vc_core_util_isvalid_full_dtmf_number(char *pnumber);
222 * This function checks the validity of the given string for SS string
224 * @return Returns SS_SI_FORMAT_INVALID - if the string is invalid ss string, SS_SI_FORMAT_VALID - if valid
225 * @param[in] pinput_string string to be verified
227 call_vc_ss_si_format _vc_core_util_check_si_format(const char *pinput_string);
230 * This function checks the validity of the given telephone number
232 * @return TRUE if the given number is valid telephone number, FALSE otherwise
233 * @param[in] ptel_number telephone number to be verified
235 gboolean _vc_core_util_isvalid_telephone_number(char *ptel_number);
238 * This function checks the if it is GCF mode or not
240 * @return TRUE if it is GCF mode, FALSE otherwise
242 gboolean _vc_core_util_check_gcf_status(void);
245 * This function checks the if it is in zuhause area or not
247 * @return TRUE if it is in zuhause area, FALSE otherwise
249 gboolean _vc_core_util_check_zuhause_status(void);
252 * This function retreive mcc information from the telephony
255 * @return TRUE on success, FALSE - otherwise
256 * @param[out] mcc mcc information to be retreived
258 gboolean _vc_core_util_get_mcc(unsigned long *mcc);
260 gboolean _vc_core_util_set_call_status(int call_status);
261 gboolean _vc_core_util_check_video_call_status(void);
262 gboolean _vc_core_util_get_SAP_status();
263 void _vc_core_util_get_cug_info(voicecall_setup_info_t *psetupcall_info);
264 void _vc_core_util_get_identity_mode(voicecall_setup_info_t *psetupcall_info);
265 gboolean _vc_core_util_is_offline_mode(void);
266 gboolean _vc_core_util_is_pwlock(void);
267 gboolean _vc_core_util_get_nw_status(int *network_status);
268 gboolean _vc_core_util_strcpy(char *pbuffer, int buf_count, const char *pstring);
271 * This function make the date and time string
273 * @return Returns newly copied string on success or NULL on failure
274 * @param[out] pbuffer Target Buffer
275 * @param[in] time time
277 char *_vc_core_util_get_date_time(time_t time);
280 * This function check phone lock status
282 * @return Returns whether phone is locked or not.
285 gboolean _vc_core_util_phonelock_status(void);
287 gboolean _vc_core_util_set_sleep_status(call_vc_power_mode_t type);
288 gboolean _vc_core_util_get_call_alert_type(int *alert_type);
290 #ifdef TIMER_ENABLED /*unused*/
291 clock_t _vc_core_util_get_curr_time();
292 void _vc_core_util_print_diff_time(clock_t start, clock_t end, char *message);
293 void _vc_core_util_print_curr_time(char *message);
296 void _vc_core_util_download_test_call(char *result);
298 gboolean _vc_core_util_set_call_volume(int vol_level);
299 int _vc_core_util_get_call_volume(void);
300 #endif /* __VC_CORE_UTIL_H_ */