coding standards
This commit is contained in:
@@ -9,24 +9,24 @@ class FilesharingDatabase:
|
|||||||
path_l = os.path.split(plugin.config.FILE_PATH)
|
path_l = os.path.split(plugin.config.FILE_PATH)
|
||||||
path = os.path.join(path_l[0], 'shared_files.db')
|
path = os.path.join(path_l[0], 'shared_files.db')
|
||||||
db_exist = os.path.exists(path)
|
db_exist = os.path.exists(path)
|
||||||
print path
|
|
||||||
self.conn = sqlite3.connect(path)
|
self.conn = sqlite3.connect(path)
|
||||||
# Enable foreign keys contraints
|
# Enable foreign keys contraints
|
||||||
self.conn.cursor().execute("pragma foreign_keys = on")
|
self.conn.cursor().execute("pragma foreign_keys = on")
|
||||||
if not db_exist:
|
if not db_exist:
|
||||||
self.create_database()
|
self.create_database()
|
||||||
|
|
||||||
# NOTE: Make sure we are getting and setting the requester without its resource
|
# NOTE: Make sure we are getting and setting the requester without its
|
||||||
|
# resource
|
||||||
def create_database(self):
|
def create_database(self):
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
# Create tables
|
# Create tables
|
||||||
c.execute("CREATE TABLE permissions" +
|
c.execute("CREATE TABLE permissions" +
|
||||||
"(fid integer REFERENCES files(fid) ON DELETE CASCADE, " +
|
"(fid integer REFERENCES files(fid) ON DELETE CASCADE, " +
|
||||||
"account text, requester text)")
|
"account text, requester text)")
|
||||||
c.execute("CREATE TABLE files" +
|
c.execute("CREATE TABLE files" +
|
||||||
"(fid INTEGER PRIMARY KEY AUTOINCREMENT," +
|
"(fid INTEGER PRIMARY KEY AUTOINCREMENT," +
|
||||||
" file_path text, relative_path text, hash_sha1 text," +
|
" file_path text, relative_path text, hash_sha1 text," +
|
||||||
"size numeric, description text, mod_date text, is_dir boolean)")
|
"size numeric, description text, mod_date text, is_dir boolean)")
|
||||||
# Save (commit) the changes
|
# Save (commit) the changes
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
@@ -34,10 +34,10 @@ class FilesharingDatabase:
|
|||||||
def get_toplevel_files(self, account, requester):
|
def get_toplevel_files(self, account, requester):
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester)
|
data = (account, requester)
|
||||||
c.execute("SELECT relative_path, hash_sha1, size, description, mod_date," +
|
c.execute("SELECT relative_path, hash_sha1, size, description, " +
|
||||||
" is_dir FROM (files JOIN permissions ON" +
|
"mod_date, is_dir FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
||||||
" AND relative_path NOT LIKE '%/%'", data)
|
" AND relative_path NOT LIKE '%/%'", data)
|
||||||
result = c.fetchall()
|
result = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
return result
|
return result
|
||||||
@@ -45,10 +45,10 @@ class FilesharingDatabase:
|
|||||||
def get_files_from_dir(self, account, requester, dir_):
|
def get_files_from_dir(self, account, requester, dir_):
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester, dir_ + '/%')
|
data = (account, requester, dir_ + '/%')
|
||||||
c.execute("SELECT relative_path, hash_sha1, size, description, mod_date," +
|
c.execute("SELECT relative_path, hash_sha1, size, description, " +
|
||||||
" is_dir FROM (files JOIN permissions ON" +
|
"mod_date, is_dir FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
||||||
" AND relative_path LIKE ?", data)
|
" AND relative_path LIKE ?", data)
|
||||||
result = c.fetchall()
|
result = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
fresult = []
|
fresult = []
|
||||||
@@ -70,9 +70,9 @@ class FilesharingDatabase:
|
|||||||
"""
|
"""
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester)
|
data = (account, requester)
|
||||||
c.execute("SELECT relative_path, hash_sha1, size, description, mod_date," +
|
c.execute("SELECT relative_path, hash_sha1, size, description, " +
|
||||||
" is_dir FROM (files JOIN permissions ON" +
|
"mod_date, is_dir FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?", data)
|
" files.fid=permissions.fid) WHERE account=? AND requester=?", data)
|
||||||
result = c.fetchall()
|
result = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
return result
|
return result
|
||||||
@@ -81,16 +81,16 @@ class FilesharingDatabase:
|
|||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
if hash_:
|
if hash_:
|
||||||
data = (account, requester, hash_)
|
data = (account, requester, hash_)
|
||||||
sql = "SELECT relative_path, hash_sha1, size, description, mod_date," + \
|
sql = "SELECT relative_path, hash_sha1, size, description, " + \
|
||||||
" file_path FROM (files JOIN permissions ON" + \
|
"mod_date, file_path FROM (files JOIN permissions ON" + \
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" + \
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +\
|
||||||
" AND hash_sha1=?"
|
" AND hash_sha1=?"
|
||||||
else:
|
else:
|
||||||
data = (account, requester, name)
|
data = (account, requester, name)
|
||||||
sql = "SELECT relative_path, hash_sha1, size, description, mod_date," + \
|
sql = "SELECT relative_path, hash_sha1, size, description, " + \
|
||||||
" file_path FROM (files JOIN permissions ON" + \
|
"mod_date, file_path FROM (files JOIN permissions ON" + \
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" + \
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +\
|
||||||
" AND relative_path=?"
|
" AND relative_path=?"
|
||||||
c.execute(sql, data)
|
c.execute(sql, data)
|
||||||
result = c.fetchall()
|
result = c.fetchall()
|
||||||
c.close()
|
c.close()
|
||||||
@@ -118,9 +118,8 @@ class FilesharingDatabase:
|
|||||||
requester = gajim.get_jid_without_resource(requester)
|
requester = gajim.get_jid_without_resource(requester)
|
||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
c.execute("INSERT INTO files (file_path, " +
|
c.execute("INSERT INTO files (file_path, " +
|
||||||
"relative_path, hash_sha1, size, description, mod_date, " +
|
"relative_path, hash_sha1, size, description, mod_date, " +
|
||||||
" is_dir) VALUES (?,?,?,?,?,?,?)",
|
" is_dir) VALUES (?,?,?,?,?,?,?)", file_)
|
||||||
file_)
|
|
||||||
fid = c.lastrowid
|
fid = c.lastrowid
|
||||||
permission_data = (fid, account, requester)
|
permission_data = (fid, account, requester)
|
||||||
c.execute("INSERT INTO permissions VALUES (?,?,?)", permission_data)
|
c.execute("INSERT INTO permissions VALUES (?,?,?)", permission_data)
|
||||||
@@ -132,14 +131,14 @@ class FilesharingDatabase:
|
|||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester, file_[1])
|
data = (account, requester, file_[1])
|
||||||
c.execute("SELECT * FROM (files JOIN permissions ON" +
|
c.execute("SELECT * FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
||||||
" AND relative_path=? ", data)
|
" AND relative_path=? ", data)
|
||||||
result = c.fetchall()
|
result = c.fetchall()
|
||||||
if file_[2] != '':
|
if file_[2] != '':
|
||||||
data = (account, requester, file_[2])
|
data = (account, requester, file_[2])
|
||||||
c.execute("SELECT * FROM (files JOIN permissions ON" +
|
c.execute("SELECT * FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
" files.fid=permissions.fid) WHERE account=? AND requester=?" +
|
||||||
" AND hash_sha1=?)", data)
|
" AND hash_sha1=?)", data)
|
||||||
result.extend(c.fetchall())
|
result.extend(c.fetchall())
|
||||||
if len(result) > 0:
|
if len(result) > 0:
|
||||||
raise Exception('Duplicated entry')
|
raise Exception('Duplicated entry')
|
||||||
@@ -156,9 +155,9 @@ class FilesharingDatabase:
|
|||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester, dir_, dir_ + '/%')
|
data = (account, requester, dir_, dir_ + '/%')
|
||||||
sql = "DELETE FROM files WHERE fid IN " + \
|
sql = "DELETE FROM files WHERE fid IN " + \
|
||||||
" (SELECT files.fid FROM files, permissions WHERE" + \
|
" (SELECT files.fid FROM files, permissions WHERE" + \
|
||||||
" files.fid=permissions.fid AND account=?"+ \
|
" files.fid=permissions.fid AND account=?"+ \
|
||||||
" AND requester=? AND (relative_path=? OR relative_path LIKE ?))"
|
" AND requester=? AND (relative_path=? OR relative_path LIKE ?))"
|
||||||
c.execute(sql, data)
|
c.execute(sql, data)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
@@ -167,8 +166,8 @@ class FilesharingDatabase:
|
|||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester, relative_path)
|
data = (account, requester, relative_path)
|
||||||
c.execute("SELECT files.fid, is_dir FROM (files JOIN permissions ON" +
|
c.execute("SELECT files.fid, is_dir FROM (files JOIN permissions ON" +
|
||||||
" files.fid=permissions.fid) WHERE account=? AND requester=? AND " +
|
" files.fid=permissions.fid) WHERE account=? AND requester=? AND " +
|
||||||
"relative_path=? ", data)
|
"relative_path=? ", data)
|
||||||
result = c.fetchone()
|
result = c.fetchone()
|
||||||
c.close()
|
c.close()
|
||||||
if result[1] == 0:
|
if result[1] == 0:
|
||||||
@@ -180,7 +179,7 @@ class FilesharingDatabase:
|
|||||||
c = self.conn.cursor()
|
c = self.conn.cursor()
|
||||||
data = (account, requester)
|
data = (account, requester)
|
||||||
sql = "DELETE FROM files WHERE fid IN (SELECT fid FROM permissions" + \
|
sql = "DELETE FROM files WHERE fid IN (SELECT fid FROM permissions" + \
|
||||||
" WHERE account=? AND requester=?)"
|
" WHERE account=? AND requester=?)"
|
||||||
c.execute(sql, data)
|
c.execute(sql, data)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
@@ -196,5 +195,5 @@ if __name__ == "__main__":
|
|||||||
conn = sqlite3.connect(path)
|
conn = sqlite3.connect(path)
|
||||||
# Enable foreign keys contraints
|
# Enable foreign keys contraints
|
||||||
conn.cursor().execute("pragma foreign_keys = on")
|
conn.cursor().execute("pragma foreign_keys = on")
|
||||||
create_database()
|
FilesharingDatabase.create_database()
|
||||||
doctest.testmod()
|
doctest.testmod()
|
||||||
|
|||||||
@@ -137,10 +137,10 @@ class FileShareWindow(gtk.Window):
|
|||||||
|
|
||||||
def add_file(self, widget):
|
def add_file(self, widget):
|
||||||
dialog = gtk.FileChooserDialog('Add file to be shared', self,
|
dialog = gtk.FileChooserDialog('Add file to be shared', self,
|
||||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
|
||||||
gtk.STOCK_OPEN, gtk.RESPONSE_OK)
|
gtk.RESPONSE_OK)
|
||||||
)
|
)
|
||||||
dialog.set_select_multiple(True)
|
dialog.set_select_multiple(True)
|
||||||
response = dialog.run()
|
response = dialog.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
@@ -150,10 +150,10 @@ class FileShareWindow(gtk.Window):
|
|||||||
|
|
||||||
def add_directory(self, widget):
|
def add_directory(self, widget):
|
||||||
dialog = gtk.FileChooserDialog('Add directory to be shared', self,
|
dialog = gtk.FileChooserDialog('Add directory to be shared', self,
|
||||||
gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||||
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
|
||||||
gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)
|
gtk.RESPONSE_ACCEPT)
|
||||||
)
|
)
|
||||||
response = dialog.run()
|
response = dialog.run()
|
||||||
if response == gtk.RESPONSE_ACCEPT:
|
if response == gtk.RESPONSE_ACCEPT:
|
||||||
file_list = []
|
file_list = []
|
||||||
@@ -171,17 +171,11 @@ class FileShareWindow(gtk.Window):
|
|||||||
dirpath = f.split('/')
|
dirpath = f.split('/')
|
||||||
if len(dirpath) == 1:
|
if len(dirpath) == 1:
|
||||||
# Top level file, it doesnt have parent, add it right away
|
# Top level file, it doesnt have parent, add it right away
|
||||||
fref[dirpath[0]] = treestore.insert(root,
|
fref[dirpath[0]] = treestore.insert(root, 0, (dirpath[0],))
|
||||||
0,
|
|
||||||
(dirpath[0],)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
for dir_ in dirpath:
|
for dir_ in dirpath:
|
||||||
if tail + dir_ not in fref:
|
if tail + dir_ not in fref:
|
||||||
fref[tail + dir_] = treestore.append(
|
fref[tail + dir_] = treestore.append(parent, (dir_,))
|
||||||
parent,
|
|
||||||
(dir_,)
|
|
||||||
)
|
|
||||||
parent = fref[tail + dir_]
|
parent = fref[tail + dir_]
|
||||||
tail = tail + dir_ + '/'
|
tail = tail + dir_ + '/'
|
||||||
return fref
|
return fref
|
||||||
@@ -191,7 +185,7 @@ class FileShareWindow(gtk.Window):
|
|||||||
import time, datetime
|
import time, datetime
|
||||||
ts = time.gmtime(epoch)
|
ts = time.gmtime(epoch)
|
||||||
dt = datetime.datetime(ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
|
dt = datetime.datetime(ts.tm_year, ts.tm_mon, ts.tm_mday, ts.tm_hour,
|
||||||
ts.tm_min, ts.tm_sec)
|
ts.tm_min, ts.tm_sec)
|
||||||
return dt.isoformat()
|
return dt.isoformat()
|
||||||
|
|
||||||
def add_items_tvcontacts(self, file_list, parentdir = None, parent = None):
|
def add_items_tvcontacts(self, file_list, parentdir = None, parent = None):
|
||||||
@@ -218,7 +212,8 @@ class FileShareWindow(gtk.Window):
|
|||||||
file_ = (f, relative_name, '', size, '', mod_date, is_dir)
|
file_ = (f, relative_name, '', size, '', mod_date, is_dir)
|
||||||
requester = self.cbb_contacts.get_active_text()
|
requester = self.cbb_contacts.get_active_text()
|
||||||
try:
|
try:
|
||||||
fid = self.plugin.database.add_file(self.account, requester, file_)
|
fid = self.plugin.database.add_file(self.account, requester,
|
||||||
|
file_)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if e == 'Duplicated entry':
|
if e == 'Duplicated entry':
|
||||||
print 'Error: ' + e
|
print 'Error: ' + e
|
||||||
@@ -238,11 +233,10 @@ class FileShareWindow(gtk.Window):
|
|||||||
contacts = gajim.contacts.get_contacts(self.account, jid)
|
contacts = gajim.contacts.get_contacts(self.account, jid)
|
||||||
for con in contacts:
|
for con in contacts:
|
||||||
if con.show in ('offline', 'error') and not \
|
if con.show in ('offline', 'error') and not \
|
||||||
con.supports(fshare_protocol.NS_FILE_SHARING):
|
con.supports(fshare_protocol.NS_FILE_SHARING):
|
||||||
break
|
break
|
||||||
cjid = con.get_full_jid()
|
cjid = con.get_full_jid()
|
||||||
r = self.ts_search.insert(None, 0,
|
r = self.ts_search.insert(None, 0, (cjid, ))
|
||||||
(cjid, ))
|
|
||||||
self.browse_jid[cjid] = r
|
self.browse_jid[cjid] = r
|
||||||
pro = fshare.FileSharePlugin.prohandler[self.account]
|
pro = fshare.FileSharePlugin.prohandler[self.account]
|
||||||
# Request list of files from peer
|
# Request list of files from peer
|
||||||
@@ -255,17 +249,15 @@ class FileShareWindow(gtk.Window):
|
|||||||
self.cbb_contacts.grab_focus()
|
self.cbb_contacts.grab_focus()
|
||||||
for c in gajim.contacts.iter_contacts(self.account):
|
for c in gajim.contacts.iter_contacts(self.account):
|
||||||
jid = gajim.get_jid_without_resource(c.get_full_jid())
|
jid = gajim.get_jid_without_resource(c.get_full_jid())
|
||||||
r = self.ts_contacts.insert(None, len(self.ts_contacts),
|
r = self.ts_contacts.insert(None, len(self.ts_contacts), (jid, ))
|
||||||
(jid, ))
|
|
||||||
if c.get_full_jid() == contact.get_full_jid():
|
if c.get_full_jid() == contact.get_full_jid():
|
||||||
self.cbb_contacts.set_active_iter(r)
|
self.cbb_contacts.set_active_iter(r)
|
||||||
self.contacts_rows.append(r)
|
self.contacts_rows.append(r)
|
||||||
self.manage_vbox2.set_sensitive(True)
|
self.manage_vbox2.set_sensitive(True)
|
||||||
self.bt_remove.set_sensitive(False)
|
self.bt_remove.set_sensitive(False)
|
||||||
self.add_file_list(self.plugin.database.get_files_name(self.account,
|
self.add_file_list(self.plugin.database.get_files_name(self.account,
|
||||||
gajim.get_jid_without_resource(contact.get_full_jid())),
|
gajim.get_jid_without_resource(contact.get_full_jid())),
|
||||||
self.ts_files
|
self.ts_files)
|
||||||
)
|
|
||||||
|
|
||||||
def delete_event(self, widget, data=None):
|
def delete_event(self, widget, data=None):
|
||||||
fshare.FileSharePlugin.filesharewindow = {}
|
fshare.FileSharePlugin.filesharewindow = {}
|
||||||
@@ -280,10 +272,8 @@ class FileShareWindow(gtk.Window):
|
|||||||
# If the contact in the comboboxentry is include inside of the
|
# If the contact in the comboboxentry is include inside of the
|
||||||
# combobox
|
# combobox
|
||||||
if contact == self.ts_contacts.get_value(i, 0):
|
if contact == self.ts_contacts.get_value(i, 0):
|
||||||
self.add_file_list(self.plugin.database.get_files_name(self.account,
|
self.add_file_list(self.plugin.database.get_files_name(
|
||||||
contact),
|
self.account, contact), self.ts_files)
|
||||||
self.ts_files
|
|
||||||
)
|
|
||||||
self.manage_vbox2.set_sensitive(True)
|
self.manage_vbox2.set_sensitive(True)
|
||||||
self.bt_remove.set_sensitive(False)
|
self.bt_remove.set_sensitive(False)
|
||||||
break
|
break
|
||||||
@@ -331,8 +321,7 @@ class FileShareWindow(gtk.Window):
|
|||||||
pro = fshare.FileSharePlugin.prohandler[self.account]
|
pro = fshare.FileSharePlugin.prohandler[self.account]
|
||||||
contact = self.get_contact_from_iter(self.ts_search, i)
|
contact = self.get_contact_from_iter(self.ts_search, i)
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(
|
contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
self.account,
|
self.account, contact)
|
||||||
contact )
|
|
||||||
stanza = pro.request(contact.get_full_jid(), name, isFile=False)
|
stanza = pro.request(contact.get_full_jid(), name, isFile=False)
|
||||||
if pro.conn.connection:
|
if pro.conn.connection:
|
||||||
pro.conn.connection.send(stanza)
|
pro.conn.connection.send(stanza)
|
||||||
@@ -371,7 +360,8 @@ class FileShareWindow(gtk.Window):
|
|||||||
file_info = self.brw_file_info[path]
|
file_info = self.brw_file_info[path]
|
||||||
fjid = self.get_contact_from_iter(tree, row)
|
fjid = self.get_contact_from_iter(tree, row)
|
||||||
# Request the file
|
# Request the file
|
||||||
file_path = os.path.join(self.plugin.config['incoming_dir'], file_info[0])
|
file_path = os.path.join(self.plugin.config['incoming_dir'],
|
||||||
|
file_info[0])
|
||||||
sid = helpers.get_random_string_16()
|
sid = helpers.get_random_string_16()
|
||||||
new_file_props = FilesProp.getNewFileProp(self.account, sid)
|
new_file_props = FilesProp.getNewFileProp(self.account, sid)
|
||||||
new_file_props.file_name = file_path
|
new_file_props.file_name = file_path
|
||||||
@@ -383,8 +373,7 @@ class FileShareWindow(gtk.Window):
|
|||||||
new_file_props.hash_ = None if file_info[3] == '' else file_info[3]
|
new_file_props.hash_ = None if file_info[3] == '' else file_info[3]
|
||||||
new_file_props.type_ = 'r'
|
new_file_props.type_ = 'r'
|
||||||
tsid = gajim.connections[self.account].start_file_transfer(fjid,
|
tsid = gajim.connections[self.account].start_file_transfer(fjid,
|
||||||
new_file_props,
|
new_file_props, True)
|
||||||
True)
|
|
||||||
new_file_props.transport_sid = tsid
|
new_file_props.transport_sid = tsid
|
||||||
ft_window = gajim.interface.instances['file_transfers']
|
ft_window = gajim.interface.instances['file_transfers']
|
||||||
contact = gajim.contacts.get_contact_from_full_jid(self.account, fjid)
|
contact = gajim.contacts.get_contact_from_full_jid(self.account, fjid)
|
||||||
@@ -392,9 +381,9 @@ class FileShareWindow(gtk.Window):
|
|||||||
|
|
||||||
def on_bt_sel_dir_pref_clicked(self, widget, data=None):
|
def on_bt_sel_dir_pref_clicked(self, widget, data=None):
|
||||||
chooser = gtk.FileChooserDialog(title='Incoming files directory',
|
chooser = gtk.FileChooserDialog(title='Incoming files directory',
|
||||||
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
action=gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,
|
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
|
||||||
gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
gtk.RESPONSE_OK))
|
||||||
response = chooser.run()
|
response = chooser.run()
|
||||||
if response == gtk.RESPONSE_OK:
|
if response == gtk.RESPONSE_OK:
|
||||||
file_name = chooser.get_filename()
|
file_name = chooser.get_filename()
|
||||||
@@ -407,4 +396,3 @@ if __name__ == "__main__":
|
|||||||
f = FileShareWindow(None)
|
f = FileShareWindow(None)
|
||||||
f.show()
|
f.show()
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ class FileSharePlugin(GajimPlugin):
|
|||||||
@log_calls('FileSharePlugin')
|
@log_calls('FileSharePlugin')
|
||||||
def init(self):
|
def init(self):
|
||||||
self.activated = False
|
self.activated = False
|
||||||
self.description = _('This plugin allows you to share folders'+
|
self.description = _('This plugin allows you to share folders'
|
||||||
' with a peer using jingle file transfer.')
|
' with a peer using jingle file transfer.')
|
||||||
self.config_dialog = None
|
self.config_dialog = None
|
||||||
home_path = os.path.expanduser('~/')
|
home_path = os.path.expanduser('~/')
|
||||||
self.config_default_values = {'incoming_dir': (home_path, '')}
|
self.config_default_values = {'incoming_dir': (home_path, '')}
|
||||||
@@ -105,8 +105,8 @@ class FileSharePlugin(GajimPlugin):
|
|||||||
submenu.attach(msf, 0, 1, 1, 2)
|
submenu.attach(msf, 0, 1, 1, 2)
|
||||||
submenu.attach(enable_fs, 0, 1, 2, 3)
|
submenu.attach(enable_fs, 0, 1, 2, 3)
|
||||||
if gajim.account_is_disconnected(account) or \
|
if gajim.account_is_disconnected(account) or \
|
||||||
contact.show in ('offline', 'error') or not \
|
contact.show in ('offline', 'error') or not \
|
||||||
contact.supports(fshare_protocol.NS_FILE_SHARING):
|
contact.supports(fshare_protocol.NS_FILE_SHARING):
|
||||||
bf.set_sensitive(False)
|
bf.set_sensitive(False)
|
||||||
submenu.show()
|
submenu.show()
|
||||||
bf.show()
|
bf.show()
|
||||||
@@ -137,7 +137,8 @@ class FileSharePlugin(GajimPlugin):
|
|||||||
def __get_fsw_instance(self, account):
|
def __get_fsw_instance(self, account):
|
||||||
# Makes sure we only have one instance of the window per account
|
# Makes sure we only have one instance of the window per account
|
||||||
if account not in FileSharePlugin.filesharewindow:
|
if account not in FileSharePlugin.filesharewindow:
|
||||||
FileSharePlugin.filesharewindow[account] = fsw = FileShareWindow(self)
|
FileSharePlugin.filesharewindow[account] = fsw = FileShareWindow(
|
||||||
|
self)
|
||||||
FileSharePlugin.prohandler[account].set_window(fsw)
|
FileSharePlugin.prohandler[account].set_window(fsw)
|
||||||
return FileSharePlugin.filesharewindow[account]
|
return FileSharePlugin.filesharewindow[account]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user