tags 316246 + patch
thanks
Hello,
Find attached a patch that closes the bug.
Changelog entry:
* Internet detection
+ Check at startup if http://art.gnome.org is reachable;
exit with an Error dialog if not.
+ Make sure whenever a download is needed that http://art.gnome.org
is reachable.
(closes: #316246)
Regards,
--
Alexis Sukrieh
Index: gnome-art-0.2/gnome-art/lib/gnome-art/get_art.rb
===================================================================
--- gnome-art-0.2.orig/gnome-art/lib/gnome-art/get_art.rb 2007-04-13
19:33:26.000000000 +0200
+++ gnome-art-0.2/gnome-art/lib/gnome-art/get_art.rb 2007-04-13
19:33:27.000000000 +0200
@@ -265,6 +265,12 @@
download(xml_filename, temp_filename)
end
+ # make sure we managed to fetch data from Internet,
+ if (! FileTest.exist?(temp_filename))
+ puts "Unable to retreive XML file from internet, not connected?"
+ return nil
+ end
+
themes = File.new(temp_filename, "r+")
if (themes == nil)
Index: gnome-art-0.2/gnome-art/lib/gnome-art/gnome_art.rb
===================================================================
--- gnome-art-0.2.orig/gnome-art/lib/gnome-art/gnome_art.rb 2007-04-13
19:33:26.000000000 +0200
+++ gnome-art-0.2/gnome-art/lib/gnome-art/gnome_art.rb 2007-04-13
19:35:49.000000000 +0200
@@ -128,6 +128,18 @@
init_directories
main_window = MainWindow.new(self)
+ # Check if we are connected, if not, refuse to start.
+ unless GnomeArt.isConnected
+ dialog = Gtk::MessageDialog.new(nil,
+ Gtk::Dialog::MODAL |
Gtk::Dialog::DESTROY_WITH_PARENT,
+ Gtk::MessageDialog::ERROR,
+ Gtk::MessageDialog::BUTTONS_OK,
+ "Unable to reach http://art.gnome.org.\n"+
+ "Make sure you are connected to Internet and try again.")
+ dialog.run
+ dialog.destroy
+ exit 1
+ end
Gtk.main
@@ -135,6 +147,23 @@
end
+ # method for pinging the outside world in order
+ # to know if we can assume that we have some network
+ # connection available
+ def self.isConnected
+ begin
+ url_to_ping = "http://art.gnome.org"
+ if open(url_to_ping, "rb")
+ return true
+ else
+ return false
+ end
+ # assume we got a SocketError if no connection up
+ rescue SocketError
+ return false
+ end
+ end
+
end
Index: gnome-art-0.2/gnome-art/lib/gnome-art/ui/main_window.rb
===================================================================
--- gnome-art-0.2.orig/gnome-art/lib/gnome-art/ui/main_window.rb
2007-04-13 19:33:27.000000000 +0200
+++ gnome-art-0.2/gnome-art/lib/gnome-art/ui/main_window.rb 2007-04-13
19:33:27.000000000 +0200
@@ -450,6 +450,11 @@
def reload_backgrounds
+ # we have to be able to reach Internet here
+ unless GnomeArt.isConnected
+ return nil
+ end
+
Thread.new {
show_download_dialog("Preparing download")
@@ -510,6 +515,10 @@
def reload_themes
+ # we have to be able to reach Internet here
+ unless GnomeArt.isConnected
+ return nil
+ end
Thread.new {