Example #1
0
 def layout(self, layout):
     if not isinstance(layout, dict):
         return False
     lay = dict(name=layout.get("name") or "",
                description=layout.get("description") or "",
                short_description=layout.get("short_description") or "")
     return LightDM.set_layout(LightDM.Layout(**lay))
Example #2
0
    def _new_user_reboot(self, event=None, button=None):
        '''
        Schedules kano-init to create a new user from scratch on next reboot,
        then performs the actual reboot
        '''
        confirm = KanoDialog(
            title_text=_('Are you sure you want to create a new account?'),
            description_text=_('A reboot will be required'),
            button_dict=[
                {
                    'label': _('Cancel').upper(),
                    'color': 'red',
                    'return_value': False
                },
                {
                    'label': _('Create').upper(),
                    'color': 'green',
                    'return_value': True
                }
            ])
        confirm.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

        if confirm.run():
            os.system("sudo kano-init schedule add-user")
            LightDM.restart()
Example #3
0
    def delete_user(self, *args):
        import pam

        password_input = Gtk.Entry()
        password_input.set_visibility(False)
        password_input.set_alignment(0.5)

        confirm = KanoDialog(
            title_text = _('Are you sure you want to delete this account?'),
            description_text = _('Enter {}\'s password - A reboot will be required'.format(self.user)),
            widget=password_input,
            has_entry=True,
            button_dict = [
                {
                    'label': _('Cancel').upper(),
                    'color': 'red',
                    'return_value': False
                },
                {
                    'label': _('Ok').upper(),
                    'color': 'green',
                    'return_value': True
                }
            ])

        confirm.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

        # Kano Dialog will return False if cancel button is clicked, or text from the entry field if Ok
        response=confirm.run()
        if response == False:
            return
        elif type(response) == str and not len(response):
            error = KanoDialog(title_text = _('Please enter the password for user {}'.format(self.user)))
            error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
            error.run()
            return
        else:
            password=response

        # Authenticate user and schedule removal. Protect against unknown troubles.
        try:
            if pam.authenticate(self.user, password):
                info = KanoDialog(title_text = _('User {} scheduled for removal'.format(self.user)), \
                                  description_text = _('Press OK to reboot'))
                info.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
                info.run()

                os.system('sudo kano-init schedule delete-user "{}"'.format(self.user))
                LightDM.restart()
            else:
                error = KanoDialog(title_text = _('Incorrect password for user {}'.format(self.user)))
                error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
                error.run()
        except Exception as e:
            logger.error('Error deleting account {} - {}'.format(self.user, str(e)))
            error = KanoDialog(title_text = _('Could not delete account {}'.format(self.user)))
            error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
            error.run()
    def __init__(self, **kwargs):
        super(GreeterApp, self).__init__(**kwargs)
        self.password = ""
        self.session = ""
        
        # Connect to lightDM
        install_gobject_iteration()
        self.greeter = LightDM.Greeter()
        self.greeter.connect("authentication-complete", self.authentication_complete_cb)
        self.greeter.connect("show-prompt", self.show_prompt_cb)
        self.greeter.connect_sync()
        
        # Get all available sessions
        available_sessions = []
        for sess in LightDM.get_sessions():
            available_sessions.append(LightDM.Session.get_key(sess))
        
        # Get all available users
        available_users = []
        inst = LightDM.UserList.get_instance()
        for user in LightDM.UserList.get_users(inst):
            user_name = LightDM.User.get_name(user)
            available_users.append(user_name)

        self.root_widget = Builder.load_string(kv)
        self.root_widget.username_spinner.values = available_users
        self.root_widget.session_spinner.values = available_sessions
