Esempio n. 1
0
/*
===============
=
= ParseEvent
=
===============
*/
void ParseEvent ( int time )
{
   eventtype * event;

   event = CreateEvent ( time, GetEventType() );

   switch (event->effecttype)
      {
      case background_noscrolling_event:
      case background_scrolling_event:
      case background_multi_event:
      case backdrop_scrolling_event:
      case backdrop_noscrolling_event:
         ParseBack(event);
         break;
      case sprite_background_event:
      case sprite_foreground_event:
         ParseSprite(event);
         break;
      case palette_event:
         ParsePalette(event);
         break;
      case flic_event:
         ParseFlic(event);
         break;
      case fadeout_event:
      case blankscreen_event:
      case clearbuffer_event:
      case cinematicend_event:
         break;
      }
}
Esempio n. 2
0
void wxFileDirPickerCtrlBase::UpdatePickerFromTextCtrl()
{
    wxASSERT(m_text);

    if (m_bIgnoreNextTextCtrlUpdate)
    {
        // ignore this update
        m_bIgnoreNextTextCtrlUpdate = false;
        return;
    }

    // remove the eventually present path-separator from the end of the textctrl
    // string otherwise we would generate a wxFileDirPickerEvent when changing
    // from e.g. /home/user to /home/user/ and we want to avoid it !
    wxString newpath(GetTextCtrlValue());
    if (!CheckPath(newpath))
        return;       // invalid user input

    if (m_pickerIface->GetPath() != newpath)
    {
        m_pickerIface->SetPath(newpath);

        // update current working directory, if necessary
        // NOTE: the path separator is required because if newpath is "C:"
        //       then no change would happen
        if (IsCwdToUpdate())
            wxSetWorkingDirectory(newpath);

        // fire an event
        wxFileDirPickerEvent event(GetEventType(), this, GetId(), newpath);
        GetEventHandler()->ProcessEvent(event);
    }
}
ButcherDocumentKeyEvent::ButcherDocumentKeyEvent(const wxKeyEvent &event) :
    wxKeyEvent(event)
{
    m_propagationLevel=wxEVENT_PROPAGATE_MAX;
    orig_=GetEventType();
    SetEventType(wxEVT_BUTCHERDOCUMENTKEY_ACTION);
}
Esempio n. 4
0
void wxFileDirPickerCtrlBase::UpdatePickerFromTextCtrl()
{
    wxASSERT(m_text);

    // remove the eventually present path-separator from the end of the textctrl
    // string otherwise we would generate a wxFileDirPickerEvent when changing
    // from e.g. /home/user to /home/user/ and we want to avoid it !
    wxString newpath(GetTextCtrlValue());

    // Notice that we use to check here whether the current path is valid, i.e.
    // if the corresponding file or directory exists for the controls with
    // wxFLP_FILE_MUST_EXIST or wxDIRP_DIR_MUST_EXIST flag, however we don't do
    // this any more as we still must notify the program about any changes in
    // the control, otherwise its view of it would be different from what is
    // actually shown on the screen, resulting in very confusing UI.

    if (m_pickerIface->GetPath() != newpath)
    {
        m_pickerIface->SetPath(newpath);

        // update current working directory, if necessary
        // NOTE: the path separator is required because if newpath is "C:"
        //       then no change would happen
        if (IsCwdToUpdate())
            wxSetWorkingDirectory(newpath);

        // fire an event
        wxFileDirPickerEvent event(GetEventType(), this, GetId(), newpath);
        GetEventHandler()->ProcessEvent(event);
    }
}
Esempio n. 5
0
void wxFileDirPickerCtrlBase::OnFileDirChange(wxFileDirPickerEvent &ev)
{
    UpdateTextCtrlFromPicker();

    // the wxFilePickerWidget sent us a colour-change notification.
    // forward this event to our parent
    wxFileDirPickerEvent event(GetEventType(), this, GetId(), ev.GetPath());
    GetEventHandler()->ProcessEvent(event);
}
Esempio n. 6
0
wxString wxLuaEventCallback::GetInfo() const
{
    return wxString::Format(wxT("%s(%d) -> wxLuaEventCallback(%p, ids %d, %d)|wxEvtHandler(%p) -> %s : %s"),
                lua2wx(m_wxlBindEvent ? m_wxlBindEvent->name : "?NULL?").c_str(),
                (int)GetEventType(),
                this, m_id, m_last_id,
                m_evtHandler,
                m_evtHandler ? m_evtHandler->GetClassInfo()->GetClassName() : wxT("?NULL?"),
                m_wxlState.GetwxLuaTypeName(m_wxlBindEvent ? *m_wxlBindEvent->wxluatype : WXLUA_TUNKNOWN).c_str());
}
Esempio n. 7
0
void wxGenericFileDirButton::OnButtonClick(wxCommandEvent& WXUNUSED(ev))
{
    wxScopedPtr<wxDialog> p(CreateDialog());
    if (p->ShowModal() == wxID_OK)
    {
        // save updated path in m_path
        UpdatePathFromDialog(p.get());

        // fire an event
        wxFileDirPickerEvent event(GetEventType(), this, GetId(), m_path);
        GetEventHandler()->ProcessEvent(event);
    }
}
Esempio n. 8
0
BYTE CPythonNonPlayer::GetEventTypeByVID(DWORD dwVID)
{
	CInstanceBase * pInstance = CPythonCharacterManager::Instance().GetInstancePtr(dwVID);

	if (NULL == pInstance)
	{
		//Tracef("CPythonNonPlayer::GetEventTypeByVID - There is no Virtual Number\n");
		return ON_CLICK_EVENT_NONE;
	}

	WORD dwVnum = pInstance->GetVirtualNumber();
	return GetEventType(dwVnum);
}
 // /////////////////////////////////////////////////////////////////
 //
 // /////////////////////////////////////////////////////////////////
 LuaPlus::LuaObject ListButtonControl::VGetLuaData()
 {
     LuaPlus::LuaObject table;
     table.AssignNewTable(g_appPtr->GetLuaStateManager()->GetGlobalState().Get());
     if(m_list.empty()) {
         table.SetString("Text", "");
     } else {
         table.SetString("Text", (*m_curr).c_str());
     }
     table.SetInteger("ScreenElementId", VGetId());
     table.SetInteger("EventTypeId", GetEventType());
     return (table);
 }
