Esempio n. 1
0
void UpnpControlPointService::serviceProxyRemoved (GUPnPControlPoint *cp, GUPnPServiceProxy *proxy, gpointer data)
{
	UpnpControlPointService* pThis = static_cast<UpnpControlPointService*>(data);
	const char* type = gupnp_service_info_get_service_type(GUPNP_SERVICE_INFO(proxy));
	const char* location = gupnp_service_info_get_location(GUPNP_SERVICE_INFO(proxy));

	g_print("Service removed: \n");
	g_print("\ttype: %s\n", type);
	g_print("\tlocation: %s\n", location);
}
Esempio n. 2
0
static void
service_proxy_unavailable_cb (G_GNUC_UNUSED GUPnPControlPoint *cp,
                              GUPnPServiceProxy               *proxy)
{
        const char *location;

        location = gupnp_service_info_get_location (GUPNP_SERVICE_INFO (proxy));

        g_print ("ContentDirectory unavailable:\n");
        g_print ("\tlocation: %s\n", location);
}
Esempio n. 3
0
static void
service_proxy_unavailable_cb (G_GNUC_UNUSED GUPnPControlPoint *cp,
                              GUPnPServiceProxy               *proxy)
{
        const char *type, *location;

        type = gupnp_service_info_get_service_type (GUPNP_SERVICE_INFO (proxy));
        location = gupnp_service_info_get_location (GUPNP_SERVICE_INFO (proxy));

        g_print ("Service unavailable:\n");
        g_print ("\ttype:     %s\n", type);
        g_print ("\tlocation: %s\n", location);
}
Esempio n. 4
0
void browse_cb(GUPnPServiceProxy *content_dir,
               GUPnPServiceProxyAction *action, gpointer user_data)
{
    struct browse_data *data;
    char *didl_xml;
    guint32 number_returned;
    guint32 total_matches;
    GError *error;

    data = (struct browse_data *)user_data;
    didl_xml = NULL;
    error = NULL;

    gupnp_service_proxy_end_action(content_dir, action, &error,
                                   "Result", G_TYPE_STRING, &didl_xml,
                                   "NumberReturned", G_TYPE_UINT,
                                       &number_returned,
                                   "TotalMatches", G_TYPE_UINT, &total_matches,
                                   NULL);
    if (didl_xml) {
        guint32 remaining;
        GError *error = NULL;

        if (!gupnp_didl_lite_parser_parse_didl(data->didl_parser, didl_xml,
                                               add_content, data, &error)) {
            g_warning("%s\n", error->message);
            g_error_free(error);
        }
        g_free(didl_xml);

        data->starting_index += number_returned;

        /* See if we have more objects to get */
        remaining = total_matches - data->starting_index;
        /* Keep browsing till we get each and every object */
        if (remaining != 0) browse(content_dir, data->id, data->starting_index,
                                   MIN(remaining, MAX_BROWSE),
                                   data->list, data->didl_parser);
    } else if (error) {
        GUPnPServiceInfo *info;

        info = GUPNP_SERVICE_INFO(content_dir);
        g_warning("Failed to browse '%s': %s\n",
                  gupnp_service_info_get_location(info),
                  error->message);

        g_error_free(error);
    }

    browse_data_free(data);
}
Esempio n. 5
0
void
show_service_details (GUPnPServiceInfo *info)
{
        char          *details[32];
        const SoupURI *uri;
        const char    *str;
        int            i = 0;

        details[i++] = _("Location");
        str = gupnp_service_info_get_location (info);
        if (str)
                details[i++] = g_strdup (str);

        details[i++] = _("UDN");
        str = gupnp_service_info_get_udn (info);
        if (str)
                details[i++] = g_strdup (str);

        details[i++] = _("Type");
        str = gupnp_service_info_get_service_type (info);
        if (str)
                details[i++] = g_strdup (str);

        details[i++] = _("Base URL");
        uri = gupnp_service_info_get_url_base (info);
        if (uri)
                details[i++] = soup_uri_to_string ((SoupURI *) uri, FALSE);

        details[i++] = _("Service ID");
        details[i++] = gupnp_service_info_get_id (info);
        details[i++] = _("Service URL");
        details[i++] = gupnp_service_info_get_scpd_url (info);
        details[i++] = _("Control URL");
        details[i++] = gupnp_service_info_get_control_url (info);
        details[i++] = _("Event Subscription URL");
        details[i++] = gupnp_service_info_get_event_subscription_url (info);
        details[i] = NULL;

        update_details ((const char **) details);

        /* Only free the values */
        for (i = 1; details[i - 1]; i += 2) {
                if (details[i])
                        g_free (details[i]);
        }
}
Esempio n. 6
0
static void
got_introspection (GUPnPServiceInfo          *info,
                   GUPnPServiceIntrospection *introspection,
                   const GError              *error,
                   G_GNUC_UNUSED gpointer     user_data)
{
        if (error) {
                g_warning ("Failed to create introspection for '%s': %s",
                           gupnp_service_info_get_udn (info),
                           error->message);

                return;
        }

        g_print ("service:  %s\nlocation: %s\n",
                gupnp_service_info_get_udn (info),
                gupnp_service_info_get_location (info));
        print_actions (introspection);
        print_state_variables (introspection);
        g_object_unref (introspection);
}
Esempio n. 7
0
static void on_service_proxy_action_ret (GUPnPServiceProxy *proxy,
                                  GUPnPServiceProxyAction *action,
                                  gpointer user_data)
{
        GError *error = NULL;

        gupnp_service_proxy_end_action (proxy,
                                        action,
                                        &error,
                                        NULL);
        if (error) {
                GUPnPServiceInfo *info = GUPNP_SERVICE_INFO (proxy);

                g_warning ("Failed to call action \"%s\" on \"%s\": %s",
                           (char *) user_data,
                           gupnp_service_info_get_location (info),
                           error->message);

                g_error_free (error);
        }

        g_free (user_data);
}
Esempio n. 8
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);
}