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"
32 #include "drm-service-types.h"
33 #include "drm-service.h"
36 #include <tapi_common.h>
37 #include <TapiUtility.h>
38 #include <ITapiCall.h>
43 #include "vconf-keys.h"
44 #include "contacts-svc.h"
45 #ifdef CALL_DEBUG_ON_DLOG
50 #define CALL_NETWORK_MCC_UK 234 /*UK = 234*/
51 #define CALL_NETWORK_MCC_IRELAND 272 /*Ireland = 272*/
52 #define CALL_NETWORK_MCC_UAE 424 /*UAE = 424*/
53 #define CALL_NETWORK_MCC_GHANA 620 /*Ghana = 620*/
54 #define CALL_NETWORK_MCC_ISRAEL 425 /*Israel = 425*/
55 #define CALL_NETWORK_MCC_CROATIA 219 /*Croatia = 219*/
56 #define CALL_NETWORK_MCC_SERBIA 220 /*Serbia = 220*/
57 #define CALL_NETWORK_MCC_RUSSIA 250 /*Russia = 250*/
59 #define CALL_NETWORK_MCC_TAIWAN 466 /*Taiwan = 466*/
60 #define CALL_NETWORK_MCC_HONGKONG 454 /*Hongkong = 454*/
61 #define CALL_NETWORK_MCC_MALAYSIA 502 /*MALAYSIA = 502*/
62 #define CALL_NETWORK_MCC_AUSTRALIA 505 /*Australia = 505*/
63 #define CALL_NETWORK_MCC_NEWZEALAND 530 /*NewZealand = 530*/
65 #define CALL_NETWORK_MCC_USA 310 /*USA = 310*/
66 #define CALL_NETWORK_MCC_CANADA 302 /*Canada = 302*/
67 #define CALL_NETWORK_MCC_BRASIL 724 /*Brasil = 724*/
68 #define CALL_NETWORK_MCC_MEXICO 334 /*Mexico = 334*/
69 #define CALL_NETWORK_MCC_URGUAY 748 /*Urguay = 748*/
70 #define CALL_NETWORK_MCC_COLOMBIA 732 /*Colombia = 732*/
71 #define CALL_NETWORK_MCC_CHILE 730 /*Chile = 730*/
72 #define CALL_NETWORK_MCC_PERU 716 /*Peru = 716*/
73 #define CALL_NETWORK_MCC_VENEZUELA 734 /*Venezuela = 734*/
74 #define CALL_NETWORK_MCC_GUATEMALA 704 /*Guatemala = 704*/
75 #define CALL_NETWORK_MCC_ELSALVADOR 706 /*El Salvador = 706*/
76 #define CALL_NETWORK_MCC_NICARAGUA 710 /*Nicaragua = 710*/
77 #define CALL_NETWORK_MCC_PANAMA 714 /*Panama = 714*/
79 #define CALL_NETWORK_MCC_JAPAN 440 /*Japan = 440*/
80 #define CALL_NETWORK_MCC_KOREA 450 /*Korae = 450*/
81 #define CALL_NETWORK_MCC_CHINA 460 /*China = 460*/
83 #define CALL_NETWORK_MCC_FRANCE 208 /*France = 208*/
84 #define CALL_NETWORK_MCC_PORTUGAL 268 /*Protugal = 268*/
85 #define CALL_NETWORK_MCC_ROMANIA 226 /*Romania = 226*/
86 #define CALL_NETWORK_MCC_DE 262 /*DE = 262(0x106)*/
88 #define CALL_NETWORK_MCC_TEST_USA 0x001 /*Test MMC*/
91 #define CALL_NETWORK_MNC_01 1 /*MNC 01*/
92 #define CALL_NETWORK_MNC_02 2 /*MNC 02*/
93 #define CALL_NETWORK_MNC_03 3 /*MNC 03*/
94 #define CALL_NETWORK_MNC_04 4 /*MNC 04*/
95 #define CALL_NETWORK_MNC_05 5 /*MNC 05*/
96 #define CALL_NETWORK_MNC_06 6 /*MNC 06*/
97 #define CALL_NETWORK_MNC_11 11 /*MNC 11 for +Movil in Panama*/
98 #define CALL_NETWORK_MNC_20 20 /*MNC 20 for TELCEL in Mexico*/
99 #define CALL_NETWORK_MNC_123 123 /*MNC 123 for Movistar in Colombia*/
100 #define CALL_NETWORK_MNC_103 103 /*MNC 103 for TIGO in Colombia*/
101 #define CALL_NETWORK_MNC_111 111 /*MNC 111 for TIGO in Colombia*/
102 #define CALL_NETWORK_MNC_30 30 /*MNC 30 for Movistar in Nicaragua*/
103 #define CALL_NETWORK_MNC_300 300 /*MNC 30 for Movistar in Nicaragua*/
104 #define CALL_NETWORK_MNC_TEST_USA 0x01 /*Test MNC*/
106 #define IS_DIGIT(value) ((value) >= '0' && (value) <= '9')
108 #ifdef CALL_DEBUG_ON_DLOG
109 #define ENG_ERR LOG_ERROR
110 #define ENG_WARN LOG_WARN
111 #define ENG_DEBUG LOG_DEBUG
118 #ifdef CALL_DEBUG_ON_DLOG
119 #define CALL_ENG_DEBUG(level, frmt, args...) \
120 do {LOG(level, TAG_CALL, "[VC_ENGINE] [%s:%d] "frmt"\n", __func__, __LINE__, ##args); } while (0)
121 #define CALL_ENG_KPI(frmt, args...) \
122 do {LOG(LOG_DEBUG, TAG_CALL_LAUNCH, "[VC_KPI] [%s:%d] "frmt"\n", __func__, __LINE__, ##args); } while (0)
124 #define CALL_ENG_DEBUG(level, fmt, args...)
127 #define VOICECALL_RETURN_IF_FAIL(check_condition) \
128 if (!(check_condition)) return;
130 #define VOICECALL_RETURN_FALSE_IF_FAIL(check_condition) \
131 if (!(check_condition)) return FALSE;
133 #define VOICECALL_RETURN_VALUE_IF_FAIL(check_condition, value) \
134 if (!(check_condition)) return value;
136 #define VOICECALL_RETURN_NULL_IF_FAIL(check_condition) \
137 if (!(check_condition)) return NULL;
139 #define VOICECALL_RETURN_ZERO_IF_FAIL(check_condition) \
140 if (!(check_condition)) return 0;
142 #define VOICECALL_RETURN_INVALID_IF_FAIL(check_condition) \
143 if (!(check_condition)) return -1;
145 #define VOICECALL_RETURN_VALUE_IF_NOT_IN_RANGE(value, min_value, max_value, ret_val) \
146 if ((value < min_value) || (value > max_value)) return ret_val;
149 #define min(a, b) (((a) < (b)) ? (a) : (b))
150 #endif /*#ifndef min*/
152 typedef unsigned int call_vc_handle;
155 * This enumeration defines SS's SI vaild types
158 SS_SI_FORMAT_INVALID = -1, /**< SI format is invalid */
159 SS_SI_FORMAT_VALID /**< SI format is valid */
160 } call_vc_ss_si_format;
163 * This enumeration defines the publish types
166 CALL_VC_SAT_RESPONSE /**< SAT response publish type */
167 } call_vc_publish_type_t;
170 * This enum defines the type of power mode.
173 CALL_VC_POWER_NONE = 0,
174 CALL_VC_POWER_GRANT_DIMMING,
175 CALL_VC_POWER_GRANT_LCDOFF,
176 CALL_VC_POWER_GRANT_SLEEP,
177 CALL_VC_POWER_PROHIBIT_DIMMING,
178 CALL_VC_POWER_PROHIBIT_LCDOFF,
179 CALL_VC_POWER_PROHIBIT_SLEEP,
180 CALL_VC_POWER_NORMAL_STATUS
181 } call_vc_power_mode_t;
184 * This function publishes the event of a given publish type
186 * @return Returns TRUE on success and FALSE on failure
187 * @param[in] src Telehone number from which call number needd to be parsed
188 * @param[out] dst Pointer to the buffer to store the parsed number
190 gboolean _vc_core_util_remove_invalid_chars(const char *src, char *dst);
193 * This function publishes the event of a given publish type
195 * @return Returns TRUE on success and FALSE on failure
196 * @param[in] pszTelNumber Telehone number from which call number nned to be extracted
197 * @param[out] pBuffer Pointer to the buffer to store the extracted number
198 * @param[in] nBufSize Size of input buffer
200 gboolean _vc_core_util_extract_call_number(const char *pszTelNumber, char *pBuffer, const int nBufSize);
201 gboolean _vc_core_util_extract_call_number_without_cli(const char *pszTelNumber, char *pBuffer, const int nBufSize);
203 #ifdef TIMER_CHECK /*unused*/
204 void call_vc_print_elapsed_time(char *string, gulong * tim_out);
205 void call_vc_print_diff_time(time_t time1, time_t time2);
209 * This function checks whether the given number is SS string or not
211 * @return TRUE if the number is SS string, FALSE otherwise
212 * @param[in] pNumber number to be verified
214 gboolean _vc_core_util_check_ss_string(const char *pNumber);
217 * This function checks whether the given number is SS string or not
219 * @return TRUE if the number is in call SS string, FALSE otherwise
220 * @param[in] pNumber number to be verified
222 gboolean _vc_core_util_check_incall_ss_string(const char *number);
225 * This function extracts the dtmf number from the given telephone number
227 * @param[in] tel_number source telephone number
228 * @param[out] dtmf_number extracted dtmf number
229 * @param[out] dtmf_buf_len size of dtmf number buffer
231 gboolean _vc_core_util_extract_dtmf_number(const char *tel_number, char *dtmf_number, const int dtmf_buf_len);
234 * This function checks whether the given number ia a valid dtmf number or not
236 * @return TRUE if the number can be used for sending dtmf , FALSE otherwise
237 * @param[in] pnumber number to be verified
239 gboolean _vc_core_util_isvalid_dtmf_number(char *pnumber);
242 * This function checks whether the entire dtmf string is valid or not
244 * @return TRUE if the number can be used for sending dtmf , FALSE otherwise
245 * @param[in] pnumber number to be verified
247 gboolean _vc_core_util_isvalid_full_dtmf_number(char *pnumber);
250 * This function checks the validity of the given string for SS string
252 * @return Returns SS_SI_FORMAT_INVALID - if the string is invalid ss string, SS_SI_FORMAT_VALID - if valid
253 * @param[in] pinput_string string to be verified
255 call_vc_ss_si_format _vc_core_util_check_si_format(const char *pinput_string);
258 * This function checks the validity of the given telephone number
260 * @return TRUE if the given number is valid telephone number, FALSE otherwise
261 * @param[in] ptel_number telephone number to be verified
263 gboolean _vc_core_util_isvalid_telephone_number(char *ptel_number);
266 * This function checks the if it is GCF mode or not
268 * @return TRUE if it is GCF mode, FALSE otherwise
270 gboolean _vc_core_util_check_gcf_status(void);
273 * This function checks the if it is in zuhause area or not
275 * @return TRUE if it is in zuhause area, FALSE otherwise
277 gboolean _vc_core_util_check_zuhause_status(void);
280 * This function retreive mcc information from the telephony
283 * @return TRUE on success, FALSE - otherwise
284 * @param[out] mcc mcc information to be retreived
286 gboolean _vc_core_util_get_mcc(unsigned long *mcc);
289 * This function retreive mnc information from the telephony
292 * @return TRUE on success, FALSE - otherwise
293 * @param[out] mnc mnc information to be retreived
295 gboolean _vc_core_util_get_mnc(unsigned long *mnc);
298 gboolean _vc_core_util_set_call_status(int call_status);
299 gboolean _vc_core_util_check_video_call_status(void);
300 gboolean _vc_core_util_get_SAP_status();
301 void _vc_core_util_get_cug_info(voicecall_setup_info_t *psetupcall_info);
302 void _vc_core_util_get_identity_mode(voicecall_setup_info_t *psetupcall_info);
303 gboolean _vc_core_util_is_offline_mode(void);
304 gboolean _vc_core_util_is_pwlock(void);
305 gboolean _vc_core_util_get_nw_status(int *network_status);
306 gboolean _vc_core_util_strcpy(char *pbuffer, int buf_count, const char *pstring);
309 * This function make the date and time string
311 * @return Returns newly copied string on success or NULL on failure
312 * @param[out] pbuffer Target Buffer
313 * @param[in] time time
315 char *_vc_core_util_get_date_time(time_t time);
318 * This function check phone lock status
320 * @return Returns whether phone is locked or not.
323 gboolean _vc_core_util_phonelock_status(void);
325 void _vc_core_util_download_test_call(char *result);
327 gboolean _vc_core_util_set_call_volume(int vol_level);
328 int _vc_core_util_get_call_volume(void);
329 #endif /* __VC_CORE_UTIL_H_ */