Commit 3d4d65b2 authored by Michael Terry's avatar Michael Terry

merge prefs-reorg branch

parents e71f973f 861f73f9
......@@ -38,8 +38,19 @@ widgets/ConfigLabelPolicy.c
widgets/ConfigLabel.c
widgets/ConfigList.c
widgets/ConfigLocation.c
widgets/ConfigLocationDAV.c
widgets/ConfigLocationFTP.c
widgets/ConfigLocationFile.c
widgets/ConfigLocationS3.c
widgets/ConfigLocationSMB.c
widgets/ConfigLocationSSH.c
widgets/ConfigLocationTable.c
widgets/ConfigLocationVolume.c
widgets/ConfigNumber.c
widgets/ConfigPeriod.c
widgets/ConfigRelPath.c
widgets/ConfigURLPart.c
widgets/ConfigURLPartBool.c
widgets/ConfigWidget.c
widgets/ToggleGroup.c
widgets/WidgetUtils.c
......
......@@ -14,6 +14,10 @@ Files: po/*.po
Copyright: 2008–2010 Rosetta Contributors and Canonical Ltd
License: GPL-3+
Files: common/uriutils.[ch]
Copyright: 2006-2007 Red Hat, Inc
License: GPL-3+
Files: nautilus/NautilusExtension.[ch]
Copyright: 2004–2005 Free Software Foundation, Inc.
2009 Michael Terry <mike@mterry.name>
......@@ -31,7 +35,7 @@ Files: man/help2man
Copyright: 1997–2005, 2009–2010 Free Software Foundation, Inc.
License: GPL-3+
Files: data/*.svg
Files: data/icons/*.svg
License:
In the public domain
......
## -*- Mode: m4; indent-tabs-mode: nil; tab-width: 2 -*-
##
## Copyright (C) 2001 Eazel, Inc.
## Author: Maciej Stachowiak <mjs@noisehavoc.org>
## Kenneth Christiansen <kenneth@gnu.org>
## Michael Terry <mike@mterry.name>
##
## Déjà Dup is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## Déjà Dup is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
## Parts copied/modified from intltool.m4 by Michael Terry
dnl AC_PROG_VALAC([MINIMUM-VERSION])
AC_DEFUN([AC_PROG_VALAC], [
AC_PATH_PROG([VALAC], [valac], [])
USE_VALAC=true
if test -z "$VALAC"; then
AC_MSG_WARN([Vala compilation is disabled.])
USE_VALAC=false
elif test -n "$1"; then
AC_MSG_CHECKING([valac version >= $1])
VALAC_REQUIRED_VERSION_AS_INT=`echo $1 | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'`
VALAC_APPLIED_VERSION=`$VALAC --version | head -1 | cut -d" " -f2`
[VALAC_APPLIED_VERSION_AS_INT=`echo $VALAC_APPLIED_VERSION | awk -F. '{ print $ 1 * 1000 + $ 2 * 100 + $ 3; }'`
]
AC_MSG_RESULT([$VALAC_APPLIED_VERSION found])
if test "$VALAC_APPLIED_VERSION_AS_INT" -lt "$VALAC_REQUIRED_VERSION_AS_INT"; then
AC_MSG_WARN([Your valac is too old. You need valac $1 or later.])
AC_MSG_WARN([Vala compilation is disabled.])
USE_VALAC=false
fi
fi
AM_CONDITIONAL([USE_VALAC], [test x$USE_VALAC = xtrue])
# -*- Mode: m4; indent-tabs-mode: nil; tab-width: 2 -*-
#
# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# Check whether the Vala compiler exists in `PATH'. If it is found, the
# variable VALAC is set. Optionally a minimum release number of the
# compiler can be requested.
#
# DEJA_PROG_VALAC([MINIMUM-VERSION])
# --------------------------------
AC_DEFUN([DEJA_PROG_VALAC],
[AC_PATH_PROG([VALAC], [valac-0.10], [])
AS_IF([test -z "$VALAC"],
[AC_MSG_WARN([No Vala compiler found. You will not be able to compile .vala source files.])],
[AS_IF([test -n "$1"],
[AC_MSG_CHECKING([$VALAC is at least version $1])
am__vala_version=`$VALAC --version | sed 's/Vala *//'`
AS_VERSION_COMPARE([$1], ["$am__vala_version"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Vala $1 not found.])])])])
])
......@@ -42,6 +42,7 @@ public abstract class Backend : Object
public static const uint64 INFINITE_SPACE = uint64.MAX;
public virtual async uint64 get_space(bool free = true) {return INFINITE_SPACE;}
public virtual bool space_can_be_infinite() {return true;}
// Arguments needed only when the particular mode is active
// If mode == INVALID, arguments needed any time the backup is referenced.
......
......@@ -143,19 +143,26 @@ public class BackendFile : Backend
}
public override Icon? get_icon() {
try {
var settings = get_settings(FILE_ROOT);
var type = settings.get_string(FILE_TYPE_KEY);
if (type == "volume") {
var icon_str = settings.get_string(FILE_ICON_KEY);
return Icon.new_for_string(icon_str);
}
else {
var settings = get_settings(FILE_ROOT);
var type = settings.get_string(FILE_TYPE_KEY);
string icon_name;
if (type == "volume")
icon_name = settings.get_string(FILE_ICON_KEY);
else {
try {
var file = get_file_from_settings();
var info = file.query_info(FILE_ATTRIBUTE_STANDARD_ICON,
FileQueryInfoFlags.NONE, null);
return info.get_icon();
}
catch (Error e) {
// Likely a remote server that is not mounted
icon_name = "folder-remote";
}
}
try {
return Icon.new_for_string(icon_name);
}
catch (Error e) {
warning("%s\n", e.message);
......@@ -186,6 +193,8 @@ public class BackendFile : Backend
{
var settings = get_settings(FILE_ROOT);
get_settings().set_string(BACKEND_KEY, "file");
if (!file.is_native()) {
settings.set_string(FILE_TYPE_KEY, "normal");
return;
......@@ -208,24 +217,36 @@ public class BackendFile : Backend
if (volume == null)
return;
string relpath = null;
if (file != null) {
relpath = mount.get_root().get_relative_path(file);
if (relpath == null)
relpath = "";
}
set_volume_info(volume, relpath);
}
public async static void set_volume_info(Volume volume, string? relpath = null)
{
get_settings().set_string(BACKEND_KEY, "file");
var uuid = volume.get_identifier(VOLUME_IDENTIFIER_KIND_UUID);
if (uuid == null || uuid == "")
return;
var relpath = mount.get_root().get_relative_path(file);
if (relpath == null)
relpath = "";
var settings = get_settings(FILE_ROOT);
settings.delay();
settings.set_string(FILE_UUID_KEY, uuid);
settings.set_value(FILE_RELPATH_KEY, new Variant.bytestring(relpath));
settings.set_string(FILE_TYPE_KEY, "volume");
settings.set_string(FILE_UUID_KEY, uuid);
if (relpath != null)
settings.set_value(FILE_RELPATH_KEY, new Variant.bytestring(relpath));
settings.apply();
update_volume_info(volume);
}
static void update_volume_info(Volume volume) throws Error
static void update_volume_info(Volume volume)
{
var settings = get_settings(FILE_ROOT);
......@@ -252,16 +273,6 @@ public class BackendFile : Backend
settings.set_string(FILE_SHORT_NAME_KEY, short_name);
settings.set_string(FILE_ICON_KEY, icon_str);
// Also update full path just in case (useful if downgrading to old version?)
var mount = volume.get_mount();
if (mount != null) {
var path_val = settings.get_value(FILE_RELPATH_KEY);
var path = path_val.get_bytestring();
if (path != null)
path = mount.get_root().get_child(path).get_parse_name();
settings.set_string(FILE_PATH_KEY, path);
}
settings.apply();
}
......@@ -337,7 +348,7 @@ public class BackendFile : Backend
return rv;
}
static Volume? find_volume_by_uuid(string uuid)
public static Volume? find_volume_by_uuid(string uuid)
{
var mon = VolumeMonitor.get();
mon.ref(); // bug 569418; bad things happen when VM goes away
......@@ -391,6 +402,8 @@ public class BackendFile : Backend
return INFINITE_SPACE;
}
}
public override bool space_can_be_infinite() {return false;}
}
} // end namespace
......
......@@ -49,6 +49,7 @@ libcommon_la_VALABUILTSOURCES = \
libcommon_la_SOURCES = \
chacks.c chacks.h \
uriutils.c uriutils.h \
$(libcommon_la_VALABUILTSOURCES)
if MAINTAINER_MODE
......
/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
* This file is part of Déjà Dup (but originally grabbed from gvfs).
* Copyright (C) 2006-2007 Red Hat, Inc.
*
* Déjà Dup is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* Déjà Dup is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#include "uriutils.h"
#include <string.h>
#include <stdlib.h>
void
deja_dup_decoded_uri_free (DejaDupDecodedUri *decoded)
{
if (decoded == NULL)
return;
g_free (decoded->scheme);
g_free (decoded->query);
g_free (decoded->fragment);
g_free (decoded->userinfo);
g_free (decoded->host);
g_free (decoded->path);
g_free (decoded);
}
DejaDupDecodedUri *
deja_dup_decoded_uri_new (void)
{
DejaDupDecodedUri *uri;
uri = g_new0 (DejaDupDecodedUri, 1);
uri->port = -1;
return uri;
}
DejaDupDecodedUri *
deja_dup_decode_uri (const char *uri)
{
DejaDupDecodedUri *decoded;
const char *p, *in, *hier_part_start, *hier_part_end, *query_start, *fragment_start;
char *out;
char c;
/* From RFC 3986 Decodes:
* URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
*/
p = uri;
/* Decode scheme:
scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
*/
if (!g_ascii_isalpha (*p))
return NULL;
while (1)
{
c = *p++;
if (c == ':')
break;
if (!(g_ascii_isalnum(c) ||
c == '+' ||
c == '-' ||
c == '.'))
return NULL;
}
decoded = deja_dup_decoded_uri_new ();
decoded->scheme = g_malloc (p - uri);
out = decoded->scheme;
for (in = uri; in < p - 1; in++)
*out++ = g_ascii_tolower (*in);
*out = 0;
hier_part_start = p;
query_start = strchr (p, '?');
if (query_start)
{
hier_part_end = query_start++;
fragment_start = strchr (query_start, '#');
if (fragment_start)
{
decoded->query = g_strndup (query_start, fragment_start - query_start);
decoded->fragment = g_strdup (fragment_start+1);
}
else
{
decoded->query = g_strdup (query_start);
decoded->fragment = NULL;
}
}
else
{
/* No query */
decoded->query = NULL;
fragment_start = strchr (p, '#');
if (fragment_start)
{
hier_part_end = fragment_start++;
decoded->fragment = g_strdup (fragment_start);
}
else
{
hier_part_end = p + strlen (p);
decoded->fragment = NULL;
}
}
/* 3:
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
*/
if (hier_part_start[0] == '/' &&
hier_part_start[1] == '/')
{
const char *authority_start, *authority_end;
const char *userinfo_start, *userinfo_end;
const char *host_start, *host_end;
const char *port_start;
authority_start = hier_part_start + 2;
/* authority is always followed by / or nothing */
authority_end = memchr (authority_start, '/', hier_part_end - authority_start);
if (authority_end == NULL)
authority_end = hier_part_end;
/* 3.2:
authority = [ userinfo "@" ] host [ ":" port ]
*/
/* Look for the last so that any multiple @ signs are put in the username part.
* This is not quite correct, as @ should be escaped here, but this happens
* in practice, so lets handle it the "nicer" way at least. */
userinfo_end = g_strrstr_len (authority_start,
authority_end - authority_start, "@");
if (userinfo_end)
{
userinfo_start = authority_start;
decoded->userinfo = g_uri_unescape_segment (userinfo_start, userinfo_end, NULL);
if (decoded->userinfo == NULL)
{
deja_dup_decoded_uri_free (decoded);
return NULL;
}
host_start = userinfo_end + 1;
}
else
host_start = authority_start;
/* We should handle hostnames in brackets, as those are used by IPv6 URIs
* See http://tools.ietf.org/html/rfc2732 */
if (*host_start == '[')
{
char *s;
port_start = NULL;
host_end = memchr (host_start, ']', authority_end - host_start);
if (host_end == NULL)
{
deja_dup_decoded_uri_free (decoded);
return NULL;
}
/* Look for the start of the port,
* And we sure we don't have it start somewhere
* in the path section */
s = (char *) host_end;
while (1)
{
if (*s == '/')
{
port_start = NULL;
break;
}
else if (*s == ':')
{
port_start = s;
break;
}
else if (*s == '\0')
{
break;
}
s++;
}
}
else
{
port_start = memchr (host_start, ':', authority_end - host_start);
}
if (port_start)
{
host_end = port_start++;
decoded->port = atoi(port_start);
}
else
{
host_end = authority_end;
decoded->port = -1;
}
decoded->host = g_uri_unescape_segment (host_start, host_end, NULL);
hier_part_start = authority_end;
}
decoded->path = g_uri_unescape_segment (hier_part_start, hier_part_end, "/");
if (decoded->path == NULL)
{
deja_dup_decoded_uri_free (decoded);
return NULL;
}
return decoded;
}
char *
deja_dup_encode_uri (DejaDupDecodedUri *decoded, gboolean allow_utf8)
{
GString *uri;
uri = g_string_new (NULL);
g_string_append (uri, decoded->scheme);
g_string_append (uri, "://");
if (decoded->host != NULL)
{
if (decoded->userinfo)
{
/* userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) */
g_string_append_uri_escaped (uri, decoded->userinfo,
G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, allow_utf8);
g_string_append_c (uri, '@');
}
g_string_append_uri_escaped (uri, decoded->host,
/* Allowed unescaped in hostname / ip address */
G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":[]" ,
allow_utf8);
if (decoded->port != -1)
{
g_string_append_c (uri, ':');
g_string_append_printf (uri, "%d", decoded->port);
}
}
g_string_append_uri_escaped (uri, decoded->path, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, allow_utf8);
if (decoded->query)
{
g_string_append_c (uri, '?');
g_string_append (uri, decoded->query);
}
if (decoded->fragment)
{
g_string_append_c (uri, '#');
g_string_append (uri, decoded->fragment);
}
return g_string_free (uri, FALSE);
}
/* -*- Mode: C; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
* This file is part of Déjà Dup (but originally grabbed from gvfs).
* Copyright (C) 2006-2007 Red Hat, Inc.
*
* Déjà Dup is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* Déjà Dup is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Déjà Dup. If not, see <http://www.gnu.org/licenses/>.
*
* Author: Alexander Larsson <alexl@redhat.com>
*/
#ifndef __URI_UTILS_H__
#define __URI_UTILS_H__
#include <glib.h>
G_BEGIN_DECLS
typedef struct {
char *scheme;
char *userinfo;
char *host;
int port; /* -1 => not in uri */
char *path;
char *query;
char *fragment;
} DejaDupDecodedUri;
char * deja_dup_encode_uri (DejaDupDecodedUri *decoded,
gboolean allow_utf8);
void deja_dup_decoded_uri_free (DejaDupDecodedUri *decoded);
DejaDupDecodedUri *deja_dup_decode_uri (const char *uri);
DejaDupDecodedUri *deja_dup_decoded_uri_new (void);
G_END_DECLS
#endif /* __URI_UTILS_H__ */
......@@ -43,7 +43,7 @@ LT_INIT
# Checks for valac
if test "x$USE_MAINTAINER_MODE" = "xyes" ; then
AM_PROG_VALAC([0.10])
DEJA_PROG_VALAC([0.10])
if test "x$VALAC" = "x" ; then
AC_MSG_ERROR([Cannot find the "valac" compiler in your PATH])
fi
......
......@@ -20,7 +20,8 @@ nobase_dist_data_DATA = \
icons/hicolor/scalable/apps/deja-dup.svg \
icons/hicolor/scalable/apps/deja-dup-symbolic.svg \
icons/hicolor/scalable/actions/deja-dup-backup.svg \
icons/hicolor/scalable/actions/deja-dup-restore.svg
icons/hicolor/scalable/actions/deja-dup-restore.svg \
icons/hicolor/scalable/devices/deja-dup-cloud.svg
nobase_dist_pkgdata_DATA = \
ui/restore-missing.ui
......
This diff is collapsed.
......@@ -40,6 +40,7 @@ public class AssistantBackup : AssistantOperation
{
int rows = 0;
Gtk.Widget w, label;
Gtk.SizeGroup label_sizes = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL);
var vbox = new Gtk.VBox(false, 0);
vbox.border_width = 12;
......@@ -48,12 +49,16 @@ public class AssistantBackup : AssistantOperation
page.set("row-spacing", 6,
"column-spacing", 6);
w = new DejaDup.ConfigLocation();
var location = new DejaDup.ConfigLocation(label_sizes);
label = new Gtk.Label.with_mnemonic(_("_Backup location:"));
label.set("xalign", 0.0f,
"mnemonic-widget", w);
"mnemonic-widget", location);
label_sizes.add_widget(label);
page.attach(label, 0, 1, rows, rows + 1, Gtk.AttachOptions.FILL, 0, 0, 0);
page.attach(w, 1, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
page.attach(location, 1, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
++rows;
page.attach(location.extras, 0, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
++rows;
w = new DejaDup.ConfigBool(DejaDup.ENCRYPT_KEY, _("_Encrypt backup files"));
......@@ -66,7 +71,18 @@ public class AssistantBackup : AssistantOperation
vbox.pack_start(page, true, true, 0);
vbox.pack_end(w, false, false, 0);
vbox.show_all();
// Now make sure to reserve the excess space that the hidden bits of
// ConfigLocation will need.
Gtk.Requisition req, hidden;
vbox.size_request(out req);
hidden = location.hidden_size();
req.width = req.width + hidden.width;
req.height = req.height + hidden.height;
vbox.set_size_request(req.width, req.height);
return vbox;
}
......
......@@ -84,18 +84,23 @@ public class AssistantRestore : AssistantOperation
{
int rows = 0;
Gtk.Widget w, label;
Gtk.SizeGroup label_sizes = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL);
var page = new Gtk.Table(rows, 2, false);
page.set("row-spacing", 6,
"column-spacing", 6,
"border-width", 12);
w = new DejaDup.ConfigLocation();
var location = new DejaDup.ConfigLocation(label_sizes);
label = new Gtk.Label.with_mnemonic(_("_Backup location:"));
label.set("xalign", 0.0f,
"mnemonic-widget", w);
"mnemonic-widget", location);
label_sizes.add_widget(label);
page.attach(label, 0, 1, rows, rows + 1, Gtk.AttachOptions.FILL, 0, 0, 0);
page.attach(w, 1, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
page.attach(location, 1, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
++rows;
page.attach(location.extras, 0, 2, rows, rows + 1, Gtk.AttachOptions.FILL | Gtk.AttachOptions.EXPAND, 0, 0, 0);
++rows;
w = new DejaDup.ConfigBool(DejaDup.ENCRYPT_KEY, _("Backup files are _encrypted"));
......@@ -104,6 +109,17 @@ public class AssistantRestore : AssistantOperation
Gtk.AttachOptions.FILL, 0, 0);
++rows;
page.show_all();
// Now make sure to reserve the excess space that the hidden bits of
// ConfigLocation will need.
Gtk.Requisition req, hidden;
page.size_request(out req);
hidden = location.hidden_size();
req.width = req.width + hidden.width;
req.height = req.height + hidden.height;
page.set_size_request(req.width, req.height);
return page;
}
......
......@@ -6,19 +6,13 @@ data/deja-dup-preferences.desktop.in
data/org.gnome.DejaDup.gschema.xml.in
[type: gettext/glade]data/ui/restore-missing.ui
deja-dup/Assistant.vala
deja-dup/AssistantBackup.vala
deja-dup/AssistantOperation.vala
deja-dup/AssistantRestore.vala
deja-dup/AssistantRestoreMissing.vala
deja-dup/main.vala
deja-dup/MainWindow.vala
deja-dup/MountOperationAssistant.vala
deja-dup/StatusIcon.vala
common/chacks.c
nautilus/NautilusExtension.c
widgets/whacks.c
common/BackendFile.vala
common/BackendS3.vala
common/Backend.vala
common/chacks.c
common/CommonUtils.vala
common/DuplicityInfo.vala
common/DuplicityInstance.vala
......@@ -32,8 +26,16 @@ common/Operation.vala
common/RecursiveDelete.vala
common/RecursiveMove.vala