Merge lp:~roignac/gwibber/Bug441641 into lp:gwibber

Proposed by Vadim Rutkovsky
Status: Rejected
Rejected by: Robert Bruce Park
Proposed branch: lp:~roignac/gwibber/Bug441641
Merge into: lp:gwibber
Diff against target: 371 lines (+76/-61)
14 files modified
gwibber/accounts.py (+9/-25)
gwibber/microblog/brightkite.py (+2/-2)
gwibber/microblog/buzz.py (+2/-2)
gwibber/microblog/dispatcher.py (+1/-1)
gwibber/microblog/friendfeed.py (+1/-1)
gwibber/microblog/greader.py (+1/-1)
gwibber/microblog/identica.py (+1/-1)
gwibber/microblog/jaiku.py (+1/-1)
gwibber/microblog/opencollaboration.py (+1/-1)
gwibber/microblog/qaiku.py (+1/-1)
gwibber/microblog/statusnet.py (+1/-1)
gwibber/microblog/storage.py (+5/-3)
gwibber/microblog/twitter.py (+1/-1)
gwibber/microblog/util/keyring.py (+49/-20)
To merge this branch: bzr merge lp:~roignac/gwibber/Bug441641
Reviewer Review Type Date Requested Status
Robert Bruce Park Disapprove
gwibber-committers Pending
Review via email: mp+35342@code.launchpad.net

Description of the change

This branch saves Gwibber preferences in Seahorse with name 'Gwibber <field name> for <username> on <service>' - e.g. 'Gwibber password for roignac on identica'.
Also, I've updated keyring code to be kept in one place and correctly being handled.

To post a comment you must log in.
Revision history for this message
Robert Bruce Park (robru) wrote :

Thanks for taking the time to submit this patch, unfortunately Gwibber has gone through extensive changes recently and your patch no longer applies to the latest codebase.

Unfortunately, the feature you were attempting to fix has been superceded. Password management is now handled by Ubuntu Online Accounts, so Gwibber does not even have to worry about handling passwords in the first place.

Please try out the latest Gwibber, I think you'll be quite pleased with what we've accomplished.

review: Disapprove

Unmerged revisions

852. By Vadim Rutkovsky

Moved all keyring-related code to one library

851. By Vadim Rutkovsky

