~ubuntu-branches/ubuntu/natty/evolution-data-server/natty

« back to all changes in this revision

Viewing changes to camel/providers/imap/camel-imap-folder.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-07 14:11:56 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: james.westby@ubuntu.com-20110207141156-jakojbbkzee62447
Tags: 2.32.2-0ubuntu1
* New upstream release
* debian/patches/01_various_linking_issues.patch:
* debian/patches/02_fix_sources_migration.patch:
* debian/patches/199-git-backport-2.32.1-b08a6a1_to_2d0f4a3.patch:
* debian/patches/199-git-backport-2.32.1-to-b08a6a1.patch:
* debian/patches/199-git-skip-empty-cache-files-ee21a86.patch:
  - Fixed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
        PROP_CHECK_FOLDER = 0x2500
70
70
};
71
71
 
 
72
enum {
 
73
        /* used when moving messages and has real trash folder set with a google account */
 
74
        CAMEL_MESSAGE_IMAP_MOVED = CAMEL_MESSAGE_FOLDER_FLAGGED << 1
 
75
};
 
76
 
72
77
extern gint camel_application_is_exiting;
73
78
 
74
79
static gboolean imap_rescan (CamelFolder *folder, gint exists, GError **error);
1364
1369
                        }
1365
1370
                }
1366
1371
 
1367
 
                if (deleted_uids && (info->info.flags & CAMEL_MESSAGE_DELETED) != 0) {
 
1372
                if (deleted_uids && (info->info.flags & (CAMEL_MESSAGE_DELETED | CAMEL_MESSAGE_IMAP_MOVED)) == CAMEL_MESSAGE_DELETED) {
1368
1373
                        g_ptr_array_add (deleted_uids, (gpointer) camel_pstring_strdup (camel_message_info_uid (info)));
 
1374
                        info->info.flags &= ~CAMEL_MESSAGE_DELETED;
1369
1375
                } else if (junked_uids && (info->info.flags & CAMEL_MESSAGE_JUNK) != 0) {
1370
1376
                        g_ptr_array_add (junked_uids, (gpointer) camel_pstring_strdup (camel_message_info_uid (info)));
1371
1377
                }
1441
1447
        return TRUE;
1442
1448
}
1443
1449
 
 
1450
static gboolean
 
1451
host_ends_with (const gchar *host, const gchar *ends)
 
1452
{
 
1453
        gint host_len, ends_len;
 
1454
 
 
1455
        g_return_val_if_fail (host != NULL, FALSE);
 
1456
        g_return_val_if_fail (ends != NULL, FALSE);
 
1457
 
 
1458
        host_len = strlen (host);
 
1459
        ends_len = strlen (ends);
 
1460
 
 
1461
        return ends_len <= host_len && g_ascii_strcasecmp (host + host_len - ends_len, ends) == 0;
 
1462
}
 
1463
 
 
1464
static gboolean
 
1465
is_google_account (CamelStore *store)
 
1466
{
 
1467
        CamelService *service;
 
1468
 
 
1469
        g_return_val_if_fail (store != NULL, FALSE);
 
1470
        g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE);
 
1471
 
 
1472
        service = CAMEL_SERVICE (store);
 
1473
        g_return_val_if_fail (service != NULL, FALSE);
 
1474
 
 
1475
        return service->url && service->url->host && (
 
1476
                host_ends_with (service->url->host, "gmail.com") ||
 
1477
                host_ends_with (service->url->host, "googlemail.com"));
 
1478
}
 
1479
 
1444
1480
static void
1445
1481
move_messages (CamelFolder *src_folder,
1446
1482
               GPtrArray *uids,
1472
1508
        CamelImapStore *store;
1473
1509
        CamelImapMessageInfo *info;
1474
1510
        CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
1475
 
        gboolean success;
 
1511
        gboolean success, is_gmail;
1476
1512
        CamelFolder *real_junk = NULL;
1477
1513
        CamelFolder *real_trash = NULL;
1478
1514
        GError *local_error = NULL;
1483
1519
 
1484
1520
        parent_store = camel_folder_get_parent_store (folder);
1485
1521
        store = CAMEL_IMAP_STORE (parent_store);
 
1522
        is_gmail = is_google_account (parent_store);
1486
1523
 
1487
1524
        if (folder->permanent_flags == 0 || CAMEL_OFFLINE_STORE (store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL) {
1488
1525
                if (expunge) {
1582
1619
                        break;
1583
1620
                }
1584
1621
 
1585
 
                if (deleted_uids && (info->info.flags & CAMEL_MESSAGE_DELETED) != 0) {
 
1622
                if (deleted_uids && !is_gmail && (info->info.flags & CAMEL_MESSAGE_DELETED) != 0) {
1586
1623
                        /* there is a real trash, do not set it on the server */
1587
1624
                        info->info.flags &= ~CAMEL_MESSAGE_DELETED;
1588
1625
                }
1634
1671
                if (local_error == NULL) {
1635
1672
                        for (j = 0; j < matches->len; j++) {
1636
1673
                                info = matches->pdata[j];
1637
 
                                if (deleted_uids) {
 
1674
                                if (deleted_uids && !is_gmail) {
1638
1675
                                        /* there is a real trash, do not keep this set */
1639
1676
                                        info->info.flags &= ~CAMEL_MESSAGE_DELETED;
1640
1677
                                }
1641
1678
 
1642
 
                                info->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
 
1679
                                info->info.flags &= ~(CAMEL_MESSAGE_FOLDER_FLAGGED | CAMEL_MESSAGE_IMAP_MOVED);
1643
1680
                                ((CamelImapMessageInfo *) info)->server_flags = info->info.flags & CAMEL_IMAP_SERVER_FLAGS;
1644
1681
                                info->info.dirty = TRUE; /* Sync it back to the DB */
1645
1682
                                if (((CamelMessageInfo *) info)->summary)
2642
2679
        gchar *uidset;
2643
2680
        gint uid = 0, last=0, i;
2644
2681
        GError *local_error = NULL;
 
2682
        gboolean mark_moved;
2645
2683
 
2646
2684
        parent_store = camel_folder_get_parent_store (source);
2647
2685
        store = CAMEL_IMAP_STORE (parent_store);
 
2686
        mark_moved = is_google_account (parent_store) && store && store->real_trash_path && *store->real_trash_path;
2648
2687
 
2649
2688
        full_name = camel_folder_get_full_name (destination);
2650
2689
 
2672
2711
                }
2673
2712
 
2674
2713
                if (local_error == NULL && delete_originals) {
2675
 
                        for (i=last;i<uid;i++)
 
2714
                        for (i = last; i < uid; i++) {
2676
2715
                                camel_folder_delete_message(source, uids->pdata[i]);
 
2716
                                if (mark_moved) {
 
2717
                                        CamelMessageInfoBase *info = (CamelMessageInfoBase *) camel_folder_summary_uid (source->summary, uids->pdata[i]);
 
2718
 
 
2719
                                        if (info)
 
2720
                                                info->flags |= CAMEL_MESSAGE_IMAP_MOVED;
 
2721
                                }
 
2722
                        }
2677
2723
                        last = uid;
2678
2724
                }
2679
2725
                g_free (uidset);