Merge lp:~andrewfister/deja-dup/network-manager into lp:~deja-dup-team/deja-dup/trunk

Proposed by Andrew Fister
Status: Merged
Merged at revision: not available
Proposed branch: lp:~andrewfister/deja-dup/network-manager
Merge into: lp:~deja-dup-team/deja-dup/trunk
Diff against target: 180 lines
4 files modified
configure.ac (+1/-0)
deja-dup/Makefile.am (+3/-1)
libdeja-dup/Duplicity.vala (+56/-2)
libdeja-dup/DuplicityInstance.vala (+26/-1)
To merge this branch: bzr merge lp:~andrewfister/deja-dup/network-manager
Reviewer Review Type Date Requested Status
Michael Terry Approve
Review via email: mp+13252@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Fister (andrewfister) wrote :

The new code is ready for review and testing.

Revision history for this message
Michael Terry (mterry) wrote :

Just a quick comment that the code looks good in theory from a quick scan. Won't have time to look at it in depth/test it for a couple days. :-/

Revision history for this message
Michael Terry (mterry) wrote :

Oh, and thanks! :)

Revision history for this message
Michael Terry (mterry) wrote :

Pushed in. Looks great! Thanks a bunch. I made a couple changes -- a few checks that 'inst' wasn't null for example. And a bit of logic to set the status to "Paused (no network)" while paused so that the user has some feedback.

