use GajimPluginConfig for file sharing plugin
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
import ConfigParser
|
||||
import sys
|
||||
import os
|
||||
|
||||
def set(option, value):
|
||||
_file = open(path, 'w')
|
||||
cp.set('General', option, value)
|
||||
cp.write(_file)
|
||||
_file.close()
|
||||
|
||||
def set_defaults():
|
||||
cp.add_section('General')
|
||||
set('incoming_dir', '/home')
|
||||
|
||||
path = sys.path[1]
|
||||
path = path + '/file_sharing/' + 'conf.cfg'
|
||||
cp = ConfigParser.ConfigParser()
|
||||
if os.path.exists(path):
|
||||
_file = open(path)
|
||||
cp.readfp(_file)
|
||||
_file.close()
|
||||
else:
|
||||
set_defaults()
|
||||
INCOMING_DIR = cp.get('General', 'incoming_dir')
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ from common.file_props import FilesProp
|
||||
import fshare
|
||||
import os
|
||||
import fshare_protocol
|
||||
import config
|
||||
|
||||
class FileShareWindow(gtk.Window):
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
gtk.Window.__init__(self)
|
||||
self.set_title('File Share')
|
||||
self.connect('delete_event', self.delete_event)
|
||||
@@ -115,7 +115,7 @@ class FileShareWindow(gtk.Window):
|
||||
# Preferences page
|
||||
self.lbl_pref = gtk.Label('Preferences')
|
||||
self.entry_dir_pref = gtk.Entry(max=0)
|
||||
self.entry_dir_pref.set_text(config.INCOMING_DIR)
|
||||
self.entry_dir_pref.set_text(self.plugin.config['incoming_dir'])
|
||||
self.bt_sel_dir_pref = gtk.Button('Select dir', gtk.STOCK_OPEN)
|
||||
self.bt_sel_dir_pref.connect('clicked', self.on_bt_sel_dir_pref_clicked)
|
||||
self.frm_dir_pref = gtk.Frame('Incoming files directory')
|
||||
@@ -372,7 +372,7 @@ class FileShareWindow(gtk.Window):
|
||||
file_info = self.brw_file_info[path]
|
||||
fjid = self.get_contact_from_iter(tree, row)
|
||||
# Request the file
|
||||
file_path = config.INCOMING_DIR + '/%s' % file_info[0]
|
||||
file_path = os.path.join(self.plugin.config['incoming_dir'], file_info[0])
|
||||
sid = helpers.get_random_string_16()
|
||||
new_file_props = FilesProp.getNewFileProp(self.account, sid)
|
||||
new_file_props.file_name = file_path
|
||||
@@ -400,12 +400,12 @@ class FileShareWindow(gtk.Window):
|
||||
if response == gtk.RESPONSE_OK:
|
||||
file_name = chooser.get_filename()
|
||||
self.entry_dir_pref.set_text(file_name)
|
||||
config.set('incoming_dir', file_name)
|
||||
self.plugin.config['incoming_dir'] = file_name
|
||||
chooser.destroy()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
f = FileShareWindow()
|
||||
f = FileShareWindow(None)
|
||||
f.show()
|
||||
gtk.main()
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ class FileSharePlugin(GajimPlugin):
|
||||
self.description = _('This plugin allows you to share folders'+
|
||||
' with a peer using jingle file transfer.')
|
||||
self.config_dialog = None
|
||||
self.config_default_values = {'incoming_dir': ('/home/', '')}
|
||||
# Create one protocol handler per account
|
||||
accounts = gajim.contacts.get_accounts()
|
||||
for account in gajim.contacts.get_accounts():
|
||||
@@ -133,7 +134,7 @@ class FileSharePlugin(GajimPlugin):
|
||||
def __get_fsw_instance(self, account):
|
||||
# Makes sure we only have one instance of the window per account
|
||||
if account not in FileSharePlugin.filesharewindow:
|
||||
FileSharePlugin.filesharewindow[account] = fsw = FileShareWindow()
|
||||
FileSharePlugin.filesharewindow[account] = fsw = FileShareWindow(self)
|
||||
FileSharePlugin.prohandler[account].set_window(fsw)
|
||||
return FileSharePlugin.filesharewindow[account]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user