// --------------------------------------------------------------------------- // Return custom event data // --------------------------------------------------------------------------- // EXPORT_C TInt TAlfEvent::CustomEventData() const { __ASSERT_ALWAYS( IsCustomEvent(), USER_INVARIANT() ); return iCustomEventData; }
int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM lParam) { TCHAR szName[CONTAINER_NAMELEN + 1]; HANDLE hDbEvent = (HANDLE)lParam; DBEVENTINFO dbei = { sizeof(dbei) }; db_event_get(hDbEvent, &dbei); HWND hwnd = M.FindWindow(hContact); if (hwnd == NULL) hwnd = M.FindWindow(db_event_getContact(hDbEvent)); BOOL isCustomEvent = IsCustomEvent(dbei.eventType); BOOL isShownCustomEvent = DbEventIsForMsgWindow(&dbei); if (dbei.markedRead() || (isCustomEvent && !isShownCustomEvent)) return 0; CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); bool bAllowAutoCreate = false; bool bAutoPopup = M.GetByte(SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP) != 0; bool bAutoCreate = M.GetByte("autotabs", 1) != 0; bool bAutoContainer = M.GetByte("autocontainer", 1) != 0; DWORD dwStatusMask = M.GetDword("autopopupmask", -1); if (hwnd) { TContainerData *pTargetContainer = 0; SendMessage(hwnd, DM_QUERYCONTAINER, 0, (LPARAM)&pTargetContainer); if (pTargetContainer == NULL || !PluginConfig.m_HideOnClose || IsWindowVisible(pTargetContainer->hwnd)) return 0; WINDOWPLACEMENT wp = { 0 }; wp.length = sizeof(wp); GetWindowPlacement(pTargetContainer->hwnd, &wp); GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); if (bAutoPopup || bAutoCreate) { if (bAutoPopup) { if (wp.showCmd == SW_SHOWMAXIMIZED) ShowWindow(pTargetContainer->hwnd, SW_SHOWMAXIMIZED); else ShowWindow(pTargetContainer->hwnd, SW_SHOWNOACTIVATE); return 0; } TContainerData *pContainer = FindContainerByName(szName); if (pContainer != NULL) { if (bAutoContainer) { ShowWindow(pTargetContainer->hwnd, SW_SHOWMINNOACTIVE); return 0; } goto nowindowcreate; } else if (bAutoContainer) { ShowWindow(pTargetContainer->hwnd, SW_SHOWMINNOACTIVE); return 0; } } } else { switch (dbei.eventType) { case EVENTTYPE_AUTHREQUEST: case EVENTTYPE_ADDED: return 0; case EVENTTYPE_FILE: tabSRMM_ShowPopup(hContact, hDbEvent, dbei.eventType, 0, 0, 0, dbei.szModule, 0); return 0; } } // if no window is open, we are not interested in anything else but unread message events // new message if (!nen_options.iNoSounds) SkinPlaySound("AlertMsg"); if (nen_options.iNoAutoPopup) goto nowindowcreate; GetContainerNameForContact(hContact, szName, CONTAINER_NAMELEN); if (dwStatusMask == -1) bAllowAutoCreate = true; else { char *szProto = GetContactProto(hContact); if (szProto && !strcmp(szProto, META_PROTO)) szProto = GetContactProto(db_mc_getSrmmSub(hContact)); if (szProto) { DWORD dwStatus = (DWORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0); if (dwStatus == 0 || dwStatus <= ID_STATUS_OFFLINE || ((1 << (dwStatus - ID_STATUS_ONLINE)) & dwStatusMask)) // should never happen, but... bAllowAutoCreate = true; } } if (bAllowAutoCreate && (bAutoPopup || bAutoCreate)) { if (bAutoPopup) { TContainerData *pContainer = FindContainerByName(szName); if (pContainer == NULL) pContainer = CreateContainer(szName, FALSE, hContact); if (pContainer) CreateNewTabForContact(pContainer, hContact, 0, NULL, TRUE, TRUE, FALSE, 0); return 0; } bool bActivate = false, bPopup = M.GetByte("cpopup", 0) != 0; TContainerData *pContainer = FindContainerByName(szName); if (pContainer != NULL) { if (M.GetByte("limittabs", 0) && !wcsncmp(pContainer->szName, L"default", 6)) { if ((pContainer = FindMatchingContainer(L"default", hContact)) != NULL) { CreateNewTabForContact(pContainer, hContact, 0, NULL, bActivate, bPopup, TRUE, hDbEvent); return 0; } } else { CreateNewTabForContact(pContainer, hContact, 0, NULL, bActivate, bPopup, TRUE, hDbEvent); return 0; } } if (bAutoContainer) { if ((pContainer = CreateContainer(szName, CNT_CREATEFLAG_MINIMIZED, hContact)) != NULL) { // 2 means create minimized, don't popup... CreateNewTabForContact(pContainer, hContact, 0, NULL, bActivate, bPopup, TRUE, hDbEvent); SendMessageW(pContainer->hwnd, WM_SIZE, 0, 0); } return 0; } } // for tray support, we add the event to the tray menu. otherwise we send it back to // the contact list for flashing nowindowcreate: if (!(dbei.flags & DBEF_READ)) { UpdateTrayMenu(0, 0, dbei.szModule, NULL, hContact, 1); if (!nen_options.bTraySupport) { TCHAR toolTip[256], *contactName; CLISTEVENT cle = { sizeof(cle) }; cle.hContact = hContact; cle.hDbEvent = hDbEvent; cle.flags = CLEF_TCHAR; cle.hIcon = LoadSkinnedIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; contactName = pcli->pfnGetContactDisplayName(hContact, 0); mir_sntprintf(toolTip, SIZEOF(toolTip), TranslateT("Message from %s"), contactName); cle.ptszTooltip = toolTip; CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } tabSRMM_ShowPopup(hContact, hDbEvent, dbei.eventType, 0, 0, 0, dbei.szModule, 0); } return 0; }
// --------------------------------------------------------------------------- // Return custom event parameter // --------------------------------------------------------------------------- // EXPORT_C TInt TAlfEvent::CustomParameter() const { __ASSERT_ALWAYS( IsCustomEvent(), USER_INVARIANT() ); return iParam; }