blob: d27e6108d96e1d8d10a91e6257556a6cae04bfcc [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/************************************************************************
2* °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
3*
4* ÎļþÃû³Æ£º zte_web_mgmt.c
5* Îļþ±êʶ£º
6* ÄÚÈÝÕªÒª£º
7* ÆäËü˵Ã÷£º
8* µ±Ç°°æ±¾£º V0.1
9* ×÷ Õߣº zyt
10* Íê³ÉÈÕÆÚ£º 2010-11-06
11*
12* Ð޸ļǼ1£º
13* ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾
14************************************************************************/
15
16/**************************************************************************
17* Ð޸ıàºÅ : й¦ÄÜ
18* ÐÞ ¸Ä ÈË : chenjie10092374
19* ÐÞ¸ÄÈÕÆÚ : 2014.6.24
20* ÐÞ¸ÄÄÚÈÝ : Ìí¼ÓÖ§³Öufi monitor¹¦ÄÜ´¦Àí´úÂë
21**************************************************************************/
22
23#include "zte_web_interface.h"
24//#include "sms_com.h"
25#include "zte_web_get_fw_para.h"
26#include "zte_web_sms.h"
27
28
29#define UPCASE( c ) ( ((c) >= 'a' && (c) <= 'z') ? ((c) - 0x20) : (c) )
30
31extern void zte_rest_get_sms_data_head(webs_t wp);
32extern void zte_rest_get_sms_data_foot(webs_t wp);
33extern void zte_rest_get_bro_data_head(webs_t wp);
34extern void zte_rest_get_bro_data_foot(webs_t wp);
35extern void zte_rest_get_sms_data(webs_t wp, zte_sms_query_result *p_sms_query_result, int i, int tag);
36extern void zte_rest_sms_parameter(webs_t wp, T_zUfiSms_ParaInfo sms_parameter_info);
37extern void zte_rest_sms_status_rpt(webs_t wp, zte_sms_query_result *p_sms_query_result, int i, int tag);
38extern void zte_rest_boradcast_data(webs_t wp, zte_wms_cell_bro_s_type *p_bro_query_result);
39static void zte_web_feed_back_empty(webs_t wp);
40static unsigned int parseStrBySeparator(unsigned char *input, unsigned char *output, int destLen, unsigned char separator);
41//static int asc_util_atoi(unsigned int *val_arg_ptr, const unsigned char *s, unsigned int r);
42//static int sms_util_asc_to_hex(unsigned char *in_ptr, unsigned char *out_ptr, int len);
43
44#define WebSms_LOG(priority,...) do { \
45 printf(__VA_ARGS__); \
46} while(0)
47
48
49VOID zte_sms_handle_DB_status_whenSend(int cmd_status)
50{
51 T_zUfiSms_StatusInfo statusInfo;
52 memset((void*)&statusInfo, 0, sizeof(T_zUfiSms_StatusInfo));
53 statusInfo.cmd = WMS_SMS_CMD_MSG_SEND;
54 statusInfo.cmd_status = cmd_status;
55 statusInfo.err_code = ZTE_SMS_CMS_NONE;
56 statusInfo.send_failed_count = 0;
57 statusInfo.delete_failed_count = 0;
58
59 zte_libwms_setSmsCmdStatus(&statusInfo);
60}
61
62VOID zte_sms_handle_DB_status(int cmd, int cmd_status)
63{
64 T_zUfiSms_StatusInfo statusInfo;
65 memset((void*)&statusInfo, 0, sizeof(T_zUfiSms_StatusInfo));
66 statusInfo.cmd = cmd;
67 statusInfo.cmd_status = cmd_status;
68 statusInfo.err_code = ZTE_SMS_CMS_NONE;
69 statusInfo.send_failed_count = 0;
70 statusInfo.delete_failed_count = 0;
71
72 zte_libwms_setSmsCmdStatus(&statusInfo);
73}
74
75/*
76*Ôö¼Ó´Ëº¯ÊýÅжÏÖ÷ÒªÊÇÒòΪÁ÷Á¿Ð£×¼¹¦ÄÜÒ²»á·¢¶ÌÐÅ
77*ΪÁ˱£Ö¤ATSERVERÁ÷³Ì´¦ÀíµÄÒ»ÖÂÐÔ£¬¼Ó´ËÅжÏ
78*/
79int zte_sms_check_can_send_sms()
80{
81 T_zUfiSms_StatusInfo cmd_status_info = {0};
82 int result = 0;
83 char buf1[NV_ITEM_STRING_LEN_10] = {0};
84 char buf2[NV_ITEM_STRING_LEN_10] = {0};
85 char buf3[NV_ITEM_STRING_LEN_20] = {0};
86
87 /*
88 *ÒÔϼ¸ÖÖÇé¿ö¿ÉÒÔ²»ÅжÏ:
89 *(1)Á÷Á¿Ð£×¼¹¦ÄÜδ´ò¿ª;
90 *(2)Á÷Á¿Ð£×¼¹¦ÄÜÒÑ´ò¿ª£¬µ«ÊÇĿǰ²»ÔÚÔËÐÐÖУ»
91 *(3)Á÷Á¿Ð£×¼¹¦ÄÜÒÑ´ò¿ªÇÒÔÚÔËÐÐÖУ¬µ«²»ÔÚ·¢ËͶÌÐŹý³ÌÖУ»
92 *×¢:ʵ¼ÊÉÏÊöÈýµãÌõ¼þ¶¼¿ÉÒÔ¹éΪÌõ¼þ(3)Ò»Ìõ½øÐÐÅжϼ´¿É£¬
93 * µ«´Ë´¦ÎªÁ˱ãÓÚÀí½âά»¤£¬»¹ÊÇÔÚ´úÂë²ãÃæ·ÖÈý¸öÌõ¼þÅжϴ¦Àí¡£
94 */
95 sc_cfg_get(NV_DATA_TRAFFIC_SWITCH, &buf1, sizeof(buf1));
96 sc_cfg_get("is_traffic_alining", buf2, sizeof(buf2));
97 sc_cfg_get("traffic_sms_number", buf3, sizeof(buf3));
98
99 if ((0 != strcmp(buf1, "yes"))
100 || (0 == strcmp(buf2, "no"))
101 || (0 == strcmp(buf3, "0"))) {
xf.libdd93d52023-05-12 07:10:14 -0700102 slog(MISC_PRINT, SLOG_DEBUG,"[traffic] sms_check_can_send_sms, no need to check!\n");
lh9ed821d2023-04-07 01:36:19 -0700103 return 0;
104 }
105
106 cmd_status_info.cmd = WMS_SMS_CMD_MSG_SEND;
107 result = zte_libwms_get_cmd_status(&cmd_status_info);
108 if (result == -1) {
109 return 0;
110 }
111
112 if (cmd_status_info.cmd_status == WMS_CMD_PROCESSING) {
113 return -1;
114 }
115
116 return 0;
117}
118
119int hex_check(char *buf)
120{
121 int i = 0;
122 int len = strlen(buf);
123 for (i = 0; i < len; i++) {
124 if(!isxdigit(buf[i]))
125 return -1;
126 }
127 return i;
128}
129
130void zte_sms_send_msg_process(webs_t wp)
131{
132 unsigned int i = 0;
133 //int j = 0;
134 int message_content_len = 0;
135 unsigned int rec_count = 0;
136 unsigned char encode_type = 0;
137 char_t *sms_encode_type = NULL;
138 char_t *msg_id = NULL;
139 unsigned char *msg_content_web = NULL;
140 //char_t *which_page = NULL;
141 char_t *sms_time = NULL;
142 int s_flag = 0; //to distinguish time field from time string
143 int index = 0;
144 unsigned char *rec_number = NULL;
145 unsigned char rec_separate[ZTE_WMS_SEND_NUM_MAX][ZTE_WMS_ADDRESS_LEN_MAX + 1] = {0};
146 T_zUfiSms_SendReq MSG_SEND_ST;
147
148 memset(&MSG_SEND_ST, 0, sizeof(T_zUfiSms_SendReq));
149 slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User send msg!\n"));
150 //which_page = websGetVar(wp, "which_cgi", T(""));
151 rec_number = websGetVar(wp, "Number", T(""));
152 msg_content_web = websGetVar(wp, "MessageBody", T(""));
153 msg_id = websGetVar(wp, "ID", T(""));
154 sms_encode_type = websGetVar(wp, "encode_type", T(""));
155 sms_time = websGetVar(wp, "sms_time", T(""));
156
157 //add by liuyingnan for server safe for xss attack start
158 if (DATA_NO_SAFE == zte_Safe_noSpecialChar(msg_content_web)
159 || DATA_NO_SAFE == zte_Safe_noSpecialChar(rec_number)
160 || hex_check(msg_content_web) < 0) {
161 sc_cfg_set("data_safe", "failed");
162 slog(MISC_PRINT, SLOG_ERR,"Get Data is no Safe:msg_content_web:%s\n", msg_content_web); /*lint !e26*/
163 zte_write_result_to_web(wp, FAILURE);
164 return;
165 }
166 //add by liuyingnan for server safe for xss attack end
167
168 /* adjust the number and contents' form */
169 message_content_len = strlen(msg_content_web) / 2;
170 slog(MISC_PRINT, SLOG_DEBUG, "goahead==message_content_len=%d", message_content_len); /*lint !e26*/
171 rec_count = parseStrBySeparator(rec_number, (unsigned char *)rec_separate, ZTE_WMS_ADDRESS_LEN_MAX + 1, SEPARATOR_CHARACTER);
172
173 if (0 == strcmp("ASCII", sms_encode_type)) { //not include chinese
174 encode_type = DCS_ASC;
175 } else if (0 == strcmp("UNICODE", sms_encode_type)) {
176 encode_type = DCS_UNICODE;
177 } else if (0 == strcmp("GSM7_span", sms_encode_type)) {
178 encode_type = DCS_SPANISH;
179 } else if (0 == strcmp("GSM7_default", sms_encode_type)) {
180 slog(MISC_PRINT, SLOG_DEBUG, "goahead==GSM7_default==sms_encode_type=%s", sms_encode_type); /*lint !e26*/
181 encode_type = DCS_GSM7_DEFAULT;
182 slog(MISC_PRINT, SLOG_DEBUG,"goahead==end==encode_type=%d", encode_type); /*lint !e26*/
183 } else if (0 == strcmp("GSM7_turkey", sms_encode_type)) {
184 encode_type = DCS_TURKISH;
185 } else {
186 slog(MISC_PRINT, SLOG_DEBUG, "invalid sms_encode_type [%s]! \n", sms_encode_type); /*lint !e26*/
187 zte_write_result_to_web(wp, FAILURE);
188 return;
189 }
190
191 //parse the time field
192 for (i = 0; i < strlen(sms_time); i++) {
193 if (';' == sms_time[i]) {
194 s_flag++;
195 index = 0;
196 continue;
197 }
198
199 if ((0 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.year) - 1))) {
200 MSG_SEND_ST.date.year[index++] = sms_time[i];
201 } else if ((1 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.month) - 1))) {
202 MSG_SEND_ST.date.month[index++] = sms_time[i];
203 } else if ((2 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.day) - 1))) {
204 MSG_SEND_ST.date.day[index++] = sms_time[i];
205 } else if ((3 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.hour) - 1))) {
206 MSG_SEND_ST.date.hour[index++] = sms_time[i];
207 } else if ((4 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.min) - 1))) { /*lint !e123*/
208 MSG_SEND_ST.date.min[index++] = sms_time[i];/*lint !e123*/
209 } else if ((5 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.sec) - 1))) {
210 MSG_SEND_ST.date.sec[index++] = sms_time[i];
211 } else if ((6 == s_flag) && (index < (sizeof(MSG_SEND_ST.date.timezone) - 1))) {
212 MSG_SEND_ST.date.timezone[index++] = sms_time[i];
213 }
214
215 }
216
xf.libdd93d52023-05-12 07:10:14 -0700217 slog(MISC_PRINT, SLOG_DEBUG,"sms_send_msg_process:year is [%s];"\
lh9ed821d2023-04-07 01:36:19 -0700218 "month is [%s];day is [%s];hour is [%s];minute is [%s];second is [%s];timezone is [%s].\n", \
219 MSG_SEND_ST.date.year, MSG_SEND_ST.date.month, MSG_SEND_ST.date.day, \
220 MSG_SEND_ST.date.hour, MSG_SEND_ST.date.min, MSG_SEND_ST.date.sec, \
221 MSG_SEND_ST.date.timezone);/*lint !e26 !e123 */
222
223 /* stuff the struct which is sending to mc */
224 slog(MISC_PRINT, SLOG_DEBUG, "goahead==============msg_content_web==========%s", msg_content_web); /*lint !e26*/
225 slog(MISC_PRINT, SLOG_DEBUG, "goahead=========message_content_len=%d", message_content_len); /*lint !e26*/
226// concat sms
227 zte_libwms_db_write_send_msg_content_data(msg_content_web);
228 //doSystem("sleep 1");
229 slog(MISC_PRINT, SLOG_NORMAL, "Send message to database succesful!\n"); /*lint !e26*/
230#if 0 // Ô­À´²»Ö§³Ö¼¶Áª¶ÌÐŵĴúÂë
231 (void)sms_util_asc_to_hex(msg_content_web, MSG_SEND_ST.msg_content, message_content_len);
232#endif
233 MSG_SEND_ST.msg_len = message_content_len;
234
235 MSG_SEND_ST.dcs = encode_type;
236
237 MSG_SEND_ST.receiver_count = rec_count;
238 memcpy(MSG_SEND_ST.dest_num, rec_separate, sizeof(rec_separate));
239
240 //handle whether to delete the old sms begin
241 if (0 != strcmp(msg_id, "")) {
242 MSG_SEND_ST.id = atol(msg_id); //-1:new msg
243 } else {
244 slog(MISC_PRINT, SLOG_ERR, "invalid msg_id [%s]! \n", msg_id); /*lint !e26*/
245 zte_write_result_to_web(wp, FAILURE);
246 return;
247 }
248 //handle whether to delete the old sms end
249
250#if 0
251 if (0 == strcmp(which_page, NEW_MESSAGE)) {
252 MSG_SEND_ST.db = ZTE_WMS_TABLE_NV;
253 } else if (0 == strcmp(which_page, NATIVE_INBOX) || 0 == strcmp(which_page, NATIVE_DRAFTBOX)) {
254 MSG_SEND_ST.db = ZTE_WMS_TABLE_NV;
255 } else if (0 == strcmp(which_page, SIM_INBOX) || 0 == strcmp(which_page, SIM_DRAFTBOX)) {
256 MSG_SEND_ST.db = ZTE_WMS_TABLE_SIM;
257 } else {
258 WebSms_LOG(LOG_INFO, "invalid which_page [%s]! \n", which_page); /*lint !e26*/
259 zte_write_result_to_web(wp, FAILURE);
260 return;
261 }
262#endif
263
264 if (0 != zte_sms_check_can_send_sms()) {
265 zte_write_result_to_web(wp, FAILURE);
266 return;
267 }
268
269 /* mc interface */
270 zte_sms_handle_DB_status_whenSend(WMS_CMD_PROCESSING);
271 if (ZTE_MC_OK_S == zte_mc_relay_sms_send_msg((T_zUfiSms_SendReq*)(&MSG_SEND_ST))) {
xf.libdd93d52023-05-12 07:10:14 -0700272 slog(MISC_PRINT, SLOG_NORMAL, "sms_send_msg_process:Send message to mc successful!\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700273 zte_write_result_to_web(wp, SUCCESS);
274 } else {
275 zte_sms_handle_DB_status_whenSend(WMS_CMD_FAILED);
xf.libdd93d52023-05-12 07:10:14 -0700276 slog(MISC_PRINT, SLOG_ERR, "sms_send_msg_process:Send message to mc fail!\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700277 zte_write_result_to_web(wp, FAILURE);
278 }
279
280}
281void zte_sms_save_msg_process(webs_t wp)
282{
283 //int j = 0;
284 unsigned int i = 0;
285 unsigned int rec_count = 0;
286 unsigned char *rec_number = NULL;
287 char_t *msg_id = NULL;
288 int message_content_len = 0;
289 unsigned char encode_type = 0;
290 unsigned char *msg_content_web = NULL;
291 char_t *sms_encode_type = NULL;
292 //char_t *which_page = NULL;
293 char_t *sms_time = NULL;
294 int s_flag = 0; //to distinguish time field from time string
295 int index = 0;
296 unsigned char rec_separate[ZTE_WMS_SEND_NUM_MAX][ZTE_WMS_ADDRESS_LEN_MAX + 1] = {0}; //separate receiver phone number
297 T_zUfiSms_SaveReq MSG_SAVE_ST;
298 char_t *mem_store = NULL;
299 char_t *tags = NULL;
300 char_t *draft_group_id = NULL;
301
302 memset(&MSG_SAVE_ST, 0, sizeof(T_zUfiSms_SaveReq));
303 mem_store = websGetVar(wp, "location", T("1"));
304 tags = websGetVar(wp, "tags", T("4"));
305 //which_page = websGetVar(wp, "which_cgi", T(""));
306 msg_content_web = websGetVar(wp, "SMSMessage", T(""));
307 rec_number = websGetVar(wp, "SMSNumber", T(""));
308 msg_id = websGetVar(wp, "Index", T(""));
309 sms_encode_type = websGetVar(wp, "encode_type", T(""));
310 sms_time = websGetVar(wp, "sms_time", T(""));
311 draft_group_id = websGetVar(wp, "draft_group_id", T(""));
312
313 //add by liuyingnan for server safe for xss attack start
314 if (DATA_NO_SAFE == zte_Safe_noSpecialChar(msg_content_web)
315 || DATA_NO_SAFE == zte_Safe_noSpecialChar(rec_number)
316 || hex_check(msg_content_web) < 0) {
317 sc_cfg_set("data_safe", "failed");
318 slog(MISC_PRINT, SLOG_DEBUG, "Get Data is no Safe:msg_content_web:%s\n", msg_content_web); /*lint !e26*/
319 zte_write_result_to_web(wp, FAILURE);
320 return;
321 }
322 //add by liuyingnan for server safe for xss attack end
323
324 /* adjust the contents' form */
325 message_content_len = strlen(msg_content_web) / 2;
326
327 if (0 == strcmp("ASCII", sms_encode_type)) { //not include chinese
328 encode_type = DCS_ASC;
329 } else if (0 == strcmp("UNICODE", sms_encode_type)) {
330 encode_type = DCS_UNICODE;
331 } else if (0 == strcmp("GSM7_span", sms_encode_type)) {
332 encode_type = DCS_SPANISH;
333 } else if (0 == strcmp("GSM7_default", sms_encode_type)) {
334 encode_type = DCS_GSM7_DEFAULT;
335 } else if (0 == strcmp("GSM7_turkey", sms_encode_type)) {
336 encode_type = DCS_TURKISH;
337 } else {
338 slog(MISC_PRINT, SLOG_DEBUG, "invalid sms_encode_type [%s]! \n", sms_encode_type); /*lint !e26*/
339 zte_write_result_to_web(wp, FAILURE);
340 return;
341 }
342
343 //parse the time field
344 for (i = 0; i < strlen(sms_time); i++) {
345 if (';' == sms_time[i]) {
346 s_flag++;
347 index = 0;
348 continue;
349 }
350
351 if ((0 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.year) - 1))) {
352 MSG_SAVE_ST.date.year[index++] = sms_time[i];
353 } else if ((1 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.month) - 1))) {
354 MSG_SAVE_ST.date.month[index++] = sms_time[i];
355 } else if ((2 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.day) - 1))) {
356 MSG_SAVE_ST.date.day[index++] = sms_time[i];
357 } else if ((3 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.hour) - 1))) {
358 MSG_SAVE_ST.date.hour[index++] = sms_time[i];
359 } else if ((4 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.min) - 1))) { /*lint !e123*/
360 MSG_SAVE_ST.date.min[index++] = sms_time[i];/*lint !e123*/
361 } else if ((5 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.sec) - 1))) {
362 MSG_SAVE_ST.date.sec[index++] = sms_time[i];
363 } else if ((6 == s_flag) && (index < (sizeof(MSG_SAVE_ST.date.timezone) - 1))) {
364 MSG_SAVE_ST.date.timezone[index++] = sms_time[i];
365 }
366
367 }
368
xf.libdd93d52023-05-12 07:10:14 -0700369 slog(MISC_PRINT, SLOG_DEBUG, "sms_save_msg_process:year is [%s];"\
lh9ed821d2023-04-07 01:36:19 -0700370 "month is [%s];day is [%s];hour is [%s];minute is [%s];second is [%s];timezone is [%s].\n", \
371 MSG_SAVE_ST.date.year, MSG_SAVE_ST.date.month, MSG_SAVE_ST.date.day, \
372 MSG_SAVE_ST.date.hour, MSG_SAVE_ST.date.min, MSG_SAVE_ST.date.sec, \
373 MSG_SAVE_ST.date.timezone);/*lint !e26 !e123 */
374//CONCAT_SMS
375 zte_libwms_db_write_send_msg_content_data(msg_content_web);
376 //doSystem("sleep 1");
377 slog(MISC_PRINT, SLOG_DEBUG, "Send message to database succesful!\n"); /*lint !e26*/
378#if 0 // Ô­À´²»Ö§³Ö¼¶Áª¶ÌÐŵĴúÂë
379 /* stuff the struct which is sending to mc */
380 (void)sms_util_asc_to_hex(msg_content_web, MSG_SAVE_ST.msg_content, message_content_len);
381#endif
382
383 MSG_SAVE_ST.msg_len = message_content_len;
384 rec_count = parseStrBySeparator(rec_number, (unsigned char *)rec_separate, ZTE_WMS_ADDRESS_LEN_MAX + 1, SEPARATOR_CHARACTER);
385
386
387 MSG_SAVE_ST.receiver_count = rec_count;
388 memcpy(MSG_SAVE_ST.dest_num, rec_separate, sizeof(rec_separate));
389 memcpy(MSG_SAVE_ST.draft_group_id, draft_group_id, sizeof(MSG_SAVE_ST.draft_group_id));
390
391 MSG_SAVE_ST.dcs = encode_type;
392 MSG_SAVE_ST.mem_store = (unsigned char)atoi(mem_store);
393 MSG_SAVE_ST.tags = (unsigned char)atoi(tags);
394 //handle whether to delete the old sms begin
395 if (0 != strcmp(msg_id, "")) {
396 MSG_SAVE_ST.id = atol(msg_id); //-1:new msg
397 } else {
398 slog(MISC_PRINT, SLOG_DEBUG, "invalid msg_id [%s]! \n", msg_id); /*lint !e26*/
399 zte_write_result_to_web(wp, FAILURE);
400 return;
401 }
402 //handle whether to delete the old sms end
403
404#if 0
405 if (0 == strcmp(which_page, NEW_MESSAGE)) {
406 MSG_SAVE_ST.db = ZTE_WMS_TABLE_NV;
407 } else if (0 == strcmp(which_page, NATIVE_INBOX) || 0 == strcmp(which_page, NATIVE_DRAFTBOX)) {
408 MSG_SAVE_ST.db = ZTE_WMS_TABLE_NV;
409 } else if (0 == strcmp(which_page, SIM_INBOX) || 0 == strcmp(which_page, SIM_DRAFTBOX)) {
410 MSG_SAVE_ST.db = ZTE_WMS_TABLE_SIM;
411 } else {
412 WebSms_LOG(LOG_INFO, "invalid which_page [%s]! \n", which_page); /*lint !e26*/
413 zte_write_result_to_web(wp, FAILURE);
414 return;
415 }
416#endif
417
418 /* print log */
419 for (i = 0; i < rec_count; i++) {
420 slog(MISC_PRINT, SLOG_DEBUG, "MSG_SAVE_ST.dest_num = [%s]\n", MSG_SAVE_ST.dest_num[i]); /*lint !e26*/
421 }
422
423 slog(MISC_PRINT, SLOG_DEBUG, "web_sms:message_content_len = [%d]\n", message_content_len); /*lint !e26*/
424#if 0
425 for (j = 0; j < message_content_len; j++) {
426 WebSms_LOG(LOG_INFO, "web_sms:MSG_SAVE_ST content=[%x]\n", MSG_SAVE_ST.msg_content[j]); /*lint !e26*/
427 }
428#endif
429 /* mc interface */
430
431 if (ZTE_MC_OK_S == zte_mc_relay_sms_write_msg((T_zUfiSms_SaveReq*)(&MSG_SAVE_ST))) {
432 slog(MISC_PRINT, SLOG_NORMAL, "web_sms:Send message to mc successful!(save msg)\n"); /*lint !e26*/
433 zte_write_result_to_web(wp, SUCCESS);
434 } else {
435 slog(MISC_PRINT, SLOG_ERR, "web_sms:Send message to mc fail!(save msg)\n"); /*lint !e26*/
436 zte_write_result_to_web(wp, FAILURE);
437 }
438
439 //zte_write_result_to_web(wp,SUCCESS);
440}
441
442void zte_sms_delete_msg_process(webs_t wp)
443{
444 unsigned int i = 0;
445 unsigned int j = 0;
446 unsigned int msg_id_count = 0;
447 unsigned char *msg_id = NULL; //receiver phone number get from web
448 unsigned char msg_id_separate[ZTE_WMS_DELETE_COUNT_MAX][WMS_MODULE_ID_LEN] = {0}; //separate receiver phone number
449 T_zUfiSms_DelReq del_sms_setting;
450 //char_t *which_page = NULL;
451 slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User delete msg!\n"));
452 WebSms_LOG(LOG_INFO, T("[SMS] User delete msg!"));
453
454 memset(&del_sms_setting, 0, sizeof(T_zUfiSms_DelReq));
455
456 msg_id = websGetVar(wp, "msg_id", T(""));
457 //which_page = websGetVar(wp, "which_cgi", T(""));
458
459 slog(MISC_PRINT, SLOG_DEBUG, "web para:[msg_id] is [%s].\n", msg_id); /*lint !e26*/
460 //WebSms_LOG(LOG_INFO,"web para:[which_page] is [%s].\n",which_page);/*lint !e26*/
461
462 msg_id_count = parseStrBySeparator(msg_id, (unsigned char *)msg_id_separate, WMS_MODULE_ID_LEN, SEPARATOR_CHARACTER);
463 slog(MISC_PRINT, SLOG_DEBUG,"!!!!goahead enter delete msg!!msg_id:%s/msg_id_count:%d.\n", msg_id, msg_id_count);
464
465 del_sms_setting.all_or_count = msg_id_count;
466 for (i = 0; i < msg_id_count; i++) {
467 del_sms_setting.id[i] = atoi(msg_id_separate[i]);
468 }
469
470 for (j = 0; j < msg_id_count; j++) {
xf.libdd93d52023-05-12 07:10:14 -0700471 slog(MISC_PRINT, SLOG_DEBUG,"sms_delete_msg_process:delete msg number:[%lu]\n", del_sms_setting.id[j]);/*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700472 }
473 /* mc interface */
474
475 zte_sms_handle_DB_status(WMS_SMS_CMD_MSG_DELETE, WMS_CMD_PROCESSING);
476 if (ZTE_MC_OK_S == zte_mc_relay_sms_delete_msg((T_zUfiSms_DelReq*)(&del_sms_setting))) {
xf.libdd93d52023-05-12 07:10:14 -0700477 slog(MISC_PRINT, SLOG_DEBUG,"sms_delete_msg_process:send delete sms cmd to mc success.\n");/*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700478 zte_write_result_to_web(wp, SUCCESS);
479 } else {
xf.libdd93d52023-05-12 07:10:14 -0700480 slog(MISC_PRINT, SLOG_DEBUG,"sms_delete_msg_process:send delete sms cmd to mc fail.\n");/*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700481 zte_sms_handle_DB_status(WMS_SMS_CMD_MSG_DELETE, WMS_CMD_FAILED);
482 zte_write_result_to_web(wp, FAILURE);
483 }
484
485 //zte_write_result_to_web(wp,SUCCESS);
486}
487
488void zte_sms_move_to_sim_msg_process(webs_t wp)
489{
490 unsigned int i = 0;
491 unsigned int j = 0;
492 unsigned int msg_id_count = 0;
493 unsigned char *msg_id = NULL; //receiver phone number get from web
494 unsigned char msg_id_separate[ZTE_WMS_DELETE_COUNT_MAX][WMS_MODULE_ID_LEN] = {0}; //separate receiver phone number
495 T_zUfiSms_DelReq del_sms_setting;
496 //char_t *which_page = NULL;
497
498 memset(&del_sms_setting, 0, sizeof(T_zUfiSms_DelReq));
499
500 msg_id = websGetVar(wp, "msg_id", T(""));
501 //which_page = websGetVar(wp, "which_cgi", T(""));
502
503 slog(MISC_PRINT, SLOG_DEBUG,"web para:[msg_id] is [%s].\n", msg_id);
504 //WEBLOG("web para:[which_page] is [%s].\n",which_page);
505
506 msg_id_count = parseStrBySeparator(msg_id, (unsigned char *)msg_id_separate, WMS_MODULE_ID_LEN, SEPARATOR_CHARACTER);
507
508 del_sms_setting.all_or_count = msg_id_count;
509 for (i = 0; i < msg_id_count; i++) {
510 del_sms_setting.id[i] = atoi(msg_id_separate[i]);
511 }
512
xf.libdd93d52023-05-12 07:10:14 -0700513 slog(MISC_PRINT, SLOG_DEBUG, "sms_move_to_sim_msg_process:del_sms_setting.all_or_count is [%lu]\n", del_sms_setting.all_or_count);
lh9ed821d2023-04-07 01:36:19 -0700514
515 for (j = 0; j < msg_id_count; j++) {
xf.libdd93d52023-05-12 07:10:14 -0700516 slog(MISC_PRINT, SLOG_DEBUG, "sms_move_to_sim_msg_process:move msg number:[%lu]\n", del_sms_setting.id[j]);
lh9ed821d2023-04-07 01:36:19 -0700517 }
518 /* mc interface */
519
520
521 if (ZTE_MC_OK_S == zte_mc_relay_sms_move_to_sim_msg((T_zUfiSms_DelReq*)(&del_sms_setting))) {
xf.libdd93d52023-05-12 07:10:14 -0700522 slog(MISC_PRINT, SLOG_NORMAL, "sms_move_to_sim_msg_process:send move sms cmd to mc success.\n");
lh9ed821d2023-04-07 01:36:19 -0700523 zte_write_result_to_web(wp, SUCCESS);
524 } else {
xf.libdd93d52023-05-12 07:10:14 -0700525 slog(MISC_PRINT, SLOG_ERR, "sms_move_to_sim_msg_process:send move sms cmd to mc fail.\n");
lh9ed821d2023-04-07 01:36:19 -0700526 zte_write_result_to_web(wp, FAILURE);
527 }
528
529 //zte_write_result_to_web(wp,SUCCESS);
530}
531void zte_goform_sms_alldel_msg_process(webs_t wp)
532{
533 int ret = 0;
534 char strPage[16] = {0};
535 WEB_DEL_SMS_BY_TYPE MSG_DEL_TYPE_ST;
536 memset(&MSG_DEL_TYPE_ST, 0, sizeof(WEB_DEL_SMS_BY_TYPE));
537
538 strncpy(strPage, websGetVar(wp, "which_page", T("")),sizeof(strPage)-1);
539 if (0 == strcmp(strPage, "inbox")) {
540 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
541 MSG_DEL_TYPE_ST.eBoxName = SMS_INBOX;
542 } else if (0 == strcmp(strPage, "outbox")) {
543 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
544 MSG_DEL_TYPE_ST.eBoxName = SMS_OUTBOX;
545 } else if (0 == strcmp(strPage, "draftbox")) {
546 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_SIM;
547 MSG_DEL_TYPE_ST.eBoxName = SMS_DRAFTBOX;
548 } else if (0 == strcmp(strPage, "me_inbox")) {
549 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
550 MSG_DEL_TYPE_ST.eBoxName = SMS_INBOX;
551 } else if (0 == strcmp(strPage, "me_outbox")) {
552 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
553 MSG_DEL_TYPE_ST.eBoxName = SMS_OUTBOX;
554 } else if (0 == strcmp(strPage, "me_draftbox")) {
555 MSG_DEL_TYPE_ST.eLocation = SMS_LOCATION_ME;
556 MSG_DEL_TYPE_ST.eBoxName = SMS_DRAFTBOX;
557 }
xf.libdd93d52023-05-12 07:10:14 -0700558 slog(MISC_PRINT, SLOG_NORMAL, "goform_sms_alldel_msg_process send message: MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE");/*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700559 //ret = zte_send_message(MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE,sizeof(WEB_DEL_SMS_BY_TYPE),(UCHAR *)&MSG_DEL_TYPE_ST); /*lint !e26 !e55*/
560 ret = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_SMS, MSG_CMD_DEL_SMS_BY_TYPE, sizeof(WEB_DEL_SMS_BY_TYPE), (UCHAR *)&MSG_DEL_TYPE_ST, 0);
561 if (0 != ret) {
562 zte_write_result_to_web(wp, FAILURE);
563 WebSms_LOG(LOG_ERR, "Delete all the message to sms failed(send msg)\n");/*lint !e26*/
564 return;
565 }
566 zte_write_result_to_web(wp, SUCCESS);
567}
568void zte_sms_set_message_center(webs_t wp)
569{
570 T_zUfiSms_ParaInfo sms_setting_st;
571 char_t *sms_center_number = NULL;
572 char_t *mem_store = NULL;
573 char_t *validity_period = NULL;
574 char_t *status_report = NULL;
575 char_t *send_retry = NULL;
576 char_t *outdate_delete = NULL;
577 char_t *default_store = NULL;
578
579 memset(&sms_setting_st, 0, sizeof(T_zUfiSms_ParaInfo));
580 slog(MISC_PRINT, SLOG_NORMAL, T("UFIx User set message center!\n"));
581
582 sms_center_number = websGetVar(wp, "MessageCenter", T(""));
583 mem_store = websGetVar(wp, "save_location", T(""));
584 validity_period = websGetVar(wp, "save_time", T(""));
585 status_report = websGetVar(wp, "status_save", T(""));
586 send_retry = websGetVar(wp, "sendfail_retry", T(""));
587 outdate_delete = websGetVar(wp, "outdate_delete", T(""));
588 default_store = websGetVar(wp, "default_store", T(""));
589
590 if (('\0' == (*sms_center_number)) || ('\0' == (*mem_store))
591 || ('\0' == (*validity_period)) || ('\0' == (*status_report))) {
592 zte_write_result_to_web(wp, FAILURE);
593 return;
594 }
595
596 if (('\0' != (*send_retry)) || ('\0' != (*outdate_delete))
597 || ('\0' != (*default_store))) {
598 sms_setting_st.sendfail_retry_on = atoi(send_retry); //open--->1;close--->0;
599 sms_setting_st.outdate_delete_on = atoi(outdate_delete); //open--->1;close--->0;
600 }
601 strncpy(sms_setting_st.default_store, default_store,sizeof(sms_setting_st.default_store)-1);
602
603 strncpy(sms_setting_st.sca, sms_center_number,sizeof(sms_setting_st.sca)-1);
604 sms_setting_st.status_report_on = atoi(status_report); //open--->1;close--->0;
605 slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.sca=%s", sms_setting_st.sca); /*lint !e26*/
606 slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.status_report_on=%d", sms_setting_st.status_report_on); /*lint !e26*/
607
608 if (!strcmp(mem_store, "native")) { //location of saving message
609 sms_setting_st.mem_store = 1;
610 } else if (!strcmp(mem_store, "sim_card")) {
611 sms_setting_st.mem_store = 0;
612 } else {
xf.libdd93d52023-05-12 07:10:14 -0700613 slog(MISC_PRINT, SLOG_ERR,"sms_set_message_center: invalid mem_store.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700614 sms_setting_st.mem_store = 1;
615 }
616 slog(MISC_PRINT, SLOG_DEBUG, "sms_setting_st.mem_store=%d", sms_setting_st.mem_store); /*lint !e26*/
617
618 if (0 == strcmp(validity_period, "twelve_hours")) { //according to 3GPP technical specification
619 sms_setting_st.tp_validity_period = 143;
620 } else if (0 == strcmp(validity_period, "one_day")) {
621 sms_setting_st.tp_validity_period = 167;
622 } else if (0 == strcmp(validity_period, "one_week")) {
623 sms_setting_st.tp_validity_period = 173;
624 } else if (0 == strcmp(validity_period, "largest")) {
625 sms_setting_st.tp_validity_period = 255;
626 } else if (0 == strcmp(validity_period, "cdma_largest")) {
627 sms_setting_st.tp_validity_period = 244;
628 } else {
xf.libdd93d52023-05-12 07:10:14 -0700629 slog(MISC_PRINT, SLOG_ERR, "sms_set_message_center: invalid validity_period.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700630 sms_setting_st.tp_validity_period = 255;
631 }
632
633 slog(MISC_PRINT, SLOG_DEBUG, " sms_setting_st.tp_validity_period=%d", sms_setting_st.tp_validity_period); /*lint !e26*/
xf.libdd93d52023-05-12 07:10:14 -0700634 slog(MISC_PRINT, SLOG_DEBUG, "sms_set_message_center:The center number is:[%s].\n", sms_setting_st.sca); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700635
636 /* mc interface */
637 if (ZTE_MC_OK_S == zte_mc_relay_sms_set_parameter((T_zUfiSms_ParaInfo*)(&sms_setting_st))) {
xf.libdd93d52023-05-12 07:10:14 -0700638 slog(MISC_PRINT, SLOG_NORMAL, "sms_set_message_center: send msg to mc success.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700639 zte_write_result_to_web(wp, SUCCESS);
640 } else {
xf.libdd93d52023-05-12 07:10:14 -0700641 slog(MISC_PRINT, SLOG_ERR, "sms_set_message_center: send msg to mc fail.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700642 zte_write_result_to_web(wp, FAILURE);
643 }
644 //zte_write_result_to_web(wp,SUCCESS);
645}
646
647/**********************************************************************
648* Function: zte_sms_view_msg_process
649* Description: to set the viewed msg as read
650* Input: the web para
651* Output:
652* Return:
653* Others:
654* Modify Date Version Author Modification
655* -----------------------------------------------
656* 2011/11/16 V1.0 chenyi first version
657**********************************************************************/
658
659void zte_sms_view_msg_process(webs_t wp)
660{
661 char_t *msg_id = NULL;
662 char_t *tag = NULL;
663 T_zUfiSms_ModifyFlag modify_tag_ptr;
664
665 unsigned int total_id = 0;
666 unsigned char id[WMS_MODULE_ID_LEN] = {0};
667 int i = 0;
668 int index = 0;
669
670 memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
671
672 /* get value from web */
673 msg_id = websGetVar(wp, "msg_id", T(""));
674 tag = websGetVar(wp, "tag", T(""));
675
676 if (('\0' == (*msg_id)) || ('\0' == (*tag))) {
677 zte_write_result_to_web(wp, FAILURE);
678 return;
679 }
680
681 modify_tag_ptr.tags = (unsigned char)atoi(tag);
682 //parse id list
683 for (i = 0; i < strlen(msg_id); i++) {
684 if (';' == msg_id[i]) {
685 if (total_id < (sizeof(modify_tag_ptr.id) / sizeof(unsigned long))) {
686 modify_tag_ptr.id[total_id] = atoi(id);
687 }
688 total_id++;
689 index = 0;
690 memset(id, 0, sizeof(id)); //reset
691 continue;
692 }
693
694 if (index < (sizeof(id) - 1)) {
695 id[index++] = msg_id[i];
696 }
697 }
698
699 modify_tag_ptr.total_id = total_id;
700
701 slog(MISC_PRINT, SLOG_DEBUG, " modify_tag_ptr.tags=%d", modify_tag_ptr.tags); /*lint !e26*/
702 slog(MISC_PRINT, SLOG_DEBUG, " modify_tag_ptr.total_id =%d", modify_tag_ptr.total_id); /*lint !e26*/
703
704#if 0
705 //msg print
706 for (i = 0 ; i < total_id; i++) {
707 WebSms_LOG(LOG_INFO, "view msg id[%d]= [%lu]\n", i, modify_tag_ptr.id[i]); /*lint !e26*/
708 }
709
710 WebSms_LOG(LOG_INFO, "view msg:tag[%c],total_id[%lu]\n", modify_tag_ptr.tags, modify_tag_ptr.total_id); /*lint !e26*/
711
712 WebSms_LOG(LOG_INFO, "view size:[%d]", (sizeof(modify_tag_ptr.id) / sizeof(unsigned long))); /*lint !e26*/
713#endif
714
715 if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
716 modify_tag_ptr.type = 1;
717 } else {
718 modify_tag_ptr.type = 0;
719 }
720 /* mc interface */
721 if (ZTE_MC_OK_S == zte_mc_relay_sms_modify_tag(&modify_tag_ptr)) {
722 slog(MISC_PRINT, SLOG_NORMAL, "web_sms:Send message to mc successful!(view message)\n"); /*lint !e26*/
723 zte_write_result_to_web(wp, SUCCESS);
724 } else {
725 slog(MISC_PRINT, SLOG_ERR, "web_sms:Send message to mc fail!(view message)\n"); /*lint !e26*/
726 zte_write_result_to_web(wp, FAILURE);
727 }
728
729 //zte_write_result_to_web(wp,SUCCESS);
730}
731
732/**********************************************************************
733* Function: zte_get_sms_data
734* Description: to get the sms data info
735* Input: the web para
736* Output:
737* Return:
738* Others:
739* Modify Date Version Author Modification
740* -----------------------------------------------
741* 2012/09/03 V1.0 liuyingnan first version
742**********************************************************************/
743
744void zte_get_sms_data(webs_t wp)
745{
746 zte_sms_query_req sms_query_req;
747 zte_sms_query_result *p_sms_query_result = NULL;
748 int result = 0;
749 int i = 0;
750 char_t *page = NULL;
751 char_t *data_per_page = NULL;
752 char_t *mem_store = NULL;
753 char_t *tags = NULL;
754 char_t *order_by = NULL;
755 T_zUfiSms_ModifyFlag modify_tag_ptr;
756 int index = 0;
757 memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
758 memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
759
760 page = websGetVar(wp, "page", T(""));
761 data_per_page = websGetVar(wp, "data_per_page", T(""));
762 mem_store = websGetVar(wp, "mem_store", T(""));
763 tags = websGetVar(wp, "tags", T(""));
764 order_by = websGetVar(wp, "order_by", T(""));
765
766 if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store) || ('\0' == *tags) || ('\0' == *order_by)) {
xf.libdd93d52023-05-12 07:10:14 -0700767 slog(MISC_PRINT, SLOG_ERR, "get_sms_data: invalid input.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700768 zte_web_feed_back_empty(wp);
769 return ;
770 }
771
772#if 0 // kw 3
773 sms_query_req.page = (uint8)atoi(page);
774#else
775 int temp_page = atoi(page);
776 if(temp_page > 255 || temp_page < 0){
777 return;
778 }
779
780 sms_query_req.page = temp_page;
781#endif
782
783 int tmp_data_per_page = atoi(data_per_page);
784 if(tmp_data_per_page > 255 || tmp_data_per_page < 0)
785 return;
786 sms_query_req.data_per_page = (uint8)tmp_data_per_page;
787
788 sms_query_req.mem_store = (uint8)atoi(mem_store);
789 sms_query_req.tags = (uint8)atoi(tags);
790 //sms_query_req.order_by = (uint8)atoi(order_by);
791 strncpy(sms_query_req.order_by, order_by, sizeof(sms_query_req.order_by) - 1);
792
793 slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u,%u,%u,%s].\n", sms_query_req.page, sms_query_req.data_per_page, sms_query_req.mem_store, \
794 sms_query_req.tags, sms_query_req.order_by); /*lint !e26*/
795
796 //handle special condition:if the @data_per_page is 0
797 if (0 == sms_query_req.data_per_page) {
798 slog(MISC_PRINT, SLOG_ERR,"to get 0 sms record.\n"); /*lint !e26*/
799 zte_web_feed_back_empty(wp);
800 return ;
801 }
802
803 p_sms_query_result = (zte_sms_query_result*)malloc(4 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
804 if (NULL == p_sms_query_result) {
805 slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
806 zte_web_feed_back_empty(wp);
807 return ;
808 }
809
810 //reset,which is important
811 memset(p_sms_query_result, 0, 4 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
812
813 slog(MISC_PRINT, SLOG_NORMAL, "SMS_DATA GET DATA FROM DB START.\n"); /*lint !e26*/
814 result = zte_libwms_get_sms_data(&sms_query_req, p_sms_query_result);
815 slog(MISC_PRINT, SLOG_DEBUG, "SMS_DATA GET DATA FROM DB END.\n"); /*lint !e26*/
816
817 if (-1 == result) {
xf.libdd93d52023-05-12 07:10:14 -0700818 slog(MISC_PRINT, SLOG_ERR, "call wms_db_get_sms_data fail.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700819 zte_web_feed_back_empty(wp);
820 //free
821// if (NULL != p_sms_query_result) { // kw 3
822 free(p_sms_query_result);
823 p_sms_query_result = NULL;
824// }
825 return ;
826 }
827
828 slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
829
830 if (0 == (*p_sms_query_result).count) {
831 zte_web_feed_back_empty(wp);
832 //free
833// if (NULL != p_sms_query_result) { // kw 3
834 free(p_sms_query_result);
835 p_sms_query_result = NULL;
836// }
837 return ;
838 }
839 //write the sms data to web
840 for (i = 0; i < (*p_sms_query_result).count; i++) {
841 if (0 == i) {
842 web_feedback_header(wp);
843 zte_rest_get_sms_data_head(wp);
844 zte_rest_get_sms_data(wp, p_sms_query_result, i, 0);
845#if 0
846 (void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_MESSAGES, SMS_ID, \
847 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
848 SMS_TAG, (*p_sms_query_result).data[i].tag, \
849 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
850 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
851 (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
852#endif
853 } else {
854 zte_rest_get_sms_data(wp, p_sms_query_result, i, 1);
855#if 0
856 (void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_ID, \
857 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
858 SMS_TAG, (*p_sms_query_result).data[i].tag, \
859 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
860 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
861 (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
862#endif
863 }
864 /*
865 if(sms_query_req.mem_store == 0 && atoi(p_sms_query_result->data[i].tag) == 1)
866 {
867 modify_tag_ptr.id[index] = atoi(p_sms_query_result->data[i].id);
868 modify_tag_ptr.total_id ++;
869 index ++;
870 }
871 */
872 }
873 /*
874 if(sms_query_req.mem_store == 0 && modify_tag_ptr.total_id > 0)
875 {
876 modify_tag_ptr.tags = 0;
877 zte_mc_relay_sms_modify_tag(&modify_tag_ptr);
878 }
879 */
880 zte_rest_get_sms_data_foot(wp);
881 //(void)websWrite(wp, T("]}"));
882
883 //free
884// if (NULL != p_sms_query_result) { // kw 3
885 free(p_sms_query_result);
886 p_sms_query_result = NULL;
887// }
888}
889
890/**********************************************************************
891* Function: zte_get_sms_data_total
892* Description: to get the total sms
893* Input: the web para
894* Output:
895* Return:
896* Others:
897* Modify Date Version Author Modification
898* -----------------------------------------------
899* 2012/09/03 V1.0 liuyingnan first version
900**********************************************************************/
901
902void zte_get_sms_data_total(webs_t wp)
903{
904 zte_sms_query_req sms_query_req;
905 zte_sms_query_result *p_sms_query_result = NULL;
906 int result = 0;
907 int i = 0;
908 char_t *page = NULL;
909 char_t *data_per_page = NULL;
910 char_t *mem_store = NULL;
911 char_t *tags = NULL;
912 char_t *order_by = NULL;
913
914 int idata_per_page = 0;
915
916 int total_pages = 0;
917 int leave_nums = 0;
918 int curr_page = 0;
919 int total_sms = 0;
920 T_zUfiSms_ModifyFlag modify_tag_ptr;
921 int index = 0;
922 memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
923
924 page = websGetVar(wp, "page", T(""));
925 data_per_page = websGetVar(wp, "data_per_page", T(""));
926 mem_store = websGetVar(wp, "mem_store", T(""));
927 tags = websGetVar(wp, "tags", T(""));
928 order_by = websGetVar(wp, "order_by", T(""));
929
930 if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store) || ('\0' == *tags) || ('\0' == *order_by)) {
xf.libdd93d52023-05-12 07:10:14 -0700931 slog(MISC_PRINT, SLOG_ERR, "get_sms_data: invalid input.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -0700932 zte_web_feed_back_empty(wp);
933 return ;
934 }
935#if 0
936 //calculate the total pages
937 total_pages = (atoi(data_per_page)) / SMS_READ_RECORD_MAX_NUM;
938 leave_nums = (atoi(data_per_page)) % SMS_READ_RECORD_MAX_NUM;
939
940 if (0 != leave_nums) {
941 total_pages++;
942 }
943
944#else
945 idata_per_page = atoi(data_per_page);
946 if(idata_per_page < 0 || idata_per_page > INT_MAX-1)
947 {
948 total_pages = 1;
949 leave_nums = 0;
950 }
951 else
952 {
953 //calculate the total pages
954 total_pages = idata_per_page / SMS_READ_RECORD_MAX_NUM;
955 leave_nums = idata_per_page % SMS_READ_RECORD_MAX_NUM;
956
957 if (0 != leave_nums) {
958 total_pages++;
959 }
960 }
961#endif
962
963 slog(MISC_PRINT, SLOG_DEBUG, "total_pages,leave_nums:[%d][%d]", total_pages, leave_nums); /*lint !e26*/
964
965 p_sms_query_result = (zte_sms_query_result*)malloc(4 + sizeof(zte_sms_data) * SMS_READ_RECORD_MAX_NUM);
966 if (NULL == p_sms_query_result) {
967 slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
968 zte_web_feed_back_empty(wp);
969 return ;
970 }
971
972 for (curr_page = 0; curr_page < total_pages; curr_page++) {
973
974 //reset
975 index = 0;
976 memset(&modify_tag_ptr, 0, sizeof(T_zUfiSms_ModifyFlag));
977 memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
978 sms_query_req.page = curr_page;
979#if 0
980 if (((total_pages - 1) == curr_page) && (0 != leave_nums)) {
981 sms_query_req.data_per_page = leave_nums;//last page
982 } else {
983 sms_query_req.data_per_page = SMS_READ_RECORD_MAX_NUM;
984 }
985#endif
986 sms_query_req.data_per_page = SMS_READ_RECORD_MAX_NUM;
987 sms_query_req.mem_store = (uint8)atoi(mem_store);
988 sms_query_req.tags = (uint8)atoi(tags);
989 //sms_query_req.order_by = (uint8)atoi(order_by);
990 strncpy(sms_query_req.order_by, order_by, sizeof(sms_query_req.order_by) - 1);
991
992 slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u,%u,%u,%s].\n", sms_query_req.page, sms_query_req.data_per_page, sms_query_req.mem_store, \
993 sms_query_req.tags, sms_query_req.order_by); /*lint !e26*/
994
995 //reset,which is important
996 memset(p_sms_query_result, 0, 4 + sizeof(zte_sms_data)*SMS_READ_RECORD_MAX_NUM);
997
998 slog(MISC_PRINT, SLOG_NORMAL, "SMS_DATA_TOTAL GET DATA FROM DB START.\n"); /*lint !e26*/
999 slog(MISC_PRINT, SLOG_DEBUG, "curr_page[%d]", sms_query_req.page); /*lint !e26*/
1000 slog(MISC_PRINT, SLOG_DEBUG, "total_sms[%d]", total_sms); /*lint !e26*/
1001 slog(MISC_PRINT, SLOG_DEBUG, " atoi(data_per_page)=%d", atoi(data_per_page)); /*lint !e26*/
1002
1003 result = zte_libwms_get_sms_data(&sms_query_req, p_sms_query_result);
1004
1005 slog(MISC_PRINT, SLOG_DEBUG, "SMS_DATA_TOTAL GET DATA FROM DB END.\n"); /*lint !e26*/
1006
1007 if (-1 == result) {
1008 WebSms_LOG(LOG_DEBUG, "read sms page [%d] fail.\n", curr_page); /*lint !e26*/
1009 //free
1010// if (NULL != p_sms_query_result) { // kw 3
1011 free(p_sms_query_result);
1012 p_sms_query_result = NULL;
1013// }
1014
1015 if (0 == curr_page) {
1016 zte_web_feed_back_empty(wp);
1017 return ;
1018 } else {
1019 break;
1020 }
1021 }
1022
1023 slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
1024
1025 if (0 == (*p_sms_query_result).count) {
1026 //free
1027// if (NULL != p_sms_query_result) { // kw 3
1028 free(p_sms_query_result);
1029 p_sms_query_result = NULL;
1030// }
1031
1032 if (0 == curr_page) {
1033 zte_web_feed_back_empty(wp);
1034 return ;
1035 } else {
1036 break;
1037 }
1038 }
1039
1040 //write the sms data to web
1041 for (i = 0; (i < (*p_sms_query_result).count) && (total_sms < atoi(data_per_page)); i++) {
1042 if ((0 == i) && (0 == curr_page)) {
1043 web_feedback_header(wp);
1044 zte_rest_get_sms_data_head(wp);
1045 zte_rest_get_sms_data(wp, p_sms_query_result, i, 0);
1046#if 0
1047 (void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_MESSAGES, SMS_ID, \
1048 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
1049 SMS_TAG, (*p_sms_query_result).data[i].tag, \
1050 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
1051 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
1052 (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
1053 total_sms ++;
1054#endif
1055 } else {
1056 zte_rest_get_sms_data(wp, p_sms_query_result, i, 1);
1057#if 0
1058 (void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\",\"%s\":\"%s\"}"), SMS_ID, \
1059 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
1060 SMS_TAG, (*p_sms_query_result).data[i].tag, \
1061 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
1062 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
1063 (*p_sms_query_result).data[i].date.timezone, SMS_DRAFT_GROUP_ID, (*p_sms_query_result).data[i].draft_group_id);
1064 total_sms ++;
1065#endif
1066 }
1067 /*
1068 if(sms_query_req.mem_store == 0 && atoi(p_sms_query_result->data[i].tag) == 1)
1069 {
1070 modify_tag_ptr.id[index] = atoi(p_sms_query_result->data[i].id);
1071 modify_tag_ptr.total_id ++;
1072 index ++;
1073 }
1074 */
1075 }
1076 /*
1077 if(sms_query_req.mem_store == 0 && modify_tag_ptr.total_id > 0
1078 && !(wp->flags & WEBS_XML_CLIENT_REQUEST))
1079 {
1080 modify_tag_ptr.tags = 0;
1081 zte_mc_relay_sms_modify_tag(&modify_tag_ptr);
1082 }
1083 */
1084 }
1085 zte_rest_get_sms_data_foot(wp);
1086 //(void)websWrite(wp, T("]}"));
1087
1088 //free
1089// if (NULL != p_sms_query_result) { // kw 3
1090 free(p_sms_query_result);
1091 p_sms_query_result = NULL;
1092// }
1093}
1094
1095/**********************************************************************
1096* Function: zte_get_sms_parameter_info
1097* Description: to get the sms parameter info
1098* Input: the web para
1099* Output:
1100* Return:
1101* Others:
1102* Modify Date Version Author Modification
1103* -----------------------------------------------
1104* 2012/09/03 V1.0 liuyingnan first version
1105**********************************************************************/
1106
1107void zte_get_sms_parameter_info(webs_t wp)
1108{
1109 T_zUfiSms_ParaInfo sms_parameter_info;
1110 int result = 0;
1111
1112 memset(&sms_parameter_info, 0, sizeof(T_zUfiSms_ParaInfo));
1113
1114 slog(MISC_PRINT, SLOG_NORMAL, "SMS_PARAMETER_INFO GET DATA FROM DB START.\n"); /*lint !e26*/
1115 result = zte_libwms_get_parameter(&sms_parameter_info);
1116 slog(MISC_PRINT, SLOG_DEBUG, "SMS_PARAMETER_INFO GET DATA FROM DB END.\n"); /*lint !e26*/
1117 if (-1 == result) {
xf.libdd93d52023-05-12 07:10:14 -07001118 slog(MISC_PRINT, SLOG_ERR, "call libwms_get_parameter fail.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -07001119 zte_web_feed_back_empty(wp);
1120 return ;
1121 }
1122
1123 web_feedback_header(wp);
1124 zte_rest_sms_parameter(wp, sms_parameter_info);
1125#if 0
1126 (void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%d\",\"%s\":\"%u\",\"%s\":\"%u\"}"), SMS_PARAMETER_SCA, sms_parameter_info.sca, SMS_PARAMETER_MEM_STORE, sms_parameter_info.mem_store, \
1127 SMS_PARAMETER_VALIDITY_PERIOD, sms_parameter_info.tp_validity_period, \
1128 SMS_PARAMETER_STATUS_REPORT, sms_parameter_info.status_report_on);
1129#endif
1130}
1131
1132
1133/**********************************************************************
1134* Function: zte_get_sms_cmd_status_info
1135* Description: to get the sms cmd status info
1136* Input: the web para
1137* Output:
1138* Return:
1139* Others:
1140* Modify Date Version Author Modification
1141* -----------------------------------------------
1142* 2012/09/03 V1.0 liuyingnan first version
1143**********************************************************************/
1144
1145void zte_get_sms_cmd_status_info(webs_t wp)
1146{
1147 T_zUfiSms_StatusInfo cmd_status_info;
1148 int result = 0;
1149 char *sms_cmd = NULL;
1150
1151 memset(&cmd_status_info, 0, sizeof(T_zUfiSms_StatusInfo));
1152
1153 //read sms_cmd
1154 sms_cmd = websGetVar(wp, "sms_cmd", T(""));
1155 if ('\0' == *sms_cmd) {
1156 slog(MISC_PRINT, SLOG_ERR, "sms_cmd is empty.\n"); /*lint !e26*/
1157 zte_web_feed_back_empty(wp);
1158 return ;
1159 }
1160
1161 /*lint -e64*/
1162 int cmd = atoi(sms_cmd);
1163 if(cmd >= WMS_SMS_CMD_NONE && cmd <= WMS_SMS_CMD_WMS_MAX){
1164 cmd_status_info.cmd = (T_zUfiSms_CmdType)cmd;
1165 } else {
1166 slog(MISC_PRINT, SLOG_ERR, "sms_cmd is %d.\n",cmd);
1167 zte_web_feed_back_empty(wp);
1168 return ;
1169 }
1170
1171 slog(MISC_PRINT, SLOG_NORMAL, "sms_cmd_status_info GET DATA FROM DB START.\n"); /*lint !e26*/
1172 result = zte_libwms_get_cmd_status(&cmd_status_info);
1173 slog(MISC_PRINT, SLOG_DEBUG, "sms_cmd_status_info GET DATA FROM DB END.\n"); /*lint !e26*/
1174 if (-1 == result) {
xf.libdd93d52023-05-12 07:10:14 -07001175 slog(MISC_PRINT, SLOG_ERR, "call libwms_get_cmd_status fail.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -07001176 zte_web_feed_back_empty(wp);
1177 return ;
1178 }
1179
1180 web_feedback_header(wp);
1181 zte_rest_cmd_write_head(wp);
1182 zte_rest_cmd_write(wp, SMS_CMD, sms_cmd, 1);
1183 zte_rest_cmd_write_int(wp, SMS_CMD_STATUS_RESULT, cmd_status_info.cmd_status, 0);
1184 zte_rest_cmd_write_foot(wp);
1185 //(void)websWrite(wp, T("{\"%s\":\"%s\",\"%s\":\"%d\"}"),SMS_CMD,sms_cmd,SMS_CMD_STATUS_RESULT,cmd_status_info.cmd_status);
1186}
1187
1188
1189int zte_get_sms_remain_capacity()
1190{
1191 int sms_remain = 0;
1192 int sms_nv_total = 0;
1193 int sms_sim_total = 0;
1194 int sms_nv_rev_total = 0;
1195 int sms_nv_send_total = 0;
1196 int sms_nv_draftbox_total = 0;
1197 char default_store[NV_ITEM_STRING_LEN_10] = {0};
1198
1199 sc_cfg_get("default_store", default_store, sizeof(default_store));
1200 if (0 == strcmp(default_store, "sim")) {
1201 sms_sim_total = zte_libwms_get_sms_capability(0);//sim
1202 //¿¨²à´æ´¢ÈÝÁ¿ÒԶμÆË㣬ÎÞ·¨°´Ìõͳ¼Æ
1203 //Òò´ËÈç¹ûжÌÐÅ´æ´¢ÔÚ¿¨²à£¬ÄÇô¾Í²»½øÐÐÅжÏ
1204 //´Ë´¦¸³ÖµÎª10£¬´óÓÚµ÷Óñ¾º¯ÊýʱÅжϵÄ5Ìõ
1205 //¿¨²à¿Õ¼äÊÇ·ñ³ä×ãÄܽÓÊÕÁ÷Á¿Ð£×¼¶ÌÐŵÄÅжÏ
1206 //½»ÓÉЭÒéÕ»Åжϴ¦Àí
1207 sms_remain = 10;
xf.libdd93d52023-05-12 07:10:14 -07001208 slog(MISC_PRINT, SLOG_DEBUG,"[traffic] get_sms_remain_capacity, default_store = %s, total = %d!\n", default_store, sms_sim_total);
lh9ed821d2023-04-07 01:36:19 -07001209 } else {
1210 sms_nv_total = zte_libwms_get_sms_capability(1);//nv
1211 sms_nv_rev_total = zte_libwms_get_sms_used(1, 0); //nv rev read
1212 sms_nv_rev_total += zte_libwms_get_sms_used(1, 1); //nv rev not read
1213 sms_nv_send_total = zte_libwms_get_sms_used(1, 2); //nv send
1214 sms_nv_draftbox_total = zte_libwms_get_sms_used(1, 3); //nv draftbox 1,not send
1215 sms_nv_draftbox_total += zte_libwms_get_sms_used(1, 4); //nv draftbox 2,write
1216
1217 if(sms_nv_total < 0 || sms_nv_total > INT_MAX -1){
1218 sms_nv_total = INT_MAX;
1219 }
1220
1221 sms_remain = sms_nv_total - sms_nv_rev_total - sms_nv_send_total - sms_nv_draftbox_total;
xf.libdd93d52023-05-12 07:10:14 -07001222 slog(MISC_PRINT, SLOG_DEBUG,"[traffic] get_sms_remain_capacity, default_store = %s, total = %d, rev= %d, send= %d, draft= %d!\n", default_store, sms_nv_total, sms_nv_rev_total, sms_nv_send_total, sms_nv_draftbox_total);
lh9ed821d2023-04-07 01:36:19 -07001223 }
xf.libdd93d52023-05-12 07:10:14 -07001224 slog(MISC_PRINT, SLOG_DEBUG,"[traffic] get_sms_remain_capacity, default_store = %s, sms_remain = %d!\n", default_store, sms_remain);
lh9ed821d2023-04-07 01:36:19 -07001225 return sms_remain;
1226}
1227
1228
1229/**********************************************************************
1230* Function: zte_get_sms_capacity_info
1231* Description: to get the sms capacity info
1232* Input: the web para
1233* Output:
1234* Return:
1235* Others:
1236* Modify Date Version Author Modification
1237* -----------------------------------------------
1238* 2012/09/03 V1.0 liuyingnan first version
1239**********************************************************************/
1240
1241void zte_get_sms_capacity_info(webs_t wp)
1242{
1243 int sms_nv_total = 0;
1244 int sms_sim_total = 0;
1245
1246 //int sms_nv_used = 0;
1247 //int sms_sim_used = 0;
1248
1249 int sms_nv_rev_total = 0;
1250 int sms_nv_send_total = 0;
1251 int sms_nv_draftbox_total = 0;
1252 int sms_sim_rev_total = 0;
1253 int sms_sim_send_total = 0;
1254 int sms_sim_draftbox_total = 0;
1255
1256 //WebSms_LOG(LOG_INFO,"sms_capacity_info GET DATA FROM DB START.\n");
1257
1258
1259 sms_nv_total = zte_libwms_get_sms_capability(1);//nv
1260 sms_sim_total = zte_libwms_get_sms_capability(0);//sim
1261
1262 sms_nv_rev_total = zte_libwms_get_sms_used(1, 0); //nv rev read
1263 sms_nv_rev_total += zte_libwms_get_sms_used(1, 1); //nv rev not read
1264 sms_nv_send_total = zte_libwms_get_sms_used(1, 2); //nv send
1265 sms_nv_draftbox_total = zte_libwms_get_sms_used(1, 3); //nv draftbox 1,not send
1266 sms_nv_draftbox_total += zte_libwms_get_sms_used(1, 4); //nv draftbox 2,write
1267
1268 sms_sim_rev_total = zte_libwms_get_sms_used(0, 0); //sim rev read
1269 sms_sim_rev_total += zte_libwms_get_sms_used(0, 1); //sim rev not read
1270 sms_sim_send_total = zte_libwms_get_sms_used(0, 2); //sim send
1271 sms_sim_draftbox_total = zte_libwms_get_sms_used(0, 3); //sim draftbox 1,not send
1272 sms_sim_draftbox_total += zte_libwms_get_sms_used(0, 4); //sim draftbox 2,write
1273
1274 //WebSms_LOG(LOG_INFO,"sms_capacity_info GET DATA FROM DB END.\n");/*lint !e26*/
1275
1276 web_feedback_header(wp);
1277 zte_rest_cmd_write_head(wp);
1278 zte_rest_cmd_write_int(wp, SMS_NV_TOTAL, sms_nv_total, 1);
1279 zte_rest_cmd_write_int(wp, SMS_SIM_TOTAL, sms_sim_total, 1);
1280 zte_rest_cmd_write_int(wp, SMS_NV_REV_TOTAL, sms_nv_rev_total, 1);
1281 zte_rest_cmd_write_int(wp, SMS_NV_SEND_TOTAL, sms_nv_send_total, 1);
1282 zte_rest_cmd_write_int(wp, SMS_NV_DRAFTBOX_TOTAL, sms_nv_draftbox_total, 1);
1283 zte_rest_cmd_write_int(wp, SMS_SIM_REV_TOTAL, sms_sim_rev_total, 1);
1284 zte_rest_cmd_write_int(wp, SMS_SIM_SEND_TOTAL, sms_sim_send_total, 1);
1285 zte_rest_cmd_write_int(wp, SMS_SIM_DRAFTBOX_TOTAL, sms_sim_draftbox_total, 0);
1286 zte_rest_cmd_write_foot(wp);
1287
1288 sc_cfg_set("sms_db_change", "0");
1289 slog(MISC_PRINT, SLOG_DEBUG, "nv set sms_db_change=0.\n"); /*lint !e26*/
1290#if 0
1291 (void)websWrite(wp, T("{\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\"}"), \
1292 SMS_NV_TOTAL, sms_nv_total, SMS_SIM_TOTAL, sms_sim_total, \
1293 SMS_NV_REV_TOTAL, sms_nv_rev_total, SMS_NV_SEND_TOTAL, sms_nv_send_total, SMS_NV_DRAFTBOX_TOTAL, sms_nv_draftbox_total, \
1294 SMS_SIM_REV_TOTAL, sms_sim_rev_total, SMS_SIM_SEND_TOTAL, sms_sim_send_total, SMS_SIM_DRAFTBOX_TOTAL, sms_sim_draftbox_total \
1295 );
1296#endif
1297}
1298
1299/**********************************************************************
1300* Function: zte_get_sms_status_rpt_data
1301* Description: to get the sms status report data
1302* Input: the web para
1303* Output:
1304* Return:
1305* Others:
1306* Modify Date Version Author Modification
1307* -----------------------------------------------
1308* 2012/09/03 V1.0 liuyingnan first version
1309**********************************************************************/
1310void zte_get_sms_status_rpt_data(webs_t wp)
1311{
1312 zte_sms_query_req sms_query_req;
1313 zte_sms_query_result *p_sms_query_result = NULL;
1314 int result = 0;
1315 int i = 0;
1316 char_t *page = NULL;
1317 char_t *data_per_page = NULL;
1318
1319 memset(&sms_query_req, 0, sizeof(zte_sms_query_req));
1320
1321 page = websGetVar(wp, "page", T(""));
1322 data_per_page = websGetVar(wp, "data_per_page", T(""));
1323
1324 if (('\0' == *page) || ('\0' == *data_per_page)) {
xf.libdd93d52023-05-12 07:10:14 -07001325 slog(MISC_PRINT, SLOG_ERR, "get_sms_data: invalid input.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -07001326 zte_web_feed_back_empty(wp);
1327 return ;
1328 }
1329 int tmp_page = atoi(page);
1330 int tmp_data_per_page = atoi(data_per_page);
1331 if((tmp_page > 255 || tmp_page < 0)
1332 ||(tmp_data_per_page > 255 || tmp_data_per_page < 0)){
1333 slog(MISC_PRINT, SLOG_ERR, "sms_query_req:err[%d,%d].\n", tmp_page, tmp_data_per_page); /*lint !e26*/
1334 zte_web_feed_back_empty(wp);
1335 return ;
1336 }
1337 sms_query_req.page = (uint8)tmp_page;
1338 sms_query_req.data_per_page = (uint8)tmp_data_per_page;
1339
1340 slog(MISC_PRINT, SLOG_DEBUG, "sms_query_req:[%u,%u].\n", sms_query_req.page, sms_query_req.data_per_page); /*lint !e26*/
1341
1342 p_sms_query_result = (zte_sms_query_result*)malloc(1 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
1343 if (NULL == p_sms_query_result) {
1344 slog(MISC_PRINT, SLOG_ERR, "malloc sms result mem fail.\n"); /*lint !e26*/
1345 zte_web_feed_back_empty(wp);
1346 return ;
1347 }
1348
1349 //reset,which is important
1350 memset(p_sms_query_result, 0, 1 + sizeof(zte_sms_data) * (sms_query_req.data_per_page));
1351 slog(MISC_PRINT, SLOG_NORMAL, "sms_status_rpt_data GET DATA FROM DB START.\n"); /*lint !e26*/
1352 result = zte_libwms_get_sms_report(&sms_query_req, p_sms_query_result);
1353 slog(MISC_PRINT, SLOG_DEBUG, "sms_status_rpt_data GET DATA FROM DB END.\n"); /*lint !e26*/
1354 if (-1 == result) {
xf.libdd93d52023-05-12 07:10:14 -07001355 slog(MISC_PRINT, SLOG_ERR, "call libwms_get_sms_report fail.\n"); /*lint !e26*/
lh9ed821d2023-04-07 01:36:19 -07001356 zte_web_feed_back_empty(wp);
1357 //free
1358// if (NULL != p_sms_query_result) { // kw 3
1359 free(p_sms_query_result);
1360 p_sms_query_result = NULL;
1361// }
1362 return ;
1363 }
1364
1365 slog(MISC_PRINT, SLOG_DEBUG, "total query count for status rpt: [%u].\n", (*p_sms_query_result).count); /*lint !e26*/
1366
1367 if (0 == (*p_sms_query_result).count) {
1368 zte_web_feed_back_empty(wp);
1369 //free
1370// if (NULL != p_sms_query_result) { // kw 3
1371 free(p_sms_query_result);
1372 p_sms_query_result = NULL;
1373// }
1374 return ;
1375 }
1376 //write the sms data to web
1377 for (i = 0; i < (*p_sms_query_result).count; i++) {
1378 if (0 == i) {
1379 web_feedback_header(wp);
1380 zte_rest_get_sms_data_head(wp);
1381 zte_rest_sms_status_rpt(wp, p_sms_query_result, i, 0);
1382#if 0
1383 (void)websWrite(wp, T("{\"%s\":[{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\"}"), SMS_MESSAGES, SMS_ID, \
1384 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
1385 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
1386 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
1387 (*p_sms_query_result).data[i].date.timezone);
1388#endif
1389
1390 } else {
1391 zte_rest_sms_status_rpt(wp, p_sms_query_result, i, 1);
1392#if 0
1393 (void)websWrite(wp, T(",{\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s\",\"%s\":\"%s,%s,%s,%s,%s,%s,%s\"}"), SMS_ID, \
1394 (*p_sms_query_result).data[i].id, SMS_NUMBER, (*p_sms_query_result).data[i].number, SMS_CONTENT, (*p_sms_query_result).data[i].sms_content, \
1395 SMS_DATE, (*p_sms_query_result).data[i].date.year, (*p_sms_query_result).data[i].date.month, (*p_sms_query_result).data[i].date.day, \
1396 (*p_sms_query_result).data[i].date.hour, (*p_sms_query_result).data[i].date.min, (*p_sms_query_result).data[i].date.sec, \
1397 (*p_sms_query_result).data[i].date.timezone);
1398#endif
1399
1400 }
1401 }
1402 zte_rest_get_sms_data_foot(wp);
1403 //(void)websWrite(wp, T("]}"));
1404
1405 //free
1406// if (NULL != p_sms_query_result) { // kw 3
1407 free(p_sms_query_result);
1408 p_sms_query_result = NULL;
1409// }
1410}
1411
1412/**********************************************************************
1413* Function: zte_get_sms_unread_count
1414* Description: to get the unread sms count
1415* Input: the web para
1416* Output:
1417* Return:
1418* Others:
1419* Modify Date Version Author Modification
1420* -----------------------------------------------
1421* 2012/09/03 V1.0 liuyingnan first version
1422**********************************************************************/
1423void zte_get_sms_unread_count(webs_t wp)
1424{
1425 int sms_dev_unread_count = 0;
1426 int sms_sim_unread_count = 0;
1427 slog(MISC_PRINT, SLOG_NORMAL, "sms_unread_count GET DATA FROM DB START.\n"); /*lint !e26*/
1428 sms_dev_unread_count = zte_libwms_get_sms_used(1, 1); //nv unread
1429 sms_sim_unread_count = zte_libwms_get_sms_used(0, 1); //sim unread
1430 slog(MISC_PRINT, SLOG_DEBUG, "sms_unread_count GET DATA FROM DB END.\n"); /*lint !e26*/
1431
1432
1433 web_feedback_header(wp);
1434 zte_rest_cmd_write_head(wp);
1435
1436 if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
1437 zte_rest_cmd_write_int(wp, CMD_SMS_UNREAD_COUNT, sms_dev_unread_count, 0);
1438 zte_rest_cmd_write_int(wp, SMS_DEV_UNREAD_COUNT, sms_dev_unread_count, 1);
1439 zte_rest_cmd_write_int(wp, SMS_SIM_UNREAD_COUNT, sms_sim_unread_count, 0);
1440 } else {
1441 (void)websWrite(wp, T("\"%s\":\"%d\",\"%s\":\"%d\",\"%s\":\"%d\""), \
1442 CMD_SMS_UNREAD_COUNT, sms_dev_unread_count, \
1443 SMS_DEV_UNREAD_COUNT, sms_dev_unread_count, \
1444 SMS_SIM_UNREAD_COUNT, sms_sim_unread_count);
1445 }
1446
1447 zte_rest_cmd_write_foot(wp);
1448
1449}
1450
1451/**********************************************************************
1452* Function: zte_get_sms_unread_num
1453* Description: to get the unread sms num
1454* Input: the web para
1455* Output:
1456* Return:
1457* Others:
1458* Modify Date Version Author Modification
1459* -----------------------------------------------
1460* 2012/09/03 V1.0 liuyingnan first version
1461**********************************************************************/
1462void zte_get_sms_unread_num(webs_t wp)
1463{
1464 int sms_dev_unread_count = 0;
1465 sms_dev_unread_count = zte_libwms_get_sms_used(1, 1); //nv unread
1466
1467 if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
1468 zte_rest_cmd_write_int(wp, NV_SMS_UNREAD_NUM, sms_dev_unread_count, 0);
1469 } else {
1470 (void)websWrite(wp, T("\"%s\":\"%d\""), NV_SMS_UNREAD_NUM, sms_dev_unread_count);
1471 }
1472}
1473
1474/**********************************************************************
1475* Function: zte_web_feed_back_empty
1476* Description: to write empty info to web
1477* Input: the web para
1478* Output:
1479* Return:
1480* Others:
1481* Modify Date Version Author Modification
1482* -----------------------------------------------
1483* 2012/09/03 V1.0 liuyingnan first version
1484**********************************************************************/
1485
1486static void zte_web_feed_back_empty(webs_t wp)
1487{
1488 if (NULL == wp) {
1489 return;
1490 }
1491
1492 web_feedback_header(wp);
1493 if (wp->flags & WEBS_XML_CLIENT_REQUEST) {
1494 websWrite(wp, T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
1495 websWrite(wp, T("<%s>empty</%s>\n"), SMS_MESSAGES, SMS_MESSAGES);
1496 } else {
1497 (void)websWrite(wp, T("{\"%s\":[]}"), SMS_MESSAGES);
1498 }
1499
1500}
1501
1502/******************************************************
1503* Function: parseStrBySeparator()
1504* Description: separate the string by a specific character
1505* Input:
1506* Output:
1507* Return: -1--->failed, 0--->successful
1508* Others:
1509* Modify Date Version Author Modification
1510* 2010/10/27 V1.0 huangmin create
15112012/06/20 v2.0 chenyi modify
1512*******************************************************/
1513static unsigned int parseStrBySeparator
1514(
1515 unsigned char* input,
1516 unsigned char* output,
1517 int destLen,
1518 unsigned char separator
1519)
1520{
1521 int i, j, k;
1522 int srcLen = 0;
1523 i = j = k = 0;
1524
1525 if (NULL == input || NULL == output || destLen == 0 || strlen(input) == 0) {
1526 slog(MISC_PRINT, SLOG_ERR, "parseStrBySemicolon: param is null!\n"); /*lint !e26*/
1527 return 0;
1528 }
1529
1530 srcLen = strlen(input) + 1;//which contains the '\0'
1531
1532 for (i = 0; i < srcLen; i++) {
1533 if ('\0' == input[i]) {
1534 if (k <= (destLen - 1)) {
1535 *(output + destLen * j + k) = '\0';
1536 } else {
1537 *(output + destLen * j + (destLen - 1)) = '\0';
1538 }
1539
1540 return j + 1;
1541 }
1542
1543 if (separator == input[i]) {
1544 if (k <= (destLen - 1)) {
1545 *(output + destLen * j + k) = '\0';
1546 } else {
1547 *(output + destLen * j + (destLen - 1)) = '\0';
1548 }
1549
1550 if ('\0' != input[i + 1]) {
1551 k = 0;
1552 j++;
1553 }
1554 } else {
1555 if (k < (destLen - 1)) {
1556 *(output + destLen * j + k) = input[i];
1557 k++;
1558 }
1559 }
1560 }
1561
1562 return j;
1563}
1564
1565#if 0
1566/******************************************************
1567* Function: sms_util_asc_to_hex()
1568* Description: transform the ASCII string of SMS code to hex
1569* Input:
1570* Output:
1571* Return: -1--->failed, 0--->successful
1572* Others:
1573* Modify Date Version Author Modification
1574* 2010/10/27 V1.0 huangmin create
1575*******************************************************/
1576static int sms_util_asc_to_hex /*lint !e528*/
1577(
1578 unsigned char *in_ptr, /* IN: Pointer to the Hex data (in ASCII format) */
1579 unsigned char *out_ptr, /* OUT: Pointer to the result buffer(converted data) */
1580 int len /* IN: Length of the input data pointer (Hex data) */
1581)
1582{
1583 unsigned char *str;
1584 unsigned char temp_buf[3];
1585 int i;
1586 unsigned int num_val;
1587 int result = 0;
1588
1589 str = in_ptr;
1590
1591 len = len * 2;
1592
1593 //WebSms_LOG(LOG_INFO,"in sms_util_asc_to_hex\n");/*lint !e26*/
1594 while (len > 0) {
1595 for (i = 0; (i < 2) && (*str != '\0'); i++) {
1596 temp_buf[i] = *str++;
1597 }
1598 temp_buf[i] = '\0';
1599 if (asc_util_atoi(&num_val, temp_buf, 16) != 0) {
1600 /* We got a out of range value */
1601 result = -1;
1602 }
1603 *out_ptr++ = (unsigned char)num_val;
1604 // WebSms_LOG(LOG_INFO,"goahead=====middle===out_ptr===%s",out_ptr);/*lint !e26*/
1605 len -= i;
1606 }
1607 WebSms_LOG(LOG_INFO, "leave sms_util_asc_to_hex\n"); /*lint !e26*/
1608
1609 return result;
1610} /* ZTE_dsat707sms_asscii_to_is637_data */
1611
1612
1613/******************************************************
1614* Function: asc_util_atoi()
1615* Description: transform the ASCII string to integer
1616* Input:
1617* Output:
1618* Return: -1--->failed, 0--->successful
1619* Others:
1620* Modify Date Version Author Modification
1621* 2010/10/27 V1.0 huangmin create
1622*******************************************************/
1623static int asc_util_atoi
1624(
1625 unsigned int *val_arg_ptr, /* value returned */
1626 const unsigned char *s, /* points to string to eval */
1627 unsigned int r /* radix */
1628)
1629{
1630 int err_ret = 0;
1631 unsigned char c;
1632 unsigned int val, val_lim, dig_lim;
1633
1634 val = 0;
1635 val_lim = (unsigned int)((unsigned int)0xFFFFFFFF / r);
1636 dig_lim = (unsigned int)((unsigned int)0xFFFFFFFF % r);
1637
1638 while ((c = *s++) != '\0') {
1639 if (c != ' ') {
1640 c = (unsigned char) UPCASE(c);
1641 if (c >= '0' && c <= '9') {
1642 c -= '0';
1643 } else if (c >= 'A') {
1644 c -= 'A' - 10;
1645 } else {
1646 err_ret = -1; /* char code too small */
1647 break;
1648 }
1649
1650 if (c >= r || val > val_lim
1651 || (val == val_lim && c > dig_lim)) {
1652 err_ret = -1; /* char code too large */
1653 break;
1654 } else {
1655 err_ret = 0; /* arg found: OK so far*/
1656 val = (unsigned int)(val * r + c);
1657 }
1658 }
1659 *val_arg_ptr = val;
1660 }
1661
1662 return err_ret;
1663}
1664#endif
1665void zte_get_boradcast_data(webs_t wp)
1666{
1667 zte_wms_cell_bro_s_type *p_bro_query_result = NULL;
1668
1669 int result = 0;
1670
xf.libdd93d52023-05-12 07:10:14 -07001671 slog(MISC_PRINT, SLOG_NORMAL, "get_boradcast_data GET DATA FROM DB START.\n");
lh9ed821d2023-04-07 01:36:19 -07001672 p_bro_query_result = (zte_wms_cell_bro_s_type*)malloc(1 + sizeof(zte_wms_cell_bro_s_type));
1673 if(p_bro_query_result == NULL) return;
1674 result = zte_libwms_get_cell_bro(p_bro_query_result);
1675
xf.libdd93d52023-05-12 07:10:14 -07001676 slog(MISC_PRINT, SLOG_DEBUG, "get_boradcast_data GET DATA FROM DB END.\n");
lh9ed821d2023-04-07 01:36:19 -07001677 if (-1 == result) {
xf.libdd93d52023-05-12 07:10:14 -07001678 slog(MISC_PRINT, SLOG_ERR, "call libwms_get_cell_bro fail.\n");
lh9ed821d2023-04-07 01:36:19 -07001679 zte_web_feed_back_empty(wp);
1680 //cov
1681 free(p_bro_query_result);
1682 p_bro_query_result = NULL;
1683 return ;
1684 }
1685 web_feedback_header(wp);
1686 zte_rest_get_bro_data_head(wp);
1687 zte_rest_boradcast_data(wp, p_bro_query_result);
1688 zte_rest_get_bro_data_foot(wp);
1689
1690
1691
1692
1693 //if (NULL != p_bro_query_result) {
1694 free(p_bro_query_result);
1695 p_bro_query_result = NULL;
1696 //}
1697
1698}