add private flag to torrentcreator

This commit is contained in:
Marcos Pinto 2007-09-05 17:35:44 +00:00
parent 87d58cd0e1
commit 63621be3ee
4 changed files with 73 additions and 55 deletions

View File

@ -148,13 +148,13 @@ class TorrentCreator:
author = _("Deluge")
add_torrent = self.glade.get_widget("add_torrent_checkbox").get_active()
set_private = self.glade.get_widget("chk_set_priv").get_active()
# Destroy the dialog.. we don't need it anymore
self.destroy()
# Create the torrent and add it to the queue if necessary
if self.core.create_torrent(torrent, source, trackers, comments,
piece_size, author) == 1:
piece_size, author, set_private) == 1:
# Torrent was created successfully
if add_torrent:
# We need to add this torrent to the queue

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Mon Jun 25 23:27:42 2007 by markybob@peg-->
<!--Generated with glade3 3.2.2 on Wed Sep 5 12:27:39 2007 by markybob@peg-->
<glade-interface>
<widget class="GtkDialog" id="torrentcreator">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -70,17 +70,28 @@
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkRadioButton" id="folder_radiobutton">
<widget class="GtkFileChooserButton" id="file_chooserbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">This torrent will be made from a directory</property>
<property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="folder_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
@ -102,28 +113,17 @@
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="folder_chooserbutton">
<widget class="GtkRadioButton" id="folder_radiobutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="tooltip" translatable="yes">This torrent will be made from a directory</property>
<property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="file_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
@ -171,14 +171,22 @@
<property name="n_rows">1</property>
<property name="n_columns">3</property>
<child>
<widget class="GtkEntry" id="torrentfile_entry">
<widget class="GtkAlignment" id="alignment8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Save Torrent File As:</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@ -206,22 +214,14 @@
</packing>
</child>
<child>
<widget class="GtkAlignment" id="alignment8">
<widget class="GtkEntry" id="torrentfile_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="right_padding">5</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Save Torrent File As:</property>
</widget>
</child>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
@ -414,21 +414,26 @@
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">1</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
<widget class="GtkLabel" id="label3">
<widget class="GtkCheckButton" id="chk_set_priv">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">The smaller the piece sizes, the more efficient the transfers will be, but the actual ".torrent" file will be larger</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
<property name="label" translatable="yes">Set Private Flag</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="y_options"></property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkComboBox" id="piece_size_combobox">
<property name="visible">True</property>
@ -449,6 +454,18 @@
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">The smaller the piece sizes, the more efficient the transfers will be, but the actual ".torrent" file will be larger</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
</widget>
<packing>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -981,8 +981,8 @@ class Manager:
return ret
def create_torrent(self, filename, source_directory, trackers, comments=None,
piece_size=32, author="Deluge"):
return deluge_core.create_torrent(filename, source_directory, trackers, comments, piece_size, author)
piece_size=32, author="Deluge", private=False):
return deluge_core.create_torrent(filename, source_directory, trackers, comments, piece_size, author, private)
# Creates/resets the IP filter list
def reset_ip_filter(self):

View File

@ -1475,9 +1475,10 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
//path::default_name_check(no_check);
char *destination, *comment, *creator_str, *input, *trackers;
bool *priv;
python_long piece_size;
if (!PyArg_ParseTuple(args, "ssssis",
&destination, &input, &trackers, &comment, &piece_size, &creator_str))
if (!PyArg_ParseTuple(args, "ssssisb",
&destination, &input, &trackers, &comment, &piece_size, &creator_str, &priv))
return NULL;
piece_size = piece_size * 1024;
@ -1519,7 +1520,7 @@ static PyObject *torrent_create_torrent(PyObject *self, PyObject *args)
t->set_creator(creator_str);
t->set_comment(comment);
t->set_priv(priv);
entry e = t->create_torrent();
bencode(std::ostream_iterator<char>(out), e);
return Py_BuildValue("l", 1);