Esempio n. 10
0
bool csKeyEventHelper::GetEventData (const iEvent* event, 
				     csKeyEventData& data)
{
  // if (!CS_IS_KEYBOARD_EVENT (*event)) return false; // Need an iObjectRegistry* to do this...

  data.autoRepeat = GetAutoRepeat (event);
  data.charType = GetCharacterType (event);
  data.codeCooked = GetCookedCode (event);
  data.codeRaw = GetRawCode (event);
  data.eventType = GetEventType (event);
  GetModifiers (event, data.modifiers);

  return true;
}
Esempio n. 11
0
bool wxFileDirPickerCtrlBase::CreateBase(wxWindow *parent,
                                         wxWindowID id,
                                         const wxString &path,
                                         const wxString &message,
                                         const wxString &wildcard,
                                         const wxPoint &pos,
                                         const wxSize &size,
                                         long style,
                                         const wxValidator& validator,
                                         const wxString &name )
{
    wxASSERT_MSG(path.empty() || CheckPath(path), wxT("Invalid initial path!"));

    if (!wxPickerBase::CreateBase(parent, id, path, pos, size,
                                   style, validator, name))
        return false;

    if (!HasFlag(wxFLP_OPEN) && !HasFlag(wxFLP_SAVE))
        m_windowStyle |= wxFLP_OPEN;     // wxFD_OPEN is the default

    // check that the styles are not contradictory
    wxASSERT_MSG( !(HasFlag(wxFLP_SAVE) && HasFlag(wxFLP_OPEN)),
                  _T("can't specify both wxFLP_SAVE and wxFLP_OPEN at once") );

    wxASSERT_MSG( !HasFlag(wxFLP_SAVE) || !HasFlag(wxFLP_FILE_MUST_EXIST),
                   _T("wxFLP_FILE_MUST_EXIST can't be used with wxFLP_SAVE" ) );

    wxASSERT_MSG( !HasFlag(wxFLP_OPEN) || !HasFlag(wxFLP_OVERWRITE_PROMPT),
                  _T("wxFLP_OVERWRITE_PROMPT can't be used with wxFLP_OPEN") );

    // create a wxFilePickerWidget or a wxDirPickerWidget...
    m_pickerIface = CreatePicker(this, path, message, wildcard);
    if ( !m_pickerIface )
        return false;
    m_picker = m_pickerIface->AsControl();

    // complete sizer creation
    wxPickerBase::PostCreation();

    m_picker->Connect(GetEventType(),
            wxFileDirPickerEventHandler(wxFileDirPickerCtrlBase::OnFileDirChange),
            NULL, this);

    // default's wxPickerBase textctrl limit is too small for this control:
    // make it bigger
    if (m_text) m_text->SetMaxLength(512);

    return true;
}
	void EventComponent::AddEvent(shared_ptr<Event> event)
	{
		if (event->GetEventType() != EVT_MOVE)
			mEventList[event->GetEventType()].push_back(event);
		else // Unpack move events.
		{
			auto mov = static_pointer_cast<MoveEvent>(event);
			auto mxe = make_shared<MoveXEvent>();
			auto mye = make_shared<MoveYEvent>();
			
			mxe->SetTime(event->GetTime());
			mye->SetTime(event->GetTime());
			mxe->SetEndTime(event->GetEndTime());
			mye->SetEndTime(event->GetEndTime());

			mxe->SetValue(mov->GetValue().x);
			mye->SetValue(mov->GetValue().y);
			mxe->SetEndValue(mov->GetEndValue().x);
			mye->SetEndValue(mov->GetEndValue().y);

			mEventList[mxe->GetEventType()].push_back(mxe);
			mEventList[mye->GetEventType()].push_back(mye);
		}
	}
