soc.2009.vulture: 3ac71950: Remove users from user-list when they de...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Fri Jul 10 18:05:57 EDT 2009


-----------------------------------------------------------------
Revision: 3ac7195006caa9a9e7315d064a29eefb42a3d8a4
Ancestor: a7eb4482a56361c1338cf8c1285dcf808d3a51d7
Author: gdick at soc.pidgin.im
Date: 2009-07-10T12:09:58
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/3ac7195006caa9a9e7315d064a29eefb42a3d8a4

Modified files:
        vulture/purpleconv.c vulture/purpleconv.h
        vulture/purplemain.c vulture/purplemain.h
        vulture/vultureblist.c vulture/vultureconv.c
        vulture/vultureconv.h

ChangeLog: 

Remove users from user-list when they depart a chat.

-------------- next part --------------
============================================================
--- vulture/purpleconv.c	23c96a88a0eed44290de7097f5790c2b1deaafa4
+++ vulture/purpleconv.c	4cf844cdbdfed251b3f922afb29135909139959f
@@ -364,3 +364,43 @@ void VultureFreeRenameUser(VULTURE_CHAT_
 
 	g_free(lpvchatrenameuser);
 }
+
+
+/**
+ * Called when users leave a chat.
+ *
+ * @param	lpconv		Conversation.
+ * @param	lpglistUsers	List of names of departing users.
+ */
+void PurpleChatRemoveUsers(PurpleConversation *lpconv, GList *lpglistUsers)
+{
+	VULTURE_CHAT_REMOVE_USERS *lpvchatremoveusers = g_new(VULTURE_CHAT_REMOVE_USERS, 1);
+
+	lpvchatremoveusers->lpvconvChat = lpconv->ui_data;
+	lpvchatremoveusers->lpglistNames = NULL;
+
+	for(; lpglistUsers; lpglistUsers = lpglistUsers->next)
+		lpvchatremoveusers->lpglistNames = g_list_prepend(lpvchatremoveusers->lpglistNames, VultureUTF8ToTCHAR(lpglistUsers->data));
+
+	lpvchatremoveusers->lpglistNames = g_list_reverse(lpvchatremoveusers->lpglistNames);
+
+	VulturePostUIMessage(VUIMSG_CHATREMOVEUSERS, lpvchatremoveusers);
+}
+
+
+/**
+ * Frees a VULTURE_CHAT_ADD_USERS structure once the UI is done with it.
+ *
+ * @param	lpvchataddusers		Structure to free.
+ */
+void VultureFreeChatRemoveUsers(VULTURE_CHAT_REMOVE_USERS *lpvchatremoveusers)
+{
+	GList *lpglistRover;
+
+	for(lpglistRover = lpvchatremoveusers->lpglistNames; lpglistRover; lpglistRover = lpglistRover->next)
+		g_free(lpglistRover->data);
+
+	g_list_free(lpvchatremoveusers->lpglistNames);
+
+	g_free(lpvchatremoveusers);
+}
============================================================
--- vulture/purpleconv.h	3c7b1b7067b9561e3d4bcee0e513966927df2f3c
+++ vulture/purpleconv.h	b52731404d292f613c1565675e704a4b136e8ed1
@@ -46,6 +46,8 @@ void VultureFreeRenameUser(VULTURE_CHAT_
 void VultureFreeChatAddUsers(VULTURE_CHAT_ADD_USERS *lpvchataddusers);
 void PurpleChatRenameUser(PurpleConversation *lpconv, const char *szOldName, const char *szNewName, const char *szNewAlias);
 void VultureFreeRenameUser(VULTURE_CHAT_RENAME_USER *lpvchatrenameuser);
+void PurpleChatRemoveUsers(PurpleConversation *lpconv, GList *lpglistUsers);
+void VultureFreeChatRemoveUsers(VULTURE_CHAT_REMOVE_USERS *lpvchatremoveusers);
 
 
 #endif
============================================================
--- vulture/purplemain.c	1db75f6b38f4f178377fc153e76345bfafa67456
+++ vulture/purplemain.c	c030ffed4a929cb36cb2c180c861e7ced380e993
@@ -190,7 +190,7 @@ static void InitUI(void)
 		PurpleWriteConversation,	/* write_conv		*/
 		PurpleChatAddUsers,		/* chat_add_users	*/
 		PurpleChatRenameUser,		/* chat_rename_user	*/
-		NULL,				/* chat_remove_users	*/
+		PurpleChatRemoveUsers,		/* chat_remove_users	*/
 		NULL,				/* chat_update_user	*/
 		NULL,				/* present		*/
 		NULL,				/* has_focus		*/
============================================================
--- vulture/purplemain.h	7a36605a7b4d06e7e86f4450b13019a838ef7d9d
+++ vulture/purplemain.h	781eddcde1d88f0b2a1dbd17f177d6fd344bbb2e
@@ -68,6 +68,9 @@ enum ENUM_VULTURE_UI_MESSAGES
 
 	/* (VULTURE_CHAT_RENAME_USER*) */
 	VUIMSG_CHATRENAMEUSER,
+
+	/* (VULTURE_CHAT_REMOVE_USERS*) */
+	VUIMSG_CHATREMOVEUSERS,
 };
 
 /* HandlEs for reigistering signal handlERs. */
