diff options
-rw-r--r-- | metacontacts/meta_menu.c | 11 | ||||
-rw-r--r-- | metacontacts/meta_services.c | 73 | ||||
-rw-r--r-- | metacontacts/version.h | 4 |
3 files changed, 84 insertions, 4 deletions
diff --git a/metacontacts/meta_menu.c b/metacontacts/meta_menu.c index 790df9f..7e21456 100644 --- a/metacontacts/meta_menu.c +++ b/metacontacts/meta_menu.c @@ -488,6 +488,17 @@ int Meta_ModifyMenu(WPARAM wParam, LPARAM lParam) CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact[i], (LPARAM)&mi);
}
}
+
+ // show hide nudge menu item
+#define MS_NUDGE_SHOWMENU "NudgeShowMenu"
+// wParam = char *szProto
+// lParam = BOOL show
+ {
+ char serviceFunc[256];
+ char *proto;
+ mir_snprintf(serviceFunc, 256, "%s/SendNudge", proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0));
+ CallService(MS_NUDGE_SHOWMENU, (WPARAM)proto, (LPARAM)ServiceExists(serviceFunc));
+ }
}
else
{// This is a simple contact
diff --git a/metacontacts/meta_services.c b/metacontacts/meta_services.c index 2d4b1f7..229d3db 100644 --- a/metacontacts/meta_services.c +++ b/metacontacts/meta_services.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "metacontacts.h"
-#define NB_SERVICES 61 //!< Number of services registered in Miranda (see Meta_CloseHandles()).
+#define NB_SERVICES 62 //!< Number of services registered in Miranda (see Meta_CloseHandles()).
#define NB_HOOKS 17 //!< Number of hooks set up (see Meta_CloseHandles()).
#define PREF_METANODB 0x2000 //!< Flag to indicate message should not be added to db by filter when sending
@@ -40,6 +40,9 @@ int previousMode, //!< Previous status of the MetaContacts Protocol HANDLE hServices[NB_SERVICES] = {0}, //!< list of all the services registered (see Meta_CloseHandles()).
hHooks[NB_HOOKS] = {0}; //!< list of all hooks set up (see Meta_CloseHandles()).
+HANDLE *hNudgeEvents = 0;
+int iNudgeProtos = 0;
+
HANDLE hMenuConvert, //!< \c HANDLE to the convert menu item.
hMenuAdd, //!< \c HANDLE to the add to menu item.
hMenuEdit, //!< \c HANDLE to the edit menu item.
@@ -52,7 +55,8 @@ HANDLE hMenuOnOff; //!< \c HANDLE to the enable/disable menu item. HANDLE hEventDefaultChanged, //!< \c HANDLE to the 'default changed' event
hEventForceSend, //!< \c HANDLE to the 'force send' event
hEventUnforceSend, //!< \c HANDLE to the 'unforce send' event
- hSubcontactsChanged; //!< \c HANDLE to the 'contacts changed' event
+ hSubcontactsChanged, //!< \c HANDLE to the 'contacts changed' event
+ hEventNudge;
struct MM_INTERFACE mmi; //!< Reference to the structure allowing memory management with Miranda.
@@ -294,6 +298,20 @@ int MetaFilter_SendMessage(WPARAM wParam,LPARAM lParam) return CallService(MS_PROTO_CHAINSEND, wParam, lParam);
}
+int Meta_SendNudge(WPARAM wParam,LPARAM lParam)
+{
+ HANDLE hMeta = (HANDLE)wParam,
+ hSubContact = Meta_GetMostOnline(hMeta);
+
+ char servicefunction[ 100 ];
+ char *protoName = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hSubContact, 0);
+ sprintf(servicefunction, "%s/SendNudge", protoName);
+
+ return CallService(servicefunction, (WPARAM)hSubContact, lParam);
+
+ //return CallService("NUDGE/Send", (WPARAM)hSubContact, lParam);
+}
+
/////////////////////////////////////////////////////////////////
/** Send a message to the protocol specific network.
@@ -1204,6 +1222,17 @@ int Meta_ClistMessageEventClicked(WPARAM wParam, LPARAM lParam) { return Meta_ClistDoubleClicked((WPARAM)hContact, (LPARAM)((CLISTEVENT *)lParam)->hDbEvent);
}
+
+int NudgeRecieved(WPARAM wParam, LPARAM lParam) {
+ /*
+ // already being forwarded by someone
+ HANDLE hMeta = (HANDLE)DBGetContactSettingDword((HANDLE)wParam,META_PROTO, "Handle", (DWORD)0);
+ if(hMeta)
+ NotifyEventHooks(hEventNudge, (WPARAM)hMeta, 0);
+ */
+ return 0;
+}
+
/** Called when all the plugin are loaded into Miranda.
*
* Initializes the 4 menus present in the context-menu
@@ -1357,6 +1386,33 @@ int Meta_ModulesLoaded(WPARAM wParam, LPARAM lParam) if(hHooks[16]) // message api available
message_window_api_enabled = TRUE;
+ // hook protocol nudge events to forward to subcontacts
+ {
+ int i, numberOfProtocols,ret;
+ char str[MAXMODULELABELLENGTH + 10];
+ HANDLE hNudgeEvent = NULL;
+ PROTOCOLDESCRIPTOR ** ppProtocolDescriptors;
+ ret = CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM) &numberOfProtocols,(LPARAM)&ppProtocolDescriptors);
+ if(ret == 0)
+ {
+ for(i = 0; i < numberOfProtocols ; i++)
+ {
+ if(ppProtocolDescriptors[i]->type == PROTOTYPE_PROTOCOL)
+ {
+ if(strcmp(ppProtocolDescriptors[i]->szName, META_PROTO)) {
+ sprintf(str,"%s/Nudge",ppProtocolDescriptors[i]->szName);
+ hNudgeEvent = HookEvent(str, NudgeRecieved);
+ if(hNudgeEvent != NULL) {
+ ++iNudgeProtos;
+ hNudgeEvents = realloc(hNudgeEvents, sizeof(HANDLE) * iNudgeProtos);
+ hNudgeEvents[iNudgeProtos - 1] = hNudgeEvent;
+ }
+ }
+ }
+ }
+
+ }
+ }
return 0;
}
@@ -1969,6 +2025,8 @@ void Meta_InitServices() hServices[59] = CreateServiceFunction("MetaContacts/OnOff", Meta_OnOff);
hServices[60] = CreateServiceFunction("MetaContacts/CListMessageEvent", Meta_ClistMessageEventClicked);
+ hServices[61] = CreateProtoServiceFunction(META_PROTO, "/SendNudge", Meta_SendNudge);
+
// create our hookable events
hEventDefaultChanged = CreateHookableEvent(ME_MC_DEFAULTTCHANGED);
hEventForceSend = CreateHookableEvent(ME_MC_FORCESEND);
@@ -1994,6 +2052,9 @@ void Meta_InitServices() /// more hooks in modules loaded event handler - for services that are not created
//hHooks[] = (HANDLE)HookEvent(ME_IDLE_CHANGED, Meta_OnIdleChanged); // what can we do with idle?
+
+ // redirect nudge events
+ hEventNudge = CreateHookableEvent(META_PROTO "/Nudge");
}
//! Unregister all hooks and services from Miranda
@@ -2001,6 +2062,13 @@ void Meta_CloseHandles() {
int i;
+ for(i=0;i<iNudgeProtos;i++) // Idem for the hooks.
+ {
+ UnhookEvent(hNudgeEvents[i]);
+ }
+ free(hNudgeEvents);
+ iNudgeProtos = 0;
+
for(i=0;i<NB_HOOKS;i++) // Idem for the hooks.
if(hHooks[i]) UnhookEvent(hHooks[i]);
@@ -2013,6 +2081,7 @@ void Meta_CloseHandles() DestroyHookableEvent(hEventForceSend);
DestroyHookableEvent(hEventUnforceSend);
DestroyHookableEvent(hSubcontactsChanged);
+ DestroyHookableEvent(hEventNudge);
// lets leave them, hey? (why?)
for(i=0;i<NB_SERVICES;i++) // Scan each 'HANDLE' and Destroy the service attached to it.
diff --git a/metacontacts/version.h b/metacontacts/version.h index 3c6473e..fa90186 100644 --- a/metacontacts/version.h +++ b/metacontacts/version.h @@ -4,8 +4,8 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 12
-#define __RELEASE_NUM 2
-#define __BUILD_NUM 8
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 0
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
|