soc.2009.vulture: fe8928ce: IM arbitrary people.

gdick at soc.pidgin.im gdick at soc.pidgin.im
Wed Aug 5 16:55:46 EDT 2009


-----------------------------------------------------------------
Revision: fe8928ced680f02c4d3fd670905c585737a63e1c
Ancestor: 4211186b62791de2154bd1733db6453bdc230d95
Author: gdick at soc.pidgin.im
Date: 2009-08-05T20:51:09
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/fe8928ced680f02c4d3fd670905c585737a63e1c

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

ChangeLog: 

IM arbitrary people.

-------------- next part --------------
============================================================
--- vulture/purpleblist.h	ba8b57e582b04e1966b9d221fb5dde0ef5b6ba1f
+++ vulture/purpleblist.h	d91223d2ed13ea091b2a02071a9202adf4f1d6db
@@ -38,6 +38,7 @@ typedef struct _VULTURE_ADD_BUDDY_DATA
 	LPTSTR			szUsername;
 	LPTSTR			szAlias;
 	VULTURE_BLIST_NODE	*lpvblistnodeGroup;
+	BOOL			bIMFieldsOnly;
 } VULTURE_ADD_BUDDY_DATA;
 
 
============================================================
--- vulture/purplequeue.c	39f977fa40b576bfa2da3e87fa474e2997e3dd94
+++ vulture/purplequeue.c	2fd7f3ee0f77e5cc45298587acf4051586f6df99
@@ -420,6 +420,16 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleBlistUpdateLeaves(purple_get_blist()->root);
 		break;
 
+	case PC_STARTIM:
+		{
+			VULTURE_ADD_BUDDY_DATA *lpvabd = lppurplecall->lpvParam;
+			gchar *szUsernameUTF8 = VultureTCHARToUTF8(lpvabd->szUsername);
+			purple_conversation_new(PURPLE_CONV_TYPE_IM, lpvabd->lppac, szUsernameUTF8);
+			g_free(szUsernameUTF8);
+		}
+
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h	309baee3b3c5dbcbc65195c2550b3ad9fe2501f1
+++ vulture/purplequeue.h	24840087e08c5e3a0dcde1bdf3ddf3f98e755834
@@ -120,6 +120,9 @@ enum PURPLE_CALL_ID
 	PC_ADDBUDDY,
 
 	PC_REFRESHBLIST,
+
+	/* (VULTURE_ADD_BUDDY_DATA*) Username and account of person to IM. */
+	PC_STARTIM,
 };
 
 
============================================================
--- vulture/resource.h	a8cf41fb85beda90008d194fc33ab0a62e1e7ddf
+++ vulture/resource.h	6640dbf2b65bdbc0869b5427721679ab49304fb0
@@ -33,6 +33,7 @@
 #define IDD_JOINCHAT                            106
 #define IDD_STATUS                              107
 #define IDD_ADDBUDDY                            108
+#define IDD_IMBUDDY                             109
 
 
 #define IDM_BLIST                               1001
@@ -41,6 +42,7 @@
 #define IDM_BLIST_BUDDIES_JOINCHAT              40002
 #define IDM_BLIST_BUDDIES_ADDBUDDY              40003
 #define IDM_BLIST_VIEW_SHOWOFFLINE              40004
+#define IDM_BLIST_BUDDIES_IM                    40005
 
 #define IDM_BLIST_CONTEXT                       1002
 #define IDM_BLIST_CONTEXT_ACTIVATE              40201
