Exemplo n.º 1
0
void Yodar_4028B::DoHandleWork()
{
	if(m_nReadIndex == m_nWriteIndex)
	{
		return ;
	}

	if(m_nReadIndex > m_nWriteIndex)
	{
		while(m_nReadIndex < MAX_DATA_COUNT && m_bRun)
		{
			HandleMessage( & m_data[m_nReadIndex]);
			memset((char *) m_data[m_nReadIndex].data, 0, MAX_DATA_LENGTH);
			m_data[m_nReadIndex].len = 0;
			
			m_nReadIndex++;
			if(m_nReadIndex >= MAX_DATA_COUNT)
			{
				m_nReadIndex = 0;
				break;
			}
		}
	}

	while(m_nReadIndex < m_nWriteIndex && m_bRun)
	{
		HandleMessage(&m_data[m_nReadIndex]);
		memset((char *) m_data[m_nReadIndex].data, 0, MAX_DATA_LENGTH);
		m_data[m_nReadIndex].len = 0;
		m_nReadIndex++;
	}
}
Exemplo n.º 2
0
//
/// Intercepts the WM_MDICREATE message sent when MDI child windows are created,
/// and, if the client's style includes MDIS_ALLCHILDSTYLES, and the child window's
/// specified style is 0, then changes the child window style attributes to
/// WS_VISIBLE, WS_CHILD, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_SYSMENU, WS_CAPTION,
/// WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX.
//
TResult
TMDIClient::EvMDICreate(MDICREATESTRUCT & createStruct)
{
  // Fill in default child window styles if they request style 0 since this
  // client by default has set allchildstyles
  //
  if ((Attr.Style&MDIS_ALLCHILDSTYLES) && !createStruct.style)
    createStruct.style =
               WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
               WS_SYSMENU | WS_CAPTION | WS_THICKFRAME |
               WS_MINIMIZEBOX | WS_MAXIMIZEBOX;

  // Work around a Windows MDI bug w/ bad menus if MDI child is created
  // maximized, by hiding child now & maximizing later
  //
  uint32 origStyle = createStruct.style;
  if (createStruct.style & WS_MAXIMIZE)
    createStruct.style &= ~(WS_MAXIMIZE | WS_VISIBLE);

  TResult result = DefaultProcessing();

  // Finish up maximized MDI child workaround
  //
  if (THandle(result) && (origStyle & WS_MAXIMIZE)) {
    HandleMessage(WM_MDIMAXIMIZE, TParam1(result));
    HandleMessage(WM_MDIREFRESHMENU);
  }

  return result;
}
Exemplo n.º 3
0
MRESULT EXPENTRY POPUPDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  HWND hwndFrame = hwndDlg;
 /* ##START Form.37 Top of window procedure */
 /* ##END Top of window procedure */
   switch (msg) {
   /* Form event Opened WM_INITDLG */
   case WM_INITDLG :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      WinAssociateHelpInstance(pMainFormInfo->hwndHelpInstance, hwndFrame);

      /* ##START Form.1  */
      /* ##END  */
      break;

   /* Form event Closed WM_CLOSE */
   case WM_CLOSE :
      /* ##START Form.2  */
      /* ##END  */
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   /* Form event Destroyed WM_DESTROY */
   case WM_DESTROY :
      /* ##START Form.3  */
      /* ##END  */
     /* Remove help instance */
     WinAssociateHelpInstance((HWND) 0, hwndFrame);
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
      break;

   case WM_COMMAND :
      switch (SHORT1FROMMP(mp1)) {
      } /* end switch */
      break;

  /* Initialize sub menus, if any */
  case WM_INITMENU:
     switch (SHORT1FROMMP(mp1)) {
     } /* end switch */
  break;
 /* ##START Form.38 User defined messages */
 /* ##END User defined messages */
   default :
     HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2);
     return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
   } /* end switch for main msg dispatch */
   return (MRESULT)FALSE;
} /* end dialog procedure */
Exemplo n.º 4
0
void* establishConnection(void* arg) 
{
    //Мы работаем с конкретным соединением
    int incomeSd = *((int*)arg);
            
    int userID = FindCell();

    MessageType *buf = (MessageType*) malloc (sizeof(MessageType));
    int resultOfHandlingMessage = 1;

    while (resultOfHandlingMessage) 
    {
        if (server_enabled)
        {
            getMessage(incomeSd, buf);
            resultOfHandlingMessage = HandleMessage(buf, incomeSd, userID);
        }
        else
        {
            char *str = "Server is turned off...";
            MessageType m = composeMessage(text, strlen(str), str);
            sendMessage(incomeSd, &m);
        }
    }   
    
    free(buf);
    return NULL;
}
Exemplo n.º 5
0
int ProcessMessages(bf_read&msgs)
{

	int processed = 0;
	while (true)
	{
		if (msgs.IsOverflowed())
		{
			return processed;
		}



		unsigned char type = msgs.ReadUBitLong(NETMSG_TYPE_BITS);

		bool handled = HandleMessage(msgs, type);

		if (!handled)
		{
			printf("Unhandled Message: %i\n", type);
			return processed;
		}

		processed++;

		if (msgs.GetNumBitsLeft() < NETMSG_TYPE_BITS)
		{
			return processed;
		}
	}


	return processed;
}
Exemplo n.º 6
0
LRESULT CALLBACK AnimaMouseInteractor::MessageProcCallback(int nCode, WPARAM wParam, LPARAM lParam)
{
	MSG* pMessageProcStruct = reinterpret_cast<MSG*>(lParam);
	if (pMessageProcStruct == nullptr)
		return 0;

	auto pair = _installedInteractors.find((long)pMessageProcStruct->hwnd);
	if (pair == _installedInteractors.end())
		return 0;

	AnimaMouseInteractor* pMouseInteractor = pair->second;
	if (pMouseInteractor == nullptr)
		return 0;

	if (nCode == HC_ACTION)
	{
		HWND wndProcWnd = pMessageProcStruct->hwnd;
		AUint wndProcMessage = pMessageProcStruct->message;
		WPARAM wndProcWparam = pMessageProcStruct->wParam;
		WPARAM wndProcLparam = pMessageProcStruct->lParam;

		HandleMessage(wndProcWnd, wndProcMessage, wndProcWparam, wndProcLparam, pMouseInteractor);
	}

	return CallNextHookEx(pMouseInteractor->_windowsProcHook, nCode, wParam, lParam);
}
Exemplo n.º 7
0
void M0CORE_IRQHandler(void)
{
    // Clear event flag
    LPC_CREG->M0TXEVENT = 0x00000000;
    // Handle message
    HandleMessage();
}
Exemplo n.º 8
0
//
/// Use the Windows message to get the active mdi child, and then down cast
/// to our MDI child derived class before returning it.
//
TMDIChild*
TMDIClient::GetActiveMDIChild()
{
  THandle hWnd = THandle(HandleMessage(WM_MDIGETACTIVE));

  return TYPESAFE_DOWNCAST(GetWindowPtr(hWnd), TMDIChild);
}
Exemplo n.º 9
0
void CD3DScrollBar::SetScrollPos(int ScrollPos,bool SendMsg)
{
	m_CurScrollPos=ScrollPos;
	UpdateTrack();
	if(SendMsg)
		HandleMessage(this,WM_D3DGUI_SCROLL_BAR_SCROLL,(WPARAM)GetID(),m_CurScrollPos);
}
Exemplo n.º 10
0
    bool Client::Peek(EventMessage &msg)
    {
        message_queue* const mq = (message_queue*)this->privateQueue;

        // check local deque for message
        if(!this->storedMessages.empty())
        {
            // get first queued element and pop it
            msg = this->storedMessages.front();
            this->storedMessages.pop_front();
            return true;
        }

        std::stringbuf msgBuffer;

        char buff[MAX_MSG_SIZE];
        size_t recvd;
        unsigned int priority;

        if(mq->try_receive(buff, MAX_MSG_SIZE, recvd, priority))
        {
            msgBuffer.sputn(buff, recvd);
            msg.deserialize(msgBuffer);

            return HandleMessage(msg, priority);
        }
        else
            return false;
        return true;
    }
Exemplo n.º 11
0
/** A worker thread that handles messages from JavaScript.
 * @param[in] user_data Unused.
 * @return unused. */
void* HandleMessageThread(void* user_data) {
  while (1) {
    char* message = DequeueMessage();
    HandleMessage(message);
    free(message);
  }
}
Exemplo n.º 12
0
/*
 * GetMessageFilter - hook for get message
 */
LRESULT CALLBACK GetMessageFilter( int ncode, WPARAM wparam, LPARAM lparam )
{
    if( ncode >= 0 ) {
        HandleMessage( (LPMSG)lparam );
    }
    return( CallNextHookEx( getHookHandle, ncode, wparam, lparam ) );

} /* GetMessageFilter */
Exemplo n.º 13
0
		static void OnReceiveMessage(ZL_WebSocketConnection_Impl* impl, int32_t result)
		{
			//ZL_LOG("NACLWSC", "ONRECEIVE - WS: %d - RESULT: %d - READYSTATE: %d - BUFFER: %d", impl->websocket, result, (int32_t)ppb_websocket_interface->GetReadyState(impl->websocket), (int32_t)ppb_websocket_interface->GetBufferedAmount(impl->websocket));
			if (result < 0) { impl->Disconnect(PP_WEBSOCKETSTATUSCODE_ABNORMAL_CLOSURE, NULL, 0); return; }
			HandleMessage(impl);
			const PP_CompletionCallback cc = PP_MakeCompletionCallback((PP_CompletionCallback_Func)&OnReceiveMessage, (void*)impl);
			while (ppb_websocket_interface->ReceiveMessage(impl->websocket, &impl->data, cc) == PP_OK) HandleMessage(impl);
		}
