async test
- From: Víctor M. Jáquez L. <vjaquez igalia com>
- To: grilo-list gnome org
- Subject: async test
- Date: Sun, 11 Apr 2010 20:11:47 +0200
The attached code is vala program which tests the resolve_async method in fake-metadata
vmjl
/**
* COMPILATION:
*
* $ valac --pkg grilo-0.1 --pkg gio-2.0 async_test.vala
*/
using Grl;
MainLoop main_loop;
async void resolve (Grl.MetadataSource source) {
unowned GLib.List keys = Grl.MetadataKey.list_new (Grl.METADATA_KEY_AUTHOR,
Grl.METADATA_KEY_DESCRIPTION,
Grl.METADATA_KEY_DATE);
try {
var media = yield source.resolve_async (keys, new Grl.Media (), Grl.MetadataResolutionFlags.NORMAL);
print ("* author = %s\n* description = %s\n* date = %s\n",
media.get_author (), media.get_description (), media.get_date ());
main_loop.quit ();
} catch (GLib.Error err) {
warning("Error: %s\n", err.message);
}
}
public static int main (string[] args) {
Grl.log_init ("*:-");
var registry = Grl.PluginRegistry.get_instance ();
if (registry.load_all () == false) {
warning ("Failed to load plugins.");
return -1;
}
var source = registry.lookup_source ("grl-fake-metadata") as Grl.MetadataSource;
if (source == null) {
warning ("Failed to lookup source");
return -1;
}
resolve.begin (source);
main_loop = new MainLoop ();
main_loop.run ();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]