============================================================
--- vulture/vulture-res.rc	bc931f38035e52858dcc2f5176d3d69d3f5e885c
+++ vulture/vulture-res.rc	70b1a3c32c4a1337e3d15ad6e19963857ca9e0b7
@@ -16,6 +16,7 @@ IDM_BLIST MENU
 {
     POPUP "&Buddies"
     {
+        MENUITEM "Send &IM...\tCtrl+M", IDM_BLIST_BUDDIES_IM
         MENUITEM "&Join Chat...\tCtrl+J", IDM_BLIST_BUDDIES_JOINCHAT
         MENUITEM SEPARATOR
 	MENUITEM "&Add Buddy...\tCtrl+B", IDM_BLIST_BUDDIES_ADDBUDDY
@@ -206,6 +207,24 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 
 
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDD_IMBUDDY DIALOG 0, 0, 204, 102
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
+CAPTION "Send IM"
+FONT 8, "Ms Shell Dlg"
+{
+    DEFPUSHBUTTON   "OK", IDOK, 95, 85, 50, 14, BS_DEFPUSHBUTTON
+    PUSHBUTTON      "Cancel", IDCANCEL, 150, 85, 50, 14, BS_PUSHBUTTON
+    LTEXT           "Please choose an account, and then enter the details of the buddy that you would like to send a message to.", 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        "Buddy Details", IDC_STATIC, 5, 50, 195, 28
+    LTEXT           "&Username:", IDC_STATIC, 15, 62, 50, 10, SS_LEFT
+    EDITTEXT        IDC_EDIT_USERNAME, 75, 60, 120, 12, ES_AUTOHSCROLL
+}
+
+
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDD_JOINCHAT 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 "Join Chat"
@@ -263,6 +282,7 @@ IDR_ACCEL_MAIN ACCELERATORS
     "A",            IDM_BLIST_ACCOUNTS_MANAGE, VIRTKEY, CONTROL
     "J",            IDM_BLIST_BUDDIES_JOINCHAT, VIRTKEY, CONTROL
     "B",            IDM_BLIST_BUDDIES_ADDBUDDY, VIRTKEY, CONTROL
+    "M",            IDM_BLIST_BUDDIES_IM, VIRTKEY, CONTROL
 }
 
 
============================================================
--- vulture/vultureblist.c	e24f15cb3f37daf5b8516e8465bdad090a87b35c
+++ vulture/vultureblist.c	e23d4f0587903da7e9823a533ba85d4fa5ffcf4d
@@ -189,6 +189,21 @@ static LRESULT CALLBACK MainWndProc(HWND
 	case WM_COMMAND:
 		switch(LOWORD(wParam))
 		{
+		case IDM_BLIST_BUDDIES_IM:
+			{
+				VULTURE_ADD_BUDDY_DATA vabd;
+
+				vabd.bIMFieldsOnly = TRUE;
+
+				if(VultureAddBuddyDlg(hwnd, &vabd))
+				{
+					VultureSingleSyncPurpleCall(PC_STARTIM, &vabd);
+					ProcHeapFree(vabd.szUsername);
+				}
+			}
+
+			return 0;
+
 		case IDM_BLIST_BUDDIES_JOINCHAT:
 			{
 				VULTURE_JOIN_CHAT_DATA vjcd;
@@ -203,6 +218,8 @@ static LRESULT CALLBACK MainWndProc(HWND
 			{
 				VULTURE_ADD_BUDDY_DATA vabd;
 
+				vabd.bIMFieldsOnly = FALSE;
+
 				if(VultureAddBuddyDlg(hwnd, &vabd))
 				{
 					VultureSingleSyncPurpleCall(PC_ADDBUDDY, &vabd);
============================================================
--- vulture/vulturedlg.c	0cc97b3baf63bbff30e6c33f590187c14e0836ef
+++ vulture/vulturedlg.c	5519d48858ed8738b56cacf098fe90bbc661a57a
@@ -498,16 +498,18 @@ static void AutoEnableJoinDlgOKButton(HW
 
 
 /**
- * Displays the "Add Buddy" dialogue.
+ * Displays either the "Add Buddy" or the "Send IM" dialogue.
  *
- * @param	hwndParent	Parent window handle.
- * @param[out]	lpvabd		Details of buddy to add are returned here.
+ * @param		hwndParent	Parent window handle.
+ * @param[in/out]	lpvabd		Details of buddy to add are returned
+ *					here, and bIMFieldsOnly determines
+ *					which flavour of dialogue to show.
  *
  * @return TRUE iff OKed.
  */
 BOOL VultureAddBuddyDlg(HWND hwndParent, VULTURE_ADD_BUDDY_DATA *lpvabd)
 {
-	return (BOOL)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_ADDBUDDY), hwndParent, AddBuddyDlgProc, (LPARAM)lpvabd);
+	return (BOOL)DialogBoxParam(g_hInstance, MAKEINTRESOURCE(lpvabd->bIMFieldsOnly ? IDD_IMBUDDY : IDD_ADDBUDDY), hwndParent, AddBuddyDlgProc, (LPARAM)lpvabd);
 }
 
 
@@ -547,13 +549,16 @@ static INT_PTR CALLBACK AddBuddyDlgProc(
 			if(SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_GETCOUNT, 0, 0) > 0)
 				SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CB_SETCURSEL, 0, 0);
 
-			/* Get all groups. */
-			VultureSingleSyncPurpleCall(PC_GETGROUPS, &s_lpglistGroups);
+			if(!s_lpvabd->bIMFieldsOnly)
+			{
+				/* Get all groups. */
+				VultureSingleSyncPurpleCall(PC_GETGROUPS, &s_lpglistGroups);
 
-			/* Populate combo and select first item. */
-			PopulateGroupsCombo(GetDlgItem(hwndDlg, IDC_CBEX_GROUP), s_lpglistGroups);
-			if(SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_GETCOUNT, 0, 0) > 0)
-				SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_SETCURSEL, 0, 0);
+				/* Populate combo and select first item. */
+				PopulateGroupsCombo(GetDlgItem(hwndDlg, IDC_CBEX_GROUP), s_lpglistGroups);
+				if(SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_GETCOUNT, 0, 0) > 0)
+					SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_SETCURSEL, 0, 0);
+			}
 
 			AutoEnableBuddyDlgOKButton(hwndDlg);
 		}
