diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_app/src/DefaultExtraIcons.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/extraicons.cpp | 174 | ||||
-rw-r--r-- | src/mir_app/src/hotkeys.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 13 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 13 | ||||
-rw-r--r-- | src/mir_app/src/miranda.h | 12 | ||||
-rw-r--r-- | src/mir_app/src/services.cpp | 6 | ||||
-rw-r--r-- | src/mir_app/src/sounds.cpp | 2 | ||||
-rw-r--r-- | src/mir_app/src/stdafx.h | 2 |
9 files changed, 128 insertions, 108 deletions
diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp index e5fa87d324..163ad21bc4 100644 --- a/src/mir_app/src/DefaultExtraIcons.cpp +++ b/src/mir_app/src/DefaultExtraIcons.cpp @@ -301,19 +301,19 @@ static int ProtocolOnClick(WPARAM wParam, LPARAM, LPARAM) void DefaultExtraIcons_Load()
{
- hExtraChat = ExtraIcon_Register("chat_activity", LPGEN("Chat activity"), "ChatActivity");
- hExtraVisibility = ExtraIcon_Register("visibility", "Visibility", Skin_GetIconName(SKINICON_OTHER_VISIBLE_ALL));
- hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male");
- hExtraProto = ExtraIcon_Register("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR),
+ hExtraChat = ExtraIcon_RegisterIcolib("chat_activity", LPGEN("Chat activity"), "ChatActivity");
+ hExtraVisibility = ExtraIcon_RegisterIcolib("visibility", "Visibility", Skin_GetIconName(SKINICON_OTHER_VISIBLE_ALL));
+ hExtraGender = ExtraIcon_RegisterIcolib("gender", "Gender", "gender_male");
+ hExtraProto = ExtraIcon_RegisterCallack("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR),
&ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick);
for (int i = 0; i < _countof(infos); i++) {
Info &p = infos[i];
p.hIcolib = Skin_GetIconHandle(p.iSkinIcon);
if (p.OnClick)
- p.hExtraIcon = ExtraIcon_Register(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p);
+ p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p);
else
- p.hExtraIcon = ExtraIcon_Register(p.name, p.desc, Skin_GetIconName(p.iSkinIcon));
+ p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon));
}
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
diff --git a/src/mir_app/src/extraicons.cpp b/src/mir_app/src/extraicons.cpp index ff11fbfed4..77392cf048 100644 --- a/src/mir_app/src/extraicons.cpp +++ b/src/mir_app/src/extraicons.cpp @@ -209,7 +209,7 @@ void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups) ///////////////////////////////////////////////////////////////////////////////
-void KillModuleExtraIcons(int hLangpack)
+MIR_APP_DLL(void) KillModuleExtraIcons(int hLangpack)
{
LIST<ExtraIcon> arDeleted(1);
@@ -345,79 +345,19 @@ void fnSetAllExtraIcons(MCONTACT hContact) ///////////////////////////////////////////////////////////////////////////////
// Services
-INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
+static void EI_PostCreate(BaseExtraIcon *extra, const char *name, int hLangpack)
{
- if (wParam == 0)
- return 0;
-
- EXTRAICON_INFO *ei = (EXTRAICON_INFO *)wParam;
- if (ei->cbSize < sizeof(EXTRAICON_INFO))
- return 0;
- if (ei->type != EXTRAICON_TYPE_CALLBACK && ei->type != EXTRAICON_TYPE_ICOLIB)
- return 0;
- if (IsEmpty(ei->name) || IsEmpty(ei->description))
- return 0;
- if (ei->type == EXTRAICON_TYPE_CALLBACK && (ei->ApplyIcon == NULL || ei->RebuildIcons == NULL))
- return 0;
-
- ptrT tszDesc(mir_a2t(ei->description));
- TCHAR *desc = TranslateTH(lParam, tszDesc);
-
- BaseExtraIcon *extra = GetExtraIconByName(ei->name);
- if (extra != NULL) {
- if (ei->type != extra->getType() || ei->type != EXTRAICON_TYPE_ICOLIB)
- return 0;
-
- // Found one, now merge it
- if (mir_tstrcmpi(extra->getDescription(), desc)) {
- CMString newDesc = extra->getDescription();
- newDesc += _T(" / ");
- newDesc += desc;
- extra->setDescription(newDesc.c_str());
- }
-
- if (!IsEmpty(ei->descIcon))
- extra->setDescIcon(ei->descIcon);
-
- if (ei->OnClick != NULL)
- extra->setOnClick(ei->OnClick, ei->onClickParam);
-
- if (extra->getSlot() > 0) {
- if (clistRebuildAlreadyCalled)
- extra->rebuildIcons();
- if (clistApplyAlreadyCalled)
- extraIconsByHandle[extra->getID() - 1]->applyIcons();
- }
-
- return extra->getID();
- }
-
- int id = registeredExtraIcons.getCount() + 1;
-
- switch (ei->type) {
- case EXTRAICON_TYPE_CALLBACK:
- extra = new CallbackExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon,
- ei->RebuildIcons, ei->ApplyIcon, ei->OnClick, ei->onClickParam);
- break;
- case EXTRAICON_TYPE_ICOLIB:
- extra = new IcolibExtraIcon(id, ei->name, desc, ei->descIcon == NULL ? "" : ei->descIcon, ei->OnClick,
- ei->onClickParam);
- break;
- default:
- return 0;
- }
-
char setting[512];
- mir_snprintf(setting, "Position_%s", ei->name);
+ mir_snprintf(setting, "Position_%s", name);
extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000));
- mir_snprintf(setting, "Slot_%s", ei->name);
+ mir_snprintf(setting, "Slot_%s", name);
int slot = db_get_w(NULL, MODULE_NAME, setting, 1);
if (slot == (WORD)-1)
slot = -1;
extra->setSlot(slot);
- extra->hLangpack = (int)lParam;
+ extra->hLangpack = hLangpack;
registeredExtraIcons.insert(extra);
extraIconsByHandle.insert(extra);
@@ -452,40 +392,112 @@ INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam) extra->applyIcons();
}
}
+}
+
+EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterCallack(const char *name, const char *description, const char *descIcon,
+ MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon,
+ MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int hLangpack)
+{
+ // EXTRAICON_TYPE_CALLBACK
+ if (IsEmpty(name) || IsEmpty(description))
+ return 0;
- return id;
+ if (ApplyIcon == NULL || RebuildIcons == NULL)
+ return 0;
+
+ // no way to merge
+ if (GetExtraIconByName(name) != NULL)
+ return 0;
+
+ ptrT tszDesc(mir_a2t(description));
+ TCHAR *desc = TranslateTH(hLangpack, tszDesc);
+
+ int id = registeredExtraIcons.getCount() + 1;
+ BaseExtraIcon *extra = new CallbackExtraIcon(id, name, desc, descIcon == NULL ? "" : descIcon, RebuildIcons, ApplyIcon, OnClick, onClickParam);
+ EI_PostCreate(extra, name, hLangpack);
+ return (HANDLE)id;
}
-INT_PTR ExtraIcon_SetIcon(WPARAM wParam, LPARAM)
+EXTERN_C MIR_APP_DLL(HANDLE) ExtraIcon_RegisterIcolib(const char *name, const char *description, const char *descIcon,
+ MIRANDAHOOKPARAM OnClick, LPARAM onClickParam, int hLangpack)
{
- if (wParam == 0)
- return -1;
+ if (IsEmpty(name) || IsEmpty(description))
+ return 0;
+
+ ptrT tszDesc(mir_a2t(description));
+ TCHAR *desc = TranslateTH(hLangpack, tszDesc);
- EXTRAICON *ei = (EXTRAICON*)wParam;
- if (ei->cbSize < sizeof(EXTRAICON) || ei->hExtraIcon == NULL || ei->hContact == NULL)
+ BaseExtraIcon *extra = GetExtraIconByName(name);
+ if (extra != NULL) {
+ if (extra->getType() != EXTRAICON_TYPE_ICOLIB)
+ return 0;
+
+ // Found one, now merge it
+ if (mir_tstrcmpi(extra->getDescription(), desc)) {
+ CMString newDesc = extra->getDescription();
+ newDesc += _T(" / ");
+ newDesc += desc;
+ extra->setDescription(newDesc.c_str());
+ }
+
+ if (!IsEmpty(descIcon))
+ extra->setDescIcon(descIcon);
+
+ if (OnClick != NULL)
+ extra->setOnClick(OnClick, onClickParam);
+
+ if (extra->getSlot() > 0) {
+ if (clistRebuildAlreadyCalled)
+ extra->rebuildIcons();
+ if (clistApplyAlreadyCalled)
+ extraIconsByHandle[extra->getID() - 1]->applyIcons();
+ }
+
+ return (HANDLE)extra->getID();
+ }
+
+ int id = registeredExtraIcons.getCount() + 1;
+ extra = new IcolibExtraIcon(id, name, desc, descIcon == NULL ? "" : descIcon, OnClick, onClickParam);
+ EI_PostCreate(extra, name, hLangpack);
+ return (HANDLE)id;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+MIR_APP_DLL(int) ExtraIcon_SetIcon(HANDLE hExtraIcon, MCONTACT hContact, HANDLE hImage)
+{
+ if (hExtraIcon == NULL || hContact == NULL)
return -1;
- ExtraIcon *extra = GetExtraIcon(ei->hExtraIcon);
+ ExtraIcon *extra = GetExtraIcon(hExtraIcon);
if (extra == NULL)
return -1;
- return extra->setIcon((int)ei->hExtraIcon, ei->hContact, ei->hImage);
+ return extra->setIcon((int)hExtraIcon, hContact, hImage);
}
-INT_PTR ExtraIcon_SetIconByName(WPARAM wParam, LPARAM)
+MIR_APP_DLL(int) ExtraIcon_SetIconByName(HANDLE hExtraIcon, MCONTACT hContact, const char *icoName)
{
- if (wParam == 0)
+ if (hExtraIcon == NULL || hContact == NULL)
+ return -1;
+
+ ExtraIcon *extra = GetExtraIcon(hExtraIcon);
+ if (extra == NULL)
return -1;
- EXTRAICON *ei = (EXTRAICON*)wParam;
- if (ei->cbSize < sizeof(EXTRAICON) || ei->hExtraIcon == NULL || ei->hContact == NULL)
+ return extra->setIconByName((int)hExtraIcon, hContact, icoName);
+}
+
+MIR_APP_DLL(int) ExtraIcon_Clear(HANDLE hExtraIcon, MCONTACT hContact)
+{
+ if (hExtraIcon == NULL || hContact == NULL)
return -1;
- ExtraIcon *extra = GetExtraIcon(ei->hExtraIcon);
+ ExtraIcon *extra = GetExtraIcon(hExtraIcon);
if (extra == NULL)
return -1;
- return extra->setIconByName((int)ei->hExtraIcon, ei->hContact, ei->icoName);
+ return extra->setIcon((int)hExtraIcon, hContact, NULL);
}
static INT_PTR svcExtraIcon_Add(WPARAM wParam, LPARAM)
@@ -509,10 +521,6 @@ void LoadExtraIconsModule() clistSlotCount = LOWORD(ret);
// Services
- CreateServiceFunction(MS_EXTRAICON_REGISTER, ExtraIcon_Register);
- CreateServiceFunction(MS_EXTRAICON_SET_ICON, ExtraIcon_SetIcon);
- CreateServiceFunction(MS_EXTRAICON_SET_ICON_BY_NAME, &ExtraIcon_SetIconByName);
-
CreateServiceFunction(MS_CLIST_EXTRA_ADD_ICON, svcExtraIcon_Add);
hEventExtraClick = CreateHookableEvent(ME_CLIST_EXTRA_CLICK);
diff --git a/src/mir_app/src/hotkeys.cpp b/src/mir_app/src/hotkeys.cpp index 0e91b12775..dfcbd9455d 100644 --- a/src/mir_app/src/hotkeys.cpp +++ b/src/mir_app/src/hotkeys.cpp @@ -308,7 +308,7 @@ void RegisterHotkeys() }
}
-void KillModuleHotkeys(int hLangpack)
+MIR_APP_DLL(void) KillModuleHotkeys(int hLangpack)
{
for (int i = hotkeys.getCount() - 1; i >= 0; i--) {
THotkeyItem *item = hotkeys[i];
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 5ae5f527e7..5d20787f03 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -235,4 +235,15 @@ Menu_BuildGroupMenu @233 Menu_AddTrayMenuItem @234
Menu_BuildTrayMenu @235
Menu_DestroyNestedMenu @236
-KillModuleIcons @237
+ExtraIcon_SetIcon @237
+ExtraIcon_SetIconByName @238
+ExtraIcon_Clear @239
+ExtraIcon_RegisterCallack @240
+ExtraIcon_RegisterIcolib @241
+KillModuleIcons @242
+KillModuleColours @243
+KillModuleEffects @244
+KillModuleExtraIcons @245
+KillModuleFonts @246
+KillModuleHotkeys @247
+KillModuleSounds @248
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 2a74b497cf..1cc06d89b0 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -235,4 +235,15 @@ Menu_BuildGroupMenu @233 Menu_AddTrayMenuItem @234
Menu_BuildTrayMenu @235
Menu_DestroyNestedMenu @236
-KillModuleIcons @237
+ExtraIcon_SetIcon @237
+ExtraIcon_SetIconByName @238
+ExtraIcon_Clear @239
+ExtraIcon_RegisterCallack @240
+ExtraIcon_RegisterIcolib @241
+KillModuleIcons @242
+KillModuleColours @243
+KillModuleEffects @244
+KillModuleExtraIcons @245
+KillModuleFonts @246
+KillModuleHotkeys @247
+KillModuleSounds @248
diff --git a/src/mir_app/src/miranda.h b/src/mir_app/src/miranda.h index 52fedfa58e..d74cee61db 100644 --- a/src/mir_app/src/miranda.h +++ b/src/mir_app/src/miranda.h @@ -55,18 +55,6 @@ extern LIST<DATABASELINK> arDbPlugins; int InitIni(void);
void UninitIni(void);
-/**** extraicons.cpp *******************************************************************/
-
-void KillModuleExtraIcons(int hLangpack);
-
-/**** fontService.cpp ******************************************************************/
-
-void KillModuleFonts(int hLangpack);
-void KillModuleColours(int hLangpack);
-void KillModuleEffects(int hLangpack);
-void KillModuleHotkeys(int hLangpack);
-void KillModuleSounds(int hLangpack);
-
/**** miranda.cpp **********************************************************************/
extern HINSTANCE g_hInst;
diff --git a/src/mir_app/src/services.cpp b/src/mir_app/src/services.cpp index 3d1fdaf5c2..c074526c4a 100644 --- a/src/mir_app/src/services.cpp +++ b/src/mir_app/src/services.cpp @@ -325,7 +325,7 @@ INT_PTR GetFont(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
-void KillModuleFonts(int hLangpack)
+MIR_APP_DLL(void) KillModuleFonts(int hLangpack)
{
for (int i = font_id_list.getCount() - 1; i >= 0; i--)
if (font_id_list[i].hLangpack == hLangpack)
@@ -400,7 +400,7 @@ INT_PTR GetColour(WPARAM wParam, LPARAM) /////////////////////////////////////////////////////////////////////////////////////////
-void KillModuleColours(int hLangpack)
+MIR_APP_DLL(void) KillModuleColours(int hLangpack)
{
for (int i = colour_id_list.getCount() - 1; i >= 0; i--)
if (colour_id_list[i].hLangpack == hLangpack)
@@ -493,7 +493,7 @@ INT_PTR GetEffect(WPARAM wParam, LPARAM lParam) /////////////////////////////////////////////////////////////////////////////////////////
-void KillModuleEffects(int hLangpack)
+MIR_APP_DLL(void) KillModuleEffects(int hLangpack)
{
for (int i = effect_id_list.getCount() - 1; i >= 0; i--)
if (effect_id_list[i].hLangpack == hLangpack)
diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index 6722e17c83..a8d230ce5c 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -55,7 +55,7 @@ static OBJLIST<SoundItem> arSounds(10, CompareSounds); ///////////////////////////////////////////////////////////////////////////////
-void KillModuleSounds(int hLangpack)
+MIR_APP_DLL(void) KillModuleSounds(int hLangpack)
{
for (int i = arSounds.getCount()-1; i >= 0; i--) {
SoundItem& p = arSounds[i];
diff --git a/src/mir_app/src/stdafx.h b/src/mir_app/src/stdafx.h index 935e2dd4c1..b5577ece4d 100644 --- a/src/mir_app/src/stdafx.h +++ b/src/mir_app/src/stdafx.h @@ -73,6 +73,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_protosvc.h>
#include <m_protocols.h>
#include <m_protoint.h>
+#include <m_hotkeys.h>
+#include <m_fontservice.h>
#include <m_options.h>
#include <m_skin.h>
#include <m_contacts.h>
|