Re: Oh no! Philip is on crack again!



This is the kind of API that I have in mind


public class MyMessageView () : Tny.Gtk.MessageView 
{
	Folder model = null;
	TextBox text = new TextBox ();
	Button cancel = new Button ();
	GIO.Cancellable cancellable = new GIO.Cancellable ();
	ProgressBar progressbar = new ProgressBar ();

	public MyMessageView () {
		cancel.Clicked += new EventHandler (OnCancelPressed);
	}

	public void OnCancelPressed (Object sender, EventArgs args) {
		cancellable.Cancel ();
	}


	public void OnStatusProgression (Status status)
	{
		progressbar.Position = status.Position;
	}

	public void OnDecodeDone (GIO.AsyncResult result)
	{
		OutputStream s = result.Stream;
		text.Text (s.ToString ());
	}

	public Message Model {
		get {
			return this.model;
		}

		set {
			foreach (MimePart part in value) {
				if (part.ContentType == "text/plain") {
					OutputStream s = new TextBoxOutputStream ();
					part.DecodeToStream (s, cancellable, OnStatusProgression, OnDecodeDone);
				}
			}

			this.model = value;
		}
	}	
}

public class Application : Gtk.Window 
{
	MessageContainerStoreView folders_view = Tny.Gtk.MessageContainerStoreView ();
	MessageContainerView folder_view = Tny.Gtk.MessageContainerView ();
	MessageView message_view = new MyMessageView ();
	Gtk.Box hbox new Gtk.HBox (), vbox = new Gtk.VBox ();

	public class Application () : super (Gtk.Window.Toplevel) 
	{
		Add (vbox);
		vbox.Add (folders_view);
		vbox.Add (hbox)
		hbox.Add (folder_view);
		hbox.Add (message_view);

		folders_view.OnContainerStoreSelected += new EventHandler (OnFolderSelected);
		folder_view.OnMessageSelected += new EventHandler (OnmessageSelected);
	}

	public void OnFolderSelected (Object sender, EventArgs args) 
	{
		folder_view.Model = folder;
		folder.Refresh ();
	}

	public void OnMessageSelected (Object sender, EventArgs args) 
	{
		Folder folder = folder_view.Model;
		Message message = folder_view.SelectedMessage;

		message_view.Model = message;
	}
}


On Mon, 2008-03-24 at 00:22 +0100, Philip Van Hoof wrote:
> A sample Tinymail 2.0 API ...
> 
> So this is a mockup of what I have in mind ... at a very high level:
> 
> So this is zooming out at big-city/country size.
> 
> Indeed, Header is gone. That should be an implementation detail of
> Message. And I also think that this would be doable too. A year ago or
> so me and Dirk-Jan where discussing this, and it was his idea to simply
> get rid of Header and make it an implementation detail of Message.
> 
> 
> Some pointers:
> 
> http://svn.gnome.org/viewvc/libgee/trunk/gee/collection.vala
> http://svn.gnome.org/viewvc/libgee/trunk/gee/iterable.vala
> http://svn.gnome.org/viewvc/libgee/trunk/gee/iterator.vala
> http://svn.gnome.org/viewvc/glib/trunk/gio/ginputstream.h
> http://svn.gnome.org/viewvc/glib/trunk/gio/goutputstream.h
> http://svn.gnome.org/viewvc/glib/trunk/gio/gcancellable.h
> http://svn.gnome.org/viewvc/glib/trunk/gio/gasyncresult.h
> 
> 
> namespace TinyMail {
> 
> 	public class MimePart: Gee.Iterable <MimePart> {
> 		string Filename { get; }
> 		string Description { get; }
> 		string ContentId { get; }
> 		string ContentType { get; }
> 		gboolean IsAttachment { get; }
> 
> 		void DecodeToStream (GIO.OutputStream stream);
> 		void DecodeToStreamAsync (GIO.OutputStream stream, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 	}
> 
> 	public class WritableMimePart: MimePart, Gee.Collection <MimePart> {
> 		void SetFilename (string filename);
> 		void SetDescription (string desc);
> 		void SetContentId (string contentid);
> 		void SetContentType (string type);
> 
> 		// Note: adding and removing parts is API in Gee.Collection
> 
> 		void Construct (GIO.InputStream stream, string mimetype, string transferencoding);
> 	}
> 
> 	public class WritableMessage: Message, WritableMimePart {
> 		void SetFrom (string str);
> 		void SetTo (string str);
> 		void SetCc (string str);
> 		...
> 	}
> 
> 	public interface Message: MimePart {
> 		string From { get; }
> 		string To { get; }
> 		string Cc { get; }
> 		...
> 	}
> 
> 	private class MessageIterator: Gee.Iterator <Message> {
> 	}
> 
> 	public class MessageContainerChangeSet {
> 		GetAdded (Gee.Collection <Message> list);
> 		GetRemoved (Gee.Collection <Message> list);
> 	}
> 
> 	public interface MessageContainer: Gee.Iterable <Message> {
> 		signal void Changed (MessageContainerChangeSet change_set);
> 	}
> 
> 	public abstract class SearchResult: MessageContainer {
> 	}
> 
> 	public abstract class Folder: MessageContainer, Gee.Collection <Message> {
> 		void SyncronizeAsync (GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 		void RefreshAsync (GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 
> 		void AddAsync (Message message, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 		void RemoveAsync (Gee.List <Message> messages, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 		void TransferAsync (Gee.List <Message> messages, Folder target, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 		void CopyAsync (Gee.List <Message> messages, FolderStore target, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 	}
> 
> 	public interface MessageContainerStore {
> 		signal void Changed (MessageContainerStoreChangeSet change_set);
> 	}
> 
> 	public class MessageContainerRename {
> 		string From { get; }
> 		MessageContainer To { get; }
> 	}
> 
> 	public class MessageContainerStoreChangeSet {
> 		void GetAdded (Gee.Collection <MessageContainer> list);
> 		void GetRemoved (Gee.Collection <MessageContainer> list);
> 		void GetRenamed (Gee.Collection <MessageContainerRename> list);
> 	}
> 
> 	public interface FolderStore: MessageContainerStore {
> 		void GetFoldersAsync (Gee.Container list, GIO.Cancellable cancel, GIO.AsyncReadyCallback callback);
> 	}
> 
> 	public interface PasswordRequester {
> 		string RequestPassword ();
> 		void ForgetIncorrectPassword ();
> 	}
> 
> 	public interface Account: PasswordRequester {
> 		string Name { get; set; }
> 		string Proto { get; set; }
> 		string User { get; set; }
> 		string Host { get; set; }
> 		int port { get; set; }
> 		string AuthMech { get; set; }
> 		string UrlString { get; set; }
> 	}
> 
> 	public class Query {
> 		public ArrayList InFolders;
> 		public string Subject;
> 		public string From;
> 		public string To;
> 		public string Cc;
> 		public string Bcc;
> 		public time_t Sent;
> 		public time_t Received;
> 	}
> 
> 	public interface StoreAccount: FolderStore {
> 		SearchResult Find (Query query);
> 	}
> 
> 
> 	public interface TransportAccount {
> 		void Send (Message message);
> 	}
> 
> 	public interface SendQueue {
> 		Folder Outbox { get; }
> 		Folder Sentbox { get; }
> 	}
> }
> 
> 
-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]