@@ -581,27 +586,31 @@ static INT_PTR CALLBACK AddBuddyDlgProc(
 				SendDlgItemMessage(hwndDlg, IDC_CBEX_ACCOUNTS, CBEM_GETITEM, 0, (LPARAM)&cbexitem);
 				s_lpvabd->lppac = ((VULTURE_ACCOUNT*)cbexitem.lParam)->lppac;
 
-				/* Get the selected group. */
-				cbexitem.mask = CBEIF_LPARAM;
-				cbexitem.iItem = SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_GETCURSEL, 0, 0);
-				SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CBEM_GETITEM, 0, (LPARAM)&cbexitem);
-				s_lpvabd->lpvblistnodeGroup = (VULTURE_BLIST_NODE*)cbexitem.lParam;
-
-				if(s_lpvabd->lpvblistnodeGroup)
-					VultureBListNodeAddRef(s_lpvabd->lpvblistnodeGroup);
-
+				/* Get username. */
 				cch = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME)) + 1;
 				s_lpvabd->szUsername = ProcHeapAlloc(cch * sizeof(TCHAR));
 				GetDlgItemText(hwndDlg, IDC_EDIT_USERNAME, s_lpvabd->szUsername, cch);
 
-				cch = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EDIT_ALIAS)) + 1;
-				if(cch > 1)
+				if(!s_lpvabd->bIMFieldsOnly)
 				{
-					s_lpvabd->szAlias = ProcHeapAlloc(cch * sizeof(TCHAR));
-					GetDlgItemText(hwndDlg, IDC_EDIT_ALIAS, s_lpvabd->szAlias, cch);
+					/* Get the selected group. */
+					cbexitem.mask = CBEIF_LPARAM;
+					cbexitem.iItem = SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CB_GETCURSEL, 0, 0);
+					SendDlgItemMessage(hwndDlg, IDC_CBEX_GROUP, CBEM_GETITEM, 0, (LPARAM)&cbexitem);
+					s_lpvabd->lpvblistnodeGroup = (VULTURE_BLIST_NODE*)cbexitem.lParam;
+
+					if(s_lpvabd->lpvblistnodeGroup)
+						VultureBListNodeAddRef(s_lpvabd->lpvblistnodeGroup);
+
+					cch = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EDIT_ALIAS)) + 1;
+					if(cch > 1)
+					{
+						s_lpvabd->szAlias = ProcHeapAlloc(cch * sizeof(TCHAR));
+						GetDlgItemText(hwndDlg, IDC_EDIT_ALIAS, s_lpvabd->szAlias, cch);
+					}
+					else
+						s_lpvabd->szAlias = NULL;
 				}
-				else
-					s_lpvabd->szAlias = NULL;
 
 				EndDialog(hwndDlg, TRUE);
 			}


More information about the Commits mailing list