- Timestamp:
- 2007-04-22T23:39:37Z (18 years ago)
- Branches:
- master
- Children:
- 0e7ab64
- Parents:
- e35d1a1
- Location:
- protocols/jabber
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/conference.c
re35d1a1 r43671b9 62 62 } 63 63 64 int jabber_chat_ leave( struct groupchat *c, const char *reason)64 int jabber_chat_msg( struct groupchat *c, char *message, int flags ) 65 65 { 66 66 struct im_connection *ic = c->ic; … … 68 68 struct xt_node *node; 69 69 70 node = xt_new_node( "body", message, NULL ); 71 node = jabber_make_packet( "message", "groupchat", jc->name, node ); 72 73 if( !jabber_write_packet( ic, node ) ) 74 { 75 xt_free_node( node ); 76 return 0; 77 } 78 xt_free_node( node ); 79 80 return 1; 81 } 82 83 int jabber_chat_leave( struct groupchat *c, const char *reason ) 84 { 85 struct im_connection *ic = c->ic; 86 struct jabber_chat *jc = c->data; 87 struct xt_node *node; 88 70 89 node = xt_new_node( "x", NULL, NULL ); 71 90 xt_add_attr( node, "xmlns", XMLNS_MUC ); … … 78 97 } 79 98 xt_free_node( node ); 80 81 /* Remove all participants from jc->buddies and clean up our data. */82 jabber_buddy_remove_bare( ic, jc->name );83 g_free( jc->name );84 g_free( jc );85 86 /* And the generic stuff. */87 imcb_chat_free( c );88 99 89 100 return 1; … … 188 199 s = strchr( bud->orig_jid, '/' ); 189 200 if( s ) *s = 0; 190 imcb_chat_msg( chat, bud->orig_jid, body->text, 0, 0);201 imcb_chat_msg( chat, bud->orig_jid, body->text, 0, jabber_get_timestamp( node ) ); 191 202 if( s ) *s = '/'; 192 203 } -
protocols/jabber/jabber.c
re35d1a1 r43671b9 336 336 } 337 337 338 static void jabber_chat_msg_( struct groupchat *c, char *message, int flags ) 339 { 340 if( c && message ) 341 jabber_chat_msg( c, message, flags ); 342 } 343 338 344 static void jabber_chat_leave_( struct groupchat *c ) 339 345 { … … 406 412 ret->buddy_msg = jabber_buddy_msg; 407 413 ret->away_states = jabber_away_states; 408 // ret->get_status_string = jabber_get_status_string;409 414 ret->set_away = jabber_set_away; 410 415 // ret->set_info = jabber_set_info; … … 412 417 ret->add_buddy = jabber_add_buddy; 413 418 ret->remove_buddy = jabber_remove_buddy; 414 // ret->chat_msg = jabber_chat_msg;419 ret->chat_msg = jabber_chat_msg_; 415 420 // ret->chat_invite = jabber_chat_invite; 416 421 ret->chat_leave = jabber_chat_leave_; -
protocols/jabber/jabber.h
re35d1a1 r43671b9 144 144 #define XMLNS_TIME "jabber:iq:time" /* XEP-0090 */ 145 145 #define XMLNS_VCARD "vcard-temp" /* XEP-0054 */ 146 #define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */ 146 147 #define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* 0085 */ 147 148 #define XMLNS_DISCOVER "http://jabber.org/protocol/disco#info" /* 0030 */ … … 192 193 int jabber_buddy_remove_bare( struct im_connection *ic, char *bare_jid ); 193 194 struct groupchat *jabber_chat_by_name( struct im_connection *ic, const char *name ); 195 time_t jabber_get_timestamp( struct xt_node *xt ); 194 196 195 197 extern const struct jabber_away_state jabber_away_state_list[]; … … 211 213 /* conference.c */ 212 214 struct groupchat *jabber_chat_join( struct im_connection *ic, char *room, char *nick, char *password ); 215 int jabber_chat_msg( struct groupchat *ic, char *message, int flags ); 213 216 int jabber_chat_leave( struct groupchat *c, const char *reason ); 214 217 void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node ); -
protocols/jabber/jabber_util.c
re35d1a1 r43671b9 558 558 return ret; 559 559 } 560 561 time_t jabber_get_timestamp( struct xt_node *xt ) 562 { 563 struct tm tp, utc; 564 struct xt_node *c; 565 time_t res, tres; 566 char *s = NULL; 567 568 for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next ) 569 { 570 if( ( s = xt_find_attr( c, "xmlns" ) ) && strcmp( s, XMLNS_DELAY ) == 0 ) 571 break; 572 } 573 574 if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) 575 return 0; 576 577 memset( &tp, 0, sizeof( tp ) ); 578 if( sscanf( s, "%4d%2d%2dT%2d:%2d:%2d", &tp.tm_year, &tp.tm_mon, &tp.tm_mday, 579 &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) != 6 ) 580 return 0; 581 582 tp.tm_year -= 1900; 583 tp.tm_mon --; 584 tp.tm_isdst = -1; /* GRRRRRRRRRRR */ 585 586 res = mktime( &tp ); 587 /* Problem is, mktime() just gave us the GMT timestamp for the 588 given local time... While the given time WAS NOT local. So 589 we should fix this now. 590 591 Now I could choose between messing with environment variables 592 (kludgy) or using timegm() (not portable)... Or doing the 593 following, which I actually prefer... */ 594 gmtime_r( &res, &utc ); 595 utc.tm_isdst = -1; /* Once more: GRRRRRRRRRRRRRRRRRR!!! */ 596 if( utc.tm_hour == tp.tm_hour && utc.tm_min == tp.tm_min ) 597 /* Sweet! We're in UTC right now... */ 598 return res; 599 600 tres = mktime( &utc ); 601 res += res - tres; 602 603 /* Yes, this is a hack. And it will go wrong around DST changes. 604 BUT this is more likely to be threadsafe than messing with 605 environment variables, and possibly more portable... */ 606 607 return res; 608 } -
protocols/jabber/message.c
re35d1a1 r43671b9 81 81 82 82 if( fullmsg->len > 0 ) 83 imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 0, 0 ); 83 imcb_buddy_msg( ic, bud ? bud->bare_jid : from, fullmsg->str, 84 0, jabber_get_timestamp( node ) ); 84 85 85 86 g_string_free( fullmsg, TRUE ); -
protocols/jabber/xmltree.c
re35d1a1 r43671b9 188 188 g_strcasecmp( xt->handlers[i].parent, "<root>" ) == 0 ) ) ) 189 189 { 190 xt_print( node );190 // xt_print( node ); 191 191 192 192 st = xt->handlers[i].func( node, xt->data );
Note: See TracChangeset
for help on using the changeset viewer.