Example #5
0
    def __init__(self):

        # create the greeter
        self.greeter = LightDM.Greeter()
        self.greeter.connect_sync()
        # define the main loop
        main_loop = GObject.MainLoop()

        # connect correct signal handlers to the greeter
        self.greeter.connect('show-prompt', self.show_prompt)
        self.greeter.connect('show-message', self.show_message)
        self.greeter.connect('authentication-complete', self.authentication_complete)

        display = Gdk.Display.get_default()
        screen = display.get_default_screen()
        screen_width = screen.get_width()
        screen_height = screen.get_height()

        self.window = gtk.Window()
        self.window.ocnnect("destroy", Gtk.main_quit)
        self.window.app_paintable = True
        self.window.set_default_size(screen_width, screen_height)
        self.window.realize()

        # TODO : self.view = 
        # TODO : view stuff...GTK? Webkit? Qt?

        ...

        self.window.add(self.view)
        self.window.show_all()
        main_loop.run()
Example #6
0
    def _btn_shutdown_pressed(self, event=None, button=None):
        shutdown_dialog = KanoDialog(
            title_text='Shutting down..',
            description_text='Are you sure you want to shutdown your Kano now?',
            button_dict=[{
                'label': _('Cancel').upper(),
                'color': 'green',
                'return_value': False
            }, {
                'label': _('SHUTDOWN').upper(),
                'color': 'orange',
                'return_value': True
            }])
        shutdown_dialog.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        poweroff = shutdown_dialog.run()

        if poweroff:
            LightDM.shutdown()
Example #7
0
    def _btn_shutdown_pressed(self, event=None, button=None):
        shutdown_dialog = KanoDialog(title_text='Shutting down..',
                                     description_text='Are you sure you want to shutdown your Kano now?',
                                     button_dict=[
                                         {
                                             'label': _('Cancel').upper(),
                                             'color': 'green',
                                             'return_value': False
                                         },
                                         {
                                             'label': _('SHUTDOWN').upper(),
                                             'color': 'orange',
                                             'return_value': True
                                         }
                                     ])
        shutdown_dialog.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
        poweroff = shutdown_dialog.run()

        if poweroff:
            LightDM.shutdown()
def authentication_complete_cb(greeter):
    logger.info('AUTH COMPLETE!')
    NOTE.set("Auth complete")
    c.itemconfig(mylabel, text=NOTE.get())
    if greeter.get_is_authenticated():
        if not greeter.start_session_sync(LightDM.get_sessions()[0]):
            NOTE.set("Failed to start XFCE")
            c.itemconfig(mylabel, text=NOTE.get())
    else:
        NOTE.set("Login failed.")
        c.itemconfig(mylabel, text=NOTE.get())
 def can_hibernate(self):
     return LightDM.get_can_hibernate()
Example #10
0
 def suspend(self):
     return LightDM.suspend()
Example #11
0
 def restart(self):
     return LightDM.restart()
Example #12
0
 def sessions(self):
     return [session_to_dict(session) for session in LightDM.get_sessions()]
Example #13
0
 def languages(self):
     return [language_to_dict(lang) for lang in LightDM.get_languages()]
Example #14
0
 def hostname(self):
     return LightDM.get_hostname()
 def languages(self):
     return [language_to_dict(lang) for lang in LightDM.get_languages()]
 def language(self):
     return language_to_dict(LightDM.get_language())
 def hostname(self):
     return LightDM.get_hostname()
 def can_suspend(self):
     return LightDM.get_can_suspend()
 def can_shutdown(self):
     return LightDM.get_can_shutdown()
 def can_restart(self):
     return LightDM.get_can_restart()
Example #21
0
 def can_shutdown(self):
     return LightDM.get_can_shutdown()
Example #22
0
 def can_suspend(self):
     return LightDM.get_can_suspend()
 def layout(self):
     return layout_to_dict(LightDM.get_layout())
Example #24
0
 def language(self):
     return language_to_dict(LightDM.get_language())
 def layouts(self):
     return [layout_to_dict(layout) for layout in LightDM.get_layouts()]
Example #26
0
 def layout(self):
     return layout_to_dict(LightDM.get_layout())
 def sessions(self):
     return [session_to_dict(session) for session in LightDM.get_sessions()]
Example #28
0
 def layouts(self):
     return [layout_to_dict(layout) for layout in LightDM.get_layouts()]
