soc.2009.vulture: 1f9866f6: Add group.

gdick at soc.pidgin.im gdick at soc.pidgin.im
Fri Aug 7 11:50:34 EDT 2009


-----------------------------------------------------------------
Revision: 1f9866f6cd14c20dd890dcb8b2ee9f26bdb5136c
Ancestor: aa81614fd6d530b0fece3cd164cdb3c9fc166f9d
Author: gdick at soc.pidgin.im
Date: 2009-08-07T15:28:24
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/1f9866f6cd14c20dd890dcb8b2ee9f26bdb5136c

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

ChangeLog: 

Add group.

-------------- next part --------------
============================================================
--- vulture/purpleblist.c	091ff8010aaff5882703a34ec62b6fae492cd047
+++ vulture/purpleblist.c	6bd9c74ef96d9ca45744b633b664feaca88afd87
@@ -853,3 +853,24 @@ void PurpleAddChat(VULTURE_JOIN_CHAT_DAT
 
 	if(szAliasUTF8) g_free(szAliasUTF8);
 }
+
+
+/**
+ * Adds a group.
+ *
+ * @param	szGroup		Name of new group.
+ */
+void PurpleAddGroup(LPTSTR szGroup)
+{
+	PurpleGroup *lpgroup;
+	gchar *szGroupUTF8;
+
+	szGroupUTF8 = VultureTCHARToUTF8(szGroup);
+
+	lpgroup = purple_group_new(szGroupUTF8);
+	purple_blist_add_group(lpgroup, NULL);
+
+	PurpleBlistUpdateNode(purple_get_blist(), (PurpleBlistNode*)lpgroup);
+
+	if(szGroupUTF8) g_free(szGroupUTF8);
+}
============================================================
--- vulture/purpleblist.h	6beb850d71dec31ef09be3aeb6ac34c0671443ac
+++ vulture/purpleblist.h	76b62c45b8c961e4ded167979bb30f245a79c6d7
@@ -70,6 +70,7 @@ void PurpleAddChat(VULTURE_JOIN_CHAT_DAT
 void PurpleAddBuddy(VULTURE_ADD_BUDDY_DATA *lpvabd);
 void PurpleBlistUpdateLeaves(PurpleBlistNode *lpbln);
 void PurpleAddChat(VULTURE_JOIN_CHAT_DATA *lpvjcd);
+void PurpleAddGroup(LPTSTR szGroup);
 
 
 static INLINE void VultureBListNodeAddRef(VULTURE_BLIST_NODE *lpvblnode) { InterlockedIncrement(&lpvblnode->lRefCount); }
============================================================
--- vulture/purplequeue.c	ea7a36f63513e76af10eab4dbb4a7aff43ec1f20
+++ vulture/purplequeue.c	13b19a79a65e5e88917e3e36964fafba7e6aed94
@@ -434,6 +434,10 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleAddChat(lppurplecall->lpvParam);
 		break;
 
+	case PC_ADDGROUP:
+		PurpleAddGroup(lppurplecall->lpvParam);
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h	ff807e3379db58b671c5c66c27ecb8bbb1a8fad8
+++ vulture/purplequeue.h	1ae1750c146a3d98504655978f404e67afe00b2d
@@ -126,6 +126,9 @@ enum PURPLE_CALL_ID
 
 	/* (VULTURE_JOIN_CHAT_DATA*) */
 	PC_ADDCHAT,
+
+	/* (LPTSTR) Group name. */
+	PC_ADDGROUP,
 };
 
 
============================================================
--- vulture/resource.h	dc4f54bfcacacd7ade09e6779362988272d3c0b4
+++ vulture/resource.h	fab2185970d7d6b03cac2ee0703db2514dad5a80
@@ -23,6 +23,7 @@
 #define IDC_EDIT_USERNAME                       1019
 #define IDC_EDIT_ALIAS                          1020
 #define IDC_CBEX_GROUP                          1021
+#define IDC_EDIT_STRING                         1022
 
 
 #define IDD_ACCOUNTS                            101
@@ -35,6 +36,7 @@
 #define IDD_ADDBUDDY                            108
 #define IDD_IMBUDDY                             109
 #define IDD_ADDCHAT                             110
+#define IDD_ADDGROUP                            111
 
 
 #define IDM_BLIST                               1001
