-rw-r--r-- | kmicromail/libetpan/mime/mailmime_decode.c | 3 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/generatemail.cpp | 13 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 7 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 3 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 11 | ||||
-rw-r--r-- | libkdepim/kprefswidget.cpp | 1 |
6 files changed, 25 insertions, 13 deletions
diff --git a/kmicromail/libetpan/mime/mailmime_decode.c b/kmicromail/libetpan/mime/mailmime_decode.c index e48ec19..dbaeb68 100644 --- a/kmicromail/libetpan/mime/mailmime_decode.c +++ b/kmicromail/libetpan/mime/mailmime_decode.c | |||
@@ -145,129 +145,130 @@ int mailmime_encoded_phrase_parse(const char * default_fromcode, | |||
145 | case MAIL_CHARCONV_ERROR_CONV: | 145 | case MAIL_CHARCONV_ERROR_CONV: |
146 | mailmime_encoded_word_free(word); | 146 | mailmime_encoded_word_free(word); |
147 | res = MAILIMF_ERROR_PARSE; | 147 | res = MAILIMF_ERROR_PARSE; |
148 | goto free; | 148 | goto free; |
149 | } | 149 | } |
150 | 150 | ||
151 | if (wordutf8 != NULL) { | 151 | if (wordutf8 != NULL) { |
152 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 152 | if (mmap_string_append(gphrase, wordutf8) == NULL) { |
153 | mailmime_encoded_word_free(word); | 153 | mailmime_encoded_word_free(word); |
154 | free(wordutf8); | 154 | free(wordutf8); |
155 | res = MAILIMF_ERROR_MEMORY; | 155 | res = MAILIMF_ERROR_MEMORY; |
156 | goto free; | 156 | goto free; |
157 | } | 157 | } |
158 | free(wordutf8); | 158 | free(wordutf8); |
159 | } | 159 | } |
160 | mailmime_encoded_word_free(word); | 160 | mailmime_encoded_word_free(word); |
161 | first = FALSE; | 161 | first = FALSE; |
162 | } | 162 | } |
163 | else if (r == MAILIMF_ERROR_PARSE) { | 163 | else if (r == MAILIMF_ERROR_PARSE) { |
164 | /* do nothing */ | 164 | /* do nothing */ |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | res = r; | 167 | res = r; |
168 | goto free; | 168 | goto free; |
169 | } | 169 | } |
170 | 170 | ||
171 | if (r == MAILIMF_ERROR_PARSE) { | 171 | if (r == MAILIMF_ERROR_PARSE) { |
172 | char * raw_word; | 172 | char * raw_word; |
173 | 173 | ||
174 | r = mailmime_non_encoded_word_parse(message, length, | 174 | r = mailmime_non_encoded_word_parse(message, length, |
175 | &cur_token, &raw_word); | 175 | &cur_token, &raw_word); |
176 | if (r == MAILIMF_NO_ERROR) { | 176 | if (r == MAILIMF_NO_ERROR) { |
177 | if (!first) { | 177 | if (!first) { |
178 | if (mmap_string_append_c(gphrase, ' ') == NULL) { | 178 | if (mmap_string_append_c(gphrase, ' ') == NULL) { |
179 | free(raw_word); | 179 | free(raw_word); |
180 | res = MAILIMF_ERROR_MEMORY; | 180 | res = MAILIMF_ERROR_MEMORY; |
181 | goto free; | 181 | goto free; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | type = TYPE_WORD; | 184 | type = TYPE_WORD; |
185 | 185 | ||
186 | wordutf8 = NULL; | 186 | wordutf8 = NULL; |
187 | r = charconv(tocode, default_fromcode, raw_word, | 187 | r = charconv(tocode, default_fromcode, raw_word, |
188 | strlen(raw_word), &wordutf8); | 188 | strlen(raw_word), &wordutf8); |
189 | 189 | ||
190 | switch (r) { | 190 | switch (r) { |
191 | case MAIL_CHARCONV_ERROR_MEMORY: | 191 | case MAIL_CHARCONV_ERROR_MEMORY: |
192 | free(raw_word); | 192 | free(raw_word); |
193 | res = MAILIMF_ERROR_MEMORY; | 193 | res = MAILIMF_ERROR_MEMORY; |
194 | goto free; | 194 | goto free; |
195 | 195 | ||
196 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: | 196 | case MAIL_CHARCONV_ERROR_UNKNOWN_CHARSET: |
197 | case MAIL_CHARCONV_ERROR_CONV: | 197 | case MAIL_CHARCONV_ERROR_CONV: |
198 | free(raw_word); | 198 | free(raw_word); |
199 | res = MAILIMF_ERROR_PARSE; | 199 | res = MAILIMF_ERROR_PARSE; |
200 | goto free; | 200 | goto free; |
201 | } | 201 | } |
202 | 202 | ||
203 | if (mmap_string_append(gphrase, wordutf8) == NULL) { | 203 | if (mmap_string_append(gphrase, wordutf8) == NULL) { |
204 | free(wordutf8); | 204 | free(wordutf8); |
205 | free(raw_word); | 205 | free(raw_word); |
206 | res = MAILIMF_ERROR_MEMORY; | 206 | res = MAILIMF_ERROR_MEMORY; |
207 | goto free; | 207 | goto free; |
208 | } | 208 | } |
209 | 209 | // LUTZ fix | |
210 | free(wordutf8); | ||
210 | free(raw_word); | 211 | free(raw_word); |
211 | first = FALSE; | 212 | first = FALSE; |
212 | } | 213 | } |
213 | else if (r == MAILIMF_ERROR_PARSE) { | 214 | else if (r == MAILIMF_ERROR_PARSE) { |
214 | break; | 215 | break; |
215 | } | 216 | } |
216 | else { | 217 | else { |
217 | res = r; | 218 | res = r; |
218 | goto free; | 219 | goto free; |
219 | } | 220 | } |
220 | } | 221 | } |
221 | } | 222 | } |
222 | 223 | ||
223 | if (first) { | 224 | if (first) { |
224 | res = MAILIMF_ERROR_PARSE; | 225 | res = MAILIMF_ERROR_PARSE; |
225 | goto free; | 226 | goto free; |
226 | } | 227 | } |
227 | 228 | ||
228 | str = strdup(gphrase->str); | 229 | str = strdup(gphrase->str); |
229 | if (str == NULL) { | 230 | if (str == NULL) { |
230 | res = MAILIMF_ERROR_MEMORY; | 231 | res = MAILIMF_ERROR_MEMORY; |
231 | goto free; | 232 | goto free; |
232 | } | 233 | } |
233 | mmap_string_free(gphrase); | 234 | mmap_string_free(gphrase); |
234 | 235 | ||
235 | * result = str; | 236 | * result = str; |
236 | * index = cur_token; | 237 | * index = cur_token; |
237 | 238 | ||
238 | return MAILIMF_NO_ERROR; | 239 | return MAILIMF_NO_ERROR; |
239 | 240 | ||
240 | free: | 241 | free: |
241 | mmap_string_free(gphrase); | 242 | mmap_string_free(gphrase); |
242 | err: | 243 | err: |
243 | return res; | 244 | return res; |
244 | } | 245 | } |
245 | 246 | ||
246 | static int | 247 | static int |
247 | mailmime_non_encoded_word_parse(const char * message, size_t length, | 248 | mailmime_non_encoded_word_parse(const char * message, size_t length, |
248 | size_t * index, | 249 | size_t * index, |
249 | char ** result) | 250 | char ** result) |
250 | { | 251 | { |
251 | int end; | 252 | int end; |
252 | size_t cur_token; | 253 | size_t cur_token; |
253 | int res; | 254 | int res; |
254 | char * text; | 255 | char * text; |
255 | int r; | 256 | int r; |
256 | size_t begin; | 257 | size_t begin; |
257 | 258 | ||
258 | cur_token = * index; | 259 | cur_token = * index; |
259 | 260 | ||
260 | r = mailimf_fws_parse(message, length, &cur_token); | 261 | r = mailimf_fws_parse(message, length, &cur_token); |
261 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { | 262 | if ((r != MAILIMF_NO_ERROR) && (r != MAILIMF_ERROR_PARSE)) { |
262 | res = r; | 263 | res = r; |
263 | goto err; | 264 | goto err; |
264 | } | 265 | } |
265 | 266 | ||
266 | begin = cur_token; | 267 | begin = cur_token; |
267 | 268 | ||
268 | end = FALSE; | 269 | end = FALSE; |
269 | while (1) { | 270 | while (1) { |
270 | if (cur_token >= length) | 271 | if (cur_token >= length) |
271 | break; | 272 | break; |
272 | 273 | ||
273 | switch (message[cur_token]) { | 274 | switch (message[cur_token]) { |
diff --git a/kmicromail/libmailwrapper/generatemail.cpp b/kmicromail/libmailwrapper/generatemail.cpp index 49315ba..32311d7 100644 --- a/kmicromail/libmailwrapper/generatemail.cpp +++ b/kmicromail/libmailwrapper/generatemail.cpp | |||
@@ -1,316 +1,317 @@ | |||
1 | #include "generatemail.h" | 1 | #include "generatemail.h" |
2 | #include "mailwrapper.h" | 2 | #include "mailwrapper.h" |
3 | 3 | ||
4 | #include <libetpan/libetpan.h> | 4 | #include <libetpan/libetpan.h> |
5 | 5 | ||
6 | //#include <qt.h> | 6 | //#include <qt.h> |
7 | 7 | ||
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | const char* Generatemail::USER_AGENT="OpieMail v0.6"; | 12 | const char* Generatemail::USER_AGENT="KOpieMail 33 1/3"; |
13 | 13 | ||
14 | Generatemail::Generatemail() | 14 | Generatemail::Generatemail() |
15 | { | 15 | { |
16 | } | 16 | } |
17 | 17 | ||
18 | Generatemail::~Generatemail() | 18 | Generatemail::~Generatemail() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { | 22 | void Generatemail::addRcpts( clist *list, mailimf_address_list *addr_list ) { |
23 | clistiter *it, *it2; | 23 | clistiter *it, *it2; |
24 | 24 | ||
25 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { | 25 | for ( it = clist_begin( addr_list->ad_list ); it; it = it->next ) { |
26 | mailimf_address *addr; | 26 | mailimf_address *addr; |
27 | addr = (mailimf_address *) it->data; | 27 | addr = (mailimf_address *) it->data; |
28 | 28 | ||
29 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { | 29 | if ( addr->ad_type == MAILIMF_ADDRESS_MAILBOX ) { |
30 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); | 30 | esmtp_address_list_add( list, addr->ad_data.ad_mailbox->mb_addr_spec, 0, NULL ); |
31 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { | 31 | } else if ( addr->ad_type == MAILIMF_ADDRESS_GROUP ) { |
32 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; | 32 | clist *l = addr->ad_data.ad_group->grp_mb_list->mb_list; |
33 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { | 33 | for ( it2 = clist_begin( l ); it2; it2 = it2->next ) { |
34 | mailimf_mailbox *mbox; | 34 | mailimf_mailbox *mbox; |
35 | mbox = (mailimf_mailbox *) it2->data; | 35 | mbox = (mailimf_mailbox *) it2->data; |
36 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); | 36 | esmtp_address_list_add( list, mbox->mb_addr_spec, 0, NULL ); |
37 | } | 37 | } |
38 | } | 38 | } |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
42 | char *Generatemail::getFrom( mailimf_field *ffrom) { | 42 | char *Generatemail::getFrom( mailimf_field *ffrom) { |
43 | char *from = NULL; | 43 | char *from = NULL; |
44 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) | 44 | if ( ffrom && (ffrom->fld_type == MAILIMF_FIELD_FROM) |
45 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { | 45 | && ffrom->fld_data.fld_from->frm_mb_list && ffrom->fld_data.fld_from->frm_mb_list->mb_list ) { |
46 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; | 46 | clist *cl = ffrom->fld_data.fld_from->frm_mb_list->mb_list; |
47 | clistiter *it; | 47 | clistiter *it; |
48 | for ( it = clist_begin( cl ); it; it = it->next ) { | 48 | for ( it = clist_begin( cl ); it; it = it->next ) { |
49 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; | 49 | mailimf_mailbox *mb = (mailimf_mailbox *) it->data; |
50 | from = strdup( mb->mb_addr_spec ); | 50 | from = strdup( mb->mb_addr_spec ); |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | return from; | 54 | return from; |
55 | } | 55 | } |
56 | 56 | ||
57 | char *Generatemail::getFrom( mailmime *mail ) { | 57 | char *Generatemail::getFrom( mailmime *mail ) { |
58 | /* no need to delete - its just a pointer to structure content */ | 58 | /* no need to delete - its just a pointer to structure content */ |
59 | mailimf_field *ffrom = 0; | 59 | mailimf_field *ffrom = 0; |
60 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); | 60 | ffrom = getField( mail->mm_data.mm_message.mm_fields, MAILIMF_FIELD_FROM ); |
61 | return getFrom(ffrom); | 61 | return getFrom(ffrom); |
62 | } | 62 | } |
63 | 63 | ||
64 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { | 64 | mailimf_field *Generatemail::getField( mailimf_fields *fields, int type ) { |
65 | mailimf_field *field; | 65 | mailimf_field *field; |
66 | clistiter *it; | 66 | clistiter *it; |
67 | 67 | ||
68 | it = clist_begin( fields->fld_list ); | 68 | it = clist_begin( fields->fld_list ); |
69 | while ( it ) { | 69 | while ( it ) { |
70 | field = (mailimf_field *) it->data; | 70 | field = (mailimf_field *) it->data; |
71 | if ( field->fld_type == type ) { | 71 | if ( field->fld_type == type ) { |
72 | return field; | 72 | return field; |
73 | } | 73 | } |
74 | it = it->next; | 74 | it = it->next; |
75 | } | 75 | } |
76 | 76 | ||
77 | return NULL; | 77 | return NULL; |
78 | } | 78 | } |
79 | 79 | ||
80 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { | 80 | mailimf_address_list *Generatemail::parseAddresses(const QString&addr ) { |
81 | mailimf_address_list *addresses; | 81 | mailimf_address_list *addresses; |
82 | 82 | ||
83 | if ( addr.isEmpty() ) | 83 | if ( addr.isEmpty() ) |
84 | return NULL; | 84 | return NULL; |
85 | 85 | ||
86 | addresses = mailimf_address_list_new_empty(); | 86 | addresses = mailimf_address_list_new_empty(); |
87 | 87 | ||
88 | bool literal_open = false; | 88 | bool literal_open = false; |
89 | unsigned int startpos = 0; | 89 | unsigned int startpos = 0; |
90 | QStringList list; | 90 | QStringList list; |
91 | QString s; | 91 | QString s; |
92 | unsigned int i = 0; | 92 | unsigned int i = 0; |
93 | for (; i < addr.length();++i) { | 93 | for (; i < addr.length();++i) { |
94 | switch (addr[i]) { | 94 | switch (addr[i]) { |
95 | case '\"': | 95 | case '\"': |
96 | literal_open = !literal_open; | 96 | literal_open = !literal_open; |
97 | break; | 97 | break; |
98 | case ',': | 98 | case ',': |
99 | if (!literal_open) { | 99 | if (!literal_open) { |
100 | s = addr.mid(startpos,i-startpos); | 100 | s = addr.mid(startpos,i-startpos); |
101 | if (!s.isEmpty()) { | 101 | if (!s.isEmpty()) { |
102 | list.append(s); | 102 | list.append(s); |
103 | } | 103 | } |
104 | // !!!! this is a MUST BE! | 104 | // !!!! this is a MUST BE! |
105 | startpos = ++i; | 105 | startpos = ++i; |
106 | } | 106 | } |
107 | break; | 107 | break; |
108 | default: | 108 | default: |
109 | break; | 109 | break; |
110 | } | 110 | } |
111 | } | 111 | } |
112 | s = addr.mid(startpos,i-startpos); | 112 | s = addr.mid(startpos,i-startpos); |
113 | if (!s.isEmpty()) { | 113 | if (!s.isEmpty()) { |
114 | list.append(s); | 114 | list.append(s); |
115 | } | 115 | } |
116 | QStringList::Iterator it; | 116 | QStringList::Iterator it; |
117 | for ( it = list.begin(); it != list.end(); it++ ) { | 117 | for ( it = list.begin(); it != list.end(); it++ ) { |
118 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); | 118 | int err = mailimf_address_list_add_parse( addresses, (char*)(*it).latin1() ); |
119 | if ( err != MAILIMF_NO_ERROR ) { | 119 | if ( err != MAILIMF_NO_ERROR ) { |
120 | qDebug(" Error parsing"); // *it | 120 | qDebug(" Error parsing"); // *it |
121 | } else { | 121 | } else { |
122 | } | 122 | } |
123 | } | 123 | } |
124 | return addresses; | 124 | return addresses; |
125 | } | 125 | } |
126 | 126 | ||
127 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { | 127 | mailmime *Generatemail::buildFilePart(const QString&filename,const QString&mimetype,const QString&TextContent ) { |
128 | mailmime * filePart = 0; | 128 | mailmime * filePart = 0; |
129 | mailmime_fields * fields = 0; | 129 | mailmime_fields * fields = 0; |
130 | mailmime_content * content = 0; | 130 | mailmime_content * content = 0; |
131 | mailmime_parameter * param = 0; | 131 | mailmime_parameter * param = 0; |
132 | char*name = 0; | 132 | char*name = 0; |
133 | char*file = 0; | 133 | char*file = 0; |
134 | int err; | 134 | int err; |
135 | |||
136 | int pos = filename.findRev( '/' ); | 135 | int pos = filename.findRev( '/' ); |
137 | 136 | ||
138 | if (filename.length()>0) { | 137 | if (filename.length()>0) { |
139 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); | 138 | QString tmp = filename.right( filename.length() - ( pos + 1 ) ); |
140 | name = strdup( tmp.latin1() ); // just filename | 139 | name = strdup( tmp.latin1() ); // just filename |
141 | file = strdup( filename.latin1() ); // full name with path | 140 | file = strdup( filename.latin1() ); // full name with path |
142 | } | 141 | } |
143 | 142 | ||
144 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; | 143 | int disptype = MAILMIME_DISPOSITION_TYPE_ATTACHMENT; |
145 | int mechanism = MAILMIME_MECHANISM_BASE64; | 144 | int mechanism = MAILMIME_MECHANISM_BASE64; |
146 | 145 | ||
147 | if ( mimetype.startsWith( "text/" ) ) { | 146 | if ( mimetype.startsWith( "text/" ) ) { |
148 | param = mailmime_parameter_new( strdup( "charset" ), | 147 | param = mailmime_parameter_new( strdup( "charset" ), |
149 | strdup( "iso-8859-1" ) ); | 148 | strdup( "iso-8859-1" ) ); |
150 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; | 149 | mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE; |
151 | } | 150 | } |
152 | 151 | ||
153 | fields = mailmime_fields_new_filename( | 152 | fields = mailmime_fields_new_filename( |
154 | disptype, name, | 153 | disptype, name, |
155 | mechanism ); | 154 | mechanism ); |
156 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); | 155 | content = mailmime_content_new_with_str( (char*)mimetype.latin1() ); |
157 | if (content!=0 && fields != 0) { | 156 | if (content!=0 && fields != 0) { |
158 | if (param) { | 157 | if (param) { |
159 | clist_append(content->ct_parameters,param); | 158 | clist_append(content->ct_parameters,param); |
160 | param = 0; | 159 | param = 0; |
161 | } | 160 | } |
162 | if (filename.length()>0) { | 161 | if (filename.length()>0) { |
163 | QFileInfo f(filename); | 162 | QFileInfo f(filename); |
164 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); | 163 | param = mailmime_parameter_new(strdup("name"),strdup(f.fileName().latin1())); |
165 | clist_append(content->ct_parameters,param); | 164 | clist_append(content->ct_parameters,param); |
166 | param = 0; | 165 | param = 0; |
167 | } | 166 | } |
168 | filePart = mailmime_new_empty( content, fields ); | 167 | filePart = mailmime_new_empty( content, fields ); |
169 | } | 168 | } |
170 | if (filePart) { | 169 | if (filePart) { |
171 | if (filename.length()>0) { | 170 | if (filename.length()>0) { |
172 | err = mailmime_set_body_file( filePart, file ); | 171 | err = mailmime_set_body_file( filePart, file ); |
173 | } else { | 172 | } else { |
174 | err = mailmime_set_body_text(filePart,strdup(TextContent.data()),TextContent.length()); | 173 | err = mailmime_set_body_text(filePart,strdup( TextContent.utf8()),TextContent.utf8().length()); |
175 | } | 174 | } |
176 | if (err != MAILIMF_NO_ERROR) { | 175 | if (err != MAILIMF_NO_ERROR) { |
177 | qDebug("Error setting body with file "); | 176 | qDebug("Error setting body with file "); |
178 | mailmime_free( filePart ); | 177 | mailmime_free( filePart ); |
179 | filePart = 0; | 178 | filePart = 0; |
180 | } | 179 | } |
181 | } | 180 | } |
182 | 181 | ||
183 | if (!filePart) { | 182 | if (!filePart) { |
184 | if ( param != NULL ) { | 183 | if ( param != NULL ) { |
185 | mailmime_parameter_free( param ); | 184 | mailmime_parameter_free( param ); |
186 | } | 185 | } |
187 | if (content) { | 186 | if (content) { |
188 | mailmime_content_free( content ); | 187 | mailmime_content_free( content ); |
189 | } | 188 | } |
190 | if (fields) { | 189 | if (fields) { |
191 | mailmime_fields_free( fields ); | 190 | mailmime_fields_free( fields ); |
192 | } else { | 191 | } else { |
193 | if (name) { | 192 | if (name) { |
194 | free( name ); | 193 | free( name ); |
195 | } | 194 | } |
196 | if (file) { | 195 | if (file) { |
197 | free( file ); | 196 | free( file ); |
198 | } | 197 | } |
199 | } | 198 | } |
200 | } | 199 | } |
201 | return filePart; // Success :) | 200 | return filePart; // Success :) |
202 | 201 | ||
203 | } | 202 | } |
204 | 203 | ||
205 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { | 204 | void Generatemail::addFileParts( mailmime *message,const QList<Attachment>&files ) { |
206 | const Attachment *it; | 205 | const Attachment *it; |
207 | unsigned int count = files.count(); | 206 | unsigned int count = files.count(); |
208 | for ( unsigned int i = 0; i < count; ++i ) { | 207 | for ( unsigned int i = 0; i < count; ++i ) { |
209 | mailmime *filePart; | 208 | mailmime *filePart; |
210 | int err; | 209 | int err; |
211 | it = ((QList<Attachment>)files).at(i); | 210 | it = ((QList<Attachment>)files).at(i); |
212 | 211 | ||
213 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); | 212 | filePart = buildFilePart( it->getFileName(), it->getMimeType(),"" ); |
214 | if ( filePart == NULL ) { | 213 | if ( filePart == NULL ) { |
215 | continue; | 214 | continue; |
216 | } | 215 | } |
217 | err = mailmime_smart_add_part( message, filePart ); | 216 | err = mailmime_smart_add_part( message, filePart ); |
218 | if ( err != MAILIMF_NO_ERROR ) { | 217 | if ( err != MAILIMF_NO_ERROR ) { |
219 | mailmime_free( filePart ); | 218 | mailmime_free( filePart ); |
220 | } | 219 | } |
221 | } | 220 | } |
222 | } | 221 | } |
223 | 222 | ||
224 | mailmime *Generatemail::buildTxtPart(const QString&str ) { | 223 | mailmime *Generatemail::buildTxtPart(const QString&str ) { |
225 | mailmime *txtPart; | 224 | mailmime *txtPart; |
226 | mailmime_fields *fields; | 225 | mailmime_fields *fields; |
227 | mailmime_content *content; | 226 | mailmime_content *content; |
228 | mailmime_parameter *param; | 227 | mailmime_parameter *param; |
229 | int err; | 228 | int err; |
230 | 229 | QCString __str; | |
231 | param = mailmime_parameter_new( strdup( "charset" ), | 230 | param = mailmime_parameter_new( strdup( "charset" ), |
232 | strdup( "iso-8859-1" ) ); | 231 | strdup( "iso-8859-1" ) ); |
233 | if ( param == NULL ) | 232 | if ( param == NULL ) |
234 | goto err_free; | 233 | goto err_free; |
235 | 234 | ||
236 | content = mailmime_content_new_with_str( "text/plain" ); | 235 | content = mailmime_content_new_with_str( "text/plain" ); |
237 | if ( content == NULL ) | 236 | if ( content == NULL ) |
238 | goto err_free_param; | 237 | goto err_free_param; |
239 | 238 | ||
240 | err = clist_append( content->ct_parameters, param ); | 239 | err = clist_append( content->ct_parameters, param ); |
241 | if ( err != MAILIMF_NO_ERROR ) | 240 | if ( err != MAILIMF_NO_ERROR ) |
242 | goto err_free_content; | 241 | goto err_free_content; |
243 | 242 | ||
244 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); | 243 | fields = mailmime_fields_new_encoding(MAILMIME_MECHANISM_8BIT); |
245 | if ( fields == NULL ) | 244 | if ( fields == NULL ) |
246 | goto err_free_content; | 245 | goto err_free_content; |
247 | 246 | ||
248 | txtPart = mailmime_new_empty( content, fields ); | 247 | txtPart = mailmime_new_empty( content, fields ); |
249 | if ( txtPart == NULL ) | 248 | if ( txtPart == NULL ) |
250 | goto err_free_fields; | 249 | goto err_free_fields; |
251 | 250 | { | |
252 | err = mailmime_set_body_text( txtPart, (char*)str.data(), str.length() ); | 251 | __str = str.utf8(); |
252 | err = mailmime_set_body_text( txtPart, __str.data(), __str.length() ); | ||
253 | } | ||
253 | if ( err != MAILIMF_NO_ERROR ) | 254 | if ( err != MAILIMF_NO_ERROR ) |
254 | goto err_free_txtPart; | 255 | goto err_free_txtPart; |
255 | 256 | ||
256 | return txtPart; // Success :) | 257 | return txtPart; // Success :) |
257 | 258 | ||
258 | err_free_txtPart: | 259 | err_free_txtPart: |
259 | mailmime_free( txtPart ); | 260 | mailmime_free( txtPart ); |
260 | err_free_fields: | 261 | err_free_fields: |
261 | mailmime_fields_free( fields ); | 262 | mailmime_fields_free( fields ); |
262 | err_free_content: | 263 | err_free_content: |
263 | mailmime_content_free( content ); | 264 | mailmime_content_free( content ); |
264 | err_free_param: | 265 | err_free_param: |
265 | mailmime_parameter_free( param ); | 266 | mailmime_parameter_free( param ); |
266 | err_free: | 267 | err_free: |
267 | ; | 268 | ; |
268 | 269 | ||
269 | return NULL; // Error :( | 270 | return NULL; // Error :( |
270 | } | 271 | } |
271 | 272 | ||
272 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { | 273 | mailimf_mailbox *Generatemail::newMailbox(const QString&name, const QString&mail ) { |
273 | return mailimf_mailbox_new( strdup( name.latin1() ), | 274 | return mailimf_mailbox_new( strdup( name.latin1() ), |
274 | strdup( mail.latin1() ) ); | 275 | strdup( mail.latin1() ) ); |
275 | } | 276 | } |
276 | 277 | ||
277 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) | 278 | mailimf_fields *Generatemail::createImfFields(const Opie::Core::OSmartPointer<Mail>&mail ) |
278 | { | 279 | { |
279 | mailimf_fields *fields = NULL; | 280 | mailimf_fields *fields = NULL; |
280 | mailimf_field *xmailer = NULL; | 281 | mailimf_field *xmailer = NULL; |
281 | mailimf_mailbox *sender=0,*fromBox=0; | 282 | mailimf_mailbox *sender=0,*fromBox=0; |
282 | mailimf_mailbox_list *from=0; | 283 | mailimf_mailbox_list *from=0; |
283 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; | 284 | mailimf_address_list *to=0, *cc=0, *bcc=0, *reply=0; |
284 | clist*in_reply_to = 0; | 285 | clist*in_reply_to = 0; |
285 | char *subject = strdup( mail->getSubject().latin1() ); | 286 | char *subject = strdup( mail->getSubject().latin1() ); |
286 | int err; | 287 | int err; |
287 | int res = 1; | 288 | int res = 1; |
288 | 289 | ||
289 | sender = newMailbox( mail->getName(), mail->getMail() ); | 290 | sender = newMailbox( mail->getName(), mail->getMail() ); |
290 | if ( sender == NULL ) { | 291 | if ( sender == NULL ) { |
291 | res = 0; | 292 | res = 0; |
292 | } | 293 | } |
293 | 294 | ||
294 | if (res) { | 295 | if (res) { |
295 | fromBox = newMailbox( mail->getName(), mail->getMail() ); | 296 | fromBox = newMailbox( mail->getName(), mail->getMail() ); |
296 | } | 297 | } |
297 | if ( fromBox == NULL ) { | 298 | if ( fromBox == NULL ) { |
298 | res = 0; | 299 | res = 0; |
299 | } | 300 | } |
300 | 301 | ||
301 | if (res) { | 302 | if (res) { |
302 | from = mailimf_mailbox_list_new_empty(); | 303 | from = mailimf_mailbox_list_new_empty(); |
303 | } | 304 | } |
304 | if ( from == NULL ) { | 305 | if ( from == NULL ) { |
305 | res = 0; | 306 | res = 0; |
306 | } | 307 | } |
307 | 308 | ||
308 | if (res && from) { | 309 | if (res && from) { |
309 | err = mailimf_mailbox_list_add( from, fromBox ); | 310 | err = mailimf_mailbox_list_add( from, fromBox ); |
310 | if ( err != MAILIMF_NO_ERROR ) { | 311 | if ( err != MAILIMF_NO_ERROR ) { |
311 | res = 0; | 312 | res = 0; |
312 | } | 313 | } |
313 | } | 314 | } |
314 | 315 | ||
315 | if (res) to = parseAddresses( mail->getTo() ); | 316 | if (res) to = parseAddresses( mail->getTo() ); |
316 | if (res) cc = parseAddresses( mail->getCC() ); | 317 | if (res) cc = parseAddresses( mail->getCC() ); |
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index ae667ec..d90a8d2 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp | |||
@@ -14,129 +14,129 @@ using namespace Opie::Core; | |||
14 | int IMAPwrapper::mMax = 0; | 14 | int IMAPwrapper::mMax = 0; |
15 | int IMAPwrapper::mCurrent = 0; | 15 | int IMAPwrapper::mCurrent = 0; |
16 | 16 | ||
17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) | 17 | IMAPwrapper::IMAPwrapper( IMAPaccount *a ) |
18 | : AbstractMail() | 18 | : AbstractMail() |
19 | { | 19 | { |
20 | account = a; | 20 | account = a; |
21 | m_imap = 0; | 21 | m_imap = 0; |
22 | m_Lastmbox = ""; | 22 | m_Lastmbox = ""; |
23 | mCurrent = 0; | 23 | mCurrent = 0; |
24 | mMax = 0; | 24 | mMax = 0; |
25 | } | 25 | } |
26 | 26 | ||
27 | IMAPwrapper::~IMAPwrapper() | 27 | IMAPwrapper::~IMAPwrapper() |
28 | { | 28 | { |
29 | logout(); | 29 | logout(); |
30 | } | 30 | } |
31 | 31 | ||
32 | /* to avoid to often select statements in loops etc. | 32 | /* to avoid to often select statements in loops etc. |
33 | we trust that we are logged in and connection is established!*/ | 33 | we trust that we are logged in and connection is established!*/ |
34 | int IMAPwrapper::selectMbox(const QString&mbox) | 34 | int IMAPwrapper::selectMbox(const QString&mbox) |
35 | { | 35 | { |
36 | if (mbox == m_Lastmbox) { | 36 | if (mbox == m_Lastmbox) { |
37 | return MAILIMAP_NO_ERROR; | 37 | return MAILIMAP_NO_ERROR; |
38 | } | 38 | } |
39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); | 39 | int err = mailimap_select( m_imap, (char*)mbox.latin1()); |
40 | if ( err != MAILIMAP_NO_ERROR ) { | 40 | if ( err != MAILIMAP_NO_ERROR ) { |
41 | m_Lastmbox = ""; | 41 | m_Lastmbox = ""; |
42 | return err; | 42 | return err; |
43 | } | 43 | } |
44 | m_Lastmbox = mbox; | 44 | m_Lastmbox = mbox; |
45 | return err; | 45 | return err; |
46 | } | 46 | } |
47 | 47 | ||
48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) | 48 | void IMAPwrapper::imap_progress( size_t current, size_t maximum ) |
49 | { | 49 | { |
50 | //qDebug("imap progress %d of %d ",current,maximum ); | 50 | //qDebug("imap progress %d of %d ",current,maximum ); |
51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); | 51 | //Global::statusMessage(i18n("Downloading message %1 of %2").arg( current).arg(maximum)); |
52 | //qApp->processEvents() | 52 | //qApp->processEvents() |
53 | static int last = 0; | 53 | static int last = 0; |
54 | if ( last != current ) | 54 | if ( last != current ) |
55 | IMAPwrapper::progress(); | 55 | IMAPwrapper::progress(); |
56 | last = current; | 56 | last = current; |
57 | } | 57 | } |
58 | void IMAPwrapper::progress( QString m ) | 58 | void IMAPwrapper::progress( QString m ) |
59 | { | 59 | { |
60 | 60 | ||
61 | static QString mProgrMess; | 61 | static QString mProgrMess; |
62 | if ( m != QString::null ) { | 62 | if ( m != QString::null ) { |
63 | mProgrMess = m; | 63 | mProgrMess = m; |
64 | mCurrent = 1; | 64 | mCurrent = 1; |
65 | return; | 65 | return; |
66 | } | 66 | } |
67 | QString mess; | 67 | QString mess; |
68 | //qDebug("progress "); | 68 | //qDebug("progress "); |
69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); | 69 | if ( mMax ) mess = mProgrMess +i18n(" message %1 of %2").arg( mCurrent++).arg(mMax); |
70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); | 70 | else mess = mProgrMess +i18n(" message %1").arg( mCurrent++); |
71 | Global::statusMessage(mess); | 71 | Global::statusMessage(mess); |
72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); | 72 | //qDebug("Progress %s %s", mess.latin1(), m.latin1()); |
73 | qApp->processEvents(); | 73 | qApp->processEvents(); |
74 | } | 74 | } |
75 | bool IMAPwrapper::start_tls(bool force_tls) | 75 | bool IMAPwrapper::start_tls(bool force_tls) |
76 | { | 76 | { |
77 | int err; | 77 | int err; |
78 | bool try_tls; | 78 | bool try_tls = force_tls; |
79 | mailimap_capability_data * cap_data = 0; | 79 | mailimap_capability_data * cap_data = 0; |
80 | 80 | ||
81 | err = mailimap_capability(m_imap,&cap_data); | 81 | err = mailimap_capability(m_imap,&cap_data); |
82 | if (err != MAILIMAP_NO_ERROR) { | 82 | if (err != MAILIMAP_NO_ERROR) { |
83 | Global::statusMessage("error getting capabilities!"); | 83 | Global::statusMessage("error getting capabilities!"); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | clistiter * cur; | 86 | clistiter * cur; |
87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { | 87 | for(cur = clist_begin(cap_data->cap_list) ; cur != NULL;cur = clist_next(cur)) { |
88 | struct mailimap_capability * cap; | 88 | struct mailimap_capability * cap; |
89 | cap = (struct mailimap_capability *)clist_content(cur); | 89 | cap = (struct mailimap_capability *)clist_content(cur); |
90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { | 90 | if (cap->cap_type == MAILIMAP_CAPABILITY_NAME) { |
91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { | 91 | if (strcasecmp(cap->cap_data.cap_name, "STARTTLS") == 0) { |
92 | try_tls = true; | 92 | try_tls = true; |
93 | break; | 93 | break; |
94 | } | 94 | } |
95 | } | 95 | } |
96 | } | 96 | } |
97 | if (cap_data) { | 97 | if (cap_data) { |
98 | mailimap_capability_data_free(cap_data); | 98 | mailimap_capability_data_free(cap_data); |
99 | } | 99 | } |
100 | if (try_tls) { | 100 | if (try_tls) { |
101 | err = mailimap_starttls(m_imap); | 101 | err = mailimap_starttls(m_imap); |
102 | if (err != MAILIMAP_NO_ERROR && force_tls) { | 102 | if (err != MAILIMAP_NO_ERROR && force_tls) { |
103 | Global::statusMessage(i18n("Server has no TLS support!")); | 103 | Global::statusMessage(i18n("Server has no TLS support!")); |
104 | try_tls = false; | 104 | try_tls = false; |
105 | } else { | 105 | } else { |
106 | mailstream_low * low; | 106 | mailstream_low * low; |
107 | mailstream_low * new_low; | 107 | mailstream_low * new_low; |
108 | low = mailstream_get_low(m_imap->imap_stream); | 108 | low = mailstream_get_low(m_imap->imap_stream); |
109 | if (!low) { | 109 | if (!low) { |
110 | try_tls = false; | 110 | try_tls = false; |
111 | } else { | 111 | } else { |
112 | int fd = mailstream_low_get_fd(low); | 112 | int fd = mailstream_low_get_fd(low); |
113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { | 113 | if (fd > -1 && (new_low = mailstream_low_ssl_open(fd))!=0) { |
114 | mailstream_low_free(low); | 114 | mailstream_low_free(low); |
115 | mailstream_set_low(m_imap->imap_stream, new_low); | 115 | mailstream_set_low(m_imap->imap_stream, new_low); |
116 | } else { | 116 | } else { |
117 | try_tls = false; | 117 | try_tls = false; |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | return try_tls; | 122 | return try_tls; |
123 | } | 123 | } |
124 | 124 | ||
125 | void IMAPwrapper::login() | 125 | void IMAPwrapper::login() |
126 | { | 126 | { |
127 | QString server, user, pass; | 127 | QString server, user, pass; |
128 | uint16_t port; | 128 | uint16_t port; |
129 | int err = MAILIMAP_NO_ERROR; | 129 | int err = MAILIMAP_NO_ERROR; |
130 | 130 | ||
131 | if (account->getOffline()) return; | 131 | if (account->getOffline()) return; |
132 | /* we are connected this moment */ | 132 | /* we are connected this moment */ |
133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ | 133 | /* TODO: setup a timer holding the line or if connection closed - delete the value */ |
134 | if (m_imap) { | 134 | if (m_imap) { |
135 | err = mailimap_noop(m_imap); | 135 | err = mailimap_noop(m_imap); |
136 | if (err!=MAILIMAP_NO_ERROR) { | 136 | if (err!=MAILIMAP_NO_ERROR) { |
137 | logout(); | 137 | logout(); |
138 | } else { | 138 | } else { |
139 | mailstream_flush(m_imap->imap_stream); | 139 | mailstream_flush(m_imap->imap_stream); |
140 | return; | 140 | return; |
141 | } | 141 | } |
142 | } | 142 | } |
@@ -417,147 +417,148 @@ RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) | |||
417 | mailimap_flag_fetch*cflag; | 417 | mailimap_flag_fetch*cflag; |
418 | int size; | 418 | int size; |
419 | QBitArray mFlags(7); | 419 | QBitArray mFlags(7); |
420 | QStringList addresslist; | 420 | QStringList addresslist; |
421 | 421 | ||
422 | if (!m_att) { | 422 | if (!m_att) { |
423 | return m; | 423 | return m; |
424 | } | 424 | } |
425 | m = new RecMail(); | 425 | m = new RecMail(); |
426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { | 426 | for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { |
427 | current = c; | 427 | current = c; |
428 | size = 0; | 428 | size = 0; |
429 | item = (mailimap_msg_att_item*)current->data; | 429 | item = (mailimap_msg_att_item*)current->data; |
430 | if ( !item ) | 430 | if ( !item ) |
431 | continue; | 431 | continue; |
432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { | 432 | if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { |
433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; | 433 | flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; |
434 | if (!flist || !flist->att_list) { | 434 | if (!flist || !flist->att_list) { |
435 | continue; | 435 | continue; |
436 | } | 436 | } |
437 | cf = flist->att_list->first; | 437 | cf = flist->att_list->first; |
438 | if( ! cf ) | 438 | if( ! cf ) |
439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { | 439 | for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { |
440 | cflag = (mailimap_flag_fetch*)cf->data; | 440 | cflag = (mailimap_flag_fetch*)cf->data; |
441 | if( ! cflag ) | 441 | if( ! cflag ) |
442 | qDebug("imap:not cflag "); | 442 | qDebug("imap:not cflag "); |
443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { | 443 | if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { |
444 | switch (cflag->fl_flag->fl_type) { | 444 | switch (cflag->fl_flag->fl_type) { |
445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ | 445 | case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ |
446 | mFlags.setBit(FLAG_ANSWERED); | 446 | mFlags.setBit(FLAG_ANSWERED); |
447 | break; | 447 | break; |
448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ | 448 | case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ |
449 | mFlags.setBit(FLAG_FLAGGED); | 449 | mFlags.setBit(FLAG_FLAGGED); |
450 | break; | 450 | break; |
451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ | 451 | case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ |
452 | mFlags.setBit(FLAG_DELETED); | 452 | mFlags.setBit(FLAG_DELETED); |
453 | break; | 453 | break; |
454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ | 454 | case MAILIMAP_FLAG_SEEN: /* \Seen flag */ |
455 | mFlags.setBit(FLAG_SEEN); | 455 | mFlags.setBit(FLAG_SEEN); |
456 | break; | 456 | break; |
457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ | 457 | case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ |
458 | mFlags.setBit(FLAG_DRAFT); | 458 | mFlags.setBit(FLAG_DRAFT); |
459 | break; | 459 | break; |
460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ | 460 | case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ |
461 | break; | 461 | break; |
462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ | 462 | case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ |
463 | break; | 463 | break; |
464 | default: | 464 | default: |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { | 467 | } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) { |
468 | mFlags.setBit(FLAG_RECENT); | 468 | mFlags.setBit(FLAG_RECENT); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | continue; | 471 | continue; |
472 | } | 472 | } |
473 | if ( item->att_data.att_static == NULL ) | 473 | if ( item->att_data.att_static == NULL ) |
474 | continue; | 474 | continue; |
475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { | 475 | if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { |
476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; | 476 | mailimap_envelope * head = item->att_data.att_static->att_data.att_env; |
477 | if ( head == NULL ) | 477 | if ( head == NULL ) |
478 | continue; | 478 | continue; |
479 | if ( head->env_date != NULL ) { | 479 | if ( head->env_date != NULL ) { |
480 | m->setDate(head->env_date); | 480 | m->setDate(head->env_date); |
481 | struct mailimf_date_time result; | 481 | //struct mailimf_date_time result; |
482 | struct mailimf_date_time* date = &result; | 482 | struct mailimf_date_time* date;// = &result; |
483 | struct mailimf_date_time **re = &date; | 483 | struct mailimf_date_time **re = &date; |
484 | size_t length = m->getDate().length(); | 484 | size_t length = m->getDate().length(); |
485 | size_t index = 0; | 485 | size_t index = 0; |
486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { | 486 | if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { |
487 | QDateTime dt = Genericwrapper::parseDateTime( date ); | 487 | QDateTime dt = Genericwrapper::parseDateTime( date ); |
488 | QString ret; | 488 | QString ret; |
489 | if ( dt.date() == QDate::currentDate () ) | 489 | if ( dt.date() == QDate::currentDate () ) |
490 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 490 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
491 | else { | 491 | else { |
492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 492 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
493 | } | 493 | } |
494 | m->setDate( ret ); | 494 | m->setDate( ret ); |
495 | char tmp[20]; | 495 | char tmp[20]; |
496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", | 496 | snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", |
497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); | 497 | dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); |
498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); | 498 | //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); |
499 | m->setIsoDate( QString( tmp ) ); | 499 | m->setIsoDate( QString( tmp ) ); |
500 | mailimf_date_time_free ( date ); | ||
500 | } else { | 501 | } else { |
501 | m->setIsoDate(head->env_date); | 502 | m->setIsoDate(head->env_date); |
502 | } | 503 | } |
503 | } | 504 | } |
504 | if ( head->env_subject != NULL ) | 505 | if ( head->env_subject != NULL ) |
505 | m->setSubject(convert_String((const char*)head->env_subject)); | 506 | m->setSubject(convert_String((const char*)head->env_subject)); |
506 | //m->setSubject(head->env_subject); | 507 | //m->setSubject(head->env_subject); |
507 | if (head->env_from!=NULL) { | 508 | if (head->env_from!=NULL) { |
508 | addresslist = address_list_to_stringlist(head->env_from->frm_list); | 509 | addresslist = address_list_to_stringlist(head->env_from->frm_list); |
509 | if (addresslist.count()) { | 510 | if (addresslist.count()) { |
510 | m->setFrom(addresslist.first()); | 511 | m->setFrom(addresslist.first()); |
511 | } | 512 | } |
512 | } | 513 | } |
513 | if (head->env_to!=NULL) { | 514 | if (head->env_to!=NULL) { |
514 | addresslist = address_list_to_stringlist(head->env_to->to_list); | 515 | addresslist = address_list_to_stringlist(head->env_to->to_list); |
515 | m->setTo(addresslist); | 516 | m->setTo(addresslist); |
516 | } | 517 | } |
517 | if (head->env_cc!=NULL) { | 518 | if (head->env_cc!=NULL) { |
518 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); | 519 | addresslist = address_list_to_stringlist(head->env_cc->cc_list); |
519 | m->setCC(addresslist); | 520 | m->setCC(addresslist); |
520 | } | 521 | } |
521 | if (head->env_bcc!=NULL) { | 522 | if (head->env_bcc!=NULL) { |
522 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); | 523 | addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); |
523 | m->setBcc(addresslist); | 524 | m->setBcc(addresslist); |
524 | } | 525 | } |
525 | /* reply to address, eg. email. */ | 526 | /* reply to address, eg. email. */ |
526 | if (head->env_reply_to!=NULL) { | 527 | if (head->env_reply_to!=NULL) { |
527 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); | 528 | addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); |
528 | if (addresslist.count()) { | 529 | if (addresslist.count()) { |
529 | m->setReplyto(addresslist.first()); | 530 | m->setReplyto(addresslist.first()); |
530 | } | 531 | } |
531 | } | 532 | } |
532 | if (head->env_in_reply_to!=NULL) { | 533 | if (head->env_in_reply_to!=NULL) { |
533 | QString h(head->env_in_reply_to); | 534 | QString h(head->env_in_reply_to); |
534 | while (h.length()>0 && h[0]=='<') { | 535 | while (h.length()>0 && h[0]=='<') { |
535 | h.remove(0,1); | 536 | h.remove(0,1); |
536 | } | 537 | } |
537 | while (h.length()>0 && h[h.length()-1]=='>') { | 538 | while (h.length()>0 && h[h.length()-1]=='>') { |
538 | h.remove(h.length()-1,1); | 539 | h.remove(h.length()-1,1); |
539 | } | 540 | } |
540 | if (h.length()>0) { | 541 | if (h.length()>0) { |
541 | m->setInreply(QStringList(h)); | 542 | m->setInreply(QStringList(h)); |
542 | } | 543 | } |
543 | } | 544 | } |
544 | if (head->env_message_id != NULL) { | 545 | if (head->env_message_id != NULL) { |
545 | m->setMsgid(QString(head->env_message_id)); | 546 | m->setMsgid(QString(head->env_message_id)); |
546 | } | 547 | } |
547 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { | 548 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { |
548 | #if 0 | 549 | #if 0 |
549 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; | 550 | mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; |
550 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); | 551 | QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); |
551 | qDebug("time %s ",da.toString().latin1() ); | 552 | qDebug("time %s ",da.toString().latin1() ); |
552 | #endif | 553 | #endif |
553 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { | 554 | } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { |
554 | size = item->att_data.att_static->att_data.att_rfc822_size; | 555 | size = item->att_data.att_static->att_data.att_rfc822_size; |
555 | } | 556 | } |
556 | } | 557 | } |
557 | /* msg is already deleted */ | 558 | /* msg is already deleted */ |
558 | if (mFlags.testBit(FLAG_DELETED) && m) { | 559 | if (mFlags.testBit(FLAG_DELETED) && m) { |
559 | delete m; | 560 | delete m; |
560 | m = 0; | 561 | m = 0; |
561 | } | 562 | } |
562 | if (m) { | 563 | if (m) { |
563 | m->setFlags(mFlags); | 564 | m->setFlags(mFlags); |
diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 5d2c0ad..04afe7c 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp | |||
@@ -1,87 +1,88 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | #include <qdir.h> | 2 | #include <qdir.h> |
3 | 3 | ||
4 | //#include <opie2/odebug.h> | 4 | //#include <opie2/odebug.h> |
5 | #include <kconfig.h> | 5 | #include <kconfig.h> |
6 | 6 | ||
7 | #include <kstandarddirs.h> | 7 | #include <kstandarddirs.h> |
8 | #include "settings.h" | 8 | #include "settings.h" |
9 | //#include "defines.h" | 9 | //#include "defines.h" |
10 | 10 | ||
11 | #define IMAP_PORT "143" | 11 | #define IMAP_PORT "143" |
12 | #define IMAP_SSL_PORT "993" | 12 | #define IMAP_SSL_PORT "993" |
13 | #define SMTP_PORT "25" | 13 | #define SMTP_PORT "25" |
14 | #define SMTP_SSL_PORT "465" | 14 | #define SMTP_SSL_PORT "465" |
15 | #define POP3_PORT "110" | 15 | #define POP3_PORT "110" |
16 | #define POP3_SSL_PORT "995" | 16 | #define POP3_SSL_PORT "995" |
17 | #define NNTP_PORT "119" | 17 | #define NNTP_PORT "119" |
18 | #define NNTP_SSL_PORT "563" | 18 | #define NNTP_SSL_PORT "563" |
19 | 19 | ||
20 | 20 | ||
21 | Settings::Settings() | 21 | Settings::Settings() |
22 | : QObject() | 22 | : QObject() |
23 | { | 23 | { |
24 | accounts.setAutoDelete( true ); ; | ||
24 | updateAccounts(); | 25 | updateAccounts(); |
25 | //qDebug("++++++++++++++++++new settings "); | 26 | //qDebug("++++++++++++++++++new settings "); |
26 | } | 27 | } |
27 | 28 | ||
28 | void Settings::checkDirectory() | 29 | void Settings::checkDirectory() |
29 | { | 30 | { |
30 | return; | 31 | return; |
31 | locateLocal("data", "kopiemail" ); | 32 | locateLocal("data", "kopiemail" ); |
32 | /* | 33 | /* |
33 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { | 34 | if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { |
34 | system( "mkdir -p $HOME/Applications/opiemail" ); | 35 | system( "mkdir -p $HOME/Applications/opiemail" ); |
35 | qDebug("$HOME/Applications/opiemail created "); | 36 | qDebug("$HOME/Applications/opiemail created "); |
36 | } | 37 | } |
37 | */ | 38 | */ |
38 | } | 39 | } |
39 | 40 | ||
40 | QList<Account> Settings::getAccounts() | 41 | QList<Account> Settings::getAccounts() |
41 | { | 42 | { |
42 | return accounts; | 43 | return accounts; |
43 | } | 44 | } |
44 | 45 | ||
45 | void Settings::addAccount( Account *account ) | 46 | void Settings::addAccount( Account *account ) |
46 | { | 47 | { |
47 | accounts.append( account ); | 48 | accounts.append( account ); |
48 | } | 49 | } |
49 | 50 | ||
50 | void Settings::delAccount( Account *account ) | 51 | void Settings::delAccount( Account *account ) |
51 | { | 52 | { |
52 | accounts.remove( account ); | 53 | accounts.remove( account ); |
53 | account->remove(); | 54 | account->remove(); |
54 | } | 55 | } |
55 | 56 | ||
56 | void Settings::updateAccounts() | 57 | void Settings::updateAccounts() |
57 | { | 58 | { |
58 | accounts.clear(); | 59 | accounts.clear(); |
59 | QDir dir( locateLocal("data", "kopiemail" ) ); | 60 | QDir dir( locateLocal("data", "kopiemail" ) ); |
60 | QStringList::Iterator it; | 61 | QStringList::Iterator it; |
61 | 62 | ||
62 | QStringList imap = dir.entryList( "imap-*" ); | 63 | QStringList imap = dir.entryList( "imap-*" ); |
63 | for ( it = imap.begin(); it != imap.end(); it++ ) { | 64 | for ( it = imap.begin(); it != imap.end(); it++ ) { |
64 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); | 65 | IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); |
65 | accounts.append( account ); | 66 | accounts.append( account ); |
66 | } | 67 | } |
67 | 68 | ||
68 | QStringList pop3 = dir.entryList( "pop3-*" ); | 69 | QStringList pop3 = dir.entryList( "pop3-*" ); |
69 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { | 70 | for ( it = pop3.begin(); it != pop3.end(); it++ ) { |
70 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); | 71 | POP3account *account = new POP3account( (*it).replace(0, 5, "") ); |
71 | accounts.append( account ); | 72 | accounts.append( account ); |
72 | } | 73 | } |
73 | 74 | ||
74 | QStringList smtp = dir.entryList( "smtp-*" ); | 75 | QStringList smtp = dir.entryList( "smtp-*" ); |
75 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { | 76 | for ( it = smtp.begin(); it != smtp.end(); it++ ) { |
76 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); | 77 | SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") ); |
77 | accounts.append( account ); | 78 | accounts.append( account ); |
78 | } | 79 | } |
79 | 80 | ||
80 | QStringList nntp = dir.entryList( "nntp-*" ); | 81 | QStringList nntp = dir.entryList( "nntp-*" ); |
81 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { | 82 | for ( it = nntp.begin(); it != nntp.end(); it++ ) { |
82 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); | 83 | NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") ); |
83 | accounts.append( account ); | 84 | accounts.append( account ); |
84 | } | 85 | } |
85 | 86 | ||
86 | readAccounts(); | 87 | readAccounts(); |
87 | } | 88 | } |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 8d16ae7..af5376f 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,89 +1,90 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "koprefsdialog.h" | 4 | #include "koprefsdialog.h" |
5 | #include <kapplication.h> | 5 | #include <kapplication.h> |
6 | #include <libkdepim/externalapphandler.h> | 6 | #include <libkdepim/externalapphandler.h> |
7 | #include <libkdepim/kpimglobalprefs.h> | 7 | #include <libkdepim/kpimglobalprefs.h> |
8 | #ifdef MINIKDE_KDIALOG_H | 8 | #ifdef MINIKDE_KDIALOG_H |
9 | #undef MINIKDE_KDIALOG_H | 9 | #undef MINIKDE_KDIALOG_H |
10 | #endif | 10 | #endif |
11 | #include "settingsdialog.h" | 11 | #include "settingsdialog.h" |
12 | #include "opiemail.h" | 12 | #include "opiemail.h" |
13 | #include "editaccounts.h" | 13 | #include "editaccounts.h" |
14 | #include "composemail.h" | 14 | #include "composemail.h" |
15 | #include "mailistviewitem.h" | 15 | #include "mailistviewitem.h" |
16 | #include "viewmail.h" | 16 | #include "viewmail.h" |
17 | #include "selectstore.h" | 17 | #include "selectstore.h" |
18 | #include "selectsmtp.h" | 18 | #include "selectsmtp.h" |
19 | #include "accountitem.h" | 19 | #include "accountitem.h" |
20 | #include "klocale.h" | 20 | #include "klocale.h" |
21 | 21 | ||
22 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qpe/global.h> | ||
26 | 27 | ||
27 | #ifdef DESKTOP_VERSION | 28 | #ifdef DESKTOP_VERSION |
28 | #include <qapplication.h> | 29 | #include <qapplication.h> |
29 | #else | 30 | #else |
30 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
31 | #endif | 32 | #endif |
32 | #include <libmailwrapper/smtpwrapper.h> | 33 | #include <libmailwrapper/smtpwrapper.h> |
33 | #include <libmailwrapper/mailtypes.h> | 34 | #include <libmailwrapper/mailtypes.h> |
34 | #include <libmailwrapper/abstractmail.h> | 35 | #include <libmailwrapper/abstractmail.h> |
35 | 36 | ||
36 | //using namespace Opie::Core; | 37 | //using namespace Opie::Core; |
37 | 38 | ||
38 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 39 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
39 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 40 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
40 | { | 41 | { |
41 | settings = new Settings(); | 42 | settings = new Settings(); |
42 | 43 | ||
43 | setIcon(SmallIcon( "kmicromail" ) ); | 44 | setIcon(SmallIcon( "kmicromail" ) ); |
44 | folderView->populate( settings->getAccounts() ); | 45 | folderView->populate( settings->getAccounts() ); |
45 | 46 | ||
46 | } | 47 | } |
47 | 48 | ||
48 | OpieMail::~OpieMail() | 49 | OpieMail::~OpieMail() |
49 | { | 50 | { |
50 | if (settings) delete settings; | 51 | if (settings) delete settings; |
51 | } | 52 | } |
52 | 53 | ||
53 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 54 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
54 | { | 55 | { |
55 | 56 | ||
56 | } | 57 | } |
57 | #include <stdlib.h> | 58 | #include <stdlib.h> |
58 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 59 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
59 | { | 60 | { |
60 | // copied from old mail2 | 61 | // copied from old mail2 |
61 | static int ii = 0; | 62 | static int ii = 0; |
62 | //qDebug("QCOP CALL ############################# %d ", ii); | 63 | //qDebug("QCOP CALL ############################# %d ", ii); |
63 | //QString mess ( msg ); | 64 | //QString mess ( msg ); |
64 | //qDebug("Message = %s ",mess.latin1()); | 65 | //qDebug("Message = %s ",mess.latin1()); |
65 | ++ii; | 66 | ++ii; |
66 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 67 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
67 | 68 | ||
68 | mPendingEmail = QString::null; | 69 | mPendingEmail = QString::null; |
69 | mPendingName = QString::null; | 70 | mPendingName = QString::null; |
70 | if (msg == "writeMail(QString,QString)") | 71 | if (msg == "writeMail(QString,QString)") |
71 | { | 72 | { |
72 | //qDebug("writeMail(QString,QString) "); | 73 | //qDebug("writeMail(QString,QString) "); |
73 | QDataStream stream(data,IO_ReadOnly); | 74 | QDataStream stream(data,IO_ReadOnly); |
74 | stream >> mPendingName >> mPendingEmail; | 75 | stream >> mPendingName >> mPendingEmail; |
75 | // removing the whitespaces at beginning and end is needed! | 76 | // removing the whitespaces at beginning and end is needed! |
76 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 77 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
77 | } | 78 | } |
78 | else if (msg == "newMail()") | 79 | else if (msg == "newMail()") |
79 | { | 80 | { |
80 | //qDebug("slotComposeMail() "); | 81 | //qDebug("slotComposeMail() "); |
81 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 82 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
82 | // and a QCOP call does not like a processevents in his execution | 83 | // and a QCOP call does not like a processevents in his execution |
83 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 84 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
84 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 85 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
85 | // slotComposeMail(); | 86 | // slotComposeMail(); |
86 | } | 87 | } |
87 | else if (msg == "newMail(QString)") | 88 | else if (msg == "newMail(QString)") |
88 | { | 89 | { |
89 | //qDebug(" newMail(QString)"); | 90 | //qDebug(" newMail(QString)"); |
@@ -128,154 +129,159 @@ void OpieMail::slotwriteMail2(const QString& namemail ) | |||
128 | #ifndef DESKTOP_VERSION | 129 | #ifndef DESKTOP_VERSION |
129 | compose.showMaximized(); | 130 | compose.showMaximized(); |
130 | #endif | 131 | #endif |
131 | compose.exec(); | 132 | compose.exec(); |
132 | raise(); | 133 | raise(); |
133 | //qDebug("retttich "); | 134 | //qDebug("retttich "); |
134 | } | 135 | } |
135 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 136 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
136 | { | 137 | { |
137 | // qDebug("OpieMail::slotwriteMail "); | 138 | // qDebug("OpieMail::slotwriteMail "); |
138 | ComposeMail compose( settings, this, 0, true ); | 139 | ComposeMail compose( settings, this, 0, true ); |
139 | if (!email.isEmpty()) | 140 | if (!email.isEmpty()) |
140 | { | 141 | { |
141 | if (!name.isEmpty()) | 142 | if (!name.isEmpty()) |
142 | { | 143 | { |
143 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); | 144 | compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); |
144 | } | 145 | } |
145 | else | 146 | else |
146 | { | 147 | { |
147 | compose.setTo(email); | 148 | compose.setTo(email); |
148 | } | 149 | } |
149 | } | 150 | } |
150 | compose.slotAdjustColumns(); | 151 | compose.slotAdjustColumns(); |
151 | #ifndef DESKTOP_VERSION | 152 | #ifndef DESKTOP_VERSION |
152 | compose.showMaximized(); | 153 | compose.showMaximized(); |
153 | #endif | 154 | #endif |
154 | compose.exec(); | 155 | compose.exec(); |
155 | raise(); | 156 | raise(); |
156 | } | 157 | } |
157 | 158 | ||
158 | void OpieMail::slotComposeMail() | 159 | void OpieMail::slotComposeMail() |
159 | { | 160 | { |
160 | if ( mPendingEmail == QString::null && mPendingName == QString::null) | 161 | if ( mPendingEmail == QString::null && mPendingName == QString::null) |
161 | slotwriteMail2( QString () ); | 162 | slotwriteMail2( QString () ); |
162 | else { | 163 | else { |
163 | if ( mPendingEmail == QString::null ) | 164 | if ( mPendingEmail == QString::null ) |
164 | slotwriteMail2( mPendingName ); | 165 | slotwriteMail2( mPendingName ); |
165 | else | 166 | else |
166 | slotwriteMail( mPendingName, mPendingEmail ); | 167 | slotwriteMail( mPendingName, mPendingEmail ); |
167 | } | 168 | } |
168 | //slotwriteMail(0l,0l); | 169 | //slotwriteMail(0l,0l); |
169 | } | 170 | } |
170 | 171 | ||
171 | void OpieMail::slotSendQueued() | 172 | void OpieMail::slotSendQueued() |
172 | { | 173 | { |
173 | SMTPaccount *smtp = 0; | 174 | SMTPaccount *smtp = 0; |
174 | 175 | ||
175 | QList<Account> list = settings->getAccounts(); | 176 | QList<Account> list = settings->getAccounts(); |
176 | QList<SMTPaccount> smtpList; | 177 | QList<SMTPaccount> smtpList; |
177 | smtpList.setAutoDelete(false); | 178 | smtpList.setAutoDelete(false); |
178 | Account *it; | 179 | Account *it; |
179 | for ( it = list.first(); it; it = list.next() ) | 180 | for ( it = list.first(); it; it = list.next() ) |
180 | { | 181 | { |
181 | if ( it->getType() == MAILLIB::A_SMTP ) | 182 | if ( it->getType() == MAILLIB::A_SMTP ) |
182 | { | 183 | { |
183 | smtp = static_cast<SMTPaccount *>(it); | 184 | smtp = static_cast<SMTPaccount *>(it); |
184 | smtpList.append(smtp); | 185 | smtpList.append(smtp); |
185 | } | 186 | } |
186 | } | 187 | } |
187 | if (smtpList.count()==0) | 188 | if (smtpList.count()==0) |
188 | { | 189 | { |
189 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); | 190 | QMessageBox::information(0,i18n("Info"),i18n("Define a smtp account first!\n")); |
190 | return; | 191 | return; |
191 | } | 192 | } |
193 | if ( QMessageBox::warning(this, i18n("Sending all mails"), i18n("Do you really want to send\nall queued mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No ) | ||
194 | return; | ||
192 | if (smtpList.count()==1) | 195 | if (smtpList.count()==1) |
193 | { | 196 | { |
194 | smtp = smtpList.at(0); | 197 | smtp = smtpList.at(0); |
195 | } | 198 | } |
196 | else | 199 | else |
197 | { | 200 | { |
198 | smtp = 0; | 201 | smtp = 0; |
199 | selectsmtp selsmtp; | 202 | selectsmtp selsmtp; |
200 | selsmtp.setSelectionlist(&smtpList); | 203 | selsmtp.setSelectionlist(&smtpList); |
201 | #ifndef DESKTOP_VERSION | 204 | #ifndef DESKTOP_VERSION |
202 | selsmtp.showMaximized(); | 205 | selsmtp.showMaximized(); |
203 | #endif | 206 | #endif |
204 | if ( selsmtp.exec() == QDialog::Accepted ) | 207 | if ( selsmtp.exec() == QDialog::Accepted ) |
205 | { | 208 | { |
206 | smtp = selsmtp.selected_smtp(); | 209 | smtp = selsmtp.selected_smtp(); |
207 | } | 210 | } |
208 | } | 211 | } |
209 | if (smtp) | 212 | if (smtp) |
210 | { | 213 | { |
214 | |||
215 | Global::statusMessage("Sending mails...!"); | ||
211 | SMTPwrapper * wrap = new SMTPwrapper(smtp); | 216 | SMTPwrapper * wrap = new SMTPwrapper(smtp); |
212 | if ( wrap->flushOutbox() ) | 217 | if ( wrap->flushOutbox() ) |
213 | { | 218 | { |
214 | QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); | 219 | Global::statusMessage("Mails sent!"); |
215 | } | 220 | } |
216 | delete wrap; | 221 | delete wrap; |
217 | } | 222 | } |
223 | // pending refresh list view, if outgoing is displayed | ||
218 | } | 224 | } |
219 | 225 | ||
220 | void OpieMail::slotSearchMails() | 226 | void OpieMail::slotSearchMails() |
221 | { | 227 | { |
222 | qDebug("OpieMail::slotSearchMails():not implemented "); | 228 | qDebug("OpieMail::slotSearchMails():not implemented "); |
223 | } | 229 | } |
224 | 230 | ||
225 | void OpieMail::slotEditSettings() | 231 | void OpieMail::slotEditSettings() |
226 | { | 232 | { |
227 | 233 | ||
228 | KOPrefsDialog settingsDialog( this, "koprefs", true ); | 234 | KOPrefsDialog settingsDialog( this, "koprefs", true ); |
229 | #ifndef DESKTOP_VERSION | 235 | #ifndef DESKTOP_VERSION |
230 | settingsDialog.showMaximized(); | 236 | settingsDialog.showMaximized(); |
231 | #endif | 237 | #endif |
232 | settingsDialog.exec(); | 238 | settingsDialog.exec(); |
233 | 239 | ||
234 | // KApplication::execDialog(settingsDialog); | 240 | // KApplication::execDialog(settingsDialog); |
235 | } | 241 | } |
236 | 242 | ||
237 | void OpieMail::slotEditAccounts() | 243 | void OpieMail::slotEditAccounts() |
238 | { | 244 | { |
239 | EditAccounts eaDialog( settings, this, 0, true ); | 245 | EditAccounts eaDialog( settings, this, 0, true ); |
240 | eaDialog.slotAdjustColumns(); | 246 | eaDialog.slotAdjustColumns(); |
241 | #ifndef DESKTOP_VERSION | 247 | #ifndef DESKTOP_VERSION |
242 | eaDialog.showMaximized(); | 248 | eaDialog.showMaximized(); |
243 | #endif | 249 | #endif |
244 | eaDialog.exec(); | 250 | eaDialog.exec(); |
245 | if ( settings ) delete settings; | 251 | if ( settings ) delete settings; |
246 | settings = new Settings(); | 252 | settings = new Settings(); |
247 | 253 | ||
248 | folderView->populate( settings->getAccounts() ); | 254 | folderView->populate( settings->getAccounts() ); |
249 | } | 255 | } |
250 | void OpieMail::replyMail() | 256 | void OpieMail::replyMail() |
251 | { | 257 | { |
252 | 258 | ||
253 | QListViewItem*item = mailView->currentItem(); | 259 | QListViewItem*item = mailView->currentItem(); |
254 | if (!item) return; | 260 | if (!item) return; |
255 | RecMailP mail = ((MailListViewItem*)item)->data(); | 261 | RecMailP mail = ((MailListViewItem*)item)->data(); |
256 | RecBodyP body = folderView->fetchBody(mail); | 262 | RecBodyP body = folderView->fetchBody(mail); |
257 | 263 | ||
258 | QString rtext; | 264 | QString rtext; |
259 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose | 265 | rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose |
260 | .arg( QString::fromUtf8( mail->getFrom().latin1())) | 266 | .arg( QString::fromUtf8( mail->getFrom().latin1())) |
261 | .arg( QString::fromUtf8( mail->getDate().latin1() )); | 267 | .arg( QString::fromUtf8( mail->getDate().latin1() )); |
262 | 268 | ||
263 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); | 269 | QString text = QString::fromUtf8( body->Bodytext().latin1() ); |
264 | QStringList lines = QStringList::split(QRegExp("\\n"), text); | 270 | QStringList lines = QStringList::split(QRegExp("\\n"), text); |
265 | QStringList::Iterator it; | 271 | QStringList::Iterator it; |
266 | for (it = lines.begin(); it != lines.end(); it++) | 272 | for (it = lines.begin(); it != lines.end(); it++) |
267 | { | 273 | { |
268 | rtext += "> " + *it + "\n"; | 274 | rtext += "> " + *it + "\n"; |
269 | } | 275 | } |
270 | rtext += "\n"; | 276 | rtext += "\n"; |
271 | 277 | ||
272 | QString prefix; | 278 | QString prefix; |
273 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; | 279 | if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; |
274 | else prefix = "Re: "; // no i18n on purpose | 280 | else prefix = "Re: "; // no i18n on purpose |
275 | 281 | ||
276 | Settings *settings = new Settings(); | 282 | Settings *settings = new Settings(); |
277 | ComposeMail composer( settings ,this, 0, true); | 283 | ComposeMail composer( settings ,this, 0, true); |
278 | if (mail->Replyto().isEmpty()) { | 284 | if (mail->Replyto().isEmpty()) { |
279 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); | 285 | composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); |
280 | } else { | 286 | } else { |
281 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); | 287 | composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); |
@@ -369,128 +375,129 @@ void OpieMail::clearSelection() | |||
369 | mailView->clearSelection(); | 375 | mailView->clearSelection(); |
370 | 376 | ||
371 | } | 377 | } |
372 | 378 | ||
373 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) | 379 | void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) |
374 | { | 380 | { |
375 | if (!mailView->currentItem()) return; | 381 | if (!mailView->currentItem()) return; |
376 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); | 382 | MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); |
377 | /* just the RIGHT button - or hold on pda */ | 383 | /* just the RIGHT button - or hold on pda */ |
378 | if (button!=2) {return;} | 384 | if (button!=2) {return;} |
379 | if (!item) return; | 385 | if (!item) return; |
380 | QPopupMenu *m = new QPopupMenu(0); | 386 | QPopupMenu *m = new QPopupMenu(0); |
381 | if (m) | 387 | if (m) |
382 | { | 388 | { |
383 | if (mailtype==MAILLIB::A_NNTP) { | 389 | if (mailtype==MAILLIB::A_NNTP) { |
384 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); | 390 | m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); |
385 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); | 391 | m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); |
386 | m->insertSeparator(); | 392 | m->insertSeparator(); |
387 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); | 393 | m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); |
388 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 394 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
389 | } else { | 395 | } else { |
390 | if (folderView->currentisDraft()) { | 396 | if (folderView->currentisDraft()) { |
391 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); | 397 | m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); |
392 | } | 398 | } |
393 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); | 399 | m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); |
394 | m->insertSeparator(); | 400 | m->insertSeparator(); |
395 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); | 401 | m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); |
396 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); | 402 | m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); |
397 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); | 403 | m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); |
398 | m->insertSeparator(); | 404 | m->insertSeparator(); |
399 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); | 405 | m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); |
400 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); | 406 | m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); |
401 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); | 407 | m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); |
402 | } | 408 | } |
403 | m->setFocus(); | 409 | m->setFocus(); |
404 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); | 410 | m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); |
405 | delete m; | 411 | delete m; |
406 | } | 412 | } |
407 | } | 413 | } |
408 | 414 | ||
409 | void OpieMail::slotShowFolders( bool show ) | 415 | void OpieMail::slotShowFolders( bool show ) |
410 | { | 416 | { |
411 | if ( show && folderView->isHidden() ) | 417 | if ( show && folderView->isHidden() ) |
412 | { | 418 | { |
413 | folderView->show(); | 419 | folderView->show(); |
414 | } | 420 | } |
415 | else if ( !show && !folderView->isHidden() ) | 421 | else if ( !show && !folderView->isHidden() ) |
416 | { | 422 | { |
417 | folderView->hide(); | 423 | folderView->hide(); |
418 | } | 424 | } |
419 | } | 425 | } |
420 | 426 | ||
421 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) | 427 | void OpieMail::refreshMailView(const QValueList<RecMailP>&list) |
422 | { | 428 | { |
423 | MailListViewItem*item = 0; | 429 | MailListViewItem*item = 0; |
424 | mailView->clear(); | 430 | mailView->clear(); |
425 | 431 | ||
426 | QValueList<RecMailP>::ConstIterator it; | 432 | QValueList<RecMailP>::ConstIterator it; |
427 | for (it = list.begin(); it != list.end();++it) | 433 | for (it = list.begin(); it != list.end();++it) |
428 | { | 434 | { |
429 | item = new MailListViewItem(mailView,item); | 435 | item = new MailListViewItem(mailView,item); |
430 | item->storeData((*it)); | 436 | item->storeData((*it)); |
431 | item->showEntry(); | 437 | item->showEntry(); |
432 | } | 438 | } |
439 | mailView->setSorting ( 4, false ); | ||
433 | } | 440 | } |
434 | 441 | ||
435 | void OpieMail::mailLeftClicked( QListViewItem *item ) | 442 | void OpieMail::mailLeftClicked( QListViewItem *item ) |
436 | { | 443 | { |
437 | mailView->clearSelection(); | 444 | mailView->clearSelection(); |
438 | /* just LEFT button - or tap with stylus on pda */ | 445 | /* just LEFT button - or tap with stylus on pda */ |
439 | //if (button!=1) return; | 446 | //if (button!=1) return; |
440 | if (!item) return; | 447 | if (!item) return; |
441 | if (folderView->currentisDraft()) { | 448 | if (folderView->currentisDraft()) { |
442 | reEditMail(); | 449 | reEditMail(); |
443 | } else { | 450 | } else { |
444 | displayMail(); | 451 | displayMail(); |
445 | } | 452 | } |
446 | } | 453 | } |
447 | 454 | ||
448 | void OpieMail::slotMoveCopyMail() | 455 | void OpieMail::slotMoveCopyMail() |
449 | { | 456 | { |
450 | if (!mailView->currentItem()) return; | 457 | if (!mailView->currentItem()) return; |
451 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); | 458 | RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); |
452 | AbstractMail*targetMail = 0; | 459 | AbstractMail*targetMail = 0; |
453 | QString targetFolder = ""; | 460 | QString targetFolder = ""; |
454 | Selectstore sels; | 461 | Selectstore sels; |
455 | folderView->setupFolderselect(&sels); | 462 | folderView->setupFolderselect(&sels); |
456 | if (!sels.exec()) return; | 463 | if (!sels.exec()) return; |
457 | targetMail = sels.currentMail(); | 464 | targetMail = sels.currentMail(); |
458 | targetFolder = sels.currentFolder(); | 465 | targetFolder = sels.currentFolder(); |
459 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || | 466 | if ( (mail->Wrapper()==targetMail && mail->getMbox()==targetFolder) || |
460 | targetFolder.isEmpty()) | 467 | targetFolder.isEmpty()) |
461 | { | 468 | { |
462 | return; | 469 | return; |
463 | } | 470 | } |
464 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) | 471 | if (sels.newFolder() && !targetMail->createMbox(targetFolder)) |
465 | { | 472 | { |
466 | QMessageBox::critical(0,i18n("Error creating new Folder"), | 473 | QMessageBox::critical(0,i18n("Error creating new Folder"), |
467 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); | 474 | i18n("<center>Error while creating<br>new folder - breaking.</center>")); |
468 | return; | 475 | return; |
469 | } | 476 | } |
470 | sels.hide(); | 477 | sels.hide(); |
471 | qApp->processEvents(); | 478 | qApp->processEvents(); |
472 | // qDebug("hiding sels "); | 479 | // qDebug("hiding sels "); |
473 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); | 480 | mail->Wrapper()->mvcpMail(mail,targetFolder,targetMail,sels.moveMails()); |
474 | folderView->refreshCurrent(); | 481 | folderView->refreshCurrent(); |
475 | } | 482 | } |
476 | 483 | ||
477 | void OpieMail::slotMoveCopyAllMail() | 484 | void OpieMail::slotMoveCopyAllMail() |
478 | { | 485 | { |
479 | 486 | ||
480 | if (!mailView->currentItem()) return; | 487 | if (!mailView->currentItem()) return; |
481 | QValueList<RecMailP> t; | 488 | QValueList<RecMailP> t; |
482 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) | 489 | // if ( QMessageBox::warning(this, i18n("Move/Copy all selected mails"), i18n("Do you really want to copy/move\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
483 | { | 490 | { |
484 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); | 491 | MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); |
485 | while ( item ) { | 492 | while ( item ) { |
486 | if ( item->isSelected() ) { | 493 | if ( item->isSelected() ) { |
487 | t.append( item->data() ); | 494 | t.append( item->data() ); |
488 | } | 495 | } |
489 | item = (MailListViewItem*)item->nextSibling(); | 496 | item = (MailListViewItem*)item->nextSibling(); |
490 | } | 497 | } |
491 | } | 498 | } |
492 | // else | 499 | // else |
493 | // return; | 500 | // return; |
494 | if ( t.count() == 0 ) | 501 | if ( t.count() == 0 ) |
495 | return; | 502 | return; |
496 | RecMailP mail = t.first(); | 503 | RecMailP mail = t.first(); |
diff --git a/libkdepim/kprefswidget.cpp b/libkdepim/kprefswidget.cpp index be9ad30..f6a0b38 100644 --- a/libkdepim/kprefswidget.cpp +++ b/libkdepim/kprefswidget.cpp | |||
@@ -227,128 +227,129 @@ KPrefsWidRadios::~KPrefsWidRadios() | |||
227 | } | 227 | } |
228 | 228 | ||
229 | void KPrefsWidRadios::addRadio(const QString &text) | 229 | void KPrefsWidRadios::addRadio(const QString &text) |
230 | { | 230 | { |
231 | new QRadioButton(text,mBox); | 231 | new QRadioButton(text,mBox); |
232 | } | 232 | } |
233 | 233 | ||
234 | QButtonGroup *KPrefsWidRadios::groupBox() | 234 | QButtonGroup *KPrefsWidRadios::groupBox() |
235 | { | 235 | { |
236 | return mBox; | 236 | return mBox; |
237 | } | 237 | } |
238 | 238 | ||
239 | void KPrefsWidRadios::readConfig() | 239 | void KPrefsWidRadios::readConfig() |
240 | { | 240 | { |
241 | mBox->setButton(*mReference); | 241 | mBox->setButton(*mReference); |
242 | } | 242 | } |
243 | 243 | ||
244 | void KPrefsWidRadios::writeConfig() | 244 | void KPrefsWidRadios::writeConfig() |
245 | { | 245 | { |
246 | *mReference = mBox->id(mBox->selected()); | 246 | *mReference = mBox->id(mBox->selected()); |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, | 250 | KPrefsWidString::KPrefsWidString(const QString &text,QString *reference, |
251 | QWidget *parent, QLineEdit::EchoMode echomode) | 251 | QWidget *parent, QLineEdit::EchoMode echomode) |
252 | { | 252 | { |
253 | mReference = reference; | 253 | mReference = reference; |
254 | 254 | ||
255 | mLabel = new QLabel(text,parent); | 255 | mLabel = new QLabel(text,parent); |
256 | mEdit = new QLineEdit(parent); | 256 | mEdit = new QLineEdit(parent); |
257 | mEdit->setEchoMode( echomode ); | 257 | mEdit->setEchoMode( echomode ); |
258 | connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); | 258 | connect( mEdit, SIGNAL( textChanged(const QString&) ), SIGNAL( modified() ) ); |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | KPrefsWidString::~KPrefsWidString() | 262 | KPrefsWidString::~KPrefsWidString() |
263 | { | 263 | { |
264 | } | 264 | } |
265 | 265 | ||
266 | void KPrefsWidString::readConfig() | 266 | void KPrefsWidString::readConfig() |
267 | { | 267 | { |
268 | mEdit->setText(*mReference); | 268 | mEdit->setText(*mReference); |
269 | } | 269 | } |
270 | 270 | ||
271 | void KPrefsWidString::writeConfig() | 271 | void KPrefsWidString::writeConfig() |
272 | { | 272 | { |
273 | *mReference = mEdit->text(); | 273 | *mReference = mEdit->text(); |
274 | } | 274 | } |
275 | 275 | ||
276 | QLabel *KPrefsWidString::label() | 276 | QLabel *KPrefsWidString::label() |
277 | { | 277 | { |
278 | return mLabel; | 278 | return mLabel; |
279 | } | 279 | } |
280 | 280 | ||
281 | QLineEdit *KPrefsWidString::lineEdit() | 281 | QLineEdit *KPrefsWidString::lineEdit() |
282 | { | 282 | { |
283 | return mEdit; | 283 | return mEdit; |
284 | } | 284 | } |
285 | 285 | ||
286 | 286 | ||
287 | KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : | 287 | KPrefsWidget::KPrefsWidget(KPrefs *prefs,QWidget *parent,const char *name) : |
288 | QWidget(parent, name ) | 288 | QWidget(parent, name ) |
289 | { | 289 | { |
290 | mPrefs = prefs; | 290 | mPrefs = prefs; |
291 | mPrefsWids.setAutoDelete( true ); | ||
291 | } | 292 | } |
292 | 293 | ||
293 | KPrefsWidget::~KPrefsWidget() | 294 | KPrefsWidget::~KPrefsWidget() |
294 | { | 295 | { |
295 | } | 296 | } |
296 | 297 | ||
297 | void KPrefsWidget::addWid(KPrefsWid *wid) | 298 | void KPrefsWidget::addWid(KPrefsWid *wid) |
298 | { | 299 | { |
299 | mPrefsWids.append(wid); | 300 | mPrefsWids.append(wid); |
300 | connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); | 301 | connect( wid, SIGNAL( modified() ), this, SLOT( modified() ) ); |
301 | 302 | ||
302 | } | 303 | } |
303 | 304 | ||
304 | KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) | 305 | KPrefsWidBool *KPrefsWidget::addWidBool(const QString &text,bool *reference,QWidget *parent) |
305 | { | 306 | { |
306 | KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); | 307 | KPrefsWidBool *w = new KPrefsWidBool(text,reference,parent); |
307 | addWid(w); | 308 | addWid(w); |
308 | return w; | 309 | return w; |
309 | } | 310 | } |
310 | 311 | ||
311 | KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) | 312 | KPrefsWidTime *KPrefsWidget::addWidTime(const QString &text,int *reference,QWidget *parent) |
312 | { | 313 | { |
313 | KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); | 314 | KPrefsWidTime *w = new KPrefsWidTime(text,reference,parent); |
314 | addWid(w); | 315 | addWid(w); |
315 | return w; | 316 | return w; |
316 | } | 317 | } |
317 | 318 | ||
318 | KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) | 319 | KPrefsWidColor *KPrefsWidget::addWidColor(const QString &text,QColor *reference,QWidget *parent) |
319 | { | 320 | { |
320 | KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); | 321 | KPrefsWidColor *w = new KPrefsWidColor(text,reference,parent); |
321 | addWid(w); | 322 | addWid(w); |
322 | return w; | 323 | return w; |
323 | } | 324 | } |
324 | 325 | ||
325 | KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) | 326 | KPrefsWidRadios *KPrefsWidget::addWidRadios(const QString &text,int *reference,QWidget *parent) |
326 | { | 327 | { |
327 | KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); | 328 | KPrefsWidRadios *w = new KPrefsWidRadios(text,reference,parent); |
328 | addWid(w); | 329 | addWid(w); |
329 | return w; | 330 | return w; |
330 | } | 331 | } |
331 | 332 | ||
332 | KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent) | 333 | KPrefsWidString *KPrefsWidget::addWidString(const QString &text,QString *reference,QWidget *parent) |
333 | { | 334 | { |
334 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent); | 335 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent); |
335 | addWid(w); | 336 | addWid(w); |
336 | return w; | 337 | return w; |
337 | } | 338 | } |
338 | 339 | ||
339 | KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent) | 340 | KPrefsWidString *KPrefsWidget::addWidPassword(const QString &text,QString *reference,QWidget *parent) |
340 | { | 341 | { |
341 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password); | 342 | KPrefsWidString *w = new KPrefsWidString(text,reference,parent,QLineEdit::Password); |
342 | addWid(w); | 343 | addWid(w); |
343 | return w; | 344 | return w; |
344 | } | 345 | } |
345 | 346 | ||
346 | KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText, | 347 | KPrefsWidFont *KPrefsWidget::addWidFont(const QString &sampleText,const QString &buttonText, |
347 | QFont *reference,QWidget *parent) | 348 | QFont *reference,QWidget *parent) |
348 | { | 349 | { |
349 | KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent); | 350 | KPrefsWidFont *w = new KPrefsWidFont(sampleText,buttonText,reference,parent); |
350 | addWid(w); | 351 | addWid(w); |
351 | return w; | 352 | return w; |
352 | } | 353 | } |
353 | 354 | ||
354 | void KPrefsWidget::setDefaults() | 355 | void KPrefsWidget::setDefaults() |