File: AttachmentEdit_8C-source.html

package info (click to toggle)
witty 3.1.2-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 45,512 kB
  • ctags: 35,832
  • sloc: cpp: 69,469; ansic: 66,945; xml: 4,383; sh: 594; perl: 108; makefile: 106
file content (209 lines) | stat: -rw-r--r-- 32,610 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Wt examples: /home/koen/project/wt/public-git/wt/examples/composer/AttachmentEdit.C Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<h1>/home/koen/project/wt/public-git/wt/examples/composer/AttachmentEdit.C</h1><a href="AttachmentEdit_8C.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> * See the LICENSE file for terms of use.</span>
<a name="l00005"></a>00005 <span class="comment"> */</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;sys/stat.h&gt;</span>
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef WIN32</span>
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00011"></a>00011 <span class="preprocessor">#endif</span>
<a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/lexical_cast.hpp&gt;</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;Wt/WApplication&gt;</span>
<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;Wt/WCheckBox&gt;</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;Wt/WText&gt;</span>
<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;Wt/WFileUpload&gt;</span>
<a name="l00020"></a>00020 
<a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="Attachment_8h.html">Attachment.h</a>"</span>
<a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="AttachmentEdit_8h.html">AttachmentEdit.h</a>"</span>
<a name="l00023"></a>00023 <span class="preprocessor">#include "<a class="code" href="Composer_8h.html">Composer.h</a>"</span>
<a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="Option_8h.html">Option.h</a>"</span>
<a name="l00025"></a>00025 
<a name="l00026"></a><a class="code" href="classAttachmentEdit.html#edd19941ecf64ef030eaa164eb34b85a">00026</a> <a class="code" href="classAttachmentEdit.html#edd19941ecf64ef030eaa164eb34b85a" title="Create an attachment edit field.">AttachmentEdit::AttachmentEdit</a>(<a class="code" href="classComposer.html" title="An E-mail composer widget.">Composer</a> *composer, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a> *parent)
<a name="l00027"></a>00027   : <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WContainerWidget.html">WContainerWidget</a>(parent),
<a name="l00028"></a>00028     composer_(composer),
<a name="l00029"></a>00029     uploadDone_(this),
<a name="l00030"></a>00030     uploadFailed_(false),
<a name="l00031"></a>00031     taken_(false)
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033   <span class="comment">/*</span>
<a name="l00034"></a>00034 <span class="comment">   * The file upload itself.</span>
<a name="l00035"></a>00035 <span class="comment">   */</span>
<a name="l00036"></a>00036   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html">WFileUpload</a>(<span class="keyword">this</span>);
<a name="l00037"></a>00037   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#c7ad1324c86d378da9da9740a631a662">setFileTextSize</a>(40);
<a name="l00038"></a>00038 
<a name="l00039"></a>00039   <span class="comment">/*</span>
<a name="l00040"></a>00040 <span class="comment">   * The 'remove' option.</span>
<a name="l00041"></a>00041 <span class="comment">   */</span>
<a name="l00042"></a>00042   <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a> = <span class="keyword">new</span> <a class="code" href="classOption.html" title="A clickable option.">Option</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#a651f107ec7cf080faef6c435705fc44">tr</a>(<span class="stringliteral">"msg.remove"</span>), <span class="keyword">this</span>);
<a name="l00043"></a>00043   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#ee0157eb927635094425c6f91cc7bd16">decorationStyle</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WCssDecorationStyle.html#5e552350f0955212ea237994a98638dc">font</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFont.html#d449c8c5c3b78e66d51fe6db0c0b9d58">setSize</a>(WFont::Smaller);
<a name="l00044"></a>00044   <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#07719d06da0dd17af2381c663e8fb0b7">setMargin</a>(5, <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#5a6f4636bcc6ab3c075165d249b3a5a36568fecac7c7d7223afaed240bcfdd9e">Left</a>);
<a name="l00045"></a>00045   <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a>-&gt;<a class="code" href="classOption.html#31cd766f28605ceba53642d7d4e68c9e" title="Returns the clickable part.">item</a>()-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WInteractWidget.html#e11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(SLOT(<span class="keyword">this</span>, WWidget::hide));
<a name="l00046"></a>00046   <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a>-&gt;<a class="code" href="classOption.html#31cd766f28605ceba53642d7d4e68c9e" title="Returns the clickable part.">item</a>()-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WInteractWidget.html#e11e050cce0d4a8f742afa3ef92bfe8c">clicked</a>().connect(SLOT(<span class="keyword">this</span>, <a class="code" href="classAttachmentEdit.html#27277be62832ebbda987707b7a2d814e" title="Slot triggered when the users wishes to remove this attachment edit.">AttachmentEdit::remove</a>));
<a name="l00047"></a>00047 
<a name="l00048"></a>00048   <span class="comment">/*</span>
<a name="l00049"></a>00049 <span class="comment">   * Fields that will display the feedback.</span>
<a name="l00050"></a>00050 <span class="comment">   */</span>
<a name="l00051"></a>00051 
<a name="l00052"></a>00052   <span class="comment">// The check box to include or exclude the attachment.</span>
<a name="l00053"></a>00053   <a class="code" href="classAttachmentEdit.html#ca36a743220d5663d340840cdb38f7ce" title="The check box to keep or discard the uploaded file.">keep_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WCheckBox.html">WCheckBox</a>(<span class="keyword">this</span>);
<a name="l00054"></a>00054   <a class="code" href="classAttachmentEdit.html#ca36a743220d5663d340840cdb38f7ce" title="The check box to keep or discard the uploaded file.">keep_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#0825c3ccbd4999afc1a88fafa6aa6fc7">hide</a>();
<a name="l00055"></a>00055 
<a name="l00056"></a>00056   <span class="comment">// The uploaded file information.</span>
<a name="l00057"></a>00057   <a class="code" href="classAttachmentEdit.html#ce5c155b8749314f50ca2ba4a46c6e56" title="The text describing the uploaded file.">uploaded_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">""</span>, <span class="keyword">this</span>);
<a name="l00058"></a>00058   <a class="code" href="classAttachmentEdit.html#ce5c155b8749314f50ca2ba4a46c6e56" title="The text describing the uploaded file.">uploaded_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#6fd43dced1a62f7e79bc3522eeb16216">setStyleClass</a>(<span class="stringliteral">"option"</span>);
<a name="l00059"></a>00059   <a class="code" href="classAttachmentEdit.html#ce5c155b8749314f50ca2ba4a46c6e56" title="The text describing the uploaded file.">uploaded_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#0825c3ccbd4999afc1a88fafa6aa6fc7">hide</a>();
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   <span class="comment">// The error message.</span>
<a name="l00062"></a>00062   <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a> = <span class="keyword">new</span> <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html">WText</a>(<span class="stringliteral">""</span>, <span class="keyword">this</span>);
<a name="l00063"></a>00063   <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#6fd43dced1a62f7e79bc3522eeb16216">setStyleClass</a>(<span class="stringliteral">"error"</span>);
<a name="l00064"></a>00064   <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#07719d06da0dd17af2381c663e8fb0b7">setMargin</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WLength.html">WLength</a>(5), <a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/namespaceWt.html#5a6f4636bcc6ab3c075165d249b3a5a36568fecac7c7d7223afaed240bcfdd9e">Left</a>);
<a name="l00065"></a>00065 
<a name="l00066"></a>00066   <span class="comment">/*</span>
<a name="l00067"></a>00067 <span class="comment">   * React to events.</span>
<a name="l00068"></a>00068 <span class="comment">   */</span>
<a name="l00069"></a>00069 
<a name="l00070"></a>00070   <span class="comment">// Try to catch the fileupload change signal to trigger an upload.</span>
<a name="l00071"></a>00071   <span class="comment">// We could do like google and at a delay with a WTimer as well...</span>
<a name="l00072"></a>00072   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#3abaf94bdba04e7833aa18bc7e8d0f40">changed</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1EventSignal.html#6efcb92576b5aa846a3354dd26918a9f">connect</a>(SLOT(<a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>, WFileUpload::upload));
<a name="l00073"></a>00073 
<a name="l00074"></a>00074   <span class="comment">// React to a succesfull upload.</span>
<a name="l00075"></a>00075   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#acb4622c8cd83d1635a8c0db13c8c0fe">uploaded</a>().<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1EventSignal.html#6efcb92576b5aa846a3354dd26918a9f">connect</a>(SLOT(<span class="keyword">this</span>, <a class="code" href="classAttachmentEdit.html#85d6892fe9c38394d17dc350ce678acd" title="Slot triggered when the WFileUpload completed an upload.">AttachmentEdit::uploaded</a>));
<a name="l00076"></a>00076 
<a name="l00077"></a>00077   <span class="comment">// React to a fileupload problem.</span>
<a name="l00078"></a>00078   <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#29dc78a0162c676f7b72904d595440d8">fileTooLarge</a>().connect(SLOT(<span class="keyword">this</span>, <a class="code" href="classAttachmentEdit.html#9f7b53df9b2342f38984832f1d2430eb" title="Slot triggered when the WFileUpload received an oversized file.">AttachmentEdit::fileTooLarge</a>));
<a name="l00079"></a>00079 
<a name="l00080"></a>00080   <span class="comment">/*</span>
<a name="l00081"></a>00081 <span class="comment">   * Connect the uploadDone signal to the Composer's attachmentDone,</span>
<a name="l00082"></a>00082 <span class="comment">   * so that the Composer can keep track of attachment upload progress,</span>
<a name="l00083"></a>00083 <span class="comment">   * if it wishes.</span>
<a name="l00084"></a>00084 <span class="comment">   */</span>
<a name="l00085"></a>00085   <a class="code" href="classAttachmentEdit.html#24ee0aca670036a7491a1c0114188cc7">uploadDone_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#6fc9536d2e7f59684ec32f3734b01f38">connect</a>(SLOT(composer, <a class="code" href="classComposer.html#aa2db4aef750f6533c53af1189c92144" title="Slotcalled when an attachment has been uploaded.">Composer::attachmentDone</a>));
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a><a class="code" href="classAttachmentEdit.html#6f3f515115ee196e625766400180d4b4">00088</a> <a class="code" href="classAttachmentEdit.html#6f3f515115ee196e625766400180d4b4">AttachmentEdit::~AttachmentEdit</a>()
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090   <span class="comment">// delete the local attachment file copy, if it was not taken from us.</span>
<a name="l00091"></a>00091   <span class="keywordflow">if</span> (!<a class="code" href="classAttachmentEdit.html#3b94f0070aa893cbae3459f2a930bc09" title="Whether the spool file is &amp;quot;taken&amp;quot; and is no longer managed by the edit...">taken_</a>)
<a name="l00092"></a>00092     unlink(<a class="code" href="classAttachmentEdit.html#86af04b8e5ebcdf2bdbd94a92847e6da" title="The filename of the local spool file.">spoolFileName_</a>.c_str());
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094 
<a name="l00095"></a><a class="code" href="classAttachmentEdit.html#172fff67913dc3e3adf8c1e4198d6ea6">00095</a> <span class="keywordtype">bool</span> <a class="code" href="classAttachmentEdit.html#172fff67913dc3e3adf8c1e4198d6ea6" title="Update the file now.">AttachmentEdit::uploadNow</a>()
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097   <span class="comment">/*</span>
<a name="l00098"></a>00098 <span class="comment">   * See if this attachment still needs to be uploaded,</span>
<a name="l00099"></a>00099 <span class="comment">   * and return if a new asynchronous upload is started.</span>
<a name="l00100"></a>00100 <span class="comment">   */</span>
<a name="l00101"></a>00101   <span class="keywordflow">if</span> (<a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>) {
<a name="l00102"></a>00102     <span class="keywordflow">if</span> (<a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#66376fb4668a037760a91abad9f83f8a">canUpload</a>()) {
<a name="l00103"></a>00103       <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#c17094f2fd6ae8cac1035161f7d80b9c">upload</a>();
<a name="l00104"></a>00104       <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00105"></a>00105     } <span class="keywordflow">else</span>
<a name="l00106"></a>00106       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00107"></a>00107   } <span class="keywordflow">else</span>
<a name="l00108"></a>00108     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110 
<a name="l00111"></a><a class="code" href="classAttachmentEdit.html#85d6892fe9c38394d17dc350ce678acd">00111</a> <span class="keywordtype">void</span> <a class="code" href="classAttachmentEdit.html#85d6892fe9c38394d17dc350ce678acd" title="Slot triggered when the WFileUpload completed an upload.">AttachmentEdit::uploaded</a>()
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113   <span class="keywordflow">if</span> (!<a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#4207ca5ea74962583d146409301c3416">emptyFileName</a>()) {
<a name="l00114"></a>00114     <a class="code" href="classAttachmentEdit.html#06536f7028735943c69325ebe33eec82" title="The filename of the uploaded file.">fileName_</a> = <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#8fc5e7671594ffd178e0930554e85f15">clientFileName</a>();
<a name="l00115"></a>00115     <a class="code" href="classAttachmentEdit.html#86af04b8e5ebcdf2bdbd94a92847e6da" title="The filename of the local spool file.">spoolFileName_</a> = <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#98bff1bc07a5d59086455a45805e43bf">spoolFileName</a>();
<a name="l00116"></a>00116     <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#541d634e9f9e546f59417682811f01ef">stealSpooledFile</a>();
<a name="l00117"></a>00117     <a class="code" href="classAttachmentEdit.html#b9d9406dda4396e37b53a77a6e6fa861" title="The content description that was sent along with the file.">contentDescription_</a> = <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WFileUpload.html#fc6902cab1ca352a06687f900f2839aa">contentDescription</a>();
<a name="l00118"></a>00118 
<a name="l00119"></a>00119     <span class="comment">/*</span>
<a name="l00120"></a>00120 <span class="comment">     * Delete this widgets since we have a succesfull upload.</span>
<a name="l00121"></a>00121 <span class="comment">     */</span>
<a name="l00122"></a>00122     <span class="keyword">delete</span> <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a>;
<a name="l00123"></a>00123     <a class="code" href="classAttachmentEdit.html#a9a3945293cf0a30d35e8bc56312d430" title="The WFileUpload control.">upload_</a> = 0;
<a name="l00124"></a>00124     <span class="keyword">delete</span> <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a>;
<a name="l00125"></a>00125     <a class="code" href="classAttachmentEdit.html#55484424d37b196d07035e245399ffae" title="The option to remove the file.">remove_</a> = 0;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127     <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html#2f788aa524d51b3962642c9f565e66e6">setText</a>(<span class="stringliteral">""</span>);
<a name="l00128"></a>00128 
<a name="l00129"></a>00129     <span class="comment">/*</span>
<a name="l00130"></a>00130 <span class="comment">     * Include the file ?</span>
<a name="l00131"></a>00131 <span class="comment">     */</span>
<a name="l00132"></a>00132     <a class="code" href="classAttachmentEdit.html#ca36a743220d5663d340840cdb38f7ce" title="The check box to keep or discard the uploaded file.">keep_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#52dcef5a385ddfa0a8c3e6c20000f181">show</a>();
<a name="l00133"></a>00133     <a class="code" href="classAttachmentEdit.html#ca36a743220d5663d340840cdb38f7ce" title="The check box to keep or discard the uploaded file.">keep_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractToggleButton.html#6838c9a37f3e9e3c466e9f48bde55e62">setChecked</a>();
<a name="l00134"></a>00134 
<a name="l00135"></a>00135     <span class="comment">/*</span>
<a name="l00136"></a>00136 <span class="comment">     * Give information on the file uploaded.</span>
<a name="l00137"></a>00137 <span class="comment">     */</span>
<a name="l00138"></a>00138     <span class="keyword">struct </span>stat buf;
<a name="l00139"></a>00139     stat(<a class="code" href="classAttachmentEdit.html#86af04b8e5ebcdf2bdbd94a92847e6da" title="The filename of the local spool file.">spoolFileName_</a>.c_str(), &amp;buf);
<a name="l00140"></a>00140     std::wstring size;
<a name="l00141"></a>00141     <span class="keywordflow">if</span> (buf.st_size &lt; 1024)
<a name="l00142"></a>00142       size = boost::lexical_cast&lt;std::wstring&gt;(buf.st_size) + L<span class="stringliteral">" bytes"</span>;
<a name="l00143"></a>00143     <span class="keywordflow">else</span>
<a name="l00144"></a>00144       size = boost::lexical_cast&lt;std::wstring&gt;((int)(buf.st_size / 1024))
<a name="l00145"></a>00145         + L<span class="stringliteral">"kb"</span>;
<a name="l00146"></a>00146 
<a name="l00147"></a>00147     <a class="code" href="classAttachmentEdit.html#ce5c155b8749314f50ca2ba4a46c6e56" title="The text describing the uploaded file.">uploaded_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html#2f788aa524d51b3962642c9f565e66e6">setText</a>(static_cast&lt;std::wstring&gt;(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWebWidget.html#94abba3bda8fc934ae86db54c577b428">escapeText</a>(<a class="code" href="classAttachmentEdit.html#06536f7028735943c69325ebe33eec82" title="The filename of the uploaded file.">fileName_</a>))
<a name="l00148"></a>00148                        + L<span class="stringliteral">" (&lt;i&gt;"</span> + <a class="code" href="classAttachmentEdit.html#b9d9406dda4396e37b53a77a6e6fa861" title="The content description that was sent along with the file.">contentDescription_</a> + L<span class="stringliteral">"&lt;/i&gt;) "</span> + size);
<a name="l00149"></a>00149     <a class="code" href="classAttachmentEdit.html#ce5c155b8749314f50ca2ba4a46c6e56" title="The text describing the uploaded file.">uploaded_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#52dcef5a385ddfa0a8c3e6c20000f181">show</a>();
<a name="l00150"></a>00150 
<a name="l00151"></a>00151     <a class="code" href="classAttachmentEdit.html#6a19f364e7a82797bc5c18adb6a01530" title="The state of the last upload process.">uploadFailed_</a> = <span class="keyword">false</span>;
<a name="l00152"></a>00152   } <span class="keywordflow">else</span> {
<a name="l00153"></a>00153     <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html#2f788aa524d51b3962642c9f565e66e6">setText</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#a651f107ec7cf080faef6c435705fc44">tr</a>(<span class="stringliteral">"msg.file-empty"</span>));
<a name="l00154"></a>00154     <a class="code" href="classAttachmentEdit.html#6a19f364e7a82797bc5c18adb6a01530" title="The state of the last upload process.">uploadFailed_</a> = <span class="keyword">true</span>;
<a name="l00155"></a>00155   }
<a name="l00156"></a>00156 
<a name="l00157"></a>00157   <span class="comment">/*</span>
<a name="l00158"></a>00158 <span class="comment">   * Signal to the Composer that a new asyncrhonous file upload was processed.</span>
<a name="l00159"></a>00159 <span class="comment">   */</span>
<a name="l00160"></a>00160   <a class="code" href="classAttachmentEdit.html#24ee0aca670036a7491a1c0114188cc7">uploadDone_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#b9ec97260c79e7b546b7235ad2ffd627">emit</a>();
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a><a class="code" href="classAttachmentEdit.html#27277be62832ebbda987707b7a2d814e">00163</a> <span class="keywordtype">void</span> <a class="code" href="classAttachmentEdit.html#27277be62832ebbda987707b7a2d814e" title="Slot triggered when the users wishes to remove this attachment edit.">AttachmentEdit::remove</a>()
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165   <a class="code" href="classAttachmentEdit.html#403927978e9c841e64b62421458790e8">composer_</a>-&gt;<a class="code" href="classComposer.html#b142f49c8de59da0f84185165eb6c1c1" title="Remove the given attachment edit.">removeAttachment</a>(<span class="keyword">this</span>);
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167 
<a name="l00168"></a><a class="code" href="classAttachmentEdit.html#9f7b53df9b2342f38984832f1d2430eb">00168</a> <span class="keywordtype">void</span> <a class="code" href="classAttachmentEdit.html#9f7b53df9b2342f38984832f1d2430eb" title="Slot triggered when the WFileUpload received an oversized file.">AttachmentEdit::fileTooLarge</a>(<span class="keywordtype">int</span> size)
<a name="l00169"></a>00169 {
<a name="l00170"></a>00170   <a class="code" href="classAttachmentEdit.html#2c3fa5d63ec5feedc63f95295989cd4d" title="The text box to display an error (empty or too big file).">error_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WText.html#2f788aa524d51b3962642c9f565e66e6">setText</a>(<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WWidget.html#a651f107ec7cf080faef6c435705fc44">tr</a>(<span class="stringliteral">"msg.file-too-large"</span>));
<a name="l00171"></a>00171   <a class="code" href="classAttachmentEdit.html#6a19f364e7a82797bc5c18adb6a01530" title="The state of the last upload process.">uploadFailed_</a> = <span class="keyword">true</span>;
<a name="l00172"></a>00172 
<a name="l00173"></a>00173   <span class="comment">/*</span>
<a name="l00174"></a>00174 <span class="comment">   * Signal to the Composer that a new asyncrhonous file upload was processed.</span>
<a name="l00175"></a>00175 <span class="comment">   */</span>
<a name="l00176"></a>00176   <a class="code" href="classAttachmentEdit.html#24ee0aca670036a7491a1c0114188cc7">uploadDone_</a>.<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1Signal.html#b9ec97260c79e7b546b7235ad2ffd627">emit</a>();
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178 
<a name="l00179"></a><a class="code" href="classAttachmentEdit.html#780f87ad49249e38bf60f2560afd9789">00179</a> <span class="keywordtype">bool</span> <a class="code" href="classAttachmentEdit.html#780f87ad49249e38bf60f2560afd9789" title="Return whether this attachment must be included in the message.">AttachmentEdit::include</a>()<span class="keyword"> const</span>
<a name="l00180"></a>00180 <span class="keyword"></span>{
<a name="l00181"></a>00181   <span class="keywordflow">return</span> <a class="code" href="classAttachmentEdit.html#ca36a743220d5663d340840cdb38f7ce" title="The check box to keep or discard the uploaded file.">keep_</a>-&gt;<a class="codeRef" doxygen="wt.tags:../../reference/html/" href="../../reference/html/classWt_1_1WAbstractToggleButton.html#bd40ce7a6c4b4e924c9097015f4971ea">isChecked</a>();
<a name="l00182"></a>00182 }
<a name="l00183"></a>00183 
<a name="l00184"></a><a class="code" href="classAttachmentEdit.html#b0212edb4c861593672381f746389410">00184</a> <a class="code" href="classAttachment.html" title="An email attachment.">Attachment</a> <a class="code" href="classAttachmentEdit.html#b0212edb4c861593672381f746389410" title="Return the attachment.">AttachmentEdit::attachment</a>()
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186   <a class="code" href="classAttachmentEdit.html#3b94f0070aa893cbae3459f2a930bc09" title="Whether the spool file is &amp;quot;taken&amp;quot; and is no longer managed by the edit...">taken_</a> = <span class="keyword">true</span>;
<a name="l00187"></a>00187   <span class="keywordflow">return</span> <a class="code" href="classAttachment.html" title="An email attachment.">Attachment</a>(<a class="code" href="classAttachmentEdit.html#06536f7028735943c69325ebe33eec82" title="The filename of the uploaded file.">fileName_</a>, <a class="code" href="classAttachmentEdit.html#b9d9406dda4396e37b53a77a6e6fa861" title="The content description that was sent along with the file.">contentDescription_</a>, <a class="code" href="classAttachmentEdit.html#86af04b8e5ebcdf2bdbd94a92847e6da" title="The filename of the local spool file.">spoolFileName_</a>);
<a name="l00188"></a>00188 }
</pre></div></div>
<hr size="1"><address style="align: right;"><small>
Generated on Fri Mar 26 17:12:12 2010 for <a href="http://www.webtoolkit.eu/wt/">Wt</a> by&nbsp;<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6</small></address>
</body>
</html>