@@ -45,6 +47,7 @@
 #define IDM_BLIST_VIEW_SHOWOFFLINE              40004
 #define IDM_BLIST_BUDDIES_IM                    40005
 #define IDM_BLIST_BUDDIES_ADDCHAT               40006
+#define IDM_BLIST_BUDDIES_ADDGROUP              40007
 
 #define IDM_BLIST_CONTEXT                       1002
 #define IDM_BLIST_CONTEXT_ACTIVATE              40201
============================================================
--- vulture/vulture-res.rc	274fd2bb26fc393827c0d5087e4ea3542fff9b9f
+++ vulture/vulture-res.rc	0fb055b9365ed4e304183ec998a80dde3de5cc17
@@ -19,8 +19,9 @@ IDM_BLIST MENU
         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
-	MENUITEM "&Add Chat...", IDM_BLIST_BUDDIES_ADDCHAT
+	MENUITEM "Add &Buddy...\tCtrl+B", IDM_BLIST_BUDDIES_ADDBUDDY
+	MENUITEM "Add &Chat...", IDM_BLIST_BUDDIES_ADDCHAT
+	MENUITEM "Add &Group...", IDM_BLIST_BUDDIES_ADDGROUP
 	MENUITEM SEPARATOR
         MENUITEM "&Close", IDM_BLIST_BUDDIES_CLOSE
     }
@@ -178,6 +179,21 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 
 
 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+IDD_ADDGROUP DIALOG 0, 0, 204, 67
+STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_POPUP | WS_SYSMENU
+CAPTION "Add Buddy"
+FONT 8, "Ms Shell Dlg"
+{
+    DEFPUSHBUTTON   "OK", IDOK, 95, 48, 50, 14, BS_DEFPUSHBUTTON
+    PUSHBUTTON      "Cancel", IDCANCEL, 150, 48, 50, 14, BS_PUSHBUTTON
+    LTEXT           "Please enter the title for the new group.", IDC_STATIC, 5, 5, 195, 20, SS_LEFT
+    LTEXT           "&Title:", IDC_STATIC, 5, 32, 35, 10, SS_LEFT
+    EDITTEXT        IDC_EDIT_STRING, 45, 30, 155, 12, ES_AUTOHSCROLL
+}
+
+
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
 IDD_BLIST DIALOG 0, 0, 186, 95
 STYLE DS_3DLOOK | DS_CENTER | DS_CONTROL | DS_SHELLFONT | WS_VISIBLE | WS_CHILDWINDOW
 FONT 8, "Ms Shell Dlg"
============================================================
--- vulture/vultureblist.c	5cd64e9ac792a62246efcc8c29754c3e9bd4f219
+++ vulture/vultureblist.c	8e99ff6d48302ae66cd330c3d5dbfd5a7a7e03c6
@@ -257,6 +257,20 @@ static LRESULT CALLBACK MainWndProc(HWND
 
 			return 0;
 
+		case IDM_BLIST_BUDDIES_ADDGROUP:
+			{
+				LPTSTR szGroup;
+
+				if((szGroup = VultureAddGroupDlg(hwnd)))
+				{
+					VultureSingleSyncPurpleCall(PC_ADDGROUP, szGroup);
+
+					ProcHeapFree(szGroup);
+				}
+			}
+
+			return 0;
+
 		case IDM_BLIST_BUDDIES_CLOSE:
 			SendMessage(hwnd, WM_CLOSE, 0, 0);
 			return 0;
============================================================
--- vulture/vulturedlg.c	858951246d56058caea824676dbccdd32b9bcad7
+++ vulture/vulturedlg.c	1c4c19b6dffeed35a510fa52f1de19bce04e9b88
@@ -41,7 +41,13 @@ typedef struct _JOIN_DLG_FIELD
 	BOOL	bIsInt, bRequired;
 } JOIN_DLG_FIELD;
 
+typedef struct _VULTURE_GET_STRING_DLG_DATA
+{
+	LPTSTR	sz;
+	BOOL	bAllowBlank;
+} VULTURE_GET_STRING_DLG_DATA;
 
+
 /* Dialogue co-ordinates for the join-chat fields. */
 #define X_JC_LABEL		15
 #define X_JC_EDIT		75
