A send-queue type
- From: Philip Van Hoof <spam pvanhoof be>
- To: tinymail-devel-list gnome org
- Subject: A send-queue type
- Date: Thu, 09 Nov 2006 00:20:57 +0100
There was a desire to have a type that defines the role of a send queue.
A few design questions for the group
E-mail applications often have to support multiple send accounts. The
user typically selects per message which send account is going to be
used.
o. My opinion is that mobile users don't care about it, and want the
software to auto detect which send account should be used
o. Nevertheless, should the send queue register per message being send
which send account to use?
o. Or should such a send queue play send queue for one specific send
account (so that you have more than one send queue if you have more than
one send account) (I favor this one)
o. If option three, should there be a TnySendQueueGroup type too? One
that can classify between the available TnySendQueues which one to use
in case the user (or developer) selected "auto detect it for me". In
this case would the detecting code be implemented in the
TnySendQueueGroup type (or a TnySendQueueClassifyer if you prefer that
name).
The API in case of option three and four is like this:
interface TnySendQueue
{
Event on_msg_sent
void add (TnyMsg msg);
}
In design pattern - correct OO code it looks like this:
interface ObservableSubject
{
void subscribe (Observer o);
void unsubscribe (Observer o);
void notify ();
}
interface Observer
{
void update ();
}
interface TnySendQueue : ObservableSubject
{
void add (TnyMsg msg);
}
public class TnyMySendQueue : TnySendQueue
{
private List observers;
private List messages;
public void subscribe (Observer o)
{
observers.add (o)
}
public void unsubscribe (Observer o)
{
observers.remove (o)
}
private void thread_start ()
{
while (messages.Count > 0)
{
lock messages
msg = messages.Current
unlock messages
send (msg)
this.notify()
lock messages
messages.RemoveCurrent
unlock messages
}
}
public void add (TnyMsg msg)
{
if a thread isn't runnig
start a thread
lock messages
messages.add (msg)
unlock messages
}
public void notify ()
{
foreach observer o in observers
do
o.update ()
done
}
}
Opinions? Thoughts?
--
Philip Van Hoof, software developer at x-tend
home: me at pvanhoof dot be
gnome: pvanhoof at gnome dot org
work: vanhoof at x-tend dot be
http://www.pvanhoof.be - http://www.x-tend.be
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]