~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
                                     _("Host or user not available in url"));
103
103
        }
104
104
 
105
 
        /*XXX: The number 3 assigned to the list_loaded variable denotes
106
 
         * the number of times the get_folder_info is called during startup.
107
 
         * We are just trying to minimize the call.
108
 
         * This is a dirty hack. But it *WORKS*
109
 
         */
110
 
        groupwise_store->list_loaded = 3;
111
 
 
112
105
        /*storage path*/
113
106
        priv->storage_path = camel_session_get_storage_path (session, service, ex);
114
107
        if (!priv->storage_path)
909
902
        if (e_gw_container_get_is_system_folder (container))
910
903
                fi->flags |= CAMEL_FOLDER_SYSTEM;
911
904
 
912
 
        fi->total = e_gw_container_get_total_count (container);
913
 
        fi->unread = e_gw_container_get_unread_count (container);
914
 
 
915
 
        si->info.total = fi->total;
916
 
        si->info.unread = fi->unread;
917
905
        si->info.flags = fi->flags;
918
906
        /*refresh info*/
919
907
        if (store->current_folder
943
931
        CamelStoreInfo *si = NULL;
944
932
        gint count, i;
945
933
 
946
 
        if (!priv->cnc && ((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL) {
947
 
                if (((CamelService *)store)->status == CAMEL_SERVICE_DISCONNECTED) {
948
 
                        ((CamelService *)store)->status = CAMEL_SERVICE_CONNECTING;
949
 
                        groupwise_connect ((CamelService *)store, ex);
950
 
                }
951
 
        }
952
 
 
953
934
        status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
954
935
        if (status == E_GW_CONNECTION_STATUS_INVALID_CONNECTION)
955
936
                status = e_gw_connection_get_container_list (priv->cnc, "folders", &folder_list);
1002
983
 
1003
984
                if (e_gw_container_is_root(container))
1004
985
                        continue;
1005
 
                if ( (type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS) )
 
986
                if ((type == E_GW_CONTAINER_TYPE_CALENDAR) || (type == E_GW_CONTAINER_TYPE_CONTACTS))
1006
987
                        continue;
1007
988
 
1008
989
                info = convert_to_folder_info (store, E_GW_CONTAINER (folder_list->data), (const gchar *)url, ex);
1140
1121
groupwise_get_folder_info (CamelStore *store, const gchar *top, guint32 flags, CamelException *ex)
1141
1122
{
1142
1123
        CamelGroupwiseStore *groupwise_store = CAMEL_GROUPWISE_STORE (store);
1143
 
        CamelGroupwiseStorePrivate *priv = groupwise_store->priv;
1144
1124
        CamelFolderInfo *info = NULL;
1145
 
        gchar *top_folder = NULL;
1146
 
 
1147
 
        if (top) {
1148
 
                top_folder = g_hash_table_lookup (priv->name_hash, top);
1149
 
                /* 'top' is a valid path, but doesnt have a container id
1150
 
                 *  return NULL */
1151
 
/*              if (!top_folder) {
1152
 
                        camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
1153
 
                                        _("You must be working online to complete this operation"));
1154
 
                        return NULL;
1155
 
                }*/
1156
 
        }
1157
 
 
1158
 
        if (top && groupwise_is_system_folder (top))
1159
 
                return groupwise_build_folder_info (groupwise_store, NULL, top );
1160
 
 
1161
 
        /*
1162
 
         * Thanks to Michael, for his cached folders implementation in IMAP
1163
 
         * is used as is here.
1164
 
         */
1165
 
        if (camel_store_summary_count ((CamelStoreSummary *)groupwise_store->summary) == 0) {
1166
 
                CAMEL_SERVICE_REC_LOCK (store, connect_lock);
1167
 
                if (groupwise_store->list_loaded == 3) {
1168
 
                        groupwise_folders_sync (groupwise_store, ex);
1169
 
                        groupwise_store->list_loaded -= 1;
1170
 
                }
1171
 
                if (camel_exception_is_set (ex)) {
1172
 
                        camel_store_summary_save ((CamelStoreSummary *) groupwise_store->summary);
1173
 
                        CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
1174
 
                        return NULL;
1175
 
                }
 
1125
 
 
1126
        /* Do not call groupwise_store_connected function as it would internall call folders_sync
 
1127
           to populate the hash table which is used for mapping container id */
 
1128
        if (!(((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
 
1129
            && camel_service_connect ((CamelService *)store, ex)))
 
1130
                goto offline;
 
1131
 
 
1132
        CAMEL_SERVICE_REC_LOCK (store, connect_lock);
 
1133
 
 
1134
        groupwise_folders_sync (groupwise_store, ex);
 
1135
        if (camel_exception_is_set (ex)) {
1176
1136
                CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
1177
 
                camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
1178
 
                goto end_r;
1179
 
        }
1180
 
 
1181
 
        if ((camel_store_summary_count((CamelStoreSummary *)groupwise_store->summary) > 0) && (groupwise_store->list_loaded > 1)) {
1182
 
                /*Load from cache*/
1183
 
                groupwise_store->list_loaded -= 1;
1184
 
                goto end_r;
1185
 
        }
1186
 
 
1187
 
        CAMEL_SERVICE_REC_LOCK (store, connect_lock);
1188
 
        if ((groupwise_store->list_loaded == 1) && check_for_connection((CamelService *)store, ex)) {
1189
 
                if (!priv->cnc) {
1190
 
                        if (groupwise_connect ((CamelService *)store, ex)) {
1191
 
                                g_warning ("Could connect!!!\n");
1192
 
                        } else
1193
 
                                g_warning ("Could not connect..failure connecting\n");
1194
 
                }
1195
 
                if (camel_groupwise_store_connected (groupwise_store, ex)) {
1196
 
                        if (groupwise_store->current_folder)
1197
 
                                CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS (groupwise_store->current_folder))->sync(groupwise_store->current_folder, FALSE, ex);
1198
 
                        groupwise_folders_sync (groupwise_store, ex);
1199
 
                        if (camel_exception_is_set (ex)) {
1200
 
                                CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
1201
 
                                return NULL;
1202
 
                        }
1203
 
                        camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
1204
 
                        camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
1205
 
                }
1206
 
        }
 
1137
                return NULL;
 
1138
        }
 
1139
 
 
1140
        camel_store_summary_touch ((CamelStoreSummary *)groupwise_store->summary);
 
1141
        camel_store_summary_save ((CamelStoreSummary *)groupwise_store->summary);
 
1142
 
1207
1143
        CAMEL_SERVICE_REC_UNLOCK (store, connect_lock);
1208
1144
 
1209
 
        /*camel_exception_clear (ex);*/
1210
 
end_r:
 
1145
offline:
1211
1146
        info = groupwise_get_folder_info_offline (store, top, flags, ex);
1212
1147
        return info;
1213
1148
}
1487
1422
{
1488
1423
        if (((CamelOfflineStore *) store)->state == CAMEL_OFFLINE_STORE_NETWORK_AVAIL
1489
1424
            && camel_service_connect ((CamelService *)store, ex)) {
 
1425
                CamelGroupwiseStore *gw_store = (CamelGroupwiseStore *) store;
 
1426
                CamelGroupwiseStorePrivate *priv = gw_store->priv;
 
1427
 
 
1428
                if (g_hash_table_size (priv->name_hash) == 0)
 
1429
                        groupwise_folders_sync ((CamelGroupwiseStore *) gw_store, ex);
 
1430
 
1490
1431
                return TRUE;
1491
1432
        }
1492
1433
        /*Not online, so return FALSE*/