summaryrefslogtreecommitdiffabout
path: root/kmicromail
Unidiff
Diffstat (limited to 'kmicromail') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/imap/mailimap_parser.c22
-rw-r--r--kmicromail/libmailwrapper/imapwrapper.cpp67
-rw-r--r--kmicromail/viewmailbase.cpp2
3 files changed, 57 insertions, 34 deletions
diff --git a/kmicromail/libetpan/imap/mailimap_parser.c b/kmicromail/libetpan/imap/mailimap_parser.c
index 1c2ecde..560e58a 100644
--- a/kmicromail/libetpan/imap/mailimap_parser.c
+++ b/kmicromail/libetpan/imap/mailimap_parser.c
@@ -2210,386 +2210,404 @@ mailimap_body_fields_parse(mailstream * fd, MMAPString * buffer,
2210 * result = body_fields; 2210 * result = body_fields;
2211 * index = cur_token; 2211 * index = cur_token;
2212 2212
2213 return MAILIMAP_NO_ERROR; 2213 return MAILIMAP_NO_ERROR;
2214 2214
2215 fld_enc_free: 2215 fld_enc_free:
2216 mailimap_body_fld_enc_free(body_fld_enc); 2216 mailimap_body_fld_enc_free(body_fld_enc);
2217 fld_desc_free: 2217 fld_desc_free:
2218 mailimap_body_fld_desc_free(body_fld_desc); 2218 mailimap_body_fld_desc_free(body_fld_desc);
2219 fld_id_free: 2219 fld_id_free:
2220 mailimap_body_fld_id_free(body_fld_id); 2220 mailimap_body_fld_id_free(body_fld_id);
2221 fld_param_free: 2221 fld_param_free:
2222 if (body_fld_param != NULL) 2222 if (body_fld_param != NULL)
2223 mailimap_body_fld_param_free(body_fld_param); 2223 mailimap_body_fld_param_free(body_fld_param);
2224 err: 2224 err:
2225 return res; 2225 return res;
2226} 2226}
2227 2227
2228/* 2228/*
2229 body-fld-desc = nstring 2229 body-fld-desc = nstring
2230*/ 2230*/
2231 2231
2232static int mailimap_body_fld_desc_parse(mailstream * fd, MMAPString * buffer, 2232static int mailimap_body_fld_desc_parse(mailstream * fd, MMAPString * buffer,
2233 size_t * index, char ** result, 2233 size_t * index, char ** result,
2234 size_t progr_rate, 2234 size_t progr_rate,
2235 progress_function * progr_fun) 2235 progress_function * progr_fun)
2236{ 2236{
2237 return mailimap_nstring_parse(fd, buffer, index, result, NULL, 2237 return mailimap_nstring_parse(fd, buffer, index, result, NULL,
2238 progr_rate, progr_fun); 2238 progr_rate, progr_fun);
2239} 2239}
2240 2240
2241/* 2241/*
2242 body-fld-dsp = "(" string SP body-fld-param ")" / nil 2242 body-fld-dsp = "(" string SP body-fld-param ")" / nil
2243*/ 2243*/
2244 2244
2245static int 2245static int
2246mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer, 2246mailimap_body_fld_dsp_parse(mailstream * fd, MMAPString * buffer,
2247 size_t * index, 2247 size_t * index,
2248 struct mailimap_body_fld_dsp ** result, 2248 struct mailimap_body_fld_dsp ** result,
2249 size_t progr_rate, 2249 size_t progr_rate,
2250 progress_function * progr_fun) 2250 progress_function * progr_fun)
2251{ 2251{
2252 size_t cur_token; 2252 size_t cur_token;
2253 char * name; 2253 char * name;
2254 struct mailimap_body_fld_param * body_fld_param; 2254 struct mailimap_body_fld_param * body_fld_param;
2255 struct mailimap_body_fld_dsp * body_fld_dsp; 2255 struct mailimap_body_fld_dsp * body_fld_dsp;
2256 int res; 2256 int res;
2257 int r; 2257 int r;
2258 2258
2259 cur_token = * index; 2259 cur_token = * index;
2260 name = NULL; 2260 name = NULL;
2261 body_fld_param = NULL; 2261 body_fld_param = NULL;
2262 2262
2263 r = mailimap_nil_parse(fd, buffer, &cur_token); 2263 r = mailimap_nil_parse(fd, buffer, &cur_token);
2264 if (r == MAILIMAP_NO_ERROR) { 2264 if (r == MAILIMAP_NO_ERROR) {
2265 * result = NULL; 2265 * result = NULL;
2266 * index = cur_token; 2266 * index = cur_token;
2267 return MAILIMAP_NO_ERROR; 2267 return MAILIMAP_NO_ERROR;
2268 } 2268 }
2269 2269
2270 if (r != MAILIMAP_ERROR_PARSE) { 2270 if (r != MAILIMAP_ERROR_PARSE) {
2271 res = r; 2271 res = r;
2272 goto err; 2272 goto err;
2273 } 2273 }
2274 2274
2275 r = mailimap_oparenth_parse(fd, buffer, &cur_token); 2275 r = mailimap_oparenth_parse(fd, buffer, &cur_token);
2276 if (r != MAILIMAP_NO_ERROR) { 2276 if (r != MAILIMAP_NO_ERROR) {
2277 res = r; 2277 res = r;
2278 goto err; 2278 goto err;
2279 } 2279 }
2280 2280
2281 r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL, 2281 r = mailimap_string_parse(fd, buffer, &cur_token, &name, NULL,
2282 progr_rate, progr_fun); 2282 progr_rate, progr_fun);
2283 if (r != MAILIMAP_NO_ERROR) { 2283 if (r != MAILIMAP_NO_ERROR) {
2284 res = r; 2284 res = r;
2285 goto err; 2285 goto err;
2286 } 2286 }
2287 2287
2288 r = mailimap_space_parse(fd, buffer, &cur_token); 2288 r = mailimap_space_parse(fd, buffer, &cur_token);
2289 if (r != MAILIMAP_NO_ERROR) { 2289 if (r != MAILIMAP_NO_ERROR) {
2290 res = r; 2290 res = r;
2291 goto string_free; 2291 goto string_free;
2292 } 2292 }
2293 2293
2294 r = mailimap_body_fld_param_parse(fd, buffer, &cur_token, 2294 r = mailimap_body_fld_param_parse(fd, buffer, &cur_token,
2295 &body_fld_param, 2295 &body_fld_param,
2296 progr_rate, progr_fun); 2296 progr_rate, progr_fun);
2297 if (r != MAILIMAP_NO_ERROR) { 2297 if (r != MAILIMAP_NO_ERROR) {
2298 res = r; 2298 res = r;
2299 goto string_free; 2299 goto string_free;
2300 } 2300 }
2301 2301
2302 r = mailimap_cparenth_parse(fd, buffer, &cur_token); 2302 r = mailimap_cparenth_parse(fd, buffer, &cur_token);
2303 if (r != MAILIMAP_NO_ERROR) { 2303 if (r != MAILIMAP_NO_ERROR) {
2304 res = r; 2304 res = r;
2305 goto string_free; 2305 goto string_free;
2306 } 2306 }
2307 2307
2308 body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param); 2308 body_fld_dsp = mailimap_body_fld_dsp_new(name, body_fld_param);
2309 if (body_fld_dsp == NULL) { 2309 if (body_fld_dsp == NULL) {
2310 res = MAILIMAP_ERROR_MEMORY; 2310 res = MAILIMAP_ERROR_MEMORY;
2311 goto fld_param_free; 2311 goto fld_param_free;
2312 } 2312 }
2313 2313
2314 * index = cur_token; 2314 * index = cur_token;
2315 * result = body_fld_dsp; 2315 * result = body_fld_dsp;
2316 2316
2317 return MAILIMAP_NO_ERROR; 2317 return MAILIMAP_NO_ERROR;
2318 2318
2319 fld_param_free: 2319 fld_param_free:
2320 if (body_fld_param != NULL) 2320 if (body_fld_param != NULL)
2321 mailimap_body_fld_param_free(body_fld_param); 2321 mailimap_body_fld_param_free(body_fld_param);
2322 string_free: 2322 string_free:
2323 mailimap_string_free(name); 2323 mailimap_string_free(name);
2324 err: 2324 err:
2325 return res; 2325 return res;
2326} 2326}
2327 2327
2328/* 2328/*
2329 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/ 2329 body-fld-enc = (DQUOTE ("7BIT" / "8BIT" / "BINARY" / "BASE64"/
2330 "QUOTED-PRINTABLE") DQUOTE) / string 2330 "QUOTED-PRINTABLE") DQUOTE) / string
2331*/ 2331*/
2332 2332
2333static inline int 2333static inline int
2334mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer, 2334mailimap_body_fld_known_enc_parse(mailstream * fd, MMAPString * buffer,
2335 size_t * index, 2335 size_t * index,
2336 int * result, 2336 int * result,
2337 size_t progr_rate, 2337 size_t progr_rate,
2338 progress_function * progr_fun) 2338 progress_function * progr_fun)
2339{ 2339{
2340 size_t cur_token; 2340 size_t cur_token;
2341 int type; 2341 int type;
2342 int r; 2342 int r;
2343 int res; 2343 int res;
2344 2344
2345 cur_token = * index; 2345 cur_token = * index;
2346 2346
2347 r = mailimap_dquote_parse(fd, buffer, &cur_token); 2347 r = mailimap_dquote_parse(fd, buffer, &cur_token);
2348 if (r != MAILIMAP_NO_ERROR) { 2348 if (r != MAILIMAP_NO_ERROR) {
2349 res = r; 2349 res = r;
2350 goto err; 2350 goto err;
2351 } 2351 }
2352 2352
2353 type = mailimap_encoding_get_token_value(fd, buffer, &cur_token); 2353 type = mailimap_encoding_get_token_value(fd, buffer, &cur_token);
2354 2354
2355 if (type == -1) { 2355 if (type == -1) {
2356 res = MAILIMAP_ERROR_PARSE; 2356 res = MAILIMAP_ERROR_PARSE;
2357 goto err; 2357 goto err;
2358 } 2358 }
2359 2359
2360 r = mailimap_dquote_parse(fd, buffer, &cur_token); 2360 r = mailimap_dquote_parse(fd, buffer, &cur_token);
2361 if (r != MAILIMAP_NO_ERROR) { 2361 if (r != MAILIMAP_NO_ERROR) {
2362 res = r; 2362 res = r;
2363 goto err; 2363 goto err;
2364 } 2364 }
2365 2365
2366 * result = type; 2366 * result = type;
2367 * index = cur_token; 2367 * index = cur_token;
2368 2368
2369 return MAILIMAP_NO_ERROR; 2369 return MAILIMAP_NO_ERROR;
2370 2370
2371 err: 2371 err:
2372 return res; 2372 return res;
2373} 2373}
2374 2374
2375static int 2375static int
2376mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer, 2376mailimap_body_fld_enc_parse(mailstream * fd, MMAPString * buffer,
2377 size_t * index, 2377 size_t * index,
2378 struct mailimap_body_fld_enc ** result, 2378 struct mailimap_body_fld_enc ** result,
2379 size_t progr_rate, 2379 size_t progr_rate,
2380 progress_function * progr_fun) 2380 progress_function * progr_fun)
2381{ 2381{
2382 size_t cur_token; 2382 size_t cur_token;
2383 int type; 2383 int type;
2384 char * value; 2384 char * value;
2385 struct mailimap_body_fld_enc * body_fld_enc; 2385 struct mailimap_body_fld_enc * body_fld_enc;
2386 int r; 2386 int r;
2387 int res; 2387 int res;
2388 2388
2389 cur_token = * index; 2389 cur_token = * index;
2390 2390
2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token, 2391 r = mailimap_body_fld_known_enc_parse(fd, buffer, &cur_token,
2392 &type, progr_rate, progr_fun); 2392 &type, progr_rate, progr_fun);
2393 if (r == MAILIMAP_NO_ERROR) { 2393 if (r == MAILIMAP_NO_ERROR) {
2394 value = NULL; 2394 value = NULL;
2395 } 2395 }
2396 else if (r == MAILIMAP_ERROR_PARSE) { 2396 else if (r == MAILIMAP_ERROR_PARSE) {
2397 type = MAILIMAP_BODY_FLD_ENC_OTHER; 2397 type = MAILIMAP_BODY_FLD_ENC_OTHER;
2398 2398
2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL, 2399 r = mailimap_string_parse(fd, buffer, &cur_token, &value, NULL,
2400 progr_rate, progr_fun); 2400 progr_rate, progr_fun);
2401 if (r != MAILIMAP_NO_ERROR) { 2401 if (r != MAILIMAP_NO_ERROR) {
2402 res = r; 2402 // LR start
2403 goto err; 2403 // accept NIL and set type to utf8
2404 int ret = r;
2405 r = mailimap_char_parse(fd, buffer, &cur_token, 'N');
2406 if (r == MAILIMAP_NO_ERROR) {
2407 r = mailimap_char_parse(fd, buffer, &cur_token, 'I');
2408 if (r == MAILIMAP_NO_ERROR) {
2409 r = mailimap_char_parse(fd, buffer, &cur_token, 'L');
2410 if (r == MAILIMAP_NO_ERROR) {
2411 type = 4;
2412 ret = MAILIMAP_NO_ERROR;
2413 value = NULL;
2414 }
2415 }
2416 }
2417 if ( ret != MAILIMAP_NO_ERROR ) {
2418 res = ret;
2419 goto err;
2420 }
2421 // LR end
2404 } 2422 }
2405 } 2423 }
2406 else { 2424 else {
2407 res = r; 2425 res = r;
2408 goto err; 2426 goto err;
2409 } 2427 }
2410 2428
2411 body_fld_enc = mailimap_body_fld_enc_new(type, value); 2429 body_fld_enc = mailimap_body_fld_enc_new(type, value);
2412 if (body_fld_enc == NULL) { 2430 if (body_fld_enc == NULL) {
2413 res = MAILIMAP_ERROR_MEMORY; 2431 res = MAILIMAP_ERROR_MEMORY;
2414 goto value_free; 2432 goto value_free;
2415 } 2433 }
2416 2434
2417 * result = body_fld_enc; 2435 * result = body_fld_enc;
2418 * index = cur_token; 2436 * index = cur_token;
2419 2437
2420 return MAILIMAP_NO_ERROR; 2438 return MAILIMAP_NO_ERROR;
2421 2439
2422 value_free: 2440 value_free:
2423 if (value) 2441 if (value)
2424 mailimap_string_free(value); 2442 mailimap_string_free(value);
2425 err: 2443 err:
2426 return res; 2444 return res;
2427} 2445}
2428 2446
2429/* 2447/*
2430 body-fld-id = nstring 2448 body-fld-id = nstring
2431*/ 2449*/
2432 2450
2433static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer, 2451static int mailimap_body_fld_id_parse(mailstream * fd, MMAPString * buffer,
2434 size_t * index, char ** result, 2452 size_t * index, char ** result,
2435 size_t progr_rate, 2453 size_t progr_rate,
2436 progress_function * progr_fun) 2454 progress_function * progr_fun)
2437{ 2455{
2438 return mailimap_nstring_parse(fd, buffer, index, result, NULL, 2456 return mailimap_nstring_parse(fd, buffer, index, result, NULL,
2439 progr_rate, progr_fun); 2457 progr_rate, progr_fun);
2440} 2458}
2441 2459
2442 2460
2443/* 2461/*
2444 body-fld-lang = nstring / "(" string *(SP string) ")" 2462 body-fld-lang = nstring / "(" string *(SP string) ")"
2445*/ 2463*/
2446 2464
2447/* 2465/*
2448"(" string *(SP string) ")" 2466"(" string *(SP string) ")"
2449*/ 2467*/
2450 2468
2451static int 2469static int
2452mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer, 2470mailimap_body_fld_lang_list_parse(mailstream * fd, MMAPString * buffer,
2453 size_t * index, clist ** result, 2471 size_t * index, clist ** result,
2454 size_t progr_rate, 2472 size_t progr_rate,
2455 progress_function * progr_fun) 2473 progress_function * progr_fun)
2456{ 2474{
2457 size_t cur_token; 2475 size_t cur_token;
2458 clist * list; 2476 clist * list;
2459 int r; 2477 int r;
2460 int res; 2478 int res;
2461 2479
2462 cur_token = * index; 2480 cur_token = * index;
2463 2481
2464 r = mailimap_oparenth_parse(fd, buffer, &cur_token); 2482 r = mailimap_oparenth_parse(fd, buffer, &cur_token);
2465 if (r != MAILIMAP_NO_ERROR) { 2483 if (r != MAILIMAP_NO_ERROR) {
2466 res = r; 2484 res = r;
2467 goto err; 2485 goto err;
2468 } 2486 }
2469 2487
2470 list = clist_new(); 2488 list = clist_new();
2471 if (list == NULL) { 2489 if (list == NULL) {
2472 res = MAILIMAP_ERROR_MEMORY; 2490 res = MAILIMAP_ERROR_MEMORY;
2473 goto err; 2491 goto err;
2474 } 2492 }
2475 2493
2476 while (1) { 2494 while (1) {
2477 char * elt; 2495 char * elt;
2478 2496
2479 r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL, 2497 r = mailimap_string_parse(fd, buffer, &cur_token, &elt, NULL,
2480 progr_rate, progr_fun); 2498 progr_rate, progr_fun);
2481 if (r != MAILIMAP_ERROR_PARSE) 2499 if (r != MAILIMAP_ERROR_PARSE)
2482 break; 2500 break;
2483 else if (r == MAILIMAP_NO_ERROR) { 2501 else if (r == MAILIMAP_NO_ERROR) {
2484 r = clist_append(list, elt); 2502 r = clist_append(list, elt);
2485 if (r < 0) { 2503 if (r < 0) {
2486 mailimap_string_free(elt); 2504 mailimap_string_free(elt);
2487 res = r; 2505 res = r;
2488 goto list_free; 2506 goto list_free;
2489 } 2507 }
2490 } 2508 }
2491 else { 2509 else {
2492 res = r; 2510 res = r;
2493 goto list_free; 2511 goto list_free;
2494 } 2512 }
2495 } 2513 }
2496 2514
2497 r = mailimap_cparenth_parse(fd, buffer, &cur_token); 2515 r = mailimap_cparenth_parse(fd, buffer, &cur_token);
2498 if (r != MAILIMAP_NO_ERROR) { 2516 if (r != MAILIMAP_NO_ERROR) {
2499 res = r; 2517 res = r;
2500 goto list_free; 2518 goto list_free;
2501 } 2519 }
2502 2520
2503 * index = cur_token; 2521 * index = cur_token;
2504 * result = list; 2522 * result = list;
2505 2523
2506 return MAILIMAP_NO_ERROR; 2524 return MAILIMAP_NO_ERROR;
2507 2525
2508 list_free: 2526 list_free:
2509 clist_foreach(list, (clist_func) mailimap_string_free, NULL); 2527 clist_foreach(list, (clist_func) mailimap_string_free, NULL);
2510 clist_free(list); 2528 clist_free(list);
2511 err: 2529 err:
2512 return res; 2530 return res;
2513} 2531}
2514 2532
2515/* 2533/*
2516 body-fld-lang = nstring / "(" string *(SP string) ")" 2534 body-fld-lang = nstring / "(" string *(SP string) ")"
2517*/ 2535*/
2518 2536
2519static int 2537static int
2520mailimap_body_fld_lang_parse(mailstream * fd, MMAPString * buffer, 2538mailimap_body_fld_lang_parse(mailstream * fd, MMAPString * buffer,
2521 size_t * index, 2539 size_t * index,
2522 struct mailimap_body_fld_lang ** result, 2540 struct mailimap_body_fld_lang ** result,
2523 size_t progr_rate, 2541 size_t progr_rate,
2524 progress_function * progr_fun) 2542 progress_function * progr_fun)
2525{ 2543{
2526 char * value; 2544 char * value;
2527 clist * list; 2545 clist * list;
2528 struct mailimap_body_fld_lang * fld_lang; 2546 struct mailimap_body_fld_lang * fld_lang;
2529 int type; 2547 int type;
2530 int r; 2548 int r;
2531 int res; 2549 int res;
2532 2550
2533 size_t cur_token; 2551 size_t cur_token;
2534 2552
2535 cur_token = * index; 2553 cur_token = * index;
2536 2554
2537 value = NULL; 2555 value = NULL;
2538 list = NULL; 2556 list = NULL;
2539 type = MAILIMAP_BODY_FLD_LANG_ERROR; /* XXX - removes a gcc warning */ 2557 type = MAILIMAP_BODY_FLD_LANG_ERROR; /* XXX - removes a gcc warning */
2540 2558
2541 r = mailimap_nstring_parse(fd, buffer, &cur_token, &value, NULL, 2559 r = mailimap_nstring_parse(fd, buffer, &cur_token, &value, NULL,
2542 progr_rate, progr_fun); 2560 progr_rate, progr_fun);
2543 if (r == MAILIMAP_NO_ERROR) 2561 if (r == MAILIMAP_NO_ERROR)
2544 type = MAILIMAP_BODY_FLD_LANG_SINGLE; 2562 type = MAILIMAP_BODY_FLD_LANG_SINGLE;
2545 2563
2546 if (r == MAILIMAP_ERROR_PARSE) { 2564 if (r == MAILIMAP_ERROR_PARSE) {
2547 r = mailimap_body_fld_lang_list_parse(fd, buffer, &cur_token, &list, 2565 r = mailimap_body_fld_lang_list_parse(fd, buffer, &cur_token, &list,
2548 progr_rate, progr_fun); 2566 progr_rate, progr_fun);
2549 if (r == MAILIMAP_NO_ERROR) 2567 if (r == MAILIMAP_NO_ERROR)
2550 type = MAILIMAP_BODY_FLD_LANG_LIST; 2568 type = MAILIMAP_BODY_FLD_LANG_LIST;
2551 } 2569 }
2552 2570
2553 if (r != MAILIMAP_NO_ERROR) { 2571 if (r != MAILIMAP_NO_ERROR) {
2554 res = r; 2572 res = r;
2555 goto err; 2573 goto err;
2556 } 2574 }
2557 2575
2558 fld_lang = mailimap_body_fld_lang_new(type, value, list); 2576 fld_lang = mailimap_body_fld_lang_new(type, value, list);
2559 if (fld_lang == NULL) { 2577 if (fld_lang == NULL) {
2560 res = MAILIMAP_ERROR_MEMORY; 2578 res = MAILIMAP_ERROR_MEMORY;
2561 goto free; 2579 goto free;
2562 } 2580 }
2563 2581
2564 * index = cur_token; 2582 * index = cur_token;
2565 * result = fld_lang; 2583 * result = fld_lang;
2566 2584
2567 return MAILIMAP_NO_ERROR; 2585 return MAILIMAP_NO_ERROR;
2568 2586
2569 free: 2587 free:
2570 if (value) 2588 if (value)
2571 mailimap_nstring_free(value); 2589 mailimap_nstring_free(value);
2572 if (list) { 2590 if (list) {
2573 clist_foreach(list, (clist_func) mailimap_string_free, NULL); 2591 clist_foreach(list, (clist_func) mailimap_string_free, NULL);
2574 clist_free(list); 2592 clist_free(list);
2575 } 2593 }
2576 err: 2594 err:
2577 return res; 2595 return res;
2578} 2596}
2579 2597
2580/* 2598/*
2581 body-fld-lines = number 2599 body-fld-lines = number
2582*/ 2600*/
2583 2601
2584static int mailimap_body_fld_lines_parse(mailstream * fd, 2602static int mailimap_body_fld_lines_parse(mailstream * fd,
2585 MMAPString * buffer, size_t * index, 2603 MMAPString * buffer, size_t * index,
2586 uint32_t * result) 2604 uint32_t * result)
2587{ 2605{
2588 return mailimap_number_parse(fd, buffer, index, result); 2606 return mailimap_number_parse(fd, buffer, index, result);
2589} 2607}
2590 2608
2591/* 2609/*
2592 body-fld-md5 = nstring 2610 body-fld-md5 = nstring
2593*/ 2611*/
2594 2612
2595static int mailimap_body_fld_md5_parse(mailstream * fd, MMAPString * buffer, 2613static int mailimap_body_fld_md5_parse(mailstream * fd, MMAPString * buffer,
diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp
index d9496af..93fb7de 100644
--- a/kmicromail/libmailwrapper/imapwrapper.cpp
+++ b/kmicromail/libmailwrapper/imapwrapper.cpp
@@ -247,556 +247,561 @@ void IMAPwrapper::listMessages(const QString&mailbox,QValueList<Opie::Core::OSma
247 247
248 login(); 248 login();
249 if (!m_imap) { 249 if (!m_imap) {
250 return; 250 return;
251 } 251 }
252 /* select mailbox READONLY for operations */ 252 /* select mailbox READONLY for operations */
253 err = selectMbox(mailbox); 253 err = selectMbox(mailbox);
254 if ( err != MAILIMAP_NO_ERROR ) { 254 if ( err != MAILIMAP_NO_ERROR ) {
255 return; 255 return;
256 } 256 }
257 257
258 int last = m_imap->imap_selection_info->sel_exists; 258 int last = m_imap->imap_selection_info->sel_exists;
259 259
260 if (last == 0) { 260 if (last == 0) {
261 Global::statusMessage(i18n("Mailbox has no mails")); 261 Global::statusMessage(i18n("Mailbox has no mails"));
262 return; 262 return;
263 } else { 263 } else {
264 } 264 }
265 progress( i18n("Fetch ")); 265 progress( i18n("Fetch "));
266 mMax = last; 266 mMax = last;
267 //qDebug("last %d ", last); 267 //qDebug("last %d ", last);
268 Global::statusMessage(i18n("Fetching header list")); 268 Global::statusMessage(i18n("Fetching header list"));
269 qApp->processEvents(); 269 qApp->processEvents();
270 /* the range has to start at 1!!! not with 0!!!! */ 270 /* the range has to start at 1!!! not with 0!!!! */
271 //LR the access to web.de imap server is no working with value 1 271 //LR the access to web.de imap server is no working with value 1
272 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain ); 272 //qDebug("interval %d - %d ", tryAgain, last-1+tryAgain );
273 set = mailimap_set_new_interval( tryAgain, last ); 273 set = mailimap_set_new_interval( tryAgain, last );
274 fetchType = mailimap_fetch_type_new_fetch_att_list_empty(); 274 fetchType = mailimap_fetch_type_new_fetch_att_list_empty();
275 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope()); 275 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_envelope());
276 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags()); 276 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_flags());
277 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate()); 277 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_internaldate());
278 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size()); 278 mailimap_fetch_type_new_fetch_att_list_add(fetchType,mailimap_fetch_att_new_rfc822_size());
279 279
280 err = mailimap_fetch( m_imap, set, fetchType, &result ); 280 err = mailimap_fetch( m_imap, set, fetchType, &result );
281 mailimap_set_free( set ); 281 mailimap_set_free( set );
282 mailimap_fetch_type_free( fetchType ); 282 mailimap_fetch_type_free( fetchType );
283 283
284 QString date,subject,from; 284 QString date,subject,from;
285 285
286 if ( err == MAILIMAP_NO_ERROR ) { 286 if ( err == MAILIMAP_NO_ERROR ) {
287 tryAgain = -1; 287 tryAgain = -1;
288 mailimap_msg_att * msg_att; 288 mailimap_msg_att * msg_att;
289 int i = 0; 289 int i = 0;
290 for (current = clist_begin(result); current != 0; current=clist_next(current)) { 290 for (current = clist_begin(result); current != 0; current=clist_next(current)) {
291 ++i; 291 ++i;
292 //qDebug("iii %d ",i); 292 //qDebug("iii %d ",i);
293 msg_att = (mailimap_msg_att*)current->data; 293 msg_att = (mailimap_msg_att*)current->data;
294 RecMail*m = parse_list_result(msg_att); 294 RecMail*m = parse_list_result(msg_att);
295 if (m) { 295 if (m) {
296 if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) { 296 if ( maxSizeInKb == 0 || m->Msgsize()<=(unsigned int ) maxSizeInKb*1024 ) {
297 m->setNumber(i); 297 m->setNumber(i);
298 m->setMbox(mailbox); 298 m->setMbox(mailbox);
299 m->setWrapper(this); 299 m->setWrapper(this);
300 target.append(m); 300 target.append(m);
301 } 301 }
302 } 302 }
303 } 303 }
304 Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count())); 304 Global::statusMessage(i18n("Mailbox has %1 mails").arg(target.count()));
305 } else { 305 } else {
306 --tryAgain; 306 --tryAgain;
307 --tryAgain;//disabled tryagain by adding this line 307 --tryAgain;//disabled tryagain by adding this line
308 if ( tryAgain < 0 ) 308 if ( tryAgain < 0 )
309 Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response)); 309 Global::statusMessage(i18n("Error fetching headers: %1").arg(m_imap->imap_response));
310 else 310 else
311 qDebug("try again... "); 311 qDebug("try again... ");
312 } 312 }
313 313
314 if (result) mailimap_fetch_list_free(result); 314 if (result) mailimap_fetch_list_free(result);
315 } 315 }
316} 316}
317 317
318QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders() 318QValueList<Opie::Core::OSmartPointer<Folder> >* IMAPwrapper::listFolders()
319{ 319{
320 const char *path, *mask; 320 const char *path, *mask;
321 int err = MAILIMAP_NO_ERROR; 321 int err = MAILIMAP_NO_ERROR;
322 clist *result = 0; 322 clist *result = 0;
323 clistcell *current = 0; 323 clistcell *current = 0;
324 clistcell*cur_flag = 0; 324 clistcell*cur_flag = 0;
325 mailimap_mbx_list_flags*bflags = 0; 325 mailimap_mbx_list_flags*bflags = 0;
326 326
327 QValueList<FolderP>* folders = new QValueList<FolderP>(); 327 QValueList<FolderP>* folders = new QValueList<FolderP>();
328 login(); 328 login();
329 if (!m_imap) { 329 if (!m_imap) {
330 return folders; 330 return folders;
331 } 331 }
332 332
333/* 333/*
334 * First we have to check for INBOX 'cause it sometimes it's not inside the path. 334 * First we have to check for INBOX 'cause it sometimes it's not inside the path.
335 * We must not forget to filter them out in next loop! 335 * We must not forget to filter them out in next loop!
336 * it seems like ugly code. and yes - it is ugly code. but the best way. 336 * it seems like ugly code. and yes - it is ugly code. but the best way.
337 */ 337 */
338 Global::statusMessage(i18n("Fetching folder list")); 338 Global::statusMessage(i18n("Fetching folder list"));
339 qApp->processEvents(); 339 qApp->processEvents();
340 QString temp; 340 QString temp;
341 mask = "INBOX" ; 341 mask = "INBOX" ;
342 mailimap_mailbox_list *list; 342 mailimap_mailbox_list *list;
343 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result ); 343 err = mailimap_list( m_imap, (char*)"", (char*)mask, &result );
344 QString del; 344 QString del;
345 bool selectable = true; 345 bool selectable = true;
346 bool no_inferiors = false; 346 bool no_inferiors = false;
347 if ( err == MAILIMAP_NO_ERROR ) { 347 if ( err == MAILIMAP_NO_ERROR ) {
348 current = result->first; 348 current = result->first;
349 for ( int i = result->count; i > 0; i-- ) { 349 for ( int i = result->count; i > 0; i-- ) {
350 list = (mailimap_mailbox_list *) current->data; 350 list = (mailimap_mailbox_list *) current->data;
351 // it is better use the deep copy mechanism of qt itself 351 // it is better use the deep copy mechanism of qt itself
352 // instead of using strdup! 352 // instead of using strdup!
353 temp = list->mb_name; 353 temp = list->mb_name;
354 del = list->mb_delimiter; 354 del = list->mb_delimiter;
355 current = current->next; 355 current = current->next;
356 if ( (bflags = list->mb_flag) ) { 356 if ( (bflags = list->mb_flag) ) {
357 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 357 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
358 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 358 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
359 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 359 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
360 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 360 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
361 no_inferiors = true; 361 no_inferiors = true;
362 } 362 }
363 } 363 }
364 } 364 }
365 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 365 folders->append( new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
366 } 366 }
367 } else { 367 } else {
368 qDebug("error fetching folders: "); 368 qDebug("error fetching folders: ");
369 369
370 } 370 }
371 mailimap_list_result_free( result ); 371 mailimap_list_result_free( result );
372 372
373/* 373/*
374 * second stage - get the other then inbox folders 374 * second stage - get the other then inbox folders
375 */ 375 */
376 mask = "*" ; 376 mask = "*" ;
377 path = account->getPrefix().latin1(); 377 path = account->getPrefix().latin1();
378 if (!path) path = ""; 378 if (!path) path = "";
379 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result ); 379 err = mailimap_list( m_imap, (char*)path, (char*)mask, &result );
380 if ( err == MAILIMAP_NO_ERROR ) { 380 if ( err == MAILIMAP_NO_ERROR ) {
381 current = result->first; 381 current = result->first;
382 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) { 382 for ( current=clist_begin(result);current!=NULL;current=clist_next(current)) {
383 no_inferiors = false; 383 no_inferiors = false;
384 list = (mailimap_mailbox_list *) current->data; 384 list = (mailimap_mailbox_list *) current->data;
385 // it is better use the deep copy mechanism of qt itself 385 // it is better use the deep copy mechanism of qt itself
386 // instead of using strdup! 386 // instead of using strdup!
387 temp = list->mb_name; 387 temp = list->mb_name;
388 if (temp.lower()=="inbox") 388 if (temp.lower()=="inbox")
389 continue; 389 continue;
390 if (temp.lower()==account->getPrefix().lower()) 390 if (temp.lower()==account->getPrefix().lower())
391 continue; 391 continue;
392 if ( (bflags = list->mb_flag) ) { 392 if ( (bflags = list->mb_flag) ) {
393 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&& 393 selectable = !(bflags->mbf_type==MAILIMAP_MBX_LIST_FLAGS_SFLAG&&
394 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT); 394 bflags->mbf_sflag==MAILIMAP_MBX_LIST_SFLAG_NOSELECT);
395 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) { 395 for(cur_flag=clist_begin(bflags->mbf_oflags);cur_flag;cur_flag=clist_next(cur_flag)) {
396 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) { 396 if ( ((mailimap_mbx_list_oflag*)cur_flag->data)->of_type==MAILIMAP_MBX_LIST_OFLAG_NOINFERIORS) {
397 no_inferiors = true; 397 no_inferiors = true;
398 } 398 }
399 } 399 }
400 } 400 }
401 del = list->mb_delimiter; 401 del = list->mb_delimiter;
402 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix())); 402 folders->append(new IMAPFolder(temp,del,selectable,no_inferiors,account->getPrefix()));
403 } 403 }
404 } else { 404 } else {
405 qDebug("error fetching folders "); 405 qDebug("error fetching folders ");
406 406
407 } 407 }
408 if (result) mailimap_list_result_free( result ); 408 if (result) mailimap_list_result_free( result );
409 return folders; 409 return folders;
410} 410}
411 411
412RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att) 412RecMail*IMAPwrapper::parse_list_result(mailimap_msg_att* m_att)
413{ 413{
414 RecMail * m = 0; 414 RecMail * m = 0;
415 mailimap_msg_att_item *item=0; 415 mailimap_msg_att_item *item=0;
416 clistcell *current,*c,*cf; 416 clistcell *current,*c,*cf;
417 mailimap_msg_att_dynamic*flist; 417 mailimap_msg_att_dynamic*flist;
418 mailimap_flag_fetch*cflag; 418 mailimap_flag_fetch*cflag;
419 int size = 0; 419 int size = 0;
420 QBitArray mFlags(7); 420 QBitArray mFlags(7);
421 QStringList addresslist; 421 QStringList addresslist;
422 422
423 if (!m_att) { 423 if (!m_att) {
424 return m; 424 return m;
425 } 425 }
426 m = new RecMail(); 426 m = new RecMail();
427 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) { 427 for (c = clist_begin(m_att->att_list); c!=NULL;c=clist_next(c) ) {
428 current = c; 428 current = c;
429 size = 0; 429 size = 0;
430 item = (mailimap_msg_att_item*)current->data; 430 item = (mailimap_msg_att_item*)current->data;
431 if ( !item ) 431 if ( !item )
432 continue; 432 continue;
433 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) { 433 if (item->att_type!=MAILIMAP_MSG_ATT_ITEM_STATIC) {
434 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn; 434 flist = (mailimap_msg_att_dynamic*)item->att_data.att_dyn;
435 if (!flist || !flist->att_list) { 435 if (!flist || !flist->att_list) {
436 continue; 436 continue;
437 } 437 }
438 cf = flist->att_list->first; 438 cf = flist->att_list->first;
439 if( ! cf ) 439 if( cf ) {
440 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) { 440 for (cf = clist_begin(flist->att_list); cf!=NULL; cf = clist_next(cf)) {
441 cflag = (mailimap_flag_fetch*)cf->data; 441 cflag = (mailimap_flag_fetch*)cf->data;
442 if( ! cflag ) 442 if( ! cflag )
443 qDebug("imap:not cflag "); 443 qDebug("imap:NO cflag ");
444 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) { 444 else {
445 switch (cflag->fl_flag->fl_type) { 445 if (cflag->fl_type==MAILIMAP_FLAG_FETCH_OTHER && cflag->fl_flag!=0) {
446 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */ 446 switch (cflag->fl_flag->fl_type) {
447 mFlags.setBit(FLAG_ANSWERED); 447 case MAILIMAP_FLAG_ANSWERED: /* \Answered flag */
448 break; 448 mFlags.setBit(FLAG_ANSWERED);
449 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */ 449 break;
450 mFlags.setBit(FLAG_FLAGGED); 450 case MAILIMAP_FLAG_FLAGGED: /* \Flagged flag */
451 break; 451 mFlags.setBit(FLAG_FLAGGED);
452 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */ 452 break;
453 mFlags.setBit(FLAG_DELETED); 453 case MAILIMAP_FLAG_DELETED: /* \Deleted flag */
454 break; 454 mFlags.setBit(FLAG_DELETED);
455 case MAILIMAP_FLAG_SEEN: /* \Seen flag */ 455 break;
456 mFlags.setBit(FLAG_SEEN); 456 case MAILIMAP_FLAG_SEEN: /* \Seen flag */
457 break; 457 mFlags.setBit(FLAG_SEEN);
458 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */ 458 break;
459 mFlags.setBit(FLAG_DRAFT); 459 case MAILIMAP_FLAG_DRAFT: /* \Draft flag */
460 break; 460 mFlags.setBit(FLAG_DRAFT);
461 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */ 461 break;
462 break; 462 case MAILIMAP_FLAG_KEYWORD: /* keyword flag */
463 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */ 463 break;
464 break; 464 case MAILIMAP_FLAG_EXTENSION: /* \extension flag */
465 default: 465 break;
466 break; 466 default:
467 break;
468 }
469 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
470 mFlags.setBit(FLAG_RECENT);
471 }
467 } 472 }
468 } else if (cflag->fl_type==MAILIMAP_FLAG_FETCH_RECENT) {
469 mFlags.setBit(FLAG_RECENT);
470 } 473 }
471 } 474 }
475 //qDebug(" continue");
472 continue; 476 continue;
473 } 477 }
474 if ( item->att_data.att_static == NULL ) 478 if ( item->att_data.att_static == NULL )
475 continue; 479 continue;
476 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) { 480 if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_ENVELOPE) {
477 mailimap_envelope * head = item->att_data.att_static->att_data.att_env; 481 mailimap_envelope * head = item->att_data.att_static->att_data.att_env;
478 if ( head == NULL ) 482 if ( head == NULL )
479 continue; 483 continue;
480 if ( head->env_date != NULL ) { 484 if ( head->env_date != NULL ) {
481 m->setDate(head->env_date); 485 m->setDate(head->env_date);
482 //struct mailimf_date_time result; 486 //struct mailimf_date_time result;
483 struct mailimf_date_time* date;// = &result; 487 struct mailimf_date_time* date;// = &result;
484 struct mailimf_date_time **re = &date; 488 struct mailimf_date_time **re = &date;
485 size_t length = m->getDate().length(); 489 size_t length = m->getDate().length();
486 size_t index = 0; 490 size_t index = 0;
487 if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) { 491 if ( mailimf_date_time_parse(head->env_date, length,&index, re ) == MAILIMF_NO_ERROR ) {
492 //qDebug("parseDateTime ");
488 QDateTime dt = Genericwrapper::parseDateTime( date ); 493 QDateTime dt = Genericwrapper::parseDateTime( date );
489 QString ret; 494 QString ret;
490 if ( dt.date() == QDate::currentDate () ) 495 if ( dt.date() == QDate::currentDate () )
491 ret = KGlobal::locale()->formatTime( dt.time(),true); 496 ret = KGlobal::locale()->formatTime( dt.time(),true);
492 else { 497 else {
493 ret = KGlobal::locale()->formatDateTime( dt,true,true); 498 ret = KGlobal::locale()->formatDateTime( dt,true,true);
494 } 499 }
495 m->setDate( ret ); 500 m->setDate( ret );
496 char tmp[20]; 501 char tmp[20];
497 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i", 502 snprintf( tmp, 20, "%04i-%02i-%02i %02i:%02i:%02i",
498 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() ); 503 dt.date().year(),dt.date().month(), dt.date().day(), dt.time().hour(), dt.time().minute(), dt.time().second() );
499 //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date); 504 //qDebug("%d iso %s %s ", date->dt_zone, tmp, head->env_date);
500 m->setIsoDate( QString( tmp ) ); 505 m->setIsoDate( QString( tmp ) );
501 mailimf_date_time_free ( date ); 506 mailimf_date_time_free ( date );
502 } else { 507 } else {
503 m->setIsoDate(head->env_date); 508 m->setIsoDate(head->env_date);
504 } 509 }
505 } 510 }
506 if ( head->env_subject != NULL ) 511 if ( head->env_subject != NULL )
507 m->setSubject(convert_String((const char*)head->env_subject)); 512 m->setSubject(convert_String((const char*)head->env_subject));
508 //m->setSubject(head->env_subject); 513 //m->setSubject(head->env_subject);
509 if (head->env_from!=NULL) { 514 if (head->env_from!=NULL) {
510 addresslist = address_list_to_stringlist(head->env_from->frm_list); 515 addresslist = address_list_to_stringlist(head->env_from->frm_list);
511 if (addresslist.count()) { 516 if (addresslist.count()) {
512 m->setFrom(addresslist.first()); 517 m->setFrom(addresslist.first());
513 } 518 }
514 } 519 }
515 if (head->env_to!=NULL) { 520 if (head->env_to!=NULL) {
516 addresslist = address_list_to_stringlist(head->env_to->to_list); 521 addresslist = address_list_to_stringlist(head->env_to->to_list);
517 m->setTo(addresslist); 522 m->setTo(addresslist);
518 } 523 }
519 if (head->env_cc!=NULL) { 524 if (head->env_cc!=NULL) {
520 addresslist = address_list_to_stringlist(head->env_cc->cc_list); 525 addresslist = address_list_to_stringlist(head->env_cc->cc_list);
521 m->setCC(addresslist); 526 m->setCC(addresslist);
522 } 527 }
523 if (head->env_bcc!=NULL) { 528 if (head->env_bcc!=NULL) {
524 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list); 529 addresslist = address_list_to_stringlist(head->env_bcc->bcc_list);
525 m->setBcc(addresslist); 530 m->setBcc(addresslist);
526 } 531 }
527 /* reply to address, eg. email. */ 532 /* reply to address, eg. email. */
528 if (head->env_reply_to!=NULL) { 533 if (head->env_reply_to!=NULL) {
529 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list); 534 addresslist = address_list_to_stringlist(head->env_reply_to->rt_list);
530 if (addresslist.count()) { 535 if (addresslist.count()) {
531 m->setReplyto(addresslist.first()); 536 m->setReplyto(addresslist.first());
532 } 537 }
533 } 538 }
534 if (head->env_in_reply_to!=NULL) { 539 if (head->env_in_reply_to!=NULL) {
535 QString h(head->env_in_reply_to); 540 QString h(head->env_in_reply_to);
536 while (h.length()>0 && h[0]=='<') { 541 while (h.length()>0 && h[0]=='<') {
537 h.remove(0,1); 542 h.remove(0,1);
538 } 543 }
539 while (h.length()>0 && h[h.length()-1]=='>') { 544 while (h.length()>0 && h[h.length()-1]=='>') {
540 h.remove(h.length()-1,1); 545 h.remove(h.length()-1,1);
541 } 546 }
542 if (h.length()>0) { 547 if (h.length()>0) {
543 m->setInreply(QStringList(h)); 548 m->setInreply(QStringList(h));
544 } 549 }
545 } 550 }
546 if (head->env_message_id != NULL) { 551 if (head->env_message_id != NULL) {
547 m->setMsgid(QString(head->env_message_id)); 552 m->setMsgid(QString(head->env_message_id));
548 } 553 }
549 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) { 554 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_INTERNALDATE) {
550#if 0 555#if 0
551 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date; 556 mailimap_date_time*d = item->att_data.att_static->att_data.att_internal_date;
552 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec)); 557 QDateTime da(QDate(d->dt_year,d->dt_month,d->dt_day),QTime(d->dt_hour,d->dt_min,d->dt_sec));
553 qDebug("time %s ",da.toString().latin1() ); 558 qDebug("time %s ",da.toString().latin1() );
554#endif 559#endif
555 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) { 560 } else if (item->att_data.att_static->att_type==MAILIMAP_MSG_ATT_RFC822_SIZE) {
556 size = item->att_data.att_static->att_data.att_rfc822_size; 561 size = item->att_data.att_static->att_data.att_rfc822_size;
557 } 562 }
558 } 563 }
559 /* msg is already deleted */ 564 /* msg is already deleted */
560 if (mFlags.testBit(FLAG_DELETED) && m) { 565 if (mFlags.testBit(FLAG_DELETED) && m) {
561 delete m; 566 delete m;
562 m = 0; 567 m = 0;
563 } 568 }
564 if (m) { 569 if (m) {
565 m->setFlags(mFlags); 570 m->setFlags(mFlags);
566 m->setMsgsize(size); 571 m->setMsgsize(size);
567 } 572 }
568 return m; 573 return m;
569} 574}
570 575
571RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail) 576RecBodyP IMAPwrapper::fetchBody(const RecMailP&mail)
572{ 577{
573 RecBodyP body = new RecBody(); 578 RecBodyP body = new RecBody();
574 const char *mb; 579 const char *mb;
575 int err = MAILIMAP_NO_ERROR; 580 int err = MAILIMAP_NO_ERROR;
576 clist *result = 0; 581 clist *result = 0;
577 clistcell *current; 582 clistcell *current;
578 mailimap_fetch_att *fetchAtt = 0; 583 mailimap_fetch_att *fetchAtt = 0;
579 mailimap_fetch_type *fetchType = 0; 584 mailimap_fetch_type *fetchType = 0;
580 mailimap_set *set = 0; 585 mailimap_set *set = 0;
581 mailimap_body*body_desc = 0; 586 mailimap_body*body_desc = 0;
582 587
583 mb = mail->getMbox().latin1(); 588 mb = mail->getMbox().latin1();
584 589
585 login(); 590 login();
586 if (!m_imap) { 591 if (!m_imap) {
587 return body; 592 return body;
588 } 593 }
589 err = selectMbox(mail->getMbox()); 594 err = selectMbox(mail->getMbox());
590 if ( err != MAILIMAP_NO_ERROR ) { 595 if ( err != MAILIMAP_NO_ERROR ) {
591 return body; 596 return body;
592 } 597 }
593 598
594 /* the range has to start at 1!!! not with 0!!!! */ 599 /* the range has to start at 1!!! not with 0!!!! */
595 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() ); 600 set = mailimap_set_new_interval( mail->getNumber(),mail->getNumber() );
596 fetchAtt = mailimap_fetch_att_new_bodystructure(); 601 fetchAtt = mailimap_fetch_att_new_bodystructure();
597 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt); 602 fetchType = mailimap_fetch_type_new_fetch_att(fetchAtt);
598 err = mailimap_fetch( m_imap, set, fetchType, &result ); 603 err = mailimap_fetch( m_imap, set, fetchType, &result );
599 mailimap_set_free( set ); 604 mailimap_set_free( set );
600 mailimap_fetch_type_free( fetchType ); 605 mailimap_fetch_type_free( fetchType );
601 606
602 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 607 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
603 mailimap_msg_att * msg_att; 608 mailimap_msg_att * msg_att;
604 msg_att = (mailimap_msg_att*)current->data; 609 msg_att = (mailimap_msg_att*)current->data;
605 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data; 610 mailimap_msg_att_item*item = (mailimap_msg_att_item*)msg_att->att_list->first->data;
606 QValueList<int> path; 611 QValueList<int> path;
607 body_desc = item->att_data.att_static->att_data.att_body; 612 body_desc = item->att_data.att_static->att_data.att_body;
608 traverseBody(mail,body_desc,body,0,path); 613 traverseBody(mail,body_desc,body,0,path);
609 } else { 614 } else {
610 //odebug << "error fetching body: " << m_imap->imap_response << "" << oendl; 615 qDebug("error fetching body %d (%d): %s", err, MAILIMAP_NO_ERROR, m_imap->imap_response );
611 } 616 }
612 if (result) mailimap_fetch_list_free(result); 617 if (result) mailimap_fetch_list_free(result);
613 return body; 618 return body;
614} 619}
615 620
616QStringList IMAPwrapper::address_list_to_stringlist(clist*list) 621QStringList IMAPwrapper::address_list_to_stringlist(clist*list)
617{ 622{
618 QStringList l; 623 QStringList l;
619 QString from; 624 QString from;
620 bool named_from; 625 bool named_from;
621 clistcell *current = NULL; 626 clistcell *current = NULL;
622 mailimap_address * current_address=NULL; 627 mailimap_address * current_address=NULL;
623 if (!list) { 628 if (!list) {
624 return l; 629 return l;
625 } 630 }
626 unsigned int count = 0; 631 unsigned int count = 0;
627 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) { 632 for (current=clist_begin(list);current!= NULL;current=clist_next(current)) {
628 from = ""; 633 from = "";
629 named_from = false; 634 named_from = false;
630 current_address=(mailimap_address*)current->data; 635 current_address=(mailimap_address*)current->data;
631 if (current_address->ad_personal_name){ 636 if (current_address->ad_personal_name){
632 from+=convert_String((const char*)current_address->ad_personal_name); 637 from+=convert_String((const char*)current_address->ad_personal_name);
633 from+=" "; 638 from+=" ";
634 named_from = true; 639 named_from = true;
635 } 640 }
636 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 641 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
637 from+="<"; 642 from+="<";
638 } 643 }
639 if (current_address->ad_mailbox_name) { 644 if (current_address->ad_mailbox_name) {
640 from+=QString(current_address->ad_mailbox_name); 645 from+=QString(current_address->ad_mailbox_name);
641 from+="@"; 646 from+="@";
642 } 647 }
643 if (current_address->ad_host_name) { 648 if (current_address->ad_host_name) {
644 from+=QString(current_address->ad_host_name); 649 from+=QString(current_address->ad_host_name);
645 } 650 }
646 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) { 651 if (named_from && (current_address->ad_mailbox_name || current_address->ad_host_name)) {
647 from+=">"; 652 from+=">";
648 } 653 }
649 l.append(QString(from)); 654 l.append(QString(from));
650 if (++count > 99) { 655 if (++count > 99) {
651 break; 656 break;
652 } 657 }
653 } 658 }
654 return l; 659 return l;
655} 660}
656 661
657encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call) 662encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int>&path,bool internal_call)
658{ 663{
659 encodedString*res=new encodedString; 664 encodedString*res=new encodedString;
660 int err; 665 int err;
661 mailimap_fetch_type *fetchType; 666 mailimap_fetch_type *fetchType;
662 mailimap_set *set; 667 mailimap_set *set;
663 clistcell*current,*cur; 668 clistcell*current,*cur;
664 mailimap_section_part * section_part = 0; 669 mailimap_section_part * section_part = 0;
665 mailimap_section_spec * section_spec = 0; 670 mailimap_section_spec * section_spec = 0;
666 mailimap_section * section = 0; 671 mailimap_section * section = 0;
667 mailimap_fetch_att * fetch_att = 0; 672 mailimap_fetch_att * fetch_att = 0;
668 673
669 login(); 674 login();
670 if (!m_imap) { 675 if (!m_imap) {
671 return res; 676 return res;
672 } 677 }
673 if (!internal_call) { 678 if (!internal_call) {
674 err = selectMbox(mail->getMbox()); 679 err = selectMbox(mail->getMbox());
675 if ( err != MAILIMAP_NO_ERROR ) { 680 if ( err != MAILIMAP_NO_ERROR ) {
676 return res; 681 return res;
677 } 682 }
678 } 683 }
679 set = mailimap_set_new_single(mail->getNumber()); 684 set = mailimap_set_new_single(mail->getNumber());
680 685
681 clist*id_list = 0; 686 clist*id_list = 0;
682 687
683 /* if path == empty then its a request for the whole rfc822 mail and generates 688 /* if path == empty then its a request for the whole rfc822 mail and generates
684 a "fetch <id> (body[])" statement on imap server */ 689 a "fetch <id> (body[])" statement on imap server */
685 if (path.count()>0 ) { 690 if (path.count()>0 ) {
686 id_list = clist_new(); 691 id_list = clist_new();
687 for (unsigned j=0; j < path.count();++j) { 692 for (unsigned j=0; j < path.count();++j) {
688 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id)); 693 uint32_t * p_id = (uint32_t *)malloc(sizeof(*p_id));
689 *p_id = path[j]; 694 *p_id = path[j];
690 clist_append(id_list,p_id); 695 clist_append(id_list,p_id);
691 } 696 }
692 section_part = mailimap_section_part_new(id_list); 697 section_part = mailimap_section_part_new(id_list);
693 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL); 698 section_spec = mailimap_section_spec_new(MAILIMAP_SECTION_SPEC_SECTION_PART, NULL, section_part, NULL);
694 } 699 }
695 700
696 section = mailimap_section_new(section_spec); 701 section = mailimap_section_new(section_spec);
697 fetch_att = mailimap_fetch_att_new_body_section(section); 702 fetch_att = mailimap_fetch_att_new_body_section(section);
698 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att); 703 fetchType = mailimap_fetch_type_new_fetch_att(fetch_att);
699 704
700 clist*result = 0; 705 clist*result = 0;
701 706
702 err = mailimap_fetch( m_imap, set, fetchType, &result ); 707 err = mailimap_fetch( m_imap, set, fetchType, &result );
703 mailimap_set_free( set ); 708 mailimap_set_free( set );
704 mailimap_fetch_type_free( fetchType ); 709 mailimap_fetch_type_free( fetchType );
705 710
706 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) { 711 if (err == MAILIMAP_NO_ERROR && (current=clist_begin(result)) ) {
707 mailimap_msg_att * msg_att; 712 mailimap_msg_att * msg_att;
708 msg_att = (mailimap_msg_att*)current->data; 713 msg_att = (mailimap_msg_att*)current->data;
709 mailimap_msg_att_item*msg_att_item; 714 mailimap_msg_att_item*msg_att_item;
710 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { 715 for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) {
711 msg_att_item = (mailimap_msg_att_item*)clist_content(cur); 716 msg_att_item = (mailimap_msg_att_item*)clist_content(cur);
712 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { 717 if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) {
713 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { 718 if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) {
714 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; 719 char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part;
715 /* detach - we take over the content */ 720 /* detach - we take over the content */
716 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; 721 msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L;
717 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); 722 res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length);
718 } 723 }
719 } 724 }
720 } 725 }
721 } else { 726 } else {
722 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; 727 ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl;
723 } 728 }
724 if (result) mailimap_fetch_list_free(result); 729 if (result) mailimap_fetch_list_free(result);
725 return res; 730 return res;
726} 731}
727 732
728/* current_recursion is for recursive calls. 733/* current_recursion is for recursive calls.
729 current_count means the position inside the internal loop! */ 734 current_count means the position inside the internal loop! */
730void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, 735void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body,
731 int current_recursion,QValueList<int>recList,int current_count) 736 int current_recursion,QValueList<int>recList,int current_count)
732{ 737{
733 if (!body || current_recursion>=10) { 738 if (!body || current_recursion>=10) {
734 return; 739 return;
735 } 740 }
736 switch (body->bd_type) { 741 switch (body->bd_type) {
737 case MAILIMAP_BODY_1PART: 742 case MAILIMAP_BODY_1PART:
738 { 743 {
739 QValueList<int>countlist = recList; 744 QValueList<int>countlist = recList;
740 countlist.append(current_count); 745 countlist.append(current_count);
741 RecPartP currentPart = new RecPart(); 746 RecPartP currentPart = new RecPart();
742 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; 747 mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part;
743 QString id(""); 748 QString id("");
744 currentPart->setPositionlist(countlist); 749 currentPart->setPositionlist(countlist);
745 for (unsigned int j = 0; j < countlist.count();++j) { 750 for (unsigned int j = 0; j < countlist.count();++j) {
746 id+=(j>0?" ":""); 751 id+=(j>0?" ":"");
747 id+=QString("%1").arg(countlist[j]); 752 id+=QString("%1").arg(countlist[j]);
748 } 753 }
749 //odebug << "ID = " << id.latin1() << "" << oendl; 754 //odebug << "ID = " << id.latin1() << "" << oendl;
750 currentPart->setIdentifier(id); 755 currentPart->setIdentifier(id);
751 fillSinglePart(currentPart,part1); 756 fillSinglePart(currentPart,part1);
752 /* important: Check for is NULL 'cause a body can be empty! 757 /* important: Check for is NULL 'cause a body can be empty!
753 And we put it only into the mail if it is the FIRST part */ 758 And we put it only into the mail if it is the FIRST part */
754 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { 759 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) {
755 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); 760 QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding());
756 761
757 size_t index = 0; 762 size_t index = 0;
758 char*res = 0; 763 char*res = 0;
759 int err = MAILIMF_NO_ERROR; 764 int err = MAILIMF_NO_ERROR;
760 765
761 QString charset = currentPart->searchParamter( "charset"); 766 QString charset = currentPart->searchParamter( "charset");
762 qDebug("CHARSET %s ",charset.latin1() ); 767 qDebug("CHARSET %s ",charset.latin1() );
763 if ( false ) { 768 if ( false ) {
764 //if ( !charset.isEmpty() ) { 769 //if ( !charset.isEmpty() ) {
765 target_body->setCharset( charset ); 770 target_body->setCharset( charset );
766 //err = mailmime_encoded_phrase_parse("iso-8859-1", 771 //err = mailmime_encoded_phrase_parse("iso-8859-1",
767 // text, strlen(text),&index, "iso-8859-1",&res); 772 // text, strlen(text),&index, "iso-8859-1",&res);
768 err = mailmime_encoded_phrase_parse(charset.latin1(), 773 err = mailmime_encoded_phrase_parse(charset.latin1(),
769 body_text.latin1(), body_text.length(),&index, "utf-8",&res); 774 body_text.latin1(), body_text.length(),&index, "utf-8",&res);
770 if (err == MAILIMF_NO_ERROR && res && strlen(res)) { 775 if (err == MAILIMF_NO_ERROR && res && strlen(res)) {
771 //qDebug("res %d %s ", index, res); 776 //qDebug("res %d %s ", index, res);
772 body_text = QString::fromUtf8(res); 777 body_text = QString::fromUtf8(res);
773 } 778 }
774 if (res) free(res); 779 if (res) free(res);
775 } 780 }
776 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); 781 //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() );
777 target_body->setDescription(currentPart); 782 target_body->setDescription(currentPart);
778 target_body->setBodytext(body_text); 783 target_body->setBodytext(body_text);
779 if (countlist.count()>1) { 784 if (countlist.count()>1) {
780 target_body->addPart(currentPart); 785 target_body->addPart(currentPart);
781 } 786 }
782 } else { 787 } else {
783 target_body->addPart(currentPart); 788 target_body->addPart(currentPart);
784 } 789 }
785 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { 790 if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) {
786 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); 791 traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist);
787 } 792 }
788 } 793 }
789 break; 794 break;
790 case MAILIMAP_BODY_MPART: 795 case MAILIMAP_BODY_MPART:
791 { 796 {
792 QValueList<int>countlist = recList; 797 QValueList<int>countlist = recList;
793 clistcell*current=0; 798 clistcell*current=0;
794 mailimap_body*current_body=0; 799 mailimap_body*current_body=0;
795 unsigned int ccount = 1; 800 unsigned int ccount = 1;
796 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; 801 mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart;
797 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { 802 for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) {
798 current_body = (mailimap_body*)current->data; 803 current_body = (mailimap_body*)current->data;
799 if (current_body->bd_type==MAILIMAP_BODY_MPART) { 804 if (current_body->bd_type==MAILIMAP_BODY_MPART) {
800 RecPartP targetPart = new RecPart(); 805 RecPartP targetPart = new RecPart();
801 targetPart->setType("multipart"); 806 targetPart->setType("multipart");
802 fillMultiPart(targetPart,mailDescription); 807 fillMultiPart(targetPart,mailDescription);
diff --git a/kmicromail/viewmailbase.cpp b/kmicromail/viewmailbase.cpp
index c4731a7..d21696a 100644
--- a/kmicromail/viewmailbase.cpp
+++ b/kmicromail/viewmailbase.cpp
@@ -1,104 +1,104 @@
1// CHANGED 2004-08-06 Lutz Rogowski 1// CHANGED 2004-08-06 Lutz Rogowski
2#include <qtextbrowser.h> 2#include <qtextbrowser.h>
3#include <qlistview.h> 3#include <qlistview.h>
4#include <qaction.h> 4#include <qaction.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qvbox.h> 6#include <qvbox.h>
7 7
8#include <qtoolbar.h> 8#include <qtoolbar.h>
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include <kiconloader.h> 10#include <kiconloader.h>
11//#include <qpe/resource.h> 11//#include <qpe/resource.h>
12#include <klocale.h> 12#include <klocale.h>
13 13
14#include "viewmailbase.h" 14#include "viewmailbase.h"
15//#include "opendiag.h" 15//#include "opendiag.h"
16 16
17ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) 17ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl)
18 : QMainWindow(parent, name, fl) 18 : QMainWindow(parent, name, fl)
19{ 19{
20 20
21 setToolBarsMovable(false); 21 setToolBarsMovable(false);
22 22
23 toolbar = new QToolBar(this); 23 toolbar = new QToolBar(this);
24 menubar = new QMenuBar( toolbar ); 24 menubar = new QMenuBar( toolbar );
25 mailmenu = new QPopupMenu( menubar ); 25 mailmenu = new QPopupMenu( menubar );
26 menubar->insertItem( i18n( "Mail" ), mailmenu ); 26 menubar->insertItem( i18n( "Mail" ), mailmenu );
27 27
28 toolbar->setHorizontalStretchable(true); 28 toolbar->setHorizontalStretchable(true);
29 addToolBar(toolbar); 29 addToolBar(toolbar);
30 30
31 reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this); 31 reply = new QAction(i18n("Reply"),SmallIcon("reply"), 0, 0, this);
32 reply->addTo(toolbar); 32 reply->addTo(toolbar);
33 reply->addTo(mailmenu); 33 reply->addTo(mailmenu);
34 34
35 forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this); 35 forward = new QAction(i18n("Forward"),SmallIcon("forward"), 0, 0, this);
36 forward->addTo(toolbar); 36 forward->addTo(toolbar);
37 forward->addTo(mailmenu); 37 forward->addTo(mailmenu);
38 38
39 attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true); 39 attachbutton = new QAction(i18n("Attachments"),SmallIcon("attach"), 0, 0, this, 0, true);
40 attachbutton->addTo(toolbar); 40 attachbutton->addTo(toolbar);
41 attachbutton->addTo(mailmenu); 41 attachbutton->addTo(mailmenu);
42 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); 42 connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool)));
43 43
44 44
45 showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true ); 45 showHtml = new QAction( i18n( "Show Html" ), SmallIcon( "html" ), 0, 0, this, 0, true );
46 showHtml->addTo( toolbar ); 46 showHtml->addTo( toolbar );
47 showHtml->addTo( mailmenu ); 47 showHtml->addTo( mailmenu );
48 48
49 deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this); 49 deleteMail = new QAction(i18n("Delete Mail"),SmallIcon("trash"), 0, 0, this);
50 deleteMail->addTo(toolbar); 50 deleteMail->addTo(toolbar);
51 deleteMail->addTo(mailmenu); 51 deleteMail->addTo(mailmenu);
52 52
53 53
54 54
55 nextMail = new QAction(i18n("Show next mail"),SmallIcon("add"), 0, 0, this); 55 nextMail = new QAction(i18n("Show next mail"),SmallIcon("enter"), 0, 0, this);
56 QLabel *spacer = new QLabel(toolbar); 56 QLabel *spacer = new QLabel(toolbar);
57 nextMail->addTo(toolbar); 57 nextMail->addTo(toolbar);
58 nextMail->addTo(mailmenu); 58 nextMail->addTo(mailmenu);
59 59
60 60
61 61
62 62
63 closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this); 63 closeMail = new QAction(i18n("Close"),SmallIcon("exit"), 0, 0, this);
64 //QLabel *spacer = new QLabel(toolbar); 64 //QLabel *spacer = new QLabel(toolbar);
65 spacer->setBackgroundMode(QWidget::PaletteButton); 65 spacer->setBackgroundMode(QWidget::PaletteButton);
66 toolbar->setStretchableWidget(spacer); 66 toolbar->setStretchableWidget(spacer);
67 closeMail->addTo(toolbar); 67 closeMail->addTo(toolbar);
68 closeMail->addTo(mailmenu); 68 closeMail->addTo(mailmenu);
69 QVBox *view = new QVBox(this); 69 QVBox *view = new QVBox(this);
70 setCentralWidget(view); 70 setCentralWidget(view);
71 71
72 attachments = new QListView(view); 72 attachments = new QListView(view);
73 attachments->setMinimumHeight(90); 73 attachments->setMinimumHeight(90);
74 attachments->setMaximumHeight(90); 74 attachments->setMaximumHeight(90);
75 attachments->setAllColumnsShowFocus(true); 75 attachments->setAllColumnsShowFocus(true);
76 attachments->addColumn("Mime Type", 60); 76 attachments->addColumn("Mime Type", 60);
77 attachments->addColumn(i18n("Description"), 100); 77 attachments->addColumn(i18n("Description"), 100);
78 attachments->addColumn(i18n("Filename"), 80); 78 attachments->addColumn(i18n("Filename"), 80);
79 attachments->addColumn(i18n("Size"), 80); 79 attachments->addColumn(i18n("Size"), 80);
80 attachments->setSorting(-1); 80 attachments->setSorting(-1);
81 attachments->hide(); 81 attachments->hide();
82 82
83 browser = new QTextBrowser(view); 83 browser = new QTextBrowser(view);
84 84
85 //openDiag = new OpenDiag(view); 85 //openDiag = new OpenDiag(view);
86 //openDiag->hide(); 86 //openDiag->hide();
87 87
88} 88}
89 89
90void ViewMailBase::slotChangeAttachview(bool state) 90void ViewMailBase::slotChangeAttachview(bool state)
91{ 91{
92 if (state) attachments->show(); 92 if (state) attachments->show();
93 else attachments->hide(); 93 else attachments->hide();
94} 94}
95 95
96void ViewMailBase::keyPressEvent ( QKeyEvent * e ) 96void ViewMailBase::keyPressEvent ( QKeyEvent * e )
97{ 97{
98 if( e->key()==Qt::Key_Escape ) { 98 if( e->key()==Qt::Key_Escape ) {
99 close(); 99 close();
100 e->accept(); 100 e->accept();
101 return; 101 return;
102 } 102 }
103 QWidget::keyPressEvent(e); 103 QWidget::keyPressEvent(e);
104} 104}