ubit
Classes | Public Member Functions | Protected Attributes | List of all members
ubit::UMService Class Reference

UMService: Ubit Mouse/Message Service. More...

#include <umservice.hpp>

Inheritance diagram for ubit::UMService:
ubit::USocket

Classes

struct  BrowseReply
 see browseUMServers(). More...
 
struct  ResolveReply
 see resolveUMServer(). More...
 

Public Member Functions

 UMService (const UStr &host, int port=0)
 opens a connection with a remote UMS server (Ubit Mouse/Message Server). More...
 
bool browseUMServers (UCall &callback)
 browse available UMSservers on a local net by using ZeroConf/Rendezvous. More...
 
bool resolveUMServer (const UStr &name, UCall &callback)
 resolves a UMS server name into a IP address by using ZeroConf/Rendezvous. More...
 
bool browseUMSNeighbors (UCall &callback)
 browse the neigbors of this UMS. More...
 
bool pressMouse (int event_flow, int button_id)
 
bool releaseMouse (int event_flow, int button_id)
 
bool moveMouse (int event_flow, int x, int y, bool absolute_coords)
 control the pointer(s) of the display managed by this UMS server. More...
 
bool pressKey (int event_flow, int keycode)
 
bool releaseKey (int event_flow, int keycode)
 sends key events on the display managed by this UMS server. More...
 
bool sendMouseClick (const char *target, int x, int y, int button_id, int modifiers)
 
bool sendMousePress (const char *target, int x, int y, int button_id, int modifiers)
 
bool sendMouseRelease (const char *target, int x, int y, int button_id, int modifiers)
 sends an event to a window located on the display managed by this UMS server. More...
 
bool sendMessage (const char *target, const UStr &message)
 
bool sendMessage (const char *target, const char *message)
 sends a message to a target window located on the display managed by this UMS server. More...
 
bool sendRequest (int ums_request, const UStr &data)
 
bool sendRequest (int ums_request, const char *data=null)
 sends a request to the UMS server (see UMSrequest).
 
 UMService (const UStr &host, int port, const char *client_name)
 [impl].
 
virtual void inputCallback ()
 [impl].
 
- Public Member Functions inherited from ubit::USocket
 USocket (const char *remote_host, int remote_port)
 
 USocket (const UStr &remote_host, int remote_port)
 
virtual int connect (const char *remote_host, int remote_port)
 
virtual void close ()
 
virtual void onInput (UCall &)
 adds a callback that is fired when data is received on the socket.
 
bool isConnected () const
 
int getRemotePort () const
 
int getDescriptor () const
 
bool sendBlock (const char *buffer, unsigned short size)
 see receiveBlock().
 
bool sendBlock (UOutbuf &)
 see receiveBlock().
 
bool receiveBlock (UInbuf &)
 simplified block oriented I/O. More...
 
bool sendBytes (const char *buffer, unsigned int size)
 see receiveBytes().
 
bool receiveBytes (char *buffer, unsigned int size)
 byte oriented I/O. More...
 

Protected Attributes

uptr< UCallbrowse_call
 
uptr< UCallneighbor_call
 
- Protected Attributes inherited from ubit::USocket
int remport
 
int sock
 
struct sockaddr_in * sin
 
USourceinput
 

Detailed Description

UMService: Ubit Mouse/Message Service.

Constructor & Destructor Documentation

§ UMService()

ubit::UMService::UMService ( const UStr host,
int  port = 0 
)

opens a connection with a remote UMS server (Ubit Mouse/Message Server).

This makes it possible to control the pointer(s) of a remote X display, to send text or events to the windows that are located on this display, and many other things (see umsproto.hpp and directory ubit/ums)

Args:

  • host: the host where the UMS server is running
  • port: the port of the UMS server. A value of 0 (the default) means that UMS_PORT (ie. 9666) is used.

Note: the UMS server (ie. the 'umsd' program) must already be running on the (local or remote) host. umsd can be found in directory ubit/ums

Member Function Documentation

§ browseUMServers()

bool ubit::UMService::browseUMServers ( UCall callback)

browse available UMSservers on a local net by using ZeroConf/Rendezvous.

Exemple:


o is an instance of Obj, a an instance of Arg (callback methods,
such as foo(), can have 0 to 2 args)
     ums->browseUMServers( ucall(o, a, &Obj::foo) );
     ....
     void Obj::foo(UEvent& e, Arg a) {
     UMService::BrowseReply r(e);
     cerr << "browse: " << r.serviceName << endl;
     if (r.isAdded())
     ....;    // this UMS server has been added
     else ...;
     }
     

§ browseUMSNeighbors()

bool ubit::UMService::browseUMSNeighbors ( UCall callback)

browse the neigbors of this UMS.

use UMService::ResolveReply in the callback function. flags indicates the position and is one of 't', 'b', 'l', 'r'.

§ moveMouse()

bool ubit::UMService::moveMouse ( int  event_flow,
int  x,
int  y,
bool  absolute_coords 
)

control the pointer(s) of the display managed by this UMS server.

args:

  • event_flow = 0 identifies the native X event flow
  • event_flow > 0 are alternate mouse event flows
  • button_mask is one of UEvent::MButton1, MButton2, MButton3...
  • x and y are screen coordinates if 'absolute_coords' is true and relative to the previous location of the mouse otherwise. notes:
  • press and release events MUST be balanced
  • only ONE mouse button at a time (button_mask should not be ORed)

§ releaseKey()

bool ubit::UMService::releaseKey ( int  event_flow,
int  keycode 
)

sends key events on the display managed by this UMS server.

see: pressMouse().

§ resolveUMServer()

bool ubit::UMService::resolveUMServer ( const UStr name,
UCall callback 
)

resolves a UMS server name into a IP address by using ZeroConf/Rendezvous.

Args:

  • 'name' : the UMS server name to resolve
  • 'callback' is fired when the address is resolved and is then automatically destroyed (except if it is pointed by a uptr<>).

Exemple:


o is an instance of Obj, a an instance of Arg (callback methods,
such as foo(), can have 0 to 2 args)
     ums->resolveUMServer(name, ucall(o, a, &Obj::foo));
     ....
     void Obj::foo(UEvent& e, Arg a) {
     UMService::ResolveReply r(e);
r.hosttarget = IP address / r.port = the port (9666 by default)
     cerr << "resolve: " << r.hosttarget << " " << r.port << endl;
     }
     

§ sendMessage()

bool ubit::UMService::sendMessage ( const char *  target,
const char *  message 
)

sends a message to a target window located on the display managed by this UMS server.

window = name or X ID of the window, can be one of:

  • name-without-blanks
  • quoted 'name' (can contain blanks)
  • decimal ID (1234)
  • hexadecimal ID (0x1234a)

§ sendMouseRelease()

bool ubit::UMService::sendMouseRelease ( const char *  target,
int  x,
int  y,
int  button_id,
int  modifiers 
)

sends an event to a window located on the display managed by this UMS server.

in contrast with pressMouse() etc. these functions do not control the pointers, they just send events to a given window.

Args:

  • target = see sendMessage()
  • x and y are relative to the target window
  • 'button_mask' is one of UEvent::MButton1, MButton2, MButton3... Notes:
  • press and release events MUST be balanced.
  • only ONE mouse button at a time (button_mask should not be ORed)

The documentation for this class was generated from the following files: