soc.2009.vulture: 77fc9b98: Added support for aliasing nodes.

gdick at soc.pidgin.im gdick at soc.pidgin.im
Tue Jul 21 15:30:42 EDT 2009


-----------------------------------------------------------------
Revision: 77fc9b9871f86ede34df14a95ca41f09d328622c
Ancestor: 08b970071624b594694fd7b2cc7dee518839cb28
Author: gdick at soc.pidgin.im
Date: 2009-07-21T14:57:46
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/77fc9b9871f86ede34df14a95ca41f09d328622c

Modified files:
        vulture/purpleblist.c vulture/purpleblist.h
        vulture/purplequeue.c vulture/purplequeue.h
        vulture/vulture-res.rc vulture/vultureblist.c
        vulture/vultureblist.h

ChangeLog: 

Added support for aliasing nodes.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	d15055009825c90a518715d6d1807f944dd4da76
+++ vulture/purpleblist.c	e1069d1dde324cba2eb0cdbe6fb049ede847fb97
@@ -105,6 +105,14 @@ void PurpleBlistUpdateNode(PurpleBuddyLi
 
 				break;
 
+			case PURPLE_BLIST_BUDDY_NODE:
+				szNodeText = purple_buddy_get_alias((PurpleBuddy*)lpblistnode);
+
+				if(szNodeText && *szNodeText)
+					break;
+
+				/* Otherwise, fall through. */
+
 			default:
 				szNodeText = PURPLE_BLIST_NODE_NAME(lpblistnode);
 				break;
@@ -406,3 +414,31 @@ void PurpleMakeChatMenu(HMENU hmenu, Pur
 		iIndex,
 		iIndex);
 }
+
+
+/**
+ * Sets the alias or name of a buddy-list node, as appropriate for the type.
+ *
+ * @param	lpblistnode	Buddy-list node.
+ * @param	szAlias		New alias/name.
+ */
+void PurpleBlistAliasNode(PurpleBlistNode *lpblistnode, LPCTSTR szAlias)
+{
+	gchar *szAliasUTF8;
+
+	if(!lpblistnode)
+		return;
+
+	szAliasUTF8 = VultureTCHARToUTF8(szAlias);
+
+	if(PURPLE_BLIST_NODE_IS_BUDDY(lpblistnode))
+		purple_blist_alias_buddy((PurpleBuddy*)lpblistnode, szAliasUTF8);
+	else if(PURPLE_BLIST_NODE_IS_CONTACT(lpblistnode))
+		purple_blist_alias_contact((PurpleContact*)lpblistnode, szAliasUTF8);
+	else if(PURPLE_BLIST_NODE_IS_CHAT(lpblistnode))
+		purple_blist_alias_chat((PurpleChat*)lpblistnode, szAliasUTF8);
+	else if(PURPLE_BLIST_NODE_IS_GROUP(lpblistnode))
+		purple_blist_rename_group((PurpleGroup*)lpblistnode, szAliasUTF8);
+
+	g_free(szAliasUTF8);
+}
============================================================
--- vulture/purpleblist.h	e62085f3fac63d5e202ec71fbf8f008bcd4af38d
+++ vulture/purpleblist.h	af9870519752904d7644f52f1da45e3833250386
@@ -26,23 +26,11 @@
 
 
 #include <windows.h>
-#include <commctrl.h>
 
+#include "vultureblist.h"
 #include "purple.h"
 
 
-typedef struct _VULTURE_BLIST_NODE
-{
-	PurpleBlistNode			*lpblistnode;
-	PurpleBlistNodeType		nodetype;
-	LPTSTR				szNodeText;
-	HTREEITEM			hti;
-	struct _VULTURE_BLIST_NODE	*lpvbnParent;
-	LONG				lRefCount;
-	CRITICAL_SECTION		cs;
-} VULTURE_BLIST_NODE;
-
-
 void PurpleBlistNewNode(PurpleBlistNode *lpblistnode);
 void PurpleBlistUpdateNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode);
 void PurpleBlistRemoveNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode);