Esempio n. 13
0
bool Lex::Run(const char * fileName) {
    std::ifstream fileP(fileName);
    Trastition trans = {State_start, State_start, Event_space};
    std::string buffer = "";
    char current;

    CreateTable();

    while(!fileP.eof()){
        fileP.get(current);
        buffer += current;

        trans.currentEvent = GetEventType(current);
        trans.prevState = trans.currentState;
        trans.currentState = tableTransition[trans.currentEvent][trans.currentState];

        // Ошибка
        if(trans.currentState == State_error)
        {
            console->LogError("Лексический анализатор", "Cчитан неизвестный символ");
            exit(1);
        }


        // Создание токена
        if(trans.currentState == State_createToken)
        {
            buffer.erase(buffer.length() - 1);
            AddTokenToList(buffer, GetTokenByState(trans.prevState));
            trans = {State_start, State_start, Event_space};
            buffer.clear();
        }

    }

    if(trans.currentState == State_createToken)
    {
        AddTokenToList(buffer, GetTokenByState(trans.prevState));
        trans = {State_start, State_start, Event_space};
        buffer.clear();
    }

    LogTokenList();
    fileP.close();
    return  true;
}
Esempio n. 14
0
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, "");
}
Esempio n. 15
0
void CDataCeneter::GetRegTbl(BYTE bOperation, LPVOID VarData)
{
	if (bOperation == GET_DDNS_INFO)
	{
		GetDDNSInfo(bOperation, VarData);
	}
	else if (bOperation >= GET_INTER_EVENT && bOperation <= GET_ALL_EVENT_BLACK) 
	{
		GetEventType(bOperation, VarData);
	}
	else if (bOperation >= GET_MAIL_SERVER && bOperation <= GET_MAIL_SERVER) 
	{
		GetMailServer(bOperation, VarData);
	}
	else if (bOperation >= GET_RECORD_PATH && bOperation <= GET_RECORD_PATH) 
	{
		GetRecordPath(bOperation, VarData);
	}
}
Esempio n. 16
0
void
nsXBLPrototypeHandler::ConstructPrototype(nsIContent* aKeyElement, 
                                          const PRUnichar* aEvent,
                                          const PRUnichar* aPhase,
                                          const PRUnichar* aAction,
                                          const PRUnichar* aCommand,
                                          const PRUnichar* aKeyCode,
                                          const PRUnichar* aCharCode,
                                          const PRUnichar* aModifiers,
                                          const PRUnichar* aButton,
                                          const PRUnichar* aClickCount,
                                          const PRUnichar* aGroup,
                                          const PRUnichar* aPreventDefault,
                                          const PRUnichar* aAllowUntrusted)
{
  mType = 0;

  if (aKeyElement) {
    mType |= NS_HANDLER_TYPE_XUL;
    nsCOMPtr<nsIWeakReference> weak = do_GetWeakReference(aKeyElement);
    if (!weak) {
      return;
    }
    weak.swap(mHandlerElement);
  }
  else {
    mType |= aCommand ? NS_HANDLER_TYPE_XBL_COMMAND : NS_HANDLER_TYPE_XBL_JS;
    mHandlerText = nsnull;
  }

  mDetail = -1;
  mMisc = 0;
  mKeyMask = 0;
  mPhase = NS_PHASE_BUBBLING;

  if (aAction)
    mHandlerText = ToNewUnicode(nsDependentString(aAction));
  else if (aCommand)
    mHandlerText = ToNewUnicode(nsDependentString(aCommand));

  nsAutoString event(aEvent);
  if (event.IsEmpty()) {
    if (mType & NS_HANDLER_TYPE_XUL)
      GetEventType(event);
    if (event.IsEmpty())
      return;
  }

  mEventName = do_GetAtom(event);

  if (aPhase) {
    const nsDependentString phase(aPhase);
    if (phase.EqualsLiteral("capturing"))
      mPhase = NS_PHASE_CAPTURING;
    else if (phase.EqualsLiteral("target"))
      mPhase = NS_PHASE_TARGET;
  }

  // Button and clickcount apply only to XBL handlers and don't apply to XUL key
  // handlers.  
  if (aButton && *aButton)
    mDetail = *aButton - '0';

  if (aClickCount && *aClickCount)
    mMisc = *aClickCount - '0';

  // Modifiers are supported by both types of handlers (XUL and XBL).  
  nsAutoString modifiers(aModifiers);
  if (mType & NS_HANDLER_TYPE_XUL)
    aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::modifiers, modifiers);
  
  if (!modifiers.IsEmpty()) {
    mKeyMask = cAllModifiers;
    char* str = ToNewCString(modifiers);
    char* newStr;
    char* token = nsCRT::strtok( str, ", \t", &newStr );
    while( token != NULL ) {
      if (PL_strcmp(token, "shift") == 0)
        mKeyMask |= cShift | cShiftMask;
      else if (PL_strcmp(token, "alt") == 0)
        mKeyMask |= cAlt | cAltMask;
      else if (PL_strcmp(token, "meta") == 0)
        mKeyMask |= cMeta | cMetaMask;
      else if (PL_strcmp(token, "control") == 0)
        mKeyMask |= cControl | cControlMask;
      else if (PL_strcmp(token, "accel") == 0)
        mKeyMask |= KeyToMask(kAccelKey);
      else if (PL_strcmp(token, "access") == 0)
        mKeyMask |= KeyToMask(kMenuAccessKey);
      else if (PL_strcmp(token, "any") == 0)
        mKeyMask &= ~(mKeyMask << 4);
    
      token = nsCRT::strtok( newStr, ", \t", &newStr );
    }

    nsMemory::Free(str);
  }

  nsAutoString key(aCharCode);
  if (key.IsEmpty()) {
    if (mType & NS_HANDLER_TYPE_XUL) {
      aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::key, key);
      if (key.IsEmpty()) 
        aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::charcode, key);
    }
  }

  if (!key.IsEmpty()) {
    if (mKeyMask == 0)
      mKeyMask = cAllModifiers;
    ToLowerCase(key);

    // We have a charcode.
    mMisc = 1;
    mDetail = key[0];
    const PRUint8 GTK2Modifiers = cShift | cControl | cShiftMask | cControlMask;
    if ((mKeyMask & GTK2Modifiers) == GTK2Modifiers &&
        modifiers.First() != PRUnichar(',') &&
        (mDetail == 'u' || mDetail == 'U'))
      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "GTK2Conflict");
    const PRUint8 WinModifiers = cControl | cAlt | cControlMask | cAltMask;
    if ((mKeyMask & WinModifiers) == WinModifiers &&
        modifiers.First() != PRUnichar(',') &&
        (('A' <= mDetail && mDetail <= 'Z') ||
         ('a' <= mDetail && mDetail <= 'z')))
      ReportKeyConflict(key.get(), modifiers.get(), aKeyElement, "WinConflict");
  }
  else {
    key.Assign(aKeyCode);
    if (mType & NS_HANDLER_TYPE_XUL)
      aKeyElement->GetAttr(kNameSpaceID_None, nsGkAtoms::keycode, key);
    
    if (!key.IsEmpty()) {
      if (mKeyMask == 0)
        mKeyMask = cAllModifiers;
      mDetail = GetMatchingKeyCode(key);
    }
  }

  if (aGroup && nsDependentString(aGroup).EqualsLiteral("system"))
    mType |= NS_HANDLER_TYPE_SYSTEM;

  if (aPreventDefault &&
      nsDependentString(aPreventDefault).EqualsLiteral("true"))
    mType |= NS_HANDLER_TYPE_PREVENTDEFAULT;

  if (aAllowUntrusted) {
    mType |= NS_HANDLER_HAS_ALLOW_UNTRUSTED_ATTR;
    if (nsDependentString(aAllowUntrusted).EqualsLiteral("true")) {
      mType |= NS_HANDLER_ALLOW_UNTRUSTED;
    } else {
      mType &= ~NS_HANDLER_ALLOW_UNTRUSTED;
    }
  }
}
Esempio n. 17
0
DWORD CSerialEx::ThreadProc (void)
{
	// Use overlapped structure
	LPOVERLAPPED lpOverlapped = 0;

	// Keep looping
	do
	{
#ifndef SERIAL_NO_OVERLAPPED
		// Reset the event handle
		::ResetEvent(m_hevtOverlappedWorkerThread);

		// Initialize the overlapped structure
		OVERLAPPED ovInternal = {0};
		ovInternal.hEvent = m_hevtOverlappedWorkerThread;

		// Start the WaitEvent (use our own overlapped structure)
		if (WaitEvent(&ovInternal) != ERROR_SUCCESS)
			return m_lLastError;

		// Wait for the overlapped operation to complete
		if (::WaitForSingleObject(m_hevtOverlappedWorkerThread,INFINITE) != WAIT_OBJECT_0)
		{
			// Set the internal error code
			m_lLastError = ::GetLastError();

			// Issue an error and quit
			_RPTF0(_CRT_WARN,"CSerialEx::ThreadProc - Unable to wait until COM event has arrived\n");
			return m_lLastError;
		}
#else
		// Start the WaitEvent (don't need to specify an overlapped structure)
		if (WaitEvent() != ERROR_SUCCESS)
			return m_lLastError;
#endif

		// Wait until one of the events happens
		if (!m_fStopping)
		{
			// Determine the event
			EEvent eEvent = GetEventType();

			// Obtain the error status during this event
			DWORD dwErrors = 0;
			if (!::ClearCommError(m_hFile,&dwErrors,0))
			{
				// Set the internal error code
				m_lLastError = ::GetLastError();

				// Issue an error and quit
				_RPTF0(_CRT_WARN, "CSerialEx::ThreadProc - Unable to obtain COM status\n");
			}

			// Convert the error
			EError eError = EError(dwErrors);

			// There was a COMM event, which needs handling. We'll call the
			// event handler. We can receive a "zero" event, when the
			// mask or event character has been set. We won't pass this
			// down to the window.
			if (eEvent)
				OnEvent(eEvent,eError);
		}
	}
	while (!m_fStopping);

	// Bye bye
	return 0;
}
Esempio n. 18
0
BOOL
QueryEventMessages(LPWSTR lpMachineName,
                   LPWSTR lpLogName)
{
    HWND hwndDlg = NULL;
    HANDLE hEventLog;
    EVENTLOGRECORD *pevlr;
    DWORD dwRead, dwNeeded, dwThisRecord, dwTotalRecords = 0, dwCurrentRecord = 0, dwRecordsToRead = 0, dwFlags, dwMaxLength;
    size_t cchRemaining;
    LPWSTR lpSourceName;
    LPWSTR lpComputerName;
    LPSTR lpData;
    BOOL bResult = TRUE; /* Read succeeded. */

    WCHAR szWindowTitle[MAX_PATH];
    WCHAR szStatusText[MAX_PATH];
    WCHAR szLocalDate[MAX_PATH];
    WCHAR szLocalTime[MAX_PATH];
    WCHAR szEventID[MAX_PATH];
    WCHAR szEventTypeText[MAX_LOADSTRING];
    WCHAR szCategoryID[MAX_PATH];
    WCHAR szUsername[MAX_PATH];
    WCHAR szEventText[EVENT_MESSAGE_FILE_BUFFER];
    WCHAR szCategory[MAX_PATH];
    WCHAR szData[MAX_PATH];
    PWCHAR lpTitleTemplateEnd;

    SYSTEMTIME time;
    LVITEMW lviEventItem;

    dwFlags = EVENTLOG_FORWARDS_READ | EVENTLOG_SEQUENTIAL_READ;

    /* Open the event log. */
    hEventLog = OpenEventLogW(lpMachineName,
                             lpLogName);
    if (hEventLog == NULL)
    {
        ShowLastWin32Error();
        return FALSE;
    }

    lpSourceLogName = lpLogName;
    lpComputerName = lpMachineName;

    /* Disable listview redraw */
    SendMessage(hwndListView, WM_SETREDRAW, FALSE, 0);

    /* Clear the list view */
    (void)ListView_DeleteAllItems (hwndListView);
    FreeRecords();

    GetOldestEventLogRecord(hEventLog, &dwThisRecord);

    /* Get the total number of event log records. */
    GetNumberOfEventLogRecords (hEventLog , &dwTotalRecords);
    g_TotalRecords = dwTotalRecords;

    if (dwTotalRecords > 0)
    {
        EnableMenuItem(hMainMenu, IDM_CLEAR_EVENTS, MF_BYCOMMAND | MF_ENABLED);
        EnableMenuItem(hMainMenu, IDM_SAVE_PROTOCOL, MF_BYCOMMAND | MF_ENABLED);
    }
    else
    {
        EnableMenuItem(hMainMenu, IDM_CLEAR_EVENTS, MF_BYCOMMAND | MF_GRAYED);
        EnableMenuItem(hMainMenu, IDM_SAVE_PROTOCOL, MF_BYCOMMAND | MF_GRAYED);
    }

    g_RecordPtrs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwTotalRecords * sizeof(PVOID));

    /* If we have at least 1000 records show the waiting dialog */
    if (dwTotalRecords > 1000)
    {
        CloseHandle(CreateThread(NULL,
                                 0,
                                 ShowStatusMessageThread,
                                 (LPVOID)&hwndDlg,
                                 0,
                                 NULL));
    }

    while (dwCurrentRecord < dwTotalRecords)
    {
        pevlr = HeapAlloc(GetProcessHeap(), 0, sizeof(EVENTLOGRECORD));
        g_RecordPtrs[dwCurrentRecord] = pevlr;

        bResult = ReadEventLog(hEventLog,  // Event log handle
                               dwFlags,    // Sequential read
                               0,          // Ignored for sequential read
                               pevlr,      // Pointer to buffer
                               sizeof(EVENTLOGRECORD),   // Size of buffer
                               &dwRead,    // Number of bytes read
                               &dwNeeded); // Bytes in the next record
        if((!bResult) && (GetLastError () == ERROR_INSUFFICIENT_BUFFER))
        {
            HeapFree(GetProcessHeap(), 0, pevlr);
            pevlr = HeapAlloc(GetProcessHeap(), 0, dwNeeded);
            g_RecordPtrs[dwCurrentRecord] = pevlr;

            ReadEventLogW(hEventLog,  // event log handle
                         dwFlags,    // read flags
                         0,          // offset; default is 0
                         pevlr,      // pointer to buffer
                         dwNeeded,   // size of buffer
                         &dwRead,    // number of bytes read
                         &dwNeeded); // bytes in next record
        }

        while (dwRead > 0)
        {
            LoadStringW(hInst, IDS_NOT_AVAILABLE, szUsername, MAX_PATH);
            LoadStringW(hInst, IDS_NOT_AVAILABLE, szEventText, MAX_PATH);
            LoadStringW(hInst, IDS_NONE, szCategory, MAX_PATH);

            // Get the event source name.
            lpSourceName = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD));

            // Get the computer name
            lpComputerName = (LPWSTR)((LPBYTE)pevlr + sizeof(EVENTLOGRECORD) + (wcslen(lpSourceName) + 1) * sizeof(WCHAR));

            // This ist the data section of the current event
            lpData = (LPSTR)((LPBYTE)pevlr + pevlr->DataOffset);

            // Compute the event type
            EventTimeToSystemTime(pevlr->TimeWritten, &time);

            // Get the username that generated the event
            GetEventUserName(pevlr, szUsername);

            GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &time, NULL, szLocalDate, MAX_PATH);
            GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &time, NULL, szLocalTime, MAX_PATH);

            GetEventType(pevlr->EventType, szEventTypeText);
            GetEventCategory(lpLogName, lpSourceName, pevlr, szCategory);

            StringCbPrintfW(szEventID, sizeof(szEventID), L"%u", (pevlr->EventID & 0xFFFF));
            StringCbPrintfW(szCategoryID, sizeof(szCategoryID), L"%u", pevlr->EventCategory);

            lviEventItem.mask = LVIF_IMAGE | LVIF_TEXT | LVIF_PARAM;
            lviEventItem.iItem = 0;
            lviEventItem.iSubItem = 0;
            lviEventItem.lParam = (LPARAM)pevlr;
            lviEventItem.pszText = szEventTypeText;

            switch (pevlr->EventType)
            {
                case EVENTLOG_ERROR_TYPE:
                    lviEventItem.iImage = 2;
                    break;

                case EVENTLOG_AUDIT_FAILURE:
                    lviEventItem.iImage = 2;
                    break;

                case EVENTLOG_WARNING_TYPE:
                    lviEventItem.iImage = 1;
                    break;

                case EVENTLOG_INFORMATION_TYPE:
                    lviEventItem.iImage = 0;
                    break;

                case EVENTLOG_AUDIT_SUCCESS:
                    lviEventItem.iImage = 0;
                    break;

                case EVENTLOG_SUCCESS:
                    lviEventItem.iImage = 0;
                    break;
            }

            lviEventItem.iItem = ListView_InsertItem(hwndListView, &lviEventItem);

            ListView_SetItemText(hwndListView, lviEventItem.iItem, 1, szLocalDate);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 2, szLocalTime);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 3, lpSourceName);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 4, szCategory);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 5, szEventID);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 6, szUsername); //User
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 7, lpComputerName); //Computer
            MultiByteToWideChar(CP_ACP,
                                0,
                                lpData,
                                pevlr->DataLength,
                                szData,
                                MAX_PATH);
            ListView_SetItemText(hwndListView, lviEventItem.iItem, 8, szData); //Event Text

            dwRead -= pevlr->Length;
            pevlr = (EVENTLOGRECORD *)((LPBYTE) pevlr + pevlr->Length);
        }

        dwRecordsToRead--;
        dwCurrentRecord++;
    }

    // All events loaded
    if(hwndDlg)
        EndDialog(hwndDlg, 0);

    StringCchPrintfExW(szWindowTitle,
                       sizeof(szWindowTitle) / sizeof(WCHAR),
                       &lpTitleTemplateEnd,
                       &cchRemaining,
                       0,
                       szTitleTemplate, szTitle, lpLogName); /* i = number of characters written */
    /* lpComputerName can be NULL here if no records was read */
    dwMaxLength = (DWORD)cchRemaining;
    if (!lpComputerName)
        GetComputerNameW(lpTitleTemplateEnd, &dwMaxLength);
    else
        StringCchCopyW(lpTitleTemplateEnd, dwMaxLength, lpComputerName);

    StringCbPrintfW(szStatusText, sizeof(szStatusText), szStatusBarTemplate, lpLogName, dwTotalRecords);

    // Update the status bar
    SendMessageW(hwndStatus, SB_SETTEXT, (WPARAM)0, (LPARAM)szStatusText);

    // Set the window title
    SetWindowTextW(hwndMainWindow, szWindowTitle);

    // Resume list view redraw
    SendMessageW(hwndListView, WM_SETREDRAW, TRUE, 0);

    // Close the event log.
    CloseEventLog(hEventLog);

    return TRUE;
}
Esempio n. 19
0
 virtual wxEvent *Clone() const { return new wxTestEvent(GetEventType()); }
