public abstract bool MoveAlbum (Album album, string end_name);
		public abstract int AddItem (Album album, string path, string filename, string caption, string description, bool autorotate);
		public override bool MoveAlbum (Album album, string end_name)
		{
			FormClient client = new FormClient (cookies);

			client.Add ("g2_form[cmd]", "move-album");
			client.Add ("g2_form[protocol_version]", "2.10");
			client.Add ("g2_form[set_albumName]", album.Name);
			client.Add ("g2_form[set_destalbumName]", end_name);
			AddG2Specific (client);

			return ParseMoveAlbum (client.Submit (uri));
		}
Exemple #4
0
 public override string GetAlbumUrl(Album album)
 {
     return(Uri.ToString() + "?g2_view=core.ShowItem&g2_itemId=" + album.Name);
 }
		public override int AddItem (Album album,
				     string path,
				     string filename,
				     string caption,
				     string description,
				     bool autorotate)
		{
			FormClient client = new FormClient (cookies);

			client.Add ("cmd", "add-item");
			client.Add ("protocol_version", "2.9");
			client.Add ("set_albumName", album.Name);
			client.Add ("caption", caption);
			client.Add ("userfile_name", filename);
			client.Add ("force_filename", filename);
			client.Add ("auto_rotate", autorotate ? "yes" : "no");
			client.Add ("userfile", new FileInfo (path));
			client.Add ("extrafield.Description", description);
			client.expect_continue = expect_continue;

			return ParseAddItem (client.Submit (uri, Progress));
		}
		public ArrayList ParseFetchAlbumImages (HttpWebResponse response, Album album)
		{
			string [] data;
			StreamReader reader = null;
			ResultCode status = ResultCode.UnknownResponse;
			string status_text = "Error: Unable to parse server response";
			try {
				Image current_image = null;
				reader = findResponse (response);
				while ((data = GetNextLine (reader)) != null) {
					if (data[0] == "status") {
						status = (ResultCode) int.Parse (data [1]);
					} else if (data[0].StartsWith ("status_text")) {
						status_text = data[1];
						Console.WriteLine ("StatusText : {0}", data[1]);
					} else if (data[0].StartsWith ("image.name")) {
						current_image = new Image (album, data[1]);
						album.Images.Add (current_image);
					} else if (data[0].StartsWith ("image.raw_width")) {
						current_image.RawWidth = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.raw_height")) {
						current_image.RawHeight = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.raw_height")) {
						current_image.RawHeight = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.raw_filesize")) {
					} else if (data[0].StartsWith ("image.capturedate.year")) {
					} else if (data[0].StartsWith ("image.capturedate.mon")) {
					} else if (data[0].StartsWith ("image.capturedate.mday")) {
					} else if (data[0].StartsWith ("image.capturedate.hours")) {
					} else if (data[0].StartsWith ("image.capturedate.minutes")) {
					} else if (data[0].StartsWith ("image.capturedate.seconds")) {
					} else if (data[0].StartsWith ("image.hidden")) {
					} else if (data[0].StartsWith ("image.resizedName")) {
						current_image.ResizedName = data[1];
					} else if (data[0].StartsWith ("image.resized_width")) {
						current_image.ResizedWidth = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.resized_height")) {
						current_image.ResizedHeight = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.thumbName")) {
						current_image.ThumbName = data[1];
					} else if (data[0].StartsWith ("image.thumb_width")) {
						current_image.ThumbWidth = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.thumb_height")) {
						current_image.ThumbHeight = int.Parse (data[1]);
					} else if (data[0].StartsWith ("image.caption")) {
						current_image.Caption = data[1];
					} else if (data[0].StartsWith ("image.extrafield.Description")) {
						current_image.Description = data[1];
					} else if (data[0].StartsWith ("image.clicks")) {
						try {
							current_image.Clicks = int.Parse (data[1]);
						} catch (System.FormatException) {
							current_image.Clicks = 0;
						}
					} else if (data[0].StartsWith ("baseurl")) {
						album.BaseURL = data[1];
					} else if (data[0].StartsWith ("image_count")) {
						if (album.Images.Count != int.Parse (data[1]))
							Console.WriteLine ("Parsed image count for " + album.Name + "(" + album.Images.Count + ") does not match image_count (" + data[1] + ").  Something is amiss");
					} else {
						Console.WriteLine ("Unparsed Line in ParseFetchAlbumImages(): {0}={1}", data[0], data[1]);
					}
				}
				//Console.WriteLine ("Found: {0} cookies", response.Cookies.Count);
				if (status != ResultCode.Success) {
					Console.WriteLine (status_text);
					throw new GalleryCommandException (status_text, status);
				}


				//Set the Urls for downloading the images.
				string baseUrl = album.BaseURL + "/";
				foreach (Image image in album.Images) {
					image.Url = baseUrl + image.Name;
				}

				return album.Images;
			} finally {
				if (reader != null)
					reader.Close ();

				response.Close ();
			}
		}
