Example #1
0
    def rayOptionSessionScripts(self, path, args, types, src_addr):
        self.option_session_scripts = bool(args[0])

        options = self.getOptions()

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/server/options', options)
Example #2
0
    def rayOptionDesktopsMemory(self, path, args, types, src_addr):
        self.option_desktops_memory = bool(args[0])

        options = self.getOptions()

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/server/options', options)
Example #3
0
    def rayOptionSaveFromClient(self, path, args, types, src_addr):
        self.option_save_from_client = bool(args[0])

        options = self.getOptions()

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/server/options', options)
Example #4
0
    def rayFavoriteRemove(self, path, args, types, src_addr):
        name, int_factory = args

        for favorite in RS.favorites:
            if (favorite.name == name
                    and bool(int_factory) == favorite.factory):
                RS.favorites.remove(favorite)
                break

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/favorites/removed', *args)
Example #5
0
    def sendRenameable(self, renameable):
        if not renameable:
            self.sendGui('/ray/gui/session/renameable', 0)
            return

        if self.nsm_locker_url:
            NSM_URL = os.getenv('NSM_URL')
            if not NSM_URL:
                return
            if not ray.areSameOscPort(self.nsm_locker_url, NSM_URL):
                return

        self.sendGui('/ray/gui/session/renameable', 1)
Example #6
0
    def nsmServerBroadcast(self, path, args, types, src_addr):
        if not args:
            return False

        #don't allow clients to broadcast NSM commands
        if args[0].startswith('/nsm/') or args[0].startswith('/ray'):
            return False

        for client in self.session.clients:
            if not client.addr:
                continue

            if not ray.areSameOscPort(client.addr.url, src_addr.url):
                self.send(client.addr, liblo.Message(*args))
Example #7
0
    def rayFavoriteAdd(self, path, args, types, src_addr):
        name, icon, int_factory = args

        for favorite in RS.favorites:
            if (favorite.name == name
                    and bool(int_factory) == favorite.factory):
                favorite.icon = icon
                break
        else:
            RS.favorites.append(ray.Favorite(name, icon, bool(int_factory)))

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/favorites/added', *args)
Example #8
0
    def rayGuiGui_disannounce(self, path, args, types, src_addr):
        for addr in self.gui_list:
            if ray.areSameOscPort(addr.url, src_addr.url):
                break
        else:
            return False

        self.gui_list.remove(addr)
        self.gui_embedded = False

        if src_addr.url == self.nsm_locker_url:
            self.net_daemon_id = random.randint(1, 999999999)

            self.is_nsm_locked = False
            self.nsm_locker_url = ''
            self.sendGui('/ray/gui/server/nsm_locked', 0)

        multi_daemon_file = MultiDaemonFile.getInstance()
        if multi_daemon_file:
            multi_daemon_file.update()
Example #9
0
    def rayServerSetOptions(self, path, args, types, src_addr):
        if not ray.areTheyAllString(args):
            self.unknownMessage(path, types, src_addr)
            return False

        for option in args:
            option_value = True
            if option.startswith('not_'):
                option_value = False
                option = option.replace('not_', '', 1)

            if option == 'save_from_client':
                self.option_save_from_client = option_value
            elif option == 'bookmark_session_folder':
                self.option_bookmark_session = option_value
            elif option == 'desktops_memory':
                if option_value and not self.option_has_wmctrl:
                    self.send(
                        src_addr, '/minor_error', path,
                        "wmctrl is not present. Impossible to activate 'desktops_memory' option"
                    )
                    continue
                self.option_desktops_memory = option_value
            elif option == 'snapshots':
                if option_value and not self.option_has_git:
                    self.send(
                        src_addr, '/minor_error', path,
                        "git is not present. Impossible to activate 'snapshots' option"
                    )
                    continue
                self.option_snapshots = option_value
            elif option == 'session_scripts':
                self.option_session_scripts = option_value

        options = self.getOptions()

        for gui_addr in self.gui_list:
            if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                self.send(gui_addr, '/ray/gui/server/options', options)

        self.send(src_addr, '/reply', path, 'Options set')
Example #10
0
    def rayGuiGui_announce(self, path, args, types, src_addr):
        version = args[0]
        nsm_locked = bool(args[1])
        is_net_free = True

        if nsm_locked:
            self.net_master_daemon_url = args[2]
            self.is_nsm_locked = True
            self.nsm_locker_url = src_addr.url

            for gui_addr in self.gui_list:
                if not ray.areSameOscPort(gui_addr.url, src_addr.url):
                    self.send(gui_addr, '/ray/gui/server/nsm_locked', 1)

            self.net_daemon_id = args[4]

            multi_daemon_file = MultiDaemonFile.getInstance()

            if multi_daemon_file:
                is_net_free = multi_daemon_file.isFreeForRoot(
                    self.net_daemon_id, self.session.root)

        self.announceGui(src_addr.url, nsm_locked, is_net_free)
Example #11
0
    def rayServerRename(self, path, args, types, src_addr):
        new_session_name = args[0]

        #prevent rename session in network session
        if self.nsm_locker_url:
            NSM_URL = os.getenv('NSM_URL')
            if not NSM_URL:
                return False

            if not ray.areSameOscPort(self.nsm_locker_url, NSM_URL):
                return False

        if '/' in new_session_name:
            self.send(src_addr, "/error", path, ray.Err.CREATE_FAILED,
                      "Invalid session name.")
            return False

        if self.isOperationPending(src_addr, path):
            return False

        if not self.session.path:
            self.send(src_addr, "/error", path, ray.Err.NO_SESSION_OPEN,
                      "No session to rename.")
            return False
Example #12
0
 def raySessionSetNotes(self, path, args, types, src_addr):
     for gui_addr in self.gui_list:
         if not ray.areSameOscPort(gui_addr.url, src_addr.url):
             self.send(gui_addr, '/ray/gui/session/notes', args[0])
Example #13
0
 def isGuiAddress(self, addr):
     for gui_addr in self.gui_list:
         if ray.areSameOscPort(gui_addr.url, addr.url):
             return True
     return False