Exemplo n.º 14
0
//
/// Intercepts the WM_MDIDESTROY message.
///
/// Destroy an MDI child window. Must temporarily unhide any hidden children,
/// and then rehide them after the destruction. Otherwise Window's MDI client
/// gets confused
//
void
TMDIClient::EvMDIDestroy(THandle THandle)
{
  ForEach(sUnHide, (void*)THandle);
  DefaultProcessing();
  ForEach(sReHide);
  HandleMessage(WM_MDIREFRESHMENU);
}
Exemplo n.º 15
0
int _0xCC::WindowManager::DoMessageLoop(){
	while (HandleMessage()) {
		for (auto v : wins) {
			v->RenderEvent();
		}
	}
	return 0;
}
Exemplo n.º 16
0
/**
 * A worker thread that handles messages from JavaScript.
 * @param[in] user_data Unused.
 * @return unused.
 */
void *HandleMessageThread(void *user_data)
{
    while ( 1 )
    {
        struct PP_Var message = DequeueMessage();
        HandleMessage(message);
        g_ppb_var->Release(message);
    }
}
Exemplo n.º 17
0
void tTVPApplication::Run() {
	TVPTerminateCode = 0;

	// メイン メッセージ ループ:
	while( windows_list_.size() > 0 && tarminate_ == false ) {
		HandleMessage();
	}
	tarminate_ = true;
}
Exemplo n.º 18
0
	bool PubSubManager::handleStanza (const QDomElement& elem)
	{
		if (elem.tagName () == "message")
			return HandleMessage (elem);
		else if (elem.tagName () == "iq")
			return HandleIq (elem);
		else
			return false;
	}
