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);
            }
        }
Ejemplo n.º 2
0
        internal void Update(Album pl)
        {
            if (pl.Name == name)
                return;

            Name = pl.Name;
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
        internal static Album FromNode(ContentNode node)
        {
            Album pl = new Album ();

            foreach (ContentNode child in (ContentNode []) node.Value) {
                switch (child.Name) {
                case  "dpap.baseplaylist":
                    return null;
                case "dmap.itemid":
                    pl.Id = (int) child.Value;
                    break;
                case "dmap.itemname":
                    pl.Name = (string) child.Value;
                    break;
                default:
                    break;
                }
            }

            return pl;
        }
Ejemplo n.º 5
0
 public AlbumArgs(Album pl)
 {
     this.pl = pl;
 }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        public void RemoveAlbum(Album pl)
        {
            albums.Remove (pl);

            if (AlbumRemoved != null)
                AlbumRemoved (this, new AlbumArgs (pl));
        }
Ejemplo n.º 8
0
 public void AddAlbum(Album pl)
 {
     // DEBUG
     Console.WriteLine ("Adding album " + pl.Name);
     albums.Add (pl);
     if (AlbumAdded != null)
         AlbumAdded (this, new AlbumArgs (pl));
 }