# later version. See the file COPYING for details. # only works with gtk2: import os from gtk import gdk assert gdk import gtk.gdkgl, gtk.gtkgl # @UnresolvedImport assert gtk.gdkgl is not None and gtk.gtkgl is not None import gobject from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_OPENGL_DEBUG") OPENGL_DEBUG = os.environ.get("XPRA_OPENGL_DEBUG", "0") == "1" from xpra.codecs.codec_constants import get_subsampling_divs from xpra.client.gl.gl_check import get_DISPLAY_MODE from xpra.client.gl.gl_colorspace_conversions import YUV2RGB_shader, RGBP2RGB_shader from xpra.client.gtk2.window_backing import GTK2WindowBacking, fire_paint_callbacks from OpenGL.GL import ( GL_PROJECTION, GL_MODELVIEW, GL_UNPACK_ROW_LENGTH, GL_UNPACK_ALIGNMENT, GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST,
# This file is part of Xpra. # Copyright (C) 2013-2014 Antoine Martin <*****@*****.**> # Copyright (C) 2008 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import socket import os import signal import gobject gobject.threads_init() from threading import Timer from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_PROXY_DEBUG") from xpra.server.server_core import get_server_info, get_thread_info from xpra.scripts.server import deadly_signal from xpra.net.protocol import Protocol, Compressed, compressed_wrapper, new_cipher_caps, get_network_caps from xpra.codecs.image_wrapper import ImageWrapper from xpra.os_util import Queue, SIGNAMES from xpra.util import typedict from xpra.daemon_thread import make_daemon_thread from xpra.scripts.config import parse_number, parse_bool from multiprocessing import Process PROXY_QUEUE_SIZE = int(os.environ.get("XPRA_PROXY_QUEUE_SIZE", "10")) #for testing only: passthrough as RGB: PASSTHROUGH = False
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys import os.path from xpra.scripts.exec_util import safe_exec from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_SOUND_DEBUG") def which(name): if sys.platform.startswith("win"): return "" cmd = ["which", name] try: returncode, out, _ = safe_exec(cmd, log_errors=False) if returncode!=0 or not out: return "" c = out.replace("\n", "").replace("\r", "") if os.path.exists(c) and os.path.isfile(c): if os.name=="posix" and not os.access(c, os.X_OK): #odd, it's there but we can't run it!? return "" return c return ""
# This file is part of Xpra. # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import ctypes from xpra.os_util import strtobytes from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_MMAP_DEBUG") warn = log.warn """ Utility functions for communicating via mmap """ def init_client_mmap(token, mmap_group=None, socket_filename=None): """ Initializes an mmap area, writes the token in it and returns: (success flag, mmap_area, mmap_size, temp_file, mmap_filename) The caller must keep hold of temp_file to ensure it does not get deleted! This is used by the client. """ debug("init_mmap(%s, %s, %s)", token, mmap_group, socket_filename) try: import mmap import tempfile from stat import S_IRUSR,S_IWUSR,S_IRGRP,S_IWGRP mmap_dir = os.getenv("TMPDIR", "/tmp")
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.codecs.csc_nvcuda.CUDA_kernels import gen_rgb_to_yuv_kernels from xpra.codecs.image_wrapper import ImageWrapper from xpra.codecs.codec_constants import codec_spec, get_subsampling_divs from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CUDA_DEBUG") error = log.error import threading import os import numpy import time assert bytearray import pycuda #@UnresolvedImport from pycuda import driver #@UnresolvedImport from pycuda.compiler import compile #@UnresolvedImport driver.init() DEFAULT_CUDA_DEVICE_ID = int(os.environ.get("XPRA_CUDA_DEVICE", "0")) COLORSPACES_MAP = { "BGRA": ("YUV420P", "YUV422P", "YUV444P"), "BGRX": ("YUV420P", "YUV422P", "YUV444P"), "RGBA": ("YUV420P", "YUV422P", "YUV444P"), "RGBX": ("YUV420P", "YUV422P", "YUV444P"), } KERNELS_MAP = {}
# coding=utf8 # This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_VIDEOPIPELINE_DEBUG") from xpra.scripts.config import csc_swscale, enc_vpx, enc_x264 class VideoPipelineHelper(object): _video_encoder_specs = {} _csc_encoder_specs = {} def may_init(self): if len(self._video_encoder_specs) == 0: self.init_video_encoders_options() if len(self._csc_encoder_specs) == 0: self.init_csc_options() def get_encoder_specs(self, encoding): return self._video_encoder_specs.get(encoding, []) def get_csc_specs(self, src_format): return self._csc_encoder_specs.get(src_format, []) def init_video_options(self):
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.codecs.csc_nvcuda.CUDA_kernels import gen_rgb_to_yuv_kernels from xpra.codecs.image_wrapper import ImageWrapper from xpra.codecs.codec_constants import codec_spec, get_subsampling_divs from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CUDA_DEBUG") error = log.error import threading import os import numpy import time assert bytearray import pycuda #@UnresolvedImport from pycuda import driver #@UnresolvedImport from pycuda.compiler import compile #@UnresolvedImport driver.init() DEFAULT_CUDA_DEVICE_ID = int(os.environ.get("XPRA_CUDA_DEVICE", "0")) COLORSPACES_MAP = { "BGRA" : ("YUV420P", "YUV422P", "YUV444P"), "BGRX" : ("YUV420P", "YUV422P", "YUV444P"), "RGBA" : ("YUV420P", "YUV422P", "YUV444P"), "RGBX" : ("YUV420P", "YUV422P", "YUV444P"), }
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os as os import sys as sys from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_IMPORT_DEBUG") _init_done = False def init(): global _init_done if not _init_done: _init_done = True do_init() def do_init(): pass def platform_import(where, pm, required, *imports): if os.name == "nt": p = "win32" elif sys.platform.startswith("darwin"): p = "darwin" elif os.name == "posix": p = "xposix" else:
import struct import re import binascii from xpra.gtk_common.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3 gobject = import_gobject() gtk = import_gtk() gdk = import_gdk() if is_gtk3(): PROPERTY_CHANGE_MASK = gdk.EventMask.PROPERTY_CHANGE_MASK else: PROPERTY_CHANGE_MASK = gdk.PROPERTY_CHANGE_MASK from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CLIPBOARD_DEBUG") from xpra.gtk_common.gobject_util import n_arg_signal from xpra.gtk_common.nested_main import NestedMainLoop from xpra.net.protocol import compressed_wrapper MAX_CLIPBOARD_PACKET_SIZE = 256 * 1024 ALL_CLIPBOARDS = ["CLIPBOARD", "PRIMARY", "SECONDARY"] CLIPBOARDS = ALL_CLIPBOARDS CLIPBOARDS_ENV = os.environ.get("XPRA_CLIPBOARDS") if CLIPBOARDS_ENV is not None: CLIPBOARDS = CLIPBOARDS_ENV.split(",") CLIPBOARDS = [x.upper().strip() for x in CLIPBOARDS] TEST_DROP_CLIPBOARD_REQUESTS = int(
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.keyboard.mask import mask_to_names, MODIFIER_MAP from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_KEYBOARD_DEBUG") class KeyboardBase(object): def __init__(self): self.modifier_mappings = {} self.modifier_keys = {} self.modifier_keycodes = {} # FIXME: this only allows a single modifier per mask # and in some cases we want to allow other modifier names # to use the same mask... (ie: META on OSX) self.modifier_map = MODIFIER_MAP def cleanup(self): pass def has_bell(self): return False def set_modifier_mappings(self, mappings): debug("set_modifier_mappings(%s)", mappings)
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import time from threading import Event from xpra.daemon_thread import make_daemon_thread from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_UIWATCHER_DEBUG") from xpra.platform.features import UI_THREAD_POLLING FAKE_UI_LOCKUPS = int(os.environ.get("XPRA_FAKE_UI_LOCKUPS", "0")) if FAKE_UI_LOCKUPS > 0 and UI_THREAD_POLLING <= 0: #even if the platform normally disables UI thread polling, #we need it for testing: UI_THREAD_POLLING = 1000 POLLING = int(os.environ.get("XPRA_UI_THREAD_POLLING", UI_THREAD_POLLING)) class UI_thread_watcher(object): """ Allows us to register callbacks to fire when the UI thread fails to run or when it resumes. We run a dedicated thread to verify that the UI thread has run since the last time it was scheduled to run. Beware that the callbacks (fail, resume and alive)
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CODEC_DEBUG") error = log.error warn = log.warn codecs = {} def codec_import_check(name, description, top_module, class_module, *classnames): debug("codec_import_check%s", (name, description, top_module, class_module, classnames)) try: try: __import__(top_module, {}, {}, []) debug(" %s found, will check for %s in %s", top_module, classnames, class_module) for classname in classnames: ic = __import__(class_module, {}, {}, classname) #warn("codec_import_check(%s, ..)=%s" % (name, ic)) debug(" found %s : %s", name, ic) codecs[name] = ic return ic except ImportError, e: debug(" cannot import %s (%s): %s", name, description, e) #the required module does not exist debug(" xpra was probably built with the option: --without-%s", name) except Exception, e: warn("cannot load %s (%s): %s missing from %s: %s", name, description, classname, class_module, e)
# later version. See the file COPYING for details. import gobject from xpra.gtk_common.gobject_util import one_arg_signal from xpra.x11.gtk_x11.gdk_bindings import ( add_event_receiver, #@UnresolvedImport remove_event_receiver, #@UnresolvedImport get_xwindow, #@UnresolvedImport get_parent) #@UnresolvedImport from xpra.x11.gtk_x11.error import trap from xpra.x11.bindings.window_bindings import constants, X11WindowBindings #@UnresolvedImport X11Window = X11WindowBindings() from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_GRAB_DEBUG") NotifyNormal = constants["NotifyNormal"] NotifyGrab = constants["NotifyGrab"] NotifyUngrab = constants["NotifyUngrab"] GRAB_CONSTANTS = { NotifyNormal : "NotifyNormal", NotifyGrab : "NotifyGrab", NotifyUngrab : "NotifyUngrab" } class PointerGrabHelper(gobject.GObject): """ Listens for StructureNotifyMask events on the window and its parents.
#1) either a single password with no "|" characters, which will be used for all usernames #2) a list of entries of the form: # username|password|uid|gid|displays|env_options|session_options # import binascii import os.path import sys import hmac from xpra.os_util import get_hex_uuid from xpra.util import xor from xpra.dotxpra import DotXpra from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_AUTH_DEBUG") password_file = None socket_dir = None def init(opts): global password_file, socket_dir password_file = opts.password_file socket_dir = opts.socket_dir def parseOptions(s): #ie: s="compression_level=1;lz4=0", ... #alternatives: ast, json/simplejson, ... if not s: return {}
import sys from socket import error as socket_error import struct import os import threading import errno import binascii from threading import Lock ZLIB_FLAG = 0x00 LZ4_FLAG = 0x10 from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_NETWORK_DEBUG") from xpra.os_util import Queue, strtobytes, get_hex_uuid from xpra.daemon_thread import make_daemon_thread from xpra.simple_stats import std_unit, std_unit_dec try: from Crypto.Cipher import AES from Crypto.Protocol.KDF import PBKDF2 except Exception, e: AES = None PBKDF2 = None debug("pycrypto is missing: %s", e) from zlib import compress, decompress, decompressobj try:
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.dotxpra import DotXpra from xpra.util import xor from xpra.os_util import get_hex_uuid from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_AUTH_DEBUG") socket_dir = None def init(opts): global socket_dir socket_dir = opts.socket_dir class SysAuthenticator(object): def __init__(self, username): self.username = username self.salt = None try: import pwd self.pw = pwd.getpwnam(username) except: self.pw = None def get_uid(self): assert self.pw, "username not found"
# This file is part of Xpra. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os as os import sys as sys from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_IMPORT_DEBUG") _init_done = False def init(): global _init_done if not _init_done: _init_done = True do_init() def do_init(): pass def platform_import(where, pm, required, *imports): if os.name == "nt": p = "win32" elif sys.platform.startswith("darwin"): p = "darwin"
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2012 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2012, 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys, os import logging from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_OPENGL_DEBUG") required_extensions = ["GL_ARB_texture_rectangle", "GL_ARB_vertex_program"] #warnings seem unavoidable on win32, so silence them #(other platforms should fix their packages instead) SILENCE_FORMAT_HANDLER_LOGGER = sys.platform.startswith("win") or sys.platform.startswith("darwin") BLACKLIST = {"vendor" : ["nouveau", "Humper", "VMware, Inc."]} DEFAULT_HAS_ALPHA = not sys.platform.startswith("win") and not sys.platform.startswith("darwin") HAS_ALPHA = os.environ.get("XPRA_ALPHA", DEFAULT_HAS_ALPHA) in (True, "1") DEFAULT_DOUBLE_BUFFERED = 0 if sys.platform.startswith("win"): #needed on win32? DEFAULT_DOUBLE_BUFFERED = 1 DOUBLE_BUFFERED = os.environ.get("XPRA_OPENGL_DOUBLE_BUFFERED", str(DEFAULT_DOUBLE_BUFFERED))=="1" def get_DISPLAY_MODE():
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. # taken from the code I wrote for winswitch import avahi import dbus XPRA_MDNS_TYPE = '_xpra._tcp.' from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_MDNS_DEBUG") from xpra.net.net_util import get_iface, if_nametoindex, if_indextoname SHOW_INTERFACE = True #publishes the name of the interface we broadcast from def get_interface_index(host): log("get_interface_index(%s)", host) if host == "0.0.0.0" or host =="" or host=="*": return avahi.IF_UNSPEC if not if_nametoindex: log.error("cannot convert interface to index (if_nametoindex is missing), so returning 'IF_UNSPEC', avahi will publish on ALL interfaces") return avahi.IF_UNSPEC
# This file is part of Xpra. # Copyright (C) 2014 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import time from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_PROXYVIDEO_DEBUG") error = log.error from xpra.codecs.image_wrapper import ImageWrapper from xpra.deque import maxdeque def get_version(): return (0, 1) def get_type(): return "proxy" def get_info(): return {"version" : get_version()} def get_encodings(): return ["proxy"] def init_module(): #nothing to do! pass
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CODEC_DEBUG") error = log.error warn = log.warn codecs = {} def codec_import_check(name, description, top_module, class_module, *classnames): debug("codec_import_check%s", (name, description, top_module, class_module, classnames)) try: try: __import__(top_module, {}, {}, []) debug(" %s found, will check for %s in %s", top_module, classnames, class_module) for classname in classnames: ic = __import__(class_module, {}, {}, classname) #warn("codec_import_check(%s, ..)=%s" % (name, ic)) debug(" found %s : %s", name, ic) codecs[name] = ic return ic except ImportError, e:
# coding=utf8 # This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_VIDEOPIPELINE_DEBUG") from xpra.scripts.config import csc_swscale, enc_vpx, enc_x264 class VideoPipelineHelper(object): _video_encoder_specs = {} _csc_encoder_specs = {} def may_init(self): if len(self._video_encoder_specs)==0: self.init_video_encoders_options() if len(self._csc_encoder_specs)==0: self.init_csc_options() def get_encoder_specs(self, encoding): return self._video_encoder_specs.get(encoding, []) def get_csc_specs(self, src_format): return self._csc_encoder_specs.get(src_format, []) def init_video_options(self):
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import time from threading import Event from xpra.daemon_thread import make_daemon_thread from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_UIWATCHER_DEBUG") from xpra.platform.features import UI_THREAD_POLLING FAKE_UI_LOCKUPS = int(os.environ.get("XPRA_FAKE_UI_LOCKUPS", "0")) if FAKE_UI_LOCKUPS>0 and UI_THREAD_POLLING<=0: #even if the platform normally disables UI thread polling, #we need it for testing: UI_THREAD_POLLING = 1000 POLLING = int(os.environ.get("XPRA_UI_THREAD_POLLING", UI_THREAD_POLLING)) class UI_thread_watcher(object): """ Allows us to register callbacks to fire when the UI thread fails to run or when it resumes. We run a dedicated thread to verify that the UI thread has run since the last time it was scheduled to run. Beware that the callbacks (fail, resume and alive)
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys import os from xpra.log import Logger, debug_if_env log = Logger() soundlog = debug_if_env(log, "XPRA_SOUND_DEBUG") SOUND_TEST_MODE = os.environ.get("XPRA_SOUND_TEST", "0") != "0" VORBIS = "vorbis" AAC = "aac" FLAC = "flac" MP3 = "mp3" WAV = "wav" OPUS = "opus" SPEEX = "speex" WAVPACK = "wavpack" #TODO: ac3, amr, dca? #format: encoder, formatter, decoder, parser CODECS = { #VORBIS : ("vorbisenc", "oggmux", "vorbisdec", "oggdemux"), #AAC : ("faac", "mp4mux", "faad", "aacparse"), FLAC: ("flacenc", "oggmux", "flacdec", "oggdemux"), MP3: ("lamemp3enc", None, "mad", "mp3parse"),
# Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import time from threading import Lock from xpra.net.protocol import Compressed from xpra.codecs.codec_constants import get_avutil_enum_from_colorspace, get_subsampling_divs, TransientCodecException, codec_spec from xpra.codecs.video_helper import getVideoHelper from xpra.server.window_source import WindowSource, log from xpra.server.background_worker import add_work_item from xpra.log import debug_if_env debug = debug_if_env(log, "XPRA_VIDEO_DEBUG") def envint(name, d): try: return int(os.environ.get(name, d)) except: return d MAX_NONVIDEO_PIXELS = envint("XPRA_MAX_NONVIDEO_PIXELS", 1024 * 4) ENCODER_TYPE = os.environ.get("XPRA_ENCODER_TYPE", "") #ie: "x264" or "nvenc" CSC_TYPE = os.environ.get("XPRA_CSC_TYPE", "") #ie: "swscale" or "opencl" FORCE_CSC_MODE = os.environ.get("XPRA_FORCE_CSC_MODE", "") #ie: "YUV444P" FORCE_CSC = bool(FORCE_CSC_MODE) or os.environ.get("XPRA_FORCE_CSC",
# This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import time from threading import Lock from xpra.net.protocol import Compressed from xpra.codecs.codec_constants import get_avutil_enum_from_colorspace, get_subsampling_divs, TransientCodecException from xpra.codecs.video_helper import getVideoHelper from xpra.server.window_source import WindowSource, log from xpra.log import debug_if_env debug = debug_if_env(log, "XPRA_VIDEO_DEBUG") def envint(name, d): try: return int(os.environ.get(name, d)) except: return d MAX_NONVIDEO_PIXELS = envint("XPRA_MAX_NONVIDEO_PIXELS", 2048) MAX_NONVIDEO_OR_INITIAL_PIXELS = envint("XPRA_MAX_NONVIDEO_OR_INITIAL_PIXELS", 1024*64) ENCODER_TYPE = os.environ.get("XPRA_ENCODER_TYPE", "") #ie: "x264" or "nvenc" CSC_TYPE = os.environ.get("XPRA_CSC_TYPE", "") #ie: "swscale" or "opencl" FORCE_CSC_MODE = os.environ.get("XPRA_FORCE_CSC_MODE", "") #ie: "YUV444P" FORCE_CSC = bool(FORCE_CSC_MODE) or os.environ.get("XPRA_FORCE_CSC", "0")=="1"
# This file is part of Xpra. # Copyright (C) 2013-2014 Antoine Martin <*****@*****.**> # Copyright (C) 2008 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import os import signal import gobject gobject.threads_init() from multiprocessing import Queue as MQueue from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_PROXY_DEBUG") from xpra.server.proxy_instance_process import ProxyInstanceProcess from xpra.server.server_core import ServerCore from xpra.scripts.config import make_defaults_struct from xpra.scripts.main import parse_display_name, connect_to from xpra.daemon_thread import make_daemon_thread PROXY_SOCKET_TIMEOUT = float(os.environ.get("XPRA_PROXY_SOCKET_TIMEOUT", "0.1")) assert PROXY_SOCKET_TIMEOUT>0, "invalid proxy socket timeout" MAX_CONCURRENT_CONNECTIONS = 200 class ProxyServer(ServerCore):
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import sys import os from xpra.gtk_common.gobject_compat import import_gtk, import_gobject gtk = import_gtk() gobject = import_gobject() from xpra.gtk_common.gtk_util import set_tooltip_text, CheckMenuItem, ensure_item_selected, set_checkeditems, menuitem from xpra.client.gtk_base.about import about, close_about from xpra.client.gtk_base.session_info import SessionInfo from xpra.scripts.config import PREFERED_ENCODING_ORDER, ENCODINGS_HELP, ENCODINGS_TO_NAME from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_TRAY_DEBUG") #compression is fine with default value (3), no need to clutter the UI SHOW_COMPRESSION_MENU = False STARTSTOP_SOUND_MENU = os.environ.get("XPRA_SHOW_SOUND_MENU", "1")=="1" LOSSLESS = "Lossless" QUALITY_OPTIONS_COMMON = { 50 : "Average", 30 : "Low", } MIN_QUALITY_OPTIONS = QUALITY_OPTIONS_COMMON.copy() MIN_QUALITY_OPTIONS[0] = "None" QUALITY_OPTIONS = QUALITY_OPTIONS_COMMON.copy() QUALITY_OPTIONS[0] = "Auto"
""" XSETTINGS This code deals with: * extracting data from XSETTINGS into nice python data structures and * converting those structures back into XSETTINGS format It is used by xpra.x11.gtk_x11.prop """ import sys import struct from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_XSETTINGS_DEBUG") #undocumented XSETTINGS endianess values: LITTLE_ENDIAN = 0 BIG_ENDIAN = 1 def get_local_byteorder(): if sys.byteorder=="little": return LITTLE_ENDIAN else: return BIG_ENDIAN #the 3 types of settings supported: XSettingsTypeInteger = 0 XSettingsTypeString = 1 XSettingsTypeColor = 2
# coding=utf8 # This file is part of Xpra. # Copyright (C) 2011 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # Copyright (C) 2008 Nathaniel Smith <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import gtk.gdk from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_KEYBOARD_DEBUG") from xpra.x11.gtk_x11.keys import grok_modifier_map from xpra.keyboard.mask import DEFAULT_MODIFIER_NUISANCE, mask_to_names from xpra.x11.xkbhelper import do_set_keymap, set_all_keycodes, \ get_modifiers_from_meanings, get_modifiers_from_keycodes, \ clear_modifiers, set_modifiers, \ clean_keyboard_state from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings #@UnresolvedImport X11Keyboard = X11KeyboardBindings() ALL_X11_MODIFIERS = { "shift": 0, "lock": 1, "control": 2, "mod1": 3, "mod2": 4,
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. import dbus from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_DBUS_DEBUG") class DBusHelper(object): def __init__(self): from xpra.x11.dbus_common import init_session_bus self.bus = init_session_bus() def call_function(self, bus_name, path, interface, function, args, ok_cb, err_cb): try: #remote_object = self.bus.get_object("com.example.SampleService","/SomeObject") obj = self.bus.get_object(bus_name, path) debug("dbus.get_object(%s, %s)=%s", bus_name, path, obj) except dbus.DBusException: err_cb("failed to locate object at: %s:%s" % (bus_name, path)) return try: fn = obj.get_dbus_method(function, interface) debug("%s.get_dbus_method(%s, %s)=%s", obj, function, interface, fn) except: err_cb("failed to locate remote function '%s' on %s" % (function, obj))
#!/usr/bin/env python # This file is part of Xpra. # Copyright (C) 2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. # taken from the code I wrote for winswitch import socket import sys from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_NETWORK_DEBUG") has_netifaces = True try: import netifaces # @UnresolvedImport debug("netifaces loaded sucessfully") except Exception, e: has_netifaces = False log.warn("python netifaces package is missing") iface_ipmasks = {} bind_IPs = None def get_interfaces(): if not has_netifaces:
import struct import re import binascii from xpra.gtk_common.gobject_compat import import_gobject, import_gtk, import_gdk, is_gtk3 gobject = import_gobject() gtk = import_gtk() gdk = import_gdk() if is_gtk3(): PROPERTY_CHANGE_MASK = gdk.EventMask.PROPERTY_CHANGE_MASK else: PROPERTY_CHANGE_MASK = gdk.PROPERTY_CHANGE_MASK from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_CLIPBOARD_DEBUG") from xpra.gtk_common.gobject_util import n_arg_signal from xpra.gtk_common.nested_main import NestedMainLoop from xpra.net.protocol import zlib_compress MAX_CLIPBOARD_PACKET_SIZE = 256*1024 ALL_CLIPBOARDS = ["CLIPBOARD", "PRIMARY", "SECONDARY"] CLIPBOARDS = ALL_CLIPBOARDS CLIPBOARDS_ENV = os.environ.get("XPRA_CLIPBOARDS") if CLIPBOARDS_ENV is not None: CLIPBOARDS = CLIPBOARDS_ENV.split(",") CLIPBOARDS = [x.upper().strip() for x in CLIPBOARDS]
# Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from xpra.gtk_common.gobject_compat import import_gtk gtk = import_gtk() from xpra.gtk_common.gtk_util import scaled_image from xpra.client.gtk_base.about import about from xpra.client.gtk_base.gtk_tray_menu_base import GTKTrayMenuBase, populate_encodingsmenu from xpra.platform.paths import get_icon from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_TRAY_DEBUG") #for attention_request: CRITICAL_REQUEST = 0 INFO_REQUEST = 10 _OSXMenuHelper = None def getOSXMenuHelper(client=None): global _OSXMenuHelper if _OSXMenuHelper is None: _OSXMenuHelper = OSXMenuHelper(client) elif client is not None: _OSXMenuHelper.set_client(client) return _OSXMenuHelper
# get around to processing it, then it'll still be processed as normal -- not # as timed out.) # # There actually is no guarantee on how long a nested call ends up blocked, # even in the face of soft timeouts, because new nested calls might keep # coming in, each extending the total blocking period by their soft # timeout. If the user ever stops pasting madly for a few seconds, though, # then everything should have a chance to return to equilibrium... from xpra.gtk_common.gobject_compat import import_gobject, import_gtk gobject = import_gobject() gtk = import_gtk() from xpra.log import Logger, debug_if_env log = Logger() debug = debug_if_env(log, "XPRA_NESTED_DEBUG") # For debugging: def _dump_recursion_info(): # This is how deeply nested in recursive main-loops we are: print("gtk depth: %s" % (gtk.main_level())) import ctypes class ThreadState(ctypes.Structure): _fields_ = [("next", ctypes.c_voidp), ("interp", ctypes.c_voidp), ("frame", ctypes.c_voidp), ("recursion_depth", ctypes.c_int)] ts = ctypes.cast(ctypes.pythonapi.PyThreadState_Get(), ctypes.POINTER(ThreadState)) # This is Python's count of the recursion depth -- i.e., the thing that # will eventually trigger the 'Maximum recursion depth exceeded' message.