public string Upload(IBrowsableItem photo, IFilter filter, bool is_public, bool is_family, bool is_friend)
    {
        if (token == null)
        {
            throw new Exception("Must Login First");
        }
        // FIXME flickr needs rotation
        string error_verbose;

        using (FilterRequest request = new FilterRequest(photo.DefaultVersionUri)) {
            try {
                string tags = null;


                filter.Convert(request);
                string path = request.Current.LocalPath;

                if (ExportTags && photo.Tags != null)
                {
                    StringBuilder taglist = new StringBuilder();
                    Tag []        t       = photo.Tags;

                    for (int i = 0; i < t.Length; i++)
                    {
                        if (i > 0)
                        {
                            taglist.Append(",");
                        }

                        taglist.Append(String.Format("\"{0}\"", t[i].Name));
                    }

                    tags = taglist.ToString();
                }
                try {
                    string photoid =
                        flickr.UploadPicture(path, photo.Name, photo.Description, tags, is_public, is_family, is_friend);
                    return(photoid);
                } catch (FlickrNet.FlickrException ex) {
                    Console.WriteLine("Problems uploading picture: " + ex.ToString());
                    error_verbose = ex.ToString();
                }
            } catch (Exception e) {
                // FIXME we need to distinguish between file IO errors and xml errors here
                throw new System.Exception("Error while uploading", e);
            }
        }

        throw new System.Exception(error_verbose);
    }
Esempio n. 2
0
        protected override void OnActivated()
        {
            try {
                if (!item.IsValid)
                {
                    throw new ApplicationException("attempt to filter invalid item");
                }

                using (FilterRequest req = new FilterRequest(item.Current.DefaultVersionUri)) {
                    IFilter filter = BuildFilter();
                    if (filter.Convert(req))
                    {
                        // The filter did something so lets ve
                        EditTarget target = new EditTarget(item);

                        Gnome.Vfs.Result result = Gnome.Vfs.Result.Ok;
                        result = Gnome.Vfs.Xfer.XferUri(new Gnome.Vfs.Uri(req.Current.ToString()),
                                                        new Gnome.Vfs.Uri(target.Uri.ToString()),
                                                        Gnome.Vfs.XferOptions.Default,
                                                        Gnome.Vfs.XferErrorMode.Abort,
                                                        Gnome.Vfs.XferOverwriteMode.Replace,
                                                        delegate {
                            System.Console.WriteLine("progress");
                            return(1);
                        });

                        if (result == Gnome.Vfs.Result.Ok)
                        {
                            System.Console.WriteLine("Done modifying image");
                            target.Commit();
                        }
                        else
                        {
                            target.Delete();
                            throw new ApplicationException(String.Format(
                                                               "{0}: error moving to destination {1}",
                                                               this, target.ToString()));
                        }
                    }
                }
            } catch (Exception e) {
                Dialog d = new EditExceptionDialog(null, e, item.Current);
                d.Show();
                d.Run();
                d.Destroy();
            }
        }
Esempio n. 3
0
        public string Upload(IPhoto photo, IFilter filter, bool is_public, bool is_family, bool is_friend)
        {
            if (token == null) {
            throw new Exception ("Must Login First");
            }
            // FIXME flickr needs rotation
            string  error_verbose;

            using (FilterRequest request = new FilterRequest (photo.DefaultVersion.Uri)) {

            try {
                string tags = null;

                filter.Convert (request);
                string path = request.Current.LocalPath;

                if (ExportTags && photo.Tags != null) {
                    StringBuilder taglist = new StringBuilder ();
                    FSpot.Core.Tag [] t = photo.Tags;
                    FSpot.Core.Tag tag_iter = null;

                    for (int i = 0; i < t.Length; i++) {
                        if (i > 0)
                            taglist.Append (",");

                        taglist.Append (String.Format ("\"{0}\"", t[i].Name));

                        // Go through the tag parents
                        if (ExportTagHierarchy) {
                            tag_iter = t[i].Category;
                            while (tag_iter != App.Instance.Database.Tags.RootCategory && tag_iter != null) {
                                // Skip top level tags because they have no meaning in a linear tag database
                                if (ExportIgnoreTopLevel && tag_iter.Category == App.Instance.Database.Tags.RootCategory) {
                                    break;
                                }

                                // FIXME Look if the tag is already there!
                                taglist.Append (",");
                                taglist.Append (String.Format ("\"{0}\"", tag_iter.Name));
                                tag_iter = tag_iter.Category;
                            }
                        }

                    }

                    tags = taglist.ToString ();
                }
                try {
                    string photoid =
                        flickr.UploadPicture (path, photo.Name, photo.Description, tags, is_public, is_family, is_friend);
                    return photoid;
                } catch (FlickrNet.FlickrException ex) {
                    Log.Error ("Problems uploading picture: " + ex.ToString());
                    error_verbose = ex.ToString();
                }
            } catch (Exception e) {
                // FIXME we need to distinguish between file IO errors and xml errors here
                throw new System.Exception ("Error while uploading", e);
            }
            }

            throw new System.Exception (error_verbose);
        }
