summaryrefslogtreecommitdiff
path: root/src/modules/extraicons
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-06-13 16:55:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-06-13 16:55:17 +0000
commitcbe3cb21f5bca61a03bbd4ae811ee906e09b3f4f (patch)
tree4854fb66f4d59940efa3c1590237915851074dbf /src/modules/extraicons
parent351bcbec48ed77af5f8efcc4d5198707922c5d86 (diff)
- miranda32.exe now does nothing bug extends PATH to %miranda_root%\libs and loads mir_app.dll;
- everything that was in miranda32.exe (including resources) moved to mir_app.dll; - exports from mir_app.dll now available for using directly, without perversions; - src/stdplug.h deleted; git-svn-id: http://svn.miranda-ng.org/main/trunk@14143 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/modules/extraicons')
-rw-r--r--src/modules/extraicons/BaseExtraIcon.cpp80
-rw-r--r--src/modules/extraicons/CallbackExtraIcon.cpp75
-rw-r--r--src/modules/extraicons/DefaultExtraIcons.cpp326
-rw-r--r--src/modules/extraicons/ExtraIcon.cpp75
-rw-r--r--src/modules/extraicons/ExtraIcon.h180
-rw-r--r--src/modules/extraicons/ExtraIconGroup.cpp217
-rw-r--r--src/modules/extraicons/IcolibExtraIcon.cpp119
-rw-r--r--src/modules/extraicons/extraicons.cpp545
-rw-r--r--src/modules/extraicons/extraicons.h72
-rw-r--r--src/modules/extraicons/options_ei.cpp472
-rw-r--r--src/modules/extraicons/usedIcons.cpp94
-rw-r--r--src/modules/extraicons/usedIcons.h34
12 files changed, 0 insertions, 2289 deletions
diff --git a/src/modules/extraicons/BaseExtraIcon.cpp b/src/modules/extraicons/BaseExtraIcon.cpp
deleted file mode 100644
index eb56429bbf..0000000000
--- a/src/modules/extraicons/BaseExtraIcon.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-BaseExtraIcon::BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param) :
- ExtraIcon(name), id(id), OnClick(OnClick), onClickParam(param),
- tszDescription(mir_tstrdup(description)),
- szDescIcon(mir_strdup(descIcon))
-{
-}
-
-BaseExtraIcon::~BaseExtraIcon()
-{
-}
-
-void BaseExtraIcon::setOnClick(MIRANDAHOOKPARAM pFunc, LPARAM pParam)
-{
- OnClick = pFunc;
- onClickParam = pParam;
-}
-
-int BaseExtraIcon::getID() const
-{
- return id;
-}
-
-const TCHAR* BaseExtraIcon::getDescription() const
-{
- return tszDescription;
-}
-
-void BaseExtraIcon::setDescription(const TCHAR *desc)
-{
- tszDescription = mir_tstrdup(desc);
-}
-
-const char* BaseExtraIcon::getDescIcon() const
-{
- return szDescIcon;
-}
-
-void BaseExtraIcon::setDescIcon(const char *icon)
-{
- szDescIcon = mir_strdup(icon);
-}
-
-void BaseExtraIcon::onClick(MCONTACT hContact)
-{
- if (OnClick != NULL)
- OnClick(hContact, (LPARAM)ConvertToClistSlot(slot), onClickParam);
-}
-
-int BaseExtraIcon::ClistSetExtraIcon(MCONTACT hContact, HANDLE hImage)
-{
- ExtraIcon *tmp = extraIconsByHandle[id - 1];
- if (tmp != this)
- return tmp->ClistSetExtraIcon(hContact, hImage);
- return Clist_SetExtraIcon(hContact, slot, hImage);
-}
diff --git a/src/modules/extraicons/CallbackExtraIcon.cpp b/src/modules/extraicons/CallbackExtraIcon.cpp
deleted file mode 100644
index 712e8e3b86..0000000000
--- a/src/modules/extraicons/CallbackExtraIcon.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-CallbackExtraIcon::CallbackExtraIcon(int _id, const char *_name, const TCHAR *_description, const char *_descIcon,
- MIRANDAHOOK _RebuildIcons, MIRANDAHOOK _ApplyIcon, MIRANDAHOOKPARAM _OnClick, LPARAM _param) :
- BaseExtraIcon(_id, _name, _description, _descIcon, _OnClick, _param),
- RebuildIcons(_RebuildIcons), ApplyIcon(_ApplyIcon), needToRebuild(true)
-{
-}
-
-CallbackExtraIcon::~CallbackExtraIcon()
-{
-}
-
-int CallbackExtraIcon::getType() const
-{
- return EXTRAICON_TYPE_CALLBACK;
-}
-
-void CallbackExtraIcon::rebuildIcons()
-{
- if (!isEnabled()) {
- needToRebuild = true;
- return;
- }
-
- needToRebuild = false;
- RebuildIcons(0, 0);
-}
-
-void CallbackExtraIcon::applyIcon(MCONTACT hContact)
-{
- if (!isEnabled() || hContact == NULL)
- return;
-
- if (needToRebuild)
- rebuildIcons();
-
- ApplyIcon(hContact, 0);
-}
-
-int CallbackExtraIcon::setIcon(int id, MCONTACT hContact, HANDLE icon)
-{
- if (!isEnabled() || hContact == NULL || id != this->id)
- return -1;
-
- return ClistSetExtraIcon(hContact, icon);
-}
-
-int CallbackExtraIcon::setIconByName(int id, MCONTACT hContact, const char *icon)
-{
- return -1;
-}
diff --git a/src/modules/extraicons/DefaultExtraIcons.cpp b/src/modules/extraicons/DefaultExtraIcons.cpp
deleted file mode 100644
index dc1833d00f..0000000000
--- a/src/modules/extraicons/DefaultExtraIcons.cpp
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "m_cluiframes.h"
-
-#include "ExtraIcon.h"
-#include "extraicons.h"
-
-ExtraIcon* GetExtraIcon(HANDLE id);
-
-////////////////////////////////////////////////////////////////////////////////////////
-// DB extra icons
-
-HANDLE hExtraVisibility, hExtraChat, hExtraGender, hExtraProto;
-
-static void SetVisibility(MCONTACT hContact, int apparentMode, bool clear)
-{
- if (hContact == NULL)
- return;
-
- char *proto = GetContactProto(hContact);
- if (IsEmpty(proto))
- return;
-
- if (apparentMode <= 0)
- apparentMode = db_get_w(hContact, proto, "ApparentMode", 0);
-
- HANDLE hExtraIcon, hIcolib = NULL;
-
- if (db_get_b(hContact, proto, "ChatRoom", 0)) {
- // Is chat
- hExtraIcon = hExtraChat;
- if (apparentMode == ID_STATUS_OFFLINE)
- hIcolib = Skin_GetIconHandle("ChatActivity");
- }
- else {
- // Not chat
- hExtraIcon = hExtraVisibility;
- if (apparentMode == ID_STATUS_OFFLINE)
- hIcolib = LoadSkinnedIconHandle(SKINICON_OTHER_INVISIBLE_ALL);
- else if (apparentMode == ID_STATUS_ONLINE)
- hIcolib = LoadSkinnedIconHandle(SKINICON_OTHER_VISIBLE_ALL);
- }
-
- if (hIcolib != NULL || clear) {
- ExtraIcon *extra = GetExtraIcon(hExtraIcon);
- if (extra)
- extra->setIcon((int)hExtraIcon, hContact, hIcolib);
- }
-}
-
-static void SetGender(MCONTACT hContact, int gender, bool clear)
-{
- if (hContact == NULL)
- return;
-
- char *proto = GetContactProto(hContact);
- if (IsEmpty(proto))
- return;
-
- if (gender <= 0)
- gender = db_get_b(hContact, proto, "Gender", 0);
- if (gender <= 0)
- gender = db_get_b(hContact, "UserInfo", "Gender", 0);
-
- const char *ico;
- if (gender == 'M')
- ico = "gender_male";
- else if (gender == 'F')
- ico = "gender_female";
- else
- ico = NULL;
-
- if (ico != NULL || clear) {
- ExtraIcon *extra = GetExtraIcon(hExtraGender);
- if (extra)
- extra->setIconByName((int)hExtraGender, hContact, ico);
- }
-}
-
-struct Info
-{
- const char *name;
- const char *desc;
- int iSkinIcon;
- const char *db[8];
- void(*OnClick)(Info *info, const char *text);
-
- HANDLE hIcolib, hExtraIcon;
-};
-
-static void EmailOnClick(Info *info, const char *text)
-{
- char cmd[1024];
- mir_snprintf(cmd, SIZEOF(cmd), "mailto:%s", text);
- ShellExecuteA(NULL, "open", cmd, NULL, NULL, SW_SHOW);
-}
-
-static void HomepageOnClick(Info *info, const char *text)
-{
- ShellExecuteA(NULL, "open", text, NULL, NULL, SW_SHOW);
-}
-
-static Info infos[] =
-{
- { "homepage", "Homepage", SKINICON_OTHER_MIRANDAWEB,
- { NULL, "Homepage", "UserInfo", "Homepage" },
- &HomepageOnClick },
- { "sms", "Phone/SMS", SKINICON_OTHER_SMS,
- { NULL, "Cellular", "UserInfo", "Cellular", "UserInfo", "Phone", "UserInfo", "MyPhone0" },
- NULL },
- { "email", "E-mail", SKINICON_OTHER_SENDEMAIL,
- { NULL, "e-mail", "UserInfo", "e-mail", "UserInfo", "Mye-mail0" },
- &EmailOnClick },
-};
-
-static void SetExtraIcons(MCONTACT hContact)
-{
- if (hContact == NULL)
- return;
-
- char *proto = GetContactProto(hContact);
- if ( IsEmpty(proto))
- return;
-
- for (unsigned int i = 0; i < SIZEOF(infos); i++) {
- Info &p = infos[i];
-
- for (unsigned int j = 0; j < SIZEOF(p.db); j += 2) {
- if (p.db[j + 1] == NULL)
- break;
-
- ptrA szValue(db_get_sa(hContact, p.db[j] == NULL ? proto : p.db[j], p.db[j + 1]));
- if (!IsEmpty(szValue)) {
- ExtraIcon_SetIcon(p.hExtraIcon, hContact, p.hIcolib);
- break;
- }
- }
- }
-}
-
-static int SettingChanged(WPARAM hContact, LPARAM lParam)
-{
- if (hContact == NULL)
- return 0;
-
- char *proto = GetContactProto(hContact);
- if (IsEmpty(proto))
- return 0;
-
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING*)lParam;
- bool isProto = (mir_strcmp(cws->szModule, proto) == 0);
- if (isProto && mir_strcmp(cws->szSetting, "ApparentMode") == 0) {
- SetVisibility(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.wVal, true);
- return 0;
- }
-
- if (mir_strcmp(cws->szSetting, "Gender") == 0 && (isProto || mir_strcmp(cws->szModule, "UserInfo") == 0)) {
- SetGender(hContact, cws->value.type == DBVT_DELETED ? 0 : cws->value.bVal, true);
- return 0;
- }
-
- for (int i = 0; i < SIZEOF(infos); i++) {
- Info &p = infos[i];
-
- for (int j = 0; j < SIZEOF(p.db); j += 2) {
- if (p.db[j + 1] == NULL)
- break;
- if (p.db[j] == NULL && !isProto)
- continue;
- if (p.db[j] != NULL && mir_strcmp(cws->szModule, p.db[j]))
- continue;
- if (mir_strcmp(cws->szSetting, p.db[j + 1]))
- continue;
-
- bool show = (cws->value.type != DBVT_DELETED && !IsEmpty(cws->value.pszVal));
- ExtraIcon_SetIcon(p.hExtraIcon, hContact, show ? p.hIcolib : NULL);
- break;
- }
- }
-
- return 0;
-}
-
-static int DefaultOnClick(WPARAM hContact, LPARAM lParam, LPARAM param)
-{
- Info *p = (Info*)param;
- if (p == NULL)
- return 0;
-
- if (hContact == NULL)
- return 0;
-
- char *proto = GetContactProto(hContact);
- if (IsEmpty(proto))
- return 0;
-
- bool found = false;
- for (int j = 0; !found && j < SIZEOF(p->db); j += 2) {
- if (p->db[j + 1] == NULL)
- break;
-
- ptrA szValue(db_get_sa(hContact, p->db[j] == NULL ? proto : p->db[j], p->db[j + 1]));
- if (!IsEmpty(szValue)) {
- p->OnClick(p, szValue);
- found = true;
- }
- }
-
- return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-// Protocol icon
-
-struct ProtoInfo
-{
- ProtoInfo(LPCSTR _proto, HANDLE _image) :
- proto(mir_strdup(_proto)),
- hImage(_image)
- {}
-
- ptrA proto;
- HANDLE hImage;
-};
-
-static int CompareProtos(const ProtoInfo *p1, const ProtoInfo *p2)
-{ return mir_strcmp(p1->proto, p2->proto);
-}
-
-OBJLIST<ProtoInfo> arProtos(10, CompareProtos);
-
-static int ProtocolRebuildIcons(WPARAM wParam, LPARAM lParam)
-{
- arProtos.destroy();
- return 0;
-}
-
-static ProtoInfo* FindProto(const char *proto)
-{
- ProtoInfo *p = arProtos.find((ProtoInfo*)&proto);
- if (p)
- return p;
-
- HICON hIcon = LoadSkinnedProtoIcon(proto, ID_STATUS_ONLINE);
- if (hIcon == NULL)
- return NULL;
-
- HANDLE hImage = ExtraIcon_Add(hIcon);
- if (hImage == INVALID_HANDLE_VALUE)
- return NULL;
-
- p = new ProtoInfo(proto, hImage);
- arProtos.insert(p);
- return p;
-}
-
-static int ProtocolApplyIcon(WPARAM hContact, LPARAM lParam)
-{
- char *proto = GetContactProto(hContact);
- if (IsEmpty(proto))
- return 0;
-
- HANDLE hImage = INVALID_HANDLE_VALUE;
- ProtoInfo *pi = FindProto(proto);
- if (pi != NULL)
- hImage = pi->hImage;
-
- ExtraIcon_SetIcon(hExtraProto, hContact, hImage);
- return 0;
-}
-
-static int ProtocolOnClick(WPARAM wParam, LPARAM lParam, LPARAM param)
-{
- if (wParam)
- CallService(MS_USERINFO_SHOWDIALOG, wParam, 0);
- return 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-
-void DefaultExtraIcons_Load()
-{
- hExtraChat = ExtraIcon_Register("chat_activity", LPGEN("Chat activity"), "ChatActivity");
- hExtraVisibility = ExtraIcon_Register("visibility", "Visibility", LoadSkinnedIconName(SKINICON_OTHER_VISIBLE_ALL));
- hExtraGender = ExtraIcon_Register("gender", "Gender", "gender_male");
- hExtraProto = ExtraIcon_Register("protocol", "Account", LoadSkinnedIconName(SKINICON_OTHER_ACCMGR),
- &ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick);
-
- for (int i = 0; i < SIZEOF(infos); i++) {
- Info &p = infos[i];
- p.hIcolib = LoadSkinnedIconHandle(p.iSkinIcon);
- if (p.OnClick)
- p.hExtraIcon = ExtraIcon_Register(p.name, p.desc, LoadSkinnedIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p);
- else
- p.hExtraIcon = ExtraIcon_Register(p.name, p.desc, LoadSkinnedIconName(p.iSkinIcon));
- }
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- SetExtraIcons(hContact);
- SetVisibility(hContact, -1, false);
- SetGender(hContact, -1, false);
- }
-
- HookEvent(ME_DB_CONTACT_SETTINGCHANGED, SettingChanged);
-}
diff --git a/src/modules/extraicons/ExtraIcon.cpp b/src/modules/extraicons/ExtraIcon.cpp
deleted file mode 100644
index 4a841423f3..0000000000
--- a/src/modules/extraicons/ExtraIcon.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-ExtraIcon::ExtraIcon(const char *name) :
- szName(mir_strdup(name)), slot(-1), position(1000), hLangpack(0)
-{
-}
-
-ExtraIcon::~ExtraIcon()
-{
-}
-
-const char *ExtraIcon::getName() const
-{
- return szName;
-}
-
-int ExtraIcon::getSlot() const
-{
- return slot;
-}
-
-void ExtraIcon::setSlot(int slot)
-{
- this->slot = slot;
-}
-
-int ExtraIcon::getPosition() const
-{
- return position;
-}
-
-void ExtraIcon::setPosition(int position)
-{
- this->position = position;
-}
-
-bool ExtraIcon::isEnabled() const
-{
- return slot >= 0;
-}
-
-void ExtraIcon::applyIcons()
-{
- if (!isEnabled())
- return;
-
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- // Clear to assert that it will be cleared
- Clist_SetExtraIcon(hContact, slot, INVALID_HANDLE_VALUE);
- applyIcon(hContact);
- }
-}
diff --git a/src/modules/extraicons/ExtraIcon.h b/src/modules/extraicons/ExtraIcon.h
deleted file mode 100644
index 3f4c34d8e0..0000000000
--- a/src/modules/extraicons/ExtraIcon.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __EXTRAICON_H__
-#define __EXTRAICON_H__
-
-#define EXTRAICON_TYPE_GROUP -1
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// ExtraIcon - base class for all extra icons
-
-class ExtraIcon
-{
-public:
- ExtraIcon(const char *name);
- virtual ~ExtraIcon();
-
- virtual void rebuildIcons() = 0;
- virtual void applyIcons();
- virtual void applyIcon(MCONTACT hContact) =0 ;
- virtual void onClick(MCONTACT hContact) = 0;
-
- virtual int setIcon(int id, MCONTACT hContact, HANDLE icon) = 0;
- virtual int setIconByName(int id, MCONTACT hContact, const char* icon) = 0;
- virtual void storeIcon(MCONTACT hContact, void *icon) {};
-
- virtual const char *getName() const;
- virtual const TCHAR *getDescription() const = 0;
- virtual const char *getDescIcon() const = 0;
- virtual int getType() const = 0;
-
- virtual int getSlot() const;
- virtual void setSlot(int slot);
-
- virtual int getPosition() const;
- virtual void setPosition(int position);
-
- virtual bool isEnabled() const;
-
- virtual int ClistSetExtraIcon(MCONTACT hContact, HANDLE hImage) = 0;
-
- int hLangpack;
-
-protected:
- ptrA szName;
-
- int slot;
- int position;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// BaseExtraIcon - basic class for all 'real' extra icons
-
-class BaseExtraIcon : public ExtraIcon
-{
-public:
- BaseExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param);
- virtual ~BaseExtraIcon();
-
- virtual int getID() const;
- virtual const TCHAR *getDescription() const;
- virtual void setDescription(const TCHAR *desc);
- virtual const char *getDescIcon() const;
- virtual void setDescIcon(const char *icon);
- virtual int getType() const =0;
-
- virtual void onClick(MCONTACT hContact);
- virtual void setOnClick(MIRANDAHOOKPARAM OnClick, LPARAM param);
-
- virtual int ClistSetExtraIcon(MCONTACT hContact, HANDLE hImage);
-
-protected:
- int id;
- ptrT tszDescription;
- ptrA szDescIcon;
- MIRANDAHOOKPARAM OnClick;
- LPARAM onClickParam;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// CallbackExtraIcon - extra icon, implemented using callback functions
-
-class CallbackExtraIcon : public BaseExtraIcon
-{
-public:
- CallbackExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon,
- MIRANDAHOOK RebuildIcons, MIRANDAHOOK ApplyIcon, MIRANDAHOOKPARAM OnClick, LPARAM param);
- virtual ~CallbackExtraIcon();
-
- virtual int getType() const;
-
- virtual void rebuildIcons();
- virtual void applyIcon(MCONTACT hContact);
-
- virtual int setIcon(int id, MCONTACT hContact, HANDLE icon);
- virtual int setIconByName(int id, MCONTACT hContact, const char* icon);
-
-private:
- int(*RebuildIcons)(WPARAM wParam, LPARAM lParam);
- int(*ApplyIcon)(WPARAM wParam, LPARAM lParam);
-
- bool needToRebuild;
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// IcolibExtraIcon - extra icon, implemented using icolib
-
-class IcolibExtraIcon : public BaseExtraIcon
-{
-public:
- IcolibExtraIcon(int id, const char *name, const TCHAR *description, const char *descIcon, MIRANDAHOOKPARAM OnClick, LPARAM param);
- virtual ~IcolibExtraIcon();
-
- virtual int getType() const;
-
- virtual void rebuildIcons();
- virtual void applyIcon(MCONTACT hContact);
-
- virtual int setIcon(int id, MCONTACT hContact, HANDLE icon);
- virtual int setIconByName(int id, MCONTACT hContact, const char* icon);
- virtual void storeIcon(MCONTACT hContact, void *icon);
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// ExtraIconGroup - joins some slots into one
-
-class ExtraIconGroup : public ExtraIcon
-{
- int internalSetIcon(int id, MCONTACT hContact, HANDLE icon, bool bByName);
-public:
- ExtraIconGroup(const char *name);
- virtual ~ExtraIconGroup();
-
- virtual void addExtraIcon(BaseExtraIcon *extra);
-
- virtual void rebuildIcons();
- virtual void applyIcon(MCONTACT hContact);
- virtual void onClick(MCONTACT hContact);
-
- virtual int setIcon(int id, MCONTACT hContact, HANDLE icon);
- virtual int setIconByName(int id, MCONTACT hContact, const char *icon);
-
- virtual const TCHAR* getDescription() const;
- virtual const char* getDescIcon() const;
- virtual int getType() const;
-
- virtual int getPosition() const;
- virtual void setSlot(int slot);
-
- LIST<BaseExtraIcon> items;
-
- virtual int ClistSetExtraIcon(MCONTACT hContact, HANDLE hImage);
-
-protected:
- ptrT tszDescription;
- bool setValidExtraIcon;
- bool insideApply;
-
- virtual ExtraIcon *getCurrentItem(MCONTACT hContact) const;
-};
-
-#endif // __EXTRAICON_H__
diff --git a/src/modules/extraicons/ExtraIconGroup.cpp b/src/modules/extraicons/ExtraIconGroup.cpp
deleted file mode 100644
index 26704a0cfa..0000000000
--- a/src/modules/extraicons/ExtraIconGroup.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-ExtraIconGroup::ExtraIconGroup(const char *_name) :
- ExtraIcon(_name), setValidExtraIcon(false), insideApply(false),
- items(1)
-{
- db_set_resident(MODULE_NAME, _name);
-}
-
-ExtraIconGroup::~ExtraIconGroup()
-{
-}
-
-void ExtraIconGroup::addExtraIcon(BaseExtraIcon *extra)
-{
- items.insert(extra);
-
- CMString description;
- for (int i = 0; i < items.getCount(); i++) {
- if (i > 0)
- description += _T(" / ");
- description += items[i]->getDescription();
- }
-
- tszDescription = mir_tstrdup(description);
-}
-
-void ExtraIconGroup::rebuildIcons()
-{
- for (int i = 0; i < items.getCount(); i++)
- items[i]->rebuildIcons();
-}
-
-void ExtraIconGroup::applyIcon(MCONTACT hContact)
-{
- if (!isEnabled() || hContact == NULL)
- return;
-
- setValidExtraIcon = false;
-
- insideApply = true;
-
- int i;
- for (i = 0; i < items.getCount(); i++) {
- items[i]->applyIcon(hContact);
- if (setValidExtraIcon)
- break;
- }
-
- insideApply = false;
-
- db_set_dw(hContact, MODULE_NAME, szName, setValidExtraIcon ? items[i]->getID() : 0);
-}
-
-int ExtraIconGroup::getPosition() const
-{
- int pos = INT_MAX;
- for (int i = 0; i < items.getCount(); i++)
- pos = MIN(pos, items[i]->getPosition());
- return pos;
-}
-
-void ExtraIconGroup::setSlot(int slot)
-{
- ExtraIcon::setSlot(slot);
-
- for (int i = 0; i < items.getCount(); i++)
- items[i]->setSlot(slot);
-}
-
-ExtraIcon * ExtraIconGroup::getCurrentItem(MCONTACT hContact) const
-{
- int id = (int)db_get_dw(hContact, MODULE_NAME, szName, 0);
- if (id < 1)
- return NULL;
-
- for (int i = 0; i < items.getCount(); i++)
- if (id == items[i]->getID())
- return items[i];
-
- return NULL;
-}
-
-void ExtraIconGroup::onClick(MCONTACT hContact)
-{
- ExtraIcon *extra = getCurrentItem(hContact);
- if (extra != NULL)
- extra->onClick(hContact);
-}
-
-int ExtraIconGroup::setIcon(int id, MCONTACT hContact, HANDLE value)
-{
- return internalSetIcon(id, hContact, (void*)value, false);
-}
-
-int ExtraIconGroup::setIconByName(int id, MCONTACT hContact, const char *value)
-{
- return internalSetIcon(id, hContact, (void*)value, true);
-}
-
-int ExtraIconGroup::internalSetIcon(int id, MCONTACT hContact, void *value, bool bByName)
-{
- if (insideApply) {
- for (int i=0; i < items.getCount(); i++)
- if (items[i]->getID() == id) {
- if (bByName)
- return items[i]->setIconByName(id, hContact, (const char*)value);
- return items[i]->setIcon(id, hContact, (HANDLE)value);
- }
-
- return -1;
- }
-
- ExtraIcon *current = getCurrentItem(hContact);
- int currentPos = items.getCount();
- int storePos = items.getCount();
- for (int i=0; i < items.getCount(); i++) {
- if (items[i]->getID() == id)
- storePos = i;
-
- if (items[i] == current)
- currentPos = i;
- }
-
- if (storePos == items.getCount())
- return -1;
-
- if (storePos > currentPos) {
- items[storePos]->storeIcon(hContact, value);
- return 0;
- }
-
- // Ok, we have to set the icon, but we have to assert it is a valid icon
-
- setValidExtraIcon = false;
-
- int ret;
- if (bByName)
- ret = items[storePos]->setIconByName(id, hContact, (const char*)value);
- else
- ret = items[storePos]->setIcon(id, hContact, (HANDLE)value);
-
- if (storePos < currentPos) {
- if (setValidExtraIcon)
- db_set_dw(hContact, MODULE_NAME, szName, items[storePos]->getID());
- }
- else if (storePos == currentPos) {
- if (!setValidExtraIcon) {
- db_set_dw(hContact, MODULE_NAME, szName, 0);
-
- insideApply = true;
-
- for (++storePos; storePos < items.getCount(); ++storePos) {
- items[storePos]->applyIcon(hContact);
- if (setValidExtraIcon)
- break;
- }
-
- insideApply = false;
-
- if (setValidExtraIcon && storePos < items.getCount())
- db_set_dw(hContact, MODULE_NAME, szName, items[storePos]->getID());
- }
- }
-
- return ret;
-}
-
-const TCHAR *ExtraIconGroup::getDescription() const
-{
- return tszDescription;
-}
-
-const char *ExtraIconGroup::getDescIcon() const
-{
- for (int i = 0; i < items.getCount(); i++)
- if (!IsEmpty(items[i]->getDescIcon()))
- return items[i]->getDescIcon();
-
- return "";
-}
-
-int ExtraIconGroup::getType() const
-{
- return EXTRAICON_TYPE_GROUP;
-}
-
-int ExtraIconGroup::ClistSetExtraIcon(MCONTACT hContact, HANDLE hImage)
-{
- if (hImage != INVALID_HANDLE_VALUE)
- setValidExtraIcon = true;
-
- return Clist_SetExtraIcon(hContact, slot, hImage);
-}
diff --git a/src/modules/extraicons/IcolibExtraIcon.cpp b/src/modules/extraicons/IcolibExtraIcon.cpp
deleted file mode 100644
index 3a9521f4d4..0000000000
--- a/src/modules/extraicons/IcolibExtraIcon.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-#include "usedIcons.h"
-
-#include "..\icolib\IcoLib.h"
-
-IcolibExtraIcon::IcolibExtraIcon(int _id, const char *_name, const TCHAR *_description, const char *_descIcon,
- MIRANDAHOOKPARAM _OnClick, LPARAM _param) :
- BaseExtraIcon(_id, _name, _description, _descIcon, _OnClick, _param)
-{
- db_set_resident(MODULE_NAME, _name);
-}
-
-IcolibExtraIcon::~IcolibExtraIcon()
-{
-}
-
-int IcolibExtraIcon::getType() const
-{
- return EXTRAICON_TYPE_ICOLIB;
-}
-
-void IcolibExtraIcon::rebuildIcons()
-{
-}
-
-void IcolibExtraIcon::applyIcon(MCONTACT hContact)
-{
- if (!isEnabled() || hContact == NULL)
- return;
-
- HANDLE hImage = INVALID_HANDLE_VALUE;
-
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
- if (!IsEmpty(szIconName))
- hImage = GetIcon(szIconName);
-
- ClistSetExtraIcon(hContact, hImage);
-}
-
-int IcolibExtraIcon::setIcon(int id, MCONTACT hContact, HANDLE hIcoLib)
-{
- if (hContact == NULL || id != this->id)
- return -1;
-
- if (hIcoLib == INVALID_HANDLE_VALUE)
- hIcoLib = NULL;
-
- if (isEnabled()) {
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
- if (!IsEmpty(szIconName))
- RemoveIcon(szIconName);
- }
-
- IcolibItem *p = (IcolibItem*)hIcoLib;
- char *szName = (p) ? p->name : NULL;
- storeIcon(hContact, szName);
-
- if (isEnabled())
- return ClistSetExtraIcon(hContact, (hIcoLib == NULL) ? INVALID_HANDLE_VALUE : AddIcon(szName));
-
- return 0;
-}
-
-int IcolibExtraIcon::setIconByName(int id, MCONTACT hContact, const char *icon)
-{
- if (hContact == NULL || id != this->id)
- return -1;
-
- if (icon == INVALID_HANDLE_VALUE)
- icon = NULL;
-
- if (isEnabled()) {
- ptrA szIconName(db_get_sa(hContact, MODULE_NAME, szName));
- if (!IsEmpty(szIconName))
- RemoveIcon(szIconName);
- }
-
- storeIcon(hContact, (char*)icon);
-
- if (isEnabled())
- return ClistSetExtraIcon(hContact, (IsEmpty(icon)) ? INVALID_HANDLE_VALUE : AddIcon(icon));
-
- return 0;
-}
-
-void IcolibExtraIcon::storeIcon(MCONTACT hContact, void *icon)
-{
- if (hContact == NULL)
- return;
-
- const char *icolibName = (const char *)icon;
- if (IsEmpty(icolibName))
- db_unset(hContact, MODULE_NAME, szName);
- else
- db_set_s(hContact, MODULE_NAME, szName, icolibName);
-}
diff --git a/src/modules/extraicons/extraicons.cpp b/src/modules/extraicons/extraicons.cpp
deleted file mode 100644
index be02a26b87..0000000000
--- a/src/modules/extraicons/extraicons.cpp
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "m_cluiframes.h"
-
-#include "extraicons.h"
-#include "usedIcons.h"
-#include "..\clist\clc.h"
-
-// Prototypes ///////////////////////////////////////////////////////////////////////////
-
-int SortFunc(const ExtraIcon *p1, const ExtraIcon *p2)
-{
- int ret = p1->getPosition() - p2->getPosition();
- if (ret != 0)
- return ret;
-
- int id1 = (p1->getType() != EXTRAICON_TYPE_GROUP) ? ((BaseExtraIcon*) p1)->getID() : 0;
- int id2 = (p2->getType() != EXTRAICON_TYPE_GROUP) ? ((BaseExtraIcon*) p2)->getID() : 0;
- return id1 - id2;
-}
-
-LIST<ExtraIcon> extraIconsByHandle(10), extraIconsBySlot(10, SortFunc);
-LIST<BaseExtraIcon> registeredExtraIcons(10);
-
-BOOL clistRebuildAlreadyCalled = FALSE;
-BOOL clistApplyAlreadyCalled = FALSE;
-
-int clistFirstSlot = 0;
-int clistSlotCount = 0;
-
-// Functions ////////////////////////////////////////////////////////////////////////////
-
-int InitOptionsCallback(WPARAM wParam, LPARAM lParam);
-
-// Called when all the modules are loaded
-int ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- // add our modules to the KnownModules list
- CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME, 0);
- CallService("DBEditorpp/RegisterSingleModule", (WPARAM) MODULE_NAME "Groups", 0);
-
- HookEvent(ME_OPT_INITIALISE, InitOptionsCallback);
- return 0;
-}
-
-int GetNumberOfSlots()
-{
- return clistSlotCount;
-}
-
-int ConvertToClistSlot(int slot)
-{
- if (slot < 0)
- return slot;
-
- return clistFirstSlot + slot;
-}
-
-int ExtraImage_ExtraIDToColumnNum(int extra)
-{
- return (extra < 1 || extra > EXTRA_ICON_COUNT) ? -1 : extra-1;
-}
-
-int Clist_SetExtraIcon(MCONTACT hContact, int slot, HANDLE hImage)
-{
- if (cli.hwndContactTree == 0)
- return -1;
-
- int icol = ExtraImage_ExtraIDToColumnNum( ConvertToClistSlot(slot));
- if (icol == -1)
- return -1;
-
- HANDLE hItem = (HANDLE)SendMessage(cli.hwndContactTree, CLM_FINDCONTACT, hContact, 0);
- if (hItem == 0)
- return -1;
-
- SendMessage(cli.hwndContactTree, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(icol,hImage));
- return 0;
-}
-
-ExtraIcon* GetExtraIcon(HANDLE id)
-{
- int i = (int)id;
- if (i < 1 || i > extraIconsByHandle.getCount())
- return NULL;
-
- return extraIconsByHandle[i-1];
-}
-
-ExtraIcon* GetExtraIconBySlot(int slot)
-{
- for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
- if (extra->getSlot() == slot)
- return extra;
- }
- return NULL;
-}
-
-BaseExtraIcon* GetExtraIconByName(const char *name)
-{
- for (int i=0; i < registeredExtraIcons.getCount(); i++) {
- BaseExtraIcon *extra = registeredExtraIcons[i];
- if (mir_strcmp(name, extra->getName()) == 0)
- return extra;
- }
- return NULL;
-}
-
-static void LoadGroups(LIST<ExtraIconGroup> &groups)
-{
- int count = db_get_w(NULL, MODULE_NAME "Groups", "Count", 0);
- for (int i=0; i < count; i++) {
- char setting[512];
- mir_snprintf(setting, "%d_count", i);
- unsigned int items = db_get_w(NULL, MODULE_NAME "Groups", setting, 0);
- if (items < 1)
- continue;
-
- mir_snprintf(setting, "__group_%d", i);
- ExtraIconGroup *group = new ExtraIconGroup(setting);
-
- for (unsigned int j = 0; j < items; j++) {
- mir_snprintf(setting, "%d_%d", i, j);
- ptrA szIconName(db_get_sa(NULL, MODULE_NAME "Groups", setting));
- if (IsEmpty(szIconName))
- continue;
-
- BaseExtraIcon *extra = GetExtraIconByName(szIconName);
- if (extra == NULL)
- continue;
-
- group->items.insert(extra);
- if (extra->getSlot() >= 0)
- group->setSlot(extra->getSlot());
- }
-
- if (group->items.getCount() < 2) {
- delete group;
- continue;
- }
-
- groups.insert(group);
- }
-}
-
-static ExtraIconGroup* IsInGroup(LIST<ExtraIconGroup> &groups, BaseExtraIcon *extra)
-{
- for (int i = 0; i < groups.getCount(); i++) {
- ExtraIconGroup *group = groups[i];
- for (int j = 0; j < group->items.getCount(); j++) {
- if (extra == group->items[j])
- return group;
- }
- }
- return NULL;
-}
-
-void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups)
-{
- extraIconsByHandle.destroy();
-
- for (int i=0; i < registeredExtraIcons.getCount(); i++)
- extraIconsByHandle.insert(registeredExtraIcons[i]);
-
- for (int k=0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
- if (extra->getType() == EXTRAICON_TYPE_GROUP)
- delete extra;
- }
- extraIconsBySlot.destroy();
-
- for (int i=0; i < groups.getCount(); i++) {
- ExtraIconGroup *group = groups[i];
-
- for (int j = 0; j < group->items.getCount(); j++)
- extraIconsByHandle.put(group->items[j]->getID()-1, group);
-
- extraIconsBySlot.insert(group);
- }
-
- for (int k=0; k < extraIconsByHandle.getCount(); k++) {
- ExtraIcon *extra = extraIconsByHandle[k];
- if (extra->getType() != EXTRAICON_TYPE_GROUP)
- extraIconsBySlot.insert(extra);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-void KillModuleExtraIcons(int hLangpack)
-{
- LIST<ExtraIcon> arDeleted(1);
-
- for (int i=registeredExtraIcons.getCount()-1; i >= 0; i--) {
- BaseExtraIcon *p = registeredExtraIcons[i];
- if (p->hLangpack == hLangpack) {
- registeredExtraIcons.remove(i);
- arDeleted.insert(p);
- }
- }
-
- if (arDeleted.getCount() == 0)
- return;
-
- LIST<ExtraIconGroup> groups(1);
- LoadGroups(groups);
- RebuildListsBasedOnGroups(groups);
-
- for (int k=0; k < arDeleted.getCount(); k++)
- delete arDeleted[k];
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-int ClistExtraListRebuild(WPARAM, LPARAM)
-{
- clistRebuildAlreadyCalled = TRUE;
-
- ResetIcons();
-
- for (int i=0; i < extraIconsBySlot.getCount(); i++)
- extraIconsBySlot[i]->rebuildIcons();
-
- return 0;
-}
-
-int ClistExtraImageApply(WPARAM hContact, LPARAM)
-{
- if (hContact == NULL)
- return 0;
-
- clistApplyAlreadyCalled = TRUE;
-
- for (int i=0; i < extraIconsBySlot.getCount(); i++)
- extraIconsBySlot[i]->applyIcon(hContact);
-
- return 0;
-}
-
-int ClistExtraClick(WPARAM hContact, LPARAM lParam)
-{
- if (hContact == NULL)
- return 0;
-
- int clistSlot = (int)lParam;
-
- for (int i=0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *extra = extraIconsBySlot[i];
- if (ConvertToClistSlot(extra->getSlot()) == clistSlot) {
- extra->onClick(hContact);
- break;
- }
- }
-
- return 0;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Extra image list functions
-
-HANDLE hEventExtraImageListRebuilding, hEventExtraImageApplying, hEventExtraClick;
-
-static bool bImageCreated = false;
-static int g_mutex_bSetAllExtraIconsCycle = 0;
-static HIMAGELIST hExtraImageList;
-
-HANDLE ExtraIcon_Add(HICON hIcon)
-{
- if (hExtraImageList == 0 || hIcon == 0)
- return INVALID_HANDLE_VALUE;
-
- int res = ImageList_AddIcon(hExtraImageList, hIcon);
- return (res > 0xFFFE) ? INVALID_HANDLE_VALUE : (HANDLE)res;
-}
-
-void fnReloadExtraIcons()
-{
- SendMessage(cli.hwndContactTree, CLM_SETEXTRASPACE, db_get_b(NULL,"CLUI","ExtraColumnSpace",18), 0);
- SendMessage(cli.hwndContactTree, CLM_SETEXTRAIMAGELIST, 0, 0);
-
- if (hExtraImageList)
- ImageList_Destroy(hExtraImageList);
-
- hExtraImageList = ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),ILC_COLOR32|ILC_MASK,1,256);
-
- SendMessage(cli.hwndContactTree, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hExtraImageList);
- SendMessage(cli.hwndContactTree, CLM_SETEXTRACOLUMNS, EXTRA_ICON_COUNT, 0);
- NotifyEventHooks(hEventExtraImageListRebuilding,0,0);
- bImageCreated = true;
-}
-
-void fnSetAllExtraIcons(MCONTACT hContact)
-{
- if (cli.hwndContactTree == 0)
- return;
-
- g_mutex_bSetAllExtraIconsCycle = 1;
- bool hcontgiven = (hContact != 0);
-
- if (!bImageCreated)
- cli.pfnReloadExtraIcons();
-
- SendMessage(cli.hwndContactTree, CLM_SETEXTRACOLUMNS, EXTRA_ICON_COUNT, 0);
-
- if (hContact == NULL)
- hContact = db_find_first();
-
- for (; hContact; hContact = db_find_next(hContact)) {
- ClcCacheEntry* pdnce = (ClcCacheEntry*)cli.pfnGetCacheEntry(hContact);
- if (pdnce == NULL)
- continue;
-
- NotifyEventHooks(hEventExtraImageApplying, hContact, 0);
- if (hcontgiven) break;
- Sleep(0);
- }
-
- g_mutex_bSetAllExtraIconsCycle = 0;
- cli.pfnInvalidateRect(cli.hwndContactTree, NULL, FALSE);
- Sleep(0);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Services
-
-INT_PTR ExtraIcon_Register(WPARAM wParam, LPARAM lParam)
-{
- 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);
- extra->setPosition(db_get_w(NULL, MODULE_NAME, setting, 1000));
-
- mir_snprintf(setting, "Slot_%s", ei->name);
- int slot = db_get_w(NULL, MODULE_NAME, setting, 1);
- if (slot == (WORD)-1)
- slot = -1;
- extra->setSlot(slot);
-
- extra->hLangpack = (int)lParam;
-
- registeredExtraIcons.insert(extra);
- extraIconsByHandle.insert(extra);
-
- LIST<ExtraIconGroup> groups(1);
- LoadGroups(groups);
-
- ExtraIconGroup *group = IsInGroup(groups, extra);
- if (group != NULL)
- RebuildListsBasedOnGroups(groups);
- else {
- for (int i = 0; i < groups.getCount(); i++)
- delete groups[i];
-
- extraIconsBySlot.insert(extra);
- }
-
- if (slot >= 0 || group != NULL) {
- if (clistRebuildAlreadyCalled)
- extra->rebuildIcons();
-
- slot = 0;
- for (int i = 0; i < extraIconsBySlot.getCount(); i++) {
- ExtraIcon *ex = extraIconsBySlot[i];
- if (ex->getSlot() < 0)
- continue;
-
- int oldSlot = ex->getSlot();
- ex->setSlot(slot++);
-
- if (clistApplyAlreadyCalled && (ex == group || ex == extra || oldSlot != slot))
- extra->applyIcons();
- }
- }
-
- return id;
-}
-
-INT_PTR ExtraIcon_SetIcon(WPARAM wParam, LPARAM)
-{
- if (wParam == 0)
- return -1;
-
- EXTRAICON *ei = (EXTRAICON*)wParam;
- if (ei->cbSize < sizeof(EXTRAICON) || ei->hExtraIcon == NULL || ei->hContact == NULL)
- return -1;
-
- ExtraIcon *extra = GetExtraIcon(ei->hExtraIcon);
- if (extra == NULL)
- return -1;
-
- return extra->setIcon((int)ei->hExtraIcon, ei->hContact, ei->hImage);
-}
-
-INT_PTR ExtraIcon_SetIconByName(WPARAM wParam, LPARAM)
-{
- if (wParam == 0)
- return -1;
-
- EXTRAICON *ei = (EXTRAICON*)wParam;
- if (ei->cbSize < sizeof(EXTRAICON) || ei->hExtraIcon == NULL || ei->hContact == NULL)
- return -1;
-
- ExtraIcon *extra = GetExtraIcon(ei->hExtraIcon);
- if (extra == NULL)
- return -1;
-
- return extra->setIconByName((int)ei->hExtraIcon, ei->hContact, ei->icoName);
-}
-
-static INT_PTR svcExtraIcon_Add(WPARAM wParam, LPARAM)
-{
- return (INT_PTR)ExtraIcon_Add((HICON)wParam);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-
-static IconItem iconList[] =
-{
- { LPGEN("Chat activity"), "ChatActivity", IDI_CHAT },
- { LPGEN("Male"), "gender_male", IDI_MALE },
- { LPGEN("Female"), "gender_female", IDI_FEMALE }
-};
-
-void LoadExtraIconsModule()
-{
- DWORD ret = CallService(MS_CLUI_GETCAPS, CLUICAPS_FLAGS2, 0);
- clistFirstSlot = HIWORD(ret);
- 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);
- hEventExtraImageApplying = CreateHookableEvent(ME_CLIST_EXTRA_IMAGE_APPLY);
- hEventExtraImageListRebuilding = CreateHookableEvent(ME_CLIST_EXTRA_LIST_REBUILD);
-
- // Icons
- Icon_Register(NULL, LPGEN("Contact list"), iconList, SIZEOF(iconList));
-
- // Hooks
- HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
-
- HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, ClistExtraListRebuild);
- HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, ClistExtraImageApply);
- HookEvent(ME_CLIST_EXTRA_CLICK, ClistExtraClick);
-
- DefaultExtraIcons_Load();
-}
-
-void UnloadExtraIconsModule(void)
-{
- for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
- if (extra->getType() == EXTRAICON_TYPE_GROUP)
- delete extra;
- }
-
- for (int i = 0; i < registeredExtraIcons.getCount(); i++)
- delete registeredExtraIcons[i];
-}
diff --git a/src/modules/extraicons/extraicons.h b/src/modules/extraicons/extraicons.h
deleted file mode 100644
index 9214dec2cf..0000000000
--- a/src/modules/extraicons/extraicons.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __COMMONS_H__
-# define __COMMONS_H__
-
-#define MODULE_NAME "ExtraIcons"
-
-// Global Variables
-extern HINSTANCE hInst;
-
-#define FREE(_m_) if (_m_ != NULL) { free(_m_); _m_ = NULL; }
-
-#define ICON_SIZE 16
-
-#include "Extraicon.h"
-
-extern LIST<BaseExtraIcon> registeredExtraIcons;
-extern LIST<ExtraIcon> extraIconsByHandle, extraIconsBySlot;
-void RebuildListsBasedOnGroups(LIST<ExtraIconGroup> &groups);
-ExtraIcon * GetExtraIconBySlot(int slot);
-
-int GetNumberOfSlots();
-int ConvertToClistSlot(int slot);
-
-int Clist_SetExtraIcon(MCONTACT hContact, int slot, HANDLE hImage);
-
-void DefaultExtraIcons_Load();
-
-HANDLE ExtraIcon_Add(HICON hIcon);
-
-void fnReloadExtraIcons();
-void fnSetAllExtraIcons(MCONTACT hContact);
-
-static inline BOOL IsEmpty(const char *str)
-{
- return str == NULL || str[0] == 0;
-}
-
-static inline int MIN(int a, int b)
-{
- if (a <= b)
- return a;
- return b;
-}
-
-static inline int MAX(int a, int b)
-{
- if (a >= b)
- return a;
- return b;
-}
-
-#endif // __COMMONS_H__
diff --git a/src/modules/extraicons/options_ei.cpp b/src/modules/extraicons/options_ei.cpp
deleted file mode 100644
index 28d0bf553d..0000000000
--- a/src/modules/extraicons/options_ei.cpp
+++ /dev/null
@@ -1,472 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-#define ICON_SIZE 16
-
-int SortFunc(const ExtraIcon *p1, const ExtraIcon *p2);
-
-struct intlist
-{
- intlist() : count(0), data(0) {}
- ~intlist() { mir_free(data); }
-
- void add(int val)
- {
- data = (int*)mir_realloc(data, sizeof(int)*(count + 1));
- data[count++] = val;
- }
-
- int count;
- int *data;
-};
-
-static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
-{
- intlist *a = (intlist*)lParam1;
- intlist *b = (intlist*)lParam2;
- return SortFunc(registeredExtraIcons[a->data[0] - 1], registeredExtraIcons[b->data[0] - 1]);
-}
-
-// Functions //////////////////////////////////////////////////////////////////////////////////////
-
-BOOL ScreenToClient(HWND hWnd, LPRECT lpRect)
-{
- POINT pt;
- pt.x = lpRect->left;
- pt.y = lpRect->top;
-
- BOOL ret = ScreenToClient(hWnd, &pt);
- if (!ret)
- return ret;
-
- lpRect->left = pt.x;
- lpRect->top = pt.y;
-
- pt.x = lpRect->right;
- pt.y = lpRect->bottom;
-
- ret = ScreenToClient(hWnd, &pt);
-
- lpRect->right = pt.x;
- lpRect->bottom = pt.y;
-
- return ret;
-}
-
-static void RemoveExtraIcons(int slot)
-{
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- Clist_SetExtraIcon(hContact, slot, INVALID_HANDLE_VALUE);
-}
-
-class CExtraIconOptsDlg : public CDlgBase
-{
- intlist* Tree_GetIDs(HTREEITEM hItem)
- {
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM;
- tvi.hItem = hItem;
- m_tree.GetItem(&tvi);
- return (intlist*)tvi.lParam;
- }
-
- HTREEITEM Tree_AddExtraIcon(BaseExtraIcon *extra, bool selected, HTREEITEM hAfter = TVI_LAST)
- {
- intlist *ids = new intlist();
- ids->add(extra->getID());
-
- TVINSERTSTRUCT tvis = { 0 };
- tvis.hInsertAfter = hAfter;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.iSelectedImage = tvis.item.iImage = extra->getID();
- tvis.item.lParam = (LPARAM)ids;
- tvis.item.pszText = (LPTSTR)extra->getDescription();
- tvis.item.state = INDEXTOSTATEIMAGEMASK(selected ? 2 : 1);
- return m_tree.InsertItem(&tvis);
- }
-
- HTREEITEM Tree_AddExtraIconGroup(intlist &group, bool selected, HTREEITEM hAfter = TVI_LAST)
- {
- intlist *ids = new intlist();
- CMString desc;
- int img = 0;
- for (int i = 0; i < group.count; i++) {
- BaseExtraIcon *extra = registeredExtraIcons[group.data[i] - 1];
- ids->add(extra->getID());
-
- if (img == 0 && !IsEmpty(extra->getDescIcon()))
- img = extra->getID();
-
- if (i > 0)
- desc += _T(" / ");
- desc += extra->getDescription();
- }
-
- TVINSERTSTRUCT tvis = { 0 };
- tvis.hInsertAfter = hAfter;
- tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_STATE;
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.iSelectedImage = tvis.item.iImage = img;
- tvis.item.lParam = (LPARAM)ids;
- tvis.item.pszText = (TCHAR*)desc.c_str();
- tvis.item.state = INDEXTOSTATEIMAGEMASK(selected ? 2 : 1);
- return m_tree.InsertItem(&tvis);
- }
-
- void GroupSelectedItems()
- {
- LIST<_TREEITEM> toRemove(1);
- intlist ids;
- bool selected = false;
- HTREEITEM hPlace = NULL;
-
- // Find items
- HTREEITEM hItem = m_tree.GetRoot();
- TVITEMEX tvi = { 0 };
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
- while (hItem) {
- if (m_tree.IsSelected(hItem)) {
- if (hPlace == NULL)
- hPlace = hItem;
-
- tvi.hItem = hItem;
- m_tree.GetItem(&tvi);
-
- intlist *iids = (intlist*)tvi.lParam;
- for (int i = 0; i < iids->count; i++)
- ids.add(iids->data[i]);
-
- if ((tvi.state & INDEXTOSTATEIMAGEMASK(3)) == INDEXTOSTATEIMAGEMASK(2))
- selected = true;
-
- toRemove.insert(hItem);
- }
-
- hItem = m_tree.GetNextSibling(hItem);
- }
-
- if (hPlace != NULL) {
- // Add new
- HTREEITEM hNew = Tree_AddExtraIconGroup(ids, selected, hPlace);
-
- // Remove old
- for (int i = 0; i < toRemove.getCount(); i++) {
- delete Tree_GetIDs(toRemove[i]);
- m_tree.DeleteItem(toRemove[i]);
- }
-
- // Select
- m_tree.UnselectAll();
- m_tree.SelectItem(hNew);
- }
- }
-
- void UngroupSelectedItems()
- {
- HTREEITEM hItem = m_tree.GetSelection();
- if (hItem == NULL)
- return;
-
- intlist *ids = Tree_GetIDs(hItem);
- if (ids->count < 2)
- return;
-
- bool selected = m_tree.IsSelected(hItem);
-
- for (int i = ids->count - 1; i >= 0; i--) {
- BaseExtraIcon *extra = registeredExtraIcons[ids->data[i] - 1];
- Tree_AddExtraIcon(extra, selected, hItem);
- }
-
- delete ids;
- m_tree.DeleteItem(hItem);
-
- m_tree.UnselectAll();
- }
-
- int ShowPopup(int popup)
- {
- // Fix selection
- HTREEITEM hSelected = m_tree.GetDropHilight();
- HTREEITEM hItem = m_tree.GetRoot();
- while (hItem) {
- if (hItem != hSelected && m_tree.IsSelected(hItem))
- m_tree.DropHilite(hItem);
-
- hItem = m_tree.GetNextSibling(hItem);
- }
-
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_OPT_POPUP));
- HMENU submenu = GetSubMenu(menu, popup);
- TranslateMenu(submenu);
-
- DWORD pos = GetMessagePos();
- int ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD | TPM_LEFTALIGN, LOWORD(pos), HIWORD(pos), 0, m_hwnd, NULL);
-
- DestroyMenu(menu);
-
- // Revert selection
- hItem = m_tree.GetRoot();
- while (hItem) {
- if (hItem != hSelected && m_tree.IsSelected(hItem))
- m_tree.DropUnhilite(hItem);
- hItem = m_tree.GetNextSibling(hItem);
- }
-
- return ret;
- }
-
- CCtrlTreeView m_tree;
-
-public:
- CExtraIconOptsDlg() :
- CDlgBase(hInst, IDD_EI_OPTIONS),
- m_tree(this, IDC_EXTRAORDER)
- {
- m_tree.SetFlags(MTREE_DND | MTREE_MULTISELECT);
- }
-
- virtual void OnInitDialog()
- {
- int numSlots = GetNumberOfSlots();
- if (numSlots < (int)registeredExtraIcons.getCount()) {
- HWND label = GetDlgItem(m_hwnd, IDC_MAX_ICONS_L);
- SetWindowText(label, CMString(FORMAT, TranslateT("*only the first %d icons will be shown"), numSlots));
- ShowWindow(label, SW_SHOW);
- }
-
- int cx = GetSystemMetrics(SM_CXSMICON);
- HIMAGELIST hImageList = ImageList_Create(cx, cx, ILC_COLOR32 | ILC_MASK, 2, 2);
-
- HICON hBlankIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, cx, cx, 0);
- ImageList_AddIcon(hImageList, hBlankIcon);
-
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- ExtraIcon *extra = registeredExtraIcons[i];
-
- HICON hIcon = Skin_GetIcon(extra->getDescIcon());
- if (hIcon == NULL)
- ImageList_AddIcon(hImageList, hBlankIcon);
- else {
- ImageList_AddIcon(hImageList, hIcon);
- Skin_ReleaseIcon(hIcon);
- }
- }
- m_tree.SetImageList(hImageList, TVSIL_NORMAL);
- DestroyIcon(hBlankIcon);
-
- for (int k = 0; k < extraIconsBySlot.getCount(); k++) {
- ExtraIcon *extra = extraIconsBySlot[k];
-
- if (extra->getType() == EXTRAICON_TYPE_GROUP) {
- ExtraIconGroup *group = (ExtraIconGroup *)extra;
- intlist ids;
- for (int j = 0; j < group->items.getCount(); j++)
- ids.add(group->items[j]->getID());
- Tree_AddExtraIconGroup(ids, extra->isEnabled());
- }
- else Tree_AddExtraIcon((BaseExtraIcon *)extra, extra->isEnabled());
- }
-
- TVSORTCB sort = { 0 };
- sort.hParent = NULL;
- sort.lParam = 0;
- sort.lpfnCompare = CompareFunc;
- m_tree.SortChildrenCB(&sort, 0);
- }
-
- virtual void OnApply()
- {
- // Store old slots
- int *oldSlots = new int[registeredExtraIcons.getCount()];
- int lastUsedSlot = -1;
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- if (extraIconsByHandle[i] == registeredExtraIcons[i])
- oldSlots[i] = registeredExtraIcons[i]->getSlot();
- else
- // Remove old slot for groups to re-set images
- oldSlots[i] = -1;
- lastUsedSlot = MAX(lastUsedSlot, registeredExtraIcons[i]->getSlot());
- }
- lastUsedSlot = MIN(lastUsedSlot, GetNumberOfSlots());
-
- // Get user data and create new groups
- LIST<ExtraIconGroup> groups(1);
-
- BYTE pos = 0;
- int firstEmptySlot = 0;
- HTREEITEM ht = m_tree.GetRoot();
- TVITEMEX tvi;
- tvi.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
- tvi.stateMask = TVIS_STATEIMAGEMASK;
- while (ht) {
- tvi.hItem = ht;
- m_tree.GetItem(&tvi);
-
- intlist*ids = (intlist*)tvi.lParam;
- if (ids == NULL || ids->count < 1)
- continue; // ???
-
- bool enabled = ((tvi.state & INDEXTOSTATEIMAGEMASK(3)) == INDEXTOSTATEIMAGEMASK(2));
- int slot = (enabled ? firstEmptySlot++ : -1);
- if (slot >= GetNumberOfSlots())
- slot = -1;
-
- if (ids->count == 1) {
- BaseExtraIcon *extra = registeredExtraIcons[ids->data[0] - 1];
- extra->setPosition(pos++);
- extra->setSlot(slot);
- }
- else {
- char name[128];
- mir_snprintf(name, "__group_%d", groups.getCount());
-
- ExtraIconGroup *group = new ExtraIconGroup(name);
-
- for (int i = 0; i < ids->count; i++) {
- BaseExtraIcon *extra = registeredExtraIcons[ids->data[i] - 1];
- extra->setPosition(pos++);
-
- group->addExtraIcon(extra);
- }
-
- group->setSlot(slot);
- groups.insert(group);
- }
-
- ht = m_tree.GetNextSibling(ht);
- }
-
- // Store data
- for (int i = 0; i < registeredExtraIcons.getCount(); i++) {
- BaseExtraIcon *extra = registeredExtraIcons[i];
-
- char setting[512];
- mir_snprintf(setting, "Position_%s", extra->getName());
- db_set_w(NULL, MODULE_NAME, setting, extra->getPosition());
-
- mir_snprintf(setting, "Slot_%s", extra->getName());
- db_set_w(NULL, MODULE_NAME, setting, extra->getSlot());
- }
-
- CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)MODULE_NAME "Groups");
- db_set_w(NULL, MODULE_NAME "Groups", "Count", groups.getCount());
- for (int k = 0; k < groups.getCount(); k++) {
- ExtraIconGroup *group = groups[k];
-
- char setting[512];
- mir_snprintf(setting, "%d_count", k);
- db_set_w(NULL, MODULE_NAME "Groups", setting, (WORD)group->items.getCount());
-
- for (int j = 0; j < group->items.getCount(); j++) {
- BaseExtraIcon *extra = group->items[j];
-
- mir_snprintf(setting, "%d_%d", k, j);
- db_set_s(NULL, MODULE_NAME "Groups", setting, extra->getName());
- }
- }
-
- // Clean removed slots
- for (int j = firstEmptySlot; j <= lastUsedSlot; j++)
- RemoveExtraIcons(j);
-
- // Apply icons to new slots
- RebuildListsBasedOnGroups(groups);
- for (int n = 0; n < extraIconsBySlot.getCount(); n++) {
- ExtraIcon *extra = extraIconsBySlot[n];
- if (extra->getType() != EXTRAICON_TYPE_GROUP)
- if (oldSlots[((BaseExtraIcon *)extra)->getID() - 1] == extra->getSlot())
- continue;
-
- if (extra->isEnabled())
- extra->applyIcons();
- }
-
- delete[] oldSlots;
- }
-
- virtual void OnDestroy()
- {
- HTREEITEM hItem = m_tree.GetRoot();
- while (hItem) {
- delete Tree_GetIDs(hItem);
- hItem = m_tree.GetNextSibling(hItem);
- }
-
- ImageList_Destroy(m_tree.GetImageList(TVSIL_NORMAL));
- }
-
- virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
- {
- if (msg == WM_NOTIFY) {
- LPNMHDR lpnmhdr = (LPNMHDR)lParam;
- if (lpnmhdr->idFrom == IDC_EXTRAORDER && lpnmhdr->code == NM_RCLICK) {
- HTREEITEM hSelected = m_tree.GetDropHilight();
- if (hSelected != NULL && !m_tree.IsSelected(hSelected)) {
- m_tree.UnselectAll();
- m_tree.SelectItem(hSelected);
- }
-
- int sels = m_tree.GetNumSelected();
- if (sels > 1) {
- if (ShowPopup(0) == ID_GROUP) {
- GroupSelectedItems();
- NotifyChange();
- }
- }
- else if (sels == 1) {
- HTREEITEM hItem = m_tree.GetSelection();
- intlist *ids = Tree_GetIDs(hItem);
- if (ids->count > 1) {
- if (ShowPopup(1) == ID_UNGROUP) {
- UngroupSelectedItems();
- NotifyChange();
- }
- }
- }
- }
- }
-
- return CDlgBase::DlgProc(msg, wParam, lParam);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-int InitOptionsCallback(WPARAM wParam, LPARAM lParam)
-{
- if (GetNumberOfSlots() < 1)
- return 0;
-
- OPTIONSDIALOGPAGE odp = { 0 };
- odp.pszGroup = LPGEN("Contact list");
- odp.pszTitle = LPGEN("Extra icons");
- odp.pszTab = LPGEN("General");
- odp.flags = ODPF_BOLDGROUPS;
- odp.pDialog = new CExtraIconOptsDlg();
- Options_AddPage(wParam, &odp);
- return 0;
-}
diff --git a/src/modules/extraicons/usedIcons.cpp b/src/modules/extraicons/usedIcons.cpp
deleted file mode 100644
index db967687dd..0000000000
--- a/src/modules/extraicons/usedIcons.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
-#include "extraicons.h"
-
-struct Icon
-{
- char *name;
- int refCount;
- HANDLE hImage;
-
- Icon(const char *icolibName) :
- name( mir_strdup(icolibName)), refCount(0), hImage(INVALID_HANDLE_VALUE)
- {
- }
-
- ~Icon()
- { mir_free(name);
- }
-};
-
-static int SortFunc(const Icon *p1, const Icon *p2)
-{
- return mir_strcmp(p1->name, p2->name);
-}
-
-static OBJLIST<Icon> usedIcons(50, SortFunc);
-
-static Icon* FindIcon(const char *icolibName)
-{
- Icon *icon = usedIcons.find((Icon*)&icolibName);
- if (icon == NULL)
- usedIcons.insert(icon = new Icon(icolibName));
-
- if (icon->hImage == INVALID_HANDLE_VALUE) {
- HICON hIcon = Skin_GetIcon(icon->name);
- if (hIcon != NULL) {
- icon->hImage = ExtraIcon_Add(hIcon);
- Skin_ReleaseIcon(hIcon);
- }
- }
-
- return icon;
-}
-
-HANDLE GetIcon(const char *icolibName)
-{
- return FindIcon(icolibName)->hImage;
-}
-
-HANDLE AddIcon(const char *icolibName)
-{
- Icon *icon = FindIcon(icolibName);
- icon->refCount++;
- return icon->hImage;
-}
-
-void RemoveIcon(const char *icolibName)
-{
- Icon *icon = usedIcons.find((Icon*)&icolibName);
- if (icon != NULL)
- icon->refCount--;
-}
-
-void ResetIcons()
-{
- for (int i = usedIcons.getCount()-1; i >= 0; i--) {
- Icon &p = usedIcons[i];
- if (p.refCount <= 0)
- usedIcons.remove(i);
- else
- p.hImage = INVALID_HANDLE_VALUE;
- }
-}
diff --git a/src/modules/extraicons/usedIcons.h b/src/modules/extraicons/usedIcons.h
deleted file mode 100644
index b15da88108..0000000000
--- a/src/modules/extraicons/usedIcons.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-
-Copyright (C) 2009 Ricardo Pescuma Domenecci
-Copyright (C) 2012-15 Miranda NG project
-
-This is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-This 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
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with this file; see the file license.txt. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#ifndef __USEDICONS_H__
-#define __USEDICONS_H__
-
-HANDLE GetIcon(LPCSTR icolibName);
-
-HANDLE AddIcon(LPCSTR icolibName);
-HANDLE AddIcon(HANDLE hIcolib);
-
-void RemoveIcon(LPCSTR icolibName);
-void ResetIcons();
-
-
-#endif // __USEDICONS_H__