adium: 9fe8480e: Every 5 minutes, perform a WHO on our ch...
zacw at adiumx.com
zacw at adiumx.com
Mon Apr 13 23:55:46 EDT 2009
-----------------------------------------------------------------
Revision: 9fe8480e88fe4bea198b87f796810e35f34e6756
Ancestor: e458e71beb6cabc19c7d0fa57cd3c4cb699a9b76
Author: zacw at adiumx.com
Date: 2009-04-14T00:59:02
Branch: im.pidgin.adium
URL: http://d.pidgin.im/viewmtn/revision/info/9fe8480e88fe4bea198b87f796810e35f34e6756
Modified files:
libpurple/conversation.h libpurple/protocols/irc/irc.c
libpurple/protocols/irc/irc.h libpurple/protocols/irc/msgs.c
ChangeLog:
Every 5 minutes, perform a WHO on our channels. Add a CB flag for "away" and set (or unset) appropriately on our channel occupants.
-------------- next part --------------
============================================================
--- libpurple/conversation.h c70c2f54a7b1af52d887971b98c1ac9b9c7c3357
+++ libpurple/conversation.h 616789defc2dbbb5d1dbd07546890d83ce5c5eee
@@ -139,8 +139,8 @@ typedef enum
PURPLE_CBFLAGS_HALFOP = 0x0002, /**< Half-op */
PURPLE_CBFLAGS_OP = 0x0004, /**< Channel Op or Moderator */
PURPLE_CBFLAGS_FOUNDER = 0x0008, /**< Channel Founder */
- PURPLE_CBFLAGS_TYPING = 0x0010 /**< Currently typing */
-
+ PURPLE_CBFLAGS_TYPING = 0x0010, /**< Currently typing */
+ PURPLE_CBFLAGS_AWAY = 0x0020 /**< Currently away */
} PurpleConvChatBuddyFlags;
#include "account.h"
============================================================
--- libpurple/protocols/irc/irc.c a1ed806241c9fbe51fac442a258f7ed9d1316861
+++ libpurple/protocols/irc/irc.c 6b64d8348119626d1e3bfd88e631581bcff8528a
@@ -40,6 +40,7 @@ static void irc_buddy_append(char *name,
#define PING_TIMEOUT 60
static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string);
+static void irc_who_channel(PurpleConversation *conv, struct irc_conn *irc);
static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b);
static GList *irc_status_types(PurpleAccount *account);
@@ -214,6 +215,26 @@ static void irc_buddy_append(char *name,
g_string_append_printf(string, "%s ", name);
}
+
+gboolean irc_who_channel_timeout(struct irc_conn *irc)
+{
+ // WHO all of our channels.
+ g_list_foreach(purple_get_conversations(), (GFunc)irc_who_channel, (gpointer)irc);
+
+ return TRUE;
+}
+
+static void irc_who_channel(PurpleConversation *conv, struct irc_conn *irc)
+{
+ if (purple_conversation_get_account(conv) == irc->account && purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) {
+ purple_debug(PURPLE_DEBUG_INFO, "irc", "Performing periodic who on %s", purple_conversation_get_name(conv));
+
+ char *buf = irc_format(irc, "vc", "WHO", purple_conversation_get_name(conv));
+ irc_send(irc, buf);
+ g_free(buf);
+ }
+}
+
static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib)
{
char *buf;
@@ -492,6 +513,8 @@ static void irc_close(PurpleConnection *
}
if (irc->timer)
purple_timeout_remove(irc->timer);
+ if (irc->who_channel_timer)
+ purple_timeout_remove(irc->who_channel_timer);
g_hash_table_destroy(irc->cmds);
g_hash_table_destroy(irc->msgs);
g_hash_table_destroy(irc->buddies);
============================================================
--- libpurple/protocols/irc/irc.h 03d495c6aa3d0c213073609ba954efe91b5da109
+++ libpurple/protocols/irc/irc.h ffda445c3e9f15984e2646985544c7ea5b4bbb37
@@ -55,6 +55,7 @@ struct irc_conn {
char *server;
int fd;
guint timer;
+ guint who_channel_timer;
GHashTable *buddies;
gboolean ison_outstanding;
@@ -103,6 +104,7 @@ gboolean irc_blist_timeout(struct irc_co
int irc_send(struct irc_conn *irc, const char *buf);
gboolean irc_blist_timeout(struct irc_conn *irc);
+gboolean irc_who_channel_timeout(struct irc_conn *irc);
char *irc_escape_privmsg(const char *text, gssize length);
============================================================
--- libpurple/protocols/irc/msgs.c 381064a378e99354fc22587d096737990ef4dede
+++ libpurple/protocols/irc/msgs.c 5d96235d4dd22b849ee2f379c08e026f38f50bc4
@@ -129,6 +129,8 @@ static void irc_connected(struct irc_con
irc_blist_timeout(irc);
if (!irc->timer)
irc->timer = purple_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc);
+ if (!irc->who_channel_timer)
+ irc->who_channel_timer = purple_timeout_add_seconds(300, (GSourceFunc)irc_who_channel_timeout, (gpointer)irc);
}
void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args)
@@ -440,6 +442,15 @@ void irc_msg_who(struct irc_conn *irc, c
g_free(userhost);
g_free(realname);
+
+ PurpleConvChatBuddyFlags flags = purple_conv_chat_user_get_flags(chat, cb->name);
+
+ // (G|H)...
+ if (args[6][0] == 'G' && !(flags & PURPLE_CBFLAGS_AWAY)) {
+ purple_conv_chat_user_set_flags(chat, cb->name, flags | PURPLE_CBFLAGS_AWAY);
+ } else if(args[6][0] == 'H' && (flags & PURPLE_CBFLAGS_AWAY)) {
+ purple_conv_chat_user_set_flags(chat, cb->name, flags & ~PURPLE_CBFLAGS_AWAY);
+ }
}
}
More information about the Commits
mailing list