comparison libpurple/protocols/msn/contact.c @ 24520:d39ed4032dc9

Split up that faultcode stuff I just changed. Stops it from printing an annoying error debug message every time we do some contact operation successfully.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 07 Dec 2008 08:02:33 +0000
parents 3915331092b2
children e63483708bd7
comparison
equal deleted inserted replaced
24519:3915331092b2 24520:d39ed4032dc9
868 static void 868 static void
869 msn_contact_request_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 869 msn_contact_request_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
870 gpointer data) 870 gpointer data)
871 { 871 {
872 MsnCallbackState *state = data; 872 MsnCallbackState *state = data;
873 xmlnode *faultcode; 873 xmlnode *fault;
874 char *faultcode_str; 874 char *faultcode_str;
875 875
876 if (resp == NULL) { 876 if (resp == NULL) {
877 purple_debug_error("msn", 877 purple_debug_error("msn",
878 "Operation {%s} failed. No response received from server.\n", 878 "Operation {%s} failed. No response received from server.\n",
879 msn_contact_operation_str(state->action)); 879 msn_contact_operation_str(state->action));
880 return; 880 return;
881 } 881 }
882 882
883 faultcode = xmlnode_get_child(resp->xml, "Body/Fault/faultcode"); 883 fault = xmlnode_get_child(resp->xml, "Body/Fault");
884 884
885 if (faultcode == NULL) { 885 if (fault == NULL) {
886 /* No errors */ 886 /* No errors */
887 if (state->cb) 887 if (state->cb)
888 ((MsnSoapCallback)state->cb)(req, resp, data); 888 ((MsnSoapCallback)state->cb)(req, resp, data);
889 msn_callback_state_free(state); 889 msn_callback_state_free(state);
890 return; 890 return;
891 } 891 }
892 892
893 faultcode_str = xmlnode_get_data(faultcode); 893 faultcode_str = xmlnode_get_data(xmlnode_get_child(fault, "faultcode"));
894 894
895 if (faultcode_str && g_str_equal(faultcode_str, "q0:BadContextToken")) { 895 if (faultcode_str && g_str_equal(faultcode_str, "q0:BadContextToken")) {
896 purple_debug_info("msn", 896 purple_debug_info("msn",
897 "Contact Operation {%s} failed because of bad token." 897 "Contact Operation {%s} failed because of bad token."
898 " Updating token now and retrying operation.\n", 898 " Updating token now and retrying operation.\n",
905 { 905 {
906 if (state->cb) { 906 if (state->cb) {
907 ((MsnSoapCallback)state->cb)(req, resp, data); 907 ((MsnSoapCallback)state->cb)(req, resp, data);
908 } else { 908 } else {
909 /* We don't know how to respond to this faultcode, so log it */ 909 /* We don't know how to respond to this faultcode, so log it */
910 char *str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 910 char *str = xmlnode_to_str(fault, NULL);
911 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 911 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
912 msn_contact_operation_str(state->action), str); 912 msn_contact_operation_str(state->action), str);
913 g_free(str); 913 g_free(str);
914 } 914 }
915 msn_callback_state_free(state); 915 msn_callback_state_free(state);
1032 msn_add_contact_to_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 1032 msn_add_contact_to_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
1033 gpointer data) 1033 gpointer data)
1034 { 1034 {
1035 MsnCallbackState *state = data; 1035 MsnCallbackState *state = data;
1036 MsnUserList *userlist; 1036 MsnUserList *userlist;
1037 char *fault_str; 1037 xmlnode *fault;
1038 1038
1039 /* We don't know how to respond to this faultcode, so log it */ 1039 /* We don't know how to respond to this faultcode, so log it */
1040 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1040 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1041 if (fault_str != NULL) { 1041 if (fault != NULL) {
1042 char *fault_str = xmlnode_to_str(fault, NULL);
1042 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1043 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1043 msn_contact_operation_str(state->action), fault_str); 1044 msn_contact_operation_str(state->action), fault_str);
1044 g_free(fault_str); 1045 g_free(fault_str);
1045 return; 1046 return;
1046 } 1047 }
1147 gpointer data) 1148 gpointer data)
1148 { 1149 {
1149 MsnCallbackState *state = data; 1150 MsnCallbackState *state = data;
1150 MsnUserList *userlist = state->session->userlist; 1151 MsnUserList *userlist = state->session->userlist;
1151 MsnUser *user = msn_userlist_find_user_with_id(userlist, state->uid); 1152 MsnUser *user = msn_userlist_find_user_with_id(userlist, state->uid);
1152 char *fault_str; 1153 xmlnode *fault;
1153 1154
1154 /* We don't know how to respond to this faultcode, so log it */ 1155 /* We don't know how to respond to this faultcode, so log it */
1155 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1156 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1156 if (fault_str != NULL) { 1157 if (fault != NULL) {
1158 char *fault_str = xmlnode_to_str(fault, NULL);
1157 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1159 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1158 msn_contact_operation_str(state->action), fault_str); 1160 msn_contact_operation_str(state->action), fault_str);
1159 g_free(fault_str); 1161 g_free(fault_str);
1160 return; 1162 return;
1161 } 1163 }
1202 static void 1204 static void
1203 msn_del_contact_from_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 1205 msn_del_contact_from_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
1204 gpointer data) 1206 gpointer data)
1205 { 1207 {
1206 MsnCallbackState *state = data; 1208 MsnCallbackState *state = data;
1207 char *fault_str; 1209 xmlnode *fault;
1208 1210
1209 /* We don't know how to respond to this faultcode, so log it */ 1211 /* We don't know how to respond to this faultcode, so log it */
1210 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1212 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1211 if (fault_str != NULL) { 1213 if (fault != NULL) {
1214 char *fault_str = xmlnode_to_str(fault, NULL);
1212 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1215 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1213 msn_contact_operation_str(state->action), fault_str); 1216 msn_contact_operation_str(state->action), fault_str);
1214 g_free(fault_str); 1217 g_free(fault_str);
1215 return; 1218 return;
1216 } 1219 }
1283 static void 1286 static void
1284 msn_update_contact_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 1287 msn_update_contact_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
1285 gpointer data) 1288 gpointer data)
1286 { 1289 {
1287 MsnCallbackState *state = (MsnCallbackState *)data; 1290 MsnCallbackState *state = (MsnCallbackState *)data;
1288 char *fault_str; 1291 xmlnode *fault;
1289 1292
1290 /* We don't know how to respond to this faultcode, so log it */ 1293 /* We don't know how to respond to this faultcode, so log it */
1291 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1294 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1292 if (fault_str != NULL) { 1295 if (fault != NULL) {
1296 char *fault_str = xmlnode_to_str(fault, NULL);
1293 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1297 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1294 msn_contact_operation_str(state->action), fault_str); 1298 msn_contact_operation_str(state->action), fault_str);
1295 g_free(fault_str); 1299 g_free(fault_str);
1296 return; 1300 return;
1297 } 1301 }
1371 msn_del_contact_from_list_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 1375 msn_del_contact_from_list_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
1372 gpointer data) 1376 gpointer data)
1373 { 1377 {
1374 MsnCallbackState *state = data; 1378 MsnCallbackState *state = data;
1375 MsnSession *session = state->session; 1379 MsnSession *session = state->session;
1376 char *fault_str; 1380 xmlnode *fault;
1377 1381
1378 /* We don't know how to respond to this faultcode, so log it */ 1382 /* We don't know how to respond to this faultcode, so log it */
1379 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1383 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1380 if (fault_str != NULL) { 1384 if (fault != NULL) {
1385 char *fault_str = xmlnode_to_str(fault, NULL);
1381 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1386 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1382 msn_contact_operation_str(state->action), fault_str); 1387 msn_contact_operation_str(state->action), fault_str);
1383 g_free(fault_str); 1388 g_free(fault_str);
1384 return; 1389 return;
1385 } 1390 }
1456 static void 1461 static void
1457 msn_add_contact_to_list_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, 1462 msn_add_contact_to_list_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp,
1458 gpointer data) 1463 gpointer data)
1459 { 1464 {
1460 MsnCallbackState *state = data; 1465 MsnCallbackState *state = data;
1461 char *fault_str; 1466 xmlnode *fault;
1462 1467
1463 /* We don't know how to respond to this faultcode, so log it */ 1468 /* We don't know how to respond to this faultcode, so log it */
1464 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1469 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1465 if (fault_str != NULL) { 1470 if (fault != NULL) {
1471 char *fault_str = xmlnode_to_str(fault, NULL);
1466 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1472 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1467 msn_contact_operation_str(state->action), fault_str); 1473 msn_contact_operation_str(state->action), fault_str);
1468 g_free(fault_str); 1474 g_free(fault_str);
1469 return; 1475 return;
1470 } 1476 }
1560 msn_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data) 1566 msn_group_read_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data)
1561 { 1567 {
1562 MsnCallbackState *state = data; 1568 MsnCallbackState *state = data;
1563 MsnSession *session; 1569 MsnSession *session;
1564 MsnUserList *userlist; 1570 MsnUserList *userlist;
1565 char *fault_str; 1571 xmlnode *fault;
1566 1572
1567 /* We don't know how to respond to this faultcode, so log it */ 1573 /* We don't know how to respond to this faultcode, so log it */
1568 fault_str = xmlnode_to_str(xmlnode_get_child(resp->xml, "Body/Fault"), NULL); 1574 fault = xmlnode_get_child(resp->xml, "Body/Fault");
1569 if (fault_str != NULL) { 1575 if (fault != NULL) {
1576 char *fault_str = xmlnode_to_str(fault, NULL);
1570 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n", 1577 purple_debug_error("msn", "Operation {%s} Failed, SOAP Fault was: %s\n",
1571 msn_contact_operation_str(state->action), fault_str); 1578 msn_contact_operation_str(state->action), fault_str);
1572 g_free(fault_str); 1579 g_free(fault_str);
1573 return; 1580 return;
1574 } 1581 }