Changeset aea8b68
- Timestamp:
- 2010-05-06T00:28:56Z (14 years ago)
- Branches:
- master
- Children:
- f1a0890
- Parents:
- 9438323
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.h
r9438323 raea8b68 147 147 148 148 const struct irc_channel_funcs *f; 149 void *data; 149 150 } irc_channel_t; 150 151 -
irc_im.c
r9438323 raea8b68 203 203 } 204 204 205 206 /* Groupchats */ 207 gboolean bee_irc_chat_new( bee_t *bee, struct groupchat *c ) 208 { 209 irc_t *irc = bee->ui_data; 210 irc_channel_t *ic; 211 char *topic; 212 int i; 213 214 for( i = 0; i <= 999; i ++ ) 215 { 216 char name[16]; 217 sprintf( name, "&chat_%03d", i ); 218 if( ( ic = irc_channel_new( irc, name ) ) ) 219 break; 220 } 221 222 if( ic == NULL ) 223 return FALSE; 224 225 c->ui_data = ic; 226 ic->data = c; 227 228 topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title ); 229 irc_channel_set_topic( ic, topic, irc->root ); 230 g_free( topic ); 231 232 return TRUE; 233 } 234 235 gboolean bee_irc_chat_free( bee_t *bee, struct groupchat *c ) 236 { 237 irc_channel_t *ic = c->ui_data; 238 239 if( ic->flags & IRC_CHANNEL_JOINED ) 240 irc_channel_printf( ic, "Cleaning up channel, bye!" ); 241 242 irc_channel_free( ic ); 243 244 return TRUE; 245 } 246 247 gboolean bee_irc_chat_log( bee_t *bee, struct groupchat *c, const char *format, ... ) 248 { 249 } 250 251 gboolean bee_irc_chat_msg( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at ) 252 { 253 } 254 255 gboolean bee_irc_chat_add_user( bee_t *bee, struct groupchat *c, bee_user_t *bu ) 256 { 257 irc_t *irc = bee->ui_data; 258 259 irc_channel_add_user( c->ui_data, bu == bee->user ? irc->user : bu->ui_data ); 260 } 261 262 gboolean bee_irc_chat_remove_user( bee_t *bee, struct groupchat *c, bee_user_t *bu ) 263 { 264 } 265 266 205 267 /* File transfers */ 206 268 static file_transfer_t *bee_irc_ft_in_start( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size ) … … 237 299 bee_irc_user_typing, 238 300 301 bee_irc_chat_new, 302 bee_irc_chat_free, 303 NULL, 304 NULL, 305 bee_irc_chat_add_user, 306 NULL, 307 239 308 bee_irc_ft_in_start, 240 309 bee_irc_ft_out_start, -
protocols/Makefile
r9438323 raea8b68 10 10 11 11 # [SH] Program variables 12 objects = account.o bee.o bee_ ft.o bee_user.o nogaim.o12 objects = account.o bee.o bee_chat.o bee_ft.o bee_user.o nogaim.o 13 13 14 14 -
protocols/bee.c
r9438323 raea8b68 47 47 s = set_add( &b->set, "strip_html", "true", NULL, b ); 48 48 49 b->user = g_malloc( 1 ); 50 49 51 return b; 50 52 } … … 70 72 set_del( &b->set, b->set->key ); 71 73 74 g_free( b->user ); 72 75 g_free( b ); 73 76 } -
protocols/bee.h
r9438323 raea8b68 28 28 29 29 struct bee_ui_funcs; 30 struct groupchat; 30 31 31 32 typedef struct bee … … 35 36 GSList *users; 36 37 struct account *accounts; /* TODO(wilmer): Use GSList here too? */ 38 39 /* Symbolic, to refer to the local user (who has no real bee_user 40 object). Not to be used by anything except so far imcb_chat_add/ 41 remove_buddy(). This seems slightly cleaner than abusing NULL. */ 42 struct bee_user *user; 37 43 38 44 const struct bee_ui_funcs *ui; … … 73 79 gboolean (*user_typing)( bee_t *bee, bee_user_t *bu, guint32 flags ); 74 80 81 gboolean (*chat_new)( bee_t *bee, struct groupchat *c ); 82 gboolean (*chat_free)( bee_t *bee, struct groupchat *c ); 83 gboolean (*chat_log)( bee_t *bee, struct groupchat *c, const char *format, ... ); 84 gboolean (*chat_msg)( bee_t *bee, struct groupchat *c, const char *who, const char *msg, time_t sent_at ); 85 gboolean (*chat_add_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); 86 gboolean (*chat_remove_user)( bee_t *bee, struct groupchat *c, bee_user_t *bu ); 87 75 88 struct file_transfer* (*ft_in_start)( bee_t *bee, bee_user_t *bu, const char *file_name, size_t file_size ); 76 89 gboolean (*ft_out_start)( struct im_connection *ic, struct file_transfer *ft ); … … 101 114 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, const char *handle, char *msg, guint32 flags, time_t sent_at ); 102 115 116 /* bee_chat.c */ 117 #if 0 118 struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle ); 119 void imcb_chat_name_hint( struct groupchat *c, const char *name ); 120 void imcb_chat_free( struct groupchat *c ); 121 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at ); 122 void imcb_chat_log( struct groupchat *c, char *format, ... ); 123 void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at ); 124 void imcb_chat_add_buddy( struct groupchat *b, const char *handle ); 125 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason ); 126 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle ); 127 #endif 128 103 129 #endif /* __BEE_H__ */ -
protocols/jabber/conference.c
r9438323 raea8b68 92 92 { 93 93 char *normalized = jabber_normalize( name ); 94 GSList *l; 94 95 struct groupchat *ret; 95 96 struct jabber_chat *jc; 96 97 97 for( ret = ic->groupchats; ret; ret = ret->next ) 98 { 98 for( l = ic->groupchats; l; l = l->next ) 99 { 100 ret = l->data; 99 101 jc = ret->data; 100 102 if( strcmp( normalized, jc->name ) == 0 ) -
protocols/jabber/jabber.c
r9438323 raea8b68 282 282 283 283 while( ic->groupchats ) 284 jabber_chat_free( ic->groupchats );284 jabber_chat_free( ic->groupchats->data ); 285 285 286 286 if( jd->r_inpa >= 0 ) -
protocols/jabber/presence.c
r9438323 raea8b68 206 206 struct xt_node *node, *cap; 207 207 struct groupchat *c; 208 GSList *l; 208 209 int st; 209 210 … … 229 230 /* Have to send this update to all groupchats too, the server won't 230 231 do this automatically. */ 231 for( c = ic->groupchats; c && st; c = c->next ) 232 { 232 for( l = ic->groupchats; l && st; l = l->next ) 233 { 234 struct groupchat *c = l->data; 233 235 struct jabber_chat *jc = c->data; 234 236 -
protocols/nogaim.c
r9438323 raea8b68 536 536 return bee_user_by_handle( ic->bee, ic, handle ); 537 537 } 538 539 struct groupchat *imcb_chat_new( struct im_connection *ic, const char *handle )540 {541 #if 0542 struct groupchat *c;543 544 /* This one just creates the conversation structure, user won't see anything yet */545 546 if( ic->groupchats )547 {548 for( c = ic->groupchats; c->next; c = c->next );549 c = c->next = g_new0( struct groupchat, 1 );550 }551 else552 ic->groupchats = c = g_new0( struct groupchat, 1 );553 554 c->ic = ic;555 c->title = g_strdup( handle );556 c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );557 c->topic = g_strdup_printf( "BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->title );558 559 if( set_getbool( &ic->bee->set, "debug" ) )560 imcb_log( ic, "Creating new conversation: (id=%p,handle=%s)", c, handle );561 562 return c;563 #endif564 return NULL;565 }566 567 void imcb_chat_name_hint( struct groupchat *c, const char *name )568 {569 #if 0570 if( !c->joined )571 {572 struct im_connection *ic = c->ic;573 char stripped[MAX_NICK_LENGTH+1], *full_name;574 575 strncpy( stripped, name, MAX_NICK_LENGTH );576 stripped[MAX_NICK_LENGTH] = '\0';577 nick_strip( stripped );578 if( set_getbool( &ic->irc->set, "lcnicks" ) )579 nick_lc( stripped );580 581 full_name = g_strdup_printf( "&%s", stripped );582 583 if( stripped[0] &&584 nick_cmp( stripped, ic->irc->channel + 1 ) != 0 &&585 irc_chat_by_channel( ic->irc, full_name ) == NULL )586 {587 g_free( c->channel );588 c->channel = full_name;589 }590 else591 {592 g_free( full_name );593 }594 }595 #endif596 }597 598 void imcb_chat_free( struct groupchat *c )599 {600 #if 0601 struct im_connection *ic = c->ic;602 struct groupchat *l;603 GList *ir;604 605 if( set_getbool( &ic->bee->set, "debug" ) )606 imcb_log( ic, "You were removed from conversation %p", c );607 608 if( c )609 {610 if( c->joined )611 {612 user_t *u, *r;613 614 r = user_find( ic->irc, ic->irc->mynick );615 irc_privmsg( ic->irc, r, "PRIVMSG", c->channel, "", "Cleaning up channel, bye!" );616 617 u = user_find( ic->irc, ic->irc->nick );618 irc_kick( ic->irc, u, c->channel, r );619 /* irc_part( ic->irc, u, c->channel ); */620 }621 622 /* Find the previous chat in the linked list. */623 for( l = ic->groupchats; l && l->next != c; l = l->next );624 625 if( l )626 l->next = c->next;627 else628 ic->groupchats = c->next;629 630 for( ir = c->in_room; ir; ir = ir->next )631 g_free( ir->data );632 g_list_free( c->in_room );633 g_free( c->channel );634 g_free( c->title );635 g_free( c->topic );636 g_free( c );637 }638 #endif639 }640 641 void imcb_chat_msg( struct groupchat *c, const char *who, char *msg, uint32_t flags, time_t sent_at )642 {643 #if 0644 struct im_connection *ic = c->ic;645 char *wrapped;646 user_t *u;647 648 /* Gaim sends own messages through this too. IRC doesn't want this, so kill them */649 if( g_strcasecmp( who, ic->acc->user ) == 0 )650 return;651 652 u = user_findhandle( ic, who );653 654 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||655 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )656 strip_html( msg );657 658 wrapped = word_wrap( msg, 425 );659 if( c && u )660 {661 char *ts = NULL;662 if( set_getbool( &ic->irc->set, "display_timestamps" ) )663 ts = format_timestamp( ic->irc, sent_at );664 irc_privmsg( ic->irc, u, "PRIVMSG", c->channel, ts ? : "", wrapped );665 g_free( ts );666 }667 else668 {669 imcb_log( ic, "Message from/to conversation %s@%p (unknown conv/user): %s", who, c, wrapped );670 }671 g_free( wrapped );672 #endif673 }674 675 void imcb_chat_log( struct groupchat *c, char *format, ... )676 {677 #if 0678 irc_t *irc = c->ic->irc;679 va_list params;680 char *text;681 user_t *u;682 683 va_start( params, format );684 text = g_strdup_vprintf( format, params );685 va_end( params );686 687 u = user_find( irc, irc->mynick );688 689 irc_privmsg( irc, u, "PRIVMSG", c->channel, "System message: ", text );690 691 g_free( text );692 #endif693 }694 695 void imcb_chat_topic( struct groupchat *c, char *who, char *topic, time_t set_at )696 {697 #if 0698 struct im_connection *ic = c->ic;699 user_t *u = NULL;700 701 if( who == NULL)702 u = user_find( ic->irc, ic->irc->mynick );703 else if( g_strcasecmp( who, ic->acc->user ) == 0 )704 u = user_find( ic->irc, ic->irc->nick );705 else706 u = user_findhandle( ic, who );707 708 if( ( g_strcasecmp( set_getstr( &ic->bee->set, "strip_html" ), "always" ) == 0 ) ||709 ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->bee->set, "strip_html" ) ) )710 strip_html( topic );711 712 g_free( c->topic );713 c->topic = g_strdup( topic );714 715 if( c->joined && u )716 irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );717 #endif718 }719 720 void imcb_chat_add_buddy( struct groupchat *b, const char *handle )721 {722 #if 0723 user_t *u = user_findhandle( b->ic, handle );724 int me = 0;725 726 if( set_getbool( &b->ic->bee->set, "debug" ) )727 imcb_log( b->ic, "User %s added to conversation %p", handle, b );728 729 /* It might be yourself! */730 if( b->ic->acc->prpl->handle_cmp( handle, b->ic->acc->user ) == 0 )731 {732 u = user_find( b->ic->irc, b->ic->irc->nick );733 if( !b->joined )734 irc_join( b->ic->irc, u, b->channel );735 b->joined = me = 1;736 }737 738 /* Most protocols allow people to join, even when they're not in739 your contact list. Try to handle that here */740 if( !u )741 {742 imcb_add_buddy( b->ic, handle, NULL );743 u = user_findhandle( b->ic, handle );744 }745 746 /* Add the handle to the room userlist, if it's not 'me' */747 if( !me )748 {749 if( b->joined )750 irc_join( b->ic->irc, u, b->channel );751 b->in_room = g_list_append( b->in_room, g_strdup( handle ) );752 }753 #endif754 }755 756 /* This function is one BIG hack... :-( EREWRITE */757 void imcb_chat_remove_buddy( struct groupchat *b, const char *handle, const char *reason )758 {759 #if 0760 user_t *u;761 int me = 0;762 763 if( set_getbool( &b->ic->bee->set, "debug" ) )764 imcb_log( b->ic, "User %s removed from conversation %p (%s)", handle, b, reason ? reason : "" );765 766 /* It might be yourself! */767 if( g_strcasecmp( handle, b->ic->acc->user ) == 0 )768 {769 if( b->joined == 0 )770 return;771 772 u = user_find( b->ic->irc, b->ic->irc->nick );773 b->joined = 0;774 me = 1;775 }776 else777 {778 u = user_findhandle( b->ic, handle );779 }780 781 if( me || ( remove_chat_buddy_silent( b, handle ) && b->joined && u ) )782 irc_part( b->ic->irc, u, b->channel );783 #endif784 }785 786 #if 0787 static int remove_chat_buddy_silent( struct groupchat *b, const char *handle )788 {789 GList *i;790 791 /* Find the handle in the room userlist and shoot it */792 i = b->in_room;793 while( i )794 {795 if( g_strcasecmp( handle, i->data ) == 0 )796 {797 g_free( i->data );798 b->in_room = g_list_remove( b->in_room, i->data );799 return( 1 );800 }801 802 i = i->next;803 }804 805 return 0;806 }807 #endif808 538 809 539 -
protocols/nogaim.h
r9438323 raea8b68 89 89 bee_t *bee; 90 90 91 struct groupchat *groupchats;91 GSList *groupchats; 92 92 }; 93 93 … … 100 100 * already, for example to avoid adding somebody two times. */ 101 101 GList *in_room; 102 GList *ignored; 103 104 struct groupchat *next; 105 char *channel; 102 //GList *ignored; 103 104 //struct groupchat *next; 106 105 /* The title variable contains the ID you gave when you created the 107 106 * chat using imcb_chat_new(). */ … … 114 113 * structure for your protocol's needs. */ 115 114 void *data; 115 void *ui_data; 116 116 }; 117 117
Note: See TracChangeset
for help on using the changeset viewer.