soc.2009.vulture: cba56919: Rejig way in which conversation titles a...

gdick at soc.pidgin.im gdick at soc.pidgin.im
Fri Jun 26 16:30:42 EDT 2009


-----------------------------------------------------------------
Revision: cba56919e816168a252fcdc98658d81d7e487987
Ancestor: 683563250dd038a8184e51dbf1e1da58a51841d3
Author: gdick at soc.pidgin.im
Date: 2009-06-26T14:46:25
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/cba56919e816168a252fcdc98658d81d7e487987

Modified files:
        vulture/purpleconv.c vulture/purpleconv.h
        vulture/purplequeue.c vulture/purplequeue.h
        vulture/vultureconv.c vulture/vultureconv.h

ChangeLog: 

Rejig way in which conversation titles are obtained.

-------------- next part --------------
============================================================
--- vulture/purpleconv.c	d5d5442d347a80a1f1c1f817bc9efc9446eaea84
+++ vulture/purpleconv.c	5cb9b21b81293a59ed8af905e0fab29b9ddb886a
@@ -53,9 +53,6 @@ void PurpleNewConversation(PurpleConvers
 	 */
 	lpvconv->convtype = lpconv->type;
 
-	InitializeCriticalSection(&lpvconv->sync.cs);
-	lpvconv->sync.szTitle = VultureUTF8ToTCHAR(purple_conversation_get_title(lpconv));
-
 	VulturePostUIMessage(g_hwndMain, VUIMSG_NEWCONVERSATION, lpvconv);
 }
 