@@ -68,6 +74,7 @@ static void PopulateGroupsCombo(HWND hwn
 static INT_PTR CALLBACK AddBuddyDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static void AutoEnableBuddyDlgOKButton(HWND hwndDlg);
 static void PopulateGroupsCombo(HWND hwndCBEx, GList *lpglistGroups);
+static INT_PTR CALLBACK GetStringDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 
 
 /**
@@ -729,3 +736,100 @@ static void PopulateGroupsCombo(HWND hwn
 		}
 	}
 }
+
+
+/**
+ * Displays either the "Add Buddy" or the "Send IM" dialogue.
+ *
+ * @param		hwndParent	Parent window handle.
+ *
+ * @return Pointer to string (which should be ProcHeapFree()d, or NULL if
+ * cancelled.
+ */
+LPTSTR VultureAddGroupDlg(HWND hwndParent)
+{
+	VULTURE_GET_STRING_DLG_DATA vgsdd;
+	vgsdd.bAllowBlank = FALSE;
+
+	return DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_ADDGROUP), hwndParent, GetStringDlgProc, (LPARAM)&vgsdd) ?
+		vgsdd.sz :
+		NULL;
+}
+
+
+/**
+ * Dialogue procedure for dialogues retrieving one string only.
+ *
+ * @param	hwndDlg		Dialogue window handle.
+ * @param	uiMsg		Message ID.
+ * @param	wParam		Message-specific.
+ * @param	lParam		Message-specific.
+ *
+ * @return Usually TRUE if message processed and FALSE otherwise. There are
+ * some exceptions for particular messages.
+ */
+static INT_PTR CALLBACK GetStringDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+{
+	VULTURE_GET_STRING_DLG_DATA *lpvgsdd;
+
+	switch(uiMsg)
+	{
+	case WM_INITDIALOG:
+		lpvgsdd = (VULTURE_GET_STRING_DLG_DATA*)lParam;
+		SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+
+		if(!lpvgsdd->bAllowBlank)
+			EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
+
+		/* Let the system set the focus. */
+		return TRUE;
+
+	case WM_COMMAND:
+		
+		switch(LOWORD(wParam))
+		{
+		case IDC_EDIT_STRING:
+			lpvgsdd = (VULTURE_GET_STRING_DLG_DATA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+			if(HIWORD(wParam) == EN_CHANGE && !lpvgsdd->bAllowBlank)
+			{
+				HWND hwndOK = GetDlgItem(hwndDlg, IDOK);
+
+				if(GetWindowTextLength((HWND)lParam) == 0)
+				{
+					/* Don't leave the focus on a disabled control. */
+					if(GetFocus() == hwndOK)
+						SendMessage(hwndDlg, WM_NEXTDLGCTL, 0, 0);
+
+					EnableWindow(hwndOK, FALSE);
+				}
+				else
+					EnableWindow(hwndOK, TRUE);
+			}
+			break;
+
+		case IDOK:
+			{
+				int cch;
+
+				lpvgsdd = (VULTURE_GET_STRING_DLG_DATA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+				/* Get username. */
+				cch = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_EDIT_STRING)) + 1;
+				lpvgsdd->sz = ProcHeapAlloc(cch * sizeof(TCHAR));
+				GetDlgItemText(hwndDlg, IDC_EDIT_STRING, lpvgsdd->sz, cch);
+
+				EndDialog(hwndDlg, TRUE);
+			}
+
+			return TRUE;
+
+		case IDCANCEL:
+			EndDialog(hwndDlg, FALSE);
+			return TRUE;
+		}
+
+		break;
+	}
+
+	return FALSE;
+}
============================================================
--- vulture/vulturedlg.h	ab03d3af54670d9b3ddff21fd24bbeaa623bd67d
+++ vulture/vulturedlg.h	f002bbc6c672723a24a351a9067fdacb5bf01ec5
@@ -42,6 +42,7 @@ BOOL VultureAddBuddyDlg(HWND hwndParent,
 
 BOOL VultureJoinChatDlg(HWND hwndParent, VULTURE_JOIN_CHAT_DATA *lpvjcd);
 BOOL VultureAddBuddyDlg(HWND hwndParent, VULTURE_ADD_BUDDY_DATA *lpvabd);
+LPTSTR VultureAddGroupDlg(HWND hwndParent);
 
 
 #endif


More information about the Commits mailing list