banshee r3644 - in branches/banshee/stable: . src/Extras/Gnome.Keyring src/Extras/Last.FM/Last.FM



Author: sdroege
Date: Wed Apr  2 09:53:38 2008
New Revision: 3644
URL: http://svn.gnome.org/viewvc/banshee?rev=3644&view=rev

Log:
* src/Extras/Gnome.Keyring/KeyringInfo.cs:
* src/Extras/Gnome.Keyring/Makefile.am:
* src/Extras/Gnome.Keyring/ResultCode.cs:
* src/Extras/Gnome.Keyring/Ring.cs:
* src/Extras/Last.FM/Last.FM/Account.cs: Update internal
gnome-keyring-sharp to the latest SVN revision. This fixes the
Ring.Unlock() method and the usage of gnome-keyring if the environment
variables are not set properly.


Modified:
   branches/banshee/stable/ChangeLog
   branches/banshee/stable/src/Extras/Gnome.Keyring/KeyringInfo.cs
   branches/banshee/stable/src/Extras/Gnome.Keyring/Makefile.am
   branches/banshee/stable/src/Extras/Gnome.Keyring/ResultCode.cs
   branches/banshee/stable/src/Extras/Gnome.Keyring/Ring.cs
   branches/banshee/stable/src/Extras/Last.FM/Last.FM/Account.cs

Modified: branches/banshee/stable/src/Extras/Gnome.Keyring/KeyringInfo.cs
==============================================================================
--- branches/banshee/stable/src/Extras/Gnome.Keyring/KeyringInfo.cs	(original)
+++ branches/banshee/stable/src/Extras/Gnome.Keyring/KeyringInfo.cs	Wed Apr  2 09:53:38 2008
@@ -35,9 +35,11 @@
 		DateTime ctime;
 		bool lock_on_idle;
 		bool locked;
+		string name;
 
-		internal KeyringInfo (bool lock_on_idle, int lock_timeout, DateTime mtime, DateTime ctime, bool locked)
+		internal KeyringInfo (string name, bool lock_on_idle, int lock_timeout, DateTime mtime, DateTime ctime, bool locked)
 		{
+			this.name = name;
 			this.lock_timeout = lock_timeout;
 			this.mtime = mtime;
 			this.ctime = ctime;
@@ -61,12 +63,17 @@
 
 		public override string ToString ()
 		{
-			return String.Format ("LockOnIdle: {0}\n" +
-						"Locked: {1}\n" +
-						"Lock timeout: {2}\n" +
-						"Creation time: {3}\n" +
-						"Modification time: {4}\n",
-						lock_on_idle, locked, lock_timeout, ctime, mtime);
+			return String.Format ("Keyring name: {0}\n" +
+						"Locked: {2}\n" +
+						"LockOnIdle: {1}\n" +
+						"Lock timeout: {3}\n" +
+						"Creation time: {4}\n" +
+						"Modification time: {5}",
+						name, lock_on_idle, locked, lock_timeout, ctime, mtime);
+		}
+
+		public string Name {
+			get { return name; }
 		}
 
 		public bool LockOnIdle {

Modified: branches/banshee/stable/src/Extras/Gnome.Keyring/Makefile.am
==============================================================================
--- branches/banshee/stable/src/Extras/Gnome.Keyring/Makefile.am	(original)
+++ branches/banshee/stable/src/Extras/Gnome.Keyring/Makefile.am	Wed Apr  2 09:53:38 2008
@@ -11,7 +11,7 @@
 gnome_keyring_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb
 
 $(ASSEMBLY): $(ASSEMBLY_SOURCES)
-	$(BUILD_LIB) -out:$@ $(LINK_MONO_UNIX) $(ASSEMBLY_SOURCES)
+	$(BUILD_LIB) -d:WITH_DBUS -out:$@ $(LINK_MONO_UNIX) $(LINK_DBUS) $(ASSEMBLY_SOURCES)
 endif
 
 EXTRA_DIST = $(ASSEMBLY_SOURCES)

Modified: branches/banshee/stable/src/Extras/Gnome.Keyring/ResultCode.cs
==============================================================================
--- branches/banshee/stable/src/Extras/Gnome.Keyring/ResultCode.cs	(original)
+++ branches/banshee/stable/src/Extras/Gnome.Keyring/ResultCode.cs	Wed Apr  2 09:53:38 2008
@@ -37,8 +37,7 @@
 		BadArguments,
 		IOError,
 		Cancelled,
-		AlreadyExists,
-        NoMatch
+		AlreadyExists
 	}
 }
 

