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

Proposed by Gary Lasker
Status: Merged
Merged at revision: 1134
Proposed branch: lp:~gary-lasker/software-center/icon-data-for-3.0
Merge into: lp:software-center/3.0
Diff against target: 206 lines (+61/-10)
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/-7)
softwarecenter/enums.py (+1/-0)
softwarecenter/view/appview.py (+21/-3)
softwarecenter/view/channelpane.py (+11/-0)
To merge this branch: bzr merge lp:~gary-lasker/software-center/icon-data-for-3.0
Reviewer Review Type Date Requested Status
software-store-developers Pending
Review via email: mp+88302@code.launchpad.net

Description of the change

Here's the branch to remove the inline icon_data from the agent for Maverick. It should be good to go, I've tested it thoroughly in a Maverick VM using both the staging server (SOFTWARE_CENTER_BUY_HOST=https://sc.staging.ubuntu.com, where inline icon_data has been shut off) as well as with the production server (after clearing the icon cache to verify that we are downloading from the icon_url).

Thanks!

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README'
2--- README 2010-09-23 07:14:12 +0000
3+++ README 2012-01-12 04:43:24 +0000
4@@ -69,4 +69,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 08:52:15 +0000
13+++ debian/changelog 2012-01-12 04:43:24 +0000
14@@ -1,3 +1,11 @@
15+software-center (3.0.12) UNRELEASED; urgency=low
16+
17+ * lp:~gary-lasker/software-center/icon-data-for-3.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 23:29:45 -0500
22+
23 software-center (3.0.11) maverick-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 2010-09-29 15:24:24 +0000
29+++ softwarecenter/db/application.py 2012-01-12 04:43:24 +0000
30@@ -304,6 +304,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 2010-09-15 20:46:57 +0000
44+++ softwarecenter/db/database.py 2012-01-12 04:43:24 +0000
45@@ -244,6 +244,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-06-16 03:48:07 +0000
60+++ softwarecenter/db/update.py 2012-01-12 04:43:24 +0000
61@@ -105,6 +105,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@@ -387,13 +388,6 @@
70 try:
71 # magic channel
72 entry.channel = AVAILABLE_FOR_PURCHASE_MAGIC_CHANNEL_NAME
73- # icon is transmited inline
74- # the iconcache gets mightly confused if there is a "." in the name
75- iconname = "sc-agent-%s" % entry.package_name.replace(".", "__")
76- icondata = base64.b64decode(entry.icon_data)
77- open(os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR,
78- "%s.png" % iconname),"w").write(icondata)
79- entry.icon = iconname
80 # now the normal parser
81 parser = SoftwareCenterAgentParser(entry)
82 index_app_info_from_parser(parser, db, cache)
83@@ -466,6 +460,15 @@
84 if parser.has_option_desktop("X-AppInstall-PPA"):
85 archive_ppa = parser.get_desktop("X-AppInstall-PPA")
86 doc.add_value(XAPIAN_VALUE_ARCHIVE_PPA, archive_ppa)
87+ # icon (for third party)
88+ if parser.has_option_desktop("X-AppInstall-Icon-Url"):
89+ doc.add_value(XAPIAN_VALUE_ICON_NEEDS_DOWNLOAD, "1")
90+ url = parser.get_desktop("X-AppInstall-Icon-Url")
91+ doc.add_value(XAPIAN_VALUE_ICON_URL, url)
92+ if not parser.has_option_desktop("X-AppInstall-Icon"):
93+ # prefix pkgname to avoid name clashes
94+ doc.add_value(XAPIAN_VALUE_ICON, "%s-icon-%s" % (
95+ pkgname, os.path.basename(url)))
96 # screenshot (for third party)
97 if parser.has_option_desktop("X-AppInstall-Screenshot-Url"):
98 url = parser.get_desktop("X-AppInstall-Screenshot-Url")
99
100=== modified file 'softwarecenter/enums.py'
101--- softwarecenter/enums.py 2010-10-11 15:39:48 +0000
102+++ softwarecenter/enums.py 2012-01-12 04:43:24 +0000
103@@ -88,6 +88,7 @@
104 XAPIAN_VALUE_ICON_NEEDS_DOWNLOAD = 186
105 XAPIAN_VALUE_THUMBNAIL_URL = 187
106 XAPIAN_VALUE_SC_DESCRIPTION = 188
107+XAPIAN_VALUE_ICON_URL = 190
108
109 # fake channels
110 PURCHASED_NEEDS_REINSTALL_MAGIC_CHANNEL_NAME = "for-pay-needs-reinstall"
111
112=== modified file 'softwarecenter/view/appview.py'
113--- softwarecenter/view/appview.py 2010-10-01 17:44:48 +0000
114+++ softwarecenter/view/appview.py 2012-01-12 04:43:24 +0000
115@@ -96,6 +96,13 @@
116
117 # the default result size for a search
118 DEFAULT_SEARCH_LIMIT = 200
119+
120+ __gsignals__ = {
121+ "needs-refresh" : (gobject.SIGNAL_RUN_LAST,
122+ None,
123+ (str, ),
124+ ),
125+ }
126
127 def __init__(self, cache, db, icons, search_query=None,
128 limit=DEFAULT_SEARCH_LIMIT,
129@@ -440,7 +447,7 @@
130 self._installable_apps = None
131
132
133- def _download_icon_and_show_when_ready(self, cache, pkgname, icon_file_name):
134+ def _download_icon_and_show_when_ready(self, cache, pkgname, icon_file_name, icon_url):
135 self._logger.debug("did not find the icon locally, must download %s" % icon_file_name)
136 def on_image_download_complete(downloader, image_file_path):
137 pb = gtk.gdk.pixbuf_new_from_file_at_size(icon_file_path,
138@@ -449,8 +456,15 @@
139 # replace the icon in the icon_cache now that we've got the real one
140 icon_file = os.path.splitext(os.path.basename(image_file_path))[0]
141 self.icon_cache[icon_file] = pb
142+ self.emit("needs-refresh", pkgname)
143
144- url = get_distro().get_downloadable_icon_url(cache, pkgname, icon_file_name)
145+ if icon_url:
146+ url = icon_url
147+ else:
148+ # if the icon url has not been provided by the agent, then this
149+ # downloadable icon is from the extras repository and so we must
150+ # generate the download url
151+ url = get_distro().get_downloadable_icon_url(cache, pkgname, icon_file_name)
152 icon_file_path = os.path.join(SOFTWARE_CENTER_ICON_CACHE_DIR, icon_file_name)
153 image_downloader = ImageDownloader()
154 image_downloader.connect('image-download-complete', on_image_download_complete)
155@@ -565,9 +579,13 @@
156 self.icon_cache[icon_name] = icon
157 return icon
158 elif self.db.get_icon_needs_download(doc):
159+ # check if this is a downloadable icon for an
160+ # application provided by the agent
161+ icon_url = self.db.get_icon_url(doc)
162 self._download_icon_and_show_when_ready(self.cache,
163 app.pkgname,
164- icon_file_name)
165+ icon_file_name,
166+ icon_url)
167 # display the missing icon while the real one downloads
168 self.icon_cache[icon_name] = self._appicon_missing_icon
169 except glib.GError, e:
170
171=== modified file 'softwarecenter/view/channelpane.py'
172--- softwarecenter/view/channelpane.py 2010-09-23 01:34:43 +0000
173+++ softwarecenter/view/channelpane.py 2012-01-12 04:43:24 +0000
174@@ -56,6 +56,7 @@
175 self.apps_filter = None
176 self.search_terms = ""
177 self.current_appview_selection = None
178+ self.refresh_handler_id = None
179 self.distro = get_distro()
180 # UI
181 self._build_ui()
182@@ -145,14 +146,24 @@
183 if self.scroll_app_list.window:
184 self.scroll_app_list.window.set_cursor(None)
185 if seq_nr == self.refresh_seq_nr:
186+ if (self.refresh_handler_id and
187+ self.app_view.handler_is_connected(self.refresh_handler_id)):
188+ self.app_view.disconnect(self.refresh_handler_id)
189 self.app_view.set_model(new_model)
190 self.app_view.get_model().active = True
191+ # connect the refresh signal from the model
192+ self.refresh_handler_id = self.app_view.get_model().connect(
193+ "needs-refresh",
194+ self._on_needs_refresh)
195 # we can not use "new_model" here, because set_model may actually
196 # discard new_model and just update the previous one
197 self.emit("app-list-changed", len(self.app_view.get_model()))
198 else:
199 LOG.debug("discarding new model (%s != %s)" % (seq_nr, self.refresh_seq_nr))
200 return False
201+
202+ def _on_needs_refresh(self, appstore, pkgname):
203+ self.app_view.queue_draw()
204
205 def set_channel(self, channel):
206 """

Subscribers

People subscribed via source and target branches