f-spot r4216 - in trunk/dpap-sharp: . DPAPService dpap-server lib
- From: apart svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4216 - in trunk/dpap-sharp: . DPAPService dpap-server lib
- Date: Wed, 30 Jul 2008 12:55:31 +0000 (UTC)
Author: apart
Date: Wed Jul 30 12:55:31 2008
New Revision: 4216
URL: http://svn.gnome.org/viewvc/f-spot?rev=4216&view=rev
Log:
Fix for iPhoto '08 compatibility
Modified:
trunk/dpap-sharp/ChangeLog
trunk/dpap-sharp/DPAPService/DPAPService.cs
trunk/dpap-sharp/dpap-server/Main.cs
trunk/dpap-sharp/lib/Album.cs
trunk/dpap-sharp/lib/ContentWriter.cs
trunk/dpap-sharp/lib/Photo.cs
trunk/dpap-sharp/lib/Server.cs
Modified: trunk/dpap-sharp/DPAPService/DPAPService.cs
==============================================================================
--- trunk/dpap-sharp/DPAPService/DPAPService.cs (original)
+++ trunk/dpap-sharp/DPAPService/DPAPService.cs Wed Jul 30 12:55:31 2008
@@ -52,6 +52,7 @@
private void StartServer ()
{
Console.WriteLine("Starting DPAP server");
+
DPAP.Database database = new DPAP.Database("DPAP");
DPAP.Server server = new Server("f-spot photos");
server.Port = 8770;
@@ -70,18 +71,25 @@
Tag []tags = {t};
FSpot.Photo [] photos = Core.Database.Photos.Query(tags);
+ int i=0;
foreach(FSpot.Photo photo in photos)
{
- string thumbnail_path = ThumbnailGenerator.ThumbnailPath (photo.DefaultVersionUri);
- DPAP.Photo p = new DPAP.Photo();
- p.FileName = thumbnail_path;
- FileInfo f = new FileInfo(p.FileName);
+ string thumbnail_path = ThumbnailGenerator.ThumbnailPath (photo.DefaultVersionUri);
+ FileInfo f = new FileInfo(thumbnail_path);
+
+ DPAP.Photo p = new DPAP.Photo();
+ p.FileName = photo.Name;
+ p.Thumbnail = thumbnail_path;
+ p.ThumbSize = (int)f.Length;
+ p.Path = photo.DefaultVersionUri.ToString().Substring(7);
+ f = new FileInfo(photo.DefaultVersionUri.ToString().Substring(7));
if(!f.Exists)
continue;
- //if(++i > 5) break;
- Console.WriteLine("Found photo " + photo.DefaultVersionUri + ", thumb " + thumbnail_path);
+
+ //if(++i > 2) break;
+ Console.WriteLine("Found photo " + p.Path + ", thumb " + thumbnail_path);
p.Title = f.Name;
p.Size = (int)f.Length;
p.Format = "JPEG";
@@ -91,7 +99,7 @@
database.AddAlbum(a);
Console.WriteLine("Album count is now " + database.Albums.Count);
- Console.WriteLine("Photo name is " + database.Photos[0].FileName);
+// Console.WriteLine("Photo name is " + database.Photos[0].FileName);
server.AddDatabase(database);
//server.GetServerInfoNode();
@@ -124,7 +132,7 @@
return true;
}
-private static void OnServiceFound(object o, ServiceArgs args)
+ private static void OnServiceFound(object o, ServiceArgs args)
{
Service service = args.Service;
Client client;
Modified: trunk/dpap-sharp/dpap-server/Main.cs
==============================================================================
--- trunk/dpap-sharp/dpap-server/Main.cs (original)
+++ trunk/dpap-sharp/dpap-server/Main.cs Wed Jul 30 12:55:31 2008
@@ -58,14 +58,20 @@
};
Photo p = new Photo();
- p.FileName = "./test1.jpg";
+ p.Thumbnail = "./test3-thumb.jpg";
+ p.ThumbSize = 44786;
+ p.FileName = "test3.jpg";
+ p.Path = "./test3.jpg";
p.Title = "test1";
p.Format = "JPEG";
- p.Size = 13946;
+ p.Size = 1088386;
database.AddPhoto(p);
Photo p1 = new Photo();
- p1.FileName = "./test2.jpg";
+ p1.Thumbnail = "./test2-thumb.jpg";
+ p1.ThumbSize = 11357;
+ p1.FileName = "test2.jpg";
+ p1.Path = "./test2.jpg";
p1.Title = "test2";
p1.Format = "JPEG";
p1.Size = 35209;
Modified: trunk/dpap-sharp/lib/Album.cs
==============================================================================
--- trunk/dpap-sharp/lib/Album.cs (original)
+++ trunk/dpap-sharp/lib/Album.cs Wed Jul 30 12:55:31 2008
@@ -23,7 +23,7 @@
//
//
-using System;
+ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -138,15 +138,16 @@
return (int) containerIds[index];
}
- internal ContentNode ToPhotosNode (int[] deletedIds) {
+ internal ContentNode ToPhotosNode (string[] fields) {
ArrayList photoNodes = new ArrayList ();
for (int i = 0; i < photos.Count; i++) {
Photo photo = photos[i] as Photo;
- photoNodes.Add (photo.ToAlbumNode ((int) containerIds[i]));
+ photoNodes.Add (photo.ToAlbumNode(fields));
+ //photoNodes.Add (photo.ToAlbumsNode ((int) containerIds[i]));
}
- ArrayList deletedNodes = null;
+ /*ArrayList deletedNodes = null;
if (deletedIds.Length > 0) {
deletedNodes = new ArrayList ();
@@ -154,16 +155,16 @@
deletedNodes.Add (new ContentNode ("dmap.itemid", id));
}
}
-
+*/
ArrayList children = new ArrayList ();
children.Add (new ContentNode ("dmap.status", 200));
- children.Add (new ContentNode ("dmap.updatetype", deletedNodes == null ? (byte) 0 : (byte) 1));
+ children.Add (new ContentNode ("dmap.updatetype", (byte) 0));
children.Add (new ContentNode ("dmap.specifiedtotalcount", photos.Count));
children.Add (new ContentNode ("dmap.returnedcount", photos.Count));
children.Add (new ContentNode ("dmap.listing", photoNodes));
- if (deletedNodes != null)
- children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
+ // if (deletedNodes != null)
+ // children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
return new ContentNode ("dpap.playlistsongs", children);
Modified: trunk/dpap-sharp/lib/ContentWriter.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentWriter.cs (original)
+++ trunk/dpap-sharp/lib/ContentWriter.cs Wed Jul 30 12:55:31 2008
@@ -19,7 +19,7 @@
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 51 Franklin Street,Fifth Floor, Boston, MA 02110-1301 USA
//
//
@@ -78,13 +78,15 @@
writer.Write ((byte) version.Build);
break;
case ContentType.FileData:
+
Console.WriteLine("ContentWriter FileData!");
ContentNode[] nodes = (ContentNode[]) node.Value;
//writer.Write(IPAddress.HostToNetworkOrder (0));
Console.WriteLine(nodes[0].Value);
writer.Write(IPAddress.HostToNetworkOrder ((int)nodes[0].Value));
- Console.WriteLine("reading file!");
- FileInfo info = new FileInfo ((string)nodes[1].Value);
+ FileInfo info = new FileInfo ((string)nodes[1].Value);
+ Console.WriteLine("reading file " + nodes[1].Value + ", length=" +info.Length);
+
FileStream stream = info.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
//writer.Write (client, stream, info.Length, offset);
Modified: trunk/dpap-sharp/lib/Photo.cs
==============================================================================
--- trunk/dpap-sharp/lib/Photo.cs (original)
+++ trunk/dpap-sharp/lib/Photo.cs Wed Jul 30 12:55:31 2008
@@ -45,6 +45,9 @@
private int photoNumber;
private int photoCount;
private string fileName;
+ private string thumbnail;
+ private string path;
+ private int thumbsize;
private DateTime dateAdded = DateTime.Now;
private DateTime dateModified = DateTime.Now;
private short bitrate;
@@ -119,6 +122,30 @@
}
}
+ public string Path {
+ get { return path; }
+ set {
+ path = value;
+ EmitUpdated ();
+ }
+ }
+
+ public string Thumbnail {
+ get { return thumbnail; }
+ set {
+ thumbnail = value;
+ EmitUpdated ();
+ }
+ }
+
+ public int ThumbSize {
+ get { return thumbsize; }
+ set {
+ thumbsize = value;
+ EmitUpdated ();
+ }
+ }
+
public int Width {
get { return width; }
set {
@@ -163,27 +190,32 @@
photo.id = id;
photo.size = size;
photo.fileName = fileName;
+ photo.thumbnail = thumbnail;
+ photo.thumbsize = thumbsize;
photo.dateAdded = dateAdded;
photo.dateModified = dateModified;
-
+ photo.path = path;
return photo;
}
public override string ToString () {
- return String.Format ("{0} - {1}.{2} ({3})", fileName, title, format, id);
+ return String.Format ("fname={0}, title={1}, format={2}, id={3}, path={4}", fileName, title, format, id, path);
}
internal void SetId (int id) {
this.id = id;
}
- internal ContentNode ToFileData () {
+ internal ContentNode ToFileData (bool thumb) {
ArrayList nodes = new ArrayList ();
-
+ Console.WriteLine("Requested "+ ((thumb)?"thumb":"file") +", thumbnail=" + thumbnail + ", hires=" + path);
+ nodes.Add (new ContentNode ("dmap.itemkind", (byte)3));
nodes.Add (new ContentNode ("dmap.itemid", id));
nodes.Add (new ContentNode ("dpap.filedata",
- new ContentNode ("dpap.imagefilesize", size),
- new ContentNode ("dpap.imagefilename", fileName)));
+ new ContentNode ("dpap.imagefilesize", (thumb)?thumbsize:size),
+ new ContentNode ("dpap.imagefilename", (thumb)?thumbnail:path),
+ new ContentNode ("dpap.imagefilename", (thumb)?thumbnail:fileName)));
+
return (new ContentNode("dmap.listingitem", nodes));
/*
@@ -214,7 +246,7 @@
val = title;
break;
case "dmap.itemkind":
- val = (byte) 2;
+ val = (byte) 3;
break;
case "dmap.persistentid":
val = (long) id;
@@ -233,7 +265,28 @@
case "dpap.imagefilename":
val = fileName;
break;
-
+ case "dpap.imagefilesize":
+ val = thumbsize;
+ break;
+ case "dpap.imagelargefilesize":
+ val = size;
+ break;
+ /*case "dpap.aspectratio":
+ val = "0";
+ break;*/
+ case "dpap.creationdate":
+ val = 7799;
+ break;
+ case "dpap.pixelheight":
+ val = 0;
+ break;
+ case "dpap.pixelwidth":
+ val = 0;
+ break;
+ case "dpap.imagerating":
+ val = 0;
+ break;
+
default:
break;
}
@@ -284,13 +337,81 @@
return photo;
}
- internal ContentNode ToAlbumNode (int containerId) {
- return new ContentNode ("dmap.listingitem",
- new ContentNode ("dmap.itemkind", (byte) 2),
- new ContentNode ("dpap.imagefilename", fileName),
+ internal ContentNode ToAlbumNode (string[] fields) {
+ArrayList nodes = new ArrayList ();
+
+ foreach (string field in fields) {
+ object val = null;
+
+ switch (field) {
+ case "dmap.itemid":
+ val = id;
+ break;
+ case "dmap.itemname":
+ val = title;
+ break;
+ case "dmap.itemkind":
+ val = (byte) 3;
+ break;
+ case "dmap.persistentid":
+ val = (long) id;
+ break;
+ case "dpap.photoalbum":
+ val = album;
+ break;
+
+ case "dpap.author":
+ val = author;
+ break;
+
+ case "dpap.imageformat":
+ val = format;
+ break;
+ case "dpap.imagefilename":
+ val = fileName;
+ break;
+ case "dpap.imagefilesize":
+ val = thumbsize;
+ break;
+ case "dpap.imagelargefilesize":
+ val = size;
+ break;
+ case "dpap.aspectratio":
+ val = "1.522581";
+ break;
+ case "dpap.creationdate":
+ val = 7799;
+ break;
+ case "dpap.pixelheight":
+ val = 0;
+ break;
+ case "dpap.pixelwidth":
+ val = 0;
+ break;
+ case "dpap.imagerating":
+ val = 0;
+ break;
+
+ default:
+ break;
+ }
+
+ if (val != null) {
+ // iTunes wants this to go first, sigh
+ if (field == "dmap.itemkind")
+ nodes.Insert (0, new ContentNode (field, val));
+ else
+ nodes.Add (new ContentNode (field, val));
+ }
+ }
+ return new ContentNode ("dmap.listingitem",
+ new ContentNode ("dmap.itemkind", (byte) 3),
+ nodes);
+ /* new ContentNode ("dpap.imagefilename", fileName),
new ContentNode ("dmap.itemid", Id),
- new ContentNode ("dmap.containeritemid", containerId),
+ //new ContentNode ("dmap.containeritemid", containerId),
new ContentNode ("dmap.itemname", Title == null ? String.Empty : Title));
+ */
}
internal static void FromAlbumNode (Database db, ContentNode node, out Photo photo, out int containerId) {
Modified: trunk/dpap-sharp/lib/Server.cs
==============================================================================
--- trunk/dpap-sharp/lib/Server.cs (original)
+++ trunk/dpap-sharp/lib/Server.cs Wed Jul 30 12:55:31 2008
@@ -276,6 +276,7 @@
try {
string path = splitRequest[1];
if (!path.StartsWith ("dpap://")) {
+ Console.WriteLine("Path is not correct - " + path);
path = String.Format ("dpap://localhost{0}", path);
}
@@ -674,6 +675,7 @@
photoQuery = query["query"];
else
photoQuery = "";
+
int session = 0;
if (query["session-id"] != null) {
session = Int32.Parse (query["session-id"]);
@@ -698,7 +700,11 @@
if (query["delta"] != null) {
delta = Int32.Parse (query["delta"]);
}
- Console.WriteLine("Before returning resources for path " + path);
+ // DEBUG data
+ Console.WriteLine("Before returning resources for path " + path + ", meta " + query["meta"] + " query " + photoQuery);
+ if(dbItemsRegex.IsMatch (path)) //&& photoQuery.Length==0
+ Console.WriteLine ("\tThis is a database/items request!");
+
if (path == "/server-info") {
ws.WriteResponse (client, GetServerInfoNode ());
} else if (path == "/content-codes") {
@@ -763,7 +769,7 @@
ws.WriteResponse (client, node);
} else if (dbPhotoRegex.IsMatch (photoQuery)) {
Console.WriteLine("dbPhotoRegex");
- Console.WriteLine("dbItemsRegex, query=" + query["query"] + " meta=" + query["meta"]);
+ Console.WriteLine("dbPhotosRegex, query=" + query["query"] + " meta=" + query["meta"]);
string[] photoIds = query["query"].Split (',');
Match match = dbPhotoRegex0.Match(path);
int dbid = Int32.Parse (match.Groups[1].Value);
@@ -779,13 +785,14 @@
}
ArrayList photoNodes = new ArrayList();
Photo photo = db.LookupPhotoById (1);
+
foreach (string photoId in photoIds)
{
match = dbPhotoRegex.Match (photoId);
photoid = Int32.Parse (match.Groups[1].Value);
Console.WriteLine("Requested photo id=" + photoid);
photo = db.LookupPhotoById (photoid);
- photoNodes.Add(photo.ToFileData());
+ photoNodes.Add(photo.ToFileData(query["meta"].Contains("dpap.thumb")));
}
ArrayList children = new ArrayList ();
@@ -796,7 +803,7 @@
children.Add (new ContentNode ("dmap.listing", photoNodes));
ContentNode dbsongs = new ContentNode ("dpap.databasesongs", children);
- Console.WriteLine(photo.ToString());
+ Console.WriteLine("Photo tostring: " + photo.ToString());
if (photo == null) {
ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid photo id");
return true;
@@ -843,6 +850,8 @@
ws.WriteResponse (client, db.ToAlbumsNode ());
} else if (dbContainerItemsRegex.IsMatch (path)) {
+ // DEBUG
+ Console.WriteLine("ContainerItems !");
Match match = dbContainerItemsRegex.Match (path);
int dbid = Int32.Parse (match.Groups[1].Value);
int plid = Int32.Parse (match.Groups[2].Value);
@@ -877,8 +886,9 @@
}
}
}
-
- ws.WriteResponse (client, curpl.ToPhotosNode ((int[]) deletedIds.ToArray (typeof (int))));
+ curpl.ToPhotosNode (query["meta"].Split (',')).Dump();
+ ws.WriteResponse (client, curpl.ToPhotosNode (query["meta"].Split (',')));
+ //, (int[]) deletedIds.ToArray (typeof (int))));
} else if (path == "/update") {
int retrev;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]