static int GetWindowData(WPARAM wParam, LPARAM lParam) { MessageWindowInputData *mwid = (MessageWindowInputData*)wParam; MessageWindowData *mwd = (MessageWindowData*)lParam; HWND hwnd; if (mwid==NULL||mwd==NULL) return 1; if (mwid->cbSize!=sizeof(MessageWindowInputData)||mwd->cbSize!=sizeof(MessageWindowData)) return 1; if (mwid->hContact==NULL) return 1; if (mwid->uFlags!=MSG_WINDOW_UFLAG_MSG_BOTH) return 1; hwnd = WindowList_Find(g_dat->hMessageWindowList, mwid->hContact); mwd->uFlags = MSG_WINDOW_UFLAG_MSG_BOTH; mwd->hwndWindow = hwnd; mwd->local = 0; mwd->uState = SendMessage(hwnd, DM_GETWINDOWSTATE, 0, 0); return 0; }
static int ModifyStatusIcon(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; StatusIconData *sid = (StatusIconData *)lParam; struct StatusIconListNode *current = status_icon_list; while(current) { if(strcmp(current->sid.szModule, sid->szModule) == 0 && current->sid.dwId == sid->dwId) { if(!hContact) { current->sid.flags = sid->flags; if(sid->hIcon) { DestroyIcon(current->sid.hIcon); current->sid.hIcon = DuplicateIcon(NULL, sid->hIcon); } if(sid->hIconDisabled) { DestroyIcon(current->sid.hIconDisabled); current->sid.hIconDisabled = DuplicateIcon(NULL, sid->hIconDisabled); } if(sid->szTooltip) { if(current->sid.szTooltip) mir_free(current->sid.szTooltip); current->sid.szTooltip = mir_strdup(sid->szTooltip); } WindowList_Broadcast(g_dat->hParentWindowList, DM_STATUSICONCHANGE, 0, 0); } else { char buff[256]; HWND hwnd; sprintf(buff, "SRMMStatusIconFlags%d", (int)sid->dwId); DBWriteContactSettingByte(hContact, sid->szModule, buff, (BYTE)sid->flags); hwnd = WindowList_Find(g_dat->hMessageWindowList, hContact); if (hwnd == NULL) { hwnd = SM_FindWindowByContact(hContact); } if (hwnd != NULL) { PostMessage(GetParent(hwnd), DM_STATUSICONCHANGE, 0, 0); } } return 0; } current = current->next; } return 1; }
void ShowHistory(MCONTACT hContact, BYTE isAlert) { HWND hHistoryDlg = WindowList_Find(hWindowList, hContact); if (hHistoryDlg == NULL) { hHistoryDlg = CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_HISTORY), NULL, HistoryDlgProc, hContact); LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); WindowList_Add(hWindowList, hHistoryDlg, hContact); } else { SetForegroundWindow(hHistoryDlg); LoadHistoryList(hContact, hHistoryDlg, IDC_HISTORYLIST); SetFocus(hHistoryDlg); } if (isAlert) SkinPlaySound("LastSeenTrackedStatusChange"); }
static void RestoreUnreadMessageAlerts(void) { CLISTEVENT cle = { 0 }; DBEVENTINFO dbei = { 0 }; char toolTip[256]; int windowAlreadyExists; int autoPopup = DBGetContactSettingByte(NULL, SRMMMOD, SRMSGSET_AUTOPOPUP, SRMSGDEFSET_AUTOPOPUP); HANDLE hDbEvent, hContact; 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 (autoPopup && !windowAlreadyExists) { HWND hwndParent; struct NewMessageWindowLParam newData = { 0 }; newData.hContact = hContact; 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; _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); } }
// show edit settings dialog // wParam = current contact INT_PTR EditSettings(WPARAM wParam, LPARAM lParam) { HWND hEditDlg = WindowList_Find(hWindowList, wParam); // search the dialog list to prevent multiple instance of dialog for the same contact if (hEditDlg != NULL) { // if the dialog box already opened, bring it to the front SetForegroundWindow(hEditDlg); SetFocus(hEditDlg); } else { // if the dialog box is not opened, open a new one if (IsMyContact(wParam)) CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_EDIT), NULL, DlgProcChange, (LPARAM)wParam); } return 0; }
static INT_PTR SetStatusText(WPARAM wParam, LPARAM lParam) { HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, wParam); if (hwnd == NULL) return 1; SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA); if (dat == NULL) return 1; StatusTextData *st = (StatusTextData*)lParam; if (st != NULL && st->cbSize != sizeof(StatusTextData)) return 1; SendMessage(dat->hwndStatus, SB_SETICON, 0, (LPARAM)(st == NULL ? 0 : st->hIcon)); SendMessage(dat->hwndStatus, SB_SETTEXT, 0, (LPARAM)(st == NULL ? _T("") : st->tszText)); return 0; }
static void RestoreUnreadMessageAlerts(void) { OBJLIST<MSavedEvent> arEvents(10, NumericKeySortT); 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)) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.cbBlob = 0; db_event_get(hDbEvent, &dbei); if ((dbei.flags & (DBEF_SENT | DBEF_READ)) || !DbEventIsMessageOrCustom(&dbei)) continue; int windowAlreadyExists = WindowList_Find(g_dat.hMessageWindowList, hContact) != NULL; if (windowAlreadyExists) continue; if (IsAutoPopup(hContact) && !windowAlreadyExists) { NewMessageWindowLParam newData = { 0 }; newData.hContact = hContact; newData.flags = NMWLP_INCOMING; HWND hParent = GetParentWindow(newData.hContact, FALSE); CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), hParent, DlgProcMessage, (LPARAM)&newData); } else arEvents.insert(new MSavedEvent(hContact, hDbEvent)); } } TCHAR toolTip[256]; CLISTEVENT cle = {}; cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); cle.pszService = "SRMsg/ReadMessage"; cle.flags = CLEF_TCHAR; cle.ptszTooltip = toolTip; for (int i = 0; i < arEvents.getCount(); i++) { MSavedEvent &e = arEvents[i]; mir_sntprintf(toolTip, TranslateT("Message from %s"), pcli->pfnGetContactDisplayName(e.hContact, 0)); cle.hContact = e.hContact; cle.hDbEvent = e.hEvent; pcli->pfnAddEvent(&cle); } }
static int TypingMessage(WPARAM wParam, LPARAM lParam) { HWND hwnd; int foundWin = 0; if (!(g_dat->flags&SMF_SHOWTYPING)) return 0; if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) { SendMessage(hwnd, DM_TYPING, 0, lParam); foundWin = 1; } if ((int) lParam && !foundWin && (g_dat->flags&SMF_SHOWTYPINGTRAY)) { char szTip[256]; mir_snprintf(szTip, sizeof(szTip), Translate("%s is typing a message"), (char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, wParam, 0)); if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat->flags&SMF_SHOWTYPINGCLIST)) { MIRANDASYSTRAYNOTIFY tn; tn.szProto = NULL; tn.cbSize = sizeof(tn); tn.szInfoTitle = Translate("Typing Notification"); tn.szInfo = szTip; tn.dwInfoFlags = NIIF_INFO; tn.uTimeout = 1000 * 4; CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & tn); } else { CLISTEVENT cle; ZeroMemory(&cle, sizeof(cle)); cle.cbSize = sizeof(cle); cle.hContact = (HANDLE) wParam; cle.hDbEvent = (HANDLE) 1; cle.flags = CLEF_ONLYAFEW; cle.hIcon = g_dat->hIcons[SMF_ICON_TYPING]; cle.pszService = "SRMsg/TypingMessage"; cle.pszTooltip = szTip; CallServiceSync(MS_CLIST_REMOVEEVENT, wParam, (LPARAM) 1); CallServiceSync(MS_CLIST_ADDEVENT, wParam, (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); } } } } }
static int SendMessageCommand(WPARAM wParam, LPARAM lParam) { HWND hwnd; struct NewMessageWindowLParam newData = { 0 }; { /* does the HCONTACT's protocol support IM messages? */ char *szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0); if (szProto) { if (!CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_1, 0) & PF1_IMSEND) return 1; } else { /* unknown contact */ return 1; } //if } if ((hwnd = WindowList_Find(g_dat->hMessageWindowList, (HANDLE) wParam))) { if (lParam) { HWND hEdit; hEdit = GetDlgItem(hwnd, IDC_MESSAGE); SendMessage(hEdit, EM_SETSEL, -1, SendMessage(hEdit, WM_GETTEXTLENGTH, 0, 0)); SendMessage(hEdit, EM_REPLACESEL, FALSE, (LPARAM) (char *) lParam); } if (IsIconic(GetParent(hwnd))) { ShowWindow(GetParent(hwnd), SW_SHOWNORMAL); } else { ShowWindow(GetParent(hwnd), SW_SHOW); } SetForegroundWindow(GetParent(hwnd)); SetFocus(hwnd); } else { newData.hContact = (HANDLE) wParam; newData.szInitialText = (const char *) lParam; if (g_dat->hParent == NULL || !(g_dat->flags & SMF_USETABS)) { g_dat->hParent = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGWIN), NULL, DlgProcParentWindow, (LPARAM) & newData); } CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSG), g_dat->hParent, DlgProcMessage, (LPARAM) & newData); } return 0; }
int Quotes_OnContactDoubleClick(WPARAM wp, LPARAM/* lp*/) { MCONTACT hContact = MCONTACT(wp); if (CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact)) { MWindowList hWL = CModuleInfo::GetInstance().GetWindowList(WINDOW_PREFIX_INFO, true); assert(hWL); HWND hWnd = WindowList_Find(hWL, hContact); if (NULL != hWnd) { SetForegroundWindow(hWnd); SetFocus(hWnd); } else if (true == IsMyContact(hContact)) CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_QUOTE_INFO_1), NULL, QuoteInfoDlgProc1, LPARAM(hContact)); return 1; } return 0; }
static int TypingMessage(WPARAM hContact, LPARAM lParam) { if (!(g_dat.flags2 & SMF2_SHOWTYPING)) return 0; hContact = db_mc_tryMeta(hContact); SkinPlaySound((lParam) ? "TNStart" : "TNStop"); HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact); if (hwnd) SendMessage(hwnd, DM_TYPING, 0, lParam); else if (lParam && (g_dat.flags2 & SMF2_SHOWTYPINGTRAY)) { TCHAR szTip[256]; mir_sntprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); if ( ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) { MIRANDASYSTRAYNOTIFY tn; tn.szProto = NULL; tn.cbSize = sizeof(tn); tn.tszInfoTitle = TranslateT("Typing notification"); tn.tszInfo = szTip; tn.dwInfoFlags = NIIF_INFO | NIIF_INTERN_UNICODE; tn.uTimeout = 1000 * 4; CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)&tn); } else { pcli->pfnRemoveEvent(hContact, 1); CLISTEVENT cle = {}; cle.hContact = hContact; cle.hDbEvent = 1; cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; cle.hIcon = GetCachedIcon("scriver_TYPING"); cle.pszService = "SRMsg/TypingMessage"; cle.ptszTooltip = szTip; pcli->pfnAddEvent(&cle); } } return 0; }
static int TypingMessage(WPARAM hContact, LPARAM lParam) { if (!(g_dat.flags & SMF_SHOWTYPING)) return 0; hContact = db_mc_tryMeta(hContact); SkinPlaySound((lParam) ? "TNStart" : "TNStop"); HWND hwnd = WindowList_Find(g_dat.hMessageWindowList, hContact); if (hwnd) SendMessage(hwnd, DM_TYPING, 0, lParam); else if (lParam && (g_dat.flags & SMF_SHOWTYPINGTRAY)) { TCHAR szTip[256]; mir_sntprintf(szTip, TranslateT("%s is typing a message"), pcli->pfnGetContactDisplayName(hContact, 0)); if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags & SMF_SHOWTYPINGCLIST)) { MIRANDASYSTRAYNOTIFY tn = { sizeof(tn) }; tn.tszInfoTitle = TranslateT("Typing notification"); tn.tszInfo = szTip; tn.dwInfoFlags = NIIF_INFO; tn.dwInfoFlags |= NIIF_INTERN_UNICODE; tn.uTimeout = 1000 * 4; CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& tn); } else { CLISTEVENT cle = { sizeof(cle) }; cle.hContact = hContact; cle.hDbEvent = 1; cle.flags = CLEF_ONLYAFEW | CLEF_TCHAR; cle.hIcon = Skin_LoadIcon(SKINICON_OTHER_TYPING); cle.pszService = "SRMsg/ReadMessage"; cle.ptszTooltip = szTip; CallServiceSync(MS_CLIST_REMOVEEVENT, hContact, 1); CallServiceSync(MS_CLIST_ADDEVENT, hContact, (LPARAM)&cle); IcoLib_ReleaseIcon(cle.hIcon); } } return 0; }
int MsgAck(WPARAM, LPARAM lParam) { ACKDATA *ack=(ACKDATA*)lParam; if (ack && ack->cbSize == sizeof(ACKDATA) && ack->type == ACKTYPE_MESSAGE) { if (ack->hProcess == (HANDLE)WindowList_Find(hWindowList,ack->hContact)) { if (db_get_b(NULL, modname, "ShowDeliveryMessages", 1)) CreateMessageAcknowlegedWindow(ack->hContact,ack->result == ACKRESULT_SUCCESS); if (ack->result == ACKRESULT_SUCCESS) { // wrtie it to the DB DBEVENTINFO dbei = { 0 }; DBVARIANT dbv; int reuse = db_get_b(ack->hContact,modname, "Reuse", 0); if (!db_get_ts(ack->hContact, modname, "PounceMsg", &dbv) && (dbv.ptszVal[0] != '\0')) { T2Utf pszUtf(dbv.ptszVal); dbei.cbSize = sizeof(dbei); dbei.eventType = EVENTTYPE_MESSAGE; dbei.flags = DBEF_UTF | DBEF_SENT; dbei.szModule = (char*)ack->szModule; dbei.timestamp = time(NULL); dbei.cbBlob = (int)mir_strlen(pszUtf) + 1; dbei.pBlob = (PBYTE)(char*)pszUtf; db_event_add(ack->hContact, &dbei); } // check to reuse if (reuse > 1) db_set_b(ack->hContact, modname, "Reuse", (BYTE)(reuse-1)); else { db_set_b(ack->hContact,modname, "Reuse", 0); db_set_ws(ack->hContact, modname, "PounceMsg", _T("")); } } WindowList_Remove(hWindowList,(HWND)ack->hProcess); } } return 0; }
INT_PTR OnSendFile(WPARAM wParam, LPARAM lParam) { HWND hwnd = WindowList_Find(hFileList,(HANDLE)wParam); if(IsWindow(hwnd)) { SetForegroundWindow(hwnd); SetFocus(hwnd); } else { if(hwnd != 0) WindowList_Remove(hFileList, hwnd); FILEECHO *fe = new FILEECHO((HANDLE)wParam); fe->inSend = TRUE; hwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN), NULL, DialogProc, (LPARAM)fe); if(hwnd == NULL) { delete fe; return 0; } //SendMessage(hwnd, WM_FE_SERVICE, 0, TRUE); ShowWindow(hwnd, SW_SHOWNORMAL); } return 1; }
HWND CMimAPI::FindWindow(HANDLE h = 0) const { return(WindowList_Find(m_hMessageWindowList, h)); }
void GetData(HANDLE hContact) { int statpos = 0, dispos = 0, statposend = 0; char*pos; DBVARIANT dbv; char tempstring[300], tempstring2[300]; int MallocSize = 0; int DownloadSuccess = 0; char*raw; char*szInfo; char truncated[MAXSIZE1]; char truncated2[MAXSIZE2]; int trunccount = 0; char url[300]; unsigned long downloadsize = 0; int AmountWspcRem = 0; static char contactname[100]; int TherewasAlert = 0; int PosButnClick = 0; char tstr[128]; static char timestring[128]; int eventIndex = 0; int location = 0; int location2 = 0; if (Startingup) Sleep(2000); HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); Startingup = 0; ZeroMemory(&url, sizeof(url)); ZeroMemory(&contactname, sizeof(contactname)); ZeroMemory(&tempstring, sizeof(tempstring)); ZeroMemory(&tempstring2, sizeof(tempstring2)); ZeroMemory(&szInfo, sizeof(szInfo)); ZeroMemory(&dbv, sizeof(dbv)); ZeroMemory(&tstr, sizeof(tstr)); ZeroMemory(×tring, sizeof(timestring)); db_set_b(hContact, MODULENAME, STOP_KEY, 0); if (db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { if ( !db_get_s(hContact, "CList", "MyHandle", &dbv)) { db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal); db_free(&dbv); } } if ( !db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { strncpy_s(contactname, SIZEOF(contactname), dbv.pszVal, _TRUNCATE); db_free(&dbv); } url[0] = '\0'; if (!Startingup) db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 1); if ( !db_get_s(hContact, MODULENAME, START_STRING_KEY, &dbv)) { strncpy_s(tempstring, SIZEOF(tempstring), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, END_STRING_KEY, &dbv)) { strncpy_s(tempstring2, SIZEOF(tempstring2), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, URL_KEY, &dbv)) { strncpy_s(url, SIZEOF(url), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if (strlen(url) < 3) WErrorPopup(hContact, TranslateT("URL not supplied")); NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) }; nlhr.requestType = REQUEST_GET; nlhr.flags = NLHRF_DUMPASTEXT; nlhr.szUrl = url; nlhr.headersCount = 2; NETLIBHTTPHEADER headers[2]; headers[0].szName = "User-Agent"; headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)"; headers[1].szName = "Content-Length"; headers[1].szValue = NULL; nlhr.headers = headers; if ( db_get_b(NULL, MODULENAME, NO_PROTECT_KEY, 0)) // disable AlreadyDownloading = 0; // //try site//// if (!AlreadyDownloading) { // not already downloading if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON))) PosButnClick = 0; else PosButnClick = 1; EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download in progress, please wait...")); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Updating...")); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_DND); // download NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr); if (nlhrReply) { if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); TCHAR *statusText = TranslateT("The server replied with a failure code"); HWND hwndDlg = WindowList_Find(hWindowList, hContact); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); } if (nlhrReply->dataLength) { int cbLen = lstrlenA(nlhrReply->pData); szInfo = (char*)malloc(cbLen + 2); lstrcpynA(szInfo, nlhrReply->pData, cbLen); downloadsize = lstrlenA(nlhrReply->pData); trunccount = 0; lstrcpynA(truncated2, szInfo, MAXSIZE2); free(szInfo); //////////////////////////////////////////// sprintf(truncated2, "%s", nlhrReply->pData); AlreadyDownloading = 1; } // END DATELENGTH } // END REPLY if (!nlhrReply) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_NA); HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); TCHAR *statusText = TranslateT("The server is down or lagging."); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); } if (!(nlhrReply)) DownloadSuccess = 0; if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300)) DownloadSuccess = 0; else if (nlhrReply) DownloadSuccess = 1; CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply); if (DownloadSuccess) { HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data...")); } ///get data in desired range // download successful if (DownloadSuccess) { // all the site if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1) lstrcpynA(truncated, truncated2, MAXSIZE1); else { // use start and end string // putting data into string if (((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0)) { // start string pos = strstr(truncated2, tempstring); statpos = pos - truncated2; ZeroMemory(&pos, sizeof(pos)); // end string pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); if (statpos > statposend) { memset(&truncated2, ' ', statpos); ZeroMemory(&pos, sizeof(pos)); pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); } if (statpos < statposend) { ZeroMemory(&raw, sizeof(raw)); // get size for malloc MallocSize = statposend - statpos; raw = (char *) malloc(MallocSize + 1); // start string pos = strstr(truncated2, tempstring); statpos = pos - truncated2; // end string pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); if (statpos > statposend) { memset(&truncated2, ' ', statpos); ZeroMemory(&pos, sizeof(pos)); pos = strstr(truncated2, tempstring2); statposend = pos - truncated2 + (int)strlen(tempstring2); } dispos = 0; strncpy(raw, &truncated2[statpos], MallocSize); raw[MallocSize] = '\0'; trunccount = 0; lstrcpynA(truncated, raw, MAXSIZE1); free(raw); DownloadSuccess = 1; } else if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { TCHAR *szStatusText = TranslateT("Invalid search parameters."); WErrorPopup(hContact, szStatusText); HWND hwndDlg = WindowList_Find(hWindowList, hContact); DownloadSuccess = 0; SetDlgItemText(hwndDlg, IDC_STATUSBAR, szStatusText); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); } } // end putting data into string } // end use start and end strings } // end download success if (DownloadSuccess) { // download success if (statpos == 0 && statposend == 0) { if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { TCHAR *statusText = TranslateT("Both search strings not found or strings not set."); WErrorPopup(hContact, statusText); db_set_ts(hContact, "CList", "StatusMsg", statusText); HWND hwndDlg = WindowList_Find(hWindowList, hContact); DownloadSuccess = 0; SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); TherewasAlert = ProcessAlerts(hContact, _T2A(statusText), contactname, contactname, 1); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY); } } } // end download success if (DownloadSuccess) { // download success char timeprefix[32]; char temptime1[32]; char timeat[16]; char temptime2[32]; char temptime[128]; time_t ftime; struct tm *nTime; setlocale(LC_ALL, ""); if (!db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) { ZeroMemory(&temptime, sizeof(temptime)); ZeroMemory(&tstr, sizeof(tstr)); ftime = time(NULL); nTime = localtime(&ftime); // 12 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0) strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); // 24 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1) strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", temptime, dbv.pszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", dbv.pszVal, temptime); db_free(&dbv); } else { db_get_ts(hContact, "CList", "MyHandle", &dbv); ZeroMemory(&temptime, sizeof(temptime)); ZeroMemory(&tstr, sizeof(tstr)); ftime = time(NULL); nTime = localtime(&ftime); // 12 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0) strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime); // 24 hour if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1) strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime); db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.ptszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", temptime, dbv.pszVal); if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0) mir_snprintf(tstr, SIZEOF(tstr), "%s %s", dbv.pszVal, temptime); db_free(&dbv); } ftime = time(NULL); nTime = localtime(&ftime); strncpy_s(timeprefix, SIZEOF(timeprefix), Translate("Last updated on"), _TRUNCATE); strncpy_s(timeat, SIZEOF(timeat), Translate("at the time"), _TRUNCATE); strftime(temptime1, 32, " %a, %b %d, %Y ", nTime); strftime(temptime2, 32, " %I:%M %p.", nTime); mir_snprintf(timestring, SIZEOF(timestring), " %s %s%s%s", timeprefix, temptime1, timeat, temptime2); } // end download success if (DownloadSuccess) { TherewasAlert = ProcessAlerts(hContact, truncated, tstr, contactname, 0); // get range of text to be highlighted when part of change changes if (TherewasAlert) { // //////////////////////// static char buff[MAXSIZE1]; char Alerttempstring[300], Alerttempstring2[300]; eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0); if (eventIndex == 2) { strncpy(buff, truncated, SIZEOF(buff)); Filter(buff); if ( !db_get_s(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv)) { strncpy_s(Alerttempstring, SIZEOF(Alerttempstring), dbv.pszVal, _TRUNCATE); db_free(&dbv); } if ( !db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv)) { strncpy_s(Alerttempstring2, SIZEOF(Alerttempstring2), dbv.pszVal, _TRUNCATE); db_free(&dbv); } // putting data into string if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0)) { location = (strstr(buff, Alerttempstring)) - buff; location2 = (strstr(buff, Alerttempstring2)) - buff; } } } if ((((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0) && (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)) || (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1)) { RemoveTabs(truncated); if ( db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0)) { HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 1)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) { LBL_Stop: TCHAR *statusText = TranslateT("Processing data stopped by user."); SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText); db_set_b(hContact, MODULENAME, STOP_KEY, 0); db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE); db_set_ts(hContact, "CList", "StatusMsg", statusText); AlreadyDownloading = 0; return; } CodetoSymbol(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 2)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; EraseBlock(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 3)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; FastTagFilter(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 4)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; NumSymbols(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 5)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; EraseSymbols(truncated); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 6)")); AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; RemoveInvis(truncated, AmountWspcRem); Sleep(100); // avoid 100% CPU SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 7)")); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; Removewhitespace(truncated); SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 8)")); //data in popup if (TherewasAlert) if ( db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0)) WAlertPopup(hContact, _A2T(truncated)); if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) goto LBL_Stop; // removed any excess characters at the end. if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3])) { int counterx = 0; while (true) { counterx++; if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1]) { truncated[(strlen(truncated) - counterx) + 2] = '\0'; break; } } } } } if (TherewasAlert) { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_OCCUPIED); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Alert!")); } else { db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE); db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Online")); } } if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) { if (statpos > statposend) DownloadSuccess = 0; else if (statpos == 0 && statposend == 0) DownloadSuccess = 0; else DownloadSuccess = 1; } AlreadyDownloading = 0; } // end not already downloading if (AlreadyDownloading) SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("A site is already downloading, try again in a moment.")); if (DownloadSuccess) { // download success char BytesString[128]; HWND hwndDlg = (WindowList_Find(hWindowList, hContact)); // update window if the update only on alert option isn't ticked or // there was an alert or the update button was clicked if ((!(db_get_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0))) || (TherewasAlert == 1) || (PosButnClick == 1)) { SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr); if (TherewasAlert) { // highlight text when part of change changes if (eventIndex == 2) { CHARRANGE sel2 = {location, location2}; SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2); SetFocus(GetDlgItem(hwndDlg, IDC_DATA)); DWORD HiBackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, Def_color_bg); DWORD HiTextClr = db_get_dw(NULL, MODULENAME, TXT_COLOR_KEY, Def_color_txt); CHARFORMAT2 Format; memset(&Format, 0, sizeof(Format)); Format.cbSize = sizeof(Format); Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_BACKCOLOR; Format.dwEffects = CFE_BOLD; Format.crBackColor = ((~HiBackgoundClr) & 0x00ffffff); Format.crTextColor = ((~HiTextClr) & 0x00ffffff); SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & Format); } } SetDlgItemTextA(hwndDlg, IDC_STATUSBAR, timestring); sprintf(BytesString, "%s: %d | %s: %lu", (Translate("Bytes in display")), (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_DATA))), (Translate("Bytes downloaded")), downloadsize); SendMessage(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM) BytesString); } else SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert test conditions not met; press the refresh button to view content.")); } EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1); if (!Startingup) db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0); }
void UpdateMwinData(HANDLE hContact) { HWND hwnd = WindowList_Find(hMwinWindowList, hContact); if (hwnd != NULL) RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW); }
HWND CMimAPI::FindWindow(MCONTACT h) const { return WindowList_Find(m_hMessageWindowList, h); }
/* This function handles the search dialog messages */ INT_PTR CALLBACK SearchDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { HWND hListDlg; DIALOGPARAM *DlgParam = (DIALOGPARAM *)GetWindowLongPtr(hDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hDlg); SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)lParam); SetWindowText(hDlg, TXT_SEARCH); CheckDlgButton(hDlg, IDC_DIR_ALL, BST_CHECKED); CheckDlgButton(hDlg, IDC_TYPE_ALL, BST_CHECKED); return TRUE; break; case WM_COMMAND: { HWND hWndMain; hWndMain = WindowList_Find(hWindowList,DlgParam->hContact); switch (wParam) { case IDCLOSE: case IDCANCEL: { HMENU listMenu = GetMenu(hWndMain); EnableMenuItem(listMenu, 101, MF_BYCOMMAND | MF_ENABLED); DestroyWindow(hDlg); return TRUE; } break; case IDSEARCH: { BYTE flags = 0x00; TCHAR filter[FILTERTEXT]; LPTSTR buffer; int length; hListDlg = WindowList_Find(hWindowList, DlgParam->hContact); if (hListDlg == NULL) break; SetDlgItemText(hListDlg, IDC_MAIN, _T("")); if (IsDlgButtonChecked(hDlg, IDC_TYPE_WEB) == BST_UNCHECKED) flags |= WLL_MAIL; if (IsDlgButtonChecked(hDlg, IDC_TYPE_MAIL) == BST_UNCHECKED) flags |= WLL_URL; if (IsDlgButtonChecked(hDlg, IDC_DIR_IN) == BST_UNCHECKED) flags |= WLL_OUT; if (IsDlgButtonChecked(hDlg, IDC_DIR_OUT) == BST_UNCHECKED) flags |= WLL_IN; if (IsDlgButtonChecked(hDlg, IDC_WHOLE_MESSAGE) == BST_CHECKED) flags |= SLL_DEEP; length = GetWindowTextLength(GetDlgItem(hDlg, IDC_SEARCHSTRING)) + 1; buffer = (LPTSTR)mir_alloc((length + 1) * sizeof(TCHAR)); if (buffer) { GetDlgItemText(hDlg, IDC_SEARCHSTRING, buffer, length); WriteLinkList(hListDlg, flags, DlgParam->listStart, buffer, 0); mir_free(buffer); } mir_sntprintf(filter, _T("%s: %s"), TXT_FILTER, TXT_SEARCHFILTER); SetDlgItemText(hWndMain, IDC_STATUS, filter); } break; } } break; } return FALSE; }
int JabberMenuProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (lstrcmpA(sicd->szModule, jabberProtoName)) return 0; HANDLE hContact = (HANDLE)wParam; if (!hContact) return 0; DBVARIANT dbv; if (JGetStringT(hContact, "jid", &dbv)) return 0; JABBER_LIST_ITEM *LI = JabberListGetItemPtr(LIST_ROSTER, dbv.ptszVal); JFreeVariant( &dbv ); if (!LI) return 0; HMENU hMenu = CreatePopupMenu(); TCHAR buf[256]; mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("Last active"), ((LI->lastSeenResource>=0) && (LI->lastSeenResource < LI->resourceCount)) ? LI->resource[LI->lastSeenResource].resourceName : TranslateT("No activity yet, use server's choice")); AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf); AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); for (int i = 0; i < LI->resourceCount; ++i) AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->resource[i].resourceName); if (LI->resourceMode == RSMODE_LASTSEEN) CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND|MF_CHECKED); else if (LI->resourceMode == RSMODE_SERVER) CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hMenu, MENUITEM_RESOURCES+LI->manualResource, MF_BYCOMMAND|MF_CHECKED); int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL); if (res == MENUITEM_LASTSEEN) { LI->manualResource = -1; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { LI->manualResource = -1; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { LI->manualResource = res - MENUITEM_RESOURCES; LI->resourceMode = RSMODE_MANUAL; } JabberUpdateMirVer(LI); JabberMenuUpdateSrmmIcon(LI); return 0; }
int UpdateValues(WPARAM hContact, LPARAM lparam) { // to make this code faster if (!hContact) return 0; DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lparam; char *szProto = GetContactProto(hContact); if (cws->value.type == DBVT_DWORD && !strcmp(cws->szSetting, "LastSeen") && !mir_strcmp(cws->szModule, szProto)) { DBWriteTimeTS(cws->value.dVal, hContact); HWND hwnd = WindowList_Find(g_pUserInfo, hContact); if (hwnd != NULL) SendMessage(hwnd, WM_REFRESH_UI, hContact, 0); return 0; } BOOL isIdleEvent = includeIdle ? (strcmp(cws->szSetting, "IdleTS") == 0) : 0; if (strcmp(cws->szSetting, "Status") && strcmp(cws->szSetting, "StatusTriger") && (isIdleEvent == 0)) return 0; if (!strcmp(cws->szModule, S_MOD)) { // here we will come when Settings/SeenModule/StatusTriger is changed WORD prevStatus = db_get_w(hContact, S_MOD, "OldStatus", ID_STATUS_OFFLINE); if (includeIdle) { if (db_get_b(hContact, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF; else prevStatus |= 0x8000; } if ((cws->value.wVal | 0x8000) <= ID_STATUS_OFFLINE) { // avoid repeating the offline status if ((prevStatus | 0x8000) <= ID_STATUS_OFFLINE) return 0; db_set_b(hContact, S_MOD, "Offline", 1); { char str[MAXMODULELABELLENGTH + 9]; mir_snprintf(str, "OffTime-%s", szProto); DWORD t = db_get_dw(NULL, S_MOD, str, 0); if (!t) t = time(NULL); DBWriteTimeTS(t, hContact); } if (!db_get_b(NULL, S_MOD, "IgnoreOffline", 1)) { if (g_bFileActive) FileWrite(hContact); char *sProto = GetContactProto(hContact); if (CallProtoService(sProto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { myPlaySound(hContact, ID_STATUS_OFFLINE, prevStatus); if (db_get_b(NULL, S_MOD, "UsePopups", 0)) ShowPopup(hContact, sProto, ID_STATUS_OFFLINE); } if (db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite(hContact); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) ShowHistory(hContact, 1); } } else { if (cws->value.wVal == prevStatus && !db_get_b(hContact, S_MOD, "Offline", 0)) return 0; DBWriteTimeTS(time(NULL), hContact); if (g_bFileActive) FileWrite(hContact); if (prevStatus != cws->value.wVal) myPlaySound(hContact, cws->value.wVal, prevStatus); if (db_get_b(NULL, S_MOD, "UsePopups", 0)) if (prevStatus != cws->value.wVal) ShowPopup(hContact, GetContactProto(hContact), cws->value.wVal | 0x8000); if (db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite(hContact); if (db_get_b(hContact, S_MOD, "OnlineAlert", 0)) ShowHistory(hContact, 1); db_set_b(hContact, S_MOD, "Offline", 0); } } else if (hContact && IsWatchedProtocol(cws->szModule) && !db_get_b(hContact, cws->szModule, "ChatRoom", false)) { // here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched if (CallProtoService(cws->szModule, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE) { mir_cslock lck(csContacts); logthread_info *p = arContacts.find((logthread_info*)&hContact); if (p == NULL) { p = (logthread_info*)mir_calloc(sizeof(logthread_info)); p->hContact = hContact; mir_strncpy(p->sProtoName, cws->szModule, _countof(p->sProtoName)); arContacts.insert(p); mir_forkthread(waitThread, p); } p->currStatus = isIdleEvent ? db_get_w(hContact, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal; } } return 0; }
static INT_PTR LinkList_Main(WPARAM wParam, LPARAM) { HANDLE hContact = (HANDLE)wParam; HWND hWnd = WindowList_Find(hWindowList, hContact); if ( hWnd != NULL ) { int len; SetForegroundWindow(hWnd); SetFocus(hWnd); len = GetWindowTextLength(GetDlgItem(hWnd, IDC_MAIN)); PostMessage(GetDlgItem(hWnd, IDC_MAIN), EM_SETSEL, (WPARAM)len, (LPARAM)len); return 0; } HANDLE hEvent = db_event_first(hContact); if (hEvent == NULL) { MessageBox(NULL, TXT_EMPTYHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION ); return 0; } int histCount = db_event_count(hContact), actCount = 0; DBEVENTINFO dbe = { sizeof(dbe) }; dbe.cbBlob = db_event_getBlobSize(hEvent); dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); db_event_get(hEvent, &dbe); dbe.pBlob[dbe.cbBlob] = 0; RECT DesktopRect; GetWindowRect(GetDesktopWindow(), &DesktopRect); HWND hWndProgress = CreateWindow(_T("Progressbar"), TranslateT("Processing history..."), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, 350, 45, NULL, NULL, hInst, NULL); if ( hWndProgress == 0 ) { free(dbe.pBlob); MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION ); return -1; } SetWindowPos(hWndProgress, HWND_TOP, (int)(DesktopRect.right*0.5)-175, (int)(DesktopRect.bottom*0.5)-22, 0, 0, SWP_NOSIZE); ShowWindow(hWndProgress, SW_SHOW); SetForegroundWindow(hWndProgress); LISTELEMENT *listStart = (LISTELEMENT*)malloc(sizeof(LISTELEMENT)); ZeroMemory(listStart, sizeof(LISTELEMENT)); while( 1 ) { if ( dbe.eventType == EVENTTYPE_URL || dbe.eventType == EVENTTYPE_MESSAGE ) { // Call function to find URIs if ( ExtractURI(&dbe, hEvent, listStart) < 0 ) { free(dbe.pBlob); RemoveList(listStart); MessageBox(NULL, TranslateT("Could not allocate memory!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION); return -1; } } actCount++; if ( ((int)(((float)actCount/histCount)*100.00)) % 10 == 0 ) SendMessage(hWndProgress, WM_COMMAND, 100, ((int)(((float)actCount/histCount)*100.00))); hEvent = db_event_next(hEvent); if ( hEvent == NULL ) break; free(dbe.pBlob); dbe.cbBlob = db_event_getBlobSize(hEvent); dbe.pBlob = (PBYTE)malloc(dbe.cbBlob+1); db_event_get(hEvent, &dbe); dbe.pBlob[dbe.cbBlob] = 0; } free(dbe.pBlob); SendMessage(hWndProgress, WM_CLOSE, 0, 0); if ( ListCount(listStart) <= 0 ) { RemoveList(listStart); MessageBox(NULL, TXT_NOLINKINHISTORY, TXT_PLUGINNAME, MB_OK | MB_ICONINFORMATION); return 0; } DIALOGPARAM *DlgParam = (DIALOGPARAM*)malloc(sizeof(DIALOGPARAM)); DlgParam->hContact = hContact; DlgParam->listStart = listStart; DlgParam->findMessage = 0; DlgParam->chrg.cpMax = -1; DlgParam->chrg.cpMin = -1; HWND hWndMain = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_MAIN_DLG), NULL, MainDlgProc, (LPARAM)DlgParam); if (hWndMain == 0) { RemoveList(listStart); MessageBox(NULL, TranslateT("Could not create window!"), TranslateT("Error"), MB_OK | MB_ICONEXCLAMATION ); return -1; } ShowWindow(hWndMain, SW_SHOW); return 0; }
int CJabberProto::OnProcessSrmmIconClick(WPARAM hContact, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (mir_strcmp(sicd->szModule, m_szModuleName)) return 0; if (!hContact) return 0; JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, ptrT(getTStringA(hContact, "jid"))); if (LI == NULL) return 0; HMENU hMenu = CreatePopupMenu(); TCHAR buf[256]; mir_sntprintf(buf, TranslateT("Last active (%s)"), LI->m_pLastSeenResource ? LI->m_pLastSeenResource->m_tszResourceName : TranslateT("No activity yet, use server's choice")); AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf); AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); for (int i = 0; i < LI->arResources.getCount(); i++) AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES + i, LI->arResources[i]->m_tszResourceName); if (LI->resourceMode == RSMODE_LASTSEEN) CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND | MF_CHECKED); else if (LI->resourceMode == RSMODE_SERVER) CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND | MF_CHECKED); else if (LI->m_pManualResource) CheckMenuItem(hMenu, MENUITEM_RESOURCES + LI->arResources.indexOf(LI->m_pManualResource), MF_BYCOMMAND | MF_CHECKED); int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL); if (res == MENUITEM_LASTSEEN) { LI->m_pManualResource = NULL; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { LI->m_pManualResource = NULL; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { LI->m_pManualResource = LI->arResources[res - MENUITEM_RESOURCES]; LI->resourceMode = RSMODE_MANUAL; } UpdateMirVer(LI); MenuUpdateSrmmIcon(LI); return 0; }
void TN_TypingMessage(MCONTACT hContact, int iMode) { // hidden & ignored contacts check if (db_get_b(hContact, "CList", "Hidden", 0) || (db_get_dw(hContact, "Ignore", "Mask1", 0) & 1)) // 9 - online notification return; if (!PluginConfig.g_bPopupAvail || Disabled) return; TCHAR *szContactName = pcli->pfnGetContactDisplayName(hContact, 0); if (OnePopup) { HWND hPopupWnd = WindowList_Find(hPopupsList, hContact); while (hPopupWnd) { PUDeletePopup(hPopupWnd); hPopupWnd = WindowList_Find(hPopupsList, hContact); } } int notyping; POPUPDATAT_V2 ppd = { 0 }; ppd.cbSize = sizeof(ppd); if (iMode == PROTOTYPE_CONTACTTYPING_OFF) { if (StopDisabled) return; _tcsncpy_s(ppd.lptzContactName, szContactName, _TRUNCATE); _tcsncpy_s(ppd.lptzText, szStop, _TRUNCATE); ppd.hNotification = hntfStopped; notyping = 1; } else { if (StartDisabled) return; _tcsncpy_s(ppd.lptzContactName, szContactName, _TRUNCATE); _tcsncpy_s(ppd.lptzText, szStart, _TRUNCATE); ppd.hNotification = hntfStarted; notyping = 0; } switch (ColorMode) { case COLOR_OWN: ppd.colorBack = colorPicker[2 * notyping].color; ppd.colorText = colorPicker[2 * notyping + 1].color; break; case COLOR_WINDOWS: ppd.colorBack = GetSysColor(COLOR_BTNFACE); ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); break; case COLOR_POPUP: default: ppd.colorBack = ppd.colorText = 0; break; } if (notyping) switch (TimeoutMode2) { case TIMEOUT_CUSTOM: ppd.iSeconds = Timeout2; break; case TIMEOUT_PERMANENT: ppd.iSeconds = -1; break; case TIMEOUT_POPUP: default: ppd.iSeconds = 0; break; } else switch (TimeoutMode) { case TIMEOUT_CUSTOM: ppd.iSeconds = Timeout; break; case TIMEOUT_PROTO: ppd.iSeconds = iMode; break; case TIMEOUT_PERMANENT: ppd.iSeconds = -1; break; case TIMEOUT_POPUP: default: ppd.iSeconds = 0; break; } ppd.lchIcon = PluginConfig.g_buttonBarIcons[ICON_DEFAULT_TYPING]; ppd.lchContact = hContact; ppd.PluginWindowProc = PopupDlgProc; CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, APF_NEWDATA); }
static int SrmmMenu_ProcessIconClick(WPARAM hContact, LPARAM lParam) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (lstrcmpA(sicd->szModule, MODULNAME)) return 0; if (!hContact) return 0; int mode = db_get_b(hContact, MODULNAME, "ShowMode", PU_SHOWMODE_AUTO); if (sicd->flags & MBCF_RIGHTBUTTON) { HMENU hMenu = CreatePopupMenu(); AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_AUTO, TranslateT("Auto")); AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_FAVORITE, TranslateT("Favorite")); AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_FULLSCREEN, TranslateT("Ignore fullscreen")); AppendMenu(hMenu, MF_STRING, 1+PU_SHOWMODE_BLOCK, TranslateT("Block")); CheckMenuItem(hMenu, 1+mode, MF_BYCOMMAND|MF_CHECKED); mode = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL); if (mode) { db_set_b(hContact, MODULNAME, "ShowMode", mode-1); SrmmMenu_UpdateIcon(hContact); } } else { db_set_b(hContact, MODULNAME, "ShowMode", (mode == PU_SHOWMODE_AUTO) ? PU_SHOWMODE_BLOCK : PU_SHOWMODE_AUTO); SrmmMenu_UpdateIcon(hContact); } return 0; }