Registration menu
This commit is contained in:
parent
ab7cd66374
commit
c34b5204ac
2
NEWS
2
NEWS
@ -1,3 +1,5 @@
|
||||
* Register to the school server from XO palette (marco)
|
||||
|
||||
Snapshot 05668dfad7
|
||||
|
||||
* First implementation of the alert bar #2822 and hooked it up
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
from sugar import profile
|
||||
from sugar.profile import get_profile
|
||||
from xmlrpclib import ServerProxy, Error
|
||||
import sys
|
||||
import os
|
||||
@ -15,19 +14,18 @@ def register_laptop(url=REGISTER_URL):
|
||||
sn = sn or 'SHF00000000'
|
||||
uuid = uuid or '00000000-0000-0000-0000-000000000000'
|
||||
|
||||
nick = profile.get_nick_name()
|
||||
pubkey = profile.get_pubkey()
|
||||
profile = get_profile()
|
||||
|
||||
try:
|
||||
server = ServerProxy(url)
|
||||
data = server.register(sn, nick, uuid, pubkey)
|
||||
data = server.register(sn, profile.nick_name, uuid, profile.pubkey)
|
||||
if data['success'] != 'OK':
|
||||
print >> sys.stderr, "Error registering laptop: " + data['error']
|
||||
return False
|
||||
backupurl = data['backupurl']
|
||||
jserver = data['jabberserver']
|
||||
profile.set_server(jserver)
|
||||
profile.set_trial2_backup(backupurl)
|
||||
|
||||
profile.jabber_server = data['jabberserver']
|
||||
profile.backup1 = data['backupurl']
|
||||
profile.save()
|
||||
except Error, e:
|
||||
print >> sys.stderr, "Error registering laptop: " + str(e)
|
||||
return False
|
||||
@ -45,9 +43,3 @@ def read_ofw(path):
|
||||
data = fh.read().rstrip('\0\n')
|
||||
fh.close()
|
||||
return data
|
||||
|
||||
if __name__ == "__main__":
|
||||
url = REGISTER_URL
|
||||
if len(sys.argv) > 1:
|
||||
url = sys.argv[1]
|
||||
register_laptop(url)
|
||||
|
@ -29,13 +29,14 @@ from sugar.graphics import style
|
||||
from sugar.graphics.xocolor import XoColor
|
||||
from sugar.graphics.palette import Palette, CanvasInvoker
|
||||
from sugar.graphics.icon import CanvasIcon
|
||||
from sugar import profile
|
||||
from sugar.profile import get_profile
|
||||
from sugar import env
|
||||
|
||||
from view.home.activitiesdonut import ActivitiesDonut
|
||||
from view.devices import deviceview
|
||||
from view.home.MyIcon import MyIcon
|
||||
from model.shellmodel import ShellModel
|
||||
from hardware import schoolserver
|
||||
|
||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||
__gtype_name__ = 'SugarHomeBox'
|
||||
@ -178,20 +179,27 @@ class _MyIcon(MyIcon):
|
||||
|
||||
self._power_manager = None
|
||||
self._shell = shell
|
||||
self._profile = get_profile()
|
||||
|
||||
def enable_palette(self):
|
||||
palette = Palette(profile.get_nick_name())
|
||||
palette = Palette(self._profile.nick_name)
|
||||
|
||||
reboot_menu_item = gtk.MenuItem(_('Reboot'))
|
||||
reboot_menu_item.connect('activate', self._reboot_activate_cb)
|
||||
shutdown_menu_item = gtk.MenuItem(_('Shutdown'))
|
||||
shutdown_menu_item.connect('activate', self._shutdown_activate_cb)
|
||||
item = gtk.MenuItem(_('Reboot'))
|
||||
item.connect('activate', self._reboot_activate_cb)
|
||||
palette.menu.append(item)
|
||||
item.show()
|
||||
|
||||
item = gtk.MenuItem(_('Shutdown'))
|
||||
item.connect('activate', self._shutdown_activate_cb)
|
||||
palette.menu.append(item)
|
||||
item.show()
|
||||
|
||||
if not self._profile.is_registered():
|
||||
item = gtk.MenuItem(_('Register'))
|
||||
item.connect('activate', self._register_activate_cb)
|
||||
palette.menu.append(item)
|
||||
item.show()
|
||||
|
||||
palette.menu.append(reboot_menu_item)
|
||||
palette.menu.append(shutdown_menu_item)
|
||||
reboot_menu_item.show()
|
||||
shutdown_menu_item.show()
|
||||
|
||||
self.set_palette(palette)
|
||||
|
||||
def _reboot_activate_cb(self, menuitem):
|
||||
@ -222,6 +230,11 @@ class _MyIcon(MyIcon):
|
||||
else:
|
||||
pm.Shutdown()
|
||||
|
||||
def _register_activate_cb(self, menuitem):
|
||||
schoolserver.register_laptop()
|
||||
if self._profile.is_registered():
|
||||
self.get_palette().menu.remove(menuitem)
|
||||
|
||||
def _close_emulator(self):
|
||||
if os.environ.has_key('SUGAR_EMULATOR_PID'):
|
||||
pid = int(os.environ['SUGAR_EMULATOR_PID'])
|
||||
|
@ -79,6 +79,9 @@ class Profile(object):
|
||||
self.pubkey is not None and \
|
||||
self.privkey_hash is not None
|
||||
|
||||
def is_registered(self):
|
||||
return self.backup1 is not None
|
||||
|
||||
def save(self):
|
||||
cp = ConfigParser()
|
||||
parsed = cp.read([self._config_path])
|
||||
|
Loading…
Reference in New Issue
Block a user