summaryrefslogtreecommitdiff
path: root/src/modules/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-02-23 19:43:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-02-23 19:43:21 +0000
commitaa387fa04aa096d163932d3f5f9711a2f146c6f0 (patch)
tree7efe5dabf5bf5b9a78f8f991522487814bfc8cb0 /src/modules/protocols
parent139c2c1a61d9f765704a2001199c2712d6587fb4 (diff)
- PROTO_INTERFACE::GetIcon removed and replaced with the standard implementation;
- PS_LOADICON also replaced with the standard function; - ProtoConstructor() & ProtoDestructor() macroses are introduced to simplify protocols' code; - GetIcon() method implementation removed from all protocols git-svn-id: http://svn.miranda-ng.org/main/trunk@3739 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/protocols')
-rw-r--r--src/modules/protocols/protoaccs.cpp4
-rw-r--r--src/modules/protocols/protocols.cpp56
-rw-r--r--src/modules/protocols/protoint.cpp1
-rw-r--r--src/modules/protocols/protoopts.cpp4
4 files changed, 54 insertions, 11 deletions
diff --git a/src/modules/protocols/protoaccs.cpp b/src/modules/protocols/protoaccs.cpp
index 5746d452c6..ae487ea866 100644
--- a/src/modules/protocols/protoaccs.cpp
+++ b/src/modules/protocols/protoaccs.cpp
@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
bool CheckProtocolOrder(void);
void BuildProtoMenus();
+HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex);
+
static BOOL bModuleInitialized = FALSE;
static int CompareAccounts(const PROTOACCOUNT* p1, const PROTOACCOUNT* p2)
@@ -319,7 +321,7 @@ static INT_PTR stub12(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM lParam)
static INT_PTR stub13(PROTO_INTERFACE* ppi, WPARAM wParam, LPARAM)
{
- return (INT_PTR)ppi->GetIcon(wParam);
+ return (INT_PTR)Proto_GetIcon(ppi, wParam);
}
static INT_PTR stub15(PROTO_INTERFACE* ppi, WPARAM, LPARAM lParam)
diff --git a/src/modules/protocols/protocols.cpp b/src/modules/protocols/protocols.cpp
index 6121609829..17c10638fa 100644
--- a/src/modules/protocols/protocols.cpp
+++ b/src/modules/protocols/protocols.cpp
@@ -302,6 +302,25 @@ static wchar_t** __fastcall Proto_FilesMatrixU(char **files)
return filesU;
}
+HICON Proto_GetIcon(PROTO_INTERFACE *ppro, int iconIndex)
+{
+ if (LOWORD(iconIndex) == PLI_PROTOCOL) {
+ if (iconIndex & PLIF_ICOLIBHANDLE)
+ return (HICON)ppro->m_hProtoIcon;
+
+ bool big = (iconIndex & PLIF_SMALL) == 0;
+ HICON hIcon = Skin_GetIconByHandle(ppro->m_hProtoIcon, big);
+
+ if (iconIndex & PLIF_ICOLIB)
+ return hIcon;
+
+ HICON hIcon2 = CopyIcon(hIcon);
+ Skin_ReleaseIcon(hIcon);
+ return hIcon2;
+ }
+ return NULL;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// 0.8.0+ - accounts
@@ -426,7 +445,7 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s
return (INT_PTR)ppi->FileResume((HANDLE)wParam, &pfr->action, (const PROTOCHAR**)&pfr->szFilename);
}
case 12: return (INT_PTR)ppi->GetCaps(wParam, (HANDLE)lParam);
- case 13: return (INT_PTR)ppi->GetIcon(wParam);
+ case 13: return (INT_PTR)Proto_GetIcon(ppi, wParam);
case 14: return (INT_PTR)ppi->GetInfo(hContact, wParam);;
case 15:
if (ppi->m_iVersion > 1)
@@ -614,6 +633,28 @@ INT_PTR CallProtoServiceInt(HANDLE hContact, const char *szModule, const char *s
/////////////////////////////////////////////////////////////////////////////////////////
+static INT_PTR srvProtoConstructor(WPARAM wParam, LPARAM lParam)
+{
+ PROTO_INTERFACE *ppi = (PROTO_INTERFACE*)wParam;
+ LPCSTR szProtoName = (LPCSTR)lParam;
+
+ ppi->m_iVersion = 2;
+ ppi->m_iStatus = ppi->m_iDesiredStatus = ID_STATUS_OFFLINE;
+ ppi->m_szModuleName = mir_strdup(szProtoName);
+ ppi->m_hProtoIcon = (HANDLE)CallService(MS_SKIN2_ISMANAGEDICON, (WPARAM)LoadSkinnedProtoIcon(szProtoName, ID_STATUS_ONLINE), 0);
+ return 0;
+}
+
+static INT_PTR srvProtoDestructor(WPARAM wParam, LPARAM)
+{
+ PROTO_INTERFACE *ppi = (PROTO_INTERFACE*)wParam;
+ mir_free(ppi->m_szModuleName);
+ mir_free(ppi->m_tszUserName);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static void InsertServiceListItem(int id, const char* szName)
{
TServiceListItem* p = (TServiceListItem*)mir_alloc(sizeof(TServiceListItem));
@@ -695,6 +736,9 @@ int LoadProtocolsModule(void)
CreateServiceFunction(MS_PROTO_ENUMACCOUNTS, Proto_EnumAccounts);
CreateServiceFunction(MS_PROTO_GETACCOUNT, srvProto_GetAccount);
+ CreateServiceFunction("Proto/Constructor", srvProtoConstructor);
+ CreateServiceFunction("Proto/Destructor", srvProtoDestructor);
+
CreateServiceFunction(MS_PROTO_ISACCOUNTENABLED, srvProto_IsAccountEnabled);
CreateServiceFunction(MS_PROTO_ISACCOUNTLOCKED, srvProto_IsAccountLocked);
@@ -703,8 +747,6 @@ int LoadProtocolsModule(void)
void UnloadProtocolsModule()
{
- int i;
-
if ( !bModuleInitialized) return;
if (hAckEvent) {
@@ -717,14 +759,14 @@ void UnloadProtocolsModule()
}
if (protos.getCount()) {
- for (i=0; i < protos.getCount(); i++) {
+ for (int i=0; i < protos.getCount(); i++) {
mir_free(protos[i]->szName);
mir_free(protos[i]);
}
protos.destroy();
}
- for (i=0; i < serviceItems.getCount(); i++)
+ for (int i=0; i < serviceItems.getCount(); i++)
mir_free(serviceItems[i]);
serviceItems.destroy();
}
@@ -733,10 +775,10 @@ void UnloadProtocolsModule()
pfnUninitProto GetProtocolDestructor(char* szProto)
{
- int idx;
PROTOCOLDESCRIPTOR temp;
temp.szName = szProto;
- if ((idx = protos.getIndex(&temp)) != -1)
+ int idx = protos.getIndex(&temp);
+ if (idx != -1)
return protos[idx]->fnUninit;
return NULL;
diff --git a/src/modules/protocols/protoint.cpp b/src/modules/protocols/protoint.cpp
index 8146754c9d..c0086cded0 100644
--- a/src/modules/protocols/protoint.cpp
+++ b/src/modules/protocols/protoint.cpp
@@ -288,7 +288,6 @@ PROTO_INTERFACE* AddDefaultAccount(const char* szProtoName)
{
PROTO_INTERFACE* ppi = new DEFAULT_PROTO_INTERFACE;
if (ppi != NULL) {
- ppi->m_iVersion = 1;
ppi->m_szModuleName = mir_strdup(szProtoName);
ppi->m_szProtoName = mir_strdup(szProtoName);
ppi->m_tszUserName = mir_a2t(szProtoName);
diff --git a/src/modules/protocols/protoopts.cpp b/src/modules/protocols/protoopts.cpp
index 80471da93f..e94abb718b 100644
--- a/src/modules/protocols/protoopts.cpp
+++ b/src/modules/protocols/protoopts.cpp
@@ -590,9 +590,9 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
lps->rcItem.left += cxIcon + 2;
if (acc->ppro) {
- hIcon = acc->ppro->GetIcon(PLI_PROTOCOL | PLIF_SMALL);
+ hIcon = Skin_GetIconByHandle(acc->ppro->m_hProtoIcon);
DrawIconEx(lps->hDC, lps->rcItem.left, lps->rcItem.top, hIcon, cxIcon, cyIcon, 0, hbrBack, DI_NORMAL);
- DestroyIcon(hIcon);
+ Skin_ReleaseIcon(hIcon);
}
lps->rcItem.left += cxIcon + 2;