Exemplo n.º 1
0
/**
 * gupnp_white_list_check_context:
 * @white_list: A #GUPnPWhiteList
 * @context: A #GUPnPContext to test.
 *
 * It will check if the @context is allowed or not. The @white_list will check
 * all its entries againt #GUPnPContext interface, host ip and network fields
 * information. This function doesn't take into account the @white_list status
 * (enabled or not).
 *
 * Return value: %TRUE if @context is matching the @white_list criterias,
 * %FALSE otherwise.
 *
 * Since: 0.20.5
 **/
gboolean
gupnp_white_list_check_context (GUPnPWhiteList *white_list,
                                GUPnPContext *context)
{
        GSSDPClient  *client;
        GList *l;
        const char *interface;
        const char *host_ip;
        const char *network;
        gboolean match = FALSE;

        g_return_val_if_fail (GUPNP_IS_WHITE_LIST (white_list), FALSE);
        g_return_val_if_fail (GUPNP_IS_CONTEXT (context), FALSE);

        client = GSSDP_CLIENT (context);

        interface = gssdp_client_get_interface (client);
        host_ip = gssdp_client_get_host_ip (client);
        network = gssdp_client_get_network (client);

        l = white_list->priv->entries;

        while (l && !match) {
                match = (interface && !strcmp (l->data, interface)) ||
                        (host_ip && !strcmp (l->data, host_ip)) ||
                        (network && !strcmp (l->data, network));

                l = l->next;
        }

        return match;
}
Exemplo n.º 2
0
static void rygel_general_pref_section_on_context_available (RygelGeneralPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context) {
#line 468 "rygel-general-pref-section.c"
	GtkTreeIter iter = {0};
#line 124 "rygel-general-pref-section.vala"
	g_return_if_fail (self != NULL);
#line 124 "rygel-general-pref-section.vala"
	g_return_if_fail (manager != NULL);
#line 124 "rygel-general-pref-section.vala"
	g_return_if_fail (context != NULL);
#line 128 "rygel-general-pref-section.vala"
	if (!rygel_general_pref_section_find_interface (self, gssdp_client_get_interface ((GSSDPClient*) context), &iter)) {
#line 129 "rygel-general-pref-section.vala"
		gtk_combo_box_append_text ((GtkComboBox*) self->priv->iface_entry, gssdp_client_get_interface ((GSSDPClient*) context));
#line 480 "rygel-general-pref-section.c"
	}
}
Exemplo n.º 3
0
static void
on_service_property_changed (CMService   *cm_service,
                             const gchar *name,
                             GVariant    *value)
{
        CMServiceState new_state;
        const gchar *state_str;

        if (g_strcmp0 (name, "Name") == 0) {
                g_free (cm_service->name);
                g_variant_get (value, "s", &cm_service->name);

                if (cm_service->context != NULL &&
                    g_strcmp0 (cm_service->name,
                               gssdp_client_get_network (GSSDP_CLIENT (cm_service->context))) != 0)
                        g_object_set (G_OBJECT (cm_service->context),
                                               "network",
                                               cm_service->name,
                                               NULL);

        } else if (g_strcmp0 (name, "Ethernet") == 0) {
                g_free (cm_service->iface);
                g_variant_lookup (value, "Interface", "s", &cm_service->iface);

                if (cm_service->context != NULL &&
                    g_strcmp0 (cm_service->iface,
                               gssdp_client_get_interface (GSSDP_CLIENT (cm_service->context))) != 0) {
                        service_context_delete (cm_service);
                        service_context_create (cm_service);
                }

        } else if (g_strcmp0 (name, "State") == 0) {
                state_str = g_variant_get_string (value, 0);

                if ((g_strcmp0 (state_str, "online") == 0) ||
                    (g_strcmp0 (state_str, "ready") == 0))
                        new_state = CM_SERVICE_STATE_ACTIVE;
                else
                        new_state = CM_SERVICE_STATE_INACTIVE;

                service_context_update (cm_service, new_state);
        }
}
Exemplo n.º 4
0
static void rygel_general_pref_section_on_context_unavailable (RygelGeneralPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context) {
#line 487 "rygel-general-pref-section.c"
	GtkTreeIter iter = {0};
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (self != NULL);
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (manager != NULL);
#line 133 "rygel-general-pref-section.vala"
	g_return_if_fail (context != NULL);
#line 137 "rygel-general-pref-section.vala"
	if (rygel_general_pref_section_find_interface (self, gssdp_client_get_interface ((GSSDPClient*) context), &iter)) {
#line 497 "rygel-general-pref-section.c"
		GtkTreeModel* _tmp0_;
		GtkListStore* list_store;
#line 138 "rygel-general-pref-section.vala"
		list_store = _g_object_ref0 ((_tmp0_ = gtk_combo_box_get_model ((GtkComboBox*) self->priv->iface_entry), GTK_IS_LIST_STORE (_tmp0_) ? ((GtkListStore*) _tmp0_) : NULL));
#line 139 "rygel-general-pref-section.vala"
		gtk_list_store_remove (list_store, &iter);
#line 504 "rygel-general-pref-section.c"
		_g_object_unref0 (list_store);
	}
}
Exemplo n.º 5
0
gint
main (gint   argc,
      gchar *argv[])
{
        GError *error = NULL;
        gint i;
        GOptionContext *context;

#if !GLIB_CHECK_VERSION(2, 35, 0)
        g_type_init ();
#endif

        context = g_option_context_new ("- Upload files to UPnP MediaServer");
        g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
        if (!g_option_context_parse (context, &argc, &argv, &error))
        {
                g_print ("option parsing failed: %s\n", error->message);
                return -1;
        }

        if (argc < 3) {
                char *help = NULL;

                help = g_option_context_get_help (context, TRUE, NULL);
                g_print ("%s\n", help);
                g_free (help);

                return -4;
        }

        /* Get the list of files to upload */
        for (i = 1; i < argc; i++) {
                if (!g_file_test (argv[i],
                                  G_FILE_TEST_EXISTS |
                                  G_FILE_TEST_IS_REGULAR)) {
                        g_printerr ("File %s does not exist\n", argv[i]);
                } else {
                        files = g_list_append (files, argv[i]);
                }
        }

        if (files == NULL) {
                return -5;
        }

        error = NULL;
        upnp_context = gupnp_context_new (NULL, interface, 0, &error);
        if (error) {
                g_printerr ("Error creating the GUPnP context: %s\n",
			    error->message);
                g_error_free (error);

                return -6;
        }

        g_print ("UPnP context created for interface %s (%s)\n",
                 gssdp_client_get_interface (GSSDP_CLIENT (upnp_context)),
                 gssdp_client_get_host_ip (GSSDP_CLIENT (upnp_context)));

        if (!init_control_point (upnp_context, udn, search_timeout)) {
           return -3;
        }

        main_loop = g_main_loop_new (NULL, FALSE);

        g_main_loop_run (main_loop);

        /* Clean-up */
        g_clear_pointer (&main_loop, g_main_loop_unref);
        deinit_control_point ();
        g_object_unref (upnp_context);
        g_option_context_free (context);
        g_free (dest_container);
        g_free (interface);

        return 0;
}