| 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(strcmp("sip:", buddy->name)) { |
199 if(strncmp(buddy->name, "sip:", 4)) { |
| 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)) { |
| 832 "Expires: %d\r\n" |
832 "Expires: %d\r\n" |
| 833 "Accept: application/pidf+xml, application/xpidf+xml\r\n" |
833 "Accept: application/pidf+xml, application/xpidf+xml\r\n" |
| 834 "Event: presence\r\n", |
834 "Event: presence\r\n", |
| 835 expiration); |
835 expiration); |
| 836 |
836 |
| 837 if(strstr(buddy->name, "sip:")) |
837 if(strncmp(buddy->name, "sip:", 4)) |
| |
838 to = g_strdup_printf("sip:%s", buddy->name); |
| |
839 else |
| 838 to = g_strdup(buddy->name); |
840 to = g_strdup(buddy->name); |
| 839 else |
|
| 840 to = g_strdup_printf("sip:%s", buddy->name); |
|
| 841 |
841 |
| 842 tmp = get_contact(sip); |
842 tmp = get_contact(sip); |
| 843 contact = g_strdup_printf("%sContact: %s\r\n", tmp2, tmp); |
843 contact = g_strdup_printf("%sContact: %s\r\n", tmp2, tmp); |
| 844 g_free(tmp); |
844 g_free(tmp); |
| 845 g_free(tmp2); |
845 g_free(tmp2); |
| 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 && !strcmp(tmp, "vnd-microsoft-roaming-contacts")){ |
884 if(tmp && !strncmp(tmp, "vnd-microsoft-roaming-contacts", 30)){ |
| 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(strcmp("sip:", to)) { |
1016 if(strncmp(to, "sip:", 4)) |
| 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) { |
| 1022 hdr = g_strdup_printf("Content-Type: %s\r\n", type); |
1022 hdr = g_strdup_printf("Content-Type: %s\r\n", type); |
| 1023 } else { |
1023 } else { |
| 1024 hdr = g_strdup("Content-Type: text/plain\r\n"); |
1024 hdr = g_strdup("Content-Type: text/plain\r\n"); |
| 1025 } |
1025 } |
| 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 || !strcmp(contenttype, "text/plain") || !strcmp(contenttype, "text/html")) { |
1053 if(!contenttype || !strncmp(contenttype, "text/plain", 10) || !strncmp(contenttype, "text/html", 9)) { |
| 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(!strcmp(contenttype, "application/im-iscomposing+xml")) { |
1058 else if(!strncmp(contenttype, "application/im-iscomposing+xml", 30)) { |
| 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) { |