summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-03-28 16:34:30 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-03-28 16:34:30 +0300
commit81ce57622c3166830b23eae534dacc6b008c659d (patch)
tree6d6ac74667f733a20b94fa27cc01c2f45688c533 /protocols/SkypeWeb/src
parentc2bb7727483b9b5620e8cc0ce6adae35ee78d0a4 (diff)
common protocol instance management code went into template
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r--protocols/SkypeWeb/src/main.cpp13
-rw-r--r--protocols/SkypeWeb/src/skype_accounts.cpp32
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h19
-rw-r--r--protocols/SkypeWeb/src/skype_timers.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp2
6 files changed, 13 insertions, 59 deletions
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp
index 678d2003a1..b7d5c38b26 100644
--- a/protocols/SkypeWeb/src/main.cpp
+++ b/protocols/SkypeWeb/src/main.cpp
@@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
+CMPlugin g_plugin;
int hLangpack;
HINSTANCE g_hInstance;
CLIST_INTERFACE *pcli;
@@ -91,15 +92,3 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
}
return 0;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-struct CMPlugin : public CMPluginBase
-{
- CMPlugin() :
- CMPluginBase("SKYPE")
- {
- RegisterProtocol(PROTOTYPE_PROTOCOL, (pfnInitProto)CSkypeProto::InitAccount, (pfnUninitProto)CSkypeProto::UninitAccount);
- }
-}
- g_plugin;
diff --git a/protocols/SkypeWeb/src/skype_accounts.cpp b/protocols/SkypeWeb/src/skype_accounts.cpp
index 2016fac51c..9ab67acff8 100644
--- a/protocols/SkypeWeb/src/skype_accounts.cpp
+++ b/protocols/SkypeWeb/src/skype_accounts.cpp
@@ -17,38 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-LIST<CSkypeProto> CSkypeProto::Accounts(1, CSkypeProto::CompareAccounts);
-
-int CSkypeProto::CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2)
-{
- return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName);
-}
-
-CSkypeProto* CSkypeProto::InitAccount(const char *protoName, const wchar_t *userName)
-{
- mir_cslock lck(accountsLock);
- CSkypeProto *proto = new CSkypeProto(protoName, userName);
- Accounts.insert(proto);
- return proto;
-}
-
-int CSkypeProto::UninitAccount(CSkypeProto *proto)
-{
- mir_cslock lck(accountsLock);
- Accounts.remove(proto);
- delete proto;
- return 0;
-}
-
-CSkypeProto* CSkypeProto::GetContactAccount(MCONTACT hContact)
-{
- mir_cslock lck(accountsLock);
- for (auto &it : Accounts)
- if (mir_strcmpi(GetContactProto(hContact), it->m_szModuleName) == 0)
- return it;
- return nullptr;
-}
-
int CSkypeProto::OnAccountLoaded(WPARAM, LPARAM)
{
setAllContactStatuses(ID_STATUS_OFFLINE, true);
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
index 55c4a4288f..5811ab33da 100644
--- a/protocols/SkypeWeb/src/skype_menus.cpp
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -48,7 +48,7 @@ int CSkypeProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
{
for (auto &it : ContactMenuItems)
Menu_ShowItem(it, false);
- CSkypeProto *proto = CSkypeProto::GetContactAccount(hContact);
+ CSkypeProto *proto = CMPlugin::getInstance(hContact);
return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 5bdd124995..3584fde7c4 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -55,10 +55,6 @@ public:
virtual HANDLE __cdecl GetAwayMsg(MCONTACT hContact);
virtual int __cdecl SetAwayMsg(int m_iStatus, const wchar_t *msg);
- // accounts
- static CSkypeProto* InitAccount(const char *protoName, const wchar_t *userName);
- static int UninitAccount(CSkypeProto *proto);
-
// icons
static void InitIcons();
@@ -123,11 +119,6 @@ private:
static UINT_PTR m_timer;
- //---Accounts
- static LIST<CSkypeProto> CSkypeProto::Accounts;
- static int CompareAccounts(const CSkypeProto *p1, const CSkypeProto *p2);
- //---/
-
RequestQueue *requestQueue;
bool m_bHistorySynced;
@@ -165,7 +156,6 @@ private:
EventHandle m_hTrouterHealthEvent;
- static CSkypeProto* GetContactAccount(MCONTACT hContact);
int __cdecl OnAccountLoaded(WPARAM, LPARAM);
INT_PTR __cdecl OnAccountManagerInit(WPARAM, LPARAM);
@@ -427,9 +417,16 @@ private:
template<INT_PTR(__cdecl CSkypeProto::*Service)(WPARAM, LPARAM)>
static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
{
- CSkypeProto *proto = GetContactAccount((MCONTACT)wParam);
+ CSkypeProto *proto = CMPlugin::getInstance((MCONTACT)wParam);
return proto ? (proto->*Service)(wParam, lParam) : 0;
}
};
+struct CMPlugin : public ACCPROTOPLUGIN<CSkypeProto>
+{
+ CMPlugin() :
+ ACCPROTOPLUGIN<CSkypeProto>("SKYPE")
+ {}
+};
+
#endif //_SKYPE_PROTO_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_timers.cpp b/protocols/SkypeWeb/src/skype_timers.cpp
index 7004188d76..3e5a5e8446 100644
--- a/protocols/SkypeWeb/src/skype_timers.cpp
+++ b/protocols/SkypeWeb/src/skype_timers.cpp
@@ -31,7 +31,7 @@ void CSkypeProto::ProcessTimer()
void CALLBACK CSkypeProto::TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
mir_cslock lck(accountsLock);
- for (auto &it : Accounts)
+ for (auto &it : CMPlugin::g_arInstances)
it->ProcessTimer();
}
@@ -45,7 +45,7 @@ void CSkypeProto::SkypeSetTimer()
void CSkypeProto::SkypeUnsetTimer()
{
mir_cslock lck(timerLock);
- if (m_timer && Accounts.getCount() == 0)
+ if (m_timer && CMPlugin::g_arInstances.getCount() == 0)
KillTimer(nullptr, m_timer);
m_timer = 0;
}
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 6350b40c8c..ffed1601de 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -593,7 +593,7 @@ INT_PTR CSkypeProto::ParseSkypeUriService(WPARAM, LPARAM lParam)
INT_PTR CSkypeProto::GlobalParseSkypeUriService(WPARAM wParam, LPARAM lParam)
{
mir_cslock lck(accountsLock);
- for (auto &it : Accounts)
+ for (auto &it : CMPlugin::g_arInstances)
if (it->IsOnline())
return it->ParseSkypeUriService(wParam, lParam);