soc.2009.vulture: 821f6f15: Option to show all offline buddies.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Wed Aug 5 16:55:41 EDT 2009
-----------------------------------------------------------------
Revision: 821f6f153a17981a24a5af88be07b85184eda43b
Ancestor: 6ddacf16a5e89800622008772c32bc2f7625b096
Author: gdick at soc.pidgin.im
Date: 2009-08-05T12:29:42
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/821f6f153a17981a24a5af88be07b85184eda43b
Modified files:
vulture/purpleblist.c vulture/purpleblist.h
vulture/purplemain.c vulture/purplequeue.c
vulture/purplequeue.h vulture/resource.h
vulture/vulture-res.rc vulture/vulture.c vulture/vulture.h
vulture/vultureblist.c
ChangeLog:
Option to show all offline buddies.
-------------- next part --------------
============================================================
--- vulture/purpleblist.c 435ba5b519f27e7c353e505b75a55cba78ccfc1e
+++ vulture/purpleblist.c 145a1e026730f2ecb2d3b96a2ca65b633c09b225
@@ -161,11 +161,16 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
}
}
}
- else if(lpvbn->hti)
+ else
{
- VultureBListNodeAddRef(lpvbn);
- VulturePostUIMessage(VUIMSG_REMOVEBLISTNODE, lpvbn);
+ /* Shouldn't show node. */
+ if(lpvbn->hti)
+ {
+ VultureBListNodeAddRef(lpvbn);
+ VulturePostUIMessage(VUIMSG_REMOVEBLISTNODE, lpvbn);
+ }
+
/* The parent may need to go, too. */
if(lpvbn->lpvbnParent && lpvbn->lpvbnParent->hti)
PurpleBlistUpdateNode(lpbuddylist, lpvbn->lpvbnParent->lpblistnode);
@@ -209,7 +214,8 @@ static BOOL ShouldShowNode(PurpleBlistNo
{
PurpleBuddy *lpbuddy = (PurpleBuddy*)lpblistnode;
return purple_account_is_connected(purple_buddy_get_account(lpbuddy)) &&
- (purple_presence_is_online(lpbuddy->presence) ||
+ (g_vflags.bShowOffline ||
+ purple_presence_is_online(lpbuddy->presence) ||
purple_blist_node_get_bool(lpblistnode, "show_offline"));
}
@@ -798,3 +804,24 @@ void PurpleAddBuddy(VULTURE_ADD_BUDDY_DA
if(szAliasUTF8) g_free(szAliasUTF8);
g_free(szUsernameUTF8);
}
+
+
+/**
+ * Updates all leaf nodes descending from a given node.
+ *
+ * @param lpbln Node.
+ */
+void PurpleBlistUpdateLeaves(PurpleBlistNode *lpbln)
+{
+ PurpleBlistNode *lpblnRover;
+
+ for(lpblnRover = lpbln; lpblnRover; lpblnRover = lpblnRover->next)
+ {
+ PurpleBlistNode *lpblnChild;
+
+ if((lpblnChild = purple_blist_node_get_first_child(lpblnRover)))
+ PurpleBlistUpdateLeaves(lpblnChild);
+ else
+ PurpleBlistUpdateNode(purple_get_blist(), lpblnRover);
+ }
+}
============================================================
--- vulture/purpleblist.h deafd04422fb9bb6db02aa288959790c35fb33ec
+++ vulture/purpleblist.h ba8b57e582b04e1966b9d221fb5dde0ef5b6ba1f
@@ -57,6 +57,7 @@ void PurpleAddBuddy(VULTURE_ADD_BUDDY_DA
GList* PurpleGetGroups(void);
void VultureFreeGroupList(GList *lpglistGroups);
void PurpleAddBuddy(VULTURE_ADD_BUDDY_DATA *lpvabd);
+void PurpleBlistUpdateLeaves(PurpleBlistNode *lpbln);
static INLINE void VultureBListNodeAddRef(VULTURE_BLIST_NODE *lpvblnode) { InterlockedIncrement(&lpvblnode->lRefCount); }
============================================================
--- vulture/purplemain.c 6823e999af2741fae0e621fbd5b3b1cca3877023
+++ vulture/purplemain.c 74044c3f709cef6aa4fdcb31c7d30882c3f0bc25
@@ -52,10 +52,15 @@
#include "purpleacct.h"
+#define VULTURE_PREFS_ROOT "/vulture"
+
+
static UINT CALLBACK PurpleThread(void *lpvData);
static int InitLibpurple(void);
static void InitUI(void);
static void Quitting(void);
+static void LoadFlags(void);
+static void SaveFlags(void);
@@ -205,6 +210,8 @@ static void InitUI(void)
NULL, /* reserved */
};
+ LoadFlags();
+
purple_blist_set_ui_ops(&s_blistuiops);
purple_conversations_set_ui_ops(&s_convuiops);
@@ -225,6 +232,8 @@ static void Quitting(void)
*/
static void Quitting(void)
{
+ SaveFlags();
+
/* The core is on its way out, so tell the UI to destroy itself. */
VulturePostUIMessage(VUIMSG_QUIT, NULL);
}
@@ -314,3 +323,21 @@ void PurpleInsertDynamicMenu(HMENU hmenu
ProcHeapFree(mii.dwTypeData);
}
}
+
+
+/** Loads flags from libpurple's preference store. */
+static void LoadFlags(void)
+{
+ purple_prefs_add_none(VULTURE_PREFS_ROOT);
+ purple_prefs_add_none(VULTURE_PREFS_ROOT "/blist");
+ purple_prefs_add_bool(VULTURE_PREFS_ROOT "/blist/show_offline_buddies", FALSE);
+
+ g_vflags.bShowOffline = purple_prefs_get_bool(VULTURE_PREFS_ROOT "/blist/show_offline_buddies");
+}
+
+
+/** Writes flags back to libpurple's preference store. */
+static void SaveFlags(void)
+{
+ purple_prefs_set_bool(VULTURE_PREFS_ROOT "/blist/show_offline_buddies", g_vflags.bShowOffline);
+}
============================================================
--- vulture/purplequeue.c 2412a1984936e493910cf521d31a7a4084bd533f
+++ vulture/purplequeue.c 39f977fa40b576bfa2da3e87fa474e2997e3dd94
@@ -416,6 +416,10 @@ static void DispatchPurpleCall(PURPLE_CA
PurpleAddBuddy(lppurplecall->lpvParam);
break;
+ case PC_REFRESHBLIST:
+ PurpleBlistUpdateLeaves(purple_get_blist()->root);
+ break;
+
case PC_QUIT:
purple_core_quit();
g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h 5abffc449ba30bd32dc7d429b66c9f8ba00cecc2
+++ vulture/purplequeue.h 309baee3b3c5dbcbc65195c2550b3ad9fe2501f1
@@ -118,6 +118,8 @@ enum PURPLE_CALL_ID
/* (VULTURE_ADD_BUDDY_DATA*) */
PC_ADDBUDDY,
+
+ PC_REFRESHBLIST,
};
============================================================
--- vulture/resource.h c0eb395d784bb3af7e1c8517af53e9f26221a1af
+++ vulture/resource.h a8cf41fb85beda90008d194fc33ab0a62e1e7ddf
@@ -40,6 +40,7 @@
#define IDM_BLIST_BUDDIES_CLOSE 40000
#define IDM_BLIST_BUDDIES_JOINCHAT 40002
#define IDM_BLIST_BUDDIES_ADDBUDDY 40003
+#define IDM_BLIST_VIEW_SHOWOFFLINE 40004
#define IDM_BLIST_CONTEXT 1002
#define IDM_BLIST_CONTEXT_ACTIVATE 40201
============================================================
--- vulture/vulture-res.rc fb6421d7465b5960c5b00bddd2c296bdb6dc8c56
+++ vulture/vulture-res.rc bc931f38035e52858dcc2f5176d3d69d3f5e885c
@@ -22,6 +22,12 @@ IDM_BLIST MENU
MENUITEM SEPARATOR
MENUITEM "&Close", IDM_BLIST_BUDDIES_CLOSE
}
+
+ POPUP "&View"
+ {
+ MENUITEM "Show &Offline Buddies", IDM_BLIST_VIEW_SHOWOFFLINE
+ }
+
POPUP "&Accounts"
{
MENUITEM "&Manage Accounts\tCtrl+A", IDM_BLIST_ACCOUNTS_MANAGE
============================================================
--- vulture/vulture.c 86f939a2eadf509b573f45ad8598422ab79c34cd
+++ vulture/vulture.c 3d1f361ef52adb86342fd470fdd08f6c25e6f112
@@ -42,7 +42,9 @@ const TCHAR cg_szAppName[] = TEXT("Vultu
const TCHAR cg_szAppName[] = TEXT("Vulture");
+VULTURE_FLAGS g_vflags;
+
/**
* Entry point.
*
============================================================
--- vulture/vulture.h 6cf7933aa57a6475608fad587677b2cd289e38cf
+++ vulture/vulture.h e05d8b9796e81217407c649e3932b7fc05f15f4b
@@ -29,6 +29,15 @@
#include <time.h>
+/* Flags that would otherwise be accessed with purple_prefs_{g,s}et_bool but
+ * which we manage ourselves for ease of access by the UI.
+ */
+typedef struct _VULTURE_FLAGS
+{
+ BOOL bShowOffline;
+} VULTURE_FLAGS;
+
+
#define INLINE __inline
#define VULTURE_ID "vulture"
@@ -39,7 +48,9 @@ extern const TCHAR cg_szAppName[];
extern const TCHAR cg_szAppName[];
+extern VULTURE_FLAGS g_vflags;
+
enum VULTURE_EXIT_CODES
{
VEC_SUCCESS = 0,
============================================================
--- vulture/vultureblist.c 3028c9f2eb7a181da2e7040b0a010f141b973acd
+++ vulture/vultureblist.c e24f15cb3f37daf5b8516e8465bdad090a87b35c
@@ -222,6 +222,11 @@ static LRESULT CALLBACK MainWndProc(HWND
SendMessage(hwnd, WM_CLOSE, 0, 0);
return 0;
+ case IDM_BLIST_VIEW_SHOWOFFLINE:
+ g_vflags.bShowOffline = !g_vflags.bShowOffline;
+ VultureEnqueueAsyncPurpleCall(PC_REFRESHBLIST, NULL);
+ return 0;
+
case IDM_BLIST_ACCOUNTS_MANAGE:
ManageAccounts(hwnd);
return 0;
@@ -229,6 +234,14 @@ static LRESULT CALLBACK MainWndProc(HWND
break;
+ case WM_INITMENUPOPUP:
+ if(!HIWORD(lParam))
+ {
+ CheckMenuItem((HMENU)wParam, IDM_BLIST_VIEW_SHOWOFFLINE, g_vflags.bShowOffline ? MF_CHECKED : MF_UNCHECKED);
+ }
+
+ return 0;
+
case WM_SIZE:
{
HDWP hdwp;
More information about the Commits
mailing list