Esempio n. 4
0
        public string Upload(IPhoto photo, IFilter filter, bool is_public, bool is_family, bool is_friend)
        {
            if (token == null)
            {
                throw new Exception("Must Login First");
            }
            // FIXME flickr needs rotation
            string error_verbose;

            using (FilterRequest request = new FilterRequest(photo.DefaultVersion.Uri)) {
                try {
                    string tags = null;

                    filter.Convert(request);
                    string path = request.Current.LocalPath;

                    if (ExportTags && photo.Tags != null)
                    {
                        StringBuilder     taglist  = new StringBuilder();
                        FSpot.Core.Tag [] t        = photo.Tags;
                        FSpot.Core.Tag    tag_iter = null;

                        for (int i = 0; i < t.Length; i++)
                        {
                            if (i > 0)
                            {
                                taglist.Append(",");
                            }

                            taglist.Append(String.Format("\"{0}\"", t[i].Name));

                            // Go through the tag parents
                            if (ExportTagHierarchy)
                            {
                                tag_iter = t[i].Category;
                                while (tag_iter != App.Instance.Database.Tags.RootCategory && tag_iter != null)
                                {
                                    // Skip top level tags because they have no meaning in a linear tag database
                                    if (ExportIgnoreTopLevel && tag_iter.Category == App.Instance.Database.Tags.RootCategory)
                                    {
                                        break;
                                    }

                                    // FIXME Look if the tag is already there!
                                    taglist.Append(",");
                                    taglist.Append(String.Format("\"{0}\"", tag_iter.Name));
                                    tag_iter = tag_iter.Category;
                                }
                            }
                        }

                        tags = taglist.ToString();
                    }
                    try {
                        string photoid =
                            flickr.UploadPicture(path, photo.Name, photo.Description, tags, is_public, is_family, is_friend);
                        return(photoid);
                    } catch (FlickrNet.FlickrException ex) {
                        Log.Error("Problems uploading picture: " + ex.ToString());
                        error_verbose = ex.ToString();
                    }
                } catch (Exception e) {
                    // FIXME we need to distinguish between file IO errors and xml errors here
                    throw new System.Exception("Error while uploading", e);
                }
            }

            throw new System.Exception(error_verbose);
        }
Esempio n. 5
0
        private void useFilter(IFilter filter)
        {
            PictureForm activeChild = (PictureForm)this.ActiveMdiChild;

            filter.setImage(activeChild.bitmap);

            if (filter.hasDialog)
                if (!filter.showDialog())
                    return;

            filter.Convert();

            activeChild.refresh();
        }
	public string Upload (IBrowsableItem photo, IFilter filter, bool is_public, bool is_family, bool is_friend)
	{
		if (token == null) {            
			throw new Exception ("Must Login First");
		}
		// FIXME flickr needs rotation
		string  error_verbose;
		
		using (FilterRequest request = new FilterRequest (photo.DefaultVersionUri)) {
			
			try {            
				string tags = null;
				

				filter.Convert (request);
				string path = request.Current.LocalPath;
				
				if (ExportTags && photo.Tags != null) {
					StringBuilder taglist = new StringBuilder ();
					Tag [] t = photo.Tags;
					
					for (int i = 0; i < t.Length; i++) {
						if (i > 0)
							taglist.Append (",");
						
						taglist.Append (String.Format ("\"{0}\"", t[i].Name));
					}
					
					tags = taglist.ToString ();
				}
				try {
					string photoid = 
						flickr.UploadPicture (path, photo.Name, photo.Description, tags, is_public, is_family, is_friend);
					return photoid;
				} catch (FlickrNet.FlickrException ex) {
					Console.WriteLine ("Problems uploading picture: " + ex.ToString());
					error_verbose = ex.ToString();
				}
			} catch (Exception e) {
				// FIXME we need to distinguish between file IO errors and xml errors here
				throw new System.Exception ("Error while uploading", e);
			}
		}
			
		throw new System.Exception (error_verbose);
	}