9 #include <gmyth-upnp/gmyth_upnp.h>
11 #include "gmyth_backendinfo.h"
12 #include "gmyth_file_transfer.h"
13 #include "gmyth_livetv.h"
14 #include "gmyth_util.h"
15 #include "gmyth_common.h"
18 GMythBackendInfo *b_info;
22 static gupnp_options_t *
25 gupnp_options_t *options = g_new0(gupnp_options_t, 1);
26 options->b_info = gmyth_backend_info_new();
32 _gupnp_options_free(gupnp_options_t * options)
34 g_return_if_fail(options != NULL);
37 g_object_unref(options->b_info);
38 g_free(options->mythtv_id);
42 _parse_args(int argc, char *argv[], gupnp_options_t * options)
45 GOptionContext *context;
47 gchar *mythtv_id = NULL;
49 GOptionEntry entries[] = {
50 {"mythtvid", 'm', 0, G_OPTION_ARG_STRING, &mythtv_id,
51 "MythTV UPnP service " "identifigupnpion", "UPNP_ID"},
56 g_return_val_if_fail(options != NULL, FALSE);
60 ("- searches for a list of connected mythtv backend recorded "
61 "file and prints it on the standard output\n");
62 g_option_context_add_main_entries(context, entries, NULL);
63 g_option_context_parse(context, &argc, &argv, &error);
64 g_option_context_set_help_enabled(context, TRUE);
66 g_option_context_free(context);
75 _got_upnp_device(GMythUPnP * gupnp, GMythUPnPDeviceStatus status,
78 g_debug("Got Device !!! [%s, %s]",
79 gmyth_upnp_device_status_to_string(status), udn);
83 _gupnp_search_devices(gupnp_options_t * options)
85 GList *upnp_servers = NULL;
87 GMythBackendInfo *backend_info = gmyth_backend_info_new();
89 g_return_val_if_fail(options != NULL, FALSE);
90 g_return_val_if_fail(options->b_info != NULL, FALSE);
92 gupnp = gmyth_upnp_new(backend_info, _got_upnp_device);
93 upnp_servers = gmyth_upnp_do_search_sync(gupnp);
95 g_list_free(upnp_servers);
96 g_object_unref(gupnp);
102 main(int argc, char *argv[])
104 gboolean res = FALSE;
105 gupnp_options_t *options;
108 if (!g_thread_supported())
111 options = _gupnp_options_new();
112 res = _parse_args(argc, argv, options);
114 g_printerr("Argument invalid. Type --help\n");
118 res = _gupnp_search_devices(options);
120 _gupnp_options_free(options);