diff options
author | pescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7> | 2009-04-09 01:41:51 +0000 |
---|---|---|
committer | pescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7> | 2009-04-09 01:41:51 +0000 |
commit | a72ac14dbb1b8d53328621e5f5362ef61bcb27e6 (patch) | |
tree | dabb199c325983afc66fba0a9faaef9532915379 | |
parent | 510d19974eab3364252df3ad1fa6965afe1c74f7 (diff) |
extraicons: changed to use callback prototypes with same signature as miranda hooks
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@157 c086bb3d-8645-0410-b8da-73a8550f86e7
-rw-r--r-- | Plugins/extraicons/.cproject | 9 | ||||
-rw-r--r-- | Plugins/extraicons/CallbackExtraIcon.cpp | 12 | ||||
-rw-r--r-- | Plugins/extraicons/CallbackExtraIcon.h | 9 | ||||
-rw-r--r-- | Plugins/extraicons/DefaultExtraIcons.cpp | 14 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.cpp | 5 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.h | 6 | ||||
-rw-r--r-- | Plugins/extraicons/IcolibExtraIcon.cpp | 5 | ||||
-rw-r--r-- | Plugins/extraicons/IcolibExtraIcon.h | 3 | ||||
-rw-r--r-- | Plugins/extraicons/extraicons.cpp | 7 | ||||
-rw-r--r-- | Plugins/extraicons/m_extraicons.h | 29 |
10 files changed, 65 insertions, 34 deletions
diff --git a/Plugins/extraicons/.cproject b/Plugins/extraicons/.cproject index d51e189..334b143 100644 --- a/Plugins/extraicons/.cproject +++ b/Plugins/extraicons/.cproject @@ -47,14 +47,13 @@ <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug.650923336" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.so.debug">
<option defaultValue="true" id="gnu.c.link.mingw.so.debug.option.shared.1575843488" name="Shared (-shared)" superClass="gnu.c.link.mingw.so.debug.option.shared" valueType="boolean"/>
</tool>
-<tool commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}"C:\Desenvolvimento\Miranda\bin\Debug Unicode\Plugins\${OUTPUT_PREFIX}${OUTPUT}" ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.836489507" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
-<option id="gnu.cpp.link.option.paths.1417684678" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
-<listOptionValue builtIn="false" value=""C:\Program Files\Microsoft SDK\Lib""/>
-</option>
+<tool commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG}"${OUTPUT_PREFIX}${OUTPUT}" ${INPUTS}" id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug.836489507" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.so.debug">
+<option id="gnu.cpp.link.option.paths.1417684678" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths"/>
<option defaultValue="true" id="gnu.cpp.link.mingw.so.debug.option.shared.1239249880" name="Shared (-shared)" superClass="gnu.cpp.link.mingw.so.debug.option.shared" valueType="boolean"/>
<option id="gnu.cpp.link.option.libs.1498281393" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" valueType="libs">
-<listOptionValue builtIn="false" value="Gdi32.Lib"/>
+<listOptionValue builtIn="false" value="gdi32"/>
</option>
+<option id="gnu.cpp.link.option.flags.714506212" name="Linker flags" superClass="gnu.cpp.link.option.flags" value="" valueType="string"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.417851543" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
diff --git a/Plugins/extraicons/CallbackExtraIcon.cpp b/Plugins/extraicons/CallbackExtraIcon.cpp index 6674c78..81153d6 100644 --- a/Plugins/extraicons/CallbackExtraIcon.cpp +++ b/Plugins/extraicons/CallbackExtraIcon.cpp @@ -19,9 +19,11 @@ #include "commons.h"
-CallbackExtraIcon::CallbackExtraIcon(const char *name, void(*RebuildIcons)(), void(*ApplyIcon)(HANDLE hContact,
- int slot), const char *description, const char *descIcon) :
- ExtraIcon(name, description, descIcon), RebuildIcons(RebuildIcons), ApplyIcon(ApplyIcon), needToRebuild(true)
+CallbackExtraIcon::CallbackExtraIcon(const char *name, const char *description, const char *descIcon,
+ int(*RebuildIcons)(WPARAM wParam, LPARAM lParam), int(*ApplyIcon)(WPARAM wParam, LPARAM lParam), int(*OnClick)(
+ WPARAM wParam, LPARAM lParam)) :
+ ExtraIcon(name, description, descIcon, OnClick), RebuildIcons(RebuildIcons), ApplyIcon(ApplyIcon), needToRebuild(
+ true)
{
}
@@ -48,7 +50,7 @@ void CallbackExtraIcon::rebuildIcons() }
needToRebuild = false;
- RebuildIcons();
+ RebuildIcons(0, 0);
}
void CallbackExtraIcon::applyIcon(HANDLE hContact)
@@ -56,7 +58,7 @@ void CallbackExtraIcon::applyIcon(HANDLE hContact) if (!isEnabled() || hContact == NULL)
return;
- ApplyIcon(hContact, ConvertToClistSlot(slot));
+ ApplyIcon((WPARAM) hContact, (LPARAM) ConvertToClistSlot(slot));
}
int CallbackExtraIcon::setIcon(HANDLE hContact, void *icon)
diff --git a/Plugins/extraicons/CallbackExtraIcon.h b/Plugins/extraicons/CallbackExtraIcon.h index 9d5a31c..3db9e15 100644 --- a/Plugins/extraicons/CallbackExtraIcon.h +++ b/Plugins/extraicons/CallbackExtraIcon.h @@ -25,8 +25,9 @@ class CallbackExtraIcon : public ExtraIcon
{
public:
- CallbackExtraIcon(const char *name, void(*RebuildIcons)(), void(*ApplyIcon)(HANDLE hContact, int slot),
- const char *description, const char *descIcon);
+ CallbackExtraIcon(const char *name, const char *description, const char *descIcon, int(*RebuildIcons)(
+ WPARAM wParam, LPARAM lParam), int(*ApplyIcon)(WPARAM wParam, LPARAM lParam), int(*OnClick)(WPARAM wParam,
+ LPARAM lParam));
virtual ~CallbackExtraIcon();
virtual int getType() const;
@@ -38,8 +39,8 @@ public: virtual int setIcon(HANDLE hContact, void *icon);
private:
- void(*RebuildIcons)();
- void(*ApplyIcon)(HANDLE hContact, int slot);
+ int(*RebuildIcons)(WPARAM wParam, LPARAM lParam);
+ int(*ApplyIcon)(WPARAM wParam, LPARAM lParam);
bool needToRebuild;
};
diff --git a/Plugins/extraicons/DefaultExtraIcons.cpp b/Plugins/extraicons/DefaultExtraIcons.cpp index e267d72..b9d23ae 100644 --- a/Plugins/extraicons/DefaultExtraIcons.cpp +++ b/Plugins/extraicons/DefaultExtraIcons.cpp @@ -227,9 +227,10 @@ vector<ProtoInfo> protos; HANDLE hExtraProto = NULL;
-static void ProtocolRebuildIcons()
+static int ProtocolRebuildIcons(WPARAM wParam, LPARAM lParam)
{
protos.clear();
+ return 0;
}
static ProtoInfo *FindProto(const char * proto)
@@ -257,11 +258,14 @@ static ProtoInfo *FindProto(const char * proto) return &protos[protos.size() - 1];
}
-static void ProtocolApplyIcon(HANDLE hContact, int slot)
+static int ProtocolApplyIcon(WPARAM wParam, LPARAM lParam)
{
+ HANDLE hContact = (HANDLE) wParam;
+ int slot = (int) lParam;
+
char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
if (IsEmpty(proto))
- return;
+ return 0;
HANDLE hImage = NULL;
@@ -274,9 +278,11 @@ static void ProtocolApplyIcon(HANDLE hContact, int slot) iec.ColumnType = slot;
iec.hImage = (hImage == NULL ? (HANDLE) -1 : hImage);
CallService(MS_CLIST_EXTRA_SET_ICON, (WPARAM) hContact, (LPARAM) &iec);
+
+ return 0;
}
static void ProtocolInit()
{
- hExtraProto = ExtraIcon_Register("protocol", ProtocolRebuildIcons, ProtocolApplyIcon, "Account", "core_main_34");
+ hExtraProto = ExtraIcon_Register("protocol", "Account", "core_main_34", ProtocolRebuildIcons, ProtocolApplyIcon);
}
diff --git a/Plugins/extraicons/ExtraIcon.cpp b/Plugins/extraicons/ExtraIcon.cpp index 95c0265..d54e1c4 100644 --- a/Plugins/extraicons/ExtraIcon.cpp +++ b/Plugins/extraicons/ExtraIcon.cpp @@ -19,8 +19,9 @@ #include "commons.h"
-ExtraIcon::ExtraIcon(const char *name, const char *description, const char *descIcon) :
- name(name), description(Translate(description)), descIcon(descIcon), slot(-1)
+ExtraIcon::ExtraIcon(const char *name, const char *description, const char *descIcon, int(*OnClick)(WPARAM wParam,
+ LPARAM lParam)) :
+ name(name), description(Translate(description)), descIcon(descIcon), OnClick(OnClick), slot(-1)
{
}
diff --git a/Plugins/extraicons/ExtraIcon.h b/Plugins/extraicons/ExtraIcon.h index 49d157e..86fe1c1 100644 --- a/Plugins/extraicons/ExtraIcon.h +++ b/Plugins/extraicons/ExtraIcon.h @@ -25,7 +25,8 @@ class ExtraIcon
{
public:
- ExtraIcon(const char *name, const char *description, const char *descIcon);
+ ExtraIcon(const char *name, const char *description, const char *descIcon, int(*OnClick)(WPARAM wParam,
+ LPARAM lParam));
virtual ~ExtraIcon();
virtual bool needToRebuildIcons() =0;
@@ -49,8 +50,9 @@ protected: std::string name;
std::string description;
std::string descIcon;
- int slot;
+ int(*OnClick)(WPARAM wParam, LPARAM lParam);
+ int slot;
};
#endif // __EXTRAICON_H__
diff --git a/Plugins/extraicons/IcolibExtraIcon.cpp b/Plugins/extraicons/IcolibExtraIcon.cpp index 406b43b..7f9cae9 100644 --- a/Plugins/extraicons/IcolibExtraIcon.cpp +++ b/Plugins/extraicons/IcolibExtraIcon.cpp @@ -19,8 +19,9 @@ #include "commons.h"
-IcolibExtraIcon::IcolibExtraIcon(const char *name, const char *description, const char *descIcon) :
- ExtraIcon(name, description, descIcon)
+IcolibExtraIcon::IcolibExtraIcon(const char *name, const char *description, const char *descIcon, int(*OnClick)(
+ WPARAM wParam, LPARAM lParam)) :
+ ExtraIcon(name, description, descIcon, OnClick)
{
char setting[512];
mir_snprintf(setting, MAX_REGS(setting), "%s/%s", MODULE_NAME, name);
diff --git a/Plugins/extraicons/IcolibExtraIcon.h b/Plugins/extraicons/IcolibExtraIcon.h index cc25a37..e813b48 100644 --- a/Plugins/extraicons/IcolibExtraIcon.h +++ b/Plugins/extraicons/IcolibExtraIcon.h @@ -25,7 +25,8 @@ class IcolibExtraIcon : public ExtraIcon
{
public:
- IcolibExtraIcon(const char *name, const char *description, const char *descIcon);
+ IcolibExtraIcon(const char *name, const char *description, const char *descIcon, int(*OnClick)(WPARAM wParam,
+ LPARAM lParam));
virtual ~IcolibExtraIcon();
virtual int getType() const;
diff --git a/Plugins/extraicons/extraicons.cpp b/Plugins/extraicons/extraicons.cpp index e945e0d..8d43f0d 100644 --- a/Plugins/extraicons/extraicons.cpp +++ b/Plugins/extraicons/extraicons.cpp @@ -267,11 +267,12 @@ int ExtraIcon_Register(WPARAM wParam, LPARAM lParam) switch (ei->type)
{
case EXTRAICON_TYPE_CALLBACK:
- extra = new CallbackExtraIcon(ei->name, ei->RebuildIcons, ei->ApplyIcon, ei->description, ei->descIcon
- == NULL ? "" : ei->descIcon);
+ extra = new CallbackExtraIcon(ei->name, ei->description, ei->descIcon == NULL ? "" : ei->descIcon,
+ ei->RebuildIcons, ei->ApplyIcon, ei->OnClick);
break;
case EXTRAICON_TYPE_ICOLIB:
- extra = new IcolibExtraIcon(ei->name, ei->description, ei->descIcon == NULL ? "" : ei->descIcon);
+ extra = new IcolibExtraIcon(ei->name, ei->description, ei->descIcon == NULL ? "" : ei->descIcon,
+ ei->OnClick);
break;
default:
return 0;
diff --git a/Plugins/extraicons/m_extraicons.h b/Plugins/extraicons/m_extraicons.h index f446dcc..c6964b9 100644 --- a/Plugins/extraicons/m_extraicons.h +++ b/Plugins/extraicons/m_extraicons.h @@ -35,12 +35,26 @@ typedef struct { // if both have the same type. In this case, both will be handled as one.
// This is usefull for ex for extra status, where icq and jabber can share the same slot.
// If the types are different the second one will be denied.
- const char *description; // Description to be used in GUI. Will be translated.
- const char *descIcon; // (Optional) Name of an icon registered with icolib to be used in GUI.
+ const char *description; // [Translated by plugin] Description to be used in GUI
+ const char *descIcon; // [Optional] Name of an icon registered with icolib to be used in GUI.
// If type == EXTRAICON_TYPE_CALLBACK this two must be set
- void (*RebuildIcons)(); // Callback to add icons to clist, calling MS_CLIST_EXTRA_ADD_ICON
- void (*ApplyIcon)(HANDLE hContact, int slot); // Callback to set the icon to clist, calling MS_CLIST_EXTRA_SET_ICON or MS_EXTRAICON_SET_ICON
+
+ // Callback to add icons to clist, calling MS_CLIST_EXTRA_ADD_ICON
+ // wParam=lParam=0
+ int (*RebuildIcons)(WPARAM wParam, LPARAM lParam);
+
+ // Callback to set the icon to clist, calling MS_CLIST_EXTRA_SET_ICON or MS_EXTRAICON_SET_ICON
+ // wParam = HANDLE hContact
+ // lParam = int slot
+ int (*ApplyIcon)(WPARAM wParam, LPARAM lParam);
+
+ // Other optional callbacks
+
+ // [Optional] Callback called when extra icon was clicked
+ // wParam = HANDLE hContact
+ // lParam = 0
+ int (*OnClick)(WPARAM wParam, LPARAM lParam);
} EXTRAICON_INFO;
@@ -72,8 +86,10 @@ typedef struct { #ifndef _NO_WRAPPERS
#ifdef __cplusplus
-static HANDLE ExtraIcon_Register(const char *name, void (*RebuildIcons)(), void (*ApplyIcon)(HANDLE hContact, int slot),
- const char *description, const char *descIcon = NULL)
+static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon,
+ int (*RebuildIcons)(WPARAM wParam, LPARAM lParam),
+ int (*ApplyIcon)(WPARAM wParam, LPARAM lParam),
+ int (*OnClick)(WPARAM wParam, LPARAM lParam) = NULL)
{
EXTRAICON_INFO ei = {0};
ei.cbSize = sizeof(ei);
@@ -83,6 +99,7 @@ static HANDLE ExtraIcon_Register(const char *name, void (*RebuildIcons)(), void ei.descIcon = descIcon;
ei.RebuildIcons = RebuildIcons;
ei.ApplyIcon = ApplyIcon;
+ ei.OnClick = OnClick;
return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0);
}
|