~ubuntu-branches/debian/sid/evolution-exchange/sid

« back to all changes in this revision

Viewing changes to storage/exchange-migrate.c

  • Committer: Bazaar Package Importer
  • Author(s): Heikki Henriksen
  • Date: 2008-07-06 15:22:58 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080706152258-nur42ykoj5d3ivw5
Tags: 2.22.3.dfsg-1
* New upstream release 
  - bugfixes
* debian/control 
  - bump Standards-Version to 3.8.0 (no changes)
  - bump build-dep on libecal1.2-dev to 2.22.3 to get
    e-cal-check-timezones.h
* debian/watch
  - add dversionmangle

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
        GtkWidget *window;
96
96
        GtkWidget *error_dialog;
97
97
        gchar *err_string;
98
 
        
 
98
 
99
99
        err_string = g_strdup_printf ( _("Warning: Evolution could not migrate "
100
100
                                        "all the Exchange account data from "
101
101
                                        "the version %d.%d.%d. \nThe data "
102
102
                                        "hasn't been deleted, but will not be "
103
 
                                        "seen by this version of Evolution"), 
 
103
                                        "seen by this version of Evolution"),
104
104
                                        maj, min, rev);
105
105
 
106
106
        window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
167
167
        if (stat (dest, &st) == 0 && st.st_size > 0)
168
168
                goto ret;
169
169
 
170
 
        if (stat (src, &st) == -1) 
 
170
        if (stat (src, &st) == -1)
171
171
                goto ret;
172
172
 
173
173
        if ((readfd = open (src, O_RDONLY)) == -1)
199
199
                total += nwritten;
200
200
 
201
201
                if (show_progress)
202
 
                        dialog_set_progress ((((double) total) / 
 
202
                        dialog_set_progress ((((double) total) /
203
203
                                              ((double) st.st_size)));
204
204
        } while (total < st.st_size);
205
205
 
242
242
        struct stat st;
243
243
        DIR *dir;
244
244
 
245
 
        if (e_util_mkdir_hier (dest, 0777) == -1)
 
245
        if (g_mkdir_with_parents (dest, 0777) == -1)
246
246
                return FALSE;
247
247
 
248
248
        if (!(dir = opendir (src)))
255
255
        destpath = g_string_new (dest);
256
256
        g_string_append_c (destpath, '/');
257
257
        dlen = destpath->len;
258
 
                
 
258
 
259
259
        dialog_set_folder_name(src);
260
260
 
261
261
        while ((dent = readdir (dir))) {
300
300
        }
301
301
        dir_path = g_strndup(path->str, strlen(path->str) - 12);
302
302
        g_string_free (path, TRUE);
303
 
        return dir_path; 
 
303
        return dir_path;
304
304
}
305
305
 
306
306
static gchar*
311
311
        gchar *dir_path = NULL;
312
312
 
313
313
        dot = strchr (file_to_be_migrated, '.');
314
 
        if (dot) { 
 
314
        if (dot) {
315
315
                file_name = g_strndup (file_to_be_migrated, dot - file_to_be_migrated);
316
316
                dir_path = form_dir_path (file_name, delim);
317
317
                g_free (file_name);
318
318
        }
319
 
        g_free (file_to_be_migrated);   
 
319
        g_free (file_to_be_migrated);
320
320
        return dir_path;
321
321
}
322
322
 
323
323
/*
324
 
 * Parse the names of summary and changes files in 
325
 
 * ~/evolution/exchange/user@exchange-server/Addressbook and  
326
 
 * copy them into the respective directories under 
 
324
 * Parse the names of summary and changes files in
 
325
 * ~/evolution/exchange/user@exchange-server/Addressbook and
 
326
 * copy them into the respective directories under
327
327
 * ~/.evolution/exchange/user@exchange-server
328
328
 *
329
329
 */
330
330
/* FIXME: handling .changes files */
331
331
/* FIXME: handling VCARD attributes changes */
332
332
 
333
 
static gboolean 
 
