diff options
Diffstat (limited to 'plugins/NewAwaySysMod')
26 files changed, 2991 insertions, 4197 deletions
diff --git a/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj index c98e48b042..4ed4a3276e 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj +++ b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj @@ -197,7 +197,6 @@ <ClInclude Include="src\ContactList.h" />
<ClInclude Include="src\CString.h" />
<ClInclude Include="src\MsgTree.h" />
- <ClInclude Include="..\CommonLibs\Options.h" />
<ClInclude Include="src\Options.h" />
<ClInclude Include="src\Path.h" />
<ClInclude Include="src\Properties.h" />
@@ -211,6 +210,7 @@ </ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\NewAwaySys.rc" />
+ <ResourceCompile Include="res\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters index 9aa019bfd9..e0b96faa3c 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters +++ b/plugins/NewAwaySysMod/NewAwaySys_10.vcxproj.filters @@ -62,9 +62,6 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\CommonLibs\Options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -108,5 +105,8 @@ <ResourceCompile Include="res\NewAwaySys.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj b/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj index 6a2379c1f2..17bd3544dd 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj +++ b/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj @@ -197,7 +197,6 @@ <ClInclude Include="src\ContactList.h" />
<ClInclude Include="src\CString.h" />
<ClInclude Include="src\MsgTree.h" />
- <ClInclude Include="..\CommonLibs\Options.h" />
<ClInclude Include="src\Options.h" />
<ClInclude Include="src\Path.h" />
<ClInclude Include="src\Properties.h" />
@@ -211,6 +210,7 @@ </ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\NewAwaySys.rc" />
+ <ResourceCompile Include="res\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj.filters b/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj.filters index 9aa019bfd9..e0b96faa3c 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj.filters +++ b/plugins/NewAwaySysMod/NewAwaySys_11.vcxproj.filters @@ -62,9 +62,6 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\CommonLibs\Options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -108,5 +105,8 @@ <ResourceCompile Include="res\NewAwaySys.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj b/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj index 23d99b8ae3..5d07f729bc 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj +++ b/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj @@ -201,7 +201,6 @@ <ClInclude Include="src\ContactList.h" />
<ClInclude Include="src\CString.h" />
<ClInclude Include="src\MsgTree.h" />
- <ClInclude Include="..\CommonLibs\Options.h" />
<ClInclude Include="src\Options.h" />
<ClInclude Include="src\Path.h" />
<ClInclude Include="src\Properties.h" />
@@ -215,6 +214,7 @@ </ItemGroup>
<ItemGroup>
<ResourceCompile Include="res\NewAwaySys.rc" />
+ <ResourceCompile Include="res\version.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj.filters b/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj.filters index 61ffbfd573..7bc41c18c7 100644 --- a/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj.filters +++ b/plugins/NewAwaySysMod/NewAwaySys_12.vcxproj.filters @@ -65,9 +65,6 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="..\CommonLibs\Options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\Common.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -111,5 +108,8 @@ <ResourceCompile Include="res\NewAwaySys.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
+ <ResourceCompile Include="res\version.rc">
+ <Filter>Resource Files</Filter>
+ </ResourceCompile>
</ItemGroup>
</Project>
\ No newline at end of file diff --git a/plugins/NewAwaySysMod/res/NewAwaySys.rc b/plugins/NewAwaySysMod/res/NewAwaySys.rc index 7e5bb36546..ab026a3ef9 100644 --- a/plugins/NewAwaySysMod/res/NewAwaySys.rc +++ b/plugins/NewAwaySysMod/res/NewAwaySys.rc @@ -155,7 +155,7 @@ BEGIN BS_ICON | WS_TABSTOP,180,17,29,12
CONTROL "Don't reply to ICQ contacts",IDC_REPLYDLG_DONTSENDTOICQ,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,21,119,275,10
- CONTROL "Don't reply when I'm invisible to the contact",
+ CONTROL "Don't reply when i'm invisible to the contact",
IDC_REPLYDLG_DONTREPLYINVISIBLE,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,21,107,275,10
CONTROL "Save autoreply to the history",IDC_REPLYDLG_LOGREPLY,
@@ -172,7 +172,7 @@ BEGIN UDS_ARROWKEYS | UDS_NOTHOUSANDS,156,70,12,12
LTEXT "times (-1=infinite)",IDC_REPLYDLG_STATIC_TIMES,172,72,
124,8
- CONTROL "Reset this counter also when I just change my status text\n(when status icon remains the same)",
+ CONTROL "Reset this counter also when i just change my status text\n(when status icon remains the same)",
IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON,"Button",
BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,34,
84,262,18
diff --git a/plugins/NewAwaySysMod/res/version.rc b/plugins/NewAwaySysMod/res/version.rc index 408fa5fa8b..5bfbab4754 100644 --- a/plugins/NewAwaySysMod/res/version.rc +++ b/plugins/NewAwaySysMod/res/version.rc @@ -1,58 +1,38 @@ -//
-// version.rc - resources Microsoft Visual C++ does not edit directly
+// 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"
-/////////////////////////////////////////////////////////////////////////////
-// Add manually edited resources here...
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-#include "VersionNo.h"
VS_VERSION_INFO VERSIONINFO
- FILEVERSION FILEVER
- PRODUCTVERSION PRODUCTVER
- FILEFLAGSMASK 0x3fL
+ FILEVERSION __FILEVERSION_STRING
+ PRODUCTVERSION __FILEVERSION_STRING
+ FILEFLAGSMASK 0x17L
#ifdef _DEBUG
- FILEFLAGS 0x21L
+ FILEFLAGS 0x1L
#else
- FILEFLAGS 0x20L
+ FILEFLAGS 0x0L
#endif
- FILEOS 0x40004L
- FILETYPE 0x2L
+ FILEOS 0x4L
+ FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
- BLOCK "040904b0"
+ BLOCK "000004b0"
BEGIN
- VALUE "CompanyName", "NightFox; Deathdemon; XF007; Goblineye Entertainment"
- VALUE "FileDescription", "New Away System plugin for Miranda NG"
- VALUE "FileVersion", STRFILEVER
- VALUE "LegalCopyright", "© 2010 NightFox; © 2005-2006 Chervov Dmitry; © 2004-2005 Iksaif Entertainment; © 2002-2003 Goblineye Entertainment"
-#ifdef _UNICODE
- VALUE "InternalName", "NewAwaySysW"
- VALUE "OriginalFilename", "NewAwaySysW.dll"
- VALUE "ProductName", "New Away System (Unicode)"
-#else
- VALUE "InternalName", "NewAwaySys"
- VALUE "OriginalFilename", "NewAwaySys.dll"
- VALUE "ProductName", "New Away System (ANSI)"
-#endif
- VALUE "ProductVersion", STRPRODUCTVER
- VALUE "SpecialBuild", STRSPECIALBUILD
+ VALUE "FileDescription", __DESCRIPTION
+ VALUE "InternalName", __PLUGIN_NAME
+ VALUE "LegalCopyright", __COPYRIGHT
+ VALUE "OriginalFilename", __FILENAME
+ VALUE "ProductName", __PLUGIN_NAME
END
END
BLOCK "VarFileInfo"
BEGIN
- VALUE "Translation", 0x409, 1200
+ VALUE "Translation", 0x0, 1200
END
END
-
-/////////////////////////////////////////////////////////////////////////////
diff --git a/plugins/NewAwaySysMod/src/AwayOpt.cpp b/plugins/NewAwaySysMod/src/AwayOpt.cpp index 050e6fa068..aeb787abdc 100644 --- a/plugins/NewAwaySysMod/src/AwayOpt.cpp +++ b/plugins/NewAwaySysMod/src/AwayOpt.cpp @@ -31,13 +31,11 @@ int g_Messages_RecentRootID, g_Messages_PredefinedRootID;
CIconList g_IconList;
-
-void MySetPos(HWND hwndParent)
// Set window size and center its controls
+void MySetPos(HWND hwndParent)
{
HWND hWndTab = FindWindowEx(GetParent(hwndParent), NULL, _T("SysTabControl32"), _T(""));
- if (!hWndTab)
- {
+ if (!hWndTab) {
_ASSERT(0);
return;
}
@@ -47,16 +45,14 @@ void MySetPos(HWND hwndParent) rcDlg.right -= rcDlg.left - 2;
rcDlg.bottom -= rcDlg.top;
rcDlg.top += 2;
- if (hwndParent)
- {
+ if (hwndParent) {
RECT OldSize;
GetClientRect(hwndParent, &OldSize);
MoveWindow(hwndParent, rcDlg.left, rcDlg.top, rcDlg.right, rcDlg.bottom, true);
int dx = (rcDlg.right - OldSize.right) >> 1;
int dy = (rcDlg.bottom - OldSize.bottom) >> 1;
HWND hCurWnd = GetWindow(hwndParent, GW_CHILD);
- while (hCurWnd)
- {
+ while (hCurWnd) {
RECT CWOldPos;
GetWindowRect(hCurWnd, &CWOldPos);
POINT pt;
@@ -75,24 +71,19 @@ COptPage g_MessagesOptPage(MOD_NAME, NULL); void EnableMessagesOptDlgControls(CMsgTree* MsgTree)
{
- int I;
int IsNotGroup = false;
int Selected = false;
- CBaseTreeItem* TreeItem = MsgTree->GetSelection();
- if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM))
- {
+ CBaseTreeItem *TreeItem = MsgTree->GetSelection();
+ if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM)) {
IsNotGroup = !(TreeItem->Flags & TIF_GROUP);
Selected = true;
}
g_MessagesOptPage.Enable(IDC_MESSAGEDLG_DEL, Selected);
g_MessagesOptPage.Enable(IDC_MESSAGEDLG_MSGTITLE, Selected);
- for (I = 0; I < g_MessagesOptPage.Items.GetSize(); I++)
- {
- if (g_MessagesOptPage.Items[I]->GetParam() == IDC_MESSAGEDLG_MSGTREE)
- {
- g_MessagesOptPage.Items[I]->Enable(IsNotGroup);
- }
- }
+ for (int i = 0; i < g_MessagesOptPage.Items.GetSize(); i++)
+ if (g_MessagesOptPage.Items[i]->GetParam() == IDC_MESSAGEDLG_MSGTREE)
+ g_MessagesOptPage.Items[i]->Enable(IsNotGroup);
+
SendDlgItemMessage(g_MessagesOptPage.GetWnd(), IDC_MESSAGEDLG_MSGDATA, EM_SETREADONLY, !IsNotGroup, 0);
g_MessagesOptPage.MemToPage(true);
}
@@ -102,13 +93,11 @@ static WNDPROC g_OrigDefStatusButtonMsgProc; static LRESULT CALLBACK DefStatusButtonSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_LBUTTONUP && IsDlgButtonChecked(GetParent(hWnd), GetDlgCtrlID(hWnd)))
- {
return 0;
- }
+
return CallWindowProc(g_OrigDefStatusButtonMsgProc, hWnd, Msg, wParam, lParam);
}
-
INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static int ChangeLock = 0;
@@ -135,254 +124,224 @@ INT_PTR CALLBACK MessagesOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP IDC_MESSAGEDLG_DEL, ILI_DELETE, LPGENT("Delete"),
IDC_MESSAGEDLG_VARS, ILI_NOICON, LPGENT("Open Variables help dialog"),
};
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- MySetPos(hwndDlg);
- ChangeLock++;
- g_MessagesOptPage.SetWnd(hwndDlg);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE), EM_LIMITTEXT, TREEITEMTITLE_MAXLEN, 0);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGDATA), EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0);
+ TranslateDialogDefault(hwndDlg);
+ MySetPos(hwndDlg);
+ ChangeLock++;
+ g_MessagesOptPage.SetWnd(hwndDlg);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE), EM_LIMITTEXT, TREEITEMTITLE_MAXLEN, 0);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGDATA), EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0);
// init image buttons
- int I;
- for (I = 0; I < lengthof(Buttons); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, Buttons[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Buttons[I].Text), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- }
+ int i;
+ for (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);
+ }
// now default status message buttons
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, DefMsgDlgItems[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, DefMsgDlgItems[I].Status, GSMDF_TCHAR), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASPUSHBTN, 0, 0);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
- }
- SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
- g_MessagesOptPage.DBToMemToPage();
- _ASSERT(!MsgTree);
- MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE));
- if (!MsgTree->SetSelection(MsgTree->GetDefMsg(ID_STATUS_AWAY), MTSS_BYID))
- {
- MsgTree->SetSelection(g_Messages_PredefinedRootID, MTSS_BYID);
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ HWND hButton = GetDlgItem(hwndDlg, DefMsgDlgItems[i].DlgItem);
+ SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, DefMsgDlgItems[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONSETASPUSHBTN, 0, 0);
+ SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
+ g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
+ }
+ SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
+ g_MessagesOptPage.DBToMemToPage();
+ _ASSERT(!MsgTree);
+ MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE));
+ if (!MsgTree->SetSelection(MsgTree->GetDefMsg(ID_STATUS_AWAY), MTSS_BYID)) {
+ MsgTree->SetSelection(g_Messages_PredefinedRootID, MTSS_BYID);
+ }
+ ChangeLock--;
+ return true;
+ } break;
+ case UM_ICONSCHANGED:
+ {
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ SendDlgItemMessage(hwndDlg, DefMsgDlgItems[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[DefMsgDlgItems[i].IconIndex]);
+ }
+ for (i = 0; i < SIZEOF(Buttons); i++) {
+ if (Buttons[i].IconIndex != ILI_NOICON) {
+ SendDlgItemMessage(hwndDlg, Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[i].IconIndex]);
}
+ }
+ my_variables_skin_helpbutton(hwndDlg, IDC_MESSAGEDLG_VARS);
+ } break;
+ case WM_NOTIFY:
+ {
+ switch (((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ {
+ HWND hTreeView = GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE);
+ HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
+ ChangeLock++;
+ TreeView_SelectItem(hTreeView, NULL);
+ TreeView_SelectItem(hTreeView, hSelectedItem);
ChangeLock--;
+ MsgTree->Save();
return true;
} break;
- case UM_ICONSCHANGED:
- {
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
+ }
+ if (((LPNMHDR)lParam)->idFrom == IDC_MESSAGEDLG_MSGTREE) {
+ switch (((LPNMHDR)lParam)->code) {
+ case MTN_SELCHANGED:
{
- SendDlgItemMessage(hwndDlg, DefMsgDlgItems[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[DefMsgDlgItems[I].IconIndex]);
- }
- for (I = 0; I < lengthof(Buttons); I++)
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ int i;
+ if (pnm->ItemOld && !(pnm->ItemOld->Flags & (TIF_ROOTITEM | TIF_GROUP))) {
+ TCString Msg;
+ GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, Msg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
+ Msg.ReleaseBuffer();
+ if (((CTreeItem*)pnm->ItemOld)->User_Str1 != (const TCHAR*)Msg) {
+ ((CTreeItem*)pnm->ItemOld)->User_Str1 = Msg;
+ MsgTree->SetModified(true);
+ }
+ }
+ if (pnm->ItemNew) {
+ ChangeLock++;
+ if (!(pnm->ItemNew->Flags & TIF_ROOTITEM)) {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, (pnm->ItemNew->Flags & TIF_GROUP) ? _T("") : ((CTreeItem*)pnm->ItemNew)->User_Str1);
+ }
+ else {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, _T(""));
+ if (pnm->ItemNew->ID == g_Messages_RecentRootID) {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("Your most recent status messages are placed in this category. It's not recommended to put your messages manually here, as they'll be replaced by your recent messages."));
+ }
+ else {
+ _ASSERT(pnm->ItemNew->ID == g_Messages_PredefinedRootID);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category."));
+ }
+ }
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[i].DlgItem);
+ Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[i].Status) == pnm->ItemNew->ID);
+ }
+ ChangeLock--;
+ }
+ EnableMessagesOptDlgControls(MsgTree);
+ return 0;
+ } break;
+ case MTN_DEFMSGCHANGED:
{
- if (Buttons[I].IconIndex != ILI_NOICON)
- {
- SendDlgItemMessage(hwndDlg, Buttons[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[I].IconIndex]);
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ if (!ChangeLock) {
+ CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
+ _ASSERT(SelectedItem);
+ if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID)) { // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[i].DlgItem);
+ Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[i].Status) == SelectedItem->ID);
+ }
+ }
}
- }
- my_variables_skin_helpbutton(hwndDlg, IDC_MESSAGEDLG_VARS);
- } break;
- case WM_NOTIFY:
- {
- switch (((NMHDR*)lParam)->code)
+ if (!ChangeLock) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
+ return 0;
+ } break;
+ case MTN_ITEMRENAMED:
{
- case PSN_APPLY:
- {
- HWND hTreeView = GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE);
- HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
+ _ASSERT(SelectedItem);
+ if (pnm->ItemNew->ID == SelectedItem->ID && !ChangeLock) {
ChangeLock++;
- TreeView_SelectItem(hTreeView, NULL);
- TreeView_SelectItem(hTreeView, hSelectedItem);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
ChangeLock--;
- MsgTree->Save();
- return true;
- } break;
- }
- if (((LPNMHDR)lParam)->idFrom == IDC_MESSAGEDLG_MSGTREE)
+ }
+ } // go through
+ case MTN_ENDDRAG:
+ case MTN_NEWCATEGORY:
+ case MTN_NEWMESSAGE:
+ case MTN_DELETEITEM:
+ case TVN_ITEMEXPANDED:
{
- switch (((LPNMHDR)lParam)->code)
- {
- case MTN_SELCHANGED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- int I;
- if (pnm->ItemOld && !(pnm->ItemOld->Flags & (TIF_ROOTITEM | TIF_GROUP)))
- {
- TCString Msg;
- GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, Msg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
- Msg.ReleaseBuffer();
- if (((CTreeItem*)pnm->ItemOld)->User_Str1 != (const TCHAR*)Msg)
- {
- ((CTreeItem*)pnm->ItemOld)->User_Str1 = Msg;
- MsgTree->SetModified(true);
- }
- }
- if (pnm->ItemNew)
- {
- ChangeLock++;
- if (!(pnm->ItemNew->Flags & TIF_ROOTITEM))
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, (pnm->ItemNew->Flags & TIF_GROUP) ? _T("") : ((CTreeItem*)pnm->ItemNew)->User_Str1);
- } else
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, _T(""));
- if (pnm->ItemNew->ID == g_Messages_RecentRootID)
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("Your most recent status messages are placed in this category. It's not recommended to put your messages manually here, as they'll be replaced by your recent messages."));
- } else
- {
- _ASSERT(pnm->ItemNew->ID == g_Messages_PredefinedRootID);
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category."));
- }
- }
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[I].DlgItem);
- Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[I].Status) == pnm->ItemNew->ID);
- }
- ChangeLock--;
- }
- EnableMessagesOptDlgControls(MsgTree);
- return 0;
- } break;
- case MTN_DEFMSGCHANGED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- if (!ChangeLock)
- {
- CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
- _ASSERT(SelectedItem);
- if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID))
- { // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[I].DlgItem);
- Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[I].Status) == SelectedItem->ID);
- }
- }
- }
- if (!ChangeLock)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- return 0;
- } break;
- case MTN_ITEMRENAMED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
- _ASSERT(SelectedItem);
- if (pnm->ItemNew->ID == SelectedItem->ID && !ChangeLock)
- {
- ChangeLock++;
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
- ChangeLock--;
- }
- } // go through
- case MTN_ENDDRAG:
- case MTN_NEWCATEGORY:
- case MTN_NEWMESSAGE:
- case MTN_DELETEITEM:
- case TVN_ITEMEXPANDED:
- {
- if (!ChangeLock)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- return 0;
- } break;
+ if (!ChangeLock) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
}
+ return 0;
+ } break;
}
- } break;
- case WM_COMMAND:
+ }
+ } break;
+ case WM_COMMAND:
+ {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
{
- switch (HIWORD(wParam))
+ switch (LOWORD(wParam)) {
+ case IDC_MESSAGEDLG_DEF_ONL:
+ case IDC_MESSAGEDLG_DEF_AWAY:
+ case IDC_MESSAGEDLG_DEF_NA:
+ case IDC_MESSAGEDLG_DEF_OCC:
+ case IDC_MESSAGEDLG_DEF_DND:
+ case IDC_MESSAGEDLG_DEF_FFC:
+ case IDC_MESSAGEDLG_DEF_INV:
+ case IDC_MESSAGEDLG_DEF_OTP:
+ case IDC_MESSAGEDLG_DEF_OTL:
{
- case BN_CLICKED:
- {
- switch (LOWORD(wParam))
- {
- case IDC_MESSAGEDLG_DEF_ONL:
- case IDC_MESSAGEDLG_DEF_AWAY:
- case IDC_MESSAGEDLG_DEF_NA:
- case IDC_MESSAGEDLG_DEF_OCC:
- case IDC_MESSAGEDLG_DEF_DND:
- case IDC_MESSAGEDLG_DEF_FFC:
- case IDC_MESSAGEDLG_DEF_INV:
- case IDC_MESSAGEDLG_DEF_OTP:
- case IDC_MESSAGEDLG_DEF_OTL:
- {
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- if (LOWORD(wParam) == DefMsgDlgItems[I].DlgItem)
- {
- MsgTree->SetDefMsg(DefMsgDlgItems[I].Status, MsgTree->GetSelection()->ID); // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more
- break;
- }
- }
- } break;
- case IDC_MESSAGEDLG_VARS:
- {
- my_variables_showhelp(hwndDlg, IDC_MESSAGEDLG_MSGDATA);
- } break;
- case IDC_MESSAGEDLG_DEL:
- {
- MsgTree->EnsureVisible(MsgTree->GetSelection()->hItem);
- MsgTree->DeleteSelectedItem();
- } break;
- case IDC_MESSAGEDLG_NEWCAT:
- {
- MsgTree->AddCategory();
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
- } break;
- case IDC_MESSAGEDLG_NEWMSG:
- {
- MsgTree->AddMessage();
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
- } break;
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ if (LOWORD(wParam) == DefMsgDlgItems[i].DlgItem) {
+ MsgTree->SetDefMsg(DefMsgDlgItems[i].Status, MsgTree->GetSelection()->ID); // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more
+ break;
}
- } break;
- case EN_CHANGE:
- {
- if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGDATA || LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE)
- {
- if (!ChangeLock)
- {
- if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE)
- {
- CBaseTreeItem* TreeItem = MsgTree->GetSelection();
- if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM))
- {
- GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, TreeItem->Title.GetBuffer(TREEITEMTITLE_MAXLEN), TREEITEMTITLE_MAXLEN);
- TreeItem->Title.ReleaseBuffer();
- ChangeLock++;
- MsgTree->UpdateItem(TreeItem->ID);
- ChangeLock--;
- }
- }
- MsgTree->SetModified(true);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- }
- } break;
+ }
+ } break;
+ case IDC_MESSAGEDLG_VARS:
+ {
+ my_variables_showhelp(hwndDlg, IDC_MESSAGEDLG_MSGDATA);
+ } break;
+ case IDC_MESSAGEDLG_DEL:
+ {
+ MsgTree->EnsureVisible(MsgTree->GetSelection()->hItem);
+ MsgTree->DeleteSelectedItem();
+ } break;
+ case IDC_MESSAGEDLG_NEWCAT:
+ {
+ MsgTree->AddCategory();
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
+ } break;
+ case IDC_MESSAGEDLG_NEWMSG:
+ {
+ MsgTree->AddMessage();
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
+ } break;
}
} break;
- case WM_DESTROY:
+ case EN_CHANGE:
{
- delete MsgTree;
- MsgTree = NULL;
- g_MessagesOptPage.SetWnd(NULL);
+ if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGDATA || LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE) {
+ if (!ChangeLock) {
+ if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE) {
+ CBaseTreeItem* TreeItem = MsgTree->GetSelection();
+ if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM)) {
+ GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, TreeItem->Title.GetBuffer(TREEITEMTITLE_MAXLEN), TREEITEMTITLE_MAXLEN);
+ TreeItem->Title.ReleaseBuffer();
+ ChangeLock++;
+ MsgTree->UpdateItem(TreeItem->ID);
+ ChangeLock--;
+ }
+ }
+ MsgTree->SetModified(true);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
+ }
} break;
+ }
+ } break;
+ case WM_DESTROY:
+ {
+ delete MsgTree;
+ MsgTree = NULL;
+ g_MessagesOptPage.SetWnd(NULL);
+ } break;
}
return 0;
}
@@ -423,109 +382,101 @@ INT_PTR CALLBACK MoreOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam IDC_MOREOPTDLG_DONTPOPDLG_OTP, ID_STATUS_ONTHEPHONE, ILI_PROTO_OTP,
IDC_MOREOPTDLG_DONTPOPDLG_OTL, ID_STATUS_OUTTOLUNCH, ILI_PROTO_OTL
};
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hwndDlg);
+ MySetPos(hwndDlg);
+ ChangeLock++;
+ g_MoreOptPage.SetWnd(hwndDlg);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_WAITFORMSG, EM_LIMITTEXT, 4, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_RECENTMSGSCOUNT, EM_LIMITTEXT, 2, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_WAITFORMSG_SPIN, UDM_SETRANGE32, -1, 9999);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_RECENTMSGSCOUNT_SPIN, UDM_SETRANGE32, 0, 99);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_UPDATEMSGSPERIOD_SPIN, UDM_SETRANGE32, 30, 99999);
+ int i;
+ for (i = 0; i < SIZEOF(StatusButtons); i++) {
+ HWND hButton = GetDlgItem(hwndDlg, StatusButtons[i].DlgItem);
+ SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusButtons[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
+ SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
+ }
+ SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
+ g_MoreOptPage.DBToMemToPage();
+ EnableMoreOptDlgControls();
+ ChangeLock--;
+ return true;
+ } break;
+ case UM_ICONSCHANGED:
+ {
+ int i;
+ for (i = 0; i < SIZEOF(StatusButtons); i++) {
+ SendDlgItemMessage(hwndDlg, StatusButtons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[StatusButtons[i].IconIndex]);
+ }
+ } break;
+ case WM_NOTIFY:
{
- case WM_INITDIALOG:
+ switch (((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
{
- TranslateDialogDefault(hwndDlg);
- MySetPos(hwndDlg);
- ChangeLock++;
- g_MoreOptPage.SetWnd(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_WAITFORMSG, EM_LIMITTEXT, 4, 0);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_RECENTMSGSCOUNT, EM_LIMITTEXT, 2, 0);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_WAITFORMSG_SPIN, UDM_SETRANGE32, -1, 9999);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_RECENTMSGSCOUNT_SPIN, UDM_SETRANGE32, 0, 99);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_UPDATEMSGSPERIOD_SPIN, UDM_SETRANGE32, 30, 99999);
- int I;
- for (I = 0; I < lengthof(StatusButtons); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, StatusButtons[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusButtons[I].Status, GSMDF_TCHAR), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- }
- SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
- g_MoreOptPage.DBToMemToPage();
- EnableMoreOptDlgControls();
- ChangeLock--;
+ g_MoreOptPage.PageToMemToDB();
+ InitUpdateMsgs();
return true;
} break;
- case UM_ICONSCHANGED:
+ }
+ } break;
+ case WM_COMMAND:
+ {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
{
- int I;
- for (I = 0; I < lengthof(StatusButtons); I++)
+ switch (LOWORD(wParam)) {
+
+ case IDC_MOREOPTDLG_RESETPROTOMSGS:
+ case IDC_MOREOPTDLG_SAVEPERSONALMSGS:
+ case IDC_MOREOPTDLG_UPDATEMSGS:
{
- SendDlgItemMessage(hwndDlg, StatusButtons[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[StatusButtons[I].IconIndex]);
- }
- } break;
- case WM_NOTIFY:
- {
- switch (((NMHDR*)lParam)->code)
+ EnableMoreOptDlgControls();
+ } // go through
+ case IDC_MOREOPTDLG_PERSTATUSMRM:
+ case IDC_MOREOPTDLG_PERSTATUSPROTOMSGS:
+ case IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS:
+ case IDC_MOREOPTDLG_PERSTATUSPERSONAL:
+ case IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS:
+ case IDC_MOREOPTDLG_USEMENUITEM:
+ case IDC_MOREOPTDLG_MYNICKPERPROTO:
+ case IDC_MOREOPTDLG_USEDEFMSG:
+ case IDC_MOREOPTDLG_USELASTMSG:
+ case IDC_MOREOPTDLG_DONTPOPDLG_ONL:
+ case IDC_MOREOPTDLG_DONTPOPDLG_AWAY:
+ case IDC_MOREOPTDLG_DONTPOPDLG_NA:
+ case IDC_MOREOPTDLG_DONTPOPDLG_OCC:
+ case IDC_MOREOPTDLG_DONTPOPDLG_DND:
+ case IDC_MOREOPTDLG_DONTPOPDLG_FFC:
+ case IDC_MOREOPTDLG_DONTPOPDLG_INV:
+ case IDC_MOREOPTDLG_DONTPOPDLG_OTP:
+ case IDC_MOREOPTDLG_DONTPOPDLG_OTL:
{
- case PSN_APPLY:
- {
- g_MoreOptPage.PageToMemToDB();
- InitUpdateMsgs();
- return true;
- } break;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ return 0;
+ } break;
}
} break;
- case WM_COMMAND:
+ case EN_CHANGE:
{
- switch (HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- switch (LOWORD(wParam))
- {
-
- case IDC_MOREOPTDLG_RESETPROTOMSGS:
- case IDC_MOREOPTDLG_SAVEPERSONALMSGS:
- case IDC_MOREOPTDLG_UPDATEMSGS:
- {
- EnableMoreOptDlgControls();
- } // go through
- case IDC_MOREOPTDLG_PERSTATUSMRM:
- case IDC_MOREOPTDLG_PERSTATUSPROTOMSGS:
- case IDC_MOREOPTDLG_PERSTATUSPROTOSETTINGS:
- case IDC_MOREOPTDLG_PERSTATUSPERSONAL:
- case IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS:
- case IDC_MOREOPTDLG_USEMENUITEM:
- case IDC_MOREOPTDLG_MYNICKPERPROTO:
- case IDC_MOREOPTDLG_USEDEFMSG:
- case IDC_MOREOPTDLG_USELASTMSG:
- case IDC_MOREOPTDLG_DONTPOPDLG_ONL:
- case IDC_MOREOPTDLG_DONTPOPDLG_AWAY:
- case IDC_MOREOPTDLG_DONTPOPDLG_NA:
- case IDC_MOREOPTDLG_DONTPOPDLG_OCC:
- case IDC_MOREOPTDLG_DONTPOPDLG_DND:
- case IDC_MOREOPTDLG_DONTPOPDLG_FFC:
- case IDC_MOREOPTDLG_DONTPOPDLG_INV:
- case IDC_MOREOPTDLG_DONTPOPDLG_OTP:
- case IDC_MOREOPTDLG_DONTPOPDLG_OTL:
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- return 0;
- } break;
- }
- } break;
- case EN_CHANGE:
- {
- if (!ChangeLock && g_MoreOptPage.GetWnd())
- {
- if (LOWORD(wParam) == IDC_MOREOPTDLG_RECENTMSGSCOUNT)
- {
- EnableMoreOptDlgControls();
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- } break;
+ if (!ChangeLock && g_MoreOptPage.GetWnd()) {
+ if (LOWORD(wParam) == IDC_MOREOPTDLG_RECENTMSGSCOUNT) {
+ EnableMoreOptDlgControls();
+ }
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
}
} break;
- case WM_DESTROY:
- {
- g_MoreOptPage.SetWnd(NULL);
- } break;
+ }
+ } break;
+ case WM_DESTROY:
+ {
+ g_MoreOptPage.SetWnd(NULL);
+ } break;
}
return 0;
}
@@ -539,22 +490,20 @@ COptPage g_AutoreplyOptPage(MOD_NAME, NULL); void EnableAutoreplyOptDlgControls()
{
- int I;
+ int i;
g_AutoreplyOptPage.PageToMem();
int Autoreply = g_AutoreplyOptPage.GetValue(IDC_REPLYDLG_ENABLEREPLY);
-
- for (I = 0; I < g_AutoreplyOptPage.Items.GetSize(); I++)
- {
- switch (g_AutoreplyOptPage.Items[I]->GetParam())
+
+ for (i = 0; i < g_AutoreplyOptPage.Items.GetSize(); i++) {
+ switch (g_AutoreplyOptPage.Items[i]->GetParam()) {
+ case IDC_REPLYDLG_ENABLEREPLY:
{
- case IDC_REPLYDLG_ENABLEREPLY:
- {
- g_AutoreplyOptPage.Items[I]->Enable(Autoreply);
- } break;
- case IDC_REPLYDLG_SENDCOUNT:
- {
- g_AutoreplyOptPage.Items[I]->Enable(Autoreply && g_AutoreplyOptPage.GetValue(IDC_REPLYDLG_SENDCOUNT) > 0);
- } break;
+ g_AutoreplyOptPage.Items[i]->Enable(Autoreply);
+ } break;
+ case IDC_REPLYDLG_SENDCOUNT:
+ {
+ g_AutoreplyOptPage.Items[i]->Enable(Autoreply && g_AutoreplyOptPage.GetValue(IDC_REPLYDLG_SENDCOUNT) > 0);
+ } break;
}
}
g_AutoreplyOptPage.MemToPage(true);
@@ -579,188 +528,173 @@ INT_PTR CALLBACK AutoreplyOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l IDC_REPLYDLG_DISABLE_OTP, ID_STATUS_ONTHEPHONE, ILI_PROTO_OTP,
IDC_REPLYDLG_DISABLE_OTL, ID_STATUS_OUTTOLUNCH, ILI_PROTO_OTL
};
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
{
- case WM_INITDIALOG:
- {
- ChangeLock++;
- TranslateDialogDefault(hwndDlg);
- MySetPos(hwndDlg);
- g_AutoreplyOptPage.SetWnd(hwndDlg);
-
- LOGFONT logFont;
- HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_DISABLEWHENSTATUS, WM_GETFONT, 0, 0); // try getting the font used by the control
- if (!hFont)
- {
- hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
- }
- GetObject(hFont, sizeof(logFont), &logFont);
- logFont.lfWeight = FW_BOLD;
- s_hDrawFont = CreateFontIndirect(&logFont); // recreate the font
- SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_DISABLEWHENSTATUS, WM_SETFONT, (WPARAM)s_hDrawFont, true);
- SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_FORMAT, WM_SETFONT, (WPARAM)s_hDrawFont, true);
-
- SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_SENDCOUNT, EM_LIMITTEXT, 3, 0);
- SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_SENDCOUNT_SPIN, UDM_SETRANGE32, -1, 999);
-
- HWND hCombo = GetDlgItem(hwndDlg, IDC_REPLYDLG_ONLYIDLEREPLY_COMBO);
- static struct {
- TCHAR *Text;
- int Meaning;
- } IdleComboValues[] = {
- LPGENT("Windows"), AUTOREPLY_IDLE_WINDOWS,
- LPGENT("Miranda"), AUTOREPLY_IDLE_MIRANDA
- };
- int I;
- for (I = 0; I < lengthof(IdleComboValues); I++)
- {
- SendMessage(hCombo, CB_SETITEMDATA, SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(IdleComboValues[I].Text)), IdleComboValues[I].Meaning);
- }
+ ChangeLock++;
+ TranslateDialogDefault(hwndDlg);
+ MySetPos(hwndDlg);
+ g_AutoreplyOptPage.SetWnd(hwndDlg);
+
+ LOGFONT logFont;
+ HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_DISABLEWHENSTATUS, WM_GETFONT, 0, 0); // try getting the font used by the control
+ if (!hFont) {
+ hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
+ }
+ GetObject(hFont, sizeof(logFont), &logFont);
+ logFont.lfWeight = FW_BOLD;
+ s_hDrawFont = CreateFontIndirect(&logFont); // recreate the font
+ SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_DISABLEWHENSTATUS, WM_SETFONT, (WPARAM)s_hDrawFont, true);
+ SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_STATIC_FORMAT, WM_SETFONT, (WPARAM)s_hDrawFont, true);
+
+ SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_SENDCOUNT, EM_LIMITTEXT, 3, 0);
+ SendDlgItemMessage(hwndDlg, IDC_REPLYDLG_SENDCOUNT_SPIN, UDM_SETRANGE32, -1, 999);
+
+ HWND hCombo = GetDlgItem(hwndDlg, IDC_REPLYDLG_ONLYIDLEREPLY_COMBO);
+ static struct {
+ TCHAR *Text;
+ int Meaning;
+ } IdleComboValues[] = {
+ LPGENT("Windows"), AUTOREPLY_IDLE_WINDOWS,
+ LPGENT("Miranda"), AUTOREPLY_IDLE_MIRANDA
+ };
+ int i;
+ for (i = 0; i < SIZEOF(IdleComboValues); i++) {
+ SendMessage(hCombo, CB_SETITEMDATA, SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(IdleComboValues[i].Text)), IdleComboValues[i].Meaning);
+ }
- for (I = 0; I < lengthof(StatusButtons); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, StatusButtons[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusButtons[I].Status, GSMDF_TCHAR), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- }
- HWND hButton = GetDlgItem(hwndDlg, IDC_REPLYDLG_VARS);
- SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Variables help dialog"), BATF_TCHAR);
+ for (i = 0; i < SIZEOF(StatusButtons); i++) {
+ HWND hButton = GetDlgItem(hwndDlg, StatusButtons[i].DlgItem);
+ SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, StatusButtons[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
-
- SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTMSG), BUTTONSETASTHEMEDBTN, TRUE, 0);
- SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTURL), BUTTONSETASTHEMEDBTN, TRUE, 0);
- SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTFILE), BUTTONSETASTHEMEDBTN, TRUE, 0);
- SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
-
- // init tooltips
- struct {
- int DlgItemID;
- TCHAR* Text;
- } Tooltips[] = {
- IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON, LPGENT("When this checkbox is ticked, NewAwaySys counts \"send times\" starting from the last status message change, even if status mode didn't change.\nWhen the checkbox isn't ticked, \"send times\" are counted from last status mode change (i.e. disabled state is more restrictive)."),
- IDC_MOREOPTDLG_EVNTMSG, LPGENT("Message"),
- IDC_MOREOPTDLG_EVNTURL, LPGENT("URL"),
- IDC_MOREOPTDLG_EVNTFILE, LPGENT("File")
- };
- TOOLINFO ti = {0};
- hWndTooltips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP | TTS_NOPREFIX, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
- ti.cbSize = sizeof(ti);
- ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
- ti.hwnd = hwndDlg;
- for (I = 0; I < lengthof(Tooltips); I++)
- {
- ti.uId = (UINT)GetDlgItem(hwndDlg, Tooltips[I].DlgItemID);
- ti.lpszText = TranslateTS(Tooltips[I].Text);
- SendMessage(hWndTooltips, TTM_ADDTOOL, 0, (LPARAM)&ti);
- }
- SendMessage(hWndTooltips, TTM_SETMAXTIPWIDTH, 0, 500);
- SendMessage(hWndTooltips, TTM_SETDELAYTIME, TTDT_AUTOPOP, 32767); // tooltip hide time; looks like 32 seconds is the maximum
-
- g_AutoreplyOptPage.DBToMemToPage();
- EnableAutoreplyOptDlgControls();
- ChangeLock--;
- MakeGroupCheckbox(GetDlgItem(hwndDlg, IDC_REPLYDLG_ENABLEREPLY));
+ }
+ HWND hButton = GetDlgItem(hwndDlg, IDC_REPLYDLG_VARS);
+ SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Open Variables help dialog"), BATF_TCHAR);
+ SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTMSG), BUTTONSETASTHEMEDBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTURL), BUTTONSETASTHEMEDBTN, TRUE, 0);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MOREOPTDLG_EVNTFILE), BUTTONSETASTHEMEDBTN, TRUE, 0);
+ SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
+
+ // init tooltips
+ struct {
+ int DlgItemID;
+ TCHAR* Text;
+ } Tooltips[] = {
+ IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON, LPGENT("When this checkbox is ticked, NewAwaySys counts \"send times\" starting from the last status message change, even if status mode didn't change.\nWhen the checkbox isn't ticked, \"send times\" are counted from last status mode change (i.e. disabled state is more restrictive)."),
+ IDC_MOREOPTDLG_EVNTMSG, LPGENT("Message"),
+ IDC_MOREOPTDLG_EVNTURL, LPGENT("URL"),
+ IDC_MOREOPTDLG_EVNTFILE, LPGENT("File")
+ };
+ TOOLINFO ti = { 0 };
+ hWndTooltips = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, _T(""), WS_POPUP | TTS_NOPREFIX, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL), NULL);
+ ti.cbSize = sizeof(ti);
+ ti.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
+ ti.hwnd = hwndDlg;
+ for (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);
+ }
+ SendMessage(hWndTooltips, TTM_SETMAXTIPWIDTH, 0, 500);
+ SendMessage(hWndTooltips, TTM_SETDELAYTIME, TTDT_AUTOPOP, 32767); // tooltip hide time; looks like 32 seconds is the maximum
+
+ g_AutoreplyOptPage.DBToMemToPage();
+ EnableAutoreplyOptDlgControls();
+ ChangeLock--;
+ MakeGroupCheckbox(GetDlgItem(hwndDlg, IDC_REPLYDLG_ENABLEREPLY));
+ return true;
+ } break;
+ case UM_ICONSCHANGED:
+ {
+ int i;
+ for (i = 0; i < SIZEOF(StatusButtons); i++) {
+ SendDlgItemMessage(hwndDlg, StatusButtons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[StatusButtons[i].IconIndex]);
+ }
+ my_variables_skin_helpbutton(hwndDlg, IDC_REPLYDLG_VARS);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTMSG, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_MESSAGE]);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTURL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_URL]);
+ SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTFILE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_FILE]);
+ } break;
+ case WM_NOTIFY:
+ {
+ switch (((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ {
+ g_AutoreplyOptPage.PageToMemToDB();
+ //UpdateSOEButtons();
return true;
} break;
- case UM_ICONSCHANGED:
+ }
+ } break;
+ case WM_COMMAND:
+ {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
{
- int I;
- for (I = 0; I < lengthof(StatusButtons); I++)
+ switch (LOWORD(wParam)) {
+ case IDC_REPLYDLG_ENABLEREPLY:
{
- SendDlgItemMessage(hwndDlg, StatusButtons[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[StatusButtons[I].IconIndex]);
- }
- my_variables_skin_helpbutton(hwndDlg, IDC_REPLYDLG_VARS);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTMSG, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_MESSAGE]);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTURL, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_URL]);
- SendDlgItemMessage(hwndDlg, IDC_MOREOPTDLG_EVNTFILE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[ILI_EVENT_FILE]);
- } break;
- case WM_NOTIFY:
- {
- switch (((NMHDR*)lParam)->code)
+ EnableAutoreplyOptDlgControls();
+ } // go through
+ case IDC_REPLYDLG_DONTSENDTOICQ:
+ case IDC_REPLYDLG_DONTREPLYINVISIBLE:
+ case IDC_REPLYDLG_ONLYCLOSEDDLGREPLY:
+ case IDC_REPLYDLG_ONLYIDLEREPLY:
+ case IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON:
+ case IDC_REPLYDLG_EVENTMSG:
+ case IDC_REPLYDLG_EVENTURL:
+ case IDC_REPLYDLG_EVENTFILE:
+ case IDC_REPLYDLG_LOGREPLY:
+ case IDC_REPLYDLG_DISABLE_ONL:
+ case IDC_REPLYDLG_DISABLE_AWAY:
+ case IDC_REPLYDLG_DISABLE_NA:
+ case IDC_REPLYDLG_DISABLE_OCC:
+ case IDC_REPLYDLG_DISABLE_DND:
+ case IDC_REPLYDLG_DISABLE_FFC:
+ case IDC_REPLYDLG_DISABLE_INV:
+ case IDC_REPLYDLG_DISABLE_OTP:
+ case IDC_REPLYDLG_DISABLE_OTL:
{
- case PSN_APPLY:
- {
- g_AutoreplyOptPage.PageToMemToDB();
- //UpdateSOEButtons();
- return true;
- } break;
+ if (!ChangeLock) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
+ } break;
+ case IDC_REPLYDLG_VARS:
+ {
+ my_variables_showhelp(hwndDlg, IDC_REPLYDLG_PREFIX);
+ } break;
}
} break;
- case WM_COMMAND:
+ case EN_CHANGE:
{
- switch (HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- switch (LOWORD(wParam))
- {
- case IDC_REPLYDLG_ENABLEREPLY:
- {
- EnableAutoreplyOptDlgControls();
- } // go through
- case IDC_REPLYDLG_DONTSENDTOICQ:
- case IDC_REPLYDLG_DONTREPLYINVISIBLE:
- case IDC_REPLYDLG_ONLYCLOSEDDLGREPLY:
- case IDC_REPLYDLG_ONLYIDLEREPLY:
- case IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON:
- case IDC_REPLYDLG_EVENTMSG:
- case IDC_REPLYDLG_EVENTURL:
- case IDC_REPLYDLG_EVENTFILE:
- case IDC_REPLYDLG_LOGREPLY:
- case IDC_REPLYDLG_DISABLE_ONL:
- case IDC_REPLYDLG_DISABLE_AWAY:
- case IDC_REPLYDLG_DISABLE_NA:
- case IDC_REPLYDLG_DISABLE_OCC:
- case IDC_REPLYDLG_DISABLE_DND:
- case IDC_REPLYDLG_DISABLE_FFC:
- case IDC_REPLYDLG_DISABLE_INV:
- case IDC_REPLYDLG_DISABLE_OTP:
- case IDC_REPLYDLG_DISABLE_OTL:
- {
- if (!ChangeLock)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- } break;
- case IDC_REPLYDLG_VARS:
- {
- my_variables_showhelp(hwndDlg, IDC_REPLYDLG_PREFIX);
- } break;
+ if ((LOWORD(wParam) == IDC_REPLYDLG_SENDCOUNT) || (LOWORD(wParam) == IDC_REPLYDLG_PREFIX)) {
+ if (!ChangeLock && g_AutoreplyOptPage.GetWnd()) {
+ if (LOWORD(wParam) == IDC_REPLYDLG_SENDCOUNT) {
+ EnableAutoreplyOptDlgControls();
}
- } break;
- case EN_CHANGE:
- {
- if ((LOWORD(wParam) == IDC_REPLYDLG_SENDCOUNT) || (LOWORD(wParam) == IDC_REPLYDLG_PREFIX))
- {
- if (!ChangeLock && g_AutoreplyOptPage.GetWnd())
- {
- if (LOWORD(wParam) == IDC_REPLYDLG_SENDCOUNT)
- {
- EnableAutoreplyOptDlgControls();
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- }
- } break;
- case CBN_SELCHANGE:
- {
- if (LOWORD(wParam) == IDC_REPLYDLG_ONLYIDLEREPLY_COMBO)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- } break;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
}
} break;
- case WM_DESTROY:
+ case CBN_SELCHANGE:
{
- g_AutoreplyOptPage.SetWnd(NULL);
- if (s_hDrawFont)
- {
- DeleteObject(s_hDrawFont);
+ if (LOWORD(wParam) == IDC_REPLYDLG_ONLYIDLEREPLY_COMBO) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
}
- DestroyWindow(hWndTooltips);
} break;
+ }
+ } break;
+ case WM_DESTROY:
+ {
+ g_AutoreplyOptPage.SetWnd(NULL);
+ if (s_hDrawFont) {
+ DeleteObject(s_hDrawFont);
+ }
+ DestroyWindow(hWndTooltips);
+ } break;
}
return 0;
}
@@ -792,272 +726,242 @@ INT_PTR CALLBACK MessagesModernOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPA IDC_MESSAGEDLG_DEL, ILI_DELETE, LPGENT("Delete"),
IDC_MESSAGEDLG_VARS, ILI_NOICON, LPGENT("Open Variables help dialog"),
};
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- MySetPos(hwndDlg);
- ChangeLock++;
- g_MessagesOptPage.SetWnd(hwndDlg);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE), EM_LIMITTEXT, TREEITEMTITLE_MAXLEN, 0);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGDATA), EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0);
+ TranslateDialogDefault(hwndDlg);
+ MySetPos(hwndDlg);
+ ChangeLock++;
+ g_MessagesOptPage.SetWnd(hwndDlg);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE), EM_LIMITTEXT, TREEITEMTITLE_MAXLEN, 0);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGDATA), EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0);
// init image buttons
- int I;
- for (I = 0; I < lengthof(Buttons); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, Buttons[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Buttons[I].Text), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- }
+ int i;
+ for (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);
+ }
// now default status message buttons
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, DefMsgDlgItems[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, DefMsgDlgItems[I].Status, GSMDF_TCHAR), BATF_TCHAR);
- SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
- SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
- g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
- }
- SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
- g_MessagesOptPage.DBToMemToPage();
- _ASSERT(!MsgTree);
- MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE));
- if (!MsgTree->SetSelection(MsgTree->GetDefMsg(ID_STATUS_AWAY), MTSS_BYID))
- {
- MsgTree->SetSelection(g_Messages_PredefinedRootID, MTSS_BYID);
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ HWND hButton = GetDlgItem(hwndDlg, DefMsgDlgItems[i].DlgItem);
+ SendMessage(hButton, BUTTONADDTOOLTIP, CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, DefMsgDlgItems[i].Status, GSMDF_TCHAR), BATF_TCHAR);
+ SendMessage(hButton, BUTTONSETASPUSHBTN, TRUE, 0);
+ SendMessage(hButton, BUTTONSETASFLATBTN, TRUE, 0);
+ g_OrigDefStatusButtonMsgProc = (WNDPROC)SetWindowLongPtr(hButton, GWLP_WNDPROC, (LONG_PTR)DefStatusButtonSubclassProc);
+ }
+ SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
+ g_MessagesOptPage.DBToMemToPage();
+ _ASSERT(!MsgTree);
+ MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE));
+ if (!MsgTree->SetSelection(MsgTree->GetDefMsg(ID_STATUS_AWAY), MTSS_BYID)) {
+ MsgTree->SetSelection(g_Messages_PredefinedRootID, MTSS_BYID);
+ }
+ ChangeLock--;
+ //MakeGroupCheckbox(GetDlgItem(hwndDlg, IDC_REPLYDLG_ENABLEREPLY));
+ return true;
+ } break;
+ case UM_ICONSCHANGED:
+ {
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ SendDlgItemMessage(hwndDlg, DefMsgDlgItems[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[DefMsgDlgItems[i].IconIndex]);
+ }
+ for (i = 0; i < SIZEOF(Buttons); i++) {
+ if (Buttons[i].IconIndex != ILI_NOICON) {
+ SendDlgItemMessage(hwndDlg, Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[i].IconIndex]);
}
+ }
+ my_variables_skin_helpbutton(hwndDlg, IDC_MESSAGEDLG_VARS);
+ } break;
+ case WM_NOTIFY:
+ {
+ switch (((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ {
+ HWND hTreeView = GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE);
+ HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
+ ChangeLock++;
+ TreeView_SelectItem(hTreeView, NULL);
+ TreeView_SelectItem(hTreeView, hSelectedItem);
ChangeLock--;
- //MakeGroupCheckbox(GetDlgItem(hwndDlg, IDC_REPLYDLG_ENABLEREPLY));
+ MsgTree->Save();
return true;
} break;
- case UM_ICONSCHANGED:
- {
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
+ }
+ if (((LPNMHDR)lParam)->idFrom == IDC_MESSAGEDLG_MSGTREE) {
+ switch (((LPNMHDR)lParam)->code) {
+ case MTN_SELCHANGED:
{
- SendDlgItemMessage(hwndDlg, DefMsgDlgItems[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[DefMsgDlgItems[I].IconIndex]);
- }
- for (I = 0; I < lengthof(Buttons); I++)
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ int i;
+ if (pnm->ItemOld && !(pnm->ItemOld->Flags & (TIF_ROOTITEM | TIF_GROUP))) {
+ TCString Msg;
+ GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, Msg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
+ Msg.ReleaseBuffer();
+ if (((CTreeItem*)pnm->ItemOld)->User_Str1 != (const TCHAR*)Msg) {
+ ((CTreeItem*)pnm->ItemOld)->User_Str1 = Msg;
+ MsgTree->SetModified(true);
+ }
+ }
+ if (pnm->ItemNew) {
+ ChangeLock++;
+ if (!(pnm->ItemNew->Flags & TIF_ROOTITEM)) {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, (pnm->ItemNew->Flags & TIF_GROUP) ? _T("") : ((CTreeItem*)pnm->ItemNew)->User_Str1);
+ }
+ else {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, _T(""));
+ if (pnm->ItemNew->ID == g_Messages_RecentRootID) {
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("Your most recent status messages are placed in this category. It's not recommended to put your messages manually here, as they'll be replaced by your recent messages."));
+ }
+ else {
+ _ASSERT(pnm->ItemNew->ID == g_Messages_PredefinedRootID);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category."));
+ }
+ }
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[i].DlgItem);
+ Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[i].Status) == pnm->ItemNew->ID);
+ }
+ ChangeLock--;
+ }
+ EnableMessagesOptDlgControls(MsgTree);
+ return 0;
+ } break;
+ case MTN_DEFMSGCHANGED:
{
- if (Buttons[I].IconIndex != ILI_NOICON)
- {
- SendDlgItemMessage(hwndDlg, Buttons[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[I].IconIndex]);
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ if (!ChangeLock) {
+ CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
+ _ASSERT(SelectedItem);
+ if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID)) { // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[i].DlgItem);
+ Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[i].Status) == SelectedItem->ID);
+ }
+ }
}
- }
- my_variables_skin_helpbutton(hwndDlg, IDC_MESSAGEDLG_VARS);
- } break;
- case WM_NOTIFY:
- {
- switch (((NMHDR*)lParam)->code)
+ if (!ChangeLock) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
+ return 0;
+ } break;
+ case MTN_ITEMRENAMED:
{
- case PSN_APPLY:
- {
- HWND hTreeView = GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTREE);
- HTREEITEM hSelectedItem = TreeView_GetSelection(hTreeView);
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
+ _ASSERT(SelectedItem);
+ if (pnm->ItemNew->ID == SelectedItem->ID && !ChangeLock) {
ChangeLock++;
- TreeView_SelectItem(hTreeView, NULL);
- TreeView_SelectItem(hTreeView, hSelectedItem);
+ SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
ChangeLock--;
- MsgTree->Save();
- return true;
- } break;
- }
- if (((LPNMHDR)lParam)->idFrom == IDC_MESSAGEDLG_MSGTREE)
+ }
+ } // go through
+ case MTN_ENDDRAG:
+ case MTN_NEWCATEGORY:
+ case MTN_NEWMESSAGE:
+ case MTN_DELETEITEM:
+ case TVN_ITEMEXPANDED:
{
- switch (((LPNMHDR)lParam)->code)
- {
- case MTN_SELCHANGED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- int I;
- if (pnm->ItemOld && !(pnm->ItemOld->Flags & (TIF_ROOTITEM | TIF_GROUP)))
- {
- TCString Msg;
- GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, Msg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
- Msg.ReleaseBuffer();
- if (((CTreeItem*)pnm->ItemOld)->User_Str1 != (const TCHAR*)Msg)
- {
- ((CTreeItem*)pnm->ItemOld)->User_Str1 = Msg;
- MsgTree->SetModified(true);
- }
- }
- if (pnm->ItemNew)
- {
- ChangeLock++;
- if (!(pnm->ItemNew->Flags & TIF_ROOTITEM))
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, (pnm->ItemNew->Flags & TIF_GROUP) ? _T("") : ((CTreeItem*)pnm->ItemNew)->User_Str1);
- } else
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, _T(""));
- if (pnm->ItemNew->ID == g_Messages_RecentRootID)
- {
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("Your most recent status messages are placed in this category. It's not recommended to put your messages manually here, as they'll be replaced by your recent messages."));
- } else
- {
- _ASSERT(pnm->ItemNew->ID == g_Messages_PredefinedRootID);
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGDATA, TranslateT("You can put your frequently used and favorite messages in this category."));
- }
- }
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[I].DlgItem);
- Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[I].Status) == pnm->ItemNew->ID);
- }
- ChangeLock--;
- }
- EnableMessagesOptDlgControls(MsgTree);
- return 0;
- } break;
- case MTN_DEFMSGCHANGED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- if (!ChangeLock)
- {
- CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
- _ASSERT(SelectedItem);
- if ((pnm->ItemOld && pnm->ItemOld->ID == SelectedItem->ID) || (pnm->ItemNew && pnm->ItemNew->ID == SelectedItem->ID))
- { // SelectedItem contains the same info as one of ItemOld or ItemNew - so we'll just use SelectedItem and won't bother with identifying which of ItemOld or ItemNew is currently selected
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- COptItem_Checkbox *Checkbox = (COptItem_Checkbox*)g_MessagesOptPage.Find(DefMsgDlgItems[I].DlgItem);
- Checkbox->SetWndValue(g_MessagesOptPage.GetWnd(), MsgTree->GetDefMsg(DefMsgDlgItems[I].Status) == SelectedItem->ID);
- }
- }
- }
- if (!ChangeLock)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- return 0;
- } break;
- case MTN_ITEMRENAMED:
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- CBaseTreeItem* SelectedItem = MsgTree->GetSelection();
- _ASSERT(SelectedItem);
- if (pnm->ItemNew->ID == SelectedItem->ID && !ChangeLock)
- {
- ChangeLock++;
- SetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, pnm->ItemNew->Title);
- ChangeLock--;
- }
- } // go through
- case MTN_ENDDRAG:
- case MTN_NEWCATEGORY:
- case MTN_NEWMESSAGE:
- case MTN_DELETEITEM:
- case TVN_ITEMEXPANDED:
- {
- if (!ChangeLock)
- {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- return 0;
- } break;
+ if (!ChangeLock) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
}
+ return 0;
+ } break;
}
- } break;
- case WM_COMMAND:
+ }
+ } break;
+ case WM_COMMAND:
+ {
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
{
- switch (HIWORD(wParam))
+
+
+ switch (LOWORD(wParam)) {
+
+ case IDC_MESSAGEDLG_DEF_ONL:
+ case IDC_MESSAGEDLG_DEF_AWAY:
+ case IDC_MESSAGEDLG_DEF_NA:
+ case IDC_MESSAGEDLG_DEF_OCC:
+ case IDC_MESSAGEDLG_DEF_DND:
+ case IDC_MESSAGEDLG_DEF_FFC:
+ case IDC_MESSAGEDLG_DEF_INV:
+ case IDC_MESSAGEDLG_DEF_OTP:
+ case IDC_MESSAGEDLG_DEF_OTL:
{
- case BN_CLICKED:
- {
-
-
- switch (LOWORD(wParam))
- {
-
- case IDC_MESSAGEDLG_DEF_ONL:
- case IDC_MESSAGEDLG_DEF_AWAY:
- case IDC_MESSAGEDLG_DEF_NA:
- case IDC_MESSAGEDLG_DEF_OCC:
- case IDC_MESSAGEDLG_DEF_DND:
- case IDC_MESSAGEDLG_DEF_FFC:
- case IDC_MESSAGEDLG_DEF_INV:
- case IDC_MESSAGEDLG_DEF_OTP:
- case IDC_MESSAGEDLG_DEF_OTL:
- {
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- if (LOWORD(wParam) == DefMsgDlgItems[I].DlgItem)
- {
- MsgTree->SetDefMsg(DefMsgDlgItems[I].Status, MsgTree->GetSelection()->ID); // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more
- break;
- }
- }
- } break;
- case IDC_MESSAGEDLG_VARS:
- {
- my_variables_showhelp(hwndDlg, IDC_MESSAGEDLG_MSGDATA);
- } break;
- case IDC_MESSAGEDLG_DEL:
- {
- MsgTree->EnsureVisible(MsgTree->GetSelection()->hItem);
- MsgTree->DeleteSelectedItem();
- } break;
- case IDC_MESSAGEDLG_NEWCAT:
- {
- MsgTree->AddCategory();
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
- } break;
- case IDC_MESSAGEDLG_NEWMSG:
- {
- MsgTree->AddMessage();
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
- } break;
-
- //NightFox:
- case IDC_LNK_AUTOAWAY:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- ood.pszPage = "Status";
- ood.pszTab = "Autoreply";
- Options_OpenPage(&ood);
- break;
- }
-
+ int i;
+ for (i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ if (LOWORD(wParam) == DefMsgDlgItems[i].DlgItem) {
+ MsgTree->SetDefMsg(DefMsgDlgItems[i].Status, MsgTree->GetSelection()->ID); // PSM_CHANGED is sent here through MTN_DEFMSGCHANGED, so we don't need to send it once more
+ break;
}
+ }
+ } break;
+ case IDC_MESSAGEDLG_VARS:
+ {
+ my_variables_showhelp(hwndDlg, IDC_MESSAGEDLG_MSGDATA);
+ } break;
+ case IDC_MESSAGEDLG_DEL:
+ {
+ MsgTree->EnsureVisible(MsgTree->GetSelection()->hItem);
+ MsgTree->DeleteSelectedItem();
+ } break;
+ case IDC_MESSAGEDLG_NEWCAT:
+ {
+ MsgTree->AddCategory();
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
+ } break;
+ case IDC_MESSAGEDLG_NEWMSG:
+ {
+ MsgTree->AddMessage();
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGEDLG_MSGTITLE));
+ } break;
-
- } break;
- case EN_CHANGE:
- {
- if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGDATA || LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE)
- {
- if (!ChangeLock)
- {
- if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE)
- {
- CBaseTreeItem* TreeItem = MsgTree->GetSelection();
- if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM))
- {
- GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, TreeItem->Title.GetBuffer(TREEITEMTITLE_MAXLEN), TREEITEMTITLE_MAXLEN);
- TreeItem->Title.ReleaseBuffer();
- ChangeLock++;
- MsgTree->UpdateItem(TreeItem->ID);
- ChangeLock--;
- }
- }
- MsgTree->SetModified(true);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- }
- } break;
+ //NightFox:
+ case IDC_LNK_AUTOAWAY:
+ {
+ OPENOPTIONSDIALOG ood = { 0 };
+ ood.cbSize = sizeof(ood);
+ ood.pszPage = "Status";
+ ood.pszTab = "Autoreply";
+ Options_OpenPage(&ood);
+ break;
}
+
+ }
+
+
} break;
- case WM_DESTROY:
+ case EN_CHANGE:
{
- delete MsgTree;
- MsgTree = NULL;
- g_MessagesOptPage.SetWnd(NULL);
+ if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGDATA || LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE) {
+ if (!ChangeLock) {
+ if (LOWORD(wParam) == IDC_MESSAGEDLG_MSGTITLE) {
+ CBaseTreeItem* TreeItem = MsgTree->GetSelection();
+ if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM)) {
+ GetDlgItemText(hwndDlg, IDC_MESSAGEDLG_MSGTITLE, TreeItem->Title.GetBuffer(TREEITEMTITLE_MAXLEN), TREEITEMTITLE_MAXLEN);
+ TreeItem->Title.ReleaseBuffer();
+ ChangeLock++;
+ MsgTree->UpdateItem(TreeItem->ID);
+ ChangeLock--;
+ }
+ }
+ MsgTree->SetModified(true);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
+ }
} break;
+ }
+ } break;
+ case WM_DESTROY:
+ {
+ delete MsgTree;
+ MsgTree = NULL;
+ g_MessagesOptPage.SetWnd(NULL);
+ } break;
}
return 0;
}
@@ -1089,115 +993,103 @@ static WNDPROC g_OrigContactsProc; __inline int DBValueToIgnoreIcon(int Value)
{
- switch (Value)
- {
- case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
- case 0: return EXTRAICON_DOT;
- default: return EXTRAICON_IGNORE;
+ switch (Value) {
+ case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
+ case 0: return EXTRAICON_DOT;
+ default: return EXTRAICON_IGNORE;
}
}
__inline int IgnoreIconToDBValue(int Value)
{
- switch (Value)
- {
- case EXTRAICON_DOT: return 0;
- case EXTRAICON_IGNORE: return 1;
- default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
+ switch (Value) {
+ case EXTRAICON_DOT: return 0;
+ case EXTRAICON_IGNORE: return 1;
+ default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
}
}
__inline int DBValueToOptReplyIcon(int Value)
{
- switch (Value)
- {
- case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
- case VAL_USEDEFAULT: return EXTRAICON_DOT;
- case 0: return EXTRAICON_AUTOREPLYOFF;
- default: return EXTRAICON_AUTOREPLYON;
+ switch (Value) {
+ case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
+ case VAL_USEDEFAULT: return EXTRAICON_DOT;
+ case 0: return EXTRAICON_AUTOREPLYOFF;
+ default: return EXTRAICON_AUTOREPLYON;
}
}
__inline int ReplyIconToDBValue(int Value)
{
- switch (Value)
- {
- case EXTRAICON_DOT: return VAL_USEDEFAULT;
- case EXTRAICON_AUTOREPLYOFF: return 0;
- case EXTRAICON_AUTOREPLYON: return 1;
- default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
+ switch (Value) {
+ case EXTRAICON_DOT: return VAL_USEDEFAULT;
+ case EXTRAICON_AUTOREPLYOFF: return 0;
+ case EXTRAICON_AUTOREPLYON: return 1;
+ default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
}
}
/*
__inline int DBValueToNotifyIcon(int Value)
{
- switch (Value)
- {
- case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
- case VAL_USEDEFAULT: return EXTRAICON_DOT;
- case 0: return EXTRAICON_DISABLENOTIFY;
- default: return EXTRAICON_ENABLENOTIFY;
- }
+switch (Value)
+{
+case VAL_INDEFINITE: return EXTRAICON_INDEFINITE;
+case VAL_USEDEFAULT: return EXTRAICON_DOT;
+case 0: return EXTRAICON_DISABLENOTIFY;
+default: return EXTRAICON_ENABLENOTIFY;
+}
}
__inline int NotifyIconToDBValue(int Value)
{
- switch (Value)
- {
- case EXTRAICON_DOT: return VAL_USEDEFAULT;
- case EXTRAICON_DISABLENOTIFY: return 0;
- case EXTRAICON_ENABLENOTIFY: return 1;
- default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
- }
+switch (Value)
+{
+case EXTRAICON_DOT: return VAL_USEDEFAULT;
+case EXTRAICON_DISABLENOTIFY: return 0;
+case EXTRAICON_ENABLENOTIFY: return 1;
+default: return VAL_INDEFINITE; // EXTRAICON_INDEFINITE and 0xFF
+}
}*/
static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem)
{
- int Icons[EXTRACOLUMNSCOUNT] = {0xFF, 0xFF, 0xFF};
- int I;
+ int Icons[EXTRACOLUMNSCOUNT] = { 0xFF, 0xFF, 0xFF };
+ int i;
HANDLE hItem;
int FirstItemType = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
hItem = (FirstItemType == CLCIT_GROUP) ? hFirstItem : (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
- while (hItem)
- {
+ while (hItem) {
HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
- if (hChildItem)
- {
+ if (hChildItem) {
SetListGroupIcons(hwndList, hChildItem, hItem);
}
- for (I = 0; I < lengthof(Icons); I++)
- {
- int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(I, 0));
- if (Icons[I] == 0xFF)
- {
- Icons[I] = Icon;
- } else if (Icon != 0xFF && Icons[I] != Icon)
- {
- Icons[I] = EXTRAICON_INDEFINITE;
+ for (i = 0; i < SIZEOF(Icons); i++) {
+ int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
+ if (Icons[i] == 0xFF) {
+ Icons[i] = Icon;
+ }
+ else if (Icon != 0xFF && Icons[i] != Icon) {
+ Icons[i] = EXTRAICON_INDEFINITE;
}
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
hItem = (FirstItemType == CLCIT_CONTACT) ? hFirstItem : (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
- while (hItem)
- {
- for (I = 0; I < lengthof(Icons); I++)
- {
- int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(I, 0));
- if (Icons[I] == 0xFF)
- {
- Icons[I] = Icon;
- } else if (Icon != 0xFF && Icons[I] != Icon)
- {
- Icons[I] = EXTRAICON_INDEFINITE;
+ while (hItem) {
+ for (i = 0; i < SIZEOF(Icons); i++) {
+ int Icon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(i, 0));
+ if (Icons[i] == 0xFF) {
+ Icons[i] = Icon;
+ }
+ else if (Icon != 0xFF && Icons[i] != Icon) {
+ Icons[i] = EXTRAICON_INDEFINITE;
}
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
-// set icons
- for (I = 0; I < lengthof(Icons); I++)
- {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(I, Icons[I]));
+ // set icons
+ for (i = 0; i < SIZEOF(Icons); i++) {
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, Icons[i]));
}
}
@@ -1207,35 +1099,29 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int HANDLE hItem, hChildItem;
typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
//check groups
- if (typeOfFirst == CLCIT_GROUP)
- {
+ if (typeOfFirst == CLCIT_GROUP) {
hItem = hFirstItem;
- } else
- {
+ }
+ else {
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
}
- while (hItem)
- {
+ while (hItem) {
hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
- if (hChildItem)
- {
+ if (hChildItem) {
SetAllChildIcons(hwndList, hChildItem, iColumn, iImage);
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
//check contacts
- if (typeOfFirst == CLCIT_CONTACT)
- {
+ if (typeOfFirst == CLCIT_CONTACT) {
hItem = hFirstItem;
- } else
- {
+ }
+ else {
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
}
- while (hItem)
- {
+ while (hItem) {
iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn);
- if (iOldIcon != 0xFF && iOldIcon != iImage)
- {
+ if (iOldIcon != 0xFF && iOldIcon != iImage) {
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
}
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
@@ -1245,35 +1131,31 @@ static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int static void SetIconsForColumn(HWND hwndList, HANDLE hItem, HANDLE hItemAll, int iColumn, int iImage)
{
int itemType = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0);
- switch (itemType)
+ switch (itemType) {
+ case CLCIT_CONTACT:
{
- case CLCIT_CONTACT:
- {
- int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn);
- if (oldiImage != 0xFF && oldiImage != iImage)
- {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
- }
- } break;
- case CLCIT_INFO:
- {
- if (hItem == hItemAll)
- {
- SetAllChildIcons(hwndList, hItem, iColumn, iImage);
- } else
- {
-// _ASSERT(hItem == hItemUnknown);
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
- }
- } break;
- case CLCIT_GROUP:
- {
- hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
- if (hItem)
- {
- SetAllChildIcons(hwndList, hItem, iColumn, iImage);
- }
- } break;
+ int oldiImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn);
+ if (oldiImage != 0xFF && oldiImage != iImage) {
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
+ }
+ } break;
+ case CLCIT_INFO:
+ {
+ if (hItem == hItemAll) {
+ SetAllChildIcons(hwndList, hItem, iColumn, iImage);
+ }
+ else {
+ // _ASSERT(hItem == hItemUnknown);
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
+ }
+ } break;
+ case CLCIT_GROUP:
+ {
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItem) {
+ SetAllChildIcons(hwndList, hItem, iColumn, iImage);
+ }
+ } break;
}
}
@@ -1281,30 +1163,24 @@ static void SaveItemState(HWND hwndList, MCONTACT hContact, HANDLE hItem) { // hContact == INVALID_HANDLE_VALUE means that hItem is hItemUnknown
int Ignore = IgnoreIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNORECOLUMN, 0)));
int Reply = ReplyIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(AUTOREPLYCOLUMN, 0)));
-// int Notify = NotifyIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(NOTIFYCOLUMN, 0)));
- if (Ignore != VAL_INDEFINITE)
- {
+ // int Notify = NotifyIconToDBValue(SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(NOTIFYCOLUMN, 0)));
+ if (Ignore != VAL_INDEFINITE) {
CContactSettings(ID_STATUS_ONLINE, hContact).Ignore = Ignore;
}
- if (Reply != VAL_INDEFINITE)
- {
+ if (Reply != VAL_INDEFINITE) {
CContactSettings(ID_STATUS_ONLINE, hContact).Autoreply = Reply;
}
-/* if (Notify != VAL_INDEFINITE)
- {
+ /* if (Notify != VAL_INDEFINITE)
+ {
CContactSettings(ID_STATUS_ONLINE, hContact).PopupNotify = Notify;
- }*/
- if (hContact != INVALID_CONTACT_ID && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS))
- {
+ }*/
+ if (hContact != INVALID_CONTACT_ID && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS)) {
int iMode;
- for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++)
- {
- if (Ignore != VAL_INDEFINITE)
- {
+ for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++) {
+ if (Ignore != VAL_INDEFINITE) {
CContactSettings(iMode, hContact).Ignore = Ignore;
}
- if (Reply != VAL_INDEFINITE)
- {
+ if (Reply != VAL_INDEFINITE) {
CContactSettings(iMode, hContact).Autoreply = Reply;
} // Notify is not per-status, so we're not setting it here
}
@@ -1323,7 +1199,7 @@ static void SetAllContactIcons(HWND hwndList, HANDLE hItemUnknown) char *szProto = GetContactProto(hContact);
int Ignore = CContactSettings(ID_STATUS_ONLINE, hContact).Ignore;
int Reply = CContactSettings(ID_STATUS_ONLINE, hContact).Autoreply;
-// int Notify = CContactSettings(ID_STATUS_ONLINE, hContact).PopupNotify;
+ // int Notify = CContactSettings(ID_STATUS_ONLINE, hContact).PopupNotify;
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS)) {
int iMode;
for (iMode = ID_STATUS_AWAY; iMode < ID_STATUS_OUTTOLUNCH; iMode++) {
@@ -1337,23 +1213,18 @@ static void SetAllContactIcons(HWND hwndList, HANDLE hItemUnknown) SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(IGNORECOLUMN, DBValueToIgnoreIcon(Ignore)));
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(AUTOREPLYCOLUMN, DBValueToOptReplyIcon(Reply)));
}
- }
- while (hContact = db_find_next(hContact));
+ } while (hContact = db_find_next(hContact));
}
static LRESULT CALLBACK ContactsSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- switch (Msg)
- {
- case WM_LBUTTONDBLCLK:
- {
- DWORD hitFlags;
- HANDLE hItem = (HANDLE)SendMessage(hWnd, CLM_HITTEST, (WPARAM)&hitFlags, lParam);
- if (hItem && (hitFlags & CLCHT_ONITEMEXTRA))
- {
- Msg = WM_LBUTTONDOWN; // may be considered as a hack, but it's needed to make clicking on extra icons more convenient
- }
- } break;
+ switch (Msg) {
+ case WM_LBUTTONDBLCLK:
+ DWORD hitFlags;
+ HANDLE hItem = (HANDLE)SendMessage(hWnd, CLM_HITTEST, (WPARAM)&hitFlags, lParam);
+ if (hItem && (hitFlags & CLCHT_ONITEMEXTRA))
+ Msg = WM_LBUTTONDOWN; // may be considered as a hack, but it's needed to make clicking on extra icons more convenient
+ break;
}
return CallWindowProc(g_OrigContactsProc, hWnd, Msg, wParam, lParam);
}
@@ -1361,11 +1232,11 @@ static LRESULT CALLBACK ContactsSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HANDLE hItemAll, hItemUnknown;
- switch (msg)
- {
+
+ switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
MySetPos(hwndDlg);
HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
@@ -1377,7 +1248,7 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndList, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
SendMessage(hwndDlg, UM_CONTACTSDLG_RESETLISTOPTIONS, 0, 0);
SendMessage(hwndList, CLM_SETEXTRACOLUMNS, EXTRACOLUMNSCOUNT, 0);
- CLCINFOITEM cii={0};
+ CLCINFOITEM cii = { 0 };
cii.cbSize = sizeof(cii);
cii.flags = CLCIIF_GROUPFONT;
cii.pszText = TranslateT("** All contacts **");
@@ -1385,23 +1256,21 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP cii.pszText = TranslateT("** Not-on-list contacts **"); // == Unknown contacts
hItemUnknown = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
MCONTACT hContact = db_find_first();
- do
- {
+ do {
char *szProto = GetContactProto(hContact);
- if (szProto)
- {
+ if (szProto) {
int Flag1 = CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0);
- if ((Flag1 & PF1_IM) != PF1_IM && !(Flag1 & PF1_INDIVMODEMSG))
- { // does contact's protocol supports message sending/receiving or individual status messages?
+ if ((Flag1 & PF1_IM) != PF1_IM && !(Flag1 & PF1_INDIVMODEMSG)) // does contact's protocol supports message sending/receiving or individual status messages?
SendMessage(hwndList, CLM_DELETEITEM, SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
- }
}
}
- while (hContact = db_find_next(hContact));
+ while (hContact = db_find_next(hContact));
SetAllContactIcons(hwndList, hItemUnknown);
SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
g_OrigContactsProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)ContactsSubclassProc);
- } break;
+ }
+ break;
+
case UM_CONTACTSDLG_RESETLISTOPTIONS:
{
HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
@@ -1411,101 +1280,80 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP SendMessage(hwndList, CLM_SETLEFTMARGIN, 4, 0);
SendMessage(hwndList, CLM_SETINDENT, 10, 0);
SendMessage(hwndList, CLM_SETHIDEEMPTYGROUPS, 1, 0);
- int I;
- for (I = 0; I <= FONTID_MAX; I++)
- {
- SendMessage(hwndList, CLM_SETTEXTCOLOR, I, GetSysColor(COLOR_WINDOWTEXT));
- }
- } break;
+ for (int i = 0; i <= FONTID_MAX; i++)
+ SendMessage(hwndList, CLM_SETTEXTCOLOR, i, GetSysColor(COLOR_WINDOWTEXT));
+ }
+ break;
+
case WM_SETFOCUS:
- {
- SetFocus(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST));
- } break;
+ SetFocus(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST));
+ break;
+
case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom)
- {
- case IDC_CONTACTSDLG_LIST:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case IDC_CONTACTSDLG_LIST:
+ switch (((LPNMHDR)lParam)->code) {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ SetAllContactIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hItemUnknown);
+ // fall through
+ case CLN_CONTACTMOVED:
+ SetListGroupIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
+ break;
+ case CLN_OPTIONSCHANGED:
+ SendMessage(hwndDlg, UM_CONTACTSDLG_RESETLISTOPTIONS, 0, 0);
+ break;
+
+ case NM_CLICK:
+ case NM_DBLCLK:
{
- switch (((LPNMHDR)lParam)->code)
- {
- case CLN_NEWCONTACT:
- case CLN_LISTREBUILT:
- {
- SetAllContactIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hItemUnknown);
- } // fall through
- case CLN_CONTACTMOVED:
- {
- SetListGroupIcons(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
- } break;
- case CLN_OPTIONSCHANGED:
- {
- SendMessage(hwndDlg, UM_CONTACTSDLG_RESETLISTOPTIONS, 0, 0);
- } break;
- case NM_CLICK:
- case NM_DBLCLK:
- {
- NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
- HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
- HANDLE hItem;
- DWORD hitFlags;
- if (nm->iColumn == -1)
- {
- break;
- }
- hItem = (HANDLE)SendMessage(hwndList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
- if (!hItem || !(hitFlags & CLCHT_ONITEMEXTRA))
- {
- break;
- }
- int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
- switch (nm->iColumn)
- {
- case AUTOREPLYCOLUMN:
- {
- switch (iImage)
- {
- case EXTRAICON_DOT: iImage = EXTRAICON_AUTOREPLYOFF; break;
- case EXTRAICON_AUTOREPLYOFF: iImage = EXTRAICON_AUTOREPLYON; break;
- default: iImage = EXTRAICON_DOT; // EXTRAICON_AUTOREPLYON and EXTRAICON_INDEFINITE
- }
- } break;
- case IGNORECOLUMN:
- {
- iImage = (iImage == EXTRAICON_DOT) ? EXTRAICON_IGNORE : EXTRAICON_DOT;
- } break;
- /*case NOTIFYCOLUMN:
- {
- switch (iImage)
- {
- case EXTRAICON_DOT: iImage = EXTRAICON_DISABLENOTIFY; break;
- case EXTRAICON_DISABLENOTIFY: iImage = EXTRAICON_ENABLENOTIFY; break;
- default: iImage = EXTRAICON_DOT; // EXTRAICON_ENABLENOTIFY and EXTRAICON_INDEFINITE
- }
- }*/ break;
- }
- SetIconsForColumn(hwndList, hItem, hItemAll, nm->iColumn, iImage);
- SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- } break;
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST);
+ if (nm->iColumn == -1)
+ break;
+
+ DWORD hitFlags;
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
+ if (!hItem || !(hitFlags & CLCHT_ONITEMEXTRA))
+ break;
+
+ int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
+ switch (nm->iColumn) {
+ case AUTOREPLYCOLUMN:
+ switch (iImage) {
+ case EXTRAICON_DOT: iImage = EXTRAICON_AUTOREPLYOFF; break;
+ case EXTRAICON_AUTOREPLYOFF: iImage = EXTRAICON_AUTOREPLYON; break;
+ default: iImage = EXTRAICON_DOT; // EXTRAICON_AUTOREPLYON and EXTRAICON_INDEFINITE
+ }
+ break;
+ case IGNORECOLUMN:
+ iImage = (iImage == EXTRAICON_DOT) ? EXTRAICON_IGNORE : EXTRAICON_DOT;
+ break;
}
+ break;
+
+ SetIconsForColumn(hwndList, hItem, hItemAll, nm->iColumn, iImage);
+ SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- break;
- case 0:
- switch (((LPNMHDR)lParam)->code) {
- case PSN_APPLY:
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
- if (hItem)
- SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hContact, hItem);
- }
-
- SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), INVALID_CONTACT_ID, hItemUnknown);
- return true;
+ }
+ break;
+
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_FINDCONTACT, (WPARAM)hContact, 0);
+ if (hItem)
+ SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), hContact, hItem);
}
- break;
+
+ SaveItemState(GetDlgItem(hwndDlg, IDC_CONTACTSDLG_LIST), INVALID_CONTACT_ID, hItemUnknown);
+ return true;
}
- } break;
+ }
+ break;
+
case WM_DESTROY:
HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_CONTACTSDLG_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
_ASSERT(hIml);
@@ -1515,11 +1363,9 @@ INT_PTR CALLBACK ContactsOptDlg(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return 0;
}
-
int OptsDlgInit(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE optDi = {0};
- optDi.cbSize = sizeof(optDi);
+ OPTIONSDIALOGPAGE optDi = { sizeof(optDi) };
optDi.position = 920000000;
optDi.hInstance = g_hInstance;
optDi.flags = ODPF_BOLDGROUPS;
@@ -1572,25 +1418,25 @@ void InitOptions() TreeRootItemArray RootItems;
RootItems.AddElem(CTreeRootItem(TranslateT("Predefined messages"), g_Messages_PredefinedRootID = ID++, TIF_EXPANDED));
RootItems.AddElem(CTreeRootItem(TranslateT("Recent messages"), g_Messages_RecentRootID = ID++, TIF_EXPANDED));
- DefMsgTree.AddElem(CTreeItem(TranslateT("Gone fragging"), g_Messages_PredefinedRootID, ID++, 0, TranslateTS(_T("Been fragging since %") _T(VAR_AWAYSINCE_TIME) _T("%, I'll msg you later when the adrenaline wears off."))));
- DefMsgTree.AddElem(CTreeItem(TranslateT("Creepy"), g_Messages_PredefinedRootID, ID++, 0, TranslateT("Your master, %nas_mynick%, has been %nas_statdesc% since the day that is only known as ?nas_awaysince_date(dddd)... When he gets back, I'll tell him you dropped by...")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("Gone fragging"), g_Messages_PredefinedRootID, ID++, 0, TranslateTS(_T("Been fragging since %") _T(VAR_AWAYSINCE_TIME) _T("%, i'll msg you later when the adrenaline wears off."))));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("Creepy"), g_Messages_PredefinedRootID, ID++, 0, TranslateT("Your master, %nas_mynick%, has been %nas_statdesc% since the day that is only known as ?nas_awaysince_date(dddd)... When he gets back, i'll tell him you dropped by...")));
DefMsgTree.AddElem(CTreeItem(TranslateT("Default messages"), g_Messages_PredefinedRootID, ParentID1 = ID++, TIF_GROUP | TIF_EXPANDED));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_ONL, StatusToDBSetting(ID_STATUS_ONLINE, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
- DefMsgTree.AddElem(CTreeItem(TranslateT("Online"), ParentID1, ID++, 0, TranslateT("Yep, I'm here.")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("Online"), ParentID1, ID++, 0, TranslateT("Yep, i'm here.")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_AWAY, StatusToDBSetting(ID_STATUS_AWAY, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
DefMsgTree.AddElem(CTreeItem(TranslateT("Away"), ParentID1, ID++, 0, TranslateT("Been gone since %nas_awaysince_time%, will be back later.")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_NA, StatusToDBSetting(ID_STATUS_NA, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
- DefMsgTree.AddElem(CTreeItem(TranslateT("NA"), ParentID1, ID++, 0, TranslateT("Give it up, I'm not in!")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("NA"), ParentID1, ID++, 0, TranslateT("Give it up, i'm not in!")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_OCC, StatusToDBSetting(ID_STATUS_OCCUPIED, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
DefMsgTree.AddElem(CTreeItem(TranslateT("Occupied"), ParentID1, ID++, 0, TranslateT("Not right now.")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_DND, StatusToDBSetting(ID_STATUS_DND, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
DefMsgTree.AddElem(CTreeItem(TranslateT("DND"), ParentID1, ID++, 0, TranslateT("Give a guy some peace, would ya?")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_FFC, StatusToDBSetting(ID_STATUS_FREECHAT, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
- DefMsgTree.AddElem(CTreeItem(TranslateT("Free for chat"), ParentID1, ID++, 0, TranslateT("I'm a chatbot!")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("Free for chat"), ParentID1, ID++, 0, TranslateT("i'm a chatbot!")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_INV, StatusToDBSetting(ID_STATUS_INVISIBLE, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
- DefMsgTree.AddElem(CTreeItem(TranslateT("Invisible"), ParentID1, ID++, 0, TranslateT("I'm hiding from the mafia.")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("Invisible"), ParentID1, ID++, 0, TranslateT("i'm hiding from the mafia.")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_OTP, StatusToDBSetting(ID_STATUS_ONTHEPHONE, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
- DefMsgTree.AddElem(CTreeItem(TranslateT("On the phone"), ParentID1, ID++, 0, TranslateT("I've been on the phone since %nas_awaysince_time%, give me a sec!")));
+ DefMsgTree.AddElem(CTreeItem(TranslateT("On the phone"), ParentID1, ID++, 0, TranslateT("i've been on the phone since %nas_awaysince_time%, give me a sec!")));
g_MsgTreePage.Items.AddElem(new COptItem_IntDBSetting(IDS_MESSAGEDLG_DEF_OTL, StatusToDBSetting(ID_STATUS_OUTTOLUNCH, MESSAGES_DB_MSGTREEDEF), DBVT_WORD, false, ID));
DefMsgTree.AddElem(CTreeItem(TranslateT("Out to lunch"), ParentID1, ID++, 0, TranslateT("Been having ?ifgreater(?ctime(H),2,?ifgreater(?ctime(H),10,?ifgreater(?ctime(H),16,supper,dinner),breakfast),supper) since %nas_awaysince_time%.")));
g_MsgTreePage.Items.AddElem(new COptItem_TreeCtrl(IDV_MSGTREE, "MsgTree", DefMsgTree, RootItems, 0, "Text"));
@@ -1664,23 +1510,22 @@ int ModernOptInitialise(WPARAM wParam, LPARAM lParam) IDC_TXT_TITLE2,
IDC_TXT_TITLE3,
MODERNOPT_CTRL_LAST
- };
-
- MODERNOPTOBJECT obj = {0};
+ };
+ MODERNOPTOBJECT obj = { 0 };
obj.cbSize = sizeof(obj);
- obj.dwFlags = MODEROPT_FLG_TCHAR|MODEROPT_FLG_NORESIZE;
+ obj.dwFlags = MODEROPT_FLG_TCHAR | MODEROPT_FLG_NORESIZE;
obj.hInstance = g_hInstance;
obj.iSection = MODERNOPT_PAGE_STATUS;
obj.iType = MODERNOPT_TYPE_SECTIONPAGE;
obj.iBoldControls = iBoldControls;
-// obj.lpzClassicGroup = NULL;
+ // obj.lpzClassicGroup = NULL;
obj.lpzClassicPage = "Status";
obj.lpzClassicTab = "Main options";
-// obj.lpzHelpUrl = "http://wiki.miranda-im.org/";
+ // obj.lpzHelpUrl = "http://wiki.miranda-im.org/";
obj.lpzTemplate = MAKEINTRESOURCEA(IDD_MODERNOPT_MESSAGES);
obj.pfnDlgProc = MessagesModernOptDlg;
CallService(MS_MODERNOPT_ADDOBJECT, wParam, (LPARAM)&obj);
return 0;
-}
\ No newline at end of file +}
diff --git a/plugins/NewAwaySysMod/src/AwaySys.cpp b/plugins/NewAwaySysMod/src/AwaySys.cpp index 537047d91f..9019768c33 100644 --- a/plugins/NewAwaySysMod/src/AwaySys.cpp +++ b/plugins/NewAwaySysMod/src/AwaySys.cpp @@ -72,24 +72,17 @@ static struct ID_STATUS_OUTTOLUNCH, IDC_REPLYDLG_DISABLE_OTL, IDC_MOREOPTDLG_DONTPOPDLG_OTL
};
-// took this nice idea from MetaContacts plugin ;)
-// my_make_version is required to break up #define PRODUCTVER from VersionNo.h
-DWORD my_make_version(const int a, const int b, const int c, const int d)
-{
- return PLUGIN_MAKE_VERSION(a, b, c, d);
-}
-
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
- "New Away System Mod",
- my_make_version(PRODUCTVER), // see VersionNo.h
- "New Away System Mod plugin for Miranda IM.",
- "NightFox; Deathdemon; XF007; Goblineye Entertainment",
- "NightFox@myied.org",
- "© 2010 NightFox; © 2005-2007 Chervov Dmitry; © 2004-2005 Iksaif; © 2002-2003 Goblineye Entertainment",
- "http://MyiEd.org/packs",
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
UNICODE_AWARE,
- {0xb2dd9270, 0xce5e, 0x11df, {0xbd, 0x3d, 0x8, 0x0, 0x20, 0xc, 0x9a, 0x66}}
+ { 0xb2dd9270, 0xce5e, 0x11df, { 0xbd, 0x3d, 0x8, 0x0, 0x20, 0xc, 0x9a, 0x66 } }
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -98,7 +91,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) return TRUE;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SRAWAY, MIID_LAST}; // TODO: add MIID_WHOISREADING here if there'll be any some time in future..
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRAWAY, MIID_LAST }; // TODO: add MIID_WHOISREADING here if there'll be any some time in future..
extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
{
@@ -106,11 +99,11 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda }
//NightFox
-int ModernOptInitialise(WPARAM wParam,LPARAM lParam);
+int ModernOptInitialise(WPARAM wParam, LPARAM lParam);
TCString GetDynamicStatMsg(MCONTACT hContact, char *szProto, DWORD UIN, int iStatus)
{
-// hContact is the contact that requests the status message
+ // hContact is the contact that requests the status message
if (hContact != INVALID_CONTACT_ID)
VarParseData.Message = CContactSettings(iStatus, hContact).GetMsgFormat(GMF_ANYCURRENT, NULL, szProto);
else // contact is unknown
@@ -120,16 +113,14 @@ TCString GetDynamicStatMsg(MCONTACT hContact, char *szProto, DWORD UIN, int iSta VarParseData.szProto = szProto ? szProto : ((hContact && hContact != INVALID_CONTACT_ID) ? (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0) : NULL);
VarParseData.UIN = UIN;
VarParseData.Flags = 0;
- if (ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES))
- {
- FORMATINFO fi = {0};
+ if (ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES)) {
+ FORMATINFO fi = { 0 };
fi.cbSize = sizeof(fi);
fi.tszFormat = VarParseData.Message;
fi.hContact = hContact;
fi.flags = FIF_TCHAR;
TCHAR *szResult = (TCHAR*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (szResult)
- {
+ if (szResult) {
VarParseData.Message = szResult;
mir_free(szResult);
}
@@ -142,7 +133,7 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) {
_ASSERT(szProto != NULL);
LogMessage("ME_ICQ_STATUSMSGREQ called. szProto=%s, Status=%d, UIN=%d", (char*)szProto, wParam, lParam);
-// find the contact
+ // find the contact
char *szFoundProto;
MCONTACT hFoundContact = NULL; // if we'll find the contact only on some other protocol, but not on szProto, then we'll use that hContact.
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
@@ -170,27 +161,24 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) CallAllowedPS_SETAWAYMSG(szProto, iMode, NULL); // we can set status messages to NULL here, as they'll be changed again when the SAM dialog closes.
return 0;
}
- if (CContactSettings(iMode, hContactForSettings).Ignore)
- {
+ if (CContactSettings(iMode, hContactForSettings).Ignore) {
CallAllowedPS_SETAWAYMSG(szProto, iMode, ""); // currently NULL makes ICQ to ignore _any_ further status message requests until the next PS_SETAWAYMSG, so i can't use it here..
return 0; // move along, sir
}
- if (iMode)
- { // if it's not an xstatus message request
+ if (iMode) { // if it's not an xstatus message request
CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(GetDynamicStatMsg(hFoundContact, szProto, lParam)));
}
-// COptPage PopupNotifyData(g_PopupOptPage);
-// PopupNotifyData.DBToMem();
+ // COptPage PopupNotifyData(g_PopupOptPage);
+ // PopupNotifyData.DBToMem();
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)) ||
+ /*
+ 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)) ||
@@ -199,49 +187,44 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) (!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())
- {
- LogMsg += _T("\r\n");
- }
- LogMsg += XMsg;
- }
- } else
+ // Show popup and play a sound
+ if (ShowPopup)
{
- LogMsg = VarParseData.Message;
+ ShowPopup = ShowPopupNotification(PopupNotifyData, hFoundContact, iMode); // we need ShowPopup also to determine whether to log to file or not
}
- 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;
- if (!szStatDesc)
- {
- _ASSERT(0);
- szStatDesc = _T("");
+ */
+ // 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()) {
+ LogMsg += _T("\r\n");
}
- 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);
+ LogMsg += XMsg;
}
-// }
+ }
+ 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;
+ 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);
+ }
+ // }
return 0;
}
@@ -251,15 +234,13 @@ int StatusMsgReq(WPARAM wParam, LPARAM lParam, CString &szProto) CString ICQProtoList[MAXICQACCOUNTS];
#define StatusMsgReqN(N) int StatusMsgReq##N(WPARAM wParam, LPARAM lParam) {return StatusMsgReq(wParam, lParam, ICQProtoList[N - 1]);}
StatusMsgReqN(1) StatusMsgReqN(2) StatusMsgReqN(3) StatusMsgReqN(4) StatusMsgReqN(5)
-MIRANDAHOOK StatusMsgReqHooks[] = {StatusMsgReq1, StatusMsgReq2, StatusMsgReq3, StatusMsgReq4, StatusMsgReq5};
+MIRANDAHOOK StatusMsgReqHooks[] = { StatusMsgReq1, StatusMsgReq2, StatusMsgReq3, StatusMsgReq4, StatusMsgReq5 };
int IsAnICQProto(char *szProto)
{
int i;
- for (i = 0; i < MAXICQACCOUNTS; i++)
- {
- if (ICQProtoList[i] == (const char*)szProto)
- {
+ for (i = 0; i < MAXICQACCOUNTS; i++) {
+ if (ICQProtoList[i] == (const char*)szProto) {
return true;
}
}
@@ -269,11 +250,11 @@ int IsAnICQProto(char *szProto) int StatusChanged(WPARAM wParam, LPARAM lParam)
{
-// wParam = iMode
-// lParam = (char*)szProto
+ // 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
+ // let's check if we handle this thingy
if (g_fNoProcessing) { // we're told not to do anything
g_fNoProcessing = false; // take it off
return 0;
@@ -294,35 +275,29 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) Flag3 |= CallProtoService(proto[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())
- {
+ if (g_SetAwayMsgPage.GetWnd()) {
SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
return 0;
}
int i;
- for (i = lengthof(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))
- {
+ if (bScreenSaverRunning || g_MoreOptPage.GetDBValueCopy(StatusModeList[i].DontShowDialogCtlID)) {
CProtoSettings((char*)lParam).SetMsgFormat(SMF_PERSONAL, CProtoSettings((char*)lParam).GetMsgFormat(GMF_LASTORDEFAULT));
ChangeProtoMessages((char*)lParam, wParam, TCString());
- } else
- {
+ }
+ else {
SetAwayMsgData *dat = new SetAwayMsgData;
ZeroMemory(dat, sizeof(SetAwayMsgData));
dat->szProtocol = (char*)lParam;
@@ -338,21 +313,17 @@ int StatusChanged(WPARAM wParam, LPARAM lParam) #define ID_STATUS_DISABLED 41083
int CSStatusChange(WPARAM wParam, LPARAM lParam) // CommonStatus plugins (StartupStatus and AdvancedAutoAway)
{
-// wParam = PROTOCOLSETTINGEX** protoSettings
+ // 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 (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_DISABLED) {
+ 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));
@@ -372,7 +343,7 @@ static int IdleChangeEvent(WPARAM wParam, LPARAM lParam) int CSModuleLoaded(WPARAM wParam, LPARAM lParam) // StartupStatus and AdvancedAutoAway
{
-// wParam = ProtoCount
+ // wParam = ProtoCount
g_CSProtoCount = wParam;
return 0;
}
@@ -381,55 +352,47 @@ int CSModuleLoaded(WPARAM wParam, LPARAM lParam) // StartupStatus and AdvancedAu int PreBuildContactMenu(WPARAM hContact, LPARAM lParam)
{
char *szProto = GetContactProto(hContact);
- CLISTMENUITEM miSetMsg = {0};
+ CLISTMENUITEM miSetMsg = { 0 };
miSetMsg.cbSize = sizeof(miSetMsg);
miSetMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIF_HIDDEN;
- CLISTMENUITEM miReadMsg = {0};
+ CLISTMENUITEM miReadMsg = { 0 };
miReadMsg.cbSize = sizeof(miReadMsg);
miReadMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIF_HIDDEN;
int iMode = szProto ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : 0;
int Flag1 = szProto ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : 0;
int iContactMode = db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE);
TCHAR szSetStr[256], szReadStr[256];
- if (szProto)
- {
+ if (szProto) {
int i;
- for (i = lengthof(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
+ 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));
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
+ 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));
miReadMsg.ptszName = szReadStr;
miReadMsg.flags = CMIM_FLAGS | CMIF_TCHAR | CMIM_NAME | CMIM_ICON;
miReadMsg.hIcon = LoadSkinnedProtoIcon(szProto, iContactMode);
}
}
- if (g_hContactMenuItem)
- {
+ 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 ((Flag1 & PF1_IM) == PF1_IM) { // if this contact supports sending/receiving messages
int iAutoreply = CContactSettings(g_ProtoStates[szProto].Status, hContact).Autoreply;
- CLISTMENUITEM mi = {0};
+ CLISTMENUITEM mi = { 0 };
mi.cbSize = 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;
+ 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;
}
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hToggleSOEContactMenuItem, (LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIF_TCHAR | (iAutoreply == 1 ? CMIF_CHECKED : 0);
@@ -438,9 +401,9 @@ int PreBuildContactMenu(WPARAM hContact, LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hAutoreplyOffContactMenuItem, (LPARAM)&mi);
mi.flags = CMIM_FLAGS | CMIF_TCHAR | (iAutoreply == VAL_USEDEFAULT ? CMIF_CHECKED : 0);
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hAutoreplyUseDefaultContactMenuItem, (LPARAM)&mi);
- } else
- { // hide the Autoreply menu item
- CLISTMENUITEM mi = {0};
+ }
+ else { // hide the Autoreply menu item
+ CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(mi);
mi.flags = CMIM_FLAGS | CMIF_TCHAR | CMIF_HIDDEN;
CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)g_hToggleSOEContactMenuItem, (LPARAM)&mi);
@@ -470,22 +433,22 @@ static INT_PTR SetContactStatMsg(WPARAM hContact, LPARAM lParam) /* //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);
- }
+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);
+}
}
*/
@@ -523,43 +486,40 @@ INT_PTR srvAutoreplyUseDefault(WPARAM hContact, LPARAM lParam) /* //NightFox: deleted used-to-be support
int Create_TopToolbar(WPARAM wParam, LPARAM lParam)
{
- int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].Status).Autoreply;
- if (ServiceExists(MS_TTB_ADDBUTTON))
- {
- TTBButton ttbb = {0};
- ttbb.cbSize = sizeof(ttbb);
- ttbb.hbBitmapUp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_SOE_DISABLED));
- ttbb.hbBitmapDown = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_SOE_ENABLED));
- ttbb.pszServiceUp = MS_AWAYSYS_AUTOREPLY_TOGGLE;
- ttbb.pszServiceDown = MS_AWAYSYS_AUTOREPLY_TOGGLE;
- ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
- ttbb.name = Translate("Toggle autoreply on/off");
- g_hTopToolbarbutton = (HANDLE)CallService(MS_TTB_ADDBUTTON, (WPARAM)&ttbb, 0);
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)g_hTopToolbarbutton, SendOnEvent ? TTBST_PUSHED : TTBST_RELEASED);
- }
- return 0;
+int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].Status).Autoreply;
+if (ServiceExists(MS_TTB_ADDBUTTON))
+{
+TTBButton ttbb = {0};
+ttbb.cbSize = sizeof(ttbb);
+ttbb.hbBitmapUp = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_SOE_DISABLED));
+ttbb.hbBitmapDown = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_SOE_ENABLED));
+ttbb.pszServiceUp = MS_AWAYSYS_AUTOREPLY_TOGGLE;
+ttbb.pszServiceDown = MS_AWAYSYS_AUTOREPLY_TOGGLE;
+ttbb.dwFlags = TTBBF_VISIBLE | TTBBF_SHOWTOOLTIP;
+ttbb.name = Translate("Toggle autoreply on/off");
+g_hTopToolbarbutton = (HANDLE)CallService(MS_TTB_ADDBUTTON, (WPARAM)&ttbb, 0);
+CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)g_hTopToolbarbutton, SendOnEvent ? TTBST_PUSHED : TTBST_RELEASED);
+}
+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())
- {
+ /* if (g_PopupOptPage.GetWnd())
+ {
SendMessage(g_PopupOptPage.GetWnd(), UM_ICONSCHANGED, 0, 0);
- }*/
+ }*/
return 0;
}
@@ -568,12 +528,10 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) {
CONTACTSETTINGSINIT *csi = (CONTACTSETTINGSINIT*)wParam;
char *szProto = (csi->Type == CSIT_CONTACT) ? GetContactProto(csi->hContact) : NULL;
- if ((csi->Type == CSIT_GROUP) || szProto)
- {
+ if ((csi->Type == CSIT_GROUP) || szProto) {
int Flag1 = (csi->Type == CSIT_CONTACT) ? CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) : PF1_IM; // we assume that there can be some contacts in the group with PF1_IM capability
- if ((Flag1 & PF1_IM) == PF1_IM || Flag1 & PF1_INDIVMODEMSG)
- { // does contact's protocol supports message sending/receiving or individual status messages?
- CONTACTSETTINGSCONTROL csc = {0};
+ if ((Flag1 & PF1_IM) == PF1_IM || Flag1 & PF1_INDIVMODEMSG) { // does contact's protocol supports message sending/receiving or individual status messages?
+ CONTACTSETTINGSCONTROL csc = { 0 };
csc.cbSize = sizeof(csc);
csc.cbStateSize = sizeof(CSCONTROLSTATE);
csc.Position = CSPOS_SORTBYALPHABET;
@@ -584,25 +542,23 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) /*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);
+ 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)
- {
+ if (csi->Type == CSIT_CONTACT) {
CContactSettings CSettings(0, csi->hContact);
StatusMode = CSettings.Status;
- } else
- {
+ }
+ else {
_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;
@@ -610,13 +566,12 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) 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))
- {
+ 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));
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.");
- } else
- {
+ }
+ else {
csc.ptszTitle = TranslateT("Enable autoreply");
csc.ptszTooltip = NULL;
}
@@ -624,13 +579,12 @@ static int ContactSettingsInit(WPARAM wParam, LPARAM lParam) csc.szSetting = Setting;
CallService(MS_CONTACTSETTINGS_ADDCONTROL, wParam, (LPARAM)&csc);
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSPERSONALSETTINGS))
- {
+ 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));
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.");
- } else
- {
+ }
+ else {
csc.ptszTitle = TranslateT("Don't send status message");
csc.ptszTooltip = TranslateT("Ignore status message requests from this contact and don't send an autoreply");
}
@@ -648,41 +602,37 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) ARGUMENTSINFO *ai = (ARGUMENTSINFO*)lParam;
ai->flags = AIF_DONTPARSE;
TCString Result;
- if (!lstrcmp(ai->targv[0], _T(VAR_AWAYSINCE_TIME)))
- {
+ if (!lstrcmp(ai->targv[0], _T(VAR_AWAYSINCE_TIME))) {
GetTimeFormat(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), 0, g_ProtoStates[VarParseData.szProto].AwaySince, (ai->argc > 1 && *ai->targv[1]) ? ai->targv[1] : _T("H:mm"), Result.GetBuffer(256), 256);
Result.ReleaseBuffer();
- } else if (!lstrcmp(ai->targv[0], _T(VAR_AWAYSINCE_DATE)))
- {
+ }
+ else if (!lstrcmp(ai->targv[0], _T(VAR_AWAYSINCE_DATE))) {
GetDateFormat(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), 0, g_ProtoStates[VarParseData.szProto].AwaySince, (ai->argc > 1 && *ai->targv[1]) ? ai->targv[1] : NULL, Result.GetBuffer(256), 256);
Result.ReleaseBuffer();
- } else if (!lstrcmp(ai->targv[0], _T(VAR_STATDESC)))
- {
+ }
+ 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);
- } else if (!lstrcmp(ai->targv[0], _T(VAR_MYNICK)))
- {
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto)
- {
+ }
+ else if (!lstrcmp(ai->targv[0], _T(VAR_MYNICK))) {
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_MYNICKPERPROTO) && VarParseData.szProto) {
Result = db_get_s(NULL, VarParseData.szProto, "Nick", (TCHAR*)NULL);
}
- if (Result == NULL)
- {
+ if (Result == NULL) {
Result = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, NULL, GCDNF_TCHAR);
}
- if (Result == NULL)
- {
+ if (Result == NULL) {
Result = TranslateT("Stranger");
}
- } else if (!lstrcmp(ai->targv[0], _T(VAR_REQUESTCOUNT)))
- {
+ }
+ 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));
Result.ReleaseBuffer();
- } else if (!lstrcmp(ai->targv[0], _T(VAR_MESSAGENUM)))
- {
+ }
+ else if (!lstrcmp(ai->targv[0], _T(VAR_MESSAGENUM))) {
mir_sntprintf(Result.GetBuffer(16), 16, _T("%d"), db_get_w(ai->fi->hContact, MOD_NAME, DB_MESSAGECOUNT, 0));
Result.ReleaseBuffer();
- } else if (!lstrcmp(ai->targv[0], _T(VAR_TIMEPASSED)))
- {
+ }
+ else if (!lstrcmp(ai->targv[0], _T(VAR_TIMEPASSED))) {
ULARGE_INTEGER ul_AwaySince, ul_Now;
SYSTEMTIME st;
GetLocalTime(&st);
@@ -694,54 +644,48 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) 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
+ }
+ 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)))
- {
+ }
+ 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++)
- {
- if (!(TreeCtrl->Value[i].Flags & TIF_GROUP) && !_tcsicmp(TreeCtrl->Value[i].Title, ai->targv[1]))
- {
+ for (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)
- {
+ }
+ else if (!lstrcmp(ai->targv[0], _T(VAR_PROTOCOL))) {
+ if (VarParseData.szProto) {
CString AnsiResult;
CallProtoService(VarParseData.szProto, PS_GETNAME, 256, (LPARAM)AnsiResult.GetBuffer(256));
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(""));
@@ -751,8 +695,7 @@ INT_PTR srvVariablesHandler(WPARAM wParam, LPARAM lParam) INT_PTR srvFreeVarMem(WPARAM wParam, LPARAM lParam)
{
- if (!lParam)
- {
+ if (!lParam) {
return -1;
}
free((void*)lParam);
@@ -765,16 +708,13 @@ 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
{
const char *pProtoNameEnd = strrchr(name, '/');
- if (pProtoNameEnd)
- {
- if (!lstrcmpA(pProtoNameEnd, PS_SETSTATUS))
- {
- // it's PS_SETSTATUS service; wParam = status; lParam = 0
- // returns 0 on success, nonzero on failure
+ if (pProtoNameEnd) {
+ if (!lstrcmpA(pProtoNameEnd, PS_SETSTATUS)) {
+ // it's PS_SETSTATUS service; wParam = status; lParam = 0
+ // returns 0 on success, nonzero on failure
CString Proto("");
Proto.DiffCat(name, pProtoNameEnd);
- if (wParam != g_ProtoStates[Proto].Status)
- {
+ if (wParam != g_ProtoStates[Proto].Status) {
g_ProtoStates[Proto].Status = wParam;
TCString Msg(CProtoSettings(Proto).GetMsgFormat(GMF_LASTORDEFAULT));
LogMessage("Detected a PS_SETSTATUS call with Status different from the one known to NAS. szProto=%s, NewStatus=%d, NewMsg:\n%s", (char*)Proto, wParam, (Msg != NULL) ? _T2A(Msg) : "NULL");
@@ -811,13 +751,10 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) 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)
- {
+ 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)
- {
+ if (hHook) {
hHooks.insert(hHook);
ICQProtoList[CurProtoIndex] = proto[i]->szName;
CurProtoIndex++;
@@ -835,10 +772,10 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) hServices.insert(CreateServiceFunction(MS_NAS_SETSTATEW, SetStateW));
hServices.insert(CreateServiceFunction(MS_NAS_INVOKESTATUSWINDOW, InvokeStatusWindow));
hServices.insert(CreateServiceFunction(MS_AWAYMSG_GETSTATUSMSG, GetStatusMsg));
-// and old AwaySysMod service, for compatibility reasons
+ // and old AwaySysMod service, for compatibility reasons
hServices.insert(CreateServiceFunction(MS_AWAYSYS_SETSTATUSMODE, SetStatusMode));
-//NightFox: none;
-// hHooks.insert(HookEvent(ME_TTB_MODULELOADED, Create_TopToolbar));
+ //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
@@ -850,7 +787,7 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) g_hReadWndList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
int SendOnEvent = CContactSettings(g_ProtoStates[(char*)NULL].Status).Autoreply;
- CLISTMENUITEM mi = {0};
+ CLISTMENUITEM mi = { 0 };
mi.cbSize = sizeof(mi);
mi.position = 1000020000;
mi.flags = CMIF_TCHAR | CMIF_NOTOFFLINE;
@@ -930,14 +867,13 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) };
hServices.insert(CreateServiceFunction(MS_AWAYSYS_FREEVARMEM, srvFreeVarMem));
hServices.insert(CreateServiceFunction(MS_AWAYSYS_VARIABLESHANDLER, srvVariablesHandler));
- TOKENREGISTER tr = {0};
+ 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 < lengthof(Variables); i++)
- {
+ for (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;
@@ -955,7 +891,7 @@ int MirandaLoaded(WPARAM wParam, LPARAM lParam) extern "C" int __declspec(dllexport) Load(void)
{
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
hHooks.insert(HookEvent(ME_SYSTEM_MODULESLOADED, MirandaLoaded));
if (db_get_s(NULL, "KnownModules", "New Away System", (char*)NULL) == NULL)
@@ -966,22 +902,16 @@ extern "C" int __declspec(dllexport) Load(void) logservice_register(LOG_ID, LPGENT("New Away System"), _T("NewAwaySys?puts(p,?dbsetting(%subject%,Protocol,p))?if2(_?dbsetting(,?get(p),?pinfo(?get(p),uidsetting)),).log"), TranslateTS(_T("`[`!cdate()-!ctime()`]` ?cinfo(%subject%,display) (?cinfo(%subject%,id)) read your %") _T(VAR_STATDESC) _T("% message:\r\n%extratext%\r\n\r\n")));
- if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 1)
- { // change all %nas_message% variables to %extratext% if it wasn't done before
- TCString Str;
- Str = db_get_s(NULL, MOD_NAME, "PopupsFormat", _T(""));
+ if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 1) { // change all %nas_message% variables to %extratext% if it wasn't done before
+ TCString Str = db_get_s(NULL, MOD_NAME, "PopupsFormat", _T(""));
if (Str.GetLen())
- {
db_set_ts(NULL, MOD_NAME, "PopupsFormat", Str.Replace(_T("nas_message"), _T("extratext")));
- }
+
Str = db_get_s(NULL, MOD_NAME, "ReplyPrefix", _T(""));
if (Str.GetLen())
- {
db_set_ts(NULL, MOD_NAME, "ReplyPrefix", Str.Replace(_T("nas_message"), _T("extratext")));
- }
}
- if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 2)
- { // disable autoreply for not-on-list contacts, as such contact may be a spam bot
+ if (db_get_b(NULL, MOD_NAME, DB_SETTINGSVER, 0) < 2) { // disable autoreply for not-on-list contacts, as such contact may be a spam bot
db_set_b(NULL, MOD_NAME, ContactStatusToDBSetting(0, DB_ENABLEREPLY, 0, INVALID_CONTACT_ID), 0);
db_set_b(NULL, MOD_NAME, DB_SETTINGSVER, 2);
}
diff --git a/plugins/NewAwaySysMod/src/Client.cpp b/plugins/NewAwaySysMod/src/Client.cpp index 9d8c520f7c..23e71972a1 100644 --- a/plugins/NewAwaySysMod/src/Client.cpp +++ b/plugins/NewAwaySysMod/src/Client.cpp @@ -33,26 +33,19 @@ void __cdecl UpdateMsgsThreadProc(void *) int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- int I;
- while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated())
- {
+ while (WaitForSingleObject(g_hTerminateUpdateMsgsThread, 0) == WAIT_TIMEOUT && !Miranda_Terminated()) {
DWORD MinUpdateTimeDifference = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGSPERIOD) * 1000; // in milliseconds
- for (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);
- if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH)
- {
- Status = g_ProtoStates[proto[I]->szName].Status;
+ 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);
+ if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH) {
+ Status = g_ProtoStates[proto[i]->szName].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(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));
}
}
}
@@ -61,26 +54,23 @@ void __cdecl UpdateMsgsThreadProc(void *) }
}
-
static void __stdcall DummyAPCFunc(ULONG_PTR)
{
return;
}
-
void InitUpdateMsgs()
{
int UpdateMsgs = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_UPDATEMSGS);
- if (g_hUpdateMsgsThread && !UpdateMsgs)
- {
+ if (g_hUpdateMsgsThread && !UpdateMsgs) {
_ASSERT(WaitForSingleObject(g_hUpdateMsgsThread, 0) == WAIT_TIMEOUT);
SetEvent(g_hTerminateUpdateMsgsThread);
QueueUserAPC(DummyAPCFunc, g_hUpdateMsgsThread, 0); // wake up the thread, as it's most probably in SleepEx() now
WaitForSingleObject(g_hUpdateMsgsThread, INFINITE);
g_hUpdateMsgsThread = NULL;
CloseHandle(g_hTerminateUpdateMsgsThread);
- } else if (!g_hUpdateMsgsThread && UpdateMsgs)
- {
+ }
+ else if (!g_hUpdateMsgsThread && UpdateMsgs) {
g_hTerminateUpdateMsgsThread = CreateEvent(NULL, TRUE, FALSE, NULL);
g_hUpdateMsgsThread = (HANDLE)mir_forkthread(UpdateMsgsThreadProc, NULL);
}
@@ -90,33 +80,28 @@ void InitUpdateMsgs() void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg)
{
TCString CurMsg(Msg);
- if (szProto)
- {
+ if (szProto) {
if (Msg == NULL)
- {
CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, szProto);
- }
+
CallAllowedPS_SETAWAYMSG(szProto, iMode, (char*)_T2A(CurMsg));
g_ProtoStates[szProto].CurStatusMsg = CurMsg;
- } else // change message of all protocols
- {
+ }
+ else { // change message of all protocols
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 && !db_get_b(NULL, proto[I]->szName, "LockMainStatus", 0))
- {
+ for (int i = 0; i < ProtoCount; i++) {
+ if (proto[i]->type == PROTOTYPE_PROTOCOL && !db_get_b(NULL, proto[i]->szName, "LockMainStatus", 0)) {
if (Msg == NULL)
- {
- CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, proto[I]->szName);
- }
- CallAllowedPS_SETAWAYMSG(proto[I]->szName, iMode, (char*)_T2A(CurMsg));
- g_ProtoStates[proto[I]->szName].CurStatusMsg = CurMsg;
+ CurMsg = GetDynamicStatMsg(INVALID_CONTACT_ID, proto[i]->szName);
+
+ CallAllowedPS_SETAWAYMSG(proto[i]->szName, iMode, (char*)_T2A(CurMsg));
+ g_ProtoStates[proto[i]->szName].CurStatusMsg = CurMsg;
}
}
}
+
static struct
{
int Status;
@@ -134,49 +119,39 @@ void ChangeProtoMessages(char* szProto, int iMode, TCString &Msg) ID_STATUS_OUTTOLUNCH, "Otl",
ID_STATUS_IDLE, "Idl"
};
- int I;
- for (I = 0; I < lengthof(StatusSettings); I++)
- {
- if (iMode == StatusSettings[I].Status)
- {
- db_set_ts(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Msg", CurMsg);
- db_set_ts(NULL, "SRAway", CString(StatusSettings[I].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
+
+ for (int i = 0; i < SIZEOF(StatusSettings); i++) {
+ if (iMode == StatusSettings[i].Status) {
+ db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Msg", CurMsg);
+ db_set_ts(NULL, "SRAway", CString(StatusSettings[i].Setting) + "Default", CurMsg); // TODO: make it more accurate, and change not only here, but when changing status messages through UpdateMsgsTimerFunc too; and when changing messages through AutoAway() ?
break;
}
}
-// InitUpdateMsgs();
+ // InitUpdateMsgs();
}
int GetRecentGroupID(int iMode)
{ // returns an ID of a group where recent messages are stored, accordingly to current settings and status mode.
// -1 if the group is not found
-// COptPage MoreOptData(g_MoreOptPage);
+ // COptPage MoreOptData(g_MoreOptPage);
COptPage MsgTreeData(g_MsgTreePage);
COptItem_TreeCtrl *TreeCtrl = (COptItem_TreeCtrl*)MsgTreeData.Find(IDV_MSGTREE);
TreeCtrl->DBToMem(CString(MOD_NAME));
- int Order;
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM))
- {
- for (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))
- {
- return TreeCtrl->Value[Order].ID;
- }
- }
- } else // simply use Recent Messages category
- {
+
+ if (!g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM))
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))
+ return TreeCtrl->Value[Order].ID;
+
return -1;
}
-
int ICQStatusToGeneralStatus(int bICQStat)
{
- switch (bICQStat)
- {
+ switch (bICQStat) {
case MTYPE_AUTOONLINE: return ID_STATUS_ONLINE;
case MTYPE_AUTOAWAY: return ID_STATUS_AWAY;
case MTYPE_AUTONA: return ID_STATUS_NA;
@@ -187,11 +162,9 @@ int ICQStatusToGeneralStatus(int bICQStat) }
}
-
TCString VariablesEscape(TCString Str)
{
- if (!Str.GetLen())
- {
+ if (!Str.GetLen()) {
return _T("");
}
enum eState
@@ -201,31 +174,27 @@ TCString VariablesEscape(TCString Str) eState State = ST_QUOTE;
TCString Result(_T("`"));
const TCHAR *p = Str;
- while (*p)
- {
- if (*p == '`')
- {
- if (State == ST_TEXT)
- {
+ while (*p) {
+ if (*p == '`') {
+ if (State == ST_TEXT) {
Result += _T("````");
State = ST_QUOTE;
- } else
- {
+ }
+ else {
Result += _T("``");
}
- } else
- {
+ }
+ else {
Result += *p;
State = ST_TEXT;
}
p++;
}
- if (State == ST_QUOTE)
- {
+ if (State == ST_QUOTE) {
Result.GetBuffer()[Result.GetLen() - 1] = '\0';
Result.ReleaseBuffer();
- } else
- {
+ }
+ else {
Result += '`';
}
return Result;
diff --git a/plugins/NewAwaySysMod/src/Common.h b/plugins/NewAwaySysMod/src/Common.h index 8449efea0a..03d9a64253 100644 --- a/plugins/NewAwaySysMod/src/Common.h +++ b/plugins/NewAwaySysMod/src/Common.h @@ -109,30 +109,7 @@ #define SF_OTP 0x100
#define SF_OTL 0x200
#define SF_OTHER 0x80000000
-/*
-// Actions on popup click
-#define PCA_OPENMESSAGEWND 0 // open message window
-#define PCA_CLOSEPOPUP 1 // close popup
-#define PCA_OPENDETAILS 2 // open contact details window
-#define PCA_OPENMENU 3 // open contact menu
-#define PCA_OPENHISTORY 4 // open contact history
-#define PCA_OPENLOG 5 // open log file
-#define PCA_DONOTHING 6 // do nothing
-
-// Notification options defaults
-#define POPUP_DEF_POPUP_FORMAT TranslateT("?cinfo(%subject%,display) (?cinfo(%subject%,id)) is reading your %nas_statdesc% message:\r\n%extratext%")
-#define POPUP_DEF_USEPOPUPS 0
-#define POPUP_DEF_LCLICKACTION PCA_OPENMESSAGEWND
-#define POPUP_DEF_RCLICKACTION PCA_CLOSEPOPUP
-#define POPUP_DEF_POPUP_BGCOLOUR 0xFFB5BC
-#define POPUP_DEF_POPUP_TEXTCOLOUR 0
-#define POPUP_DEF_USEDEFBGCOLOUR 0
-#define POPUP_DEF_USEDEFTEXTCOLOUR 0
-#define POPUP_DEF_POPUPNOTIFYFLAGS (SF_ONL | SF_AWAY | SF_NA | SF_OCC | SF_DND | SF_FFC | SF_INV | SF_OTP | SF_OTL)
-#define POPUP_DEF_POPUPDELAY 0
-
-#define POPUP_MAXPOPUPDELAY 9999
-*/
+
#define MOREOPTDLG_DEF_DONTPOPDLG (SF_ONL | SF_INV)
#define MOREOPTDLG_DEF_USEBYDEFAULT 0
@@ -177,8 +154,8 @@ #define DB_SETTINGSVER "SettingsVer"
-#ifndef lengthof
-#define lengthof(s) (sizeof(s) / sizeof(*s))
+#ifndef SIZEOF
+#define SIZEOF(s) (sizeof(s) / sizeof(*s))
#endif
#define MS_NETLIB_LOG "Netlib/Log"
@@ -249,52 +226,52 @@ int ICQStatusToGeneralStatus(int bICQStat); // TODO: get rid of these protocol-s #define MS_AWAYSYS_SETSTATUSMODE "AwaySys/SetStatusMode" // change the status mode. wParam is new mode, lParam is new status message (AwaySys will interpret variables out of it), may be NULL.
#define MS_AWAYSYS_IGNORENEXT "AwaySys/IgnoreNextStatusChange" //ignore nest status change
-typedef struct SetAwayMsgData_type
+struct SetAwayMsgData
{
CString szProtocol;
MCONTACT hInitContact; // initial contact (filled by caller)
TCString Message; // initial message, NULL means default
bool IsModeless; // means the dialog was created with the CreateDialogParam function, not DialogBoxParam
int ISW_Flags; // InvokeStatusWindow service flags
-} SetAwayMsgData;
+};
-typedef struct READAWAYMSGDATA_TYPE
+struct READAWAYMSGDATA
{
MCONTACT hContact; // contact
HANDLE hSeq; // sequence for stat msg request
HANDLE hAwayMsgEvent; // hooked
-} READAWAYMSGDATA;
+};
-typedef struct
+struct VAR_PARSE_DATA
{
char *szProto;
TCString Message;
DWORD UIN;
int Flags; // a combination of VPF_ flags
-} VAR_PARSE_DATA;
+};
-typedef struct
+struct DYNAMIC_NOTIFY_DATA
{
MCONTACT hContact;
int iStatusMode;
TCString Proto;
-} DYNAMIC_NOTIFY_DATA;
+};
-typedef struct
+struct PLUGIN_DATA
{
BYTE PopupLClickAction, PopupRClickAction;
MCONTACT hContact;
HICON hStatusIcon; // needed here to destroy its handle on UM_FREEPLUGINDATA
-} PLUGIN_DATA;
+};
-typedef struct
+struct NAS_ISWINFOv1
{
int cbSize;
char *szProto;
MCONTACT hContact;
char *szMsg;
WORD status;
-} NAS_ISWINFOv1;
+};
#define MTYPE_AUTOONLINE 0xE7 // required to support ICQ Plus online status messages
@@ -358,7 +335,7 @@ static __inline int LogMessage(const char *Format, ...) char szText[8096];
strcpy(szText, LOG_PREFIX);
va_start(va, Format);
- mir_vsnprintf(szText + (lengthof(LOG_PREFIX) - 1), sizeof(szText) - (lengthof(LOG_PREFIX) - 1), Format, va);
+ mir_vsnprintf(szText + (SIZEOF(LOG_PREFIX) - 1), sizeof(szText) - (SIZEOF(LOG_PREFIX) - 1), Format, va);
va_end(va);
return CallService(MS_NETLIB_LOG, NULL, (LPARAM)szText);
}
@@ -381,8 +358,7 @@ static __inline void my_variables_skin_helpbutton(HWND hwndDlg, UINT uIDButton) static __inline int my_variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags = 0, char *szSubjectDesc = NULL, char *szExtraDesc = NULL)
{
- if (ServiceExists(MS_VARS_SHOWHELPEX))
- {
+ if (ServiceExists(MS_VARS_SHOWHELPEX)) {
VARHELPINFO vhi = {0};
vhi.cbSize = sizeof(VARHELPINFO);
vhi.flags = flags ? flags : (VHF_FULLDLG | VHF_SETLASTSUBJECT);
@@ -391,8 +367,7 @@ static __inline int my_variables_showhelp(HWND hwndDlg, UINT uIDEdit, int flags vhi.szExtraTextDesc = szExtraDesc;
return CallService(MS_VARS_SHOWHELPEX, (WPARAM)hwndDlg, (LPARAM)&vhi);
}
- else
- {
+ else {
ShowMsg(TranslateT("New Away System"), TranslateT("Variables plugin is not installed"), true);
return -1;
}
diff --git a/plugins/NewAwaySysMod/src/ContactList.cpp b/plugins/NewAwaySysMod/src/ContactList.cpp index f9a710532f..1be3c4ff8d 100644 --- a/plugins/NewAwaySysMod/src/ContactList.cpp +++ b/plugins/NewAwaySysMod/src/ContactList.cpp @@ -35,7 +35,6 @@ static HANDLE hCLWindowList;
-
static int CLContactDeleted(WPARAM wParam, LPARAM lParam)
{
WindowList_Broadcast(hCLWindowList, INTM_CONTACTDELETED, wParam, lParam);
@@ -66,16 +65,13 @@ void LoadCListModule() static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CCList *dat = CWndUserData(hWnd).GetCList();
- switch (Msg)
- {
- case WM_NOTIFY:
+ switch (Msg) {
+ case WM_NOTIFY:
{
LPNMHDR pnmh = (LPNMHDR)lParam;
- if (pnmh->hwndFrom == dat->hTreeView)
- {
- switch (pnmh->code)
- {
- case TVN_ITEMEXPANDED: // just set an appropriate group image
+ if (pnmh->hwndFrom == dat->hTreeView) {
+ switch (pnmh->code) {
+ case TVN_ITEMEXPANDED: // just set an appropriate group image
{
LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
TVITEM tvItem;
@@ -83,22 +79,19 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L tvItem.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvItem.iImage = tvItem.iSelectedImage = (pnmtv->itemNew.state & TVIS_EXPANDED) ? IMAGE_GROUPOPEN : IMAGE_GROUPSHUT;
TreeView_SetItem(dat->hTreeView, &tvItem);
- } break;
- case TVN_SELCHANGED:
+ }
+ break;
+ case TVN_SELCHANGED:
{
LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
TREEITEMARRAY OldSelection = dat->SelectedItems;
- int I;
- for (I = 0; I < dat->SelectedItems.GetSize(); I++)
- {
- if (dat->SelectedItems[I] != pnmtv->itemNew.hItem)
- {
- TreeView_SetItemState(dat->hTreeView, dat->SelectedItems[I], 0, TVIS_SELECTED);
+ for (int i = 0; i < dat->SelectedItems.GetSize(); i++) {
+ if (dat->SelectedItems[i] != pnmtv->itemNew.hItem) {
+ TreeView_SetItemState(dat->hTreeView, dat->SelectedItems[i], 0, TVIS_SELECTED);
}
}
dat->SelectedItems.RemoveAll();
- if (pnmtv->itemNew.hItem)
- {
+ if (pnmtv->itemNew.hItem) {
dat->SelectedItems.AddElem(pnmtv->itemNew.hItem);
dat->SelectGroups(pnmtv->itemNew.hItem, true);
}
@@ -109,74 +102,59 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L nm.OldSelection = &OldSelection;
nm.NewSelection = &dat->SelectedItems;
SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
- } break;
- case TVN_DELETEITEM:
- {
- if (dat->Items.GetSize()) // if Items size = 0, then this TVN_DELETEITEM came after WM_DESTROY, so there is no need to do anything
- {
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- TREEITEMARRAY OldSelection = dat->SelectedItems;
- int Index = dat->SelectedItems.Find(pnmtv->itemOld.hItem);
- if (Index != -1)
- {
- dat->SelectedItems.RemoveElem(Index);
- }
+ }
+ break;
+
+ case TVN_DELETEITEM:
+ if (dat->Items.GetSize()) { // if Items size = 0, then this TVN_DELETEITEM came after WM_DESTROY, so there is no need to do anything
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ TREEITEMARRAY OldSelection = dat->SelectedItems;
+ int Index = dat->SelectedItems.Find(pnmtv->itemOld.hItem);
+ if (Index != -1)
+ dat->SelectedItems.RemoveElem(Index);
+
// find an item to pass to SelectGroups()
- HTREEITEM hItem = TreeView_GetNextSibling(dat->hTreeView, pnmtv->itemOld.hItem);
+ HTREEITEM hItem = TreeView_GetNextSibling(dat->hTreeView, pnmtv->itemOld.hItem);
+ if (!hItem) {
+ hItem = TreeView_GetPrevSibling(dat->hTreeView, pnmtv->itemOld.hItem);
if (!hItem)
- {
- hItem = TreeView_GetPrevSibling(dat->hTreeView, pnmtv->itemOld.hItem);
- if (!hItem)
- {
- hItem = TreeView_GetParent(dat->hTreeView, pnmtv->itemOld.hItem);
- }
- }
- if (hItem) // if it wasn't one of the root items
- {
- dat->SelectGroups(hItem, dat->SelectedItems.Find(hItem) != -1);
- }
- NMCLIST nm;
- nm.hdr.code = MCLN_SELCHANGED;
- nm.hdr.hwndFrom = dat->hTreeView;
- nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
- nm.OldSelection = &OldSelection;
- nm.NewSelection = &dat->SelectedItems;
- SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
- dat->Items[pnmtv->itemOld.lParam].hContact = INVALID_CONTACT_ID;
+ hItem = TreeView_GetParent(dat->hTreeView, pnmtv->itemOld.hItem);
}
- } break;
- case NM_CUSTOMDRAW:
- {
- LPNMTVCUSTOMDRAW lpNMCD = (LPNMTVCUSTOMDRAW)lParam;
- switch (lpNMCD->nmcd.dwDrawStage)
- {
- case CDDS_PREPAINT: // the control is about to start painting
- {
- return CDRF_NOTIFYITEMDRAW; // instruct the control to return information when it draws items
- } break;
- case CDDS_ITEMPREPAINT:
- {
- return CDRF_NOTIFYPOSTPAINT;
- } break;
- case CDDS_ITEMPOSTPAINT:
- {
- RECT rc;
- if (TreeView_GetItemRect(dat->hTreeView, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, false))
- {
- int I;
- for (I = 0; I < MAXEXTRAICONS; I++)
- {
- BYTE nIndex = dat->Items[lpNMCD->nmcd.lItemlParam].ExtraIcons[I];
- if (nIndex != CLC_EXTRAICON_EMPTY)
- {
- ImageList_DrawEx(dat->ExtraImageList, nIndex, lpNMCD->nmcd.hdc, rc.right - EXTRAICON_XSTEP * (I + 1), rc.top, 0, 0, /*GetSysColor(COLOR_WINDOW)*/CLR_NONE, CLR_NONE, ILD_NORMAL);
- }
- }
+ if (hItem) // if it wasn't one of the root items
+ dat->SelectGroups(hItem, dat->SelectedItems.Find(hItem) != -1);
+
+ NMCLIST nm;
+ nm.hdr.code = MCLN_SELCHANGED;
+ nm.hdr.hwndFrom = dat->hTreeView;
+ nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
+ nm.OldSelection = &OldSelection;
+ nm.NewSelection = &dat->SelectedItems;
+ SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
+ dat->Items[pnmtv->itemOld.lParam].hContact = INVALID_CONTACT_ID;
+ }
+ break;
+
+ case NM_CUSTOMDRAW:
+ LPNMTVCUSTOMDRAW lpNMCD = (LPNMTVCUSTOMDRAW)lParam;
+ switch (lpNMCD->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT: // the control is about to start painting
+ return CDRF_NOTIFYITEMDRAW; // instruct the control to return information when it draws items
+ case CDDS_ITEMPREPAINT:
+ return CDRF_NOTIFYPOSTPAINT;
+ case CDDS_ITEMPOSTPAINT:
+ RECT rc;
+ if (TreeView_GetItemRect(dat->hTreeView, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, false)) {
+ for (int i = 0; i < MAXEXTRAICONS; i++) {
+ BYTE nIndex = dat->Items[lpNMCD->nmcd.lItemlParam].ExtraIcons[i];
+ if (nIndex != CLC_EXTRAICON_EMPTY) {
+ ImageList_DrawEx(dat->ExtraImageList, nIndex, lpNMCD->nmcd.hdc, rc.right - EXTRAICON_XSTEP * (i + 1), rc.top, 0, 0, /*GetSysColor(COLOR_WINDOW)*/CLR_NONE, CLR_NONE, ILD_NORMAL);
}
- } break;
+ }
}
- } break;
+ break;
+ }
}
+ break;
}
}
}
@@ -187,57 +165,54 @@ static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, L static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CCList *dat = CWndUserData(GetParent(hWnd)).GetCList();
- switch (Msg)
- {
- case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact
+ switch (Msg) {
+ case INTM_CONTACTDELETED: // wParam = (HANDLE)hContact
{
HTREEITEM hItem = dat->FindContact(wParam);
if (hItem)
TreeView_DeleteItem(hWnd, hItem);
- } break;
- case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID
+ }
+ break;
+ case INTM_ICONCHANGED: // wParam = (HANDLE)hContact, lParam = IconID
{
TVITEM tvi;
tvi.hItem = dat->FindContact(wParam);
- if (tvi.hItem)
- {
+ 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;
- case INTM_INVALIDATE:
- {
- InvalidateRect(hWnd, NULL, true);
- } break;
- case WM_RBUTTONDOWN:
+ }
+ break;
+
+ case INTM_INVALIDATE:
+ InvalidateRect(hWnd, NULL, true);
+ break;
+
+ case WM_RBUTTONDOWN:
+ SetFocus(hWnd);
{
- SetFocus(hWnd);
TVHITTESTINFO hitTest;
hitTest.pt.x = (short)LOWORD(lParam);
hitTest.pt.y = (short)HIWORD(lParam);
TreeView_HitTest(hWnd, &hitTest);
if (hitTest.hItem && hitTest.flags & TVHT_ONITEM)
- {
TreeView_SelectItem(hWnd, hitTest.hItem);
- }
- return DefWindowProc(hWnd, Msg, wParam, lParam);
- } break;
- case WM_LBUTTONDOWN:
+ }
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+
+ case WM_LBUTTONDOWN:
{
- POINT pt = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
+ POINT pt = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
DWORD hitFlags;
HTREEITEM hItem = dat->HitTest(&pt, &hitFlags);
if (!hItem)
- {
break;
- }
- if (hitFlags & MCLCHT_ONITEMICON)
- {
- if (TreeView_GetChild(hWnd, hItem)) // if it's a group, then toggle its state
- {
+
+ if (hitFlags & MCLCHT_ONITEMICON) {
+ if (TreeView_GetChild(hWnd, hItem)) { // if it's a group, then toggle its state
NMTREEVIEW nmtv;
nmtv.hdr.hwndFrom = hWnd;
nmtv.hdr.idFrom = GetDlgCtrlID(hWnd);
@@ -248,14 +223,12 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar TreeView_GetItem(hWnd, &nmtv.itemNew);
nmtv.ptDrag = pt;
if (SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmtv))
- {
return 0;
- }
+
HTREEITEM hOldSelItem = TreeView_GetSelection(hWnd);
TreeView_Expand(hWnd, hItem, TVE_TOGGLE);
HTREEITEM hNewSelItem = TreeView_GetSelection(hWnd);
- if (hNewSelItem != hOldSelItem)
- {
+ if (hNewSelItem != hOldSelItem) {
TreeView_SetItemState(hWnd, hOldSelItem, (dat->SelectedItems.Find(hOldSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED);
TreeView_SetItemState(hWnd, hNewSelItem, (dat->SelectedItems.Find(hNewSelItem) == -1) ? 0 : TVIS_SELECTED, TVIS_SELECTED);
}
@@ -265,19 +238,16 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar return 0;
}
}
- if (hitFlags & MCLCHT_ONITEM)
- {
- if (wParam & MK_CONTROL)
- {
+ if (hitFlags & MCLCHT_ONITEM) {
+ if (wParam & MK_CONTROL) {
SetFocus(hWnd);
TREEITEMARRAY OldSelection = dat->SelectedItems;
int nIndex = dat->SelectedItems.Find(hItem);
- if (nIndex == -1)
- {
+ if (nIndex == -1) {
TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED);
dat->SelectedItems.AddElem(hItem);
- } else
- {
+ }
+ else {
TreeView_SetItemState(hWnd, hItem, 0, TVIS_SELECTED);
dat->SelectedItems.RemoveElem(nIndex);
}
@@ -290,66 +260,56 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar nm.NewSelection = &dat->SelectedItems;
SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
return 0;
- } else
- {
- if (hItem == TreeView_GetSelection(hWnd) && (dat->SelectedItems.GetSize() != 1 || (dat->SelectedItems.GetSize() == 1 && dat->SelectedItems[0] != hItem))) // if it was a click on the selected item and there's need to do something in this case, then send SELCHANGED notification by ourselves, as the tree control doesn't do anything
- {
- TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED);
- NMTREEVIEW nm = {0};
- nm.hdr.code = TVN_SELCHANGED;
- nm.hdr.hwndFrom = hWnd;
- nm.hdr.idFrom = GetDlgCtrlID(hWnd);
- nm.itemOld.hItem = TreeView_GetSelection(hWnd);
- nm.itemOld.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
- TreeView_GetItem(hWnd, &nm.itemOld);
- nm.itemNew = nm.itemOld;
- SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
- }
}
- }
- } break;
- case WM_SETFOCUS:
- case WM_KILLFOCUS:
- {
- int I;
- for (I = 0; I < dat->SelectedItems.GetSize(); I++)
- {
- RECT rc;
- if (TreeView_GetItemRect(hWnd, dat->SelectedItems[I], &rc, false))
- {
- InvalidateRect(hWnd, &rc, false);
+ // if it was a click on the selected item and there's need to do something in this case, then send SELCHANGED notification by ourselves, as the tree control doesn't do anything
+ if (hItem == TreeView_GetSelection(hWnd) && (dat->SelectedItems.GetSize() != 1 || (dat->SelectedItems.GetSize() == 1 && dat->SelectedItems[0] != hItem))) {
+ TreeView_SetItemState(hWnd, hItem, TVIS_SELECTED, TVIS_SELECTED);
+ NMTREEVIEW nm = { 0 };
+ nm.hdr.code = TVN_SELCHANGED;
+ nm.hdr.hwndFrom = hWnd;
+ nm.hdr.idFrom = GetDlgCtrlID(hWnd);
+ nm.itemOld.hItem = TreeView_GetSelection(hWnd);
+ nm.itemOld.mask = TVIF_HANDLE | TVIF_STATE | TVIF_PARAM;
+ TreeView_GetItem(hWnd, &nm.itemOld);
+ nm.itemNew = nm.itemOld;
+ SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nm);
}
}
- } break;
- case WM_SIZE:
- case WM_HSCROLL:
- {
- InvalidateRect(hWnd, NULL, false);
- } break;
- case WM_MEASUREITEM:
- {
- if (!wParam) // if the message was sent by a menu
- {
- return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
- }
- } break;
- case WM_DRAWITEM:
- {
- if (!wParam) // if the message was sent by a menu
- {
- return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
- }
- } break;
- case WM_CONTEXTMENU:
+ }
+ break;
+
+ case WM_SETFOCUS:
+ case WM_KILLFOCUS:
+ for (int i = 0; i < dat->SelectedItems.GetSize(); i++) {
+ RECT rc;
+ if (TreeView_GetItemRect(hWnd, dat->SelectedItems[i], &rc, false))
+ InvalidateRect(hWnd, &rc, false);
+ }
+ break;
+
+ case WM_SIZE:
+ case WM_HSCROLL:
+ InvalidateRect(hWnd, NULL, false);
+ break;
+
+ case WM_MEASUREITEM:
+ if (!wParam) // if the message was sent by a menu
+ return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+ break;
+
+ case WM_DRAWITEM:
+ if (!wParam) // if the message was sent by a menu
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
+ break;
+
+ case WM_CONTEXTMENU:
{
POINT pt;
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
HTREEITEM hItem = NULL;
- if (pt.x == -1 && pt.y == -1)
- {
- if (dat->SelectedItems.GetSize() == 1)
- {
+ if (pt.x == -1 && pt.y == -1) {
+ if (dat->SelectedItems.GetSize() == 1) {
hItem = dat->SelectedItems[0];
TreeView_EnsureVisible(hWnd, hItem);
RECT rc;
@@ -357,24 +317,19 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar pt.x = rc.left;
pt.y = rc.bottom;
}
- } else
- {
+ }
+ else {
DWORD hitFlags;
ScreenToClient(hWnd, &pt);
hItem = dat->HitTest(&pt, &hitFlags);
if (!(hitFlags & MCLCHT_ONITEM))
- {
hItem = NULL;
- }
}
- if (hItem)
- {
+ if (hItem) {
MCONTACT hContact = dat->GetItemData(hItem).hContact;
- if (IsHContactContact(hContact))
- {
+ if (IsHContactContact(hContact)) {
HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
- if (hMenu)
- {
+ if (hMenu) {
ClientToScreen(hWnd, &pt);
CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hWnd, NULL), MPCF_CONTACTMENU), (LPARAM)hContact);
DestroyMenu(hMenu);
@@ -382,32 +337,29 @@ static LRESULT CALLBACK ContactListSubclassProc(HWND hWnd, UINT Msg, WPARAM wPar }
}
}
- } break;
- case WM_DESTROY:
- {
- if (dat->ExtraImageList)
- {
- ImageList_Destroy(dat->ExtraImageList);
- }
- dat->SelectedItems.RemoveAll();
- dat->Items.RemoveAll();
- } break;
+ }
+ break;
+
+ case WM_DESTROY:
+ if (dat->ExtraImageList)
+ ImageList_Destroy(dat->ExtraImageList);
+ dat->SelectedItems.RemoveAll();
+ dat->Items.RemoveAll();
+ break;
}
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);
OrigParentProc = (WNDPROC)SetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC, (LONG_PTR)ParentSubclassProc);
TreeView_SetImageList(hTreeView, CallService(MS_CLIST_GETICONSIMAGELIST, 0, 0), TVSIL_NORMAL);
WindowList_Add(hCLWindowList, hTreeView, NULL);
- TreeView_SetIndent(hTreeView, 5); // doesn't set it less than the initial value on my system, and I guess it's because of icons... but who knows - maybe it will work somewhere
+ TreeView_SetIndent(hTreeView, 5); // doesn't set it less than the initial value on my system, and i guess it's because of icons... but who knows - maybe it will work somewhere
}
-
CCList::~CCList()
{
WindowList_Remove(hCLWindowList, hTreeView);
@@ -417,23 +369,17 @@ CCList::~CCList() CWndUserData(GetParent(hTreeView)).SetCList(NULL);
}
-
-HTREEITEM CCList::AddContact(MCONTACT hContact)
// adds a new contact if it doesn't exist yet; returns its hItem
+HTREEITEM CCList::AddContact(MCONTACT hContact)
{
_ASSERT(IsHContactContact(hContact));
HTREEITEM hContactItem = FindContact(hContact);
if (hContactItem)
- {
return hContactItem;
- }
+
TVINSERTSTRUCT tvIns;
ZeroMemory(&tvIns, sizeof(tvIns));
tvIns.hParent = AddGroup(db_get_s(hContact, "CList", "Group", _T("")));
-/* if (!tvIns.hParent)
- {
- return NULL;
- }*/ // <- place hidden contacts in the root anyway, as otherwise we won't see icq contacts that are hidden beneath metacontacts; TODO: show metacontacts as groups??
tvIns.item.pszText = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
tvIns.hInsertAfter = TVI_ROOT;
tvIns.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
@@ -442,7 +388,6 @@ HTREEITEM CCList::AddContact(MCONTACT hContact) return TreeView_InsertItem(hTreeView, &tvIns);
}
-
typedef struct
{
HANDLE hGroup;
@@ -454,19 +399,16 @@ int GroupEnum(const char *szSetting, LPARAM lParam) sGroupEnumData *GroupEnumData = (sGroupEnumData*)lParam;
TCString GroupName = db_get_s(NULL, "CListGroups", szSetting, _T(" "));
if (!lstrcmp(GroupEnumData->GroupName, &GroupName[1]))
- {
GroupEnumData->hGroup = (HANDLE)(atol(szSetting) | HCONTACT_ISGROUP);
- }
return 0;
}
-HTREEITEM CCList::AddGroup(TCString GroupName)
// adds a new group if it doesn't exist yet; returns its hItem
+HTREEITEM CCList::AddGroup(TCString GroupName)
{
if (GroupName == _T(""))
- {
return TVI_ROOT;
- }
+
sGroupEnumData GroupEnumData;
GroupEnumData.GroupName = GroupName;
GroupEnumData.hGroup = NULL;
@@ -477,26 +419,22 @@ HTREEITEM CCList::AddGroup(TCString GroupName) dbEnum.szModule = "CListGroups";
CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
if (!GroupEnumData.hGroup) // means there is no such group in the groups list
- {
return NULL;
- }
+
HTREEITEM hGroupItem = FindContact((MCONTACT)GroupEnumData.hGroup);
if (hGroupItem)
- {
return hGroupItem; // exists already, just return its handle
- }
- TVINSERTSTRUCT tvIns = {0};
+
+ TVINSERTSTRUCT tvIns = { 0 };
tvIns.hParent = TVI_ROOT;
tvIns.item.pszText = _tcsrchr(GroupName, '\\');
- if (tvIns.item.pszText)
- {
+ if (tvIns.item.pszText) {
TCString ParentGroupName(_T(""));
tvIns.hParent = AddGroup(ParentGroupName.DiffCat(GroupName, tvIns.item.pszText));
tvIns.item.pszText++;
- } else
- {
- tvIns.item.pszText = GroupName;
}
+ else tvIns.item.pszText = GroupName;
+
tvIns.hInsertAfter = TVI_ROOT;
tvIns.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
tvIns.item.state = tvIns.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
@@ -505,10 +443,9 @@ HTREEITEM CCList::AddGroup(TCString GroupName) return TreeView_InsertItem(hTreeView, &tvIns);
}
-
HTREEITEM CCList::AddInfo(TCString Title, HTREEITEM hParent, HTREEITEM hInsertAfter, LPARAM lParam, HICON hIcon)
{
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
tvi.item.pszText = Title;
tvi.hParent = hParent;
@@ -516,21 +453,19 @@ HTREEITEM CCList::AddInfo(TCString Title, HTREEITEM hParent, HTREEITEM hInsertAf tvi.item.lParam = Items.AddElem(CCLItemData());
Items[tvi.item.lParam].lParam = lParam;
tvi.item.state = tvi.item.stateMask = TVIS_BOLD | TVIS_EXPANDED;
- if (hIcon)
- {
+ if (hIcon) {
HIMAGELIST iml = TreeView_GetImageList(hTreeView, TVSIL_NORMAL);
tvi.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
- tvi.item.iImage = tvi.item.iSelectedImage = ImageList_AddIcon(iml, hIcon); // we don't check for duplicate icons, but I think that's ok, judging that the check will require some pretty significant amount of additional coding
+ tvi.item.iImage = tvi.item.iSelectedImage = ImageList_AddIcon(iml, hIcon); // we don't check for duplicate icons, but i think that's ok, judging that the check will require some pretty significant amount of additional coding
TreeView_SetImageList(hTreeView, iml, TVSIL_NORMAL);
}
return TreeView_InsertItem(hTreeView, &tvi);
}
-
void CCList::SetInfoIcon(HTREEITEM hItem, HICON hIcon)
{
_ASSERT(hItem && hIcon && GetItemType(hItem) == MCLCIT_INFO);
- TVITEM tvi = {0};
+ TVITEM tvi = { 0 };
tvi.mask = TVIF_HANDLE | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.hItem = hItem;
HIMAGELIST iml = TreeView_GetImageList(hTreeView, TVSIL_NORMAL);
@@ -539,31 +474,25 @@ void CCList::SetInfoIcon(HTREEITEM hItem, HICON hIcon) TreeView_SetItem(hTreeView, &tvi);
}
-
static int CALLBACK CompareItemsCallback(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CCList *dat = (CCList*)lParamSort;
if (IsHContactInfo(dat->Items[lParam1].hContact)) // Info items precede all other items
- {
return (IsHContactInfo(dat->Items[lParam2].hContact)) ? 0 : -1;
- } else if (IsHContactInfo(dat->Items[lParam2].hContact))
- {
+
+ if (IsHContactInfo(dat->Items[lParam2].hContact))
return 1;
- }
- if (IsHContactGroup(dat->Items[lParam1].hContact)) // groups precede contacts
- {
+
+ if (IsHContactGroup(dat->Items[lParam1].hContact)) { // groups precedes contacts
if (IsHContactGroup(dat->Items[lParam2].hContact))
- {
return (unsigned)dat->Items[lParam1].hContact - (unsigned)dat->Items[lParam2].hContact;
- } else
- {
- return -1;
- }
- } else if (IsHContactGroup(dat->Items[lParam2].hContact))
- {
- return 1;
+ return -1;
}
- return CallService(MS_CLIST_CONTACTSCOMPARE, (WPARAM)dat->Items[lParam1].hContact, (LPARAM)dat->Items[lParam2].hContact);
+
+ if (IsHContactGroup(dat->Items[lParam2].hContact))
+ return 1;
+
+ return CallService(MS_CLIST_CONTACTSCOMPARE, dat->Items[lParam1].hContact, dat->Items[lParam2].hContact);
}
void CCList::SortContacts()
@@ -573,158 +502,124 @@ void CCList::SortContacts() tvSort.lpfnCompare = CompareItemsCallback;
tvSort.hParent = TVI_ROOT;
tvSort.lParam = (LPARAM)this;
- while (tvSort.hParent)
- {
+ while (tvSort.hParent) {
TreeView_SortChildrenCB(hTreeView, &tvSort, 0);
tvSort.hParent = GetNextItem(MCLGN_NEXT | MCLGN_GROUP | MCLGN_MULTILEVEL, tvSort.hParent);
}
}
-
int CCList::GetExtraImage(HTREEITEM hItem, int iColumn) // returns iImage, or CLC_EXTRAICON_EMPTY
{
_ASSERT(iColumn < MAXEXTRAICONS);
return GetItemData(hItem).ExtraIcons[iColumn];
}
-
void CCList::SetExtraImage(HTREEITEM hItem, int iColumn, int iImage) // set iImage to CLC_EXTRAICON_EMPTY to reset image
{
_ASSERT(iColumn < MAXEXTRAICONS);
GetItemData(hItem).ExtraIcons[iColumn] = iImage;
RECT rc;
if (TreeView_GetItemRect(hTreeView, hItem, &rc, false))
- {
InvalidateRect(hTreeView, &rc, true);
- }
}
-
void CCList::SetExtraImageList(HIMAGELIST hImgList)
{
ExtraImageList = hImgList;
InvalidateRect(hTreeView, NULL, false);
}
-
int CCList::GetItemType(HTREEITEM hItem) // returns a MCLCIT_ (see below)
{
MCONTACT hContact = GetItemData(hItem).hContact;
return (IsHContactInfo(hContact)) ? MCLCIT_INFO : ((IsHContactGroup(hContact)) ? MCLCIT_GROUP : MCLCIT_CONTACT);
}
-
DWORD CCList::GetItemTypeAsCLGNFlag(HTREEITEM hItem)
{
MCONTACT hContact = GetItemData(hItem).hContact;
return (IsHContactInfo(hContact)) ? MCLGN_INFO : ((IsHContactGroup(hContact)) ? MCLGN_GROUP : MCLGN_CONTACT);
}
-
HTREEITEM CCList::GetNextItem(DWORD Flags, HTREEITEM hItem)
{
- switch (Flags & ~(MCLGN_MULTILEVEL | MCLGN_NOTCHILD | MCLGN_ANY))
- {
- case MCLGN_ROOT:
- {
- return TreeView_GetRoot(hTreeView);
- } break;
- case MCLGN_LAST:
+ switch (Flags & ~(MCLGN_MULTILEVEL | MCLGN_NOTCHILD | MCLGN_ANY)) {
+ case MCLGN_ROOT:
+ return TreeView_GetRoot(hTreeView);
+
+ case MCLGN_LAST:
{
HTREEITEM hNextItem = TVI_ROOT;
- do
- {
+ do {
hItem = hNextItem;
hNextItem = TreeView_GetLastChild(hTreeView, hNextItem);
} while (hNextItem);
return (hItem == TVI_ROOT) ? NULL : hItem;
- } break;
- case MCLGN_CHILD:
- {
- return TreeView_GetChild(hTreeView, hItem);
- } break;
- case MCLGN_LASTCHILD:
- {
- return TreeView_GetLastChild(hTreeView, hItem);
- } break;
- case MCLGN_PARENT:
- {
- return TreeView_GetParent(hTreeView, hItem);
- } break;
- case MCLGN_NEXT:
- {
- do
- {
- if (Flags & MCLGN_MULTILEVEL)
- {
- HTREEITEM hNextItem = NULL;
- if ((Flags & MCLGN_NOTCHILD) != MCLGN_NOTCHILD)
- {
- hNextItem = TreeView_GetChild(hTreeView, hItem);
- }
- if (!hNextItem)
- {
+ }
+
+ case MCLGN_CHILD:
+ return TreeView_GetChild(hTreeView, hItem);
+
+ case MCLGN_LASTCHILD:
+ return TreeView_GetLastChild(hTreeView, hItem);
+
+ case MCLGN_PARENT:
+ return TreeView_GetParent(hTreeView, hItem);
+
+ case MCLGN_NEXT:
+ do {
+ if (Flags & MCLGN_MULTILEVEL) {
+ HTREEITEM hNextItem = NULL;
+ if ((Flags & MCLGN_NOTCHILD) != MCLGN_NOTCHILD)
+ hNextItem = TreeView_GetChild(hTreeView, hItem);
+
+ if (!hNextItem) {
+ hNextItem = TreeView_GetNextSibling(hTreeView, hItem);
+ while (!hNextItem) { // move back until we find next sibling of the item or one of its parents
+ hItem = TreeView_GetParent(hTreeView, hItem);
+ if (!hItem) // means it was the root, there are no items left.
+ break; // returns NULL as the next item
+
hNextItem = TreeView_GetNextSibling(hTreeView, hItem);
- while (!hNextItem) // move back until we find next sibling of the item or one of its parents
- {
- hItem = TreeView_GetParent(hTreeView, hItem);
- if (!hItem) // means it was the root, there are no items left.
- {
- break; // returns NULL as the next item
- }
- hNextItem = TreeView_GetNextSibling(hTreeView, hItem);
- }
}
- hItem = hNextItem;
- } else
- {
- hItem = TreeView_GetNextSibling(hTreeView, hItem);
}
- Flags &= ~(MCLGN_NOTCHILD & ~MCLGN_MULTILEVEL); // clear MCLGN_NOTCHILD flag
- } while (hItem && !(Flags & GetItemTypeAsCLGNFlag(hItem)));
- return hItem;
- } break;
- case MCLGN_PREV:
- {
- do
- {
- if (Flags & MCLGN_MULTILEVEL)
- {
- HTREEITEM hNextItem = TreeView_GetPrevSibling(hTreeView, hItem);
- if (hNextItem)
- {
- if ((Flags & MCLGN_NOTCHILD) != MCLGN_NOTCHILD)
- {
- while (hNextItem)
- {
- hItem = hNextItem;
- hNextItem = TreeView_GetLastChild(hTreeView, hItem);
- }
- } else
- {
+ hItem = hNextItem;
+ }
+ else hItem = TreeView_GetNextSibling(hTreeView, hItem);
+
+ Flags &= ~(MCLGN_NOTCHILD & ~MCLGN_MULTILEVEL); // clear MCLGN_NOTCHILD flag
+ }
+ while (hItem && !(Flags & GetItemTypeAsCLGNFlag(hItem)));
+ return hItem;
+
+ case MCLGN_PREV:
+ do {
+ if (Flags & MCLGN_MULTILEVEL) {
+ HTREEITEM hNextItem = TreeView_GetPrevSibling(hTreeView, hItem);
+ if (hNextItem) {
+ if ((Flags & MCLGN_NOTCHILD) != MCLGN_NOTCHILD) {
+ while (hNextItem) {
hItem = hNextItem;
+ hNextItem = TreeView_GetLastChild(hTreeView, hItem);
}
- } else
- {
- hItem = TreeView_GetParent(hTreeView, hItem);
}
- } else
- {
- hItem = TreeView_GetPrevSibling(hTreeView, hItem);
+ else hItem = hNextItem;
}
- Flags &= ~(MCLGN_NOTCHILD & ~MCLGN_MULTILEVEL); // clear MCLGN_NOTCHILD flag
- } while (hItem && !(Flags & GetItemTypeAsCLGNFlag(hItem)));
- return hItem;
- } break;
- default:
- {
- _ASSERT(0);
- } break;
+ else hItem = TreeView_GetParent(hTreeView, hItem);
+ }
+ else hItem = TreeView_GetPrevSibling(hTreeView, hItem);
+
+ Flags &= ~(MCLGN_NOTCHILD & ~MCLGN_MULTILEVEL); // clear MCLGN_NOTCHILD flag
+ }
+ while (hItem && !(Flags & GetItemTypeAsCLGNFlag(hItem)));
+ return hItem;
+
+ default:
+ _ASSERT(0);
}
return NULL;
}
-
MCONTACT CCList::GethContact(HTREEITEM hItem) // returns hContact, hGroup or hInfo
{
MCONTACT hContact = GetItemData(hItem).hContact;
@@ -735,7 +630,6 @@ MCONTACT CCList::GethContact(HTREEITEM hItem) // returns hContact, hGroup or hIn return hContact & ~HCONTACT_ISINFO;
}
-
HTREEITEM CCList::HitTest(LPPOINT pt, PDWORD hitFlags) // pt is relative to control; returns hItem or NULL
{
TVHITTESTINFO hti;
@@ -743,74 +637,58 @@ HTREEITEM CCList::HitTest(LPPOINT pt, PDWORD hitFlags) // pt is relative to cont TreeView_HitTest(hTreeView, &hti);
*hitFlags = 0;
if (hti.flags & TVHT_ABOVE)
- {
*hitFlags |= MCLCHT_ABOVE;
- }
+
if (hti.flags & TVHT_BELOW)
- {
*hitFlags |= MCLCHT_BELOW;
- }
+
if (hti.flags & TVHT_TOLEFT)
- {
*hitFlags |= MCLCHT_TOLEFT;
- }
+
if (hti.flags & TVHT_TORIGHT)
- {
*hitFlags |= MCLCHT_TORIGHT;
- }
+
if (hti.flags & TVHT_NOWHERE)
- {
*hitFlags |= MCLCHT_NOWHERE;
- }
+
if (hti.flags & TVHT_ONITEMINDENT)
- {
*hitFlags |= MCLCHT_ONITEMINDENT;
- }
+
if (hti.flags & (TVHT_ONITEMICON | TVHT_ONITEMSTATEICON))
- {
*hitFlags |= MCLCHT_ONITEMICON;
- }
+
if (hti.flags & TVHT_ONITEMLABEL)
- {
*hitFlags |= MCLCHT_ONITEMLABEL;
- }
+
if (hti.flags & TVHT_ONITEMRIGHT)
- {
*hitFlags |= MCLCHT_ONITEMRIGHT;
- }
- if (hti.flags & (TVHT_ONITEMINDENT | TVHT_ONITEM | TVHT_ONITEMRIGHT))
- {
- // extraicon tests
+
+ if (hti.flags & (TVHT_ONITEMINDENT | TVHT_ONITEM | TVHT_ONITEMRIGHT)) {
+ // extraicon tests
RECT rc;
- if (TreeView_GetItemRect(hTreeView, hti.hItem, &rc, false))
- {
+ if (TreeView_GetItemRect(hTreeView, hti.hItem, &rc, false)) {
int nIndex = (rc.right - pt->x - 1) / EXTRAICON_XSTEP;
if (nIndex >= 0 && nIndex < MAXEXTRAICONS && GetItemData(hti.hItem).ExtraIcons[nIndex] != CLC_EXTRAICON_EMPTY)
- {
*hitFlags |= MCLCHT_ONITEMEXTRA | (nIndex << 24);
- }
}
}
return hti.hItem;
}
-
int CCList::Array_SetItemState(HTREEITEM hItem, bool bSelected)
{
_ASSERT(hItem);
int nIndex = SelectedItems.Find(hItem);
if (nIndex == -1 && bSelected)
- {
return SelectedItems.AddElem(hItem);
- } else if (nIndex != -1 && !bSelected)
- {
+
+ if (nIndex != -1 && !bSelected) {
SelectedItems.RemoveElem(nIndex);
return -1;
}
return nIndex;
}
-
CCLItemData& CCList::GetItemData(HTREEITEM hItem)
{
_ASSERT(hItem && hItem != INVALID_HANDLE_VALUE);
@@ -822,30 +700,25 @@ CCLItemData& CCList::GetItemData(HTREEITEM hItem) return Items[tvi.lParam];
}
-
HTREEITEM CCList::TreeView_GetLastChild(HWND hTreeView, HTREEITEM hItem)
{
HTREEITEM hPrevItem = TreeView_GetChild(hTreeView, hItem);
hItem = hPrevItem;
- while (hItem) // find last sibling
- {
+ while (hItem) { // find last sibling
hPrevItem = hItem;
hItem = TreeView_GetNextSibling(hTreeView, hPrevItem);
}
return hPrevItem;
}
-
HTREEITEM CCList::FindContact(MCONTACT hContact)
{
TVITEM tvi;
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
tvi.hItem = TreeView_GetRoot(hTreeView);
- while (tvi.hItem)
- {
+ while (tvi.hItem) {
TreeView_GetItem(hTreeView, &tvi);
- if (Items[tvi.lParam].hContact == hContact)
- {
+ if (Items[tvi.lParam].hContact == hContact) {
return tvi.hItem;
}
tvi.hItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, tvi.hItem);
@@ -853,44 +726,37 @@ HTREEITEM CCList::FindContact(MCONTACT hContact) return NULL;
}
-
void CCList::SelectGroups(HTREEITEM hCurItem, bool bSelected)
{
-// select/deselect all child items
+ // select/deselect all child items
HTREEITEM hItem = TreeView_GetChild(hTreeView, hCurItem);
HTREEITEM hLimitItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_NOTCHILD, hCurItem);
- while (hItem && hItem != hLimitItem)
- {
+ while (hItem && hItem != hLimitItem) {
TreeView_SetItemState(hTreeView, hItem, bSelected ? TVIS_SELECTED : 0, TVIS_SELECTED);
Array_SetItemState(hItem, bSelected);
hItem = GetNextItem(MCLGN_NEXT | MCLGN_ANY | MCLGN_MULTILEVEL, hItem);
}
-// select/deselect all parent groups
+ // select/deselect all parent groups
hCurItem = TreeView_GetParent(hTreeView, hCurItem);
- if (bSelected)
- {
- while (hCurItem) // select until we'll find an unselected item or until we'll reach the root
- {
+ if (bSelected) {
+ while (hCurItem) { // select until we'll find an unselected item or until we'll reach the root
hItem = TreeView_GetChild(hTreeView, hCurItem);
- while (hItem) // walk through all siblings
- {
+ while (hItem) { // walk through all siblings
if (!(TreeView_GetItemState(hTreeView, hItem, TVIS_SELECTED) & TVIS_SELECTED))
- {
break;
- }
+
hItem = TreeView_GetNextSibling(hTreeView, hItem);
}
if (hItem) // means there was at least one unselected item
- {
break;
- }
+
TreeView_SetItemState(hTreeView, hCurItem, TVIS_SELECTED, TVIS_SELECTED);
Array_SetItemState(hCurItem, true);
hCurItem = TreeView_GetParent(hTreeView, hCurItem);
}
}
- while (hCurItem) // and deselect all remaining parent groups
- {
+
+ while (hCurItem) { // and deselect all remaining parent groups
TreeView_SetItemState(hTreeView, hCurItem, 0, TVIS_SELECTED);
Array_SetItemState(hCurItem, false);
hCurItem = TreeView_GetParent(hTreeView, hCurItem);
diff --git a/plugins/NewAwaySysMod/src/ContactList.h b/plugins/NewAwaySysMod/src/ContactList.h index 8b9ce2f845..20020cc32f 100644 --- a/plugins/NewAwaySysMod/src/ContactList.h +++ b/plugins/NewAwaySysMod/src/ContactList.h @@ -17,7 +17,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-// Miranda's built-in CListControl is very slow and it has too limited functionality... 8( So I had to use my own control instead.
+// Miranda's built-in CListControl is very slow and it has too limited functionality... 8( So i had to use my own control instead.
#pragma once
diff --git a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp index d396631676..3753f62999 100644 --- a/plugins/NewAwaySysMod/src/GroupCheckbox.cpp +++ b/plugins/NewAwaySysMod/src/GroupCheckbox.cpp @@ -44,8 +44,8 @@ #define CGSM_ISCHECKED 3 // mask for BM_GETCHECK
#define CGSM_GETSTATE 7 // mask to get only valid values for BM_GETSTATE
-#ifndef lengthof
-#define lengthof(s) (sizeof(s) / sizeof(*s))
+#ifndef SIZEOF
+#define SIZEOF(s) (sizeof(s) / sizeof(*s))
#endif
class CCheckboxData
@@ -268,7 +268,7 @@ static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l { 0, 0, DFCS_PUSHED, DFCS_INACTIVE,
DFCS_CHECKED, DFCS_CHECKED, DFCS_CHECKED | DFCS_PUSHED, DFCS_CHECKED | DFCS_INACTIVE,
DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED };
- _ASSERT(StateID >= 1 && StateID <= lengthof(dfcStates));
+ _ASSERT(StateID >= 1 && StateID <= SIZEOF(dfcStates));
DrawFrameControl(hdcMem, &rc, DFC_BUTTON, dfcStates[StateID - 1]);
}
diff --git a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp index 6995a6c683..b624a2d088 100644 --- a/plugins/NewAwaySysMod/src/MsgEventAdded.cpp +++ b/plugins/NewAwaySysMod/src/MsgEventAdded.cpp @@ -22,8 +22,6 @@ #include "Common.h"
#include "Properties.h"
-// stupid compiler.. kept returning me an "INTERNAL COMPILER ERROR" on almost every line of MsgEventAdded function with Release mode and unicode enabled >:( even disabling optimization through #pragma optimize didn't help.. The only acceptable solution I found is to move this function to a separate file and to disable optimization for the whole file in the project properties.
-
static struct
{
int Status, DisableReplyCtlID, DontShowDialogCtlID;
@@ -55,21 +53,19 @@ void __cdecl AutoreplyDelayThread(void *_ad) CAutoreplyData *ad = (CAutoreplyData*)_ad;
_ASSERT(ad && ad->hContact && ad->Reply.GetLen());
char *szProto = GetContactProto(ad->hContact);
- if (!szProto)
- {
+ if (!szProto) {
_ASSERT(0);
return;
}
- int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char) + sizeof(WCHAR));
+ int ReplyLen = (ad->Reply.GetLen() + 1) * (sizeof(char)+sizeof(WCHAR));
PBYTE pBuf = (PBYTE)malloc(ReplyLen);
memcpy(pBuf, _T2A(ad->Reply), ad->Reply.GetLen() + 1);
memcpy(pBuf + ad->Reply.GetLen() + 1, ad->Reply, (ad->Reply.GetLen() + 1) * sizeof(WCHAR));
CallContactService(ad->hContact, ServiceExists(CString(szProto) + PSS_MESSAGE "W") ? (PSS_MESSAGE "W") : PSS_MESSAGE, PREF_UNICODE, (LPARAM)pBuf);
- if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY))
- { // store in the history
- DBEVENTINFO dbeo = {0};
+ if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_LOGREPLY)) { // store in the history
+ DBEVENTINFO dbeo = { 0 };
dbeo.cbSize = sizeof(dbeo);
dbeo.eventType = EVENTTYPE_MESSAGE;
dbeo.flags = DBEF_SENT;
@@ -90,19 +86,17 @@ void __cdecl AutoreplyDelayThread(void *_ad) int IsSRMsgWindowOpen(MCONTACT hContact, int DefaultRetVal)
{
- if (ServiceExists(MS_MSG_GETWINDOWDATA))
- {
- MessageWindowData mwd = {0};
+ if (ServiceExists(MS_MSG_GETWINDOWDATA)) {
+ MessageWindowData mwd = { 0 };
mwd.cbSize = sizeof(mwd);
- MessageWindowInputData mwid = {0};
+ MessageWindowInputData mwid = { 0 };
mwid.cbSize = sizeof(mwid);
mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
mwid.hContact = hContact;
return !CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd) && mwd.hwndWindow;
- } else
- {
- return DefaultRetVal;
}
+
+ return DefaultRetVal;
}
@@ -112,7 +106,7 @@ int IsSRMsgWindowOpen(MCONTACT hContact, int DefaultRetVal) class CMetacontactEvent
{
public:
- CMetacontactEvent(MCONTACT hMetaContact, DWORD timestamp, int bMsgWindowIsOpen): hMetaContact(hMetaContact), timestamp(timestamp), bMsgWindowIsOpen(bMsgWindowIsOpen) {};
+ CMetacontactEvent(MCONTACT hMetaContact, DWORD timestamp, int bMsgWindowIsOpen) : hMetaContact(hMetaContact), timestamp(timestamp), bMsgWindowIsOpen(bMsgWindowIsOpen) {};
MCONTACT hMetaContact;
DWORD timestamp;
@@ -144,146 +138,116 @@ int MsgEventAdded(WPARAM hContact, LPARAM lParam) int bMsgWindowIsOpen = MSGWNDOPEN_UNDEFINED;
if (dbei->flags & DBEF_READ) {
+ // if it's a subcontact of a metacontact
MCONTACT hMetaContact;
- if (ServiceExists(MS_MC_GETMETACONTACT) && (hMetaContact = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0))) // if it's a subcontact of a metacontact
- { // ugly workaround for metacontacts, part II
- // remove outdated events first
+ if (ServiceExists(MS_MC_GETMETACONTACT) && (hMetaContact = CallService(MS_MC_GETMETACONTACT, hContact, 0))) { // ugly workaround for metacontacts, part II
+ // remove outdated events first
DWORD CurTime = time(NULL);
- int I;
- for (I = MetacontactEvents.GetSize() - 1; I >= 0; I--)
- {
- if (CurTime - MetacontactEvents[I].timestamp > MAX_REPLY_TIMEDIFF)
- {
- MetacontactEvents.RemoveElem(I);
- }
- }
- // we compare only event timestamps, and do not look at the message itself. it's unlikely that there'll be two events from a contact at the same second, so it's a trade-off between speed and reliability
- for (I = MetacontactEvents.GetSize() - 1; I >= 0; I--)
- {
- if (MetacontactEvents[I].timestamp == dbei->timestamp && MetacontactEvents[I].hMetaContact == hMetaContact)
- {
- bMsgWindowIsOpen = MetacontactEvents[I].bMsgWindowIsOpen;
+ int i;
+ for (i = MetacontactEvents.GetSize() - 1; i >= 0; i--)
+ if (CurTime - MetacontactEvents[i].timestamp > MAX_REPLY_TIMEDIFF)
+ MetacontactEvents.RemoveElem(i);
+
+ // we compare only event timestamps, and do not look at the message itself. it's unlikely that there'll be two events from a contact at the same second, so it's a trade-off between speed and reliability
+ for (i = MetacontactEvents.GetSize() - 1; i >= 0; i--) {
+ if (MetacontactEvents[i].timestamp == dbei->timestamp && MetacontactEvents[i].hMetaContact == hMetaContact) {
+ bMsgWindowIsOpen = MetacontactEvents[i].bMsgWindowIsOpen;
break;
}
}
- if (I < 0)
- {
+ if (i < 0) {
_ASSERT(0);
return 0;
}
- } else
- {
- return 0;
}
+ else return 0;
}
- if (ServiceExists(MS_MC_GETPROTOCOLNAME) && !lstrcmpA(szProto, (char*)CallService(MS_MC_GETPROTOCOLNAME, 0, 0)))
- { // ugly workaround for metacontacts, part I; store all metacontacts' events to a temporary array, so we'll be able to get the 'source' protocol when subcontact event happens later. we need the protocol to get its status and per-status settings properly
- // remove outdated events first
+
+ // ugly workaround for metacontacts, part i; store all metacontacts' events to a temporary array, so we'll be able to get the 'source' protocol when subcontact event happens later. we need the protocol to get its status and per-status settings properly
+ if (ServiceExists(MS_MC_GETPROTOCOLNAME) && !lstrcmpA(szProto, (char*)CallService(MS_MC_GETPROTOCOLNAME, 0, 0))) {
+ // remove outdated events first
DWORD CurTime = time(NULL);
- int I;
- for (I = MetacontactEvents.GetSize() - 1; I >= 0; I--)
- {
- if (CurTime - MetacontactEvents[I].timestamp > MAX_REPLY_TIMEDIFF)
- {
- MetacontactEvents.RemoveElem(I);
- }
- }
- // add the new event and wait for a subcontact's event
+ for (int i = MetacontactEvents.GetSize() - 1; i >= 0; i--)
+ if (CurTime - MetacontactEvents[i].timestamp > MAX_REPLY_TIMEDIFF)
+ MetacontactEvents.RemoveElem(i);
+
+ // add the new event and wait for a subcontact's event
MetacontactEvents.AddElem(CMetacontactEvent(hContact, dbei->timestamp, IsSRMsgWindowOpen(hContact, false)));
return 0;
}
+
unsigned int iMode = CallProtoService(szProto, PS_GETSTATUS, 0, 0);
- int I;
- for (I = lengthof(StatusModeList) - 1; I >= 0; I--)
- {
- if (iMode == StatusModeList[I].Status)
- {
+ int i;
+ for (i = SIZEOF(StatusModeList) - 1; i >= 0; i--)
+ if (iMode == StatusModeList[i].Status)
break;
- }
- }
- if (I < 0)
- {
+
+ if (i < 0)
return 0;
- }
+
COptPage AutoreplyOptData(g_AutoreplyOptPage);
AutoreplyOptData.DBToMem();
if (dbei->eventType == EVENTTYPE_MESSAGE)
- {
db_set_w(hContact, MOD_NAME, DB_MESSAGECOUNT, db_get_w(hContact, MOD_NAME, DB_MESSAGECOUNT, 0) + 1); // increment message counter
- }
- if (AutoreplyOptData.GetValue(StatusModeList[I].DisableReplyCtlID))
- {
+
+ if (AutoreplyOptData.GetValue(StatusModeList[i].DisableReplyCtlID))
return 0;
- }
+
MCONTACT hContactForSettings = hContact; // used to take into account not-on-list contacts when getting contact settings, but at the same time allows to get correct contact info for contacts that are in the DB
if (hContactForSettings != INVALID_CONTACT_ID && db_get_b(hContactForSettings, "CList", "NotOnList", 0))
- {
hContactForSettings = INVALID_CONTACT_ID; // INVALID_HANDLE_VALUE means the contact is not-on-list
- }
+
if (!CContactSettings(iMode, hContactForSettings).Autoreply.IncludingParents(szProto) || CContactSettings(iMode, hContactForSettings).Ignore)
- {
return 0;
- }
- if (AutoreplyOptData.GetValue(IDC_REPLYDLG_DONTREPLYINVISIBLE))
- {
+
+ if (AutoreplyOptData.GetValue(IDC_REPLYDLG_DONTREPLYINVISIBLE)) {
WORD ApparentMode = db_get_w(hContact, szProto, "ApparentMode", 0);
- if ((iMode == ID_STATUS_INVISIBLE && (!(Flags1 & PF1_INVISLIST) || ApparentMode != ID_STATUS_ONLINE)) ||
- (Flags1 & PF1_VISLIST && ApparentMode == ID_STATUS_OFFLINE))
- {
+ if ((iMode == ID_STATUS_INVISIBLE && (!(Flags1 & PF1_INVISLIST) || ApparentMode != ID_STATUS_ONLINE)) || (Flags1 & PF1_VISLIST && ApparentMode == ID_STATUS_OFFLINE))
return 0;
- }
}
- if (AutoreplyOptData.GetValue(IDC_REPLYDLG_ONLYCLOSEDDLGREPLY))
- {
+ if (AutoreplyOptData.GetValue(IDC_REPLYDLG_ONLYCLOSEDDLGREPLY)) {
if (bMsgWindowIsOpen && bMsgWindowIsOpen != MSGWNDOPEN_UNDEFINED)
- {
return 0;
- }
- // we never get here for a metacontact; we did check for metacontact's window earlier, and here we need to check only for subcontact's window
+
+ // we never get here for a metacontact; we did check for metacontact's window earlier, and here we need to check only for subcontact's window
if (IsSRMsgWindowOpen(hContact, false))
- {
return 0;
- }
}
if (AutoreplyOptData.GetValue(IDC_REPLYDLG_ONLYIDLEREPLY) && !g_bIsIdle)
- {
return 0;
- }
+
int UIN = 0;
if (IsAnICQProto(szProto))
- {
UIN = db_get_dw(hContact, szProto, "UIN", 0);
- }
+
int SendCount = AutoreplyOptData.GetValue(IDC_REPLYDLG_SENDCOUNT);
if ((AutoreplyOptData.GetValue(IDC_REPLYDLG_DONTSENDTOICQ) && UIN) || // an icq contact
- (SendCount != -1 && db_get_b(hContact, MOD_NAME, DB_SENDCOUNT, 0) >= SendCount))
- {
+ (SendCount != -1 && db_get_b(hContact, MOD_NAME, DB_SENDCOUNT, 0) >= SendCount))
return 0;
- }
- if ((dbei->eventType == EVENTTYPE_MESSAGE && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTMSG)) || (dbei->eventType == EVENTTYPE_URL && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTURL)) || (dbei->eventType == EVENTTYPE_FILE && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTFILE)))
- {
+
+ if ((dbei->eventType == EVENTTYPE_MESSAGE && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTMSG)) ||
+ (dbei->eventType == EVENTTYPE_URL && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTURL)) ||
+ (dbei->eventType == EVENTTYPE_FILE && !AutoreplyOptData.GetValue(IDC_REPLYDLG_EVENTFILE)))
return 0;
- }
+
db_set_b(hContact, MOD_NAME, DB_SENDCOUNT, db_get_b(hContact, MOD_NAME, DB_SENDCOUNT, 0) + 1);
GetDynamicStatMsg(hContact); // it updates VarParseData.Message needed for %extratext% in the format
TCString Reply(*(TCString*)AutoreplyOptData.GetValue(IDC_REPLYDLG_PREFIX));
- if (Reply != NULL && ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES))
- {
- FORMATINFO fi = {0};
+ if (Reply != NULL && ServiceExists(MS_VARS_FORMATSTRING) && !g_SetAwayMsgPage.GetDBValueCopy(IDS_SAWAYMSG_DISABLEVARIABLES)) {
+ FORMATINFO fi = { 0 };
fi.cbSize = sizeof(FORMATINFO);
fi.tszFormat = Reply;
fi.hContact = hContact;
fi.flags = FIF_TCHAR;
fi.tszExtraText = VarParseData.Message;
TCHAR *szResult = (TCHAR *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (szResult != NULL)
- {
+ if (szResult != NULL) {
Reply = szResult;
mir_free(szResult);
}
}
- if (Reply.GetLen())
- {
+
+ if (Reply.GetLen()) {
CAutoreplyData *ad = new CAutoreplyData(hContact, Reply);
mir_forkthread(AutoreplyDelayThread, ad);
}
diff --git a/plugins/NewAwaySysMod/src/MsgTree.cpp b/plugins/NewAwaySysMod/src/MsgTree.cpp index e53ea75cfc..fbcf96424b 100644 --- a/plugins/NewAwaySysMod/src/MsgTree.cpp +++ b/plugins/NewAwaySysMod/src/MsgTree.cpp @@ -33,36 +33,32 @@ struct {
int DBSetting, Status, MenuItemID;
-} StatusModeList[] = {
- IDS_MESSAGEDLG_DEF_ONL, ID_STATUS_ONLINE, IDR_MSGTREEMENU_DEF_ONL,
- IDS_MESSAGEDLG_DEF_AWAY, ID_STATUS_AWAY, IDR_MSGTREEMENU_DEF_AWAY,
- IDS_MESSAGEDLG_DEF_NA, ID_STATUS_NA, IDR_MSGTREEMENU_DEF_NA,
- IDS_MESSAGEDLG_DEF_OCC, ID_STATUS_OCCUPIED, IDR_MSGTREEMENU_DEF_OCC,
- IDS_MESSAGEDLG_DEF_DND, ID_STATUS_DND, IDR_MSGTREEMENU_DEF_DND,
- IDS_MESSAGEDLG_DEF_FFC, ID_STATUS_FREECHAT, IDR_MSGTREEMENU_DEF_FFC,
- IDS_MESSAGEDLG_DEF_INV, ID_STATUS_INVISIBLE, IDR_MSGTREEMENU_DEF_INV,
- IDS_MESSAGEDLG_DEF_OTP, ID_STATUS_ONTHEPHONE, IDR_MSGTREEMENU_DEF_OTP,
- IDS_MESSAGEDLG_DEF_OTL, ID_STATUS_OUTTOLUNCH, IDR_MSGTREEMENU_DEF_OTL
+}
+SettingsList[] = {
+ IDS_MESSAGEDLG_DEF_ONL, ID_STATUS_ONLINE, IDR_MSGTREEMENU_DEF_ONL,
+ IDS_MESSAGEDLG_DEF_AWAY, ID_STATUS_AWAY, IDR_MSGTREEMENU_DEF_AWAY,
+ IDS_MESSAGEDLG_DEF_NA, ID_STATUS_NA, IDR_MSGTREEMENU_DEF_NA,
+ IDS_MESSAGEDLG_DEF_OCC, ID_STATUS_OCCUPIED, IDR_MSGTREEMENU_DEF_OCC,
+ IDS_MESSAGEDLG_DEF_DND, ID_STATUS_DND, IDR_MSGTREEMENU_DEF_DND,
+ IDS_MESSAGEDLG_DEF_FFC, ID_STATUS_FREECHAT, IDR_MSGTREEMENU_DEF_FFC,
+ IDS_MESSAGEDLG_DEF_INV, ID_STATUS_INVISIBLE, IDR_MSGTREEMENU_DEF_INV,
+ IDS_MESSAGEDLG_DEF_OTP, ID_STATUS_ONTHEPHONE, IDR_MSGTREEMENU_DEF_OTP,
+ IDS_MESSAGEDLG_DEF_OTL, ID_STATUS_OUTTOLUNCH, IDR_MSGTREEMENU_DEF_OTL
};
static HANDLE hMTWindowList;
static WNDPROC g_OrigEditProc;
-
void LoadMsgTreeModule()
{
hMTWindowList = (HANDLE)CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
}
-
static LRESULT CALLBACK EditSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- switch (Msg)
- {
- case WM_GETDLGCODE:
- {
- return CallWindowProc(g_OrigEditProc, hWnd, Msg, wParam, lParam) | DLGC_WANTALLKEYS;
- } break;
+ switch (Msg) {
+ case WM_GETDLGCODE:
+ return CallWindowProc(g_OrigEditProc, hWnd, Msg, wParam, lParam) | DLGC_WANTALLKEYS;
}
return CallWindowProc(g_OrigEditProc, hWnd, Msg, wParam, lParam);
}
@@ -70,305 +66,246 @@ static LRESULT CALLBACK EditSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPA static LRESULT CALLBACK ParentSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CMsgTree *dat = CWndUserData(hWnd).GetMsgTree();
- switch (Msg)
- {
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->hwndFrom == dat->hTreeView)
- {
- switch (((LPNMHDR)lParam)->code)
+ switch (Msg) {
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->hwndFrom == dat->hTreeView) {
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_BEGINDRAGA:
+ case TVN_BEGINDRAGW:
{
- case TVN_BEGINDRAGA:
- case TVN_BEGINDRAGW:
- {
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- NMMSGTREE nm = {0};
- COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
- int Order = TreeCtrl->hItemToOrder(pnmtv->itemNew.hItem);
- _ASSERT(Order != -1);
- if (Order != -1)
- {
- nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
- nm.hdr.code = MTN_BEGINDRAG;
- nm.hdr.hwndFrom = dat->hTreeView;
- nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
- if (!SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm))
- {
- SetCapture(hWnd);
- dat->hPrevDropTarget = dat->hDragItem = pnmtv->itemNew.hItem;
- SetFocus(dat->hTreeView);
- TreeView_SelectItem(dat->hTreeView, dat->hDragItem);
- }
- }
- } break;
- case TVN_SELCHANGEDA:
- case TVN_SELCHANGEDW:
- {
- if (dat->UpdateLock)
- {
- return 0;
- }
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- NMMSGTREE nm = {0};
- COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
- if (pnmtv->itemOld.hItem)
- {
- int Order = TreeCtrl->IDToOrder(pnmtv->itemOld.lParam);
- if (Order != -1)
- {
- nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
- }
- }
- if (pnmtv->itemNew.hItem)
- {
- int Order = TreeCtrl->IDToOrder(pnmtv->itemNew.lParam);
- if (Order != -1)
- {
- nm.ItemNew = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
- }
- }
- nm.hdr.code = MTN_SELCHANGED;
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ NMMSGTREE nm = { 0 };
+ COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
+ int Order = TreeCtrl->hItemToOrder(pnmtv->itemNew.hItem);
+ _ASSERT(Order != -1);
+ if (Order != -1) {
+ nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
+ nm.hdr.code = MTN_BEGINDRAG;
nm.hdr.hwndFrom = dat->hTreeView;
nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
- SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
- } break;
- case TVN_BEGINLABELEDITA:
- case TVN_BEGINLABELEDITW:
- {
- if (dat->GetTreeCtrl()->IDToOrder(((LPNMTVDISPINFO)lParam)->item.lParam) < 0)
- {
- return true; // cancel editing
- }
- g_OrigEditProc = (WNDPROC)SetWindowLongPtr(TreeView_GetEditControl(dat->hTreeView), GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
- } break;
-// case TVN_ENDLABELEDITA: // stupid miranda options.. how am I supposed to get ptvdi->item.pszText if it's in ANSI??
- case TVN_ENDLABELEDIT:
- {
- LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
- if (ptvdi->item.pszText)
- {
- COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
- int Order = TreeCtrl->IDToOrder(ptvdi->item.lParam);
- if (Order >= 0)
- {
- TreeCtrl->Value[Order].Title = ptvdi->item.pszText;
- TreeCtrl->SetModified(true);
- NMMSGTREE nm = {0};
- nm.ItemNew = &TreeCtrl->Value[Order];
- nm.hdr.code = MTN_ITEMRENAMED;
- nm.hdr.hwndFrom = dat->hTreeView;
- nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
- SendMessage(GetParent(dat->hTreeView), WM_NOTIFY, 0, (LPARAM)&nm);
- return true; // commit new text
- }
+ if (!SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm)) {
+ SetCapture(hWnd);
+ dat->hPrevDropTarget = dat->hDragItem = pnmtv->itemNew.hItem;
+ SetFocus(dat->hTreeView);
+ TreeView_SelectItem(dat->hTreeView, dat->hDragItem);
}
- } break;
- case NM_CLICK:
- case NM_RCLICK:
- {
- TVHITTESTINFO hitTest;
- hitTest.pt.x = (short)LOWORD(GetMessagePos());
- hitTest.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(dat->hTreeView, &hitTest.pt);
- TreeView_HitTest(dat->hTreeView, &hitTest);
- if (hitTest.hItem)
- {
- if (TreeView_GetSelection(dat->hTreeView) == hitTest.hItem)
- { // make sure TVN_SELCHANGED notification is sent always, even if previous selected item was the same as new
- TreeView_SelectItem(dat->hTreeView, NULL);
- }
- TreeView_SelectItem(dat->hTreeView, hitTest.hItem);
+ }
+ }
+ break;
+ case TVN_SELCHANGEDA:
+ case TVN_SELCHANGEDW:
+ if (dat->UpdateLock)
+ return 0;
+ else {
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ NMMSGTREE nm = { 0 };
+ COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
+ if (pnmtv->itemOld.hItem) {
+ int Order = TreeCtrl->IDToOrder(pnmtv->itemOld.lParam);
+ if (Order != -1) {
+ nm.ItemOld = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
- } break;
- case NM_CUSTOMDRAW:
- {
- NMTVCUSTOMDRAW *lpNMCD = (NMTVCUSTOMDRAW*)lParam;
- switch (lpNMCD->nmcd.dwDrawStage)
- {
- case CDDS_PREPAINT: // the control is about to start painting
- {
- return CDRF_NOTIFYITEMDRAW; // instruct the control to return information when it draws items
- } break;
- case CDDS_ITEMPREPAINT:
- {
- return CDRF_NOTIFYPOSTPAINT;
- } break;
- case CDDS_ITEMPOSTPAINT:
- {
- RECT rc;
- TreeView_GetItemRect(lpNMCD->nmcd.hdr.hwndFrom, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, true);
- int iSize = GetSystemMetrics(SM_CXSMICON);
- int I;
- int x = rc.left - iSize - 5;
- for (I = 0; I < lengthof(StatusModeList); I++)
- {
- if (lpNMCD->nmcd.lItemlParam == dat->MsgTreePage.GetValue(StatusModeList[I].DBSetting))
- {
- DrawIconEx(lpNMCD->nmcd.hdc, x, rc.top, LoadSkinnedProtoIcon(NULL, StatusModeList[I].Status), iSize, iSize, 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL);
- x -= iSize + 1;
- }
-/* if (lpNMCD->nmcd.lItemlParam == GetRecentGroupID(StatusModeList[I].Status))
- {
- DrawIconEx(lpNMCD->nmcd.hdc, 3, rc.top, LoadSkinnedProtoIcon(NULL, StatusModeList[I].Status), iSize, iSize, 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL);
- }*/
- }
- } break;
+ }
+ if (pnmtv->itemNew.hItem) {
+ int Order = TreeCtrl->IDToOrder(pnmtv->itemNew.lParam);
+ if (Order != -1) {
+ nm.ItemNew = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
- } break;
+ }
+ nm.hdr.code = MTN_SELCHANGED;
+ nm.hdr.hwndFrom = dat->hTreeView;
+ nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
+ SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm);
}
- }
- } break;
- case WM_MOUSEMOVE:
- {
- if (dat->hDragItem)
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hWnd, &hti.pt);
- ScreenToClient(dat->hTreeView, &hti.pt);
- TreeView_HitTest(dat->hTreeView, &hti);
- if (hti.hItem)
+ break;
+
+ case TVN_BEGINLABELEDITA:
+ case TVN_BEGINLABELEDITW:
+ if (dat->GetTreeCtrl()->IDToOrder(((LPNMTVDISPINFO)lParam)->item.lParam) < 0)
+ return true; // cancel editing
+
+ g_OrigEditProc = (WNDPROC)SetWindowLongPtr(TreeView_GetEditControl(dat->hTreeView), GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
+ break;
+
+ case TVN_ENDLABELEDIT:
{
- TreeView_SelectDropTarget(dat->hTreeView, hti.hItem);
- SetTimer(hWnd, MSGTREE_TIMER_ID, MSGTREE_DRAGANDDROP_GROUPEXPANDTIME, NULL);
- } else
+ LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam;
+ if (ptvdi->item.pszText) {
+ COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
+ int Order = TreeCtrl->IDToOrder(ptvdi->item.lParam);
+ if (Order >= 0) {
+ TreeCtrl->Value[Order].Title = ptvdi->item.pszText;
+ TreeCtrl->SetModified(true);
+ NMMSGTREE nm = { 0 };
+ nm.ItemNew = &TreeCtrl->Value[Order];
+ nm.hdr.code = MTN_ITEMRENAMED;
+ nm.hdr.hwndFrom = dat->hTreeView;
+ nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
+ SendMessage(GetParent(dat->hTreeView), WM_NOTIFY, 0, (LPARAM)&nm);
+ return true; // commit new text
+ }
+ }
+ }
+ break;
+
+ case NM_CLICK:
+ case NM_RCLICK:
{
- if (hti.flags & TVHT_ABOVE)
- {
- SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ TVHITTESTINFO hitTest;
+ hitTest.pt.x = (short)LOWORD(GetMessagePos());
+ hitTest.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(dat->hTreeView, &hitTest.pt);
+ TreeView_HitTest(dat->hTreeView, &hitTest);
+ if (hitTest.hItem) {
+ if (TreeView_GetSelection(dat->hTreeView) == hitTest.hItem) // make sure TVN_SELCHANGED notification is sent always, even if previous selected item was the same as new
+ TreeView_SelectItem(dat->hTreeView, NULL);
+ TreeView_SelectItem(dat->hTreeView, hitTest.hItem);
}
- if (hti.flags & TVHT_BELOW)
- {
- SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+ }
+ break;
+
+ case NM_CUSTOMDRAW:
+ NMTVCUSTOMDRAW *lpNMCD = (NMTVCUSTOMDRAW*)lParam;
+ switch (lpNMCD->nmcd.dwDrawStage) {
+ case CDDS_PREPAINT: // the control is about to start painting
+ return CDRF_NOTIFYITEMDRAW; // instruct the control to return information when it draws items
+ case CDDS_ITEMPREPAINT:
+ return CDRF_NOTIFYPOSTPAINT;
+ case CDDS_ITEMPOSTPAINT:
+ RECT rc;
+ TreeView_GetItemRect(lpNMCD->nmcd.hdr.hwndFrom, (HTREEITEM)lpNMCD->nmcd.dwItemSpec, &rc, true);
+ int iSize = GetSystemMetrics(SM_CXSMICON);
+ int x = rc.left - iSize - 5;
+ for (int i = 0; i < SIZEOF(SettingsList); i++) {
+ if (lpNMCD->nmcd.lItemlParam == dat->MsgTreePage.GetValue(SettingsList[i].DBSetting)) {
+ DrawIconEx(lpNMCD->nmcd.hdc, x, rc.top, LoadSkinnedProtoIcon(NULL, SettingsList[i].Status), iSize, iSize, 0, GetSysColorBrush(COLOR_WINDOW), DI_NORMAL);
+ x -= iSize + 1;
+ }
}
- TreeView_SelectDropTarget(dat->hTreeView, NULL);
- KillTimer(hWnd, MSGTREE_TIMER_ID);
}
}
- } break;
- case WM_LBUTTONUP:
- {
- if (dat->hDragItem)
- {
+ }
+ break;
+
+ case WM_MOUSEMOVE:
+ if (dat->hDragItem) {
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hWnd, &hti.pt);
+ ScreenToClient(dat->hTreeView, &hti.pt);
+ TreeView_HitTest(dat->hTreeView, &hti);
+ if (hti.hItem) {
+ TreeView_SelectDropTarget(dat->hTreeView, hti.hItem);
+ SetTimer(hWnd, MSGTREE_TIMER_ID, MSGTREE_DRAGANDDROP_GROUPEXPANDTIME, NULL);
+ }
+ else {
+ if (hti.flags & TVHT_ABOVE)
+ SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEUP, 0), 0);
+ if (hti.flags & TVHT_BELOW)
+ SendMessage(dat->hTreeView, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0);
+
TreeView_SelectDropTarget(dat->hTreeView, NULL);
KillTimer(hWnd, MSGTREE_TIMER_ID);
- ReleaseCapture();
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hWnd, &hti.pt);
- ScreenToClient(dat->hTreeView, &hti.pt);
- TreeView_HitTest(dat->hTreeView, &hti);
- if (hti.hItem && dat->hDragItem != hti.hItem)
- {
- NMMSGTREE nm = {0};
- COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
- int OrderOld = TreeCtrl->hItemToOrder(dat->hDragItem);
- int OrderNew = TreeCtrl->hItemToOrder(hti.hItem);
- _ASSERT(OrderOld != -1 && OrderNew != -1);
- nm.ItemOld = (OrderOld <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OrderOld)] : (CBaseTreeItem*)&TreeCtrl->Value[OrderOld];
- nm.ItemNew = (OrderNew <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OrderNew)] : (CBaseTreeItem*)&TreeCtrl->Value[OrderNew];
- nm.hdr.code = MTN_ENDDRAG;
- nm.hdr.hwndFrom = dat->hTreeView;
- nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
- if (!SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm))
- {
- dat->UpdateLock++;
- dat->GetTreeCtrl()->MoveItem(hWnd, dat->hDragItem, hti.hItem);
- dat->UpdateLock--;
- }
- }
- dat->hDragItem = NULL;
}
- } break;
- case WM_TIMER:
- {
- if (wParam == MSGTREE_TIMER_ID)
- {
- KillTimer(hWnd, MSGTREE_TIMER_ID);
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(dat->hTreeView, &hti.pt);
- TreeView_HitTest(dat->hTreeView, &hti);
- if (hti.hItem && dat->hDragItem != hti.hItem && TreeView_GetChild(dat->hTreeView, hti.hItem)) // target is a group and is not the same item that we're dragging
- {
- TreeView_Expand(dat->hTreeView, hti.hItem, TVE_EXPAND);
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ if (dat->hDragItem) {
+ TreeView_SelectDropTarget(dat->hTreeView, NULL);
+ KillTimer(hWnd, MSGTREE_TIMER_ID);
+ ReleaseCapture();
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hWnd, &hti.pt);
+ ScreenToClient(dat->hTreeView, &hti.pt);
+ TreeView_HitTest(dat->hTreeView, &hti);
+ if (hti.hItem && dat->hDragItem != hti.hItem) {
+ NMMSGTREE nm = { 0 };
+ COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
+ int OrderOld = TreeCtrl->hItemToOrder(dat->hDragItem);
+ int OrderNew = TreeCtrl->hItemToOrder(hti.hItem);
+ _ASSERT(OrderOld != -1 && OrderNew != -1);
+ nm.ItemOld = (OrderOld <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OrderOld)] : (CBaseTreeItem*)&TreeCtrl->Value[OrderOld];
+ nm.ItemNew = (OrderNew <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OrderNew)] : (CBaseTreeItem*)&TreeCtrl->Value[OrderNew];
+ nm.hdr.code = MTN_ENDDRAG;
+ nm.hdr.hwndFrom = dat->hTreeView;
+ nm.hdr.idFrom = GetDlgCtrlID(dat->hTreeView);
+ if (!SendMessage(hWnd, WM_NOTIFY, 0, (LPARAM)&nm)) {
+ dat->UpdateLock++;
+ dat->GetTreeCtrl()->MoveItem(hWnd, dat->hDragItem, hti.hItem);
+ dat->UpdateLock--;
}
}
- } break;
+ dat->hDragItem = NULL;
+ }
+ break;
+
+ case WM_TIMER:
+ if (wParam == MSGTREE_TIMER_ID) {
+ KillTimer(hWnd, MSGTREE_TIMER_ID);
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(dat->hTreeView, &hti.pt);
+ TreeView_HitTest(dat->hTreeView, &hti);
+ if (hti.hItem && dat->hDragItem != hti.hItem && TreeView_GetChild(dat->hTreeView, hti.hItem)) // target is a group and is not the same item that we're dragging
+ TreeView_Expand(dat->hTreeView, hti.hItem, TVE_EXPAND);
+ }
}
return CallWindowProc(dat->OrigParentProc, hWnd, Msg, wParam, lParam);
}
-
static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CMsgTree *dat = CWndUserData(GetParent(hWnd)).GetMsgTree();
- switch (Msg)
- {
- case UM_MSGTREE_UPDATE: // returns TRUE if updated
+ switch (Msg) {
+ case UM_MSGTREE_UPDATE: // returns TRUE if updated
{
bool Modified = dat->MsgTreePage.GetModified();
TCString WndTitle;
- if (Modified)
- {
+ if (Modified) {
WndTitle.GetBuffer(256);
HWND hCurWnd = hWnd;
- do
- {
+ do {
hCurWnd = GetParent(hCurWnd);
} while (hCurWnd && !GetWindowText(hCurWnd, WndTitle, 256));
WndTitle.ReleaseBuffer();
}
- if (!Modified || MessageBox(GetParent(hWnd), TCString(TranslateT("You've made changes to multiple Message trees at a time.\r\nDo you want to leave changes in \"")) + WndTitle + TranslateT("\" dialog?\r\nPress Yes to leave changes in this dialog, or No to discard its changes and save changes of the other Message tree instead."), WndTitle + _T(" - ") + TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO) == IDNO)
- {
+ if (!Modified || MessageBox(GetParent(hWnd), TCString(TranslateT("You've made changes to multiple Message trees at a time.\r\nDo you want to leave changes in \"")) + WndTitle + TranslateT("\" dialog?\r\nPress Yes to leave changes in this dialog, or No to discard its changes and save changes of the other Message tree instead."), WndTitle + _T(" - ") + TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO) == IDNO) {
COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
TCString OldTitle, OldMsg, NewTitle, NewMsg;
int OldOrder = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hWnd)));
- if (OldOrder != -1)
- {
+ if (OldOrder != -1) {
CBaseTreeItem* ItemOld = (OldOrder <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(OldOrder)] : (CBaseTreeItem*)&TreeCtrl->Value[OldOrder];
OldTitle = ItemOld->Title;
if (!(ItemOld->Flags & TIF_ROOTITEM))
- {
OldMsg = ((CTreeItem*)ItemOld)->User_Str1;
- }
}
dat->UpdateLock++;
dat->MsgTreePage.DBToMemToPage();
dat->UpdateLock--;
- NMMSGTREE nm = {0};
+ NMMSGTREE nm = { 0 };
int Order = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hWnd)));
- if (Order != -1)
- {
+ if (Order != -1) {
nm.ItemNew = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
NewTitle = nm.ItemNew->Title;
if (!(nm.ItemNew->Flags & TIF_ROOTITEM))
- {
NewMsg = ((CTreeItem*)nm.ItemNew)->User_Str1;
- }
}
if (OldTitle.IsEmpty())
- {
OldTitle = _T(""); // to be sure that NULL will be equal to "" in the latter comparisons
- }
if (OldMsg.IsEmpty())
- {
OldMsg = _T("");
- }
if (NewTitle.IsEmpty())
- {
NewTitle = _T("");
- }
if (NewMsg.IsEmpty())
- {
NewMsg = _T("");
- }
- if (OldTitle != (const TCHAR*)NewTitle || OldMsg != (const TCHAR*)NewMsg)
- {
- // probably it's better to leave nm.ItemOld = NULL, to prevent accidental rewriting of it with old data from an edit control etc.
+
+ if (OldTitle != (const TCHAR*)NewTitle || OldMsg != (const TCHAR*)NewMsg) {
+ // probably it's better to leave nm.ItemOld = NULL, to prevent accidental rewriting of it with old data from an edit control etc.
nm.hdr.code = MTN_SELCHANGED;
nm.hdr.hwndFrom = hWnd;
nm.hdr.idFrom = GetDlgCtrlID(hWnd);
@@ -376,76 +313,68 @@ static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, }
return true;
}
- return false;
- } break;
- case WM_KEYDOWN:
- {
- switch (wParam)
- {
- case VK_DELETE:
- {
- dat->DeleteSelectedItem();
- } break;
- case VK_INSERT:
- {
- dat->AddMessage();
- } break;
- }
- } break;
- case WM_RBUTTONDOWN:
+ }
+ return false;
+
+ case WM_KEYDOWN:
+ switch (wParam) {
+ case VK_DELETE:
+ dat->DeleteSelectedItem();
+ break;
+ case VK_INSERT:
+ dat->AddMessage();
+ break;
+ }
+ break;
+
+ case WM_RBUTTONDOWN:
+ SetFocus(hWnd);
{
- SetFocus(hWnd);
TVHITTESTINFO hitTest;
hitTest.pt.x = (short)LOWORD(lParam);
hitTest.pt.y = (short)HIWORD(lParam);
TreeView_HitTest(hWnd, &hitTest);
- if (hitTest.hItem && hitTest.flags & TVHT_ONITEM)
- {
+ if (hitTest.hItem && hitTest.flags & TVHT_ONITEM) {
TreeView_SelectItem(hWnd, hitTest.hItem);
}
return DefWindowProc(hWnd, Msg, wParam, lParam);
- } break;
- case WM_CONTEXTMENU:
+ }
+ break;
+
+ case WM_CONTEXTMENU:
{
TVHITTESTINFO ht;
ht.pt.x = (short)LOWORD(lParam);
ht.pt.y = (short)HIWORD(lParam);
- TVITEM tvi = {0};
- if (ht.pt.x == -1 && ht.pt.y == -1) // use selected item
- {
- if (tvi.hItem = TreeView_GetSelection(hWnd))
- {
+ TVITEM tvi = { 0 };
+ if (ht.pt.x == -1 && ht.pt.y == -1) { // use selected item
+ if (tvi.hItem = TreeView_GetSelection(hWnd)) {
TreeView_EnsureVisible(hWnd, tvi.hItem);
RECT rc;
TreeView_GetItemRect(hWnd, tvi.hItem, &rc, true);
ht.pt.x = rc.left;
ht.pt.y = rc.bottom;
}
- } else
- {
+ }
+ else {
ScreenToClient(hWnd, &ht.pt);
TreeView_HitTest(hWnd, &ht);
- if (ht.hItem && ht.flags & TVHT_ONITEM)
- {
+ if (ht.hItem && ht.flags & TVHT_ONITEM) {
tvi.hItem = ht.hItem;
}
}
- if (tvi.hItem)
- {
+ if (tvi.hItem) {
COptItem_TreeCtrl *TreeCtrl = dat->GetTreeCtrl();
tvi.mask = TVIF_HANDLE | TVIF_PARAM;
TreeView_GetItem(hWnd, &tvi);
int Order = TreeCtrl->IDToOrder(tvi.lParam);
- if (Order >= 0)
- {
+ if (Order >= 0) {
HMENU hMenu;
if (TreeCtrl->Value[Order].Flags & TIF_GROUP)
- {
hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MSGTREE_CATEGORYMENU));
- } else
- {
+ else
hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MSGTREE_MESSAGEMENU));
- }
+
_ASSERT(hMenu);
HMENU hPopupMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hPopupMenu);
@@ -453,100 +382,89 @@ static LRESULT CALLBACK MsgTreeSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, struct
{
int ItemID, IconID;
- } MenuItems[] = {
+ }
+ MenuItems[] = {
IDM_MSGTREEMENU_NEWMESSAGE, IMGLIST_NEWMESSAGE,
IDM_MSGTREEMENU_NEWCATEGORY, IMGLIST_NEWCATEGORY,
IDM_MSGTREEMENU_DELETE, IMGLIST_DELETE
};
- MENUITEMINFO mii = {0};
+ MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_BITMAP | MIIM_DATA | MIIM_STATE | MIIM_CHECKMARKS;
mii.hbmpItem = HBMMENU_CALLBACK;
- int I;
- for (I = 0; I < lengthof(MenuItems); I++) // set icons
- {
- mii.dwItemData = MenuItems[I].IconID;
- SetMenuItemInfo(hPopupMenu, MenuItems[I].ItemID, false, &mii);
+ int i;
+ for (i = 0; i < SIZEOF(MenuItems); i++) { // set icons
+ mii.dwItemData = MenuItems[i].IconID;
+ SetMenuItemInfo(hPopupMenu, MenuItems[i].ItemID, false, &mii);
}
mii.fMask = MIIM_STATE;
mii.fState = MFS_CHECKED;
- for (I = 0; I < lengthof(StatusModeList); I++) // set checkmarks
- {
- if (TreeCtrl->Value[Order].ID == dat->MsgTreePage.GetValue(StatusModeList[I].DBSetting))
- {
- SetMenuItemInfo(hPopupMenu, StatusModeList[I].MenuItemID, false, &mii);
- }
- }
+ for (i = 0; i < SIZEOF(SettingsList); i++) // set checkmarks
+ if (TreeCtrl->Value[Order].ID == dat->MsgTreePage.GetValue(SettingsList[i].DBSetting))
+ SetMenuItemInfo(hPopupMenu, SettingsList[i].MenuItemID, false, &mii);
+
int MenuResult = TrackPopupMenu(hPopupMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, ht.pt.x, ht.pt.y, 0, hWnd, NULL);
- switch (MenuResult)
- {
- case IDM_MSGTREEMENU_NEWMESSAGE:
- {
- dat->AddMessage();
- } break;
- case IDM_MSGTREEMENU_NEWCATEGORY:
- {
- dat->AddCategory();
- } break;
- case IDM_MSGTREEMENU_RENAME:
- {
- TreeView_EditLabel(hWnd, tvi.hItem);
- } break;
- case IDM_MSGTREEMENU_DELETE:
- {
- dat->DeleteSelectedItem();
- } break;
- case IDR_MSGTREEMENU_DEF_ONL:
- case IDR_MSGTREEMENU_DEF_AWAY:
- case IDR_MSGTREEMENU_DEF_NA:
- case IDR_MSGTREEMENU_DEF_OCC:
- case IDR_MSGTREEMENU_DEF_DND:
- case IDR_MSGTREEMENU_DEF_FFC:
- case IDR_MSGTREEMENU_DEF_INV:
- case IDR_MSGTREEMENU_DEF_OTP:
- case IDR_MSGTREEMENU_DEF_OTL:
- {
- int I;
- for (I = 0; I < lengthof(StatusModeList); I++)
- {
- if (StatusModeList[I].MenuItemID == MenuResult)
- {
- dat->SetDefMsg(StatusModeList[I].Status, tvi.lParam);
- break;
- }
+ switch (MenuResult) {
+ case IDM_MSGTREEMENU_NEWMESSAGE:
+ dat->AddMessage();
+ break;
+ case IDM_MSGTREEMENU_NEWCATEGORY:
+ dat->AddCategory();
+ break;
+ case IDM_MSGTREEMENU_RENAME:
+ TreeView_EditLabel(hWnd, tvi.hItem);
+ break;
+ case IDM_MSGTREEMENU_DELETE:
+ dat->DeleteSelectedItem();
+ break;
+ case IDR_MSGTREEMENU_DEF_ONL:
+ case IDR_MSGTREEMENU_DEF_AWAY:
+ case IDR_MSGTREEMENU_DEF_NA:
+ case IDR_MSGTREEMENU_DEF_OCC:
+ case IDR_MSGTREEMENU_DEF_DND:
+ case IDR_MSGTREEMENU_DEF_FFC:
+ case IDR_MSGTREEMENU_DEF_INV:
+ case IDR_MSGTREEMENU_DEF_OTP:
+ case IDR_MSGTREEMENU_DEF_OTL:
+ for (int i = 0; i < SIZEOF(SettingsList); i++) {
+ if (SettingsList[i].MenuItemID == MenuResult) {
+ dat->SetDefMsg(SettingsList[i].Status, tvi.lParam);
+ break;
}
- } break;
+ }
}
DestroyMenu(hMenu);
return 0;
}
}
- } break;
- case WM_MEASUREITEM:
+ }
+ break;
+
+ case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpmi = (LPMEASUREITEMSTRUCT)lParam;
- if (lpmi->CtlType == ODT_MENU)
- {
+ if (lpmi->CtlType == ODT_MENU) {
lpmi->itemWidth = max(0, GetSystemMetrics(SM_CXSMICON) - GetSystemMetrics(SM_CXMENUCHECK) + 4);
lpmi->itemHeight = GetSystemMetrics(SM_CYSMICON) + 2;
return true;
}
- } break;
- case WM_DRAWITEM:
+ }
+ break;
+
+ case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
- if (dis->CtlType == ODT_MENU)
- {
+ if (dis->CtlType == ODT_MENU) {
ImageList_DrawEx(dat->hImageList, dis->itemData, dis->hDC, 2, (dis->rcItem.bottom + dis->rcItem.top - GetSystemMetrics(SM_CYSMICON)) / 2 + 1, 0, 0, GetSysColor(COLOR_WINDOW), CLR_NONE, ILD_NORMAL);
return true;
}
- } break;
+ }
+ break;
}
return CallWindowProc(dat->OrigTreeViewProc, hWnd, Msg, wParam, lParam);
}
-
-CMsgTree::CMsgTree(HWND hTreeView): MsgTreePage(g_MsgTreePage), hTreeView(hTreeView), hDragItem(NULL), hPrevDropTarget(NULL), UpdateLock(0)
+CMsgTree::CMsgTree(HWND hTreeView) : MsgTreePage(g_MsgTreePage), hTreeView(hTreeView), hDragItem(NULL), hPrevDropTarget(NULL), UpdateLock(0)
{
CWndUserData(GetParent(hTreeView)).SetMsgTree(this);
OrigParentProc = (WNDPROC)SetWindowLongPtr(GetParent(hTreeView), GWLP_WNDPROC, (LONG_PTR)ParentSubclassProc);
@@ -559,8 +477,7 @@ CMsgTree::CMsgTree(HWND hTreeView): MsgTreePage(g_MsgTreePage), hTreeView(hTreeV ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_NEWCATEGORY)));
ImageList_AddIcon(hImageList, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DELETE)));
MsgTreePage.DBToMemToPage();
- if (!g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT))
- { // show "Recent messages" group only when RECENTMSGSCOUNT is not set to 0.
+ if (!g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT)) { // show "Recent messages" group only when RECENTMSGSCOUNT is not set to 0.
TreeView_DeleteItem(hTreeView, TreeCtrl->RootItems[g_Messages_RecentRootID].hItem);
}
WindowList_Add(hMTWindowList, hTreeView, NULL);
@@ -580,11 +497,9 @@ CBaseTreeItem* CMsgTree::GetSelection() // returns NULL if there's nothing selec {
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
int Order = TreeCtrl->IDToOrder(TreeCtrl->GetSelectedItemID(GetParent(hTreeView)));
- if (Order != -1)
- {
- return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
- }
- return NULL;
+ if (Order == -1)
+ return NULL;
+ return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
bool CMsgTree::SetSelection(int ID, int Flags) // set ID = -1 to unselect; returns TRUE on unselect and on successful select
@@ -592,57 +507,42 @@ bool CMsgTree::SetSelection(int ID, int Flags) // set ID = -1 to unselect; retur COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
int Order = (Flags & MTSS_BYORDER) ? ID : TreeCtrl->IDToOrder(ID);
if (Order == -1 && ID != -1)
- {
return false;
- }
+
TreeView_SelectItem(hTreeView, (Order == -1) ? NULL : ((Order <= TREECTRL_ROOTORDEROFFS) ? TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)].hItem : TreeCtrl->Value[Order].hItem));
return true;
}
int CMsgTree::GetDefMsg(int iMode)
{
- int I;
- for (I = 0; I < lengthof(StatusModeList); I++)
- {
- if (StatusModeList[I].Status == iMode)
- {
- return MsgTreePage.GetValue(StatusModeList[I].DBSetting);
- }
- }
+ for (int i = 0; i < SIZEOF(SettingsList); i++)
+ if (SettingsList[i].Status == iMode)
+ return MsgTreePage.GetValue(SettingsList[i].DBSetting);
+
return 0;
}
void CMsgTree::SetDefMsg(int iMode, int ID)
{
- int I;
- for (I = 0; I < lengthof(StatusModeList); I++)
- {
- if (StatusModeList[I].Status == iMode)
- {
- if (MsgTreePage.GetValue(StatusModeList[I].DBSetting) != ID)
- {
+ for (int i = 0; i < SIZEOF(SettingsList); i++) {
+ if (SettingsList[i].Status == iMode) {
+ if (MsgTreePage.GetValue(SettingsList[i].DBSetting) != ID) {
RECT rc;
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
- int OrderOld = TreeCtrl->IDToOrder(MsgTreePage.GetValue(StatusModeList[I].DBSetting));
+ int OrderOld = TreeCtrl->IDToOrder(MsgTreePage.GetValue(SettingsList[i].DBSetting));
if (OrderOld >= 0 && TreeView_GetItemRect(hTreeView, TreeCtrl->Value[OrderOld].hItem, &rc, false))
- {
InvalidateRect(hTreeView, &rc, true); // refresh icons of previous default tree item
- }
+
int OrderNew = TreeCtrl->IDToOrder(ID);
if (OrderNew >= 0 && TreeView_GetItemRect(hTreeView, TreeCtrl->Value[OrderNew].hItem, &rc, false))
- {
InvalidateRect(hTreeView, &rc, true); // refresh new default item icons
- }
- MsgTreePage.SetValue(StatusModeList[I].DBSetting, ID);
- NMMSGTREE nm = {0};
+
+ MsgTreePage.SetValue(SettingsList[i].DBSetting, ID);
+ NMMSGTREE nm = { 0 };
if (OrderOld >= 0)
- {
nm.ItemOld = &TreeCtrl->Value[OrderOld];
- }
if (OrderNew >= 0)
- {
nm.ItemNew = &TreeCtrl->Value[OrderNew];
- }
nm.hdr.code = MTN_DEFMSGCHANGED;
nm.hdr.hwndFrom = hTreeView;
nm.hdr.idFrom = GetDlgCtrlID(hTreeView);
@@ -655,8 +555,7 @@ void CMsgTree::SetDefMsg(int iMode, int ID) void CMsgTree::Save()
{
- if (MsgTreePage.GetModified())
- {
+ if (MsgTreePage.GetModified()) {
MsgTreePage.PageToMemToDB();
WindowList_BroadcastAsync(hMTWindowList, UM_MSGTREE_UPDATE, 0, 0);
}
@@ -666,8 +565,7 @@ void CMsgTree::UpdateItem(int ID) // updates item title, and expanded/collapsed {
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
int Order = TreeCtrl->IDToOrder(ID);
- if (Order != -1)
- {
+ if (Order != -1) {
CBaseTreeItem* TreeItem = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
TCString NewTitle;
TVITEM tvi;
@@ -676,10 +574,9 @@ void CMsgTree::UpdateItem(int ID) // updates item title, and expanded/collapsed tvi.pszText = NewTitle.GetBuffer(TREEITEMTITLE_MAXLEN);
tvi.cchTextMax = TREEITEMTITLE_MAXLEN;
TreeView_GetItem(hTreeView, &tvi);
- if (TreeItem->Title != (const TCHAR*)tvi.pszText)
- {
+ if (TreeItem->Title != (const TCHAR*)tvi.pszText) {
TreeCtrl->SetModified(true);
- NMMSGTREE nm = {0};
+ NMMSGTREE nm = { 0 };
nm.ItemNew = TreeItem;
nm.hdr.code = MTN_ITEMRENAMED;
nm.hdr.hwndFrom = hTreeView;
@@ -701,21 +598,17 @@ bool CMsgTree::DeleteSelectedItem() // returns true if the item was deleted CTreeItem *SelectedItem = &TreeCtrl->Value[Order];
//NightFox: fix for langpack and fix cut char space in text
//if (MessageBox(GetParent(hTreeView), TCString(TranslateT("Do you really want to delete this ")) + ((SelectedItem->Flags & TIF_GROUP) ? TranslateT("category with its messages?") : TranslateT("message?")), TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
- if (MessageBox(GetParent(hTreeView),
- ((SelectedItem->Flags & TIF_GROUP) ?
- TranslateT("Do you really want to delete this category with its messages?")
- :
- TranslateT("Do you really want to delete this message?"))
- ,
- TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES)
- {
- NMMSGTREE nm = {0};
+ if (MessageBox(GetParent(hTreeView),
+ ((SelectedItem->Flags & TIF_GROUP) ?
+ TranslateT("Do you really want to delete this category with its messages?") :
+ TranslateT("Do you really want to delete this message?")),
+ TranslateT("New Away System"), MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
+ NMMSGTREE nm = { 0 };
nm.ItemOld = SelectedItem;
nm.hdr.code = MTN_DELETEITEM;
nm.hdr.hwndFrom = hTreeView;
nm.hdr.idFrom = GetDlgCtrlID(hTreeView);
- if (!SendMessage(GetParent(hTreeView), WM_NOTIFY, 0, (LPARAM)&nm))
- {
+ if (!SendMessage(GetParent(hTreeView), WM_NOTIFY, 0, (LPARAM)&nm)) {
TreeCtrl->Delete(GetParent(hTreeView), TreeCtrl->GetSelectedItemID(GetParent(hTreeView)));
return true;
}
@@ -733,7 +626,7 @@ CTreeItem* CMsgTree::AddCategory() TreeItem->Title = tvi.pszText = TranslateT("New category");
TreeView_SetItem(hTreeView, &tvi);
TreeView_EditLabel(hTreeView, TreeItem->hItem);
- NMMSGTREE nm = {0};
+ NMMSGTREE nm = { 0 };
nm.ItemNew = TreeItem;
nm.hdr.code = MTN_NEWCATEGORY;
nm.hdr.hwndFrom = hTreeView;
@@ -752,7 +645,7 @@ CTreeItem* CMsgTree::AddMessage() TreeItem->Title = tvi.pszText = TranslateT("New message");
TreeView_SetItem(hTreeView, &tvi);
TreeView_EditLabel(hTreeView, TreeItem->hItem);
- NMMSGTREE nm = {0};
+ NMMSGTREE nm = { 0 };
nm.ItemNew = TreeItem;
nm.hdr.code = MTN_NEWMESSAGE;
nm.hdr.hwndFrom = hTreeView;
@@ -765,15 +658,14 @@ CBaseTreeItem* CMsgTree::GetNextItem(int Flags, CBaseTreeItem* Item) // Item is {
COptItem_TreeCtrl *TreeCtrl = GetTreeCtrl();
CBaseTreeItem* TreeItem = Item;
- if (Flags & MTGN_BYID)
- {
+ if (Flags & MTGN_BYID) {
int Order = TreeCtrl->IDToOrder((int)Item);
_ASSERT(Order != -1);
TreeItem = (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
+
int TVFlag = 0;
- switch (Flags & ~MTGN_BYID)
- {
+ switch (Flags & ~MTGN_BYID) {
case MTGN_ROOT: TVFlag = TVGN_ROOT; break;
case MTGN_CHILD: TVFlag = TVGN_CHILD; break;
case MTGN_PARENT: TVFlag = TVGN_PARENT; break;
@@ -782,9 +674,8 @@ CBaseTreeItem* CMsgTree::GetNextItem(int Flags, CBaseTreeItem* Item) // Item is default: _ASSERT(0);
}
int Order = TreeCtrl->hItemToOrder(TreeView_GetNextItem(hTreeView, TreeItem ? TreeItem->hItem : NULL, TVFlag));
- if (Order != -1)
- {
- return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
- }
- return NULL;
+ if (Order =- -1)
+ return NULL;
+
+ return (Order <= TREECTRL_ROOTORDEROFFS) ? (CBaseTreeItem*)&TreeCtrl->RootItems[ROOT_ORDER_TO_INDEX(Order)] : (CBaseTreeItem*)&TreeCtrl->Value[Order];
}
diff --git a/plugins/NewAwaySysMod/src/Notification.cpp b/plugins/NewAwaySysMod/src/Notification.cpp index 03ca926f94..c55cab9feb 100644 --- a/plugins/NewAwaySysMod/src/Notification.cpp +++ b/plugins/NewAwaySysMod/src/Notification.cpp @@ -21,12 +21,10 @@ #include "Path.h"
#include "Properties.h"
-
void ShowMsg(TCHAR *FirstLine, TCHAR *SecondLine, bool IsErrorMsg, int Timeout)
{
- if (ServiceExists(MS_POPUP_ADDPOPUPT))
- {
- POPUPDATAT ppd = {0};
+ if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
+ POPUPDATAT ppd = { 0 };
ppd.lchIcon = LoadIcon(NULL, IsErrorMsg ? IDI_EXCLAMATION : IDI_INFORMATION);
lstrcpy(ppd.lptzContactName, FirstLine);
lstrcpy(ppd.lptzText, SecondLine);
@@ -41,243 +39,35 @@ void ShowMsg(TCHAR *FirstLine, TCHAR *SecondLine, bool IsErrorMsg, int Timeout) static int CALLBACK MenuWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg)
- {
- case WM_MEASUREITEM:
- {
- return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
- }
- case WM_DRAWITEM:
- {
- return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
- }
+ switch (uMsg) {
+ case WM_MEASUREITEM:
+ return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+
+ case WM_DRAWITEM:
+ return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
-static VOID CALLBACK ShowContactMenu(DWORD wParam)
-// wParam = hContact
+static VOID CALLBACK ShowContactMenu(MCONTACT hContact)
{
POINT pt;
HWND hMenuWnd = CreateWindowEx(WS_EX_TOOLWINDOW, _T("static"), _T(MOD_NAME)_T("_MenuWindow"), 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, g_hInstance, NULL);
SetWindowLongPtr(hMenuWnd, GWLP_WNDPROC, (LONG)(WNDPROC)MenuWndProc);
- HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)wParam, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, hContact, 0);
GetCursorPos(&pt);
SetForegroundWindow(hMenuWnd);
- CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hMenuWnd, NULL), MPCF_CONTACTMENU), (LPARAM)wParam);
+ CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hMenuWnd, NULL), MPCF_CONTACTMENU), hContact);
PostMessage(hMenuWnd, WM_NULL, 0, 0);
DestroyMenu(hMenu);
DestroyWindow(hMenuWnd);
}
-/*
-void Popup_DoAction(HWND hWnd, BYTE Action, PLUGIN_DATA *pdata)
-{
- MCONTACT hContact = (HANDLE)CallService(MS_POPUP_GETCONTACT, (WPARAM)hWnd, 0);
- switch (Action)
- {
- case PCA_OPENMESSAGEWND: // open message window
- {
- if (hContact && hContact != INVALID_HANDLE_VALUE)
- {
- CallServiceSync(ServiceExists("SRMsg/LaunchMessageWindow") ? "SRMsg/LaunchMessageWindow" : MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
- }
- } break;
- case PCA_OPENMENU: // open contact menu
- {
- if (hContact && hContact != INVALID_HANDLE_VALUE)
- {
- QueueUserAPC(ShowContactMenu, hMainThread, (ULONG_PTR)hContact);
- }
- } break;
- case PCA_OPENDETAILS: // open contact details window
- {
- if (hContact != INVALID_HANDLE_VALUE)
- {
- CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
- }
- } break;
- case PCA_OPENHISTORY: // open contact history
- {
- if (hContact != INVALID_HANDLE_VALUE)
- {
- CallServiceSync(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0);
- }
- } break;
- case PCA_OPENLOG: // open log file
- {
- TCString LogFilePath;
- LS_LOGINFO li = {0};
- li.cbSize = sizeof(li);
- li.szID = LOG_ID;
- li.hContact = hContact;
- li.Flags = LSLI_TCHAR;
- li.tszLogPath = LogFilePath.GetBuffer(MAX_PATH);
- if (!CallService(MS_LOGSERVICE_GETLOGINFO, (WPARAM)&li, 0))
- {
- LogFilePath.ReleaseBuffer();
- ShowLog(LogFilePath);
- } else
- {
- LogFilePath.ReleaseBuffer();
- }
- } break;
- case PCA_CLOSEPOPUP: // close popup
- {
- PUDeletePopup(hWnd);
- } break;
- case PCA_DONOTHING: // do nothing
- break;
- }
-}
-
-
-static int CALLBACK ReqNotifyPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- PLUGIN_DATA *pdata;
- switch (message)
- {
- case WM_COMMAND:
- {
- if (HIWORD(wParam) == STN_CLICKED) // left mouse button
- {
- pdata = (PLUGIN_DATA*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);
- if (pdata)
- {
- Popup_DoAction(hWnd, pdata->PopupLClickAction, pdata);
- }
- return true;
- }
- } break;
- case WM_CONTEXTMENU: // right mouse button
- {
- pdata = (PLUGIN_DATA*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);
- if (pdata)
- {
- Popup_DoAction(hWnd, pdata->PopupRClickAction, pdata);
- }
- return true;
- } break;
- case UM_FREEPLUGINDATA:
- {
- pdata = (PLUGIN_DATA*)CallService(MS_POPUP_GETPLUGINDATA, (WPARAM)hWnd, 0);
- if (pdata)
- {
- if (pdata->hStatusIcon)
- {
- DestroyIcon(pdata->hStatusIcon);
- }
- free(pdata);
- }
- return true;
- } break;
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
-}
-
-
-int ShowPopupNotification(COptPage &PopupNotifyData, MCONTACT hContact, int iStatusMode)
-{ // returns TRUE if popup was shown
-// we take szProto, UIN and Message from VarParseData
- POPUPDATAT ppd = {0};
- ppd.lchContact = hContact;
- TCString ExtraText;
- if (!iStatusMode)
- { // if it's an xstatus message request
- ExtraText = db_get_s(NULL, VarParseData.szProto, "XStatusName", _T(""));
- TCString XMsg(db_get_s(NULL, VarParseData.szProto, "XStatusMsg", _T("")));
- if (XMsg.GetLen())
- {
- if (ExtraText.GetLen())
- {
- ExtraText += _T("\r\n");
- }
- ExtraText += XMsg;
- }
- } else
- {
- ExtraText = VarParseData.Message;
- }
- TCString PopupMsg(*(TCString*)PopupNotifyData.GetValue(IDC_POPUPOPTDLG_POPUPFORMAT));
- if (ServiceExists(MS_VARS_FORMATSTRING))
- {
- FORMATINFO fi = {0};
- fi.cbSize = sizeof(fi);
- fi.flags = FIF_TCHAR;
- fi.tszFormat = PopupMsg;
- fi.hContact = hContact;
- fi.tszExtraText = ExtraText;
- TCHAR *szResult = (TCHAR*)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (szResult)
- {
- PopupMsg = szResult;
- mir_free(szResult);
- }
- } else
- {
- TCString szUIN;
- _ultot(VarParseData.UIN, szUIN.GetBuffer(16), 10);
- szUIN.ReleaseBuffer();
- TCHAR *szStatDesc = iStatusMode ? (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, iStatusMode, GSMDF_TCHAR) : STR_XSTATUSDESC;
- _ASSERT(szStatDesc);
- PopupMsg = TCString((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)) + _T(" (") + szUIN + TranslateT(") is reading your ") + szStatDesc + TranslateT(" message:\r\n") + ExtraText;
- }
- if (PopupMsg.GetLen())
- {
- TCHAR *pLineBreak = _tcsstr(PopupMsg, _T("\n"));
- if (pLineBreak)
- {
- PopupMsg.GetBuffer();
- TCHAR *pNextLine = pLineBreak + 1;
- while ((*pNextLine == '\r' || *pNextLine == '\n') && *pNextLine)
- {
- *pNextLine++;
- }
- _tcsncpy(ppd.lpzText, pNextLine, 499);
- while ((*pLineBreak == '\r' || *pLineBreak == '\n') && (pLineBreak >= PopupMsg))
- {
- *pLineBreak-- = 0;
- }
- PopupMsg.ReleaseBuffer();
- } else
- {
- lstrcpy(ppd.lpzText, _T(""));
- }
- _tcsncpy(ppd.lpzContactName, PopupMsg, 499);
- ppd.colorBack = (PopupNotifyData.GetValue(IDC_POPUPOPTDLG_DEFBGCOLOUR) ? 0 : PopupNotifyData.GetValue(IDC_POPUPOPTDLG_BGCOLOUR));
- ppd.colorText = (PopupNotifyData.GetValue(IDC_POPUPOPTDLG_DEFTEXTCOLOUR) ? 0 : PopupNotifyData.GetValue(IDC_POPUPOPTDLG_TEXTCOLOUR));
- ppd.PluginWindowProc = (WNDPROC)ReqNotifyPopupDlgProc;
- PLUGIN_DATA *pdata = (PLUGIN_DATA*)calloc(1, sizeof(PLUGIN_DATA));
- if (!iStatusMode)
- { // it's an xstatus message request
- ppd.lchIcon = pdata->hStatusIcon = (HICON)CallProtoService(VarParseData.szProto, PS_ICQ_GETCUSTOMSTATUSICON, 0, 0);
- }
- if (!pdata->hStatusIcon || (DWORD)pdata->hStatusIcon == CALLSERVICE_NOTFOUND)
- {
- pdata->hStatusIcon = NULL;
- ppd.lchIcon = LoadSkinnedProtoIcon(VarParseData.szProto, iStatusMode);
- }
- pdata->PopupLClickAction = PopupNotifyData.GetValue(IDC_POPUPOPTDLG_LCLICK_ACTION);
- pdata->PopupRClickAction = PopupNotifyData.GetValue(IDC_POPUPOPTDLG_RCLICK_ACTION);
- ppd.PluginData = pdata;
- ppd.iSeconds = PopupNotifyData.GetValue(IDC_POPUPOPTDLG_POPUPDELAY);
- CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, 0);
- if (hContact)
- {
- SkinPlaySound(AWAYSYS_STATUSMSGREQUEST_SOUND);
- }
- return true;
- }
- return false;
-}
-*/
-
void ShowLog(TCString &LogFilePath)
{
int Result = (int)ShellExecute(NULL, _T("open"), LogFilePath, NULL, NULL, SW_SHOW);
- if (Result <= 32) // Error
- {
+ if (Result <= 32) {
TCHAR szError[64];
mir_sntprintf(szError, SIZEOF(szError), TranslateT("Error #%d"), Result);
ShowMsg(szError, TranslateT("Can't open log file ") + LogFilePath, true);
diff --git a/plugins/NewAwaySysMod/src/Options.cpp b/plugins/NewAwaySysMod/src/Options.cpp index e0d585d991..cd25755a13 100644 --- a/plugins/NewAwaySysMod/src/Options.cpp +++ b/plugins/NewAwaySysMod/src/Options.cpp @@ -30,77 +30,77 @@ COptPage::COptPage(const COptPage &Item) COptPage::~COptPage()
{
- int I;
- for (I = 0; I < Items.GetSize(); I++)
+ int i;
+ for (i = 0; i < Items.GetSize(); i++)
{
- delete Items[I];
+ delete Items[i];
}
Items.RemoveAll();
}
void COptPage::MemToPage(int OnlyEnable)
{
- int I;
+ int i;
_ASSERT(hWnd);
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
if (OnlyEnable)
{
- Items[I]->COptItem::MemToWnd(hWnd);
+ Items[i]->COptItem::MemToWnd(hWnd);
} else
{
- Items[I]->MemToWnd(hWnd);
+ Items[i]->MemToWnd(hWnd);
}
}
}
void COptPage::PageToMem()
{
- int I;
+ int i;
_ASSERT(hWnd);
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- Items[I]->WndToMem(hWnd);
+ Items[i]->WndToMem(hWnd);
}
}
void COptPage::DBToMem()
{
- int I;
+ int i;
_ASSERT(sModule != "");
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- Items[I]->DBToMem(sModule, &sDBSettingPrefix);
+ Items[i]->DBToMem(sModule, &sDBSettingPrefix);
}
}
void COptPage::MemToDB()
{
- int I;
+ int i;
_ASSERT(sModule != "");
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- Items[I]->MemToDB(sModule, &sDBSettingPrefix);
+ Items[i]->MemToDB(sModule, &sDBSettingPrefix);
}
}
void COptPage::CleanDBSettings()
{
- int I;
+ int i;
_ASSERT(sModule != "");
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- Items[I]->CleanDBSettings(sModule, &sDBSettingPrefix);
+ Items[i]->CleanDBSettings(sModule, &sDBSettingPrefix);
}
}
bool COptPage::GetModified()
{
- int I;
+ int i;
_ASSERT(sModule != "");
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- if (Items[I]->GetModified())
+ if (Items[i]->GetModified())
{
return true;
}
@@ -110,22 +110,22 @@ bool COptPage::GetModified() void COptPage::SetModified(bool Modified)
{
- int I;
+ int i;
_ASSERT(sModule != "");
- for (I = 0; I < Items.GetSize(); I++)
+ for (i = 0; i < Items.GetSize(); i++)
{
- Items[I]->SetModified(Modified);
+ Items[i]->SetModified(Modified);
}
}
COptItem *COptPage::Find(int DlgItemID)
{
- int I;
- for (I = 0; I < Items.GetSize(); I++)
+ int i;
+ for (i = 0; i < Items.GetSize(); i++)
{
- if (Items[I]->GetID() == DlgItemID)
+ if (Items[i]->GetID() == DlgItemID)
{
- return Items[I];
+ return Items[i];
}
}
_ASSERT(0);
@@ -134,14 +134,14 @@ COptItem *COptPage::Find(int DlgItemID) COptPage& COptPage::operator = (const COptPage& Page)
{
- int I;
+ int i;
hWnd = Page.hWnd;
sModule = Page.sModule;
sDBSettingPrefix = Page.sDBSettingPrefix;
Items.RemoveAll();
- for (I = 0; I < Page.Items.GetSize(); I++)
+ for (i = 0; i < Page.Items.GetSize(); i++)
{
- Items.AddElem(Page.Items[I]->Copy());
+ Items.AddElem(Page.Items[i]->Copy());
}
return *this;
}
@@ -275,19 +275,19 @@ void COptItem_BitDBSetting::MemToDB(CString &sModule, CString *sDBSettingPrefix) int COptItem_TreeCtrl::IDToOrder(int ID)
{
- int I;
- for (I = 0; I < RootItems.GetSize(); I++)
+ int i;
+ for (i = 0; i < RootItems.GetSize(); i++)
{
- if (RootItems[I].ID == ID)
+ if (RootItems[i].ID == ID)
{
- return ROOT_INDEX_TO_ORDER(I);
+ return ROOT_INDEX_TO_ORDER(i);
}
}
- for (I = 0; I < Value.GetSize(); I++)
+ for (i = 0; i < Value.GetSize(); i++)
{
- if (Value[I].ID == ID)
+ if (Value[i].ID == ID)
{
- return I;
+ return i;
}
}
return -1;
@@ -295,19 +295,19 @@ int COptItem_TreeCtrl::IDToOrder(int ID) int COptItem_TreeCtrl::hItemToOrder(HTREEITEM hItem)
{
- int I;
- for (I = 0; I < RootItems.GetSize(); I++)
+ int i;
+ for (i = 0; i < RootItems.GetSize(); i++)
{
- if (RootItems[I].hItem == hItem)
+ if (RootItems[i].hItem == hItem)
{
- return ROOT_INDEX_TO_ORDER(I);
+ return ROOT_INDEX_TO_ORDER(i);
}
}
- for (I = 0; I < Value.GetSize(); I++)
+ for (i = 0; i < Value.GetSize(); i++)
{
- if (Value[I].hItem == hItem)
+ if (Value[i].hItem == hItem)
{
- return I;
+ return i;
}
}
return -1;
@@ -333,7 +333,7 @@ typedef struct int TreeReadEnum(const char *szSetting, LPARAM lParam)
{
sTreeReadEnumData *TreeReadEnumData = (sTreeReadEnumData*)lParam;
- int Len = TreeReadEnumData->TreeCtrl->sDBSetting.GetLen() + lengthof(TREEITEM_DBSTR_TITLE) - 1;
+ int Len = TreeReadEnumData->TreeCtrl->sDBSetting.GetLen() + SIZEOF(TREEITEM_DBSTR_TITLE) - 1;
if (!strncmp(szSetting, TreeReadEnumData->TreeCtrl->sDBSetting + TREEITEM_DBSTR_TITLE, Len) && isdigit(szSetting[Len]))
{
int ID = atol(szSetting + Len);
@@ -380,13 +380,13 @@ void COptItem_TreeCtrl::DBToMem(CString &sModule, CString *sDBSettingPrefix) Value = DefValue;
} else
{
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
- if (Value[I].Title == NULL)
+ if (Value[i].Title == NULL)
{
- Value.RemoveElem(I);
- I--;
+ Value.RemoveElem(i);
+ i--;
}
}
}
@@ -402,22 +402,22 @@ void COptItem_TreeCtrl::MemToDB(CString &sModule, CString *sDBSettingPrefix) sDBSettingPrefix = &sEmptyString;
}
CleanDBSettings(sModule, sDBSettingPrefix);
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
CString StrID;
- _itoa(Value[I].ID, StrID.GetBuffer(64), 10);
+ _itoa(Value[i].ID, StrID.GetBuffer(64), 10);
StrID.ReleaseBuffer();
- db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_TITLE + StrID, Value[I].Title);
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_TITLE + StrID, Value[i].Title);
if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL))
- db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_PARENT + StrID, Value[I].ParentID);
+ db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_PARENT + StrID, Value[i].ParentID);
- db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_ORDER + StrID, I);
+ db_set_w(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_ORDER + StrID, i);
if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL) || TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
- db_set_b(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_FLAGS + StrID, Value[I].Flags);
+ db_set_b(NULL, sModule, *sDBSettingPrefix + sDBSetting + TREEITEM_DBSTR_FLAGS + StrID, Value[i].Flags);
- if (User_Str1_DBName != NULL && Value[I].User_Str1 != NULL)
- db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + User_Str1_DBName + StrID, Value[I].User_Str1);
+ if (User_Str1_DBName != NULL && Value[i].User_Str1 != NULL)
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + User_Str1_DBName + StrID, Value[i].User_Str1);
}
COptItem::MemToDB(sModule, sDBSettingPrefix);
}
@@ -426,26 +426,26 @@ void COptItem_TreeCtrl::MemToDB(CString &sModule, CString *sDBSettingPrefix) void COptItem_TreeCtrl::WndToMem(HWND hWnd)
{ // only need to gather info of items state (expanded/collapsed, checked/unchecked)
HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
- DWORD State = TreeView_GetItemState(hTreeView, Value[I].hItem, TVIS_EXPANDED | TVIS_STATEIMAGEMASK);
- int OldFlags = Value[I].Flags;
+ DWORD State = TreeView_GetItemState(hTreeView, Value[i].hItem, TVIS_EXPANDED | TVIS_STATEIMAGEMASK);
+ int OldFlags = Value[i].Flags;
if (State & TVIS_EXPANDED)
{
- Value[I].Flags |= TIF_EXPANDED;
+ Value[i].Flags |= TIF_EXPANDED;
} else
{
- Value[I].Flags &= ~TIF_EXPANDED;
+ Value[i].Flags &= ~TIF_EXPANDED;
}
if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES && (State >> 12) - 1)
{
- Value[I].Flags |= TIF_ENABLED;
+ Value[i].Flags |= TIF_ENABLED;
} else
{
- Value[I].Flags &= ~TIF_ENABLED;
+ Value[i].Flags &= ~TIF_ENABLED;
}
- if (Value[I].Flags != OldFlags)
+ if (Value[i].Flags != OldFlags)
{
Modified = true;
}
@@ -468,46 +468,46 @@ void COptItem_TreeCtrl::MemToWnd(HWND hWnd) SendMessage(hTreeView, WM_SETREDRAW, false, 0);
TreeView_DeleteAllItems(hTreeView);
_ASSERT(RootItems.GetSize());
- int I;
+ int i;
if (!(TreeFlags & TREECTRL_FLAG_IS_SINGLE_LEVEL))
{
- for (I = 0; I < RootItems.GetSize(); I++)
+ for (i = 0; i < RootItems.GetSize(); i++)
{
tvIn.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
- RootItems[I].Flags |= TIF_GROUP;
- tvIn.item.state = tvIn.item.stateMask = TVIS_BOLD | ((RootItems[I].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0);
- tvIn.item.pszText = RootItems[I].Title;
+ RootItems[i].Flags |= TIF_GROUP;
+ tvIn.item.state = tvIn.item.stateMask = TVIS_BOLD | ((RootItems[i].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0);
+ tvIn.item.pszText = RootItems[i].Title;
tvIn.hParent = TVI_ROOT;
tvIn.hInsertAfter = TVI_LAST;
- tvIn.item.lParam = RootItems[I].ID;
- RootItems[I].hItem = TreeView_InsertItem(hTreeView, &tvIn);
+ tvIn.item.lParam = RootItems[i].ID;
+ RootItems[i].hItem = TreeView_InsertItem(hTreeView, &tvIn);
}
}
- for (I = 0; I < Value.GetSize(); I++)
+ for (i = 0; i < Value.GetSize(); i++)
{
- Value[I].hItem = RootItems[0].hItem; // put an item to first group in case of some strange error
+ Value[i].hItem = RootItems[0].hItem; // put an item to first group in case of some strange error
}
- for (I = 0; I < Value.GetSize(); I++)
+ for (i = 0; i < Value.GetSize(); i++)
{
tvIn.item.mask = TVIF_TEXT | TVIF_STATE | TVIF_PARAM;
- tvIn.item.state = tvIn.item.stateMask = (Value[I].Flags & TIF_GROUP) ? (TVIS_BOLD | ((Value[I].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0)) : 0;
+ tvIn.item.state = tvIn.item.stateMask = (Value[i].Flags & TIF_GROUP) ? (TVIS_BOLD | ((Value[i].Flags & TIF_EXPANDED) ? TVIS_EXPANDED : 0)) : 0;
if (TreeFlags & TREECTRL_FLAG_HAS_CHECKBOXES)
{
tvIn.item.stateMask |= TVIS_STATEIMAGEMASK;
- tvIn.item.state |= INDEXTOSTATEIMAGEMASK((Value[I].Flags & TIF_ENABLED) ? 2 : 1);
+ tvIn.item.state |= INDEXTOSTATEIMAGEMASK((Value[i].Flags & TIF_ENABLED) ? 2 : 1);
}
- tvIn.item.pszText = Value[I].Title;
- int Order = IDToOrder(Value[I].ParentID);
+ tvIn.item.pszText = Value[i].Title;
+ int Order = IDToOrder(Value[i].ParentID);
if (Order != -1)
{
tvIn.hParent = (Order <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(Order)].hItem : Value[Order].hItem;
tvIn.hInsertAfter = TVI_LAST;
- tvIn.item.lParam = Value[I].ID;
- Value[I].hItem = TreeView_InsertItem(hTreeView, &tvIn);
+ tvIn.item.lParam = Value[i].ID;
+ Value[i].hItem = TreeView_InsertItem(hTreeView, &tvIn);
} else
{ // found an orphan item; probably it's better just to delete it
- Value.RemoveElem(I);
- I--;
+ Value.RemoveElem(i);
+ i--;
}
}
TreeView_SelectItem(hTreeView, (SelectOrder >= 0) ? Value[SelectOrder].hItem : ((SelectOrder <= TREECTRL_ROOTORDEROFFS) ? RootItems[ROOT_ORDER_TO_INDEX(SelectOrder)].hItem : NULL));
@@ -589,10 +589,10 @@ void COptItem_TreeCtrl::CleanDBSettings(CString &sModule, CString *sDBSettingPre dbEnum.pfnEnumProc = TreeDeleteEnum;
dbEnum.szModule = sModule;
CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
- int I;
- for (I = 0; I < TreeDeleteEnumData.TreeSettings.GetSize(); I++)
+ int i;
+ for (i = 0; i < TreeDeleteEnumData.TreeSettings.GetSize(); i++)
{
- db_unset(NULL, sModule, TreeDeleteEnumData.TreeSettings[I]);
+ db_unset(NULL, sModule, TreeDeleteEnumData.TreeSettings[i]);
}
}
@@ -619,22 +619,22 @@ void COptItem_TreeCtrl::Delete(HWND hWnd, int ID) Modified = true;
}
-void COptItem_TreeCtrl::RecursiveDelete(HWND hWnd, int I)
+void COptItem_TreeCtrl::RecursiveDelete(HWND hWnd, int i)
{
- if (Value[I].Flags & TIF_GROUP)
+ if (Value[i].Flags & TIF_GROUP)
{
int J;
- for (J = I + 1; J < Value.GetSize(); J++)
+ for (J = i + 1; J < Value.GetSize(); J++)
{
- if (Value[J].ParentID == Value[I].ID)
+ if (Value[J].ParentID == Value[i].ID)
{
RecursiveDelete(hWnd, J--);
}
}
}
HWND hTreeView = GetDlgItem(hWnd, DlgItemID);
- TreeView_DeleteItem(hTreeView, Value[I].hItem);
- Value.RemoveElem(I);
+ TreeView_DeleteItem(hTreeView, Value[i].hItem);
+ Value.RemoveElem(i);
}
CTreeItem* COptItem_TreeCtrl::InsertItem(HWND hWnd, CTreeItem &Item)
@@ -701,15 +701,15 @@ int COptItem_TreeCtrl::RecursiveMove(int ItemOrder, int ParentID, int InsertAtOr if (Value[InsertAtOrder].Flags & TIF_GROUP) // need to ensure that no items were left before their group by an order.
{
int GroupID = Value[InsertAtOrder].ID;
- int I;
- for (I = ItemOrder; I < InsertAtOrder; I++) // if ItemOrder > InsertAtOrder then there is simply nothing to do
+ int i;
+ for (i = ItemOrder; i < InsertAtOrder; i++) // if ItemOrder > InsertAtOrder then there is simply nothing to do
{
- if (Value[I].ParentID == GroupID)
+ if (Value[i].ParentID == GroupID)
{
- int CurrentItemsMoved = RecursiveMove(I, GroupID, InsertAtOrder);
+ int CurrentItemsMoved = RecursiveMove(i, GroupID, InsertAtOrder);
ItemsMoved += CurrentItemsMoved;
InsertAtOrder -= CurrentItemsMoved;
- I--;
+ i--;
}
}
}
@@ -783,7 +783,7 @@ typedef struct int ListReadEnum(const char *szSetting, LPARAM lParam)
{
sListReadEnumData *ListReadEnumData = (sListReadEnumData*)lParam;
- int Len = ListReadEnumData->sDBSettingPrefix->GetLen() + ListReadEnumData->ListCtrl->sDBSetting.GetLen() + lengthof(LISTITEM_DBSTR_TEXT) - 1;
+ int Len = ListReadEnumData->sDBSettingPrefix->GetLen() + ListReadEnumData->ListCtrl->sDBSetting.GetLen() + SIZEOF(LISTITEM_DBSTR_TEXT) - 1;
if (!strncmp(szSetting, *ListReadEnumData->sDBSettingPrefix + ListReadEnumData->ListCtrl->sDBSetting + LISTITEM_DBSTR_TEXT, Len) && isdigit(szSetting[Len]))
{
int ID = atol(szSetting + Len);
@@ -814,13 +814,13 @@ void COptItem_ListCtrl::DBToMem(CString &sModule, CString *sDBSettingPrefix) Value = DefValue;
} else
{
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
- if (Value[I].Text == NULL) // NULL is not ""!
+ if (Value[i].Text == NULL) // NULL is not ""!
{
- Value.RemoveElem(I);
- I--;
+ Value.RemoveElem(i);
+ i--;
}
}
}
@@ -836,13 +836,13 @@ void COptItem_ListCtrl::MemToDB(CString &sModule, CString *sDBSettingPrefix) sDBSettingPrefix = &sEmptyString;
}
CleanDBSettings(sModule, sDBSettingPrefix);
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
CString StrID;
- _itoa(I, StrID.GetBuffer(64), 10);
+ _itoa(i, StrID.GetBuffer(64), 10);
StrID.ReleaseBuffer();
- db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + LISTITEM_DBSTR_TEXT + StrID, Value[I].Text);
+ db_set_ts(NULL, sModule, *sDBSettingPrefix + sDBSetting + LISTITEM_DBSTR_TEXT + StrID, Value[i].Text);
}
COptItem::MemToDB(sModule, sDBSettingPrefix);
}
@@ -859,10 +859,10 @@ void COptItem_ListCtrl::MemToWnd(HWND hWnd) HWND hListView = GetDlgItem(hWnd, DlgItemID);
SendMessage(hListView, WM_SETREDRAW, false, 0);
SendMessage(hListView, LB_RESETCONTENT, 0, 0);
- int I;
- for (I = 0; I < Value.GetSize(); I++)
+ int i;
+ for (i = 0; i < Value.GetSize(); i++)
{
- SendMessage(hListView, LB_INSERTSTRING, -1, (LPARAM)(TCHAR*)Value[I].Text);
+ SendMessage(hListView, LB_INSERTSTRING, -1, (LPARAM)(TCHAR*)Value[i].Text);
}
SendMessage(hListView, WM_SETREDRAW, true, 0);
COptItem::MemToWnd(hWnd);
@@ -902,10 +902,10 @@ void COptItem_ListCtrl::CleanDBSettings(CString &sModule, CString *sDBSettingPre dbEnum.pfnEnumProc = ListDeleteEnum;
dbEnum.szModule = sModule;
CallService(MS_DB_CONTACT_ENUMSETTINGS, NULL, (LPARAM)&dbEnum);
- int I;
- for (I = 0; I < ListDeleteEnumData.ListSettings.GetSize(); I++)
+ int i;
+ for (i = 0; i < ListDeleteEnumData.ListSettings.GetSize(); i++)
{
- db_unset(NULL, sModule, ListDeleteEnumData.ListSettings[I]);
+ db_unset(NULL, sModule, ListDeleteEnumData.ListSettings[i]);
}
}
@@ -913,7 +913,7 @@ void COptItem_ListCtrl::CleanDBSettings(CString &sModule, CString *sDBSettingPre int COptItem_ListCtrl::GetSelectedItemID(HWND hWnd)
{
int Res = SendDlgItemMessage(hWnd, DlgItemID, LB_GETCURSEL, 0, 0);
- return (Res == LB_ERR) ? -1 : Res; // I know that LB_ERR = -1 ;)
+ return (Res == LB_ERR) ? -1 : Res; // i know that LB_ERR = -1 ;)
}
int COptItem_ListCtrl::SetSelectedItemID(HWND hWnd, int ID)
@@ -957,7 +957,7 @@ CListItem* COptItem_ListCtrl::InsertItem(HWND hWnd, int ID, CListItem &Item) HWND hListView = GetDlgItem(hWnd, DlgItemID);
int Res = SendMessage(hListView, LB_INSERTSTRING, ID, (LPARAM)(TCHAR*)(Item.Text)); // LB_INSERTSTRING doesn't sort the lists even with LBS_SORT style
_ASSERT(Res != LB_ERR && Res != LB_ERRSPACE);
- int I = Value.AddElem(Item);
+ int i = Value.AddElem(Item);
Modified = true;
- return &Value[I];
+ return &Value[i];
}
diff --git a/plugins/NewAwaySysMod/src/Options.h b/plugins/NewAwaySysMod/src/Options.h index 666162c50a..5fda4082d9 100644 --- a/plugins/NewAwaySysMod/src/Options.h +++ b/plugins/NewAwaySysMod/src/Options.h @@ -22,11 +22,6 @@ #include "CString.h"
#include "TMyArray.h"
-#ifndef lengthof
-#define lengthof(s) (sizeof(s) / sizeof(*s))
-#endif
-
-
class COptItem
{
public:
@@ -399,7 +394,7 @@ public: int TreeFlags;
protected:
- void RecursiveDelete(HWND hWnd, int I);
+ void RecursiveDelete(HWND hWnd, int i);
int RecursiveMove(int ItemOrder, int ParentID, int InsertAtOrder);
};
diff --git a/plugins/NewAwaySysMod/src/Properties.cpp b/plugins/NewAwaySysMod/src/Properties.cpp index d1e87d0b8c..b8bee383e1 100644 --- a/plugins/NewAwaySysMod/src/Properties.cpp +++ b/plugins/NewAwaySysMod/src/Properties.cpp @@ -29,22 +29,17 @@ void ResetContactSettingsOnStatusChange(MCONTACT hContact) db_unset(hContact, MOD_NAME, DB_MESSAGECOUNT);
}
-
void ResetSettingsOnStatusChange(const char *szProto = NULL, int bResetPersonalMsgs = false, int Status = 0)
{
if (bResetPersonalMsgs)
- { // bResetPersonalMsgs &&= g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_SAVEPERSONALMSGS);
bResetPersonalMsgs = !g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_SAVEPERSONALMSGS);
- }
+
MCONTACT hContact = db_find_first();
- while (hContact)
- {
+ while (hContact) {
const char *szCurProto;
- if (!szProto || ((szCurProto = (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)) && !lstrcmpA(szProto, szCurProto)))
- {
+ if (!szProto || ((szCurProto = (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0)) && !lstrcmpA(szProto, szCurProto))) {
ResetContactSettingsOnStatusChange(hContact);
- if (bResetPersonalMsgs)
- {
+ if (bResetPersonalMsgs) {
CContactSettings(Status, hContact).SetMsgFormat(SMF_PERSONAL, NULL); // TODO: delete only when SAM dialog opens?
}
}
@@ -57,98 +52,73 @@ CProtoState::CStatus& CProtoState::CStatus::operator = (int Status) {
_ASSERT(Status >= ID_STATUS_OFFLINE && Status <= ID_STATUS_OUTTOLUNCH);
if (Status < ID_STATUS_OFFLINE || Status > ID_STATUS_OUTTOLUNCH)
- {
return *this; // ignore status change if the new status is unknown
- }
+
bool bModified = false;
- if (szProto)
- {
- if (this->Status != Status)
- {
+ if (szProto) {
+ if (this->Status != Status) {
this->Status = Status;
(*GrandParent)[szProto].AwaySince.Reset();
ResetSettingsOnStatusChange(szProto, true, Status);
bModified = true;
}
- if ((*GrandParent)[szProto].TempMsg.IsSet())
- {
+ if ((*GrandParent)[szProto].TempMsg.IsSet()) {
(*GrandParent)[szProto].TempMsg.Unset();
bModified = true;
}
- } else // global status change
- {
- int I;
+ }
+ else { // global status change
int bStatusModified = false;
- for (I = 0; I < GrandParent->GetSize(); I++)
- {
- CProtoState &State = (*GrandParent)[I];
- if (!db_get_b(NULL, State.GetProto(), "LockMainStatus", 0)) // if the protocol isn't locked
- {
- if (State.Status != Status)
- {
+ for (int i = 0; i < GrandParent->GetSize(); i++) {
+ CProtoState &State = (*GrandParent)[i];
+ if (!db_get_b(NULL, State.GetProto(), "LockMainStatus", 0)) { // if the protocol isn't locked
+ if (State.Status != Status) {
State.Status.Status = Status; // "Status.Status" - changing Status directly to prevent recursive calls to the function
State.AwaySince.Reset();
bModified = true;
bStatusModified = true;
}
- if (State.TempMsg.IsSet())
- {
+ if (State.TempMsg.IsSet()) {
State.TempMsg.Unset();
bModified = true;
}
if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RESETPROTOMSGS))
- {
CProtoSettings(State.szProto, Status).SetMsgFormat(SMF_PERSONAL, NULL);
- }
}
}
if (bStatusModified)
- {
ResetSettingsOnStatusChange(NULL, true, Status);
- }
}
if (bModified && g_SetAwayMsgPage.GetWnd())
- {
SendMessage(g_SetAwayMsgPage.GetWnd(), UM_SAM_PROTOSTATUSCHANGED, (WPARAM)(char*)szProto, 0);
- }
return *this;
}
-
void CProtoState::CAwaySince::Reset()
{
GetLocalTime(&AwaySince);
+
if (GrandParent && !szProto)
- {
- int I;
- for (I = 0; I < GrandParent->GetSize(); I++)
- {
- GetLocalTime((*GrandParent)[I].AwaySince);
- }
- }
+ for (int i = 0; i < GrandParent->GetSize(); i++)
+ GetLocalTime((*GrandParent)[i].AwaySince);
}
void CContactSettings::SetMsgFormat(int Flags, TCString Message)
{
- if (Flags & SMF_PERSONAL)
- { // set a personal message for a contact. also it's used to set global status message (hContact = NULL).
- // if Message == NULL, then the function deletes the message.
+ if (Flags & SMF_PERSONAL) { // set a personal message for a contact. also it's used to set global status message (hContact = NULL).
+ // if Message == NULL, then the function deletes the message.
CString DBSetting(StatusToDBSetting(Status, DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPERSONAL));
if (g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON) && GetMsgFormat(SMF_PERSONAL) != (const TCHAR*)Message)
- {
ResetContactSettingsOnStatusChange(hContact);
- }
+
if (Message != NULL)
- {
db_set_ts(hContact, MOD_NAME, DBSetting, Message);
- } else
- {
+ else
db_unset(hContact, MOD_NAME, DBSetting);
- }
}
- if (Flags & (SMF_LAST | SMF_TEMPORARY))
- {
+
+ if (Flags & (SMF_LAST | SMF_TEMPORARY)) {
_ASSERT(!hContact);
CProtoSettings().SetMsgFormat(Flags & (SMF_LAST | SMF_TEMPORARY), Message);
}
@@ -157,112 +127,92 @@ void CContactSettings::SetMsgFormat(int Flags, TCString Message) TCString CContactSettings::GetMsgFormat(int Flags, int *pOrder, char *szProtoOverride)
// returns the requested message; sets Order to the order of the message in the message tree, if available; or to -1 otherwise.
-// szProtoOverride is needed only to get status message of the right protocol when the ICQ contact is on list, but not with the same protocol on which it requests the message - this way we can still get contact details.
+// szProtoOverride is needed only to get status message of the right protocol when the ICQ contact is on list, but not with the same
+// protocol on which it requests the message - this way we can still get contact details.
{
TCString Message = NULL;
if (pOrder)
- {
*pOrder = -1;
- }
- if (Flags & GMF_PERSONAL)
- { // try getting personal message (it overrides global)
+
+ if (Flags & GMF_PERSONAL) // try getting personal message (it overrides global)
Message = db_get_s(hContact, MOD_NAME, StatusToDBSetting(Status, DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPERSONAL), (TCHAR*)NULL);
- }
- if (Flags & (GMF_LASTORDEFAULT | GMF_PROTOORGLOBAL | GMF_TEMPORARY) && Message.IsEmpty())
- {
+
+ if (Flags & (GMF_LASTORDEFAULT | GMF_PROTOORGLOBAL | GMF_TEMPORARY) && Message.IsEmpty()) {
char *szProto = szProtoOverride ? szProtoOverride : (hContact ? GetContactProto(hContact) : NULL);
+
+ // we mustn't pass here by GMF_TEMPORARY flag, as otherwise we'll handle GMF_TEMPORARY | GMF_PERSONAL combination incorrectly,
+ // which is supposed to get only per-contact messages, and at the same time also may be used with NULL contact to get the global status message
if (Flags & (GMF_LASTORDEFAULT | GMF_PROTOORGLOBAL))
- { // we mustn't pass here by GMF_TEMPORARY flag, as otherwise we'll handle GMF_TEMPORARY | GMF_PERSONAL combination incorrectly, which is supposed to get only per-contact messages, and at the same time also may be used with NULL contact to get the global status message
Message = CProtoSettings(szProto).GetMsgFormat(Flags, pOrder);
- } else if (!hContact)
- { // handle global temporary message too
+ else if (!hContact) { // handle global temporary message too
if (g_ProtoStates[szProto].TempMsg.IsSet())
- {
Message = g_ProtoStates[szProto].TempMsg;
- }
}
}
return Message;
}
-
void CProtoSettings::SetMsgFormat(int Flags, TCString Message)
{
if (Flags & (SMF_TEMPORARY | SMF_PERSONAL) && g_AutoreplyOptPage.GetDBValueCopy(IDC_REPLYDLG_RESETCOUNTERWHENSAMEICON) && GetMsgFormat(Flags & (SMF_TEMPORARY | SMF_PERSONAL)) != (const TCHAR*)Message)
- {
ResetSettingsOnStatusChange(szProto);
- }
- if (Flags & SMF_TEMPORARY)
- {
+
+ if (Flags & SMF_TEMPORARY) {
_ASSERT(!Status || Status == g_ProtoStates[szProto].Status);
g_ProtoStates[szProto].TempMsg = (szProto || Message != NULL) ? Message : CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT);
}
- if (Flags & SMF_PERSONAL)
- { // set a "personal" message for a protocol. also it's used to set global status message (hContact = NULL).
- // if Message == NULL, then we'll use the "default" message - i.e. it's either the global message for szProto != NULL (we delete the per-proto DB setting), or it's just a default message for a given status for szProto == NULL.
+
+ if (Flags & SMF_PERSONAL) { // set a "personal" message for a protocol. also it's used to set global status message (hContact = NULL).
+ // if Message == NULL, then we'll use the "default" message - i.e. it's either the global message for szProto != NULL (we delete the per-proto DB setting), or it's just a default message for a given status for szProto == NULL.
g_ProtoStates[szProto].TempMsg.Unset();
CString DBSetting(ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS));
if (Message != NULL)
- {
db_set_ts(NULL, MOD_NAME, DBSetting, Message);
- } else
- {
+ else {
if (!szProto)
- {
db_set_ts(NULL, MOD_NAME, DBSetting, CProtoSettings(NULL, Status).GetMsgFormat(GMF_LASTORDEFAULT)); // global message can't be NULL; we can use an empty string instead if it's really necessary
- } else
- {
+ else
db_unset(NULL, MOD_NAME, DBSetting);
- }
}
}
- if (Flags & SMF_LAST)
- {
+
+ if (Flags & SMF_LAST) {
COptPage MsgTreeData(g_MsgTreePage);
COptItem_TreeCtrl *TreeCtrl = (COptItem_TreeCtrl*)MsgTreeData.Find(IDV_MSGTREE);
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
+ 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->SetModified(true);
}
- int I;
+ int i;
+ // try to find an identical message in the same group (to prevent saving multiple identical messages),
+ // or at least if we'll find an identical message somewhere else, then we'll use its title for our new message
TCString Title(_T(""));
- for (I = 0; I < TreeCtrl->Value.GetSize(); I++) // try to find an identical message in the same group (to prevent saving multiple identical messages), or at least if we'll find an identical message somewhere else, then we'll use its title for our new message
- {
- if (!(TreeCtrl->Value[I].Flags & TIF_GROUP) && TreeCtrl->Value[I].User_Str1 == (const TCHAR*)Message)
- {
- if (TreeCtrl->Value[I].ParentID == RecentGroupID)
- { // found it in the same group
+ for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
+ if (!(TreeCtrl->Value[i].Flags & TIF_GROUP) && TreeCtrl->Value[i].User_Str1 == (const TCHAR*)Message) {
+ if (TreeCtrl->Value[i].ParentID == RecentGroupID) { // found it in the same group
int GroupOrder = TreeCtrl->IDToOrder(RecentGroupID);
- TreeCtrl->Value.MoveElem(I, (GroupOrder >= 0) ? (GroupOrder + 1) : 0); // now move it to the top of recent messages list
+ TreeCtrl->Value.MoveElem(i, (GroupOrder >= 0) ? (GroupOrder + 1) : 0); // now move it to the top of recent messages list
TreeCtrl->SetModified(true);
break; // no reason to search for anything else
- } else if (Title.IsEmpty())
- { // it's not in the same group, but at least we'll use its title
- Title = TreeCtrl->Value[I].Title;
}
+ if (Title.IsEmpty()) // it's not in the same group, but at least we'll use its title
+ Title = TreeCtrl->Value[i].Title;
}
}
- if (I == TreeCtrl->Value.GetSize())
- { // we didn't find an identical message in the same group, so we'll add our new message here
- if (Title.IsEmpty())
- { // didn't find a title for our message either
+ if (i == TreeCtrl->Value.GetSize()) { // we didn't find an identical message in the same group, so we'll add our new message here
+ if (Title.IsEmpty()) { // didn't find a title for our message either
if (Message.GetLen() > MRM_MAX_GENERATED_TITLE_LEN)
- {
Title = Message.Left(MRM_MAX_GENERATED_TITLE_LEN - 3) + _T("...");
- } else
- {
+ else
Title = Message;
- }
+
TCHAR *p = Title.GetBuffer();
- while (*p) // remove "garbage"
- {
+ while (*p) { // remove "garbage"
if (!(p = _tcspbrk(p, _T("\r\n\t"))))
- {
break;
- }
+
*p++ = ' ';
}
Title.ReleaseBuffer();
@@ -271,32 +221,28 @@ void CProtoSettings::SetMsgFormat(int Flags, TCString Message) TreeCtrl->Value.InsertElem(CTreeItem(Title, RecentGroupID, TreeCtrl->GenerateID(), 0, Message), (GroupOrder >= 0) ? (GroupOrder + 1) : 0);
TreeCtrl->SetModified(true);
}
- // now clean up here
+
+ // now clean up here
int MRMNum = 0;
int MaxMRMNum = g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT);
- for (I = 0; I < TreeCtrl->Value.GetSize(); I++)
- {
- if (TreeCtrl->Value[I].ParentID == RecentGroupID)
- { // found a child of our group
- if (TreeCtrl->Value[I].Flags & TIF_GROUP || ++MRMNum > MaxMRMNum) // what groups are doing here?! :))
- {
- TreeCtrl->Value.RemoveElem(I);
+ for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
+ if (TreeCtrl->Value[i].ParentID == RecentGroupID) { // found a child of our group
+ if (TreeCtrl->Value[i].Flags & TIF_GROUP || ++MRMNum > MaxMRMNum) { // what groups are doing here?! :))
+ TreeCtrl->Value.RemoveElem(i);
TreeCtrl->SetModified(true);
- I--;
+ i--;
}
}
}
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM))
- { // if we're saving recent messages per status, then remove any messages that were left at the recent messages' root
- for (I = 0; I < TreeCtrl->Value.GetSize(); I++)
- {
- if (TreeCtrl->Value[I].ParentID == g_Messages_RecentRootID)
- {
- if (!(TreeCtrl->Value[I].Flags & TIF_GROUP))
- {
- TreeCtrl->Value.RemoveElem(I);
+
+ // if we're saving recent messages per status, then remove any messages that were left at the recent messages' root
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM)) {
+ for (i = 0; i < TreeCtrl->Value.GetSize(); i++) {
+ if (TreeCtrl->Value[i].ParentID == g_Messages_RecentRootID) {
+ if (!(TreeCtrl->Value[i].Flags & TIF_GROUP)) {
+ TreeCtrl->Value.RemoveElem(i);
TreeCtrl->SetModified(true);
- I--;
+ i--;
}
}
}
@@ -305,70 +251,58 @@ void CProtoSettings::SetMsgFormat(int Flags, TCString Message) }
}
-
-TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder)
// returns the requested message; sets Order to the order of the message in the message tree, if available; or to -1 otherwise.
+TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder)
{
TCString Message = NULL;
if (pOrder)
- {
*pOrder = -1;
- }
- if (Flags & GMF_TEMPORARY)
- {
+
+ if (Flags & GMF_TEMPORARY) {
_ASSERT(!Status || Status == g_ProtoStates[szProto].Status);
- if (g_ProtoStates[szProto].TempMsg.IsSet())
- {
+ if (g_ProtoStates[szProto].TempMsg.IsSet()) {
Message = g_ProtoStates[szProto].TempMsg;
Flags &= ~GMF_PERSONAL; // don't allow personal message to overwrite our NULL temporary message
}
}
- if (Flags & GMF_PERSONAL && Message == NULL)
- { // try getting personal message (it overrides global)
+ if (Flags & GMF_PERSONAL && Message == NULL) // try getting personal message (it overrides global)
Message = db_get_s(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL);
- }
- if (Flags & GMF_PROTOORGLOBAL && Message == NULL)
- {
+
+ if (Flags & GMF_PROTOORGLOBAL && Message == NULL) {
Message = CProtoSettings().GetMsgFormat(GMF_PERSONAL | (Flags & GMF_TEMPORARY), pOrder);
return (Message == NULL) ? _T("") : Message; // global message can't be NULL
}
- if (Flags & GMF_LASTORDEFAULT && Message == NULL)
- { // try to get the last or default message, depending on current settings
+
+ if (Flags & GMF_LASTORDEFAULT && Message == NULL) { // try to get the last or default message, depending on current settings
COptPage MsgTreeData(g_MsgTreePage);
COptItem_TreeCtrl *TreeCtrl = (COptItem_TreeCtrl*)MsgTreeData.Find(IDV_MSGTREE);
TreeCtrl->DBToMem(CString(MOD_NAME));
Message = NULL;
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_USELASTMSG)) // if using last message by default...
- {
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_USELASTMSG)) { // if using last message by default...
Message = db_get_s(NULL, MOD_NAME, ProtoStatusToDBSetting(DB_STATUSMSG, IDC_MOREOPTDLG_PERSTATUSPROTOMSGS), (TCHAR*)NULL); // try per-protocol message first
- if (Message.IsEmpty())
- {
+ if (Message.IsEmpty()) {
Message = NULL; // to be sure it's NULL, not "" - as we're checking 'Message == NULL' later
int RecentGroupID = GetRecentGroupID(Status);
- if (RecentGroupID != -1)
- {
- int I;
- for (I = 0; I < TreeCtrl->Value.GetSize(); I++) // find first message in the group
- {
- if (TreeCtrl->Value[I].ParentID == RecentGroupID && !(TreeCtrl->Value[I].Flags & TIF_GROUP))
- {
- Message = TreeCtrl->Value[I].User_Str1;
+ if (RecentGroupID != -1) {
+ for (int i = 0; i < TreeCtrl->Value.GetSize(); i++) { // find first message in the group
+ if (TreeCtrl->Value[i].ParentID == RecentGroupID && !(TreeCtrl->Value[i].Flags & TIF_GROUP)) {
+ Message = TreeCtrl->Value[i].User_Str1;
if (pOrder)
- {
- *pOrder = I;
- }
+ *pOrder = i;
break;
}
}
}
}
} // else, if using default message by default...
- if (Message == NULL) // ...or we didn't succeed retrieving the last message
- { // get default message for this status
+
+ if (Message == NULL) { // ...or we didn't succeed retrieving the last message
+ // get default message for this status
int DefMsgID = -1;
static struct {
int DBSetting, Status;
- } DefMsgDlgItems[] = {
+ }
+ DefMsgDlgItems[] = {
IDS_MESSAGEDLG_DEF_ONL, ID_STATUS_ONLINE,
IDS_MESSAGEDLG_DEF_AWAY, ID_STATUS_AWAY,
IDS_MESSAGEDLG_DEF_NA, ID_STATUS_NA,
@@ -379,33 +313,25 @@ TCString CProtoSettings::GetMsgFormat(int Flags, int *pOrder) IDS_MESSAGEDLG_DEF_OTP, ID_STATUS_ONTHEPHONE,
IDS_MESSAGEDLG_DEF_OTL, ID_STATUS_OUTTOLUNCH
};
- int I;
- for (I = 0; I < lengthof(DefMsgDlgItems); I++)
- {
- if (DefMsgDlgItems[I].Status == Status)
- {
- DefMsgID = MsgTreeData.GetDBValue(DefMsgDlgItems[I].DBSetting);
+
+ for (int i = 0; i < SIZEOF(DefMsgDlgItems); i++) {
+ if (DefMsgDlgItems[i].Status == Status) {
+ DefMsgID = MsgTreeData.GetDBValue(DefMsgDlgItems[i].DBSetting);
break;
}
}
if (DefMsgID == -1)
- {
DefMsgID = MsgTreeData.GetDBValue(IDS_MESSAGEDLG_DEF_AWAY); // use away message for unknown statuses
- }
+
int Order = TreeCtrl->IDToOrder(DefMsgID); // this will return -1 in any case if something goes wrong
if (Order >= 0)
- {
Message = TreeCtrl->Value[Order].User_Str1;
- }
+
if (pOrder)
- {
*pOrder = Order;
- }
}
if (Message == NULL)
- {
Message = _T(""); // last or default message can't be NULL.. otherwise ICQ won't reply to status message requests and won't notify us of status message requests at all
- }
}
return Message;
}
diff --git a/plugins/NewAwaySysMod/src/Properties.h b/plugins/NewAwaySysMod/src/Properties.h index b484f4c2d1..0dd66b56d9 100644 --- a/plugins/NewAwaySysMod/src/Properties.h +++ b/plugins/NewAwaySysMod/src/Properties.h @@ -115,12 +115,12 @@ class CIconList public:
~CIconList()
{
- int I;
- for (I = 0; I < IconList.GetSize(); I++)
+ int i;
+ for (i = 0; i < IconList.GetSize(); i++)
{
- if (IconList[I])
+ if (IconList[i])
{
- DestroyIcon(IconList[I]);
+ DestroyIcon(IconList[i]);
}
}
}
@@ -130,22 +130,22 @@ public: {
int cxIcon = GetSystemMetrics(SM_CXSMICON);
int cyIcon = GetSystemMetrics(SM_CYSMICON);
- int I;
- for (I = 0; I < lengthof(Icons); I++)
+ int i;
+ for (i = 0; i < SIZEOF(Icons); i++)
{
- if (IconList.GetSize() > I && IconList[I])
+ if (IconList.GetSize() > i && IconList[i])
{
- DestroyIcon(IconList[I]);
+ DestroyIcon(IconList[i]);
}
- if (Icons[I] & IL_SKINICON)
+ 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)
+ IconList.SetAtGrow(i) = (HICON)CopyImage(LoadSkinnedIcon(Icons[i] & ~IL_SKINICON), IMAGE_ICON, cxIcon, cyIcon, LR_COPYFROMRESOURCE);
+ } else if (Icons[i] & IL_PROTOICON)
{
- IconList.SetAtGrow(I) = (HICON)CopyImage(LoadSkinnedProtoIcon(NULL, Icons[I] & ~IL_PROTOICON), IMAGE_ICON, cxIcon, cyIcon, LR_COPYFROMRESOURCE);
+ IconList.SetAtGrow(i) = (HICON)CopyImage(LoadSkinnedProtoIcon(NULL, Icons[i] & ~IL_PROTOICON), IMAGE_ICON, cxIcon, cyIcon, LR_COPYFROMRESOURCE);
} else
{
- IconList.SetAtGrow(I) = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(Icons[I]), IMAGE_ICON, cxIcon, cyIcon, 0);
+ IconList.SetAtGrow(i) = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(Icons[i]), IMAGE_ICON, cxIcon, cyIcon, 0);
}
}
}
@@ -199,7 +199,7 @@ public: CurStatusMsg = Msg;
SYSTEMTIME st;
GetLocalTime(&st);
- SystemTimeToFileTime(&st, (LPFILETIME)&LastUpdateTime); // I'm too lazy to declare FILETIME structure and then copy its data to absolutely equivalent ULARGE_INTEGER structure, so we'll just pass a pointer to the ULARGE_INTEGER directly ;-P
+ SystemTimeToFileTime(&st, (LPFILETIME)&LastUpdateTime); // i'm too lazy to declare FILETIME structure and then copy its data to absolutely equivalent ULARGE_INTEGER structure, so we'll just pass a pointer to the ULARGE_INTEGER directly ;-P
return *this;
}
operator TCString() {return CurStatusMsg;}
@@ -260,22 +260,22 @@ public: CProtoStates& operator = (const CProtoStates& States)
{
ProtoStates = States.ProtoStates;
- int I;
- for (I = 0; I < ProtoStates.GetSize(); I++)
+ int i;
+ for (i = 0; i < ProtoStates.GetSize(); i++)
{
- ProtoStates[I].SetParent(this);
+ ProtoStates[i].SetParent(this);
}
return *this;
}
CProtoState& operator[](const char *szProto)
{
- int I;
- for (I = 0; I < ProtoStates.GetSize(); I++)
+ int i;
+ for (i = 0; i < ProtoStates.GetSize(); i++)
{
- if (ProtoStates[I].GetProto() == szProto)
+ if (ProtoStates[i].GetProto() == szProto)
{
- return ProtoStates[I];
+ 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.
@@ -283,12 +283,12 @@ public: int ProtoCount;
PROTOCOLDESCRIPTOR **proto;
CallService(MS_PROTO_ENUMACCOUNTS, (WPARAM)&ProtoCount, (LPARAM)&proto);
- int I;
- for (I = 0; I < ProtoCount; I++)
+ int i;
+ for (i = 0; i < ProtoCount; i++)
{
- if (proto[I]->type == PROTOTYPE_PROTOCOL)
+ if (proto[i]->type == PROTOTYPE_PROTOCOL)
{
- (*this)[proto[I]->szName]; // add a protocol if it isn't in the list yet
+ (*this)[proto[i]->szName]; // add a protocol if it isn't in the list yet
}
}
}
@@ -340,12 +340,12 @@ public: {
if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID))
{
- int I;
- for (I = 0; I < lengthof(StatusSettings); I++)
+ int i;
+ for (i = 0; i < SIZEOF(StatusSettings); i++)
{
- if (Status == StatusSettings[I].Status)
+ if (Status == StatusSettings[i].Status)
{
- return szProto ? (CString(Prefix) + "_" + szProto + "_" + StatusSettings[I].Setting) : (CString(Prefix) + StatusSettings[I].Setting);
+ return szProto ? (CString(Prefix) + "_" + szProto + "_" + StatusSettings[i].Setting) : (CString(Prefix) + StatusSettings[i].Setting);
}
}
}
@@ -419,12 +419,12 @@ __inline CString StatusToDBSetting(int Status, const char *Prefix, int MoreOpt_P {
if (!MoreOpt_PerStatusID || g_MoreOptPage.GetDBValueCopy(MoreOpt_PerStatusID))
{
- int I;
- for (I = 0; I < lengthof(StatusSettings); I++)
+ int i;
+ for (i = 0; i < SIZEOF(StatusSettings); i++)
{
- if (Status == StatusSettings[I].Status)
+ if (Status == StatusSettings[i].Status)
{
- return CString(Prefix) + StatusSettings[I].Setting;
+ return CString(Prefix) + StatusSettings[i].Setting;
}
}
}
diff --git a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp index 2464c38f4c..1ce86f628b 100644 --- a/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/ReadAwayMsg.cpp @@ -25,35 +25,27 @@ HANDLE g_hReadWndList = NULL;
-
static int ReadAwayMsgDlgResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
{
- switch (urc->wId)
- {
- case IDC_READAWAYMSG_MSG:
- {
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- }
- case IDC_READAWAYMSG_RETRIEVE:
- {
- return RD_ANCHORX_CENTRE | RD_ANCHORY_CENTRE;
- }
- case IDOK:
- {
- return RD_ANCHORX_CENTRE | RD_ANCHORY_BOTTOM;
- }
+ switch (urc->wId) {
+ case IDC_READAWAYMSG_MSG:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDC_READAWAYMSG_RETRIEVE:
+ return RD_ANCHORX_CENTRE | RD_ANCHORY_CENTRE;
+
+ case IDOK:
+ return RD_ANCHORX_CENTRE | RD_ANCHORY_BOTTOM;
}
return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
}
-
static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
HICON hTitleIcon = LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hTitleIcon);
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hTitleIcon);
@@ -70,26 +62,25 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam contactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)awayData->hContact, GCDNF_TCHAR);
char *szProto = GetContactProto(awayData->hContact);
status = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, db_get_w(awayData->hContact, szProto, "Status", ID_STATUS_OFFLINE), GSMDF_TCHAR);
- GetWindowText(hwndDlg, format, lengthof(format));
- _sntprintf(str, lengthof(str), format, status, contactName);
+ GetWindowText(hwndDlg, format, SIZEOF(format));
+ _sntprintf(str, SIZEOF(str), format, status, contactName);
SetWindowText(hwndDlg, str);
GetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, format, sizeof(format));
- _sntprintf(str, lengthof(str), format, status);
+ _sntprintf(str, SIZEOF(str), format, status);
SetDlgItemText(hwndDlg, IDC_READAWAYMSG_RETRIEVE, str);
- return true;
- } break;
- case UM_RAM_AWAYMSGACK: // got away msg
+ }
+ return true;
+
+ case UM_RAM_AWAYMSGACK: // got away msg
{
ACKDATA *ack = (ACKDATA*)lParam;
READAWAYMSGDATA *awayData = (READAWAYMSGDATA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
// make sure everything is ok, and this is our ack
if (ack->hContact != awayData->hContact || ack->type != ACKTYPE_AWAYMSG || ack->hProcess != awayData->hSeq || ack->result != ACKRESULT_SUCCESS)
- {
break;
- }
+
// done with the event
- if (awayData->hAwayMsgEvent)
- {
+ if (awayData->hAwayMsgEvent) {
UnhookEvent(awayData->hAwayMsgEvent);
awayData->hAwayMsgEvent = NULL;
}
@@ -98,56 +89,49 @@ static INT_PTR CALLBACK ReadAwayMsgDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam ShowWindow(GetDlgItem(hwndDlg, IDC_READAWAYMSG_MSG), SW_SHOW);
SetDlgItemText(hwndDlg, IDOK, TranslateT("&Close"));
db_set_s(awayData->hContact, "CList", "StatusMsg", (const char*)ack->lParam);
- } break;
- case WM_COMMAND:
- {
- switch (HIWORD(wParam))
- {
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDCANCEL:
- case IDOK:
- {
- DestroyWindow(hwndDlg);
- } break;
- }
- } break;
+ }
+ break;
+
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ case IDOK:
+ DestroyWindow(hwndDlg);
+ break;
}
- } break;
- case WM_SIZE:
+ }
+ break;
+
+ case WM_SIZE:
{
- UTILRESIZEDIALOG urd = {0};
- urd.cbSize = sizeof(urd);
+ UTILRESIZEDIALOG urd = { sizeof(urd) };
urd.hInstance = g_hInstance;
urd.hwndDlg = hwndDlg;
urd.lpTemplate = MAKEINTRESOURCEA(IDD_READAWAYMSG);
urd.pfnResizer = ReadAwayMsgDlgResize;
CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd);
- break;
}
- case WM_CLOSE:
- {
- DestroyWindow(hwndDlg);
- } break;
- case WM_DESTROY:
- {
- READAWAYMSGDATA *awayData = (READAWAYMSGDATA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (awayData->hAwayMsgEvent)
- {
- UnhookEvent(awayData->hAwayMsgEvent);
- awayData->hAwayMsgEvent = NULL;
- }
- delete awayData;
- Utils_SaveWindowPosition(hwndDlg, NULL, MOD_NAME, RAMDLGSIZESETTING);
- WindowList_Remove(g_hReadWndList, hwndDlg);
- } break;
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_DESTROY:
+ READAWAYMSGDATA *awayData = (READAWAYMSGDATA*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (awayData->hAwayMsgEvent) {
+ UnhookEvent(awayData->hAwayMsgEvent);
+ awayData->hAwayMsgEvent = NULL;
+ }
+ delete awayData;
+ Utils_SaveWindowPosition(hwndDlg, NULL, MOD_NAME, RAMDLGSIZESETTING);
+ WindowList_Remove(g_hReadWndList, hwndDlg);
}
return false;
}
-
INT_PTR GetContactStatMsg(WPARAM wParam, LPARAM lParam)
{
if (HWND hWnd = WindowList_Find(g_hReadWndList, wParam)) // already have it
diff --git a/plugins/NewAwaySysMod/src/Services.cpp b/plugins/NewAwaySysMod/src/Services.cpp index 392d318222..44aa93e633 100644 --- a/plugins/NewAwaySysMod/src/Services.cpp +++ b/plugins/NewAwaySysMod/src/Services.cpp @@ -22,39 +22,24 @@ #include "Properties.h"
#include "m_NewAwaySys.h"
-
-typedef struct {
+struct NAS_PROTOINFOv1
+{
int cbSize;
char *szProto;
- union
- {
+ union {
char *szMsg;
WCHAR *wszMsg;
TCHAR *tszMsg;
};
WORD status;
-} NAS_PROTOINFOv1;
-
+};
__inline void PSSetStatus(char *szProto, WORD Status, int bNoClistSetStatusMode = false) // just a helper function that sets the status and handles szProto==NULL correctly
{
g_ProtoStates[szProto].Status = Status;
if (szProto)
- {
CallProtoService(szProto, PS_SETSTATUS, Status, 0);
- } else if (!bNoClistSetStatusMode) // global 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_SETSTATUS, Status, 0);
- }
- }*/
+ else if (!bNoClistSetStatusMode) { // global status
g_fNoProcessing = true;
CallService(MS_CLIST_SETSTATUSMODE, Status, 0);
_ASSERT(!g_fNoProcessing && g_ProtoStates[(char*)NULL].Status == Status);
@@ -62,19 +47,17 @@ __inline void PSSetStatus(char *szProto, WORD Status, int bNoClistSetStatusMode }
}
-
-INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam) // called by GamerStatus and built-in miranda autoaway module
+// called by GamerStatus and built-in miranda autoaway module
// wParam = (int)status, lParam = 0
// MS_AWAYMSG_GETSTATUSMSG "SRAway/GetStatusMessage"
+INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam)
{
LogMessage("MS_AWAYMSG_GETSTATUSMSG called. status=%d", wParam);
CString Msg(_T2A(GetDynamicStatMsg(INVALID_CONTACT_ID, NULL, 0, wParam)));
char *szMsg;
- if (Msg == NULL)
- { // it's ok to return NULL, so we'll do it
+ if (Msg == NULL) // it's ok to return NULL, so we'll do it
szMsg = NULL;
- } else
- {
+ else {
szMsg = (char*)mir_alloc(Msg.GetLen() + 1);
lstrcpyA(szMsg, Msg);
}
@@ -82,17 +65,14 @@ INT_PTR GetStatusMsg(WPARAM wParam, LPARAM lParam) // called by GamerStatus and return (int)szMsg;
}
-
-INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam) // called by GamerStatus and StatCtrl
-{
// wParam = int iMode
// lParam = char* szMsg, may be null - then we need to use the default message
-/* if (CallService(MS_CLIST_GETSTATUSMODE, 0, 0) != wParam) // not same status
- {*/ // try this way; global status may be not the same as current status of some separate protocol
+INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam) // called by GamerStatus and StatCtrl
+{
LogMessage("MS_AWAYSYS_SETSTATUSMODE called. status=%d, szMsg:\n%s", wParam, lParam ? (char*)lParam : "NULL");
g_fNoProcessing = true;
CallService(MS_CLIST_SETSTATUSMODE, wParam, 0);
-// }
+
_ASSERT(!g_fNoProcessing && g_ProtoStates[(char*)NULL].Status == wParam);
g_fNoProcessing = false;
CProtoSettings(NULL, wParam).SetMsgFormat(SMF_TEMPORARY, lParam ? (TCHAR*)_A2T((char*)lParam) : CProtoSettings(NULL, wParam).GetMsgFormat(GMF_LASTORDEFAULT));
@@ -100,26 +80,22 @@ INT_PTR SetStatusMode(WPARAM wParam, LPARAM lParam) // called by GamerStatus and return 0;
}
-
-int GetState(WPARAM wParam, LPARAM lParam, int Widechar)
// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items to be filled.
// lParam = (LPARAM)(int)protoCount - number of items in pi.
// returns 0 on success
+int GetState(WPARAM wParam, LPARAM lParam, int Widechar)
{
NAS_PROTOINFO *pi = (NAS_PROTOINFO*)wParam;
LogMessage("MS_NAS_GETSTATE called with %d items and Widechar=%d:", lParam, Widechar);
- for (int i = 0; i < lParam; i++)
- {
+ for (int i = 0; i < lParam; i++) {
if (pi->cbSize < sizeof(NAS_PROTOINFO) && pi->cbSize != sizeof(NAS_PROTOINFOv1))
return 1;
int Flags = (pi->cbSize > sizeof(NAS_PROTOINFOv1)) ? pi->Flags : 0;
LogMessage("%d (received): cbSize=%d, status=%d, szProto=%s, Flags=0x%x", i + 1, pi->cbSize, pi->status, pi->szProto ? pi->szProto : "NULL", Flags);
- if ((pi->status >= ID_STATUS_ONLINE && pi->status <= ID_STATUS_OUTTOLUNCH) || !pi->status)
- {
+ if ((pi->status >= ID_STATUS_ONLINE && pi->status <= ID_STATUS_OUTTOLUNCH) || !pi->status) {
TCString Msg(pi->status ? CProtoSettings(pi->szProto, pi->status).GetMsgFormat(GMF_LASTORDEFAULT) : CProtoSettings(pi->szProto).GetMsgFormat(((Flags & PIF_NOTTEMPORARY) ? 0 : GMF_TEMPORARY) | GMF_PERSONAL));
- if (Msg != NULL)
- {
+ if (Msg != NULL) {
pi->szMsg = (char*)mir_alloc(Msg.GetLen() + 1);
_ASSERT(pi->szMsg);
if (Widechar)
@@ -140,28 +116,24 @@ int GetState(WPARAM wParam, LPARAM lParam, int Widechar) return 0;
}
-
INT_PTR GetStateA(WPARAM wParam, LPARAM lParam)
{
return GetState(wParam, lParam, false);
}
-
INT_PTR GetStateW(WPARAM wParam, LPARAM lParam)
{
return GetState(wParam, lParam, true);
}
-
-int SetState(WPARAM wParam, LPARAM lParam, int Widechar)
// wParam = (WPARAM)(NAS_PROTOINFO*)pi - pointer to an array of NAS_PROTOINFO items.
// lParam = (LPARAM)(int)protoCount - number of items in pi.
// returns 0 on success
+int SetState(WPARAM wParam, LPARAM lParam, int Widechar)
{
NAS_PROTOINFO *pi = (NAS_PROTOINFO*)wParam;
LogMessage("MS_NAS_SETSTATE called with %d items and Widechar=%d:", lParam, Widechar);
- for (int i = 0; i < lParam; i++)
- {
+ for (int i = 0; i < lParam; i++) {
_ASSERT(pi->szMsg != (char*)(-1));
if (pi->cbSize < sizeof(NAS_PROTOINFO) && pi->cbSize != sizeof(NAS_PROTOINFOv1))
return 1;
@@ -184,37 +156,31 @@ int SetState(WPARAM wParam, LPARAM lParam, int Widechar) return 0;
}
-
INT_PTR SetStateA(WPARAM wParam, LPARAM lParam)
{
return SetState(wParam, lParam, false);
}
-
INT_PTR SetStateW(WPARAM wParam, LPARAM lParam)
{
return SetState(wParam, lParam, true);
}
-
-INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM lParam)
// wParam = (WPARAM)(NAS_ISWINFO*)iswi - pointer to a NAS_ISWINFO structure.
// lParam = 0
// returns HWND of the window on success, or NULL on failure.
+INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM lParam)
{
NAS_ISWINFO *iswi = (NAS_ISWINFO*)wParam;
if (iswi->cbSize != sizeof(NAS_ISWINFOv1) && iswi->cbSize < sizeof(NAS_ISWINFO))
- {
return NULL;
- }
+
LogMessage("MS_NAS_INVOKESTATUSWINDOW called. cbSize=%d, status=%d, szProto=%s, hContact=0x%08x, Flags=0x%x, szMsg:\n%s", iswi->cbSize, iswi->status, iswi->szProto ? iswi->szProto : "NULL", iswi->hContact, (iswi->cbSize < sizeof(NAS_ISWINFO)) ? 0 : iswi->Flags, iswi->szMsg ? ((iswi->Flags & ISWF_UNICODE) ? _T2A(iswi->wszMsg) : iswi->szMsg) : "NULL");
if (iswi->status)
- {
PSSetStatus(iswi->szProto, iswi->status);
- }
- if (g_SetAwayMsgPage.GetWnd()) // already setting something
- {
- SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
+
+ if (g_SetAwayMsgPage.GetWnd()) { // already setting something
+ SetForegroundWindow(g_SetAwayMsgPage.GetWnd());
return (int)g_SetAwayMsgPage.GetWnd();
}
SetAwayMsgData *dat = new SetAwayMsgData;
@@ -224,8 +190,6 @@ INT_PTR InvokeStatusWindow(WPARAM wParam, LPARAM lParam) dat->Message = (iswi->Flags & ISWF_UNICODE) ? iswi->wszMsg : _A2T(iswi->szMsg);
dat->IsModeless = true;
if (iswi->cbSize > sizeof(NAS_ISWINFOv1))
- {
dat->ISW_Flags = iswi->Flags;
- }
return (int)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_SETAWAYMSG), NULL, SetAwayMsgDlgProc, (LPARAM)dat);
}
diff --git a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp index 9b918be898..f934d45022 100644 --- a/plugins/NewAwaySysMod/src/SetAwayMsg.cpp +++ b/plugins/NewAwaySysMod/src/SetAwayMsg.cpp @@ -55,53 +55,44 @@ static int g_MsgSplitterX, g_ContactSplitterX; static int MinMsgSplitterX, MinContactSplitterX;
static int MinMsgEditSize; // used to calculate minimal X size of the dialog
-
-
static LRESULT CALLBACK MsgEditSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- switch (Msg)
- {
- case WM_CHAR:
- {
- if (GetKeyState(VK_CONTROL) & 0x8000)
- {
- if (wParam == '\n')
- { // ctrl-enter
- PostMessage(GetParent(hWnd), WM_COMMAND, IDC_OK, 0);
- return 0;
- }
- if (wParam == 1)
- { // ctrl-a
- SendMessage(hWnd, EM_SETSEL, 0, -1);
- return 0;
- }
- if (wParam == 23)
- { // ctrl-w
- SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
- return 0;
- }
- if (wParam == 127)
- { // ctrl-backspace
- DWORD start, end;
- SendMessage(hWnd, EM_GETSEL, (WPARAM)&end, NULL);
- SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0);
- SendMessage(hWnd, EM_GETSEL, (WPARAM)&start, NULL);
- int nLen = GetWindowTextLength(hWnd);
- TCHAR *text = (TCHAR*)malloc((nLen + 1) * sizeof(TCHAR));
- GetWindowText(hWnd, text, nLen + 1);
- MoveMemory(text + start, text + end, sizeof(TCHAR) * (_tcslen(text) + 1 - end));
- SetWindowText(hWnd, text);
- free(text);
- SendMessage(hWnd, EM_SETSEL, start, start);
- SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), EN_CHANGE), (LPARAM)hWnd);
- return 0;
- }
+ switch (Msg) {
+ case WM_CHAR:
+ if (GetKeyState(VK_CONTROL) & 0x8000) {
+ if (wParam == '\n') { // ctrl-enter
+ PostMessage(GetParent(hWnd), WM_COMMAND, IDC_OK, 0);
+ return 0;
}
- } break;
- case WM_KEYDOWN:
- {
- SendMessage(GetParent(hWnd), UM_SAM_KILLTIMER, 0, 0);
- } break;
+ if (wParam == 1) { // ctrl-a
+ SendMessage(hWnd, EM_SETSEL, 0, -1);
+ return 0;
+ }
+ if (wParam == 23) { // ctrl-w
+ SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
+ return 0;
+ }
+ if (wParam == 127) { // ctrl-backspace
+ DWORD start, end;
+ SendMessage(hWnd, EM_GETSEL, (WPARAM)&end, NULL);
+ SendMessage(hWnd, WM_KEYDOWN, VK_LEFT, 0);
+ SendMessage(hWnd, EM_GETSEL, (WPARAM)&start, NULL);
+ int nLen = GetWindowTextLength(hWnd);
+ TCHAR *text = (TCHAR*)malloc((nLen + 1) * sizeof(TCHAR));
+ GetWindowText(hWnd, text, nLen + 1);
+ MoveMemory(text + start, text + end, sizeof(TCHAR)* (_tcslen(text) + 1 - end));
+ SetWindowText(hWnd, text);
+ free(text);
+ SendMessage(hWnd, EM_SETSEL, start, start);
+ SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), EN_CHANGE), (LPARAM)hWnd);
+ return 0;
+ }
+ }
+ break;
+
+ case WM_KEYDOWN:
+ SendMessage(GetParent(hWnd), UM_SAM_KILLTIMER, 0, 0);
+ break;
}
return CallWindowProc(g_OrigEditMsgProc, hWnd, Msg, wParam, lParam);
}
@@ -109,37 +100,29 @@ static LRESULT CALLBACK MsgEditSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, // used splitter code from TabSRMM as a base
static LRESULT CALLBACK SplitterSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
- switch (Msg)
- {
- case WM_NCHITTEST:
- {
- return HTCLIENT;
- }
- case WM_SETCURSOR:
- {
- SetCursor(LoadCursor(NULL, IDC_SIZEWE));
- return true;
- }
- case WM_LBUTTONDOWN:
- {
- SetCapture(hWnd);
- return false;
- }
- case WM_MOUSEMOVE:
- {
- if (GetCapture() == hWnd)
- {
- RECT rc;
- GetClientRect(hWnd, &rc);
- SendMessage(GetParent(hWnd), UM_SAM_SPLITTERMOVED, (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)GetDlgCtrlID(hWnd));
- }
- return 0;
- }
- case WM_LBUTTONUP:
- {
- ReleaseCapture();
- return false;
+ switch (Msg) {
+ case WM_NCHITTEST:
+ return HTCLIENT;
+
+ case WM_SETCURSOR:
+ SetCursor(LoadCursor(NULL, IDC_SIZEWE));
+ return true;
+
+ case WM_LBUTTONDOWN:
+ SetCapture(hWnd);
+ return false;
+
+ case WM_MOUSEMOVE:
+ if (GetCapture() == hWnd) {
+ RECT rc;
+ GetClientRect(hWnd, &rc);
+ SendMessage(GetParent(hWnd), UM_SAM_SPLITTERMOVED, (short)LOWORD(GetMessagePos()) + rc.right / 2, (LPARAM)GetDlgCtrlID(hWnd));
}
+ return 0;
+
+ case WM_LBUTTONUP:
+ ReleaseCapture();
+ return false;
}
return CallWindowProc(g_OrigSplitterProc, hWnd, Msg, wParam, lParam);
}
@@ -147,125 +130,102 @@ static LRESULT CALLBACK SplitterSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, static LRESULT CALLBACK CListSubclassProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
CCList *dat = CWndUserData(GetParent(hWnd)).GetCList();
- switch (Msg)
- {
- case WM_MOUSEMOVE:
+ switch (Msg) {
+ case WM_MOUSEMOVE:
{
DWORD hitFlags;
- POINT pt = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
+ POINT pt = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
if (dat->HitTest(&pt, &hitFlags) && hitFlags & MCLCHT_ONITEMEXTRA)
- {
lParam = 0; // reset mouse coordinates, so TreeView's wndproc will not draw any item in a hovered state
- }
- } break;
- case WM_LBUTTONDOWN:
- case WM_LBUTTONDBLCLK:
- {
- DWORD hitFlags;
- POINT pt = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
- if (dat->HitTest(&pt, &hitFlags) && hitFlags & MCLCHT_ONITEMEXTRA)
- {
- SetFocus(hWnd);
- NMHDR nmhdr;
- nmhdr.code = NM_CLICK;
- nmhdr.hwndFrom = hWnd;
- nmhdr.idFrom = GetDlgCtrlID(hWnd);
- SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
- return DefWindowProc(hWnd, Msg, wParam, lParam);
- }
- } break;
+ }
+ break;
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ DWORD hitFlags;
+ POINT pt = { (short)LOWORD(lParam), (short)HIWORD(lParam) };
+ if (dat->HitTest(&pt, &hitFlags) && hitFlags & MCLCHT_ONITEMEXTRA) {
+ SetFocus(hWnd);
+ NMHDR nmhdr;
+ nmhdr.code = NM_CLICK;
+ nmhdr.hwndFrom = hWnd;
+ nmhdr.idFrom = GetDlgCtrlID(hWnd);
+ SendMessage(GetParent(hWnd), WM_NOTIFY, 0, (LPARAM)&nmhdr);
+ return DefWindowProc(hWnd, Msg, wParam, lParam);
+ }
}
return CallWindowProc(g_OrigCListProc, hWnd, Msg, wParam, lParam);
}
-
static int SetAwayMsgDlgResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL *urc)
{
COptPage *SetAwayMsgPage = (COptPage*)lParam;
- int bShowMsgTree = SetAwayMsgPage->GetValue(IDS_SAWAYMSG_SHOWMSGTREE);
+ int bShowMsgTree = SetAwayMsgPage->GetValue(IDS_SAWAYMSG_SHOWMSGTREE), X;
int bShowContactTree = SetAwayMsgPage->GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE);
- switch (urc->wId)
- {
- case IDC_SAWAYMSG_MSGDATA:
- {
- urc->rcItem.right = urc->dlgOriginalSize.cx - 2;
- if (bShowContactTree)
- {
- urc->rcItem.right -= g_ContactSplitterX;
- }
- urc->rcItem.left = (bShowMsgTree) ? (g_MsgSplitterX + 2) : 2;
- return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
- }
- case IDC_SAWAYMSG_TREE:
- {
- urc->rcItem.right = g_MsgSplitterX - 2;
- return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
- }
- case IDC_SAWAYMSG_CONTACTSTREE:
- {
- urc->rcItem.left = urc->dlgOriginalSize.cx - g_ContactSplitterX + 2;
- return RD_ANCHORX_RIGHT | RD_ANCHORY_HEIGHT;
- }
- case IDC_OK:
- {
- int X = bShowMsgTree ? min(max(g_MsgSplitterX, MinMsgSplitterX), urc->dlgNewSize.cx - ((bShowContactTree ? MinContactSplitterX : 0) + MinMsgEditSize)) : 0;
- OffsetRect(&urc->rcItem, X + 2 - urc->rcItem.left, 0);
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- }
- case IDC_SAWAYMSG_EDITMSGS:
- case IDC_SAWAYMSG_SAVEMSG:
- case IDC_SAWAYMSG_SAVEASNEW:
- case IDC_SAWAYMSG_NEWCATEGORY:
- case IDC_SAWAYMSG_DELETE:
- {
- return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
- }
- case IDC_SAWAYMSG_VARS:
- case IDC_SAWAYMSG_OPTIONS:
- {
- int X = bShowContactTree ? max(min(g_ContactSplitterX, urc->dlgNewSize.cx - (bShowMsgTree ? max(g_MsgSplitterX, MinMsgSplitterX) : 0) - MinMsgEditSize), MinContactSplitterX) : 0;
- OffsetRect(&urc->rcItem, urc->dlgOriginalSize.cx - X - 2 - urc->rcItem.right - ((urc->wId == IDC_SAWAYMSG_VARS) ? g_VariablesButtonDX : 0), 0);
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
- }
- case IDC_SAWAYMSG_STATIC_IGNOREICON:
- case IDC_SAWAYMSG_STATIC_REPLYICON:
- {
- urc->rcItem.left = urc->rcItem.right - 16;
- urc->rcItem.top = urc->rcItem.bottom - 16;
- } // go through
- case IDC_SAWAYMSG_IGNOREREQ:
- case IDC_SAWAYMSG_SENDMSG:
- {
- return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
- }
- case IDC_SAWAYMSG_MSGSPLITTER:
- {
- OffsetRect(&urc->rcItem, g_MsgSplitterX - (urc->rcItem.left + ++urc->rcItem.right) / 2, 0);
- return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
- }
- case IDC_SAWAYMSG_CONTACTSPLITTER:
- {
- OffsetRect(&urc->rcItem, urc->dlgOriginalSize.cx - g_ContactSplitterX - (urc->rcItem.left + urc->rcItem.right) / 2, 0);
- return RD_ANCHORX_RIGHT | RD_ANCHORY_HEIGHT;
- }
+ switch (urc->wId) {
+ case IDC_SAWAYMSG_MSGDATA:
+ urc->rcItem.right = urc->dlgOriginalSize.cx - 2;
+ if (bShowContactTree)
+ urc->rcItem.right -= g_ContactSplitterX;
+ urc->rcItem.left = (bShowMsgTree) ? (g_MsgSplitterX + 2) : 2;
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+
+ case IDC_SAWAYMSG_TREE:
+ urc->rcItem.right = g_MsgSplitterX - 2;
+ return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
+
+ case IDC_SAWAYMSG_CONTACTSTREE:
+ urc->rcItem.left = urc->dlgOriginalSize.cx - g_ContactSplitterX + 2;
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_HEIGHT;
+
+ case IDC_OK:
+ X = bShowMsgTree ? min(max(g_MsgSplitterX, MinMsgSplitterX), urc->dlgNewSize.cx - ((bShowContactTree ? MinContactSplitterX : 0) + MinMsgEditSize)) : 0;
+ OffsetRect(&urc->rcItem, X + 2 - urc->rcItem.left, 0);
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+
+ case IDC_SAWAYMSG_EDITMSGS:
+ case IDC_SAWAYMSG_SAVEMSG:
+ case IDC_SAWAYMSG_SAVEASNEW:
+ case IDC_SAWAYMSG_NEWCATEGORY:
+ case IDC_SAWAYMSG_DELETE:
+ return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
+
+ case IDC_SAWAYMSG_VARS:
+ case IDC_SAWAYMSG_OPTIONS:
+ X = bShowContactTree ? max(min(g_ContactSplitterX, urc->dlgNewSize.cx - (bShowMsgTree ? max(g_MsgSplitterX, MinMsgSplitterX) : 0) - MinMsgEditSize), MinContactSplitterX) : 0;
+ OffsetRect(&urc->rcItem, urc->dlgOriginalSize.cx - X - 2 - urc->rcItem.right - ((urc->wId == IDC_SAWAYMSG_VARS) ? g_VariablesButtonDX : 0), 0);
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_SAWAYMSG_STATIC_IGNOREICON:
+ case IDC_SAWAYMSG_STATIC_REPLYICON:
+ urc->rcItem.left = urc->rcItem.right - 16;
+ urc->rcItem.top = urc->rcItem.bottom - 16;
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_SAWAYMSG_IGNOREREQ:
+ case IDC_SAWAYMSG_SENDMSG:
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_BOTTOM;
+
+ case IDC_SAWAYMSG_MSGSPLITTER:
+ OffsetRect(&urc->rcItem, g_MsgSplitterX - (urc->rcItem.left + ++urc->rcItem.right) / 2, 0);
+ return RD_ANCHORX_LEFT | RD_ANCHORY_HEIGHT;
+
+ case IDC_SAWAYMSG_CONTACTSPLITTER:
+ OffsetRect(&urc->rcItem, urc->dlgOriginalSize.cx - g_ContactSplitterX - (urc->rcItem.left + urc->rcItem.right) / 2, 0);
+ return RD_ANCHORX_RIGHT | RD_ANCHORY_HEIGHT;
}
-
return RD_ANCHORX_LEFT | RD_ANCHORY_BOTTOM;
}
-
__inline int DBValueToReplyIcon(int Value)
{
- switch (Value)
- {
+ switch (Value) {
case VAL_USEDEFAULT: return EXTRAIMGLIST_DOT;
case 0: return EXTRAIMGLIST_AUTOREPLY_OFF;
default: return EXTRAIMGLIST_AUTOREPLY_ON;
}
}
-
int GetRealReplyIcon(CCList *CList, HTREEITEM hItem)
{
_ASSERT(CList);
@@ -281,86 +241,63 @@ void SetExtraIcon(CCList *CList, int nColumn, HTREEITEM hItem, int nIcon) _ASSERT(CList);
int ItemType = CList->GetItemType(hItem);
MCONTACT hContact = CList->GethContact(hItem);
- if (ItemType == MCLCIT_CONTACT)
- {
- if (nIcon == -1) // means we need to retrieve it from the db by ourselves
- {
+ if (ItemType == MCLCIT_CONTACT) {
+ if (nIcon == -1) { // means we need to retrieve it from the db by ourselves
if (nColumn == EXTRACOLUMN_IGNORE)
- {
nIcon = CContactSettings(0, hContact).Ignore ? EXTRAIMGLIST_IGNORE : EXTRAIMGLIST_DOT;
- } else
- {
+ else {
_ASSERT(nColumn == EXTRACOLUMN_REPLY);
nIcon = DBValueToReplyIcon(CContactSettings(0, hContact).Autoreply);
}
- } else // save it back to the db
- {
+ }
+ else { // save it back to the db
if (nColumn == EXTRACOLUMN_IGNORE)
- {
CContactSettings(0, hContact).Ignore = nIcon == EXTRAIMGLIST_IGNORE;
- } else
- {
+ else {
_ASSERT(nColumn == EXTRACOLUMN_REPLY);
CContactSettings(0, hContact).Autoreply = (nIcon == EXTRAIMGLIST_DOT) ? VAL_USEDEFAULT : (nIcon == EXTRAIMGLIST_AUTOREPLY_ON);
}
}
if (nColumn == EXTRACOLUMN_IGNORE && nIcon != EXTRAIMGLIST_IGNORE)
- {
nIcon = (CContactSettings(0, hContact).GetMsgFormat(GMF_PERSONAL) == NULL) ? EXTRAIMGLIST_DOT : EXTRAIMGLIST_MSG;
- }
- } else if (ItemType == MCLCIT_INFO)
- {
+ }
+ else if (ItemType == MCLCIT_INFO) {
char *szProto = (char*)CList->GetItemParam(hItem);
- if (nColumn == EXTRACOLUMN_REPLY)
- {
+ if (nColumn == EXTRACOLUMN_REPLY) {
if (nIcon == -1)
- {
nIcon = DBValueToReplyIcon(CProtoSettings(szProto).Autoreply);
- } else
- {
+ else
CProtoSettings(szProto).Autoreply = (nIcon == EXTRAIMGLIST_DOT) ? VAL_USEDEFAULT : (nIcon == EXTRAIMGLIST_AUTOREPLY_ON);
- }
+
if (!szProto && nIcon == EXTRAIMGLIST_DOT)
- {
nIcon = EXTRAIMGLIST_AUTOREPLY_OFF;
- }
- } else
- {
- nIcon = (CProtoSettings(szProto).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL) == NULL) ? EXTRAIMGLIST_DOT : EXTRAIMGLIST_MSG;
}
+ else nIcon = (CProtoSettings(szProto).GetMsgFormat(GMF_TEMPORARY | GMF_PERSONAL) == NULL) ? EXTRAIMGLIST_DOT : EXTRAIMGLIST_MSG;
}
+
int Ignore = (nColumn == EXTRACOLUMN_IGNORE) ? (nIcon == EXTRAIMGLIST_IGNORE) : ((ItemType == MCLCIT_CONTACT) ? CContactSettings(0, hContact).Ignore : ((ItemType == MCLCIT_GROUP) ? CList->GetExtraImage(hItem, EXTRACOLUMN_IGNORE) : false));
- if (Ignore)
- {
+ if (Ignore) {
if (nColumn == EXTRACOLUMN_IGNORE)
- {
CList->SetExtraImage(hItem, EXTRACOLUMN_REPLY, CLC_EXTRAICON_EMPTY);
- } else
- {
+ else
nIcon = CLC_EXTRAICON_EMPTY;
- }
- } else
- {
+ }
+ else {
int nReplyIcon;
if (ItemType == MCLCIT_CONTACT)
- {
nReplyIcon = DBValueToReplyIcon(CContactSettings(0, hContact).Autoreply);
- } else if (ItemType == MCLCIT_GROUP)
- {
+ else if (ItemType == MCLCIT_GROUP)
nReplyIcon = GetRealReplyIcon(CList, hItem);
- } else
- {
+ else {
_ASSERT(ItemType == MCLCIT_INFO);
char *szProto = (char*)CList->GetItemParam(hItem);
nReplyIcon = DBValueToReplyIcon(CProtoSettings(szProto).Autoreply);
}
+
if (nColumn == EXTRACOLUMN_IGNORE)
- {
CList->SetExtraImage(hItem, EXTRACOLUMN_REPLY, nReplyIcon);
- } else if (nIcon == CLC_EXTRAICON_EMPTY)
- {
+ else if (nIcon == CLC_EXTRAICON_EMPTY)
nIcon = nReplyIcon;
- }
}
CList->SetExtraImage(hItem, nColumn, nIcon);
}
@@ -371,77 +308,61 @@ void SetCListGroupIcons(SetAwayMsgData *dat, CCList *CList) _ASSERT(CList);
HTREEITEM hItem = CList->GetNextItem(MCLGN_LAST, NULL); // start from last item, so every item is processed before its parents
if (!hItem)
- {
return;
- }
- if (CList->GetItemType(hItem) != MCLCIT_GROUP)
- {
+
+ if (CList->GetItemType(hItem) != MCLCIT_GROUP) {
hItem = CList->GetNextItem(MCLGN_PREV | MCLGN_GROUP | MCLGN_MULTILEVEL, hItem);
if (!hItem)
- {
return;
- }
}
- do
- {
+
+ do {
HTREEITEM hCurItem = CList->GetNextItem(MCLGN_CHILD, hItem);
- if (hCurItem)
- {
+ if (hCurItem) {
int IgnoreIcon = CList->GetExtraImage(hCurItem, EXTRACOLUMN_IGNORE);
int AutoreplyIcon = GetRealReplyIcon(CList, hCurItem);
if (IgnoreIcon == EXTRAIMGLIST_MSG)
- {
IgnoreIcon = EXTRAIMGLIST_DOT;
- }
- while ((hCurItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY, hCurItem)) && (IgnoreIcon != EXTRAIMGLIST_DOT || AutoreplyIcon != EXTRAIMGLIST_DOT))
- {
+
+ while ((hCurItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_ANY, hCurItem)) && (IgnoreIcon != EXTRAIMGLIST_DOT || AutoreplyIcon != EXTRAIMGLIST_DOT)) {
if (CList->GetExtraImage(hCurItem, EXTRACOLUMN_IGNORE) != EXTRAIMGLIST_IGNORE)
- {
IgnoreIcon = EXTRAIMGLIST_DOT;
- }
+
int CurReplyIcon = GetRealReplyIcon(CList, hCurItem);
if (CurReplyIcon != AutoreplyIcon)
- {
AutoreplyIcon = EXTRAIMGLIST_DOT;
- }
}
CList->SetItemParam(hItem, AutoreplyIcon); // store Reply icon in item's Param, so that we can always get real reply icon for groups later, even if CLC_EXTRAICON_EMPTY is set instead of it
SetExtraIcon(CList, EXTRACOLUMN_IGNORE, hItem, IgnoreIcon);
SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, AutoreplyIcon);
}
- } while (hItem = CList->GetNextItem(MCLGN_PREV | MCLGN_GROUP | MCLGN_MULTILEVEL, hItem));
+ }
+ while (hItem = CList->GetNextItem(MCLGN_PREV | MCLGN_GROUP | MCLGN_MULTILEVEL, hItem));
}
int GetSelContactsNum(CCList *CList, PTREEITEMARRAY Selection = NULL, bool *bOnlyInfo = NULL) // "SelContacts" mean not only contacts, but everything with "personal" status messages and settings - i.e. "All contacts" and protocol items are counted too.
{
if (!CList)
- {
return (Selection == CLSEL_DAT_NOTHING) ? 0 : 1; // Selection == NULL means we need to retrieve current selection by ourselves, and current selection is always CLSEL_DAT_CONTACT in this case
- }
+
if (!Selection)
- {
Selection = CList->GetSelection();
- }
- int I;
+
int nContacts = 0;
if (bOnlyInfo)
- {
*bOnlyInfo = true;
- }
- for (I = 0; I < Selection->GetSize(); I++)
- {
- int ItemType = CList->GetItemType((*Selection)[I]);
+
+ for (int i = 0; i < Selection->GetSize(); i++) {
+ int ItemType = CList->GetItemType((*Selection)[i]);
if (bOnlyInfo && ItemType != MCLCIT_INFO)
- {
*bOnlyInfo = false;
- }
+
nContacts += ItemType == MCLCIT_CONTACT || ItemType == MCLCIT_INFO;
}
return nContacts;
}
-
void ApplySelContactsMessage(SetAwayMsgData* dat, CCList *CList, PTREEITEMARRAY Selection = NULL)
{
TCString Message;
@@ -449,36 +370,29 @@ void ApplySelContactsMessage(SetAwayMsgData* dat, CCList *CList, PTREEITEMARRAY GetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, Message.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
Message.ReleaseBuffer();
if (!lstrlen(Message))
- {
Message = NULL; // delete personal message if it's empty
- }
- if (CList)
- {
+
+ if (CList) {
if (!Selection)
- {
Selection = CList->GetSelection();
- }
- int I;
- for (I = 0; I < Selection->GetSize(); I++)
- {
- HTREEITEM hItem = (*Selection)[I];
+
+ for (int i = 0; i < Selection->GetSize(); i++) {
+ HTREEITEM hItem = (*Selection)[i];
int ItemType = CList->GetItemType(hItem);
- if (ItemType == MCLCIT_CONTACT)
- {
+ if (ItemType == MCLCIT_CONTACT) {
MCONTACT hContact = CList->GethContact(hItem);
CContactSettings(0, hContact).SetMsgFormat(SMF_PERSONAL, Message);
- } else if (ItemType == MCLCIT_INFO)
- {
+ }
+ else if (ItemType == MCLCIT_INFO) {
char *szProto = (char*)CList->GetItemParam(hItem);
CProtoSettings(szProto).SetMsgFormat(SMF_PERSONAL, (szProto || Message != NULL) ? Message : _T("")); // "szProto || Message != NULL..." means that we'll set an empty message instead of NULL for the global status, if the message is empty (NULL for the global status has a special meaning - SetMsgFormat will set the default message instead of NULL)
- } else
- {
- continue;
}
+ else continue;
+
SetExtraIcon(CList, EXTRACOLUMN_IGNORE, hItem, -1); // refresh contact's personal message icon (MSG or DOT)
}
- } else if (Selection != CLSEL_DAT_NOTHING)
- {
+ }
+ else if (Selection != CLSEL_DAT_NOTHING) {
if (dat->hInitContact)
CContactSettings(0, dat->hInitContact).SetMsgFormat(SMF_PERSONAL, Message);
else
@@ -488,36 +402,27 @@ void ApplySelContactsMessage(SetAwayMsgData* dat, CCList *CList, PTREEITEMARRAY SetDlgItemText(hwndDlg, IDC_OK, TranslateT("OK"));
}
-
void UpdateCheckboxesState(CCList *CList)
{
_ASSERT(CList);
PTREEITEMARRAY Selection = CList->GetSelection();
- int I;
int ReplyIcon = -1;
int IgnoreIcon = -1;
- for (I = 0; I < Selection->GetSize() && (IgnoreIcon != EXTRAIMGLIST_DOT || ReplyIcon != EXTRAIMGLIST_DOT); I++)
- {
- HTREEITEM hItem = (*Selection)[I];
+ for (int i = 0; i < Selection->GetSize() && (IgnoreIcon != EXTRAIMGLIST_DOT || ReplyIcon != EXTRAIMGLIST_DOT); i++) {
+ HTREEITEM hItem = (*Selection)[i];
int ItemType = CList->GetItemType(hItem);
- if (ItemType == MCLCIT_CONTACT || ItemType == MCLCIT_INFO)
- {
+ if (ItemType == MCLCIT_CONTACT || ItemType == MCLCIT_INFO) {
int CurIgnoreIcon = CList->GetExtraImage(hItem, EXTRACOLUMN_IGNORE);
if (IgnoreIcon == -1)
- {
IgnoreIcon = CurIgnoreIcon;
- } else if (CurIgnoreIcon != EXTRAIMGLIST_IGNORE)
- {
+ else if (CurIgnoreIcon != EXTRAIMGLIST_IGNORE)
IgnoreIcon = EXTRAIMGLIST_DOT;
- }
+
int CurReplyIcon = CList->GetExtraImage(hItem, EXTRACOLUMN_REPLY);
if (ReplyIcon == -1)
- {
ReplyIcon = CurReplyIcon;
- } else if (CurReplyIcon != ReplyIcon)
- {
+ else if (CurReplyIcon != ReplyIcon)
ReplyIcon = EXTRAIMGLIST_DOT;
- }
}
}
HWND hwndDlg = g_SetAwayMsgPage.GetWnd();
@@ -526,12 +431,33 @@ void UpdateCheckboxesState(CCList *CList) CheckDlgButton(hwndDlg, IDC_SAWAYMSG_SENDMSG, (ReplyIcon == EXTRAIMGLIST_AUTOREPLY_ON) ? BST_CHECKED : ((ReplyIcon == EXTRAIMGLIST_AUTOREPLY_OFF) ? BST_UNCHECKED : BST_INDETERMINATE));
}
-HICON g_LoadIconEx( const char* name, bool big )
+HICON g_LoadIconEx(const char* name, bool big)
{
char szSettingName[100];
- mir_snprintf( szSettingName, sizeof( szSettingName ), "%s_%s", "", name );
+ mir_snprintf(szSettingName, sizeof(szSettingName), "%s_%s", "", name);
return Skin_GetIcon(szSettingName, big);
}
+
+static 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")
+};
+
+struct {
+ int DlgItemID;
+ TCHAR* Text;
+} Tooltips[] = {
+ IDC_SAWAYMSG_IGNOREREQ, LPGENT("Don't send the status message to selected contact(s)"),
+ IDC_SAWAYMSG_SENDMSG, LPGENT("Send an autoreply to selected contact(s)"),
+};
+
INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static int SetMsgSplitterX, SetContactSplitterX;
@@ -541,25 +467,11 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA static int Countdown;
static CMsgTree *MsgTree = NULL;
static CCList *CList = NULL;
- static 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")
- };
-
-
- switch (uMsg)
- {
- case WM_INITDIALOG:
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
dat = (SetAwayMsgData*)lParam;
- TranslateDialogDefault(hwndDlg);
g_SetAwayMsgPage.SetWnd(hwndDlg);
g_SetAwayMsgPage.DBToMemToPage();
@@ -571,24 +483,15 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA HICON hTitleIcon = LoadSkinnedProtoIcon(szProto, Status);
HICON hTitleIconBig = LoadSkinnedProtoIconBig(szProto, Status);
-
-
-
- if(hTitleIconBig == NULL || (HICON)CALLSERVICE_NOTFOUND == hTitleIconBig) {
+ if (hTitleIconBig == NULL || (HICON)CALLSERVICE_NOTFOUND == hTitleIconBig)
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hTitleIconBigElse);
- } else {
+ else
SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hTitleIconBig);
- }
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hTitleIcon);
-
-
SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_LIMITTEXT, AWAY_MSGDATA_MAX, 0);
-
-
-
- // init window size variables / resize the window
+ // init window size variables / resize the window
RECT rc;
POINT pt;
GetWindowRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_MSGSPLITTER), &rc);
@@ -604,20 +507,12 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA RECT rcVars;
GetWindowRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_VARS), &rcVars);
g_VariablesButtonDX = rcContactSplitter.left - rcVars.right;
-// GetWindowRect(GetDlgItem(hwndDlg, IDC_OK), &rc);
+
RECT rcOK;
GetWindowRect(GetDlgItem(hwndDlg, IDC_OK), &rcOK);
- //MinMsgEditSize = rc.right - rc.left + rcContactSplitter.right - rcVars.left + 3;
MinMsgEditSize = rcOK.right - rc.left + rcContactSplitter.right - rcVars.left + 3;
rc.left = MINSPLITTERPOS;
- //NightFox: use MINSPLITTERPOS as min size ;
-// GetWindowRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), &rc);
-// GetWindowRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_DELETE), &rc);
-// rc.left = MINSPLITTERPOS;
- //GetWindowRect(GetDlgItem(hwndDlg, IDC_OK), &rc);
- //GetWindowRect(GetDlgItem(hwndDlg, IDC_OK), &rc);
-
pt.x = rc.right;
pt.y = 0;
ScreenToClient(hwndDlg, &pt);
@@ -625,55 +520,18 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA GetWindowRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_IGNOREREQ), &rc);
MinContactSplitterX = rcMsgDlg.right - rc.left + 1;
- /*
-
- //NightFox: add status bar
-
- PROTOACCOUNT * acc = ProtoGetAccount(szProto);
-
- //HWND hWndStatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | SBARS_SIZEGRIP, NULL, hwndDlg, 999);//IDC_STATUSBAR);
- SetWindowPos(hWndStatusBar, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
-
-
- SIZE sz;
-
- HDC hdc = GetDC(hWndStatusBar);
- HFONT hFntSave = (HFONT)SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
- GetTextExtentPoint32(hdc, acc->tszAccountName, lstrlen(acc->tszAccountName), &sz);
- sz.cx += GetSystemMetrics(SM_CXSMICON) * 3;
- SelectObject(hdc, hFntSave);
- ReleaseDC(hWndStatusBar, hdc);
-
- RECT rcStatus; GetWindowRect(hWndStatusBar, &rcStatus);
- int parts[] = { rcStatus.right-rcStatus.left - sz.cx, -1 };
- SendMessage(hWndStatusBar, SB_SETPARTS, 2, (LPARAM)parts);
- SendMessage(hWndStatusBar, SB_SETICON, 1, (LPARAM)LoadSkinnedProtoIcon(szProto, Status));
- SendMessage(hWndStatusBar, SB_SETTEXT, 1, (LPARAM)acc->tszAccountName);
- */
-
-
-
-
-
-
-
-
-
-
- // [try] getting dialog position
+ // [try] getting dialog position
int DlgPosX = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGPOSX, -1);
int DlgPosY = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGPOSY, -1);
int DlgSizeX = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEX, -1);
int DlgSizeY = db_get_dw(NULL, MOD_NAME, SAM_DB_DLGSIZEY, -1);
int MsgSplitterX = db_get_dw(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, -1);
int ContactSplitterX = db_get_dw(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, -1);
- if (DlgPosX >= 0 && DlgPosY >= 0 && DlgSizeX > 0 && DlgSizeY > 0 && MsgSplitterX > 0 && ContactSplitterX > 0)
- {
+ if (DlgPosX >= 0 && DlgPosY >= 0 && DlgSizeX > 0 && DlgSizeY > 0 && MsgSplitterX > 0 && ContactSplitterX > 0) {
RECT rcWorkArea, rcIntersect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, 0);
- RECT rcDlgPos = {DlgPosX, DlgPosY, DlgPosX + DlgSizeX, DlgPosY + DlgSizeY};
- if (!IntersectRect(&rcIntersect, &rcDlgPos, &rcWorkArea)) // make sure the window will be visible
- {
+ RECT rcDlgPos = { DlgPosX, DlgPosY, DlgPosX + DlgSizeX, DlgPosY + DlgSizeY };
+ if (!IntersectRect(&rcIntersect, &rcDlgPos, &rcWorkArea)) { // make sure the window will be visible
DlgPosX = rcWorkArea.left;
DlgPosY = rcWorkArea.top;
}
@@ -686,13 +544,12 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SetContactSplitterX = g_ContactSplitterX;
SendMessage(hwndDlg, WM_SIZE, 0, 0); // show/hide dialog controls accordingly to the settings
- MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_SAWAYMSG_TREE)); // Attention: it's important to call NEW and DELETE in a proper order, as CMsgTree and CCList are setting their own WNDPROCs for the parent window, so we must prevent WNDPROC conflicts.
+ // Attention: it's important to call NEW and DELETE in a proper order, as CMsgTree and CCList are setting their own WNDPROCs for the parent window, so we must prevent WNDPROC conflicts.
+ MsgTree = new CMsgTree(GetDlgItem(hwndDlg, IDC_SAWAYMSG_TREE));
CList = NULL;
if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE))
- {
SendMessage(hwndDlg, UM_SAM_INITCLIST, 0, 0);
- } else
- {
+ else {
NMCLIST nm;
nm.hdr.code = MCLN_SELCHANGED;
nm.hdr.hwndFrom = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
@@ -702,79 +559,59 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm);
}
- // init message tree
- if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT) && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM))
- {
+ // init message tree
+ if (g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_RECENTMSGSCOUNT) && g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_PERSTATUSMRM)) {
char *szProto = dat->hInitContact ? GetContactProto(dat->hInitContact) : dat->szProtocol;
int ID = GetRecentGroupID((szProto || !dat->hInitContact) ? g_ProtoStates[szProto].Status : ID_STATUS_AWAY);
CBaseTreeItem* pTreeItem = MsgTree->GetNextItem(MTGN_CHILD | MTGN_BYID, (CBaseTreeItem*)g_Messages_RecentRootID);
- while (pTreeItem)
- {
- if (pTreeItem->Flags & TIF_GROUP)
- {
+ while (pTreeItem) {
+ if (pTreeItem->Flags & TIF_GROUP) {
if (pTreeItem->ID == ID)
- {
pTreeItem->Flags |= TIF_EXPANDED; // leave expanded only one appropriate subgroup of Recent Messages group
- } else
- {
+ else
pTreeItem->Flags &= ~TIF_EXPANDED;
- }
+
MsgTree->UpdateItem(pTreeItem->ID);
}
pTreeItem = MsgTree->GetNextItem(MTGN_NEXT, pTreeItem);
}
-// InvalidateRect(GetDlgItem(hwndDlg, IDC_SAWAYMSG_TREE), NULL, true);
}
int Order;
CProtoSettings(dat->szProtocol).GetMsgFormat(GMF_LASTORDEFAULT, &Order);
- if (Order >= 0)
- { // so just select an appropriate message tree item; MSGDATA text is filled automatically through SELCHANGED notification
+ if (Order >= 0) // so just select an appropriate message tree item; MSGDATA text is filled automatically through SELCHANGED notification
MsgTree->SetSelection(Order, MTSS_BYORDER);
- }
- if (dat->Message != NULL) // this allows to override the default message
- {
+ if (dat->Message != NULL) { // this allows to override the default message
SetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, dat->Message);
SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETMODIFY, true, 0);
}
SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETSEL, 0, -1); // select all the text in the edit control
- // init timer
+ // init timer
Countdown = (dat->ISW_Flags & ISWF_NOCOUNTDOWN) ? -1 : g_MoreOptPage.GetDBValueCopy(IDC_MOREOPTDLG_WAITFORMSG);
if (Countdown == -1) // infinite
- {
SetDlgItemText(hwndDlg, IDC_OK, TranslateT("OK"));
- } else
- {
+ else {
SendMessage(hwndDlg, WM_TIMER, SAM_TIMER_ID, NULL);
SetTimer(hwndDlg, SAM_TIMER_ID, 1000, NULL);
}
- // init image buttons
- int I;
- for (I = 0; I < lengthof(Buttons); I++)
- {
- HWND hButton = GetDlgItem(hwndDlg, Buttons[I].DlgItem);
- SendMessage(hButton, BUTTONADDTOOLTIP, (WPARAM)TranslateTS(Buttons[I].Text), BATF_TCHAR);
+ // init image buttons
+ int i;
+ for (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);
}
- // init tooltips
- struct {
- int DlgItemID;
- TCHAR* Text;
- } Tooltips[] = {
- IDC_SAWAYMSG_IGNOREREQ, LPGENT("Don't send the status message to selected contact(s)"),
- IDC_SAWAYMSG_SENDMSG, LPGENT("Send an autoreply to selected contact(s)"),
- };
- TOOLINFO ti = {0};
+ // init tooltips
+ TOOLINFO ti = { 0 };
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 < lengthof(Tooltips); I++)
- {
- ti.uId = (UINT)GetDlgItem(hwndDlg, Tooltips[I].DlgItemID);
- ti.lpszText = TranslateTS(Tooltips[I].Text);
+ for (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);
}
SendMessage(hwndDlg, UM_ICONSCHANGED, 0, 0);
@@ -783,317 +620,281 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA g_OrigEditMsgProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SAWAYMSG_MSGDATA), GWLP_WNDPROC, (LONG_PTR)MsgEditSubclassProc);
g_OrigSplitterProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SAWAYMSG_MSGSPLITTER), GWLP_WNDPROC, (LONG_PTR)SplitterSubclassProc);
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSPLITTER), GWLP_WNDPROC, (LONG_PTR)SplitterSubclassProc);
- return false;
- } break;
- case WM_NOTIFY:
+ }
+ return false;
+
+ case WM_NOTIFY:
+ switch (((NMHDR*)lParam)->idFrom) {
+ case IDC_SAWAYMSG_CONTACTSTREE:
{
- switch (((NMHDR*)lParam)->idFrom)
+ switch (((NMHDR*)lParam)->code) // check the notification code
{
- case IDC_SAWAYMSG_CONTACTSTREE:
- {
- 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;
+ }
+ }
+ SetExtraIcon(CList, nColumn, hItem, CurIcon);
+ if (ItemType == MCLCIT_GROUP) // set all child items
{
- 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;
- }
- }
- 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);
- }
+ 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);
+ }
+ } 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]) {
+ break;
}
- SetCListGroupIcons(dat, CList);
- UpdateCheckboxesState(CList);
}
- } break;
- case MCLN_SELCHANGED:
+ 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
{
- PNMCLIST nm = (PNMCLIST)lParam;
- TCString BtnTitle(TranslateT("OK"));
- if (CList)
- {
- UpdateCheckboxesState(CList);
+ 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);
}
- 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 (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);
- }
- } 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) {
+ 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("");
}
- } else
- {
- if (nOldContacts && !nNewContacts)
- {
- ApplySelContactsMessage(dat, CList, nm->OldSelection);
+ if (Message == NULL) {
+ Message = CurMessage;
}
- }
-
- // 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 (CurMessage != (const TCHAR*)Message) {
+ Message = _T("");
+ BtnTitle = TranslateT("Apply");
+ MessageDetermined = 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;
- if (CList)
- {
- int I;
- for (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;
- } else if (ItemType == MCLCIT_INFO)
- {
- szProto = (char*)CList->GetItemParam(hItem);
- break;
- }
- }
- } else
- {
- hContact = dat->hInitContact;
- szProto = dat->szProtocol;
+ if (!StatusDetermined) {
+ if (!Status) {
+ Status = CurStatus;
}
- 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(")");
- } else {
- 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);
-
- WindowTitle += acc->tszAccountName;
- //WindowTitle += _T(" ");
- //WindowTitle += TranslateT("account");
- WindowTitle += _T(")");
- }
+ else if (CurStatus != Status) {
+ Status = 0;
+ StatusDetermined = true;
}
- } else {
- WindowTitle += _T("\"");
}
- SetWindowText(hwndDlg, WindowTitle);
- } break;
+ }
}
- } break;
- case IDC_SAWAYMSG_TREE:
+ }
+ else if (nNewContacts) // if (!CList)
{
- switch (((NMHDR*)lParam)->code)
- {
- case MTN_SELCHANGED:
- {
- if (!UpdateLock)
- {
- PNMMSGTREE pnm = (PNMMSGTREE)lParam;
- if (pnm->ItemNew && !(pnm->ItemNew->Flags & (TIF_ROOTITEM | TIF_GROUP)))
- {
- SetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, ((CTreeItem*)pnm->ItemNew)->User_Str1);
- SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SAWAYMSG_MSGDATA, EN_CHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_SAWAYMSG_MSGDATA));
- SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETMODIFY, true, 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), true);
- } else
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), false);
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_DELETE), pnm->ItemNew && !(pnm->ItemNew->Flags & TIF_ROOTITEM));
+ 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;
+ if (CList) {
+ int i;
+ for (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;
}
- } break;
+ else if (ItemType == MCLCIT_INFO) {
+ szProto = (char*)CList->GetItemParam(hItem);
+ break;
+ }
+ }
+ }
+ else {
+ 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(")");
+ }
+ else {
+ 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);
+
+ WindowTitle += acc->tszAccountName;
+ //WindowTitle += _T(" ");
+ //WindowTitle += TranslateT("account");
+ WindowTitle += _T(")");
+ }
}
- } break;
+ }
+ else {
+ WindowTitle += _T("\"");
+ }
+ SetWindowText(hwndDlg, WindowTitle);
+ } break;
}
- return true;
- } break;
- case WM_TIMER:
- {
- if (wParam == SAM_TIMER_ID)
+ break;
+ case IDC_SAWAYMSG_TREE:
+ switch (((NMHDR*)lParam)->code) {
+ case MTN_SELCHANGED:
{
- if (!Countdown)
- {
- SendMessage(hwndDlg, UM_SAM_APPLYANDCLOSE, 0, 0);
- return true;
+ if (!UpdateLock) {
+ PNMMSGTREE pnm = (PNMMSGTREE)lParam;
+ if (pnm->ItemNew && !(pnm->ItemNew->Flags & (TIF_ROOTITEM | TIF_GROUP))) {
+ SetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, ((CTreeItem*)pnm->ItemNew)->User_Str1);
+ SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_SAWAYMSG_MSGDATA, EN_CHANGE), (LPARAM)GetDlgItem(hwndDlg, IDC_SAWAYMSG_MSGDATA));
+ SendDlgItemMessage(hwndDlg, IDC_SAWAYMSG_MSGDATA, EM_SETMODIFY, true, 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), true);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_SAVEMSG), false);
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_DELETE), pnm->ItemNew && !(pnm->ItemNew->Flags & TIF_ROOTITEM));
}
- TCHAR BtnTitle[64];
- _sntprintf(BtnTitle, sizeof(BtnTitle), TranslateT("Closing in %d"), Countdown);
- SetDlgItemText(hwndDlg, IDC_OK, BtnTitle);
- Countdown--;
+ } break;
}
} break;
- case UM_SAM_INITCLIST:
- {
- _ASSERT(!CList);
- CList = new CCList(GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE));
+ }
+ return true;
- // init contact tree
- HIMAGELIST hil;
- hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
+ case WM_TIMER:
+ if (wParam == SAM_TIMER_ID) {
+ if (!Countdown) {
+ SendMessage(hwndDlg, UM_SAM_APPLYANDCLOSE, 0, 0);
+ return true;
+ }
+ TCHAR BtnTitle[64];
+ _sntprintf(BtnTitle, sizeof(BtnTitle), TranslateT("Closing in %d"), Countdown);
+ SetDlgItemText(hwndDlg, IDC_OK, BtnTitle);
+ Countdown--;
+ }
+ break;
+
+ case UM_SAM_INITCLIST:
+ _ASSERT(!CList);
+ CList = new CCList(GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE));
+ {
+ // init contact tree
+ HIMAGELIST hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 5, 2);
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_DOT)));
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IGNORE)));
ImageList_AddIcon(hil, LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MSGICON)));
@@ -1106,21 +907,19 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA 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
+ 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));
+ //CallProtoService(proto[i]->szName, PS_GETNAME, 256, (LPARAM)ProtoTitle.GetBuffer(256));
//ProtoTitle.ReleaseBuffer();
- PROTOACCOUNT * acc = ProtoGetAccount(proto[I]->szName);
+ 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))
- {
+ //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)) {
hSelItem = hItem;
}
}
@@ -1128,17 +927,13 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA MCONTACT hContact = db_find_first();
CList->SetRedraw(false);
- do
- {
+ do {
char *szProto = GetContactProto(hContact);
- if (szProto)
- {
+ if (szProto) {
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
+ 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;
}
}
@@ -1146,68 +941,59 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA } while (hContact = db_find_next(hContact));
CList->SortContacts();
hItem = CLC_ROOT;
- while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem))
- {
+ while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem)) {
SetExtraIcon(CList, EXTRACOLUMN_IGNORE, hItem, -1);
SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1);
}
SetCListGroupIcons(dat, CList);
CList->SetRedraw(true); // SetRedraw must be before SelectItem - otherwise SelectItem won't change scrollbar position to make the selected contact visible
CList->SelectItem(hSelItem); // must be selected after setting all extra icons, to set checkboxes properly
- } break;
- case UM_SAM_APPLYANDCLOSE:
+ }
+ break;
+
+ case UM_SAM_APPLYANDCLOSE:
+ KillTimer(hwndDlg, SAM_TIMER_ID);
+ 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;
+ nm.OldSelection = CLSEL_DAT_CONTACT;
+ nm.NewSelection = CLSEL_DAT_NOTHING;
+ SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm);
+ }
+ MsgTree->Save();
{
- KillTimer(hwndDlg, SAM_TIMER_ID);
- 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;
- nm.OldSelection = CLSEL_DAT_CONTACT;
- nm.NewSelection = CLSEL_DAT_NOTHING;
- SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm);
- }
- MsgTree->Save();
- // save Recent Messages
+ // save Recent Messages
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)
- {
- 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
+ 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
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(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
}
}
TCString Message(CProtoSettings().GetMsgFormat(GMF_PERSONAL));
if (Message != NULL)
- {
CProtoSettings().SetMsgFormat(SMF_LAST, Message); // save the global message to the recent messages
- }
+
if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS))
- {
SendMessage(hwndDlg, UM_SAM_SAVEDLGSETTINGS, 0, 0);
- }
+
if (dat->IsModeless)
- {
DestroyWindow(hwndDlg);
- } else
- {
+ else
EndDialog(hwndDlg, 2);
- }
- return true;
- } break;
- case UM_SAM_SAVEDLGSETTINGS:
+ }
+ return true;
+
+ case UM_SAM_SAVEDLGSETTINGS:
{
RECT rcRect;
GetWindowRect(hwndDlg, &rcRect);
@@ -1218,376 +1004,318 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA db_set_dw(NULL, MOD_NAME, SAM_DB_MSGSPLITTERPOS, g_MsgSplitterX);
db_set_dw(NULL, MOD_NAME, SAM_DB_CONTACTSPLITTERPOS, g_ContactSplitterX);
g_SetAwayMsgPage.PageToMemToDB();
- } break;
- case UM_SAM_REPLYSETTINGCHANGED:
- { // wParam = (HANDLE)hContact
- if (CList)
- {
- HTREEITEM hItem = CLC_ROOT;
- if (!wParam)
- { // it's the global autoreply setting
- while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem))
- {
- if (!CList->GetItemParam(hItem))
- { // we found the item
- SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1); // update it
- break;
- }
+ }
+ break;
+
+ case UM_SAM_REPLYSETTINGCHANGED:
+ if (CList) {
+ HTREEITEM hItem = CLC_ROOT;
+ if (!wParam) { // it's the global autoreply setting
+ while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem)) {
+ if (!CList->GetItemParam(hItem)) { // we found the item
+ SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1); // update it
+ break;
}
- } else
- { // it's a contact's autoreply setting
- while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_MULTILEVEL, hItem))
- {
- MCONTACT hContact = CList->GethContact(hItem);
- if (CList->GethContact(hItem) == wParam)
- { // we found the item
- SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1); // update it
- break;
- }
+ }
+ }
+ else { // it's a contact's autoreply setting
+ while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_MULTILEVEL, hItem)) {
+ MCONTACT hContact = CList->GethContact(hItem);
+ if (CList->GethContact(hItem) == wParam) { // we found the item
+ SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1); // update it
+ break;
}
}
- UpdateCheckboxesState(CList);
}
- } break;
- case UM_SAM_PROTOSTATUSCHANGED:
- { // wParam = (char*)szProto
- if (CList)
- {
- HTREEITEM hItem = CLC_ROOT;
- while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem))
- {
- if (CList->GetItemType(hItem) == MCLCIT_INFO)
- {
- char *szProto = (char*)CList->GetItemParam(hItem);
- if (!wParam || !lstrcmpA(szProto, (char*)wParam))
- {
- CList->SetInfoIcon(hItem, LoadSkinnedProtoIcon(szProto, g_ProtoStates[szProto].Status));
- }
+ UpdateCheckboxesState(CList);
+ }
+ break;
+ case UM_SAM_PROTOSTATUSCHANGED:
+ if (CList) {
+ HTREEITEM hItem = CLC_ROOT;
+ while (hItem = CList->GetNextItem(MCLGN_NEXT | MCLGN_CONTACT | MCLGN_INFO | MCLGN_MULTILEVEL, hItem)) {
+ if (CList->GetItemType(hItem) == MCLCIT_INFO) {
+ char *szProto = (char*)CList->GetItemParam(hItem);
+ if (!wParam || !lstrcmpA(szProto, (char*)wParam)) {
+ CList->SetInfoIcon(hItem, LoadSkinnedProtoIcon(szProto, g_ProtoStates[szProto].Status));
}
- SetExtraIcon(CList, EXTRACOLUMN_IGNORE, hItem, -1);
- SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1);
}
- SetCListGroupIcons(dat, CList);
+ SetExtraIcon(CList, EXTRACOLUMN_IGNORE, hItem, -1);
+ SetExtraIcon(CList, EXTRACOLUMN_REPLY, hItem, -1);
}
-/* dat->hInitContact = NULL; // TODO: test it
- dat->szProtocol = (char*)wParam;*/
+ 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.
- } break;
- case UM_ICONSCHANGED:
- {
- int I;
- for (I = 0; I < lengthof(Buttons); I++)
- {
- if (Buttons[I].IconIndex != ILI_NOICON)
- {
- SendDlgItemMessage(hwndDlg, Buttons[I].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[I].IconIndex]);
- }
- }
- my_variables_skin_helpbutton(hwndDlg, IDC_SAWAYMSG_VARS);
- } break;
- case WM_COMMAND:
- {
- switch (HIWORD(wParam))
- {
- case EN_CHANGE:
+ }
+ break;
+
+ case UM_ICONSCHANGED:
+ for (int i = 0; i < SIZEOF(Buttons); i++)
+ if (Buttons[i].IconIndex != ILI_NOICON)
+ SendDlgItemMessage(hwndDlg, Buttons[i].DlgItem, BM_SETIMAGE, IMAGE_ICON, (LPARAM)g_IconList[Buttons[i].IconIndex]);
+
+ my_variables_skin_helpbutton(hwndDlg, IDC_SAWAYMSG_VARS);
+ break;
+
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case EN_CHANGE:
+ if (LOWORD(wParam) == IDC_SAWAYMSG_MSGDATA)
+ SetDlgItemText(hwndDlg, IDC_OK, TranslateTS((GetSelContactsNum(CList) > 1) ? LPGENT("Apply") : LPGENT("OK")));
+ break;
+
+ case EN_KILLFOCUS:
+ if (LOWORD(wParam) == IDC_SAWAYMSG_MSGDATA && GetForegroundWindow() == hwndDlg)
+ SendMessage(hwndDlg, UM_SAM_KILLTIMER, 0, 0);
+ break;
+
+ case BN_CLICKED:
+ switch (LOWORD(wParam)) {
+ case IDC_SAWAYMSG_IGNOREREQ:
+ _ASSERT(CList);
{
- if (LOWORD(wParam) == IDC_SAWAYMSG_MSGDATA)
- {
- SetDlgItemText(hwndDlg, IDC_OK, TranslateTS((GetSelContactsNum(CList) > 1) ? LPGENT("Apply") : LPGENT("OK")));
+ 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) {
+ SetExtraIcon(CList, EXTRACOLUMN_IGNORE, (*Selection)[i], Ignore ? EXTRAIMGLIST_IGNORE : EXTRAIMGLIST_DOT);
+ }
}
- } break;
- case EN_KILLFOCUS:
- {
- if (LOWORD(wParam) == IDC_SAWAYMSG_MSGDATA && GetForegroundWindow() == hwndDlg)
- {
- SendMessage(hwndDlg, UM_SAM_KILLTIMER, 0, 0);
+ if (Selection->GetSize() == 1) {
+ CList->EnsureVisible((*Selection)[0]);
}
- } break;
- case BN_CLICKED:
+ SetCListGroupIcons(dat, CList);
+ }
+ break;
+
+ case IDC_SAWAYMSG_SENDMSG:
+ _ASSERT(CList);
{
- switch (LOWORD(wParam))
- {
- case IDC_SAWAYMSG_IGNOREREQ:
- {
- _ASSERT(CList);
- 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)
- {
- SetExtraIcon(CList, EXTRACOLUMN_IGNORE, (*Selection)[I], Ignore ? EXTRAIMGLIST_IGNORE : EXTRAIMGLIST_DOT);
- }
- }
- if (Selection->GetSize() == 1)
- {
- CList->EnsureVisible((*Selection)[0]);
- }
- SetCListGroupIcons(dat, CList);
- } break;
- case IDC_SAWAYMSG_SENDMSG:
- {
- _ASSERT(CList);
- int Reply = IsDlgButtonChecked(hwndDlg, IDC_SAWAYMSG_SENDMSG);
- int ReplyIcon = (Reply == BST_CHECKED) ? EXTRAIMGLIST_AUTOREPLY_ON : ((Reply == BST_UNCHECKED) ? EXTRAIMGLIST_AUTOREPLY_OFF : EXTRAIMGLIST_DOT);
- PTREEITEMARRAY Selection = CList->GetSelection();
- int I;
- for (I = 0; I < Selection->GetSize(); I++)
- {
- SetExtraIcon(CList, EXTRACOLUMN_REPLY, (*Selection)[I], ReplyIcon);
- }
- if (Selection->GetSize() == 1)
- {
- CList->EnsureVisible((*Selection)[0]);
- }
- SetCListGroupIcons(dat, CList);
- } break;
- case IDC_SAWAYMSG_OPTIONS:
- {
- HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_SAM_OPTIONS));
- _ASSERT(hMenu);
- HMENU hPopupMenu = GetSubMenu(hMenu, 0);
- TranslateMenu(hPopupMenu);
- CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_SHOWMSGTREE, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_SHOWCONTACTTREE, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE) ? MF_CHECKED : MF_UNCHECKED));
- CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_AUTOSAVEDLGSETTINGS, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS) ? MF_CHECKED : MF_UNCHECKED));
- int VariablesInstalled = ServiceExists(MS_VARS_FORMATSTRING);
- CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_DISABLEVARIABLES, MF_BYCOMMAND | ((g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_DISABLEVARIABLES) || !VariablesInstalled) ? MF_CHECKED : MF_UNCHECKED));
- if (!VariablesInstalled)
- {
- EnableMenuItem(hPopupMenu, IDM_SAM_OPTIONS_DISABLEVARIABLES, MF_BYCOMMAND | MF_GRAYED);
- }
- switch (TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, (short)LOWORD(GetMessagePos()), (short)HIWORD(GetMessagePos()), 0, hwndDlg, NULL))
- {
- case IDM_SAM_OPTIONS_SHOWMSGTREE:
- {
- int bShow = !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE);
- g_SetAwayMsgPage.SetValue(IDS_SAWAYMSG_SHOWMSGTREE, bShow);
- RECT rcDlg;
- GetWindowRect(hwndDlg, &rcDlg);
- rcDlg.left -= bShow ? g_MsgSplitterX : -g_MsgSplitterX;
- SendMessage(hwndDlg, WM_SIZING, WMSZ_LEFT, (LPARAM)&rcDlg);
- SetWindowPos(hwndDlg, NULL, rcDlg.left, rcDlg.top, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_NOZORDER);
- SendMessage(hwndDlg, WM_SIZE, 0, 0); // show/hide dialog controls accordingly
- } break;
- case IDM_SAM_OPTIONS_SHOWCONTACTTREE:
- {
- 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;
- nm.OldSelection = CLSEL_DAT_CONTACT;
- nm.NewSelection = CLSEL_DAT_NOTHING;
- SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm); // save current message
- SendMessage(hwndDlg, UM_SAM_INITCLIST, 0, 0);
- }
- g_SetAwayMsgPage.SetValue(IDS_SAWAYMSG_SHOWCONTACTTREE, bShow);
- RECT rcDlg;
- GetWindowRect(hwndDlg, &rcDlg);
- rcDlg.right += bShow ? g_ContactSplitterX : -g_ContactSplitterX;
- SendMessage(hwndDlg, WM_SIZING, WMSZ_RIGHT, (LPARAM)&rcDlg);
- SetWindowPos(hwndDlg, NULL, 0, 0, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_NOZORDER | SWP_NOMOVE);
- SendMessage(hwndDlg, WM_SIZE, 0, 0); // show/hide dialog controls accordingly
- } break;
- case IDM_SAM_OPTIONS_AUTOSAVEDLGSETTINGS:
- {
- g_SetAwayMsgPage.SetDBValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS, !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS));
- } break;
- case IDM_SAM_OPTIONS_SAVEDLGSETTINGSNOW:
- {
- SendMessage(hwndDlg, UM_SAM_SAVEDLGSETTINGS, 0, 0);
- } break;
- case IDM_SAM_OPTIONS_DISABLEVARIABLES:
- {
- g_SetAwayMsgPage.SetDBValue(IDS_SAWAYMSG_DISABLEVARIABLES, !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_DISABLEVARIABLES));
- } break;
- }
- DestroyMenu(hMenu);
- } break;
- case IDC_SAWAYMSG_SAVEMSG:
- {
- CBaseTreeItem* TreeItem = MsgTree->GetSelection();
- if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM))
- {
- MsgTree->EnsureVisible(TreeItem->hItem);
- TCString NewMsg;
- GetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, NewMsg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
- NewMsg.ReleaseBuffer();
- if (((CTreeItem*)TreeItem)->User_Str1 != (const TCHAR*)NewMsg)
- {
- ((CTreeItem*)TreeItem)->User_Str1 = NewMsg;
- MsgTree->SetModified(true);
- }
- }
- } break;
- case IDC_SAWAYMSG_SAVEASNEW:
- {
- TCString Text;
- GetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, Text.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
- Text.ReleaseBuffer();
- UpdateLock++;
- CTreeItem* TreeItem = MsgTree->AddMessage();
- UpdateLock--;
- 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;
- GetDlgItemText(hwndDlg, IDC_OK, BtnTitle.GetBuffer(64), 64);
- BtnTitle.ReleaseBuffer();
- ApplySelContactsMessage(dat, CList);
- if (BtnTitle != (const TCHAR*)TranslateT("Apply"))
- {
- SendMessage(hwndDlg, UM_SAM_APPLYANDCLOSE, 0, 0);
- }
- } break;
- }
- } break;
- }
- } break;
- case UM_SAM_SPLITTERMOVED:
- {
- switch (lParam)
- {
- RECT rc;
- POINT pt;
- case IDC_SAWAYMSG_MSGSPLITTER:
+ int Reply = IsDlgButtonChecked(hwndDlg, IDC_SAWAYMSG_SENDMSG);
+ int ReplyIcon = (Reply == BST_CHECKED) ? EXTRAIMGLIST_AUTOREPLY_ON : ((Reply == BST_UNCHECKED) ? EXTRAIMGLIST_AUTOREPLY_OFF : EXTRAIMGLIST_DOT);
+ PTREEITEMARRAY Selection = CList->GetSelection();
+ for (int i = 0; i < Selection->GetSize(); i++)
+ SetExtraIcon(CList, EXTRACOLUMN_REPLY, (*Selection)[i], ReplyIcon);
+ if (Selection->GetSize() == 1)
+ CList->EnsureVisible((*Selection)[0]);
+ SetCListGroupIcons(dat, CList);
+ }
+ break;
+ case IDC_SAWAYMSG_OPTIONS:
{
- GetClientRect(hwndDlg, &rc);
- pt.x = wParam;
- pt.y = 0;
- ScreenToClient(hwndDlg, &pt);
- g_MsgSplitterX = (pt.x < MINSPLITTERPOS) ? MINSPLITTERPOS : pt.x;
- int MaxSetSplitterX = rc.right - MINSPLITTERPOS + 2;
- int MaxSplitterX = MaxSetSplitterX;
- if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE))
- {
- MaxSetSplitterX -= g_ContactSplitterX;
- MaxSplitterX -= MINSPLITTERPOS;
- }
- if (g_MsgSplitterX > MaxSetSplitterX)
- {
- if (g_MsgSplitterX > MaxSplitterX)
+ HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_SAM_OPTIONS));
+ _ASSERT(hMenu);
+ HMENU hPopupMenu = GetSubMenu(hMenu, 0);
+ TranslateMenu(hPopupMenu);
+ CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_SHOWMSGTREE, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_SHOWCONTACTTREE, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE) ? MF_CHECKED : MF_UNCHECKED));
+ CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_AUTOSAVEDLGSETTINGS, MF_BYCOMMAND | (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS) ? MF_CHECKED : MF_UNCHECKED));
+ int VariablesInstalled = ServiceExists(MS_VARS_FORMATSTRING);
+ CheckMenuItem(hPopupMenu, IDM_SAM_OPTIONS_DISABLEVARIABLES, MF_BYCOMMAND | ((g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_DISABLEVARIABLES) || !VariablesInstalled) ? MF_CHECKED : MF_UNCHECKED));
+ if (!VariablesInstalled)
+ EnableMenuItem(hPopupMenu, IDM_SAM_OPTIONS_DISABLEVARIABLES, MF_BYCOMMAND | MF_GRAYED);
+
+ switch (TrackPopupMenu(hPopupMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, (short)LOWORD(GetMessagePos()), (short)HIWORD(GetMessagePos()), 0, hwndDlg, NULL)) {
+ case IDM_SAM_OPTIONS_SHOWMSGTREE:
{
- g_ContactSplitterX = MINSPLITTERPOS;
- g_MsgSplitterX = MaxSplitterX;
- } else
+ int bShow = !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE);
+ g_SetAwayMsgPage.SetValue(IDS_SAWAYMSG_SHOWMSGTREE, bShow);
+ RECT rcDlg;
+ GetWindowRect(hwndDlg, &rcDlg);
+ rcDlg.left -= bShow ? g_MsgSplitterX : -g_MsgSplitterX;
+ SendMessage(hwndDlg, WM_SIZING, WMSZ_LEFT, (LPARAM)&rcDlg);
+ SetWindowPos(hwndDlg, NULL, rcDlg.left, rcDlg.top, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_NOZORDER);
+ SendMessage(hwndDlg, WM_SIZE, 0, 0); // show/hide dialog controls accordingly
+ }
+ break;
+ case IDM_SAM_OPTIONS_SHOWCONTACTTREE:
{
- g_ContactSplitterX = MINSPLITTERPOS + MaxSplitterX - g_MsgSplitterX;
+ 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;
+ nm.OldSelection = CLSEL_DAT_CONTACT;
+ nm.NewSelection = CLSEL_DAT_NOTHING;
+ SendMessage(hwndDlg, WM_NOTIFY, 0, (LPARAM)&nm); // save current message
+ SendMessage(hwndDlg, UM_SAM_INITCLIST, 0, 0);
+ }
+ g_SetAwayMsgPage.SetValue(IDS_SAWAYMSG_SHOWCONTACTTREE, bShow);
+ RECT rcDlg;
+ GetWindowRect(hwndDlg, &rcDlg);
+ rcDlg.right += bShow ? g_ContactSplitterX : -g_ContactSplitterX;
+ SendMessage(hwndDlg, WM_SIZING, WMSZ_RIGHT, (LPARAM)&rcDlg);
+ SetWindowPos(hwndDlg, NULL, 0, 0, rcDlg.right - rcDlg.left, rcDlg.bottom - rcDlg.top, SWP_NOZORDER | SWP_NOMOVE);
+ SendMessage(hwndDlg, WM_SIZE, 0, 0); // show/hide dialog controls accordingly
}
+ break;
+ case IDM_SAM_OPTIONS_AUTOSAVEDLGSETTINGS:
+ g_SetAwayMsgPage.SetDBValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS, !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_AUTOSAVEDLGSETTINGS));
+ break;
+ case IDM_SAM_OPTIONS_SAVEDLGSETTINGSNOW:
+ SendMessage(hwndDlg, UM_SAM_SAVEDLGSETTINGS, 0, 0);
+ break;
+ case IDM_SAM_OPTIONS_DISABLEVARIABLES:
+ g_SetAwayMsgPage.SetDBValue(IDS_SAWAYMSG_DISABLEVARIABLES, !g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_DISABLEVARIABLES));
+ break;
}
- } break;
- case IDC_SAWAYMSG_CONTACTSPLITTER:
+ DestroyMenu(hMenu);
+ }
+ break;
+ case IDC_SAWAYMSG_SAVEMSG:
{
- GetClientRect(hwndDlg, &rc);
- pt.x = wParam;
- pt.y = 0;
- ScreenToClient(hwndDlg, &pt);
- g_ContactSplitterX = (rc.right - pt.x < MINSPLITTERPOS) ? MINSPLITTERPOS : (rc.right - pt.x);
- int MaxSetSplitterX = rc.right - MINSPLITTERPOS + 2;
- int MaxSplitterX = MaxSetSplitterX;
- if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE))
- {
- MaxSetSplitterX -= g_MsgSplitterX;
- MaxSplitterX -= MINSPLITTERPOS;
- }
- if (g_ContactSplitterX > MaxSetSplitterX)
- {
- if (g_ContactSplitterX > MaxSplitterX)
- {
- g_MsgSplitterX = MINSPLITTERPOS;
- g_ContactSplitterX = MaxSplitterX;
- } else
- {
- g_MsgSplitterX = MINSPLITTERPOS + MaxSplitterX - g_ContactSplitterX;
+ CBaseTreeItem* TreeItem = MsgTree->GetSelection();
+ if (TreeItem && !(TreeItem->Flags & TIF_ROOTITEM)) {
+ MsgTree->EnsureVisible(TreeItem->hItem);
+ TCString NewMsg;
+ GetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, NewMsg.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
+ NewMsg.ReleaseBuffer();
+ if (((CTreeItem*)TreeItem)->User_Str1 != (const TCHAR*)NewMsg) {
+ ((CTreeItem*)TreeItem)->User_Str1 = NewMsg;
+ MsgTree->SetModified(true);
}
}
- } break;
+ }
+ break;
+ case IDC_SAWAYMSG_SAVEASNEW:
+ {
+ TCString Text;
+ GetDlgItemText(hwndDlg, IDC_SAWAYMSG_MSGDATA, Text.GetBuffer(AWAY_MSGDATA_MAX), AWAY_MSGDATA_MAX);
+ Text.ReleaseBuffer();
+ UpdateLock++;
+ CTreeItem* TreeItem = MsgTree->AddMessage();
+ UpdateLock--;
+ 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;
+ GetDlgItemText(hwndDlg, IDC_OK, BtnTitle.GetBuffer(64), 64);
+ BtnTitle.ReleaseBuffer();
+ ApplySelContactsMessage(dat, CList);
+ if (BtnTitle != (const TCHAR*)TranslateT("Apply"))
+ SendMessage(hwndDlg, UM_SAM_APPLYANDCLOSE, 0, 0);
}
- SetMsgSplitterX = g_MsgSplitterX;
- SetContactSplitterX = g_ContactSplitterX;
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
- } break;
- case WM_SIZING:
+ }
+ break;
+
+ case UM_SAM_SPLITTERMOVED:
+ switch (lParam) {
+ RECT rc;
+ POINT pt;
+ int MaxSetSplitterX, MaxSplitterX;
+ case IDC_SAWAYMSG_MSGSPLITTER:
+ GetClientRect(hwndDlg, &rc);
+ pt.x = wParam;
+ pt.y = 0;
+ ScreenToClient(hwndDlg, &pt);
+ g_MsgSplitterX = (pt.x < MINSPLITTERPOS) ? MINSPLITTERPOS : pt.x;
+ MaxSetSplitterX = rc.right - MINSPLITTERPOS + 2;
+ MaxSplitterX = MaxSetSplitterX;
+ if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE)) {
+ MaxSetSplitterX -= g_ContactSplitterX;
+ MaxSplitterX -= MINSPLITTERPOS;
+ }
+ if (g_MsgSplitterX > MaxSetSplitterX) {
+ if (g_MsgSplitterX > MaxSplitterX) {
+ g_ContactSplitterX = MINSPLITTERPOS;
+ g_MsgSplitterX = MaxSplitterX;
+ }
+ else g_ContactSplitterX = MINSPLITTERPOS + MaxSplitterX - g_MsgSplitterX;
+ }
+ break;
+
+ case IDC_SAWAYMSG_CONTACTSPLITTER:
+ GetClientRect(hwndDlg, &rc);
+ pt.x = wParam;
+ pt.y = 0;
+ ScreenToClient(hwndDlg, &pt);
+ g_ContactSplitterX = (rc.right - pt.x < MINSPLITTERPOS) ? MINSPLITTERPOS : (rc.right - pt.x);
+ MaxSetSplitterX = rc.right - MINSPLITTERPOS + 2;
+ MaxSplitterX = MaxSetSplitterX;
+ if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE)) {
+ MaxSetSplitterX -= g_MsgSplitterX;
+ MaxSplitterX -= MINSPLITTERPOS;
+ }
+ if (g_ContactSplitterX > MaxSetSplitterX) {
+ if (g_ContactSplitterX > MaxSplitterX) {
+ g_MsgSplitterX = MINSPLITTERPOS;
+ g_ContactSplitterX = MaxSplitterX;
+ }
+ else g_MsgSplitterX = MINSPLITTERPOS + MaxSplitterX - g_ContactSplitterX;
+ }
+ }
+ SetMsgSplitterX = g_MsgSplitterX;
+ SetContactSplitterX = g_ContactSplitterX;
+ SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ break;
+
+ case WM_SIZING:
{
RECT *prcDlg = (RECT*)lParam;
int MinSetXSize = MINSPLITTERPOS + 7;
int MinXSize = MinMsgEditSize + 7;
- if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE))
- {
+ if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWMSGTREE)) {
MinSetXSize += SetMsgSplitterX - 1;
MinXSize += MinMsgSplitterX - 1;
}
- if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE))
- {
+ if (g_SetAwayMsgPage.GetValue(IDS_SAWAYMSG_SHOWCONTACTTREE)) {
MinSetXSize += SetContactSplitterX - 1;
MinXSize += MinContactSplitterX - 1;
}
- if (prcDlg->right - prcDlg->left < MinXSize)
- {
+ if (prcDlg->right - prcDlg->left < MinXSize) {
if (wParam != WMSZ_LEFT && wParam != WMSZ_TOPLEFT && wParam != WMSZ_BOTTOMLEFT)
- {
prcDlg->right = prcDlg->left + MinXSize;
- } else
- {
+ else
prcDlg->left = prcDlg->right - MinXSize;
- }
}
- if (prcDlg->right - prcDlg->left < MinSetXSize)
- {
+ if (prcDlg->right - prcDlg->left < MinSetXSize) {
int Delta = MinSetXSize - (prcDlg->right - prcDlg->left);
- if (SetMsgSplitterX > MinMsgSplitterX)
- {
+ if (SetMsgSplitterX > MinMsgSplitterX) {
int D2 = min(Delta, SetMsgSplitterX - MinMsgSplitterX);
g_MsgSplitterX = SetMsgSplitterX - D2;
Delta -= D2;
}
g_ContactSplitterX = SetContactSplitterX - Delta;
- } else
- {
+ }
+ else {
g_MsgSplitterX = SetMsgSplitterX;
g_ContactSplitterX = SetContactSplitterX;
}
- if (prcDlg->bottom - prcDlg->top < MINYDLGSIZE)
- {
- if (wParam != WMSZ_TOP && wParam != WMSZ_TOPLEFT && wParam != WMSZ_TOPRIGHT)
- {
+ if (prcDlg->bottom - prcDlg->top < MINYDLGSIZE) {
+ if (wParam != WMSZ_TOP && wParam != WMSZ_TOPLEFT && wParam != WMSZ_TOPRIGHT) {
prcDlg->bottom = prcDlg->top + MINYDLGSIZE;
- } else
- {
+ }
+ else {
prcDlg->top = prcDlg->bottom - MINYDLGSIZE;
}
}
- return true;
- } break;
- case WM_SIZE:
+ }
+ return true;
+
+ case WM_SIZE:
{
- UTILRESIZEDIALOG urd = {0};
- urd.cbSize = sizeof(urd);
+ UTILRESIZEDIALOG urd = { sizeof(urd) };
urd.hInstance = g_hInstance;
urd.hwndDlg = hwndDlg;
urd.lParam = (LPARAM)&g_SetAwayMsgPage;
@@ -1612,32 +1340,22 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA ShowWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_STATIC_IGNOREICON), bShow);
ShowWindow(GetDlgItem(hwndDlg, IDC_SAWAYMSG_STATIC_REPLYICON), bShow);
}
- /*if (hWndStatusBar)
- {
- RECT rcStatus; GetWindowRect(hWndStatusBar, &rcStatus);
- RECT rcClient; GetClientRect(hwndDlg, &rcClient);
- SetWindowPos(hWndStatusBar, NULL, 0, rcClient.bottom-(rcStatus.bottom-rcStatus.top), rcClient.right, (rcStatus.bottom-rcStatus.top), SWP_NOZORDER);
- }*/
-
-
} // go through
- case UM_SAM_KILLTIMER:
- case WM_LBUTTONDOWN:
- case WM_MOUSEACTIVATE:
- case WM_MOVING: // stops counting
- {
- if (Countdown != -1) // still counting
- {
- KillTimer(hwndDlg, SAM_TIMER_ID);
- SetDlgItemText(hwndDlg, IDC_OK, TranslateT("OK"));
- Countdown = -1;
- }
- } break;
- case WM_SETCURSOR:
+ case UM_SAM_KILLTIMER:
+ case WM_LBUTTONDOWN:
+ case WM_MOUSEACTIVATE:
+ case WM_MOVING: // stops counting
+ if (Countdown != -1) { // still counting
+ KillTimer(hwndDlg, SAM_TIMER_ID);
+ SetDlgItemText(hwndDlg, IDC_OK, TranslateT("OK"));
+ Countdown = -1;
+ }
+ break;
+
+ case WM_SETCURSOR:
{
HWND hTreeView = GetDlgItem(hwndDlg, IDC_SAWAYMSG_CONTACTSTREE);
- if ((HWND)wParam == hTreeView && LOWORD(lParam) == HTCLIENT)
- {
+ if ((HWND)wParam == hTreeView && LOWORD(lParam) == HTCLIENT) {
_ASSERT(CList);
DWORD hitFlags;
POINT pt;
@@ -1646,53 +1364,41 @@ INT_PTR CALLBACK SetAwayMsgDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA ScreenToClient(hTreeView, &pt);
CList->HitTest(&pt, &hitFlags);
HCURSOR hCursor = NULL;
- if (hitFlags & (MCLCHT_ONITEM | MCLCHT_ONITEMEXTRA))
- {
+ if (hitFlags & (MCLCHT_ONITEM | MCLCHT_ONITEMEXTRA)) {
SetClassLong(hTreeView, GCLP_HCURSOR, NULL);
hCursor = LoadCursor(NULL, IDC_HAND); // set mouse cursor to a hand when hovering over items or their extra images
- } else
- {
- SetClassLong(hTreeView, GCLP_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW));
}
+ else SetClassLong(hTreeView, GCLP_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW));
+
if (!hCursor)
- {
hCursor = LoadCursor(NULL, IDC_ARROW);
- }
+
SetCursor(hCursor);
return true;
- } else
- {
- SetClassLong(hTreeView, GCLP_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW));
}
- } break;
- case WM_CLOSE:
- {
- KillTimer(hwndDlg, SAM_TIMER_ID);
- if (dat->IsModeless)
- {
- DestroyWindow(hwndDlg);
- } else
- {
- EndDialog(hwndDlg, 2);
- }
- } break;
- case WM_DESTROY:
- {
- if (dat)
- {
- delete dat;
- }
- if (CList)
- {
- delete CList;
- CList = NULL;
- }
- delete MsgTree;
- MsgTree = NULL;
- g_SetAwayMsgPage.SetWnd(NULL);
- DestroyWindow(hWndTooltips);
- return false;
- } break;
+ else SetClassLong(hTreeView, GCLP_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW));
+ }
+ break;
+
+ case WM_CLOSE:
+ KillTimer(hwndDlg, SAM_TIMER_ID);
+ if (dat->IsModeless)
+ DestroyWindow(hwndDlg);
+ else
+ EndDialog(hwndDlg, 2);
+ break;
+
+ case WM_DESTROY:
+ delete dat;
+ if (CList) {
+ delete CList;
+ CList = NULL;
+ }
+ delete MsgTree;
+ MsgTree = NULL;
+ g_SetAwayMsgPage.SetWnd(NULL);
+ DestroyWindow(hWndTooltips);
+ return false;
}
return false;
}
diff --git a/plugins/NewAwaySysMod/src/version.h b/plugins/NewAwaySysMod/src/version.h index 3634e99662..27b95c6b1d 100644 --- a/plugins/NewAwaySysMod/src/version.h +++ b/plugins/NewAwaySysMod/src/version.h @@ -1,5 +1,14 @@ -#define STRSPECIALBUILD "2636"
-#define FILEVER 0, 3, 8, 4
-#define STRFILEVER "0, 3, 8, 4"
-#define PRODUCTVER FILEVER
-#define STRPRODUCTVER STRFILEVER
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 4
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "New Away System Mod"
+#define __FILENAME "NewAwaySys.dll"
+#define __DESCRIPTION "New Away System Mod plugin for Miranda IM."
+#define __AUTHOR "NightFox; Deathdemon; XF007; Goblineye Entertainment"
+#define __AUTHOREMAIL "NightFox@myied.org"
+#define __AUTHORWEB "http://miranda-ng.org/p/NewAwaySys/"
+#define __COPYRIGHT "© 2010 NightFox; © 2005-2007 Chervov Dmitry; © 2004-2005 Iksaif; © 2002-2003 Goblineye Entertainment"
|