Changeset cfcc587 for protocols/jabber/jabber.c
- Timestamp:
- 2005-11-28T01:14:35Z (19 years ago)
- Branches:
- master
- Children:
- ed165fe
- Parents:
- cf13671 (diff), b20b32f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
rcf13671 rcfcc587 757 757 static void jabber_handlemessage(gjconn gjc, jpacket p) 758 758 { 759 xmlnode y, xmlns, subj,z;759 xmlnode y, xmlns, z; 760 760 time_t time_sent = time(NULL); 761 761 762 char *from = NULL, *msg = NULL, *type = NULL , *topic = NULL;762 char *from = NULL, *msg = NULL, *type = NULL; 763 763 char m[BUF_LONG * 2]; 764 764 … … 798 798 799 799 if (type && !g_strcasecmp(type, "jabber:x:conference")) { 800 char *room; 801 GList *m = NULL; 802 char **data; 803 804 room = xmlnode_get_attrib(xmlns, "jid"); 805 data = g_strsplit(room, "@", 2); 806 m = g_list_append(m, g_strdup(data[0])); 807 m = g_list_append(m, g_strdup(data[1])); 808 m = g_list_append(m, g_strdup(gjc->user->user)); 809 g_strfreev(data); 810 811 /* ** Bitlbee ** serv_got_chat_invite(GJ_GC(gjc), room, from, msg, m); */ 800 /* do nothing */ 812 801 } else if (msg) { /* whisper */ 813 802 struct jabber_chat *jc; … … 817 806 else { 818 807 int flags = 0; 819 /* ** Bitlbee ** 820 if (xmlnode_get_tag(p->x, "gaim")) 821 flags = IM_FLAG_GAIMUSER; 822 if (find_conversation(jid_full(p->from))) 823 serv_got_im(GJ_GC(gjc), jid_full(p->from), m, flags, time_sent, -1); 824 else { 825 ** End - Bitlbee ** */ 826 if(p->from->user) { 827 from = g_strdup_printf("%s@%s", p->from->user, p->from->server); 828 } else { 829 /* server message? */ 830 from = g_strdup(p->from->server); 831 } 832 serv_got_im(GJ_GC(gjc), from, m, flags, time_sent, -1); 833 g_free(from); 834 /* ** Bitlbee ** } ** End - Bitlbee ** */ 808 809 if(p->from->user) { 810 from = g_strdup_printf("%s@%s", p->from->user, p->from->server); 811 } else { 812 /* server message? */ 813 from = g_strdup(p->from->server); 814 } 815 serv_got_im(GJ_GC(gjc), from, m, flags, time_sent, -1); 816 g_free(from); 835 817 } 836 818 } … … 847 829 g_free(from); 848 830 } 849 } else if (!g_strcasecmp(type, "groupchat")) { 850 struct jabber_chat *jc; 851 static int i = 0; 852 853 /* 854 if ((y = xmlnode_get_tag(p->x, "html"))) { 855 msg = xmlnode_get_data(y); 856 } else 857 */ 858 if ((y = xmlnode_get_tag(p->x, "body"))) { 859 msg = xmlnode_get_data(y); 860 } 861 862 msg = utf8_to_str(msg); 831 } else if (!g_strcasecmp(type, "headline")) { 832 char *subject, *body, *url; 863 833 864 if ((subj = xmlnode_get_tag(p->x, "subject"))) { 865 topic = xmlnode_get_data(subj); 866 } 867 topic = utf8_to_str(topic); 868 869 jc = find_existing_chat(GJ_GC(gjc), p->from); 870 if (!jc) { 871 /* we're not in this chat. are we supposed to be? */ 872 if ((jc = find_pending_chat(GJ_GC(gjc), p->from)) != NULL) { 873 /* yes, we're supposed to be. so now we are. */ 874 jc->b = serv_got_joined_chat(GJ_GC(gjc), i++, p->from->user); 875 jc->id = jc->b->id; 876 jc->state = JCS_ACTIVE; 877 } else { 878 /* no, we're not supposed to be. */ 879 g_free(msg); 880 return; 881 } 882 } 883 if (p->from->resource) { 884 if (!y) { 885 if (!find_chat_buddy(jc->b, p->from->resource)) { 886 add_chat_buddy(jc->b, p->from->resource); 887 } else if ((y = xmlnode_get_tag(p->x, "status"))) { 888 char *buf; 889 890 buf = g_strdup_printf("%s@%s/%s", 891 p->from->user, p->from->server, p->from->resource); 892 jabber_track_away(gjc, p, buf, NULL); 893 g_free(buf); 894 895 } 896 } else if (jc->b && msg) { 897 char buf[8192]; 898 899 if (topic) { 900 char tbuf[8192]; 901 g_snprintf(tbuf, sizeof(tbuf), "%s", topic); 902 } 903 904 905 g_snprintf(buf, sizeof(buf), "%s", msg); 906 serv_got_chat_in(GJ_GC(gjc), jc->b->id, p->from->resource, 0, buf, time_sent); 907 } 908 } else { /* message from the server */ 909 if(jc->b && topic) { 910 char tbuf[8192]; 911 g_snprintf(tbuf, sizeof(tbuf), "%s", topic); 912 } 913 } 914 915 g_free(msg); 916 g_free(topic); 917 834 y = xmlnode_get_tag( p->x, "body" ); 835 body = y ? g_strdup( xmlnode_get_data( y ) ) : NULL; 836 837 y = xmlnode_get_tag( p->x, "subject" ); 838 subject = y ? g_strdup( xmlnode_get_data( y ) ) : NULL; 839 840 url = NULL; 841 z = xmlnode_get_firstchild(p->x); 842 while( z ) 843 { 844 char *xtype = xmlnode_get_attrib( z, "xmlns" ); 845 846 if( xtype && g_strcasecmp( xtype, "jabber:x:oob" ) == 0 && 847 ( y = xmlnode_get_tag( z, "url" ) ) ) 848 { 849 url = g_strdup( xmlnode_get_data( y ) ); 850 break; 851 } 852 853 z = xmlnode_get_nextsibling( z ); 854 } 855 856 g_snprintf( m, BUF_LONG, "Subject: %s\nURL: %s\nMessage:\n%s", subject ? subject : "(none)", 857 url ? url : "(none)", body ? body : "(none)" ); 858 859 if( p->from->user ) 860 from = g_strdup_printf( "%s@%s", p->from->user, p->from->server ); 861 else 862 from = g_strdup( p->from->server ); 863 864 serv_got_im( GJ_GC(gjc), from, m, 0, time_sent, -1 ); 865 866 g_free( from ); 867 g_free( subject ); 868 g_free( body ); 869 g_free( url ); 918 870 } 919 871 }
Note: See TracChangeset
for help on using the changeset viewer.