Esempio n. 1
0
    def send_num_shared_folders_files(self):
        """ Send number publicly shared files to the server. """

        config = self.config.sections

        if config["transfers"]["enablebuddyshares"] and config["transfers"][
                "friendsonly"]:
            # No public shares
            files = folders = 0
            self.queue.put(slskmessages.SharedFoldersFiles(files, folders))
            return

        shared_db = "files"
        index_db = "fileindex"

        try:
            try:
                sharedfolders = len(self.share_dbs[shared_db])
                sharedfiles = len(self.share_dbs[index_db])

            except TypeError:
                sharedfolders = len(list(self.share_dbs[shared_db]))
                sharedfiles = len(list(self.share_dbs[index_db]))

            self.queue.put(
                slskmessages.SharedFoldersFiles(sharedfolders, sharedfiles))

        except Exception as e:
            log.add(
                _("Failed to send number of shared files to the server: %s"),
                e)
Esempio n. 2
0
    def send_num_shared_folders_files(self):
        """ Send number publicly shared files to the server. """

        if self.config.sections["transfers"]["friendsonly"]:
            # No public shares
            files = folders = 0
            self.queue.append(slskmessages.SharedFoldersFiles(files, folders))
            return

        try:
            shared = self.share_dbs.get("files")
            index = self.share_dbs.get("fileindex")

            if shared is None or index is None:
                return

            try:
                sharedfolders = len(shared)
                sharedfiles = len(index)

            except TypeError:
                sharedfolders = len(list(shared))
                sharedfiles = len(list(index))

            self.queue.append(
                slskmessages.SharedFoldersFiles(sharedfolders, sharedfiles))

        except Exception as e:
            log.add(
                _("Failed to send number of shared files to the server: %s"),
                e)
Esempio n. 3
0
    def sendNumSharedFoldersFiles(self):
        """
        Send number of files in buddy shares if only buddies can
        download, and buddy-shares are enabled.
        """

        conf = self.config.sections

        if conf["transfers"]["enablebuddyshares"] and conf["transfers"][
                "friendsonly"]:
            shared_db = "bsharedfiles"
            index_db = "bfileindex"
        else:
            shared_db = "sharedfiles"
            index_db = "fileindex"

        try:
            sharedfolders = len(conf["transfers"][shared_db])
            sharedfiles = len(conf["transfers"][index_db])
        except TypeError:
            sharedfolders = len(list(conf["transfers"][shared_db]))
            sharedfiles = len(list(conf["transfers"][index_db]))

        self.queue.put(
            slskmessages.SharedFoldersFiles(sharedfolders, sharedfiles))
Esempio n. 4
0
    def send_num_shared_folders_files(self):
        """ Send number publicly shared files to the server. """

        if not (self.core and self.core.logged_in):
            return

        try:
            shared = self.share_dbs.get("files")
            index = self.share_dbs.get("fileindex")

            if shared is None or index is None:
                return

            try:
                sharedfolders = len(shared)
                sharedfiles = len(index)

            except TypeError:
                sharedfolders = len(list(shared))
                sharedfiles = len(list(index))

            self.queue.append(
                slskmessages.SharedFoldersFiles(sharedfolders, sharedfiles))

        except Exception as error:
            log.add(
                _("Failed to send number of shared files to the server: %s"),
                error)
Esempio n. 5
0
    def sendNumSharedFoldersFiles(self):
        """
        Send number of files in buddy shares if only buddies can
        download, and buddy-shares are enabled.
        """
        conf = self.config.sections

        if conf["transfers"]["enablebuddyshares"] and conf["transfers"]["friendsonly"]:
            shared_db = "bsharedfiles"
        else:
            shared_db = "sharedfiles"

        sharedfolders = len(conf["transfers"][shared_db])
        sharedfiles = sum([len(x) for x in list(conf["transfers"][shared_db].values())])
        self.queue.put(slskmessages.SharedFoldersFiles(sharedfolders, sharedfiles))