summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-06-03 22:00:48 (GMT)
committerPierre-Luc Beaudoin <pierre-luc.beaudoin@collabora.co.uk>2009-08-06 20:05:36 (GMT)
commitda9347f856bb605b6e446466e0cfb2fc0ae7f958 (patch)
tree88c96f5d0b2496ec6594ead5d97dcab82eb17139
parenta18995b2d21908d56c03e26765bc6c3c62ddf331 (diff)
downloadgtimelog-da9347f856bb605b6e446466e0cfb2fc0ae7f958.tar.gz
gtimelog-da9347f856bb605b6e446466e0cfb2fc0ae7f958.tar.xz
Don't display the Auth dialog if a password already exist in the keyring
-rwxr-xr-xsrc/gtimelog/gtimelog.py118
1 files changed, 56 insertions, 62 deletions
diff --git a/src/gtimelog/gtimelog.py b/src/gtimelog/gtimelog.py
index 0dccfbc..13ad338 100755
--- a/src/gtimelog/gtimelog.py
+++ b/src/gtimelog/gtimelog.py
@@ -752,8 +752,8 @@ class TaskList(object):
class GtkPasswordRequest (urllib2.HTTPPasswordMgr):
# FIXME : work out how to find the parent window
def find_user_password (self, realm, authuri):
- username = ""
- password = ""
+ username = None
+ password = None
# try to use GNOME Keyring if available
try:
@@ -791,79 +791,73 @@ class GtkPasswordRequest (urllib2.HTTPPasswordMgr):
username = l['user']
password = l['password']
- # ask the user if she would like to save her
- # password
-
- # pop up a username/password dialog
- gtk.gdk.threads_enter()
- d = gtk.Dialog ()
- d.set_has_separator (False)
- d.set_title ('Authentication Required')
-
- t = gtk.Table (4, 2)
- t.set_border_width (5)
- t.set_row_spacings (5)
+ # If not found, ask the user for it
+ if username == None:
+ # pop up a username/password dialog
+ gtk.gdk.threads_enter()
+ d = gtk.Dialog ()
+ d.set_has_separator (False)
+ d.set_title ('Authentication Required')
- l = gtk.Label ('Authentication is required for the domain "%s".' % realm)
- l.set_line_wrap (True)
- t.attach (l, 0, 2, 0, 1)
+ t = gtk.Table (4, 2)
+ t.set_border_width (5)
+ t.set_row_spacings (5)
- t.attach (gtk.Label ("Username:"), 0, 1, 1, 2)
- t.attach (gtk.Label ("Password:"), 0, 1, 2, 3)
+ l = gtk.Label ('Authentication is required for the domain "%s".' % realm)
+ l.set_line_wrap (True)
+ t.attach (l, 0, 2, 0, 1)
- userentry = gtk.Entry ()
- passentry = gtk.Entry ()
- passentry.set_visibility (False)
+ t.attach (gtk.Label ("Username:"), 0, 1, 1, 2)
+ t.attach (gtk.Label ("Password:"), 0, 1, 2, 3)
- userentry.set_text (username)
- passentry.set_text (password)
+ userentry = gtk.Entry ()
+ passentry = gtk.Entry ()
+ passentry.set_visibility (False)
- userentry.connect ('activate', lambda entry:
- passentry.grab_focus ())
- passentry.connect ('activate', lambda entry:
- d.response (gtk.RESPONSE_OK))
+ userentry.connect ('activate', lambda entry:
+ passentry.grab_focus ())
+ passentry.connect ('activate', lambda entry:
+ d.response (gtk.RESPONSE_OK))
- t.attach (userentry, 1, 2, 1, 2)
- t.attach (passentry, 1, 2, 2, 3)
+ t.attach (userentry, 1, 2, 1, 2)
+ t.attach (passentry, 1, 2, 2, 3)
- if gnomekeyring:
- savepasstoggle = gtk.CheckButton ("Save Password in Keyring")
- savepasstoggle.set_active (True)
- t.attach (savepasstoggle, 1, 2, 3, 4)
+ if gnomekeyring:
+ savepasstoggle = gtk.CheckButton ("Save Password in Keyring")
+ savepasstoggle.set_active (True)
+ t.attach (savepasstoggle, 1, 2, 3, 4)
- d.vbox.pack_start (t)
+ d.vbox.pack_start (t)
- d.add_buttons (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
- gtk.STOCK_OK, gtk.RESPONSE_OK)
+ d.add_buttons (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK)
- d.show_all ()
- r = d.run ()
+ d.show_all ()
+ r = d.run ()
- username = userentry.get_text ()
- password = passentry.get_text ()
- save_to_keyring = savepasstoggle.get_active()
+ username = userentry.get_text ()
+ password = passentry.get_text ()
+ save_to_keyring = savepasstoggle.get_active()
- d.destroy ()
- gtk.gdk.threads_leave()
+ d.destroy ()
+ gtk.gdk.threads_leave()
- if r == gtk.RESPONSE_OK:
- if gnomekeyring and save_to_keyring:
- try:
- gnomekeyring.set_network_password_sync (
- None, # keyring
- username, # user
- o.hostname, # domain
- o.hostname, # server
- object, # object
- o.scheme, # protocol
- None, # authtype
- port, # port
- password) # password
- except gnomekeyring.NoKeyringDaemonError:
- pass
- return (username, password)
- else:
- return (None, None)
+ if r == gtk.RESPONSE_OK:
+ if gnomekeyring and save_to_keyring:
+ try:
+ gnomekeyring.set_network_password_sync (
+ None, # keyring
+ username, # user
+ o.hostname, # domain
+ o.hostname, # server
+ object, # object
+ o.scheme, # protocol
+ None, # authtype
+ port, # port
+ password) # password
+ except gnomekeyring.NoKeyringDaemonError:
+ pass
+ return (username, password)
class RemoteTaskList(TaskList):
"""Task list stored on a remote server.