static void
gupnp_simple_igd_gather (GUPnPSimpleIgd *self,
                         struct Proxy *prox)
{
    prox->external_ip_action = gupnp_service_proxy_begin_action (prox->proxy,
                               "GetExternalIPAddress",
                               _service_proxy_got_external_ip_address, prox, NULL);

    gupnp_service_proxy_add_notify (prox->proxy, "ExternalIPAddress",
                                    G_TYPE_STRING, _external_ip_address_changed, prox);

    gupnp_service_proxy_set_subscribed (prox->proxy, TRUE);
}
static void
append_state_variables (GUPnPServiceProxy *proxy,
                        GUPnPServiceIntrospection *introspection,
                        const GList       *variables,
                        GtkTreeStore      *store,
                        GtkTreeIter       *service_iter)
{
        const GList *iter;
        GtkTreeIter  variables_iter;

        gtk_tree_store_insert_with_values (store,
                                           &variables_iter,
                                           service_iter, -1,
                                           0, get_icon_by_id (ICON_VARIABLES),
                                           1, _("State variables"),
                                           5, ICON_VARIABLES,
                                           -1);

        for (iter = variables; iter; iter = iter->next) {
                GUPnPServiceStateVariableInfo *info;

                info = iter->data;

                gtk_tree_store_insert_with_values
                                (store,
                                 NULL, &variables_iter, -1,
                                 0, get_icon_by_id (ICON_VARIABLE),
                                 1, info->name,
                                 2, proxy,
                                 3, introspection,
                                 4, info,
                                 5, ICON_VARIABLE,
                                 -1);

                /* Set-up event notitications for variable */
                gupnp_service_proxy_add_notify (proxy,
                                                info->name,
                                                info->type,
                                                on_state_variable_changed,
                                                NULL);
        }
}
Beispiel #3
0
static void
service_proxy_available_cb (G_GNUC_UNUSED GUPnPControlPoint *cp,
                            GUPnPServiceProxy               *proxy)
{
        const char *location;
        char *result = NULL;
        guint count, total;
        GError *error = NULL;

        location = gupnp_service_info_get_location (GUPNP_SERVICE_INFO (proxy));

        g_print ("ContentDirectory available:\n");
        g_print ("\tlocation: %s\n", location);

        /* We want to be notified whenever SystemUpdateID (of type uint)
         * changes */
        gupnp_service_proxy_add_notify (proxy,
                                        "SystemUpdateID",
                                        G_TYPE_UINT,
                                        notify_cb,
                                        (gpointer) "Test");

        /* Subscribe */
        g_signal_connect (proxy,
                          "subscription-lost",
                          G_CALLBACK (subscription_lost_cb),
                          NULL);

        gupnp_service_proxy_set_subscribed (proxy, TRUE);

        /* And test action IO */
        gupnp_service_proxy_send_action (proxy,
                                         "Browse",
                                         &error,
                                         /* IN args */
                                         "ObjectID",
                                                G_TYPE_STRING,
                                                "0",
                                         "BrowseFlag",
                                                G_TYPE_STRING,
                                                "BrowseDirectChildren",
                                         "Filter",
                                                G_TYPE_STRING,
                                                "*",
                                         "StartingIndex",
                                                G_TYPE_UINT,
                                                0,
                                         "RequestedCount",
                                                G_TYPE_UINT,
                                                0,
                                         "SortCriteria",
                                                G_TYPE_STRING,
                                                "",
                                         NULL,
                                         /* OUT args */
                                         "Result",
                                                G_TYPE_STRING,
                                                &result,
                                         "NumberReturned",
                                                G_TYPE_UINT,
                                                &count,
                                         "TotalMatches",
                                                G_TYPE_UINT,
                                                &total,
                                         NULL);

        if (error) {
                g_printerr ("Error: %s\n", error->message);
                g_error_free (error);

                return;
        }

        g_print ("Browse returned:\n");
        g_print ("\tResult:         %s\n", result);
        g_print ("\tNumberReturned: %u\n", count);
        g_print ("\tTotalMatches:   %u\n", total);

        g_free (result);
}