diff options
author | George Hazan <ghazan@miranda.im> | 2018-05-07 17:50:35 +0200 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-05-07 18:07:33 +0200 |
commit | 1732a6b13f52b573cc4af91c2d9120c596e6bf78 (patch) | |
tree | 57e853c70f4bf51bfedbd8a50874746e5a3bc971 | |
parent | d1c9c916887e91a32d7794c83c37ff1c512660d9 (diff) |
PROTOACCOUNT::bIsLocked: lock status to be stored in memory
PROTOACCOUNT became a normal class with constructor & destructor
-rw-r--r-- | include/m_protocols.h | 10 | ||||
-rw-r--r-- | libs/win32/mir_app.lib | bin | 162334 -> 162248 bytes | |||
-rw-r--r-- | libs/win64/mir_app.lib | bin | 157440 -> 157342 bytes | |||
-rw-r--r-- | plugins/Clist_modern/src/modern_statusbar.cpp | 2 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/clui.cpp | 31 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/cluiframes.h | 13 | ||||
-rw-r--r-- | plugins/Clist_nicer/src/statusbar.cpp | 7 | ||||
-rw-r--r-- | plugins/StatusManager/src/KeepStatus/keepstatus.cpp | 2 | ||||
-rw-r--r-- | plugins/StatusManager/src/commonstatus.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/menu_clist.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 3 | ||||
-rw-r--r-- | src/mir_app/src/proto_accs.cpp | 35 | ||||
-rw-r--r-- | src/mir_app/src/proto_chains.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/proto_opts.cpp | 16 | ||||
-rw-r--r-- | src/mir_app/src/protocols.cpp | 23 |
16 files changed, 78 insertions, 77 deletions
diff --git a/include/m_protocols.h b/include/m_protocols.h index ff364d3e7e..e72b31de72 100644 --- a/include/m_protocols.h +++ b/include/m_protocols.h @@ -243,9 +243,10 @@ EXTERN_C MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char * #define ME_PROTO_CONTACTISTYPING "Proto/ContactIsTypingEvent"
-// -------------- accounts support --------------------- 0.8.0+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Accounts support
-struct MIR_APP_EXPORT PROTOACCOUNT
+struct MIR_APP_EXPORT PROTOACCOUNT : public MZeroedObject
{
char* szModuleName; // unique physical account name (matches database module name)
wchar_t* tszAccountName; // user-defined account name
@@ -253,6 +254,7 @@ struct MIR_APP_EXPORT PROTOACCOUNT bool bIsEnabled; // is account enabled?
bool bIsVisible; // is account visible?
bool bIsVirtual; // is account virtual?
+ bool bIsLocked; // is locked in the contacts list?
bool bOldProto; // old-styled account (one instance per dll)
bool bDynDisabled; // dynamic disable flag, is never written to db
@@ -270,6 +272,10 @@ struct MIR_APP_EXPORT PROTOACCOUNT int protostatus[MAX_STATUS_COUNT];
HGENMENU menuhandle[MAX_STATUS_COUNT];
+ //---- methods ------------
+ PROTOACCOUNT(const char *szProto);
+ ~PROTOACCOUNT();
+
bool IsEnabled(void) const;
bool IsLocked(void) const;
bool IsVisible(void) const;
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 391561e5d5..9c120b48eb 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex 3fe09f51ae..896c9f7235 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Clist_modern/src/modern_statusbar.cpp b/plugins/Clist_modern/src/modern_statusbar.cpp index 02fe347366..5764ad7c05 100644 --- a/plugins/Clist_modern/src/modern_statusbar.cpp +++ b/plugins/Clist_modern/src/modern_statusbar.cpp @@ -495,7 +495,7 @@ int ModernDrawStatusBarWorker(HWND hWnd, HDC hDC) }
if (hxIcon || hIcon) { // TODO g_StatusBarData.bDrawLockOverlay options to draw locked proto
- if (db_get_b(0, p.szAccountName, "LockMainStatus", 0)) {
+ if (Proto_GetAccount(p.szAccountName)->IsLocked()) {
HICON hLockOverlay = Skin_LoadIcon(SKINICON_OTHER_STATUS_LOCKED);
if (hLockOverlay != nullptr) {
ske_DrawIconEx(hDC, x, iconY, hLockOverlay, iconWidth, iconHeight, 0, nullptr, DI_NORMAL | dim);
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index 8346228903..caa6b9b723 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -1634,23 +1634,27 @@ buttons_done: if (cfg::shutDown) return TRUE; + char *szProto = pd->RealName; + PROTOACCOUNT *pa = Proto_GetAccount(szProto); + if (pa == nullptr) + return TRUE; + int nParts = SendMessage(pcli->hwndStatus, SB_GETPARTS, 0, 0); SIZE textSize; BYTE showOpts = db_get_b(NULL, "CLUI", "SBarShow", 1); - char *szProto = pd->RealName; - int status = Proto_GetStatus(szProto); + SetBkMode(dis->hDC, TRANSPARENT); int x = dis->rcItem.left; if (showOpts & 1) { HICON hIcon; - if (status >= ID_STATUS_CONNECTING && status < ID_STATUS_OFFLINE) { + if (pa->iRealStatus >= ID_STATUS_CONNECTING && pa->iRealStatus < ID_STATUS_OFFLINE) { char szBuffer[128]; mir_snprintf(szBuffer, "%s_conn", pd->RealName); hIcon = IcoLib_GetIcon(szBuffer); } - else if (cfg::dat.bShowXStatusOnSbar && status > ID_STATUS_OFFLINE) { + else if (cfg::dat.bShowXStatusOnSbar && pa->iRealStatus > ID_STATUS_OFFLINE) { int xStatus; CUSTOM_STATUS cst = { sizeof(cst) }; cst.flags = CSSF_MASK_STATUS; @@ -1658,10 +1662,9 @@ buttons_done: if (ProtoServiceExists(pd->RealName, PS_GETCUSTOMSTATUSEX) && !CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cst) && xStatus > 0) hIcon = (HICON)CallProtoService(pd->RealName, PS_GETCUSTOMSTATUSICON, 0, LR_SHARED); // get OWN xStatus icon (if set) else - hIcon = Skin_LoadProtoIcon(szProto, status); + hIcon = Skin_LoadProtoIcon(szProto, pa->iRealStatus); } - else - hIcon = Skin_LoadProtoIcon(szProto, status); + else hIcon = Skin_LoadProtoIcon(szProto, pa->iRealStatus); if (!(showOpts & 6) && cfg::dat.bEqualSections) x = (dis->rcItem.left + dis->rcItem.right - 16) >> 1; @@ -1673,7 +1676,7 @@ buttons_done: IcoLib_ReleaseIcon(hIcon); if (db_get_b(NULL, "CLUI", "sbar_showlocked", 1)) { - if (db_get_b(NULL, szProto, "LockMainStatus", 0)) { + if (pa->bIsLocked) { hIcon = Skin_LoadIcon(SKINICON_OTHER_STATUS_LOCKED); if (hIcon != nullptr) { DrawIconEx(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - 16) >> 1, hIcon, 16, 16, 0, nullptr, DI_NORMAL); @@ -1693,22 +1696,16 @@ buttons_done: if (showOpts & 2) { wchar_t szName[64]; - PROTOACCOUNT *pa = Proto_GetAccount(szProto); - if (pa) { - mir_wstrncpy(szName, pa->tszAccountName, _countof(szName)); - szName[_countof(szName) - 1] = 0; - } - else - szName[0] = 0; + wcsncpy_s(szName, pa->tszAccountName, _TRUNCATE); - if (mir_wstrlen(szName) < sizeof(szName) - 1) + if (mir_wstrlen(szName) < _countof(szName) - 1) mir_wstrcat(szName, L" "); GetTextExtentPoint32(dis->hDC, szName, (int)mir_wstrlen(szName), &textSize); TextOut(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, szName, (int)mir_wstrlen(szName)); x += textSize.cx; } if (showOpts & 4) { - wchar_t *szStatus = Clist_GetStatusModeDescription(status, 0); + wchar_t *szStatus = Clist_GetStatusModeDescription(pa->iRealStatus, 0); GetTextExtentPoint32(dis->hDC, szStatus, (int)mir_wstrlen(szStatus), &textSize); TextOut(dis->hDC, x, (dis->rcItem.top + dis->rcItem.bottom - textSize.cy) >> 1, szStatus, (int)mir_wstrlen(szStatus)); } diff --git a/plugins/Clist_nicer/src/cluiframes.h b/plugins/Clist_nicer/src/cluiframes.h index 3f3d79687a..60e9ce7948 100644 --- a/plugins/Clist_nicer/src/cluiframes.h +++ b/plugins/Clist_nicer/src/cluiframes.h @@ -27,22 +27,19 @@ int UnLoadCLUIFramesModule(void); int CLUIFramesGetMinHeight();
int CLUIFramesOnClistResize(WPARAM wParam, LPARAM lParam);
int SizeFramesByWindowRect(RECT *r);
-int CLUIFramesResizeFrames(RECT *rc);
-typedef struct tagProtocolData {
+struct ProtocolData
+{
char *RealName;
int protopos;
boolean show;
-} ProtocolData;
+};
-typedef struct
+struct SortData
{
int order;
int realpos;
-}SortData;
-
-
-
+};
//============
#define CLUIFRAMESSETALIGN "CLUIFramesSetAlign"
diff --git a/plugins/Clist_nicer/src/statusbar.cpp b/plugins/Clist_nicer/src/statusbar.cpp index c8b5d443ed..47ddaf4948 100644 --- a/plugins/Clist_nicer/src/statusbar.cpp +++ b/plugins/Clist_nicer/src/statusbar.cpp @@ -155,11 +155,12 @@ LRESULT CALLBACK NewStatusBarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM if (NotifyEventHooks(hStatusBarShowToolTipEvent, (WPARAM)PD->RealName, 0) > 0) // a plugin handled this event
tooltip_active = TRUE;
else if (db_get_dw(NULL, "mToolTip", "ShowStatusTip", 0)) {
- int wStatus = Proto_GetStatus(PD->RealName);
- BYTE isLocked = db_get_b(NULL, PD->RealName, "LockMainStatus", 0);
+ PROTOACCOUNT *pa = Proto_GetAccount(PD->RealName);
+ if (pa == nullptr)
+ break;
wchar_t szTipText[256];
- mir_snwprintf(szTipText, L"<b>%s</b>: %s%s", PD->RealName, Clist_GetStatusModeDescription(wStatus, 0), isLocked ? L" (LOCKED)" : L"");
+ mir_snwprintf(szTipText, L"<b>%s</b>: %s%s", PD->RealName, Clist_GetStatusModeDescription(pa->iRealStatus, 0), pa->bIsLocked ? L" (LOCKED)" : L"");
CLCINFOTIP ti = { sizeof(ti) };
ti.isTreeFocused = (GetFocus() == pcli->hwndContactList);
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp index cd24606687..1209e46f5c 100644 --- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp +++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp @@ -132,7 +132,7 @@ int SMProto::AssignStatus(int iStatus, int iLastStatus, wchar_t *pwszMsg) return -1; if (iStatus != ID_STATUS_OFFLINE && m_status == ID_STATUS_DISABLED) return -2; - if (!db_get_b(0, KSMODULENAME, SETTING_NOLOCKED, 0) && db_get_b(0, m_szName, "LockMainStatus", 0)) + if (!db_get_b(0, KSMODULENAME, SETTING_NOLOCKED, 0) && Proto_GetAccount(m_szName)->IsLocked()) return -3; mir_cslock lck(GenStatusCS); diff --git a/plugins/StatusManager/src/commonstatus.cpp b/plugins/StatusManager/src/commonstatus.cpp index 13e7108af6..1fa60745dd 100644 --- a/plugins/StatusManager/src/commonstatus.cpp +++ b/plugins/StatusManager/src/commonstatus.cpp @@ -164,7 +164,7 @@ static int equalsGlobalStatus(PROTOCOLSETTINGEX **ps) if (pstatus == 0) pstatus = pa->iRealStatus; - if (db_get_b(0, pa->szModuleName, "LockMainStatus", 0)) { + if (pa->bIsLocked) { // if proto is locked, pstatus must be the current status if (pstatus != pa->iRealStatus) return 0; diff --git a/src/mir_app/src/menu_clist.cpp b/src/mir_app/src/menu_clist.cpp index d8eba369c9..b7c1e66ea5 100644 --- a/src/mir_app/src/menu_clist.cpp +++ b/src/mir_app/src/menu_clist.cpp @@ -525,8 +525,8 @@ static INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) char *prot = smep->szProto;
char szHumanName[64] = { 0 };
PROTOACCOUNT *acc = Proto_GetAccount(smep->szProto);
- bool bIsLocked = !acc->IsLocked();
- db_set_b(0, prot, "LockMainStatus", bIsLocked);
+ acc->bIsLocked = !acc->bIsLocked;
+ db_set_b(0, prot, "LockMainStatus", acc->bIsLocked);
CallProtoServiceInt(0, smep->szProto, PS_GETNAME, _countof(szHumanName), (LPARAM)szHumanName);
@@ -536,7 +536,7 @@ static INT_PTR StatusMenuExecService(WPARAM wParam, LPARAM) TMO_IntMenuItem *root = (TMO_IntMenuItem*)pimi->mi.root;
wchar_t buf[256], *ptszName;
- if (bIsLocked) {
+ if (acc->bIsLocked) {
pimi->mi.flags |= CMIF_CHECKED;
mir_snwprintf(buf, TranslateT("%s (locked)"), acc->tszAccountName);
ptszName = buf;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 8361e8c9ae..6fa1d98644 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -523,7 +523,6 @@ Proto_GetAverageStatus @512 ?RegisterProtocol@CMPluginBase@@IAEXHP6APAUPROTO_INTERFACE@@PBDPB_W@ZP6AHPAU2@@Z@Z @547 NONAME
Proto_GetUniqueId @548
Proto_SetUniqueId @549
-??4PROTOACCOUNT@@QAEAAU0@$$QAU0@@Z @550 NONAME
??4PROTOACCOUNT@@QAEAAU0@ABU0@@Z @551 NONAME
?IsEnabled@PROTOACCOUNT@@QBE_NXZ @552 NONAME
?IsLocked@PROTOACCOUNT@@QBE_NXZ @553 NONAME
@@ -594,3 +593,5 @@ Contact_GetStatus @609 ?getMStringW@CMPluginBase@@QAE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PBD@Z @618 NONAME
?getMStringW@PROTO_INTERFACE@@QAE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@IPBD@Z @619 NONAME
?getMStringW@PROTO_INTERFACE@@QAE?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PBD@Z @620 NONAME
+??0PROTOACCOUNT@@QAE@PBD@Z @621 NONAME
+??1PROTOACCOUNT@@QAE@XZ @622 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index e54f50ddcc..109b032808 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -523,7 +523,6 @@ Proto_GetAverageStatus @512 ?RegisterProtocol@CMPluginBase@@IEAAXHP6APEAUPROTO_INTERFACE@@PEBDPEB_W@ZP6AHPEAU2@@Z@Z @547 NONAME
Proto_GetUniqueId @548
Proto_SetUniqueId @549
-??4PROTOACCOUNT@@QEAAAEAU0@$$QEAU0@@Z @550 NONAME
??4PROTOACCOUNT@@QEAAAEAU0@AEBU0@@Z @551 NONAME
?IsEnabled@PROTOACCOUNT@@QEBA_NXZ @552 NONAME
?IsLocked@PROTOACCOUNT@@QEBA_NXZ @553 NONAME
@@ -594,3 +593,5 @@ Contact_GetStatus @609 ?getMStringW@CMPluginBase@@QEAA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PEBD@Z @618 NONAME
?getMStringW@PROTO_INTERFACE@@QEAA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@IPEBD@Z @619 NONAME
?getMStringW@PROTO_INTERFACE@@QEAA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@PEBD@Z @620 NONAME
+??0PROTOACCOUNT@@QEAA@PEBD@Z @621 NONAME
+??1PROTOACCOUNT@@QEAA@XZ @622 NONAME
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index 68b61a17ae..39604d8da2 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -48,15 +48,12 @@ static int EnumDbModules(const char *szModuleName, void*) ptrA szProtoName(db_get_sa(0, szModuleName, "AM_BaseProto"));
if (szProtoName) {
if (!Proto_GetAccount(szModuleName)) {
- PROTOACCOUNT *pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
- pa->szModuleName = mir_strdup(szModuleName);
+ PROTOACCOUNT *pa = new PROTOACCOUNT(szModuleName);
pa->szProtoName = szProtoName.detach();
pa->tszAccountName = mir_a2u(szModuleName);
pa->bIsVisible = true;
pa->bIsEnabled = false;
pa->iOrder = accounts.getCount();
- pa->iIconBase = -1;
- pa->iRealStatus = ID_STATUS_OFFLINE;
accounts.insert(pa);
}
}
@@ -71,22 +68,15 @@ void LoadDbAccounts(void) for (int i = 0; i < count; i++) {
char buf[10];
_itoa(i, buf, 10);
- char *szModuleName = db_get_sa(0, "Protocols", buf);
+ ptrA szModuleName(db_get_sa(0, "Protocols", buf));
if (szModuleName == nullptr)
continue;
PROTOACCOUNT *pa = Proto_GetAccount(szModuleName);
if (pa == nullptr) {
- pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
- pa->szModuleName = szModuleName;
- pa->iIconBase = -1;
- pa->iRealStatus = ID_STATUS_OFFLINE;
+ pa = new PROTOACCOUNT(szModuleName);
accounts.insert(pa);
}
- else {
- mir_free(szModuleName);
- szModuleName = pa->szModuleName;
- }
_itoa(OFFSET_VISIBLE + i, buf, 10);
pa->bIsVisible = db_get_dw(0, "Protocols", buf, 1) != 0;
@@ -128,12 +118,11 @@ void LoadDbAccounts(void) /////////////////////////////////////////////////////////////////////////////////////////
-typedef struct
+struct enumDB_ProtoProcParam
{
int arrlen;
char **pszSettingName;
-}
-enumDB_ProtoProcParam;
+};
static int enumDB_ProtoProc(const char* szSetting, void *lParam)
{
@@ -436,22 +425,20 @@ void UnloadAccount(PROTOACCOUNT *pa, int flags) {
DeactivateAccount(pa, flags);
- replaceStrW(pa->tszAccountName, 0);
- replaceStr(pa->szProtoName, 0);
- replaceStr(pa->szUniqueId, 0);
-
// szModuleName should be freed only on a program's exit.
// otherwise many plugins dependand on static protocol names will crash!
// do NOT fix this 'leak', please
- if (!(flags & DAF_DYNAMIC)) {
- mir_free(pa->szModuleName);
- mir_free(pa);
+ if (!(flags & DAF_DYNAMIC))
+ delete pa;
+ else {
+ replaceStrW(pa->tszAccountName, 0);
replaceStr(pa->szProtoName, 0);
replaceStr(pa->szUniqueId, 0);
}
}
void UnloadAccountsModule()
{
- if (!bModuleInitialized) return;
+ if (!bModuleInitialized)
+ return;
auto T = accounts.rev_iter();
for (auto &it : T) {
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp index f295886181..4e9912a07b 100644 --- a/src/mir_app/src/proto_chains.cpp +++ b/src/mir_app/src/proto_chains.cpp @@ -155,7 +155,7 @@ MIR_APP_DLL(char*) GetContactProto(MCONTACT hContact) MIR_APP_DLL(char*) Proto_GetBaseAccountName(MCONTACT hContact)
{
PROTOACCOUNT *pa = Proto_GetAccount(hContact);
- return pa ? pa->szModuleName : nullptr;
+ return pa->IsEnabled() ? pa->szModuleName : nullptr;
}
MIR_APP_DLL(int) Proto_IsProtoOnContact(MCONTACT hContact, const char *szProto)
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index 208ccb107f..7b58a4abd0 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -55,14 +55,8 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const ch if (pszBaseProto == nullptr || tszAccountName == nullptr)
return nullptr;
- PROTOACCOUNT *pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
- pa->bIsEnabled = pa->bIsVisible = true;
- pa->iOrder = accounts.getCount();
- pa->szProtoName = mir_strdup(pszBaseProto);
- pa->iRealStatus = ID_STATUS_OFFLINE;
- pa->iIconBase = -1;
-
// if the internal name is empty, generate new one
+ const char *szProto;
if (mir_strlen(pszInternal) == 0) {
char buf[100];
int count = 1;
@@ -71,10 +65,14 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const ch if (ptrA(db_get_sa(0, buf, "AM_BaseProto")) == nullptr)
break;
}
- pa->szModuleName = mir_strdup(buf);
+ szProto = buf;
}
- else pa->szModuleName = mir_strdup(pszInternal);
+ else szProto = pszInternal;
+ PROTOACCOUNT *pa = new PROTOACCOUNT(szProto);
+ pa->bIsEnabled = pa->bIsVisible = true;
+ pa->iOrder = accounts.getCount();
+ pa->szProtoName = mir_strdup(pszBaseProto);
pa->tszAccountName = mir_wstrdup(tszAccountName);
db_set_s(0, pa->szModuleName, "AM_BaseProto", pszBaseProto);
diff --git a/src/mir_app/src/protocols.cpp b/src/mir_app/src/protocols.cpp index 14f679ea9b..6a28c9bfeb 100644 --- a/src/mir_app/src/protocols.cpp +++ b/src/mir_app/src/protocols.cpp @@ -121,14 +121,11 @@ MIR_APP_DLL(PROTOCOLDESCRIPTOR*) Proto_RegisterModule(int type, const char *szNa ppi->m_iVersion = 1;
PROTOACCOUNT *pa = Proto_GetAccount(pd->szName);
if (pa == nullptr) {
- pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
- pa->szModuleName = mir_strdup(szName);
+ pa = new PROTOACCOUNT(szName);
pa->szProtoName = mir_strdup(szName);
pa->tszAccountName = mir_a2u(szName);
pa->bIsVisible = pa->bIsEnabled = true;
pa->iOrder = accounts.getCount();
- pa->iIconBase = -1;
- pa->iRealStatus = ID_STATUS_OFFLINE;
accounts.insert(pa);
}
pa->bOldProto = true;
@@ -335,6 +332,22 @@ MIR_APP_DLL(LIST<PROTOACCOUNT>&) Accounts(void) /////////////////////////////////////////////////////////////////////////////////////////
+PROTOACCOUNT::PROTOACCOUNT(const char *szProto) :
+ szModuleName(mir_strdup(szProto)),
+ iIconBase(-1),
+ iRealStatus(ID_STATUS_OFFLINE)
+{
+ bIsLocked = db_get_b(0, szProto, "LockMainStatus", 0) != 0;
+}
+
+PROTOACCOUNT::~PROTOACCOUNT()
+{
+ mir_free(szModuleName);
+ mir_free(szProtoName);
+ mir_free(szUniqueId);
+ mir_free(tszAccountName);
+}
+
bool PROTOACCOUNT::IsEnabled() const
{
return (this != nullptr) && ((bIsEnabled && !bDynDisabled) || bOldProto);
@@ -342,7 +355,7 @@ bool PROTOACCOUNT::IsEnabled() const bool PROTOACCOUNT::IsLocked() const
{
- return (this != nullptr) && db_get_b(0, szModuleName, "LockMainStatus", 0) != 0;
+ return (this != nullptr) && bIsLocked;
}
bool PROTOACCOUNT::IsVisible() const
|