Esempio n. 20
0
void Reaction::React(NPC *who, Perception *pcpt)
{
    CS_ASSERT(who);

    // Check if the perception is a match for this reaction
    if (!pcpt->ShouldReact(this,who))
    {
        if (who->IsDebugging(20))
        {
            who->Printf(20, "Reaction '%s' skipping perception %s", GetEventType(), pcpt->ToString().GetDataSafe());
        }
        return;
    }

    // If dead we should not react unless reactWhenDead is set
    if (!(who->IsAlive() || reactWhenDead))
    {
        who->Printf(5, "Only react to '%s' when alive", GetEventType());
        return;
    }

    // Check if the active behavior should not be interrupted.
    if (who->GetCurrentBehavior() && DoNotInterrupt(who->GetCurrentBehavior()))
    {
        who->Printf(5,"Prevented from reacting to '%s' while not interrupt behavior '%s' is active",
                    GetEventType(),who->GetCurrentBehavior()->GetName());
        return; 
    } 

    // Check if this reaction is limited to only interrupt some given behaviors.
    if (who->GetCurrentBehavior() && OnlyInterrupt(who->GetCurrentBehavior()))
    {
        who->Printf(5,"Prevented from reacting to '%s' since behavior '%s' should not be interrupted",
                    GetEventType(),who->GetCurrentBehavior()->GetName());
        return; 
    } 



    // We should no react and triggerd all affected behaviors

    // For debug get the time this reaction was triggered
    GetTimeOfDay(lastTriggered);


    // Adjust the needs for the triggerd behaviors
    for (size_t i = 0; i < affected.GetSize(); i++)
    {

        // When activeOnly flag is set we should do nothing
        // if the affected behaviour is inactive.
        if (activeOnly && !affected[i]->IsActive() )
            break;
        
        // When inactiveOnly flag is set we should do nothing
        // if the affected behaviour is active.
        if (inactiveOnly && affected[i]->IsActive() )
            break;


        who->Printf(2, "Reaction '%s' reacting to perception %s", GetEventType(), pcpt->ToString().GetDataSafe());
        switch (desireType)
        {
        case DESIRE_NONE:
            who->Printf(10, "No change to need for behavior %s.", affected[i]->GetName());
            break;
        case DESIRE_ABSOLUTE:
            who->Printf(10, "Setting %1.1f need to behavior %s", desireValue, affected[i]->GetName());
            affected[i]->ApplyNeedAbsolute(who, desireValue);
            break;
        case DESIRE_DELTA:
            who->Printf(10, "Adding %1.1f need to behavior %s", desireValue, affected[i]->GetName());
            affected[i]->ApplyNeedDelta(who, desireValue);
            break;
        case DESIRE_GUARANTIED:
            who->Printf(10, "Guarantied need to behavior %s", affected[i]->GetName());
            
            float highest = 0;
            if (who->GetCurrentBehavior())
            {
                highest = who->GetCurrentBehavior()->CurrentNeed();
            }
            if (who->GetCurrentBehavior() != affected[i])
            {
                affected[i]->ApplyNeedAbsolute(who, highest + 25);
                affected[i]->SetCompletionDecay(-1);
            }
            break;
        }
    }
    
    // Execute the perception
    pcpt->ExecutePerception(who,weight);

    Perception *p = pcpt->MakeCopy();
    who->SetLastPerception(p);

}
Esempio n. 21
0
//~~ std::map<wxString, wxString> GetVirtualOperations() [AdeStatechart] ~~

