示例#1
0
void EventList::AddGroup(const EventIndex& ev)
{
	EventData data;
	GetEventData(ev, data);
	TCHAR eventText[256];
	int i;
	eventText[0] = 0;
	tmi.printTimeStamp(NULL, data.timestamp, _T("d t"), eventText, 64, 0);
	std::wstring time = eventText;
	std::wstring user;
	if (data.isMe)
		user = myName;
	else
		user = contactName;
	GetEventMessage(ev, eventText, 256);
	for (i = 0; eventText[i] != 0 && eventText[i] != _T('\r') && eventText[i] != _T('\n'); ++i);
	eventText[i] = 0;
	if (i > Options::instance->groupMessageLen) {
		eventText[Options::instance->groupMessageLen - 3] = '.';
		eventText[Options::instance->groupMessageLen - 2] = '.';
		eventText[Options::instance->groupMessageLen - 1] = '.';
		eventText[Options::instance->groupMessageLen] = 0;
	}

	int ico = 0;
	GetEventIcon(data.isMe, data.eventType, ico);
	AddGroup(data.isMe, time, user, eventText, ico);
}
示例#2
0
文件: EventAge.c 项目: trieck/source
void SetEventRecord(EVENTLOGRECORD* pEventLogRecord, EVENTRECORD* pER)
{
    LPCSTR	pStringOffset;
    LPSTR	pOffset;
    CHAR	szMessageFileName[_MAX_FNAME];
    WORD	i;

    // set event id
    pER->EventID = pEventLogRecord->EventID;

    // set event date
    ConvertUTCToDate(pEventLogRecord->TimeWritten, pER->szEventDate);

    // set event type
    GetEventType(&pEventLogRecord->EventType, pER->szEventType);

    // set source name
    pOffset	= (LPSTR)pEventLogRecord + sizeof(EVENTLOGRECORD);
    strcpy(pER->szSourceName, pOffset);

    // set computer name
    pOffset += strlen(pER->szSourceName) + 1;
    strcpy(pER->szComputerName, pOffset);

    // get number of strings
    pER->numStrings = pEventLogRecord->NumStrings;

    // get insert strings
    pStringOffset	= (LPCSTR)pEventLogRecord + pEventLogRecord->StringOffset;
    pOffset			= (LPSTR)pStringOffset;

    for (i = 0; i < pER->numStrings; i++) {
        pER->pStrings[i] = (LPCSTR)pOffset;
        pOffset = strchr(pOffset, '\0') + 1;
    }

    // get event message filename
    if (GetEventMessageFileName(pER->szSourceName, szMessageFileName))
        // get event message
        GetEventMessage(pER->EventID, szMessageFileName, pER->pStrings, pER->pMessage);
    else
        // set empty message
        strcpy(pER->pMessage, "");
}
示例#3
0
bool EventList::SearchInContact(MCONTACT hContact, TCHAR *strFind, ComparatorInterface* compFun)
{
	InitFilters();

	if (useImportedMessages) {
		std::vector<IImport::ExternalMessage> messages;
		{
			mir_cslock lck(csEventList);
			std::map<MCONTACT, EventList::ImportDiscData>::iterator it = contactFileMap.find(hContact);
			if (it != contactFileMap.end()) {
				ExportManager imp(hWnd, hContact, 1);
				imp.SetAutoImport(it->second.file);
				if (!imp.Import(it->second.type, messages, NULL))
					messages.clear();
			}
		}

		for (int i = 0; i < (int)importedMessages.size(); ++i)
			if (compFun->Compare((importedMessages[i].flags & DBEF_SENT) != 0, importedMessages[i].message, strFind))
				return true;
	}

	std::list<EventTempIndex> tempList;
	GetTempList(tempList, false, true, hContact);

	EventIndex ei;
	EventData ed;
	TCHAR str[MAXSELECTSTR + 8]; // for safety reason
	for (std::list<EventTempIndex>::iterator itL = tempList.begin(); itL != tempList.end(); ++itL) {
		ei.isExternal = itL->isExternal;
		ei.hEvent = itL->hEvent;
		if (GetEventData(ei, ed)) {
			GetEventMessage(ei, str);
			if (compFun->Compare(ed.isMe, str, strFind))
				return true;
		}
	}

	return false;
}
示例#4
0
void ExportManager::AddGroup(bool isMe, const std::wstring &time, const std::wstring &user, const std::wstring &eventText, int ico)
{
	if (exp == NULL)
		return;
	
	exp->WriteGroup(isMe, time, user, eventText);
	TCHAR str[MAXSELECTSTR + 8]; // for safety reason
	str[0] = 0;
	tm lastTime;
	bool isFirst = true;
	bool lastMe = false;
	EventData data;
	std::deque<EventIndex> revDeq;
	std::deque<EventIndex>& deq = eventList.back();
	if (!oldOnTop && Options::instance->messagesNewOnTop) {
		revDeq.insert(revDeq.begin(), deq.rbegin(), deq.rend());
		deq = revDeq;
	}
	for (std::deque<EventIndex>::iterator it = deq.begin(); it != deq.end(); ++it) {
		EventIndex hDbEvent = *it;
		if (GetEventData(hDbEvent, data)) {
			lastMe = data.isMe;

			TCHAR* formatDate = Options::instance->messagesShowSec ? _T("d s") : _T("d t");
			TCHAR* longFormatDate = Options::instance->messagesShowSec ? _T("d s") : _T("d t");
			if (!Options::instance->messagesShowDate) {
				if (isFirst) {
					isFirst = false;
					formatDate = Options::instance->messagesShowSec ? _T("s") : _T("t");
					time_t tt = data.timestamp;
					localtime_s(&lastTime,  &tt);
				}
				else {
					time_t tt = data.timestamp;
					tm t;
					localtime_s(&t,  &tt);
					if (lastTime.tm_yday == t.tm_yday && lastTime.tm_year == t.tm_year)
						formatDate = Options::instance->messagesShowSec ? _T("s") : _T("t");
				}
			}
				
			TimeZone_PrintTimeStamp(NULL, data.timestamp, longFormatDate, str , MAXSELECTSTR, 0);
			std::wstring longDate = str;
			TimeZone_PrintTimeStamp(NULL, data.timestamp, formatDate, str , MAXSELECTSTR, 0);
			std::wstring shortDate = str;

			std::wstring user;
			if (lastMe)
				user = myName;
			else
				user = contactName;
				
			GetEventMessage(hDbEvent, str);
			std::wstring strMessage = str;
			if (strMessage.length() + 1 >= MAXSELECTSTR)
				continue;

			if (hDbEvent.isExternal)
				GetExtEventDBei(hDbEvent);

			exp->WriteMessage(lastMe, longDate, shortDate, user, strMessage, gdbei);
		}
	}
}
示例#5
0
VOID
DisplayEvent(HWND hDlg)
{
    WCHAR szEventType[MAX_PATH];
    WCHAR szTime[MAX_PATH];
    WCHAR szDate[MAX_PATH];
    WCHAR szUser[MAX_PATH];
    WCHAR szComputer[MAX_PATH];
    WCHAR szSource[MAX_PATH];
    WCHAR szCategory[MAX_PATH];
    WCHAR szEventID[MAX_PATH];
    WCHAR szEventText[EVENT_MESSAGE_EVENTTEXT_BUFFER];
    WCHAR szEventData[MAX_PATH];
    BOOL bEventData = FALSE;
    LVITEMW li;
    EVENTLOGRECORD* pevlr;
    int iIndex;

    // Get index of selected item
    iIndex = (int)SendMessage (hwndListView, LVM_GETNEXTITEM, -1, LVNI_SELECTED | LVNI_FOCUSED);

    li.mask = LVIF_PARAM;
    li.iItem = iIndex;
    li.iSubItem = 0;

    (void)ListView_GetItem(hwndListView, &li);

    pevlr = (EVENTLOGRECORD*)li.lParam;

    if (iIndex != -1)
    {
        ListView_GetItemText(hwndListView, iIndex, 0, szEventType, sizeof(szEventType) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 1, szDate, sizeof(szDate) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 2, szTime, sizeof(szTime) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 3, szSource, sizeof(szSource) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 4, szCategory, sizeof(szCategory) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 5, szEventID, sizeof(szEventID) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 6, szUser, sizeof(szUser) / sizeof(WCHAR));
        ListView_GetItemText(hwndListView, iIndex, 7, szComputer, sizeof(szComputer) / sizeof(WCHAR));

        bEventData = !(pevlr->DataLength == 0);

        if (pevlr->DataLength > 0)
        {
            MultiByteToWideChar(CP_ACP,
                                0,
                                (LPCSTR)((LPBYTE)pevlr + pevlr->DataOffset),
                                pevlr->DataLength,
                                szEventData,
                                MAX_PATH);
        }

        GetEventMessage(lpSourceLogName, szSource, pevlr, szEventText);

        EnableWindow(GetDlgItem(hDlg, IDC_BYTESRADIO), bEventData);
        EnableWindow(GetDlgItem(hDlg, IDC_WORDRADIO), bEventData);

        SetDlgItemTextW(hDlg, IDC_EVENTDATESTATIC, szDate);
        SetDlgItemTextW(hDlg, IDC_EVENTTIMESTATIC, szTime);

        SetDlgItemTextW(hDlg, IDC_EVENTUSERSTATIC, szUser);
        SetDlgItemTextW(hDlg, IDC_EVENTSOURCESTATIC, szSource);
        SetDlgItemTextW(hDlg, IDC_EVENTCOMPUTERSTATIC, szComputer);
        SetDlgItemTextW(hDlg, IDC_EVENTCATEGORYSTATIC, szCategory);
        SetDlgItemTextW(hDlg, IDC_EVENTIDSTATIC, szEventID);
        SetDlgItemTextW(hDlg, IDC_EVENTTYPESTATIC, szEventType);
        SetDlgItemTextW(hDlg, IDC_EVENTTEXTEDIT, szEventText);
        SetDlgItemTextW(hDlg, IDC_EVENTDATAEDIT, szEventData);
    }
    else
    {
        MessageBoxW(NULL,
                   L"No Items in ListView",
                   L"Error",
                   MB_OK | MB_ICONINFORMATION);
    }
}