diff options
author | Sebastian Heinlein <devel@glatzor.de> | 2008-08-18 12:21:08 +0200 |
---|---|---|
committer | Sebastian Heinlein <devel@glatzor.de> | 2008-08-18 12:21:08 +0200 |
commit | 8ebf6d2dae4bea16ddf95d7f902b2acc33191aaa (patch) | |
tree | bd717af9bf59920f0fa0f1aa5a2af1ff64962204 | |
parent | a75453457f167831e37a19a7248340155f69ba97 (diff) |
APT: Implement SearchGroup
-rwxr-xr-x | backends/apt/aptDBUSBackend.py | 117 | ||||
-rw-r--r-- | backends/apt/pk-backend-apt.c | 27 |
2 files changed, 135 insertions, 9 deletions
diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py index cb52e9997..dc004ab03 100755 --- a/backends/apt/aptDBUSBackend.py +++ b/backends/apt/aptDBUSBackend.py @@ -254,6 +254,29 @@ class PackageKitAptBackend(PackageKitBaseBackend): self._canceled.wait() @threaded + def doSearchGroup(self, filters, group): + ''' + Implement the apt2-search-group functionality + ''' + pklog.info("Searching for group: %s" % group) + self.StatusChanged(STATUS_QUERY) + self.NoPercentageUpdates() + self._check_init(progress=False) + self.AllowCancel(True) + + for pkg in self._cache: + if self._canceled.isSet(): + self.ErrorCode(ERROR_TRANSACTION_CANCELLED, + "The search was canceled") + self.Finished(EXIT_KILLED) + self._canceled.clear() + return + elif self._get_package_group(pkg) == group and \ + self._is_package_visible(pkg, filters): + self._emit_package(pkg) + self.Finished(EXIT_SUCCESS) + + @threaded def doSearchName(self, filters, search): ''' Implement the apt2-search-name functionality @@ -437,15 +460,15 @@ class PackageKitAptBackend(PackageKitBaseBackend): # replace all multiple spaces by newlines p = re.compile(r'\s\s+', re.MULTILINE) desc = p.sub('\n', desc) - #FIXME: group information missing #FIXME: We need more fine grained license information! - origin = pkg.candidateOrigin - if origin[0].component in ["main", "universe"] and \ - origin[0].origin in ["Debian", "Ubuntu"]: + origin = pkg.candidateOrigin[0] + if origin.component in ["main", "universe"] and \ + origin.origin in ["Debian", "Ubuntu"]: license = "free" else: license = "unknown" - self.Details(pkg_id, license, 'unknown', desc, + group = self._get_package_group(pkg) + self.Details(pkg_id, license, group, desc, pkg.homepage, pkg.packageSize) self.Finished(EXIT_SUCCESS) @@ -1315,6 +1338,90 @@ class PackageKitAptBackend(PackageKitBaseBackend): "check your Internet connection." return changelog + def _get_package_group(self, pkg): + """ + Return the packagekit group corresponding to the package's section + """ + section = pkg.section + if section == "admin": + return GROUP_ADMIN_TOOLS + elif section == "base": + return GROUP_SYSTEM + elif section == "comm": + return GROUP_COMMUNICATION + elif section == "devel": + return GROUP_PROGRAMMING + elif section == "doc": + #FIXME: introduce a new group + return GROUP_OTHER + elif section == "editors": + return GROUP_PUBLISHING + elif section == "electronics": + #FIXME: do we need a special group? + return GROUP_OTHER + elif section == "embedded": + return GROUP_SYSTEM + elif section == "games": + return GROUP_GAMES + elif section == "GNOME": + return GROUP_DESKTOP_GNOME + elif section == "graphics": + return GROUP_GRAPHICS + elif section == "hamradio": + return GROUP_COMMUNICATION + elif section == "interpreters": + return GROUP_PROGRAMMING + elif section == "kde": + return GROUP_DESKTOP_KDE + elif section == "libdevel": + return GROUP_PROGRAMMING + elif section == "lib": + return GROUP_SYSTEM + elif section == "mail": + return GROUP_INTERNET + elif section == "math": + #FIXME: Need a group science + return GROUP_OTHER + elif section == "misc": + return GROUP_OTHER + elif section == "net": + return GROUP_NETWORK + elif section == "news": + return GROUP_INTERNET + elif section == "oldlibs": + return GROUP_LEGACY + elif section == "otherosfs": + return GROUP_SYSTEM + elif section == "perl": + return GROUP_PROGRAMMING + elif section == "python": + return GROUP_PROGRAMMING + elif section == "science": + #FIXME Need a new group + return GROUP_OTHER + elif section == "shells": + return GROUP_SYSTEM + elif section == "sound": + return GROUP_MULTIMEDIA + elif section == "tex": + return GROUP_PUBLISHING + elif section == "text": + return GROUP_PUBLISHING + elif section == "utils": + return GROUP_ACCESSORIES + elif section == "web": + return GROUP_INTERNET + elif section == "x11": + return GROUP_DESKTOP_OTHER + elif section == "unknown": + return GROUP_UNKNOWN + elif section == "alien": + return GROUP_UNKNOWN + elif section == "translations": + return GROUP_LOCALIZATION + else: + return GROUP_UNKNOWN + def takeover(): """ Exit the currently running backend diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c index d12854830..da1ef9701 100644 --- a/backends/apt/pk-backend-apt.c +++ b/backends/apt/pk-backend-apt.c @@ -58,14 +58,23 @@ static PkGroupEnum backend_get_groups (PkBackend *backend) { return (PK_GROUP_ENUM_ACCESSORIES | + PK_GROUP_ENUM_ADMIN_TOOLS | + PK_GROUP_ENUM_COMMUNICATION | + PK_GROUP_ENUM_DESKTOP_GNOME | + PK_GROUP_ENUM_DESKTOP_KDE | + PK_GROUP_ENUM_DESKTOP_OTHER | PK_GROUP_ENUM_GAMES | PK_GROUP_ENUM_GRAPHICS | PK_GROUP_ENUM_INTERNET | - PK_GROUP_ENUM_OFFICE | + PK_GROUP_ENUM_LEGACY | + PK_GROUP_ENUM_LOCALIZATION | + PK_GROUP_ENUM_MULTIMEDIA | + PK_GROUP_ENUM_NETWORK | PK_GROUP_ENUM_OTHER | PK_GROUP_ENUM_PROGRAMMING | - PK_GROUP_ENUM_MULTIMEDIA | - PK_GROUP_ENUM_SYSTEM); + PK_GROUP_ENUM_PUBLISHING | + PK_GROUP_ENUM_SYSTEM | + PK_GROUP_ENUM_UNKNOWN); } /** @@ -177,6 +186,16 @@ backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *sear } /** + * * pk_backend_search_group: + * */ +static void +backend_search_group (PkBackend *backend, PkFilterEnum filters, const gchar *group) +{ + pk_backend_dbus_search_name (dbus, filters, group); +} + + +/** * * pk_backend_cancel: * */ static void @@ -268,7 +287,7 @@ PK_BACKEND_OPTIONS ( NULL, /* rollback */ backend_search_details, /* search_details */ NULL, /* search_file */ - NULL, /* search_group */ + backend_search_group, /* search_group */ backend_search_name, /* search_name */ NULL, /* service_pack */ backend_update_packages, /* update_packages */ |