Exemple #7
0
        public ArrayList ParseFetchAlbums(HttpWebResponse response)
        {
            //Console.WriteLine ("in ParseFetchAlbums()");
            string []    data;
            StreamReader reader      = null;
            ResultCode   status      = ResultCode.UnknownResponse;
            string       status_text = "Error: Unable to parse server response";

            albums = new ArrayList();
            try {
                Album current_album = null;
                reader = findResponse(response);
                while ((data = GetNextLine(reader)) != null)
                {
                    //Console.WriteLine ("Parsing Line: {0}={1}", data[0], data[1]);
                    if (data[0] == "status")
                    {
                        status = (ResultCode)int.Parse(data [1]);
                    }
                    else if (data[0].StartsWith("status_text"))
                    {
                        status_text = data[1];
                        Console.WriteLine("StatusText : {0}", data[1]);
                    }
                    else if (data[0].StartsWith("album.name"))
                    {
                        //this is the URL name
                        int ref_num = -1;
                        if (this.Version == GalleryVersion.Version1)
                        {
                            string [] segments = data[0].Split(new char[1] {
                                '.'
                            });
                            ref_num = int.Parse(segments[segments.Length - 1]);
                        }
                        else
                        {
                            ref_num = int.Parse(data[1]);
                        }
                        current_album = new Album(this, data[1], ref_num);
                        albums.Add(current_album);
                        //Console.WriteLine ("current_album: " + data[1]);
                    }
                    else if (data[0].StartsWith("album.title"))
                    {
                        //this is the display name
                        current_album.Title = data[1];
                    }
                    else if (data[0].StartsWith("album.summary"))
                    {
                        current_album.Summary = data[1];
                    }
                    else if (data[0].StartsWith("album.parent"))
                    {
                        //FetchAlbums and G2 FetchAlbumsPrune return ints
                        //G1 FetchAlbumsPrune returns album names (and 0 for root albums)
                        try {
                            current_album.ParentRefNum = int.Parse(data[1]);
                        } catch (System.FormatException) {
                            current_album.ParentRefNum = LookupAlbum(data[1]).RefNum;
                        }
                        //Console.WriteLine ("album.parent data[1]: " + data[1]);
                    }
                    else if (data[0].StartsWith("album.resize_size"))
                    {
                        current_album.ResizeSize = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("album.thumb_size"))
                    {
                        current_album.ThumbSize = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("album.info.extrafields"))
                    {
                        //ignore, this is the album description
                    }
                    else if (data[0].StartsWith("album.perms.add"))
                    {
                        if (data[1] == "true")
                        {
                            current_album.Perms |= AlbumPermission.Add;
                        }
                    }
                    else if (data[0].StartsWith("album.perms.write"))
                    {
                        if (data[1] == "true")
                        {
                            current_album.Perms |= AlbumPermission.Write;
                        }
                    }
                    else if (data[0].StartsWith("album.perms.del_item"))
                    {
                        if (data[1] == "true")
                        {
                            current_album.Perms |= AlbumPermission.Delete;
                        }
                    }
                    else if (data[0].StartsWith("album.perms.del_alb"))
                    {
                        if (data[1] == "true")
                        {
                            current_album.Perms |= AlbumPermission.DeleteAlbum;
                        }
                    }
                    else if (data[0].StartsWith("album.perms.create_sub"))
                    {
                        if (data[1] == "true")
                        {
                            current_album.Perms |= AlbumPermission.CreateSubAlbum;
                        }
                    }
                    else if (data[0].StartsWith("album_count"))
                    {
                        if (Albums.Count != int.Parse(data[1]))
                        {
                            Console.WriteLine("Parsed album count does not match album_count.  Something is amiss");
                        }
                    }
                    else if (data[0].StartsWith("auth_token"))
                    {
                        AuthToken = data [1];
                    }
                    else
                    {
                        Console.WriteLine("Unparsed Line in ParseFetchAlbums(): {0}={1}", data[0], data[1]);
                    }
                }
                //Console.WriteLine ("Found: {0} cookies", response.Cookies.Count);
                if (status != ResultCode.Success)
                {
                    Console.WriteLine(status_text);
                    throw new GalleryCommandException(status_text, status);
                }

                //Console.WriteLine (After parse albums.Count + " albums parsed");
                return(albums);
            } finally {
                if (reader != null)
                {
                    reader.Close();
                }

                response.Close();
            }
        }
		public ArrayList ParseFetchAlbums (HttpWebResponse response)
		{
			//Console.WriteLine ("in ParseFetchAlbums()");
			string [] data;
			StreamReader reader = null;
			ResultCode status = ResultCode.UnknownResponse;
			string status_text = "Error: Unable to parse server response";
			albums = new ArrayList ();
			try {

				Album current_album = null;
				reader = findResponse (response);
				while ((data = GetNextLine (reader)) != null) {
					//Console.WriteLine ("Parsing Line: {0}={1}", data[0], data[1]);
					if (data[0] == "status") {
						status = (ResultCode) int.Parse (data [1]);
					} else if (data[0].StartsWith ("status_text")) {
						status_text = data[1];
						Console.WriteLine ("StatusText : {0}", data[1]);
					} else if (data[0].StartsWith ("album.name")) {
						//this is the URL name
						int ref_num = -1;
						if (this.Version == GalleryVersion.Version1) {
							string [] segments = data[0].Split (new char[1]{'.'});
							ref_num = int.Parse (segments[segments.Length -1]);
						} else {
							ref_num = int.Parse (data[1]);
						}
						current_album = new Album (this, data[1], ref_num);
						albums.Add (current_album);
						//Console.WriteLine ("current_album: " + data[1]);
					} else if (data[0].StartsWith ("album.title")) {
						//this is the display name
						current_album.Title = data[1];
					} else if (data[0].StartsWith ("album.summary")) {
						current_album.Summary = data[1];
					} else if (data[0].StartsWith ("album.parent")) {
						//FetchAlbums and G2 FetchAlbumsPrune return ints
						//G1 FetchAlbumsPrune returns album names (and 0 for root albums)
						try {
							current_album.ParentRefNum = int.Parse (data[1]);
						} catch (System.FormatException) {
							current_album.ParentRefNum = LookupAlbum (data[1]).RefNum;
						}
						//Console.WriteLine ("album.parent data[1]: " + data[1]);
					} else if (data[0].StartsWith ("album.resize_size")) {
						current_album.ResizeSize = int.Parse (data[1]);
					} else if (data[0].StartsWith ("album.thumb_size")) {
						current_album.ThumbSize = int.Parse (data[1]);
					} else if (data[0].StartsWith ("album.info.extrafields")) {
						//ignore, this is the album description
					} else if (data[0].StartsWith ("album.perms.add")) {
						if (data[1] == "true")
							current_album.Perms |= AlbumPermission.Add;
					} else if (data[0].StartsWith ("album.perms.write")) {
						if (data[1] == "true")
							current_album.Perms |= AlbumPermission.Write;
					} else if (data[0].StartsWith ("album.perms.del_item")) {
						if (data[1] == "true")
							current_album.Perms |= AlbumPermission.Delete;
					} else if (data[0].StartsWith ("album.perms.del_alb")) {
						if (data[1] == "true")
							current_album.Perms |= AlbumPermission.DeleteAlbum;
					} else if (data[0].StartsWith ("album.perms.create_sub")) {
						if (data[1] == "true")
							current_album.Perms |= AlbumPermission.CreateSubAlbum;
					} else if (data[0].StartsWith ("album_count")) {
						if (Albums.Count != int.Parse (data[1]))
							Console.WriteLine ("Parsed album count does not match album_count.  Something is amiss");
					} else if (data[0].StartsWith ("auth_token")) {
						AuthToken = data [1];
					} else {
						Console.WriteLine ("Unparsed Line in ParseFetchAlbums(): {0}={1}", data[0], data[1]);
					}
				}
				//Console.WriteLine ("Found: {0} cookies", response.Cookies.Count);
				if (status != ResultCode.Success) {
					Console.WriteLine (status_text);
					throw new GalleryCommandException (status_text, status);
				}

				//Console.WriteLine (After parse albums.Count + " albums parsed");
				return albums;
			} finally {
				if (reader != null)
					reader.Close ();

				response.Close ();
			}
		}
