private void StartServer() { Console.WriteLine ("Starting DPAP server"); DPAP.Database database = new DPAP.Database ("DPAP"); DPAP.Server server = new Server (System.Environment.UserName.ToString() + " f-spot photos"); server.Port = 8770; server.AuthenticationMethod = AuthenticationMethod.None; int collision_count = 0; server.Collision += delegate { server.Name = System.Environment.UserName.ToString() + " f-spot photos" + "[" + ++collision_count + "]"; }; //FSpot.Photo photo = (FSpot.Photo) Core.Database.Photos.Get (1); try { Album a = new Album ("test album"); Tag t = Core.Database.Tags.GetTagByName ("Shared items"); Tag []tags = {t}; FSpot.Photo [] photos = Core.Database.Photos.Query (tags); int i=0; foreach (FSpot.Photo photo in photos) { string thumbnail_path = Gnome.Thumbnail.PathForUri (photo.DefaultVersion.Uri.ToString(), Gnome.ThumbnailSize.Large); 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.DefaultVersion.Uri.ToString ().Substring (7); f = new FileInfo (photo.DefaultVersion.Uri.ToString ().Substring (7)); if (!f.Exists) continue; //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"; database.AddPhoto (p); a.AddPhoto (p); } database.AddAlbum (a); Console.WriteLine ("Album count is now " + database.Albums.Count); server.AddDatabase (database); //server.GetServerInfoNode (); try { server.Start(); } catch (System.Net.Sockets.SocketException) { Console.WriteLine ("Server socket exception!"); server.Port = 0; server.Start(); } //DaapPlugin.ServerEnabledSchema.Set (true); // if(!initial_db_committed) { server.Commit(); // initial_db_committed = true; // } } catch (Exception e) { Console.WriteLine ("Failed starting dpap server \n{0}", e); } }
private void StartServer() { Console.WriteLine("Starting DPAP server"); DPAP.Database database = new DPAP.Database("DPAP"); DPAP.Server server = new Server(System.Environment.UserName.ToString() + " f-spot photos"); server.Port = 8770; server.AuthenticationMethod = AuthenticationMethod.None; int collision_count = 0; server.Collision += delegate { server.Name = System.Environment.UserName.ToString() + " f-spot photos" + "[" + ++collision_count + "]"; }; //FSpot.Photo photo = (FSpot.Photo) Core.Database.Photos.Get (1); try { Album a = new Album("test album"); Tag t = Core.Database.Tags.GetTagByName("Shared items"); 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); 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 > 2) break; Console.WriteLine("Found photo " + p.Path + ", thumb " + thumbnail_path); p.Title = f.Name; p.Size = (int)f.Length; p.Format = "JPEG"; database.AddPhoto(p); a.AddPhoto(p); } database.AddAlbum(a); Console.WriteLine("Album count is now " + database.Albums.Count); server.AddDatabase(database); //server.GetServerInfoNode (); try { server.Start(); } catch (System.Net.Sockets.SocketException) { Console.WriteLine("Server socket exception!"); server.Port = 0; server.Start(); } //DaapPlugin.ServerEnabledSchema.Set (true); // if(!initial_db_committed) { server.Commit(); // initial_db_committed = true; // } } catch (Exception e) { Console.WriteLine("Failed starting dpap server \n{0}", e); } }
public static void Main(string[] args) { //Regex dbPhotoRegex = new Regex ("/databases/([0-9]*?)/items?session-id=([0-9]*)&meta=.*&query=('dmap.itemid:([0-9]*)')"); // string path = "/databases/1/items?session-id=9527&meta=dpap.thumb,dmap.itemid,dpap.filedata&query=('dmap.itemid:35')$"; //string path = "'dmap.itemid:35'"; // Console.WriteLine("regex:"+rg.IsMatch(path)); Console.WriteLine("Starting DPAP server"); DPAP.Database database = new DPAP.Database("DPAP"); DPAP.Server server = new Server("f-spot photos"); server.Port = 8770; server.AuthenticationMethod = AuthenticationMethod.None; int collision_count = 0; server.Collision += delegate { server.Name = "f-spot photos" + " [" + ++collision_count + "]"; }; Photo p = new Photo(); p.Thumbnail = "./test3-thumb.jpg"; p.ThumbSize = 44786; p.FileName = "test3.jpg"; p.Path = "./test3.jpg"; p.Title = "test1"; p.Format = "JPEG"; p.Size = 1088386; database.AddPhoto(p); Photo p1 = new Photo(); 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; database.AddPhoto(p1); Album a = new Album("test album"); a.AddPhoto(p); a.AddPhoto(p1); database.AddAlbum(a); Console.WriteLine("Album count is now " + database.Albums.Count); Console.WriteLine("Photo name is " + database.Photos[0].FileName); server.AddDatabase(database); //server.GetServerInfoNode(); try { server.Start(); } catch (System.Net.Sockets.SocketException) { Console.WriteLine("Server socket exception!"); server.Port = 0; server.Start(); } //DaapPlugin.ServerEnabledSchema.Set(true); // if(!initial_db_committed) { server.Commit(); // initial_db_committed = true; // } Console.ReadLine(); }