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