f-spot r4130 - trunk/dpap-sharp/lib



Author: apart
Date: Tue Jul  1 20:03:28 2008
New Revision: 4130
URL: http://svn.gnome.org/viewvc/f-spot?rev=4130&view=rev

Log:
Fixed for proper database retrieval.


Modified:
   trunk/dpap-sharp/lib/Client.cs
   trunk/dpap-sharp/lib/ContentCodeBag.cs
   trunk/dpap-sharp/lib/ContentParser.cs

Modified: trunk/dpap-sharp/lib/Client.cs
==============================================================================
--- trunk/dpap-sharp/lib/Client.cs	(original)
+++ trunk/dpap-sharp/lib/Client.cs	Tue Jul  1 20:03:28 2008
@@ -117,14 +117,14 @@
 
             try {
                 bag = ContentCodeBag.ParseCodes (fetcher.Fetch ("/content-codes"));
-				Console.WriteLine("DEBUG LOGIN !");
+				
                 ContentNode node = ContentParser.Parse (bag, fetcher.Fetch ("/login"));
                 ParseSessionId (node);
-				byte[] db_reply = fetcher.Fetch ("/databases");
+				//byte[] db_reply = fetcher.Fetch ("/databases");
 				
-				Console.Write(BitConverter.ToString(db_reply));
-            //ContentNode dbnode = ContentParser.Parse (bag, fetcher.Fetch ("/databases"));
-              //  FetchDatabases ();
+				//Console.Write(BitConverter.ToString(db_reply));
+			//	ContentNode dbnode = ContentParser.Parse (bag, fetcher.Fetch ("/databases"));
+                FetchDatabases ();
                // Refresh ();
                 
                /* if (serverInfo.SupportsUpdate) {
@@ -164,6 +164,7 @@
 
                 foreach (ContentNode item in (ContentNode[]) child.Value) {
                     Database db = new Database (this, item);
+					Console.WriteLine("Adding database {0} with {1} items." , db.Name,db.TrackCount);
                     databases.Add (db);
                 }
             }

Modified: trunk/dpap-sharp/lib/ContentCodeBag.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentCodeBag.cs	(original)
+++ trunk/dpap-sharp/lib/ContentCodeBag.cs	Tue Jul  1 20:03:28 2008
@@ -117,7 +117,7 @@
         }
 
         internal ContentNode ToNode () {
-			Console.WriteLine("Entering ContentCodeBag ToNode()");
+		//	Console.WriteLine("Entering ContentCodeBag ToNode()");
             ArrayList nodes = new ArrayList ();
             
             foreach (int number in codes.Keys) {
@@ -133,12 +133,12 @@
             }
 
             ContentNode status = new ContentNode ("dmap.status", 200);
-			Console.WriteLine("Leaving ContentCodeBag ToNode()");
+			//Console.WriteLine("Leaving ContentCodeBag ToNode()");
             return new ContentNode ("dmap.contentcodesresponse", status, nodes);
         }
 
         public static ContentCodeBag ParseCodes (byte[] buffer) {
-			Console.WriteLine("Entering ContentCodeBag ParseCodes(byte[])");
+			//Console.WriteLine("Entering ContentCodeBag ParseCodes(byte[])");
             ContentCodeBag bag = new ContentCodeBag ();
 
             // add some codes to bootstrap us
@@ -152,11 +152,12 @@
             // some photo-specific codes
             bag.AddCode ("ppro", "dpap.protocolversion", ContentType.Long);
             bag.AddCode ("pret", "dpap.blah", ContentType.Container);
-
+			bag.AddCode ("avdb", "dpap.serverdatabases", ContentType.Container);
+			
             ContentNode node = ContentParser.Parse (bag, buffer);
 
             foreach (ContentNode dictNode in (node.Value as ContentNode[])) {
-				Console.Write(node.Name + ' ' + node.Value + ' ');
+			//	Console.Write(node.Name + ' ' + node.Value + ' ');
 				if (dictNode.Name != "dmap.dictionary") {
                     continue;
                 }
@@ -179,7 +180,7 @@
 
                 bag.codes[code.Number] = code;
             }
-            Console.WriteLine("Leaving ContentCodeBag ParseCodes(byte[])");
+           // Console.WriteLine("Leaving ContentCodeBag ParseCodes(byte[])");
             return bag;
         }
     }

Modified: trunk/dpap-sharp/lib/ContentParser.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentParser.cs	(original)
+++ trunk/dpap-sharp/lib/ContentParser.cs	Tue Jul  1 20:03:28 2008
@@ -108,16 +108,17 @@
 
         public static ContentNode Parse (ContentCodeBag bag, byte[] buffer, string root,
                                          ref int offset) {
-			Console.WriteLine("Entering ContentNode Pares (...)");
+			//Console.WriteLine("Entering ContentNode Parse (...)");
             ContentNode node = new ContentNode ();
 //System.Console.WriteLine("debug1!");
             int num = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset));
 	//		System.Console.WriteLine("debug2!");
             ContentCode code = bag.Lookup (num);
-			Console.Write(code.Name);
-		//	System.Console.WriteLine("debug3!");
+			//Console.WriteLine("Code number: "+num);
+			//System.Console.WriteLine("debug3!");
             if (code.Equals (ContentCode.Zero)) {
                 // probably a buggy server.  fallback to our internal code bag
+				Console.WriteLine("fallback to internal code bag");
                 code = ContentCodeBag.Default.Lookup (num);
             }
 			
@@ -130,7 +131,7 @@
             }
 
             node.Name = code.Name;
-
+			//Console.WriteLine("Code=" +code.Type.ToString());
             switch (code.Type) {
             case ContentType.Char:
                 node.Value = (byte) buffer[offset + 8];
@@ -167,7 +168,7 @@
             }
 
             offset += length + 8;
-Console.WriteLine("Leaving ContentNode Pares (...)");
+			//Console.WriteLine("Leaving ContentNode Parse (...)");
             if (root != null) {
                 ContentNode rootNode = node.GetChild (root);
 



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