Ejemplo n.º 1
0
    def __init__(self,
                 name,
                 theme,
                 next,
                 width,
                 height,
                 room_str=None,
                 id=None):
        if id:
            self.id = id
        else:
            self.id = unique_id()

        self.name = name
        self.theme = theme
        self.next = next
        self.width = width
        self.height = height

        self.roomlist = []

        for y in range(0, height):
            room_row = []
            for x in range(0, width):
                if room_str:
                    room_row.append(Room(x, y, room_str.pop(0)))
                else:
                    room_row.append(Room(x, y))
            self.roomlist.append(room_row)
Ejemplo n.º 2
0
    def _connect(self):
        # Activate existing connection, if there is one
        connection = network.find_connection_by_ssid(self._ssid)
        if connection:
            logging.debug('Activating existing connection for SSID %r',
                          self._ssid)
            connection.activate(self._device)
            return

        # Otherwise, create new connection and activate it
        logging.debug('Creating new connection for SSID %r', self._ssid)
        settings = Settings()
        settings.connection.id = self._display_name
        settings.connection.uuid = unique_id()
        settings.connection.type = '802-11-wireless'
        settings.wireless.ssid = self._ssid

        if self._mode == network.NM_802_11_MODE_INFRA:
            settings.wireless.mode = 'infrastructure'
            settings.connection.autoconnect = True
        elif self._mode == network.NM_802_11_MODE_ADHOC:
            settings.wireless.mode = 'adhoc'
            settings.wireless.band = 'bg'
            settings.ip4_config = IP4Config()
            settings.ip4_config.method = 'link-local'

        wireless_security = self._get_security()
        settings.wireless_security = wireless_security

        if wireless_security is not None:
            settings.wireless.security = '802-11-wireless-security'

        network.add_and_activate_connection(self._device, settings,
                                            self.get_first_ap().model)
Ejemplo n.º 3
0
 def _add_connection(self, channel, xs_hosted):
     anycast_addr = _XS_ANYCAST if xs_hosted else None
     wireless_config = OlpcMeshSettings(channel, anycast_addr)
     settings = Settings(wireless_cfg=wireless_config)
     if not xs_hosted:
         settings.ip4_config = network.IP4Config()
         settings.ip4_config.method = 'link-local'
     settings.connection.id = self._get_connection_id(channel, xs_hosted)
     settings.connection.autoconnect = False
     settings.connection.uuid = unique_id()
     settings.connection.type = '802-11-olpc-mesh'
     network.add_connection(settings,
                            reply_handler=self._add_connection_reply_cb,
                            error_handler=self._add_connection_err_cb)
Ejemplo n.º 4
0
    def _ps_connection_status_cb(self, ps, connected):
        if not connected:
            return

        if not len(self._test_activities):
            # Share some activities
            actid = util.unique_id("Activity 1")
            atype = "org.laptop.WebActivity"
            properties = {"tags": "bar"}
            self._ps.ShareActivity(actid, atype, "Wembley Stadium", properties,
                    async_cb=lambda path: self._share_reply_cb(actid, path),
                    async_err_cb=lambda e: self._share_error_cb(actid, e))

            actid2 = util.unique_id("Activity 2")
            atype = "org.laptop.WebActivity"
            properties = {"tags": "baz"}
            self._ps.ShareActivity(actid2, atype, "Maine Road", properties,
                async_cb=lambda path: self._share_reply_cb(actid2, path),
                async_err_cb=lambda e: self._share_error_cb(actid2, e))

        # Change a random property ever 10 seconds
        if self._change_timeout == 0:
            self._change_timeout = gobject.timeout_add(10000, self._update_something)
Ejemplo n.º 5
0
 def _add_connection(self, channel):
     ssid = "Ad-hoc Network %d" % (channel,)
     settings = Settings()
     settings.connection.id = self._get_connection_id(channel)
     settings.connection.uuid = unique_id()
     settings.connection.type = "802-11-wireless"
     settings.connection.autoconnect = False
     settings.wireless.ssid = dbus.ByteArray(ssid)
     settings.wireless.band = "bg"
     settings.wireless.channel = channel
     settings.wireless.mode = "adhoc"
     settings.ip4_config = IP4Config()
     settings.ip4_config.method = "link-local"
     network.add_connection(settings)
