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

« back to all changes in this revision

Viewing changes to camel/providers/nntp/camel-nntp-store.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
199
199
        struct _xover_header *xover, *last;
200
200
 
201
201
        /* manual override */
202
 
        if (store->xover || getenv("CAMEL_NNTP_DISABLE_XOVER") != NULL)
 
202
        if (store->xover || getenv ("CAMEL_NNTP_DISABLE_XOVER") != NULL)
203
203
                return 0;
204
204
 
205
 
        ret = camel_nntp_raw_command_auth(store, cancellable, error, &line, "list overview.fmt");
 
205
        ret = camel_nntp_raw_command_auth (store, cancellable, error, &line, "list overview.fmt");
206
206
        if (ret == -1) {
207
207
                return -1;
208
208
        } else if (ret != 215)
223
223
                                for (i = 0; i < G_N_ELEMENTS (headers); i++) {
224
224
                                        if (strcmp (line, headers[i].name) == 0) {
225
225
                                                xover->name = headers[i].name;
226
 
                                                if (strncmp((gchar *) p, "full", 4) == 0)
 
226
                                                if (strncmp ((gchar *) p, "full", 4) == 0)
227
227
                                                        xover->skip = strlen (xover->name) + 1;
228
228
                                                else
229
229
                                                        xover->skip = 0;
261
261
        gchar *user;
262
262
 
263
263
        session = camel_service_get_session (service);
264
 
        settings = camel_service_get_settings (service);
265
264
        user_cache_dir = camel_service_get_user_cache_dir (service);
266
265
 
 
266
        settings = camel_service_ref_settings (service);
 
267
 
267
268
        network_settings = CAMEL_NETWORK_SETTINGS (settings);
268
269
        host = camel_network_settings_dup_host (network_settings);
269
270
        user = camel_network_settings_dup_user (network_settings);
270
271
 
 
272
        g_object_unref (settings);
 
273
 
271
274
        tcp_stream = camel_network_service_connect_sync (
272
275
                CAMEL_NETWORK_SERVICE (service), cancellable, error);
273
276
 
447
450
        gchar *host;
448
451
        gchar *name;
449
452
 
450
 
        settings = camel_service_get_settings (service);
 
453
        settings = camel_service_ref_settings (service);
451
454
 
452
455
        network_settings = CAMEL_NETWORK_SETTINGS (settings);
453
456
        host = camel_network_settings_dup_host (network_settings);
454
457
 
 
458
        g_object_unref (settings);
 
459
 
455
460
        if (brief)
456
461
                name = g_strdup_printf ("%s", host);
457
462
        else
482
487
        store = CAMEL_NNTP_STORE (service);
483
488
 
484
489
        password = camel_service_get_password (service);
485
 
        settings = camel_service_get_settings (service);
 
490
 
 
491
        settings = camel_service_ref_settings (service);
486
492
 
487
493
        network_settings = CAMEL_NETWORK_SETTINGS (settings);
488
494
        user = camel_network_settings_dup_user (network_settings);
489
495
 
 
496
        g_object_unref (settings);
 
497
 
490
498
        if (user == NULL) {
491
499
                g_set_error_literal (
492
500
                        error, CAMEL_SERVICE_ERROR,
648
656
                si = (CamelNNTPStoreInfo *) camel_store_summary_info_new (summ);
649
657
 
650
658
                relpath = g_alloca (strlen (line) + 2);
651
 
                sprintf(relpath, "/%s", line);
 
659
                sprintf (relpath, "/%s", line);
652
660
 
653
661
                si->info.path = g_strdup (line);
654
662
                si->full_name = g_strdup (line); /* why do we keep this? */
667
675
                }
668
676
        }
669
677
 
670
 
        dd(printf("store info update '%s' first '%u' last '%u'\n", line, first, last));
 
678
        dd (printf ("store info update '%s' first '%u' last '%u'\n", line, first, last));
671
679
 
672
680
        if (si->last) {
673
681
                if (last > si->last)
709
717
                return NULL;
710
718
 
711
719
        service = CAMEL_SERVICE (store);
712
 
        settings = camel_service_get_settings (service);
 
720
 
 
721
        settings = camel_service_ref_settings (service);
713
722
 
714
723
        short_folder_names = camel_nntp_settings_get_short_folder_names (
715
724
                CAMEL_NNTP_SETTINGS (settings));
716
725
 
 
726
        g_object_unref (settings);
 
727
 
717
728
        for (i = 0; i < camel_store_summary_count ((CamelStoreSummary *) store->summary); i++) {
718
729
                si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i);
719
730
                if (si == NULL)
858
869
        GHashTable *known; /* folder name to folder info */
859
870
        gboolean folder_hierarchy_relative;
860
871
        gchar *tmpname;
861
 
        gchar *top = g_strconcat(orig_top?orig_top:"", ".", NULL);
 
872
        gchar *top = g_strconcat (orig_top ? orig_top:"", ".", NULL);
862
873
        gint toplen = strlen (top);
863
874
 
864
875
        service = CAMEL_SERVICE (store);
865
 
        settings = camel_service_get_settings (service);
 
876
 
 
877
        settings = camel_service_ref_settings (service);
866
878
 
867
879
        folder_hierarchy_relative =
868
880
                camel_nntp_settings_get_folder_hierarchy_relative (
869
881
                CAMEL_NNTP_SETTINGS (settings));
870
882
 
 
883
        g_object_unref (settings);
 
884
 
871
885
        known = g_hash_table_new (g_str_hash, g_str_equal);
872
886
 
873
887
        for (i = 0; (si = camel_store_summary_index ((CamelStoreSummary *) store->summary, i)); i++) {
965
979
               GError **error)
966
980
{
967
981
        guchar *line;
968
 
        gint ret = camel_nntp_command(nntp_store, cancellable, error, NULL, (gchar **)&line, "date");
 
982
        gint ret = camel_nntp_command (nntp_store, cancellable, error, NULL, (gchar **) &line, "date");
969
983
        gchar *ptr;
970
984
 
971
985
        nntp_store->summary->last_newslist[0] = 0;
1034
1048
                        /* at first, we do a DATE to find out the last load occasion */
1035
1049
                        nntp_get_date (nntp_store, cancellable, NULL);
1036
1050
                do_complete_list_nodate:
1037
 
                        ret = camel_nntp_command (nntp_store, cancellable, error, NULL, (gchar **)&line, "list");
 
1051
                        ret = camel_nntp_command (nntp_store, cancellable, error, NULL, (gchar **) &line, "list");
1038
1052
                        if (ret == -1)
1039
1053
                                goto error;
1040
1054
                        else if (ret != 215) {
1083
1097
        CamelNNTPStore *nntp_store = CAMEL_NNTP_STORE (store);
1084
1098
        CamelFolderInfo *first = NULL;
1085
1099
 
1086
 
        dd(printf("g_f_i: fast %d subscr %d recursive %d online %d top \"%s\"\n",
 
1100
        dd (printf (
 
1101
                "g_f_i: fast %d subscr %d recursive %d online %d top \"%s\"\n",
1087
1102
                flags & CAMEL_STORE_FOLDER_INFO_FAST,
1088
1103
                flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED,
1089
1104
                flags & CAMEL_STORE_FOLDER_INFO_RECURSIVE,
1090
1105
                online,
1091
 
                top?top:""));
 
1106
                top ? top:""));
1092
1107
 
1093
1108
        if (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)
1094
1109
                first = nntp_store_get_subscribed_folder_info (
1095
1110
                        nntp_store, top, flags, cancellable, error);
1096
1111
        else
1097
 
                first = nntp_store_get_folder_info_all (nntp_store, top, flags, online, cancellable, error);
 
1112
                first = nntp_store_get_folder_info_all (
 
1113
                        nntp_store, top, flags, online, cancellable, error);
1098
1114
 
1099
1115
        return first;
1100
1116
}
1134
1150
                error, CAMEL_FOLDER_ERROR,
1135
1151
                CAMEL_FOLDER_ERROR_INVALID,
1136
1152
                _("You cannot create a folder in a News store: "
1137
 
                  "subscribe instead."));
 
1153
                "subscribe instead."));
1138
1154
 
1139
1155
        return NULL;
1140
1156
}
1173
1189
                error, CAMEL_FOLDER_ERROR,
