outdated: This has been implemented
Attachment & mime-part views
Note: this has been implemented
The idea & concept
The idea is to extract viewing the attachment from the message view component. At this moment the only support for viewing an attachment is in libtinymailui-gtk a gtktreemodel implementation that can be loaded with mime-parts.
Some mime-part views, however, require more flexibility. Examples are viewing PGP mime-parts and more importantly viewing ".ics" attachments (calendar and todo items being sent to your E-mail address).
Such an attachment viewer could, if registered with a message view, integrate with an application like Dates. For example the functionality to optionally transfer the calendar/todo item via libecal to an application like Dates.
The current idea is to make it possible to register zero or more attachment or mime-part viewers to one message view instance.
Class diagram and clarification
void TnyMsgView::register_mime_part_view (TnyMimePartView *view) gchar * TnyMimePartView::get_supported_content_type (); gchar * TnyMimePartView::get_supported_fileext(); void TnyMimePartView::view_mime_part (TnyMimePart *mime_part);
+-------------------------------------------------+
| TnyMsgView | <- implements -- [TnyGtkHTMLMsgView] (inherits from TnyGtkMsgView)
+-------------------------------------------------+ <- implements -- [TnyMozEmbedMsgView] (inherits from TnyGtkMsgView)
| + register_mime_part_view(view:TnyMimePartView) | <- implements -- [TnyGtkMsgView]
| ... |
+-------------------------------------------------+
| |
| | ----- uses
| `---+
.--+ |
| \ /
| +-----------'------------------------------+
| | TnyMimePartView |
| +------------------------------------------+ <- implements -- [TnyFileAttachmentMimePartView]
| | + get_supported_content_type():string | <- implements -- [TnyICSMimePartView]
| | + get_supported_fileext():string | <- implements -- [TnyICSMimePartView]
| | + view_mime_part (part:TnyMimePart):void | <- implements -- [TnyPGPMimePartView]
| | + set_save_strategy (st:TnySaveStrategy) |
| +------------------------------------------+
| |
| --- uses | ----- uses
| `---+
`---+ |
| |
\ / \ /
+---'-------------'--------------+
| TnySaveStrategy |
+--------------------------------+ <- implements -- [TnyGtkSaveStrategy]
| save_mime_part (p:TnyMimePart) | <- implements -- [TnyMaemoSaveStrategy]
+--------------------------------+
Sample code, how it will look like
void
tny_msg_view_register_mime_part_view (TnyMsgView *self, TnyMimePartView *pview)
{
tny_list_prepend (mimepartviews, pview);
}
void
tny_msg_view_set_msg (TnyMsgView *self, TnyMsg *msg)
{
...
foreach mimepart in msg
tny_list_foreach (mimepartviews, foreach_mpvw, mimepart);
...
}
static void
foreach_mpvw (TnyMimePartView *view, TnyMimePart *part)
{
gchar *filext = getfileext (tny_mime_part_get_filename (part));
if (strcmp (filext, tny_mime_part_view_get_supported_fileext(view) == 0)
{
tny_mime_part_view_view_mime_part (view, mimepart);
g_free (filext);
return;
}
g_free (filext);
if (tny_mime_part_content_type_is (part,
tny_mime_part_view_get_supported_content_type (view)))
{
tny_mime_part_view_view_mime_part (view, mimepart);
return;
}
}
Discussion
This is a mailing list discussion about this subject. Feel free to join if you would like to discuss ideas.
