last_cinema.phone = phone;
}
- public void parse (ref char[] buf) throws Error {
+ public int parse (ref char[] buf) throws Error {
+ int movies = 0;
+
current = buf;
next_tag ();
while (location == null && current[0] != 0) {
while (current[i++] != '>');
if (((string) current).has_prefix ("<div class=movie>")) {
parse_movie ();
+ movies++;
} else if (((string) current).has_prefix("<div class=theater>")) {
parse_cinema ();
} else {
}
next_tag ();
}
+
+ return movies;
}
- public async void query (MovieFilter filter, string? location, MovieSource.ReceiveMovieFunction callback, Cancellable? cancellable) {
+ public async int query (MovieFilter filter, string? location, MovieSource.ReceiveMovieFunction callback, Cancellable? cancellable) {
_get_callback = callback;
_filter = filter;
if (filter.title.chr(filter.title.length, '*') != null) {
nread = yield stream.read_async ((char *)buf + total, 256*1024 - total, Priority.DEFAULT_IDLE, cancellable);
total += nread;
if (cancellable.is_cancelled ())
- return;
+ return 0;
if (nread == 0)
break;
}
buf[total] = 0;
- parse (ref buf);
+ return parse (ref buf);
} catch (Error e) {
stderr.printf ("Error: %s\n", e.message);
}
+
+ return 0;
}
}