std::map<wxString, wxString> retVal;

wxString event = GetEventType() + wxS("&");
wxString coder = GetCoderSuffix();
if (coder == wxS("C"))
	event = wxS("const ") + event;
else if (coder.StartsWith(wxS("ACF")))
	event = wxS("ACF_Message*");
else if (coder == wxS("VSM"))
	event = wxS("CMessage&");
else if (coder == wxS("Wx"))
	event = wxS("wxEvent&");

std::set<wxString> aSet = GetActions();
for (std::set<wxString>::iterator it = aSet.begin(); it != aSet.end(); ++it)
{
	wxString op = *it;
	op += wxS("(") + event + wxS(")");
	retVal[op] = wxS("void");
}
aSet = GetGuards();
for (std::set<wxString>::iterator it = aSet.begin(); it != aSet.end(); ++it)
{
	wxString op = *it;
	op += wxS("(") + event + wxS(")");
	retVal[op] = wxS("bool");
}

return retVal;
EXPORT_C void CTestUtils::DisplayLogL(const CLogFilter& aFilter, TBool aForward)
	{
	TBuf<256> header;
	TBuf<256> txt;
	TBuf<64> temp;

	CLogClient* client = CLogClient::NewL(iFs);
	CleanupStack::PushL(client);

	CLogViewEvent* eventView = CLogViewEvent::NewL(*client);
	CleanupStack::PushL(eventView);

	CTestActive* testAct = new (ELeave) CTestActive();
	CleanupStack::PushL(testAct);

	TBool found = eventView->SetFilterL(aFilter, testAct->iStatus);

	if (found)
		{
		testAct->StartL();
		CActiveScheduler::Start();	
		}

	if (!CheckLogStatus(found, testAct->iStatus))
		{
		CleanupStack::PopAndDestroy(3);
		return;
		}

	TInt totalCount = eventView->CountL();

	txt.Zero();
	txt.Append(_L("Total Log Events: "));
	temp.Num(totalCount);
	txt.Append(temp);
	AppendEol(txt, EFalse);
	Printf(txt);

	const TInt numLen		= 3;
	const TInt timeLen		= 11;
	const TInt dateLen		= 10;
	const TInt statusLen	= 7;
	const TInt subjLen		= 20;
	const TInt dirLen		= 3;
	const TInt typeLen		= 10;

	header.Zero();
	AppendText(_L("Num"), header, numLen);
	header.Append('|');
	AppendText(_L("Date"), header, dateLen);
	header.Append('|');
	AppendText(_L("Time"), header, timeLen);
	header.Append('|');
	AppendText(_L("Status"), header, statusLen);
	header.Append('|');
	AppendText(_L("Subject"), header, subjLen);
	header.Append('|');
	AppendText(_L("Dir"), header, dirLen);
	header.Append('|');
	AppendText(_L("Type"), header, typeLen);

	AppendEol(header, EFalse);
	Printf(header);

	found = aForward ? eventView->FirstL(testAct->iStatus) : eventView->LastL(testAct->iStatus);

	if (found)
		{
		testAct->StartL();
		CActiveScheduler::Start();	
		}

	if (!CheckLogStatus(found, testAct->iStatus))
		{
		CleanupStack::PopAndDestroy(3);
		return;
		}

	TInt counter = 0;
	do
		{
		const CLogEvent& event = eventView->Event();
		counter++;
		if (!RunAuto() && (counter % 6 == 0))
			{
			iRTest.Printf(_L("\nPress any key for more...\n"));
			iRTest.Getch();
			Printf(header);
			}

		txt.Zero();

		if (aForward)
			{
			temp.Num(totalCount - counter + 1);
			}
		else
			{
			temp.Num(counter);
			}

		AppendText(temp, txt, numLen);
		txt.Append('|');

		event.Time().FormatL(temp, _L("%D%M%Y%/0%1%/1%2%/2%3%/3"));
		AppendText(temp, txt, dateLen);
		txt.Append('|');

	    event.Time().FormatL(temp,_L("%-B%:0%J%:1%T%:2%S%:3%+B"));
		AppendText(temp, txt, timeLen);
		txt.Append('|');

		AppendText(event.Status(), txt, statusLen);
		txt.Append('|');
		AppendText(event.Subject(), txt, subjLen);
		txt.Append('|');
		AppendText(event.Direction(), txt, dirLen);
		txt.Append('|');

		GetEventType(event.EventType(), temp);
		AppendText(temp, txt, typeLen);

		AppendEol(txt, EFalse);
		Printf(txt);

		DisplayLogEventData(event);

		found = aForward ? eventView->NextL(testAct->iStatus) : eventView->PreviousL(testAct->iStatus);

		if (found)
			{
			testAct->StartL();
			CActiveScheduler::Start();	
			}

		if (!CheckLogStatus(found, testAct->iStatus))
			{
			CleanupStack::PopAndDestroy(3);
			return;
			}
		}
	while (found);

	CleanupStack::PopAndDestroy(3);
	}
