public PhotoRequestedArgs(string user, IPAddress host, Database db, Photo photo)
 {
     this.user = user;
     this.host = host;
     this.db = db;
     this.photo = photo;
 }
        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);
            }
        }
 public void AddDatabase(Database db)
 {
     databases.Add (db);
 }
 public void RemoveDatabase(Database db)
 {
     databases.Remove (db);
 }
        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();
        }
示例#6
0
        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);
            }
        }
示例#7
0
        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();
        }
        private Album CloneAlbum(Database db, Album pl)
        {
            Album clone_pl = new Album (pl.Name);
            clone_pl.Id = pl.Id;

            IList<Photo> plphotos = pl.Photos;
            for (int i = 0; i < plphotos.Count; i++) {
                clone_pl.AddPhoto (db.LookupPhotoById (plphotos [i].Id), pl.GetContainerId (i));
            }

            return clone_pl;
        }
        public object Clone()
        {
            Database db = new Database (this.name);
            db.id = id;
            db.persistent_id = persistent_id;

            List<Photo> clone_photos = new List<Photo> ();
            foreach (Photo photo in photos) {
                clone_photos.Add ( (Photo) photo.Clone ());
            }

            db.photos = clone_photos;

            List<Album> clone_albums = new List<Album> ();
            foreach (Album pl in albums) {
                clone_albums.Add (CloneAlbum (db, pl));
            }

            db.albums = clone_albums;
            db.base_album = CloneAlbum (db, base_album);
            return db;
        }