comparison libpurple/protocols/simple/simple.c @ 24526:222be065ce6e

Some cleanup. The headers are all NUL delimited, so we don't need to mess with the incorrectly used strncmp()s.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 02 Dec 2008 03:34:17 +0000
parents dea69e5e3427
children 08414e3d8b4f 65cfc59858cf 25e2ab1fff1d
comparison
equal deleted inserted replaced
24525:dea69e5e3427 24526:222be065ce6e
194 194
195 static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) 195 static void simple_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
196 { 196 {
197 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data; 197 struct simple_account_data *sip = (struct simple_account_data *)gc->proto_data;
198 struct simple_buddy *b; 198 struct simple_buddy *b;
199 if(strncmp("sip:", buddy->name, 4)) { 199 if(strcmp("sip:", buddy->name)) {
200 gchar *buf = g_strdup_printf("sip:%s", buddy->name); 200 gchar *buf = g_strdup_printf("sip:%s", buddy->name);
201 purple_blist_rename_buddy(buddy, buf); 201 purple_blist_rename_buddy(buddy, buf);
202 g_free(buf); 202 g_free(buf);
203 } 203 }
204 if(!g_hash_table_lookup(sip->buddies, buddy->name)) { 204 if(!g_hash_table_lookup(sip->buddies, buddy->name)) {
879 struct simple_buddy *bs; 879 struct simple_buddy *bs;
880 int len = msg->bodylen; 880 int len = msg->bodylen;
881 881
882 882
883 tmp = sipmsg_find_header(msg, "Event"); 883 tmp = sipmsg_find_header(msg, "Event");
884 if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ 884 if(tmp && !strcmp(tmp, "vnd-microsoft-roaming-contacts")){
885 885
886 purple_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len); 886 purple_debug_info("simple", "simple_add_lcs_contacts->%s-%d\n", msg->body, len);
887 /*Convert the contact from XML to Purple Buddies*/ 887 /*Convert the contact from XML to Purple Buddies*/
888 isc = xmlnode_from_str(msg->body, len); 888 isc = xmlnode_from_str(msg->body, len);
889 889
1011 } 1011 }
1012 1012
1013 static void simple_send_message(struct simple_account_data *sip, const char *to, const char *msg, const char *type) { 1013 static void simple_send_message(struct simple_account_data *sip, const char *to, const char *msg, const char *type) {
1014 gchar *hdr; 1014 gchar *hdr;
1015 gchar *fullto; 1015 gchar *fullto;
1016 if(strncmp("sip:", to, 4)) { 1016 if(strcmp("sip:", to)) {
1017 fullto = g_strdup_printf("sip:%s", to); 1017 fullto = g_strdup_printf("sip:%s", to);
1018 } else { 1018 } else {
1019 fullto = g_strdup(to); 1019 fullto = g_strdup(to);
1020 } 1020 }
1021 if(type) { 1021 if(type) {
1048 if(!from) return; 1048 if(!from) return;
1049 1049
1050 purple_debug(PURPLE_DEBUG_MISC, "simple", "got message from %s: %s\n", from, msg->body); 1050 purple_debug(PURPLE_DEBUG_MISC, "simple", "got message from %s: %s\n", from, msg->body);
1051 1051
1052 contenttype = sipmsg_find_header(msg, "Content-Type"); 1052 contenttype = sipmsg_find_header(msg, "Content-Type");
1053 if(!contenttype || !strncmp(contenttype, "text/plain", 10) || !strncmp(contenttype, "text/html", 9)) { 1053 if(!contenttype || !strcmp(contenttype, "text/plain") || !strcmp(contenttype, "text/html")) {
1054 serv_got_im(sip->gc, from, msg->body, 0, time(NULL)); 1054 serv_got_im(sip->gc, from, msg->body, 0, time(NULL));
1055 send_sip_response(sip->gc, msg, 200, "OK", NULL); 1055 send_sip_response(sip->gc, msg, 200, "OK", NULL);
1056 found = TRUE; 1056 found = TRUE;
1057 } 1057 }
1058 else if(!strncmp(contenttype, "application/im-iscomposing+xml", 30)) { 1058 else if(!strcmp(contenttype, "application/im-iscomposing+xml")) {
1059 xmlnode *isc = xmlnode_from_str(msg->body, msg->bodylen); 1059 xmlnode *isc = xmlnode_from_str(msg->body, msg->bodylen);
1060 xmlnode *state; 1060 xmlnode *state;
1061 gchar *statedata; 1061 gchar *statedata;
1062 1062
1063 if(!isc) { 1063 if(!isc) {
1075 return; 1075 return;
1076 } 1076 }
1077 1077
1078 statedata = xmlnode_get_data(state); 1078 statedata = xmlnode_get_data(state);
1079 if(statedata) { 1079 if(statedata) {
1080 if(strstr(statedata, "active")) serv_got_typing(sip->gc, from, 0, PURPLE_TYPING); 1080 if(strstr(statedata, "active"))
1081 else serv_got_typing_stopped(sip->gc, from); 1081 serv_got_typing(sip->gc, from, 0, PURPLE_TYPING);
1082 else
1083 serv_got_typing_stopped(sip->gc, from);
1082 1084
1083 g_free(statedata); 1085 g_free(statedata);
1084 } 1086 }
1085 xmlnode_free(isc); 1087 xmlnode_free(isc);
1086 send_sip_response(sip->gc, msg, 200, "OK", NULL); 1088 send_sip_response(sip->gc, msg, 200, "OK", NULL);