soc.2009.vulture: 65fc03fa: Chats can now be joined via the dialogue...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Wed Jul 8 20:25:40 EDT 2009


-----------------------------------------------------------------
Revision: 65fc03fab04dc63fcc04ff80fe27a7909d1056fe
Ancestor: 23b32bebce442f9dbd9c1460727f258adfadde3a
Author: gdick at soc.pidgin.im
Date: 2009-07-08T14:48:19
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/65fc03fab04dc63fcc04ff80fe27a7909d1056fe

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

ChangeLog: 

Chats can now be joined via the dialogue.

-------------- next part --------------
============================================================
--- vulture/purpleconv.c	602a1ec80af31223f69b4b588a64bd511580c151
+++ vulture/purpleconv.c	0e81f68dee5437dec7f29734d3585fea6b179d7c
@@ -223,3 +223,38 @@ GList* PurpleGetChatFields(PurpleAccount
 
 	return NULL;
 }
+
+
+/**
+ * Joins a chat specified by a set of parameters.
+ *
+ * @param	lppac			Account.
+ * @param	lphashParameters	Parameters specifying the chat.
+ */
+void PurpleJoinAdHocChat(PurpleAccount *lppac, GHashTable *lphashParameters)
+{
+	/* Make a new chat, join it and then delete it immediately. */
+	PurpleChat *lpchat;
+
+	if(!lppac || !lphashParameters)
+		return;
+	
+	lpchat = purple_chat_new(lppac, NULL, lphashParameters);
+	PurpleJoinChat(lpchat);
+	purple_blist_remove_chat(lpchat);
+}
+
+
+/**
+ * Joins a chat.
+ *
+ * @param	lpchat	Chat to join.
+ */
+void PurpleJoinChat(PurpleChat *lpchat)
+{
+	/* TODO: Check whether there's already a conversation for this chat.
+	 * See Pidgin's gtk_blist_join_chat.
+	 */
+
+	serv_join_chat(lpchat->account->gc, lpchat->components);
+}
============================================================
--- vulture/purpleconv.h	536ee563a286c8473bedd90f8ffdf5bb6c11faae
+++ vulture/purpleconv.h	81da17373c2daa10989d196b0b38f992789181aa
@@ -24,6 +24,9 @@
 #define _VULTURE_PURPLECONV_H_
 
 
+#include <windows.h>
+#include <glib.h>
+
 #include "purple.h"
 #include "vultureconv.h"
 
