soc.2009.vulture: 65ab3cd9: Edit chat properties.

gdick at soc.pidgin.im gdick at soc.pidgin.im
Fri Aug 14 17:36:34 EDT 2009


-----------------------------------------------------------------
Revision: 65ab3cd9ade773fa58857f8790bb99009eb853b1
Ancestor: 54be3de21c6741c6e71620093d30d17cd1ab178f
Author: gdick at soc.pidgin.im
Date: 2009-08-14T21:30:11
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/65ab3cd9ade773fa58857f8790bb99009eb853b1

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

ChangeLog: 

Edit chat properties.

-------------- next part --------------
============================================================
--- vulture/purplequeue.c	bb0ae45b7790eea107512830c66dc8c3e1988ee0
+++ vulture/purplequeue.c	7e4106c7d061e444d597f9cde5f2405a6144e1d8
@@ -63,6 +63,7 @@ static gboolean QueueDispatch(GSource *l
 static gboolean QueuePrepare(GSource *lpgsource, int *lpiTimeout);
 static gboolean QueueCheck(GSource *lpgsource);
 static gboolean QueueDispatch(GSource *lpgsource, GSourceFunc gsfCallback, gpointer lpvData);
+static void AddChatComponentCallback(gpointer lpvKey, gpointer lpvValue, gpointer lpvHashTable);
 
 
 #define EFFECTIVE_BUDDY(lpblistnode) \
@@ -457,6 +458,45 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleRefreshBuddyIcon(purple_prefs_get_path(VULTURE_PREFS_ROOT "/accounts/buddyicon"));
 		break;
 
+	case PC_GETCHATPROPERTIES:
+		{
+			VULTURE_CHAT_PROPERTIES *lpvcp = lppurplecall->lpvParam;
+
+			if(lpvcp->lpvblistnode->lpblistnode)
+			{
+				GHashTable *lphashChat = purple_chat_get_components((PurpleChat*)lpvcp->lpvblistnode->lpblistnode);
+
+				lpvcp->lphashComponents = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+				g_hash_table_foreach(lphashChat, AddChatComponentCallback, lpvcp->lphashComponents);
+			}
+			else
+				lpvcp->lphashComponents = NULL;
+		}
+
+		break;
+
+	case PC_SETCHATPROPERTIES:
+		{
+			VULTURE_CHAT_PROPERTIES *lpvcp = lppurplecall->lpvParam;
+
+			if(lpvcp->lpvblistnode->lpblistnode)
+				g_hash_table_foreach(lpvcp->lphashComponents, AddChatComponentCallback, purple_chat_get_components((PurpleChat*)lpvcp->lpvblistnode->lpblistnode));
+		}
+
+		break;
+
+	case PC_GETBLISTCHATNODEACCOUNT:
+		{
+			VULTURE_BLIST_NODE_GET_ACCOUNT *lpvblngetacct = lppurplecall->lpvParam;
+
+			if(lpvblngetacct->lpvblistnode->lpblistnode && PURPLE_BLIST_NODE_IS_CHAT(lpvblngetacct->lpvblistnode->lpblistnode))
+				lpvblngetacct->lpaccount = purple_chat_get_account((PurpleChat*)lpvblngetacct->lpvblistnode->lpblistnode);
+			else
+				lpvblngetacct->lpaccount = NULL;
+		}
+
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
@@ -664,3 +704,17 @@ void VultureSingleSyncPurpleCall(int iCa
 	WaitForSingleObject(hevent, INFINITE);
 	CloseHandle(hevent);
 }
+
+
+/**
+ * Callback function for g_hash_table_foreach that adds a key/value pair to
+ * another hash table.
+ *
+ * @param	lpvKey		Key to add.
+ * @param	lpvValue	Value to add.
+ * @param	lpvHashTable	Hash table to add to.
+ */
+static void AddChatComponentCallback(gpointer lpvKey, gpointer lpvValue, gpointer lpvHashTable)
+{
+	g_hash_table_insert(lpvHashTable, g_strdup(lpvKey), g_strdup(lpvValue));
+}
============================================================
--- vulture/purplequeue.h	145dd4289a5102cefea92a285ecc4a9795fdab38
+++ vulture/purplequeue.h	b22dceb98860f0ae6649d10713cd82d490a67836
@@ -134,6 +134,15 @@ enum PURPLE_CALL_ID
 	PC_SETGLOBALBICON,
 
 	PC_REFRESHGLOBALBICON,
+
+	/* (VULTURE_CHAT_PROPERTIES*) */
+	PC_GETCHATPROPERTIES,
+
+	/* (VULTURE_CHAT_PROPERTIES*) */
+	PC_SETCHATPROPERTIES,
+
+	/* (VULTURE_BLIST_NODE_GET_ACCOUNT*) */
+	PC_GETBLISTCHATNODEACCOUNT,
 };
 
 