@@ -68,8 +65,6 @@ void VultureFreeConversation(VULTURE_CON
  */
 void VultureFreeConversation(VULTURE_CONVERSATION *lpvconv)
 {
-	g_free(lpvconv->sync.szTitle);
-	DeleteCriticalSection(&lpvconv->sync.cs);
 	g_free(lpvconv);
 }
 
@@ -156,31 +151,30 @@ void PurpleConvChanged(PurpleConversatio
 void PurpleConvChanged(PurpleConversation *lpconv, PurpleConvUpdateType pcut)
 {
 	VULTURE_CONVERSATION *lpvconv = lpconv->ui_data;
+	VULTURE_CONV_CHANGED *lpvcchanged;
 
 	if(!lpvconv)
 		return;
 
-	EnterCriticalSection(&lpvconv->sync.cs);
-	{
-		switch(pcut)
-		{
-		case PURPLE_CONV_UPDATE_TITLE:
-			{
-				VULTURE_CONV_CHANGED *lpvcchanged = g_new(VULTURE_CONV_CHANGED, 1);
+	/* Forward the message to the UI. */
 
-				lpvcchanged->lpvconv = lpvconv;
-				lpvcchanged->pcut = pcut;
+	lpvcchanged = g_new(VULTURE_CONV_CHANGED, 1);
 
-				g_free(lpvconv->sync.szTitle);
-				lpvconv->sync.szTitle = VultureUTF8ToTCHAR(purple_conversation_get_title(lpconv));
-				VulturePostUIMessage(g_hwndMain, VUIMSG_CONVCHANGED, lpvcchanged);
-			}
+	lpvcchanged->lpvconv = lpvconv;
+	lpvcchanged->pcut = pcut;
 
-			break;
+	VulturePostUIMessage(g_hwndMain, VUIMSG_CONVCHANGED, lpvcchanged);
+}
 
-		default:
-			break;
-		}
-	}
-	LeaveCriticalSection(&lpvconv->sync.cs);
+
+/**
+ * Gets the title of a conversation.
+ *
+ * @param	lpconv	Conversation.
+ * @param	pcut	Type of change.
+ */
+LPTSTR PurpleConvGetTitle(PurpleConversation *lpconv)
+{
+	const char *szTitle = purple_conversation_get_title(lpconv);
+	return szTitle ? VultureUTF8ToTCHAR(szTitle) : NULL;
 }
============================================================
--- vulture/purpleconv.h	26ae44acd70bc7dd1051eaa4621a3c54ce118d04
+++ vulture/purpleconv.h	890fc611c423d8f83f12e38ca0abe228530d5903
@@ -34,6 +34,7 @@ void PurpleConvChanged(PurpleConversatio
 void VultureFreeConvWrite(VULTURE_CONV_WRITE *lpvcwrite);
 void PurpleConversationSend(VULTURE_CONV_SEND *lpvcsend);
 void PurpleConvChanged(PurpleConversation *lpconv, PurpleConvUpdateType pcut);
+LPTSTR PurpleConvGetTitle(PurpleConversation *lpconv);
 
 
 #endif
============================================================
--- vulture/purplequeue.c	bb128a7f3f9fe6c1904289573425bd77b5015295
+++ vulture/purplequeue.c	f39856088cba59183a7c3711f31606028e8ebc24
@@ -212,6 +212,14 @@ static void DispatchPurpleCall(PURPLE_CA
 		PurpleBListNodeDoubleClicked((VULTURE_BLIST_NODE*)lppurplecall->lpvParam);
 		break;
 
+	case PC_CONVGETTITLE:
+		{
+			VULTURE_CONV_GET_TITLE *lpvcgt = (VULTURE_CONV_GET_TITLE*)lppurplecall->lpvParam;
+			lpvcgt->szTitle = PurpleConvGetTitle(lpvcgt->lpvconv->lpconv);
+		}
+		
+		break;
+
 	case PC_QUIT:
 		purple_core_quit();
 		g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h	49db1f3aced7010812056bc9485184c8c6b15dbb
+++ vulture/purplequeue.h	67759c5f437e50fa4eb74d843567f34d2987f5fc
@@ -62,6 +62,12 @@ enum PURPLE_CALL_ID
 
 	/* (VULTURE_BLIST_NODE*) Node double-clicked.  */
 	PC_BLISTNODEDBLCLKED,
+
+	/* (VULTURE_CONV_GET_TITLE*) */
+	PC_CONVGETTITLE,
+
+	/* (VULTURE_BUDDY_GET_STATUS_MSG*) */
+	PC_BUDDYGETSTATUSMSG,
 };
 
 
============================================================
--- vulture/vultureconv.c	3f3f93ab3aee6f755c8d150126ccc5319ee65054
+++ vulture/vultureconv.c	de0dde4bf7380ff07939c3ad4318eb7c96ac711c
@@ -59,7 +59,7 @@ static void EnableAppropriateConvWindow(
 static void RepositionConvControls(HWND hwndConvDlg);
 static LRESULT CALLBACK InputBoxSubclassProc(HWND hwnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
 static void EnableAppropriateConvWindow(CONVCONTAINERDATA *lpccd);
-static void SetConvTitle(VULTURE_CONVERSATION *lpvconv, HWND hwndTabs);
+static void SetConvTitle(VULTURE_CONVERSATION *lpvconv, HWND hwndTabs, LPTSTR szTitle);
 
 
 /**
@@ -154,6 +154,7 @@ static LRESULT CALLBACK ConvContainerWnd
 				VULTURE_CONVERSATION *lpvconv = (VULTURE_CONVERSATION*)lParam;
 				TCITEM tcitem;
 				HWND hwndTabs = GetDlgItem(lpccd->hwndTabDlg, IDC_TAB_CONVERSATIONS);
+				VULTURE_CONV_GET_TITLE vcgt;
 
 				lpvconv->hwndContainer = hwnd;
 
@@ -176,7 +177,9 @@ static LRESULT CALLBACK ConvContainerWnd
 				/* Set the title, both of the tab and in the
 				 * conversation window itself.
 				 */
-				SetConvTitle(lpvconv, hwndTabs);
+				vcgt.lpvconv = lpvconv;
+				VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgt);
+				SetConvTitle(lpvconv, hwndTabs, vcgt.szTitle ? vcgt.szTitle : TEXT(""));
 
 				/* Only strictly necessary if we're the only
 				 * tab.
@@ -223,7 +226,14 @@ static LRESULT CALLBACK ConvContainerWnd
 				switch(lpvcchanged->pcut)
 				{
 				case PURPLE_CONV_UPDATE_TITLE:
-					SetConvTitle(lpvcchanged->lpvconv, hwndTabs);
+					{
+						VULTURE_CONV_GET_TITLE vcgt;
+
+						vcgt.lpvconv = lpvcchanged->lpvconv;
+						VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgt);
+						SetConvTitle(lpvcchanged->lpvconv, hwndTabs, vcgt.szTitle ? vcgt.szTitle : TEXT(""));
+					}
+
 					break;
 
 				default:
@@ -732,15 +742,14 @@ static void EnableAppropriateConvWindow(
  *
  * @param	lpvconv		Conversation.
  * @param	hwndTabs	Tab control.
+ * @param	szTitle		New title.
  */
-static void SetConvTitle(VULTURE_CONVERSATION *lpvconv, HWND hwndTabs)
+static void SetConvTitle(VULTURE_CONVERSATION *lpvconv, HWND hwndTabs, LPTSTR szTitle)
 {
 	TCITEM tcitem;
 
-	EnterCriticalSection(&lpvconv->sync.cs);
-		tcitem.mask = TCIF_TEXT;
-		tcitem.pszText = lpvconv->sync.szTitle;
-		TabCtrl_SetItem(hwndTabs, lpvconv->iTabIndex, &tcitem);
-		SetDlgItemText(lpvconv->hwndConv, IDC_STATIC_NAME, lpvconv->sync.szTitle);
-	LeaveCriticalSection(&lpvconv->sync.cs);
+	tcitem.mask = TCIF_TEXT;
+	tcitem.pszText = szTitle;
+	TabCtrl_SetItem(hwndTabs, lpvconv->iTabIndex, &tcitem);
+	SetDlgItemText(lpvconv->hwndConv, IDC_STATIC_NAME, szTitle);
 }
============================================================
--- vulture/vultureconv.h	91114c765e04be2345d238eb3fea303c8bbffb1e
+++ vulture/vultureconv.h	43e0ef9a2f91e4cfd623add63708bdcfd569cf40
@@ -37,13 +37,6 @@ typedef struct _VULTURE_CONVERSATION
 	int			iTabIndex;
 	WNDPROC			wndprocInputOrig;
 	PurpleConversationType	convtype;
-
-	/* Data still needed by the core thread after initialisation. */
-	struct
-	{
-		CRITICAL_SECTION	cs;
-		LPTSTR			szTitle;
-	} sync;
 } VULTURE_CONVERSATION;
 
 
@@ -67,7 +60,13 @@ typedef struct _VULTURE_CONV_CHANGED
 	PurpleConvUpdateType	pcut;
 } VULTURE_CONV_CHANGED;
 
+typedef struct _VULTURE_CONV_GET_TITLE
+{
+	VULTURE_CONVERSATION	*lpvconv;
+	LPTSTR			szTitle;
+} VULTURE_CONV_GET_TITLE;
 
+
 int VultureRegisterConvContainerWindowClass(void);
 HWND VultureCreateConvContainer(void);
 void VultureWriteConversation(VULTURE_CONV_WRITE *lpvcwrite);


More information about the Commits mailing list