Ejemplo n.º 6
0
 def _add_connection(self, channel):
     ssid = 'Ad-hoc Network %d' % (channel,)
     settings = Settings()
     settings.connection.id = self._get_connection_id(channel)
     settings.connection.uuid = unique_id()
     settings.connection.type = '802-11-wireless'
     settings.connection.autoconnect = False
     settings.wireless.ssid = dbus.ByteArray(ssid)
     settings.wireless.band = 'bg'
     settings.wireless.channel = channel
     settings.wireless.mode = 'adhoc'
     settings.ip4_config = IP4Config()
     settings.ip4_config.method = 'link-local'
     network.add_connection(settings)
Ejemplo n.º 7
0
 def _add_connection(self, channel, xs_hosted):
     anycast_addr = _XS_ANYCAST if xs_hosted else None
     wireless_config = OlpcMeshSettings(channel, anycast_addr)
     settings = Settings(wireless_cfg=wireless_config)
     if not xs_hosted:
         settings.ip4_config = network.IP4Config()
         settings.ip4_config.method = 'link-local'
     settings.connection.id = self._get_connection_id(channel, xs_hosted)
     settings.connection.autoconnect = False
     settings.connection.uuid = unique_id()
     settings.connection.type = '802-11-olpc-mesh'
     network.add_connection(settings,
                            reply_handler=self._add_connection_reply_cb,
                            error_handler=self._add_connection_err_cb)
Ejemplo n.º 8
0
    def __init__(self, parent):
        self.pydebug = parent

        if version < 0.838:
            from hulahop.webview import WebView as Browser
        else:
            from browser import Browser

        self.help_id = None
        self.handle = ActivityHandle()
        self.handle.activity_id = util.unique_id()
        Window.__init__(self)
        self.connect('realize', self.realize_cb)

        self._web_view = Browser()

        #determine which language we are going to be using
        help_root = self.get_help_root()
        self.HOME = os.path.join(help_root, 'PyDebug.htm')

        self.toolbox = Toolbox()
        self.toolbox.connect('current_toolbar_changed', self.goto_cb)
        self.set_toolbox(self.toolbox)
        self.toolbox.show()
        activitybar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Activity'), activitybar)
        activitybar.show_all()

        editbar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Edit'), editbar)
        editbar.show_all()

        projectbar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Project'), projectbar)
        projectbar.show_all()

        self.help_toolbar = Toolbar(self, self._web_view)
        self.help_toolbar.show()
        self.toolbox.add_toolbar(_('Help'), self.help_toolbar)
        self.toolbox._notebook.set_current_page(HELP_PANE)

        self.set_canvas(self._web_view)
        self._web_view.show()

        self.toolbox.set_current_toolbar(HELP_PANE)

        self._web_view.load_uri(self.HOME)
        self.pid = Popen(['/usr/bin/pydoc', '-p', '23432'])
Ejemplo n.º 9
0
def create_gsm_connection(username, password, number, apn, pin):
    settings = SettingsGsm()
    settings.gsm.username = username
    settings.gsm.number = number
    settings.gsm.apn = apn
    settings.gsm.pin = pin
    settings.gsm.password = password

    settings.connection.id = GSM_CONNECTION_ID
    settings.connection.type = NM_CONNECTION_TYPE_GSM
    settings.connection.uuid = unique_id()
    settings.connection.autoconnect = False
    settings.ip4_config.method = 'auto'
    settings.serial.baud = GSM_BAUD_RATE

    add_connection(settings)