============================================================
--- vulture/resource.h	a10f7dc555490305e0c03cbf6d508eb22ba22e76
+++ vulture/resource.h	d7743566f45444031fc3891e7cb09de6cf4f27bb
@@ -61,6 +61,7 @@
 #define IDD_IMBUDDY			109
 #define IDD_ADDCHAT			110
 #define IDD_ADDGROUP			111
+#define IDD_CHATPROPERTIES		112
 
 
 #define IDM_BLIST			1001
@@ -90,16 +91,16 @@
 #define IDM_BLIST_CONTEXT_AUTOJOIN	40213
 #define IDM_BLIST_CONTEXT_PROPERTIES	40214
 #define IDM_BLIST_CONTEXT_COLLAPSE	40215
-#define IDM_BLIST_CONTEXT_ADDBUDDY      40216
-#define IDM_BLIST_CONTEXT_ADDCHAT       40217
-#define IDM_BLIST_CONTEXT_ADDGROUP      40218
+#define IDM_BLIST_CONTEXT_ADDBUDDY	40216
+#define IDM_BLIST_CONTEXT_ADDCHAT	40217
+#define IDM_BLIST_CONTEXT_ADDGROUP	40218
 
 #define IDM_CONV			1003
 #define IDM_CONV_CONV_CLOSE		40401
 
-#define IDM_BUDDYICON_CONTEXT           1004
-#define IDM_BUDDYICON_CONTEXT_SET       40601
-#define IDM_BUDDYICON_CONTEXT_REMOVE    40602
+#define IDM_BUDDYICON_CONTEXT		1004
+#define IDM_BUDDYICON_CONTEXT_SET	40601
+#define IDM_BUDDYICON_CONTEXT_REMOVE	40602
 
 /* For dynamic menu items not sent as WM_COMMAND notifications. */
 #define IDM_DYNAMIC_FIRST		50000
============================================================
--- vulture/vulture-res.rc	fc9874b1cd6571ca03f50cb3ea84c964c4c2be00
+++ vulture/vulture-res.rc	4a1c676638f2e0f78961ad6e53dd7db948719fa2
@@ -135,7 +135,7 @@ IDM_BLIST_CONTEXT MENUEX
 		CONTEXT_ALIAS_REMOVE
 		CONTEXT_CUSTOMICON
 		MENUITEM "", 0, MFT_SEPARATOR
-		MENUITEM "&Properties", IDM_BLIST_CONTEXT_PROPERTIES, MFT_STRING, MFS_GRAYED
+		MENUITEM "&Properties", IDM_BLIST_CONTEXT_PROPERTIES, MFT_STRING
 	}
 
 	POPUP "Group"
@@ -274,7 +274,27 @@ FONT 8, "Ms Shell Dlg"
 
 
 
+#define CHAT_DLG_COMMON \
+	LTEXT		"&Account:", IDC_STATIC, 5, 32, 35, 10, SS_LEFT \
+	CONTROL		"", IDC_CBEX_ACCOUNTS, "ComboBoxEx32", 0x50010003, 45, 30, 155, 90 \
+	GROUPBOX	"Details", IDC_STATIC_DETAILS, 5, 50, 195, 58 \
+	DEFPUSHBUTTON   "OK", IDOK, 95, 115, 50, 14, BS_DEFPUSHBUTTON \
+	PUSHBUTTON	"Cancel", IDCANCEL, 150, 115, 50, 14, BS_PUSHBUTTON
+
+
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDD_CHATPROPERTIES DIALOG 0, 0, 204, 132
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
+CAPTION "Chat Properties"
+FONT 8, "Ms Shell Dlg"
+{
+	LTEXT		"Please set the properties for this chat.", IDC_STATIC, 5, 5, 195, 20, SS_LEFT
+	CHAT_DLG_COMMON
+}
+
+
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDD_CONVCONT DIALOG 0, 0, 281, 169
 STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
 EXSTYLE WS_EX_TRANSPARENT
@@ -324,11 +344,7 @@ FONT 8, "Ms Shell Dlg"
 FONT 8, "Ms Shell Dlg"
 {
 	LTEXT		"Please choose an account, and then enter the details of the chat that you wish to join.", IDC_STATIC, 5, 5, 195, 20, SS_LEFT
-	LTEXT		"&Account:", IDC_STATIC, 5, 32, 35, 10, SS_LEFT
-	CONTROL		"", IDC_CBEX_ACCOUNTS, "ComboBoxEx32", 0x50010003, 45, 30, 155, 90
-	GROUPBOX	"Details", IDC_STATIC_DETAILS, 5, 50, 195, 58
-	DEFPUSHBUTTON   "OK", IDOK, 95, 115, 50, 14, BS_DEFPUSHBUTTON
-	PUSHBUTTON	"Cancel", IDCANCEL, 150, 115, 50, 14, BS_PUSHBUTTON
+	CHAT_DLG_COMMON
 }
 
 