Exemple #9
0
 public abstract ArrayList FetchAlbumImages(Album album, bool include_ablums);
Exemple #10
0
 public abstract string GetAlbumUrl(Album album);
Exemple #11
0
 public abstract int AddItem(Album album, string path, string filename, string caption, string description, bool autorotate);
Exemple #12
0
 public abstract bool MoveAlbum(Album album, string end_name);
Exemple #13
0
 public Image(Album album, string name)
 {
     Name  = name;
     Owner = album;
 }
		public abstract ArrayList FetchAlbumImages (Album album, bool include_ablums);
Exemple #15
0
        public ArrayList ParseFetchAlbumImages(HttpWebResponse response, Album album)
        {
            string []    data;
            StreamReader reader      = null;
            ResultCode   status      = ResultCode.UnknownResponse;
            string       status_text = "Error: Unable to parse server response";

            try {
                Image current_image = null;
                reader = findResponse(response);
                while ((data = GetNextLine(reader)) != null)
                {
                    if (data[0] == "status")
                    {
                        status = (ResultCode)int.Parse(data [1]);
                    }
                    else if (data[0].StartsWith("status_text"))
                    {
                        status_text = data[1];
                        Console.WriteLine("StatusText : {0}", data[1]);
                    }
                    else if (data[0].StartsWith("image.name"))
                    {
                        current_image = new Image(album, data[1]);
                        album.Images.Add(current_image);
                    }
                    else if (data[0].StartsWith("image.raw_width"))
                    {
                        current_image.RawWidth = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.raw_height"))
                    {
                        current_image.RawHeight = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.raw_height"))
                    {
                        current_image.RawHeight = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.raw_filesize"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.year"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.mon"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.mday"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.hours"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.minutes"))
                    {
                    }
                    else if (data[0].StartsWith("image.capturedate.seconds"))
                    {
                    }
                    else if (data[0].StartsWith("image.hidden"))
                    {
                    }
                    else if (data[0].StartsWith("image.resizedName"))
                    {
                        current_image.ResizedName = data[1];
                    }
                    else if (data[0].StartsWith("image.resized_width"))
                    {
                        current_image.ResizedWidth = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.resized_height"))
                    {
                        current_image.ResizedHeight = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.thumbName"))
                    {
                        current_image.ThumbName = data[1];
                    }
                    else if (data[0].StartsWith("image.thumb_width"))
                    {
                        current_image.ThumbWidth = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.thumb_height"))
                    {
                        current_image.ThumbHeight = int.Parse(data[1]);
                    }
                    else if (data[0].StartsWith("image.caption"))
                    {
                        current_image.Caption = data[1];
                    }
                    else if (data[0].StartsWith("image.extrafield.Description"))
                    {
                        current_image.Description = data[1];
                    }
                    else if (data[0].StartsWith("image.clicks"))
                    {
                        try {
                            current_image.Clicks = int.Parse(data[1]);
                        } catch (System.FormatException) {
                            current_image.Clicks = 0;
                        }
                    }
                    else if (data[0].StartsWith("baseurl"))
                    {
                        album.BaseURL = data[1];
                    }
                    else if (data[0].StartsWith("image_count"))
                    {
                        if (album.Images.Count != int.Parse(data[1]))
                        {
                            Console.WriteLine("Parsed image count for " + album.Name + "(" + album.Images.Count + ") does not match image_count (" + data[1] + ").  Something is amiss");
                        }
                    }
                    else
                    {
                        Console.WriteLine("Unparsed Line in ParseFetchAlbumImages(): {0}={1}", data[0], data[1]);
                    }
                }
                //Console.WriteLine ("Found: {0} cookies", response.Cookies.Count);
                if (status != ResultCode.Success)
                {
                    Console.WriteLine(status_text);
                    throw new GalleryCommandException(status_text, status);
                }


                //Set the Urls for downloading the images.
                string baseUrl = album.BaseURL + "/";
                foreach (Image image in album.Images)
                {
                    image.Url = baseUrl + image.Name;
                }

                return(album.Images);
            } finally {
                if (reader != null)
                {
                    reader.Close();
                }

                response.Close();
            }
        }
		public abstract string GetAlbumUrl (Album album);
Exemple #17
0
        private void HandleResponse(object sender, Gtk.ResponseArgs args)
        {
            if (args.ResponseId != Gtk.ResponseType.Ok) {
                export_dialog.Destroy ();
                return;
            }

            if (scale_check != null) {
                scale = scale_check.Active;
                size = size_spin.ValueAsInt;
            } else
                scale = false;

            browser = browser_check.Active;
            meta = meta_check.Active;
            rotate = rotate_check.Active;

            if (account != null) {
                //System.Console.WriteLine ("history = {0}", album_optionmenu.History);
                album = (Album) account.Gallery.Albums [Math.Max (0, album_optionmenu.History)];
                photo_index = 0;

                export_dialog.Destroy ();

                command_thread = new System.Threading.Thread (new System.Threading.ThreadStart (this.Upload));
                command_thread.Name = Catalog.GetString ("Uploading Pictures");

                progress_dialog = new ThreadProgressDialog (command_thread, items.Length);
                progress_dialog.Start ();

                // Save these settings for next time
                Preferences.Set (SCALE_KEY, scale);
                Preferences.Set (SIZE_KEY, size);
                Preferences.Set (BROWSER_KEY, browser);
                Preferences.Set (META_KEY, meta);
                Preferences.Set (ROTATE_KEY, rotate);
            }
        }
		public override bool MoveAlbum (Album album, string end_name)
		{
			FormClient client = new FormClient (cookies);

			client.Add ("cmd", "move-album");
			client.Add ("protocol_version", "2.7");
			client.Add ("set_albumName", album.Name);
			client.Add ("set_destalbumName", end_name);

			return ParseMoveAlbum (client.Submit (uri));
		}
		public override ArrayList FetchAlbumImages (Album album, bool include_ablums)
		{
			FormClient client = new FormClient (cookies);
			client.Add ("g2_form[cmd]", "fetch-album-images");
			client.Add ("g2_form[protocol_version]","2.10");
			client.Add ("g2_form[set_albumName]", album.Name);
			client.Add ("g2_form[albums_too]", include_ablums ? "yes" : "no");
			AddG2Specific (client);

			album.Images = ParseFetchAlbumImages (client.Submit (uri), album);
			return album.Images;
		}
		public override ArrayList FetchAlbumImages (Album album, bool include_ablums)
		{
			FormClient client = new FormClient (cookies);
			client.Add ("cmd", "fetch-album-images");
			client.Add ("protocol_version","2.3");
			client.Add ("set_albumName", album.Name);
			client.Add ("albums_too", include_ablums ? "yes" : "no");

			album.Images = ParseFetchAlbumImages (client.Submit (uri), album);
			return album.Images;
		}
		public override string GetAlbumUrl (Album album)
		{
			return Uri.ToString() + "?g2_view=core.ShowItem&g2_itemId=" + album.Name;
		}
		public override string GetAlbumUrl (Album album)
		{
			string url = Uri.ToString();
			url = url.Remove (url.Length - script_name.Length, script_name.Length);

			string path = album.Name;

			url = url + path;
			url = url.Replace (" ", "+");
			return url;
		}
		public Image (Album album, string name) {
			Name = name;
			Owner = album;
		}
		public override int AddItem (Album album,
				     string path,
				     string filename,
				     string caption,
				     string description,
				     bool autorotate)
		{
			FormClient client = new FormClient (cookies);

			client.Add ("g2_form[cmd]", "add-item");
			client.Add ("g2_form[protocol_version]", "2.10");
			client.Add ("g2_form[set_albumName]", album.Name);
			client.Add ("g2_form[caption]", caption);
			client.Add ("g2_form[userfile_name]", filename);
			client.Add ("g2_form[force_filename]", filename);
			client.Add ("g2_form[auto_rotate]", autorotate ? "yes" : "no");
			client.Add ("g2_form[extrafield.Description]", description);
			client.Add ("g2_userfile", new FileInfo (path));
			client.expect_continue = expect_continue;
			AddG2Specific (client);

			return ParseAddItem (client.Submit (uri, Progress));
		}
Exemple #25
0
        public int CompareTo(Object obj)
        {
            Album other = obj as Album;

            int numThis = this.Parents.Count;
            int numOther = other.Parents.Count;
            int thisVal = -1, otherVal = -1;

            //find where they first differ
            int maxIters = Math.Min(numThis, numOther);
            int i        = 0;

            while (i < maxIters)
            {
                thisVal  = (int)this.Parents[i];
                otherVal = (int)other.Parents[i];
                if (thisVal != otherVal)
                {
                    break;
                }
                i++;
            }

            int retVal;

            if (i < numThis && i < numOther)
            {
                //Parentage differed
                retVal = thisVal.CompareTo(otherVal);
            }
            else if (i < numThis)
            {
                //other shorter
                thisVal = (int)this.Parents[i];
                retVal  = thisVal.CompareTo(other.RefNum);

                //if equal, we want to make the shorter one come first
                if (retVal == 0)
                {
                    retVal = 1;
                }
            }
            else if (i < numOther)
            {
                //this shorter
                otherVal = (int)other.Parents[i];
                retVal   = this.RefNum.CompareTo(otherVal);

                //if equal, we want to make the shorter one come first
                if (retVal == 0)
                {
                    retVal = -1;
                }
            }
            else
            {
                //children of the same parent
                retVal = this.RefNum.CompareTo(other.RefNum);
            }

            return(retVal);
        }