@@ -37,6 +40,8 @@ GList* PurpleGetChatFields(PurpleAccount
 LPTSTR PurpleConvGetTitle(PurpleConversation *lpconv);
 LPTSTR PurpleIMGetStatusText(PurpleConversation *lpconv);
 GList* PurpleGetChatFields(PurpleAccount *lppac);
+void PurpleJoinAdHocChat(PurpleAccount *lppac, GHashTable *lphashParameters);
+void PurpleJoinChat(PurpleChat *lpchat);
 
 
 #endif
============================================================
--- vulture/purplequeue.c	1e63aaea35e35e994c4d20f7cb67db175a1a2710
+++ vulture/purplequeue.c	aefd0f450cf55356eab36138441a3bacbb78d7f8
@@ -242,6 +242,14 @@ static void DispatchPurpleCall(PURPLE_CA
 		
 		break;
 
+	case PC_JOINCHAT:
+		{
+			VULTURE_JOIN_CHAT_DATA *lpvjcd = lppurplecall->lpvParam;
+			PurpleJoinAdHocChat(lpvjcd->lppac, lpvjcd->lphashParameters);
+		}
+		
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h	5d73a21f5ed89cb91fdc9fefc99191e06f8f2e7d
+++ vulture/purplequeue.h	4bc3d10785ade94dbdb0d1b8f7ac8ffb2bf5a1c8
@@ -73,6 +73,9 @@ enum PURPLE_CALL_ID
 
 	/* (VULTURE_GET_CHAT_FIELDS*) */
 	PC_GETCHATFIELDS,
+
+	/* (VULTURE_JOIN_CHAT_DATA*) */
+	PC_JOINCHAT,
 };
 
 
============================================================
--- vulture/vulture-res.rc	7c0b9e9ac0950ea9f4cf0d5f9cc2da4d4a5170aa
+++ vulture/vulture-res.rc	51d606e20dbade0d325ab768e89bb1ed0c2ab2f5
@@ -76,8 +76,8 @@ FONT 8, "Ms Shell Dlg"
 STYLE DS_3DLOOK | DS_CENTER | DS_SHELLFONT | WS_CHILDWINDOW | WS_DISABLED
 FONT 8, "Ms Shell Dlg"
 {
-    CONTROL         "Rich Edit", IDC_RICHEDIT_CONV, RICHEDIT_CLASS, WS_TABSTOP | WS_VSCROLL | WS_BORDER | ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY, 5, 5, 245, 180
-    CONTROL         "Rich Edit", IDC_RICHEDIT_INPUT, RICHEDIT_CLASS, WS_TABSTOP | WS_BORDER | ES_MULTILINE | ES_WANTRETURN, 5, 190, 245, 40
+    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
 }
 
============================================================
--- vulture/vultureblist.c	0a3f1d1362b4b969935f2948b9ffde22b1ae0104
+++ vulture/vultureblist.c	648b120eb4c5f0557d7d0fa88419b1ae3763eebb
@@ -168,7 +168,9 @@ static LRESULT CALLBACK MainWndProc(HWND
 		case IDM_BLIST_BUDDIES_JOINCHAT:
 			{
 				VULTURE_JOIN_CHAT_DATA vjcd;
-				VultureJoinChatDlg(hwnd, &vjcd);
+
+				if(VultureJoinChatDlg(hwnd, &vjcd))
+					VultureSingleSyncPurpleCall(PC_JOINCHAT, &vjcd);
 			}
 
 			return 0;
============================================================
--- vulture/vulturedlg.c	4101f1f661a640eb9c7522a1295fe6887c58c51e
+++ vulture/vulturedlg.c	ecb0872dd5d797e36cd8a013490945150be004ba
@@ -148,7 +148,40 @@ static INT_PTR CALLBACK JoinChatDlgProc(
 		switch(LOWORD(wParam))
 		{
 		case IDOK:
-			EndDialog(hwndDlg, TRUE);
+			{
+				GList *lpglistRover;
+				COMBOBOXEXITEM cbexitem;
+
+				/* Get the selected account. */
+				cbexitem.mask = CBEIF_LPARAM;
+				cbexitem.iItem = SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_GETCURSEL, 0, 0);
+				SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CBEM_GETITEM, 0, (LPARAM)&cbexitem);
+				s_lpvjcd->lppac = ((VULTURE_ACCOUNT*)cbexitem.lParam)->lppac;
+
+				/* Build hash table. */
+				s_lpvjcd->lphashParameters = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+
+				for(lpglistRover = s_lpglistFields; lpglistRover; lpglistRover = lpglistRover->next)
+				{
+					JOIN_DLG_FIELD *lpjdf = lpglistRover->data;
+					int cchField = GetWindowTextLength(lpjdf->hwndEdit) + 1;
+
+					if(cchField > 1)
+					{
+						LPTSTR szField = ProcHeapAlloc(cchField * sizeof(TCHAR));
+						gchar *szFieldUTF8;
+
+						GetWindowText(lpjdf->hwndEdit, szField, cchField);
+						szFieldUTF8 = VultureTCHARToUTF8(szField);
+						ProcHeapFree(szField);
+
+						g_hash_table_replace(s_lpvjcd->lphashParameters, g_strdup(lpjdf->szID), szFieldUTF8);
+					}
+				}
+
+				EndDialog(hwndDlg, TRUE);
+			}
+
 			return TRUE;
 
 		case IDCANCEL:
============================================================
--- vulture/vulturedlg.h	347a73a6ddd85a0a6a67f2c24eb00aaf24e6cef7
+++ vulture/vulturedlg.h	5a96cfa2add01c5e64f30453a267e8d5dd09e043
@@ -32,7 +32,7 @@ typedef struct _VULTURE_JOIN_CHAT_DATA
 
 typedef struct _VULTURE_JOIN_CHAT_DATA
 {
-	VULTURE_ACCOUNT	*lpvac;
+	PurpleAccount	*lppac;
 	GHashTable	*lphashParameters;
 } VULTURE_JOIN_CHAT_DATA;
 


More information about the Commits mailing list