246
250
recorded_info->subtitle->str);
247
251
thumb_fname = g_strdup_printf ("%s.png", recorded_info->basename->str);
248
252
uri = g_strdup_printf ("myth://%s:%d/%s",
249
plugin->b_info->hostname,
250
plugin->b_info->port,
251
255
recorded_info->basename->str);
252
pixbuf = get_thumbnail (plugin, thumb_fname);
256
pixbuf = get_thumbnail (plugin, b_info, thumb_fname);
253
257
g_free (thumb_fname);
255
259
gtk_list_store_insert_with_values (GTK_LIST_STORE (plugin->model), &iter, G_MAXINT32,
288
device_found_cb (GMythUPnP *upnp,
289
GMythBackendInfo *b_info,
290
TotemMythtvPlugin *plugin)
292
if (!g_list_find (plugin->lst_b_info, b_info)) {
293
plugin->lst_b_info = g_list_append (plugin->lst_b_info,
294
g_object_ref (b_info));
295
totem_mythtv_list_recordings (plugin, b_info);
300
device_lost_cb (GMythUPnP *upnp,
301
GMythBackendInfo *info,
302
TotemMythtvPlugin *plugin)
305
GMythBackendInfo *b_info;
307
elem = g_list_find (plugin->lst_b_info, info);
308
if (elem && elem->data) {
310
plugin->lst_b_info = g_list_remove (plugin->lst_b_info,
312
g_object_unref (b_info);
284
318
totem_mythtv_update_binfo (TotemMythtvPlugin *plugin)
286
char *address, *user, *password, *database;
289
if (plugin->b_info != NULL) {
290
//FIXME why would this crash?
291
//g_object_unref (plugin->b_info);
292
plugin->b_info = NULL;
295
if (plugin->client == NULL)
296
plugin->client = gconf_client_get_default ();
297
if (plugin->client == NULL)
300
address = gconf_client_get_string (plugin->client, CONF_IP, NULL);
302
if (address == NULL || address[0] == '\0')
305
user = gconf_client_get_string (plugin->client, CONF_USER, NULL);
306
if (user == NULL || user[0] == '\0')
307
user = g_strdup ("mythtv");
308
password = gconf_client_get_string (plugin->client, CONF_PASSWORD, NULL);
309
if (password == NULL || password[0] == '\0')
310
password = g_strdup ("mythtv");
311
database = gconf_client_get_string (plugin->client, CONF_DATABASE, NULL);
312
if (database == NULL || database[0] == '\0')
313
database = g_strdup ("mythconverg");
314
port = gconf_client_get_int (plugin->client, CONF_PORT, NULL);
318
plugin->b_info = gmyth_backend_info_new_full (address,
323
/* Clear old b_info */
324
if (plugin->lst_b_info != NULL) {
325
g_list_foreach (plugin->lst_b_info, (GFunc) g_object_unref, NULL);
326
g_list_free (plugin->lst_b_info);
327
plugin->lst_b_info = NULL;
331
/* Using GMythUPnP to search for avaliable servers */
332
if (plugin->upnp == NULL) {
333
plugin->upnp = gmyth_upnp_get_instance ();
334
g_signal_connect (G_OBJECT (plugin->upnp),
336
G_CALLBACK (device_found_cb),
338
plugin->upnp = gmyth_upnp_get_instance ();
339
g_signal_connect (G_OBJECT (plugin->upnp),
341
G_CALLBACK (device_lost_cb),
345
/* Load current servers */
346
lst = gmyth_upnp_get_devices (plugin->upnp);
347
for (w = lst; w != NULL; w = w->next) {
348
GMythBackendInfo *b_info;
350
b_info = (GMythBackendInfo *) w->data;
351
plugin->lst_b_info = g_list_append (plugin->lst_b_info,
353
totem_mythtv_list_recordings (plugin, b_info);
356
gmyth_upnp_search (plugin->upnp);
326
360
refresh_cb (GtkWidget *button, TotemMythtvPlugin *plugin)
328
362
gtk_widget_set_sensitive (button, FALSE);
329
totem_mythtv_update_binfo (plugin);
330
363
gtk_list_store_clear (GTK_LIST_STORE (plugin->model));
364
totem_mythtv_update_binfo (plugin);
331
365
totem_gdk_window_set_waiting_cursor (plugin->sidebar->window);
332
totem_mythtv_list_recordings (plugin);
333
366
gdk_window_set_cursor (plugin->sidebar->window, NULL);
334
367
gtk_widget_set_sensitive (button, TRUE);
346
379
TotemMythtvPlugin *plugin = TOTEM_MYTHTV_PLUGIN(object);
348
if (plugin->b_info != NULL) {
349
g_object_unref (plugin->b_info);
350
plugin->b_info = NULL;
381
if (plugin->lst_b_info != NULL) {
382
g_list_foreach (plugin->lst_b_info, (GFunc ) g_object_unref, NULL);
383
g_list_free (plugin->lst_b_info);
384
plugin->lst_b_info = NULL;
352
386
if (plugin->client != NULL) {
353
387
g_object_unref (plugin->client);
354
388
plugin->client = NULL;
390
if (plugin->upnp != NULL) {
391
g_object_unref (plugin->upnp);
394
if (plugin->sidebar != NULL) {
395
g_object_unref (plugin->sidebar);
396
plugin->sidebar = NULL;
357
399
G_OBJECT_CLASS (totem_mythtv_plugin_parent_class)->finalize (object);
406
448
TotemMythtvPlugin *tm = TOTEM_MYTHTV_PLUGIN(plugin);
408
g_object_unref (tm->sidebar);
409
450
totem_remove_sidebar_page (totem, "mythtv");
411
if (tm && tm->client != NULL) {
452
if (tm->lst_b_info != NULL) {
453
g_list_foreach (tm->lst_b_info, (GFunc ) g_object_unref, NULL);
454
g_list_free (tm->lst_b_info);
455
tm->lst_b_info = NULL;
457
if (tm->client != NULL) {
412
458
g_object_unref (tm->client);
413
459
tm->client = NULL;
461
if (tm->upnp != NULL) {
462
g_object_unref (tm->upnp);
465
if (tm->sidebar != NULL) {
466
gtk_widget_destroy (tm->sidebar);
415
470
g_object_unref (totem);