def Start(self):
        '''Start client side'''
        client_log.debug('[dbus] start client')

        if self._status >= constants.CLIENT_STATUS_STARTED:
            client_log.warn('[dbus] already started: %s' % self._status)
            return

        self.main_window = MainWindow()

        # Stop host service when main window is closed
        if not self.main_window:
            client_host.critical('[dbus] Failed to init main window!')
            self.Stop()
        self.main_window.windowClosed.connect(self.Stop)
        self.main_window.show()

        self.client_host = Client(self)
        self.client_host.start()

        self.StatusChanged(constants.CLIENT_STATUS_STARTED)

        # Init webserver-connection-timed-out timer
        QtCore.QTimer.singleShot(constants.WEBSERVER_CONNECTION_TIMEOUT,
                                 self.on_webserver_connection_timeout)

        screensaver_iface = ScreenSaver()
        if screensaver_iface.check():
            self.screensaver_iface = screensaver_iface
            self.screensaver_iface.inhibit()
    def Start(self):
        '''Start client side'''
        client_log.debug('[dbus] start client')

        if self._status >= constants.CLIENT_STATUS_STARTED:
            client_log.warn('[dbus] already started: %s' % self._status)
            return

        self.main_window = MainWindow()

        # Stop host service when main window is closed
        if not self.main_window:
            client_host.critical('[dbus] Failed to init main window!')
            self.Stop()
        self.main_window.windowClosed.connect(self.Stop)
        self.main_window.show()

        self.client_host = Client(self)
        self.client_host.start()

        self.StatusChanged(constants.CLIENT_STATUS_STARTED)

        # Init webserver-connection-timed-out timer
        QtCore.QTimer.singleShot(constants.WEBSERVER_CONNECTION_TIMEOUT,
                                 self.on_webserver_connection_timeout)

        screensaver_iface = ScreenSaver()
        if screensaver_iface.check():
            self.screensaver_iface = screensaver_iface
            self.screensaver_iface.inhibit()
예제 #3
0
def handle(msg):
    '''Handle clipboard data messages'''
    try:
        msg = json.loads(msg)
    except ValueError as e:
        client_log.warn('[clipboard] Warning: handle this error: %s' % e)
        return
    if msg['type'] == constants.CLIPBOARD_TEXT:
        clipboard_daemon.set_text(msg['payload'])
    elif msg['type'] == constants.CLIPBOARD_PIXMAP:
        clipboard_daemon.set_pixmap(msg['payload'])
    else:
        client_log.warn('[clipboard] unsupported clipboard data %s.' % msg)
def handle(msg):
    '''Handle clipboard data messages'''
    try:
        msg = json.loads(msg)
    except ValueError as e:
        client_log.warn('[clipboard] Warning: handle this error: %s' % e)
        return
    if msg['type'] == constants.CLIPBOARD_TEXT:
        clipboard_daemon.set_text(msg['payload'])
    elif msg['type'] == constants.CLIPBOARD_PIXMAP:
        clipboard_daemon.set_pixmap(msg['payload'])
    else:
        client_log.warn('[clipboard] unsupported clipboard data %s.' % msg)
예제 #5
0
    def start_server(self):
        for port in range(PORT_MIN, PORT_MAX):
            try:
                self.application.listen(port)
                break
            # That port is unavailable
            except OSError:
                pass
        else:
            client_log.warn('[wssd] failed to start websocket server')
            return

        self.port = port
        self.loop = tornado.ioloop.IOLoop.instance()
        self.loop.start()
def main():
    if is_client_dbus_running():
        client_log.warn('[client] client side is running')
        return
#    if is_server_dbus_running():
#        client_log.warn('[client] server side is running')
#        return
    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(_(APP_NAME))

    client_dbus = ClientDBus()
    # FIXME: log service failed to dump log
    client_log.debug('Init client dbus: %s' % client_dbus)

    app.exec()
예제 #7
0
    def start_server(self):
        for port in range(PORT_MIN, PORT_MAX):
            try:
                self.application.listen(port)
                break
            # That port is unavailable
            except OSError:
                pass
        else:
            client_log.warn('[wssd] failed to start websocket server')
            return

        self.port = port
        self.loop = tornado.ioloop.IOLoop.instance()
        self.loop.start()
예제 #8
0
def main():
    if is_client_dbus_running():
        client_log.warn('[client] client side is running')
        return


#    if is_server_dbus_running():
#        client_log.warn('[client] server side is running')
#        return
    app = QtWidgets.QApplication(sys.argv)
    app.setApplicationName(_(APP_NAME))

    client_dbus = ClientDBus()
    # FIXME: log service failed to dump log
    client_log.debug('Init client dbus: %s' % client_dbus)

    app.exec()
