deja-dup-team team mailing list archive
-
deja-dup-team team
-
Mailing list archive
-
Message #00044
[Merge] lp:~temposs/deja-dup/network-manager into lp:deja-dup
Andrew Fister has proposed merging lp:~temposs/deja-dup/network-manager into lp:deja-dup.
Requested reviews:
Déjà Dup Maintainers (deja-dup-team)
Related bugs:
#306978 Don't network-backup if no network
https://bugs.launchpad.net/bugs/306978
#397720 Deja Dup needs to wait for any network-up on login
https://bugs.launchpad.net/bugs/397720
#438389 Pause network backup when network-manager is down
https://bugs.launchpad.net/bugs/438389
The new code is ready for review and testing.
--
https://code.launchpad.net/~temposs/deja-dup/network-manager/+merge/13252
Your team Déjà Dup Maintainers is subscribed to branch lp:deja-dup.
=== modified file 'configure.ac'
--- configure.ac 2009-09-24 05:05:42 +0000
+++ configure.ac 2009-10-12 22:45:21 +0000
@@ -71,6 +71,7 @@
gtk+-2.0 >= $GTK_REQ_VER
gio-2.0 >= $GIO_REQ_VER
gconf-2.0
+ dbus-glib-1
gnome-keyring-1)
AC_SUBST(DUP_CFLAGS)
AC_SUBST(DUP_LIBS)
=== modified file 'deja-dup/Makefile.am'
--- deja-dup/Makefile.am 2009-09-02 01:06:00 +0000
+++ deja-dup/Makefile.am 2009-10-12 22:45:21 +0000
@@ -1,7 +1,8 @@
# -*- Mode: Makefile; indent-tabs-mode: t; tab-width: 2 -*-
#
# This file is part of Déjà Dup.
-# © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>
+# © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>,
+# © 2009 Andrew Fister <temposs@xxxxxxxxx>
#
# 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
@@ -25,6 +26,7 @@
--pkg gio-2.0 \
--pkg gconf-2.0 \
--pkg gnome-keyring-1 \
+ --pkg dbus-glib-1 \
--pkg libdeja-dup \
--pkg PassphraseSchema \
--pkg unix \
=== modified file 'libdeja-dup/Duplicity.vala'
--- libdeja-dup/Duplicity.vala 2009-09-24 00:24:16 +0000
+++ libdeja-dup/Duplicity.vala 2009-10-12 22:45:21 +0000
@@ -1,7 +1,8 @@
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
This file is part of Déjà Dup.
- © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>
+ © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>,
+ © 2009 Andrew Fister <temposs@xxxxxxxxx>
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
@@ -90,9 +91,48 @@
File last_touched_file = null;
+ protected dynamic DBus.Object network_manager;
+ protected bool connected = true;
+ protected const uint32 NM_STATE_CONNECTED = 3;
+
+ protected void init_dbus_to_network_manager() throws DBus.Error, GLib.Error
+ {
+ //Set up the DBus connection to network manager
+ DBus.Connection conn = DBus.Bus.get(DBus.BusType.SYSTEM);
+ network_manager = conn.get_object(
+ "org.freedesktop.NetworkManager",
+ "/org/freedesktop/NetworkManager",
+ "org.freedesktop.NetworkManager");
+
+ //Retrieve the network manager connection state.
+ uint32 network_manager_state = network_manager.State;
+ connected = network_manager_state == NM_STATE_CONNECTED;
+
+ //Dbus signal when the state of the connection is changed.
+ network_manager.StateChanged += network_manager_state_changed;
+ }
+
+ protected void network_manager_state_changed(DBus.Object obj, uint32 new_state)
+ {
+ bool was_connected = connected;
+ connected = new_state == NM_STATE_CONNECTED;
+
+ if (connected)
+ resume();
+ else if (was_connected)
+ pause();
+ }
+
public Duplicity(Operation.Mode mode, Gtk.Window? win) {
this.original_mode = mode;
toplevel = win;
+
+ try {
+ init_dbus_to_network_manager();
+ }
+ catch (Error e) {
+ warning("%s\n\n%s", e.message, "Failed to initialize DBus\n");
+ }
}
public virtual void start(Backend backend, bool encrypted,
@@ -122,9 +162,15 @@
delete_age = client.get_int(DELETE_AFTER_KEY);
}
catch (Error e) {warning("%s\n", e.message);}
-
+
if (!restart())
done(false, false);
+
+ if (!backend.is_native() && !connected) {
+ debug("No connection found. Postponing the backup.");
+ pause();
+ return;
+ }
}
public void cancel() {
@@ -149,6 +195,14 @@
}
}
+ public void pause() {
+ inst.pause();
+ }
+
+ public void resume() {
+ inst.resume();
+ }
+
void cancel_inst()
{
if (inst == null)
=== modified file 'libdeja-dup/DuplicityInstance.vala'
--- libdeja-dup/DuplicityInstance.vala 2009-09-21 00:18:22 +0000
+++ libdeja-dup/DuplicityInstance.vala 2009-10-12 22:45:21 +0000
@@ -1,7 +1,8 @@
/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
This file is part of Déjà Dup.
- © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>
+ © 2008,2009 Michael Terry <mike@xxxxxxxxxxx>,
+ © 2009 Andrew Fister <temposs@xxxxxxxxx>
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
@@ -140,6 +141,22 @@
else
done(false, true);
}
+
+ public void pause()
+ {
+ if (is_started())
+ stop_child();
+ else
+ done(false, true);
+ }
+
+ public void resume()
+ {
+ if (is_started())
+ cont_child();
+ else
+ done(false, true);
+ }
uint stanza_id;
uint watch_id;
@@ -169,6 +186,14 @@
void kill_child() {
Posix.kill((Posix.pid_t)child_pid, Posix.SIGKILL);
}
+
+ void stop_child() {
+ Posix.kill((Posix.pid_t)child_pid, Posix.SIGSTOP);
+ }
+
+ void cont_child() {
+ Posix.kill((Posix.pid_t)child_pid, Posix.SIGCONT);
+ }
bool read_stanza(IOChannel channel, IOCondition cond)
{
Follow ups