Example #1
0
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);
}
Example #2
0
BOOL InternalListHandler(HXML node, LPCTSTR jid, LPCTSTR mailboxUrl)
{
	ULONGLONG maxTid = 0;
	LPCTSTR sMaxTid = NULL;
	int unreadCount = 0;
	for (int i = 0; i < xi.getChildCount(node); i++) {
		LPCTSTR sTid = xi.getAttrValue(xi.getChild(node, i), ATTRNAME_TID);
		ULONGLONG tid = _tcstoui64(sTid, NULL, 10);
		if (tid > maxTid) {
			maxTid = tid;
			sMaxTid = sTid;
		}

		HXML senders = xi.getChildByPath(xi.getChild(node, i), NODENAME_SENDERS, FALSE);
		for (int j = 0; j < xi.getChildCount(senders); j++)
			if (xi.getAttrValue(xi.getChild(senders, j), ATTRNAME_UNREAD)) {
				unreadCount++;
				break;
			}
	}

	LPCSTR acc = GetJidAcc(jid);
	if (!acc)
		return FALSE;

	if (!unreadCount) {
		SetupPseudocontact(jid, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), acc);
		return TRUE;
	}

	DWORD settings = ReadNotificationSettings(acc);

	if (unreadCount > 5) {
		CloseNotifications(acc, mailboxUrl, jid, FALSE);
		UnreadMailNotification(acc, jid, mailboxUrl, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED));
	}
	else
		for (int i = 0; i < xi.getChildCount(node); i++) {
			MAIL_THREAD_NOTIFICATION mtn = { 0 };
			HXML thread = xi.getChild(node, i);

			mtn.subj = xi.getText(xi.getChildByPath(thread, NODENAME_SUBJECT, FALSE));
			mtn.snip = xi.getText(xi.getChildByPath(thread, NODENAME_SNIPPET, FALSE));

			int threadUnreadCount = 0;
			HXML senders = xi.getChildByPath(thread, NODENAME_SENDERS, FALSE);
			for (int j = 0; threadUnreadCount < SENDER_COUNT && j < xi.getChildCount(senders); j++) {
				HXML sender = xi.getChild(senders, j);
				if (xi.getAttrValue(sender, ATTRNAME_UNREAD)) {
					mtn.senders[threadUnreadCount].name = xi.getAttrValue(sender, ATTRNAME_NAME);
					mtn.senders[threadUnreadCount].addr = xi.getAttrValue(sender, ATTRNAME_ADDRESS);
					threadUnreadCount++;
				}
			}

			LPCTSTR url = xi.getAttrValue(thread, ATTRNAME_URL);
			LPCTSTR tid = xi.getAttrValue(thread, ATTRNAME_TID);

			if (ReadCheckbox(0, IDC_STANDARDVIEW, settings))
				FormatMessageUrl(MESSAGE_URL_FORMAT_STANDARD, (LPTSTR)url, mailboxUrl, tid);
			else if (ReadCheckbox(0, IDC_HTMLVIEW, settings))
				FormatMessageUrl(MESSAGE_URL_FORMAT_HTML, (LPTSTR)url, mailboxUrl, tid);
			else
				MakeUrlHex((LPTSTR)url, tid);

			CloseNotifications(acc, url, jid, i);
			UnreadThreadNotification(acc, jid, url, xi.getAttrValue(node, ATTRNAME_TOTAL_MATCHED), &mtn);
		}

	LPCTSTR time = xi.getAttrValue(node, ATTRNAME_RESULT_TIME);
	WriteJidSetting(LAST_MAIL_TIME_FROM_JID, jid, time);
	WriteJidSetting(LAST_THREAD_ID_FROM_JID, jid, sMaxTid);
	return TRUE;
}