From 34306c48a9fb217405e4f36496ca3e910cdfdb3b Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Thu, 25 Dec 2014 18:16:52 +0000 Subject: files structure changed git-svn-id: http://svn.miranda-ng.org/main/trunk@11629 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/core/stdaway/awaymsg.cpp | 185 --------- src/core/stdaway/commonheaders.cpp | 2 - src/core/stdaway/commonheaders.h | 79 ---- src/core/stdaway/main.cpp | 69 ---- src/core/stdaway/res/resource.rc | 157 +++++++ src/core/stdaway/res/version.rc | 38 ++ src/core/stdaway/resource.rc | 157 ------- src/core/stdaway/sendmsg.cpp | 613 ---------------------------- src/core/stdaway/src/awaymsg.cpp | 185 +++++++++ src/core/stdaway/src/commonheaders.cpp | 2 + src/core/stdaway/src/commonheaders.h | 79 ++++ src/core/stdaway/src/main.cpp | 69 ++++ src/core/stdaway/src/sendmsg.cpp | 613 ++++++++++++++++++++++++++++ src/core/stdaway/src/version.h | 12 + src/core/stdaway/stdaway_10.vcxproj | 20 +- src/core/stdaway/stdaway_10.vcxproj.filters | 17 +- src/core/stdaway/stdaway_12.vcxproj | 20 +- src/core/stdaway/stdaway_12.vcxproj.filters | 17 +- src/core/stdaway/version.h | 14 - src/core/stdaway/version.rc | 42 -- 20 files changed, 1193 insertions(+), 1197 deletions(-) delete mode 100644 src/core/stdaway/awaymsg.cpp delete mode 100644 src/core/stdaway/commonheaders.cpp delete mode 100644 src/core/stdaway/commonheaders.h delete mode 100644 src/core/stdaway/main.cpp create mode 100644 src/core/stdaway/res/resource.rc create mode 100644 src/core/stdaway/res/version.rc delete mode 100644 src/core/stdaway/resource.rc delete mode 100644 src/core/stdaway/sendmsg.cpp create mode 100644 src/core/stdaway/src/awaymsg.cpp create mode 100644 src/core/stdaway/src/commonheaders.cpp create mode 100644 src/core/stdaway/src/commonheaders.h create mode 100644 src/core/stdaway/src/main.cpp create mode 100644 src/core/stdaway/src/sendmsg.cpp create mode 100644 src/core/stdaway/src/version.h delete mode 100644 src/core/stdaway/version.h delete mode 100644 src/core/stdaway/version.rc diff --git a/src/core/stdaway/awaymsg.cpp b/src/core/stdaway/awaymsg.cpp deleted file mode 100644 index c9512ee944..0000000000 --- a/src/core/stdaway/awaymsg.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "commonheaders.h" - -int LoadAwayMessageSending(void); - -static HGENMENU hAwayMsgMenuItem; -static HANDLE hWindowList; - -struct AwayMsgDlgData { - MCONTACT hContact; - 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); - - 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; - - case HM_AWAYMSG: - { - ACKDATA *ack = (ACKDATA*)lParam; - if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break; - if (ack->result != ACKRESULT_SUCCESS) break; - if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } - - SetDlgItemText(hwndDlg, IDC_MSG, (const TCHAR*)ack->lParam); - - ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); - ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); - SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDCANCEL: - case IDOK: - DestroyWindow(hwndDlg); - 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) -{ - if (HWND hwnd = WindowList_Find(hWindowList, wParam)) { - SetForegroundWindow(hwnd); - SetFocus(hwnd); - } - else CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam); - return 0; -} - -static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) -{ - TCHAR str[128]; - char *szProto = GetContactProto(hContact); - - CLISTMENUITEM mi = { sizeof(mi) }; - mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN | CMIF_TCHAR; - - if (szProto != NULL) { - int chatRoom = szProto ? db_get_b(hContact, szProto, "ChatRoom", 0) : 0; - 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; - if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) { - 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); - return 0; -} - -static int AwayMsgPreShutdown(WPARAM, LPARAM) -{ - if (hWindowList) { - WindowList_BroadcastAsync(hWindowList, WM_CLOSE, 0, 0); - WindowList_Destroy(hWindowList); - } - return 0; -} - -int LoadAwayMsgModule(void) -{ - hWindowList = WindowList_Create(); - CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetMessageCommand); - - CLISTMENUITEM mi = { sizeof(mi) }; - mi.position = -2000005000; - mi.flags = CMIF_NOTOFFLINE; - mi.pszName = LPGEN("Re&ad status message"); - mi.pszService = MS_AWAYMSG_SHOWAWAYMSG; - hAwayMsgMenuItem = Menu_AddContactMenuItem(&mi); - HookEvent(ME_CLIST_PREBUILDCONTACTMENU, AwayMsgPreBuildMenu); - HookEvent(ME_SYSTEM_PRESHUTDOWN, AwayMsgPreShutdown); - return LoadAwayMessageSending(); -} diff --git a/src/core/stdaway/commonheaders.cpp b/src/core/stdaway/commonheaders.cpp deleted file mode 100644 index 95b2201163..0000000000 --- a/src/core/stdaway/commonheaders.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#include "commonheaders.h" - diff --git a/src/core/stdaway/commonheaders.h b/src/core/stdaway/commonheaders.h deleted file mode 100644 index aaa9876948..0000000000 --- a/src/core/stdaway/commonheaders.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#define WINVER 0x0700 -#define _WIN32_WINNT 0x0700 -#define _WIN32_IE 0x0601 - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "version.h" - -#include "../../resource.h" -#include "../stdplug.h" - -extern HINSTANCE hInst; diff --git a/src/core/stdaway/main.cpp b/src/core/stdaway/main.cpp deleted file mode 100644 index 6137fbd264..0000000000 --- a/src/core/stdaway/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - -Standard away message processing module for Miranda NG - -Copyright (C) 2012-14 George Hazan - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#include "commonheaders.h" - -int LoadAwayMsgModule(void); - -CLIST_INTERFACE* pcli; -HINSTANCE hInst; -int hLangpack; - -PLUGININFOEX pluginInfo = { - sizeof(PLUGININFOEX), - __PLUGIN_NAME, - MIRANDA_VERSION_DWORD, - __DESCRIPTION, - __AUTHOR, - __AUTHOREMAIL, - __COPYRIGHT, - __AUTHORWEB, - UNICODE_AWARE, - // {E58558E3-83E7-44EF-8E39-D9E0541956DF} - { 0xe58558e3, 0x83e7, 0x44ef, {0x8e, 0x39, 0xd9, 0xe0, 0x54, 0x19, 0x56, 0xdf}} -}; - -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - hInst = hinstDLL; - return TRUE; -} - -extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) -{ - return &pluginInfo; -} - -extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST }; - -extern "C" int __declspec(dllexport) Load(void) -{ - mir_getLP(&pluginInfo); - mir_getCLI(); - - LoadAwayMsgModule(); - return 0; -} - -extern "C" int __declspec(dllexport) Unload(void) -{ - return 0; -} diff --git a/src/core/stdaway/res/resource.rc b/src/core/stdaway/res/resource.rc new file mode 100644 index 0000000000..2b794d95eb --- /dev/null +++ b/src/core/stdaway/res/resource.rc @@ -0,0 +1,157 @@ +// Microsoft Visual C++ generated resource script. +// +#include "..\..\resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include +#include + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_READAWAYMSG DIALOGEX 0, 0, 187, 72 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "%s message for %s" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "&Cancel",IDOK,69,53,50,14 + CTEXT "Retrieving %s message...",IDC_RETRIEVING,5,21,177,8,SS_NOPREFIX + EDITTEXT IDC_MSG,5,5,177,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_VISIBLE | WS_VSCROLL +END + +IDD_OPT_AWAYMSG DIALOGEX 0, 0, 263, 151 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + GROUPBOX "Status messages",IDC_STATIC,4,5,255,142 + COMBOBOX IDC_STATUS,12,19,240,97,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CONTROL "Do not reply to requests for this message",IDC_DONTREPLY, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,37,227,10 + CONTROL "Do not pop up dialog asking for new message",IDC_NODIALOG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,50,227,10 + CONTROL "By default, use the same message as last time",IDC_USEPREVIOUS, + "Button",BS_AUTORADIOBUTTON,23,65,227,10 + CONTROL "By default, use this message:",IDC_USESPECIFIC,"Button",BS_AUTORADIOBUTTON,23,78,227,10 + EDITTEXT IDC_MSG,33,91,219,38,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + LTEXT "Use %time% for the current time, %date% for the current date",IDC_STATIC,33,131,219,8 +END + +IDD_MODERNOPT_STATUS DIALOGEX 0, 0, 369, 113 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x0 +BEGIN + COMBOBOX IDC_STATUS,2,54,16,97,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP + CONTROL "Do not reply to requests for this message",IDC_DONTREPLY, + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,0,33,10,10 + CONTROL "Do not pop up dialog asking for new message",IDC_NODIALOG, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,93,264,10 + CONTROL "By default, use the same message as last time",IDC_USEPREVIOUS, + "Button",BS_AUTORADIOBUTTON,105,13,227,10 + CONTROL "By default, use this message:",IDC_USESPECIFIC,"Button",BS_AUTORADIOBUTTON,105,26,227,10 + EDITTEXT IDC_MSG,125,39,244,38,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL + CTEXT "Use %time% for the current time, %date% for the current date",IDC_STATIC,125,78,244,8,SS_CENTERIMAGE + LTEXT "Status messages:",IDC_TXT_TITLE1,0,0,246,8 + LISTBOX IDC_LST_STATUS,10,13,90,95,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP +END + +IDD_SETAWAYMSG DIALOGEX 0, 0, 187, 72 +STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT +CAPTION "Change %s message" +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + DEFPUSHBUTTON "Closing in %d",IDOK,61,53,65,14 + EDITTEXT IDC_MSG,5,5,177,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL +END + +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_READAWAYMSG, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 182 + TOPMARGIN, 5 + BOTTOMMARGIN, 67 + END + IDD_OPT_AWAYMSG, DIALOG + BEGIN + LEFTMARGIN, 4 + RIGHTMARGIN, 259 + TOPMARGIN, 4 + BOTTOMMARGIN, 147 + END + + IDD_MODERNOPT_STATUS, DIALOG + BEGIN + VERTGUIDE, 10 + VERTGUIDE, 100 + VERTGUIDE, 105 + VERTGUIDE, 218 + BOTTOMMARGIN, 103 + HORZGUIDE, 8 + HORZGUIDE, 13 + END + + IDD_SETAWAYMSG, DIALOG + BEGIN + LEFTMARGIN, 5 + RIGHTMARGIN, 182 + TOPMARGIN, 5 + BOTTOMMARGIN, 67 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "..\..\resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include \r\n" + "#include \r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED diff --git a/src/core/stdaway/res/version.rc b/src/core/stdaway/res/version.rc new file mode 100644 index 0000000000..5bfbab4754 --- /dev/null +++ b/src/core/stdaway/res/version.rc @@ -0,0 +1,38 @@ +// Microsoft Visual C++ generated resource script. +// +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + +#include "afxres.h" +#include "..\src\version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x0L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "FileDescription", __DESCRIPTION + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + VALUE "ProductName", __PLUGIN_NAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END diff --git a/src/core/stdaway/resource.rc b/src/core/stdaway/resource.rc deleted file mode 100644 index 2b794d95eb..0000000000 --- a/src/core/stdaway/resource.rc +++ /dev/null @@ -1,157 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "..\..\resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include -#include - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (United States) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_READAWAYMSG DIALOGEX 0, 0, 187, 72 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "%s message for %s" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "&Cancel",IDOK,69,53,50,14 - CTEXT "Retrieving %s message...",IDC_RETRIEVING,5,21,177,8,SS_NOPREFIX - EDITTEXT IDC_MSG,5,5,177,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_VISIBLE | WS_VSCROLL -END - -IDD_OPT_AWAYMSG DIALOGEX 0, 0, 263, 151 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - GROUPBOX "Status messages",IDC_STATIC,4,5,255,142 - COMBOBOX IDC_STATUS,12,19,240,97,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - CONTROL "Do not reply to requests for this message",IDC_DONTREPLY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,37,227,10 - CONTROL "Do not pop up dialog asking for new message",IDC_NODIALOG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,50,227,10 - CONTROL "By default, use the same message as last time",IDC_USEPREVIOUS, - "Button",BS_AUTORADIOBUTTON,23,65,227,10 - CONTROL "By default, use this message:",IDC_USESPECIFIC,"Button",BS_AUTORADIOBUTTON,23,78,227,10 - EDITTEXT IDC_MSG,33,91,219,38,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - LTEXT "Use %time% for the current time, %date% for the current date",IDC_STATIC,33,131,219,8 -END - -IDD_MODERNOPT_STATUS DIALOGEX 0, 0, 369, 113 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -EXSTYLE WS_EX_CONTROLPARENT -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - COMBOBOX IDC_STATUS,2,54,16,97,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP - CONTROL "Do not reply to requests for this message",IDC_DONTREPLY, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,0,33,10,10 - CONTROL "Do not pop up dialog asking for new message",IDC_NODIALOG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,105,93,264,10 - CONTROL "By default, use the same message as last time",IDC_USEPREVIOUS, - "Button",BS_AUTORADIOBUTTON,105,13,227,10 - CONTROL "By default, use this message:",IDC_USESPECIFIC,"Button",BS_AUTORADIOBUTTON,105,26,227,10 - EDITTEXT IDC_MSG,125,39,244,38,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - CTEXT "Use %time% for the current time, %date% for the current date",IDC_STATIC,125,78,244,8,SS_CENTERIMAGE - LTEXT "Status messages:",IDC_TXT_TITLE1,0,0,246,8 - LISTBOX IDC_LST_STATUS,10,13,90,95,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP -END - -IDD_SETAWAYMSG DIALOGEX 0, 0, 187, 72 -STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_CONTROLPARENT -CAPTION "Change %s message" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Closing in %d",IDOK,61,53,65,14 - EDITTEXT IDC_MSG,5,5,177,43,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL -END - -#endif // APSTUDIO_INVOKED - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_READAWAYMSG, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 182 - TOPMARGIN, 5 - BOTTOMMARGIN, 67 - END - IDD_OPT_AWAYMSG, DIALOG - BEGIN - LEFTMARGIN, 4 - RIGHTMARGIN, 259 - TOPMARGIN, 4 - BOTTOMMARGIN, 147 - END - - IDD_MODERNOPT_STATUS, DIALOG - BEGIN - VERTGUIDE, 10 - VERTGUIDE, 100 - VERTGUIDE, 105 - VERTGUIDE, 218 - BOTTOMMARGIN, 103 - HORZGUIDE, 8 - HORZGUIDE, 13 - END - - IDD_SETAWAYMSG, DIALOG - BEGIN - LEFTMARGIN, 5 - RIGHTMARGIN, 182 - TOPMARGIN, 5 - BOTTOMMARGIN, 67 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "..\..\resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include \r\n" - "#include \r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED diff --git a/src/core/stdaway/sendmsg.cpp b/src/core/stdaway/sendmsg.cpp deleted file mode 100644 index b9df962748..0000000000 --- a/src/core/stdaway/sendmsg.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/* - -Miranda NG: the free IM client for Microsoft* Windows* - -Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), -Copyright (c) 2000-12 Miranda IM project, -all portions of this codebase are copyrighted to the people -listed in contributors.txt. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "commonheaders.h" - -static DWORD protoModeMsgFlags; -static HWND hwndStatusMsg; - -static bool Proto_IsAccountEnabled(PROTOACCOUNT *pa) -{ - return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto); -} - -static bool Proto_IsAccountLocked(PROTOACCOUNT *pa) -{ - return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0; -} - -static const TCHAR *GetDefaultMessage(int status) -{ - switch(status) { - case ID_STATUS_AWAY: return TranslateT("I've been away since %time%."); - case ID_STATUS_NA: return TranslateT("Give it up, I'm not in!"); - case ID_STATUS_OCCUPIED: return TranslateT("Not right now."); - case ID_STATUS_DND: return TranslateT("Give a guy some peace, would ya?"); - case ID_STATUS_FREECHAT: return TranslateT("I'm a chatbot!"); - case ID_STATUS_ONLINE: return TranslateT("Yep, I'm here."); - case ID_STATUS_OFFLINE: return TranslateT("Nope, not here."); - case ID_STATUS_INVISIBLE: return TranslateT("I'm hiding from the mafia."); - case ID_STATUS_ONTHEPHONE: return TranslateT("That'll be the phone."); - case ID_STATUS_OUTTOLUNCH: return TranslateT("Mmm... food."); - case ID_STATUS_IDLE: return TranslateT("idleeeeeeee"); - } - return NULL; -} - -static const char *StatusModeToDbSetting(int status, const char *suffix) -{ - const char *prefix; - static char str[64]; - - switch(status) - { - case ID_STATUS_AWAY: prefix = "Away"; break; - case ID_STATUS_NA: prefix = "Na"; break; - case ID_STATUS_DND: prefix = "Dnd"; break; - case ID_STATUS_OCCUPIED: prefix = "Occupied"; break; - case ID_STATUS_FREECHAT: prefix = "FreeChat"; break; - case ID_STATUS_ONLINE: prefix = "On"; break; - case ID_STATUS_OFFLINE: prefix = "Off"; break; - case ID_STATUS_INVISIBLE: prefix = "Inv"; break; - case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break; - case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break; - case ID_STATUS_IDLE: prefix = "Idl"; break; - default: return NULL; - } - mir_snprintf(str, SIZEOF(str), "%s%s", prefix, suffix); - return str; -} - -static bool GetStatusModeByte(int status, const char *suffix, bool bDefault = false) -{ - return db_get_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), bDefault) != 0; -} - -static void SetStatusModeByte(int status, const char *suffix, BYTE value) -{ - db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), value); -} - -static TCHAR* GetAwayMessage(int statusMode, char *szProto) -{ - if (szProto && !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode))) - return NULL; - - if ( GetStatusModeByte(statusMode, "Ignore")) - return NULL; - - DBVARIANT dbv; - if ( GetStatusModeByte(statusMode, "UsePrev")) { - if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Msg"), &dbv)) - dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode)); - } - else { - if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Default"), &dbv)) - dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode)); - - for (int i=0; dbv.ptszVal[i]; i++) { - if (dbv.ptszVal[i] != '%') - continue; - - TCHAR substituteStr[128]; - if ( !_tcsnicmp(dbv.ptszVal + i, _T("%time%"), 6)) { - MIRANDA_IDLE_INFO mii = { sizeof(mii) }; - CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); - - if (mii.idleType == 1) { - int mm; - SYSTEMTIME t; - GetLocalTime(&t); - mm = t.wMinute + t.wHour * 60 - mii.idleTime; - if (mm < 0) mm += 60 * 24; - t.wMinute = mm % 60; - t.wHour = mm / 60; - GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr)); - } - else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr)); - } - else if ( !_tcsnicmp(dbv.ptszVal + i, _T("%date%"), 6)) - GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr)); - else continue; - - if (mir_tstrlen(substituteStr) > 6) - dbv.ptszVal = (TCHAR*)mir_realloc(dbv.ptszVal, (mir_tstrlen(dbv.ptszVal) + 1 + mir_tstrlen(substituteStr) - 6) * sizeof(TCHAR)); - memmove(dbv.ptszVal + i + mir_tstrlen(substituteStr), dbv.ptszVal + i + 6, (mir_tstrlen(dbv.ptszVal) - i - 5) * sizeof(TCHAR)); - memcpy(dbv.ptszVal+i, substituteStr, mir_tstrlen(substituteStr) * sizeof(TCHAR)); - } - } - return dbv.ptszVal; -} - -static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch(msg) { - case WM_CHAR: - if (wParam == '\n' && GetKeyState(VK_CONTROL) & 0x8000) - { - PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); - return 0; - } - if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) //ctrl-a - { - SendMessage(hwnd, EM_SETSEL, 0, -1); - return 0; - } - if (wParam == 23 && GetKeyState(VK_CONTROL) & 0x8000) // ctrl-w - { - SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0); - return 0; - } - if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) //ctrl-backspace - { - DWORD start, end; - TCHAR *text; - int textLen; - SendMessage(hwnd, EM_GETSEL, (WPARAM)&end, 0); - SendMessage(hwnd, WM_KEYDOWN, VK_LEFT, 0); - SendMessage(hwnd, EM_GETSEL, (WPARAM)&start, 0); - textLen = GetWindowTextLength(hwnd); - text = (TCHAR *)alloca(sizeof(TCHAR) * (textLen + 1)); - GetWindowText(hwnd, text, textLen + 1); - memmove(text + start, text + end, sizeof(TCHAR) * (textLen + 1 - end)); - SetWindowText(hwnd, text); - SendMessage(hwnd, EM_SETSEL, start, start); - SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd); - return 0; - } - break; - } - return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam); -} - -void ChangeAllProtoMessages(char *szProto, int statusMode, TCHAR *msg) -{ - if (szProto == NULL) { - int nAccounts; - PROTOACCOUNT **accounts; - ProtoEnumAccounts(&nAccounts, &accounts); - - for (int i = 0; i < nAccounts; i++) { - PROTOACCOUNT *pa = accounts[i]; - if (!Proto_IsAccountEnabled(pa)) - continue; - - if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && !Proto_IsAccountLocked(pa)) - CallProtoService(pa->szModuleName, PS_SETAWAYMSGT, statusMode, (LPARAM)msg); - } - } - else CallProtoService(szProto, PS_SETAWAYMSGT, statusMode, (LPARAM)msg); -} - -struct SetAwayMsgData -{ - int statusMode; - int countdown; - TCHAR okButtonFormat[64]; - char *szProto; - HANDLE hPreshutdown; -}; - -struct SetAwasMsgNewData -{ - char *szProto; - int statusMode; -}; - -#define DM_SRAWAY_SHUTDOWN WM_USER+10 - -static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - SetAwayMsgData* dat = (SetAwayMsgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - switch (message) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { - SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)lParam; - dat = (SetAwayMsgData*)mir_alloc(sizeof(SetAwayMsgData)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->statusMode = newdat->statusMode; - dat->szProto = newdat->szProto; - mir_free(newdat); - SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0); - mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc); - { - TCHAR str[256], format[128]; - GetWindowText(hwndDlg, format, SIZEOF(format)); - mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); - SetWindowText(hwndDlg, str); - } - GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat)); - { - TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); - SetDlgItemText(hwndDlg, IDC_MSG, msg); - mir_free(msg); - } - dat->countdown = 6; - SendMessage(hwndDlg, WM_TIMER, 0, 0); - Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode); - Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); - SetTimer(hwndDlg, 1, 1000, 0); - dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN); - } - return TRUE; - - case WM_TIMER: - if (--dat->countdown >= 0) { - TCHAR str[64]; - mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown); - SetDlgItemText(hwndDlg, IDOK, str); - } - else { - KillTimer(hwndDlg, 1); - PostMessage(hwndDlg, WM_CLOSE, 0, 0); - } - break; - - case WM_CLOSE: - { - TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); - ChangeAllProtoMessages(dat->szProto, dat->statusMode, msg); - mir_free(msg); - } - DestroyWindow(hwndDlg); - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDOK: - if (dat->countdown < 0) { - TCHAR str[1024]; - GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str)); - ChangeAllProtoMessages(dat->szProto, dat->statusMode, str); - db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str); - DestroyWindow(hwndDlg); - } - else PostMessage(hwndDlg, WM_CLOSE, 0, 0); - break; - - case IDC_MSG: - if (dat->countdown >= 0) { - KillTimer(hwndDlg, 1); - SetDlgItemText(hwndDlg, IDOK, TranslateT("OK")); - dat->countdown = -1; - } - break; - } - break; - - case DM_SRAWAY_SHUTDOWN: - DestroyWindow(hwndDlg); - break; - - case WM_DESTROY: - Utils_SaveWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); - KillTimer(hwndDlg, 1); - UnhookEvent(dat->hPreshutdown); - Window_FreeIcon_IcoLib(hwndDlg); - mir_free(dat); - hwndStatusMsg = NULL; - break; - } - return FALSE; -} - -static int StatusModeChange(WPARAM wParam, LPARAM lParam) -{ - int statusMode = (int)wParam; - char *szProto = (char*)lParam; - - if (protoModeMsgFlags == 0) - return 0; - - // If its a global change check the complete PFLAGNUM_3 flags to see if a popup might be needed - if (!szProto) { - if (!(protoModeMsgFlags & Proto_Status2Flag(statusMode))) - return 0; - } - else { - // If its a single protocol check the PFLAGNUM_3 for the single protocol - if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) || - !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode))) - return 0; - } - - BOOL bScreenSaverRunning = IsScreenSaverRunning(); - if (GetStatusModeByte(statusMode, "Ignore")) - ChangeAllProtoMessages(szProto, statusMode, NULL); - - else if (bScreenSaverRunning || GetStatusModeByte(statusMode, "NoDlg", true)) { - TCHAR *msg = GetAwayMessage(statusMode, szProto); - ChangeAllProtoMessages(szProto, statusMode, msg); - mir_free(msg); - } - else { - SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)mir_alloc(sizeof(SetAwasMsgNewData)); - newdat->szProto = szProto; - newdat->statusMode = statusMode; - if (hwndStatusMsg) - DestroyWindow(hwndStatusMsg); - hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)newdat); - } - return 0; -} - -static const int statusModes[] = -{ - ID_STATUS_OFFLINE, ID_STATUS_ONLINE, ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, - ID_STATUS_FREECHAT, ID_STATUS_INVISIBLE, ID_STATUS_OUTTOLUNCH, ID_STATUS_ONTHEPHONE, ID_STATUS_IDLE -}; - -struct AwayMsgInfo -{ - int ignore; - int noDialog; - int usePrevious; - TCHAR msg[1024]; -}; - -struct AwayMsgDlgData -{ - struct AwayMsgInfo info[SIZEOF(statusModes)]; - int oldPage; -}; - -static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - HWND hLst = GetDlgItem(hwndDlg, IDC_LST_STATUS); - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - { - dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); - dat->oldPage = -1; - for (int i = 0; i < SIZEOF(statusModes); i++) { - if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) - continue; - - int j; - if (hLst) { - j = SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); - SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETITEMDATA, j, statusModes[i]); - } - else { - j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); - SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModes[i]); - } - - dat->info[j].ignore = GetStatusModeByte(statusModes[i], "Ignore"); - dat->info[j].noDialog = GetStatusModeByte(statusModes[i], "NoDlg", true); - dat->info[j].usePrevious = GetStatusModeByte(statusModes[i], "UsePrev"); - - DBVARIANT dbv; - if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Default"), &dbv)) - if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Msg"), &dbv)) - dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusModes[i])); - mir_tstrcpy(dat->info[j].msg, dbv.ptszVal); - mir_free(dbv.ptszVal); - } - if (hLst) - SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETCURSEL, 0, 0); - else - SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); - SendMessage(hwndDlg, WM_COMMAND, hLst ? MAKEWPARAM(IDC_LST_STATUS, LBN_SELCHANGE) : MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); - } - return TRUE; - - case WM_MEASUREITEM: - { - LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam; - if (mis->CtlID == IDC_LST_STATUS) - mis->itemHeight = 20; - } - break; - - case WM_DRAWITEM: - { - LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; - if (dis->CtlID != IDC_LST_STATUS) break; - if (dis->itemID < 0) break; - - TCHAR buf[128]; - SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETTEXT, dis->itemID, (LPARAM)buf); - - if (dis->itemState & (ODS_SELECTED | ODS_FOCUS)) { - FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); - SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); - } - else { - FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW)); - SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT)); - } - - RECT rc = dis->rcItem; - DrawIconEx(dis->hDC, 3, (rc.top + rc.bottom - 16) / 2, LoadSkinnedProtoIcon(NULL, dis->itemData), 16, 16, 0, NULL, DI_NORMAL); - rc.left += 25; - SetBkMode(dis->hDC, TRANSPARENT); - DrawText(dis->hDC, buf, -1, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); - } - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_LST_STATUS: - case IDC_STATUS: - if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == LBN_SELCHANGE)) { - int i = hLst ? - SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCURSEL, 0, 0) : - SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0); - if (dat->oldPage != -1) { - dat->info[dat->oldPage].ignore = IsDlgButtonChecked(hwndDlg, IDC_DONTREPLY); - dat->info[dat->oldPage].noDialog = IsDlgButtonChecked(hwndDlg, IDC_NODIALOG); - dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS); - GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg)); - } - CheckDlgButton(hwndDlg, IDC_DONTREPLY, (i < 0 ? 0 : dat->info[i].ignore) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NODIALOG, (i < 0 ? 0 : dat->info[i].noDialog) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USEPREVIOUS, (i < 0 ? 0 : dat->info[i].usePrevious) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_USESPECIFIC, (i < 0 ? 0 : !dat->info[i].usePrevious) ? BST_CHECKED : BST_UNCHECKED); - - SetDlgItemText(hwndDlg, IDC_MSG, i < 0 ? _T("") : dat->info[i].msg); - - EnableWindow(GetDlgItem(hwndDlg, IDC_NODIALOG), i < 0 ? 0 : !dat->info[i].ignore); - EnableWindow(GetDlgItem(hwndDlg, IDC_USEPREVIOUS), i < 0 ? 0 : !dat->info[i].ignore); - EnableWindow(GetDlgItem(hwndDlg, IDC_USESPECIFIC), i < 0 ? 0 : !dat->info[i].ignore); - EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), i < 0 ? 0 : !(dat->info[i].ignore || dat->info[i].usePrevious)); - dat->oldPage = i; - } - return 0; - - case IDC_DONTREPLY: - case IDC_USEPREVIOUS: - case IDC_USESPECIFIC: - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); - break; - - case IDC_MSG: - if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) - return 0; - break; - } - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); - { - int i = hLst ? (SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCOUNT, 0, 0) - 1) : - (SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCOUNT, 0, 0) - 1); - for (; i >= 0; i--) { - int status = hLst ? - SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETITEMDATA, i, 0) : - SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, i, 0); - SetStatusModeByte(status, "Ignore", (BYTE)dat->info[i].ignore); - SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog); - SetStatusModeByte(status, "UsePrev", (BYTE)dat->info[i].usePrevious); - db_set_ts(NULL, "SRAway", StatusModeToDbSetting(status, "Default"), dat->info[i].msg); - } - return TRUE; - } - } - break; - } - break; - - case WM_DESTROY: - mir_free(dat); - break; - } - return FALSE; -} - -static int AwayMsgOptInitialise(WPARAM wParam, LPARAM) -{ - if (protoModeMsgFlags == 0) - return 0; - - OPTIONSDIALOGPAGE odp = { sizeof(odp) }; - odp.position = 870000000; - odp.hInstance = hInst; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_AWAYMSG); - odp.pszTitle = LPGEN("Status messages"); - odp.pszGroup = LPGEN("Status"); - odp.pfnDlgProc = DlgProcAwayMsgOpts; - odp.flags = ODPF_BOLDGROUPS; - Options_AddPage(wParam, &odp); - return 0; -} - -static int AwayMsgSendModernOptInit(WPARAM wParam, LPARAM) -{ - if (protoModeMsgFlags == 0) - return 0; - - static const int iBoldControls[] = - { - IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, - MODERNOPT_CTRL_LAST - }; - - MODERNOPTOBJECT obj = { 0 }; - obj.cbSize = sizeof(obj); - obj.hInstance = hInst; - obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE; - obj.iSection = MODERNOPT_PAGE_STATUS; - obj.iType = MODERNOPT_TYPE_SECTIONPAGE; - obj.iBoldControls = (int*)iBoldControls; - obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_STATUS); - obj.pfnDlgProc = DlgProcAwayMsgOpts; - obj.lpzHelpUrl = "http://wiki.miranda-ng.org/"; - CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj); - return 0; -} - -static int AwayMsgSendAccountsChanged(WPARAM, LPARAM) -{ - protoModeMsgFlags = 0; - - int nAccounts; - PROTOACCOUNT** accounts; - ProtoEnumAccounts(&nAccounts, &accounts); - for (int i = 0; i < nAccounts; i++) { - if (!Proto_IsAccountEnabled(accounts[i])) - continue; - - protoModeMsgFlags |= CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); - } - - return 0; -} - -static int AwayMsgSendModulesLoaded(WPARAM, LPARAM) -{ - AwayMsgSendAccountsChanged(0, 0); - - HookEvent(ME_CLIST_STATUSMODECHANGE, StatusModeChange); - HookEvent(ME_MODERNOPT_INITIALIZE, AwayMsgSendModernOptInit); - HookEvent(ME_OPT_INITIALISE, AwayMsgOptInitialise); - return 0; -} - -//remember to mir_free() the return value -static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) -{ - return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam); -} - -int LoadAwayMessageSending(void) -{ - HookEvent(ME_SYSTEM_MODULESLOADED, AwayMsgSendModulesLoaded); - HookEvent(ME_PROTO_ACCLISTCHANGED, AwayMsgSendAccountsChanged); - - CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT); - return 0; -} diff --git a/src/core/stdaway/src/awaymsg.cpp b/src/core/stdaway/src/awaymsg.cpp new file mode 100644 index 0000000000..c9512ee944 --- /dev/null +++ b/src/core/stdaway/src/awaymsg.cpp @@ -0,0 +1,185 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +int LoadAwayMessageSending(void); + +static HGENMENU hAwayMsgMenuItem; +static HANDLE hWindowList; + +struct AwayMsgDlgData { + MCONTACT hContact; + 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); + + 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; + + case HM_AWAYMSG: + { + ACKDATA *ack = (ACKDATA*)lParam; + if (ack->hContact != dat->hContact || ack->type != ACKTYPE_AWAYMSG) break; + if (ack->result != ACKRESULT_SUCCESS) break; + if (dat->hAwayMsgEvent && ack->hProcess == dat->hSeq) { UnhookEvent(dat->hAwayMsgEvent); dat->hAwayMsgEvent = NULL; } + + SetDlgItemText(hwndDlg, IDC_MSG, (const TCHAR*)ack->lParam); + + ShowWindow(GetDlgItem(hwndDlg, IDC_RETRIEVING), SW_HIDE); + ShowWindow(GetDlgItem(hwndDlg, IDC_MSG), SW_SHOW); + SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close")); + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDCANCEL: + case IDOK: + DestroyWindow(hwndDlg); + 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) +{ + if (HWND hwnd = WindowList_Find(hWindowList, wParam)) { + SetForegroundWindow(hwnd); + SetFocus(hwnd); + } + else CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_READAWAYMSG), NULL, ReadAwayMsgDlgProc, wParam); + return 0; +} + +static int AwayMsgPreBuildMenu(WPARAM hContact, LPARAM) +{ + TCHAR str[128]; + char *szProto = GetContactProto(hContact); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_HIDDEN | CMIF_TCHAR; + + if (szProto != NULL) { + int chatRoom = szProto ? db_get_b(hContact, szProto, "ChatRoom", 0) : 0; + 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; + if (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGRECV) { + 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); + return 0; +} + +static int AwayMsgPreShutdown(WPARAM, LPARAM) +{ + if (hWindowList) { + WindowList_BroadcastAsync(hWindowList, WM_CLOSE, 0, 0); + WindowList_Destroy(hWindowList); + } + return 0; +} + +int LoadAwayMsgModule(void) +{ + hWindowList = WindowList_Create(); + CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetMessageCommand); + + CLISTMENUITEM mi = { sizeof(mi) }; + mi.position = -2000005000; + mi.flags = CMIF_NOTOFFLINE; + mi.pszName = LPGEN("Re&ad status message"); + mi.pszService = MS_AWAYMSG_SHOWAWAYMSG; + hAwayMsgMenuItem = Menu_AddContactMenuItem(&mi); + HookEvent(ME_CLIST_PREBUILDCONTACTMENU, AwayMsgPreBuildMenu); + HookEvent(ME_SYSTEM_PRESHUTDOWN, AwayMsgPreShutdown); + return LoadAwayMessageSending(); +} diff --git a/src/core/stdaway/src/commonheaders.cpp b/src/core/stdaway/src/commonheaders.cpp new file mode 100644 index 0000000000..95b2201163 --- /dev/null +++ b/src/core/stdaway/src/commonheaders.cpp @@ -0,0 +1,2 @@ +#include "commonheaders.h" + diff --git a/src/core/stdaway/src/commonheaders.h b/src/core/stdaway/src/commonheaders.h new file mode 100644 index 0000000000..aaa9876948 --- /dev/null +++ b/src/core/stdaway/src/commonheaders.h @@ -0,0 +1,79 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#define WINVER 0x0700 +#define _WIN32_WINNT 0x0700 +#define _WIN32_IE 0x0601 + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +#include "../../resource.h" +#include "../stdplug.h" + +extern HINSTANCE hInst; diff --git a/src/core/stdaway/src/main.cpp b/src/core/stdaway/src/main.cpp new file mode 100644 index 0000000000..6137fbd264 --- /dev/null +++ b/src/core/stdaway/src/main.cpp @@ -0,0 +1,69 @@ +/* + +Standard away message processing module for Miranda NG + +Copyright (C) 2012-14 George Hazan + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#include "commonheaders.h" + +int LoadAwayMsgModule(void); + +CLIST_INTERFACE* pcli; +HINSTANCE hInst; +int hLangpack; + +PLUGININFOEX pluginInfo = { + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + MIRANDA_VERSION_DWORD, + __DESCRIPTION, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + // {E58558E3-83E7-44EF-8E39-D9E0541956DF} + { 0xe58558e3, 0x83e7, 0x44ef, {0x8e, 0x39, 0xd9, 0xe0, 0x54, 0x19, 0x56, 0xdf}} +}; + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + hInst = hinstDLL; + return TRUE; +} + +extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) +{ + return &pluginInfo; +} + +extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST }; + +extern "C" int __declspec(dllexport) Load(void) +{ + mir_getLP(&pluginInfo); + mir_getCLI(); + + LoadAwayMsgModule(); + return 0; +} + +extern "C" int __declspec(dllexport) Unload(void) +{ + return 0; +} diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp new file mode 100644 index 0000000000..b9df962748 --- /dev/null +++ b/src/core/stdaway/src/sendmsg.cpp @@ -0,0 +1,613 @@ +/* + +Miranda NG: the free IM client for Microsoft* Windows* + +Copyright (c) 2012-14 Miranda NG project (http://miranda-ng.org), +Copyright (c) 2000-12 Miranda IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "commonheaders.h" + +static DWORD protoModeMsgFlags; +static HWND hwndStatusMsg; + +static bool Proto_IsAccountEnabled(PROTOACCOUNT *pa) +{ + return pa && ((pa->bIsEnabled && !pa->bDynDisabled) || pa->bOldProto); +} + +static bool Proto_IsAccountLocked(PROTOACCOUNT *pa) +{ + return pa && db_get_b(NULL, pa->szModuleName, "LockMainStatus", 0) != 0; +} + +static const TCHAR *GetDefaultMessage(int status) +{ + switch(status) { + case ID_STATUS_AWAY: return TranslateT("I've been away since %time%."); + case ID_STATUS_NA: return TranslateT("Give it up, I'm not in!"); + case ID_STATUS_OCCUPIED: return TranslateT("Not right now."); + case ID_STATUS_DND: return TranslateT("Give a guy some peace, would ya?"); + case ID_STATUS_FREECHAT: return TranslateT("I'm a chatbot!"); + case ID_STATUS_ONLINE: return TranslateT("Yep, I'm here."); + case ID_STATUS_OFFLINE: return TranslateT("Nope, not here."); + case ID_STATUS_INVISIBLE: return TranslateT("I'm hiding from the mafia."); + case ID_STATUS_ONTHEPHONE: return TranslateT("That'll be the phone."); + case ID_STATUS_OUTTOLUNCH: return TranslateT("Mmm... food."); + case ID_STATUS_IDLE: return TranslateT("idleeeeeeee"); + } + return NULL; +} + +static const char *StatusModeToDbSetting(int status, const char *suffix) +{ + const char *prefix; + static char str[64]; + + switch(status) + { + case ID_STATUS_AWAY: prefix = "Away"; break; + case ID_STATUS_NA: prefix = "Na"; break; + case ID_STATUS_DND: prefix = "Dnd"; break; + case ID_STATUS_OCCUPIED: prefix = "Occupied"; break; + case ID_STATUS_FREECHAT: prefix = "FreeChat"; break; + case ID_STATUS_ONLINE: prefix = "On"; break; + case ID_STATUS_OFFLINE: prefix = "Off"; break; + case ID_STATUS_INVISIBLE: prefix = "Inv"; break; + case ID_STATUS_ONTHEPHONE: prefix = "Otp"; break; + case ID_STATUS_OUTTOLUNCH: prefix = "Otl"; break; + case ID_STATUS_IDLE: prefix = "Idl"; break; + default: return NULL; + } + mir_snprintf(str, SIZEOF(str), "%s%s", prefix, suffix); + return str; +} + +static bool GetStatusModeByte(int status, const char *suffix, bool bDefault = false) +{ + return db_get_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), bDefault) != 0; +} + +static void SetStatusModeByte(int status, const char *suffix, BYTE value) +{ + db_set_b(NULL, "SRAway", StatusModeToDbSetting(status, suffix), value); +} + +static TCHAR* GetAwayMessage(int statusMode, char *szProto) +{ + if (szProto && !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode))) + return NULL; + + if ( GetStatusModeByte(statusMode, "Ignore")) + return NULL; + + DBVARIANT dbv; + if ( GetStatusModeByte(statusMode, "UsePrev")) { + if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Msg"), &dbv)) + dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode)); + } + else { + if ( db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusMode, "Default"), &dbv)) + dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusMode)); + + for (int i=0; dbv.ptszVal[i]; i++) { + if (dbv.ptszVal[i] != '%') + continue; + + TCHAR substituteStr[128]; + if ( !_tcsnicmp(dbv.ptszVal + i, _T("%time%"), 6)) { + MIRANDA_IDLE_INFO mii = { sizeof(mii) }; + CallService(MS_IDLE_GETIDLEINFO, 0, (LPARAM)&mii); + + if (mii.idleType == 1) { + int mm; + SYSTEMTIME t; + GetLocalTime(&t); + mm = t.wMinute + t.wHour * 60 - mii.idleTime; + if (mm < 0) mm += 60 * 24; + t.wMinute = mm % 60; + t.wHour = mm / 60; + GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &t, NULL, substituteStr, SIZEOF(substituteStr)); + } + else GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + } + else if ( !_tcsnicmp(dbv.ptszVal + i, _T("%date%"), 6)) + GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, substituteStr, SIZEOF(substituteStr)); + else continue; + + if (mir_tstrlen(substituteStr) > 6) + dbv.ptszVal = (TCHAR*)mir_realloc(dbv.ptszVal, (mir_tstrlen(dbv.ptszVal) + 1 + mir_tstrlen(substituteStr) - 6) * sizeof(TCHAR)); + memmove(dbv.ptszVal + i + mir_tstrlen(substituteStr), dbv.ptszVal + i + 6, (mir_tstrlen(dbv.ptszVal) - i - 5) * sizeof(TCHAR)); + memcpy(dbv.ptszVal+i, substituteStr, mir_tstrlen(substituteStr) * sizeof(TCHAR)); + } + } + return dbv.ptszVal; +} + +static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch(msg) { + case WM_CHAR: + if (wParam == '\n' && GetKeyState(VK_CONTROL) & 0x8000) + { + PostMessage(GetParent(hwnd), WM_COMMAND, IDOK, 0); + return 0; + } + if (wParam == 1 && GetKeyState(VK_CONTROL) & 0x8000) //ctrl-a + { + SendMessage(hwnd, EM_SETSEL, 0, -1); + return 0; + } + if (wParam == 23 && GetKeyState(VK_CONTROL) & 0x8000) // ctrl-w + { + SendMessage(GetParent(hwnd), WM_CLOSE, 0, 0); + return 0; + } + if (wParam == 127 && GetKeyState(VK_CONTROL) & 0x8000) //ctrl-backspace + { + DWORD start, end; + TCHAR *text; + int textLen; + SendMessage(hwnd, EM_GETSEL, (WPARAM)&end, 0); + SendMessage(hwnd, WM_KEYDOWN, VK_LEFT, 0); + SendMessage(hwnd, EM_GETSEL, (WPARAM)&start, 0); + textLen = GetWindowTextLength(hwnd); + text = (TCHAR *)alloca(sizeof(TCHAR) * (textLen + 1)); + GetWindowText(hwnd, text, textLen + 1); + memmove(text + start, text + end, sizeof(TCHAR) * (textLen + 1 - end)); + SetWindowText(hwnd, text); + SendMessage(hwnd, EM_SETSEL, start, start); + SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd); + return 0; + } + break; + } + return mir_callNextSubclass(hwnd, MessageEditSubclassProc, msg, wParam, lParam); +} + +void ChangeAllProtoMessages(char *szProto, int statusMode, TCHAR *msg) +{ + if (szProto == NULL) { + int nAccounts; + PROTOACCOUNT **accounts; + ProtoEnumAccounts(&nAccounts, &accounts); + + for (int i = 0; i < nAccounts; i++) { + PROTOACCOUNT *pa = accounts[i]; + if (!Proto_IsAccountEnabled(pa)) + continue; + + if ((CallProtoService(pa->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) && !Proto_IsAccountLocked(pa)) + CallProtoService(pa->szModuleName, PS_SETAWAYMSGT, statusMode, (LPARAM)msg); + } + } + else CallProtoService(szProto, PS_SETAWAYMSGT, statusMode, (LPARAM)msg); +} + +struct SetAwayMsgData +{ + int statusMode; + int countdown; + TCHAR okButtonFormat[64]; + char *szProto; + HANDLE hPreshutdown; +}; + +struct SetAwasMsgNewData +{ + char *szProto; + int statusMode; +}; + +#define DM_SRAWAY_SHUTDOWN WM_USER+10 + +static INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + SetAwayMsgData* dat = (SetAwayMsgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + switch (message) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { + SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)lParam; + dat = (SetAwayMsgData*)mir_alloc(sizeof(SetAwayMsgData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + dat->statusMode = newdat->statusMode; + dat->szProto = newdat->szProto; + mir_free(newdat); + SendDlgItemMessage(hwndDlg, IDC_MSG, EM_LIMITTEXT, 1024, 0); + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_MSG), MessageEditSubclassProc); + { + TCHAR str[256], format[128]; + GetWindowText(hwndDlg, format, SIZEOF(format)); + mir_sntprintf(str, SIZEOF(str), format, pcli->pfnGetStatusModeDescription(dat->statusMode, 0)); + SetWindowText(hwndDlg, str); + } + GetDlgItemText(hwndDlg, IDOK, dat->okButtonFormat, SIZEOF(dat->okButtonFormat)); + { + TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); + SetDlgItemText(hwndDlg, IDC_MSG, msg); + mir_free(msg); + } + dat->countdown = 6; + SendMessage(hwndDlg, WM_TIMER, 0, 0); + Window_SetProtoIcon_IcoLib(hwndDlg, dat->szProto, dat->statusMode); + Utils_RestoreWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); + SetTimer(hwndDlg, 1, 1000, 0); + dat->hPreshutdown = HookEventMessage(ME_SYSTEM_PRESHUTDOWN, hwndDlg, DM_SRAWAY_SHUTDOWN); + } + return TRUE; + + case WM_TIMER: + if (--dat->countdown >= 0) { + TCHAR str[64]; + mir_sntprintf(str, SIZEOF(str), dat->okButtonFormat, dat->countdown); + SetDlgItemText(hwndDlg, IDOK, str); + } + else { + KillTimer(hwndDlg, 1); + PostMessage(hwndDlg, WM_CLOSE, 0, 0); + } + break; + + case WM_CLOSE: + { + TCHAR *msg = GetAwayMessage(dat->statusMode, dat->szProto); + ChangeAllProtoMessages(dat->szProto, dat->statusMode, msg); + mir_free(msg); + } + DestroyWindow(hwndDlg); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDOK: + if (dat->countdown < 0) { + TCHAR str[1024]; + GetDlgItemText(hwndDlg, IDC_MSG, str, SIZEOF(str)); + ChangeAllProtoMessages(dat->szProto, dat->statusMode, str); + db_set_ts(NULL, "SRAway", StatusModeToDbSetting(dat->statusMode, "Msg"), str); + DestroyWindow(hwndDlg); + } + else PostMessage(hwndDlg, WM_CLOSE, 0, 0); + break; + + case IDC_MSG: + if (dat->countdown >= 0) { + KillTimer(hwndDlg, 1); + SetDlgItemText(hwndDlg, IDOK, TranslateT("OK")); + dat->countdown = -1; + } + break; + } + break; + + case DM_SRAWAY_SHUTDOWN: + DestroyWindow(hwndDlg); + break; + + case WM_DESTROY: + Utils_SaveWindowPosition(hwndDlg, NULL, "SRAway", "AwayMsgDlg"); + KillTimer(hwndDlg, 1); + UnhookEvent(dat->hPreshutdown); + Window_FreeIcon_IcoLib(hwndDlg); + mir_free(dat); + hwndStatusMsg = NULL; + break; + } + return FALSE; +} + +static int StatusModeChange(WPARAM wParam, LPARAM lParam) +{ + int statusMode = (int)wParam; + char *szProto = (char*)lParam; + + if (protoModeMsgFlags == 0) + return 0; + + // If its a global change check the complete PFLAGNUM_3 flags to see if a popup might be needed + if (!szProto) { + if (!(protoModeMsgFlags & Proto_Status2Flag(statusMode))) + return 0; + } + else { + // If its a single protocol check the PFLAGNUM_3 for the single protocol + if (!(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) || + !(CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(statusMode))) + return 0; + } + + BOOL bScreenSaverRunning = IsScreenSaverRunning(); + if (GetStatusModeByte(statusMode, "Ignore")) + ChangeAllProtoMessages(szProto, statusMode, NULL); + + else if (bScreenSaverRunning || GetStatusModeByte(statusMode, "NoDlg", true)) { + TCHAR *msg = GetAwayMessage(statusMode, szProto); + ChangeAllProtoMessages(szProto, statusMode, msg); + mir_free(msg); + } + else { + SetAwasMsgNewData *newdat = (SetAwasMsgNewData*)mir_alloc(sizeof(SetAwasMsgNewData)); + newdat->szProto = szProto; + newdat->statusMode = statusMode; + if (hwndStatusMsg) + DestroyWindow(hwndStatusMsg); + hwndStatusMsg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)newdat); + } + return 0; +} + +static const int statusModes[] = +{ + ID_STATUS_OFFLINE, ID_STATUS_ONLINE, ID_STATUS_AWAY, ID_STATUS_NA, ID_STATUS_OCCUPIED, ID_STATUS_DND, + ID_STATUS_FREECHAT, ID_STATUS_INVISIBLE, ID_STATUS_OUTTOLUNCH, ID_STATUS_ONTHEPHONE, ID_STATUS_IDLE +}; + +struct AwayMsgInfo +{ + int ignore; + int noDialog; + int usePrevious; + TCHAR msg[1024]; +}; + +struct AwayMsgDlgData +{ + struct AwayMsgInfo info[SIZEOF(statusModes)]; + int oldPage; +}; + +static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + AwayMsgDlgData *dat = (AwayMsgDlgData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + HWND hLst = GetDlgItem(hwndDlg, IDC_LST_STATUS); + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + { + dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData)); + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat); + dat->oldPage = -1; + for (int i = 0; i < SIZEOF(statusModes); i++) { + if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i]))) + continue; + + int j; + if (hLst) { + j = SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); + SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETITEMDATA, j, statusModes[i]); + } + else { + j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0)); + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModes[i]); + } + + dat->info[j].ignore = GetStatusModeByte(statusModes[i], "Ignore"); + dat->info[j].noDialog = GetStatusModeByte(statusModes[i], "NoDlg", true); + dat->info[j].usePrevious = GetStatusModeByte(statusModes[i], "UsePrev"); + + DBVARIANT dbv; + if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Default"), &dbv)) + if (db_get_ts(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Msg"), &dbv)) + dbv.ptszVal = mir_tstrdup(GetDefaultMessage(statusModes[i])); + mir_tstrcpy(dat->info[j].msg, dbv.ptszVal); + mir_free(dbv.ptszVal); + } + if (hLst) + SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETCURSEL, 0, 0); + else + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETCURSEL, 0, 0); + SendMessage(hwndDlg, WM_COMMAND, hLst ? MAKEWPARAM(IDC_LST_STATUS, LBN_SELCHANGE) : MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); + } + return TRUE; + + case WM_MEASUREITEM: + { + LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam; + if (mis->CtlID == IDC_LST_STATUS) + mis->itemHeight = 20; + } + break; + + case WM_DRAWITEM: + { + LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam; + if (dis->CtlID != IDC_LST_STATUS) break; + if (dis->itemID < 0) break; + + TCHAR buf[128]; + SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETTEXT, dis->itemID, (LPARAM)buf); + + if (dis->itemState & (ODS_SELECTED | ODS_FOCUS)) { + FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_HIGHLIGHT)); + SetTextColor(dis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); + } + else { + FillRect(dis->hDC, &dis->rcItem, GetSysColorBrush(COLOR_WINDOW)); + SetTextColor(dis->hDC, GetSysColor(COLOR_WINDOWTEXT)); + } + + RECT rc = dis->rcItem; + DrawIconEx(dis->hDC, 3, (rc.top + rc.bottom - 16) / 2, LoadSkinnedProtoIcon(NULL, dis->itemData), 16, 16, 0, NULL, DI_NORMAL); + rc.left += 25; + SetBkMode(dis->hDC, TRANSPARENT); + DrawText(dis->hDC, buf, -1, &rc, DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX); + } + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_LST_STATUS: + case IDC_STATUS: + if ((HIWORD(wParam) == CBN_SELCHANGE) || (HIWORD(wParam) == LBN_SELCHANGE)) { + int i = hLst ? + SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCURSEL, 0, 0) : + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0); + if (dat->oldPage != -1) { + dat->info[dat->oldPage].ignore = IsDlgButtonChecked(hwndDlg, IDC_DONTREPLY); + dat->info[dat->oldPage].noDialog = IsDlgButtonChecked(hwndDlg, IDC_NODIALOG); + dat->info[dat->oldPage].usePrevious = IsDlgButtonChecked(hwndDlg, IDC_USEPREVIOUS); + GetDlgItemText(hwndDlg, IDC_MSG, dat->info[dat->oldPage].msg, SIZEOF(dat->info[dat->oldPage].msg)); + } + CheckDlgButton(hwndDlg, IDC_DONTREPLY, (i < 0 ? 0 : dat->info[i].ignore) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NODIALOG, (i < 0 ? 0 : dat->info[i].noDialog) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_USEPREVIOUS, (i < 0 ? 0 : dat->info[i].usePrevious) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_USESPECIFIC, (i < 0 ? 0 : !dat->info[i].usePrevious) ? BST_CHECKED : BST_UNCHECKED); + + SetDlgItemText(hwndDlg, IDC_MSG, i < 0 ? _T("") : dat->info[i].msg); + + EnableWindow(GetDlgItem(hwndDlg, IDC_NODIALOG), i < 0 ? 0 : !dat->info[i].ignore); + EnableWindow(GetDlgItem(hwndDlg, IDC_USEPREVIOUS), i < 0 ? 0 : !dat->info[i].ignore); + EnableWindow(GetDlgItem(hwndDlg, IDC_USESPECIFIC), i < 0 ? 0 : !dat->info[i].ignore); + EnableWindow(GetDlgItem(hwndDlg, IDC_MSG), i < 0 ? 0 : !(dat->info[i].ignore || dat->info[i].usePrevious)); + dat->oldPage = i; + } + return 0; + + case IDC_DONTREPLY: + case IDC_USEPREVIOUS: + case IDC_USESPECIFIC: + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); + break; + + case IDC_MSG: + if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()) + return 0; + break; + } + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_STATUS, CBN_SELCHANGE), 0); + { + int i = hLst ? (SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETCOUNT, 0, 0) - 1) : + (SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCOUNT, 0, 0) - 1); + for (; i >= 0; i--) { + int status = hLst ? + SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_GETITEMDATA, i, 0) : + SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, i, 0); + SetStatusModeByte(status, "Ignore", (BYTE)dat->info[i].ignore); + SetStatusModeByte(status, "NoDlg", (BYTE)dat->info[i].noDialog); + SetStatusModeByte(status, "UsePrev", (BYTE)dat->info[i].usePrevious); + db_set_ts(NULL, "SRAway", StatusModeToDbSetting(status, "Default"), dat->info[i].msg); + } + return TRUE; + } + } + break; + } + break; + + case WM_DESTROY: + mir_free(dat); + break; + } + return FALSE; +} + +static int AwayMsgOptInitialise(WPARAM wParam, LPARAM) +{ + if (protoModeMsgFlags == 0) + return 0; + + OPTIONSDIALOGPAGE odp = { sizeof(odp) }; + odp.position = 870000000; + odp.hInstance = hInst; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_AWAYMSG); + odp.pszTitle = LPGEN("Status messages"); + odp.pszGroup = LPGEN("Status"); + odp.pfnDlgProc = DlgProcAwayMsgOpts; + odp.flags = ODPF_BOLDGROUPS; + Options_AddPage(wParam, &odp); + return 0; +} + +static int AwayMsgSendModernOptInit(WPARAM wParam, LPARAM) +{ + if (protoModeMsgFlags == 0) + return 0; + + static const int iBoldControls[] = + { + IDC_TXT_TITLE1, IDC_TXT_TITLE2, IDC_TXT_TITLE3, + MODERNOPT_CTRL_LAST + }; + + MODERNOPTOBJECT obj = { 0 }; + obj.cbSize = sizeof(obj); + obj.hInstance = hInst; + obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE; + obj.iSection = MODERNOPT_PAGE_STATUS; + obj.iType = MODERNOPT_TYPE_SECTIONPAGE; + obj.iBoldControls = (int*)iBoldControls; + obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_STATUS); + obj.pfnDlgProc = DlgProcAwayMsgOpts; + obj.lpzHelpUrl = "http://wiki.miranda-ng.org/"; + CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj); + return 0; +} + +static int AwayMsgSendAccountsChanged(WPARAM, LPARAM) +{ + protoModeMsgFlags = 0; + + int nAccounts; + PROTOACCOUNT** accounts; + ProtoEnumAccounts(&nAccounts, &accounts); + for (int i = 0; i < nAccounts; i++) { + if (!Proto_IsAccountEnabled(accounts[i])) + continue; + + protoModeMsgFlags |= CallProtoService(accounts[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0); + } + + return 0; +} + +static int AwayMsgSendModulesLoaded(WPARAM, LPARAM) +{ + AwayMsgSendAccountsChanged(0, 0); + + HookEvent(ME_CLIST_STATUSMODECHANGE, StatusModeChange); + HookEvent(ME_MODERNOPT_INITIALIZE, AwayMsgSendModernOptInit); + HookEvent(ME_OPT_INITIALISE, AwayMsgOptInitialise); + return 0; +} + +//remember to mir_free() the return value +static INT_PTR sttGetAwayMessageT(WPARAM wParam, LPARAM lParam) +{ + return (INT_PTR)GetAwayMessage((int)wParam, (char*)lParam); +} + +int LoadAwayMessageSending(void) +{ + HookEvent(ME_SYSTEM_MODULESLOADED, AwayMsgSendModulesLoaded); + HookEvent(ME_PROTO_ACCLISTCHANGED, AwayMsgSendAccountsChanged); + + CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSGW, sttGetAwayMessageT); + return 0; +} diff --git a/src/core/stdaway/src/version.h b/src/core/stdaway/src/version.h new file mode 100644 index 0000000000..56f04d9ede --- /dev/null +++ b/src/core/stdaway/src/version.h @@ -0,0 +1,12 @@ +#include + +#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION +#define __VERSION_STRING MIRANDA_VERSION_STRING + +#define __PLUGIN_NAME "Standard Away module" +#define __FILENAME "stdaway.dll" +#define __DESCRIPTION "Core module for the away messages processing." +#define __AUTHOR "Miranda NG Development Team" +#define __AUTHOREMAIL "" +#define __AUTHORWEB "http://miranda-ng.org/p/StdAway/" +#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stdaway/stdaway_10.vcxproj b/src/core/stdaway/stdaway_10.vcxproj index 605797bac1..92d3ed1187 100644 --- a/src/core/stdaway/stdaway_10.vcxproj +++ b/src/core/stdaway/stdaway_10.vcxproj @@ -199,23 +199,21 @@ - - - Create - Create - Create - Create + + + Create - - + + - + + - - + + diff --git a/src/core/stdaway/stdaway_10.vcxproj.filters b/src/core/stdaway/stdaway_10.vcxproj.filters index 5bd397eed2..7d169c18e9 100644 --- a/src/core/stdaway/stdaway_10.vcxproj.filters +++ b/src/core/stdaway/stdaway_10.vcxproj.filters @@ -15,16 +15,16 @@ - + Source Files - + Source Files - + Source Files - + Source Files @@ -32,15 +32,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stdaway/stdaway_12.vcxproj b/src/core/stdaway/stdaway_12.vcxproj index 321332f1f5..36587fd1c1 100644 --- a/src/core/stdaway/stdaway_12.vcxproj +++ b/src/core/stdaway/stdaway_12.vcxproj @@ -202,23 +202,21 @@ - - - Create - Create - Create - Create + + + Create - - + + - + + - - + + diff --git a/src/core/stdaway/stdaway_12.vcxproj.filters b/src/core/stdaway/stdaway_12.vcxproj.filters index 5bd397eed2..7d169c18e9 100644 --- a/src/core/stdaway/stdaway_12.vcxproj.filters +++ b/src/core/stdaway/stdaway_12.vcxproj.filters @@ -15,16 +15,16 @@ - + Source Files - + Source Files - + Source Files - + Source Files @@ -32,15 +32,18 @@ Header Files - + + Header Files + + Header Files - + Resource Files - + Resource Files diff --git a/src/core/stdaway/version.h b/src/core/stdaway/version.h deleted file mode 100644 index b2e0b908c2..0000000000 --- a/src/core/stdaway/version.h +++ /dev/null @@ -1,14 +0,0 @@ - -#include - -#define __FILEVERSION_STRING MIRANDA_VERSION_FILEVERSION -#define __VERSION_STRING MIRANDA_VERSION_STRING - -#define __PLUGIN_NAME "Standard Away module" -#define __INTERNAL_NAME "stdaway" -#define __FILENAME "stdaway.dll" -#define __DESCRIPTION "Core module for the away messages processing." -#define __AUTHOR "Miranda NG Development Team" -#define __AUTHOREMAIL "" -#define __AUTHORWEB "http://miranda-ng.org/p/StdAway/" -#define __COPYRIGHT "© 2012 Miranda NG Development Team" diff --git a/src/core/stdaway/version.rc b/src/core/stdaway/version.rc deleted file mode 100644 index d1da5e8d6a..0000000000 --- a/src/core/stdaway/version.rc +++ /dev/null @@ -1,42 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#ifdef APSTUDIO_INVOKED -#error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - -#include "afxres.h" -#include "version.h" - -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#endif //_WIN32 - -VS_VERSION_INFO VERSIONINFO - FILEVERSION __FILEVERSION_STRING - PRODUCTVERSION __FILEVERSION_STRING - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x0L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "FileDescription", __DESCRIPTION - VALUE "InternalName", __PLUGIN_NAME - VALUE "LegalCopyright", __COPYRIGHT - VALUE "OriginalFilename", __FILENAME - VALUE "ProductName", __PLUGIN_NAME - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END -- cgit v1.2.3