@@ -52,6 +40,7 @@ void PurpleMakeChatMenu(HMENU hmenu, Pur
 void PurpleBuddyStatusChanged(PurpleBuddy *lpbuddy, PurpleStatus *lpstatusOld, PurpleStatus *lpstatusNew);
 void PurpleMakeBuddyMenu(HMENU hmenu, PurpleBlistNode *lpblistnode, GList **lplpglistVMA);
 void PurpleMakeChatMenu(HMENU hmenu, PurpleBlistNode *lpblistnode, GList **lplpglistVMA);
+void PurpleBlistAliasNode(PurpleBlistNode *lpblistnode, LPCTSTR szAlias);
 
 
 static INLINE void VultureBListNodeAddRef(VULTURE_BLIST_NODE *lpvblnode) { InterlockedIncrement(&lpvblnode->lRefCount); }
============================================================
--- vulture/purplequeue.c	d29d9b59ecc40a63acbd526bd71c5dc1d5701d62
+++ vulture/purplequeue.c	190c224549d42f60fc62a98053bd853e4ad03486
@@ -310,6 +310,14 @@ static void DispatchPurpleCall(PURPLE_CA
 
 		break;
 
+	case PC_ALIASNODE:
+		{
+			VULTURE_ALIAS_NODE *lpvaliasnode = lppurplecall->lpvParam;
+			PurpleBlistAliasNode(lpvaliasnode->lpvblistnode->lpblistnode, lpvaliasnode->szAlias);
+		}
+
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h	c3fbf1f5d643071908c606423ea7d8355410db07
+++ vulture/purplequeue.h	1c0f2dff4d423172dc0886d9e57f0b1bcc6686ee
@@ -91,6 +91,9 @@ enum PURPLE_CALL_ID
 
 	/* (VULTURE_BLIST_NODE*) Buddy or contact node. */
 	PC_TOGGLESHOWOFFLINE,
+
+	/* (VULTURE_ALIAS_NODE*) */
+	PC_ALIASNODE,
 };
 
 
============================================================
--- vulture/vulture-res.rc	d4adffc130389c8a069f39aaf8bbfc805433d283
+++ vulture/vulture-res.rc	b93e7a864095745b42300f286e6e2999383a592e
@@ -40,7 +40,7 @@ IDM_CONV MENU
 	MENUITEM "View &log", IDM_BLIST_CONTEXT_VIEWLOG, MFT_STRING, MFS_GRAYED
 
 #define CONTEXT_ALIAS_REMOVE \
-	MENUITEM "Set &alias...", IDM_BLIST_CONTEXT_ALIAS, MFT_STRING, MFS_GRAYED \
+	MENUITEM "Set &alias", IDM_BLIST_CONTEXT_ALIAS, MFT_STRING \
 	MENUITEM "&Remove from buddy list", IDM_BLIST_CONTEXT_REMOVE, MFT_STRING, MFS_GRAYED
 
 #define BUDDY_CONTACT_COMMON \
@@ -124,7 +124,7 @@ FONT 8, "Ms Shell Dlg"
 STYLE DS_3DLOOK | DS_CENTER | DS_CONTROL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
 FONT 8, "Ms Shell Dlg"
 {
-    CONTROL         "", IDC_TREE_BLIST, WC_TREEVIEW, WS_TABSTOP | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_INFOTIP | TVS_FULLROWSELECT, 5, 5, 175, 85
+    CONTROL         "", IDC_TREE_BLIST, WC_TREEVIEW, WS_TABSTOP | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_SHOWSELALWAYS | TVS_INFOTIP | TVS_FULLROWSELECT | TVS_EDITLABELS, 5, 5, 175, 85
 }
 
 
============================================================
--- vulture/vultureblist.c	d12bd7013e4b82382784ffae982da52175b55429
+++ vulture/vultureblist.c	526c67609ea84b036649f2f5213055b94f37be91
@@ -56,9 +56,9 @@ static void RemoveBListNode(HWND hwndBli
 static LRESULT CALLBACK StatusMsgBoxSubclassProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static void SetStatusMsg(HWND hwndStatusDlg);
 static void RemoveBListNode(HWND hwndBlistTree, VULTURE_BLIST_NODE *lpvbn);
-static void RunBuddyMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
-static BOOL RunCommonMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
-static void RunChatMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
+static void RunBuddyMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
+static BOOL RunCommonMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
+static void RunChatMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd);
 
 
 #define BLIST_MARGIN 6
@@ -672,10 +672,10 @@ static INT_PTR CALLBACK BuddyListDlgProc
 									{
 									case PURPLE_BLIST_BUDDY_NODE:
 									case PURPLE_BLIST_CONTACT_NODE:
-										RunBuddyMenuCmd(lpvblistnode, hmenuSubmenu, iCmd);
+										RunBuddyMenuCmd(lpnmhdr->hwndFrom, lpvblistnode, hmenuSubmenu, iCmd);
 										break;
 									case PURPLE_BLIST_CHAT_NODE:
-										RunChatMenuCmd(lpvblistnode, hmenuSubmenu, iCmd);
+										RunChatMenuCmd(lpnmhdr->hwndFrom, lpvblistnode, hmenuSubmenu, iCmd);
 										break;
 									default:
 										break;
@@ -702,6 +702,29 @@ static INT_PTR CALLBACK BuddyListDlgProc
 					}
 
 					break;
+
+				case TVN_ENDLABELEDIT:
+					{
+						/* Label-editing in the buddy-
+						 * list has finished. Alias the
+						 * node if appropriate.
+						 */
+
+						VULTURE_ALIAS_NODE valiasnode;
+						LPNMTVDISPINFO lpnmtvdispinfo = (LPNMTVDISPINFO)lParam;
+
+						/* Make sure editing wasn't
+						 * cancelled.
+						 */
+						if(lpnmtvdispinfo->item.pszText)
+						{
+							valiasnode.lpvblistnode = (VULTURE_BLIST_NODE*)lpnmtvdispinfo->item.lParam;
+							valiasnode.szAlias = lpnmtvdispinfo->item.pszText;
+							VultureSingleSyncPurpleCall(PC_ALIASNODE, &valiasnode);
+						}
+					}
+
+					return TRUE;
 				}
 			}
 		}
