diff options
author | pescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7> | 2009-04-10 01:33:53 +0000 |
---|---|---|
committer | pescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7> | 2009-04-10 01:33:53 +0000 |
commit | fc113593e97d2a048560dad022b6c3f31ecac4fa (patch) | |
tree | a9af7bc122c88b2bb37dcb48ea2c4330c216374a | |
parent | a72ac14dbb1b8d53328621e5f5362ef61bcb27e6 (diff) |
extraicons: added click handling
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@158 c086bb3d-8645-0410-b8da-73a8550f86e7
-rw-r--r-- | Plugins/extraicons/DefaultExtraIcons.cpp | 95 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.cpp | 9 | ||||
-rw-r--r-- | Plugins/extraicons/ExtraIcon.h | 1 | ||||
-rw-r--r-- | Plugins/extraicons/commons.h | 1 | ||||
-rw-r--r-- | Plugins/extraicons/extraicons.cpp | 22 | ||||
-rw-r--r-- | Plugins/extraicons/m_extraicons.h | 6 | ||||
-rw-r--r-- | Plugins/extraicons/sdk/m_cluiframes.h | 20 |
7 files changed, 140 insertions, 14 deletions
diff --git a/Plugins/extraicons/DefaultExtraIcons.cpp b/Plugins/extraicons/DefaultExtraIcons.cpp index b9d23ae..e8aa647 100644 --- a/Plugins/extraicons/DefaultExtraIcons.cpp +++ b/Plugins/extraicons/DefaultExtraIcons.cpp @@ -100,21 +100,25 @@ static void VisibilityInit() }
}
+static int EmailOnClick(WPARAM wParam, LPARAM lParam);
+static int HomepageOnClick(WPARAM wParam, LPARAM lParam);
+
struct Info
{
const char *name;
const char *desc;
const char *icon;
const char *db[4];
+ int (*OnClick)(WPARAM wParam, LPARAM lParam);
HANDLE hExtraIcon;
} infos[] = {
-{ "email", "E-mail", "core_main_14", { NULL, "e-mail", "UserInfo", "Mye-mail0" }, NULL },
+{ "email", "E-mail", "core_main_14", { NULL, "e-mail", "UserInfo", "Mye-mail0" }, &EmailOnClick, NULL },
-{ "sms", "Phone/SMS", "core_main_17", { NULL, "Cellular", "UserInfo", "MyPhone0" }, NULL },
+{ "sms", "Phone/SMS", "core_main_17", { NULL, "Cellular", "UserInfo", "MyPhone0" }, NULL, NULL },
-{ "homepage", "Homepage", "core_main_2", { NULL, "Homepage", "UserInfo", "Homepage" }, NULL },
+{ "homepage", "Homepage", "core_main_2", { NULL, "Homepage", "UserInfo", "Homepage" }, &HomepageOnClick, NULL },
};
@@ -196,12 +200,82 @@ static int SettingChanged(WPARAM wParam, LPARAM lParam) return 0;
}
+static int EmailOnClick(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE) wParam;
+ if (hContact == NULL)
+ return 0;
+
+ char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if (IsEmpty(proto))
+ return 0;
+
+ Info &info = infos[0];
+
+ bool found = false;
+ for (unsigned int j = 0; !found && j < MAX_REGS(info.db); j += 2)
+ {
+ if (info.db[j + 1] == NULL)
+ break;
+
+ DBVARIANT dbv = { 0 };
+ if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv))
+ {
+ if (!IsEmpty(dbv.ptszVal))
+ {
+ char cmd[1024];
+ mir_snprintf(cmd, MAX_REGS(cmd), "mailto:%s", dbv.ptszVal);
+ ShellExecute(NULL, "open", cmd, NULL, NULL, SW_SHOW);
+ found = true;
+ }
+
+ DBFreeVariant(&dbv);
+ }
+ }
+
+ return 0;
+}
+
+static int HomepageOnClick(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE) wParam;
+ if (hContact == NULL)
+ return 0;
+
+ char *proto = (char*) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if (IsEmpty(proto))
+ return 0;
+
+ Info &info = infos[2];
+
+ bool found = false;
+ for (unsigned int j = 0; !found && j < MAX_REGS(info.db); j += 2)
+ {
+ if (info.db[j + 1] == NULL)
+ break;
+
+ DBVARIANT dbv = { 0 };
+ if (!DBGetContactSettingString(hContact, info.db[j] == NULL ? proto : info.db[j], info.db[j+1], &dbv))
+ {
+ if (!IsEmpty(dbv.ptszVal))
+ {
+ ShellExecute(NULL, "open", dbv.ptszVal, NULL, NULL, SW_SHOW);
+ found = true;
+ }
+
+ DBFreeVariant(&dbv);
+ }
+ }
+
+ return 0;
+}
+
static void DBExtraIconsInit()
{
for (unsigned int i = 0; i < MAX_REGS(infos); ++i)
{
Info &info = infos[i];
- info.hExtraIcon = ExtraIcon_Register(info.name, info.desc, info.icon);
+ info.hExtraIcon = ExtraIcon_Register(info.name, info.desc, info.icon, info.OnClick);
}
HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
@@ -282,7 +356,18 @@ static int ProtocolApplyIcon(WPARAM wParam, LPARAM lParam) return 0;
}
+static int ProtocolOnClick(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE) wParam;
+ if (hContact == NULL)
+ return 0;
+
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM) hContact, 0);
+ return 0;
+}
+
static void ProtocolInit()
{
- hExtraProto = ExtraIcon_Register("protocol", "Account", "core_main_34", ProtocolRebuildIcons, ProtocolApplyIcon);
+ hExtraProto = ExtraIcon_Register("protocol", "Account", "core_main_34", &ProtocolRebuildIcons, &ProtocolApplyIcon,
+ &ProtocolOnClick);
}
diff --git a/Plugins/extraicons/ExtraIcon.cpp b/Plugins/extraicons/ExtraIcon.cpp index d54e1c4..6dd63b8 100644 --- a/Plugins/extraicons/ExtraIcon.cpp +++ b/Plugins/extraicons/ExtraIcon.cpp @@ -75,3 +75,12 @@ void ExtraIcon::applyIcons() hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
}
}
+
+void ExtraIcon::onClick(HANDLE hContact)
+{
+ if (OnClick == NULL)
+ return;
+
+ OnClick((WPARAM) hContact, (LPARAM) ConvertToClistSlot(slot));
+}
+
diff --git a/Plugins/extraicons/ExtraIcon.h b/Plugins/extraicons/ExtraIcon.h index 86fe1c1..19db99a 100644 --- a/Plugins/extraicons/ExtraIcon.h +++ b/Plugins/extraicons/ExtraIcon.h @@ -33,6 +33,7 @@ public: virtual void rebuildIcons() =0;
virtual void applyIcons();
virtual void applyIcon(HANDLE hContact) =0;
+ virtual void onClick(HANDLE hContact);
virtual int setIcon(HANDLE hContact, void *icon) =0;
diff --git a/Plugins/extraicons/commons.h b/Plugins/extraicons/commons.h index 734fa0f..4320025 100644 --- a/Plugins/extraicons/commons.h +++ b/Plugins/extraicons/commons.h @@ -54,6 +54,7 @@ using namespace std; #include <m_metacontacts.h>
#include <m_icolib.h>
#include <m_skin.h>
+#include <m_userinfo.h>
#include "resource.h"
#include "m_extraicons.h"
diff --git a/Plugins/extraicons/extraicons.cpp b/Plugins/extraicons/extraicons.cpp index 8d43f0d..2e3a636 100644 --- a/Plugins/extraicons/extraicons.cpp +++ b/Plugins/extraicons/extraicons.cpp @@ -52,6 +52,7 @@ int PreShutdown(WPARAM wParam, LPARAM lParam); int IconsChanged(WPARAM wParam, LPARAM lParam);
int ClistExtraListRebuild(WPARAM wParam, LPARAM lParam);
int ClistExtraImageApply(WPARAM wParam, LPARAM lParam);
+int ClistExtraClick(WPARAM wParam, LPARAM lParam);
int ExtraIcon_Register(WPARAM wParam, LPARAM lParam);
int ExtraIcon_SetIcon(WPARAM wParam, LPARAM lParam);
@@ -95,6 +96,7 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) hHooks.push_back(HookEvent(ME_SYSTEM_PRESHUTDOWN, &PreShutdown));
hHooks.push_back(HookEvent(ME_CLIST_EXTRA_LIST_REBUILD, &ClistExtraListRebuild));
hHooks.push_back(HookEvent(ME_CLIST_EXTRA_IMAGE_APPLY, &ClistExtraImageApply));
+ hHooks.push_back(HookEvent(ME_CLIST_EXTRA_CLICK, &ClistExtraClick));
// Services
@@ -352,3 +354,23 @@ int ClistExtraImageApply(WPARAM wParam, LPARAM lParam) return 0;
}
+
+int ClistExtraClick(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE) wParam;
+ if (hContact == NULL)
+ return 0;
+
+ int extra = (int) lParam;
+
+ for (unsigned int i = 0; i < extraIcons.size(); ++i)
+ {
+ if (ConvertToClistSlot(extraIcons[i]->getSlot()) == extra)
+ {
+ extraIcons[i]->onClick(hContact);
+ break;
+ }
+ }
+
+ return 0;
+}
diff --git a/Plugins/extraicons/m_extraicons.h b/Plugins/extraicons/m_extraicons.h index c6964b9..01e793c 100644 --- a/Plugins/extraicons/m_extraicons.h +++ b/Plugins/extraicons/m_extraicons.h @@ -53,7 +53,7 @@ typedef struct { // [Optional] Callback called when extra icon was clicked
// wParam = HANDLE hContact
- // lParam = 0
+ // lParam = int slot
int (*OnClick)(WPARAM wParam, LPARAM lParam);
} EXTRAICON_INFO;
@@ -104,7 +104,8 @@ static HANDLE ExtraIcon_Register(const char *name, const char *description, cons return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0);
}
-static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon = NULL)
+static HANDLE ExtraIcon_Register(const char *name, const char *description, const char *descIcon = NULL,
+ int (*OnClick)(WPARAM wParam, LPARAM lParam) = NULL)
{
EXTRAICON_INFO ei = {0};
ei.cbSize = sizeof(ei);
@@ -112,6 +113,7 @@ static HANDLE ExtraIcon_Register(const char *name, const char *description, cons ei.name = name;
ei.description = description;
ei.descIcon = descIcon;
+ ei.OnClick = OnClick;
return (HANDLE) CallService(MS_EXTRAICON_REGISTER, (WPARAM) &ei, 0);
}
diff --git a/Plugins/extraicons/sdk/m_cluiframes.h b/Plugins/extraicons/sdk/m_cluiframes.h index 07aacab..73ca5e9 100644 --- a/Plugins/extraicons/sdk/m_cluiframes.h +++ b/Plugins/extraicons/sdk/m_cluiframes.h @@ -63,16 +63,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //
// [statusicon] ContactName [WEB][ADV1][ADV2][SMS][EMAIL][PROTO][CLIENT]
//
+#define EXTRA_ICON_RES0 0 // only used by nicer
#define EXTRA_ICON_EMAIL 1
-#define EXTRA_ICON_PROTO 2
+#define EXTRA_ICON_WEB 2
#define EXTRA_ICON_SMS 3
#define EXTRA_ICON_ADV1 4
#define EXTRA_ICON_ADV2 5
-#define EXTRA_ICON_WEB 6
-#define EXTRA_ICON_CLIENT 7
-#define EXTRA_ICON_VISMODE 8
-#define EXTRA_ICON_ADV3 9
-#define EXTRA_ICON_ADV4 10
+#define EXTRA_ICON_ADV3 6
+#define EXTRA_ICON_CLIENT 7
+#define EXTRA_ICON_ADV4 8
+#define EXTRA_ICON_RES1 9 // only used by nicer
+#define EXTRA_ICON_PROTO 9 // used by mwclist and modern
+#define EXTRA_ICON_RES2 10 // only used by nicer
+#define EXTRA_ICON_VISMODE 10 // only used by modern
#define EXTRA_ICON_COUNT 10
@@ -104,6 +107,9 @@ typedef struct //called with wparam=hContact
#define ME_CLIST_EXTRA_IMAGE_APPLY "CListFrames/OnExtraImageApply"
+//called with wparam=hContact lparam=extra
+#define ME_CLIST_EXTRA_CLICK "CListFrames/OnExtraClick"
+
//End of extra images header. TODO move it to separate m_extraimages.h file
//Cause it has not any relationship to cluiframes engine
@@ -114,7 +120,7 @@ typedef struct // NOTE: Clui frames engine is in to be reconsructed..
-// Constants used bellow
+// Constants used below
typedef struct tagCLISTFrame {
DWORD cbSize;
HWND hWnd ;
|