void MarkEventRead(MCONTACT hCnt, MEVENT hEvt) { DWORD settings = (DWORD)TlsGetValue(itlsSettings); if (ReadCheckbox(0, IDC_POPUPSENABLED, settings) && ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, settings) && ReadCheckbox(0, IDC_MARKEVENTREAD, settings) && db_event_markRead(hCnt, hEvt) != -1) CallService(MS_CLIST_REMOVEEVENT, hCnt, hEvt); }
void CloseNotifications(LPCSTR acc, LPCTSTR url, LPCTSTR jid, BOOL PopupsOnly) { DWORD settings = (DWORD)TlsGetValue(itlsSettings); if (acc && !PopupsOnly && ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, settings) && ReadCheckbox(0, IDC_CLEARPSEUDOCONTACTLOG, settings)) ClearNotificationContactHistory(acc); POPUP_IDENT_STRINGS pis = { url, jid }; EnumWindows(ClosePopupFunc, (LPARAM)&pis); }
static bool DoAddPopup(POPUPDATAT *data) { if (ReadCheckbox(0, IDC_POPUPSINFULLSCREEN, (DWORD)TlsGetValue(itlsSettings)) && IsFullScreen()) { HWND handle = CreateWindowEx(WS_EX_TOOLWINDOW, TEMP_WINDOW_CLASS_NAME, NULL, WS_OVERLAPPED | WS_VISIBLE, -100, -100, 10, 10, 0, 0, 0, 0); if (handle) { ShowWindow(handle, SW_MINIMIZE); ShowWindow(handle, SW_RESTORE); } DestroyWindow(handle); } return PUAddPopupT(data) == 0; }
void ShowNotification(LPCSTR acc, POPUPDATAT *data, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount) { MCONTACT hCnt = SetupPseudocontact(jid, unreadCount, acc, &data->lptzContactName[0]); MEVENT hEvt = ReadCheckbox(0, IDC_PSEUDOCONTACTENABLED, (DWORD)TlsGetValue(itlsSettings)) ? AddCListNotification(hCnt, acc, data, url) : NULL; if (!UsePopups()) return; extern HICON g_hPopupIcon; data->lchIcon = g_hPopupIcon; data->iSeconds = (int)db_get_dw(0, SHORT_PLUGIN_NAME, TIMEOUT_SETTING, 0); data->colorBack = (COLORREF)db_get_dw(0, SHORT_PLUGIN_NAME, BACK_COLOR_SETTING, 0); data->colorText = (COLORREF)db_get_dw(0, SHORT_PLUGIN_NAME, TEXT_COLOR_SETTING, 0); if (data->colorBack == data->colorText) { data->colorBack = 0; data->colorText = 0; } data->PluginWindowProc = PopupProc; size_t lurl = (mir_tstrlen(url) + 1) * sizeof(TCHAR); size_t ljid = (mir_tstrlen(jid) + 1) * sizeof(TCHAR); POPUP_DATA_HEADER *ppdh = (POPUP_DATA_HEADER*)malloc(sizeof(POPUP_DATA_HEADER) + lurl + ljid); ppdh->MarkRead = FALSE; ppdh->hContact = hCnt; ppdh->hDbEvent = hEvt; ppdh->jid = (LPTSTR)((PBYTE)ppdh + sizeof(*ppdh)); memcpy(ppdh->jid, jid, ljid); ppdh->url = (LPTSTR)((PBYTE)ppdh->jid + ljid); memcpy(ppdh->url, url, lurl); data->PluginData = ppdh; if (!DoAddPopup(data)) free(data->PluginData); }
void UnreadThreadNotification(LPCSTR acc, LPCTSTR jid, LPCTSTR url, LPCTSTR unreadCount, const MAIL_THREAD_NOTIFICATION *mtn) { POPUPDATAT data = { 0 }; FormatPseudocontactDisplayName(&data.lptzContactName[0], jid, unreadCount); CMString tszSenders; for (int i = 0; i < SENDER_COUNT; i++) { const SENDER &p = mtn->senders[i]; if (p.addr == NULL) break; if (p.name) tszSenders.AppendFormat(_T(" %s <%s>\n"), p.name, p.addr); else tszSenders.AppendFormat(_T(" %s\n"), p.addr); } if (ReadCheckbox(0, IDC_ADDSNIP, (DWORD)TlsGetValue(itlsSettings))) mir_sntprintf(data.lptzText, TranslateTS(FULL_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str(), mtn->snip); else mir_sntprintf(data.lptzText, TranslateTS(SHORT_NOTIFICATION_FORMAT), mtn->subj, tszSenders.c_str()); ShowNotification(acc, &data, jid, url, unreadCount); }
void OpenUrl(LPCSTR acc, LPCTSTR mailbox, LPCTSTR url) { extern DWORD itlsSettings; if (!ReadCheckbox(0, IDC_AUTHONMAILBOX, (UINT_PTR)TlsGetValue(itlsSettings)) || !OpenUrlWithAuth(acc, mailbox, url)) Utils_OpenUrlT(url); }
BOOL UsePopups() { return ServiceExists(MS_POPUP_QUERY) && CallService(MS_POPUP_QUERY, PUQS_GETSTATUS, 0) && ReadCheckbox(0, IDC_POPUPSENABLED, (DWORD)TlsGetValue(itlsSettings)); }
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; }