diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-10 21:07:20 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-10 21:07:20 +0000 |
commit | 6b1fbf4d40fa3b643aca4e9e82a132cc54f36b76 (patch) | |
tree | c9757bf9da76e125d8a8da1ca3d4e8e996ae792f /src | |
parent | 1df925a85fe8e7a03698a8a5a7a2e3ee03e2c3a1 (diff) |
- SRMM status icons module moved to the core;
- this code removed from Scriver & tabSRMM
git-svn-id: http://svn.miranda-ng.org/main/trunk@4416 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/modules.cpp | 4 | ||||
-rw-r--r-- | src/miranda32_10.vcxproj | 3 | ||||
-rw-r--r-- | src/miranda32_10.vcxproj.filters | 6 | ||||
-rw-r--r-- | src/miranda32_11.vcxproj | 3 | ||||
-rw-r--r-- | src/miranda32_11.vcxproj.filters | 6 | ||||
-rw-r--r-- | src/modules/srmm/statusicon.cpp | 206 |
6 files changed, 228 insertions, 0 deletions
diff --git a/src/core/modules.cpp b/src/core/modules.cpp index 1eb92eab3c..b36a6812cc 100644 --- a/src/core/modules.cpp +++ b/src/core/modules.cpp @@ -43,6 +43,7 @@ int LoadAccountsModule(void); // core: account manager int LoadIgnoreModule(void); // protocol filter: ignore
int LoadDbintfModule(void);
int LoadEventsModule(void);
+int LoadSrmmModule(void);
int LoadContactsModule(void);
int LoadContactListModule(void);// ui: clist
@@ -81,6 +82,7 @@ void UnloadNewPlugins(void); void UnloadProtocolsModule(void);
void UnloadSkinSounds(void);
void UnloadSkinHotkeys(void);
+void UnloadSrmmModule(void);
void UnloadSslModule(void);
void UnloadUtilsModule(void);
@@ -138,6 +140,7 @@ int LoadDefaultModules(void) if ( LoadSkinSounds()) return 1;
if ( LoadSkinHotkeys()) return 1;
if ( LoadFontserviceModule()) return 1;
+ if ( LoadSrmmModule()) return 1;
if ( LoadDescButtonModule()) return 1;
if ( LoadOptionsModule()) return 1;
@@ -170,6 +173,7 @@ void UnloadDefaultModules(void) UnloadProtocolsModule();
UnloadSkinSounds();
UnloadSkinHotkeys();
+ UnloadSrmmModule();
// UnloadErrorsModule();
UnloadIcoLibModule();
UnloadUtilsModule();
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index 973bd08757..3fbd6ce645 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -478,6 +478,9 @@ <ClCompile Include="modules\skin\sounds.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\srmm\statusicon.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\utils\bmpfilter.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index ad46aa0a85..fc15b485fc 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -73,6 +73,9 @@ <Filter Include="Modules\extraicons">
<UniqueIdentifier>{e125e36b-fc7d-4a78-8f13-67d3c9333621}</UniqueIdentifier>
</Filter>
+ <Filter Include="Modules\srmm">
+ <UniqueIdentifier>{3da88f1b-9c87-43dc-a7a1-140d8dc6eefc}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\m_addcontact.h">
@@ -620,6 +623,9 @@ <ClCompile Include="core\stdafx.cpp">
<Filter>Core</Filter>
</ClCompile>
+ <ClCompile Include="modules\srmm\statusicon.cpp">
+ <Filter>Modules\srmm</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc">
diff --git a/src/miranda32_11.vcxproj b/src/miranda32_11.vcxproj index 553711141d..762b9e1626 100644 --- a/src/miranda32_11.vcxproj +++ b/src/miranda32_11.vcxproj @@ -483,6 +483,9 @@ <ClCompile Include="modules\skin\sounds.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
+ <ClCompile Include="modules\srmm\statusicon.cpp">
+ <PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
+ </ClCompile>
<ClCompile Include="modules\utils\bmpfilter.cpp">
<PrecompiledHeaderFile>..\..\core\commonheaders.h</PrecompiledHeaderFile>
</ClCompile>
diff --git a/src/miranda32_11.vcxproj.filters b/src/miranda32_11.vcxproj.filters index ad46aa0a85..4ec98818a1 100644 --- a/src/miranda32_11.vcxproj.filters +++ b/src/miranda32_11.vcxproj.filters @@ -73,6 +73,9 @@ <Filter Include="Modules\extraicons">
<UniqueIdentifier>{e125e36b-fc7d-4a78-8f13-67d3c9333621}</UniqueIdentifier>
</Filter>
+ <Filter Include="Modules\srmm">
+ <UniqueIdentifier>{b3f78380-76da-4a82-a0e2-1a14b173dac1}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\m_addcontact.h">
@@ -620,6 +623,9 @@ <ClCompile Include="core\stdafx.cpp">
<Filter>Core</Filter>
</ClCompile>
+ <ClCompile Include="modules\srmm\statusicon.cpp">
+ <Filter>Modules\srmm</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource.rc">
diff --git a/src/modules/srmm/statusicon.cpp b/src/modules/srmm/statusicon.cpp new file mode 100644 index 0000000000..dcf055a88f --- /dev/null +++ b/src/modules/srmm/statusicon.cpp @@ -0,0 +1,206 @@ +/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-13 Miranda NG project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "..\..\core\commonheaders.h"
+
+struct StatusIconChild : public MZeroedObject
+{
+ ~StatusIconChild()
+ {
+ mir_free(szTooltip);
+ }
+
+ HANDLE hContact;
+ HICON hIcon, hIconDisabled;
+ int flags;
+ char *szTooltip;
+};
+
+struct StatusIconMain : public MZeroedObject
+{
+ StatusIconMain() :
+ arChildren(3, HandleKeySortT)
+ {}
+
+ ~StatusIconMain()
+ {
+ mir_free(sid.szModule);
+ mir_free(sid.szTooltip);
+ }
+
+ StatusIconData sid;
+ OBJLIST<StatusIconChild> arChildren;
+};
+
+static int CompareIcons(const StatusIconMain *p1, const StatusIconMain *p2)
+{
+ int res = strcmp(p1->sid.szModule, p2->sid.szModule);
+ if (res)
+ return res;
+
+ return p1->sid.dwId - p2->sid.dwId;
+}
+
+static OBJLIST<StatusIconMain> arIcons(3, CompareIcons);
+
+static HANDLE hHookIconsChanged;
+
+INT_PTR ModifyStatusIcon(WPARAM wParam, LPARAM lParam)
+{
+ StatusIconData *sid = (StatusIconData *)lParam;
+ if (sid == NULL || sid->cbSize != sizeof(StatusIconData))
+ return 1;
+
+ StatusIconMain *p = arIcons.find((StatusIconMain*)sid);
+ if (p == NULL)
+ return 1;
+
+ HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL) {
+ memcpy(&p->sid, sid, sizeof(p->sid));
+ replaceStr(p->sid.szModule, sid->szModule);
+ replaceStr(p->sid.szTooltip, sid->szTooltip);
+ NotifyEventHooks(hHookIconsChanged, NULL, (LPARAM)p);
+ return 0;
+ }
+
+ StatusIconChild *pc = p->arChildren.find((StatusIconChild*)&hContact);
+ if (pc == NULL) {
+ pc = new StatusIconChild();
+ pc->hContact = hContact;
+ p->arChildren.insert(pc);
+ }
+
+ pc->flags = sid->flags;
+ pc->hIcon = sid->hIcon;
+ pc->hIconDisabled = sid->hIconDisabled;
+ replaceStr(pc->szTooltip, sid->szTooltip);
+ NotifyEventHooks(hHookIconsChanged, wParam, (LPARAM)p);
+ return 0;
+}
+
+static INT_PTR AddStatusIcon(WPARAM wParam, LPARAM lParam)
+{
+ StatusIconData *sid = (StatusIconData *)lParam;
+ if (sid == NULL || sid->cbSize != sizeof(StatusIconData))
+ return 1;
+
+ StatusIconMain *p = arIcons.find((StatusIconMain*)sid);
+ if (p != NULL)
+ return ModifyStatusIcon(0, lParam);
+
+ p = new StatusIconMain;
+ memcpy(&p->sid, sid, sizeof(p->sid));
+ p->sid.szModule = mir_strdup(sid->szModule);
+ p->sid.szTooltip = mir_strdup(sid->szTooltip);
+ arIcons.insert(p);
+
+ NotifyEventHooks(hHookIconsChanged, NULL, (LPARAM)p);
+ return 0;
+}
+
+static INT_PTR RemoveStatusIcon(WPARAM wParam, LPARAM lParam)
+{
+ StatusIconData *sid = (StatusIconData *)lParam;
+ if (sid == NULL || sid->cbSize != sizeof(StatusIconData))
+ return 1;
+
+ StatusIconMain *p = arIcons.find((StatusIconMain*)sid);
+ if (p == NULL)
+ return 1;
+
+ arIcons.remove(p);
+ return 0;
+}
+
+static INT_PTR GetNthIcon(WPARAM wParam, LPARAM lParam)
+{
+ static StatusIconData res;
+
+ for (int i=arIcons.getCount()-1, nVis = 0; i >= 0; i--) {
+ StatusIconMain &p = arIcons[i];
+
+ StatusIconChild *pc = p.arChildren.find((StatusIconChild*)&wParam);
+ if (pc) {
+ if (pc->flags & MBF_HIDDEN)
+ continue;
+ }
+ else if (p.sid.flags & MBF_HIDDEN)
+ continue;
+
+ if (nVis == (int)lParam) {
+ memcpy(&res, &p, sizeof(res));
+ if (pc) {
+ res.hIcon = pc->hIcon;
+ res.hIconDisabled = pc->hIconDisabled;
+ res.flags = pc->flags;
+ res.szTooltip = pc->szTooltip;
+ }
+ return (INT_PTR)&res;
+ }
+ nVis++;
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static int OnWindowEvent(WPARAM, LPARAM lParam)
+{
+ MessageWindowEventData *evt = (MessageWindowEventData*)lParam;
+ if (evt->uType == MSG_WINDOW_EVT_CLOSE) {
+ for (int i=0; i < arIcons.getCount(); i++) {
+ StatusIconMain &p = arIcons[i];
+ p.arChildren.remove((StatusIconChild*)&evt->hContact);
+ }
+ }
+
+ return 0;
+}
+
+static int OnModulesLoaded(WPARAM, LPARAM)
+{
+ HookEvent(ME_MSG_WINDOWEVENT, OnWindowEvent);
+ return 0;
+}
+
+int LoadSrmmModule()
+{
+ CreateServiceFunction(MS_MSG_ADDICON, AddStatusIcon);
+ CreateServiceFunction(MS_MSG_REMOVEICON, RemoveStatusIcon);
+ CreateServiceFunction(MS_MSG_MODIFYICON, ModifyStatusIcon);
+ CreateServiceFunction(MS_MSG_GETNTHICON, GetNthIcon);
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+
+ hHookIconsChanged = CreateHookableEvent(ME_MSG_ICONSCHANGED);
+ return 0;
+}
+
+void UnloadSrmmModule()
+{
+ arIcons.destroy();
+ NotifyEventHooks(hHookIconsChanged, NULL, NULL);
+ DestroyHookableEvent(hHookIconsChanged);
+}
|