soc.2009.vulture: ae109c47: Auto-join support for chats.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Tue Jul 21 15:30:43 EDT 2009
-----------------------------------------------------------------
Revision: ae109c479f64c6c10ca7e3003dac924fdc223769
Ancestor: 77fc9b9871f86ede34df14a95ca41f09d328622c
Author: gdick at soc.pidgin.im
Date: 2009-07-21T15:53:45
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/ae109c479f64c6c10ca7e3003dac924fdc223769
Modified files:
vulture/purpleacct.c vulture/purpleacct.h
vulture/purpleblist.c vulture/purplemain.c
vulture/purplequeue.c vulture/purplequeue.h
vulture/vulture-res.rc vulture/vultureblist.c
ChangeLog:
Auto-join support for chats.
-------------- next part --------------
============================================================
--- vulture/purpleacct.c b970f746fbbcefee6558602478c9fe10abbb7f0a
+++ vulture/purpleacct.c 2e574bd9886c99534cf32d6921e88957020bb238
@@ -27,6 +27,7 @@
#include "purple.h"
#include "purpleacct.h"
#include "acctmanager.h"
+#include "purpleconv.h"
/**
@@ -103,3 +104,43 @@ void PurpleApplyVultureAccount(VULTURE_A
g_free(szProtocolID);
g_free(szUsername);
}
+
+
+/**
+ * Called in response to the signed-on account signal. Modelled on Pidgin's
+ * account_signon_cb.
+ *
+ * @param lpconnection Connection for the account.
+ * @param lpvUnused Ignored.
+ */
+void PurpleAccountSignedOn(PurpleConnection *lpconnection, gpointer lpvUnused)
+{
+ PurpleAccount *lpaccount = purple_connection_get_account(lpconnection);
+ PurpleBlistNode *lpblistnodeGroup;
+
+ UNREFERENCED_PARAMETER(lpvUnused);
+
+ /* Loop through all groups. */
+ for(lpblistnodeGroup = purple_get_blist()->root; lpblistnodeGroup; lpblistnodeGroup = lpblistnodeGroup->next)
+ {
+ if(PURPLE_BLIST_NODE_IS_GROUP(lpblistnodeGroup))
+ {
+ PurpleBlistNode *lpblistnodeChat;
+
+ /* Loop through all chats in this group belonging to
+ * this account, autojoining any that request it.
+ */
+ for(lpblistnodeChat = lpblistnodeGroup->child; lpblistnodeChat; lpblistnodeChat = lpblistnodeChat->next)
+ {
+ PurpleChat *lpchat = (PurpleChat*)lpblistnodeChat;
+
+ if(PURPLE_BLIST_NODE_IS_CHAT(lpblistnodeChat) &&
+ lpchat->account == lpaccount &&
+ purple_blist_node_get_bool((PurpleBlistNode*)lpchat, "vulture-autojoin"))
+ {
+ PurpleJoinChat(lpchat);
+ }
+ }
+ }
+ }
+}
============================================================
--- vulture/purpleacct.h 290134562e787747c50d09c3f6bae2d94b43d961
+++ vulture/purpleacct.h 0359093314454feb8f3b3a488e37424efde2d4d9
@@ -34,6 +34,7 @@ void PurpleApplyVultureAccount(VULTURE_A
void PurpleGetAccounts(BOOL bOnlineOnly, GList **lplpglistAccounts);
void VultureFreeAccountList(GList *lpglistAccounts);
void PurpleApplyVultureAccount(VULTURE_ACCOUNT *lpvac);
+void PurpleAccountSignedOn(PurpleConnection *lpconnection, gpointer lpvUnused);
#endif
============================================================
--- vulture/purpleblist.c e1069d1dde324cba2eb0cdbe6fb049ede847fb97
+++ vulture/purpleblist.c 2d911fe2ada93f664c18255511e9eff977ff663e
@@ -413,6 +413,9 @@ void PurpleMakeChatMenu(HMENU hmenu, Pur
((PurpleChat*)lpblistnode)->account->gc,
iIndex,
iIndex);
+
+ /* Enable/disable/check stuff as appropriate. */
+ CheckMenuItem(hmenu, IDM_BLIST_CONTEXT_AUTOJOIN, purple_blist_node_get_bool(lpblistnode, "vulture-autojoin") ? MF_CHECKED : MF_UNCHECKED);
}
============================================================
--- vulture/purplemain.c 96a9f91dee0ab6daccfec873318a404f22010b20
+++ vulture/purplemain.c 8afc7b182175d5011dab06bb294fa70dd6d333ab
@@ -49,6 +49,7 @@
#include "purpleblist.h"
#include "purpleconv.h"
#include "purplestatus.h"
+#include "purpleacct.h"
static UINT CALLBACK PurpleThread(void *lpvData);
@@ -210,6 +211,7 @@ static void InitUI(void)
purple_signal_connect(purple_savedstatuses_get_handle(), "savedstatus-changed", GINT_TO_POINTER(VSH_STATUS), PURPLE_CALLBACK(PurpleStatusChanged), NULL);
purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", GINT_TO_POINTER(VSH_CONV), PURPLE_CALLBACK(PurpleConvChanged), NULL);
purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", GINT_TO_POINTER(VSH_BLIST), PURPLE_CALLBACK(PurpleBuddyStatusChanged), NULL);
+ purple_signal_connect(purple_connections_get_handle(), "signed-on", GINT_TO_POINTER(VSH_BLIST), PURPLE_CALLBACK(PurpleAccountSignedOn), NULL);
/* Create and load libpurple's buddy-list. */
purple_set_blist(purple_blist_new());
============================================================
--- vulture/purplequeue.c 190c224549d42f60fc62a98053bd853e4ad03486
+++ vulture/purplequeue.c 7f16e6679fbaf37b6ee5dd1e38c1ef42762b4454
@@ -318,6 +318,23 @@ static void DispatchPurpleCall(PURPLE_CA
break;
+ case PC_TOGGLEAUTOJOIN:
+ {
+ if(((VULTURE_BLIST_NODE*)lppurplecall->lpvParam)->lpblistnode)
+ {
+ purple_blist_node_set_bool(
+ ((VULTURE_BLIST_NODE*)lppurplecall->lpvParam)->lpblistnode,
+ "vulture-autojoin",
+ !purple_blist_node_get_bool(
+ ((VULTURE_BLIST_NODE*)lppurplecall->lpvParam)->lpblistnode,
+ "vulture-autojoin"
+ )
+ );
+ }
+ }
+
+ break;
+
case PC_QUIT:
purple_core_quit();
g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h 1c0f2dff4d423172dc0886d9e57f0b1bcc6686ee
+++ vulture/purplequeue.h 231e847f1a6d7a374a98e035870840358a1af803
@@ -94,6 +94,9 @@ enum PURPLE_CALL_ID
/* (VULTURE_ALIAS_NODE*) */
PC_ALIASNODE,
+
+ /* (VULTURE_BLIST_NODE*) Chat node. */
+ PC_TOGGLEAUTOJOIN,
};
============================================================
--- vulture/vulture-res.rc b93e7a864095745b42300f286e6e2999383a592e
+++ vulture/vulture-res.rc 9c4feae7646ef2779d955bccba9eee35028dbba3
@@ -87,7 +87,7 @@ IDM_BLIST_CONTEXT MENUEX
POPUP "Chat"
{
MENUITEM "&Join chat", IDM_BLIST_CONTEXT_ACTIVATE, MFT_STRING, MFS_DEFAULT
- MENUITEM "Join &automatically at login", IDM_BLIST_CONTEXT_AUTOJOIN, MFT_STRING, MFS_GRAYED
+ MENUITEM "Join &automatically at login", IDM_BLIST_CONTEXT_AUTOJOIN, MFT_STRING
CONTEXT_VIEWLOG
MENUITEM "", 0, MFT_SEPARATOR
CONTEXT_ALIAS_REMOVE
============================================================
--- vulture/vultureblist.c 526c67609ea84b036649f2f5213055b94f37be91
+++ vulture/vultureblist.c a347134346da08104a987c0aa867c0c44a9be6a9
@@ -1025,4 +1025,11 @@ static void RunChatMenuCmd(HWND hwndBudd
{
if(RunCommonMenuCmd(hwndBuddies, lpvblistnode, hmenu, iCmd))
return;
+
+ switch(iCmd)
+ {
+ case IDM_BLIST_CONTEXT_AUTOJOIN:
+ VultureEnqueueAsyncPurpleCall(PC_TOGGLEAUTOJOIN, lpvblistnode);
+ break;
+ }
}
More information about the Commits
mailing list