============================================================
--- vulture/vultureblist.c	f7a66d22371c7b3d88139a3074036c06d8799bf3
+++ vulture/vultureblist.c	cf3bf4b64c56df113ed9db7a6d80e0881666e3b5
@@ -339,6 +339,10 @@ static LRESULT CALLBACK MainWndProc(HWND
 				hwndForward = ((VULTURE_CHAT_RENAME_USER*)lParam)->lpvconvChat->hwndConv;
 				break;
 
+			case VUIMSG_CHATREMOVEUSERS:
+				hwndForward = ((VULTURE_CHAT_REMOVE_USERS*)lParam)->lpvconvChat->hwndConv;
+				break;
+
 			case VUIMSG_QUIT:
 				DestroyWindow(hwnd);
 				break;
============================================================
--- vulture/vultureconv.c	c69610d47587473ade53c8e37c57e4b173a6fff6
+++ vulture/vultureconv.c	e3b594801e05add88a6a563e9a641f59eef9ca91
@@ -532,6 +532,28 @@ static INT_PTR CALLBACK ChatDlgProc(HWND
 			}
 
 			break;
+
+		case VUIMSG_CHATREMOVEUSERS:
+			{
+				VULTURE_CHAT_REMOVE_USERS *lpvchatremoveusers = (VULTURE_CHAT_REMOVE_USERS*)lParam;
+				GList *lpglistRover;
+				HWND hwndTVNames = GetDlgItem(hwndDlg, IDC_TREE_NAMES);
+
+				for(lpglistRover = lpvchatremoveusers->lpglistNames; lpglistRover; lpglistRover = lpglistRover->next)
+				{
+					VULTURE_CHAT_USER *lpvchatuser = g_tree_lookup(lpvconvchat->lpgtreePeople, lpglistRover->data);
+
+					/* Remove from tree-view. */
+					TreeView_DeleteItem(hwndTVNames, lpvchatuser->hti);
+
+					/* Remove from binary tree. */
+					g_tree_remove(lpvconvchat->lpgtreePeople, lpglistRover->data);
+				}
+
+				VultureFreeChatRemoveUsers(lpvchatremoveusers);
+			}
+
+			break;
 		}
 
 		break;
============================================================
--- vulture/vultureconv.h	9a93750e52b4314a219ad82b6ce06082195f6755
+++ vulture/vultureconv.h	805ea9076253aad94f63a799077e7b0faf1de0b3
@@ -114,7 +114,13 @@ typedef struct _VULTURE_CHAT_RENAME_USER
 	LPTSTR			szOldName, szNewName, szNewAlias;
 } VULTURE_CHAT_RENAME_USER;
 
+typedef struct _VULTURE_CHAT_REMOVE_USERS
+{
+	VULTURE_CONVERSATION	*lpvconvChat;
+	GList			*lpglistNames;
+} VULTURE_CHAT_REMOVE_USERS;
 
+
 int VultureRegisterConvContainerWindowClass(void);
 HWND VultureCreateConvContainer(void);
 void VultureWriteConversation(VULTURE_CONV_WRITE *lpvcwrite);


More information about the Commits mailing list