333
static gboolean
334
334
migrate_contacts (gchar *src_path, const gchar *dest_path)
335
335
{
336
336
        gchar *dest_sub_dir = NULL, *summary_file = NULL;
344
344
        dir = opendir (src_path);
345
345
        if (dir) {
346
346
                while ((dent = readdir (dir))) {
347
 
                        if (!strcmp (dent->d_name, ".") || 
 
347
                        if (!strcmp (dent->d_name, ".") ||
348
348
                            !strcmp (dent->d_name, ".."))
349
349
                                continue;
350
350
 
351
351
                        /* Parse the file name and form the dir hierarchy */
352
 
                        dest_sub_dir = get_contacts_dir_from_filename ( 
 
352
                        dest_sub_dir = get_contacts_dir_from_filename (
353
353
                                                                dent->d_name);
354
354
 
355
355
                        if (dest_sub_dir) {
356
356
                                contacts_dir = g_build_filename (
357
 
                                                        dest_path, 
 
357
                                                        dest_path,
358
358
                                                        dest_sub_dir,
359
359
                                                        NULL);
360
 
        
 
360
 
361
361
                                /* Check if it is a summary file */
362
 
                                summary_file = g_strrstr (dent->d_name, 
 
362
                                summary_file = g_strrstr (dent->d_name,
363
363
                                                          ".summary");
364
 
                                if (summary_file) 
 
364
                                if (summary_file)
365
365
                                        dest_file = g_build_filename (
366
366
                                                        contacts_dir,
367
 
                                                        "summary", 
 
367
                                                        "summary",
368
368
                                                        NULL);
369
369
                                else
370
370
                                        /* FIXME: replace d_name by change_id */
372
372
                                                        contacts_dir,
373
373
                                                        dent->d_name,
374
374
                                                        NULL);
375
 
                        
 
375
 
376
376
                                /* Create destination dir, and copy the files */
377
 
                                if (e_util_mkdir_hier (contacts_dir, 0777) == -1) {
 
377
                                if (g_mkdir_with_parents (contacts_dir, 0777) == -1) {
378
378
                                        ret = FALSE;
379
379
                                        g_free (dest_file);
380
380
                                        g_free (contacts_dir);
381
381
                                        continue;
382
382
                                }
383
383
 
384
 
                                src_file = g_build_filename ( src_path, 
385
 
                                                              dent->d_name, 
 
384
                                src_file = g_build_filename ( src_path,
 
385
                                                              dent->d_name,
386
386
                                                              NULL);
387
387
 
388
388
                                ret = cp (src_file, dest_file, TRUE);
402
402
        return ret;
403
403
}
404
404
 
405
 
/* 
406
 
 * Copy the summary files from ~/evolution/mail/exchange to 
 
405
/*
 
406
 * Copy the summary files from ~/evolution/mail/exchange to
407
407
 * ~/.evolution/exchange/
408
408
 */
409
 
static gboolean 
 
409
static gboolean
410
410
migrate_mail (gchar *src_path, const gchar *dest_path)
411
411
{
412
412
        gboolean ret;
414
414
        setup_progress_dialog ();
415
415
        ret = cp_r (src_path, dest_path);
416
416
        dialog_close ();
417
 
        
 
417
 
418
418
        return ret;
419
419
}
420
420
 
421
 
/* 
422
 
 * copy personal and public folders from ~/evolution/exchange into 
 
421
/*
 
422
 * copy personal and public folders from ~/evolution/exchange into
423
423
 * ~/.evolution/exchange.
424
 
 * 
 
424
 *
425
425
 * This includes copying all the folders and metadata.xml files, also
426
 
 * Calendar and Tasks, cache files 
 
426
 * Calendar and Tasks, cache files
427
427
 */
428
428
static gboolean
429
429
migrate_common (gchar *src_path, const gchar *dest_path)
450
450
}
451
451
 
452
452
void
453
 
exchange_migrate (const CORBA_short major, 
454
 
                  const CORBA_short minor, 
 
453
exchange_migrate (const CORBA_short major,
 
454
                  const CORBA_short minor,
455
455
                  const CORBA_short revision,
456
456
                  const gchar *base_dir,
457
457
                  char *account_filename)
470
470
 
471
471
                /* This is not needed if done by cp_r() */
472
472
                if (stat (base_dir, &st) == -1) {
473
 
                        if (errno != ENOENT || 
474
 
                            e_util_mkdir_hier (base_dir, 0777) == -1) {
 
473
                        if (errno != ENOENT ||
 
474
                            g_mkdir_with_parents (base_dir, 0777) == -1) {
475
475
                                printf ("Failed to create directory `%s': %s",
476
476
                                base_dir, g_strerror (errno));
477
477
                                return;
478
478
                        }
479
479
                }
480
480
 
481
 
                src_path = g_build_filename (g_get_home_dir (), 
482
 
                                             "evolution", 
483
 
                                             "exchange", 
484
 
                                             account_filename, 
 
481
                src_path = g_build_filename (g_get_home_dir (),
 
482
                                             "evolution",
 
483
                                             "exchange",
 
484
                                             account_filename,
485
485
                                             NULL);
486
486
                ret = migrate_common (src_path, base_dir);
487
487
                g_free (src_path);
488
488
 
489
 
                src_path = g_build_filename (g_get_home_dir (), 
490
 
                                             "evolution", 
491
 
                                             "exchange", 
492
 
                                             account_filename, 
 
489
                src_path = g_build_filename (g_get_home_dir (),
 
490
                                             "evolution",
 
491
                                             "exchange",
 
492
                                             account_filename,
493
493
                                             "Addressbook",
494
494
                                             NULL);
495
495
                ret = migrate_contacts ( src_path, base_dir);
496
496
                g_free (src_path);
497
 
                
498
 
                src_path = g_build_filename (g_get_home_dir (), 
499
 
                                             "evolution", 
 
497
 
 
498
                src_path = g_build_filename (g_get_home_dir (),
 
499
                                             "evolution",
500
500
                                             "mail",
501
 
                                             "exchange", 
502
 
                                             account_filename, 
 
501
                                             "exchange",
 
502
                                             account_filename,
503
503
                                             NULL);
504
504
                ret = migrate_mail ( src_path, base_dir);
505
505
                g_free (src_path);