// creates a connection and destroys it again
enum TVerdict TE_RConnectionTest301::doTestStepL(void)
{
	TInt err;

	RConnection activeConn;
	RConnection conn;
	RSocketServ ss;

	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(ss);

	err = OpenConnection(conn, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(conn);

	err = OpenConnection(activeConn, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(activeConn);

	err = StartConnectionWithOverrides(conn, 1);
	TESTEL(KErrNone == err, err);

	// issue request
	AllInterfaceNotification(conn, status, info);

	// start another different connection to complete request if it hasn't already done so
	err = StartConnectionWithOverrides(activeConn, 6);
	TESTEL(KErrNone == err, err);

	// wait for completion
	User::WaitForRequest(status);

	// check for correct value
	TESTEL(status.Int() == KErrInUse, status.Int());

	CloseConnection(activeConn);
	CleanupStack::Pop();

	CloseConnection(conn);
	CleanupStack::Pop();

	CloseSocketServer(ss);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest301
// creates a connection and destroys it again
enum TVerdict TE_RConnectionTest304::doTestStepL(void)
{
	TInt err;

	RSocketServ socketServer;
	RConnection connection;
	RConnection monitor;

	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(socketServer);

	err = OpenConnection(connection, socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(connection);

	err = OpenConnection(monitor, socketServer);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(monitor);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	// start connection to complete request
	err = StartConnection(connection);
	TESTEL(KErrNone == err, err);

	CheckInterfaceNotificationL(status, info, EInterfaceUp, &connection);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	CloseConnection(connection);
	CleanupStack::Pop();

	CheckInterfaceNotificationL(status, info, EInterfaceDown);

	CloseConnection(monitor);
	CleanupStack::Pop();

	CloseSocketServer(socketServer);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest304
Beispiel #3
0
//重新连接
bool __cdecl CDataBase::TryConnectAgain(bool bFocusConnect, CComError * pComError)
{
	try
	{
		//判断重连
		bool bReConnect = bFocusConnect;
		if (bReConnect == false)
		{
			DWORD dwNowTime = (DWORD)time(NULL);
			if ((m_dwConnectErrorTime + m_dwResumeConnectTime) > dwNowTime) bReConnect = true;
		}
		if ((bReConnect == false) && (m_dwConnectCount > m_dwResumeConnectCount)) bReConnect = true;

		//设置变量
		m_dwConnectCount++;
		m_dwConnectErrorTime = (DWORD)time(NULL);
		if (bReConnect == false)
		{
			if (pComError != NULL) SetErrorInfo(SQLException_Connect, GetComErrorDescribe(*pComError));
			return false;
		}

		//重新连接
		OpenConnection();
		return true;
	}
	catch (IDataBaseException * pIDataBaseException)
	{
		//重新连接错误
		if (pComError != NULL) SetErrorInfo(SQLException_Connect, GetComErrorDescribe(*pComError));
		else throw pIDataBaseException;
	}

	return false;
}
Beispiel #4
0
//---------------------------------------------------------------------------
void
DagmanClassad::GetAcctInfo( MyString &group, MyString &user )
{
	if ( !_valid ) {
		debug_printf( DEBUG_VERBOSE,
					"Skipping ClassAd query -- DagmanClassad object is invalid\n" );
		return;
	}

	Qmgr_connection *queue = OpenConnection();
	if ( !queue ) {
		return;
	}

	GetDagAttribute( ATTR_ACCT_GROUP, group, false );
	debug_printf( DEBUG_VERBOSE, "Workflow accounting_group: <%s>\n",
				group.Value() );

	GetDagAttribute( ATTR_ACCT_GROUP_USER, user, false );
	debug_printf( DEBUG_VERBOSE, "Workflow accounting_group_user: <%s>\n",
				user.Value() );

	CloseConnection( queue );

	return;
}
Beispiel #5
0
void InputImpl::setMousePosition(const Vector2i& position, const Window& relativeTo)
{
    // Open a connection with the X server
    xcb_connection_t* connection = OpenConnection();

    WindowHandle handle = relativeTo.getSystemHandle();
    if (handle)
    {
        ScopedXcbPtr<xcb_generic_error_t> error(xcb_request_check(
                connection,
                xcb_warp_pointer(
                    connection,
                    None,                  // Source window
                    handle,                // Destination window
                    0, 0,                  // Source position
                    0, 0,                  // Source size
                    position.x, position.y // Destination position
                )
                                                ));

        if (error)
            err() << "Failed to set mouse position" << std::endl;

        xcb_flush(connection);
    }

    // Close the connection with the X server
    CloseConnection(connection);
}
Beispiel #6
0
//---------------------------------------------------------------------------
void
DagmanClassad::Update( int total, int done, int pre, int submitted,
			int post, int ready, int failed, int unready,
			Dag::dag_status dagStatus, bool recovery, const DagmanStats &stats )
{

	if ( !_valid ) {
		debug_printf( DEBUG_VERBOSE,
					"Skipping ClassAd update -- DagmanClassad object is invalid\n" );
		return;
	}

	Qmgr_connection *queue = OpenConnection();
	if ( !queue ) {
		return;
	}

	SetDagAttribute( ATTR_DAG_NODES_TOTAL, total );
	SetDagAttribute( ATTR_DAG_NODES_DONE, done );
	SetDagAttribute( ATTR_DAG_NODES_PRERUN, pre );
	SetDagAttribute( ATTR_DAG_NODES_QUEUED, submitted );
	SetDagAttribute( ATTR_DAG_NODES_POSTRUN, post );
	SetDagAttribute( ATTR_DAG_NODES_READY, ready );
	SetDagAttribute( ATTR_DAG_NODES_FAILED, failed );
	SetDagAttribute( ATTR_DAG_NODES_UNREADY, unready );
	SetDagAttribute( ATTR_DAG_STATUS, (int)dagStatus );
	SetDagAttribute( ATTR_DAG_IN_RECOVERY, recovery );
	
	// Publish DAGMan stats to a classad, then update those also
	ClassAd stats_ad;
	stats.Publish( stats_ad );
	SetDagAttribute( ATTR_DAG_STATS, stats_ad );

	CloseConnection( queue );
}
Beispiel #7
0
void InputImpl::setMousePosition(const Vector2i& position)
{
    // Open a connection with the X server
    xcb_connection_t* connection = OpenConnection();

    ScopedXcbPtr<xcb_generic_error_t> error(xcb_request_check(
            connection,
            xcb_warp_pointer(
                connection,
                None,                             // Source window
                XCBDefaultRootWindow(connection), // Destination window
                0, 0,                             // Source position
                0, 0,                             // Source size
                position.x, position.y            // Destination position
            )
                                            ));

    if (error)
        err() << "Failed to set mouse position" << std::endl;

    xcb_flush(connection);

    // Close the connection with the X server
    CloseConnection(connection);
}
Beispiel #8
0
Vector2i InputImpl::getMousePosition()
{
    // Open a connection with the X server
    xcb_connection_t* connection = OpenConnection();

    ScopedXcbPtr<xcb_generic_error_t> error(NULL);

    ScopedXcbPtr<xcb_query_pointer_reply_t> pointer(
        xcb_query_pointer_reply(
            connection,
            xcb_query_pointer(
                connection,
                XCBDefaultRootWindow(connection)
            ),
            &error
        )
    );

    // Close the connection with the X server
    CloseConnection(connection);

    if (error)
    {
        err() << "Failed to query pointer" << std::endl;

        return Vector2i(0, 0);
    }

    return Vector2i(pointer->root_x, pointer->root_y);
}
I2cConnection::I2cConnection(QString DevPath, int DevId):
i_DevPath(DevPath),
i_DevId(DevId),
i_BusFd(0)
{
	OpenConnection();
}
Beispiel #10
0
//////////////////////////////////////////////////////////////////////
// OpenConnection
// return:   0  success
//          -1  error
//
int CAsyncPort::OpenConnection(const char * pszPortName, DWORD dwBaudRate, BYTE bByteSize, BYTE bParity, BYTE bStopBits)
{
	// setup connection properties
    DCB dcb;
	dcb.DCBlength = sizeof (DCB) ;

	// common settings
	dcb.BaudRate = dwBaudRate;
	dcb.ByteSize = bByteSize;
	dcb.Parity = bParity;
	dcb.StopBits = bStopBits;

	// setup hardware flow control
	dcb.fDtrControl = DTR_CONTROL_DISABLE;
	dcb.fRtsControl = RTS_CONTROL_ENABLE;

	// setup software flow control
	dcb.fInX = FALSE;
	dcb.fOutX = FALSE;
	dcb.XonChar = 0x11;
	dcb.XoffChar = 0x13;
	dcb.XonLim = 100;
	dcb.XoffLim = 100;

	// other 
	dcb.fBinary = TRUE;
	dcb.fParity = TRUE;

	return OpenConnection(pszPortName, dcb);
}
Beispiel #11
0
//---------------------------------------------------------------------------
void
DagmanClassad::GetSetBatchName( const MyString &primaryDagFile,
			MyString &batchName )
{
	if ( !_valid ) {
		debug_printf( DEBUG_VERBOSE,
					"Skipping ClassAd query -- DagmanClassad object is invalid\n" );
		return;
	}

	Qmgr_connection *queue = OpenConnection();
	if ( !queue ) {
		return;
	}

	if ( !GetDagAttribute( ATTR_JOB_BATCH_NAME, batchName, false ) ) {
			// Default batch name is top-level DAG's primary
			// DAG file (base name only).
		batchName = condor_basename( primaryDagFile.Value() );
		batchName += "+";
		batchName += IntToStr( _dagmanId._cluster );
		SetDagAttribute( ATTR_JOB_BATCH_NAME, batchName );
	}

	CloseConnection( queue );

	debug_printf( DEBUG_VERBOSE, "Workflow batch-name: <%s>\n",
				batchName.Value() );
}
void EngineClient::sendLevelData(LevelData _data)
{
    if(!_data.ReadFileValid) return;

    if(!engine->isOpen())
        OpenConnection();


    QString sendLvlx;
    if(!_data.path.isEmpty())
        sendLvlx = QString("SEND_LVLX: %1/%2").arg(_data.path).arg(_data.filename);
    else
        sendLvlx = QString("SEND_LVLX: %1/%2").arg(ApplicationPath).arg("_untitled.lvlx");

    qDebug() << sendLvlx;
    sendCommand(sendLvlx);
    qApp->processEvents();

    if(engine->waitForReadyRead(1000))
    {
        QByteArray data = engine->readAll();
        QString acceptedData = QString::fromUtf8(data);

        if(!acceptedData.isEmpty())
        {
            QStringList StrData = acceptedData.split("\n\n");
            foreach(QString x, StrData)
            {
                if(x=="READY")
                {
                    qDebug() << "Engine is ready to accept data";
                    readyToSendLvlx = true;
                }
            }
        }
Beispiel #13
0
/*---------------------------------------------------------------------*/
bool MakeSSLRequest(const char* hostname, int port, 
    ClientFunction client_func, void* client_data)
{   
    // Set up context
    SSL_CTX* ctx = InitCTX();
    CHECK_CALL(ctx);

    // Connect to server
    int server = OpenConnection(hostname, port);
    if(server < 0) return false;
    CHECK_CALL(server);

    SSL* ssl = SSL_new(ctx);
    SSL_set_fd(ssl, server);

    // Do handshake
    if ( SSL_connect(ssl) == FAIL ) {
        ERR_print_errors_fp(stderr);
        return false;
    }

    client_func(ssl, client_data);

    fprintf(stderr, "Connected with %s encryption\n", SSL_get_cipher(ssl));

    SSL_free(ssl);
    
    close(server);

    SSL_CTX_free(ctx);
    ERR_free_strings();
    EVP_cleanup();

    return true;
}
Beispiel #14
0
//---------------------------------------------------------------------------
void
DagmanClassad::GetInfo( MyString &owner, MyString &nodeName )
{
	if ( !_valid ) {
		debug_printf( DEBUG_VERBOSE,
					"Skipping ClassAd query -- DagmanClassad object is invalid\n" );
		return;
	}

	Qmgr_connection *queue = OpenConnection();
	if ( !queue ) {
		return;
	}

	if ( !GetDagAttribute( ATTR_OWNER, owner ) ) {
		check_warning_strictness( DAG_STRICT_1 );
		owner = "undef";
	}

	if ( !GetDagAttribute( ATTR_DAG_NODE_NAME, nodeName ) ) {
		// We should only get this value if we're a sub-DAG.
		nodeName = "undef";
	}

	CloseConnection( queue );

	return;
}
Beispiel #15
0
int
GetUrl(char *url, char **reply_ret, int *len_ret)
{
    char *hostname, *path;
    int port;
    XtransConnInfo trans;
    int status = 0;

    if (ParseHttpUrl(url, &hostname, &port, &path) != 0)
	return 1;		/* invalid URL */

    trans = OpenConnection(hostname, port);
    if (trans == NULL) {
	status = 1;		/* connection failed */
	goto end;
    }

    SendGetRequest(trans, path);

    *len_ret = ReadGetReply(trans, reply_ret);

    CloseConnection(trans);

end:
    Free(hostname);
    Free(path);
    return status;
}
//---------------------------------------------------------------------------
void __fastcall TfrmEditFTP::Label6Click(TObject *Sender)
{
  Screen->Cursor = crHourGlass;
  if(OpenConnection())
  {
    MessageBox(Handle,"测试成功完成.","信息",MB_OK | MB_ICONINFORMATION);
  }
  Screen->Cursor = crDefault;
}
Beispiel #17
0
CConn_IOStream* CId2Reader::x_GetConnection(TConn conn)
{
    _ASSERT(m_Connections.count(conn));
    CReaderServiceConnector::SConnInfo& conn_info = m_Connections[conn];
    if ( conn_info.m_Stream.get() ) {
        return conn_info.m_Stream.get();
    }
    OpenConnection(conn);
    return m_Connections[conn].m_Stream.get();
}
Beispiel #18
0
void QPlc::init(QString ip,QString strPath, Plc_Type PlcType, int Network, int Node)
{
    ParsePath(strPath);
    m_ip = ip;
    m_PlcType = PlcType;
    m_Network=Network;
    m_Node=Node;
    m_time_out=10000;
    OpenConnection();
}
// creates a connection and destroys it again
// Implicitly detect a single connection using SendTo()
enum TVerdict TE_RConnectionTest306::doTestStepL(void)
{
	TInt err;

	RSocketServ ss;
	RSocket sock;

	RConnection monitor;
	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(ss);

	err = OpenConnection(monitor, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(monitor);

	err = OpenTcpSocket(sock, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(sock);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	err = ConnectTcpSocket(sock, iEchoServerAddr); // this will use Connect()
	TESTEL(KErrNone == err, err);

	err = TestTcpDataPathL(sock);
	TESTEL(KErrNone == err, err);

	// check for interface up...
	CheckInterfaceNotificationL(status, info, EInterfaceUp);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	err = DestroyTcpSocket(sock);
	TESTEL(KErrNone == err, err);
	CleanupStack::Pop();

	// check for interface down...
	CheckInterfaceNotificationL(status, info, EInterfaceDown);

	CloseConnection(monitor);
	CleanupStack::Pop();

	CloseSocketServer(ss);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest306
Beispiel #20
0
/** Send a JWM message to the root window. */
void SendJWMMessage(const char *message)
{
   XEvent event;
   OpenConnection();
   memset(&event, 0, sizeof(event));
   event.xclient.type = ClientMessage;
   event.xclient.window = rootWindow;
   event.xclient.message_type = JXInternAtom(display, message, False);
   event.xclient.format = 32;
   JXSendEvent(display, rootWindow, False, SubstructureRedirectMask, &event);
   CloseConnection();
}
Beispiel #21
0
//////////////////////////////////////////////////////////////////////
// OpenConnection
// return:   0  success
//          -1  error
//
int CAsyncPort::OpenConnection(const char * pszPortName, const char * pszSetupString)
{
	DWORD dwBaudRate;
	BYTE bByteSize;
	BYTE bParity;
	BYTE bStopBits;

	if (! ParseSetupString(pszSetupString, & dwBaudRate, & bByteSize, & bParity, & bStopBits)) {
		return OpenConnection(pszPortName, dwBaudRate, bByteSize, bParity, bStopBits);
	}

	return (-1);
}
// Implicitly create a single connection using GetByName()
enum TVerdict TE_RConnectionTest307::doTestStepL(void)
{
	TInt err;

	RSocketServ ss;
	RHostResolver hr;

	RConnection monitor;
	TRequestStatus status;
	TInterfaceNotificationBuf info;

	err = OpenSocketServer(ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(ss);

	err = OpenConnection(monitor, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(monitor);

	err = OpenHostResolver(hr, ss);
	TESTEL(KErrNone == err, err);
	CleanupClosePushL(hr);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	err = MakeNameRequest(hr, iTestName); // this will use GetByName()
	TESTEL(KErrNone == err, err);

	// check for interface up...
	CheckInterfaceNotificationL(status, info, EInterfaceUp);

	// issue request
	AllInterfaceNotification(monitor, status, info);

	DestroyHostResolver(hr);
	CleanupStack::Pop();

	// check for interface down...
	CheckInterfaceNotificationL(status, info, EInterfaceDown);

	CloseConnection(monitor);
	CleanupStack::Pop();

	CloseSocketServer(ss);
	CleanupStack::Pop();

	return TestStepResult();

} // TE_RConnectionTest307
CNearFieldTag * CNearFieldTag::CastToTag()
    {
    BEGIN
    TInt error = KErrNone;

    if (!IsConnectionOpened())
        {
        error = OpenConnection();
        LOG("open connection, error is "<<error);
        }
    END
    return (error == KErrNone) ? const_cast<CNearFieldTag *>(this)
                               : reinterpret_cast<CNearFieldTag *>(0);
    }
Beispiel #24
0
int Server::_OpenConnection()
{
	//set the log dest
	_log->Init(EMPTY_STRING);
	_log->SetLogLevel(LOG_LEVEL_DEBUG);
	_log->SetPrinterMethod(printf);
	
	Init(_log);

	const char* userName = GetEIBUserName();
	const char* userPassword = GetPassword();
	const char* encryptKey = GetEncryptKey();
	
	CString local_ip;

	START_TRY
		local_ip = Socket::LocalAddress(GetLocalNetworkIf());
	END_TRY_START_CATCH_SOCKET(e)
		_log->Log(LOG_LEVEL_ERROR, e.what());
		return ERR_NETWORK_ERROR;
	END_CATCH

	_log->Log(LOG_LEVEL_DEBUG, "Trying to connect to EIBServer...");

	
	CString serverIP = GetEIBServerAddress();
	int serverPort = GetEIBServerPort();

	DiscoverEIBServer(local_ip,
					  encryptKey,
					  serverIP,
					  serverPort);

	ConnectionResult res;
	res = OpenConnection("Generic",
						userName,
						serverPort,
						encryptKey,
						local_ip.GetBuffer(),
						userName,
						userPassword);

	
	if(res == STATUS_CONN_OK) {
		start();
	}

	return (int)res;
}
Beispiel #25
0
int ReOpenConnection(stream_t* s)
{
//printf("Reopening connection\n");fflush(stdout);
    struct stream_priv_s* p = (struct stream_priv_s*)s->priv;
    if (!p->url) return 0;
	unlock_fd(p);
	close(s->fd);
	s->fd = 0;
	if (OpenConnection(s))
	{
		lock_fd(p);
		return 1;
	}
	return 0;
}
Beispiel #26
0
HTTPInputStream::HTTPInputStream(const string & url) {
  host = "";
  port = 80;
  path = "/";
  sockfd = -1;
  contentLength = -1;
  numRead = 0;

  ParseURL(url);
  //***cout << "[host=" << host << ", port=" << port << ", path=" << path << "]" << endl;
  OpenConnection();
  //***cout << "[connection established]" << endl;
  SendRequest();
  ParseHTTPHeader();
}
void Cedrus::XIDDevice::SetBaudRate(unsigned char rate)
{
    if (m_config->IsMPod())
        return;

    static unsigned char change_baud_cmd[3] = { 'f', '1' };
    change_baud_cmd[2] = rate;

    DWORD bytes_written = 0;
    m_xidCon->Write(change_baud_cmd, 3, &bytes_written);

    m_xidCon->SetBaudRate(rate);
    CloseConnection();
    OpenConnection();
}
Beispiel #28
0
void EngineClient::run()
{
    working=true;
    //Set default values
    readyToSendLvlx = false;
    _busy = false;
    OpenConnection();
    _connected=true;
    msleep(100);
    alreadyRequested=false;
    exec();
    emit closed();
    _connected=false;
    working=false;
}
Beispiel #29
0
bool MySQLConnection::HandleMySQLError(uint32 errNo)
{
    switch (errNo)
    {
        case CR_SERVER_GONE_ERROR:
        case CR_SERVER_LOST:
        case CR_INVALID_CONN_HANDLE:
        case CR_SERVER_LOST_EXTENDED:
        {
            uint64 oldThreadId = mysql_thread_id(mMysql);
            mysql_close(mMysql);

            if (OpenConnection(true))
            {
                FreePreparedStatements(); // We need to prepare everything again!
                sLog.outString("Reconnection attempt to database %s (on %s)", m_database.c_str(), m_host.c_str());
                if (oldThreadId != mysql_thread_id(mMysql))
                    sLog.outString("Successfully reconnected to %s @%s:%u.",
                        m_database.c_str(), m_host.c_str(), m_port);

                return true;
            }

            return false; // Failed to reconnect
        }

        case ER_LOCK_DEADLOCK:
            return false;
        // Query related errors - skip query
        case ER_WRONG_VALUE_COUNT:
        case ER_DUP_ENTRY:
            return false;

        // Outdated table or database structure - terminate core
        case ER_BAD_FIELD_ERROR:
        case ER_NO_SUCH_TABLE:
            sLog.outErrorDb("Your database structure is not up to date. Please make sure you have executed all the queries in the sql/updates folders.");
            ASSERT(false);
            return false;
        case ER_PARSE_ERROR:
            sLog.outErrorDb("Error while parsing SQL. Core fix required.");
            ASSERT(false);
            return false;
        default:
            sLog.outErrorDb("Unhandled MySQL errno %u. Unexpected behaviour possible.", errNo);
            return false;
    }
}
Beispiel #30
0
bool InputImpl::isMouseButtonPressed(Mouse::Button button)
{
    // Open a connection with the X server
    xcb_connection_t* connection = OpenConnection();

    ScopedXcbPtr<xcb_generic_error_t> error(NULL);

    // Get pointer mask
    ScopedXcbPtr<xcb_query_pointer_reply_t> pointer(
        xcb_query_pointer_reply(
            connection,
            xcb_query_pointer(
                connection,
                XCBDefaultRootWindow(connection)
            ),
            &error
        )
    );

    // Close the connection with the X server
    CloseConnection(connection);

    if (error)
    {
        err() << "Failed to query pointer" << std::endl;

        return false;
    }

    uint16_t buttons = pointer->mask;

    switch (button)
    {
    case Mouse::Left:
        return buttons & XCB_BUTTON_MASK_1;
    case Mouse::Right:
        return buttons & XCB_BUTTON_MASK_3;
    case Mouse::Middle:
        return buttons & XCB_BUTTON_MASK_2;
    case Mouse::XButton1:
        return false; // not supported by X
    case Mouse::XButton2:
        return false; // not supported by X
    default:
        return false;
    }
}