summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-23 20:41:14 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-23 20:41:14 +0300
commitd1f521b945ad56a7ca399204e01acea593ad18f5 (patch)
treefa1ae8c796d36a93df952125bd50fe6978c9a977
parentbb5dfcb3c97622419bfd3bb4e3161489e361132e (diff)
account activation separated from account creation
-rw-r--r--include/m_protocols.h6
-rw-r--r--libs/win32/mir_app.libbin131654 -> 132008 bytes
-rw-r--r--libs/win64/mir_app.libbin127182 -> 127542 bytes
-rw-r--r--plugins/Import/src/import.cpp2
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
-rw-r--r--src/mir_app/src/miranda.h1
-rw-r--r--src/mir_app/src/proto_accs.cpp12
-rw-r--r--src/mir_app/src/proto_opts.cpp25
9 files changed, 26 insertions, 22 deletions
diff --git a/include/m_protocols.h b/include/m_protocols.h
index e5713768e7..a7e13ffab1 100644
--- a/include/m_protocols.h
+++ b/include/m_protocols.h
@@ -300,6 +300,12 @@ MIR_APP_DLL(void) Proto_EnumAccounts(int *nAccs, PROTOACCOUNT ***pAccs);
MIR_APP_DLL(PROTOACCOUNT*) Proto_CreateAccount(const char *pszInternal, const char *pszBaseProto, const wchar_t *ptszAccountName);
/////////////////////////////////////////////////////////////////////////////////////////
+// constructs the appropriate PROTOACCOUNT::ppro member if needed
+// returns true if succeeded
+
+MIR_APP_DLL(bool) Proto_ActivateAccount(PROTOACCOUNT *pAccount);
+
+/////////////////////////////////////////////////////////////////////////////////////////
// retrieves an account's interface by its physical name (database module)
// return value = PROTOACCOUNT* or NULL
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index c7adf43d41..e64350bca5 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 8f4b79a2af..83ae0fbf5c 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index a70983d192..5d90bbd9a2 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -505,6 +505,8 @@ bool ImportAccounts(OBJLIST<char> &arSkippedModules)
CopySettings(NULL, p->szSrcAcc, NULL, p->pa->szModuleName);
if (bImportSysAll)
arSkippedModules.insert(newStr(p->szSrcAcc));
+
+ Proto_ActivateAccount(p->pa);
}
CopySettings(NULL, META_PROTO, NULL, META_PROTO);
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))