1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5
<title>TnyMimePartSaveStrategy</title>
6
<meta name="generator" content="DocBook XSL Stylesheets V1.71.0">
7
<link rel="start" href="index.html" title="Reference Manual of the tinymail framework">
8
<link rel="up" href="libtinymailui.html" title="libtinymailui - ui abstraction library">
9
<link rel="prev" href="libtinymail-tny-msg-window.html" title="TnyMsgWindow">
10
<link rel="next" href="libtinymail-tny-platform-factory.html" title="TnyPlatformFactory">
11
<meta name="generator" content="GTK-Doc V1.8 (XML mode)">
12
<link rel="stylesheet" href="style.css" type="text/css">
13
<link rel="preface" href="pr01.html" title="Introduction">
14
<link rel="reference" href="rn01.html" title="Object Index">
15
<link rel="reference" href="rn02.html" title="API Reference">
16
<link rel="chapter" href="libtinymail.html" title="libtinymail - main abstraction library">
17
<link rel="chapter" href="libtinymailui.html" title="libtinymailui - ui abstraction library">
18
<link rel="chapter" href="libtinymailui-gtk.html" title="libtinymailui-gtk - an optional ui implementation library">
19
<link rel="chapter" href="libtinymail-gnomevfs.html" title="libtinymail-gnomevfs - an optional implementation library">
20
<link rel="chapter" href="libtinymailui-mozembed.html" title="libtinymailui-mozembed - an optional ui implementation library">
21
<link rel="chapter" href="libtinymail-gnome-desktop.html" title="libtinymail-gnome-desktop - implementations for a gnome desktop">
22
<link rel="chapter" href="libtinymail-camel.html" title="libtinymail-camel - implementation of the main library">
23
<link rel="index" href="ix01.html" title="Index">
25
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
26
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
28
<td><a accesskey="p" href="libtinymail-tny-msg-window.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
29
<td><a accesskey="u" href="libtinymailui.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
30
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
31
<th width="100%" align="center">Reference Manual of the tinymail framework</th>
32
<td><a accesskey="n" href="libtinymail-tny-platform-factory.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
34
<tr><td colspan="5" class="shortcuts"><nobr><a href="#id2660911" class="shortcut">Top</a>
36
<a href="#id2661894" class="shortcut">Description</a>
38
<a href="#id2661824" class="shortcut">Object Hierarchy</a>
40
<a href="#id2661848" class="shortcut">Prerequisites</a>
42
<a href="#id2661871" class="shortcut">Known Implementations</a></nobr></td></tr>
44
<div class="refentry" lang="en">
45
<a name="libtinymail-tny-mime-part-save-strategy"></a><div class="titlepage"></div>
46
<div class="refnamediv"><table width="100%"><tr>
49
<a name="id2660911"></a><span class="refentrytitle">TnyMimePartSaveStrategy</span>
51
<p>TnyMimePartSaveStrategy — A strategy for saving a mime part</p>
53
<td valign="top" align="right"></td>
55
<div class="refsynopsisdiv">
57
<a name="TnyMimePartSaveStrategy"></a><pre class="synopsis">
61
<a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategy-struct">TnyMimePartSaveStrategy</a>;
62
<a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategyIface">TnyMimePartSaveStrategyIface</a>;
63
void <a href="libtinymail-tny-mime-part-save-strategy.html#tny-mime-part-save-strategy-perform-save">tny_mime_part_save_strategy_perform_save</a>
64
(<a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategy">TnyMimePartSaveStrategy</a> *self,
65
<a href="libtinymail-tny-mime-part.html#TnyMimePart">TnyMimePart</a> *part);
69
<div class="refsect1" lang="en">
70
<a name="id2661824"></a><h2>Object Hierarchy</h2>
71
<pre class="synopsis">
74
+----TnyMimePartSaveStrategy
77
<div class="refsect1" lang="en">
78
<a name="id2661848"></a><h2>Prerequisites</h2>
80
TnyMimePartSaveStrategy requires
83
<div class="refsect1" lang="en">
84
<a name="id2661871"></a><h2>Known Implementations</h2>
86
TnyMimePartSaveStrategy is implemented by
87
<a href="TnyGtkMimePartSaveStrategy.html" title="TnyGtkMimePartSaveStrategy">TnyGtkMimePartSaveStrategy</a>.</p>
89
<div class="refsect1" lang="en">
90
<a name="id2661894"></a><h2>Description</h2>
92
A type typically used by a <a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a> implementation for saving a <a href="libtinymail-tny-mime-part.html#TnyMimePart"><span class="type">TnyMimePart</span></a> or a <a href="libtinymail-tny-msg.html#TnyMsg"><span class="type">TnyMsg</span></a>
93
(which inherits from <a href="libtinymail-tny-mime-part.html#TnyMimePart"><span class="type">TnyMimePart</span></a>) to a file.
96
<div class="refsect1" lang="en">
97
<a name="id2661942"></a><h2>Details</h2>
98
<div class="refsect2" lang="en">
99
<a name="id2661952"></a><h3>
100
<a name="TnyMimePartSaveStrategy-struct"></a>TnyMimePartSaveStrategy</h3>
101
<a class="indexterm" name="id2661966"></a><pre class="programlisting">typedef struct _TnyMimePartSaveStrategy TnyMimePartSaveStrategy;</pre>
107
<div class="refsect2" lang="en">
108
<a name="id2661982"></a><h3>
109
<a name="TnyMimePartSaveStrategyIface"></a>TnyMimePartSaveStrategyIface</h3>
110
<a class="indexterm" name="id2661996"></a><pre class="programlisting">typedef struct {
111
GTypeInterface parent;
113
void (*perform_save_func) (TnyMimePartSaveStrategy *self, TnyMimePart *part);
114
} TnyMimePartSaveStrategyIface;
121
<div class="refsect2" lang="en">
122
<a name="id2662013"></a><h3>
123
<a name="tny-mime-part-save-strategy-perform-save"></a>tny_mime_part_save_strategy_perform_save ()</h3>
124
<a class="indexterm" name="id2662027"></a><pre class="programlisting">void tny_mime_part_save_strategy_perform_save
125
(<a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategy">TnyMimePartSaveStrategy</a> *self,
126
<a href="libtinymail-tny-mime-part.html#TnyMimePart">TnyMimePart</a> *part);</pre>
128
With <em class="parameter"><code>self</code></em> being a delegate of a <a href="libtinymail-tny-mime-part-saver.html#TnyMimePartSaver"><span class="type">TnyMimePartSaver</span></a>, this method performs the
129
saving of <em class="parameter"><code>part</code></em>.
132
A save strategy for a mime part is used with a type that implements the
133
<a href="libtinymail-tny-mime-part-saver.html#TnyMimePartSaver"><span class="type">TnyMimePartSaver</span></a> interface. Types that do, will often also implement the
134
<a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a> or <a href="libtinymail-tny-mime-part-view.html#TnyMimePartView"><span class="type">TnyMimePartView</span></a> interface (it's not a requirement). In this
135
case they say that the view has functionality for saving mime parts.
138
You can for example inherit an implementation of a <a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a>, like the
139
<a href="TnyGtkMsgView.html" title="TnyGtkMsgView"><span class="type">TnyGtkMsgView</span></a> one, and let yours also implement <a href="libtinymail-tny-mime-part-saver.html#TnyMimePartSaver"><span class="type">TnyMimePartSaver</span></a>. The
140
example shown here is for example such a situation.
145
<div class="informalexample"><pre class="programlisting">
147
tny_my_msg_view_save (TnyMimePartView *self_i, TnyMimePart *attachment)
149
TnyMyMsgView *self = TNY_MY_MSG_VIEW (self_i);
150
tny_mime_part_save_strategy_perform_save (self->mime_part_save_strategy, attachment);
156
Implementors: The idea is that devices can have specific strategies that can
157
be changed at runtime.
160
For example a strategy that sends it to another computer and/or a strategy
161
that saves it to a flash disk. Configurable at runtime by simply switching
162
the strategy property of a <a href="libtinymail-tny-mime-part-saver.html#TnyMimePartSaver"><span class="type">TnyMimePartSaver</span></a>.
165
The implementation shown in this example implements it using the gtk+ toolkit.
166
If your device doesn't support saving mime parts, saving a mime part can also
167
be implemented by doing nothing. For example a <span class="type">TnyMyDoNothingSaveStrategy</span>.
168
Maybe you will implement it by letting it contact a service and sending the
169
mime part to it? It's up to you.
174
<div class="informalexample"><pre class="programlisting">
176
tny_gtk_mime_part_save_strategy_perform_save (TnyMimePartSaveStrategy *self, TnyMimePart *part)
178
GtkFileChooserDialog *dialog;
179
dialog = GTK_FILE_CHOOSER_DIALOG
180
(gtk_file_chooser_dialog_new (_("MimePartSave File"), NULL,
181
GTK_FILE_CHOOSER_ACTION_MIME_PART_SAVE,
182
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_MIME_PART_SAVE,
183
GTK_RESPONSE_ACCEPT, NULL));
184
gtk_file_chooser_set_current_name (dialog,
185
tny_mime_part_get_filename (part));
186
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
189
uri = gtk_file_chooser_get_filename (dialog);
190
fd = open (uri, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
192
TnyStream *stream = tny_fs_stream_new (fd);
193
tny_mime_part_decode_to_stream (part, TNY_STREAM (stream));
194
g_object_unref (G_OBJECT (stream));
197
gtk_widget_destroy (GTK_WIDGET (dialog));
203
The method is typically called by the implementation of a <a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a>.
204
For example a clicked handler of a popup menu of a attachment view in your
205
<a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a> implementation.
208
Note that a mime part can mean both the entire message (without its headers)
209
and one individual mime part in such a message or a message in a message (in
210
case of a messge/rfc822 mime part).
213
A <a href="libtinymail-tny-msg.html#TnyMsg"><span class="type">TnyMsg</span></a> inherits from <a href="libtinymail-tny-mime-part.html#TnyMimePart"><span class="type">TnyMimePart</span></a> which means that if you use the message
214
instance with a <a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategy"><span class="type">TnyMimePartSaveStrategy</span></a> instance that the strategy for
215
saving it must save the entire message. Whereas when you pass it just one
216
individual mime part instance, the strategy must save only that part.</p>
220
<div class="variablelist"><table border="0">
221
<col align="left" valign="top">
224
<td><span class="term"><em class="parameter"><code>self</code></em> :</span></td>
225
<td> A <a href="libtinymail-tny-mime-part-save-strategy.html#TnyMimePartSaveStrategy"><span class="type">TnyMimePartSaveStrategy</span></a> instance
229
<td><span class="term"><em class="parameter"><code>part</code></em> :</span></td>
230
<td> The <a href="libtinymail-tny-mime-part.html#TnyMimePart"><span class="type">TnyMimePart</span></a> instance that must be saved
237
<div class="refsect1" lang="en">
238
<a name="id2662342"></a><h2>See Also</h2>
240
<a href="libtinymail-tny-msg-view.html#TnyMsgView"><span class="type">TnyMsgView</span></a>, <a href="libtinymail-tny-mime-part.html#TnyMimePart"><span class="type">TnyMimePart</span></a>, <a href="libtinymail-tny-msg.html#TnyMsg"><span class="type">TnyMsg</span></a>