예제 #9
0
 def onClipboardDataChanged(self):
     # If connection not initialized, ignore current clipboard content
     if not connection:
         return
     text = self.clipboard.text(QtGui.QClipboard.Clipboard)
     pixmap = self.clipboard.pixmap(QtGui.QClipboard.Clipboard)
     # Check text first
     if text:
         msg = {
             'type': constants.CLIPBOARD_TEXT,
             'payload': text,
         }
         send_message(json.dumps(msg))
     elif pixmap:
         msg = {
             'type': constants.CLIPBOARD_PIXMAP,
             'payload': pixmap,
         }
         print('TODO: [clipboard] serialize pixmap:', pixmap)
     else:
         client_log.warn('[clipboard] unknown clipboard data')
 def onClipboardDataChanged(self):
     # If connection not initialized, ignore current clipboard content
     if not connection:
         return
     text = self.clipboard.text(QtGui.QClipboard.Clipboard)
     pixmap = self.clipboard.pixmap(QtGui.QClipboard.Clipboard)
     # Check text first
     if text:
         msg = {
             'type': constants.CLIPBOARD_TEXT,
             'payload': text,
         }
         send_message(json.dumps(msg))
     elif pixmap:
         msg = {
             'type': constants.CLIPBOARD_PIXMAP,
             'payload': pixmap,
         }
         print('TODO: [clipboard] serialize pixmap:', pixmap)
     else:
         client_log.warn('[clipboard] unknown clipboard data')
예제 #11
0
def handle(msg):
    '''Handle cmd messages'''
    if not client_dbus:
        client_log.warn('[cmd] client dbus is uninitialized')
        return
    try:
        msg = json.loads(msg)
    except ValueError as e:
        client_log.warn('[cmd] Warning: handle this error: %s' % e)
        return

    router = {
        constants.CLIENT_MSG_READY: constants.CLIENT_STATUS_PAGE_READY,
        constants.CLIENT_MSG_CONNECTED: constants.CLIENT_STATUS_CONNECT_OK,
        constants.CLIENT_MSG_UNAVAILABLE: constants.CLIENT_STATUS_UNAVAILABLE,
        constants.CLIENT_MSG_DISCONNECTED: constants.CLIENT_STATUS_DISCONNECTED,
    }

    if msg['Type'] == constants.CLIENT_MSG_READY:
        client_dbus.StatusChanged(constants.CLIENT_STATUS_PAGE_READY)
    elif msg['Type'] == constants.CLIENT_MSG_CONNECTED:
        client_dbus.StatusChanged(constants.CLIENT_STATUS_CONNECT_OK)
        try:
            video = json.loads(msg['Payload'])
        except ValueError as e:
            client_log.warn('[cmd] Failed to read video info: %s, %s' %
                    (e, msg['Payload']))
            return

        # Notify qml about video property
        client_dbus.main_window.root.setVideoAspectRatio(video['width'],
                                                         video['height'])

    elif msg['Type'] == constants.CLIENT_MSG_UNAVAILABLE:
        client_dbus.StatusChanged(constants.CLIENT_STATUS_UNAVAILABLE)
    elif msg['Type'] == constants.CLIENT_MSG_DISCONNECTED:
        client_dbus.StatusChanged(constants.CLIENT_STATUS_DISCONNECTED)
    else:
        lient_log.warn('[cmd] Warning: handle this message: %s' % msg)
예제 #12
0
 def on_webrtc_connection_timeout(self):
     '''Handle WebRTC connection timeout signal'''
     if not self.remoting_connected:
         client_log.warn('[dbus] connected to remote peer timeout')
         self.StatusChanged(constants.CLIENT_STATUS_CONNECT_FAILED)
예제 #13
0
 def on_webserver_connection_timeout(self):
     '''Handle webserver connection timeout signal'''
     if not self.connected_to_webserver:
         client_log.warn('[dbus] connected to webserver timeout')
         self.StatusChanged(constants.CLIENT_STATUS_CONNECT_FAILED)
 def on_webrtc_connection_timeout(self):
     '''Handle WebRTC connection timeout signal'''
     if not self.remoting_connected:
         client_log.warn('[dbus] connected to remote peer timeout')
         self.StatusChanged(constants.CLIENT_STATUS_CONNECT_FAILED)
 def on_webserver_connection_timeout(self):
     '''Handle webserver connection timeout signal'''
     if not self.connected_to_webserver:
         client_log.warn('[dbus] connected to webserver timeout')
         self.StatusChanged(constants.CLIENT_STATUS_CONNECT_FAILED)