soc.2009.vulture: 1c3a0415: Show interlocutor's status message in IM...
gdick at soc.pidgin.im
gdick at soc.pidgin.im
Sat Jun 27 15:50:41 EDT 2009
-----------------------------------------------------------------
Revision: 1c3a0415d676084c623d12c2e6454f3b1a0f0974
Ancestor: 9e1224372ee566c97b3c46352accbcee1702e309
Author: gdick at soc.pidgin.im
Date: 2009-06-27T19:44:24
Branch: im.pidgin.soc.2009.vulture
URL: http://d.pidgin.im/viewmtn/revision/info/1c3a0415d676084c623d12c2e6454f3b1a0f0974
Modified files:
vulture/purpleblist.c vulture/purpleblist.h
vulture/purpleconv.c vulture/purpleconv.h
vulture/purplequeue.c vulture/purplequeue.h
vulture/vultureblist.h vulture/vultureconv.c
vulture/vultureconv.h
ChangeLog:
Show interlocutor's status message in IM windows at initialisation.
-------------- next part --------------
============================================================
--- vulture/purpleblist.c d5ba7b569dbe333f7cec2bdb728fd9aa593c3de0
+++ vulture/purpleblist.c be2723a66ead46fea82a18710a4c929d20d371e3
@@ -242,3 +242,30 @@ void PurpleBListNodeDoubleClicked(VULTUR
purple_conversation_new(PURPLE_CONV_TYPE_IM, lpbuddy->account, lpbuddy->name);
}
}
+
+
+/**
+ * Retrieves a buddy's status text. Adapted from pidgin_blist_get_name_markup.
+ *
+ * @param lpbuddy Buddy.
+ */
+LPTSTR PurpleBuddyGetStatusText(PurpleBuddy *lpbuddy)
+{
+ PurplePlugin *lppluginPrpl;
+
+ /* Find prpl for buddy. */
+ if((lppluginPrpl = purple_find_prpl(purple_account_get_protocol_id(lpbuddy->account))))
+ {
+ PurplePluginProtocolInfo *lpprplinfo = PURPLE_PLUGIN_PROTOCOL_INFO(lppluginPrpl);
+
+ /* If prpl supports status text, get the text. */
+ if(lpprplinfo && lpprplinfo->status_text)
+ {
+ char *szStatus = lpprplinfo->status_text(lpbuddy);
+
+ return szStatus ? VultureUTF8ToTCHAR(szStatus) : NULL;
+ }
+ }
+
+ return NULL;
+}
============================================================
--- vulture/purpleblist.h fbda4cdf6dedd4b37c00831b80d6f7d50683e308
+++ vulture/purpleblist.h 6eceabbc34b41174cecb6563cdb8e15376fa4612
@@ -47,6 +47,7 @@ void PurpleBListNodeDoubleClicked(VULTUR
void PurpleBlistRemoveNode(PurpleBuddyList *lpbuddylist, PurpleBlistNode *lpblistnode);
void VultureBListNodeRelease(VULTURE_BLIST_NODE *lpvblnode);
void PurpleBListNodeDoubleClicked(VULTURE_BLIST_NODE *lpvbn);
+LPTSTR PurpleBuddyGetStatusText(PurpleBuddy *lpbuddy);
static INLINE void VultureBListNodeAddRef(VULTURE_BLIST_NODE *lpvblnode) { InterlockedIncrement(&lpvblnode->lRefCount); }
============================================================
--- vulture/purpleconv.c 5cb9b21b81293a59ed8af905e0fab29b9ddb886a
+++ vulture/purpleconv.c 5a2cc55104ce3db91c5d8939de31401188d60a3f
@@ -29,6 +29,7 @@
#include "purpleconv.h"
#include "vultureconv.h"
#include "purplemain.h"
+#include "purpleblist.h"
@@ -171,10 +172,28 @@ void PurpleConvChanged(PurpleConversatio
* 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);
+ const char *szTitle;
+
+ if(!lpconv)
+ return NULL;
+
+ szTitle = purple_conversation_get_title(lpconv);
return szTitle ? VultureUTF8ToTCHAR(szTitle) : NULL;
}
+
+
+/**
+ * Gets the status message of our interlocutor in an IM window.
+ *
+ * @param lpconv Conversation.
+ */
+LPTSTR PurpleIMGetStatusText(PurpleConversation *lpconv)
+{
+ if(!lpconv || lpconv->type != PURPLE_CONV_TYPE_IM)
+ return NULL;
+
+ return PurpleBuddyGetStatusText(purple_find_buddy(lpconv->account, lpconv->name));
+}
============================================================
--- vulture/purpleconv.h 890fc611c423d8f83f12e38ca0abe228530d5903
+++ vulture/purpleconv.h 4c41ac97acf8ccd812df3e714c39922bf1e849d8
@@ -35,6 +35,7 @@ LPTSTR PurpleConvGetTitle(PurpleConversa
void PurpleConversationSend(VULTURE_CONV_SEND *lpvcsend);
void PurpleConvChanged(PurpleConversation *lpconv, PurpleConvUpdateType pcut);
LPTSTR PurpleConvGetTitle(PurpleConversation *lpconv);
+LPTSTR PurpleIMGetStatusText(PurpleConversation *lpconv);
#endif
============================================================
--- vulture/purplequeue.c f39856088cba59183a7c3711f31606028e8ebc24
+++ vulture/purplequeue.c da8c62004b726dbb3028ec5dcc4e9b0cc7b3d440
@@ -31,6 +31,7 @@
#include "vultureconv.h"
#include "purpleconv.h"
#include "purpleblist.h"
+#include "vultureblist.h"
/** Queue node representing a libpurple call. */
@@ -214,12 +215,20 @@ static void DispatchPurpleCall(PURPLE_CA
case PC_CONVGETTITLE:
{
- VULTURE_CONV_GET_TITLE *lpvcgt = (VULTURE_CONV_GET_TITLE*)lppurplecall->lpvParam;
- lpvcgt->szTitle = PurpleConvGetTitle(lpvcgt->lpvconv->lpconv);
+ VULTURE_CONV_GET_STRING *lpvcgetstr = (VULTURE_CONV_GET_STRING*)lppurplecall->lpvParam;
+ lpvcgetstr->sz = PurpleConvGetTitle(lpvcgetstr->lpvconv->lpconv);
}
break;
+ case PC_IMGETSTATUSMSG:
+ {
+ VULTURE_CONV_GET_STRING *lpvcgetstr = (VULTURE_CONV_GET_STRING*)lppurplecall->lpvParam;
+ lpvcgetstr->sz = PurpleIMGetStatusText(lpvcgetstr->lpvconv->lpconv);
+ }
+
+ break;
+
case PC_QUIT:
purple_core_quit();
g_main_loop_quit(g_lpgmainloop);
============================================================
--- vulture/purplequeue.h 67759c5f437e50fa4eb74d843567f34d2987f5fc
+++ vulture/purplequeue.h 08bd96f669fc6b7148f30e61ea0dcb0ae74b83fd
@@ -66,8 +66,8 @@ enum PURPLE_CALL_ID
/* (VULTURE_CONV_GET_TITLE*) */
PC_CONVGETTITLE,
- /* (VULTURE_BUDDY_GET_STATUS_MSG*) */
- PC_BUDDYGETSTATUSMSG,
+ /* (VULTURE_IM_GET_STATUS_MSG*) */
+ PC_IMGETSTATUSMSG,
};
============================================================
--- vulture/vultureblist.h 79de054c320b98101b3000cfca9c785a427243e1
+++ vulture/vultureblist.h 26df72aa0a31dbec27875c5f54c8ff7c2d9a7ef2
@@ -24,6 +24,7 @@
#define _VULTURE_VULTUREBLIST_H_
#include <windows.h>
+#include <glib.h>
extern HWND g_hwndMain;
============================================================
--- vulture/vultureconv.c c8e10dad505196c14a2cc38c39b92a8fe1908906
+++ vulture/vultureconv.c 4e0de7f9f4a408d0691fb6ef519b558f86f8075a
@@ -154,7 +154,6 @@ 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;
@@ -165,23 +164,16 @@ static LRESULT CALLBACK ConvContainerWnd
lpvconv->iTabIndex = TabCtrl_InsertItem(hwndTabs, TabCtrl_GetItemCount(hwndTabs), &tcitem);
/* Create conversation dialogue. It is
- * initially disabled and hidden.
+ * initially disabled and hidden. The window
+ * handle is saved by the dialogue procedure.
*/
if(lpvconv->convtype == PURPLE_CONV_TYPE_IM)
- lpvconv->hwndConv = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_IM), hwndTabs, IMDlgProc, (LPARAM)lpvconv);
+ CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_IM), hwndTabs, IMDlgProc, (LPARAM)lpvconv);
else
- lpvconv->hwndConv = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CHAT), hwndTabs, ChatDlgProc, (LPARAM)lpvconv);
+ CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_CHAT), hwndTabs, ChatDlgProc, (LPARAM)lpvconv);
SetWindowPos(lpvconv->hwndConv, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
- /* Set the title, both of the tab and in the
- * conversation window itself.
- */
- vcgt.lpvconv = lpvconv;
- VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgt);
- SetConvTitle(lpvconv, hwndTabs, vcgt.szTitle ? vcgt.szTitle : TEXT(""));
- if(vcgt.szTitle) g_free(vcgt.szTitle);
-
/* Only strictly necessary if we're the only
* tab.
*/
@@ -228,12 +220,12 @@ static LRESULT CALLBACK ConvContainerWnd
{
case PURPLE_CONV_UPDATE_TITLE:
{
- VULTURE_CONV_GET_TITLE vcgt;
+ VULTURE_CONV_GET_STRING vcgetstring;
- vcgt.lpvconv = lpvcchanged->lpvconv;
- VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgt);
- SetConvTitle(lpvcchanged->lpvconv, hwndTabs, vcgt.szTitle ? vcgt.szTitle : TEXT(""));
- if(vcgt.szTitle) g_free(vcgt.szTitle);
+ vcgetstring.lpvconv = lpvcchanged->lpvconv;
+ VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgetstring);
+ SetConvTitle(lpvcchanged->lpvconv, hwndTabs, vcgetstring.sz ? vcgetstring.sz : TEXT(""));
+ if(vcgetstring.sz) g_free(vcgetstring.sz);
}
break;
@@ -415,6 +407,22 @@ static INT_PTR CALLBACK IMDlgProc(HWND h
*/
static INT_PTR CALLBACK IMDlgProc(HWND hwndDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
+ switch(uiMsg)
+ {
+ case WM_INITDIALOG:
+ {
+ VULTURE_CONV_GET_STRING vcgetstring;
+
+ /* Set the status text. */
+ vcgetstring.lpvconv = (VULTURE_CONVERSATION*)lParam;
+ VultureSingleSyncPurpleCall(PC_IMGETSTATUSMSG, &vcgetstring);
+ SetDlgItemText(hwndDlg, IDC_STATIC_STATUS, vcgetstring.sz ? vcgetstring.sz : TEXT(""));
+ if(vcgetstring.sz) g_free(vcgetstring.sz);
+ }
+
+ break;
+ }
+
return ConvCommonDlgProc(hwndDlg, uiMsg, wParam, lParam);
}
@@ -456,15 +464,32 @@ static INT_PTR CALLBACK ConvCommonDlgPro
{
case WM_INITDIALOG:
{
+ CONVCONTAINERDATA *lpccd;
HWND hwndREInput = GetDlgItem(hwndDlg, IDC_RICHEDIT_INPUT);
+ VULTURE_CONV_GET_STRING vcgetstring;
+ HWND hwndTabs;
/* Remember the conversation. */
lpvconv = (VULTURE_CONVERSATION*)lParam;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ lpvconv->hwndConv = hwndDlg;
+
+ /* Parent data. */
+ lpccd = (CONVCONTAINERDATA*)GetWindowLongPtr(lpvconv->hwndContainer, GWLP_USERDATA);
+ hwndTabs = GetDlgItem(lpccd->hwndTabDlg, IDC_TAB_CONVERSATIONS);
+
/* Subclass the input box. */
lpvconv->wndprocInputOrig = (WNDPROC)GetWindowLongPtr(hwndREInput, GWLP_WNDPROC);
SetWindowLongPtr(hwndREInput, GWLP_WNDPROC, (LONG)InputBoxSubclassProc);
+
+ /* Set the title, both of the tab and in the
+ * conversation window itself.
+ */
+ vcgetstring.lpvconv = lpvconv;
+ VultureSingleSyncPurpleCall(PC_CONVGETTITLE, &vcgetstring);
+ SetConvTitle(lpvconv, hwndTabs, vcgetstring.sz ? vcgetstring.sz : TEXT(""));
+ if(vcgetstring.sz) g_free(vcgetstring.sz);
}
/* Let the system set the focus. */
============================================================
--- vulture/vultureconv.h 43e0ef9a2f91e4cfd623add63708bdcfd569cf40
+++ vulture/vultureconv.h aaba7f14efa54acc0bb5e7abc1bafbca41df31b0
@@ -60,11 +60,11 @@ typedef struct _VULTURE_CONV_CHANGED
PurpleConvUpdateType pcut;
} VULTURE_CONV_CHANGED;
-typedef struct _VULTURE_CONV_GET_TITLE
+typedef struct _VULTURE_CONV_GET_STRING
{
VULTURE_CONVERSATION *lpvconv;
- LPTSTR szTitle;
-} VULTURE_CONV_GET_TITLE;
+ LPTSTR sz;
+} VULTURE_CONV_GET_STRING;
int VultureRegisterConvContainerWindowClass(void);
More information about the Commits
mailing list