soc.2009.vulture: edc99b62: Show list of users in chat. Renaming and...
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Thu Jul 9 14:45:40 EDT 2009
-----------------------------------------------------------------
Revision: edc99b6230741c3997e7e1bf32238d1acc4e50ed
Ancestor: 9e4632e7cc5a28248b91cebb7d496a09db07dfbb
Author: gdick at soc.pidgin.im
Date: 2009-07-09T16:12:16
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/edc99b6230741c3997e7e1bf32238d1acc4e50ed
Modified files:
vulture/purpleconv.c vulture/purpleconv.h
vulture/purplemain.c vulture/purplemain.h vulture/resource.h
vulture/vulture-res.rc vulture/vulture.c vulture/vulture.h
vulture/vultureblist.c vulture/vultureconv.c
vulture/vultureconv.h
ChangeLog:
Show list of users in chat. Renaming and leaving not handled yet.
-------------- next part --------------
============================================================
--- vulture/purpleconv.c 0e81f68dee5437dec7f29734d3585fea6b179d7c
+++ vulture/purpleconv.c 31d0a6a74b2b3a98825a4681b5002ffd7451fd07
@@ -42,8 +42,13 @@ void PurpleNewConversation(PurpleConvers
void PurpleNewConversation(PurpleConversation *lpconv)
{
/* The UI will eventually free this. */
- VULTURE_CONVERSATION *lpvconv = g_new(VULTURE_CONVERSATION, 1);
+ VULTURE_CONVERSATION *lpvconv;
+ if(lpconv->type == PURPLE_CONV_TYPE_IM)
+ lpvconv = (VULTURE_CONVERSATION*)g_new(VULTURE_CONVERSATION_IM, 1);
+ else
+ lpvconv = (VULTURE_CONVERSATION*)g_new(VULTURE_CONVERSATION_CHAT, 1);
+
lpconv->ui_data = lpvconv;
lpvconv->lpconv = lpconv;
@@ -258,3 +263,68 @@ void PurpleJoinChat(PurpleChat *lpchat)
serv_join_chat(lpchat->account->gc, lpchat->components);
}
+
+
+/**
+ * Called when users join a chat.
+ *
+ * @param lpconv Conversation.
+ * @param lpglistChatBuddies List of PurpleConvChatBuddy structures
+ * describing new users.
+ * @param bNewArrivals Whether entrance messages are shown.
+ */
+void PurpleChatAddUsers(PurpleConversation *lpconv, GList *lpglistChatBuddies, gboolean bNewArrivals)
+{
+ VULTURE_CHAT_ADD_USERS *lpvchataddusers = g_new(VULTURE_CHAT_ADD_USERS, 1);
+ VULTURE_ADD_CHAT_USER *lpvaddchatuser;
+
+ UNREFERENCED_PARAMETER(bNewArrivals);
+
+ lpvchataddusers->lpvconvChat = lpconv->ui_data;
+ lpvchataddusers->lpglistNewUsers = NULL;
+
+ /* We make a new list for the UI's consumption. */
+ for(; lpglistChatBuddies; lpglistChatBuddies = lpglistChatBuddies->next)
+ {
+ PurpleConvChatBuddy *lppccbuddy = lpglistChatBuddies->data;
+
+ lpvaddchatuser = g_new(VULTURE_ADD_CHAT_USER, 1);
+ lpvaddchatuser->szAlias = lppccbuddy->alias ? VultureUTF8ToTCHAR(lppccbuddy->alias) : NULL;
+ lpvaddchatuser->szAliasKey = lppccbuddy->alias_key ? VultureUTF8ToTCHAR(lppccbuddy->alias_key) : NULL;
+ lpvaddchatuser->szName = VultureUTF8ToTCHAR(lppccbuddy->name);
+ lpvaddchatuser->bIsBuddy = lppccbuddy->buddy;
+ lpvaddchatuser->pccbflags = lppccbuddy->flags;
+
+ lpvchataddusers->lpglistNewUsers = g_list_prepend(lpvchataddusers->lpglistNewUsers, lpvaddchatuser);
+ }
+
+ lpvchataddusers->lpglistNewUsers = g_list_reverse(lpvchataddusers->lpglistNewUsers);
+
+ VulturePostUIMessage(VUIMSG_CHATADDUSERS, lpvchataddusers);
+}
+
+
+/**
+ * Frees a VULTURE_CHAT_ADD_USERS structure once the UI is done with it.
+ *
+ * @param lpvchataddusers Structure to free.
+ */
+void VultureFreeChatAddUsers(VULTURE_CHAT_ADD_USERS *lpvchataddusers)
+{
+ GList *lpglistRover;
+
+ for(lpglistRover = lpvchataddusers->lpglistNewUsers; lpglistRover; lpglistRover = lpglistRover->next)
+ {
+ VULTURE_ADD_CHAT_USER *lpvaddchatuser = lpglistRover->data;
+
+ if(lpvaddchatuser->szAlias) g_free(lpvaddchatuser->szAlias);
+ if(lpvaddchatuser->szAliasKey) g_free(lpvaddchatuser->szAliasKey);
+ if(lpvaddchatuser->szName) g_free(lpvaddchatuser->szName);
+
+ g_free(lpvaddchatuser);
+ }
+
+ g_list_free(lpvchataddusers->lpglistNewUsers);
+
+ g_free(lpvchataddusers);
+}
============================================================
--- vulture/purpleconv.h 81da17373c2daa10989d196b0b38f992789181aa
+++ vulture/purpleconv.h 20878400e8f55b17cfe5556ac0500f475c9c326b
@@ -42,6 +42,8 @@ void PurpleJoinChat(PurpleChat *lpchat);
GList* PurpleGetChatFields(PurpleAccount *lppac);
void PurpleJoinAdHocChat(PurpleAccount *lppac, GHashTable *lphashParameters);
void PurpleJoinChat(PurpleChat *lpchat);
+void PurpleChatAddUsers(PurpleConversation *lpconv, GList *lpglistChatBuddies, gboolean bNewArrivals);
+void VultureFreeChatAddUsers(VULTURE_CHAT_ADD_USERS *lpvchataddusers);
#endif
============================================================
--- vulture/purplemain.c 4f608d0871c2cde8c49e86ae92d1b7db4334a28b
+++ vulture/purplemain.c 324649ed4f41a4686b1d6218f5a4fd9a8a30590c
@@ -188,7 +188,7 @@ static void InitUI(void)
NULL, /* write_chat */
NULL, /* write_im */
PurpleWriteConversation, /* write_conv */
- NULL, /* chat_add_users */
+ PurpleChatAddUsers, /* chat_add_users */
NULL, /* chat_rename_user */
NULL, /* chat_remove_users */
NULL, /* chat_update_user */
============================================================
--- vulture/purplemain.h 709b09087c04d1b31d04a5daf99878a1112141ce
+++ vulture/purplemain.h 4d840ab48b62d9c11a4e1614cf3b13ccaa8714e5
@@ -62,6 +62,9 @@ enum ENUM_VULTURE_UI_MESSAGES
/* (VULTURE_CONVERSATION*) */
VUIMSG_UPDATEIMSTATUSTEXT,
+
+ /* (VULTURE_CHAT_ADD_USERS*) */
+ VUIMSG_CHATADDUSERS,
};
/* HandlEs for reigistering signal handlERs. */
============================================================
--- vulture/resource.h 7aa8930203dfef3e9009f5715597e4513d0c245e
+++ vulture/resource.h ddf3bb2fa6ec549bff5742e152ead714e18c3b32
@@ -13,10 +13,10 @@
#define IDD_CHAT 117
#define IDD_JOINCHAT 119
#define IDC_CBEX_ACCOUNTS 1000
-#define IDC_LIST_NAMES 1001
#define IDC_STATIC_DETAILS 1001
#define IDC_TAB_CONVERSATIONS 1001
#define IDC_BUDDY_ICON 1002
+#define IDC_TREE_NAMES 1002
#define IDC_LIST_ACCOUNTS 1003
#define IDC_CBEX_STATUS 1004
#define IDM_BLIST_BUDDIES_CLOSE 40000
============================================================
--- vulture/vulture-res.rc f3435662e145624cc479fbf17f8d524047baa4f4
+++ vulture/vulture-res.rc f13aaa069d5d50d7050fc47275c3a8778ef1cceb
@@ -78,7 +78,7 @@ FONT 8, "Ms Shell Dlg"
{
CONTROL "", IDC_RICHEDIT_CONV, RICHEDIT_CLASS, WS_TABSTOP | WS_VSCROLL | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY, 5, 5, 245, 180
CONTROL "", IDC_RICHEDIT_INPUT, RICHEDIT_CLASS, WS_TABSTOP | WS_BORDER | ES_MULTILINE | ES_WANTRETURN, 5, 190, 245, 40
- CONTROL "", IDC_LIST_NAMES, WC_LISTVIEW, WS_TABSTOP | WS_BORDER | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | LVS_SHAREIMAGELISTS | LVS_REPORT, 255, 5, 65, 225
+ CONTROL "", IDC_TREE_NAMES, WC_TREEVIEW, WS_TABSTOP | WS_BORDER | TVS_INFOTIP | TVS_NOHSCROLL | TVS_FULLROWSELECT, 255, 5, 65, 225
}
============================================================
--- vulture/vulture.c 7182bc7b2abddaf6071a17728c58ae8571916e70
+++ vulture/vulture.c 04f9b98a996dd13b06e462ba23f0204ee4788c7f
@@ -239,3 +239,21 @@ LPTSTR VultureAmpersandify(LPCTSTR szUnd
return szAmpersanded;
}
+
+
+/**
+ * GCompareDataFunc for comparing TCHAR strings. Useful for, e.g., the binary
+ * tree containing chat participants' names.
+ *
+ * @param lpvStr1 First string.
+ * @param lpvStr1 Second string.
+ * @param lpvUnused Ignored.
+ *
+ * @return Negative/zero/positive as lpvStr1 is resp. lexicographically less
+ * than/equal to/greater than lpvStr2.
+ */
+gint VultureCompareTCHARStrings(gconstpointer lpvStr1, gconstpointer lpvStr2, gpointer lpvUnused)
+{
+ UNREFERENCED_PARAMETER(lpvUnused);
+ return _tcscmp((LPCTSTR)lpvStr1, (LPCTSTR)lpvStr2);
+}
============================================================
--- vulture/vulture.h 1ea290ca0dba6c9e2c6384f66137fbf993d7b9f3
+++ vulture/vulture.h bdf8473724935c22d91408bcf488b8391e927b22
@@ -61,13 +61,14 @@ LPTSTR VultureAmpersandify(LPCTSTR szUnd
int MessageBoxFromStringTable(HWND hwnd, WORD wResourceString, UINT uiType);
void VultureTimetToSystemTime(time_t t, LPSYSTEMTIME lpsystime);
LPTSTR VultureAmpersandify(LPCTSTR szUnderscored);
+gint VultureCompareTCHARStrings(gconstpointer lpvStr1, gconstpointer lpvStr2, gpointer lpvUnused);
/** Wrappers for heap functions. */
static INLINE LPVOID ProcHeapAlloc(DWORD cb) { return HeapAlloc(g_hProcHeap, HEAP_GENERATE_EXCEPTIONS, cb); }
static INLINE LPVOID ProcHeapReAlloc(LPVOID lpv, DWORD cb) { return HeapReAlloc(g_hProcHeap, HEAP_GENERATE_EXCEPTIONS, lpv, cb); }
-static INLINE BOOL ProcHeapFree(LPVOID lpv) { return HeapFree(g_hProcHeap, 0, lpv); }
+static INLINE void ProcHeapFree(LPVOID lpv) { HeapFree(g_hProcHeap, 0, lpv); }
/**
============================================================
--- vulture/vultureblist.c 648b120eb4c5f0557d7d0fa88419b1ae3763eebb
+++ vulture/vultureblist.c 98daff9b2ec06d06ce4ad199334168d314bbf4c2
@@ -331,6 +331,10 @@ static LRESULT CALLBACK MainWndProc(HWND
hwndForward = ((VULTURE_CONVERSATION*)lParam)->hwndConv;
break;
+ case VUIMSG_CHATADDUSERS:
+ hwndForward = ((VULTURE_CHAT_ADD_USERS*)lParam)->lpvconvChat->hwndConv;
+ break;
+
case VUIMSG_QUIT:
DestroyWindow(hwnd);
break;
============================================================
--- vulture/vultureconv.c 0f796f87318f187d5bbca149577cadd0f6025753
+++ vulture/vultureconv.c 642cad5ca8e0fd65b519f493eae21eec3830cca6
@@ -24,6 +24,9 @@
#include <commctrl.h>
#include <richedit.h>
#include <glib.h>
+#include <string.h>
+#include <tchar.h>
+#include <stdlib.h>
#include "vulture.h"
#include "resource.h"
@@ -443,6 +446,67 @@ static INT_PTR CALLBACK ChatDlgProc(HWND
*/
static INT_PTR CALLBACK ChatDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
+ VULTURE_CONVERSATION_CHAT *lpvconvchat;
+
+ switch(uiMsg)
+ {
+ case WM_INITDIALOG:
+ lpvconvchat = (VULTURE_CONVERSATION_CHAT*)lParam;
+ lpvconvchat->lpgtreePeople = g_tree_new_full(VultureCompareTCHARStrings, NULL, free, ProcHeapFree);
+ break;
+
+ case WM_PURPLEUIMSG:
+
+ lpvconvchat = (VULTURE_CONVERSATION_CHAT*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch(wParam)
+ {
+ case VUIMSG_CHATADDUSERS:
+ {
+ VULTURE_CHAT_ADD_USERS *lpvchataddusers = (VULTURE_CHAT_ADD_USERS*)lParam;
+ GList *lpglistRover;
+ HWND hwndTVNames = GetDlgItem(hwndDlg, IDC_TREE_NAMES);
+
+ /* Add the new users to the binary tree, and
+ * create tree-view entries for them.
+ */
+ for(lpglistRover = lpvchataddusers->lpglistNewUsers; lpglistRover; lpglistRover = lpglistRover->next)
+ {
+ VULTURE_CHAT_USER *lpvcu = ProcHeapAlloc(sizeof(VULTURE_CHAT_USER));
+ VULTURE_ADD_CHAT_USER *lpvaddchatuser = lpglistRover->data;
+ TVINSERTSTRUCT tvis;
+
+ lpvcu->szAlias = lpvaddchatuser->szAlias ? _tcsdup(lpvaddchatuser->szAlias) : NULL;
+ lpvcu->szAliasKey = lpvaddchatuser->szAliasKey ? _tcsdup(lpvaddchatuser->szAliasKey) : NULL;
+ lpvcu->bIsBuddy = lpvaddchatuser->bIsBuddy;
+ lpvcu->pccbflags = lpvaddchatuser->pccbflags;
+
+ /* Add to tree-view. */
+ tvis.hParent = TVI_ROOT;
+ tvis.hInsertAfter = TVI_ROOT;
+ tvis.item.mask = TVIF_PARAM | TVIF_TEXT;
+ tvis.item.pszText = lpvaddchatuser->szName;
+ tvis.item.lParam = (LPARAM)lpvcu;
+ lpvcu->hti = TreeView_InsertItem(hwndTVNames, &tvis);
+
+ /* Add to binary tree. */
+ g_tree_insert(lpvconvchat->lpgtreePeople, _tcsdup(lpvaddchatuser->szName), lpvcu);
+ }
+
+ VultureFreeChatAddUsers(lpvchataddusers);
+ }
+
+ break;
+ }
+
+ break;
+
+ case WM_DESTROY:
+ lpvconvchat = (VULTURE_CONVERSATION_CHAT*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ g_tree_destroy(lpvconvchat->lpgtreePeople);
+ break;
+ }
+
return ConvCommonDlgProc(hwndDlg, uiMsg, wParam, lParam);
}
@@ -621,7 +685,7 @@ static void RepositionConvControls(HWND
{
hdwp = DeferWindowPos(
hdwp,
- GetDlgItem(hwndConvDlg, IDC_LIST_NAMES),
+ GetDlgItem(hwndConvDlg, IDC_TREE_NAMES),
NULL,
2 * CONV_DLG_MARGIN + cxLeft,
CONV_DLG_MARGIN,
============================================================
--- vulture/vultureconv.h aaba7f14efa54acc0bb5e7abc1bafbca41df31b0
+++ vulture/vultureconv.h 07d800491580607a37a94f6eee2e5048f50afcce
@@ -25,6 +25,8 @@
#include <windows.h>
+#include <commctrl.h>
+#include <glib.h>
#include "purple.h"
@@ -40,6 +42,20 @@ typedef struct _VULTURE_CONVERSATION
} VULTURE_CONVERSATION;
+/* These two structs inherit from VULTURE_CONVERSATION. */
+
+typedef struct _VULTURE_CONVERSATION_IM
+{
+ VULTURE_CONVERSATION vconv;
+} VULTURE_CONVERSATION_IM;
+
+typedef struct _VULTURE_CONVERSATION_CHAT
+{
+ VULTURE_CONVERSATION vconv;
+ GTree *lpgtreePeople;
+} VULTURE_CONVERSATION_CHAT;
+
+
typedef struct _VULTURE_CONV_WRITE
{
VULTURE_CONVERSATION *lpvconv;
@@ -66,7 +82,33 @@ typedef struct _VULTURE_CONV_GET_STRING
LPTSTR sz;
} VULTURE_CONV_GET_STRING;
+typedef struct _VULTURE_ADD_CHAT_USER
+{
+ LPTSTR szName;
+ LPTSTR szAlias;
+ LPTSTR szAliasKey;
+ BOOL bIsBuddy;
+ PurpleConvChatBuddyFlags pccbflags;
+} VULTURE_ADD_CHAT_USER;
+typedef struct _VULTURE_CHAT_ADD_USERS
+{
+ VULTURE_CONVERSATION *lpvconvChat;
+ GList *lpglistNewUsers;
+} VULTURE_CHAT_ADD_USERS;
+
+typedef struct _VULTURE_CHAT_USER
+{
+ /* We don't store the name here. */
+
+ LPTSTR szAlias;
+ LPTSTR szAliasKey;
+ BOOL bIsBuddy;
+ PurpleConvChatBuddyFlags pccbflags;
+ HTREEITEM hti;
+} VULTURE_CHAT_USER;
+
+
int VultureRegisterConvContainerWindowClass(void);
HWND VultureCreateConvContainer(void);
void VultureWriteConversation(VULTURE_CONV_WRITE *lpvcwrite);
More information about the Commits
mailing list