Works well.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
71 gtk+-2.0 >= $GTK_REQ_VER71 gtk+-2.0 >= $GTK_REQ_VER
72 gio-2.0 >= $GIO_REQ_VER72 gio-2.0 >= $GIO_REQ_VER
73 gconf-2.073 gconf-2.0
74 dbus-glib-1
74 gnome-keyring-1)75 gnome-keyring-1)
75AC_SUBST(DUP_CFLAGS)76AC_SUBST(DUP_CFLAGS)
76AC_SUBST(DUP_LIBS)77AC_SUBST(DUP_LIBS)
7778
=== 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 @@
1# -*- Mode: Makefile; indent-tabs-mode: t; tab-width: 2 -*-1# -*- Mode: Makefile; indent-tabs-mode: t; tab-width: 2 -*-
2#2#
3# This file is part of Déjà Dup.3# This file is part of Déjà Dup.
4# © 2008,2009 Michael Terry <mike@mterry.name>4# © 2008,2009 Michael Terry <mike@mterry.name>,
5# © 2009 Andrew Fister <temposs@gmail.com>
5#6#
6# Déjà Dup is free software; you can redistribute it and/or modify7# Déjà Dup is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by8# it under the terms of the GNU General Public License as published by
@@ -25,6 +26,7 @@
25 --pkg gio-2.0 \26 --pkg gio-2.0 \
26 --pkg gconf-2.0 \27 --pkg gconf-2.0 \
27 --pkg gnome-keyring-1 \28 --pkg gnome-keyring-1 \
29 --pkg dbus-glib-1 \
28 --pkg libdeja-dup \30 --pkg libdeja-dup \
29 --pkg PassphraseSchema \31 --pkg PassphraseSchema \
30 --pkg unix \32 --pkg unix \
3133
=== 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 @@
1/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */1/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
2/*2/*
3 This file is part of Déjà Dup.3 This file is part of Déjà Dup.
4 © 2008,2009 Michael Terry <mike@mterry.name>4 © 2008,2009 Michael Terry <mike@mterry.name>,
5 © 2009 Andrew Fister <temposs@gmail.com>
56
6 Déjà Dup is free software: you can redistribute it and/or modify7 Déjà Dup is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -90,9 +91,48 @@
90 91
91 File last_touched_file = null;92 File last_touched_file = null;
92 93
94 protected dynamic DBus.Object network_manager;
95 protected bool connected = true;
96 protected const uint32 NM_STATE_CONNECTED = 3;
97
98 protected void init_dbus_to_network_manager() throws DBus.Error, GLib.Error
99 {
100 //Set up the DBus connection to network manager
101 DBus.Connection conn = DBus.Bus.get(DBus.BusType.SYSTEM);
102 network_manager = conn.get_object(
103 "org.freedesktop.NetworkManager",
104 "/org/freedesktop/NetworkManager",
105 "org.freedesktop.NetworkManager");
106
107 //Retrieve the network manager connection state.
108 uint32 network_manager_state = network_manager.State;
109 connected = network_manager_state == NM_STATE_CONNECTED;
110
111 //Dbus signal when the state of the connection is changed.
112 network_manager.StateChanged += network_manager_state_changed;
113 }
114
115 protected void network_manager_state_changed(DBus.Object obj, uint32 new_state)
116 {
117 bool was_connected = connected;
118 connected = new_state == NM_STATE_CONNECTED;
119
120 if (connected)
121 resume();
122 else if (was_connected)
123 pause();
124 }
125
93 public Duplicity(Operation.Mode mode, Gtk.Window? win) {126 public Duplicity(Operation.Mode mode, Gtk.Window? win) {
94 this.original_mode = mode;127 this.original_mode = mode;
95 toplevel = win;128 toplevel = win;
129
130 try {
131 init_dbus_to_network_manager();
132 }
133 catch (Error e) {
134 warning("%s\n\n%s", e.message, "Failed to initialize DBus\n");
135 }
96 }136 }
97 137
98 public virtual void start(Backend backend, bool encrypted,138 public virtual void start(Backend backend, bool encrypted,
@@ -122,9 +162,15 @@
122 delete_age = client.get_int(DELETE_AFTER_KEY);162 delete_age = client.get_int(DELETE_AFTER_KEY);
123 }163 }
124 catch (Error e) {warning("%s\n", e.message);}164 catch (Error e) {warning("%s\n", e.message);}
125 165
126 if (!restart())166 if (!restart())
127 done(false, false);167 done(false, false);
168
169 if (!backend.is_native() && !connected) {
170 debug("No connection found. Postponing the backup.");
171 pause();
172 return;
173 }
128 }174 }
129 175
130 public void cancel() {176 public void cancel() {
@@ -149,6 +195,14 @@
149 }195 }
150 }196 }
151197
198 public void pause() {
199 inst.pause();
200 }
201
202 public void resume() {
203 inst.resume();
204 }
205
152 void cancel_inst()206 void cancel_inst()
153 {207 {
154 if (inst == null)208 if (inst == null)
155209
=== 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 @@
1/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */1/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
2/*2/*
3 This file is part of Déjà Dup.3 This file is part of Déjà Dup.
4 © 2008,2009 Michael Terry <mike@mterry.name>4 © 2008,2009 Michael Terry <mike@mterry.name>,
5 © 2009 Andrew Fister <temposs@gmail.com>
56
6 Déjà Dup is free software: you can redistribute it and/or modify7 Déjà Dup is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by8 it under the terms of the GNU General Public License as published by
@@ -140,6 +141,22 @@
140 else141 else
141 done(false, true);142 done(false, true);
142 }143 }
144
145 public void pause()
146 {
147 if (is_started())
148 stop_child();
149 else
150 done(false, true);
151 }
152
153 public void resume()
154 {
155 if (is_started())
156 cont_child();
157 else
158 done(false, true);
159 }
143 160
144 uint stanza_id;161 uint stanza_id;
145 uint watch_id;162 uint watch_id;
@@ -169,6 +186,14 @@
169 void kill_child() {186 void kill_child() {
170 Posix.kill((Posix.pid_t)child_pid, Posix.SIGKILL);187 Posix.kill((Posix.pid_t)child_pid, Posix.SIGKILL);
171 }188 }
189
190 void stop_child() {
191 Posix.kill((Posix.pid_t)child_pid, Posix.SIGSTOP);
192 }
193
194 void cont_child() {
195 Posix.kill((Posix.pid_t)child_pid, Posix.SIGCONT);
196 }
172 197
173 bool read_stanza(IOChannel channel, IOCondition cond)198 bool read_stanza(IOChannel channel, IOCondition cond)
174 {199 {

Subscribers

People subscribed via source and target branches