soc.2009.vulture: a7eb4482: Rename users in user-list in chats.
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Thu Jul 9 14:45:39 EDT 2009
-----------------------------------------------------------------
Revision: a7eb4482a56361c1338cf8c1285dcf808d3a51d7
Ancestor: edc99b6230741c3997e7e1bf32238d1acc4e50ed
Author: gdick at soc.pidgin.im
Date: 2009-07-09T18:39:26
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/a7eb4482a56361c1338cf8c1285dcf808d3a51d7
Modified files:
vulture/purpleconv.c vulture/purpleconv.h
vulture/purplemain.c vulture/purplemain.h vulture/vulture.h
vulture/vultureblist.c vulture/vultureconv.c
vulture/vultureconv.h
ChangeLog:
Rename users in user-list in chats.
-------------- next part --------------
============================================================
--- vulture/purpleconv.c 31d0a6a74b2b3a98825a4681b5002ffd7451fd07
+++ vulture/purpleconv.c 23c96a88a0eed44290de7097f5790c2b1deaafa4
@@ -328,3 +328,39 @@ void VultureFreeChatAddUsers(VULTURE_CHA
g_free(lpvchataddusers);
}
+
+
+/**
+ * Called when a user is renamed in a chat.
+ *
+ * @param lpconv Conversation.
+ * @param szOldName Old name.
+ * @param szNewName New name.
+ * @param szNewAlias New alias. Possibly NULL.
+ */
+void PurpleChatRenameUser(PurpleConversation *lpconv, const char *szOldName, const char *szNewName, const char *szNewAlias)
+{
+ VULTURE_CHAT_RENAME_USER *lpvchatrenameuser = g_new(VULTURE_CHAT_RENAME_USER, 1);
+
+ lpvchatrenameuser->lpvconvChat = lpconv->ui_data;
+ lpvchatrenameuser->szOldName = VultureUTF8ToTCHAR(szOldName);
+ lpvchatrenameuser->szNewName = VultureUTF8ToTCHAR(szNewName);
+ lpvchatrenameuser->szNewAlias = szNewAlias ? VultureUTF8ToTCHAR(szNewAlias) : NULL;
+
+ VulturePostUIMessage(VUIMSG_CHATRENAMEUSER, lpvchatrenameuser);
+}
+
+
+/**
+ * Frees a VULTURE_CHAT_RENAME_USER structure once the UI is done with it.
+ *
+ * @param lpvchatrenameuser Structure to free.
+ */
+void VultureFreeRenameUser(VULTURE_CHAT_RENAME_USER *lpvchatrenameuser)
+{
+ g_free(lpvchatrenameuser->szOldName);
+ g_free(lpvchatrenameuser->szNewName);
+ if(lpvchatrenameuser->szNewAlias) g_free(lpvchatrenameuser->szNewAlias);
+
+ g_free(lpvchatrenameuser);
+}
============================================================
--- vulture/purpleconv.h 20878400e8f55b17cfe5556ac0500f475c9c326b
+++ vulture/purpleconv.h 3c7b1b7067b9561e3d4bcee0e513966927df2f3c
@@ -44,6 +44,8 @@ void VultureFreeChatAddUsers(VULTURE_CHA
void PurpleJoinChat(PurpleChat *lpchat);
void PurpleChatAddUsers(PurpleConversation *lpconv, GList *lpglistChatBuddies, gboolean bNewArrivals);
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);
#endif
============================================================
--- vulture/purplemain.c 324649ed4f41a4686b1d6218f5a4fd9a8a30590c
+++ vulture/purplemain.c 1db75f6b38f4f178377fc153e76345bfafa67456
@@ -189,7 +189,7 @@ static void InitUI(void)
NULL, /* write_im */
PurpleWriteConversation, /* write_conv */
PurpleChatAddUsers, /* chat_add_users */
- NULL, /* chat_rename_user */
+ PurpleChatRenameUser, /* chat_rename_user */
NULL, /* chat_remove_users */
NULL, /* chat_update_user */
NULL, /* present */
============================================================
--- vulture/purplemain.h 4d840ab48b62d9c11a4e1614cf3b13ccaa8714e5
+++ vulture/purplemain.h 7a36605a7b4d06e7e86f4450b13019a838ef7d9d
@@ -65,6 +65,9 @@ enum ENUM_VULTURE_UI_MESSAGES
/* (VULTURE_CHAT_ADD_USERS*) */
VUIMSG_CHATADDUSERS,
+
+ /* (VULTURE_CHAT_RENAME_USER*) */
+ VUIMSG_CHATRENAMEUSER,
};
/* HandlEs for reigistering signal handlERs. */
============================================================
--- vulture/vulture.h bdf8473724935c22d91408bcf488b8391e927b22
+++ vulture/vulture.h 27c53cafd100bac89ff55196e5f36398a7db21ab
@@ -68,7 +68,7 @@ static INLINE LPVOID ProcHeapReAlloc(LPV
/** 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 void ProcHeapFree(LPVOID lpv) { HeapFree(g_hProcHeap, 0, lpv); }
+static INLINE BOOL ProcHeapFree(LPVOID lpv) { return HeapFree(g_hProcHeap, 0, lpv); }
/**
============================================================
--- vulture/vultureblist.c 98daff9b2ec06d06ce4ad199334168d314bbf4c2
+++ vulture/vultureblist.c f7a66d22371c7b3d88139a3074036c06d8799bf3
@@ -335,6 +335,10 @@ static LRESULT CALLBACK MainWndProc(HWND
hwndForward = ((VULTURE_CHAT_ADD_USERS*)lParam)->lpvconvChat->hwndConv;
break;
+ case VUIMSG_CHATRENAMEUSER:
+ hwndForward = ((VULTURE_CHAT_RENAME_USER*)lParam)->lpvconvChat->hwndConv;
+ break;
+
case VUIMSG_QUIT:
DestroyWindow(hwnd);
break;
============================================================
--- vulture/vultureconv.c 642cad5ca8e0fd65b519f493eae21eec3830cca6
+++ vulture/vultureconv.c c69610d47587473ade53c8e37c57e4b173a6fff6
@@ -64,6 +64,7 @@ static void UpdateIMStatusText(HWND hwnd
static void EnableAppropriateConvWindow(CONVCONTAINERDATA *lpccd);
static void SetConvTitle(VULTURE_CONVERSATION *lpvconv, HWND hwndTabs, LPTSTR szTitle);
static void UpdateIMStatusText(HWND hwndDlg, VULTURE_CONVERSATION *lpvconv);
+static void FreeChatUser(void *lpvChatUser);
/**
@@ -452,7 +453,7 @@ static INT_PTR CALLBACK ChatDlgProc(HWND
{
case WM_INITDIALOG:
lpvconvchat = (VULTURE_CONVERSATION_CHAT*)lParam;
- lpvconvchat->lpgtreePeople = g_tree_new_full(VultureCompareTCHARStrings, NULL, free, ProcHeapFree);
+ lpvconvchat->lpgtreePeople = g_tree_new_full(VultureCompareTCHARStrings, NULL, free, FreeChatUser);
break;
case WM_PURPLEUIMSG:
@@ -497,6 +498,40 @@ static INT_PTR CALLBACK ChatDlgProc(HWND
}
break;
+
+ case VUIMSG_CHATRENAMEUSER:
+ {
+ VULTURE_CHAT_RENAME_USER *lpvchatrenameuser = (VULTURE_CHAT_RENAME_USER*)lParam;
+ VULTURE_CHAT_USER *lpvchatuser = g_tree_lookup(lpvconvchat->lpgtreePeople, lpvchatrenameuser->szOldName);
+ VULTURE_CHAT_USER *lpvchatuserNew;
+ TVITEM tvitem;
+ HWND hwndTVNames = GetDlgItem(hwndDlg, IDC_TREE_NAMES);
+
+ tvitem.mask = TVIF_TEXT | TVIF_PARAM;
+ tvitem.hItem = lpvchatuser->hti;
+ tvitem.pszText = lpvchatrenameuser->szNewName;
+
+ /* Create new entry for this user. */
+ lpvchatuserNew = ProcHeapAlloc(sizeof(VULTURE_CHAT_USER));
+ lpvchatuserNew->szAlias = lpvchatrenameuser->szNewAlias ? _tcsdup(lpvchatrenameuser->szNewAlias) : NULL;
+ lpvchatuserNew->szAliasKey = lpvchatuser->szAliasKey ? _tcsdup(lpvchatuser->szAliasKey) : NULL;
+ lpvchatuserNew->bIsBuddy = lpvchatuser->bIsBuddy;
+ lpvchatuserNew->pccbflags = lpvchatuser->pccbflags;
+ lpvchatuserNew->hti = lpvchatuser->hti;
+
+ /* Remove old entry from binary tree. */
+ g_tree_remove(lpvconvchat->lpgtreePeople, lpvchatrenameuser->szOldName);
+
+ /* Add new entry. */
+ g_tree_insert(lpvconvchat->lpgtreePeople, lpvchatrenameuser->szNewName, lpvchatuserNew);
+
+ /* Update tree-view. */
+ TreeView_SetItem(hwndTVNames, &tvitem);
+
+ VultureFreeRenameUser(lpvchatrenameuser);
+ }
+
+ break;
}
break;
@@ -864,3 +899,19 @@ static void UpdateIMStatusText(HWND hwnd
SetDlgItemText(hwndDlg, IDC_STATIC_STATUS, vcgetstring.sz ? vcgetstring.sz : TEXT(""));
if(vcgetstring.sz) g_free(vcgetstring.sz);
}
+
+
+/**
+ * GDestroyNotify that frees a VULTURE_CHAT_USER structure and its contents.
+ *
+ * @param lpvChatUser Structure to free.
+ */
+static void FreeChatUser(void *lpvChatUser)
+{
+ VULTURE_CHAT_USER *lpvchatuser = (VULTURE_CHAT_USER*)lpvChatUser;
+
+ if(lpvchatuser->szAlias) free(lpvchatuser->szAlias);
+ if(lpvchatuser->szAliasKey) free(lpvchatuser->szAliasKey);
+
+ ProcHeapFree(lpvchatuser);
+}
============================================================
--- vulture/vultureconv.h 07d800491580607a37a94f6eee2e5048f50afcce
+++ vulture/vultureconv.h 9a93750e52b4314a219ad82b6ce06082195f6755
@@ -108,7 +108,13 @@ typedef struct _VULTURE_CHAT_USER
HTREEITEM hti;
} VULTURE_CHAT_USER;
+typedef struct _VULTURE_CHAT_RENAME_USER
+{
+ VULTURE_CONVERSATION *lpvconvChat;
+ LPTSTR szOldName, szNewName, szNewAlias;
+} VULTURE_CHAT_RENAME_USER;
+
int VultureRegisterConvContainerWindowClass(void);
HWND VultureCreateConvContainer(void);
void VultureWriteConversation(VULTURE_CONV_WRITE *lpvcwrite);
More information about the Commits
mailing list