1174
1190
                CAMEL_FOLDER_ERROR_INVALID,
1175
1191
                _("You cannot remove a folder in a News store: "
1176
 
                  "unsubscribe instead."));
 
1192
                "unsubscribe instead."));
1177
1193
 
1178
1194
        return FALSE;
1179
1195
}
1358
1374
        gboolean success = TRUE;
1359
1375
 
1360
1376
        service = CAMEL_SERVICE (subscribable);
1361
 
        settings = camel_service_get_settings (service);
 
1377
 
 
1378
        settings = camel_service_ref_settings (service);
1362
1379
 
1363
1380
        short_folder_names = camel_nntp_settings_get_short_folder_names (
1364
1381
                CAMEL_NNTP_SETTINGS (settings));
1365
1382
 
 
1383
        g_object_unref (settings);
 
1384
 
1366
1385
        si = camel_store_summary_path (CAMEL_STORE_SUMMARY (nntp_store->summary), folder_name);
1367
1386
        if (!si) {
1368
1387
                g_set_error (
1369
1388
                        error, CAMEL_FOLDER_ERROR,
1370
1389
                        CAMEL_FOLDER_ERROR_INVALID,
1371
1390
                        _("You cannot subscribe to this newsgroup:\n\n"
1372
 
                          "No such newsgroup. The selected item is a "
1373
 
                          "probably a parent folder."));
 
1391
                        "No such newsgroup. The selected item is a "
 
1392
                        "probably a parent folder."));