Exemplo n.º 19
0
int _0xCC::WindowManager::SingleMessageLoop(){
	if (HandleMessage()) {
		for (auto v : wins) {
			v->RenderEvent();
		}
		return 1;
	}
	return 0;
}
Exemplo n.º 20
0
void Server::UpdateRecv(){
	while (isServerRunning){
		if ((nbytes = recvfrom(sockfd, buf, MAXDATASIZE-1 , 0,
				(struct sockaddr *)&remoteaddr, &remoteaddrlen)) == -1) {
					return;
		}
		if (nbytes > 0){
			HandleMessage();
		}
	}
}
Exemplo n.º 21
0
void HumanClientApp::HandleSystemEvents() {
    SDLGUI::HandleSystemEvents();
    if (m_connected && !m_networking.Connected()) {
        m_connected = false;
        DisconnectedFromServer();
    } else if (m_networking.MessageAvailable()) {
        Message msg;
        m_networking.GetMessage(msg);
        HandleMessage(msg);
    }
}
Exemplo n.º 22
0
uintptr_t CPROC ProcessDisplayMessages( PTHREAD thread )
{
	XEvent event;
	struct display_camera *camera;
	INDEX idx;
	struct display_camera *did_one;
	LoadOptions(); // loads camera config, and logging options...
	SACK_Vidlib_OpenCameras();  // create logical camera structures
	l.bThreadRunning = 1;
	while( !l.bExitThread )
	{
		did_one = NULL;
		LIST_FORALL( l.cameras, idx, struct display_camera *, camera )
		{
		//lprintf( "Checking Thread %Lx", GetThreadID( MakeThread() ) );
			if( !camera->hVidCore )
            continue;
			GLWindow *x11_gl_window = camera->hVidCore->x11_gl_window;
			if( !x11_gl_window && ( l.bottom ) )
			{
				x11_gl_window = createGLWindow( camera );  // opens the physical device
			}
			//lprintf( "is it %Lx?", GetThreadID( thread ) );
			if( x11_gl_window && x11_gl_window->dpy )
			{
				did_one = camera;
				while( XPending( x11_gl_window->dpy ) > 0 )
				{
					XNextEvent(x11_gl_window->dpy, &event);
					//if( l.flags.bLogMessageDispatch )
					//	lprintf( WIDE("(E)Got message:%d"), event.type );
					HandleMessage( camera->hVidCore, x11_gl_window, &event );
					//if( l.flags.bLogMessageDispatch )
					//	lprintf( WIDE("(X)Got message:%d"), event.type );
				}
				//lprintf( "Draw GL..." );
				//drawGLScene( camera, x11_gl_window );

				//  calls Update; moves the camera if it has a motion...
				// does a global tick then draws all cameras
				// returns if draw should be done; might step and draw one message
				// loop for each camera instead
				ProcessGLDraw( TRUE );
			}
			
			
		}
		if( !did_one )
			WakeableSleep( 1000 );
      else
			Relinquish();
	}
	return 1;
}
Exemplo n.º 23
0
void Application::HandleEvents() {
  SDL_Event event;
  while (SDL_PollEvent(&event) != 0) {
    Json::Value event_message;
    switch (event.type) {
      case SDL_QUIT:
        app_running_ = false;
        break;
      case SDL_MOUSEBUTTONDOWN:
      case SDL_MOUSEBUTTONUP: {
        // Please check SDL website for button enums.
        event_message["type"] = "mouse_button";
        event_message["button"] = event.button.button;
        event_message["button_pressed"] = event.button.state == SDL_PRESSED;
        event_message["x"] = event.button.x;
        event_message["y"] = event.button.y;
      } break;
      case SDL_MOUSEMOTION: {
        // Please check SDL website for button mask enums.
        event_message["type"] = "mouse_motion";
        event_message["button_mask"] = event.motion.state;
        event_message["x"] = event.motion.x;
        event_message["y"] = event.motion.y;
        event_message["xrel"] = event.motion.xrel;
        event_message["yrel"] = event.motion.yrel;
      } break;
      case SDL_MOUSEWHEEL: {
        // Please check SDL website for event detail.
        event_message["type"] = "mouse_wheel";
        event_message["x"] = event.wheel.x;
        event_message["y"] = event.wheel.y;
      } break;

      case SDL_KEYDOWN:
      case SDL_KEYUP: {
        event_message["type"] = "key";
        event_message["key_pressed"] = event.key.state == SDL_PRESSED;
        // Warning, there
        event_message["key_code"] = SDL_GetKeyName(event.key.keysym.sym);
      } break;
      default:
        break;
    }
    if (event_message.empty()) {
      continue;
    }

    // std::cout << event_message << std::endl;
    if (HandleMessage(event_message)) {
      continue;
    }
    world_->HandleMessage(event_message);
  }
}
Exemplo n.º 24
0
SpotifyClient::SpotifyClient(QObject* parent)
  : QObject(parent),
    api_key_(QByteArray::fromBase64(kSpotifyApiKey)),
    protocol_socket_(new QTcpSocket(this)),
    media_socket_(NULL),
    handler_(new SpotifyMessageHandler(protocol_socket_, this)),
    session_(NULL),
    events_timer_(new QTimer(this)),
    media_length_msec_(-1) {
  memset(&spotify_callbacks_, 0, sizeof(spotify_callbacks_));
  memset(&spotify_config_, 0, sizeof(spotify_config_));
  memset(&playlistcontainer_callbacks_, 0, sizeof(playlistcontainer_callbacks_));
  memset(&get_playlists_callbacks_, 0, sizeof(get_playlists_callbacks_));
  memset(&load_playlist_callbacks_, 0, sizeof(load_playlist_callbacks_));

  spotify_callbacks_.logged_in = &LoggedInCallback;
  spotify_callbacks_.notify_main_thread = &NotifyMainThreadCallback;
  spotify_callbacks_.log_message = &LogMessageCallback;
  spotify_callbacks_.metadata_updated = &MetadataUpdatedCallback;
  spotify_callbacks_.music_delivery = &MusicDeliveryCallback;
  spotify_callbacks_.end_of_track = &EndOfTrackCallback;
  spotify_callbacks_.streaming_error = &StreamingErrorCallback;
  spotify_callbacks_.offline_status_updated = &OfflineStatusUpdatedCallback;

  playlistcontainer_callbacks_.container_loaded = &PlaylistContainerLoadedCallback;
  playlistcontainer_callbacks_.playlist_added = &PlaylistAddedCallback;
  playlistcontainer_callbacks_.playlist_moved = &PlaylistMovedCallback;
  playlistcontainer_callbacks_.playlist_removed = &PlaylistRemovedCallback;

  get_playlists_callbacks_.playlist_state_changed = &PlaylistStateChangedForGetPlaylists;

  load_playlist_callbacks_.playlist_state_changed = &PlaylistStateChangedForLoadPlaylist;

  QString cache = utilities::GetCacheDirectory();
  qLog(Debug) << "Using:" << cache << "for Spotify cache";

  spotify_config_.api_version = SPOTIFY_API_VERSION;  // From libspotify/api.h
  spotify_config_.cache_location = strdup(cache.toLocal8Bit().constData());
  spotify_config_.settings_location = strdup(QDir::tempPath().toLocal8Bit().constData());
  spotify_config_.application_key = api_key_.constData();
  spotify_config_.application_key_size = api_key_.size();
  spotify_config_.callbacks = &spotify_callbacks_;
  spotify_config_.userdata = this;
  spotify_config_.user_agent = "Clementine Player";

  events_timer_->setSingleShot(true);
  connect(events_timer_, SIGNAL(timeout()), SLOT(ProcessEvents()));

  connect(handler_, SIGNAL(MessageArrived(spotify_pb::SpotifyMessage)),
          SLOT(HandleMessage(spotify_pb::SpotifyMessage)));
  connect(protocol_socket_, SIGNAL(disconnected()),
          QCoreApplication::instance(), SLOT(quit()));
}
Exemplo n.º 25
0
	bool Xep0313Manager::CheckMessage (const QXmppMessage& msg)
	{
		for (const auto& extension : msg.extensions ())
			if (extension.tagName () == "result" &&
					extension.attribute ("xmlns") == NsMam)
			{
				HandleMessage (extension);
				return true;
			}

		return false;
	}
