示例#1
0
 def _feed_in_private_sources_list_entry(self, source_entry):
     """
     this feeds in a private sources.list entry that is
     available to the user (like a private PPA) that may or
     may not be active 
     """
     # FIXME: strip out password and use apt/auth.conf
     potential_new_entry = SourceEntry(source_entry)
     # look if we have it
     sources = SourcesList()
     for source in sources.list:
         if source == potential_new_entry:
             return False
     # need to add it as a not yet enabled channel
     name = human_readable_name_from_ppa_uri(potential_new_entry.uri)
     # FIXME: use something better than uri as name
     private_channel = SoftwareChannel(name,
                                       None,
                                       None,
                                       source_entry=source_entry)
     private_channel.needs_adding = True
     if private_channel in self.extra_channels:
         return False
     # add it
     self.extra_channels.append(private_channel)
     return True
示例#2
0
    def add_channel(self, name, icon, query):
        """
        create a channel with the name, icon and query specified and append
        it to the set of channels
        return the new channel object
        """
        # print name, icon, query
        channel = SoftwareChannel(name, None, None,
                                  channel_icon=icon,
                                  channel_query=query)
        self.extra_channels.append(channel)
        self.backend.emit("channels-changed", True)

        if channel.installed_only:
            channel._channel_view_id = ViewPages.INSTALLED
        else:
            channel._channel_view_id = ViewPages.AVAILABLE
        return channel
示例#3
0
    def add_channel(self, name, icon, query):
        """
        create a channel with the name, icon and query specified and append
        it to the set of channels
        return the new channel object
        """
        # print name, icon, query
        channel = SoftwareChannel(name,
                                  None,
                                  None,
                                  channel_icon=icon,
                                  channel_query=query)
        self.extra_channels.append(channel)
        self.backend.emit("channels-changed", True)

        if channel.installed_only:
            channel._channel_view_id = ViewPages.INSTALLED
        else:
            channel._channel_view_id = ViewPages.AVAILABLE
        return channel
 def on_previous_purchases_activated(self, query):
     """ called to activate the previous purchases view """
     #print cat_view, name, query
     LOG.debug("on_previous_purchases_activated with query: %s" % query)
     self.state.channel = SoftwareChannel("Previous Purchases",
                                          "software-center-agent",
                                          None,
                                          channel_query=query)
     vm = get_viewmanager()
     vm.display_page(self, AvailablePane.Pages.LIST, self.state,
                     self.display_previous_purchases)
示例#5
0
 def _feed_in_private_sources_list_entry(self, source_entry):
     """
     this feeds in a private sources.list entry that is
     available to the user (like a private PPA) that may or
     may not be active
     """
     # FIXME: strip out password and use apt/auth.conf
     potential_new_entry = SourceEntry(source_entry)
     # look if we have it
     sources = SourcesList()
     for source in sources.list:
         if source == potential_new_entry:
             return False
     # need to add it as a not yet enabled channel
     name = human_readable_name_from_ppa_uri(potential_new_entry.uri)
     # FIXME: use something better than uri as name
     private_channel = SoftwareChannel(name, None, None,
                                       source_entry=source_entry)
     private_channel.needs_adding = True
     if private_channel in self.extra_channels:
         return False
     # add it
     self.extra_channels.append(private_channel)
     return True
示例#6
0
    def _get_channels(self, installed_only=False):
        """
        (internal) implements 'channels()' and 'channels_installed_only()' properties
        """
        distro_channel_name = self.distro.get_distro_channel_name()

        # gather the set of software channels and order them
        other_channel_list = []
        cached_origins = []
        for channel_iter in self.db.xapiandb.allterms("XOL"):
            if len(channel_iter.term) == 3:
                continue
            channel_name = channel_iter.term[3:]
            channel_origin = ""

            # get origin information for this channel
            m = self.db.xapiandb.postlist_begin(channel_iter.term)
            doc = self.db.xapiandb.get_document(m.get_docid())
            for term_iter in doc.termlist():
                if term_iter.term.startswith("XOO") and len(
                        term_iter.term) > 3:
                    channel_origin = term_iter.term[3:]
                    break
            self._logger.debug("channel_name: %s" % channel_name)
            self._logger.debug("channel_origin: %s" % channel_origin)
            if channel_origin not in cached_origins:
                other_channel_list.append((channel_name, channel_origin))
                cached_origins.append(channel_origin)

        dist_channel = None
        partner_channel = None
        for_purchase_channel = None
        new_apps_channel = None
        ppa_channels = []
        other_channels = []
        unknown_channel = []
        local_channel = None

        for (channel_name, channel_origin) in other_channel_list:
            if not channel_name:
                unknown_channel.append(
                    SoftwareChannel(channel_name,
                                    channel_origin,
                                    None,
                                    installed_only=installed_only))
            elif channel_name == distro_channel_name:
                dist_channel = (SoftwareChannel(distro_channel_name,
                                                channel_origin,
                                                None,
                                                installed_only=installed_only))
            elif channel_name == "Partner archive":
                partner_channel = SoftwareChannel(
                    channel_name,
                    channel_origin,
                    "partner",
                    installed_only=installed_only)
            elif channel_name == "notdownloadable":
                if installed_only:
                    local_channel = SoftwareChannel(
                        channel_name,
                        None,
                        None,
                        installed_only=installed_only)
            elif (channel_origin and channel_origin.startswith(
                    "LP-PPA-commercial-ppa-uploaders")):
                # do not display commercial private PPAs, they will all be
                # displayed in the "for-purchase" node anyway
                pass
            elif channel_origin and channel_origin.startswith("LP-PPA"):
                if channel_origin == "LP-PPA-app-review-board":
                    new_apps_channel = SoftwareChannel(
                        channel_name,
                        channel_origin,
                        None,
                        installed_only=installed_only)
                else:
                    ppa_channels.append(
                        SoftwareChannel(channel_name,
                                        channel_origin,
                                        None,
                                        installed_only=installed_only))
            # TODO: detect generic repository source (e.g., Google, Inc.)
            else:
                other_channels.append(
                    SoftwareChannel(channel_name,
                                    channel_origin,
                                    None,
                                    installed_only=installed_only))

        # always display the partner channel, even if its source is not enabled
        if not partner_channel and distro_channel_name == "Ubuntu":
            partner_channel = SoftwareChannel("Partner archive",
                                              "Canonical",
                                              "partner",
                                              installed_only=installed_only)

        # create a "magic" channel to display items available for purchase
        for_purchase_query = xapian.Query(
            "AH" + AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME)
        for_purchase_channel = SoftwareChannel(
            "For Purchase",
            None,
            None,
            channel_icon=None,  # FIXME:  need an icon
            channel_query=for_purchase_query,
            installed_only=installed_only)

        # set them in order
        channels = []
        if dist_channel is not None:
            channels.append(dist_channel)
        if partner_channel is not None:
            channels.append(partner_channel)
        if get_distro().PURCHASE_APP_URL:
            channels.append(for_purchase_channel)
        if new_apps_channel is not None:
            channels.append(new_apps_channel)
        channels.extend(ppa_channels)
        channels.extend(other_channels)
        channels.extend(unknown_channel)
        channels.extend(self.extra_channels)
        if local_channel is not None:
            channels.append(local_channel)

        for channel in channels:
            if installed_only:
                channel._channel_view_id = ViewPages.INSTALLED
            else:
                channel._channel_view_id = ViewPages.AVAILABLE
        return channels