From d1f521b945ad56a7ca399204e01acea593ad18f5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 23 Mar 2018 20:41:14 +0300 Subject: account activation separated from account creation --- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/miranda.h | 1 - src/mir_app/src/proto_accs.cpp | 12 ++++++------ src/mir_app/src/proto_opts.cpp | 25 ++++++++++--------------- 5 files changed, 18 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index a8d5636259..38942137a0 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -491,3 +491,4 @@ GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QBE?AVContacts@@XZ @509 NONAME SetServiceModePlugin @510 Proto_CreateAccount @511 +Proto_ActivateAccount @512 diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b442569c50..da18a51b62 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -491,3 +491,4 @@ GetDatabasePlugin @508 ?AccContacts@PROTO_INTERFACE@@QEBA?AVContacts@@XZ @509 NONAME SetServiceModePlugin @510 Proto_CreateAccount @511 +Proto_ActivateAccount @512 diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index c3ea3e82f6..5cad812460 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -143,7 +143,6 @@ PROTOACCOUNT* __fastcall Proto_GetAccount(MCONTACT hContact); PROTO_INTERFACE* AddDefaultAccount(const char *szProtoName); int FreeDefaultAccount(PROTO_INTERFACE* ppi); -BOOL ActivateAccount(PROTOACCOUNT *pa); void EraseAccount(const char *pszProtoName); void DeactivateAccount(PROTOACCOUNT *pa, bool bIsDynamic, bool bErase); void UnloadAccount(PROTOACCOUNT *pa, bool bIsDynamic, bool bErase); diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp index db051c9303..6319a270fd 100644 --- a/src/mir_app/src/proto_accs.cpp +++ b/src/mir_app/src/proto_accs.cpp @@ -264,7 +264,7 @@ int LoadAccountsModule(void) if (!Proto_IsAccountEnabled(pa)) continue; - if (!ActivateAccount(pa)) + if (!Proto_ActivateAccount(pa)) pa->bDynDisabled = true; } @@ -284,22 +284,22 @@ static HANDLE CreateProtoServiceEx(const char* szModule, const char* szService, return CreateServiceFunctionObj(tmp, pFunc, param); } -BOOL ActivateAccount(PROTOACCOUNT *pa) +MIR_APP_DLL(bool) Proto_ActivateAccount(PROTOACCOUNT *pa) { PROTOCOLDESCRIPTOR* ppd = Proto_IsProtocolLoaded(pa->szProtoName); if (ppd == nullptr) - return FALSE; + return false; if (ppd->fnInit == nullptr) - return FALSE; + return false; PROTO_INTERFACE *ppi = ppd->fnInit(pa->szModuleName, pa->tszAccountName); if (ppi == nullptr) - return FALSE; + return false; pa->ppro = ppi; ppi->m_iDesiredStatus = ppi->m_iStatus = ID_STATUS_OFFLINE; - return TRUE; + return true; } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index c4d88b9466..f761bc4859 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -85,15 +85,6 @@ MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const ch db_set_s(0, pa->szModuleName, "AM_BaseProto", pszBaseProto); accounts.insert(pa); - if (ActivateAccount(pa)) { - if (bModulesLoadedFired) - pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); - if (!db_get_b(0, "CList", "MoveProtoMenus", true)) - pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); - } - - WriteDbAccounts(); - NotifyEventHooks(hAccListChanged, PRAC_ADDED, (LPARAM)pa); return pa; } @@ -215,13 +206,17 @@ public: rtrim(buf); m_pa = Proto_CreateAccount(buf, szBaseProto, tszAccName); + if (Proto_ActivateAccount(m_pa)) { + if (bModulesLoadedFired) + m_pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); + if (!db_get_b(0, "CList", "MoveProtoMenus", true)) + m_pa->ppro->OnEvent(EV_PROTO_ONMENU, 0, 0); + } } - else { - replaceStrW(m_pa->tszAccountName, tszAccName); + else replaceStrW(m_pa->tszAccountName, tszAccName); - WriteDbAccounts(); - NotifyEventHooks(hAccListChanged, m_action, (LPARAM)m_pa); - } + WriteDbAccounts(); + NotifyEventHooks(hAccListChanged, m_action, (LPARAM)m_pa); SendMessage(GetParent(m_hwnd), WM_MY_REFRESH, 0, 0); EndModal(IDOK); @@ -551,7 +546,7 @@ public: pa->bIsEnabled = !pa->bIsEnabled; if (pa->bIsEnabled) { - if (ActivateAccount(pa)) { + if (Proto_ActivateAccount(pa)) { if (bModulesLoadedFired) pa->ppro->OnEvent(EV_PROTO_ONLOAD, 0, 0); if (!db_get_b(0, "CList", "MoveProtoMenus", TRUE)) -- cgit v1.2.3