Changeset f0071b7
- Timestamp:
- 2006-10-23T20:01:19Z (18 years ago)
- Branches:
- master
- Children:
- 62d0c14
- Parents:
- e8a6211
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/message.c
re8a6211 rf0071b7 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); 31 struct xt_node *body = xt_find_node( node->children, "body" ) ;31 struct xt_node *body = xt_find_node( node->children, "body" ), *c; 32 32 char *s; 33 33 34 if( !type ) 35 return XT_HANDLED; /* Grmbl... FIXME */ 36 37 if( strcmp( type, "chat" ) == 0 ) 34 if( type && strcmp( type, "error" ) == 0 ) 35 { 36 /* Handle type=error packet. */ 37 } 38 else if( type && strcmp( type, "groupchat" ) == 0 ) 39 { 40 /* TODO! */ 41 } 42 else /* "chat", "normal", "headline", no-type or whatever. Should all be pretty similar. */ 38 43 { 39 44 struct jabber_buddy *bud = NULL; 45 GString *fullmsg = g_string_new( "" ); 40 46 41 if( ( s = strchr( from, '/' ) ) == NULL)47 if( ( s = strchr( from, '/' ) ) ) 42 48 { 43 /* It just shouldn't happen. */44 hide_login_progress( gc, "Received message packet from bare JID");45 signoff( gc );46 return XT_ABORT;49 if( ( bud = jabber_buddy_by_jid( gc, from ) ) ) 50 bud->last_act = time( NULL ); 51 else 52 *s = 0; /* We need to generate a bare JID now. */ 47 53 } 48 54 49 if( ( bud = jabber_buddy_by_jid( gc, from ) ) ) 50 bud->last_act = time( NULL ); 51 else 52 *s = 0; /* We need to generate a bare JID now. */ 55 if( strcmp( type, "headline" ) == 0 ) 56 { 57 c = xt_find_node( node->children, "subject" ); 58 g_string_append_printf( fullmsg, "Headline: %s\n", c && c->text_len > 0 ? c->text : "" ); 59 60 /* <x xmlns="jabber:x:oob"><url>http://....</url></x> can contain a URL, it seems. */ 61 for( c = node->children; c; c = c->next ) 62 { 63 struct xt_node *url; 64 65 if( ( url = xt_find_node( c->children, "url" ) ) && url->text_len > 0 ) 66 g_string_append_printf( fullmsg, "URL: %s\n", url->text ); 67 } 68 } 69 else if( ( c = xt_find_node( node->children, "subject" ) ) && c->text_len > 0 ) 70 { 71 g_string_append_printf( fullmsg, "<< \002BitlBee\002 - Message with subject: %s >>\n", c->text ); 72 } 53 73 54 if( body ) /* Could be just a typing notification. */ 55 serv_got_im( gc, bud ? bud->handle : from, body->text, 0, 0, 0 ); 74 if( body && body->text_len > 0 ) /* Could be just a typing notification. */ 75 fullmsg = g_string_append( fullmsg, body->text ); 76 77 if( fullmsg->len > 0 ) 78 serv_got_im( gc, bud ? bud->handle : from, fullmsg->str, 0, 0, fullmsg->len ); 79 80 g_string_free( fullmsg, TRUE ); 56 81 57 82 /* Handling of incoming typing notifications. */ … … 76 101 *s = '/'; /* And convert it back to a full JID. */ 77 102 } 78 else79 {80 printf( "Received MSG from %s:\n", from );81 xt_print( node );82 }83 103 84 104 return XT_HANDLED;
Note: See TracChangeset
for help on using the changeset viewer.