Ejemplo n.º 1
0
LRESULT basic_window::WndProc(HWND hWnd, INT uMsg, WPARAM wParam, LPARAM lParam)
{ 
  switch (uMsg)
  {
    case WM_CREATE:      onCreate(uMsg, wParam, lParam); break;
    case WM_COMMAND:    onCommand(uMsg, wParam, lParam); break;
    case WM_NOTIFY:      onNotify(uMsg, wParam, lParam); break;
    case WM_PAINT:        onPaint(uMsg, wParam, lParam); break;
    case WM_LBUTTONDOWN:  onClick(uMsg, wParam, lParam); break;
    case WM_RBUTTONDOWN: onRClick(uMsg, wParam, lParam); break;
    case WM_MOUSEMOVE:    onMouse(uMsg, wParam, lParam); break;    
    case WM_DESTROY:    onDestroy(uMsg, wParam, lParam); break;
    
    case WM_CLOSE:					   
    {
      PostQuitMessage(0);			// send quit message
      return 0;					      // jump back
    }
    default:           
      onOther(uMsg, wParam, lParam); 
      break;
  } 
  
  return DefProc(hWnd, uMsg, wParam, lParam);
}
Ejemplo n.º 2
0
LRESULT __stdcall CMyNotepad::wndProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_CREATE:
        onCreate();
        return 0;

    case WM_CLOSE:
        onClose();
        return 0;

    case WM_SIZE:
        onSize();
        return 0;

    case WM_DESTROY:
        onDestroy();
        return 0;

    case WM_PAINT:
        handlePaint();
        return 0;

    case WM_COMMAND:
        onCommand(wParam, lParam);
        return 0;

    default:
        return ::DefWindowProc(handle, uMsg, wParam, lParam);
    }
}
Ejemplo n.º 3
0
void Console::cmdConnect(const QString& args)
{
    QString ret;
    if (args == "")
    {
        ret = "UASGE\nconnect <DeviceID>";
    }
    if (this->isConnected)
        ret = "already connected";
    else
    {
        extern MainWindow *mw;
        this->dev = mw->GetDeviceById(args);
        if (this->dev == NULL)
            ret = "unknown device";
        else
        {
            connect(this, SIGNAL(onCommand(QString)), this->dev, SLOT(onExecuteCommand(QString)));
            connect(this->dev, SIGNAL(KeepCommandRequest()), this, SLOT(KeepCommandString()));
            connect(this->dev, SIGNAL(CommandReturn()), this, SLOT(CommandFinished()));
            connect(this->dev, SIGNAL(ConsoleWrite(QString)) , this, SLOT(ConsoleWriteRequest(QString)));
            connect(this->dev, SIGNAL(ConsoleWriteHTML(QString)), this, SLOT(ConsoleWriteRequestHTML(QString)));
            connect(this->dev, SIGNAL(ChangePrompt(QString)), this, SLOT(ChangePrompt(QString)));
            connect(this, SIGNAL(CommandInterrupted(QString)), this->dev, SLOT(onCommandInterrupt(QString)));
            connect(this->dev, SIGNAL(DisconnectConsole()), this, SLOT(cmdExit()));
            connect(this->dev, SIGNAL(destroyed()), this, SLOT(DeviceDeleted()));
            this->isConnected = true;
            ret = "connected to " + args;
        }
    }

    ConsoleWriteRequest(ret);
    CommandFinished();
}
Ejemplo n.º 4
0
static int docommand(lua_State* L)
{
	const char* cmd = luaL_checkstring(L, 1);
	const char* arg = (!lua_isnil(L,2)) ? luaL_checkstring(L, 2) : NULL;
	if (!onCommand(cmd, arg))
		exit(1);
	return 0;
}
Ejemplo n.º 5
0
bool SimTreeView::handleContextMenuItemSelection( int id )
{
   // for SimTreeView class, the context menu members are already part
   // of the main menu, so just pass them onto the main menu handler.
   // if your derived context menu has unique items not also handled
   // by the main menu, just switch on their id's here and handle them.
   onCommand( id, NULL, NULL );
   return ( true );
}   
Ejemplo n.º 6
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // "Гасим" светодиод
    ui->led->turnOff();

    // Смена COM-порта
    connect(ui->portNameBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkCustomPortName(int)));
    // Смена скорости COM-порта
    connect(ui->baudRateBox, SIGNAL(currentIndexChanged(int)), this, SLOT(checkCustomBaudRatePolicy(int)));
    // Нажата кнопка подключения
    connect(ui->connectBtn, SIGNAL(clicked()), this, SIGNAL(processConnect()));
    // Отправка команды через консоль
    connect(ui->console, SIGNAL(onCommand(QString)), this, SIGNAL(onCommand(QString)));
}
Ejemplo n.º 7
0
 bool doCommand( int cmd, int params )
 {
     if ( !onCommand( cmd, params ) )
         return false;
     if ( main_win!=NULL ) {
         main_win->getDocView()->setBatteryState( checkPowerState() );
     }
     update( false );
     return true;
 }