============================================================
--- vulture/vultureblist.c	40d91262893a47e2a0015a640e1d5cf411e4732b
+++ vulture/vultureblist.c	2cfea1b0f443065a65658984d471e0bc05e1954f
@@ -226,6 +226,8 @@ static LRESULT CALLBACK MainWndProc(HWND
 				VULTURE_JOIN_CHAT_DATA vjcd;
 
 				vjcd.bJoinFieldsOnly = TRUE;
+				vjcd.lphashParameters = NULL;
+				vjcd.lppac = NULL;
 
 				if(VultureJoinChatDlg(hwnd, &vjcd))
 					VultureSingleSyncPurpleCall(PC_JOINCHAT, &vjcd);
@@ -1402,6 +1404,42 @@ static void RunChatMenuCmd(HWND hwndBudd
 	case IDM_BLIST_CONTEXT_AUTOJOIN:
 		VultureEnqueueAsyncPurpleCall(PC_TOGGLEAUTOJOIN, lpvblistnode);
 		break;
+
+	case IDM_BLIST_CONTEXT_PROPERTIES:
+		{
+			VULTURE_CHAT_PROPERTIES vcp;
+			VULTURE_JOIN_CHAT_DATA vjcd;
+			VULTURE_BLIST_NODE_GET_ACCOUNT vblngetacct;
+
+			vcp.lpvblistnode = lpvblistnode;
+			VultureSingleSyncPurpleCall(PC_GETCHATPROPERTIES, &vcp);
+
+			vblngetacct.lpvblistnode = lpvblistnode;
+			VultureSingleSyncPurpleCall(PC_GETBLISTCHATNODEACCOUNT, &vblngetacct);
+
+			vjcd.bJoinFieldsOnly = TRUE;
+			vjcd.lphashParameters = vcp.lphashComponents;
+			vjcd.lppac = vblngetacct.lpaccount;
+
+			if(VultureChatPropertiesDlg(g_hwndMain, &vjcd))
+			{
+				VULTURE_CHAT_PROPERTIES vcpSet;
+
+				vcpSet.lpvblistnode = lpvblistnode;
+				vcpSet.lphashComponents = vjcd.lphashParameters;
+				VultureSingleSyncPurpleCall(PC_SETCHATPROPERTIES, &vcpSet);
+
+				g_hash_table_destroy(vjcd.lphashParameters);
+
+				/* Update tree node. */
+				UpdateBListNode(hwndBuddies, lpvblistnode);				
+			}
+
+			if(vcp.lphashComponents)
+				g_hash_table_destroy(vcp.lphashComponents);
+		}
+
+		break;
 	}
 }
 
@@ -1704,6 +1742,8 @@ static void RequestAddChat(HWND hwndPare
 	vjcd.bJoinFieldsOnly = FALSE;
 	vjcd.szAlias = szAlias;
 	vjcd.szInitGroup = szInitGroup;
+	vjcd.lphashParameters = NULL;
+	vjcd.lppac = NULL;
 
 	if(VultureJoinChatDlg(hwndParent, &vjcd))
 	{
============================================================
--- vulture/vultureblist.h	9113d855c390713869a4274f32a4607866c67171
+++ vulture/vultureblist.h	ac1c009adf9de5a09a16786609f7270e87414d2c
@@ -82,8 +82,20 @@ typedef struct _VULTURE_BLIST_NODE_STRIN
 	LPTSTR			sz;
 } VULTURE_BLIST_NODE_STRING_PAIR;
 
+typedef struct _VULTURE_CHAT_PROPERTIES
+{
+	VULTURE_BLIST_NODE	*lpvblistnode;
+	GHashTable		*lphashComponents;
+} VULTURE_CHAT_PROPERTIES;
 
+typedef struct _VULTURE_BLIST_NODE_GET_ACCOUNT
+{
+	VULTURE_BLIST_NODE	*lpvblistnode;
+	PurpleAccount		*lpaccount;
+} VULTURE_BLIST_NODE_GET_ACCOUNT;
 
+
+
 enum VULTURE_STATUS_ICONS
 {
 	SICON_AVAILABLE = 0,
============================================================
--- vulture/vulturedlg.c	a3d87d6092bcf986ecb65d21e25ab0b53210ddd4
+++ vulture/vulturedlg.c	abfebdba1db2a76dc71f7453ea3ccc399da5ab81
@@ -119,6 +119,7 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 			VULTURE_GET_ACCOUNTS vgetaccounts;
 			RECT rcGroup, rcDlg, rcButton;
 			VULTURE_JOIN_CHAT_DATA *lpvjcd = (VULTURE_JOIN_CHAT_DATA*)lParam;
+			int iCount;
 
 			/* Get online accounts. */
 			vgetaccounts.bOnlineOnly = TRUE;
@@ -147,14 +148,55 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 			 */
 			s_iMaxShowFields = 3 + (lpvjcd->bJoinFieldsOnly ? 0 : ADD_CHAT_FIXED_FIELDS);
 
-			/* Populate combo and select first item. */
+			/* Populate combo and select item if appropriate. */
 			PopulateAccountsCombo(GetDlgItem(hwndDlg, IDC_CBEX_ACCOUNTS), s_lpglistAccounts);
-			if(SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_GETCOUNT, 0, 0) > 0)
+			iCount = SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_GETCOUNT, 0, 0);
+			if(iCount > 0)
 			{
 				SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_SETCURSEL, 0, 0);
 
