aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--irc.c17
-rw-r--r--irc_commands.c17
-rw-r--r--protocols/nogaim.c24
-rw-r--r--protocols/nogaim.h10
4 files changed, 54 insertions, 14 deletions
diff --git a/irc.c b/irc.c
index 72bc5d92..ebb2876b 100644
--- a/irc.c
+++ b/irc.c
@@ -787,19 +787,14 @@ void irc_motd( irc_t *irc )
void irc_topic( irc_t *irc, char *channel )
{
- if( g_strcasecmp( channel, irc->channel ) == 0 )
- {
+ struct groupchat *c = irc_chat_by_channel( irc, channel );
+
+ if( c && c->topic )
+ irc_reply( irc, 332, "%s :%s", channel, c->topic );
+ else if( g_strcasecmp( channel, irc->channel ) == 0 )
irc_reply( irc, 332, "%s :%s", channel, CONTROL_TOPIC );
- }
else
- {
- struct groupchat *c = irc_chat_by_channel( irc, channel );
-
- if( c )
- irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
- else
- irc_reply( irc, 331, "%s :No topic for this channel", channel );
- }
+ irc_reply( irc, 331, "%s :No topic for this channel", channel );
}
void irc_umode_set( irc_t *irc, char *s, int allow_priv )
diff --git a/irc_commands.c b/irc_commands.c
index 266d9732..287a126f 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -420,10 +420,21 @@ static void irc_cmd_watch( irc_t *irc, char **cmd )
static void irc_cmd_topic( irc_t *irc, char **cmd )
{
- if( cmd[2] )
- irc_reply( irc, 482, "%s :Cannot change topic", cmd[1] );
+ char *channel = cmd[1];
+ char *topic = cmd[2];
+
+ if( topic )
+ {
+ /* Send the topic */
+ struct groupchat *c = irc_chat_by_channel( irc, channel );
+ if( c && c->ic && c->ic->acc->prpl->chat_topic )
+ c->ic->acc->prpl->chat_topic( c, topic );
+ }
else
- irc_topic( irc, cmd[1] );
+ {
+ /* Get the topic */
+ irc_topic( irc, channel );
+ }
}
static void irc_cmd_away( irc_t *irc, char **cmd )
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index d1aceb1a..2ad8a049 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -759,6 +759,29 @@ void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags,
g_free( wrapped );
}
+void imcb_chat_topic( struct groupchat *c, char *who, char *topic )
+{
+ struct im_connection *ic = c->ic;
+ user_t *u = NULL;
+
+ if( who == NULL)
+ u = user_find( ic, ic->irc->mynick );
+ else if( g_strcasecmp( who, ic->acc->user ) == 0 )
+ u = user_find( ic, ic->irc->nick );
+ else
+ u = user_findhandle( ic, who );
+
+ if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
+ ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
+ strip_html( topic );
+
+ g_free( c->topic );
+ c->topic = g_strdup( topic );
+
+ if( c->joined && u )
+ irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
+}
+
struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
{
struct groupchat *c;
@@ -776,6 +799,7 @@ struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
c->ic = ic;
c->title = g_strdup( handle );
c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
+ c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );
if( set_getbool( &ic->irc->set, "debug" ) )
imcb_log( ic, "Creating new conversation: (id=0x%x,handle=%s)", (int) c, handle );
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 5bf6d922..7c643cd3 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -109,6 +109,9 @@ struct groupchat {
/* The title variable contains the ID you gave when you created the
* chat using imcb_chat_new(). */
char *title;
+ /* Use imcb_chat_topic() to change this variable otherwise the user
+ * won't notice the topic change. */
+ char *topic;
char joined;
/* This is for you, you can add your own structure here to extend this
* structure for your protocol's needs. */
@@ -211,6 +214,11 @@ struct prpl {
* not implement this. */
struct groupchat *
(* chat_join) (struct im_connection *, char *room, char *nick, char *password);
+ /* Change the topic, if supported. Note that BitlBee expects the IM
+ server to confirm the topic change with a regular topic change
+ event. If it doesn't do that, you have to fake it to make it
+ visible to the user. */
+ void (* chat_topic) (struct groupchat *, char *message);
/* You can tell what away states your protocol supports, so that
* BitlBee will try to map the IRC away reasons to them, or use
@@ -292,6 +300,8 @@ G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle );
G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason );
/* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
+/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */
+G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic );
G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
/* Actions, or whatever. */