Modified: branches/banshee/stable/src/Extras/Gnome.Keyring/Ring.cs
==============================================================================
--- branches/banshee/stable/src/Extras/Gnome.Keyring/Ring.cs	(original)
+++ branches/banshee/stable/src/Extras/Gnome.Keyring/Ring.cs	Wed Apr  2 09:53:38 2008
@@ -3,8 +3,10 @@
 //
 // Authors:
 //	Gonzalo Paniagua Javier (gonzalo ximian com)
+//	Alp Toker (alp atoker com)
 //
 // (C) Copyright 2006 Novell, Inc. (http://www.novell.com)
+// (C) Copyright 2007 Alp Toker
 //
 
 // Permission is hereby granted, free of charge, to any person obtaining
@@ -36,6 +38,10 @@
 
 using Mono.Unix;
 
+#if WITH_DBUS
+using NDesk.DBus;
+#endif
+
 namespace Gnome.Keyring {
 	public class Ring {
 		static string appname;
@@ -77,7 +83,28 @@
 
 		static Socket Connect ()
 		{
-			string filename = Environment.GetEnvironmentVariable ("GNOME_KEYRING_SOCKET");
+			string filename;
+			Socket sock;
+		 
+			filename = Environment.GetEnvironmentVariable ("GNOME_KEYRING_SOCKET");
+			sock = Connect (filename);
+
+#if WITH_DBUS
+			if (sock == null) {
+				try {
+					filename = Bus.Session.GetObject<IDaemon> ("org.gnome.keyring", new ObjectPath ("/org/gnome/keyring/daemon")).GetSocketPath ();
+				} catch (Exception) {
+					filename = null;
+				}
+				sock = Connect (filename);
+			}
+#endif
+
+			return sock;
+		}
+
+		static Socket Connect (string filename)
+		{
 			if (filename == null || filename == "")
 				return null;
 
@@ -178,14 +205,22 @@
 			SendRequest (req.Stream);
 		}
 
-		public static void Unlock (string keyring)
+		public static void Unlock (string keyring, string password)
 		{
 			if (keyring == null)
 				throw new ArgumentNullException ("keyring");
 
+			if (password == null)
+				throw new ArgumentNullException ("password");
+
 			RequestMessage req = new RequestMessage ();
-			req.CreateSimpleOperation (Operation.UnlockKeyring, keyring);
-			SendRequest (req.Stream);
+			req.CreateSimpleOperation (Operation.UnlockKeyring, keyring, password);
+			try {
+				SendRequest (req.Stream);
+			} catch (KeyringException ke) {
+				if (ke.ResultCode != ResultCode.AlreadyUnlocked)
+					throw;
+			}
 		}
 
 		public static void DeleteKeyring (string keyring)
@@ -417,7 +452,7 @@
 			RequestMessage req = new RequestMessage ();
 			req.CreateSimpleOperation (Operation.GetKeyringInfo, keyring);
 			ResponseMessage resp = SendRequest (req.Stream);
-			return new KeyringInfo ((resp.GetInt32 () != 0),
+			return new KeyringInfo (keyring, (resp.GetInt32 () != 0),
 							resp.GetInt32 (),
 							resp.GetDateTime (),
 							resp.GetDateTime (),
@@ -492,5 +527,13 @@
 			SendRequest (req.Stream);
 		}
 	}
+
+#if WITH_DBUS
+	[Interface ("org.gnome.keyring.Daemon")]
+	interface IDaemon
+	{
+		string GetSocketPath ();
+	}
+#endif
 }
 

Modified: branches/banshee/stable/src/Extras/Last.FM/Last.FM/Account.cs
==============================================================================
--- branches/banshee/stable/src/Extras/Last.FM/Last.FM/Account.cs	(original)
+++ branches/banshee/stable/src/Extras/Last.FM/Last.FM/Account.cs	Wed Apr  2 09:53:38 2008
@@ -70,7 +70,7 @@
         public static void RequestLoginSync()
         {
             try {
-                Ring.Unlock (Ring.GetDefaultKeyring ());
+                Ring.Unlock (Ring.GetDefaultKeyring (), String.Empty);
             } catch {}
 
             foreach(ItemData result in Ring.Find(ItemType.NetworkPassword, request_attributes)) {
@@ -90,7 +90,7 @@
         public static void CommitLoginSync()
         {
             try {
-                Ring.Unlock (Ring.GetDefaultKeyring ());
+                Ring.Unlock (Ring.GetDefaultKeyring (), String.Empty);
             } catch {}
 
             Hashtable update_request_attributes = request_attributes.Clone() as Hashtable;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]