From: Philipp Zabel Date: Fri, 25 Jun 2010 16:49:20 +0000 (+0200) Subject: Adac Mitfahrclub: Split URL generation into separate functions X-Git-Url: http://vcs.maemo.org/git/?p=beifahrer;a=commitdiff_plain;h=6a28edb5332d5deddefd323113fb31b660982c49 Adac Mitfahrclub: Split URL generation into separate functions --- diff --git a/src/adac-mitfahrclub.vala b/src/adac-mitfahrclub.vala index e93fe95..bf5f25d 100644 --- a/src/adac-mitfahrclub.vala +++ b/src/adac-mitfahrclub.vala @@ -400,21 +400,17 @@ public class AdacMitfahrclub { return result; } - public async List? get_lift_list (string city_from, int radius_from, string city_to, int radius_to, Date date, int tolerance = 0) { + public string? get_lift_list_url (string city_from, int radius_from, string city_to, int radius_to, Date date, int tolerance = 0) { if (city_list == null) get_city_list (); int num_from = get_city_number (city_from); - if (num_from == 0) { - stderr.printf ("Unknown city: %s\n", city_to); + if (num_from == 0) return null; - } int num_to = get_city_number (city_to); - if (num_to == 0) { - stderr.printf ("Unknown city: %s\n", city_to); + if (num_to == 0) return null; - } string url = HTTP_BASE_URI + "/mitfahrclub/%s/%s/b.html".printf ( city_from, @@ -435,7 +431,11 @@ public class AdacMitfahrclub { tolerance ); - var doc = yield get_html_document (url); + return url; + } + + public async List? get_lift_list (string city_from, int radius_from, string city_to, int radius_to, Date date, int tolerance = 0) { + var doc = yield get_html_document (get_lift_list_url (city_from, radius_from, city_to, radius_to, date, tolerance)); if (doc == null) { stderr.printf ("Error: parsing failed\n"); return null; @@ -531,10 +531,12 @@ public class AdacMitfahrclub { return lift; } - public async bool update_lift_details (Lift lift) { - string url = HTTP_BASE_URI + lift.href; + public string get_lift_details_url (Lift lift) { + return HTTP_BASE_URI + lift.href; + } - var doc = yield get_html_document (url); + public async bool update_lift_details (Lift lift) { + var doc = yield get_html_document (get_lift_details_url (lift)); if (doc == null) { stderr.printf ("Error: parsing failed\n"); return false; @@ -675,10 +677,12 @@ public class AdacMitfahrclub { return true; } - public async MyInformation get_my_information () { - string url = HTTPS_BASE_URI + "/users/view"; + public string get_my_information_url () { + return HTTPS_BASE_URI + "/users/view"; + } - var doc = yield get_html_document (url); + public async MyInformation get_my_information () { + var doc = yield get_html_document (get_my_information_url ()); if (doc == null) { stderr.printf ("Error: parsing failed\n"); return null;