+ public string get_my_offers_url () {
+ return HTTP_BASE_URI + "/lifts/mysinglelifts";
+ }
+
+ public async List<Lift>? get_my_offers () {
+ var doc = yield get_html_document (get_my_offers_url ());
+ if (doc == null) {
+ stderr.printf ("Error: parsing failed\n");
+ return null;
+ }
+
+ var table = search_tag_by_class (doc->children, "table", "list");
+ if (table == null) {
+ stderr.printf ("Error: does not contain user table\n");
+ return null;
+ }
+
+ var list = new List<Lift> ();
+ for (var n = table->children; n != null; n = n->next) {
+ if (n->name == "tr") {
+ var lift = parse_offer_row (n);
+ if (lift != null) // Skip the title row
+ list.append ((owned) lift);
+ }
+ }
+
+ if (table->next != null && table->next->name == "div") {
+ var text = get_child_text_content (table->next);
+ if (text != null) {
+ print ("\"%s\"\n", text);
+ if (text == "Sie haben derzeit keine einmaligen Fahrten eingetragen") {
+ print ("NO ENTRIES\n");
+ }
+ }
+ }
+
+ return list;
+ }
+
+ Lift? parse_offer_row (Xml.Node *tr) {
+ var lift = new Lift ();
+
+ // checkbox
+ var td = get_next_td (tr->children);
+ if (td == null)
+ return null;
+
+ // action
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ // FIXME: get uri
+
+ // type
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ var text = get_child_text_content (td);
+ if (text == null)
+ return null;
+ // FIXME ==
+ if (text != "Mitfahrer")
+ return null;
+
+ // point of departure
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ text = get_child_text_content (td);
+ if (text == null)
+ return null;
+ lift.city_from = text;
+
+ // point of arrival
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ text = get_child_text_content (td);
+ if (text == null)
+ return null;
+ lift.city_to = text;
+
+ // date
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ text = get_child_text_content (td);
+ if (text == null)
+ return null;
+ parse_date (text, out lift.time);
+
+ // time
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ text = get_child_text_content (td);
+ if (text == null)
+ return null;
+ parse_time (text, out lift.time);
+
+ // active?
+ td = get_next_td (td->next);
+ if (td == null)
+ return null;
+ var a = td->children;
+ if (a == null || a->name != "a")
+ return null;
+ text = a->get_prop ("class");
+ if (text == "status icon icon_ajax_active")
+ lift.flags |= LiftFlags.ACTIVE;
+
+ return lift;
+ }
+
+ Xml.Node* get_next_td (Xml.Node *n) {
+ while (n != null) {
+ if (n->name == "td")
+ return n;
+ n = n->next;
+ }
+ return null;
+ }
+
+ unowned string get_child_text_content (Xml.Node *n) {
+ if (n->children != null && n->children->name == "text")
+ return n->children->content;
+ else
+ return null;
+ }
+