summaryrefslogtreecommitdiff
path: root/src/core/stdaway
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-07-16 14:11:57 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-07-16 14:11:57 +0000
commit48078905d338193c13ad2e62c083a94419f4247d (patch)
tree94cf7e7fe8ea3239da8aafaec5155beff9ca9fa3 /src/core/stdaway
parent5c39998e831c982812d1a6c7b9747f695c4dbeef (diff)
fixes #742 (StdAway doesn't retrieve status messages from metas)
git-svn-id: http://svn.miranda-ng.org/main/trunk@9831 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core/stdaway')
-rw-r--r--src/core/stdaway/awaymsg.cpp129
-rw-r--r--src/core/stdaway/commonheaders.h1
2 files changed, 67 insertions, 63 deletions
diff --git a/src/core/stdaway/awaymsg.cpp b/src/core/stdaway/awaymsg.cpp
index bfdcc52ada..c9512ee944 100644
--- a/src/core/stdaway/awaymsg.cpp
+++ b/src/core/stdaway/awaymsg.cpp
@@ -34,53 +34,55 @@ struct AwayMsgDlgData {
HANDLE hSeq;
HANDLE hAwayMsgEvent;
};
+
#define HM_AWAYMSG (WM_USER+10)
+
static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch(message)
- {
- case WM_INITDIALOG:
- TranslateDialogDefault(hwndDlg);
- dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+ switch (message) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+ dat->hContact = db_mc_getMostOnline(lParam);
+ if (dat->hContact == NULL)
dat->hContact = lParam;
- dat->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG);
- dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0);
- WindowList_Add(hWindowList, hwndDlg, dat->hContact);
-
- {
- TCHAR str[256], format[128];
- TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
- char *szProto = GetContactProto(dat->hContact);
- WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE);
- TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0);
-
- GetWindowText(hwndDlg, format, SIZEOF(format));
- mir_sntprintf(str, SIZEOF(str), format, status, contactName);
- SetWindowText(hwndDlg, str);
-
- GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format));
- mir_sntprintf(str, SIZEOF(str), format, status);
- SetDlgItemText(hwndDlg, IDC_RETRIEVING, str);
-
- Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus);
- }
- if (dat->hSeq == NULL)
- {
- ACKDATA ack = {0};
- ack.cbSize = sizeof(ack);
- ack.hContact = dat->hContact;
- ack.type = ACKTYPE_AWAYMSG;
- ack.result = ACKRESULT_SUCCESS;
- SendMessage(hwndDlg, HM_AWAYMSG, 0, (LPARAM)&ack);
- }
- Utils_RestoreWindowPosition(hwndDlg, lParam, "SRAway", "AwayMsgDlg");
- return TRUE;
+ dat->hAwayMsgEvent = HookEventMessage(ME_PROTO_ACK, hwndDlg, HM_AWAYMSG);
+ dat->hSeq = (HANDLE)CallContactService(dat->hContact, PSS_GETAWAYMSG, 0, 0);
+ WindowList_Add(hWindowList, hwndDlg, dat->hContact);
+ {
+ TCHAR str[256], format[128];
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
+ char *szProto = GetContactProto(dat->hContact);
+ WORD dwStatus = db_get_w(dat->hContact, szProto, "Status", ID_STATUS_OFFLINE);
+ TCHAR *status = pcli->pfnGetStatusModeDescription(dwStatus, 0);
+
+ GetWindowText(hwndDlg, format, SIZEOF(format));
+ mir_sntprintf(str, SIZEOF(str), format, status, contactName);
+ SetWindowText(hwndDlg, str);
+
+ GetDlgItemText(hwndDlg, IDC_RETRIEVING, format, SIZEOF(format));
+ mir_sntprintf(str, SIZEOF(str), format, status);
+ SetDlgItemText(hwndDlg, IDC_RETRIEVING, str);
+
+ Window_SetProtoIcon_IcoLib(hwndDlg, szProto, dwStatus);
+ }
+
+ if (dat->hSeq == NULL) {
+ ACKDATA ack = { 0 };
+ ack.cbSize = sizeof(ack);
+ ack.hContact = dat->hContact;
+ ack.type = ACKTYPE_AWAYMSG;
+ ack.result = ACKRESULT_SUCCESS;
+ SendMessage(hwndDlg, HM_AWAYMSG, 0, (LPARAM)&ack);
+ }
+ Utils_RestoreWindowPosition(hwndDlg, lParam, "SRAway", "AwayMsgDlg");
+ return TRUE;
- case HM_AWAYMSG:
+ case HM_AWAYMSG:
{
ACKDATA *ack = (ACKDATA*)lParam;
if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break;
@@ -92,38 +94,36 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wP
ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW);
SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
- break;
}
+ break;
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case IDCANCEL:
- case IDOK:
- DestroyWindow(hwndDlg);
- break;
- }
- break;
-
- case WM_CLOSE:
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ case IDOK:
DestroyWindow(hwndDlg);
break;
-
- case WM_DESTROY:
- if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent);
- Utils_SaveWindowPosition(hwndDlg, dat->hContact, "SRAway", "AwayMsgDlg");
- WindowList_Remove(hWindowList, hwndDlg);
- Window_FreeIcon_IcoLib(hwndDlg);
- mir_free(dat);
- break;
+ }
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ if (dat->hAwayMsgEvent) UnhookEvent(dat->hAwayMsgEvent);
+ Utils_SaveWindowPosition(hwndDlg, dat->hContact, "SRAway", "AwayMsgDlg");
+ WindowList_Remove(hWindowList, hwndDlg);
+ Window_FreeIcon_IcoLib(hwndDlg);
+ mir_free(dat);
+ break;
}
return FALSE;
}
static INT_PTR GetMessageCommand(WPARAM wParam, LPARAM)
{
- HWND hwnd;
- if (hwnd = WindowList_Find(hWindowList, wParam)) {
+ if (HWND hwnd = WindowList_Find(hWindowList, wParam)) {
SetForegroundWindow(hwnd);
SetFocus(hwnd);
}
@@ -141,7 +141,7 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM)
if (szProto != NULL) {
int chatRoom = szProto ? db_get_b(hContact, szProto, "ChatRoom", 0) : 0;
- if ( !chatRoom) {
+ if (!chatRoom) {
int status = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
mir_sntprintf(str, SIZEOF(str), TranslateT("Re&ad %s message"), pcli->pfnGetStatusModeDescription(status, 0));
mi.ptszName = str;
@@ -149,7 +149,10 @@ static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM)
if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(status)) {
mi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_NOTOFFLINE | CMIM_ICON | CMIF_TCHAR;
mi.hIcon = LoadSkinProtoIcon(szProto, status);
- } } } }
+ }
+ }
+ }
+ }
Menu_ModifyItem(hAwayMsgMenuItem, &mi);
IcoLib_ReleaseIcon(mi.hIcon, 0);
diff --git a/src/core/stdaway/commonheaders.h b/src/core/stdaway/commonheaders.h
index d067e7e7db..aaa9876948 100644
--- a/src/core/stdaway/commonheaders.h
+++ b/src/core/stdaway/commonheaders.h
@@ -69,6 +69,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_icolib.h>
#include <m_modernopt.h>
#include <m_timezones.h>
+#include <m_metacontacts.h>
#include "version.h"