diff options
author | George Hazan <george.hazan@gmail.com> | 2014-02-22 15:43:09 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-02-22 15:43:09 +0000 |
commit | 81c1360e1fd7149a47f0d8c51e27aef811cf2351 (patch) | |
tree | 86da359b1898679f12c15e5a9801774adf35b19c /plugins/NewAwaySysMod | |
parent | 23060dd7bd4c9cb2572582d2ba3ad7a68790b5af (diff) |
- switch to more effective functions of pcli;
- switch to the new protocol helpers;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@8217 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NewAwaySysMod')
-rw-r--r-- | plugins/NewAwaySysMod/src/AwayOpt.cpp | 8 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/AwaySys.cpp | 386 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Client.cpp | 45 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Common.h | 9 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ContactList.cpp | 43 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Properties.cpp | 2 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/Properties.h | 198 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/ReadAwayMsg.cpp | 13 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/SetAwayMsg.cpp | 480 | ||||
-rw-r--r-- | plugins/NewAwaySysMod/src/version.h | 2 |
10 files changed, 482 insertions, 704 deletions
diff --git a/plugins/NewAwaySysMod/src/AwayOpt.cpp b/plugins/NewAwaySysMod/src/AwayOpt.cpp index 20c2109618..1b71f8312a 100644 --- a/plugins/NewAwaySysMod/src/AwayOpt.cpp +++ b/plugins/NewAwaySysMod/src/AwayOpt.cpp @@ -146,7 +146,7 @@ static INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LP // now default status message buttons
for (int i = 0; i < SIZEOF(Dlg1DefMsgDlgItems); i++) {
HWND hButton = GetDlgItem(hwndDlg, Dlg1DefMsgDlgItems[i].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Dlg1DefMsgDlgItems[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg1DefMsgDlgItems[i].Status, 0), BATF_TCHAR);
SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
@@ -375,7 +375,7 @@ static INT_PTR CALLBACK MoreOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_UPDATEMSGSPERIOD_SPIN, UDM_SETRANGE32, 30, 99999);
for (int i = 0; i < SIZEOF(Dlg2StatusButtons); i++) {
HWND hButton = GetDlgItem(hwndDlg, Dlg2StatusButtons[i].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Dlg2StatusButtons[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg2StatusButtons[i].Status, 0), BATF_TCHAR);
SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
}
@@ -528,7 +528,7 @@ INT_PTR CALLBACK AutoreplyOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l for (int i = 0; i < SIZEOF(Dlg3StatusButtons); i++) {
HWND hButton = GetDlgItem(hwndDlg, Dlg3StatusButtons[i].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Dlg3StatusButtons[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg3StatusButtons[i].Status, 0), BATF_TCHAR);
SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
}
@@ -702,7 +702,7 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA // now default status message buttons
for (int i = 0; i < SIZEOF(Dlg4DefMsgDlgItems); i++) {
HWND hButton = GetDlgItem(hwndDlg, Dlg4DefMsgDlgItems[i].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Dlg4DefMsgDlgItems[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)pcli->pfnGetStatusModeDescription(Dlg4DefMsgDlgItems[i].Status, 0), BATF_TCHAR);
SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 9019768c33..179d21e162 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -46,9 +46,9 @@ #include <m_modernopt.h>
HINSTANCE g_hInstance;
+CLIST_INTERFACE *pcli;
int hLangpack = 0;
-LIST<void> hHooks(5), hServices(5);
HANDLE g_hContactMenuItem = NULL, g_hReadStatMenuItem = NULL, /*g_hTopToolbarbutton = NULL, */g_hToggleSOEMenuItem = NULL, g_hToggleSOEContactMenuItem = NULL, g_hAutoreplyOnContactMenuItem = NULL, g_hAutoreplyOffContactMenuItem = NULL, g_hAutoreplyUseDefaultContactMenuItem = NULL;
bool g_fNoProcessing = false; // tells the status change proc not to do anything
int g_bIsIdle = false;
@@ -174,57 +174,35 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) VarParseData.szProto = szProto;
VarParseData.UIN = lParam;
VarParseData.Flags = 0;
- if (!iMode) {
+ if (!iMode)
VarParseData.Flags |= VPF_XSTATUS;
- }
- /*
- int ShowPopup = ((iMode == ID_STATUS_ONLINE && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_ONLNOTIFY)) ||
- (iMode == ID_STATUS_AWAY && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_AWAYNOTIFY)) ||
- (iMode == ID_STATUS_DND && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_DNDNOTIFY)) ||
- (iMode == ID_STATUS_NA && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_NANOTIFY)) ||
- (iMode == ID_STATUS_OCCUPIED && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_OCCNOTIFY)) ||
- (iMode == ID_STATUS_FREECHAT && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_FFCNOTIFY)) ||
- (!iMode && PopupNotifyData.GetValue(IDC_POPUPOPTDLG_OTHERNOTIFY))) &&
- CContactSettings(iMode, hContactForSettings).PopupNotify.IncludingParents();
-
- // Show popup and play a sound
- if (ShowPopup)
- {
- ShowPopup = ShowPopupNotification(PopupNotifyData, hFoundContact, iMode); // we need ShowPopup also to determine whether to log to file or not
- }
- */
- // Log status message request to a file
- // if (!PopupNotifyData.GetValue(IDC_POPUPOPTDLG_LOGONLYWITHPOPUP) || ShowPopup)
- // {
+
TCString LogMsg;
if (!iMode) { // if it's an xstatus message request
LogMsg = db_get_s(NULL, szProto, "XStatusName", _T(""));
TCString XMsg(db_get_s(NULL, szProto, "XStatusMsg", _T("")));
if (XMsg.GetLen()) {
- if (LogMsg.GetLen()) {
+ if (LogMsg.GetLen())
LogMsg += _T("\r\n");
- }
+
LogMsg += XMsg;
}
}
- else {
- LogMsg = VarParseData.Message;
- }
- if (ServiceExists(MS_VARS_FORMATSTRING)) {
+ else LogMsg = VarParseData.Message;
+
+ if (ServiceExists(MS_VARS_FORMATSTRING))
logservice_log(LOG_ID, hFoundContact, LogMsg);
- }
else {
TCString szUIN;
_ultot(lParam, szUIN.GetBuffer(16), 10);
szUIN.ReleaseBuffer();
- TCHAR *szStatDesc = iMode ? (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iMode, 0) : STR_XSTATUSDESC;
+ TCHAR *szStatDesc = iMode ? pcli->pfnGetStatusModeDescription(iMode, 0) : STR_XSTATUSDESC;
if (!szStatDesc) {
_ASSERT(0);
szStatDesc = _T("");
}
- logservice_log(LOG_ID, hFoundContact, TCString((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hFoundContact, GCDNF_TCHAR)) + _T(" (") + szUIN + TranslateT(") read your ") + szStatDesc + TranslateT(" message:\r\n") + LogMsg);
+ logservice_log(LOG_ID, hFoundContact, TCString(pcli->pfnGetContactDisplayName(hFoundContact, 0)) + _T(" (") + szUIN + TranslateT(") read your ") + szStatDesc + TranslateT(" message:\r\n") + LogMsg);
}
- // }
return 0;
}
@@ -238,20 +216,17 @@ MIRANDAHOOK StatusMsgReqHooks[] = { StatusMsgReq1, StatusMsgReq2, StatusMsgReq3, int IsAnICQProto(char *szProto)
{
- int i;
- for (i = 0; i < MAXICQACCOUNTS; i++) {
- if (ICQProtoList[i] == (const char*)szProto) {
+ for (int i = 0; i < MAXICQACCOUNTS; i++)
+ if (ICQProtoList[i] == (const char*)szProto)
return true;
- }
- }
+
return false;
}
-
+// wParam = iMode
+// lParam = (char*)szProto
int StatusChanged(WPARAM wParam, LPARAM lParam)
{
- // wParam = iMode
- // lParam = (char*)szProto
LogMessage("MS_CLIST_SETSTATUSMODE called. szProto=%s, Status=%d", lParam ? (char*)lParam : "NULL", wParam);
g_ProtoStates[(char*)lParam].Status = wParam;
// let's check if we handle this thingy
@@ -266,31 +241,30 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) Flag3 = CallProtoService((char*)lParam, PS_GETCAPS, PFLAGNUM_3, 0);
}
else {
- PROTOACCOUNT **proto;
- int iProtoCount = 0;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&iProtoCount, (LPARAM)&proto);
- int i;
- for (i = 0; i < iProtoCount; i++) {
- Flag1 |= CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
- Flag3 |= CallProtoService(proto[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
+ PROTOACCOUNT **accs;
+ int numAccs = 0;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0; i < numAccs; i++) {
+ Flag1 |= CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0);
+ Flag3 |= CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0);
}
}
- if (!(Flag1 & PF1_MODEMSGSEND || Flag3 & Proto_Status2Flag(wParam) || (Flag1 & PF1_IM) == PF1_IM)) {
+
+ if (!(Flag1 & PF1_MODEMSGSEND || Flag3 & Proto_Status2Flag(wParam) || (Flag1 & PF1_IM) == PF1_IM))
return 0; // there are no protocols with changed status that support autoreply or away messages for this status
- }
+
if (g_SetAwayMsgPage.GetWnd()) {
SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
return 0;
}
+
int i;
- for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--) {
- if (wParam == StatusModeList[i].Status) {
+ for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--)
+ if (wParam == StatusModeList[i].Status)
break;
- }
- }
- if (i < 0) {
+ if (i < 0)
return 0;
- }
+
BOOL bScreenSaverRunning;
SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, &bScreenSaverRunning, 0);
if (bScreenSaverRunning || g_MoreOptPage.GetDBValueCopy(StatusModeList[i].DontShowDialogCtlID)) {
@@ -311,28 +285,28 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) #define ID_STATUS_LAST 40081 // yes, 40081 means internal CommonStatus' ID_STATUS_LAST here, not ID_STATUS_IDLE :-S
#define ID_STATUS_CURRENT 40082
#define ID_STATUS_DISABLED 41083
+
+// wParam = PROTOCOLSETTINGEX** protoSettings
int CSStatusChange(WPARAM wParam, LPARAM lParam) // CommonStatus plugins (StartupStatus and AdvancedAutoAway)
{
- // wParam = PROTOCOLSETTINGEX** protoSettings
PROTOCOLSETTINGEX** ps = *(PROTOCOLSETTINGEX***)wParam;
- if (!ps) {
+ if (!ps)
return -1;
- }
+
LogMessage("ME_CS_STATUSCHANGEEX event:");
- int i;
- for (i = 0; i < g_CSProtoCount; i++) {
+
+ for (int i = 0; i < g_CSProtoCount; i++) {
LogMessage("%d: cbSize=%d, szProto=%s, status=%d, lastStatus=%d, szMsg:", i + 1, ps[i]->cbSize, ps[i]->szName ? (char*)ps[i]->szName : "NULL", ps[i]->status, ps[i]->lastStatus, ps[i]->szMsg ? ps[i]->szMsg : _T("NULL"));
if (ps[i]->status != ID_STATUS_DISABLED) {
- if (ps[i]->status != ID_STATUS_CURRENT) {
+ if (ps[i]->status != ID_STATUS_CURRENT)
g_ProtoStates[ps[i]->szName].Status = (ps[i]->status == ID_STATUS_LAST) ? ps[i]->lastStatus : ps[i]->status;
- }
+
CProtoSettings(ps[i]->szName).SetMsgFormat(SMF_TEMPORARY, ps[i]->szMsg ? ps[i]->szMsg : CProtoSettings(ps[i]->szName).GetMsgFormat(GMF_LASTORDEFAULT));
}
}
return 0;
}
-
static int IdleChangeEvent(WPARAM wParam, LPARAM lParam)
{
LogMessage("ME_IDLE_CHANGED event. lParam=0x%x", lParam); // yes, we don't do anything with status message changes on idle.. there seems to be no any good solution for the wrong status message issue :(
@@ -340,15 +314,13 @@ static int IdleChangeEvent(WPARAM wParam, LPARAM lParam) return 0;
}
-
+// wParam = numAccs
int CSModuleLoaded(WPARAM wParam, LPARAM lParam) // StartupStatus and AdvancedAutoAway
{
- // wParam = ProtoCount
g_CSProtoCount = wParam;
return 0;
}
-
int PreBuildContactMenu(WPARAM hContact, LPARAM lParam)
{
char *szProto = GetContactProto(hContact);
@@ -364,18 +336,20 @@ int PreBuildContactMenu(WPARAM hContact, LPARAM lParam) TCHAR szSetStr[256], szReadStr[256];
if (szProto) {
int i;
- for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--) {
- if (iMode == StatusModeList[i].Status) {
+ for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--)
+ if (iMode == StatusModeList[i].Status)
break;
- }
- }
- if ((Flag1 & PF1_MODEMSGSEND && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iMode)) || ((Flag1 & PF1_IM) == PF1_IM && (i < 0 || !g_AutoreplyOptPage.GetDBValueCopy(StatusModeList[i].DisableReplyCtlID)))) { // the protocol supports status message sending for current status, or autoreplying
- mir_sntprintf(szSetStr, SIZEOF(szSetStr), TranslateT("Set %s message for the contact"), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iMode, GSMDF_TCHAR), CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR));
+
+ // the protocol supports status message sending for current status, or autoreplying
+ if ((Flag1 & PF1_MODEMSGSEND && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iMode)) || ((Flag1 & PF1_IM) == PF1_IM && (i < 0 || !g_AutoreplyOptPage.GetDBValueCopy(StatusModeList[i].DisableReplyCtlID)))) {
+ mir_sntprintf(szSetStr, SIZEOF(szSetStr), TranslateT("Set %s message for the contact"), pcli->pfnGetStatusModeDescription(iMode, 0), pcli->pfnGetContactDisplayName(hContact, 0));
miSetMsg.ptszName = szSetStr;
miSetMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME;
}
- if (Flag1 & PF1_MODEMSGRECV && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iContactMode)) { // the protocol supports status message reading for contact's status
- mir_sntprintf(szReadStr, SIZEOF(szReadStr), TranslateT("Re&ad %s Message"), CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iContactMode, GSMDF_TCHAR));
+
+ // the protocol supports status message reading for contact's status
+ if (Flag1 & PF1_MODEMSGRECV && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(iContactMode)) {
+ mir_sntprintf(szReadStr, SIZEOF(szReadStr), TranslateT("Re&ad %s Message"), pcli->pfnGetStatusModeDescription(iContactMode, 0));
miReadMsg.ptszName = szReadStr;
miReadMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME | CMIM_ICON;
miReadMsg.hIcon = LoadSkinnedProtoIcon(szProto, iContactMode);
@@ -384,15 +358,15 @@ int PreBuildContactMenu(WPARAM hContact, LPARAM lParam) if (g_hContactMenuItem) {
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hContactMenuItem, (LPARAM)&miSetMsg);
- if ((Flag1 & PF1_IM) == PF1_IM) { // if this contact supports sending/receiving messages
+ // if this contact supports sending/receiving messages
+ if ((Flag1 & PF1_IM) == PF1_IM) {
int iAutoreply = CContactSettings(g_ProtoStates[szProto].Status, hContact).Autoreply;
- CLISTMENUITEM mi = { 0 };
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_ICON | CMIM_FLAGS | CMIF_TCHAR;
switch (iAutoreply) {
- case VAL_USEDEFAULT: mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DOT)); break;
- case 0: mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_DISABLED)); break;
- default: iAutoreply = 1; mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_ENABLED)); break;
+ case VAL_USEDEFAULT: mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DOT)); break;
+ case 0: mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_DISABLED)); break;
+ default: iAutoreply = 1; mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_SOE_ENABLED)); break;
}
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hToggleSOEContactMenuItem, (LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIF_TCHAR | (iAutoreply == 1 ? CMIF_CHECKED : 0);
@@ -416,11 +390,11 @@ int PreBuildContactMenu(WPARAM hContact, LPARAM lParam) static INT_PTR SetContactStatMsg(WPARAM hContact, LPARAM lParam)
{
- if (g_SetAwayMsgPage.GetWnd()) // already setting something
- {
+ if (g_SetAwayMsgPage.GetWnd()) { // already setting something
SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
return 0;
}
+
SetAwayMsgData *dat = new SetAwayMsgData;
ZeroMemory(dat, sizeof(SetAwayMsgData));
dat->hInitContact = hContact;
@@ -430,56 +404,27 @@ static INT_PTR SetContactStatMsg(WPARAM hContact, LPARAM lParam) return 0;
}
-/* //NightFox: deleted used-to-be support
-void UpdateSOEButtons(MCONTACT hContact)
-{
-if (!hContact)
-{
-int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].Status).Autoreply;
-CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)g_hTopToolbarbutton, SendOnEvent ? TTBST_PUSHED : TTBST_RELEASED);
-CLISTMENUITEM mi = {0};
-mi.cbSize = sizeof(mi);
-mi.position = 1000020000;
-mi.flags = CMIF_TCHAR | CMIM_NAME | CMIM_ICON; // strange, but CMIF_TCHAR is still necessary even without CMIM_FLAGS
-mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(SendOnEvent ? IDI_SOE_ENABLED : IDI_SOE_DISABLED));
-mi.ptszName = SendOnEvent ? DISABLE_SOE_COMMAND : ENABLE_SOE_COMMAND;
-CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hToggleSOEMenuItem, (LPARAM)&mi);
-}
-if (g_SetAwayMsgPage.GetWnd())
-{
-SendMessage(g_SetAwayMsgPage.GetWnd(), UM_SAM_REPLYSETTINGCHANGED, (WPARAM)hContact, 0);
-}
-}
-*/
-
INT_PTR ToggleSendOnEvent(WPARAM hContact, LPARAM lParam)
{ // used only for the global setting
CContactSettings(g_ProtoStates[hContact ? GetContactProto(hContact) : NULL].Status, hContact).Autoreply.Toggle();
- //UpdateSOEButtons();
return 0;
}
-
INT_PTR srvAutoreplyOn(WPARAM hContact, LPARAM lParam)
{
CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = 1;
- //UpdateSOEButtons(hContact);
return 0;
}
-
INT_PTR srvAutoreplyOff(WPARAM hContact, LPARAM lParam)
{
CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = 0;
- //UpdateSOEButtons(hContact);
return 0;
}
-
INT_PTR srvAutoreplyUseDefault(WPARAM hContact, LPARAM lParam)
{
CContactSettings(g_ProtoStates[GetContactProto(hContact)].Status, hContact).Autoreply = VAL_USEDEFAULT;
- //UpdateSOEButtons(hContact);
return 0;
}
@@ -507,23 +452,18 @@ return 0; static int IconsChanged(WPARAM wParam, LPARAM lParam)
{
g_IconList.ReloadIcons();
- if (g_MessagesOptPage.GetWnd()) {
+
+ if (g_MessagesOptPage.GetWnd())
SendMessage(g_MessagesOptPage.GetWnd(), UM_ICONSCHANGED, 0, 0);
- }
- if (g_MoreOptPage.GetWnd()) {
+
+ if (g_MoreOptPage.GetWnd())
SendMessage(g_MoreOptPage.GetWnd(), UM_ICONSCHANGED, 0, 0);
- }
- if (g_AutoreplyOptPage.GetWnd()) {
+
+ if (g_AutoreplyOptPage.GetWnd())
SendMessage(g_AutoreplyOptPage.GetWnd(), UM_ICONSCHANGED, 0, 0);
- }
- /* if (g_PopupOptPage.GetWnd())
- {
- SendMessage(g_PopupOptPage.GetWnd(), UM_ICONSCHANGED, 0, 0);
- }*/
return 0;
}
-
static int ContactSettingsInit(WPARAM wParam, LPARAM lParam)
{
CONTACTSETTINGSINIT *csi = (CONTACTSETTINGSINIT*)wParam;
@@ -540,15 +480,6 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) csc.StateNum = 3;
csc.DefState = 2; // these settings are used for all controls below
- /*if ((csi->Type == CSIT_GROUP) || IsAnICQProto(szProto))
- {
- csc.Flags = CSCF_TCHAR;
- csc.ptszTitle = LPGENT("New Away System: Status message request notifications");
- csc.ptszGroup = CSGROUP_NOTIFICATIONS;
- csc.ptszTooltip = NULL;
- csc.szSetting = DB_POPUPNOTIFY;
- CallService(MS_CONTACTSETTINGS_ADDCONTROL, wParam, (LPARAM)&csc);
- }*/
int StatusMode = 0;
if (csi->Type == CSIT_CONTACT) {
CContactSettings CSettings(0, csi->hContact);
@@ -558,16 +489,17 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) _ASSERT(csi->Type == CSIT_GROUP);
StatusMode = g_ProtoStates[(char*)NULL].Status;
}
- if (StatusMode == ID_STATUS_OFFLINE) {
+
+ if (StatusMode == ID_STATUS_OFFLINE)
StatusMode = ID_STATUS_AWAY;
- }
+
CString Setting;
TCHAR Title[128];
csc.Flags = CSCF_TCHAR | CSCF_DONT_TRANSLATE_STRINGS; // these Flags and ptszGroup are used for both controls below
csc.ptszGroup = TranslateT("New Away System");
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS)) {
- mir_sntprintf(Title, SIZEOF(Title), TranslateT("Enable autoreply when you are %s"), (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusMode, GSMDF_TCHAR));
+ mir_sntprintf(Title, SIZEOF(Title), TranslateT("Enable autoreply when you are %s"), pcli->pfnGetStatusModeDescription(StatusMode, 0));
csc.ptszTitle = Title;
csc.ptszTooltip = TranslateT("\"Store contact autoreply/ignore settings for each status separately\" is enabled, so this setting is per-contact AND per-status.");
}
@@ -580,7 +512,7 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) CallService(MS_CONTACTSETTINGS_ADDCONTROL, wParam, (LPARAM)&csc);
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS)) {
- mir_sntprintf(Title, SIZEOF(Title), TranslateT("Don't send status message when you are %s"), (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusMode, GSMDF_TCHAR));
+ mir_sntprintf(Title, SIZEOF(Title), TranslateT("Don't send status message when you are %s"), pcli->pfnGetStatusModeDescription(StatusMode, 0));
csc.ptszTitle = Title;
csc.ptszTooltip = TranslateT("Ignore status message requests from this contact and don't send an autoreply.\r\n\"Store contact autoreply/ignore settings for each status separately\" is enabled, so this setting is per-contact AND per-status.");
}
@@ -596,7 +528,6 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) return 0;
}
-
INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam)
{
ARGUMENTSINFO *ai = (ARGUMENTSINFO*)lParam;
@@ -611,18 +542,17 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) Result.ReleaseBuffer();
}
else if (!lstrcmp(ai->targv[0], _T(VAR_STATDESC))) {
- Result = (VarParseData.Flags & VPF_XSTATUS) ? STR_XSTATUSDESC : (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, g_ProtoStates[VarParseData.szProto].Status, GSMDF_TCHAR);
+ Result = (VarParseData.Flags & VPF_XSTATUS) ? STR_XSTATUSDESC : pcli->pfnGetStatusModeDescription(g_ProtoStates[VarParseData.szProto].Status, 0);
}
else if (!lstrcmp(ai->targv[0], _T(VAR_MYNICK))) {
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto) {
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto)
Result = db_get_s(NULL, VarParseData.szProto, "Nick", (TCHAR*)NULL);
- }
- if (Result == NULL) {
- Result = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, NULL, GCDNF_TCHAR);
- }
- if (Result == NULL) {
+
+ if (Result == NULL)
+ Result = pcli->pfnGetContactDisplayName(NULL, 0);
+
+ if (Result == NULL)
Result = TranslateT("Stranger");
- }
}
else if (!lstrcmp(ai->targv[0], _T(VAR_REQUESTCOUNT))) {
mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), db_get_w(ai->fi->hContact, MOD_NAME, DB_REQUESTCOUNT, 0));
@@ -642,36 +572,30 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) ul_Now.QuadPart /= 10000000; // now it's in seconds
Result.GetBuffer(256);
if (ul_Now.LowPart >= 7200) // more than 2 hours
- {
mir_sntprintf(Result, 256, TranslateT("%d hours"), ul_Now.LowPart / 3600);
- }
else if (ul_Now.LowPart >= 120) // more than 2 minutes
- {
mir_sntprintf(Result, 256, TranslateT("%d minutes"), ul_Now.LowPart / 60);
- }
- else {
+ else
mir_sntprintf(Result, 256, TranslateT("%d seconds"), ul_Now.LowPart);
- }
Result.ReleaseBuffer();
}
else if (!lstrcmp(ai->targv[0], _T(VAR_PREDEFINEDMESSAGE))) {
ai->flags = 0; // reset AIF_DONTPARSE flag
- if (ai->argc != 2) {
+ if (ai->argc != 2)
return NULL;
- }
+
COptPage MsgTreeData(g_MsgTreePage);
COptItem_TreeCtrl *TreeCtrl = (COptItem_TreeCtrl*)MsgTreeData.Find(IDV_MSGTREE);
TreeCtrl->DBToMem(CString(MOD_NAME));
- int i;
- for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
+
+ for (int i = 0; i < TreeCtrl->Value.GetSize(); i++) {
if (!(TreeCtrl->Value[i].Flags & TIF_GROUP) && !_tcsicmp(TreeCtrl->Value[i].Title, ai->targv[1])) {
Result = TreeCtrl->Value[i].User_Str1;
break;
}
}
- if (Result == NULL) { // if we didn't find a message with specified title
+ if (Result == NULL) // if we didn't find a message with specified title
return NULL; // return it now, as later we change NULL to ""
- }
}
else if (!lstrcmp(ai->targv[0], _T(VAR_PROTOCOL))) {
if (VarParseData.szProto) {
@@ -680,33 +604,31 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) AnsiResult.ReleaseBuffer();
Result = _A2T(AnsiResult);
}
- if (Result == NULL) { // if we didn't find a message with specified title
+ if (Result == NULL) // if we didn't find a message with specified title
return NULL; // return it now, as later we change NULL to ""
- }
}
TCHAR *szResult;
- if (!(szResult = (TCHAR*)malloc((Result.GetLen() + 1) * sizeof(TCHAR)))) {
+ if (!(szResult = (TCHAR*)malloc((Result.GetLen() + 1) * sizeof(TCHAR))))
return NULL;
- }
+
_tcscpy(szResult, (Result != NULL) ? Result : _T(""));
return (int)szResult;
}
-
INT_PTR srvFreeVarMem(WPARAM wParam, LPARAM lParam)
{
- if (!lParam) {
+ if (!lParam)
return -1;
- }
+
free((void*)lParam);
return 0;
}
-
static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam)
{
- if (name && wParam <= ID_STATUS_OUTTOLUNCH && wParam >= ID_STATUS_OFFLINE) // wParam conditions here are distinctive "features" of PS_SETSTATUS and PS_SETAWAYMSG services, so if wParam does not suit them, we'll pass the control to the old CallService function as soon as possible
- {
+ // wParam conditions here are distinctive "features" of PS_SETSTATUS and PS_SETAWAYMSG services,
+ // so if wParam does not suit them, we'll pass the control to the old CallService function as soon as possible
+ if (name && wParam <= ID_STATUS_OUTTOLUNCH && wParam >= ID_STATUS_OFFLINE) {
const char *pProtoNameEnd = strrchr(name, '/');
if (pProtoNameEnd) {
if (!lstrcmpA(pProtoNameEnd, PS_SETSTATUS)) {
@@ -737,6 +659,24 @@ static INT_PTR MyCallService(const char *name, WPARAM wParam, LPARAM lParam) return g_OldCallService(name, wParam, lParam);
}
+struct
+{
+ TCHAR *Name;
+ char *Descr;
+ int Flags;
+}
+static Variables[] =
+{
+ { _T(VAR_AWAYSINCE_TIME), LPGEN("New Away System\t(x)\tAway since time in default format; ?nas_awaysince_time(x) in format x"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_AWAYSINCE_DATE), LPGEN("New Away System\t(x)\tAway since date in default format; ?nas_awaysince_date(x) in format x"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_STATDESC), LPGEN("New Away System\tStatus description"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_MYNICK), LPGEN("New Away System\tYour nick for current protocol"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_REQUESTCOUNT), LPGEN("New Away System\tNumber of status message requests from the contact"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_MESSAGENUM), LPGEN("New Away System\tNumber of messages from the contact"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_TIMEPASSED), LPGEN("New Away System\tTime passed until request"), TRF_FIELD | TRF_FUNCTION },
+ { _T(VAR_PREDEFINEDMESSAGE), LPGEN("New Away System\t(x)\tReturns one of your predefined messages by its title: ?nas_predefinedmessage(creepy)"), TRF_FUNCTION },
+ { _T(VAR_PROTOCOL), LPGEN("New Away System\tCurrent protocol name"), TRF_FIELD | TRF_FUNCTION }
+};
int MirandaLoaded(WPARAM wParam, LPARAM lParam)
{
@@ -745,50 +685,49 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) InitUpdateMsgs();
g_IconList.ReloadIcons();
- PROTOCOLDESCRIPTOR **proto;
DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &hMainThread, THREAD_SET_CONTEXT, false, 0);
- int iProtoCount = 0;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&iProtoCount, (LPARAM)&proto);
- int i;
- int CurProtoIndex;
- for (i = 0, CurProtoIndex = 0; i < iProtoCount && CurProtoIndex < MAXICQACCOUNTS; i++) {
- if (proto[i]->type == PROTOTYPE_PROTOCOL) {
- HANDLE hHook = HookEvent(CString(proto[i]->szName) + ME_ICQ_STATUSMSGREQ, StatusMsgReqHooks[CurProtoIndex]);
- if (hHook) {
- hHooks.insert(hHook);
- ICQProtoList[CurProtoIndex] = proto[i]->szName;
- CurProtoIndex++;
- }
+
+ int numAccs = 0;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0, CurProtoIndex = 0; i < numAccs && CurProtoIndex < MAXICQACCOUNTS; i++) {
+ HANDLE hHook = HookEvent(CString(accs[i]->szModuleName) + ME_ICQ_STATUSMSGREQ, StatusMsgReqHooks[CurProtoIndex]);
+ if (hHook) {
+ ICQProtoList[CurProtoIndex] = accs[i]->szModuleName;
+ CurProtoIndex++;
}
}
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_SETCONTACTSTATMSG, SetContactStatMsg));
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_TOGGLE, ToggleSendOnEvent));
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_ON, srvAutoreplyOn));
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_OFF, srvAutoreplyOff));
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_USEDEFAULT, srvAutoreplyUseDefault));
- hServices.insert(CreateServiceFunction(MS_NAS_GETSTATEA, GetStateA));
- hServices.insert(CreateServiceFunction(MS_NAS_SETSTATEA, SetStateA));
- hServices.insert(CreateServiceFunction(MS_NAS_GETSTATEW, GetStateW));
- hServices.insert(CreateServiceFunction(MS_NAS_SETSTATEW, SetStateW));
- hServices.insert(CreateServiceFunction(MS_NAS_INVOKESTATUSWINDOW, InvokeStatusWindow));
- hServices.insert(CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, GetStatusMsg));
+
+ CreateServiceFunction(MS_AWAYSYS_SETCONTACTSTATMSG, SetContactStatMsg);
+ CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_TOGGLE, ToggleSendOnEvent);
+ CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_ON, srvAutoreplyOn);
+ CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_OFF, srvAutoreplyOff);
+ CreateServiceFunction(MS_AWAYSYS_AUTOREPLY_USEDEFAULT, srvAutoreplyUseDefault);
+ CreateServiceFunction(MS_NAS_GETSTATEA, GetStateA);
+ CreateServiceFunction(MS_NAS_SETSTATEA, SetStateA);
+ CreateServiceFunction(MS_NAS_GETSTATEW, GetStateW);
+ CreateServiceFunction(MS_NAS_SETSTATEW, SetStateW);
+ CreateServiceFunction(MS_NAS_INVOKESTATUSWINDOW, InvokeStatusWindow);
+ CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, GetStatusMsg);
+
// and old AwaySysMod service, for compatibility reasons
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_SETSTATUSMODE, SetStatusMode));
- //NightFox: none;
- // hHooks.insert(HookEvent(ME_TTB_MODULELOADED, Create_TopToolbar));
- hHooks.insert(HookEvent(ME_OPT_INITIALISE, OptsDlgInit));
- hHooks.insert(HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChanged));
- hHooks.insert(HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChange)); // for compatibility with StartupStatus and AdvancedAutoAway
- hHooks.insert(HookEvent(ME_DB_EVENT_FILTER_ADD, MsgEventAdded));
- hHooks.insert(HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu));
- hHooks.insert(HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged));
- hHooks.insert(HookEvent(ME_IDLE_CHANGED, IdleChangeEvent));
- hHooks.insert(HookEvent(ME_CONTACTSETTINGS_INITIALISE, ContactSettingsInit));
+ CreateServiceFunction(MS_AWAYSYS_SETSTATUSMODE, SetStatusMode);
+
+ // hHooks.insert(HookEvent(ME_TTB_MODULELOADED, Create_TopToolbar);
+ HookEvent(ME_OPT_INITIALISE, OptsDlgInit);
+ HookEvent(ME_CLIST_STATUSMODECHANGE, StatusChanged);
+ HookEvent(ME_CS_STATUSCHANGEEX, CSStatusChange); // for compatibility with StartupStatus and AdvancedAutoAway
+ HookEvent(ME_DB_EVENT_FILTER_ADD, MsgEventAdded);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
+ HookEvent(ME_SKIN_ICONSCHANGED, IconsChanged);
+ HookEvent(ME_IDLE_CHANGED, IdleChangeEvent);
+ HookEvent(ME_CONTACTSETTINGS_INITIALISE, ContactSettingsInit);
+
g_hReadWndList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+
int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].Status).Autoreply;
- CLISTMENUITEM mi = { 0 };
- mi.cbSize = sizeof(mi);
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.position = 1000020000;
mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE;
mi.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(SendOnEvent ? IDI_SOE_ENABLED : IDI_SOE_DISABLED));
@@ -844,36 +783,20 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) }
// add that funky thingy (just tweaked a bit, was spotted in Miranda's src code)
// we have to read the status message from contacts too... err
- hServices.insert(CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetContactStatMsg));
+ CreateServiceFunction(MS_AWAYMSG_SHOWAWAYMSG, GetContactStatMsg);
SkinAddNewSoundEx(AWAYSYS_STATUSMSGREQUEST_SOUND, NULL, LPGEN("NewAwaySys: Incoming status message request"));
if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
- struct
- {
- TCHAR *Name;
- char *Descr;
- int Flags;
- } Variables[] = {
- _T(VAR_AWAYSINCE_TIME), LPGEN("New Away System\t(x)\tAway since time in default format; ?nas_awaysince_time(x) in format x"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_AWAYSINCE_DATE), LPGEN("New Away System\t(x)\tAway since date in default format; ?nas_awaysince_date(x) in format x"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_STATDESC), LPGEN("New Away System\tStatus description"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_MYNICK), LPGEN("New Away System\tYour nick for current protocol"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_REQUESTCOUNT), LPGEN("New Away System\tNumber of status message requests from the contact"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_MESSAGENUM), LPGEN("New Away System\tNumber of messages from the contact"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_TIMEPASSED), LPGEN("New Away System\tTime passed until request"), TRF_FIELD | TRF_FUNCTION,
- _T(VAR_PREDEFINEDMESSAGE), LPGEN("New Away System\t(x)\tReturns one of your predefined messages by its title: ?nas_predefinedmessage(creepy)"), TRF_FUNCTION,
- _T(VAR_PROTOCOL), LPGEN("New Away System\tCurrent protocol name"), TRF_FIELD | TRF_FUNCTION
- };
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_FREEVARMEM, srvFreeVarMem));
- hServices.insert(CreateServiceFunction(MS_AWAYSYS_VARIABLESHANDLER, srvVariablesHandler));
+ CreateServiceFunction(MS_AWAYSYS_FREEVARMEM, srvFreeVarMem);
+ CreateServiceFunction(MS_AWAYSYS_VARIABLESHANDLER, srvVariablesHandler);
+
TOKENREGISTER tr = { 0 };
tr.cbSize = sizeof(TOKENREGISTER);
tr.szService = MS_AWAYSYS_VARIABLESHANDLER;
tr.szCleanupService = MS_AWAYSYS_FREEVARMEM;
tr.memType = TR_MEM_OWNER;
- int i;
- for (i = 0; i < SIZEOF(Variables); i++) {
+ for (int i = 0; i < SIZEOF(Variables); i++) {
tr.flags = Variables[i].Flags | TRF_CALLSVC | TRF_TCHAR;
tr.tszTokenString = Variables[i].Name;
tr.szHelpText = Variables[i].Descr;
@@ -881,19 +804,16 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) }
}
- //NightFox
HookEvent(ME_MODERNOPT_INITIALIZE, ModernOptInitialise);
-
-
return 0;
}
-
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
+ mir_getCLI();
- hHooks.insert(HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded));
+ HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded);
if (db_get_s(NULL, "KnownModules", "New Away System", (char*)NULL) == NULL)
db_set_s(NULL, "KnownModules", "New Away System", MOD_NAME);
@@ -918,16 +838,8 @@ extern "C" int __declspec(dllexport) Load(void) return 0;
}
-
extern "C" int __declspec(dllexport) Unload()
{
CloseHandle(hMainThread);
- int i;
- for (i = 0; i < hHooks.getCount(); i++)
- UnhookEvent(hHooks[i]);
-
- for (i = 0; i < hServices.getCount(); i++)
- DestroyServiceFunction(hServices[i]);
-
return 0;
}
diff --git a/plugins/NewAwaySysMod/src/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index 23e71972a1..6eb74afad8 100644 --- a/plugins/NewAwaySysMod/src/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -30,22 +30,24 @@ HANDLE g_hUpdateMsgsThread = NULL; void __cdecl UpdateMsgsThreadProc(void *)
{
- int ProtoCount;
- PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
+ int numAccs;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+
while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated()) {
DWORD MinUpdateTimeDifference = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGSPERIOD) * 1000; // in milliseconds
- for (int i = 0; i < ProtoCount; i++) {
- if (proto[i]->type == PROTOTYPE_PROTOCOL && CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND && !IsAnICQProto(proto[i]->szName)) {
- int Status = CallProtoService(proto[i]->szName, PS_GETSTATUS, 0, 0);
+ for (int i = 0; i < numAccs; i++) {
+ PROTOACCOUNT *p = accs[i];
+ if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND && !IsAnICQProto(p->szModuleName)) {
+ int Status = CallProtoService(p->szModuleName, PS_GETSTATUS, 0, 0);
if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH) {
- Status = g_ProtoStates[proto[i]->szName].Status;
+ Status = g_ProtoStates[p->szModuleName].Status;
}
- if (CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(Status) && g_ProtoStates[proto[i]->szName].CurStatusMsg.GetUpdateTimeDifference() >= MinUpdateTimeDifference) {
- TCString CurMsg(GetDynamicStatMsg(INVALID_CONTACT_ID, proto[i]->szName));
- if ((TCString)g_ProtoStates[proto[i]->szName].CurStatusMsg != (const TCHAR*)CurMsg) { // if the message has changed
- g_ProtoStates[proto[i]->szName].CurStatusMsg = CurMsg;
- CallAllowedPS_SETAWAYMSG(proto[i]->szName, Status, (char*)_T2A(CurMsg));
+ if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(Status) && g_ProtoStates[p->szModuleName].CurStatusMsg.GetUpdateTimeDifference() >= MinUpdateTimeDifference) {
+ TCString CurMsg(GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName));
+ if ((TCString)g_ProtoStates[p->szModuleName].CurStatusMsg != (const TCHAR*)CurMsg) { // if the message has changed
+ g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg;
+ CallAllowedPS_SETAWAYMSG(p->szModuleName, Status, (char*)_T2A(CurMsg));
}
}
}
@@ -88,16 +90,17 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) g_ProtoStates[szProto].CurStatusMsg = CurMsg;
}
else { // change message of all protocols
- int ProtoCount;
- PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- for (int i = 0; i < ProtoCount; i++) {
- if (proto[i]->type == PROTOTYPE_PROTOCOL && !db_get_b(NULL, proto[i]->szName, "LockMainStatus", 0)) {
+ int numAccs;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0; i < numAccs; i++) {
+ PROTOACCOUNT *p = accs[i];
+ if (!db_get_b(NULL, p->szModuleName, "LockMainStatus", 0)) {
if (Msg == NULL)
- CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, proto[i]->szName);
+ CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, p->szModuleName);
- CallAllowedPS_SETAWAYMSG(proto[i]->szName, iMode, (char*)_T2A(CurMsg));
- g_ProtoStates[proto[i]->szName].CurStatusMsg = CurMsg;
+ CallAllowedPS_SETAWAYMSG(p->szModuleName, iMode, (char*)_T2A(CurMsg));
+ g_ProtoStates[p->szModuleName].CurStatusMsg = CurMsg;
}
}
}
@@ -143,7 +146,7 @@ int GetRecentGroupID(int iMode) return g_Messages_RecentRootID;
for (int Order = 0; Order < TreeCtrl->Value.GetSize(); Order++) // find a group named accordingly to the current status
- if (TreeCtrl->Value[Order].ParentID == g_Messages_RecentRootID && TreeCtrl->Value[Order].Flags & TIF_GROUP && !_tcsicmp(TreeCtrl->Value[Order].Title, iMode ? (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iMode, GSMDF_TCHAR) : MSGTREE_RECENT_OTHERGROUP))
+ if (TreeCtrl->Value[Order].ParentID == g_Messages_RecentRootID && TreeCtrl->Value[Order].Flags & TIF_GROUP && !_tcsicmp(TreeCtrl->Value[Order].Title, iMode ? pcli->pfnGetStatusModeDescription(iMode, 0) : MSGTREE_RECENT_OTHERGROUP))
return TreeCtrl->Value[Order].ID;
return -1;
diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index 03d9a64253..446df14a68 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -44,7 +44,7 @@ #include "m_clist.h"
#include "m_system.h"
#include "m_database.h"
-#include "m_clui.h"
+#include "m_clistint.h"
#include "m_langpack.h"
#include "m_protosvc.h"
#include "m_options.h"
@@ -235,13 +235,6 @@ struct SetAwayMsgData int ISW_Flags; // InvokeStatusWindow service flags
};
-struct READAWAYMSGDATA
-{
- MCONTACT hContact; // contact
- HANDLE hSeq; // sequence for stat msg request
- HANDLE hAwayMsgEvent; // hooked
-};
-
struct VAR_PARSE_DATA
{
char *szProto;
diff --git a/plugins/NewAwaySysMod/src/ContactList.cpp b/plugins/NewAwaySysMod/src/ContactList.cpp index 1be3c4ff8d..88102ed768 100644 --- a/plugins/NewAwaySysMod/src/ContactList.cpp +++ b/plugins/NewAwaySysMod/src/ContactList.cpp @@ -21,16 +21,6 @@ #include "ContactList.h"
#include "Properties.h"
-#define INTM_CONTACTDELETED (WM_USER + 1)
-#define INTM_ICONCHANGED (WM_USER + 2)
-#define INTM_INVALIDATE (WM_USER + 3)
-
-#define HCONTACT_ISGROUP 0x80000000
-#define HCONTACT_ISINFO 0xFFFF0000
-#define IsHContactInfo(h) (((unsigned)(h) & HCONTACT_ISINFO) == HCONTACT_ISINFO)
-#define IsHContactGroup(h) (!IsHContactInfo(h) && ((unsigned)(h) & HCONTACT_ISGROUP))
-#define IsHContactContact(h) (((unsigned)(h) & HCONTACT_ISGROUP) == 0)
-
#define EXTRAICON_XSTEP (GetSystemMetrics(SM_CXSMICON) + 1)
static HANDLE hCLWindowList;
@@ -164,7 +154,9 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
+ TVITEM tvi;
CCList *dat = CWndUserData(GetParent(hWnd)).GetCList();
+
switch (Msg) {
case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact
{
@@ -173,17 +165,15 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar TreeView_DeleteItem(hWnd, hItem);
}
break;
+
case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID
- {
- TVITEM tvi;
- tvi.hItem = dat->FindContact(wParam);
- if (tvi.hItem) {
- tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.iImage = tvi.iSelectedImage = lParam;
- TreeView_SetItem(hWnd, &tvi);
- dat->SortContacts();
- InvalidateRect(hWnd, NULL, false);
- }
+ tvi.hItem = dat->FindContact(wParam);
+ if (tvi.hItem) {
+ tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
+ tvi.iImage = tvi.iSelectedImage = lParam;
+ TreeView_SetItem(hWnd, &tvi);
+ dat->SortContacts();
+ InvalidateRect(hWnd, NULL, false);
}
break;
@@ -350,7 +340,9 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar return CallWindowProc(dat->OrigTreeViewProc, hWnd, Msg, wParam, lParam);
}
-CCList::CCList(HWND hTreeView) : hTreeView(hTreeView), ExtraImageList(NULL)
+CCList::CCList(HWND hTreeView) :
+ hTreeView(hTreeView),
+ ExtraImageList(NULL)
{
CWndUserData(GetParent(hTreeView)).SetCList(this);
OrigTreeViewProc = (WNDPROC)SetWindowLongPtr(hTreeView, GWLP_WNDPROC, (LONG_PTR)ContactListSubclassProc);
@@ -380,7 +372,7 @@ HTREEITEM CCList::AddContact(MCONTACT hContact) TVINSERTSTRUCT tvIns;
ZeroMemory(&tvIns, sizeof(tvIns));
tvIns.hParent = AddGroup(db_get_s(hContact, "CList", "Group", _T("")));
- tvIns.item.pszText = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
+ tvIns.item.pszText = pcli->pfnGetContactDisplayName(hContact, 0);
tvIns.hInsertAfter = TVI_ROOT;
tvIns.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
tvIns.item.iImage = tvIns.item.iSelectedImage = CallService(MS_CLIST_GETCONTACTICON, (WPARAM)hContact, 0);
@@ -388,11 +380,11 @@ HTREEITEM CCList::AddContact(MCONTACT hContact) return TreeView_InsertItem(hTreeView, &tvIns);
}
-typedef struct
+struct sGroupEnumData
{
HANDLE hGroup;
TCString GroupName;
-} sGroupEnumData;
+};
int GroupEnum(const char *szSetting, LPARAM lParam)
{
@@ -497,8 +489,7 @@ static int CALLBACK CompareItemsCallback(LPARAM lParam1, LPARAM lParam2, LPARAM void CCList::SortContacts()
{
- TVSORTCB tvSort;
- ZeroMemory(&tvSort, sizeof(tvSort));
+ TVSORTCB tvSort = { 0 };
tvSort.lpfnCompare = CompareItemsCallback;
tvSort.hParent = TVI_ROOT;
tvSort.lParam = (LPARAM)this;
diff --git a/plugins/NewAwaySysMod/src/Properties.cpp b/plugins/NewAwaySysMod/src/Properties.cpp index b8bee383e1..f0721d3088 100644 --- a/plugins/NewAwaySysMod/src/Properties.cpp +++ b/plugins/NewAwaySysMod/src/Properties.cpp @@ -182,7 +182,7 @@ void CProtoSettings::SetMsgFormat(int Flags, TCString Message) TreeCtrl->DBToMem(CString(MOD_NAME));
int RecentGroupID = GetRecentGroupID(Status);
if (RecentGroupID == -1) { // we didn't find the group, it also means that we're using per status messages; so we need to create it
- TreeCtrl->Value.AddElem(CTreeItem(Status ? (const TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Status, GSMDF_TCHAR) : MSGTREE_RECENT_OTHERGROUP, g_Messages_RecentRootID, RecentGroupID = TreeCtrl->GenerateID(), TIF_GROUP));
+ TreeCtrl->Value.AddElem(CTreeItem(Status ? pcli->pfnGetStatusModeDescription(Status, 0) : MSGTREE_RECENT_OTHERGROUP, g_Messages_RecentRootID, RecentGroupID = TreeCtrl->GenerateID(), TIF_GROUP));
TreeCtrl->SetModified(true);
}
int i;
diff --git a/plugins/NewAwaySysMod/src/Properties.h b/plugins/NewAwaySysMod/src/Properties.h index 0dd66b56d9..b068189332 100644 --- a/plugins/NewAwaySysMod/src/Properties.h +++ b/plugins/NewAwaySysMod/src/Properties.h @@ -27,7 +27,7 @@ #define DB_STATUSMSG "StatusMsg"
#define DB_ENABLEREPLY "EnableReply"
#define DB_IGNOREREQUESTS "IgnoreRequests"
-//#define DB_POPUPNOTIFY "UsePopups"
+
#define DB_UNK_CONTACT_PREFIX "Unk" // DB_ENABLEREPLY, DB_IGNOREREQUESTS and DB_POPUPNOTIFY settings prefix for not-on-list contacts
class _CWndUserData
@@ -39,16 +39,14 @@ public: CCList *CList;
};
-
class CWndUserData
{
public:
- CWndUserData(HWND hWnd): hWnd(hWnd)
+ CWndUserData(HWND hWnd) : hWnd(hWnd)
{
_ASSERT(hWnd);
dat = (_CWndUserData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- if (!dat)
- {
+ if (!dat) {
dat = new _CWndUserData;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)dat);
}
@@ -57,8 +55,7 @@ public: ~CWndUserData()
{
_ASSERT(dat == (_CWndUserData*)GetWindowLongPtr(hWnd, GWLP_USERDATA));
- if (!dat->MsgTree && !dat->CList) // TODO: Uninitialized Memory Read on closing the options dialog - fix it
- {
+ if (!dat->MsgTree && !dat->CList) {
SetWindowLongPtr(hWnd, GWLP_USERDATA, NULL);
delete dat; // TODO: memory leak - this is never executed - fix it
}
@@ -115,14 +112,9 @@ class CIconList public:
~CIconList()
{
- int i;
- for (i = 0; i < IconList.GetSize(); i++)
- {
+ for (int i = 0; i < IconList.GetSize(); i++)
if (IconList[i])
- {
DestroyIcon(IconList[i]);
- }
- }
}
HICON& operator [] (int nIndex) {return IconList[nIndex];}
@@ -131,22 +123,16 @@ public: int cxIcon = GetSystemMetrics(SM_CXSMICON);
int cyIcon = GetSystemMetrics(SM_CYSMICON);
int i;
- for (i = 0; i < SIZEOF(Icons); i++)
- {
+ for (i = 0; i < SIZEOF(Icons); i++) {
if (IconList.GetSize() > i && IconList[i])
- {
DestroyIcon(IconList[i]);
- }
+
if (Icons[i] & IL_SKINICON)
- {
IconList.SetAtGrow(i) = (HICON)CopyImage(LoadSkinnedIcon(Icons[i] & ~IL_SKINICON), IMAGE_ICON, cxIcon, cyIcon, LR_COPYFROMRESOURCE);
- } else if (Icons[i] & IL_PROTOICON)
- {
+ else if (Icons[i] & IL_PROTOICON)
IconList.SetAtGrow(i) = (HICON)CopyImage(LoadSkinnedProtoIcon(NULL, Icons[i] & ~IL_PROTOICON), IMAGE_ICON, cxIcon, cyIcon, LR_COPYFROMRESOURCE);
- } else
- {
+ else
IconList.SetAtGrow(i) = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(Icons[i]), IMAGE_ICON, cxIcon, cyIcon, 0);
- }
}
}
@@ -247,7 +233,7 @@ public: //private:
public:
CString szProto;
- CProtoStates* Parent;
+ CProtoStates *Parent;
};
@@ -260,37 +246,24 @@ public: CProtoStates& operator = (const CProtoStates& States)
{
ProtoStates = States.ProtoStates;
- int i;
- for (i = 0; i < ProtoStates.GetSize(); i++)
- {
+ for (int i = 0; i < ProtoStates.GetSize(); i++)
ProtoStates[i].SetParent(this);
- }
return *this;
}
CProtoState& operator[](const char *szProto)
{
- int i;
- for (i = 0; i < ProtoStates.GetSize(); i++)
- {
+ for (int i = 0; i < ProtoStates.GetSize(); i++)
if (ProtoStates[i].GetProto() == szProto)
- {
return ProtoStates[i];
- }
- }
- if (!szProto) // we need to be sure that we have _all_ protocols in the list, before dealing with global status, so we're adding them here.
- {
- int ProtoCount;
- PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- int i;
- for (i = 0; i < ProtoCount; i++)
- {
- if (proto[i]->type == PROTOTYPE_PROTOCOL)
- {
- (*this)[proto[i]->szName]; // add a protocol if it isn't in the list yet
- }
- }
+
+ // we need to be sure that we have _all_ protocols in the list, before dealing with global status, so we're adding them here.
+ if (!szProto) {
+ int numAccs;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0; i < numAccs; i++)
+ (*this)[accs[i]->szModuleName]; // add a protocol if it isn't in the list yet
}
return ProtoStates[ProtoStates.AddElem(CProtoState(szProto, this))];
}
@@ -313,7 +286,8 @@ static struct {
int Status;
char *Setting;
-} StatusSettings[] = {
+}
+StatusSettings[] = {
ID_STATUS_OFFLINE, "Off",
ID_STATUS_ONLINE, "Onl",
ID_STATUS_AWAY, "Away",
@@ -330,24 +304,22 @@ static struct class CProtoSettings
{
+ LPCSTR szProto;
+
public:
- CProtoSettings(const char *szProto = NULL, int iStatus = 0): szProto(szProto), Status(iStatus, szProto)
+ CProtoSettings(LPCSTR szProto = NULL, int iStatus = 0) :
+ szProto(szProto),
+ Status(iStatus, szProto)
{
Autoreply.Parent = this;
}
CString ProtoStatusToDBSetting(const char *Prefix, int MoreOpt_PerStatusID = 0)
{
- if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID))
- {
- int i;
- for (i = 0; i < SIZEOF(StatusSettings); i++)
- {
+ if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID)) {
+ for (int i = 0; i < SIZEOF(StatusSettings); i++)
if (Status == StatusSettings[i].Status)
- {
return szProto ? (CString(Prefix) + "_" + szProto + "_" + StatusSettings[i].Setting) : (CString(Prefix) + StatusSettings[i].Setting);
- }
- }
}
return szProto ? (CString(Prefix) + "_" + szProto) : CString(Prefix);
}
@@ -359,23 +331,21 @@ public: {
CString Setting(Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY);
if (db_get_b(NULL, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
- {
return *this; // prevent deadlocks when calling UpdateSOEButtons
- }
+
if (Value != VAL_USEDEFAULT)
- {
db_set_b(NULL, MOD_NAME, Setting, Value != 0);
- } else
- {
+ else
db_unset(NULL, MOD_NAME, Setting);
- }
- /*if (!Parent->szProto)
- {
- UpdateSOEButtons();
- }*/
return *this;
}
- operator int() {return db_get_b(NULL, MOD_NAME, Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY, Parent->szProto ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);}
+
+ operator int()
+ {
+ return db_get_b(NULL, MOD_NAME, Parent->szProto ? Parent->ProtoStatusToDBSetting(DB_ENABLEREPLY, IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS) : DB_ENABLEREPLY,
+ Parent->szProto ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY);
+ }
+
int IncludingParents() // takes into account global data also, if per-protocol setting is not defined
{
_ASSERT(Parent->szProto);
@@ -395,9 +365,7 @@ public: operator int()
{
if (!Status)
- {
Status = g_ProtoStates[szProto].Status;
- }
return Status;
}
private:
@@ -407,53 +375,41 @@ public: void SetMsgFormat(int Flags, TCString Message);
TCString GetMsgFormat(int Flags, int *pOrder = NULL);
-
-//NightFox: fix?
-//private:
-public:
- const char *szProto;
};
__inline CString StatusToDBSetting(int Status, const char *Prefix, int MoreOpt_PerStatusID = 0)
{
if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID))
- {
- int i;
- for (i = 0; i < SIZEOF(StatusSettings); i++)
- {
+ for (int i = 0; i < SIZEOF(StatusSettings); i++)
if (Status == StatusSettings[i].Status)
- {
return CString(Prefix) + StatusSettings[i].Setting;
- }
- }
- }
+
return CString(Prefix);
}
__inline CString ContactStatusToDBSetting(int Status, const char *Prefix, int MoreOpt_PerStatusID, MCONTACT hContact)
{
+ // it's a not-on-list contact
if (hContact == INVALID_CONTACT_ID)
- { // it's a not-on-list contact
return CString(DB_UNK_CONTACT_PREFIX) + Prefix;
- }
+
if (hContact)
- {
StatusToDBSetting(Status, Prefix, MoreOpt_PerStatusID);
- }
return CString(Prefix);
}
class CContactSettings
{
+ MCONTACT hContact;
+
public:
CContactSettings(int iStatus = 0, MCONTACT _hContact = NULL): Status(iStatus, hContact), hContact(_hContact)
{
Ignore.Parent = this;
Autoreply.Parent = this;
-// PopupNotify.Parent = this;
}
CString ContactStatusToDBSetting(const char *Prefix, int MoreOpt_PerStatusID = 0)
@@ -469,15 +425,18 @@ public: CString Setting(Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS));
MCONTACT hContact = (Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL;
if (Value)
- {
db_set_b(hContact, MOD_NAME, Setting, 1);
- } else
- {
+ else
db_unset(hContact, MOD_NAME, Setting);
- }
return *this;
}
- operator int() {return db_get_b((Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), 0);}
+
+ operator int()
+ {
+ return db_get_b((Parent->hContact != INVALID_CONTACT_ID) ? Parent->hContact : NULL, MOD_NAME,
+ Parent->ContactStatusToDBSetting(DB_IGNOREREQUESTS, IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS), 0);
+ }
+
friend class CContactSettings;
private:
CContactSettings *Parent;
@@ -504,8 +463,7 @@ public: {
_ASSERT((Parent->hContact && Parent->hContact != INVALID_CONTACT_ID) || szProtoOverride); // we need either correct protocol or a correct hContact to determine its protocol
int Value = *this;
- if (Value == VAL_USEDEFAULT)
- {
+ if (Value == VAL_USEDEFAULT) {
const char *szProto = (Parent->hContact && Parent->hContact != INVALID_CONTACT_ID) ? (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)Parent->hContact, 0) : szProtoOverride;
return CProtoSettings(szProto).Autoreply.IncludingParents();
}
@@ -513,8 +471,7 @@ public: }
int GetNextToggleValue()
{
- switch ((int)*this)
- {
+ switch ((int)*this) {
case VAL_USEDEFAULT: return 0; break;
case 0: return 1; break;
default: return Parent->hContact ? VAL_USEDEFAULT : AUTOREPLY_DEF_REPLY; break;
@@ -526,45 +483,6 @@ public: CContactSettings *Parent;
} Autoreply;
-/* class CPopupNotify
- {
- public:
- CPopupNotify& operator = (const int Value)
- {
- //CString Setting(Parent->ContactStatusToDBSetting(DB_POPUPNOTIFY, 0)); //IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS
- MCONTACT hContact = (Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL;
- if (db_get_b(hContact, MOD_NAME, Setting, VAL_USEDEFAULT) == Value)
- {
- return *this; // prevent deadlocks when calling UpdateSOEButtons
- }
- if (Value != VAL_USEDEFAULT)
- {
- db_set_b(hContact, MOD_NAME, Setting, Value != 0);
- } else
- {
- db_unset(hContact, MOD_NAME, Setting);
- }
- if (!Parent->hContact)
- {
- //UpdateSOEButtons();
- }
- return *this;
- }
- operator int() {return db_get_b((Parent->hContact != INVALID_HANDLE_VALUE) ? Parent->hContact : NULL, MOD_NAME, Parent->ContactStatusToDBSetting(DB_POPUPNOTIFY, 0), Parent->hContact ? VAL_USEDEFAULT : POPUP_DEF_USEPOPUPS);} //IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS
- int IncludingParents() // takes into account protocol and global data also, if per-contact setting is not defined
- {
- int Value = *this;
- if (Value == VAL_USEDEFAULT)
- { // PopupNotify setting is not per-status
- return CContactSettings(ID_STATUS_ONLINE).PopupNotify;
- }
- return Value;
- }
- friend class CContactSettings;
- private:
- CContactSettings *Parent;
- } PopupNotify;
-*/
class CStatus
{
public:
@@ -572,8 +490,7 @@ public: CStatus& operator = (int Status) {this->Status = Status; return *this;}
operator int()
{
- if (!Status)
- {
+ if (!Status) {
_ASSERT(hContact != INVALID_CONTACT_ID);
char *szProto = hContact ? GetContactProto(hContact) : NULL;
Status = (szProto || !hContact) ? g_ProtoStates[szProto].Status : ID_STATUS_AWAY;
@@ -589,9 +506,4 @@ public: void SetMsgFormat(int Flags, TCString Message);
TCString GetMsgFormat(int Flags, int *pOrder = NULL, char *szProtoOverride = NULL);
-
-//NightFox: fix?
-//private:
-public:
- MCONTACT hContact;
};
diff --git a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp index 1ce86f628b..5b7b9efb70 100644 --- a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp @@ -21,6 +21,13 @@ #include "Common.h"
+struct READAWAYMSGDATA
+{
+ MCONTACT hContact; // contact
+ HANDLE hSeq; // sequence for stat msg request
+ HANDLE hAwayMsgEvent; // hooked
+};
+
#define RAMDLGSIZESETTING "ReadAwayMsgDlg"
HANDLE g_hReadWndList = NULL;
@@ -50,6 +57,7 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hTitleIcon);
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hTitleIcon);
Utils_RestoreWindowPosition(hwndDlg, NULL, MOD_NAME, RAMDLGSIZESETTING);
+
READAWAYMSGDATA *awayData = new READAWAYMSGDATA;
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)awayData);
awayData->hContact = lParam;
@@ -58,10 +66,9 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam WindowList_Add(g_hReadWndList, hwndDlg, awayData->hContact);
TCHAR str[256], format[128];
- TCHAR *status, *contactName;
- contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)awayData->hContact, GCDNF_TCHAR);
+ TCHAR *contactName = pcli->pfnGetContactDisplayName(awayData->hContact, 0);
char *szProto = GetContactProto(awayData->hContact);
- status = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), GSMDF_TCHAR);
+ TCHAR *status = pcli->pfnGetStatusModeDescription(db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), 0);
GetWindowText(hwndDlg, format, SIZEOF(format));
_sntprintf(str, SIZEOF(str), format, status, contactName);
SetWindowText(hwndDlg, str);
diff --git a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index f934d45022..ea3d95e58e 100644 --- a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -438,16 +438,18 @@ HICON g_LoadIconEx(const char* name, bool big) return Skin_GetIcon(szSettingName, big);
}
-static struct {
+struct {
int DlgItem, IconIndex;
TCHAR* Text;
-} Buttons[] = {
- IDC_SAWAYMSG_SAVEMSG, ILI_SAVE, LPGENT("Save, replacing the selected message"),
- IDC_SAWAYMSG_SAVEASNEW, ILI_SAVEASNEW, LPGENT("Save as a new message"),
- IDC_SAWAYMSG_NEWCATEGORY, ILI_NEWCATEGORY, LPGENT("Create new category"),
- IDC_SAWAYMSG_DELETE, ILI_DELETE, LPGENT("Delete"),
- IDC_SAWAYMSG_VARS, ILI_NOICON, LPGENT("Open Variables help dialog"),
- IDC_SAWAYMSG_OPTIONS, ILI_SETTINGS, LPGENT("Show settings menu")
+}
+static Buttons[] =
+{
+ { IDC_SAWAYMSG_SAVEMSG, ILI_SAVE, LPGENT("Save, replacing the selected message") },
+ { IDC_SAWAYMSG_SAVEASNEW, ILI_SAVEASNEW, LPGENT("Save as a new message") },
+ { IDC_SAWAYMSG_NEWCATEGORY, ILI_NEWCATEGORY, LPGENT("Create new category") },
+ { IDC_SAWAYMSG_DELETE, ILI_DELETE, LPGENT("Delete") },
+ { IDC_SAWAYMSG_VARS, ILI_NOICON, LPGENT("Open Variables help dialog") },
+ { IDC_SAWAYMSG_OPTIONS, ILI_SETTINGS, LPGENT("Show settings menu") }
};
struct {
@@ -467,6 +469,9 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA static int Countdown;
static CMsgTree *MsgTree = NULL;
static CCList *CList = NULL;
+
+ NMCLIST nm;
+
switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -550,7 +555,6 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE))
SendMessage(hwndDlg, UM_SAM_INITCLIST, 0, 0);
else {
- NMCLIST nm;
nm.hdr.code = MCLN_SELCHANGED;
nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
nm.hdr.idFrom = IDC_SAWAYMSG_CONTACTSTREE;
@@ -597,8 +601,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
// init image buttons
- int i;
- for (i = 0; i < SIZEOF(Buttons); i++) {
+ for (int i = 0; i < SIZEOF(Buttons); i++) {
HWND hButton = GetDlgItem(hwndDlg, Buttons[i].DlgItem);
SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Buttons[i].Text), BATF_TCHAR);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
@@ -609,7 +612,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA hWndTooltips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
- for (i = 0; i < SIZEOF(Tooltips); i++) {
+ for (int i = 0; i < SIZEOF(Tooltips); i++) {
ti.uId = (UINT)GetDlgItem(hwndDlg, Tooltips[i].DlgItemID);
ti.lpszText = TranslateTS(Tooltips[i].Text);
SendMessage(hWndTooltips, TTM_ADDTOOL, 0, (LPARAM)&ti);
@@ -626,237 +629,202 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA case WM_NOTIFY:
switch (((NMHDR*)lParam)->idFrom) {
case IDC_SAWAYMSG_CONTACTSTREE:
- {
- switch (((NMHDR*)lParam)->code) // check the notification code
- {
+ switch (((NMHDR*)lParam)->code) { // check the notification code
case NM_CLICK:
- {
_ASSERT(CList);
- HWND hTreeView = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
- POINT pt = { (short)LOWORD(GetMessagePos()), (short)HIWORD(GetMessagePos()) };
- ScreenToClient(hTreeView, &pt);
- DWORD hitFlags;
- HTREEITEM hItem = CList->HitTest(&pt, &hitFlags);
- if (hitFlags & MCLCHT_ONITEMEXTRA) {
- int nColumn = HIBYTE(HIWORD(hitFlags));
- int CurIcon = CList->GetExtraImage(hItem, nColumn);
- int ItemType = CList->GetItemType(hItem);
- if (nColumn == EXTRACOLUMN_IGNORE) {
- CurIcon = (CurIcon == EXTRAIMGLIST_IGNORE) ? EXTRAIMGLIST_DOT : EXTRAIMGLIST_IGNORE;
- }
- else {
- _ASSERT(nColumn == EXTRACOLUMN_REPLY);
- switch (CurIcon) {
- case EXTRAIMGLIST_DOT: CurIcon = EXTRAIMGLIST_AUTOREPLY_OFF; break;
- case EXTRAIMGLIST_AUTOREPLY_OFF: CurIcon = EXTRAIMGLIST_AUTOREPLY_ON; break;
- case EXTRAIMGLIST_AUTOREPLY_ON: CurIcon = EXTRAIMGLIST_DOT; break;
+ {
+ HWND hTreeView = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
+ POINT pt = { (short)LOWORD(GetMessagePos()), (short)HIWORD(GetMessagePos()) };
+ ScreenToClient(hTreeView, &pt);
+ DWORD hitFlags;
+ HTREEITEM hItem = CList->HitTest(&pt, &hitFlags);
+ if (hitFlags & MCLCHT_ONITEMEXTRA) {
+ int nColumn = HIBYTE(HIWORD(hitFlags));
+ int CurIcon = CList->GetExtraImage(hItem, nColumn);
+ int ItemType = CList->GetItemType(hItem);
+ if (nColumn == EXTRACOLUMN_IGNORE)
+ CurIcon = (CurIcon == EXTRAIMGLIST_IGNORE) ? EXTRAIMGLIST_DOT : EXTRAIMGLIST_IGNORE;
+ else {
+ _ASSERT(nColumn == EXTRACOLUMN_REPLY);
+ switch (CurIcon) {
+ case EXTRAIMGLIST_DOT: CurIcon = EXTRAIMGLIST_AUTOREPLY_OFF; break;
+ case EXTRAIMGLIST_AUTOREPLY_OFF: CurIcon = EXTRAIMGLIST_AUTOREPLY_ON; break;
+ case EXTRAIMGLIST_AUTOREPLY_ON: CurIcon = EXTRAIMGLIST_DOT; break;
+ }
}
- }
- SetExtraIcon(CList, nColumn, hItem, CurIcon);
- if (ItemType == MCLCIT_GROUP) // set all child items
- {
- HTREEITEM hCurItem = CList->GetNextItem(MCLGN_CHILD, hItem);
- HTREEITEM hLimitItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_NOTCHILD, hItem);
- while (hCurItem && hCurItem != hLimitItem) {
- SetExtraIcon(CList, nColumn, hCurItem, CurIcon);
- hCurItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, hCurItem);
+ SetExtraIcon(CList, nColumn, hItem, CurIcon);
+ if (ItemType == MCLCIT_GROUP) { // set all child items
+ HTREEITEM hCurItem = CList->GetNextItem(MCLGN_CHILD, hItem);
+ HTREEITEM hLimitItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_NOTCHILD, hItem);
+ while (hCurItem && hCurItem != hLimitItem) {
+ SetExtraIcon(CList, nColumn, hCurItem, CurIcon);
+ hCurItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, hCurItem);
+ }
}
+ SetCListGroupIcons(dat, CList);
+ UpdateCheckboxesState(CList);
}
- SetCListGroupIcons(dat, CList);
- UpdateCheckboxesState(CList);
}
- } break;
+ break;
+
case MCLN_SELCHANGED:
- {
- PNMCLIST nm = (PNMCLIST)lParam;
- TCString BtnTitle(TranslateT("OK"));
- if (CList) {
- UpdateCheckboxesState(CList);
- }
- bool bOnlyInfo;
- bool bLeaveOldMessage = nm->OldSelection == nm->NewSelection; // OldSelection == NewSelection when we send MCLN_SELCHANGED from UM_SAM_PROTOSTATUSCHANGED; seems that it's better to leave old message then
- int nOldContacts = GetSelContactsNum(CList, nm->OldSelection);
- int nNewContacts = GetSelContactsNum(CList, nm->NewSelection, &bOnlyInfo);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_IGNOREREQ), !bOnlyInfo);
- if (CList) {
- if (SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_GETMODIFY, 0, 0)) {
- int i, J;
- for (i = nm->OldSelection->GetSize() - 1; i >= 0; i--) {
- for (J = nm->NewSelection->GetSize() - 1; J >= 0; J--) {
- if ((*nm->NewSelection)[J] == (*nm->OldSelection)[i]) {
+ {
+ PNMCLIST nm = (PNMCLIST)lParam;
+ TCString BtnTitle(TranslateT("OK"));
+ if (CList)
+ UpdateCheckboxesState(CList);
+
+ bool bOnlyInfo;
+ bool bLeaveOldMessage = nm->OldSelection == nm->NewSelection; // OldSelection == NewSelection when we send MCLN_SELCHANGED from UM_SAM_PROTOSTATUSCHANGED; seems that it's better to leave old message then
+ int nOldContacts = GetSelContactsNum(CList, nm->OldSelection);
+ int nNewContacts = GetSelContactsNum(CList, nm->NewSelection, &bOnlyInfo);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_IGNOREREQ), !bOnlyInfo);
+ if (CList) {
+ if (SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_GETMODIFY, 0, 0)) {
+ int i, j;
+ for (i = nm->OldSelection->GetSize() - 1; i >= 0; i--) {
+ for (j = nm->NewSelection->GetSize() - 1; j >= 0; j--)
+ if ((*nm->NewSelection)[j] == (*nm->OldSelection)[i])
+ break;
+ if (j < 0)
break;
- }
- }
- if (J < 0) {
- break;
}
- }
- if (nNewContacts > 1) {
- BtnTitle = TranslateT("Apply");
- }
- if (i >= 0 && nOldContacts) // there's at least one item in the old selection that is not present in the new one
- {
- if ((nOldContacts == 1) || MessageBox(hwndDlg, TranslateT("Do you want to apply the message?"), TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO) == IDYES) {
- ApplySelContactsMessage(dat, CList, nm->OldSelection);
+ if (nNewContacts > 1)
+ BtnTitle = TranslateT("Apply");
+
+ // there's at least one item in the old selection that is not present in the new one
+ if (i >= 0 && nOldContacts) {
+ if ((nOldContacts == 1) || MessageBox(hwndDlg, TranslateT("Do you want to apply the message?"), TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO) == IDYES)
+ ApplySelContactsMessage(dat, CList, nm->OldSelection);
}
- }
- else if (nOldContacts) {
- bLeaveOldMessage = true; // don't change the edit control text yet - we're still writing...
+ else if (nOldContacts)
+ bLeaveOldMessage = true; // don't change the edit control text yet - we're still writing...
}
}
- }
- else {
- if (nOldContacts && !nNewContacts) {
+ else if (nOldContacts && !nNewContacts)
ApplySelContactsMessage(dat, CList, nm->OldSelection);
- }
- }
- // determine the right new message and window title for the edit control now
- TCString Message;
- int Status = 0;
- if (CList) {
- bool MessageDetermined = false;
- bool StatusDetermined = false;
- int i;
- for (i = 0; i < nm->NewSelection->GetSize(); i++) {
- HTREEITEM hItem = (*nm->NewSelection)[i];
- MCONTACT hContact;
- char *szProto;
- int ItemType = CList->GetItemType(hItem);
- if (ItemType == MCLCIT_CONTACT) {
- hContact = CList->GethContact(hItem);
- _ASSERT(hContact);
- szProto = GetContactProto(hContact);
- _ASSERT(szProto);
- }
- else if (ItemType == MCLCIT_INFO) {
- szProto = (char*)CList->GetItemParam(hItem);
- }
- if (ItemType == MCLCIT_CONTACT || ItemType == MCLCIT_INFO) {
- int CurStatus = g_ProtoStates[szProto].Status;
- if (!MessageDetermined) {
- TCString CurMessage((ItemType == MCLCIT_CONTACT) ? CContactSettings(0, hContact).GetMsgFormat(GMF_PERSONAL) : CProtoSettings(szProto).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL));
- if (CurMessage == NULL) {
- CurMessage = _T("");
- }
- if (Message == NULL) {
- Message = CurMessage;
- }
- else if (CurMessage != (const TCHAR*)Message) {
- Message = _T("");
- BtnTitle = TranslateT("Apply");
- MessageDetermined = true;
- }
- }
- if (!StatusDetermined) {
- if (!Status) {
- Status = CurStatus;
- }
- else if (CurStatus != Status) {
- Status = 0;
- StatusDetermined = true;
- }
- }
- }
- }
- }
- else if (nNewContacts) // if (!CList)
- {
- Status = g_ProtoStates[dat->szProtocol].Status;
- Message = dat->hInitContact ? CContactSettings(0, dat->hInitContact).GetMsgFormat(GMF_PERSONAL) : CProtoSettings(dat->szProtocol).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL);
- }
- if (!bLeaveOldMessage) {
- SetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, (Message == NULL) ? _T("") : Message);
- }
- SetDlgItemText(hwndDlg, IDC_OK, BtnTitle);
- //NightFox: fix titlebar
- //TCString WindowTitle(TranslateT("Set "));
- TCString WindowTitle(TranslateT("Set message for"));
- WindowTitle += _T(" \"");
- WindowTitle += Status ? (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, Status, GSMDF_TCHAR) : TranslateT("Statuses");
- //WindowTitle += TranslateT(" message");
- if (nNewContacts == 1) {
- WindowTitle += TCString(TranslateT("\" ("));
- MCONTACT hContact = NULL;
- char *szProto = NULL;
+ // determine the right new message and window title for the edit control now
+ TCString Message;
+ int Status = 0;
if (CList) {
- int i;
- for (i = 0; i < nm->NewSelection->GetSize(); i++) {
+ bool MessageDetermined = false;
+ bool StatusDetermined = false;
+ for (int i = 0; i < nm->NewSelection->GetSize(); i++) {
HTREEITEM hItem = (*nm->NewSelection)[i];
+ MCONTACT hContact;
+ char *szProto;
int ItemType = CList->GetItemType(hItem);
if (ItemType == MCLCIT_CONTACT) {
- hContact = CList->GethContact((*nm->NewSelection)[i]);
- break;
+ hContact = CList->GethContact(hItem);
+ _ASSERT(hContact);
+ szProto = GetContactProto(hContact);
+ _ASSERT(szProto);
}
- else if (ItemType == MCLCIT_INFO) {
+ else if (ItemType == MCLCIT_INFO)
szProto = (char*)CList->GetItemParam(hItem);
- break;
+
+ if (ItemType == MCLCIT_CONTACT || ItemType == MCLCIT_INFO) {
+ int CurStatus = g_ProtoStates[szProto].Status;
+ if (!MessageDetermined) {
+ TCString CurMessage((ItemType == MCLCIT_CONTACT) ? CContactSettings(0, hContact).GetMsgFormat(GMF_PERSONAL) : CProtoSettings(szProto).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL));
+ if (CurMessage == NULL)
+ CurMessage = _T("");
+
+ if (Message == NULL)
+ Message = CurMessage;
+ else if (CurMessage != (const TCHAR*)Message) {
+ Message = _T("");
+ BtnTitle = TranslateT("Apply");
+ MessageDetermined = true;
+ }
+ }
+ if (!StatusDetermined) {
+ if (!Status)
+ Status = CurStatus;
+ else if (CurStatus != Status) {
+ Status = 0;
+ StatusDetermined = true;
+ }
+ }
}
}
}
- else {
- hContact = dat->hInitContact;
- szProto = dat->szProtocol;
+ else if (nNewContacts) {
+ Status = g_ProtoStates[dat->szProtocol].Status;
+ Message = dat->hInitContact ? CContactSettings(0, dat->hInitContact).GetMsgFormat(GMF_PERSONAL) : CProtoSettings(dat->szProtocol).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL);
}
- if (hContact) {
- if (IsAnICQProto(GetContactProto(hContact))) {
- WindowTitle += TranslateT("message for");
- WindowTitle += _T(" ");
+ if (!bLeaveOldMessage)
+ SetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, (Message == NULL) ? _T("") : Message);
+
+ SetDlgItemText(hwndDlg, IDC_OK, BtnTitle);
+ TCString WindowTitle(TranslateT("Set message for"));
+ WindowTitle += _T(" \"");
+ WindowTitle += Status ? pcli->pfnGetStatusModeDescription(Status, 0) : TranslateT("Statuses");
+ if (nNewContacts == 1) {
+ WindowTitle += TCString(TranslateT("\" ("));
+ MCONTACT hContact = NULL;
+ char *szProto = NULL;
+ if (CList) {
+ for (int i = 0; i < nm->NewSelection->GetSize(); i++) {
+ HTREEITEM hItem = (*nm->NewSelection)[i];
+ int ItemType = CList->GetItemType(hItem);
+ if (ItemType == MCLCIT_CONTACT) {
+ hContact = CList->GethContact((*nm->NewSelection)[i]);
+ break;
+ }
+ if (ItemType == MCLCIT_INFO) {
+ szProto = (char*)CList->GetItemParam(hItem);
+ break;
+ }
+ }
}
else {
- WindowTitle += TranslateT("for");
- WindowTitle += _T(" ");
+ hContact = dat->hInitContact;
+ szProto = dat->szProtocol;
}
+ if (hContact) {
+ if (IsAnICQProto(GetContactProto(hContact))) {
+ WindowTitle += TranslateT("message for");
+ WindowTitle += _T(" ");
+ }
+ else {
+ WindowTitle += TranslateT("for");
+ WindowTitle += _T(" ");
+ }
- WindowTitle += (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
- if (!IsAnICQProto(GetContactProto(hContact))) {
- //WindowTitle += TranslateT(" (autoreply only)");
- WindowTitle += _T(" ");
- WindowTitle += TranslateT("available autoreply only");
- WindowTitle += _T(")");
+ WindowTitle += (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
+ if (!IsAnICQProto(GetContactProto(hContact))) {
+ WindowTitle += _T(" ");
+ WindowTitle += TranslateT("available autoreply only");
+ WindowTitle += _T(")");
+ }
+ else WindowTitle += _T(")");
}
else {
- WindowTitle += _T(")");
+ if (!szProto) {
+ WindowTitle += TranslateT("all accounts");
+ WindowTitle += _T(")");
+ }
+ else {
+ PROTOACCOUNT *acc = ProtoGetAccount(szProto);
+ WindowTitle += acc->tszAccountName;
+ WindowTitle += _T(")");
+ }
}
}
- else {
- if (!szProto) {
- //WindowTitle += TranslateT("all contacts");
- WindowTitle += TranslateT("all accounts");
- WindowTitle += _T(")");
- }
- else {
- //CString ProtoTitle;
-
- /*if (CallProtoService(szProto, PS_GETNAME, 256, (LPARAM)ProtoTitle.GetBuffer(256)))
- { // on a failure, set ProtoTitle to an empty string
- //ProtoTitle[0] = '\0';
- }*/
- //ProtoTitle.ReleaseBuffer();
- //WindowTitle += _A2T(ProtoTitle) + TranslateT(" protocol");
-
- PROTOACCOUNT * acc = ProtoGetAccount(szProto);
+ else WindowTitle += _T("\"");
- WindowTitle += acc->tszAccountName;
- //WindowTitle += _T(" ");
- //WindowTitle += TranslateT("account");
- WindowTitle += _T(")");
- }
- }
- }
- else {
- WindowTitle += _T("\"");
+ SetWindowText(hwndDlg, WindowTitle);
}
- SetWindowText(hwndDlg, WindowTitle);
- } break;
}
break;
+
case IDC_SAWAYMSG_TREE:
switch (((NMHDR*)lParam)->code) {
case MTN_SELCHANGED:
- {
if (!UpdateLock) {
PNMMSGTREE pnm = (PNMMSGTREE)lParam;
if (pnm->ItemNew && !(pnm->ItemNew->Flags & (TIF_ROOTITEM | TIF_GROUP))) {
@@ -865,14 +833,12 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETMODIFY, true, 0);
EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), true);
}
- else {
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), false);
- }
+ else EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), false);
+
EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_DELETE), pnm->ItemNew && !(pnm->ItemNew->Flags & TIF_ROOTITEM));
}
- } break;
}
- } break;
+ break;
}
return true;
@@ -904,24 +870,17 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA HTREEITEM hSelItem;
HTREEITEM hItem = hSelItem = CList->AddInfo(TranslateT("** All contacts **"), CLC_ROOT, CLC_ROOT, NULL, LoadSkinnedProtoIcon(NULL, g_ProtoStates[(char*)NULL].Status));
- int ProtoCount;
- PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- int i;
- for (i = 0; i < ProtoCount; i++) {
- if (proto[i]->type == PROTOTYPE_PROTOCOL && CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) // don't forget to change Recent Message Save loop in the UM_SAM_APPLYANDCLOSE if you're changing something here
- {
- //CString ProtoTitle;
- //CallProtoService(proto[i]->szName, PS_GETNAME, 256, (LPARAM)ProtoTitle.GetBuffer(256));
- //ProtoTitle.ReleaseBuffer();
-
- PROTOACCOUNT * acc = ProtoGetAccount(proto[i]->szName);
- //NightFox: protocols -> accounts
- //hItem = CList->AddInfo(TCString(_T("* ")) + _A2T(ProtoTitle) + TranslateT(" contacts *"), CLC_ROOT, hItem, (LPARAM)proto[i]->szName, LoadSkinnedProtoIcon(proto[i]->szName, g_ProtoStates[proto[i]->szName].Status));
- hItem = CList->AddInfo(TCString(_T("* ")) + acc->tszAccountName/* + TranslateT(" contacts *")*/ + _T(" *"), CLC_ROOT, hItem, (LPARAM)proto[i]->szName, LoadSkinnedProtoIcon(proto[i]->szName, g_ProtoStates[proto[i]->szName].Status));
- if (dat->szProtocol && !strcmp(proto[i]->szName, dat->szProtocol)) {
+ int numAccs;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0; i < numAccs; i++) {
+ PROTOACCOUNT *p = accs[i];
+ // don't forget to change Recent Message Save loop in the UM_SAM_APPLYANDCLOSE if you're changing something here
+ if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
+ PROTOACCOUNT * acc = ProtoGetAccount(p->szModuleName);
+ hItem = CList->AddInfo(TCString(_T("* ")) + acc->tszAccountName + _T(" *"), CLC_ROOT, hItem, (LPARAM)p->szModuleName, LoadSkinnedProtoIcon(p->szModuleName, g_ProtoStates[p->szModuleName].Status));
+ if (dat->szProtocol && !strcmp(p->szModuleName, dat->szProtocol))
hSelItem = hItem;
- }
}
}
@@ -933,12 +892,13 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA int Flag1 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
if ((Flag1 & PF1_IM) == PF1_IM || Flag1 & PF1_INDIVMODEMSG) { // check if the protocol supports message sending/receiving or individual status messages before adding this contact
HTREEITEM hItem = CList->AddContact(hContact);
- if (dat->hInitContact == hContact) {
+ if (dat->hInitContact == hContact)
hSelItem = hItem;
- }
}
}
- } while (hContact = db_find_next(hContact));
+ }
+ while (hContact = db_find_next(hContact));
+
CList->SortContacts();
hItem = CLC_ROOT;
while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem)) {
@@ -953,11 +913,9 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA case UM_SAM_APPLYANDCLOSE:
KillTimer(hwndDlg, SAM_TIMER_ID);
- if (CList) {
+ if (CList)
CList->SelectItem(NULL);
- }
else {
- NMCLIST nm;
nm.hdr.code = MCLN_SELCHANGED;
nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
nm.hdr.idFrom = IDC_SAWAYMSG_CONTACTSTREE;
@@ -968,15 +926,16 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA MsgTree->Save();
{
// save Recent Messages
- int ProtoCount;
- PROTOCOLDESCRIPTOR **proto;
- CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- for (int i = 0; i < ProtoCount; i++) {
- if (proto[i]->type == PROTOTYPE_PROTOCOL && CallProtoService(proto[i]->szName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
- TCString Message(CProtoSettings(proto[i]->szName).GetMsgFormat(GMF_PERSONAL)); // yes, we don't specify GMF_TEMPORARY here, because we don't need to save it
+ int numAccs;
+ PROTOACCOUNT **accs;
+ ProtoEnumAccounts(&numAccs, &accs);
+ for (int i = 0; i < numAccs; i++) {
+ PROTOACCOUNT *p = accs[i];
+ if (CallProtoService(p->szModuleName, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_MODEMSGSEND) {
+ TCString Message(CProtoSettings(p->szModuleName).GetMsgFormat(GMF_PERSONAL)); // yes, we don't specify GMF_TEMPORARY here, because we don't need to save it
if (Message != NULL)
- CProtoSettings(proto[i]->szName).SetMsgFormat(SMF_LAST, Message); // if the user set a message for this protocol, save it to the recent messages
- ChangeProtoMessages(proto[i]->szName, g_ProtoStates[proto[i]->szName].Status, TCString(NULL)); // and actual setting of a status message for the protocol
+ CProtoSettings(p->szModuleName).SetMsgFormat(SMF_LAST, Message); // if the user set a message for this protocol, save it to the recent messages
+ ChangeProtoMessages(p->szModuleName, g_ProtoStates[p->szModuleName].Status, TCString(NULL)); // and actual setting of a status message for the protocol
}
}
TCString Message(CProtoSettings().GetMsgFormat(GMF_PERSONAL));
@@ -1030,6 +989,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA UpdateCheckboxesState(CList);
}
break;
+
case UM_SAM_PROTOSTATUSCHANGED:
if (CList) {
HTREEITEM hItem = CLC_ROOT;
@@ -1045,14 +1005,11 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
SetCListGroupIcons(dat, CList);
}
- {
- NMCLIST nm;
- nm.hdr.code = MCLN_SELCHANGED;
- nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
- nm.hdr.idFrom = IDC_SAWAYMSG_CONTACTSTREE;
- nm.OldSelection = nm.NewSelection = CList ? CList->GetSelection() : CLSEL_DAT_CONTACT;
- SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm); // everything else is in the MCLN_SELCHANGED handler, so we'll just call it from here.
- }
+ nm.hdr.code = MCLN_SELCHANGED;
+ nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
+ nm.hdr.idFrom = IDC_SAWAYMSG_CONTACTSTREE;
+ nm.OldSelection = nm.NewSelection = CList ? CList->GetSelection() : CLSEL_DAT_CONTACT;
+ SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm); // everything else is in the MCLN_SELCHANGED handler, so we'll just call it from here.
break;
case UM_ICONSCHANGED:
@@ -1083,15 +1040,13 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA int Ignore = IsDlgButtonChecked(hwndDlg, IDC_SAWAYMSG_IGNOREREQ) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SENDMSG), !Ignore);
PTREEITEMARRAY Selection = CList->GetSelection();
- int i;
- for (i = 0; i < Selection->GetSize(); i++) {
- if (CList->GetItemType((*Selection)[i]) == MCLCIT_CONTACT) {
+ for (int i = 0; i < Selection->GetSize(); i++)
+ if (CList->GetItemType((*Selection)[i]) == MCLCIT_CONTACT)
SetExtraIcon(CList, EXTRACOLUMN_IGNORE, (*Selection)[i], Ignore ? EXTRAIMGLIST_IGNORE : EXTRAIMGLIST_DOT);
- }
- }
- if (Selection->GetSize() == 1) {
+
+ if (Selection->GetSize() == 1)
CList->EnsureVisible((*Selection)[0]);
- }
+
SetCListGroupIcons(dat, CList);
}
break;
@@ -1109,6 +1064,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SetCListGroupIcons(dat, CList);
}
break;
+
case IDC_SAWAYMSG_OPTIONS:
{
HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_SAM_OPTIONS));
@@ -1140,7 +1096,6 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA {
int bShow = !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE);
if (bShow && !CList) {
- NMCLIST nm;
nm.hdr.code = MCLN_SELCHANGED;
nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
nm.hdr.idFrom = IDC_SAWAYMSG_CONTACTSTREE;
@@ -1171,6 +1126,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA DestroyMenu(hMenu);
}
break;
+
case IDC_SAWAYMSG_SAVEMSG:
{
CBaseTreeItem* TreeItem = MsgTree->GetSelection();
@@ -1186,6 +1142,7 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA }
}
break;
+
case IDC_SAWAYMSG_SAVEASNEW:
{
TCString Text;
@@ -1197,16 +1154,20 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA TreeItem->User_Str1 = Text;
}
break;
+
case IDC_SAWAYMSG_NEWCATEGORY:
MsgTree->AddCategory();
break;
+
case IDC_SAWAYMSG_DELETE:
MsgTree->EnsureVisible(MsgTree->GetSelection()->hItem);
MsgTree->DeleteSelectedItem();
break;
+
case IDC_SAWAYMSG_VARS:
my_variables_showhelp(hwndDlg, IDC_SAWAYMSG_MSGDATA);
break;
+
case IDC_OK:
// save OK button title before resetting it in SetSelContactsMessage
TCString BtnTitle;
@@ -1303,12 +1264,10 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA g_ContactSplitterX = SetContactSplitterX;
}
if (prcDlg->bottom - prcDlg->top < MINYDLGSIZE) {
- if (wParam != WMSZ_TOP && wParam != WMSZ_TOPLEFT && wParam != WMSZ_TOPRIGHT) {
+ if (wParam != WMSZ_TOP && wParam != WMSZ_TOPLEFT && wParam != WMSZ_TOPRIGHT)
prcDlg->bottom = prcDlg->top + MINYDLGSIZE;
- }
- else {
+ else
prcDlg->top = prcDlg->bottom - MINYDLGSIZE;
- }
}
}
return true;
@@ -1322,8 +1281,9 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA urd.lpTemplate = MAKEINTRESOURCEA(IDD_SETAWAYMSG);
urd.pfnResizer = SetAwayMsgDlgResize;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
- if (!wParam && !lParam) // means that we sent WM_SIZE message to apply new settings to the dialog; probably it's somewhat a misuse, but who cares ;-P
- {
+
+ // means that we sent WM_SIZE message to apply new settings to the dialog; probably it's somewhat a misuse, but who cares ;-P
+ if (!wParam && !lParam) {
int bShow;
bShow = g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE) ? SW_SHOW : SW_HIDE;
ShowWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_TREE), bShow);
diff --git a/plugins/NewAwaySysMod/src/version.h b/plugins/NewAwaySysMod/src/version.h index 27b95c6b1d..532d1b5c68 100644 --- a/plugins/NewAwaySysMod/src/version.h +++ b/plugins/NewAwaySysMod/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>
|