summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/StatusManager/src/KeepStatus/keepstatus.cpp114
1 files changed, 56 insertions, 58 deletions
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
index 32aef32206..0fe84b286c 100644
--- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
+++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
@@ -64,7 +64,6 @@ static VOID CALLBACK CheckContinueslyTimer(HWND hwnd, UINT message, UINT_PTR idE
INT_PTR IsProtocolEnabledService(WPARAM wParam, LPARAM lParam);
static int ProcessPopup(int reason, LPARAM lParam);
-static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon);
LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static DWORD CALLBACK MessageWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -769,6 +768,41 @@ static VOID CALLBACK CheckContinueslyTimer(HWND, UINT, UINT_PTR, DWORD)
/////////////////////////////////////////////////////////////////////////////////////////
// popup
+static INT_PTR ShowPopup(const wchar_t *msg, HICON hIcon)
+{
+ POPUPDATAT ppd = {};
+ ppd.lchIcon = hIcon;
+ wcsncpy(ppd.lptzContactName, TranslateT("Keep status"), MAX_CONTACTNAME);
+ wcsncpy(ppd.lptzText, msg, MAX_SECONDLINE);
+ if (db_get_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0)) {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ else if (!db_get_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) {
+ ppd.colorBack = db_get_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA);
+ ppd.colorText = db_get_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC);
+ }
+ ppd.PluginWindowProc = KSPopupDlgProc;
+
+ switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) {
+ case POPUP_DELAYCUSTOM:
+ ppd.iSeconds = (int)db_get_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0);
+ if (ppd.iSeconds == 0)
+ ppd.iSeconds = currentDelay / 1000 - 1;
+ break;
+
+ case POPUP_DELAYPERMANENT:
+ ppd.iSeconds = -1;
+ break;
+
+ case POPUP_DELAYFROMPU:
+ default:
+ ppd.iSeconds = 0;
+ break;
+ }
+ return PUAddPopupT(&ppd);
+}
+
static wchar_t* GetHumanName(LPARAM lParam)
{
PROTOACCOUNT *ProtoAccount = Proto_GetAccount((char*)lParam);
@@ -777,19 +811,19 @@ static wchar_t* GetHumanName(LPARAM lParam)
static int ProcessPopup(int reason, LPARAM lParam)
{
- HICON hIcon = nullptr;
- wchar_t text[MAX_SECONDLINE];
-
if (!db_get_b(0, KSMODULENAME, SETTING_SHOWCONNECTIONPOPUPS, FALSE) || !ServiceExists(MS_POPUP_ADDPOPUPT))
return -1;
+ HICON hIcon = nullptr;
+ CMStringW wszText;
+
switch (reason) {
case KS_CONN_STATE_OTHERLOCATION: // lParam = 1 proto
if (!db_get_b(0, KSMODULENAME, SETTING_PUOTHER, TRUE))
return -1;
hIcon = Skin_LoadProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE);
- mir_snwprintf(text, TranslateT("%s connected from another location"), GetHumanName(lParam));
+ wszText.Format(TranslateT("%s connected from another location"), GetHumanName(lParam));
break;
case KS_CONN_STATE_LOGINERROR: // lParam = 1 proto
@@ -798,9 +832,9 @@ static int ProcessPopup(int reason, LPARAM lParam)
hIcon = Skin_LoadProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE);
if (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_CANCEL)
- mir_snwprintf(text, TranslateT("%s login error, cancel reconnecting"), GetHumanName(lParam));
+ wszText.Format(TranslateT("%s login error, cancel reconnecting"), GetHumanName(lParam));
else if (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING) == LOGINERR_SETDELAY)
- mir_snwprintf(text, TranslateT("%s login error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, db_get_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY));
+ wszText.Format(TranslateT("%s login error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, db_get_dw(0, KSMODULENAME, SETTING_LOGINERR_DELAY, DEFAULT_MAXDELAY));
else
return -1;
break;
@@ -811,9 +845,9 @@ static int ProcessPopup(int reason, LPARAM lParam)
if (lParam) { // указатель на имя модуля.
hIcon = Skin_LoadProtoIcon((char*)lParam, SKINICON_STATUS_OFFLINE);
- mir_snwprintf(text, TranslateT("%s status error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, currentDelay / 1000);
+ wszText.Format(TranslateT("%s status error (next retry (%d) in %d s)"), GetHumanName(lParam), retryCount + 1, currentDelay / 1000);
}
- else mir_snwprintf(text, TranslateT("Status error (next retry (%d) in %d s)"), retryCount + 1, currentDelay / 1000);
+ else wszText.Format(TranslateT("Status error (next retry (%d) in %d s)"), retryCount + 1, currentDelay / 1000);
break;
case KS_CONN_STATE_RETRY: // lParam = PROTOCOLSETTINGEX**
@@ -823,7 +857,11 @@ static int ProcessPopup(int reason, LPARAM lParam)
if (lParam) {
PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX **)lParam;
- CMStringW wszProtoInfo(L"\r\n");
+ if (retryCount == maxRetries - 1)
+ wszText.Format(TranslateT("Resetting status... (last try (%d))"), retryCount + 1);
+ else
+ wszText.Format(TranslateT("Resetting status... (next retry (%d) in %d s)"), retryCount + 2, currentDelay / 1000);
+ wszText.Append(L"\r\n");
for (int i = 0; i < protoList.getCount(); i++) {
PROTOCOLSETTINGEX *p = ps[i];
if (p->m_status == ID_STATUS_DISABLED)
@@ -831,16 +869,11 @@ static int ProcessPopup(int reason, LPARAM lParam)
if (mir_wstrlen(p->m_tszAccName) > 0)
if (db_get_b(0, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE))
- wszProtoInfo.AppendFormat(TranslateT("%s\t(will be set to %s)\r\n"), p->m_tszAccName, pcli->pfnGetStatusModeDescription(p->m_status, 0));
+ wszText.AppendFormat(TranslateT("%s\t(will be set to %s)\r\n"), p->m_tszAccName, pcli->pfnGetStatusModeDescription(p->m_status, 0));
}
hIcon = Skin_LoadProtoIcon(ps[0]->m_szName, SKINICON_STATUS_OFFLINE);
- wszProtoInfo.TrimRight();
-
- if (retryCount == maxRetries - 1)
- mir_snwprintf(text, TranslateT("Resetting status... (last try (%d))%s"), retryCount + 1, wszProtoInfo.c_str());
- else
- mir_snwprintf(text, TranslateT("Resetting status... (next retry (%d) in %d s)%s"), retryCount + 2, currentDelay / 1000, wszProtoInfo.c_str());
+ wszText.TrimRight();
}
break;
@@ -849,9 +882,9 @@ static int ProcessPopup(int reason, LPARAM lParam)
return -1;
if (retryCount == maxRetries - 1)
- mir_snwprintf(text, TranslateT("No internet connection seems available... (last try (%d))"), retryCount + 1);
+ wszText.Format(TranslateT("No internet connection seems available... (last try (%d))"), retryCount + 1);
else
- mir_snwprintf(text, TranslateT("No internet connection seems available... (next retry (%d) in %d s)"), retryCount + 2, currentDelay / 1000);
+ wszText.Format(TranslateT("No internet connection seems available... (next retry (%d) in %d s)"), retryCount + 2, currentDelay / 1000);
break;
case KS_CONN_STATE_STOPPEDCHECKING: // lParam == BOOL succes
@@ -860,51 +893,16 @@ static int ProcessPopup(int reason, LPARAM lParam)
if (lParam) {
hIcon = Skin_LoadIcon(SKINICON_STATUS_ONLINE);
- mir_snwprintf(text, TranslateT("Status was set ok"));
+ wszText.Format(TranslateT("Status was set ok"));
}
- else mir_snwprintf(text, TranslateT("Giving up"));
+ else wszText.Format(TranslateT("Giving up"));
break;
}
if (hIcon == nullptr)
hIcon = Skin_LoadIcon(SKINICON_STATUS_OFFLINE);
- log_info(L"KeepStatus: %s", text);
- return ShowPopup(text, hIcon);
-}
-
-static INT_PTR ShowPopup(wchar_t *msg, HICON hIcon)
-{
- POPUPDATAT ppd = {};
- ppd.lchIcon = hIcon;
- wcsncpy(ppd.lptzContactName, TranslateT("Keep status"), MAX_CONTACTNAME);
- wcsncpy(ppd.lptzText, msg, MAX_SECONDLINE);
- if (db_get_b(0, KSMODULENAME, SETTING_POPUP_USEWINCOLORS, 0)) {
- ppd.colorBack = GetSysColor(COLOR_BTNFACE);
- ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
- }
- else if (!db_get_b(0, KSMODULENAME, SETTING_POPUP_USEDEFCOLORS, 0)) {
- ppd.colorBack = db_get_dw(0, KSMODULENAME, SETTING_POPUP_BACKCOLOR, 0xAAAAAA);
- ppd.colorText = db_get_dw(0, KSMODULENAME, SETTING_POPUP_TEXTCOLOR, 0x0000CC);
- }
- ppd.PluginWindowProc = KSPopupDlgProc;
-
- switch (db_get_b(0, KSMODULENAME, SETTING_POPUP_DELAYTYPE, POPUP_DELAYFROMPU)) {
- case POPUP_DELAYCUSTOM:
- ppd.iSeconds = (int)db_get_dw(0, KSMODULENAME, SETTING_POPUP_TIMEOUT, 0);
- if (ppd.iSeconds == 0)
- ppd.iSeconds = currentDelay / 1000 - 1;
- break;
-
- case POPUP_DELAYPERMANENT:
- ppd.iSeconds = -1;
- break;
-
- case POPUP_DELAYFROMPU:
- default:
- ppd.iSeconds = 0;
- break;
- }
- return PUAddPopupT(&ppd);
+ log_info(L"KeepStatus: %s", wszText.c_str());
+ return ShowPopup(wszText, hIcon);
}
LRESULT CALLBACK KSPopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)