lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /************************************************************************ |
| 2 | * °æÈ¨ËùÓÐ (C)2010, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£ |
| 3 | * |
| 4 | * ÎļþÃû³Æ£º zte_web_pbm.c |
| 5 | * Îļþ±êʶ£º |
| 6 | * ÄÚÈÝÕªÒª£º |
| 7 | * ÆäËü˵Ã÷£º |
| 8 | * µ±Ç°°æ±¾£º V0.1 |
| 9 | * ×÷ Õߣº zyt |
| 10 | * Íê³ÉÈÕÆÚ£º 2010-11-06 |
| 11 | * |
| 12 | * Ð޸ļǼ1£º |
| 13 | * ÐÞ¸ÄÄÚÈÝ£º³õʼ°æ±¾ |
| 14 | ************************************************************************/ |
| 15 | |
| 16 | #include "zte_web_interface.h" |
| 17 | //#include "../../phonebook/phonebook.h" |
| 18 | #include "zte_web_get_fw_para.h" |
| 19 | #include "zte_web_pbm.h" |
| 20 | |
| 21 | static void zte_web_pbm_feed_back_empty(webs_t wp); |
| 22 | |
| 23 | #define IFSTREQUAL(str1, str2) (strcmp((str1), (str2))?0:1) |
| 24 | |
| 25 | int zte_web_pbm_check_can_process() |
| 26 | { |
| 27 | char flag[20] = {0}; |
| 28 | |
| 29 | (void)zte_web_read(ZTE_PBM_NV, flag); |
| 30 | if (0 == strcmp(flag, PBM_OPRATING)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 31 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_check_can_process flag=%s, not can process.\n", flag); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 32 | return 0; |
| 33 | } else { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 34 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_check_can_process flag=%s, can process.\n", flag); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 35 | return -1; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | static data_safe_result_type_t zte_Safe_noSpecialChar_ucs2(char *str) |
| 40 | { |
| 41 | int i = 0; |
| 42 | int len = 0; |
| 43 | if (NULL == str || strlen(str) < 4) { |
| 44 | return 0; |
| 45 | } |
| 46 | len = strlen(str); |
| 47 | for (i = 0; i < len; i=i+4) { |
| 48 | if (str[i] == '0' && str[i+1] == '0') { |
| 49 | if(str[i+2] == '2') {//"'/ |
| 50 | if(str[i+3] == '2' || str[i+3] == '7' || str[i+3] == 'f' || str[i+3] == 'F') |
| 51 | return 0; |
| 52 | } else if(str[i+2] == '3') {//<> |
| 53 | if(str[i+3] == 'c' || str[i+3] == 'C' || str[i+3] == 'e' || str[i+3] == 'E') |
| 54 | return 0; |
| 55 | } else if(str[i+2] == '5') {//\ |
| 56 | if(str[i+3] == 'c' || str[i+3] == 'C') |
| 57 | return 0; |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | return 1; |
| 62 | |
| 63 | } |
| 64 | |
| 65 | /********************************************************************** |
| 66 | * Function: zte_web_pbm_contact_saveto_sim |
| 67 | * Description: |
| 68 | * Input: wp:web para;sim_contact_location:save location |
| 69 | * Output: |
| 70 | * Return: void |
| 71 | * Others: |
| 72 | * Modify Date Version Author Modification |
| 73 | * ----------------------------------------------- |
| 74 | * 20120926 V1.0 liuyingnan first version |
| 75 | **********************************************************************/ |
| 76 | static void zte_web_pbm_contact_saveto_sim(webs_t wp, int sim_contact_location) |
| 77 | { |
| 78 | /*contact added type*/ |
| 79 | zte_pbm_create_ext_record_s_type sim_contact_add; |
| 80 | int ret_code = 0; |
| 81 | //add by liuyingnan for server safe start |
| 82 | char* pbm_name = NULL; |
| 83 | char* pbm_mobilephone_num = NULL; |
| 84 | //add by liuyingnan for server safe end |
| 85 | |
| 86 | /*LOG*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 87 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm->web_pbm_contact_saveto_sim()."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 88 | |
| 89 | /*check input*/ |
| 90 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 91 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->goform_pbm_contact_add_process(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 92 | return; |
| 93 | } |
| 94 | |
| 95 | //add by liuyingnan for server safe for xss attack start |
| 96 | pbm_name = websGetVar(wp, T("name"), T("")); |
| 97 | pbm_mobilephone_num = websGetVar(wp, T("mobilephone_num"), T("")); |
| 98 | |
| 99 | if (PBM_MAX_TEXT_LENGTH < strlen(pbm_name) || PBM_MAX_NUM_LENGTH < strlen(pbm_mobilephone_num) |
| 100 | ||DATA_NO_SAFE == zte_Safe_noSpecialChar_ucs2(pbm_name) |
| 101 | || DATA_NO_SAFE == zte_Safe_noSpecialChar(pbm_mobilephone_num) |
| 102 | ) { |
| 103 | slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:pbm_name:%s\n", pbm_name); /*lint !e26*/ |
| 104 | sc_cfg_set("data_safe", "failed"); |
| 105 | zte_write_result_to_web(wp, FAILURE); |
| 106 | return; |
| 107 | } |
| 108 | //add by liuyingnan for server safe for xss attack end |
| 109 | |
| 110 | /*init contact_add*/ |
| 111 | memset(&sim_contact_add, 0, sizeof(sim_contact_add)); |
| 112 | /*set struct value*/ |
| 113 | sim_contact_add.zte_pbm_del_id = atoi(websGetVar(wp, T("delId"), T("-1"))); |
| 114 | sim_contact_add.zte_pbm_location = sim_contact_location; |
| 115 | sim_contact_add.zte_pbm_id = atoi(websGetVar(wp, T("edit_index"), T(""))); |
| 116 | |
| 117 | memcpy(sim_contact_add.zte_pbm_name, websGetVar(wp, T("name"), T("")), |
| 118 | sizeof(sim_contact_add.zte_pbm_name)); |
| 119 | memcpy(sim_contact_add.zte_pbm_number, websGetVar(wp, T("mobilephone_num"), T("")), |
| 120 | sizeof(sim_contact_add.zte_pbm_number)); |
| 121 | memcpy(sim_contact_add.zte_pbm_anr, websGetVar(wp, T("homephone_num"), T("")), |
| 122 | sizeof(sim_contact_add.zte_pbm_anr)); |
| 123 | memcpy(sim_contact_add.zte_pbm_anr1, websGetVar(wp, T("officephone_num"), T("")), |
| 124 | sizeof(sim_contact_add.zte_pbm_anr1)); |
| 125 | memcpy(sim_contact_add.zte_pbm_email, websGetVar(wp, T("email"), T("")), |
| 126 | sizeof(sim_contact_add.zte_pbm_email)); |
| 127 | memcpy(sim_contact_add.zte_pbm_sne, websGetVar(wp, T("nick_name"), T("")), |
| 128 | sizeof(sim_contact_add.zte_pbm_sne)); |
| 129 | if (sim_contact_add.zte_pbm_number[ZTE_WEB_PBM_NUMBER_TYPE_START] == |
| 130 | ZTE_WEB_PBM_NUMBER_TYPE_SPLIT) { |
| 131 | sim_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_1; |
| 132 | } else { |
| 133 | sim_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_2; |
| 134 | } |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 135 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm_contact_saveto_sim:send messsage to mc start"); /*lint !e26*/ |
| 136 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.pbm_id:%d", sim_contact_add.zte_pbm_id); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 137 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.name:%s", sim_contact_add.zte_pbm_name); /*lint !e26*/ |
| 138 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.mobilephone_num:%s", sim_contact_add.zte_pbm_number); /*lint !e26*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 139 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.pbm_type:%d", sim_contact_add.zte_pbm_type); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 140 | |
| 141 | /*send msg to mc*/ |
| 142 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_WRITE_REC_MSG, sizeof(sim_contact_add), (char*)&sim_contact_add); |
| 143 | (void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING); |
| 144 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB, sizeof(sim_contact_add), (char*)&sim_contact_add, 0); |
| 145 | if (ret_code != 0) { |
| 146 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send create modify record fail"); /*lint !e26*/ |
| 147 | (void)zte_web_write(ZTE_PBM_NV, "14"); |
| 148 | zte_write_result_to_web(wp, FAILURE); |
| 149 | return; |
| 150 | } |
| 151 | |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 152 | slog(MISC_PRINT, SLOG_NORMAL, "web_pbm_contact_saveto_sim:send messsage to mc end"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 153 | /*goto web page*/ |
| 154 | zte_write_result_to_web(wp, "success"); |
| 155 | return; |
| 156 | } |
| 157 | /********************************************************************** |
| 158 | * Function: zte_web_pbm_contact_saveto_pc |
| 159 | * Description: wp:web para;pc_contact_location:save location |
| 160 | * Input: null |
| 161 | * Output: null |
| 162 | * Return: void |
| 163 | * Others: |
| 164 | * Modify Date Version Author Modification |
| 165 | * ----------------------------------------------- |
| 166 | * 20120926 V1.0 liuyingnan first version |
| 167 | **********************************************************************/ |
| 168 | static void zte_web_pbm_contact_saveto_pc(webs_t wp, int pc_contact_location) |
| 169 | { |
| 170 | /*contact added type*/ |
| 171 | zte_pbm_create_ext_record_s_type pc_contact_add; |
| 172 | int ret_code = 0; |
| 173 | //add by liuyingnan for server safe start |
| 174 | char* pbm_name = NULL; |
| 175 | char* pbm_mobilephone_num = NULL; |
| 176 | //add by liuyingnan for server safe end |
| 177 | /*LOG*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 178 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm->web_pbm_contact_saveto_pc()."); /*lint !e26*/ |
| 179 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_contact_saveto_pc entry\n"); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 180 | /*check input*/ |
| 181 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 182 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_saveto_pc(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 183 | return; |
| 184 | } |
| 185 | //add by liuyingnan for server safe for xss attack start |
| 186 | pbm_name = websGetVar(wp, T("name"), T("")); |
| 187 | pbm_mobilephone_num = websGetVar(wp, T("mobilephone_num"), T("")); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 188 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_contact_saveto_pc entry1\n"); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 189 | if (PBM_MAX_TEXT_LENGTH < strlen(pbm_name) || PBM_MAX_NUM_LENGTH < strlen(pbm_mobilephone_num) |
| 190 | ||DATA_NO_SAFE == zte_Safe_noSpecialChar_ucs2(pbm_name) |
| 191 | || DATA_NO_SAFE == zte_Safe_noSpecialChar(pbm_mobilephone_num) |
| 192 | ) { |
| 193 | slog(MISC_PRINT, SLOG_ERR, "Get Data is no Safe:pbm_name:%s\n", pbm_name); /*lint !e26*/ |
| 194 | sc_cfg_set("data_safe", "failed"); |
| 195 | zte_write_result_to_web(wp, FAILURE); |
| 196 | return; |
| 197 | } |
| 198 | //add by liuyingnan for server safe for xss attack end |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 199 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_contact_saveto_pc entry2\n"); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 200 | /*init contact_add*/ |
| 201 | memset(&pc_contact_add, 0, sizeof(pc_contact_add)); |
| 202 | /*set struct value*/ |
| 203 | pc_contact_add.zte_pbm_del_id = atoi(websGetVar(wp, T("delId"), T("-1"))); |
| 204 | pc_contact_add.zte_pbm_location = pc_contact_location; |
| 205 | pc_contact_add.zte_pbm_id = atoi(websGetVar(wp, T("add_index_pc"), T(""))); |
| 206 | memcpy(pc_contact_add.zte_pbm_name, websGetVar(wp, T("name"), T("")), |
| 207 | sizeof(pc_contact_add.zte_pbm_name)); |
| 208 | memcpy(pc_contact_add.zte_pbm_number, websGetVar(wp, T("mobilephone_num"), T("")), |
| 209 | sizeof(pc_contact_add.zte_pbm_number)); |
| 210 | memcpy(pc_contact_add.zte_pbm_anr, websGetVar(wp, T("homephone_num"), T("")), |
| 211 | sizeof(pc_contact_add.zte_pbm_anr)); |
| 212 | memcpy(pc_contact_add.zte_pbm_anr1, websGetVar(wp, T("officephone_num"), T("")), |
| 213 | sizeof(pc_contact_add.zte_pbm_anr1)); |
| 214 | memcpy(pc_contact_add.zte_pbm_email, websGetVar(wp, T("email"), T("")), |
| 215 | sizeof(pc_contact_add.zte_pbm_email)); |
| 216 | memcpy(pc_contact_add.zte_pbm_sne, websGetVar(wp, T("nick_name"), T("")), |
| 217 | sizeof(pc_contact_add.zte_pbm_sne)); |
| 218 | memcpy(pc_contact_add.zte_pbm_group, websGetVar(wp, T("groupchoose"), T("")), |
| 219 | sizeof(pc_contact_add.zte_pbm_group)); |
| 220 | |
| 221 | if (pc_contact_add.zte_pbm_number[ZTE_WEB_PBM_NUMBER_TYPE_START] == |
| 222 | ZTE_WEB_PBM_NUMBER_TYPE_SPLIT) { |
| 223 | pc_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_1; |
| 224 | } else { |
| 225 | pc_contact_add.zte_pbm_type = ZTE_WEB_PBM_NUMBER_TYPE_2; |
| 226 | } |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 227 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm_contact_saveto_pc:send messsage to mc start"); /*lint !e26*/ |
| 228 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.pbm_id:%d", pc_contact_add.zte_pbm_id); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 229 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.name:%s", pc_contact_add.zte_pbm_name); /*lint !e26*/ |
| 230 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.mobilephone_num:%s", pc_contact_add.zte_pbm_number); /*lint !e26*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 231 | slog(MISC_PRINT, SLOG_DEBUG, "sim_contact_add.pbm_type:%d", pc_contact_add.zte_pbm_type); /*lint !e26*/ |
| 232 | printf("[PB] web_pbm_contact_saveto_pc entry3\n"); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 233 | /*send msg to mc*/ |
| 234 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_WRITE_REC_MSG, sizeof(pc_contact_add), (char*)&pc_contact_add); |
| 235 | (void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING); |
| 236 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB, sizeof(pc_contact_add), (char*)&pc_contact_add, 0); |
| 237 | if (ret_code != 0) { |
| 238 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send create modify record fail"); /*lint !e26*/ |
| 239 | (void)zte_web_write(ZTE_PBM_NV, "14"); |
| 240 | zte_write_result_to_web(wp, FAILURE); |
| 241 | return; |
| 242 | } |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 243 | printf("web_pbm_contact_saveto_pc:%d,%d,%d,%d\n", ret_code, MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_WRITE_PB); |
| 244 | slog(MISC_PRINT, SLOG_NORMAL, "web_pbm_contact_saveto_pc:send messsage to mc end"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 245 | /*goto web page*/ |
| 246 | zte_write_result_to_web(wp, "success"); |
| 247 | } |
| 248 | |
| 249 | /********************************************************************** |
| 250 | * Function: zte_web_pbm_utils_parseStr |
| 251 | * Description: |
| 252 | * Input: |
| 253 | * Output: |
| 254 | * Return: void |
| 255 | * Others: |
| 256 | * Modify Date Version Author Modification |
| 257 | * ----------------------------------------------- |
| 258 | * 20120409 V1.0 chenyi first version |
| 259 | **********************************************************************/ |
| 260 | static int zte_web_pbm_utils_parseStr |
| 261 | ( |
| 262 | char *input, char *output, int srcLen, int destLen, char separator |
| 263 | ) |
| 264 | { |
| 265 | /*index*/ |
| 266 | int input_ind = 0; |
| 267 | int dest_ind = 0; |
| 268 | int all_ind = 0; |
| 269 | |
| 270 | /*check input*/ |
| 271 | if (NULL == input || NULL == output || srcLen == 0 || destLen == 0) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 272 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_utils_parseStr():invalid input."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | /*handler*/ |
| 277 | for (input_ind = 0; input_ind < srcLen; input_ind++) { |
| 278 | //kw |
| 279 | if (all_ind > destLen) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 280 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_utils_parseStr():invalid param."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 281 | return 0; |
| 282 | } |
| 283 | |
| 284 | if ('\0' == input[input_ind]) { |
| 285 | *(output + destLen * dest_ind + all_ind) = '\0'; |
| 286 | return dest_ind + 1; |
| 287 | } |
| 288 | |
| 289 | if (separator == input[input_ind]) { |
| 290 | *(output + destLen * dest_ind + all_ind) = '\0'; |
| 291 | if ('\0' != input[input_ind + 1]) { |
| 292 | all_ind = 0; |
| 293 | dest_ind++; |
| 294 | } |
| 295 | } else { |
| 296 | *(output + destLen * dest_ind + all_ind) = input[input_ind]; |
| 297 | all_ind++; |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | /*return value*/ |
| 302 | return dest_ind; |
| 303 | } |
| 304 | |
| 305 | |
| 306 | /********************************************************************** |
| 307 | * Function: zte_web_pbm_contact_del_part |
| 308 | * Description: |
| 309 | * Input: web para |
| 310 | * Output: |
| 311 | * Return: void |
| 312 | * Others: reason of error. |
| 313 | * Others: |
| 314 | * Modify Date Version Author Modification |
| 315 | * ----------------------------------------------- |
| 316 | * 20120409 V1.0 chenyi first version |
| 317 | **********************************************************************/ |
| 318 | static void zte_web_pbm_contact_del_part(webs_t wp) |
| 319 | { |
| 320 | int ret_code = 0; |
| 321 | /*deleted index get from page*/ |
| 322 | char del_index[PBM_WEB_MAX_CHAR_LEN] = {0}; |
| 323 | /*split deleted index*/ |
| 324 | char split_index[ZTE_PB_INDEX_MAX][ZTE_WEB_PBM_REC_LEN+1]; |
| 325 | /*flag of contact number*/ |
| 326 | /*index for for circle*/ |
| 327 | int num_ind = 0; |
| 328 | /*data struct */ |
| 329 | zte_pbm_del_multi_records_s_type sendto_data; |
| 330 | |
| 331 | /*check input*/ |
| 332 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 333 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_part(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 334 | return; |
| 335 | } |
| 336 | |
| 337 | /*init*/ |
| 338 | memset(del_index, 0, sizeof(del_index)); |
| 339 | memset(&sendto_data, 0, sizeof(sendto_data)); |
| 340 | memset(split_index, 0, sizeof(split_index)); |
| 341 | |
| 342 | /*set data struct*/ |
| 343 | //sendto_data.zte_del_pbm_location = atoi(websGetVar(wp,T("savelocation1"), T(""))); |
| 344 | memcpy(del_index, websGetVar(wp, T("delete_id"), T("")), sizeof(del_index)); |
| 345 | sendto_data.zte_del_pbm_total = zte_web_pbm_utils_parseStr(del_index, (char *)split_index, |
| 346 | (int)ZTE_PB_INDEX_MAX, (int)ZTE_WEB_PBM_REC_LEN, (char)ZTE_WEB_PBM_INDEX_SPLIT_FLAG); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 347 | slog(MISC_PRINT, SLOG_DEBUG,"liuyingnan sendto_data.del_pbm_total:%d", sendto_data.zte_del_pbm_total); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 348 | |
| 349 | /*del one contact*/ |
| 350 | if (ZTE_WEB_PBM_DEL_MULT_OR_ONE_FLAG == sendto_data.zte_del_pbm_total) { |
| 351 | sendto_data.zte_del_pbm_id[ZTE_WEB_PBM_DEL_ONE_IND] = atoi(split_index[ZTE_WEB_PBM_DEL_ONE_IND]); |
| 352 | |
| 353 | #if 0 |
| 354 | if (-1 == zte_mc_relay_pbm_del_one_record(&sendto_data)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 355 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_part():delete one contact failed."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 356 | zte_write_result_to_web(wp, FAILURE); |
| 357 | return; |
| 358 | } |
| 359 | #endif |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 360 | slog(MISC_PRINT, SLOG_NORMAL, "web_pbm_contact_del_part:send messsage start"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 361 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_A_REC_MSG, sizeof(sendto_data), (char*)&sendto_data); |
| 362 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_A_PB, sizeof(sendto_data), (char*)&sendto_data, 0); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 363 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm_contact_del_part:send messsage end"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 364 | if (ret_code != 0) { |
| 365 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send DEL A record fail"); /*lint !e26*/ |
| 366 | zte_write_result_to_web(wp, FAILURE); |
| 367 | return; |
| 368 | } |
| 369 | } else { |
| 370 | /*handler*/ |
| 371 | for (num_ind = 0; num_ind < sendto_data.zte_del_pbm_total; num_ind ++) { |
| 372 | sendto_data.zte_del_pbm_id[num_ind] = atoi(split_index[num_ind]); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 373 | printf("web_pbm->web_pbm_contact_del_part():split_index=[%d]", sendto_data.zte_del_pbm_id[num_ind]); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /*handler*/ |
| 377 | #if 0 |
| 378 | if (-1 == zte_mc_relay_pbm_del_multi_record(&sendto_data)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 379 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_part():delete mult contact failed."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 380 | zte_write_result_to_web(wp, FAILURE); |
| 381 | return; |
| 382 | } |
| 383 | #endif |
| 384 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_MUTI_REC_MSG, sizeof(sendto_data), (char*)&sendto_data); |
| 385 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_MUTI_PB, sizeof(sendto_data), (char*)&sendto_data, 0); |
| 386 | if (ret_code != 0) { |
| 387 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send DEL MUTI record fail"); /*lint !e26*/ |
| 388 | zte_write_result_to_web(wp, FAILURE); |
| 389 | return; |
| 390 | } |
| 391 | } |
| 392 | /*goto differ page*/ |
| 393 | (void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING); |
| 394 | zte_write_result_to_web(wp, "success"); |
| 395 | //zte_web_pbm_goto_diff_page(wp,sendto_data.zte_del_pbm_location); |
| 396 | } |
| 397 | /********************************************************************** |
| 398 | * Function: zte_web_pbm_contact_del_all |
| 399 | * Description: |
| 400 | * Input: web para |
| 401 | * Output: null |
| 402 | * Return: void |
| 403 | * Others: reason of error. |
| 404 | * Others: |
| 405 | * Modify Date Version Author Modification |
| 406 | * ----------------------------------------------- |
| 407 | * 20120409 V1.0 chenyi first version |
| 408 | **********************************************************************/ |
| 409 | static void zte_web_pbm_contact_del_all(webs_t wp) |
| 410 | { |
| 411 | int ret_code = 0; |
| 412 | /*data struct*/ |
| 413 | zte_pbm_del_multi_records_s_type sendto_data; |
| 414 | |
| 415 | /*check input*/ |
| 416 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 417 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_all(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 418 | return; |
| 419 | } |
| 420 | |
| 421 | /*init*/ |
| 422 | memset(&sendto_data, 0, sizeof(sendto_data)); |
| 423 | |
| 424 | /*set data struct*/ |
| 425 | sendto_data.zte_del_pbm_location = atoi(websGetVar(wp, T("del_all_location"), T(""))); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 426 | slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan sendto_data.del_pbm_location:%d", sendto_data.zte_del_pbm_location); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 427 | |
| 428 | /*handler del all*/ |
| 429 | //(void)zte_mc_relay_pbm_del_all_record(&sendto_data); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 430 | slog(MISC_PRINT, SLOG_NORMAL, "web_pbm_contact_del_all:send messsage start"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 431 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_ALL_REC_MSG, sizeof(sendto_data), (char*)&sendto_data); |
| 432 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_ALL_PB, sizeof(sendto_data), (char*)&sendto_data, 0); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 433 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm_contact_del_all:send messsage end"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 434 | if (ret_code != 0) { |
| 435 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send DEL ALL record fail"); /*lint !e26*/ |
| 436 | zte_write_result_to_web(wp, FAILURE); |
| 437 | return; |
| 438 | } |
| 439 | /*goto differ page*/ |
| 440 | (void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING); |
| 441 | zte_write_result_to_web(wp, "success"); |
| 442 | //zte_web_pbm_goto_diff_page(wp,sendto_data.zte_del_pbm_location); |
| 443 | } |
| 444 | /********************************************************************** |
| 445 | * Function: zte_web_pbm_contact_del_by_group |
| 446 | * Description: |
| 447 | * Input: web para |
| 448 | * Output: |
| 449 | * Return: void |
| 450 | * Others: reason of error. |
| 451 | * Others: |
| 452 | * Modify Date Version Author Modification |
| 453 | * ----------------------------------------------- |
| 454 | * 20120711 V1.0 chenyi first version |
| 455 | **********************************************************************/ |
| 456 | static void zte_web_pbm_contact_del_by_group(webs_t wp) |
| 457 | { |
| 458 | int ret_code = 0; |
| 459 | zte_pbm_del_multi_records_s_type sendto_data; |
| 460 | char *group = NULL; |
| 461 | |
| 462 | /*check input*/ |
| 463 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 464 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_by_group(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 465 | return; |
| 466 | } |
| 467 | |
| 468 | /*init*/ |
| 469 | memset(&sendto_data, 0, sizeof(zte_pbm_del_multi_records_s_type)); |
| 470 | |
| 471 | group = websGetVar(wp, T("del_group"), T("")); |
| 472 | slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan group:%s", group); /*lint !e26*/ |
| 473 | if (0 == strcmp(group, "")) { |
| 474 | slog(MISC_PRINT, SLOG_ERR, "pbm:group is empty.\n"); /*lint !e26*/ |
| 475 | zte_write_result_to_web(wp, FAILURE); |
| 476 | return; |
| 477 | } |
| 478 | |
| 479 | /*set data struct*/ |
| 480 | sendto_data.zte_del_pbm_location = atoi(websGetVar(wp, T("del_all_location"), T("0"))); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 481 | slog(MISC_PRINT, SLOG_DEBUG, "liuyingnan sendto_data.del_pbm_location:%d", sendto_data.zte_del_pbm_location); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 482 | |
| 483 | if (ZTE_NVIO_DONE != zte_web_write("pbm_group", group)) { |
| 484 | slog(MISC_PRINT, SLOG_ERR, "write the nv [pbm_group] failure.\n"); /*lint !e26*/ |
| 485 | zte_write_result_to_web(wp, FAILURE); |
| 486 | return; |
| 487 | } |
| 488 | |
| 489 | (void)zte_web_write(ZTE_PBM_NV, PBM_OPRATING); |
| 490 | |
| 491 | #if 0 |
| 492 | if (ZTE_MC_OK_S != zte_mc_relay_pbm_del_all_record(&sendto_data)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 493 | slog(MISC_PRINT, SLOG_ERR, "call mc_relay_pbm_del_all_record fail.\n"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 494 | zte_write_result_to_web(wp, FAILURE); |
| 495 | } else { |
| 496 | zte_write_result_to_web(wp, SUCCESS); |
| 497 | } |
| 498 | #endif |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 499 | slog(MISC_PRINT, SLOG_NORMAL, "web_pbm_contact_del_by_group:send messsage start"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 500 | //ret_code = zte_send_message(ZUFI_MODULE_ID_AT_LOCAL,ZTE_PBM_DEL_ALL_REC_MSG, sizeof(sendto_data), (char*)&sendto_data); |
| 501 | ret_code = ipc_send_message(MODULE_ID_WEB_CGI, MODULE_ID_PB, MSG_CMD_DEL_ALL_PB, sizeof(sendto_data), (char*)&sendto_data, 0); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 502 | slog(MISC_PRINT, SLOG_DEBUG, "web_pbm_contact_del_by_group:send messsage end"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 503 | if (ret_code != 0) { |
| 504 | slog(MISC_PRINT, SLOG_ERR, "mc lib relay pbm send DEL record by group fail"); /*lint !e26*/ |
| 505 | zte_write_result_to_web(wp, FAILURE); |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | zte_write_result_to_web(wp, "success"); |
| 510 | } |
| 511 | |
| 512 | |
| 513 | /********************************************************************** |
| 514 | * Function: zte_goform_pbm_contact_add_process |
| 515 | * Description: |
| 516 | * Input: null |
| 517 | * Output: null |
| 518 | * Return: void |
| 519 | * Others: |
| 520 | * Modify Date Version Author Modification |
| 521 | * ----------------------------------------------- |
| 522 | * 20120926 V1.0 liuyingnan first version |
| 523 | **********************************************************************/ |
| 524 | void zte_goform_pbm_contact_add_process(webs_t wp) |
| 525 | { |
| 526 | /*contact location*/ |
| 527 | int contact_location = 0; |
| 528 | |
| 529 | /*check input*/ |
| 530 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 531 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->goform_pbm_contact_add_process(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 532 | return; |
| 533 | } |
| 534 | |
| 535 | if (0 == zte_web_pbm_check_can_process()) { |
| 536 | zte_write_result_to_web(wp, FAILURE); |
| 537 | return; |
| 538 | } |
| 539 | |
| 540 | /*get the saved mem*/ |
| 541 | contact_location = atoi(websGetVar(wp, T("location"), T(""))); |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 542 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_check_can_process contact_location=%d, can process.\n", contact_location); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 543 | /*goto different mem handler*/ |
| 544 | switch (contact_location) { |
| 545 | case ZTE_WEB_PBM_CONTACT_SIM: { /*goto sim mem handler*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 546 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_check_can_process sim=%d, can process.\n", ZTE_WEB_PBM_CONTACT_SIM); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 547 | zte_web_pbm_contact_saveto_sim(wp, ZTE_WEB_PBM_CONTACT_SIM); |
| 548 | break; |
| 549 | } |
| 550 | case ZTE_WEB_PBM_CONTACT_PC: { /*goto pc mem handler*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 551 | slog(MISC_PRINT, SLOG_DEBUG,"[PB] web_pbm_check_can_process pc=%d, can process.\n", ZTE_WEB_PBM_CONTACT_PC); |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 552 | zte_web_pbm_contact_saveto_pc(wp, ZTE_WEB_PBM_CONTACT_PC); |
| 553 | break; |
| 554 | } |
| 555 | |
| 556 | default: { /*unknown mem*/ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 557 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->goform_pbm_contact_add_process():unknown pbm mem."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 558 | zte_write_result_to_web(wp, FAILURE); |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | void zte_goform_pbm_contact_del_process(webs_t wp) |
| 564 | { |
| 565 | /*check input*/ |
| 566 | if (NULL == wp) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 567 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->web_pbm_contact_del_all(): invalid input.."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 568 | return; |
| 569 | } |
| 570 | |
| 571 | if (0 == zte_web_pbm_check_can_process()) { |
| 572 | zte_write_result_to_web(wp, FAILURE); |
| 573 | return; |
| 574 | } |
| 575 | |
| 576 | /*del the given index contact in specified mem*/ |
| 577 | if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_PAGE_DEL_PART)) { |
| 578 | zte_web_pbm_contact_del_part(wp); |
| 579 | } |
| 580 | |
| 581 | /*del all the contact in specified mem*/ |
| 582 | else if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_PAGE_DEL_ALL)) { |
| 583 | zte_web_pbm_contact_del_all(wp); |
| 584 | } |
| 585 | //delete the pbm data by group |
| 586 | else if (0 == strcmp(websGetVar(wp, T("del_option"), T("")), ZTE_WEB_PBM_DEL_BY_GROUP)) { |
| 587 | zte_web_pbm_contact_del_by_group(wp); |
| 588 | } |
| 589 | |
| 590 | else { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 591 | slog(MISC_PRINT, SLOG_ERR, "web_pbm->goform_pbm_contact_del_process():unknown pbm del."); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 592 | zte_write_result_to_web(wp, FAILURE); |
| 593 | } |
| 594 | |
| 595 | } |
| 596 | |
| 597 | |
| 598 | /********************************************************************** |
| 599 | * Function: zte_get_pbm_data |
| 600 | * Description: to get the pbm data info |
| 601 | * Input: the web para |
| 602 | * Output: |
| 603 | * Return: |
| 604 | * Others: |
| 605 | * Modify Date Version Author Modification |
| 606 | * ----------------------------------------------- |
| 607 | * 2012/04/10 V1.0 chenyi first version |
| 608 | **********************************************************************/ |
| 609 | void zte_get_pbm_data(webs_t wp) |
| 610 | { |
| 611 | zte_pbm_query_req_s_type pbm_query_req; |
| 612 | zte_pbm_query_resp_s_type *p_pbm_query_result = NULL; |
| 613 | int result = 0; |
| 614 | int i = 0; |
| 615 | char_t *page = NULL; |
| 616 | char_t *data_per_page = NULL; |
| 617 | char_t *mem_store = NULL; |
| 618 | |
| 619 | memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type)); |
| 620 | |
| 621 | page = websGetVar(wp, "page", T("")); |
| 622 | data_per_page = websGetVar(wp, "data_per_page", T("")); |
| 623 | mem_store = websGetVar(wp, "mem_store", T("")); |
| 624 | |
| 625 | if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 626 | slog(MISC_PRINT, SLOG_ERR, "get_pbm_data: invalid web para.\n"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 627 | zte_web_pbm_feed_back_empty(wp); |
| 628 | return ; |
| 629 | } |
| 630 | int tmp_page = atoi(page); |
| 631 | int tmp_num_per_page = atoi(data_per_page); |
| 632 | int location = atoi(mem_store); |
| 633 | if((tmp_page < 0 || tmp_page > 255) |
| 634 | ||(tmp_num_per_page < 0 || tmp_num_per_page > 255) |
| 635 | ||(location < PBM_LOCATION_SIM || location > PBM_LOCATION_MAX)){ |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 636 | slog(MISC_PRINT, SLOG_ERR, "get_pbm_data:err[%d,%d,%d]\n", tmp_page,tmp_num_per_page,location); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 637 | zte_web_pbm_feed_back_empty(wp); |
| 638 | return ; |
| 639 | } |
| 640 | pbm_query_req.page = (uint8)tmp_page; |
| 641 | pbm_query_req.num_per_page = (uint8)tmp_num_per_page; |
| 642 | pbm_query_req.location = (zte_pbm_location_e_type)location; //0:sim;1:device |
| 643 | |
| 644 | slog(MISC_PRINT, SLOG_DEBUG, "pbm_query_req:[%u,%u,%d].\n", pbm_query_req.page, pbm_query_req.num_per_page, pbm_query_req.location); /*lint !e26*/ |
| 645 | |
| 646 | p_pbm_query_result = (zte_pbm_query_resp_s_type*)malloc(4 + sizeof(zte_pbm_create_ext_record_s_type) * (pbm_query_req.num_per_page)); |
| 647 | if (NULL == p_pbm_query_result) { |
| 648 | slog(MISC_PRINT, SLOG_ERR, "malloc pbm result mem fail.\n"); /*lint !e26*/ |
| 649 | zte_web_pbm_feed_back_empty(wp); |
| 650 | return ;/*lint !e429*/ |
| 651 | } |
| 652 | |
| 653 | memset(p_pbm_query_result, 0, (4 + sizeof(zte_pbm_create_ext_record_s_type) * (pbm_query_req.num_per_page))); /*lint !e668*/ |
| 654 | |
| 655 | slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/ |
| 656 | result = zte_libpbm_get_rec_data(&pbm_query_req, p_pbm_query_result); |
| 657 | slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/ |
| 658 | |
| 659 | if (-1 == result) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 660 | slog(MISC_PRINT, SLOG_ERR, "call libpbm_get_rec_data fail.\n"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 661 | zte_web_pbm_feed_back_empty(wp); |
| 662 | //free |
| 663 | // if (NULL != p_pbm_query_result) { // kw 3 |
| 664 | free(p_pbm_query_result); |
| 665 | p_pbm_query_result = NULL; |
| 666 | // } |
| 667 | return ; |
| 668 | } |
| 669 | |
| 670 | slog(MISC_PRINT, SLOG_DEBUG, "total query count [%u].\n", (*p_pbm_query_result).count); /*lint !e26*/ |
| 671 | |
| 672 | if (0 == (*p_pbm_query_result).count) { |
| 673 | zte_web_pbm_feed_back_empty(wp); |
| 674 | //free |
| 675 | // if (NULL != p_pbm_query_result) { kw 3 |
| 676 | free(p_pbm_query_result); |
| 677 | p_pbm_query_result = NULL; |
| 678 | // } |
| 679 | return ; |
| 680 | } |
| 681 | |
| 682 | //write the pbm data to web |
| 683 | for (i = 0; i < (*p_pbm_query_result).count; i++) { |
| 684 | if (0 == i) { |
| 685 | web_feedback_header(wp); |
| 686 | zte_rest_get_pbm_data_head(wp); |
| 687 | if (0 == pbm_query_req.location) { |
| 688 | zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 0); |
| 689 | } else { |
| 690 | zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 0); |
| 691 | } |
| 692 | } else { |
| 693 | if (0 == pbm_query_req.location) { |
| 694 | zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 1); |
| 695 | } else { |
| 696 | zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 1); |
| 697 | } |
| 698 | } |
| 699 | } |
| 700 | zte_rest_get_pbm_data_foot(wp); |
| 701 | //(void)websWrite(wp, T("]}")); |
| 702 | |
| 703 | //free |
| 704 | // if (NULL != p_pbm_query_result) { // kw 3 |
| 705 | free(p_pbm_query_result); |
| 706 | p_pbm_query_result = NULL; |
| 707 | // } |
| 708 | } |
| 709 | |
| 710 | /********************************************************************** |
| 711 | * Function: zte_get_pbm_data_total |
| 712 | * Description: to get the total pbm data |
| 713 | * Input: the web para |
| 714 | * Output: |
| 715 | * Return: |
| 716 | * Others: |
| 717 | * Modify Date Version Author Modification |
| 718 | * ----------------------------------------------- |
| 719 | * 2012/04/10 V1.0 chenyi first version |
| 720 | **********************************************************************/ |
| 721 | void zte_get_pbm_data_total(webs_t wp) |
| 722 | { |
| 723 | zte_pbm_query_req_s_type pbm_query_req; |
| 724 | zte_pbm_query_resp_s_type *p_pbm_query_result = NULL; |
| 725 | int result = 0; |
| 726 | int i = 0; |
| 727 | char_t *page = NULL; |
| 728 | char_t *data_per_page = NULL; |
| 729 | char_t *mem_store = NULL; |
| 730 | char *pbm_group = NULL; |
| 731 | |
| 732 | int total_pages = 0; |
| 733 | int leave_nums = 0; |
| 734 | int curr_page = 0; |
| 735 | int total_pbm = 0; |
| 736 | |
| 737 | int idata_per_page = 0; |
| 738 | |
| 739 | memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type)); |
| 740 | |
| 741 | page = websGetVar(wp, "page", T("")); |
| 742 | data_per_page = websGetVar(wp, "data_per_page", T("")); |
| 743 | mem_store = websGetVar(wp, "mem_store", T("")); |
| 744 | pbm_group = websGetVar(wp, "pbm_group", T("")); //not to check whether is empty |
| 745 | |
| 746 | if (('\0' == *page) || ('\0' == *data_per_page) || ('\0' == *mem_store)) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 747 | slog(MISC_PRINT, SLOG_ERR, "get_pbm_data: invalid web para.\n"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 748 | zte_web_pbm_feed_back_empty(wp); |
| 749 | return ; |
| 750 | } |
| 751 | |
| 752 | |
| 753 | #if 0 |
| 754 | //calculate the total pages |
| 755 | total_pages = (atoi(data_per_page)) / PBM_PAGE_RECORD_MAX_NUM; |
| 756 | leave_nums = (atoi(data_per_page)) % PBM_PAGE_RECORD_MAX_NUM; |
| 757 | |
| 758 | if (0 != leave_nums) { |
| 759 | total_pages++; |
| 760 | } |
| 761 | |
| 762 | #else |
| 763 | idata_per_page = atoi(data_per_page); |
| 764 | if(idata_per_page < 0 || idata_per_page > INT_MAX-1) |
| 765 | { |
| 766 | total_pages = 1; |
| 767 | leave_nums = 0; |
| 768 | } |
| 769 | else |
| 770 | { |
| 771 | //calculate the total pages |
| 772 | total_pages = idata_per_page / PBM_PAGE_RECORD_MAX_NUM; |
| 773 | leave_nums = idata_per_page % PBM_PAGE_RECORD_MAX_NUM; |
| 774 | |
| 775 | if (0 != leave_nums) { |
| 776 | total_pages++; |
| 777 | } |
| 778 | } |
| 779 | #endif |
| 780 | |
| 781 | slog(MISC_PRINT, SLOG_DEBUG, "pbm:total_pages,leave_nums:[%d][%d]", total_pages, leave_nums); /*lint !e26*/ |
| 782 | |
| 783 | p_pbm_query_result = (zte_pbm_query_resp_s_type*)malloc(4 + sizeof(zte_pbm_create_ext_record_s_type) * PBM_PAGE_RECORD_MAX_NUM); |
| 784 | if (NULL == p_pbm_query_result) { |
| 785 | slog(MISC_PRINT, SLOG_ERR, "malloc pbm result mem fail.\n"); /*lint !e26*/ |
| 786 | zte_web_pbm_feed_back_empty(wp); |
| 787 | return ;/*lint !e429*/ |
| 788 | } |
| 789 | |
| 790 | (void)zte_web_write("pbm_group", pbm_group); //only wrtite one time |
| 791 | |
| 792 | for (curr_page = 0; curr_page < total_pages; curr_page++) { |
| 793 | |
| 794 | //reset |
| 795 | memset(&pbm_query_req, 0, sizeof(zte_pbm_query_req_s_type)); |
| 796 | |
| 797 | pbm_query_req.page = curr_page; |
| 798 | pbm_query_req.num_per_page = PBM_PAGE_RECORD_MAX_NUM; |
| 799 | /*lint -e64*/ |
| 800 | pbm_query_req.location = atoi(mem_store); //0:sim;1:device |
| 801 | |
| 802 | slog(MISC_PRINT, SLOG_DEBUG, "pbm_query_req:[%u,%u,%d].\n", pbm_query_req.page, pbm_query_req.num_per_page, pbm_query_req.location); /*lint !e26*/ |
| 803 | |
| 804 | //reset |
| 805 | memset(p_pbm_query_result, 0, 4 + sizeof(zte_pbm_create_ext_record_s_type)*PBM_PAGE_RECORD_MAX_NUM); /*lint !e668*/ |
| 806 | |
| 807 | slog(MISC_PRINT, SLOG_NORMAL, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/ |
| 808 | result = zte_libpbm_get_rec_data(&pbm_query_req, p_pbm_query_result); |
| 809 | slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/ |
| 810 | |
| 811 | if (-1 == result) { |
| 812 | slog(MISC_PRINT, SLOG_DEBUG, "read pbm page [%d] fail.\n", curr_page); /*lint !e26*/ |
| 813 | //free |
| 814 | // if (NULL != p_pbm_query_result) { // kw 3 |
| 815 | free(p_pbm_query_result); |
| 816 | p_pbm_query_result = NULL; |
| 817 | // } |
| 818 | |
| 819 | if (0 == curr_page) { |
| 820 | zte_web_pbm_feed_back_empty(wp); |
| 821 | return ; |
| 822 | } else { |
| 823 | break; |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | slog(MISC_PRINT, SLOG_DEBUG, "pbm:total query count [%u].\n", (*p_pbm_query_result).count); /*lint !e26*/ |
| 828 | |
| 829 | if (0 == (*p_pbm_query_result).count) { |
| 830 | //free |
| 831 | // if (NULL != p_pbm_query_result) { // kw 3 |
| 832 | free(p_pbm_query_result); |
| 833 | p_pbm_query_result = NULL; |
| 834 | // } |
| 835 | |
| 836 | if (0 == curr_page) { |
| 837 | zte_web_pbm_feed_back_empty(wp); |
| 838 | return ; |
| 839 | } else { |
| 840 | break; |
| 841 | } |
| 842 | } |
| 843 | |
| 844 | //write the pbm data to web |
| 845 | for (i = 0; (i < (*p_pbm_query_result).count) && (total_pbm < atoi(data_per_page)); i++, total_pbm++) { |
| 846 | if ((0 == i) && (0 == curr_page)) { |
| 847 | web_feedback_header(wp); |
| 848 | zte_rest_get_pbm_data_head(wp); |
| 849 | if (0 == pbm_query_req.location) { |
| 850 | zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 0); |
| 851 | } else { |
| 852 | zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 0); |
| 853 | } |
| 854 | } else { |
| 855 | if (0 == pbm_query_req.location) { |
| 856 | zte_rest_get_pbm_data_sim(wp, p_pbm_query_result, i, 1); |
| 857 | } else { |
| 858 | zte_rest_get_pbm_data_other(wp, p_pbm_query_result, i, 1); |
| 859 | } |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | } |
| 864 | |
| 865 | |
| 866 | zte_rest_get_pbm_data_foot(wp); |
| 867 | //free |
| 868 | // if (NULL != p_pbm_query_result) { // kw 3 |
| 869 | free(p_pbm_query_result); |
| 870 | p_pbm_query_result = NULL; |
| 871 | // } |
| 872 | } |
| 873 | |
| 874 | /********************************************************************** |
| 875 | * Function: zte_get_pbm_parameter_info |
| 876 | * Description: to get the pbm parameter info |
| 877 | * Input: the web para |
| 878 | * Output: |
| 879 | * Return: |
| 880 | * Others: |
| 881 | * Modify Date Version Author Modification |
| 882 | * ----------------------------------------------- |
| 883 | * 2012/04/10 V1.0 chenyi first version |
| 884 | **********************************************************************/ |
| 885 | void zte_get_pbm_parameter_info(webs_t wp) |
| 886 | { |
| 887 | zte_pbm_query_req_s_type pbm_para_query_info; |
| 888 | zte_pbm_sim_capability_s_type pbm_sim_capability_s; |
| 889 | zte_pbm_device_capability_s_type pbm_device_capability_s; |
| 890 | char *pbm_location = NULL; |
| 891 | int result = 0; |
| 892 | |
| 893 | //initialize |
| 894 | memset(&pbm_para_query_info, 0, sizeof(zte_pbm_query_req_s_type)); |
| 895 | memset(&pbm_sim_capability_s, 0, sizeof(zte_pbm_sim_capability_s_type)); |
| 896 | memset(&pbm_device_capability_s, 0, sizeof(zte_pbm_device_capability_s_type)); |
| 897 | |
| 898 | pbm_location = websGetVar(wp, "pbm_location", T("")); |
| 899 | |
| 900 | if (0 == strcmp(pbm_location, "")) { |
| 901 | slog(MISC_PRINT, SLOG_ERR, "pbm_location is empty.\n"); /*lint !e26*/ |
| 902 | zte_web_pbm_feed_back_empty(wp); |
| 903 | return; |
| 904 | } |
| 905 | |
| 906 | slog(MISC_PRINT, SLOG_DEBUG, "pbm_location is [%s].\n", pbm_location); /*lint !e26*/ |
| 907 | |
| 908 | if (0 == strcmp(pbm_location, PBM_NATIVE)) { |
| 909 | pbm_para_query_info.location = PBM_LOCATION_DEVICE; |
| 910 | } else if (0 == strcmp(pbm_location, PBM_SIM)) { |
| 911 | pbm_para_query_info.location = PBM_LOCATION_SIM; |
| 912 | } else { |
| 913 | slog(MISC_PRINT, SLOG_ERR, "invalid pbm_location[%s].\n", pbm_location); /*lint !e26*/ |
| 914 | zte_web_pbm_feed_back_empty(wp); |
| 915 | return; |
| 916 | } |
| 917 | slog(MISC_PRINT, SLOG_NORMAL, "GET PBM DATA FROM DB START.\n"); /*lint !e26*/ |
| 918 | result = zte_libpbm_get_capability(&pbm_para_query_info, &pbm_sim_capability_s, &pbm_device_capability_s); |
| 919 | slog(MISC_PRINT, SLOG_DEBUG, "GET PBM DATA FROM DB END.\n"); /*lint !e26*/ |
| 920 | if (-1 == result) { |
xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 921 | slog(MISC_PRINT, SLOG_ERR, "call libpbm_get_capability fail.\n"); /*lint !e26*/ |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 922 | zte_web_pbm_feed_back_empty(wp); |
| 923 | return ; |
| 924 | } |
| 925 | |
| 926 | web_feedback_header(wp); |
| 927 | if (0 == strcmp(pbm_location, PBM_NATIVE)) { |
| 928 | zte_rest_cmd_write_head(wp); |
| 929 | zte_rest_cmd_write_int(wp, PBM_DEV_MAX_RECORD_NUM, pbm_device_capability_s.max_record_number, 1); |
| 930 | zte_rest_cmd_write_int(wp, PBM_DEV_USED_RECORD_NUM, pbm_device_capability_s.used_record_number, 0); |
| 931 | zte_rest_cmd_write_foot(wp); |
| 932 | } else { |
| 933 | zte_rest_cmd_write_head(wp); |
| 934 | zte_rest_cmd_write_int(wp, PBM_SIM_SIM_TYPE, pbm_sim_capability_s.sim_type, 1); |
| 935 | zte_rest_cmd_write_int(wp, PBM_SIM_MAX_RECORD_NUM, pbm_sim_capability_s.max_record_number, 1); |
| 936 | zte_rest_cmd_write_int(wp, PBM_SIM_USED_RECORD_NUM, pbm_sim_capability_s.used_record_number, 1); |
| 937 | zte_rest_cmd_write_int(wp, PBM_SIM_MAX_NAME_LEN, pbm_sim_capability_s.max_name_len, 1); |
| 938 | zte_rest_cmd_write_int(wp, PBM_SIM_MAX_NUMBER_LEN, pbm_sim_capability_s.max_number_len, 0); |
| 939 | zte_rest_cmd_write_foot(wp); |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | /********************************************************************** |
| 944 | * Function: zte_web_pbm_feed_back_empty |
| 945 | * Description: to write empty info to web |
| 946 | * Input: the web para |
| 947 | * Output: |
| 948 | * Return: |
| 949 | * Others: |
| 950 | * Modify Date Version Author Modification |
| 951 | * ----------------------------------------------- |
| 952 | * 2012/04/10 V1.0 chenyi first version |
| 953 | **********************************************************************/ |
| 954 | |
| 955 | static void zte_web_pbm_feed_back_empty(webs_t wp) |
| 956 | { |
| 957 | if (NULL == wp) { |
| 958 | return; |
| 959 | } |
| 960 | |
| 961 | web_feedback_header(wp); |
| 962 | if (wp->flags & WEBS_XML_CLIENT_REQUEST) { |
| 963 | websWrite(wp, T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")); |
| 964 | websWrite(wp, T("<%s>empty</%s>\n"), PBM_DATA, PBM_DATA); |
| 965 | } else { |
| 966 | (void)websWrite(wp, T("{\"%s\":[]}"), PBM_DATA); |
| 967 | } |
| 968 | //(void)websWrite(wp, T("{\"%s\":[]}"),PBM_DATA); |
| 969 | } |
| 970 | //added by chenyi for handle the http request end 20111118 |
| 971 | |