def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) self.RegisterHandler(handler) self.carbon = Carbon() self.coref = CoreFoundation() self.center = self.coref.CFDistributedNotificationCenter() self.is_available = False self.client_id = -1
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys())) self.hwnd = None self.Skype = None self.RegisterHandler(handler) self._SkypeControlAPIDiscover = windll.user32.RegisterWindowMessageA('SkypeControlAPIDiscover') self._SkypeControlAPIAttach = windll.user32.RegisterWindowMessageA('SkypeControlAPIAttach') windll.user32.GetWindowLongA.restype = c_ulong self.start() # wait till the thread initializes while not self.hwnd: time.sleep(0.01)
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys())) self.hwnd = None self.Skype = None self.RegisterHandler(handler) self._SkypeControlAPIDiscover = windll.user32.RegisterWindowMessageA( 'SkypeControlAPIDiscover') self._SkypeControlAPIAttach = windll.user32.RegisterWindowMessageA( 'SkypeControlAPIAttach') windll.user32.GetWindowLongA.restype = c_ulong self.start() # wait till the thread initializes while not self.hwnd: time.sleep(0.01)
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) self.RegisterHandler(handler) self.skype_in = self.skype_out = self.dbus_name_owner_watch = None self.bus = opts.pop('Bus', None) try: mainloop = opts.pop('MainLoop') if self.bus is not None: raise TypeError('Bus and MainLoop cannot be used at the same time!') except KeyError: if self.bus is None: import dbus.mainloop.glib import gobject gobject.threads_init() dbus.mainloop.glib.threads_init() mainloop = dbus.mainloop.glib.DBusGMainLoop() self.mainloop = gobject.MainLoop() if self.bus is None: from dbus import SessionBus self.bus = SessionBus(private=True, mainloop=mainloop) if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys()))
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) self.RegisterHandler(handler) self.skype_in = self.skype_out = self.dbus_name_owner_watch = None self.bus = opts.pop('Bus', None) try: mainloop = opts.pop('MainLoop') if self.bus is not None: raise TypeError( 'Bus and MainLoop cannot be used at the same time!') except KeyError: if self.bus is None: import dbus.mainloop.glib import gobject gobject.threads_init() dbus.mainloop.glib.threads_init() mainloop = dbus.mainloop.glib.DBusGMainLoop() self.mainloop = gobject.MainLoop() if self.bus is None: from dbus import SessionBus self.bus = SessionBus(private=True, mainloop=mainloop) if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys()))
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) self.RegisterHandler(handler) # check options if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys())) # setup Xlib libpath = find_library('X11') if not libpath: raise ImportError('Could not find X11 library') self.x11 = cdll.LoadLibrary(libpath) # setup Xlib function prototypes self.x11.XCloseDisplay.argtypes = (DisplayP,) self.x11.XCloseDisplay.restype = None self.x11.XCreateSimpleWindow.argtypes = (DisplayP, Window, c_int, c_int, c_uint, c_uint, c_uint, c_ulong, c_ulong) self.x11.XCreateSimpleWindow.restype = Window self.x11.XDefaultRootWindow.argtypes = (DisplayP,) self.x11.XDefaultRootWindow.restype = Window self.x11.XDeleteProperty.argtypes = (DisplayP, Window, Atom) self.x11.XDeleteProperty.restype = None self.x11.XDestroyWindow.argtypes = (DisplayP, Window) self.x11.XDestroyWindow.restype = None self.x11.XPending.argtypes = (DisplayP,) self.x11.XPending.restype = c_int self.x11.XGetAtomName.argtypes = (DisplayP, Atom) self.x11.XGetAtomName.restype = c_char_p self.x11.XGetErrorText.argtypes = (DisplayP, c_int, c_char_p, c_int) self.x11.XGetErrorText.restype = None self.x11.XGetWindowProperty.argtypes = (DisplayP, Window, Atom, c_long, c_long, Bool, Atom, AtomP, c_int_p, c_ulong_p, c_ulong_p, POINTER(POINTER(Window))) self.x11.XGetWindowProperty.restype = c_int self.x11.XInitThreads.argtypes = () self.x11.XInitThreads.restype = Status self.x11.XInternAtom.argtypes = (DisplayP, c_char_p, Bool) self.x11.XInternAtom.restype = Atom self.x11.XNextEvent.argtypes = (DisplayP, XEventP) self.x11.XNextEvent.restype = None self.x11.XOpenDisplay.argtypes = (c_char_p,) self.x11.XOpenDisplay.restype = DisplayP self.x11.XSelectInput.argtypes = (DisplayP, Window, c_long) self.x11.XSelectInput.restype = None self.x11.XSendEvent.argtypes = (DisplayP, Window, Bool, c_long, XEventP) self.x11.XSendEvent.restype = Status self.x11.XSetErrorHandler.argtypes = (XErrorHandlerP,) self.x11.XSetErrorHandler.restype = None self.x11.XLockDisplay.argtypes = (DisplayP,) self.x11.XLockDisplay.restype = None self.x11.XUnlockDisplay.argtypes = (DisplayP,) self.x11.XUnlockDisplay.restype = None # init Xlib self.x11.XInitThreads() self.error = None # callback has to be saved to keep reference to bound method self._error_handler_callback = XErrorHandlerP(self._error_handler) self.x11.XSetErrorHandler(self._error_handler_callback) self.disp = self.x11.XOpenDisplay(None) if not self.disp: raise ISkypeAPIError('Could not open XDisplay') self.win_root = self.x11.XDefaultRootWindow(self.disp) self.win_self = self.x11.XCreateSimpleWindow(self.disp, self.win_root, 100, 100, 100, 100, 1, 0, 0) self.x11.XSelectInput(self.disp, self.win_root, _PropertyChangeMask) self.win_skype = self.get_skype() ctrl = 'SKYPECONTROLAPI_MESSAGE' self.atom_msg = self.x11.XInternAtom(self.disp, ctrl, False) self.atom_msg_begin = self.x11.XInternAtom(self.disp, ctrl + '_BEGIN', False) self.loop_event = threading.Event() self.loop_timeout = 0.0001 self.loop_break = False
def __init__(self, handler, opts): _ISkypeAPIBase.__init__(self, opts) self.RegisterHandler(handler) # check options if opts: raise TypeError('Unexpected parameter(s): %s' % ', '.join(opts.keys())) # setup Xlib libpath = find_library('X11') if not libpath: raise ImportError('Could not find X11 library') self.x11 = cdll.LoadLibrary(libpath) # setup Xlib function prototypes self.x11.XCloseDisplay.argtypes = (DisplayP, ) self.x11.XCloseDisplay.restype = None self.x11.XCreateSimpleWindow.argtypes = (DisplayP, Window, c_int, c_int, c_uint, c_uint, c_uint, c_ulong, c_ulong) self.x11.XCreateSimpleWindow.restype = Window self.x11.XDefaultRootWindow.argtypes = (DisplayP, ) self.x11.XDefaultRootWindow.restype = Window self.x11.XDeleteProperty.argtypes = (DisplayP, Window, Atom) self.x11.XDeleteProperty.restype = None self.x11.XDestroyWindow.argtypes = (DisplayP, Window) self.x11.XDestroyWindow.restype = None self.x11.XPending.argtypes = (DisplayP, ) self.x11.XPending.restype = c_int self.x11.XGetAtomName.argtypes = (DisplayP, Atom) self.x11.XGetAtomName.restype = c_char_p self.x11.XGetErrorText.argtypes = (DisplayP, c_int, c_char_p, c_int) self.x11.XGetErrorText.restype = None self.x11.XGetWindowProperty.argtypes = (DisplayP, Window, Atom, c_long, c_long, Bool, Atom, AtomP, c_int_p, c_ulong_p, c_ulong_p, POINTER(POINTER(Window))) self.x11.XGetWindowProperty.restype = c_int self.x11.XInitThreads.argtypes = () self.x11.XInitThreads.restype = Status self.x11.XInternAtom.argtypes = (DisplayP, c_char_p, Bool) self.x11.XInternAtom.restype = Atom self.x11.XNextEvent.argtypes = (DisplayP, XEventP) self.x11.XNextEvent.restype = None self.x11.XOpenDisplay.argtypes = (c_char_p, ) self.x11.XOpenDisplay.restype = DisplayP self.x11.XSelectInput.argtypes = (DisplayP, Window, c_long) self.x11.XSelectInput.restype = None self.x11.XSendEvent.argtypes = (DisplayP, Window, Bool, c_long, XEventP) self.x11.XSendEvent.restype = Status self.x11.XSetErrorHandler.argtypes = (XErrorHandlerP, ) self.x11.XSetErrorHandler.restype = None self.x11.XLockDisplay.argtypes = (DisplayP, ) self.x11.XLockDisplay.restype = None self.x11.XUnlockDisplay.argtypes = (DisplayP, ) self.x11.XUnlockDisplay.restype = None # init Xlib self.x11.XInitThreads() self.error = None # callback has to be saved to keep reference to bound method self._error_handler_callback = XErrorHandlerP(self._error_handler) self.x11.XSetErrorHandler(self._error_handler_callback) self.disp = self.x11.XOpenDisplay(None) if not self.disp: raise ISkypeAPIError('Could not open XDisplay') self.win_root = self.x11.XDefaultRootWindow(self.disp) self.win_self = self.x11.XCreateSimpleWindow(self.disp, self.win_root, 100, 100, 100, 100, 1, 0, 0) self.x11.XSelectInput(self.disp, self.win_root, _PropertyChangeMask) self.win_skype = self.get_skype() ctrl = 'SKYPECONTROLAPI_MESSAGE' self.atom_msg = self.x11.XInternAtom(self.disp, ctrl, False) self.atom_msg_begin = self.x11.XInternAtom(self.disp, ctrl + '_BEGIN', False) self.loop_event = threading.Event() self.loop_timeout = 0.0001 self.loop_break = False