Exemplo n.º 26
0
/**
 * A worker thread that handles messages from JavaScript.
 * @param[in] user_data Unused.
 * @return unused.
 */
void* HandleMessageThread(void* user_data) {
  extern char *k2pdfopt_version;
  char* buf = (char*) malloc(50);
  sprintf(buf, "k2pdfopt version %s", k2pdfopt_version);
  pp_post_message("debug", buf);
  free(buf);

  while (1) {
    struct PP_Var message = DequeueMessage();
    HandleMessage(message);
    g_ppb_var->Release(message);
  }
}
Exemplo n.º 27
0
InReaction IGUIObject::SendEvent(EGUIMessageType type, const CStr& EventName)
{
	PROFILE2_EVENT("gui event");
	PROFILE2_ATTR("type: %s", EventName.c_str());
	PROFILE2_ATTR("object: %s", m_Name.c_str());

	SGUIMessage msg(type);
	HandleMessage(msg);

	ScriptEvent(EventName);

	return (msg.skipped ? IN_PASS : IN_HANDLED);
}
Exemplo n.º 28
0
Arquivo: smf.c Projeto: CSRedRat/vlc
/*****************************************************************************
 * Demux: read chunks and send them to the synthesizer
 *****************************************************************************
 * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
 *****************************************************************************/
