2 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
3 * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
5 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Library General Public
22 * License as published by the Free Software Foundation; either
23 * version 2 of the License, or (at your option) any later version.
30 public class Rygel.Main : Object {
31 private PluginLoader plugin_loader;
32 private MediaServerFactory ms_factory;
33 private List<MediaServer> media_servers;
35 private MainLoop main_loop;
37 private int exit_code;
39 public Main () throws GLib.Error {
40 this.media_servers = new List<MediaServer> ();
41 this.plugin_loader = new PluginLoader ();
42 this.ms_factory = new MediaServerFactory ();
43 this.main_loop = new GLib.MainLoop (null, false);
47 this.plugin_loader.plugin_available += this.on_plugin_loaded;
49 Utils.on_application_exit (this.application_exit_cb);
53 this.plugin_loader.load_plugins ();
55 this.main_loop.run ();
57 return this.exit_code;
60 public void exit (int exit_code) {
61 this.exit_code = exit_code;
62 this.main_loop.quit ();
65 private void application_exit_cb () {
69 private void on_plugin_loaded (PluginLoader plugin_loader,
72 var server = this.ms_factory.create_media_server (plugin);
74 /* Make our device available */
75 server.available = true;
77 media_servers.append (server);
78 } catch (GLib.Error error) {
79 warning ("Failed to create MediaServer for %s. Reason: %s\n",
85 public static int main (string[] args) {
88 // initialize gstreamer
93 } catch (GLib.Error err) {
94 error ("%s", err.message);
99 int exit_code = main.run ();