Example #29
0
    global cam

    if len(sys.argv) > 1 and sys.argv[1] == 'dev':
        DEV = True
        debug_print("Started DEV Mode")
    else:
        debug_print("Started in GREETER mode")

    set_resource_path()

    cam = cv2.VideoCapture(0)
    if cam is not None and cam.isOpened():
        CAM_FOUND = True
        debug_print("CAM FOUND!")

    greeter = LightDM.Greeter()

    if not DEV:
        greeter.connect_to_daemon_sync()
        debug_print("Connected to daemon")

    greeter.connect("show-message", show_message_func)
    greeter.connect("show-prompt", show_prompt_func)
    greeter.connect("authentication-complete", authentication_complete_cb)
    debug_print("Greeter functions connected")

    css_P = Gtk.CssProvider()
    css_P.load_from_path(RES_PATH + "style.css")
    Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css_P,
                                             400)
    builder.add_from_file(RES_PATH + "OptiGreeter_UI.glade")
Example #30
0
 def hibernate(self):
     return LightDM.hibernate()
Example #31
0
from logger import logger
from browser.error_prompt import Dialog, general_error_prompt
from browser.bridge import Bridge, BridgeObject

from config import web_greeter_config
from utils.battery import Battery
from bindings.screensaver import screensaver
from utils.brightness import BrightnessController
import globales

from . import (language_to_dict, layout_to_dict, session_to_dict, user_to_dict,
               battery_to_dict)

# import utils.battery as battery

LightDMGreeter = LightDM.Greeter()
LightDMUsers = LightDM.UserList()


class Greeter(BridgeObject):
    # pylint: disable=no-self-use,missing-function-docstring,too-many-public-methods,invalid-name
    """Greeter bridge class, known as `lightdm` in javascript"""

    # LightDM.Greeter Signals
    authentication_complete = Bridge.signal()
    autologin_timer_expired = Bridge.signal()
    idle = Bridge.signal()
    reset = Bridge.signal()
    show_message = Bridge.signal(str, int, arguments=('text', 'type'))
    show_prompt = Bridge.signal(str, int, arguments=('text', 'type'))
Example #32
0
 def shutdown(self):
     return LightDM.shutdown()
Example #33
0
 def can_hibernate(self):
     return LightDM.get_can_hibernate()
Example #34
0
    def delete_user(self, *args):
        import pam

        password_input = Gtk.Entry()
        password_input.set_visibility(False)
        password_input.set_alignment(0.5)

        confirm = KanoDialog(
            title_text=_('Are you sure you want to delete this account?'),
            description_text=_(
                'Enter {}\'s password - A reboot will be required'.format(
                    self.user)),
            widget=password_input,
            has_entry=True,
            button_dict=[{
                'label': _('Cancel').upper(),
                'color': 'red',
                'return_value': False
            }, {
                'label': _('Ok').upper(),
                'color': 'green',
                'return_value': True
            }])

        confirm.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)

        # Kano Dialog will return False if cancel button is clicked, or text from the entry field if Ok
        response = confirm.run()
        if response == False:
            return
        elif type(response) == str and not len(response):
            error = KanoDialog(title_text=_(
                'Please enter the password for user {}'.format(self.user)))
            error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
            error.run()
            return
        else:
            password = response

        # Authenticate user and schedule removal. Protect against unknown troubles.
        try:
            if pam.authenticate(self.user, password):
                info = KanoDialog(title_text = _('User {} scheduled for removal'.format(self.user)), \
                                  description_text = _('Press OK to reboot'))
                info.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
                info.run()

                os.system('sudo kano-init schedule delete-user "{}"'.format(
                    self.user))
                LightDM.restart()
            else:
                error = KanoDialog(title_text=_(
                    'Incorrect password for user {}'.format(self.user)))
                error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
                error.run()
        except Exception as e:
            logger.error('Error deleting account {} - {}'.format(
                self.user, str(e)))
            error = KanoDialog(
                title_text=_('Could not delete account {}'.format(self.user)))
            error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
            error.run()
Example #35
0
 def can_restart(self):
     return LightDM.get_can_restart()