Ejemplo n.º 1
0
    def OnUploadDirectoryTo(self, widget, recurse=0):

        dir = self.selected_folder
        if dir is None:
            return

        users = []
        for entry in self.frame.np.config.sections["server"]["userlist"]:
            users.append(entry[0])

        users.sort()
        user = input_box(self.frame,
                         title=_("Nicotine+: Upload Directory's Contents"),
                         message=_('Enter the User you wish to upload to:'),
                         droplist=users)

        if user is None or user == "":
            return

        self.frame.np.ProcessRequestToPeer(
            user, slskmessages.UploadQueueNotification(None))

        self.UploadDirectoryTo(user, dir, recurse)
Ejemplo n.º 2
0
    def OnUploadFiles(self, widget, prefix=""):

        dir = self.selected_folder
        users = []

        for entry in self.frame.np.config.sections["server"]["userlist"]:
            users.append(entry[0])

        users.sort()
        user = input_box(
            self.frame,
            title=_('Nicotine+: Upload File(s)'),
            message=_('Enter the User you wish to upload to:'),
            droplist=users
        )

        if user is None or user == "":
            return

        self.frame.np.ProcessRequestToPeer(user, slskmessages.UploadQueueNotification(None))

        for fn in self.selected_files:
            self.frame.np.transfers.pushFile(user, "\\".join([dir, fn]), prefix)
            self.frame.np.transfers.checkUploadQueue()
Ejemplo n.º 3
0
    def OnButtonPressed(self, widget):

        if self.initphase:
            return

        name = gtk.Buildable.get_name(widget)

        if name == "checkmyport":
            OpenUri('='.join([
                'http://tools.slsknet.org/porttest.php?port',
                str(self.frame.np.waitport)
            ]))

        if name == "addshare":

            selected = ChooseDir(self.window.get_toplevel(),
                                 title=_("Nicotine+") + ": " +
                                 _("Add a shared directory"))

            if selected:

                for directory in selected:

                    virtual = input_box(
                        self.frame,
                        title=_("Virtual name"),
                        message=_("Enter virtual name for '%(dir)s':") %
                        {'dir': directory})

                    # If the virtual name is empty
                    if virtual == '' or virtual is None:

                        popupWarning(self.window, _("Warning"),
                                     _("The chosen virtual name is empty"),
                                     self.frame.images["n"])
                        pass

                    else:
                        # We get the current defined shares from the treeview
                        model, paths = self.kids[
                            'shareddirectoriestree'].get_selection(
                            ).get_selected_rows()

                        iter = model.get_iter_first()

                        while iter is not None:

                            # We reject the share if the virtual share name is already used
                            if virtual == model.get_value(iter, 0):

                                popupWarning(
                                    self.window, _("Warning"),
                                    _("The chosen virtual name already exist"),
                                    self.frame.images["n"])
                                return

                            # We also reject the share if the directory is already used
                            elif directory == model.get_value(iter, 6):

                                popupWarning(
                                    self.window, _("Warning"),
                                    _("The chosen directory is already shared"
                                      ), self.frame.images["n"])
                                return

                            else:
                                iter = model.iter_next(iter)

                        # The share is unique: we can add it
                        self.addshareddir((virtual, directory))

        if name == "removeshares":

            model, paths = self.kids['shareddirectoriestree'].get_selection(
            ).get_selected_rows()
            refs = [gtk.TreeRowReference(model, x) for x in paths]

            for i in refs:
                self.sharelist.remove(self.sharelist.get_iter(i.get_path()))

        self.resetcompleteness()