Author: jwilcox
Date: 2006-07-18 15:26:37 -0400 (Tue, 18 Jul 2006)
New Revision: 62722
Modified:
trunk/daap-sharp/ChangeLog
trunk/daap-sharp/src/Client.cs
trunk/daap-sharp/src/ContentCodeBag.cs
trunk/daap-sharp/src/ContentParser.cs
trunk/daap-sharp/src/Database.cs
Log:
2006-07-13 James Willcox <[EMAIL PROTECTED]>
* src/ContentCodeBag.cs: add some missing content codes for use
with iPhoto
Modified: trunk/daap-sharp/ChangeLog
===================================================================
--- trunk/daap-sharp/ChangeLog 2006-07-18 19:20:40 UTC (rev 62721)
+++ trunk/daap-sharp/ChangeLog 2006-07-18 19:26:37 UTC (rev 62722)
@@ -1,5 +1,10 @@
2006-07-13 James Willcox <[EMAIL PROTECTED]>
+ * src/ContentCodeBag.cs: add some missing content codes for use
+ with iPhoto
+
+2006-07-13 James Willcox <[EMAIL PROTECTED]>
+
* src/Database.cs: make the events conform to the standard
framework design guidelines (added TrackArgs and PlaylistArgs)
Modified: trunk/daap-sharp/src/Client.cs
===================================================================
--- trunk/daap-sharp/src/Client.cs 2006-07-18 19:20:40 UTC (rev 62721)
+++ trunk/daap-sharp/src/Client.cs 2006-07-18 19:26:37 UTC (rev 62722)
@@ -87,6 +87,8 @@
this.port = port;
fetcher = new ContentFetcher (address, port);
+ bag = ContentCodeBag.ParseCodes (fetcher.Fetch ("/content-codes"));
+
ContentNode node = ContentParser.Parse (ContentCodeBag.Default,
fetcher.Fetch ("/server-info"));
serverInfo = ServerInfo.FromNode (node);
}
@@ -121,8 +123,6 @@
fetcher.Password = password;
try {
- bag = ContentCodeBag.ParseCodes (fetcher.Fetch
("/content-codes"));
-
ContentNode node = ContentParser.Parse (bag, fetcher.Fetch
("/login"));
ParseSessionId (node);
Modified: trunk/daap-sharp/src/ContentCodeBag.cs
===================================================================
--- trunk/daap-sharp/src/ContentCodeBag.cs 2006-07-18 19:20:40 UTC (rev
62721)
+++ trunk/daap-sharp/src/ContentCodeBag.cs 2006-07-18 19:26:37 UTC (rev
62722)
@@ -98,6 +98,10 @@
return IPAddress.NetworkToHostOrder (BitConverter.ToInt32
(Encoding.ASCII.GetBytes (code), 0));
}
+ internal static string GetStringFormat (int code) {
+ return Encoding.ASCII.GetString (BitConverter.GetBytes
(IPAddress.HostToNetworkOrder (code)));
+ }
+
private void AddCode (string num, string name, ContentType type) {
ContentCode code = new ContentCode ();
code.Number = GetIntFormat (num);
@@ -137,6 +141,10 @@
bag.AddCode ("mcty", "dmap.contentcodestype", ContentType.Short);
bag.AddCode ("mstt", "dmap.status", ContentType.Long);
+ // some photo-specific codes
+ bag.AddCode ("ppro", "dpap.protocolversion", ContentType.Long);
+ bag.AddCode ("pret", "dpap.blah", ContentType.Container);
+
ContentNode node = ContentParser.Parse (bag, buffer);
foreach (ContentNode dictNode in (node.Value as ContentNode[])) {
Modified: trunk/daap-sharp/src/ContentParser.cs
===================================================================
--- trunk/daap-sharp/src/ContentParser.cs 2006-07-18 19:20:40 UTC (rev
62721)
+++ trunk/daap-sharp/src/ContentParser.cs 2006-07-18 19:26:37 UTC (rev
62722)
@@ -115,14 +115,15 @@
if (code.Equals (ContentCode.Zero)) {
// probably a buggy server. fallback to our internal code bag
code = ContentCodeBag.Default.Lookup (num);
-
- if (code.Equals (ContentCode.Zero)) {
- throw new ContentException ("Failed to find content code
for: " + num);
- }
}
int length = IPAddress.NetworkToHostOrder (BitConverter.ToInt32
(buffer, offset + 4));
+ if (code.Equals (ContentCode.Zero)) {
+ throw new ContentException (String.Format ("Failed to find
content code for '{0}'. Data length is {1}",
+
ContentCodeBag.GetStringFormat (num), length));
+ }
+
node.Name = code.Name;
switch (code.Type) {
Modified: trunk/daap-sharp/src/Database.cs
===================================================================
--- trunk/daap-sharp/src/Database.cs 2006-07-18 19:20:40 UTC (rev 62721)
+++ trunk/daap-sharp/src/Database.cs 2006-07-18 19:26:37 UTC (rev 62722)
@@ -262,7 +262,14 @@
}
private void RefreshPlaylists (string revquery) {
- byte[] playlistsData = client.Fetcher.Fetch (String.Format
("/databases/{0}/containers", id, revquery));
+ byte[] playlistsData;
+
+ try {
+ playlistsData = client.Fetcher.Fetch (String.Format
("/databases/{0}/containers", id, revquery));
+ } catch (WebException e) {
+ return;
+ }
+
ContentNode playlistsNode = ContentParser.Parse (client.Bag,
playlistsData);
if (IsUpdateResponse (playlistsNode))
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches