HANDLE HookProtoEvent(const char *szModule, const char *szEvent, MIRANDAHOOKPARAM hookProc) { char szProtoEvent[MAXMODULELABELLENGTH]; mir_snprintf(szProtoEvent, sizeof(szProtoEvent), "%s%s", szModule, szEvent); HANDLE res = HookEventParam(szProtoEvent, hookProc, (LPARAM)szModule); arProtoHooks.insert(res); return res; }
LRESULT CALLBACK PopupProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam) { POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)PUGetPluginData(wnd); LPCSTR acc; if (EVENT_DELETED_MSG == msg) { if ((MEVENT)lParam == ppdh->hDbEvent) ppdh->hDbEvent = NULL; return 0; } if (MESSAGE_CLOSEPOPUP == msg) { ppdh->MarkRead = TRUE; PUDeletePopup(wnd); } switch (msg) { case UM_INITPOPUP: SetProp(wnd, PLUGIN_DATA_PROP_NAME, (HANDLE)ppdh); SetProp(wnd, EVT_DELETED_HOOK_PROP_NAME, HookEventParam(ME_DB_EVENT_DELETED, OnEventDeleted, (LPARAM)wnd)); return 0; case UM_FREEPLUGINDATA: { HANDLE hHook = GetProp(wnd, EVT_DELETED_HOOK_PROP_NAME); RemoveProp(wnd, EVT_DELETED_HOOK_PROP_NAME); UnhookEvent(hHook); } if (ppdh->MarkRead && ppdh->hDbEvent && (acc = GetJidAcc(ppdh->jid))) { ReadNotificationSettings(acc); MarkEventRead(ppdh->hContact, ppdh->hDbEvent); CallService(MS_CLIST_REMOVEEVENT, (WPARAM)ppdh->hContact, (LPARAM)ppdh->hDbEvent); } RemoveProp(wnd, PLUGIN_DATA_PROP_NAME); free(ppdh); return 0; case WM_LBUTTONUP: acc = NULL; __try { if (!(acc = GetJidAcc(ppdh->jid))) return 0; ReadNotificationSettings(acc); OpenUrl(acc, ppdh->jid, ppdh->url); } __finally { CloseNotifications(acc, ppdh->url, ppdh->jid, TRUE); } return 0; case WM_RBUTTONUP: SendMessage(wnd, MESSAGE_CLOSEPOPUP, 0, 0); return 0; } return DefWindowProc(wnd, msg, wParam, lParam); }
void QueryAwayMessage(HWND hWnd, PLUGINDATA *pdp) { MCONTACT hContact = PUGetContact(hWnd); char *szProto = GetContactProto(hContact); if (szProto) { if ((CallProtoService(szProto, PS_GETCAPS,PFLAGNUM_1, 0) & PF1_MODEMSGRECV) && (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_3, 0) & Proto_Status2Flag(pdp->newStatus))) { pdp->hWnd = hWnd; //The following HookEventMessage will hook the ME_PROTO_ACK event and send a WM_AWAYMSG to hWnd when the hooks get notified. pdp->hAwayMsgHook = HookEventParam(ME_PROTO_ACK, AwayMsgHook, (LPARAM)pdp); //The following instruction asks Miranda to retrieve the away message and associates a hProcess (handle) to this request. This handle will appear in the ME_PROTO_ACK event. pdp->hAwayMsgProcess = (HANDLE)CallContactService(hContact, PSS_GETAWAYMSG, 0, 0); } } }