aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-12-09 23:19:35 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2007-12-09 23:19:35 +0000
commitc058ff976bbbbf43ef11c262f21440e61244f73e (patch)
treefb5f6438555ab486d44925f7fd06f0d4265ec10d
parentde0337481fca3894c406a2724da30af8cc8bae2f (diff)
Added /invite support for Jabber chatrooms (and fixed the argument order
to chat_invite).
-rw-r--r--irc_commands.c2
-rw-r--r--protocols/jabber/conference.c21
-rw-r--r--protocols/jabber/jabber.c16
-rw-r--r--protocols/jabber/jabber.h1
-rw-r--r--protocols/msn/msn.c2
-rw-r--r--protocols/oscar/oscar.c2
-rw-r--r--protocols/yahoo/yahoo.c2
7 files changed, 41 insertions, 5 deletions
diff --git a/irc_commands.c b/irc_commands.c
index 287a126f..65f0d6c6 100644
--- a/irc_commands.c
+++ b/irc_commands.c
@@ -206,7 +206,7 @@ static void irc_cmd_invite( irc_t *irc, char **cmd )
if( u && c && ( u->ic == c->ic ) )
if( c->ic && c->ic->acc->prpl->chat_invite )
{
- c->ic->acc->prpl->chat_invite( c, "", u->handle );
+ c->ic->acc->prpl->chat_invite( c, u->handle, NULL );
irc_reply( irc, 341, "%s %s", nick, channel );
return;
}
diff --git a/protocols/jabber/conference.c b/protocols/jabber/conference.c
index c5bc0e68..074412ec 100644
--- a/protocols/jabber/conference.c
+++ b/protocols/jabber/conference.c
@@ -175,6 +175,27 @@ int jabber_chat_leave( struct groupchat *c, const char *reason )
return 1;
}
+void jabber_chat_invite( struct groupchat *c, char *who, char *message )
+{
+ struct xt_node *node;
+ struct im_connection *ic = c->ic;
+ struct jabber_chat *jc = c->data;
+
+ node = xt_new_node( "reason", message, NULL );
+
+ node = xt_new_node( "invite", NULL, node );
+ xt_add_attr( node, "to", who );
+
+ node = xt_new_node( "x", NULL, node );
+ xt_add_attr( node, "xmlns", XMLNS_MUC_USER );
+
+ node = jabber_make_packet( "message", NULL, jc->name, node );
+
+ jabber_write_packet( ic, node );
+
+ xt_free_node( node );
+}
+
/* Not really the same syntax as the normal pkt_ functions, but this isn't
called by the xmltree parser directly and this way I can add some extra
parameters so we won't have to repeat too many things done by the caller
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index e2a3a27a..4c89ab5c 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -426,6 +426,20 @@ static void jabber_chat_leave_( struct groupchat *c )
jabber_chat_leave( c, NULL );
}
+static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )
+{
+ struct jabber_chat *jc = c->data;
+ gchar *msg_alt = NULL;
+
+ if( msg == NULL )
+ msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name );
+
+ if( c && who )
+ jabber_chat_invite( c, who, msg ? msg : msg_alt );
+
+ g_free( msg_alt );
+}
+
static void jabber_keepalive( struct im_connection *ic )
{
/* Just any whitespace character is enough as a keepalive for XMPP sessions. */
@@ -497,7 +511,7 @@ void jabber_initmodule()
ret->remove_buddy = jabber_remove_buddy;
ret->chat_msg = jabber_chat_msg_;
ret->chat_topic = jabber_chat_topic_;
-// ret->chat_invite = jabber_chat_invite;
+ ret->chat_invite = jabber_chat_invite_;
ret->chat_leave = jabber_chat_leave_;
ret->chat_join = jabber_chat_join_;
ret->keepalive = jabber_keepalive;
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 94d017d6..56056534 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -236,5 +236,6 @@ int jabber_chat_topic( struct groupchat *c, char *topic );
int jabber_chat_leave( struct groupchat *c, const char *reason );
void jabber_chat_pkt_presence( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node );
void jabber_chat_pkt_message( struct im_connection *ic, struct jabber_buddy *bud, struct xt_node *node );
+void jabber_chat_invite( struct groupchat *c, char *who, char *message );
#endif
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index df04e30d..aa05dbdd 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -240,7 +240,7 @@ static void msn_chat_msg( struct groupchat *c, char *message, int flags )
already severely broken) disappeared here! */
}
-static void msn_chat_invite( struct groupchat *c, char *msg, char *who )
+static void msn_chat_invite( struct groupchat *c, char *who, char *message )
{
struct msn_switchboard *sb = msn_sb_by_chat( c );
char buf[1024];
diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c
index 96983738..8d45acf0 100644
--- a/protocols/oscar/oscar.c
+++ b/protocols/oscar/oscar.c
@@ -2508,7 +2508,7 @@ void oscar_chat_msg(struct groupchat *c, char *message, int msgflags)
/* return (ret >= 0); */
}
-void oscar_chat_invite(struct groupchat *c, char *message, char *who)
+void oscar_chat_invite(struct groupchat *c, char *who, char *message)
{
struct im_connection *ic = c->ic;
struct oscar_data * od = (struct oscar_data *)ic->proto_data;
diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c
index 28a72877..625f3d1c 100644
--- a/protocols/yahoo/yahoo.c
+++ b/protocols/yahoo/yahoo.c
@@ -305,7 +305,7 @@ static void byahoo_chat_msg( struct groupchat *c, char *message, int flags )
yahoo_conference_message( yd->y2_id, NULL, c->data, c->title, message, 1 );
}
-static void byahoo_chat_invite( struct groupchat *c, char *msg, char *who )
+static void byahoo_chat_invite( struct groupchat *c, char *who, char *msg )
{
struct byahoo_data *yd = (struct byahoo_data *) c->ic->proto_data;