Ejemplo n.º 8
0
void Console::onEnter()
{
	if(textCursor().positionInBlock() == prompt.length())
	{
	insertPrompt();
	return;
	}
	QString cmd = textCursor().block().text().mid(prompt.length());
	isLocked = true;
	historyAdd(cmd);
	emit onCommand(cmd);
}
Ejemplo n.º 9
0
BOOL dialog::DlgProc(HWND hWnd, INT uMsg, WPARAM wParam, LPARAM lParam)
{ 
  switch (uMsg)
  {
    case WM_INITDIALOG: return onInitDialog(uMsg, wParam, lParam); break;
    case WM_CREATE:     return     onCreate(uMsg, wParam, lParam); break;
    case WM_COMMAND:    return    onCommand(uMsg, wParam, lParam); break;
    default:            return      onOther(uMsg, wParam, lParam); break;
  }
  
  //return DefMDIChildProc(hWnd, uMsg, wParam, lParam)
}
Ejemplo n.º 10
0
int main(int argc, char* argv[]) {
	Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

	SwitchInvoker invoker;
	LightWindow window(&invoker);
	OnCommand onCommand(&window);
	OffCommand offCommand(&window);
	invoker.setOnCommand(&onCommand);
	invoker.setOffCommand(&offCommand);

	app->run(window);
	return 0;
}
Ejemplo n.º 11
0
bool mxWindow::handleMessage(
		LRESULT *lRes,
		UINT uMsg,
		WPARAM wParam,
		LPARAM lParam
		)
{
	switch (uMsg) {
	case MM_MCINOTIFY:
		return onMciNotify(wParam, lParam);

	case WM_CLOSE:
		return onClose();

	case WM_COMMAND:
		return onCommand(
				LOWORD(wParam),
				reinterpret_cast<HWND>(lParam),
				HIWORD(wParam));

	case WM_CREATE:
		return onCreate(lRes, reinterpret_cast<CREATESTRUCT*>(lParam));

	case WM_DESTROY:
		return onDestroy();

	case WM_ERASEBKGND:
		return onEraseBkgnd(lRes, reinterpret_cast<HDC>(wParam));

	case WM_LBUTTONDBLCLK:
		return onLButtonDown(TRUE, mxPoint(lParam), wParam);

	case WM_LBUTTONDOWN:
		return onLButtonDown(FALSE, mxPoint(lParam), wParam);

	case WM_MOUSEMOVE:
		return onMouseMove(mxPoint(lParam), wParam);

	case WM_PAINT: {
		mxPaintDC dc(this);
		return onPaint(&dc); }

	case WM_SIZE:
		return onSize(wParam, mxSize(lParam));

	case WM_TIMER:
		return onTimer(wParam);

	}
	return false;
}
Ejemplo n.º 12
0
LRESULT UIControl::onEvent(UINT msg, WPARAM wp, LPARAM lp, UINT flag, Point pt)
{
    switch (msg)
    {
    case WM_NCHITTEST:
        return m_hittest;
    case WM_COMMAND:
        onCommand(wp, lp);
        return 0;
    default:
        break;
    }
    return 0;
}
void HwaHomePage::setUI(QObject* ui)
{
	if (ui == NULL)
	{
		qDebug("ui is NULL");
		return;
	}

	QObject* homePage = ui->findChild<QObject*>("homepage");
	connect(homePage, SIGNAL(action(const QString&, const QVariant&)), this, SLOT(onAction(const QString&, const QVariant&)));
	connect(this, SIGNAL(command(QVariant, QVariant)), homePage, SLOT(onCommand(QVariant, QVariant)));
	qDebug("connect ui to home page");
	qDebug("connect home page to ui");
	_homeRoot = ui;
}
Ejemplo n.º 14
0
int ConsolePanel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QPlainTextEdit::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: onEnter(); break;
        case 1: onCommand((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Ejemplo n.º 15
0
void geGUIBase::DoCommand(int cmd)
{
	if(m_uGUIID==GEGUI_LAYOUT && getActiveWindowPtrOnlyForLayout())	//layout hack: no need to implement this, but for consistency purpose i kept
	{
		getActiveWindowPtrOnlyForLayout()->DoCommand(cmd);
	}
	else
	{
		for(std::vector<geGUIBase*>::iterator it = m_vControls.begin(); it != m_vControls.end(); ++it)
		{
			geGUIBase* obj = *it;
			obj->DoCommand(cmd);
		}
	}
	return onCommand(cmd);
}
Ejemplo n.º 16
0
void Console::cmdExit()
{
    disconnect(this, SIGNAL(onCommand(QString)), this->dev, SLOT(onExecuteCommand(QString)));
    disconnect(this->dev, SIGNAL(KeepCommandRequest()), this, SLOT(KeepCommandString()));
    disconnect(this->dev, SIGNAL(CommandReturn()), this, SLOT(CommandFinished()));
    disconnect(this->dev, SIGNAL(ConsoleWrite(QString)) , this, SLOT(ConsoleWriteRequest(QString)));
    disconnect(this->dev, SIGNAL(ConsoleWriteHTML(QString)), this, SLOT(ConsoleWriteRequestHTML(QString)));
    disconnect(this->dev, SIGNAL(ChangePrompt(QString)), this, SLOT(ChangePrompt(QString)));
    disconnect(this, SIGNAL(CommandInterrupted(QString)), this->dev, SLOT(onCommandInterrupt(QString)));
    disconnect(this->dev, SIGNAL(DisconnectConsole()), this, SLOT(cmdExit()));
    disconnect(this->dev, SIGNAL(destroyed()), this, SLOT(DeviceDeleted()));
    emit disconnectCommand(this);
    this->isConnected = false;
    ConsoleWriteRequest("connection closed with "+this->dev->GetDeviceID());
    CommandFinished();
    this->dev = NULL;
}
Ejemplo n.º 17
0
      bool
      waitForCommand(uint8_t code)
      {
        LUCL::Command cmd;
        unsigned retries = 10;

        while (retries)
        {
          LUCL::CommandType type = m_proto.consumeData(cmd);

          switch (type)
          {
            case LUCL::CommandTypeNormal:
              onCommand(cmd.command.code, cmd.command.data, cmd.command.size);
              if (cmd.command.code == code)
                return true;
              break;

            case LUCL::CommandTypeVersion:
              onVersion(cmd.version.major, cmd.version.minor, cmd.version.patch);
              break;

            case LUCL::CommandTypeInvalidVersion:
              err("%s", DTR(Status::getString(Status::CODE_INVALID_CHECKSUM)));
              break;

            case LUCL::CommandTypeError:
              err(DTR("device reported: %s"), m_proto.getErrorString(cmd.error.code));
              break;

            case LUCL::CommandTypeInvalidChecksum:
              err("%s", DTR(Status::getString(Status::CODE_INVALID_CHECKSUM)));
              break;

            case LUCL::CommandTypeNone:
              --retries;
              Delay::waitMsec(50);
              break;

            default:
              break;
          }
        }

        return false;
      }
Ejemplo n.º 18
0
void *listenForConnections(void *arg) {
    while(1) {
        int c;
        long read_size;
        struct sockaddr_in client;
        char client_message[1024];

        c = sizeof(struct sockaddr_in);

        int tmpUserSocket;

        tmpUserSocket = accept(socketConnection, (struct sockaddr *)&client, (socklen_t*)&c);
        if (userSocket == -1)
            printf("accept failed\n");

        if(userSocket >= 0) // if there is already a socket connected, disconnect
            close(userSocket);

        userSocket = tmpUserSocket;

        char * sendBuff = "Connection established.";
        write(userSocket, sendBuff, strlen(sendBuff));

        printf("Client has connected!\n");

        while((read_size = recv(userSocket, client_message, 1024, 0)) > 0 ){
            onCommand(client_message);
            int i;
			for (i = 0; i < read_size; i++) {
				client_message[i] = '\0';
			}
        }

        if(read_size == 0) {
            close(userSocket);
            printf("Client disconnected\n");
        }
        else if(read_size == -1) {
            close(userSocket);
            printf("Client error\n");
        }
    }
}
Ejemplo n.º 19
0
	//
	// command input
	//
	void input(uint8_t ch) {
		switch (ch) {
		case '$':	// start of command
			m_cmd.clear();
			m_bStart = true;
			break;

		case '#':	// end of command
			m_cmd.makeLower();
			onCommand(m_cmd);
			m_bStart = false;
			break;

		default:
			if (m_bStart) {
				m_cmd += (char) ch;
			}
			break;
		}
	}
Ejemplo n.º 20
0
MRESULT EXPENTRY NP_LOADDS AutoDlgProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
  switch(msg)
  {
    case WM_INITDLG:
      onInitDialog(hWnd, 0, mp2);
      return (MRESULT)FALSE;
    case WM_COMMAND:
    case WM_CONTROL:
      onCommand(hWnd, SHORT1FROMMP(mp1), 0, SHORT2FROMMP(mp1));
      break;
    case WM_DESTROY:
      onDestroy(hWnd);
      break;

    default:
      return WinDefDlgProc(hWnd, msg, mp1, mp2);
  }
  return (MRESULT)TRUE;
}
bool NotificationManager::onDataAvailable(NuSocketClient *cli)
{
    int socket = cli->getSocket();
    ssize_t count;

    count = TEMP_FAILURE_RETRY(read(socket, mBuffer, sizeof(mBuffer)));
    if (count < 0 || count > 4) {
        SLOGE("recvmsg failed (%s)", strerror(errno));
        return false;
    } else if (count == 0){
        LOGD("count = 0, client closed!");
        return false;
    }
    

    int *value = (int *)&mBuffer[0];
    onCommand(*value); 

    return true;
}
Ejemplo n.º 22
0
MRESULT EXPENTRY dlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) {
   switch (msg) {
      case WM_INITDLG:
         WinSendMsg(hwnd, WM_SETICON,
                    (MPARAM)WinLoadPointer(HWND_DESKTOP, 0, 1), MPVOID);
         enumClasses(hwnd, FALSE);
         break;
      case WM_CONTROL:
         onCtrlNotify(hwnd,  SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), (HWND)mp2);
         break;
      case WM_COMMAND:
         onCommand(hwnd, (ULONG)mp1);
         break;
      case WM_CLOSE:
         WinPostMsg(hwnd, WM_QUIT, 0, 0);
         break;
      default:
         return WinDefDlgProc(hwnd, msg, mp1, mp2);
   } /* endswitch */
   return MRFALSE;
}
Ejemplo n.º 23
0
void NetworkTestEnv::onFindCommand(OnFindCommandFunction func) {
    onCommand([&func](const RemoteCommandRequest& request) -> StatusWith<BSONObj> {
        const auto& resultStatus = func(request);

        if (!resultStatus.isOK()) {
            return resultStatus.getStatus();
        }

        BSONArrayBuilder arr;
        for (const auto& obj : resultStatus.getValue()) {
            arr.append(obj);
        }

        const NamespaceString nss =
            NamespaceString(request.dbname, request.cmdObj.firstElement().String());
        BSONObjBuilder result;
        appendCursorResponseObject(0LL, nss.toString(), arr.arr(), &result);

        return result.obj();
    });
}
Ejemplo n.º 24
0
bool IEToolbar::processSiteWindowMessage(const UINT message,
                                         const WPARAM wParam,
                                         const LPARAM lParam,
                                         LRESULT& lResult) {
  switch (message) {
  case WM_COMMAND:
    return onCommand(wParam);
  case WM_NOTIFY:
    return onNotify(wParam, *(LPNMHDR)lParam, lResult);
  case TBM_DATA_CHANGED:
    dataUpdated(wParam);
    return true;
  case TBM_COOKIES: {
    UNREFERENCED_PARAMETER(lParam);
    String cookie = String((Char*)wParam);
    UserDataObserver::getInstance().setSession(cookie);
    return true;
  }
  default:
    return false;
  }
}
Ejemplo n.º 25
0
void serialMessageTask(void){
    int chars_read;
    char read_buffer[MAX_COMMAND_LENGTH + 1] = {0};

    for (;;)
	{
		if (serial_port != -1)
		{
			#if 1
			// Read received data into the buffer
			// up to but not including the buffer's terminating null.
			chars_read = serial_port_read(read_buffer, MAX_COMMAND_LENGTH,serial_port);
			if (chars_read > 0)
			{
				// Data was read.
				onCommand(read_buffer, chars_read, serial_port);
			}
			#endif
		}
		// The application can perform other tasks here.
	}
}
Ejemplo n.º 26
0
LRESULT CALLBACK windowProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
    switch (umsg)
    {
        case WM_CREATE:
            onCreate(hwnd);
            break;

        case WM_CLOSE:
            DestroyWindow(hwnd); // exit
            break;

        case WM_DESTROY:
            onDestroy(hwnd);
            break;

        case WM_SHELLNOTIFY:
            onTray(hwnd, wparam, lparam);
            break;

        case WM_TIMER:
            onTimer(hwnd, wparam, lparam);
            break;

        case WM_HOTKEY:
            onHotkey(hwnd, wparam, lparam);
            break;

        case WM_COMMAND:
            onCommand(hwnd, LOWORD(wparam), HIWORD(wparam), (HWND)lparam);
            SetForegroundWindow(tibia_getwindow()); // set focus to tibia window after using tray menu
            break;

        default:
            return DefWindowProc(hwnd, umsg, wparam, lparam);
    }
    return 0;
}
Ejemplo n.º 27
0
LRESULT WinWindow::Proc(UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CREATE:
            onCreate();
            break;
        case WM_COMMAND:
        {
            if (onCommand(wParam, lParam))
                return 0;
            else
                break;
        }
        case WM_CLOSE:
            DestroyWindow(m_window);
            break;
        default:
            break;
    }

    return DefWindowProc(m_window, msg, wParam, lParam);
}
Ejemplo n.º 28
0
void Console::onEnter()
{
    if(textCursor().position() == prompt.length())
    {
        insertPrompt();
        return;
    }
    QString cmd = textCursor().block().text().mid(prompt.length()).simplified();
    isLocked = true;
    historyAdd(cmd);
    QTextCharFormat format;
    format.setForeground(Qt::green);
    textCursor().setBlockCharFormat(format);
    this->_currentCommand = cmd;


    if (cmd.startsWith("connect") && !isConnected)
    {
        cmdConnect(cmd.section(" ",1));
    }
    else if (cmd.startsWith("clear"))
    {
        cmdClear();
    }
    else
    {
        if (isConnected) {
            emit onCommand(cmd);
        }
        else
        {
            ConsoleWriteRequest(cmd + ": command unknown");
            CommandFinished();
        }
    }
}
err_t FTPServerConnection::onReceive(pbuf *buf)
{
	if (buf == NULL) return ERR_OK;
	int p = 0, prev = 0;
	while (true)
	{
		p = NetUtils::pbufFindStr(buf, "\r\n", prev);
		if (p == -1 || p - prev > MAX_FTP_CMD) break;
		int split = NetUtils::pbufFindChar(buf, ' ', prev);
		String cmd, data;
		if (split != -1 && split < p)
		{
			cmd = NetUtils::pbufStrCopy(buf, prev, split - prev);
			split++;
			data = NetUtils::pbufStrCopy(buf, split, p - split);
		}
		else
			cmd = NetUtils::pbufStrCopy(buf, prev, p - prev);
		debugf("%s: '%s'", cmd.c_str(), data.c_str());
		onCommand(cmd, data);
		prev = p + 1;
	};
	return ERR_OK;
}
Ejemplo n.º 30
0
const char * AIPlugin::consoleCallback(CMDConsole*,int id,int argc,const char *argv[])
{
   const char     * returnTxt = 0;
   HandleCmdFunc  listableCommand = 0;

   if( (aim = AIManager::it) == NULL )
   {
      if( sg.manager )
      {
         SimGroup * cleanupGroup = (SimGroup *) sg.manager->findObject(missionCleanup);
      
         if( cleanupGroup == NULL ){
            console->printf( "No cleanup group yet, can't install AI manager and, "
                     "therefore, cannot execute command %s", argv[0] );
            return returnTxt;
         }
         
         aim = new AIManager();
         AssertFatal( aim, "ai: couldn't new() the AIManager." );
         
         if( ! sg.manager->registerObject(aim) ){
            delete aim;
            aim = 0;
            console->printf( "Couldn't register AI manager...  "
                     "Cannot execute command %s", argv[0] );
            return returnTxt;
         }
         else{//success
            sg.manager->assignId(aim,AIManagerId);
            cleanupGroup->addObject(aim);
         }
      }
      else{
         console->printf("No server manager yet, can't install AI manager thus, "
                     "cannot execute command %s.", argv[0] );
         return returnTxt;
      }
   }

   switch( id )
   {
      onCommand(SpawnAI);                          // create an AI.  
      onCommand(List);                             // list all AIs in manager.  
      onCommand(GetAICount);                       // return list size.
      onCommand(GetId);                            // return rep Id.  
      onCommand(GetTarget);                        // return rep Id.  
      onCommand(FetchObject);                      // return SimObjectId

      onListableCommand(AttackPlayer);
      onListableCommand(DeleteAI);
      
      onListableCommand(CallWithId);
      onListableCommand(SetVariable);
      
      onListableCommand(FollowDirective);          // follow the specified player 
      onListableCommand(WaypointDirective);        // add waypoint to list
      onListableCommand(TargetDirective);          // add Target (player rep Id) to list.
      onListableCommand(TargetDirectiveLaser);     //    Use Laser as target (Pt Ok).  
      onListableCommand(TargetDirectivePoint);     //    Fire at given Point.
      //onListableCommand(GuardDirective);         // guard this point or player.  
      onListableCommand(RemoveDirective);          //    remove using order number.
      onListableCommand(ListDirectives);
      onListableCommand(DirectiveCallback1);
      onListableCommand(DirectiveCallback2);
      onListableCommand(DirectiveCallback3);
      onListableCommand(DirectiveCallback4);
      
      onListableCommand(CallbackDied);
      onListableCommand(CallbackPeriodic);
      onListableCommand(SetAutomaticTargets);
      onListableCommand(SetSciptedTargets);
      
#     if INCLUDE_AI_GRAPH_CODE
      onCommand(GraphAddNode);
      onCommand(GraphNodeCount);
      onCommand(GraphLoadNode);
      onCommand(GraphPrintNode);
#     endif
   }

   if( aim )
   {
      if( listableCommand )
      {
         if( argc > 1 )
         {
            // Execute command an all AIs which match the name spec.  
            AIManager::iterator itr;
            for( itr = aim->begin(); itr != aim->end(); itr++ )
               if( (*itr)->nameMatches( argv[1] ) )
                  returnTxt = (this->*listableCommand)( *itr, argc-2, argv+2 );
         }
         else
         {
            // Just give help:
            returnTxt = (this->*listableCommand)( NULL, 0, 0 );
         }
      }
   }
   
   return returnTxt;
}