summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-29 14:54:24 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-29 14:54:30 +0300
commitfe0ce0abd68bed541735f3519a52a802bb87ca0a (patch)
treec9d0e2adb21a15d9707489e300b0a24855d44e5a
parent6e8defa9cc46283eb1e8f53ed24f80b05abc5e01 (diff)
StatusManager:
- all protocol data really merged together; - duplicated settings arrays removed; - stupid protoList removed; - fixed #1119; - version bump
-rw-r--r--plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp32
-rw-r--r--plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp120
-rw-r--r--plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h52
-rw-r--r--plugins/StatusManager/src/KeepStatus/keepstatus.cpp164
-rw-r--r--plugins/StatusManager/src/KeepStatus/keepstatus.h11
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_options.cpp74
-rw-r--r--plugins/StatusManager/src/StartupStatus/ss_profiles.cpp37
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.cpp134
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.h23
-rw-r--r--plugins/StatusManager/src/commonstatus.cpp33
-rw-r--r--plugins/StatusManager/src/commonstatus.h69
-rw-r--r--plugins/StatusManager/src/confirmdialog.cpp2
-rw-r--r--plugins/StatusManager/src/main.cpp53
-rw-r--r--plugins/StatusManager/src/options.cpp130
-rw-r--r--plugins/StatusManager/src/stdafx.h22
-rw-r--r--plugins/StatusManager/src/version.h4
16 files changed, 397 insertions, 563 deletions
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp
index 3a733b9074..9e979e1230 100644
--- a/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp
+++ b/plugins/StatusManager/src/AdvancedAutoAway/aaa_options.cpp
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "..\stdafx.h"
-int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char* protoName);
+int LoadAutoAwaySetting(SMProto &autoAwaySetting, char* protoName);
INT_PTR CALLBACK DlgProcAutoAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -28,7 +28,7 @@ static BOOL bSettingSame = FALSE;
/////////////////////////////////////////////////////////////////////////////////////////
// Dialog service functions
-static int WriteAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoName)
+static int WriteAutoAwaySetting(SMProto &autoAwaySetting, char *protoName)
{
char setting[128];
mir_snprintf(setting, "%s_OptionFlags", protoName);
@@ -47,7 +47,7 @@ static int WriteAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoNa
return 0;
}
-static void SetDialogItems(HWND hwndDlg, TAAAProtoSetting *setting)
+static void SetDialogItems(HWND hwndDlg, SMProto *setting)
{
bool bIsTimed = (setting->optionFlags & FLAG_ONMOUSE) != 0;
bool bSetNA = (setting->optionFlags & FLAG_SETNA) != 0;
@@ -83,7 +83,7 @@ static void SetDialogItems(HWND hwndDlg, TAAAProtoSetting *setting)
EnableWindow(GetDlgItem(hwndDlg, IDC_PROTOCOL), !bSettingSame);
}
-static TAAAProtoSetting* GetSetting(HWND hwndDlg, TAAAProtoSetting *sameSetting)
+static SMProto* GetSetting(HWND hwndDlg, SMProto *sameSetting)
{
if (bSettingSame)
return sameSetting;
@@ -93,12 +93,12 @@ static TAAAProtoSetting* GetSetting(HWND hwndDlg, TAAAProtoSetting *sameSetting)
return nullptr;
INT_PTR iData = (INT_PTR)SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_GETITEMDATA, iItem, 0);
- return (iData == -1) ? nullptr : (TAAAProtoSetting*)iData;
+ return (iData == -1) ? nullptr : (SMProto*)iData;
}
-static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting)
+static void SetDialogStatus(HWND hwndDlg, SMProto *sameSetting)
{
- TAAAProtoSetting *setting = GetSetting(hwndDlg, sameSetting);
+ SMProto *setting = GetSetting(hwndDlg, sameSetting);
if (setting == nullptr)
return;
@@ -119,17 +119,17 @@ static void SetDialogStatus(HWND hwndDlg, TAAAProtoSetting *sameSetting)
/////////////////////////////////////////////////////////////////////////////////////////
// Rules dialog window procedure
-int AAACompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2)
+int AAACompareSettings(const SMProto *p1, const SMProto *p2)
{
return mir_strcmp(p1->m_szName, p2->m_szName);
}
-static TAAAProtoSettingList optionSettings(10, AAACompareSettings);
+static TProtoSettings optionSettings(10, AAACompareSettings);
static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static TAAAProtoSetting* sameSetting;
- TAAAProtoSetting *setting;
+ static SMProto* sameSetting;
+ SMProto *setting;
static int init;
switch (msg) {
@@ -138,15 +138,15 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM
TranslateDialogDefault(hwndDlg);
// copy the settings
- optionSettings = autoAwaySettings;
+ optionSettings = protoList;
- sameSetting = (TAAAProtoSetting*)malloc(sizeof(TAAAProtoSetting));
+ sameSetting = (SMProto*)malloc(sizeof(SMProto));
LoadAutoAwaySetting(*sameSetting, SETTING_ALL);
// fill list from currentProtoSettings
{
for (int i = 0; i < optionSettings.getCount(); i++) {
- TAAAProtoSetting &p = optionSettings[i];
+ SMProto &p = optionSettings[i];
int item = SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM)p.m_tszAccName);
SendDlgItemMessage(hwndDlg, IDC_PROTOCOL, CB_SETITEMDATA, item, (LPARAM)&p);
}
@@ -342,7 +342,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayRulesOpts(HWND hwndDlg, UINT msg, WPARAM
for (int i = 0; i < optionSettings.getCount(); i++)
WriteAutoAwaySetting(optionSettings[i], optionSettings[i].m_szName);
}
- AAALoadOptions(autoAwaySettings, false);
+ AAALoadOptions();
}
break;
@@ -407,7 +407,7 @@ static INT_PTR CALLBACK DlgProcAutoAwayGeneralOpts(HWND hwndDlg, UINT msg, WPARA
db_set_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, (WORD)GetDlgItemInt(hwndDlg, IDC_CONFIRMDELAY, nullptr, FALSE));
db_set_b(0, AAAMODULENAME, SETTING_MONITORMOUSE, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORMOUSE));
db_set_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_MONITORKEYBOARD));
- AAALoadOptions(autoAwaySettings, false);
+ AAALoadOptions();
}
break;
}
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
index 81cff37ffd..b37830b90f 100644
--- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
+++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
@@ -30,28 +30,9 @@
/////////////////////////////////////////////////////////////////////////////////////////
-TAAAProtoSettingList autoAwaySettings(10, AAACompareSettings);
-
-TAAAProtoSetting::TAAAProtoSetting(PROTOACCOUNT *pa)
-{
- m_szName = pa->szModuleName;
- m_tszAccName = pa->tszAccountName;
- m_lastStatus = m_status = originalStatusMode = ID_STATUS_CURRENT;
- m_szMsg = nullptr;
- curState = ACTIVE;
- mStatus = FALSE;
-}
-
-TAAAProtoSetting::~TAAAProtoSetting()
-{
- free(m_szMsg);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
int AAALangPack;
-static HANDLE hEvents[4];
+static HANDLE hEvents[3];
static BOOL ignoreLockKeys = FALSE;
static BOOL ignoreSysKeys = FALSE;
@@ -88,21 +69,20 @@ extern char *StatusModeToDbSetting(int status, const char *suffix);
/////////////////////////////////////////////////////////////////////////////////////////
// Load from DB
-void AAAUnloadOptions(bool bOverride)
+void AAAUnloadOptions()
{
- if (!bOverride)
- UnhookWindowsHooks();
+ UnhookWindowsHooks();
if (hAutoAwayTimer != 0)
KillTimer(nullptr, hAutoAwayTimer);
}
-void AAALoadOptions(TAAAProtoSettingList &loadSettings, bool bOverride)
+void AAALoadOptions()
{
// if bOverride is enabled, samesettings will be ignored (for options loading)
int monitorMiranda = FALSE; // use windows hooks?
int monitorAll = FALSE; // use windows hooks?
- AAAUnloadOptions(bOverride);
+ AAAUnloadOptions();
ignoreLockKeys = db_get_b(0, AAAMODULENAME, SETTING_IGNLOCK, FALSE);
ignoreSysKeys = db_get_b(0, AAAMODULENAME, SETTING_IGNSYSKEYS, FALSE);
@@ -111,19 +91,18 @@ void AAALoadOptions(TAAAProtoSettingList &loadSettings, bool bOverride)
monitorKeyboard = db_get_b(0, AAAMODULENAME, SETTING_MONITORKEYBOARD, TRUE);
lastInput = lastMirandaInput = GetTickCount();
- for (int i = 0; i < loadSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
char* protoName;
- if ((db_get_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, 0)) && !bOverride)
+ if ((db_get_b(0, AAAMODULENAME, SETTING_SAMESETTINGS, 0)))
protoName = SETTING_ALL;
else
- protoName = loadSettings[i].m_szName;
- LoadAutoAwaySetting(loadSettings[i], protoName);
- if (!bOverride) {
- if (loadSettings[i].optionFlags & FLAG_MONITORMIRANDA)
- monitorMiranda = TRUE;
- else if (ignoreLockKeys || ignoreSysKeys || ignoreAltCombo || (monitorMouse != monitorKeyboard))
- monitorAll = TRUE;
- }
+ protoName = protoList[i].m_szName;
+ LoadAutoAwaySetting(protoList[i], protoName);
+
+ if (protoList[i].optionFlags & FLAG_MONITORMIRANDA)
+ monitorMiranda = TRUE;
+ else if (ignoreLockKeys || ignoreSysKeys || ignoreAltCombo || (monitorMouse != monitorKeyboard))
+ monitorAll = TRUE;
}
if (db_get_b(0, "Idle", "AAEnable", 0))
@@ -133,7 +112,7 @@ void AAALoadOptions(TAAAProtoSettingList &loadSettings, bool bOverride)
hAutoAwayTimer = SetTimer(nullptr, 0, db_get_w(0, AAAMODULENAME, SETTING_AWAYCHECKTIMEINSECS, 5) * 1000, AutoAwayTimer);
}
-int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char* protoName)
+int LoadAutoAwaySetting(SMProto &autoAwaySetting, char* protoName)
{
char setting[128];
mir_snprintf(setting, "%s_OptionFlags", protoName);
@@ -165,8 +144,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
return 0;
log_debugA("ProcessProtoAck: ack->szModule: %s", ack->szModule);
- for (int i = 0; i < autoAwaySettings.getCount(); i++) {
- TAAAProtoSetting &p = autoAwaySettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &p = protoList[i];
log_debugA("chk: %s", p.m_szName);
if (!mir_strcmp(p.m_szName, ack->szModule)) {
log_debugA("ack->szModule: %s p.statusChanged: %d", ack->szModule, p.statusChanged);
@@ -183,27 +162,6 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
// Account control event
-int OnAAAAccChanged(WPARAM wParam, LPARAM lParam)
-{
- PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
- switch (wParam) {
- case PRAC_ADDED:
- autoAwaySettings.insert(new TAAAProtoSetting(pa));
- break;
-
- case PRAC_REMOVED:
- for (int i = 0; i < autoAwaySettings.getCount(); i++) {
- if (!mir_strcmp(autoAwaySettings[i].m_szName, pa->szModuleName)) {
- autoAwaySettings.remove(i);
- break;
- }
- }
- break;
- }
-
- return 0;
-}
-
static char* status2descr(int status)
{
switch (status) {
@@ -216,7 +174,7 @@ static char* status2descr(int status)
return "ERROR";
}
-static int changeState(TAAAProtoSetting &setting, STATES newState)
+static int changeState(SMProto &setting, STATES newState)
{
if (setting.curState == newState)
return 0;
@@ -254,8 +212,8 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD)
int statusChanged = FALSE;
int confirm = FALSE;
- for (int i = 0; i < autoAwaySettings.getCount(); i++) {
- TAAAProtoSetting& aas = autoAwaySettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto& aas = protoList[i];
aas.m_status = ID_STATUS_DISABLED;
BOOL bTrigger = false;
@@ -362,11 +320,11 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD)
changeState(aas, ACTIVE);
aas.sts1setTimer = 0;
}
- autoAwaySettings[i].mStatus = FALSE;
+ protoList[i].mStatus = FALSE;
}
if (confirm || statusChanged) {
- TAAAProtoSettingList ps = autoAwaySettings;
+ TProtoSettings ps = protoList;
for (int i = 0; i < ps.getCount(); i++) {
if (ps[i].m_szMsg)
ps[i].m_szMsg = wcsdup(ps[i].m_szMsg);
@@ -376,7 +334,7 @@ static VOID CALLBACK AutoAwayTimer(HWND, UINT, UINT_PTR, DWORD)
}
if (confirm)
- confirmDialog = ShowConfirmDialogEx((TProtoSettings*)&ps, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5));
+ confirmDialog = ShowConfirmDialogEx(&ps, db_get_w(0, AAAMODULENAME, SETTING_CONFIRMDELAY, 5));
else if (statusChanged)
CallService(MS_CS_SETSTATUSEX, (WPARAM)&ps, 0);
}
@@ -545,35 +503,22 @@ static LRESULT CALLBACK KeyBoardHookFunction(int code, WPARAM wParam, LPARAM lPa
static int AutoAwayShutdown(WPARAM, LPARAM)
{
- AAAUnloadOptions(false);
+ AAAUnloadOptions();
return 0;
}
int AAAModuleLoaded(WPARAM, LPARAM)
{
- hEvents[0] = HookEvent(ME_PROTO_ACCLISTCHANGED, OnAAAAccChanged);
- hEvents[1] = HookEvent(ME_OPT_INITIALISE, AutoAwayOptInitialise);
- hEvents[2] = HookEvent(ME_SYSTEM_PRESHUTDOWN, AutoAwayShutdown);
- hEvents[3] = HookEvent(ME_PROTO_ACK, ProcessProtoAck);
+ hEvents[0] = HookEvent(ME_OPT_INITIALISE, AutoAwayOptInitialise);
+ hEvents[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, AutoAwayShutdown);
+ hEvents[2] = HookEvent(ME_PROTO_ACK, ProcessProtoAck);
mouseStationaryTimer = 0;
lastInput = lastMirandaInput = GetTickCount();
////////////////////////////////////////////////////////////////////////////////////////
- protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&autoAwaySettings;
-
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- autoAwaySettings.insert(new TAAAProtoSetting(protos[i]));
-
- ////////////////////////////////////////////////////////////////////////////////////////
-
- AAALoadOptions(autoAwaySettings, false);
+ AAALoadOptions();
return 0;
}
@@ -581,11 +526,10 @@ void AdvancedAutoAwayLoad()
{
AAALangPack = GetPluginLangId(MIID_LAST, 0);
- if (g_bMirandaLoaded) {
+ if (g_bMirandaLoaded)
AAAModuleLoaded(0, 0);
- AutoAwayOptInitialise(0, 0);
- }
- else HookEvent(ME_SYSTEM_MODULESLOADED, AAAModuleLoaded);
+ else
+ HookEvent(ME_SYSTEM_MODULESLOADED, AAAModuleLoaded);
}
void AdvancedAutoAwayUnload()
@@ -600,5 +544,5 @@ void AdvancedAutoAwayUnload()
it = nullptr;
}
- autoAwaySettings.destroy();
+ protoList.destroy();
}
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h
index 8ba6e3f606..b6ca5cbeb6 100644
--- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h
+++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.h
@@ -33,61 +33,13 @@
#define SETTING_NATIME_DEFAULT 20
#define SETTING_AWAYCHECKTIMEINSECS "CheckInterval"
-#define STATUS_RESET 1
-#define STATUS_AUTOAWAY 2
-#define STATUS_AUTONA 3
-
#define SETTING_MONITORMOUSE "MonitorMouse"
#define SETTING_MONITORKEYBOARD "MonitorKeyboard"
-#define FLAG_ONSAVER 0x0001 // db: set lv1 status on screensaver ?
-#define FLAG_ONMOUSE 0x0002 // db: set after inactivity ?
-#define FLAG_SETNA 0x0004 // db: set NA after xx of away time ?
-#define FLAG_CONFIRM 0x0008 // db: show confirm dialog ?
-#define FLAG_RESET 0x0010 // db: restore status ?
-#define FLAG_LV2ONINACTIVE 0x0020 // db: set lv2 only on inactivity
-#define FLAG_MONITORMIRANDA 0x0040 // db: monitor miranda activity only
-#define FLAG_ONLOCK 0x0080 // db: on work station lock
-#define FLAG_FULLSCREEN 0x0100 // db: on full screen
-
-typedef enum
-{
- ACTIVE, // user is active
- STATUS1_SET, // first status change happened
- STATUS2_SET, // second status change happened
- SET_ORGSTATUS, // user was active again, original status will be restored
- HIDDEN_ACTIVE // user is active, but this is not shown to the outside world
-} STATES;
-
-struct TAAAProtoSetting : public PROTOCOLSETTINGEX, public MZeroedObject
-{
- TAAAProtoSetting(PROTOACCOUNT *pa);
- ~TAAAProtoSetting();
-
- int originalStatusMode;
- STATES
- oldState,
- curState;
- BOOL statusChanged; // AAA changed the status, don't update mStatus
- BOOL mStatus; // status changed manually or not ?
- int optionFlags, // db: see above
- awayTime, // db: time to wait for inactivity
- naTime, // db: time to wait after away is set
- statusFlags; // db: set lv1 status if this is original status
- WORD lv1Status, // db
- lv2Status; // db
- unsigned int sts1setTimer;
-};
-
-int AAACompareSettings(const TAAAProtoSetting *p1, const TAAAProtoSetting *p2);
-
void AdvancedAutoAwayLoad();
void AdvancedAutoAwayUnload();
-typedef OBJLIST<TAAAProtoSetting> TAAAProtoSettingList;
-extern TAAAProtoSettingList autoAwaySettings;
-
-int LoadAutoAwaySetting(TAAAProtoSetting &autoAwaySetting, char *protoName);
-void AAALoadOptions(TAAAProtoSettingList &settings, bool override);
+int LoadAutoAwaySetting(SMProto&, char *protoName);
+void AAALoadOptions();
#endif
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
index 5c925893f9..bbdc6587c7 100644
--- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
+++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
@@ -22,7 +22,7 @@
int KSLangPack;
static HANDLE hConnectionEvent = nullptr;
-static HANDLE hServices[4], hEvents[3];
+static HANDLE hServices[4], hEvents[2];
static mir_cs GenTimerCS, GenStatusCS, CheckContinueslyCS;
@@ -33,13 +33,6 @@ static HANDLE hCSStatusChangeExHook = nullptr;
static HWND hMessageWindow = nullptr;
-static int CompareConnections(const TKSSettings *p1, const TKSSettings *p2)
-{
- return mir_strcmp(p1->m_szName, p2->m_szName);
-}
-
-static OBJLIST<TKSSettings> connectionSettings(10, CompareConnections);
-
static UINT_PTR checkConnectionTimerId = 0;
static UINT_PTR afterCheckTimerId = 0;
static UINT_PTR processAckTimerId = 0;
@@ -80,22 +73,6 @@ extern int KeepStatusOptionsInit(WPARAM wparam, LPARAM);
/////////////////////////////////////////////////////////////////////////////////////////
-TKSSettings::TKSSettings(PROTOACCOUNT *pa)
-{
- m_szName = pa->szModuleName;
- m_tszAccName = pa->tszAccountName;
- m_szMsg = nullptr;
- m_status = m_lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
-}
-
-TKSSettings::~TKSSettings()
-{
- if (m_szMsg != nullptr)
- free(m_szMsg);
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
void KSUnloadOptions()
{
UnhookEvent(hProtoAckHook);
@@ -111,22 +88,12 @@ void KSUnloadOptions()
WSACleanup();
StopTimer(IDT_CHECKCONN | IDT_PROCESSACK | IDT_AFTERCHECK | IDT_CHECKCONTIN | IDT_CHECKCONNECTING);
-
- connectionSettings.destroy();
}
int KSLoadOptions()
{
KSUnloadOptions();
- int count;
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- connectionSettings.insert(new TKSSettings(protos[i]));
-
if (db_get_b(0, KSMODULENAME, SETTING_CHECKCONNECTION, FALSE)) {
if (db_get_b(0, KSMODULENAME, SETTING_CONTCHECK, FALSE)) {
if (db_get_b(0, KSMODULENAME, SETTING_BYPING, FALSE)) {
@@ -163,18 +130,18 @@ int KSLoadOptions()
static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy()
{
mir_cslock lck(GenStatusCS);
- PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(connectionSettings.getCount() * sizeof(PROTOCOLSETTINGEX *));
+ PROTOCOLSETTINGEX **ps = (PROTOCOLSETTINGEX**)malloc(protoList.getCount() * sizeof(PROTOCOLSETTINGEX *));
if (ps == nullptr) {
return nullptr;
}
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
ps[i] = (PROTOCOLSETTINGEX*)calloc(1, sizeof(PROTOCOLSETTINGEX));
if (ps[i] == nullptr) {
free(ps);
return nullptr;
}
- TKSSettings &cs = connectionSettings[i];
+ SMProto &cs = protoList[i];
ps[i]->m_lastStatus = cs.m_lastStatus;
ps[i]->m_status = cs.m_status;
ps[i]->m_szMsg = nullptr;
@@ -187,7 +154,7 @@ static PROTOCOLSETTINGEX** GetCurrentProtoSettingsCopy()
static void FreeProtoSettings(PROTOCOLSETTINGEX** ps)
{
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
if (ps[i]->m_szMsg != nullptr)
free(ps[i]->m_szMsg);
free(ps[i]);
@@ -195,7 +162,7 @@ static void FreeProtoSettings(PROTOCOLSETTINGEX** ps)
free(ps);
}
-int TKSSettings::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg)
+int SMProto::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg)
{
if (iStatus < MIN_STATUS || iStatus > MAX_STATUS)
return -1;
@@ -233,7 +200,7 @@ int TKSSettings::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg)
return 0;
}
-int TKSSettings::GetStatus() const
+int SMProto::GetStatus() const
{
switch (m_status) {
case ID_STATUS_CURRENT:
@@ -248,10 +215,10 @@ int TKSSettings::GetStatus() const
static int SetCurrentStatus()
{
PROTOCOLSETTINGEX **ps = GetCurrentProtoSettingsCopy();
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
auto p = ps[i];
int realStatus = CallProtoService(p->m_szName, PS_GETSTATUS, 0, 0);
- int curStatus = connectionSettings[i].GetStatus();
+ int curStatus = protoList[i].GetStatus();
if (curStatus == ID_STATUS_DISABLED || curStatus == realStatus) { // ignore this proto by removing it's name (not so nice)
p->m_szName = "";
}
@@ -276,14 +243,14 @@ static int StatusChange(WPARAM wParam, LPARAM lParam)
{
char *szProto = (char *)lParam;
if (szProto == nullptr) { // global status change
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
cs.AssignStatus(wParam, 0, cs.m_szMsg);
}
}
else {
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(cs.m_szName, szProto))
cs.AssignStatus(wParam, 0, cs.m_szMsg);
}
@@ -300,13 +267,13 @@ static int CSStatusChange(WPARAM wParam, LPARAM)
if (protoSettings == nullptr)
return -1;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
auto psi = protoSettings[i];
if (psi->szName == nullptr)
continue;
- for (int j = 0; j < connectionSettings.getCount(); j++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int j = 0; j < protoList.getCount(); j++) {
+ SMProto &cs = protoList[i];
if (cs.m_szName == nullptr)
continue;
@@ -327,13 +294,13 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM)
if (protoSettings == nullptr)
return -1;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
auto psi = protoSettings[i];
if (psi->m_szName == nullptr)
continue;
- for (int j = 0; j < connectionSettings.getCount(); j++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int j = 0; j < protoList.getCount(); j++) {
+ SMProto &cs = protoList[i];
if (cs.m_szName == nullptr)
continue;
@@ -515,8 +482,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
return 0;
if (ack->type == ACKTYPE_STATUS && ack->result == ACKRESULT_SUCCESS) {
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(cs.m_szName, ack->szModule))
cs.lastStatusAckTime = GetTickCount();
}
@@ -526,14 +493,14 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
if (ack->type == ACKTYPE_LOGIN) {
if (ack->lParam == LOGINERR_OTHERLOCATION) {
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(ack->szModule, cs.m_szName)) {
cs.AssignStatus(ID_STATUS_OFFLINE);
if (db_get_b(0, KSMODULENAME, SETTING_CNCOTHERLOC, 0)) {
StopTimer(IDT_PROCESSACK);
- for (int j = 0; j < connectionSettings.getCount(); j++)
- connectionSettings[j].AssignStatus(ID_STATUS_OFFLINE);
+ for (int j = 0; j < protoList.getCount(); j++)
+ protoList[j].AssignStatus(ID_STATUS_OFFLINE);
}
NotifyEventHooks(hConnectionEvent, (WPARAM)KS_CONN_STATE_OTHERLOCATION, (LPARAM)cs.m_szName);
@@ -548,8 +515,8 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
switch (db_get_b(0, KSMODULENAME, SETTING_LOGINERR, LOGINERR_NOTHING)) {
case LOGINERR_CANCEL:
log_infoA("KeepStatus: cancel on login error (%s)", ack->szModule);
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(ack->szModule, cs.m_szName))
cs.AssignStatus(ID_STATUS_OFFLINE);
}
@@ -581,8 +548,8 @@ static VOID CALLBACK CheckConnectingTimer(HWND, UINT, UINT_PTR, DWORD)
{
StopTimer(IDT_CHECKCONNECTING);
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
int curStatus = cs.GetStatus();
if (IsStatusConnecting(curStatus)) { // connecting
@@ -603,8 +570,8 @@ static VOID CALLBACK CheckAckStatusTimer(HWND, UINT, UINT_PTR, DWORD)
bool needChecking = false;
StopTimer(IDT_PROCESSACK);
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
int curStatus = cs.GetStatus();
int newStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0);
@@ -641,8 +608,8 @@ static VOID CALLBACK CheckConnectionTimer(HWND, UINT, UINT_PTR, DWORD)
log_debugA("CheckConnectionTimer");
bool setStatus = false;
- for (int i = 0; i < connectionSettings.getCount() && !setStatus; i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount() && !setStatus; i++) {
+ SMProto &cs = protoList[i];
int realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0);
int shouldBeStatus = cs.GetStatus();
if (shouldBeStatus == ID_STATUS_LAST)
@@ -682,8 +649,8 @@ static int StopChecking()
StopTimer(IDT_CHECKCONN | IDT_PROCESSACK | IDT_AFTERCHECK | IDT_CHECKCONNECTING);
BOOL isOk = TRUE;
- for (int i = 0; i < connectionSettings.getCount() && isOk; i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount() && isOk; i++) {
+ SMProto &cs = protoList[i];
int curStatus = cs.GetStatus();
int newStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0);
if (newStatus != curStatus) {
@@ -708,8 +675,8 @@ static VOID CALLBACK AfterCheckTimer(HWND, UINT, UINT_PTR, DWORD)
bool setStatus = false;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
int realStatus = CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0);
int shouldBeStatus = cs.GetStatus();
if (shouldBeStatus == ID_STATUS_LAST) // this should never happen
@@ -735,8 +702,8 @@ static void CheckContinuouslyFunction(void *)
// do a ping, even if reconnecting
bool doPing = false;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
int shouldBeStatus = cs.GetStatus();
if (shouldBeStatus == ID_STATUS_LAST)
shouldBeStatus = cs.m_lastStatus;
@@ -910,7 +877,7 @@ static int ProcessPopup(int reason, LPARAM lParam)
memset(protoInfoLine, '\0', sizeof(protoInfoLine));
memset(protoInfo, '\0', sizeof(protoInfo));
mir_wstrcpy(protoInfo, L"\r\n");
- for (int i = 0; i < connectionSettings.getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
if (mir_wstrlen(ps[i]->m_tszAccName) > 0 && mir_strlen(ps[i]->m_szName) > 0) {
if (db_get_b(0, KSMODULENAME, SETTING_PUSHOWEXTRA, TRUE)) {
mir_snwprintf(protoInfoLine, TranslateT("%s\t(will be set to %s)\r\n"), ps[i]->m_tszAccName, pcli->pfnGetStatusModeDescription(ps[i]->m_status, 0));
@@ -1038,8 +1005,8 @@ INT_PTR EnableProtocolService(WPARAM wParam, LPARAM lParam)
return -1;
int ret = -2;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(szProto, cs.m_szName)) {
if (wParam)
cs.AssignStatus(CallProtoService(cs.m_szName, PS_GETSTATUS, 0, 0));
@@ -1062,8 +1029,8 @@ INT_PTR IsProtocolEnabledService(WPARAM, LPARAM lParam)
if (!db_get_b(0, KSMODULENAME, dbSetting, 1))
return FALSE;
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(szProto, cs.m_szName))
return cs.GetStatus() != ID_STATUS_DISABLED;
}
@@ -1076,8 +1043,8 @@ INT_PTR AnnounceStatusChangeService(WPARAM, LPARAM lParam)
PROTOCOLSETTINGEX *newSituation = (PROTOCOLSETTINGEX *)lParam;
log_infoA("Another plugin announced a status change to %d for %s", newSituation->m_status, newSituation->m_szName == nullptr ? "all" : newSituation->m_szName);
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- TKSSettings &cs = connectionSettings[i];
+ for (int i = 0; i < protoList.getCount(); i++) {
+ SMProto &cs = protoList[i];
if (!mir_strcmp(cs.m_szName, newSituation->m_szName))
cs.AssignStatus(newSituation->m_status, newSituation->m_lastStatus, newSituation->m_szMsg);
}
@@ -1099,7 +1066,7 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara
log_infoA("KeepStatus: suspend state detected: %08X %08X", wParam, lParam);
if (ps == nullptr) {
ps = GetCurrentProtoSettingsCopy();
- for (int i = 0; i < connectionSettings.getCount(); i++)
+ for (int i = 0; i < protoList.getCount(); i++)
EnableProtocolService(0, (LPARAM)ps[i]->m_szName);
// set proto's offline, the clist will not try to reconnect in that case
@@ -1112,8 +1079,8 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara
case PBT_APMRESUMECRITICAL:
log_infoA("KeepStatus: resume from suspend state");
if (ps != nullptr) {
- for (int i = 0; i < connectionSettings.getCount(); i++)
- connectionSettings[i].AssignStatus(ps[i]->m_status, ps[i]->m_lastStatus, ps[i]->m_szMsg);
+ for (int i = 0; i < protoList.getCount(); i++)
+ protoList[i].AssignStatus(ps[i]->m_status, ps[i]->m_lastStatus, ps[i]->m_szMsg);
FreeProtoSettings(ps);
ps = nullptr;
}
@@ -1134,29 +1101,6 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM lPara
}
/////////////////////////////////////////////////////////////////////////////////////////
-// Account control event
-
-int OnKSAccChanged(WPARAM wParam, LPARAM lParam)
-{
- PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
- switch (wParam) {
- case PRAC_ADDED:
- connectionSettings.insert(new TKSSettings(pa));
- break;
-
- case PRAC_REMOVED:
- for (int i = 0; i < connectionSettings.getCount(); i++) {
- if (!mir_strcmp(connectionSettings[i].m_szName, pa->szModuleName)) {
- connectionSettings.remove(i);
- break;
- }
- }
- break;
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// init stuff
static int onShutdown(WPARAM, LPARAM)
@@ -1169,14 +1113,11 @@ static int onShutdown(WPARAM, LPARAM)
int KSModuleLoaded(WPARAM, LPARAM)
{
- protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&connectionSettings;
-
hMessageWindow = nullptr;
KSLoadOptions();
hEvents[0] = HookEvent(ME_OPT_INITIALISE, KeepStatusOptionsInit);
hEvents[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, onShutdown);
- hEvents[2] = HookEvent(ME_PROTO_ACCLISTCHANGED, OnKSAccChanged);
return 0;
}
@@ -1184,11 +1125,10 @@ void KeepStatusLoad()
{
KSLangPack = GetPluginLangId(MIID_LAST, 0);
- if (g_bMirandaLoaded) {
+ if (g_bMirandaLoaded)
KSModuleLoaded(0, 0);
- KeepStatusOptionsInit(0, 0);
- }
- else HookEvent(ME_SYSTEM_MODULESLOADED, KSModuleLoaded);
+ else
+ HookEvent(ME_SYSTEM_MODULESLOADED, KSModuleLoaded);
hConnectionEvent = CreateHookableEvent(ME_KS_CONNECTIONEVENT);
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.h b/plugins/StatusManager/src/KeepStatus/keepstatus.h
index eac911a3f0..e4b1f5a7a4 100644
--- a/plugins/StatusManager/src/KeepStatus/keepstatus.h
+++ b/plugins/StatusManager/src/KeepStatus/keepstatus.h
@@ -88,17 +88,6 @@
#define TRIGGER_CONNGIVEUP 0x20
#define SETTING_TRIGGERON "TriggerOn"
-struct TKSSettings : public PROTOCOLSETTINGEX
-{
- TKSSettings(PROTOACCOUNT *pa);
- ~TKSSettings();
-
- int AssignStatus(int status, int lastStatus = 0, wchar_t *szMsg = nullptr);
- int GetStatus() const;
-
- int lastStatusAckTime; // the time the last status ack was received
-};
-
/* old; replaced by PROTOCOLSETTINGEX see m_statusplugins.h */
typedef struct {
char *szName; // pointer to protocol modulename
diff --git a/plugins/StatusManager/src/StartupStatus/ss_options.cpp b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
index 90bdc218aa..dc7acf304e 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_options.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_options.cpp
@@ -27,30 +27,6 @@ char* OptName(int i, const char* setting)
}
/////////////////////////////////////////////////////////////////////////////////////////
-
-int SSCompareSettings(const TSSSetting *p1, const TSSSetting *p2)
-{
- return mir_strcmp(p1->m_szName, p2->m_szName);
-}
-
-TSettingsList* GetCurrentProtoSettings()
-{
- int count;
- PROTOACCOUNT **protos;
- Proto_EnumAccounts(&count, &protos);
-
- TSettingsList *result = new TSettingsList(count, SSCompareSettings);
- if (result == nullptr)
- return nullptr;
-
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- result->insert(new TSSSetting(protos[i]));
-
- return result;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
// Command line processing
static char* GetStatusDesc(int status)
@@ -71,7 +47,7 @@ static char* GetStatusDesc(int status)
return "offline";
}
-static char* GetCMDLArguments(TSettingsList& protoSettings)
+static char* GetCMDLArguments(TProtoSettings& protoSettings)
{
if (protoSettings.getCount() == 0)
return nullptr;
@@ -107,7 +83,7 @@ static char* GetCMDLArguments(TSettingsList& protoSettings)
return cmdl;
}
-static char* GetCMDL(TSettingsList& protoSettings)
+static char* GetCMDL(TProtoSettings& protoSettings)
{
char path[MAX_PATH];
GetModuleFileNameA(nullptr, path, MAX_PATH);
@@ -127,14 +103,14 @@ static char* GetCMDL(TSettingsList& protoSettings)
/////////////////////////////////////////////////////////////////////////////////////////
// Link processing
-static wchar_t* GetLinkDescription(TSettingsList& protoSettings)
+static wchar_t* GetLinkDescription(TProtoSettings& protoSettings)
{
if (protoSettings.getCount() == 0)
return nullptr;
CMStringW result(SHORTCUT_DESC);
for (int i = 0; i < protoSettings.getCount(); i++) {
- TSSSetting &p = protoSettings[i];
+ SMProto &p = protoSettings[i];
wchar_t *status;
if (p.m_status == ID_STATUS_LAST)
@@ -158,7 +134,7 @@ static wchar_t* GetLinkDescription(TSettingsList& protoSettings)
return mir_wstrndup(result, result.GetLength());
}
-HRESULT CreateLink(TSettingsList& protoSettings)
+HRESULT CreateLink(TProtoSettings& protoSettings)
{
wchar_t savePath[MAX_PATH];
if (SHGetSpecialFolderPath(nullptr, savePath, 0x10, FALSE))
@@ -201,13 +177,13 @@ HRESULT CreateLink(TSettingsList& protoSettings)
INT_PTR CALLBACK CmdlOptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static TSettingsList* optionsProtoSettings;
+ static TProtoSettings* optionsProtoSettings;
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
{
- optionsProtoSettings = (TSettingsList*)lParam;
+ optionsProtoSettings = (TProtoSettings*)lParam;
char* cmdl = GetCMDL(*optionsProtoSettings);
SetDlgItemTextA(hwndDlg, IDC_CMDL, cmdl);
free(cmdl);
@@ -421,15 +397,13 @@ static INT_PTR CALLBACK StartupStatusOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w
int defProfile = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA,
SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0);
- TSettingsList* ps = GetCurrentProtoSettings();
- if (ps) {
- GetProfile(defProfile, *ps);
- for (int i = 0; i < ps->getCount(); i++)
- if ((*ps)[i].m_szMsg != nullptr)
- (*ps)[i].m_szMsg = wcsdup((*ps)[i].m_szMsg);
+ TProtoSettings ps = protoList;
+ GetProfile(defProfile, ps);
+ for (int i = 0; i < ps.getCount(); i++)
+ if (ps[i].m_szMsg != nullptr)
+ ps[i].m_szMsg = wcsdup(ps[i].m_szMsg);
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)ps);
- }
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CMDLOPTIONS), hwndDlg, CmdlOptionsDlgProc, (LPARAM)&ps);
break;
}
}
@@ -573,7 +547,7 @@ class CSSAdvancedOptDlg : public CDlgBase
// fill proto list
lstAccount.ResetContent();
- TSettingsList& ar = *arProfiles[sel].ps;
+ TProtoSettings &ar = arProfiles[sel].ps;
for (int i = 0; i < ar.getCount(); i++)
lstAccount.AddString(ar[i].m_tszAccName, (LPARAM)&ar[i]);
lstAccount.SetCurSel(0);
@@ -586,7 +560,7 @@ class CSSAdvancedOptDlg : public CDlgBase
int idx = lstAccount.GetCurSel();
if (idx != -1) {
// fill status box
- TSSSetting* ps = (TSSSetting*)lstAccount.GetItemData(idx);
+ SMProto* ps = (SMProto*)lstAccount.GetItemData(idx);
int flags = (CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_2, 0))&~(CallProtoService(ps->m_szName, PS_GETCAPS, PFLAGNUM_5, 0));
lstStatus.ResetContent();
@@ -616,7 +590,7 @@ class CSSAdvancedOptDlg : public CDlgBase
bool bStatusMsg = false;
int idx = lstAccount.GetCurSel();
if (idx != -1) {
- TSSSetting *ps = (TSSSetting*)lstAccount.GetItemData(idx);
+ SMProto *ps = (SMProto*)lstAccount.GetItemData(idx);
CheckRadioButton(m_hwnd, IDC_MIRANDAMSG, IDC_CUSTOMMSG, ps->m_szMsg != nullptr ? IDC_CUSTOMMSG : IDC_MIRANDAMSG);
if (ps->m_szMsg != nullptr)
@@ -690,8 +664,8 @@ public:
for (int i = 0; i < profileCount; i++) {
PROFILEOPTIONS *ppo = new PROFILEOPTIONS;
- ppo->ps = GetCurrentProtoSettings();
- TSettingsList& ar = *ppo->ps;
+ ppo->ps = protoList;
+ TProtoSettings &ar = ppo->ps;
if (GetProfile(i, ar) == -1) {
/* create an empty profile */
@@ -754,7 +728,7 @@ public:
db_set_w(0, SSMODULENAME, OptName(i, SETTING_HOTKEY), po.hotKey);
db_set_ws(0, SSMODULENAME, OptName(i, SETTING_PROFILENAME), po.tszName);
- TSettingsList& ar = *po.ps;
+ TProtoSettings &ar = po.ps;
for (int j = 0; j < ar.getCount(); j++) {
if (ar[j].m_szMsg != nullptr) {
char setting[128];
@@ -809,7 +783,7 @@ public:
{
int idx = lstAccount.GetCurSel();
if (idx != -1) {
- TSSSetting* ps = (TSSSetting*)lstAccount.GetItemData(idx);
+ SMProto* ps = (SMProto*)lstAccount.GetItemData(idx);
ps->m_status = lstStatus.GetItemData(lstStatus.GetCurSel());
NotifyChange();
}
@@ -829,7 +803,7 @@ public:
void onChange_StatusMsg(CCtrlCheck*)
{
int len;
- TSSSetting* ps = (TSSSetting*)lstAccount.GetItemData(lstAccount.GetCurSel());
+ SMProto* ps = (SMProto*)lstAccount.GetItemData(lstAccount.GetCurSel());
if (ps->m_szMsg != nullptr)
free(ps->m_szMsg);
@@ -852,7 +826,7 @@ public:
{
// update the status message in memory, this is done on each character tick, not nice
// but it works
- TSSSetting* ps = (TSSSetting*)lstAccount.GetItemData(lstAccount.GetCurSel());
+ SMProto* ps = (SMProto*)lstAccount.GetItemData(lstAccount.GetCurSel());
if (ps->m_szMsg != nullptr) {
if (*ps->m_szMsg)
free(ps->m_szMsg);
@@ -897,10 +871,10 @@ public:
PROFILEOPTIONS* ppo = new PROFILEOPTIONS;
ppo->tszName = mir_wstrdup(tszName);
- ppo->ps = GetCurrentProtoSettings();
+ ppo->ps = protoList;
arProfiles.insert(ppo);
- ReinitProfiles();;
+ ReinitProfiles();
break;
}
diff --git a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
index 19f9d05ecd..0e151abb99 100644
--- a/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
+++ b/plugins/StatusManager/src/StartupStatus/ss_profiles.cpp
@@ -164,7 +164,29 @@ wchar_t* GetStatusMessage(int profile, char *szProto)
return pce[pceCount - 1].msg;
}
-int GetProfile(int profile, TSettingsList& arSettings)
+void FillStatus(SMProto &ps, int profile)
+{
+ // load status
+ char setting[80];
+ mir_snprintf(setting, "%d_%s", profile, ps.m_szName);
+ int iStatus = db_get_w(0, SSMODULENAME, setting, 0);
+ if (iStatus < MIN_STATUS || iStatus > MAX_STATUS)
+ iStatus = DEFAULT_STATUS;
+ ps.m_status = iStatus;
+
+ // load last status
+ mir_snprintf(setting, "%s%s", PREFIX_LAST, ps.m_szName);
+ iStatus = db_get_w(0, SSMODULENAME, setting, 0);
+ if (iStatus < MIN_STATUS || iStatus > MAX_STATUS)
+ iStatus = DEFAULT_STATUS;
+ ps.m_lastStatus = iStatus;
+
+ ps.m_szMsg = GetStatusMessage(profile, ps.m_szName);
+ if (ps.m_szMsg)
+ ps.m_szMsg = wcsdup(ps.m_szMsg);
+}
+
+int GetProfile(int profile, TProtoSettings &arSettings)
{
if (profile < 0) // get default profile
profile = db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0);
@@ -173,15 +195,8 @@ int GetProfile(int profile, TSettingsList& arSettings)
if (profile >= count && count > 0)
return -1;
- arSettings.destroy();
-
- // if count == 0, continue so the default profile will be returned
- PROTOACCOUNT** protos;
- Proto_EnumAccounts(&count, &protos);
-
- for (int i = 0; i < count; i++)
- if (IsSuitableProto(protos[i]))
- arSettings.insert(new TSSSetting(profile, protos[i]));
+ for (int i = 0; i < arSettings.getCount(); i++)
+ FillStatus(arSettings[i], profile);
return (arSettings.getCount() == 0) ? -1 : 0;
}
@@ -197,7 +212,7 @@ INT_PTR LoadAndSetProfile(WPARAM iProfileNo, LPARAM)
{
// wParam == profile no.
int profile = (int)iProfileNo;
- TSettingsList profileSettings(10, SSCompareSettings);
+ TProtoSettings profileSettings(10, CompareProtoSettings);
if (!GetProfile(profile, profileSettings)) {
profile = (profile >= 0) ? profile : db_get_w(0, SSMODULENAME, SETTING_DEFAULTPROFILE, 0);
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
index 6559fa6811..d84781c1be 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
@@ -21,50 +21,9 @@
int SSLangPack;
-static HANDLE hServices[3], hEvents[4];
+static HANDLE hServices[3], hEvents[3];
static UINT_PTR setStatusTimerId = 0;
-static TSettingsList startupSettings(10, SSCompareSettings);
-
-TSSSetting::TSSSetting(PROTOACCOUNT *pa)
-{
- m_szName = pa->szModuleName;
- m_tszAccName = pa->tszAccountName;
- m_status = m_lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
- m_szMsg = nullptr;
-}
-
-TSSSetting::TSSSetting(int profile, PROTOACCOUNT *pa)
-{
- // copy name
- m_szName = pa->szModuleName;
- m_tszAccName = pa->tszAccountName;
-
- // load status
- char setting[80];
- mir_snprintf(setting, "%d_%s", profile, pa->szModuleName);
- int iStatus = db_get_w(0, SSMODULENAME, setting, 0);
- if (iStatus < MIN_STATUS || iStatus > MAX_STATUS)
- iStatus = DEFAULT_STATUS;
- m_status = iStatus;
-
- // load last status
- mir_snprintf(setting, "%s%s", PREFIX_LAST, m_szName);
- iStatus = db_get_w(0, SSMODULENAME, setting, 0);
- if (iStatus < MIN_STATUS || iStatus > MAX_STATUS)
- iStatus = DEFAULT_STATUS;
- m_lastStatus = iStatus;
-
- m_szMsg = GetStatusMessage(profile, m_szName);
- if (m_szMsg)
- m_szMsg = wcsdup(m_szMsg);
-}
-
-TSSSetting::~TSSSetting()
-{
- free(m_szMsg);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
static HANDLE hProtoAckHook, hCSStatusChangeHook, hStatusChangeHook;
@@ -76,7 +35,7 @@ static BYTE showDialogOnStartup = 0;
/////////////////////////////////////////////////////////////////////////////////////////
// command line options
-static PROTOCOLSETTINGEX* IsValidProtocol(TSettingsList& protoSettings, char* protoName)
+static PROTOCOLSETTINGEX* IsValidProtocol(TProtoSettings &protoSettings, const char *protoName)
{
for (int i = 0; i < protoSettings.getCount(); i++)
if (!strncmp(protoSettings[i].m_szName, protoName, mir_strlen(protoSettings[i].m_szName)))
@@ -113,7 +72,7 @@ static int IsValidStatusDesc(char* statusDesc)
return 0;
}
-static void ProcessCommandLineOptions(TSettingsList& protoSettings)
+static void ProcessCommandLineOptions(TProtoSettings& protoSettings)
{
if (protoSettings.getCount() == 0)
return;
@@ -156,7 +115,7 @@ static void ProcessCommandLineOptions(TSettingsList& protoSettings)
}
}
-static void SetLastStatusMessages(TSettingsList &ps)
+static void SetLastStatusMessages(TProtoSettings &ps)
{
for (int i = 0; i < ps.getCount(); i++) {
if (ps[i].m_status != ID_STATUS_LAST)
@@ -176,27 +135,6 @@ static void SetLastStatusMessages(TSettingsList &ps)
/////////////////////////////////////////////////////////////////////////////////////////
// Account control event
-int OnSSAccChanged(WPARAM wParam, LPARAM lParam)
-{
- PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
- switch (wParam) {
- case PRAC_ADDED:
- startupSettings.insert(new TSSSetting(-1, pa));
- break;
-
- case PRAC_REMOVED:
- for (int i = 0; i < startupSettings.getCount(); i++) {
- if (!mir_strcmp(startupSettings[i].m_szName, pa->szModuleName)) {
- startupSettings.remove(i);
- break;
- }
- }
- break;
- }
-
- return 0;
-}
-
// 'allow override'
static int ProcessProtoAck(WPARAM, LPARAM lParam)
{
@@ -205,12 +143,12 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
if (ack->type != ACKTYPE_STATUS && ack->result != ACKRESULT_FAILED)
return 0;
- if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
+ if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0)
return 0;
- for (int i = 0; i < startupSettings.getCount(); i++) {
- if (!mir_strcmp(ack->szModule, startupSettings[i].m_szName)) {
- startupSettings[i].m_szName = "";
+ for (int i = 0; i < protoList.getCount(); i++) {
+ if (!mir_strcmp(ack->szModule, protoList[i].m_szName)) {
+ protoList[i].m_szName = "";
log_debugA("StartupStatus: %s overridden by ME_PROTO_ACK, status will not be set", ack->szModule);
}
}
@@ -221,20 +159,20 @@ static int ProcessProtoAck(WPARAM, LPARAM lParam)
static int StatusChange(WPARAM, LPARAM lParam)
{
// change by menu
- if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
+ if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0)
return 0;
char *szProto = (char *)lParam;
if (szProto == nullptr) { // global status change
- for (int i = 0; i < startupSettings.getCount(); i++) {
- startupSettings[i].m_szName = "";
+ for (int i = 0; i < protoList.getCount(); i++) {
+ protoList[i].m_szName = "";
log_debugA("StartupStatus: all protos overridden by ME_CLIST_STATUSMODECHANGE, status will not be set");
}
}
else {
- for (int i = 0; i < startupSettings.getCount(); i++) {
- if (!mir_strcmp(startupSettings[i].m_szName, szProto)) {
- startupSettings[i].m_szName = "";
+ for (int i = 0; i < protoList.getCount(); i++) {
+ if (!mir_strcmp(protoList[i].m_szName, szProto)) {
+ protoList[i].m_szName = "";
log_debugA("StartupStatus: %s overridden by ME_CLIST_STATUSMODECHANGE, status will not be set", szProto);
}
}
@@ -246,7 +184,7 @@ static int StatusChange(WPARAM, LPARAM lParam)
static int CSStatusChangeEx(WPARAM wParam, LPARAM)
{
// another status plugin made the change
- if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || startupSettings.getCount() == 0)
+ if (!db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1) || protoList.getCount() == 0)
return 0;
if (wParam != 0) {
@@ -254,15 +192,15 @@ static int CSStatusChangeEx(WPARAM wParam, LPARAM)
if (ps == nullptr)
return -1;
- for (int i = 0; i < startupSettings.getCount(); i++) {
- for (int j = 0; j < startupSettings.getCount(); j++) {
- if (ps[i]->m_szName == nullptr || startupSettings[j].m_szName == nullptr)
+ for (int i = 0; i < protoList.getCount(); i++) {
+ for (int j = 0; j < protoList.getCount(); j++) {
+ if (ps[i]->m_szName == nullptr || protoList[j].m_szName == nullptr)
continue;
- if (!mir_strcmp(ps[i]->m_szName, startupSettings[j].m_szName)) {
+ if (!mir_strcmp(ps[i]->m_szName, protoList[j].m_szName)) {
log_debugA("StartupStatus: %s overridden by MS_CS_SETSTATUSEX, status will not be set", ps[i]->m_szName);
// use a hack to disable this proto
- startupSettings[j].m_szName = "";
+ protoList[j].m_szName = "";
}
}
}
@@ -277,7 +215,7 @@ static void CALLBACK SetStatusTimed(HWND, UINT, UINT_PTR, DWORD)
UnhookEvent(hProtoAckHook);
UnhookEvent(hCSStatusChangeHook);
UnhookEvent(hStatusChangeHook);
- CallService(MS_CS_SETSTATUSEX, (WPARAM)&startupSettings, 0);
+ CallService(MS_CS_SETSTATUSEX, (WPARAM)&protoList, 0);
}
static int OnOkToExit(WPARAM, LPARAM)
@@ -370,7 +308,7 @@ static int OnShutdown(WPARAM, LPARAM)
if (hMessageWindow)
DestroyWindow(hMessageWindow);
- startupSettings.destroy();
+ protoList.destroy();
return 0;
}
@@ -393,28 +331,25 @@ static DWORD CALLBACK MessageWndProc(HWND, UINT msg, WPARAM wParam, LPARAM)
int SSModuleLoaded(WPARAM, LPARAM)
{
- protoList = (OBJLIST<PROTOCOLSETTINGEX>*)&startupSettings;
-
InitProfileModule();
- hEvents[0] = HookEvent(ME_PROTO_ACCLISTCHANGED, OnSSAccChanged);
- hEvents[1] = HookEvent(ME_OPT_INITIALISE, StartupStatusOptionsInit);
+ hEvents[0] = HookEvent(ME_OPT_INITIALISE, StartupStatusOptionsInit);
/* shutdown hook for normal shutdown */
- hEvents[2] = HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit);
- hEvents[3] = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
+ hEvents[1] = HookEvent(ME_SYSTEM_OKTOEXIT, OnOkToExit);
+ hEvents[2] = HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
/* message window for poweroff */
hMessageWindow = CreateWindowEx(0, L"STATIC", nullptr, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr);
SetWindowLongPtr(hMessageWindow, GWLP_WNDPROC, (LONG_PTR)MessageWndProc);
- GetProfile(-1, startupSettings);
+ GetProfile(-1, protoList);
// override with cmdl
- ProcessCommandLineOptions(startupSettings);
- if (startupSettings.getCount() == 0)
+ ProcessCommandLineOptions(protoList);
+ if (protoList.getCount() == 0)
return 0;// no protocols are loaded
- SetLastStatusMessages(startupSettings);
+ SetLastStatusMessages(protoList);
showDialogOnStartup = (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0));
// dial
@@ -424,7 +359,7 @@ int SSModuleLoaded(WPARAM, LPARAM)
// set the status!
if (showDialogOnStartup || db_get_b(0, SSMODULENAME, SETTING_SHOWDIALOG, 0))
- ShowConfirmDialogEx((TProtoSettings*)&startupSettings, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5));
+ ShowConfirmDialogEx((TProtoSettings*)&protoList, db_get_dw(0, SSMODULENAME, SETTING_DLGTIMEOUT, 5));
else if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1)) {
// set hooks for override
if (db_get_b(0, SSMODULENAME, SETTING_OVERRIDE, 1)) {
@@ -479,18 +414,17 @@ int SSModuleLoaded(WPARAM, LPARAM)
static INT_PTR SrvGetProfile(WPARAM wParam, LPARAM lParam)
{
- return GetProfile((int)wParam, *(TSettingsList*)lParam);
+ return GetProfile((int)wParam, *(TProtoSettings*)lParam);
}
void StartupStatusLoad()
{
SSLangPack = GetPluginLangId(MIID_LAST, 0);
- if (g_bMirandaLoaded) {
+ if (g_bMirandaLoaded)
SSModuleLoaded(0, 0);
- StartupStatusOptionsInit(0, 0);
- }
- else HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded);
+ else
+ HookEvent(ME_SYSTEM_MODULESLOADED, SSModuleLoaded);
if (db_get_b(0, SSMODULENAME, SETTING_SETPROFILE, 1) || db_get_b(0, SSMODULENAME, SETTING_OFFLINECLOSE, 0))
db_set_w(0, "CList", "Status", (WORD)ID_STATUS_OFFLINE);
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.h b/plugins/StatusManager/src/StartupStatus/startupstatus.h
index 2c9f03b40e..e680962e17 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.h
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.h
@@ -21,17 +21,6 @@
#define SSMODULENAME "StartupStatus"
-struct TSSSetting : public PROTOCOLSETTINGEX, public MZeroedObject
-{
- TSSSetting(PROTOACCOUNT *pa);
- TSSSetting(int profile, PROTOACCOUNT *pa);
- ~TSSSetting();
-};
-
-int SSCompareSettings(const TSSSetting *p1, const TSSSetting *p2);
-
-typedef OBJLIST<TSSSetting> TSettingsList;
-
struct PROFILECE
{
int profile;
@@ -41,14 +30,17 @@ struct PROFILECE
struct PROFILEOPTIONS : public MZeroedObject
{
+ __inline PROFILEOPTIONS() :
+ ps(10, CompareProtoSettings)
+ {}
+
__inline ~PROFILEOPTIONS()
{
- delete ps;
mir_free(tszName);
}
wchar_t *tszName;
- TSettingsList* ps;
+ TProtoSettings ps;
BOOL showDialog;
BOOL createTtb;
BOOL createMmi;
@@ -133,10 +125,11 @@ void StartupStatusUnload();
int SSLoadMainOptions();
-TSettingsList* GetCurrentProtoSettings();
+void GetCurrentProtoSettings(TProtoSettings&);
// profile
-int GetProfile(int profileID, TSettingsList& arSettings );
+void FillStatus(SMProto &ps, int profile);
+int GetProfile(int profileID, TProtoSettings& arSettings );
wchar_t *GetStatusMessage(int profile, char *szProto);
INT_PTR LoadAndSetProfile(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp
index fe1860ecb3..02f85a1d0b 100644
--- a/plugins/StatusManager/src/commonstatus.cpp
+++ b/plugins/StatusManager/src/commonstatus.cpp
@@ -24,14 +24,36 @@
// handles for hooks and other Miranda thingies
static HANDLE hCSStatusChangedExEvent;
-OBJLIST<PROTOCOLSETTINGEX> *protoList;
+int CompareProtoSettings(const SMProto *p1, const SMProto *p2)
+{
+ return mir_strcmp(p1->m_szName, p2->m_szName);
+}
+
+OBJLIST<SMProto> protoList(10, CompareProtoSettings);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+SMProto::SMProto(PROTOACCOUNT *pa)
+{
+ m_szName = pa->szModuleName;
+ m_tszAccName = pa->tszAccountName;
+ m_status = m_lastStatus = CallProtoService(pa->szModuleName, PS_GETSTATUS, 0, 0);
+}
+
+SMProto::~SMProto()
+{
+ free(m_szMsg);
+}
+/////////////////////////////////////////////////////////////////////////////////////////
// prototypes
+
char* StatusModeToDbSetting(int status, const char *suffix);
DWORD StatusModeToProtoFlag(int status);
INT_PTR SetStatusEx(WPARAM wParam, LPARAM lParam);
// some helpers from awaymsg.c ================================================================
+
char *StatusModeToDbSetting(int status, const char *suffix)
{
char *prefix;
@@ -79,6 +101,7 @@ int GetActualStatus(PROTOCOLSETTINGEX *protoSetting)
return CallProtoService(protoSetting->m_szName, PS_GETSTATUS, 0, 0);
return protoSetting->m_lastStatus;
}
+
if (protoSetting->m_status == ID_STATUS_CURRENT)
return CallProtoService(protoSetting->m_szName, PS_GETSTATUS, 0, 0);
@@ -105,7 +128,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps)
{
int i, j, pstatus = 0, gstatus = 0;
- for (i = 0; i < protoList->getCount(); i++)
+ for (i = 0; i < protoList.getCount(); i++)
if (ps[i]->m_szMsg != nullptr && GetActualStatus(ps[i]) != ID_STATUS_OFFLINE)
return 0;
@@ -118,7 +141,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps)
continue;
pstatus = 0;
- for (j = 0; j < protoList->getCount(); j++)
+ for (j = 0; j < protoList.getCount(); j++)
if (!mir_strcmp(protos[i]->szModuleName, ps[j]->m_szName))
pstatus = GetActualStatus(ps[j]);
@@ -187,10 +210,10 @@ INT_PTR SetStatusEx(WPARAM wParam, LPARAM)
// issue with setting global status;
// things get messy because SRAway hooks ME_CLIST_STATUSMODECHANGE, so the status messages of SRAway and
// commonstatus will clash
- NotifyEventHooks(hCSStatusChangedExEvent, (WPARAM)&protoSettings, protoList->getCount());
+ NotifyEventHooks(hCSStatusChangedExEvent, (WPARAM)&protoSettings, protoList.getCount());
// set all status messages first
- for (int i = 0; i < protoList->getCount(); i++) {
+ for (int i = 0; i < protoList.getCount(); i++) {
char *szProto = protoSettings[i]->m_szName;
if (!Proto_GetAccount(szProto)) {
log_debugA("CommonStatus: %s is not loaded", szProto);
diff --git a/plugins/StatusManager/src/commonstatus.h b/plugins/StatusManager/src/commonstatus.h
index 438a4f6614..54e64f003c 100644
--- a/plugins/StatusManager/src/commonstatus.h
+++ b/plugins/StatusManager/src/commonstatus.h
@@ -72,18 +72,63 @@ int GetActualStatus(PROTOCOLSETTINGEX *protoSetting);
int InitCommonStatus();
bool IsSuitableProto(PROTOACCOUNT *pa);
-/* SimpleAway */
-
-// wParam = 0
-// lParam = 0
-// allways returns 1
-#define MS_SA_ISSARUNNING "SimpleAway/IsSARunning"
-
-typedef OBJLIST<PROTOCOLSETTINGEX> TProtoSettings;
-
-extern HINSTANCE hInst;
-extern TProtoSettings *protoList;
-
+/////////////////////////////////////////////////////////////////////////////////////////
+// external data
+
+#define STATUS_RESET 1
+#define STATUS_AUTOAWAY 2
+#define STATUS_AUTONA 3
+
+#define FLAG_ONSAVER 0x0001 // db: set lv1 status on screensaver ?
+#define FLAG_ONMOUSE 0x0002 // db: set after inactivity ?
+#define FLAG_SETNA 0x0004 // db: set NA after xx of away time ?
+#define FLAG_CONFIRM 0x0008 // db: show confirm dialog ?
+#define FLAG_RESET 0x0010 // db: restore status ?
+#define FLAG_LV2ONINACTIVE 0x0020 // db: set lv2 only on inactivity
+#define FLAG_MONITORMIRANDA 0x0040 // db: monitor miranda activity only
+#define FLAG_ONLOCK 0x0080 // db: on work station lock
+#define FLAG_FULLSCREEN 0x0100 // db: on full screen
+
+typedef enum
+{
+ ACTIVE, // user is active
+ STATUS1_SET, // first status change happened
+ STATUS2_SET, // second status change happened
+ SET_ORGSTATUS, // user was active again, original status will be restored
+ HIDDEN_ACTIVE // user is active, but this is not shown to the outside world
+} STATES;
+
+struct SMProto : public PROTOCOLSETTINGEX, public MZeroedObject
+{
+ SMProto(PROTOACCOUNT *pa);
+ ~SMProto();
+
+ // AdvancedAutoAway settings
+ int originalStatusMode = ID_STATUS_CURRENT;
+ STATES
+ oldState,
+ curState = ACTIVE;
+ BOOL statusChanged; // AAA changed the status, don't update mStatus
+ BOOL mStatus; // status changed manually or not ?
+ int optionFlags, // db: see above
+ awayTime, // db: time to wait for inactivity
+ naTime, // db: time to wait after away is set
+ statusFlags; // db: set lv1 status if this is original status
+ WORD lv1Status, // db
+ lv2Status; // db
+ unsigned int sts1setTimer;
+
+ // KeepStatus
+ int AssignStatus(int status, int lastStatus = 0, wchar_t *szMsg = nullptr);
+ int GetStatus() const;
+
+ int lastStatusAckTime; // the time the last status ack was received
+};
+
+typedef OBJLIST<SMProto> TProtoSettings;
+extern TProtoSettings protoList;
+
+int CompareProtoSettings(const SMProto *p1, const SMProto *p2);
HWND ShowConfirmDialogEx(TProtoSettings *params, int _timeout);
#endif //COMMONSTATUSHEADER
diff --git a/plugins/StatusManager/src/confirmdialog.cpp b/plugins/StatusManager/src/confirmdialog.cpp
index c5d125150d..3b9b20694a 100644
--- a/plugins/StatusManager/src/confirmdialog.cpp
+++ b/plugins/StatusManager/src/confirmdialog.cpp
@@ -401,7 +401,7 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
return 0;
}
-HWND ShowConfirmDialogEx(OBJLIST<PROTOCOLSETTINGEX> *params, int _timeout)
+HWND ShowConfirmDialogEx(TProtoSettings *params, int _timeout)
{
delete confirmSettings;
confirmSettings = new OBJLIST<TConfirmSetting>(10, CompareSettings);
diff --git a/plugins/StatusManager/src/main.cpp b/plugins/StatusManager/src/main.cpp
index 599e3d54ae..478112b6af 100644
--- a/plugins/StatusManager/src/main.cpp
+++ b/plugins/StatusManager/src/main.cpp
@@ -63,7 +63,7 @@ MUUID miidAutoAway = MIID_AUTOAWAY;
MUUID* GetInterfaces(void)
{
- if (IsSubPluginEnabled(AAAMODULENAME))
+ if (g_AAAEnabled)
Interfaces[0] = miidAutoAway;
return Interfaces;
};
@@ -78,7 +78,40 @@ bool g_bMirandaLoaded = false;
int OnModulesLoaded(WPARAM, LPARAM)
{
g_bMirandaLoaded = true;
- HookEvent(ME_OPT_INITIALISE, CSubPluginsOptionsDlg::OnOptionsInit);
+
+ HookEvent(ME_OPT_INITIALISE, OnCommonOptionsInit);
+
+ ////////////////////////////////////////////////////////////////////////////////////////
+
+ int count;
+ PROTOACCOUNT** protos;
+ Proto_EnumAccounts(&count, &protos);
+
+ for (int i = 0; i < count; i++)
+ if (IsSuitableProto(protos[i]))
+ protoList.insert(new SMProto(protos[i]));
+
+ return 0;
+}
+
+int OnAccChanged(WPARAM wParam, LPARAM lParam)
+{
+ PROTOACCOUNT *pa = (PROTOACCOUNT*)lParam;
+ switch (wParam) {
+ case PRAC_ADDED:
+ protoList.insert(new SMProto(pa));
+ break;
+
+ case PRAC_REMOVED:
+ for (int i = 0; i < protoList.getCount(); i++) {
+ if (!mir_strcmp(protoList[i].m_szName, pa->szModuleName)) {
+ protoList.remove(i);
+ break;
+ }
+ }
+ break;
+ }
+
return 0;
}
@@ -88,15 +121,17 @@ extern "C" int __declspec(dllexport) Load(void)
pcli = Clist_GetInterface();
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, OnAccChanged);
InitCommonStatus();
+ InitCommonOptions();
- if (IsSubPluginEnabled(KSMODULENAME))
+ if (g_AAAEnabled)
+ AdvancedAutoAwayLoad();
+ if (g_KSEnabled)
KeepStatusLoad();
- if (IsSubPluginEnabled(SSMODULENAME))
+ if (g_SSEnabled)
StartupStatusLoad();
- if (IsSubPluginEnabled(AAAMODULENAME))
- AdvancedAutoAwayLoad();
return 0;
}
@@ -105,11 +140,11 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
- if (IsSubPluginEnabled(KSMODULENAME))
+ if (g_KSEnabled)
KeepStatusUnload();
- if (IsSubPluginEnabled(SSMODULENAME))
+ if (g_SSEnabled)
StartupStatusUnload();
- if (IsSubPluginEnabled(AAAMODULENAME))
+ if (g_AAAEnabled)
AdvancedAutoAwayUnload();
return 0;
}
diff --git a/plugins/StatusManager/src/options.cpp b/plugins/StatusManager/src/options.cpp
index dcb6739741..3678bee1fd 100644
--- a/plugins/StatusManager/src/options.cpp
+++ b/plugins/StatusManager/src/options.cpp
@@ -1,84 +1,90 @@
#include "stdafx.h"
-bool IsSubPluginEnabled(const char *name)
-{
- // Check if this plugin was disabled as separate dll
- CMStringA dllName(FORMAT, "%s.dll", name);
- dllName.MakeLower();
- int dllEnabled = !db_get_b(0, "PluginDisable", dllName);
-
- char setting[128];
- mir_snprintf(setting, "%s_enabled", name);
- return db_get_b(0, MODULENAME, setting, dllEnabled) != 0;
-}
+CMOption<bool> g_AAAEnabled(MODULENAME, AAAMODULENAME "_enabled", true);
+CMOption<bool> g_KSEnabled(MODULENAME, KSMODULENAME "_enabled", true);
+CMOption<bool> g_SSEnabled(MODULENAME, SSMODULENAME "_enabled", true);
/////////////////////////////////////////////////////////////////////////////////////////
-CSubPluginsOptionsDlg::CSubPluginsOptionsDlg() :
- CPluginDlgBase(hInst, IDD_OPT_SUBPLUGINS, MODULENAME),
- m_enableKeepStatus(this, IDC_ENABLE_KEEPSTATUS),
- m_enableStartupStatus(this, IDC_ENABLE_STARTUPSTATUS),
- m_enableAdvancedAutoAway(this, IDC_ENABLE_ADVANCEDAUTOAWAY)
-{
-}
-
-void CSubPluginsOptionsDlg::OnInitDialog()
-{
- CDlgBase::OnInitDialog();
-
- m_enableKeepStatus.SetState(IsSubPluginEnabled(KSMODULENAME));
- m_enableStartupStatus.SetState(IsSubPluginEnabled(SSMODULENAME));
- m_enableAdvancedAutoAway.SetState(IsSubPluginEnabled(AAAMODULENAME));
-}
-
-void CSubPluginsOptionsDlg::OnApply()
+class CSubPluginsOptionsDlg : public CPluginDlgBase
{
- char setting[128];
- mir_snprintf(setting, "%s_enabled", KSMODULENAME);
- int bEnabled = m_enableKeepStatus.GetState();
- if (bEnabled != db_get_b(0, MODULENAME, setting)) {
- db_set_b(0, MODULENAME, setting, m_enableKeepStatus.GetState());
+ CCtrlCheck m_enableKeepStatus;
+ CCtrlCheck m_enableStartupStatus;
+ CCtrlCheck m_enableAdvancedAutoAway;
- if (bEnabled)
- KeepStatusLoad();
- else
- KeepStatusUnload();
+public:
+ CSubPluginsOptionsDlg()
+ : CPluginDlgBase(hInst, IDD_OPT_SUBPLUGINS, MODULENAME),
+ m_enableKeepStatus(this, IDC_ENABLE_KEEPSTATUS),
+ m_enableStartupStatus(this, IDC_ENABLE_STARTUPSTATUS),
+ m_enableAdvancedAutoAway(this, IDC_ENABLE_ADVANCEDAUTOAWAY)
+ {
+ CreateLink(m_enableKeepStatus, g_KSEnabled);
+ CreateLink(m_enableStartupStatus, g_SSEnabled);
+ CreateLink(m_enableAdvancedAutoAway, g_AAAEnabled);
}
- mir_snprintf(setting, "%s_enabled", SSMODULENAME);
- bEnabled = m_enableStartupStatus.GetState();
- if (bEnabled != db_get_b(0, MODULENAME, setting)) {
- db_set_b(0, MODULENAME, setting, m_enableStartupStatus.GetState());
+ void OnApply() override
+ {
+ bool bEnabled = m_enableKeepStatus.GetState();
+ if (bEnabled != g_KSEnabled) {
+ if (bEnabled)
+ KeepStatusLoad();
+ else
+ KeepStatusUnload();
+ }
- if (bEnabled)
- StartupStatusLoad();
- else
- StartupStatusUnload();
- }
-
- mir_snprintf(setting, "%s_enabled", AAAMODULENAME);
- bEnabled = m_enableAdvancedAutoAway.GetState();
- if (bEnabled != db_get_b(0, MODULENAME, setting)) {
- db_set_b(0, MODULENAME, setting, m_enableAdvancedAutoAway.GetState());
+ bEnabled = m_enableStartupStatus.GetState();
+ if (bEnabled != g_SSEnabled) {
+ if (bEnabled)
+ StartupStatusLoad();
+ else
+ StartupStatusUnload();
+ }
- if (bEnabled)
- AdvancedAutoAwayLoad();
- else
- AdvancedAutoAwayUnload();
+ bEnabled = m_enableAdvancedAutoAway.GetState();
+ if (bEnabled != g_AAAEnabled) {
+ if (bEnabled)
+ AdvancedAutoAwayLoad();
+ else
+ AdvancedAutoAwayUnload();
+ }
}
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
+};
-int CSubPluginsOptionsDlg::OnOptionsInit(WPARAM wParam, LPARAM)
+int OnCommonOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
odp.szGroup.w = LPGENW("Status");
odp.szTitle.w = LPGENW("Status manager");
- odp.pDialog = CSubPluginsOptionsDlg::CreateOptionsPage();
+ odp.pDialog = new CSubPluginsOptionsDlg();
Options_AddPage(wParam, &odp);
return 0;
-} \ No newline at end of file
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static bool IsSubPluginEnabled(const char *name)
+{
+ // Check if this plugin was disabled as separate dll
+ CMStringA dllName(FORMAT, "%s.dll", name);
+ dllName.MakeLower();
+ bool res = !db_get_b(0, "PluginDisable", dllName);
+
+ db_unset(0, "PluginDisable", dllName);
+ return res;
+}
+
+void InitCommonOptions()
+{
+ // if this options dialog was never filled, apply default options
+ if (db_get_b(0, MODULENAME, AAAMODULENAME "_enabled", -1) == -1) {
+ g_AAAEnabled = IsSubPluginEnabled(AAAMODULENAME);
+ g_KSEnabled = IsSubPluginEnabled(KSMODULENAME);
+ g_SSEnabled = IsSubPluginEnabled(SSMODULENAME);
+ }
+}
+
diff --git a/plugins/StatusManager/src/stdafx.h b/plugins/StatusManager/src/stdafx.h
index 92e55b158c..4185fd83d7 100644
--- a/plugins/StatusManager/src/stdafx.h
+++ b/plugins/StatusManager/src/stdafx.h
@@ -36,25 +36,9 @@
extern HINSTANCE hInst;
extern bool g_bMirandaLoaded;
extern int AAALangPack, KSLangPack, SSLangPack;
+extern CMOption<bool> g_AAAEnabled, g_KSEnabled, g_SSEnabled;
-bool IsSubPluginEnabled(const char *name);
-
-class CSubPluginsOptionsDlg : CPluginDlgBase
-{
-private:
- CCtrlCheck m_enableKeepStatus;
- CCtrlCheck m_enableStartupStatus;
- CCtrlCheck m_enableAdvancedAutoAway;
-
-protected:
- void OnInitDialog();
- void OnApply();
-
-public:
- CSubPluginsOptionsDlg();
-
- static int OnOptionsInit(WPARAM wParam, LPARAM);
- static CDlgBase *CreateOptionsPage() { return new CSubPluginsOptionsDlg(); }
-};
+int OnCommonOptionsInit(WPARAM wParam, LPARAM);
+void InitCommonOptions();
#endif //_COMMON_H_
diff --git a/plugins/StatusManager/src/version.h b/plugins/StatusManager/src/version.h
index ab699b9308..b0d2ac3d74 100644
--- a/plugins/StatusManager/src/version.h
+++ b/plugins/StatusManager/src/version.h
@@ -1,7 +1,7 @@
// plugin version part
#define __MAJOR_VERSION 1
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 1
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
#define __BUILD_NUM 1
// other stuff for Version resource