static int Demux (demux_t *p_demux)
{
    stream_t *s = p_demux->s;
    demux_sys_t *p_sys = p_demux->p_sys;
    uint64_t     pulse = p_sys->pulse, next_pulse = UINT64_MAX;

    if (pulse == UINT64_MAX)
        return 0; /* all tracks are done */

    es_out_Control (p_demux->out, ES_OUT_SET_PCR, VLC_TS_0 + date_Get (&p_sys->pts));

    for (unsigned i = 0; i < p_sys->trackc; i++)
    {
        mtrk_t *track = p_sys->trackv + i;

        while (track->next == pulse)
        {
            if (HandleMessage (p_demux, track)
             || ReadDeltaTime (s, track))
            {
                msg_Err (p_demux, "fatal parsing error");
                return VLC_EGENERIC;
            }
        }

        if (track->next < next_pulse)
            next_pulse = track->next;
    }

    mtime_t cur_tick = (date_Get (&p_sys->pts) + 9999) / 10000, last_tick;
    if (next_pulse != UINT64_MAX)
        last_tick = date_Increment (&p_sys->pts, next_pulse - pulse) / 10000;
    else
        last_tick = cur_tick + 1;

    /* MIDI Tick emulation (ping the decoder every 10ms) */
    while (cur_tick < last_tick)
    {
        block_t *tick = block_New (p_demux, 1);
        if (tick == NULL)
            break;

        tick->p_buffer[0] = 0xF9;
        tick->i_dts = tick->i_pts = VLC_TS_0 + cur_tick++ * 10000;
        es_out_Send (p_demux->out, p_sys->es, tick);
    }

    p_sys->pulse = next_pulse;

    return 1;
}
Exemplo n.º 29
0
	void MSNAccount::handleGotMessage (const QString& from, MSN::Message *msnMsg)
	{
		if (!Entries_.contains (from))
		{
			qWarning () << Q_FUNC_INFO
					<< "got a message from unknown buddy"
					<< from;
			return;
		}

		auto entry = Entries_ [from];
		MSNMessage *msg = new MSNMessage (msnMsg, entry);
		entry->HandleMessage (msg);
	}
Exemplo n.º 30
0
bool LimeShared::FinishSetup(){
    //create the sync timer
    limeTimer = new LimeTimer(this);

    //handle messages, whilst we are running
    while(run && up.ThreadRunning()){
        //get next message
        NetMessage* msg = up.GetMessageQueue()->Pop(true);
        HandleMessage(msg);
    }
    run = false;

    return true;
}