Moved to a format of string secrets in Seahorse

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/accounts.py'
2--- gwibber/accounts.py 2010-09-03 19:03:56 +0000
3+++ gwibber/accounts.py 2010-09-13 22:20:59 +0000
4@@ -18,11 +18,6 @@
5 # Accounts interface for Gwibber
6 #
7
8-try:
9- import gnomekeyring
10-except:
11- gnomekeyring = None
12-
13 import gettext
14 from gettext import lgettext as _
15 if hasattr(gettext, 'bind_textdomain_codeset'):
16@@ -35,6 +30,7 @@
17
18 from gwibber.lib import GwibberPublic
19 from gwibber.lib.gtk import *
20+from microblog.util.keyring import GwibberKeyring
21
22 from dbus.mainloop.glib import DBusGMainLoop
23 DBusGMainLoop(set_as_default=True)
24@@ -42,6 +38,7 @@
25 class GwibberAccountManager(object):
26 def __init__(self):
27 self.gwibber = GwibberPublic()
28+ self.keyring = GwibberKeyring()
29 self.services = json.loads(self.gwibber.GetServices())
30
31 self.ui = gtk.Builder()
32@@ -115,21 +112,6 @@
33 icf = resources.get_ui_asset("icons/breakdance/16x16/%s.png" % name)
34 return gtk.gdk.pixbuf_new_from_file(icf) if os.path.exists(icf) else None
35
36- def get_from_keyring(self, acctid, name):
37- item = {"id": str("%s/%s" % (acctid, name))}
38- try:
39- return gnomekeyring.find_items_sync(gnomekeyring.ITEM_GENERIC_SECRET, item)[0].secret
40- except gnomekeyring.NoMatchError:
41- return None
42-
43- def put_in_keyring(self, acctid, name, value):
44- id = "%s/%s" % (acctid, name)
45- return gnomekeyring.item_create_sync(
46- gnomekeyring.get_default_keyring_sync(),
47- gnomekeyring.ITEM_GENERIC_SECRET,
48- "Gwibber preference: %s" % id,
49- {"id": str(id)}, str(value), True)
50-
51 def populate_account_tree(self):
52 self.account_store.clear()
53 accounts = json.loads(self.gwibber.GetAccounts())
54@@ -141,7 +123,7 @@
55 for f in private_fields:
56 if not account.has_key(f): account[f] = ":KEYRING:MISSING"
57 if account[f].startswith(":KEYRING:"):
58- value = self.get_from_keyring(account["id"], f)
59+ value = self.keyring.get_value("Gwibber %s for %s on %s" % (f, account["username"], account["service"]))
60 if value is None:
61 color = "pink"
62 self.account_store.append(None, [name, icon, account, color])
63@@ -169,7 +151,7 @@
64 for f in private_fields:
65 if self.account[f].startswith(":KEYRING:"):
66 keyring_id = int(self.account[f].split(":")[-1])
67- gnomekeyring.item_delete_sync(gnomekeyring.get_default_keyring_sync(), keyring_id)
68+ self.keyring.delete_secret(keyring_id)
69 except:
70 pass
71 self.gwibber.accounts.Delete(self.account["id"])
72@@ -198,8 +180,9 @@
73
74 if is_private and self.account.has_key(config):
75 if not self.account[config].startswith(":KEYRING:"):
76- self.account[config] = ":KEYRING:%s" % self.put_in_keyring(
77- self.account["id"], config, self.account[config])
78+ keyringtext = "Gwibber %s for %s on %s" % (config, self.account["username"], self.account["service"])
79+ self.account[config] = ":KEYRING:%s" % self.keyring.set_value(
80+ keyringtext, self.account[config])
81
82 if value:
83 if isinstance(value, gtk.gdk.Color):
84@@ -280,7 +263,8 @@
85
86 if isinstance(widget, gtk.Entry):
87 if is_private and account[config].startswith(":KEYRING:"):
88- value = self.get_from_keyring(account["id"], config)
89+ value = self.keyring.get_value("Gwibber %s for %s on %s" %
90+ (config, account["username"], account["service"]))
91 if not value:
92 widget.modify_base(gtk.STATE_NORMAL, gtk.gdk.color_parse("pink"))
93 if value:
94
95=== modified file 'gwibber/microblog/brightkite.py'
96--- gwibber/microblog/brightkite.py 2010-08-19 12:50:51 +0000
97+++ gwibber/microblog/brightkite.py 2010-09-13 22:20:59 +0000
98@@ -14,9 +14,9 @@
99 "version": 0.2,
100
101 "config": [
102- "password",
103 "username",
104- "message_color",
105+ "private:password",
106+ "color",
107 "receive_enabled",
108 "send_enabled"
109 ],
110
111=== modified file 'gwibber/microblog/buzz.py'
112--- gwibber/microblog/buzz.py 2010-05-24 02:16:38 +0000
113+++ gwibber/microblog/buzz.py 2010-09-13 22:20:59 +0000
114@@ -6,12 +6,12 @@
115 "version": "1.0",
116
117 "config": [
118+ "username",
119 "color",
120 "receive_enabled",
121 "send_enabled",
122- "username",
123 "access_token",
124- "secret_token",
125+ "private:secret_token",
126 ],
127
128 "authtype": "oauth1a",
129
130=== modified file 'gwibber/microblog/dispatcher.py'
131--- gwibber/microblog/dispatcher.py 2010-09-13 18:00:25 +0000
132+++ gwibber/microblog/dispatcher.py 2010-09-13 22:20:59 +0000
133@@ -123,7 +123,7 @@
134 def get_passwords(self, acct):
135 for key, val in acct.items():
136 if hasattr(val, "startswith") and val.startswith(":KEYRING:"):
137- id = "%s/%s" % (acct["id"], key)
138+ id = "Gwibber %s for %s on %s" % (key, acct["username"], acct["service"])
139 try:
140 acct[key] = self.dispatcher.accounts.passwords[id]
141 except:
142
143=== modified file 'gwibber/microblog/friendfeed.py'
144--- gwibber/microblog/friendfeed.py 2010-08-19 15:55:03 +0000
145+++ gwibber/microblog/friendfeed.py 2010-09-13 22:20:59 +0000
146@@ -9,8 +9,8 @@
147 "version": 0.1,
148
149 "config": [
150+ "username",
151 "private:secret_key",
152- "username",
153 "color",
154 "receive_enabled",
155 "send_enabled",
156
157=== modified file 'gwibber/microblog/greader.py'
158--- gwibber/microblog/greader.py 2010-08-19 12:50:51 +0000
159+++ gwibber/microblog/greader.py 2010-09-13 22:20:59 +0000
160@@ -19,8 +19,8 @@
161 "version": 0.1,
162
163 "config": [
164+ "username",
165 "private:password",
166- "username",
167 "message_color",
168 "receive_enabled",
169 ],
170
171=== modified file 'gwibber/microblog/identica.py'
172--- gwibber/microblog/identica.py 2010-08-25 20:41:55 +0000
173+++ gwibber/microblog/identica.py 2010-09-13 22:20:59 +0000
174@@ -9,8 +9,8 @@
175 "version": 1.0,
176
177 "config": [
178+ "username",
179 "private:password",
180- "username",
181 "color",
182 "receive_enabled",
183 "send_enabled",
184
185=== modified file 'gwibber/microblog/jaiku.py'
186--- gwibber/microblog/jaiku.py 2010-08-19 12:50:51 +0000
187+++ gwibber/microblog/jaiku.py 2010-09-13 22:20:59 +0000
188@@ -14,8 +14,8 @@
189 "version": 0.3,
190
191 "config": [
192+ "username",
193 "private:password",
194- "username",
195 "message_color",
196 "comment_color",
197 "receive_enabled",
198
199=== modified file 'gwibber/microblog/opencollaboration.py'
200--- gwibber/microblog/opencollaboration.py 2010-08-19 12:50:51 +0000
201+++ gwibber/microblog/opencollaboration.py 2010-09-13 22:20:59 +0000
202@@ -14,8 +14,8 @@
203 "version": 0.1,
204
205 "config": [
206+ "username",
207 "private:password",
208- "username",
209 "domain",
210 "message_color",
211 "receive_enabled",
212
213=== modified file 'gwibber/microblog/qaiku.py'
214--- gwibber/microblog/qaiku.py 2010-07-25 23:13:46 +0000
215+++ gwibber/microblog/qaiku.py 2010-09-13 22:20:59 +0000
216@@ -7,8 +7,8 @@
217 "version": "1.0",
218
219 "config": [
220+ "username",
221 "private:password",
222- "username",
223 "color",
224 "receive_enabled",
225 "send_enabled",
226
227=== modified file 'gwibber/microblog/statusnet.py'
228--- gwibber/microblog/statusnet.py 2010-08-25 20:51:11 +0000
229+++ gwibber/microblog/statusnet.py 2010-09-13 22:20:59 +0000
230@@ -9,8 +9,8 @@
231 "version": 1.0,
232
233 "config": [
234+ "username",
235 "private:password",
236- "username",
237 "domain",
238 "color",
239 "receive_enabled",
240
241=== modified file 'gwibber/microblog/storage.py'
242--- gwibber/microblog/storage.py 2010-09-03 19:23:01 +0000
243+++ gwibber/microblog/storage.py 2010-09-13 22:20:59 +0000
244@@ -4,6 +4,7 @@
245 import gtk, gobject, dbus, dbus.service
246 import util, util.keyring, atexit
247 from util import log
248+from util.keyring import GwibberKeyring
249 from dbus.mainloop.glib import DBusGMainLoop
250
251 DBusGMainLoop(set_as_default=True)
252@@ -199,6 +200,7 @@
253 bus_name = dbus.service.BusName("com.Gwibber.Accounts", bus=self.bus)
254 dbus.service.Object.__init__(self, bus_name, self.__dbus_object_path__)
255 self.db = db
256+ self.keyring = GwibberKeyring()
257
258 if not self.db.execute("PRAGMA table_info(accounts)").fetchall():
259 self.setup_table()
260@@ -231,13 +233,13 @@
261 def unlock_password_cache(self):
262 log.logger.debug("Unlocking password cache!")
263 for id in self.passwords:
264- util.keyring.munlock(self.passwords[id])
265+ self.keyring.munlock(self.passwords[id])
266
267 def update_password_cache(self, acct):
268 for key, val in acct.items():
269 if hasattr(val, "startswith") and val.startswith(":KEYRING:"):
270- id = "%s/%s" % (acct["id"], key)
271- self.passwords[id] = util.keyring.get_secret(id)
272+ id = "Gwibber %s for %s on %s" % (key, acct["username"], acct["service"])
273+ self.passwords[id] = self.keyring.get_value(id)
274
275 @dbus.service.signal("com.Gwibber.Accounts", signature="s")
276 def Updated(self, data):
277
278=== modified file 'gwibber/microblog/twitter.py'
279--- gwibber/microblog/twitter.py 2010-08-30 19:38:08 +0000
280+++ gwibber/microblog/twitter.py 2010-09-13 22:20:59 +0000
281@@ -10,9 +10,9 @@
282 "version": "1.0",
283
284 "config": [
285+ "username",
286 "private:secret_token",
287 "access_token",
288- "username",
289 "color",
290 "receive_enabled",
291 "send_enabled",
292
293=== modified file 'gwibber/microblog/util/keyring.py'
294--- gwibber/microblog/util/keyring.py 2010-08-19 15:55:03 +0000
295+++ gwibber/microblog/util/keyring.py 2010-09-13 22:20:59 +0000
296@@ -1,26 +1,55 @@
297 from const import *
298
299+
300+try:
301+ import gnomekeyring
302+except:
303+ gnomekeyring = None
304+import exceptions
305 import ctypes
306-import gnomekeyring
307-import exceptions
308-
309-def get_secret(id):
310- value = ""
311- try:
312- value = gnomekeyring.find_items_sync(
313- gnomekeyring.ITEM_GENERIC_SECRET,
314- {"id": str(id)})[0].secret
315- #mlock(value)
316- except gnomekeyring.NoMatchError:
317- print id
318- raise exceptions.GwibberServiceError("keyring")
319-
320- return value
321-
322-libc = ctypes.CDLL("libc.so.6")
323-
324-def mlock(var):
325+
326+class GwibberKeyring:
327+
328+ libc = ctypes.CDLL("libc.so.6")
329+
330+ def get_value(self, id):
331+ val = ""
332+ try:
333+ val = gnomekeyring.find_items_sync(
334+ gnomekeyring.ITEM_GENERIC_SECRET,
335+ {"id": str(id)})[0].secret
336+ #mlock(value)
337+ except gnomekeyring.NoMatchError:
338+ print "Can't get a keyring with id '%s'" % id
339+ raise exceptions.GwibberServiceError("keyring")
340+
341+ return val
342+
343+ def set_value(self, keyring_name, value):
344+ id = ""
345+ try:
346+ id = gnomekeyring.item_create_sync(
347+ gnomekeyring.get_default_keyring_sync(),
348+ gnomekeyring.ITEM_GENERIC_SECRET,
349+ keyring_name, {"id": str(keyring_name)}, str(value), True)
350+ #mlock(value)
351+ except gnomekeyring.NoMatchError:
352+ print "Can't set keyring with keyring_name '%s' to value '%s'" % (keyring_name, value)
353+ raise exceptions.GwibberServiceError("keyring")
354+
355+ return id
356+
357+ def delete_secret(self, id):
358+ try:
359+ gnomekeyring.item_delete_sync(gnomekeyring.get_default_keyring_sync(), id)
360+ except gnomekeyring.NoMatchError:
361+ print "Can't delete keyring with id '%s'" % id
362+ raise exceptions.GwibberServiceError("keyring")
363+
364+ return value
365+
366+ def mlock(self, var):
367 libc.mlock(var, len(var))
368
369-def munlock(var):
370+ def munlock(self, var):
371 libc.munlock(var, len(var))