@@ -921,13 +944,14 @@ static void RemoveBListNode(HWND hwndBli
  * Executes a menu command from the context menu for a buddy or contact node in
  * the buddy list.
  *
+ * @param	hwndBuddies	Buddy-list tree-view.
  * @param	lpvblistnode	List node to which the context menu relates.
  * @param	hmenu		Context menu.
  * @param	iCmd		Command ID.
  */
-static void RunBuddyMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
+static void RunBuddyMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
 {
-	if(RunCommonMenuCmd(lpvblistnode, hmenu, iCmd))
+	if(RunCommonMenuCmd(hwndBuddies, lpvblistnode, hmenu, iCmd))
 		return;
 
 	switch(iCmd)
@@ -943,13 +967,14 @@ static void RunBuddyMenuCmd(VULTURE_BLIS
  * Determines whether a menu command is one of those common to various sorts of
  * context menu, and if so, executes it.
  *
+ * @param	hwndBuddies	Buddy-list tree-view.
  * @param	lpvblistnode	List node to which the context menu relates.
  * @param	hmenu		Context menu.
  * @param	iCmd		Command ID.
  *
  * @return TRUE iff we processed the command.
  */
-static BOOL RunCommonMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
+static BOOL RunCommonMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
 {
 	UNREFERENCED_PARAMETER(hmenu);
 
@@ -959,6 +984,10 @@ static BOOL RunCommonMenuCmd(VULTURE_BLI
 		VultureEnqueueAsyncPurpleCall(PC_BLISTNODEACTIVATED, lpvblistnode);
 		return TRUE;
 
+	case IDM_BLIST_CONTEXT_ALIAS:
+		SendMessage(hwndBuddies, TVM_EDITLABEL, 0, (LPARAM)lpvblistnode->hti);
+		return TRUE;
+
 	default:
 		/* Not a static command that we recongise; might be a dynamic
 		 * command.
@@ -987,12 +1016,13 @@ static BOOL RunCommonMenuCmd(VULTURE_BLI
  * Executes a menu command from the context menu for a chat node in the buddy
  * list.
  *
+ * @param	hwndBuddies	Buddy-list tree-view.
  * @param	lpvblistnode	List node to which the context menu relates.
  * @param	hmenu		Context menu.
  * @param	iCmd		Command ID.
  */
-static void RunChatMenuCmd(VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
+static void RunChatMenuCmd(HWND hwndBuddies, VULTURE_BLIST_NODE *lpvblistnode, HMENU hmenu, int iCmd)
 {
-	if(RunCommonMenuCmd(lpvblistnode, hmenu, iCmd))
+	if(RunCommonMenuCmd(hwndBuddies, lpvblistnode, hmenu, iCmd))
 		return;
 }
============================================================
--- vulture/vultureblist.h	26df72aa0a31dbec27875c5f54c8ff7c2d9a7ef2
+++ vulture/vultureblist.h	677720b04ee7247e4f175ab294c5466b8b7be9c9
@@ -24,9 +24,30 @@
 #define _VULTURE_VULTUREBLIST_H_
 
 #include <windows.h>
+#include <commctrl.h>
 #include <glib.h>
 
+#include "purple.h"
 
+
+typedef struct _VULTURE_BLIST_NODE
+{
+	PurpleBlistNode			*lpblistnode;
+	PurpleBlistNodeType		nodetype;
+	LPTSTR				szNodeText;
+	HTREEITEM			hti;
+	struct _VULTURE_BLIST_NODE	*lpvbnParent;
+	LONG				lRefCount;
+	CRITICAL_SECTION		cs;
+} VULTURE_BLIST_NODE;
+
+typedef struct _VULTURE_ALIAS_NODE
+{
+	VULTURE_BLIST_NODE *lpvblistnode;
+	LPTSTR szAlias;
+} VULTURE_ALIAS_NODE;
+
+
 extern HWND g_hwndMain;
 GList *g_lpglistConvContainers;
 


More information about the Commits mailing list