+				/* Maybe override this with given account. */
+				if(lpvjcd->lppac)
+				{
+					COMBOBOXEXITEM cbexitem;
+					cbexitem.mask = CBEIF_LPARAM;
+					
+					for(cbexitem.iItem = 0; cbexitem.iItem < iCount; cbexitem.iItem++)
+					{
+						SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CBEM_GETITEM, 0, (LPARAM)&cbexitem);
+
+						if(cbexitem.lParam && ((VULTURE_ACCOUNT*)cbexitem.lParam)->lppac == lpvjcd->lppac)
+						{
+							SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_SETCURSEL, cbexitem.iItem, 0);
+							break;
+						}
+					}
+
+					EnableWindow(GetDlgItem(hwndDlg, IDC_CBEX_ACCOUNTS), FALSE);
+				}
+
 				/* Show fields. */
 				UpdateJoinChatFields(hwndDlg, &s_lpglistFields, &s_iMaxShowFields);
+
+				/* Initialise fields if appropriate. */
+				if(lpvjcd->lphashParameters && s_lpglistFields)
+				{
+					GList *lpglistRover;
+
+					for(lpglistRover = s_lpglistFields; lpglistRover; lpglistRover = lpglistRover->next)
+					{
+						JOIN_DLG_FIELD *lpjdf = lpglistRover->data;
+						const gchar *szValueUTF8;
+						LPTSTR szValue;
+
+						if((szValueUTF8 = g_hash_table_lookup(lpvjcd->lphashParameters, lpjdf->szID)))
+						{
+							szValue = VultureUTF8ToTCHAR(szValueUTF8);
+							SetWindowText(lpjdf->hwndEdit, szValue);
+							g_free(szValue);
+						}
+					}
+				}
 			}
 
 			if(!lpvjcd->bJoinFieldsOnly)
@@ -170,7 +212,7 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 
 				if(SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_GETCOUNT, 0, 0) > 0)
 				{
-					/* Maybe override this with given group. */
+					/* If we're given a group, select it. */
 					if(lpvjcd->szInitGroup)
 					{
 						LRESULT lIndex = SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_FINDSTRINGEXACT, -1, (LPARAM)lpvjcd->szInitGroup);
@@ -877,3 +919,20 @@ static INT_PTR CALLBACK GetStringDlgProc
 
 	return FALSE;
 }
+
+
+/**
+ * Displays the "Chat Properties" dialogue.
+ *
+ * @param		hwndParent	Parent window handle.
+ * @param[in,out]	lpvjcd		Details of chat to join are returned
+ *					here. bJoinFieldsOnly is set to TRUE
+ *					before the dialogue is shown.
+ *
+ * @return TRUE iff OKed.
+ */
+BOOL VultureChatPropertiesDlg(HWND hwndParent, VULTURE_JOIN_CHAT_DATA *lpvjcd)
+{
+	lpvjcd->bJoinFieldsOnly = TRUE;
+	return (BOOL)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CHATPROPERTIES), hwndParent, JoinChatDlgProc, (LPARAM)lpvjcd);
+}
============================================================
--- vulture/vulturedlg.h	f002bbc6c672723a24a351a9067fdacb5bf01ec5
+++ vulture/vulturedlg.h	5684cd41a23001362bcbeaa0ba17ed93a1bad2de
@@ -43,6 +43,7 @@ LPTSTR VultureAddGroupDlg(HWND hwndParen
 BOOL VultureJoinChatDlg(HWND hwndParent, VULTURE_JOIN_CHAT_DATA *lpvjcd);
 BOOL VultureAddBuddyDlg(HWND hwndParent, VULTURE_ADD_BUDDY_DATA *lpvabd);
 LPTSTR VultureAddGroupDlg(HWND hwndParent);
+BOOL VultureChatPropertiesDlg(HWND hwndParent, VULTURE_JOIN_CHAT_DATA *lpvjcd);
 
 
 #endif


More information about the Commits mailing list