Mercurial > pidgin.yaz
comparison libpurple/protocols/simple/simple.c @ 20914:74ec24deb267
Patch from Will Hawkins for some cleanup of the SIMPLE notify message processing. This should hopefully fix some cases when a user signs off but we don't notice. Fixes #3507.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 13 Oct 2007 16:36:06 +0000 |
parents | b8e8b7dba8e0 |
children | 89c7be36fd61 e747ac0c42d6 |
comparison
equal
deleted
inserted
replaced
20913:b8e8b7dba8e0 | 20914:74ec24deb267 |
---|---|
1071 } | 1071 } |
1072 | 1072 |
1073 static void process_incoming_notify(struct simple_account_data *sip, struct sipmsg *msg) { | 1073 static void process_incoming_notify(struct simple_account_data *sip, struct sipmsg *msg) { |
1074 gchar *from; | 1074 gchar *from; |
1075 gchar *fromhdr; | 1075 gchar *fromhdr; |
1076 gchar *tmp2; | 1076 gchar *basicstatus_data; |
1077 xmlnode *pidf; | 1077 xmlnode *pidf; |
1078 xmlnode *basicstatus = NULL, *tuple, *status; | 1078 xmlnode *basicstatus = NULL, *tuple, *status; |
1079 gboolean isonline = FALSE; | 1079 gboolean isonline = FALSE; |
1080 | 1080 |
1081 fromhdr = sipmsg_find_header(msg, "From"); | 1081 fromhdr = sipmsg_find_header(msg, "From"); |
1084 | 1084 |
1085 pidf = xmlnode_from_str(msg->body, msg->bodylen); | 1085 pidf = xmlnode_from_str(msg->body, msg->bodylen); |
1086 | 1086 |
1087 if(!pidf) { | 1087 if(!pidf) { |
1088 purple_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); | 1088 purple_debug_info("simple", "process_incoming_notify: no parseable pidf\n"); |
1089 purple_prpl_got_user_status(sip->account, from, "offline", NULL); | |
1090 send_sip_response(sip->gc, msg, 200, "OK", NULL); | |
1089 g_free(from); | 1091 g_free(from); |
1090 send_sip_response(sip->gc, msg, 200, "OK", NULL); | |
1091 return; | 1092 return; |
1092 } | 1093 } |
1093 | 1094 |
1094 if ((tuple = xmlnode_get_child(pidf, "tuple"))) | 1095 if ((tuple = xmlnode_get_child(pidf, "tuple"))) |
1095 if ((status = xmlnode_get_child(tuple, "status"))) | 1096 if ((status = xmlnode_get_child(tuple, "status"))) |
1100 xmlnode_free(pidf); | 1101 xmlnode_free(pidf); |
1101 g_free(from); | 1102 g_free(from); |
1102 return; | 1103 return; |
1103 } | 1104 } |
1104 | 1105 |
1105 tmp2 = xmlnode_get_data(basicstatus); | 1106 basicstatus_data = xmlnode_get_data(basicstatus); |
1106 | 1107 |
1107 if(!tmp2) { | 1108 if(!basicstatus_data) { |
1108 purple_debug_info("simple", "process_incoming_notify: no basic data found\n"); | 1109 purple_debug_info("simple", "process_incoming_notify: no basic data found\n"); |
1109 xmlnode_free(pidf); | 1110 xmlnode_free(pidf); |
1110 g_free(from); | 1111 g_free(from); |
1111 return; | 1112 return; |
1112 } | 1113 } |
1113 | 1114 |
1114 if(strstr(tmp2, "open")) { | 1115 if(strstr(basicstatus_data, "open")) |
1115 isonline = TRUE; | 1116 isonline = TRUE; |
1116 } | 1117 |
1117 | 1118 |
1118 g_free(tmp2); | 1119 if(isonline) |
1119 | 1120 purple_prpl_got_user_status(sip->account, from, "available", NULL); |
1120 if(isonline) purple_prpl_got_user_status(sip->account, from, "available", NULL); | 1121 else |
1121 else purple_prpl_got_user_status(sip->account, from, "offline", NULL); | 1122 purple_prpl_got_user_status(sip->account, from, "offline", NULL); |
1122 | 1123 |
1123 xmlnode_free(pidf); | 1124 xmlnode_free(pidf); |
1124 | |
1125 g_free(from); | 1125 g_free(from); |
1126 g_free(basicstatus_data); | |
1127 | |
1126 send_sip_response(sip->gc, msg, 200, "OK", NULL); | 1128 send_sip_response(sip->gc, msg, 200, "OK", NULL); |
1127 } | 1129 } |
1128 | 1130 |
1129 static unsigned int simple_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) { | 1131 static unsigned int simple_typing(PurpleConnection *gc, const char *name, PurpleTypingState state) { |
1130 struct simple_account_data *sip = gc->proto_data; | 1132 struct simple_account_data *sip = gc->proto_data; |