~ubuntu-branches/ubuntu/saucy/deja-dup/saucy

« back to all changes in this revision

Viewing changes to common/CommonUtils.vala

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2012-10-30 19:03:03 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20121030190303-w3fatge63ncm5uiw
Tags: 25.1.1-0ubuntu1
* New upstream release
* debian/control:
  - Use libsecret, not libgnome-keyring
  - Switch to valac-0.18
  - Add various deja-dup-backend-* metapackages to make seeding
    different ones easier for flavors
* debian/tests:
  - Add dep8 test to run upstream test suite against system install
* debian/patches/support-new-u1backend.patch:
  - Support new u1backend in duplicity 0.6.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
327
327
  return rv;
328
328
}
329
329
 
330
 
const string SSH_USERNAME_KEY = "username";
331
 
const string SSH_SERVER_KEY = "server";
332
 
const string SSH_PORT_KEY = "port";
333
 
const string SSH_DIRECTORY_KEY = "directory";
334
 
 
335
 
// Once, we didn't use GIO, but had a special SSH backend for duplicity that
336
 
// would tell duplicity to use its own SSH handling.  We convert those gsettings
337
 
// values to the new ones here.
338
 
void convert_ssh_to_file()
339
 
{
340
 
  var settings = get_settings();
341
 
  var backend = settings.get_string(BACKEND_KEY);
342
 
  if (backend == "ssh") {
343
 
    settings.set_string(BACKEND_KEY, "file");
344
 
    var ssh_settings = get_settings("SSH");
345
 
    var server = ssh_settings.get_string(SSH_SERVER_KEY);
346
 
    if (server != null && server != "") {
347
 
      var username = ssh_settings.get_string(SSH_USERNAME_KEY);
348
 
      var port = ssh_settings.get_int(SSH_PORT_KEY);
349
 
      var directory = ssh_settings.get_string(SSH_DIRECTORY_KEY);
350
 
      
351
 
      var gio_uri = "ssh://";
352
 
      if (username != null && username != "")
353
 
        gio_uri += username + "@";
354
 
      gio_uri += server;
355
 
      if (port > 0 && port != 22)
356
 
        gio_uri += ":" + port.to_string();
357
 
      if (directory == null || directory == "")
358
 
        gio_uri += "/";
359
 
      else if (directory[0] != '/')
360
 
        gio_uri += "/" + directory;
361
 
      else
362
 
        gio_uri += directory;
363
 
      
364
 
      var file_settings = get_settings(FILE_ROOT);
365
 
      file_settings.set_string(FILE_PATH_KEY, gio_uri);
366
 
    }
367
 
  }
368
 
}
369
 
 
370
 
void convert_s3_folder_to_hostname()
371
 
{
372
 
  // So historically, the default S3 folder was '/'.  But in keeping with other
373
 
  // cloud backends, the desire to use a hostname in the default folder would
374
 
  // make one want to change that default.  But since the user might not have
375
 
  // actually changed the default, we don't want to upgrade the folder default
376
 
  // in such a case.  So we check here if the user has ever backed up before
377
 
  // and if not (or not using S3), then we update the field.
378
 
  var settings = get_settings();
379
 
  var s3_settings = get_settings(S3_ROOT);
380
 
  if ((s3_settings.get_string(S3_FOLDER_KEY) == "" ||
381
 
       s3_settings.get_string(S3_FOLDER_KEY) == "/") &&
382
 
      (Backend.get_default_type() != "s3" ||
383
 
       settings.get_string(LAST_RUN_KEY) == "")) {
384
 
    s3_settings.set_string(S3_FOLDER_KEY, "$HOSTNAME");
385
 
  }
386
 
}
387
 
 
388
330
ToolPlugin tool = null;
389
331
void initialize_tool_plugin() throws Error
390
332
{
433
375
    return false;
434
376
  }
435
377
 
436
 
  convert_ssh_to_file();
437
 
  convert_s3_folder_to_hostname();
438
 
 
439
378
  /* We do a little trick here.  BackendAuto -- which is the default
440
379
     backend on a fresh install of deja-dup -- will do some work to
441
380
     automatically suss out which backend should be used instead of it.
455
394
  var language = Environment.get_variable("DEJA_DUP_LANGUAGE");
456
395
  if (language != null && language != "")
457
396
    Environment.set_variable("LANGUAGE", language, true);
 
397
  Intl.setlocale(LocaleCategory.ALL, "");
458
398
  Intl.textdomain(Config.GETTEXT_PACKAGE);
459
399
  Intl.bindtextdomain(Config.GETTEXT_PACKAGE, localedir);
460
400
  Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "UTF-8");
582
522
  return date;
583
523
}
584
524
 
 
525
public Secret.Schema get_passphrase_schema()
 
526
{
 
527
  // Use freedesktop's schema id for historical reasons
 
528
  return new Secret.Schema("org.freedesktop.Secret.Generic",
 
529
                           Secret.SchemaFlags.NONE,
 
530
                           "owner", Secret.SchemaAttributeType.STRING,
 
531
                           "type", Secret.SchemaAttributeType.STRING);
 
532
}
 
533
 
585
534
} // end namespace
586
535