Merge lp:~gary-lasker/software-center/icon-data-for-4.0 into lp:software-center/4.0

Proposed by Gary Lasker
Status: Merged
Merged at revision: 1790
Proposed branch: lp:~gary-lasker/software-center/icon-data-for-4.0
Merge into: lp:software-center/4.0
Diff against target: 193 lines (+55/-19)
8 files modified
README (+1/-0)
debian/changelog (+8/-0)
softwarecenter/db/application.py (+4/-0)
softwarecenter/db/database.py (+5/-0)
softwarecenter/db/update.py (+10/-15)
softwarecenter/enums.py (+1/-0)
softwarecenter/models/appstore.py (+22/-4)
softwarecenter/view/softwarepane.py (+4/-0)
To merge this branch: bzr merge lp:~gary-lasker/software-center/icon-data-for-4.0
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+88289@code.launchpad.net

Description of the change

This branch for a Natty SRU removes the need for the inline icon data from the software-center-agent, and instead downloads the icon directly using the provided url from the agent.

We currently already have this functionality for Oneiric and Precise.

Thanks!

To post a comment you must log in.
1795. By Gary Lasker

d'oh, fix typo in README

Revision history for this message
Gary Lasker (gary-lasker) wrote :

Just a note that I've tested this branch in a Natty VM using both staging and production servers as per my comment for the Maverick merge proposal. Thanks again!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2011-03-20 19:19:58 +0000
3+++ README 2012-01-12 00:32:23 +0000
4@@ -86,4 +86,5 @@
5 XAPIAN_VALUE_SCREENSHOT_URL - a (optional) screenshot url that overrides the default
6 XAPIAN_VALUE_ICON_NEEDS_DOWNLOAD - icon needs to be fetched
7 XAPIAN_VALUE_THUMBNAIL_URL - thumbnail url
8+XAPIAN_VALUE_ICON_URL - the icon url for an application that has been provided by the agent (only available after the software-center-agent server was queried)
9
10
11=== modified file 'debian/changelog'
12--- debian/changelog 2011-11-24 09:05:02 +0000
13+++ debian/changelog 2012-01-12 00:32:23 +0000
14@@ -1,3 +1,11 @@
15+software-center (4.0.7) UNRELEASED; urgency=low
16+
17+ * lp:~gary-lasker/software-center/icon-data-for-4.0:
18+ - remove the need for inline icon data from the agent, instead
19+ download icons directly using the provided URL (LP: #914054)
20+
21+ -- Gary Lasker <gary.lasker@canonical.com> Wed, 11 Jan 2012 18:25:49 -0500
22+
23 software-center (4.0.6) natty-proposed; urgency=low
24
25 * cherry pick fix to allow webkit to create additional windows
26
27=== modified file 'softwarecenter/db/application.py'
28--- softwarecenter/db/application.py 2011-04-12 13:19:00 +0000
29+++ softwarecenter/db/application.py 2012-01-12 00:32:23 +0000
30@@ -335,6 +335,10 @@
31
32 @property
33 def icon_url(self):
34+ if self._doc:
35+ icon_url = self._db.get_icon_url(self._doc)
36+ if icon_url:
37+ return icon_url
38 return self._distro.get_downloadable_icon_url(self._cache, self.pkgname, self.icon_file_name)
39
40 @property
41
42=== modified file 'softwarecenter/db/database.py'
43--- softwarecenter/db/database.py 2011-04-11 16:12:10 +0000
44+++ softwarecenter/db/database.py 2012-01-12 00:32:23 +0000
45@@ -331,6 +331,11 @@
46 """ Return the iconname from the xapian document """
47 iconname = doc.get_value(XAPIAN_VALUE_ICON)
48 return iconname
49+
50+ def get_icon_url(self, doc):
51+ """ Return the icon_url from the xapian document """
52+ icon_url = doc.get_value(XAPIAN_VALUE_ICON_URL)
53+ return icon_url
54
55 def pkg_in_category(self, pkgname, cat_query):
56 """ Return True if the given pkg is in the given category """
57
58=== modified file 'softwarecenter/db/update.py'
59--- softwarecenter/db/update.py 2011-04-14 02:25:14 +0000
60+++ softwarecenter/db/update.py 2012-01-12 00:32:23 +0000
61@@ -122,6 +122,7 @@
62 'Purchased-Date' : 'purchase_date',
63 'PPA' : 'archive_id',
64 'Icon' : 'icon',
65+ 'Icon-Url' : 'icon_url',
66 'Screenshot-Url' : 'screenshot_url',
67 'Thumbnail-Url' : 'thumbnail_url',
68 }
69@@ -472,21 +473,6 @@
70 try:
71 # magic channel
72 entry.channel = AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME
73- # icon is transmited inline
74- if hasattr(entry, "icon_data") and entry.icon_data:
75- icondata = base64.b64decode(entry.icon_data)
76- elif hasattr(entry, "icon_64_data") and entry.icon_64_data:
77- # workaround for scagent bug #740112
78- icondata = base64.b64decode(entry.icon_64_data)
79- else:
80- icondata = ""
81- # write it if we have data
82- if icondata:
83- # the iconcache gets mightly confused if there is a "." in the name
84- iconname = "sc-agent-%s" % entry.package_name.replace(".", "__")
85- open(os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR,
86- "%s.png" % iconname),"w").write(icondata)
87- entry.icon = iconname
88 # now the normal parser
89 parser = SoftwareCenterAgentParser(entry)
90 index_app_info_from_parser(parser, db, cache)
91@@ -586,6 +572,15 @@
92 # add archive origin data here so that its available even if
93 # the PPA is not (yet) enabled
94 doc.add_term("XOO"+"lp-ppa-%s" % archive_ppa.replace("/", "-"))
95+ # icon (for third party)
96+ if parser.has_option_desktop("X-AppInstall-Icon-Url"):
97+ doc.add_value(XAPIAN_VALUE_ICON_NEEDS_DOWNLOAD, "1")
98+ url = parser.get_desktop("X-AppInstall-Icon-Url")
99+ doc.add_value(XAPIAN_VALUE_ICON_URL, url)
100+ if not parser.has_option_desktop("X-AppInstall-Icon"):
101+ # prefix pkgname to avoid name clashes
102+ doc.add_value(XAPIAN_VALUE_ICON, "%s-icon-%s" % (
103+ pkgname, os.path.basename(url)))
104 # screenshot (for third party)
105 if parser.has_option_desktop("X-AppInstall-Screenshot-Url"):
106 url = parser.get_desktop("X-AppInstall-Screenshot-Url")
107
108=== modified file 'softwarecenter/enums.py'
109--- softwarecenter/enums.py 2011-05-10 14:50:15 +0000
110+++ softwarecenter/enums.py 2012-01-12 00:32:23 +0000
111@@ -101,6 +101,7 @@
112 XAPIAN_VALUE_THUMBNAIL_URL = 187
113 XAPIAN_VALUE_SC_DESCRIPTION = 188
114 XAPIAN_VALUE_APPNAME_UNTRANSLATED = 189
115+XAPIAN_VALUE_ICON_URL = 190
116
117 # fake channels
118 PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"
119
120=== modified file 'softwarecenter/models/appstore.py'
121--- softwarecenter/models/appstore.py 2011-04-12 13:54:58 +0000
122+++ softwarecenter/models/appstore.py 2012-01-12 00:32:23 +0000
123@@ -85,6 +85,13 @@
124 (NONAPPS_ALWAYS_VISIBLE,
125 NONAPPS_MAYBE_VISIBLE,
126 NONAPPS_NEVER_VISIBLE) = range (3)
127+
128+ __gsignals__ = {
129+ "needs-refresh" : (gobject.SIGNAL_RUN_LAST,
130+ None,
131+ (str, ),
132+ ),
133+ }
134
135 def __init__(self, cache, db, icons, search_query=None,
136 limit=DEFAULT_SEARCH_LIMIT,
137@@ -381,7 +388,7 @@
138 if result.pkgname in self.transaction_index_map:
139 del self.transaction_index_map[result.pkgname]
140
141- def _download_icon_and_show_when_ready(self, cache, pkgname, icon_file_name):
142+ def _download_icon_and_show_when_ready(self, cache, pkgname, icon_file_name, icon_url):
143 self._logger.debug("did not find the icon locally, must download %s" % icon_file_name)
144 def on_image_download_complete(downloader, image_file_path):
145 pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_file_path,
146@@ -390,8 +397,15 @@
147 # replace the icon in the icon_cache now that we've got the real one
148 icon_file = os.path.splitext(os.path.basename(image_file_path))[0]
149 self.icon_cache[icon_file] = pb
150-
151- url = get_distro().get_downloadable_icon_url(cache, pkgname, icon_file_name)
152+ self.emit("needs-refresh", pkgname)
153+
154+ if icon_url:
155+ url = icon_url
156+ else:
157+ # if the icon url has not been provided by the agent, then this
158+ # downloadable icon is from the extras repository and so we must
159+ # generate the download url
160+ url = get_distro().get_downloadable_icon_url(cache, pkgname, icon_file_name)
161 if url is not None:
162 icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, icon_file_name)
163 image_downloader = SimpleFileDownloader()
164@@ -514,9 +528,13 @@
165 self.icon_cache[icon_name] = icon
166 return icon
167 elif self.db.get_icon_needs_download(doc):
168+ # check if this is a downloadable icon for an
169+ # application provided by the agent
170+ icon_url = self.db.get_icon_url(doc)
171 self._download_icon_and_show_when_ready(self.cache,
172 app.pkgname,
173- icon_file_name)
174+ icon_file_name,
175+ icon_url)
176 # display the missing icon while the real one downloads
177 self.icon_cache[icon_name] = self._appicon_missing_icon
178 except glib.GError, e:
179
180=== modified file 'softwarecenter/view/softwarepane.py'
181--- softwarecenter/view/softwarepane.py 2011-06-02 19:13:33 +0000
182+++ softwarecenter/view/softwarepane.py 2012-01-12 00:32:23 +0000
183@@ -719,6 +719,10 @@
184 # set model
185 self.app_view.set_model(new_model)
186 self.app_view.get_model().active = True
187+
188+ # connect the refresh signal from the model
189+ new_model.connect(
190+ "needs-refresh", lambda helper, pkgname: self.app_view.queue_draw())
191
192 self.hide_appview_spinner()
193 # we can not use "new_model" here, because set_model may actually

Subscribers

People subscribed via source and target branches