Ejemplo n.º 10
0
    def __init__(self, parent):
        self.parent_obj = parent
        hulahop.startup(os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'],'data','gecko'))
        #from hulahop.webview import WebView
        from browser import Browser
        import xpcom
        from xpcom.components import interfaces
        self.help_id = None
        self.handle = ActivityHandle()
        self.handle.activity_id = util.unique_id()
        Window.__init__(self)
        self.connect('realize',self.realize_cb)

        #self.props.max_participants = 1

        self._web_view = Browser()

        #Mimic the other tabs (hide the fact that this is another window)
        self.toolbox = Toolbox()
        self.toolbox.connect_after('current_toolbar_changed',self.goto_cb)
        self.set_toolbox(self.toolbox)
        self.toolbox.show()
        
        activitybar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Activity'), activitybar)
        activitybar.show_all()
        
        editbar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Edit'), editbar)
        editbar.show_all()
        
        usebar = gtk.Toolbar()
        self.toolbox.add_toolbar(_('Output'), usebar)
        usebar.show_all()
        
        self.help_toolbar = Toolbar(self._web_view)
        self.help_toolbar.show()
        self.toolbox.add_toolbar(_('Help'), self.help_toolbar)
        self.toolbox._notebook.set_current_page(HELP_PANE)

        self.set_canvas(self._web_view)
        self._web_view.show()

        self.toolbox.set_current_toolbar(HELP_PANE)
def create_activity_id():
    """Generate a new, unique ID for this activity"""
    pservice = presenceservice.get_instance()

    # create a new unique activity ID
    i = 0
    act_id = None
    while i < 10:
        act_id = util.unique_id()
        i += 1

        # check through network activities
        found = False
        activities = pservice.get_activities()
        for act in activities:
            if act_id == act.props.id:
                found = True
                break
        if not found:
            return act_id
    raise RuntimeError("Cannot generate unique activity id.")
Ejemplo n.º 12
0
    def drag_drop_cb(self, widget, context, x, y, time):
        logging.debug('ClipboardTray._drag_drop_cb')

        if self._internal_drag(context):
            # TODO: We should move the object within the clipboard here
            if not self._context_map.has_context(context):
                context.drop_finish(False, gtk.get_current_event_time())
            return False

        cb_service = clipboard.get_instance()
        object_id = cb_service.add_object(name="")

        self._context_map.add_context(context, object_id, len(context.targets))

        if 'XdndDirectSave0' in context.targets:
            window = context.source_window
            prop_type, format_, filename = \
                window.property_get('XdndDirectSave0', 'text/plain')

            # FIXME query the clipboard service for a filename?
            base_dir = tempfile.gettempdir()
            dest_filename = util.unique_id()

            name_, dot, extension = filename.rpartition('.')
            dest_filename += dot + extension

            dest_uri = 'file://' + os.path.join(base_dir, dest_filename)

            window.property_change('XdndDirectSave0', prop_type, format_,
                                   gtk.gdk.PROP_MODE_REPLACE, dest_uri)

            widget.drag_get_data(context, 'XdndDirectSave0', time)
        else:
            for target in context.targets:
                if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
                    widget.drag_get_data(context, target, time)

        cb_service.set_object_percent(object_id, percent=100)

        return True
Ejemplo n.º 13
0
    def drag_drop_cb(self, widget, context, x, y, time):
        logging.debug('ClipboardTray._drag_drop_cb')

        if self._internal_drag(context):
            # TODO: We should move the object within the clipboard here
            if not self._context_map.has_context(context):
                context.drop_finish(False, gtk.get_current_event_time())
            return False

        cb_service = clipboard.get_instance()
        object_id = cb_service.add_object(name="")

        self._context_map.add_context(context, object_id, len(context.targets))

        if 'XdndDirectSave0' in context.targets:
            window = context.source_window
            prop_type, format_, filename = \
                window.property_get('XdndDirectSave0', 'text/plain')

            # FIXME query the clipboard service for a filename?
            base_dir = tempfile.gettempdir()
            dest_filename = util.unique_id()

            name_, dot, extension = filename.rpartition('.')
            dest_filename += dot + extension

            dest_uri = 'file://' + os.path.join(base_dir, dest_filename)

            window.property_change('XdndDirectSave0', prop_type, format_,
                                   gtk.gdk.PROP_MODE_REPLACE, dest_uri)

            widget.drag_get_data(context, 'XdndDirectSave0', time)
        else:
            for target in context.targets:
                if str(target) not in ('TIMESTAMP', 'TARGETS', 'MULTIPLE'):
                    widget.drag_get_data(context, target, time)

        cb_service.set_object_percent(object_id, percent=100)

        return True
Ejemplo n.º 14
0
    def __init__( self, name, theme, next, width, height, room_str = None, id = None ):
        if id:
            self.id = id
        else:
            self.id = unique_id()

        self.name = name
        self.theme = theme
        self.next = next
        self.width = width
        self.height = height

        self.roomlist = []

        for y in range(0, height):
            room_row = []
            for x in range(0, width):
                if room_str:
                    room_row.append( Room(x,y, room_str.pop(0) ) )
                else:
                    room_row.append( Room(x,y) )
            self.roomlist.append(room_row)
Ejemplo n.º 15
0
 def realize_cb(self, window):
     self.help_id = util.unique_id()
     wm.set_activity_id(window.window, self.help_id)
     self.help_window = window
Ejemplo n.º 16
0
 def realize_cb(self, window):
     self.help_id = util.unique_id()
     wm.set_activity_id(window.window, self.help_id)
     self.help_window = window
     self._web_view.load_uri(HOME)
Ejemplo n.º 17
0
def create_activity_id():
    """Generate a new, unique ID for this activity"""
    return util.unique_id(uuid.getnode())