1374
1393
                success = FALSE;
1375
1394
        } else {
1376
1395
                if (!(si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)) {
1402
1421
        gboolean success = TRUE;
1403
1422
 
1404
1423
        service = CAMEL_SERVICE (subscribable);
1405
 
        settings = camel_service_get_settings (service);
 
1424
 
 
1425
        settings = camel_service_ref_settings (service);
1406
1426
 
1407
1427
        short_folder_names = camel_nntp_settings_get_short_folder_names (
1408
1428
                CAMEL_NNTP_SETTINGS (settings));
1409
1429
 
 
1430
        g_object_unref (settings);
 
1431
 
1410
1432
        fitem = camel_store_summary_path (CAMEL_STORE_SUMMARY (nntp_store->summary), folder_name);
1411
1433
 
1412
1434
        if (!fitem) {
1414
1436
                        error, CAMEL_FOLDER_ERROR,
1415
1437
                        CAMEL_FOLDER_ERROR_INVALID,
1416
1438
                        _("You cannot unsubscribe to this newsgroup:\n\n"
1417
 
                          "newsgroup does not exist!"));
 
1439
                        "newsgroup does not exist!"));
1418
1440
                success = FALSE;
1419
1441
        } else {
1420
1442
                if (fitem->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) {
1565
1587
                                        strval = g_strdup_printf ("%u-%u", u, u2);
1566
1588
                                break;
1567
1589
                        default:
1568
 
                                g_warning("Passing unknown format to nntp_command: %c\n", c);
 
1590
                                g_warning ("Passing unknown format to nntp_command: %c\n", c);
1569
1591
                                g_assert (0);
1570
1592
                        }
1571
1593
 
1705
1727
 
1706
1728
                /* Check for unprocessed data, !*/
1707
1729
                if (store->stream && store->stream->mode == CAMEL_NNTP_STREAM_DATA) {
1708
 
                        g_warning("Unprocessed data left in stream, flushing");
 
1730
                        g_warning ("Unprocessed data left in stream, flushing");
1709
1731
                        while (camel_nntp_stream_getd (store->stream, (guchar **) &p, &u, cancellable, error) > 0)
1710
1732
                                ;
1711
1733
                }
1713
1735
 
1714
1736
                if (folder != NULL
1715
1737
                    && (store->current_folder == NULL || strcmp (store->current_folder, full_name) != 0)) {
1716
 
                        ret = camel_nntp_raw_command_auth(store, cancellable, &local_error, line, "group %s", full_name);
 
1738
                        ret = camel_nntp_raw_command_auth (store, cancellable, &local_error, line, "group %s", full_name);
1717
1739
                        if (ret == 211) {
1718
1740
                                g_free (store->current_folder);
1719
1741
                                store->current_folder = g_strdup (full_name);