From 172ad46d5c457dda639376478e856a3c643635fa Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 30 Jan 2023 19:16:28 +0300 Subject: =?UTF-8?q?fixes=20#3312=20(Telegram:=20=D1=83=D0=BD=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D1=86=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D1=83=20=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D1=82=D1=83=D1=81=D0=BE=D0=B2=20=D1=81=20ICQ)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Telegram/res/resource.rc | 14 +++++++ protocols/Telegram/src/options.cpp | 76 ++++++++++++++++++++++++++++++++++++++ protocols/Telegram/src/proto.cpp | 4 ++ protocols/Telegram/src/proto.h | 4 ++ protocols/Telegram/src/resource.h | 7 ++++ 5 files changed, 105 insertions(+) diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc index 8e8936badf..fcbf34361b 100644 --- a/protocols/Telegram/res/resource.rc +++ b/protocols/Telegram/res/resource.rc @@ -90,6 +90,20 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,4,64,294,10 END +IDD_OPTIONS_ADV DIALOGEX 0, 0, 310, 86 +STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT +FONT 8, "MS Shell Dlg", 0, 0, 0x1 +BEGIN + LTEXT "If a contact goes Offline, set this status instead and cache it for given timeout in seconds (0 - disabled)",IDC_STATIC,12,16,204,23 + EDITTEXT IDC_DIFF1,221,13,54,12,ES_AUTOHSCROLL + CONTROL "",IDC_SPIN1,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,12,11,14 + COMBOBOX IDC_STATUS1,221,28,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "After that, set this status to a contact and move it offline after specified timeout in seconds (0 - disabled)",IDC_STATIC,12,49,204,23 + EDITTEXT IDC_DIFF2,221,46,54,12,ES_AUTOHSCROLL + CONTROL "",IDC_SPIN2,"msctls_updown32",UDS_SETBUDDYINT | UDS_AUTOBUDDY | UDS_ARROWKEYS,275,45,11,14 + COMBOBOX IDC_STATUS2,221,61,81,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP +END ///////////////////////////////////////////////////////////////////////////// // diff --git a/protocols/Telegram/src/options.cpp b/protocols/Telegram/src/options.cpp index 5d2d6b83d5..af8c0c2545 100644 --- a/protocols/Telegram/src/options.cpp +++ b/protocols/Telegram/src/options.cpp @@ -57,6 +57,77 @@ public: } }; +///////////////////////////////////////////////////////////////////////////////////////// +// Advanced options + +class CIcqOptionsAdv : public CProtoDlgBase +{ + CCtrlEdit edtDiff1, edtDiff2; + CCtrlSpin spin1, spin2; + CCtrlCombo cmbStatus1, cmbStatus2; + +public: + CIcqOptionsAdv(CTelegramProto *ppro) : + CProtoDlgBase(ppro, IDD_OPTIONS_ADV), + spin1(this, IDC_SPIN1, 32000), + spin2(this, IDC_SPIN2, 32000), + edtDiff1(this, IDC_DIFF1), + edtDiff2(this, IDC_DIFF2), + cmbStatus1(this, IDC_STATUS1), + cmbStatus2(this, IDC_STATUS2) + { + edtDiff1.OnChange = Callback(this, &CIcqOptionsAdv::onChange_Timeout1); + edtDiff2.OnChange = Callback(this, &CIcqOptionsAdv::onChange_Timeout2); + + CreateLink(spin1, ppro->m_iTimeDiff1); + CreateLink(spin2, ppro->m_iTimeDiff2); + } + + bool OnInitDialog() override + { + if (cmbStatus1.GetHwnd()) { + for (uint32_t iStatus = ID_STATUS_OFFLINE; iStatus <= ID_STATUS_MAX; iStatus++) { + int idx = cmbStatus1.AddString(Clist_GetStatusModeDescription(iStatus, 0)); + cmbStatus1.SetItemData(idx, iStatus); + if (iStatus == m_proto->m_iStatus1) + cmbStatus1.SetCurSel(idx); + + idx = cmbStatus2.AddString(Clist_GetStatusModeDescription(iStatus, 0)); + cmbStatus2.SetItemData(idx, iStatus); + if (iStatus == m_proto->m_iStatus2) + cmbStatus2.SetCurSel(idx); + } + } + + return true; + } + + bool OnApply() override + { + if (cmbStatus1.GetHwnd()) { + m_proto->m_iStatus1 = cmbStatus1.GetCurData(); + m_proto->m_iStatus2 = cmbStatus2.GetCurData(); + } + + return true; + } + + void onChange_Timeout1(CCtrlEdit *) + { + bool bEnabled = edtDiff1.GetInt() != 0; + spin2.Enable(bEnabled); + edtDiff2.Enable(bEnabled); + cmbStatus1.Enable(bEnabled); + cmbStatus2.Enable(bEnabled && edtDiff2.GetInt() != 0); + } + + void onChange_Timeout2(CCtrlEdit *) + { + bool bEnabled = edtDiff2.GetInt() != 0; + cmbStatus2.Enable(bEnabled); + } +}; + ///////////////////////////////////////////////////////////////////////////////////////// INT_PTR CTelegramProto::SvcCreateAccMgrUI(WPARAM, LPARAM hwndParent) @@ -78,5 +149,10 @@ int CTelegramProto::OnOptionsInit(WPARAM wParam, LPARAM) odp.szTab.w = LPGENW("Account"); odp.pDialog = new COptionsDlg(this, IDD_OPTIONS, true); g_plugin.addOptions(wParam, &odp); + + odp.position = 2; + odp.szTab.w = LPGENW("Advanced"); + odp.pDialog = new CIcqOptionsAdv(this); + g_plugin.addOptions(wParam, &odp); return 0; } diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp index fa9313c0be..715e511ea3 100644 --- a/protocols/Telegram/src/proto.cpp +++ b/protocols/Telegram/src/proto.cpp @@ -23,6 +23,10 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) : m_arUsers(10, CompareUsers), m_arRequests(10, CompareRequests), m_szOwnPhone(this, "Phone"), + m_iStatus1(this, "Status1", ID_STATUS_AWAY), + m_iStatus2(this, "Status2", ID_STATUS_NA), + m_iTimeDiff1(this, "TimeDiff1", 600), + m_iTimeDiff2(this, "TimeDiff2", 600), m_wszDeviceName(this, "DeviceName", L"Miranda NG"), m_wszDefaultGroup(this, "DefaultGroup", L"Telegram"), m_bUsePopups(this, "UsePopups", true), diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h index c88c6c9666..ba643520e5 100644 --- a/protocols/Telegram/src/proto.h +++ b/protocols/Telegram/src/proto.h @@ -226,6 +226,10 @@ public: CMOption m_wszDeviceName; // how do you see this session in Device List CMOption m_bHideGroupchats; // do not open chat windows on creation CMOption m_bUsePopups; + CMOption m_iTimeDiff1; // set this status to m_iStatus1 after this interval of secs + CMOption m_iStatus1; + CMOption m_iTimeDiff2; // set this status to m_iStatus2 after this interval of secs + CMOption m_iStatus2; // Processing Threads //////////////////////////////////////////////////////////////// diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h index 9ea3641d02..5bd28839a5 100644 --- a/protocols/Telegram/src/resource.h +++ b/protocols/Telegram/src/resource.h @@ -6,12 +6,19 @@ #define IDD_ACCMGRUI 101 #define IDD_OPTIONS 102 #define IDI_PREMIUM 103 +#define IDD_OPTIONS_ADV 104 #define IDC_PHONE 1001 #define IDC_DEFGROUP 1002 #define IDC_HIDECHATS 1003 #define IDC_POPUPS 1004 #define IDC_DEFGROUP2 1004 #define IDC_DEVICE_NAME 1005 +#define IDC_DIFF1 1006 +#define IDC_DIFF2 1007 +#define IDC_SPIN1 1008 +#define IDC_SPIN2 1009 +#define IDC_STATUS1 1010 +#define IDC_STATUS2 1011 // Next default values for new objects // -- cgit v1.2.3