static int MessageEventAdded(WPARAM wParam, LPARAM lParam) { CLISTEVENT cle; DBEVENTINFO dbei; char *contactName; char toolTip[256]; HWND hwnd; ZeroMemory(&dbei, sizeof(dbei)); dbei.cbSize = sizeof(dbei); dbei.cbBlob = 0; CallService(MS_DB_EVENT_GET, lParam, (LPARAM) & dbei); hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam); if (hwnd) { SendMessage(hwnd, HM_DBEVENTADDED, wParam, lParam); } if (dbei.flags & DBEF_SENT || dbei.eventType != EVENTTYPE_MESSAGE) return 0; if (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ)) return 0; CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1); /* does a window for the contact exist? */ if (hwnd) { return 0; } /* new message */ SkinPlaySound("AlertMsg"); if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP)) { char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) wParam, 0); if (szProto && (g_dat->openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) { struct NewMessageWindowLParam newData = { 0 }; newData.hContact = (HANDLE) wParam; if (g_dat->hParent == NULL || !(g_dat->flags & SMF_USETABS)) { g_dat->hParent = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM) & newData); } newData.flags = NMWLP_INCOMING; CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), g_dat->hParent, DlgProcMessage, (LPARAM) & newData); return 0; } } ZeroMemory(&cle, sizeof(cle)); cle.cbSize = sizeof(cle); cle.hContact = (HANDLE) wParam; cle.hDbEvent = (HANDLE) lParam; cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; contactName = (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0); mir_snprintf(toolTip, sizeof(toolTip), Translate("Message from %s"), contactName); cle.pszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle); return 0; }
static void RestoreUnreadMessageAlerts(void) { CLISTEVENT cle = { 0 }; DBEVENTINFO dbei = { 0 }; char toolTip[256]; int windowAlreadyExists; HANDLE hDbEvent, hContact; int autoPopup = 0; dbei.cbSize = sizeof(dbei); cle.cbSize = sizeof(cle); cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact) { hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRSTUNREAD, (WPARAM) hContact, 0); while (hDbEvent) { dbei.cbBlob = 0; CallService(MS_DB_EVENT_GET, (WPARAM) hDbEvent, (LPARAM) & dbei); if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && dbei.eventType == EVENTTYPE_MESSAGE) { windowAlreadyExists = WindowList_Find(g_dat->hMessageWindowList, hContact) != NULL; if (windowAlreadyExists) continue; if (DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP)) { char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0); if (szProto && (g_dat->openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) { autoPopup = 1; } } if (autoPopup && !windowAlreadyExists) { HWND hwndParent; struct NewMessageWindowLParam newData = { 0 }; newData.hContact = hContact; newData.flags = NMWLP_INCOMING; hwndParent = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM) & newData); CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hwndParent, DlgProcMessage, (LPARAM) & newData); // CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM) & newData); } else { cle.hContact = hContact; cle.hDbEvent = hDbEvent; mir_snprintf(toolTip, sizeof(toolTip), Translate("Message from %s"), (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0)); cle.pszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM) & cle); } } hDbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) hDbEvent, 0); } hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0); } }
int IsAutoPopup(MCONTACT hContact) { if (g_dat.flags & SMF_AUTOPOPUP) { char *szProto = GetContactProto(hContact); hContact = db_mc_getSrmmSub(hContact); if (hContact != NULL) szProto = GetContactProto(hContact); if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) return 1; } return 0; }
static int MessageEventAdded(WPARAM hContact, LPARAM lParam) { DBEVENTINFO dbei = { sizeof(dbei) }; db_event_get(lParam, &dbei); if (dbei.flags & (DBEF_SENT | DBEF_READ) || !(dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) return 0; CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); /* does a window for the contact exist? */ HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact); if (hwnd) { if (!db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS)) { ShowWindow(hwnd, SW_RESTORE); SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); SetForegroundWindow(hwnd); SkinPlaySound("RecvMsgActive"); } else { if (GetForegroundWindow() == hwnd) SkinPlaySound("RecvMsgActive"); else SkinPlaySound("RecvMsgInactive"); } return 0; } /* new message */ SkinPlaySound("AlertMsg"); char *szProto = GetContactProto(hContact); if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) { NewMessageWindowLParam newData = { 0 }; newData.hContact = hContact; newData.noActivate = db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS); CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)&newData); return 0; } CLISTEVENT cle = { sizeof(cle) }; cle.hContact = hContact; cle.hDbEvent = lParam; cle.flags = CLEF_TCHAR; cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; TCHAR toolTip[256]; mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); cle.ptszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); return 0; }
static void RestoreUnreadMessageAlerts(void) { TCHAR toolTip[256]; CLISTEVENT cle = { sizeof(cle) }; cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; cle.flags = CLEF_TCHAR; cle.ptszTooltip = toolTip; DBEVENTINFO dbei = { sizeof(dbei) }; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) { bool autoPopup = false; dbei.cbBlob = 0; db_event_get(hDbEvent, &dbei); if (!(dbei.flags & (DBEF_SENT | DBEF_READ)) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) { int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL; if (windowAlreadyExists) continue; char *szProto = GetContactProto(hContact); if (szProto && (g_dat.openFlags & SRMMStatusToPf2(CallProtoService(szProto, PS_GETSTATUS, 0, 0)))) autoPopup = true; if (autoPopup && !windowAlreadyExists) { NewMessageWindowLParam newData = { 0 }; newData.hContact = hContact; newData.noActivate = db_get_b(NULL, SRMMMOD, SRMSGSET_DONOTSTEALFOCUS, SRMSGDEFSET_DONOTSTEALFOCUS); CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), NULL, DlgProcMessage, (LPARAM)& newData); } else { cle.hContact = hContact; cle.hDbEvent = hDbEvent; mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } } } } }