Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2007-02-27 20:09:40 +01:00
commit 4f4291e41c
3 changed files with 48 additions and 3 deletions

View File

@ -57,9 +57,19 @@ class ServerPlugin(gobject.GObject):
self._conn = self._init_connection()
def _get_account_info(self):
account_info = {'server': 'olpc.collabora.co.uk'}
account_info = {}
pubkey = profile.get_pubkey()
server = profile.get_server()
if not server:
account_info['server'] = 'olpc.collabora.co.uk'
else:
account_info['server'] = server
registered = profile.get_server_registered()
account_info['register'] = not registered
khash = util.printable_hash(util._sha_data(pubkey))
account_info['account'] = "%s@%s" % (khash, account_info['server'])
@ -88,7 +98,6 @@ class ServerPlugin(gobject.GObject):
conn = self._find_existing_connection()
if not conn:
acct = self._account.copy()
acct['register'] = True
# Create a new connection
print acct
@ -117,6 +126,10 @@ class ServerPlugin(gobject.GObject):
return channel
def _connected_cb(self):
if self._account['register']:
# we successfully register this account
profile.set_server_registered()
# the group of contacts who may receive your presence
publish = self._request_list_channel('publish')
publish_handles, local_pending, remote_pending = publish[CHANNEL_INTERFACE_GROUP].GetAllMembers()

View File

@ -239,6 +239,11 @@ class IntroBox(hippo.CanvasBox, hippo.CanvasItem):
cp.set(section, 'NickName', name)
cp.set(section, 'Color', color.to_string())
secion = 'Server'
cp.add_section(section)
cp.set(section, 'Server', 'olpc.collabora.co.uk')
cp.set(Section, 'Registered', 'False')
config_path = os.path.join(env.get_profile_path(), 'config')
f = open(config_path, 'w')
cp.write(f)

View File

@ -28,6 +28,8 @@ class _Profile(object):
self.color = None
self.pubkey = None
self.privkey_hash = None
self.server = None
self.server_registered = False
self._load()
def update(self):
@ -44,6 +46,12 @@ class _Profile(object):
if cp.has_option('Buddy', 'Color'):
self.color = XoColor(cp.get('Buddy', 'Color'))
if cp.has_option('Server', 'Server'):
self.server = cp.get('Server', 'Server')
if cp.has_option('Server', 'Registered'):
self.server_registered = cp.get('Server', 'Registered')
del cp
self._load_pubkey()
@ -110,6 +118,25 @@ def get_pubkey():
def get_private_key_hash():
return _profile.privkey_hash
def get_server():
return _profile.server
def get_server_registered():
return _profile.server_registered
def set_server_registered():
_profile.server_registered = True
cp = ConfigParser()
config_path = os.path.join(env.get_profile_path(), 'config')
cp.read([config_path])
if not cp.has_section('Server'):
cp.add_section('Server')
cp.set('Server', 'Registered', True)
cp.write(open(config_path, 'w'))
def update():
_profile.update()