shared_ptr<osb::SpriteList> ReadOSBEvents(std::istream& event_str)
{
	auto list = make_shared<osb::SpriteList>();
	int previous_lead = 100;
	shared_ptr<osb::BGASprite> sprite = nullptr;
	shared_ptr<osb::Loop> loop = nullptr;
	bool readingLoop = false;

	GString line;
	while (std::getline(event_str, line))
	{
		int lead_spaces;
		line = line.substr(line.find("//")); // strip comments
		lead_spaces = line.find_first_not_of("\t _");
		line = line.substr(lead_spaces, line.length() - lead_spaces + 1);

		vector<GString> split_result;
		boost::split(split_result, line, boost::is_any_of(","));
		for (auto &&s : split_result) boost::algorithm::to_lower(s);

		if (!line.length() || !split_result.size()) continue;

		if (lead_spaces < previous_lead && !readingLoop)
		{
			if (split_result[0] == "sprite")
			{
				Vec2 new_position(latof(split_result[3]), latof(split_result[4]));
				sprite = make_shared<osb::BGASprite>(split_result[1], OriginFromString(split_result[2]), new_position);
				list->push_back(sprite);
			}
		} else {
			if (!sprite)
				throw std::runtime_error("OSB command unpaired with sprite.");

			// If it's a loop, check if we're out of it.
			// If we're out of it, read a regular event, otherwise, read an event to the loop
			if (readingLoop)
			{
				if (lead_spaces < previous_lead) {
					readingLoop = false;

					// We're done reading the loop - unroll it.
					auto loop_events = loop->Unroll();
					for (auto i = 0; i < osb::EVT_COUNT; i++)
						for (auto evt : (*loop_events)[i])
							sprite->AddEvent(evt);
				}
				else
					loop->AddEvent(ParseEvent(split_result));
			}
			
			// It's not a command on the loop, or we weren't reading a loop in the first place.
			// Read a regular command.

			// Not "else" because we do want to execute this if we're no longer reading the loop.
			if (!readingLoop) {
				auto ev = ParseEvent(split_result);

				// A loop began - set that we are reading a loop and set this loop as where to add the following commands.
				if (ev->GetEventType() == osb::EVT_LOOP)
				{
					loop = static_pointer_cast<osb::Loop>(ev);
					readingLoop = true;
				}else // add this event, if not a loop to this sprite. It'll be unrolled once outside.
					sprite->AddEvent(ev);
			}
		}

		previous_lead = lead_spaces;
	}

	return list;
}