Example #1
0
void
show_device_details (GUPnPDeviceInfo *info)
{
        char          *details[32];
        const SoupURI *uri;
        const char    *str;
        int            i = 0;

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

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

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

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

        details[i++] = _("Friendly Name");
        details[i++] = gupnp_device_info_get_friendly_name (info);
        details[i++] = _("Manufacturer");
        details[i++] = gupnp_device_info_get_manufacturer (info);
        details[i++] = _("Manufacturer URL");
        details[i++] = gupnp_device_info_get_manufacturer_url (info);
        details[i++] = _("Model Description");
        details[i++] = gupnp_device_info_get_model_description (info);
        details[i++] = _("Model Name");
        details[i++] = gupnp_device_info_get_model_name (info);
        details[i++] = _("Model Number");
        details[i++] = gupnp_device_info_get_model_number (info);
        details[i++] = _("Model URL");
        details[i++] = gupnp_device_info_get_model_url (info);
        details[i++] = _("Serial Number");
        details[i++] = gupnp_device_info_get_serial_number (info);
        details[i++] = _("UPC");
        details[i++] = gupnp_device_info_get_upc (info);
        details[i++] = _("Presentation URL");
        details[i++] = gupnp_device_info_get_presentation_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]);
        }
}
void UpnpControlPointService::deviceProxyRemoved (GUPnPControlPoint *cp, GUPnPServiceProxy *proxy, gpointer data)
{
	UpnpControlPointService* pThis = static_cast<UpnpControlPointService*>(data);
	const char* type = gupnp_device_info_get_device_type(GUPNP_DEVICE_INFO(proxy));
	const char* location = gupnp_device_info_get_location(GUPNP_DEVICE_INFO(proxy));

	g_print("Device removed: \n");
	g_print("\ttype: %s\n", type);
	g_print("\tlocation: %s\n", location);
	pThis->fireDeviceRemoved(cp, proxy);
}
Example #3
0
static void device_proxy_found(GUPnPControlPoint* cp, GUPnPServiceProxy* proxy, GUPnPContext* context) {
  GUPnPDeviceInfo* info = GUPNP_DEVICE_INFO(proxy);
  
  if(g_strcmp0(gupnp_device_info_get_device_type(info),"urn:schemas-upnp-org:device:InternetGatewayDevice:1") == 0) {
    const char* devname = gupnp_device_info_get_friendly_name(info);
    const char* serialno = gupnp_device_info_get_serial_number(info);
    devname = devname ? devname : "unknown";
    serialno = serialno ? serialno : "unknown";
    routerip = gupnp_context_get_host_ip(context);
    printf("Found device named %s with serial number %s on local interface %s\n",devname,serialno,gupnp_context_get_host_ip(context));
  }
}
static void
gupnp_device_info_get_property (GObject    *object,
                                guint       property_id,
                                GValue     *value,
                                GParamSpec *pspec)
{
        GUPnPDeviceInfo *info;

        info = GUPNP_DEVICE_INFO (object);

        switch (property_id) {
        case PROP_RESOURCE_FACTORY:
                g_value_set_object (value,
                                    info->priv->factory);
                break;
        case PROP_CONTEXT:
                g_value_set_object (value,
                                    info->priv->context);
                break;
        case PROP_LOCATION:
                g_value_set_string (value,
                                    info->priv->location);
                break;
        case PROP_UDN:
                g_value_set_string (value,
                                    gupnp_device_info_get_udn (info));
                break;
        case PROP_DEVICE_TYPE:
                g_value_set_string (value,
                                    gupnp_device_info_get_device_type (info));
                break;
        case PROP_URL_BASE:
                g_value_set_pointer (value,
                                     info->priv->url_base);
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                break;
        }
}
Example #5
0
static void prv_device_available_cb(GUPnPControlPoint *cp,
				    GUPnPDeviceProxy *proxy,
				    gpointer user_data)
{
	dls_upnp_t *upnp = user_data;
	const char *udn;
	dls_device_t *device;
	const gchar *ip_address;
	dls_device_context_t *context;
	const dleyna_task_queue_key_t *queue_id;
	unsigned int i;
	prv_device_new_ct_t *priv_t;
	GUPnPDeviceInfo *device_proxy = (GUPnPDeviceInfo *)proxy;
	GUPnPDeviceInfo *device_info = NULL;
	const gchar *device_type;
	gboolean subscribe = FALSE;
	gpointer key;
	gpointer val;

	udn = gupnp_device_info_get_udn(device_proxy);

	ip_address = gssdp_client_get_host_ip(
		GSSDP_CLIENT(gupnp_control_point_get_context(cp)));

	if (!udn || !ip_address)
		goto on_error;

	DLEYNA_LOG_DEBUG("UDN %s", udn);
	DLEYNA_LOG_DEBUG("IP Address %s", ip_address);

	device_type = gupnp_device_info_get_device_type(device_proxy);

	if (!g_str_has_prefix(device_type, DLS_DMS_DEVICE_TYPE)) {
		device_info = prv_lookup_dms_child_device(device_proxy);

		if (device_info == NULL)
			goto on_error;
	} else {
		device_info = device_proxy;
	}

	device = g_hash_table_lookup(upnp->device_udn_map, udn);

	if (!device) {
		device = g_hash_table_lookup(upnp->sleeping_device_udn_map,
					     udn);

		if (device != NULL) {
			if (g_hash_table_lookup_extended(
						  upnp->sleeping_device_udn_map,
						  udn,
						  &key,
						  &val)) {
				g_hash_table_steal(
						upnp->sleeping_device_udn_map,
						udn);

				g_free(key);
			}

			g_hash_table_insert(upnp->device_udn_map, g_strdup(udn),
					    device);

			if (device->wake_on_timeout_id) {
				DLEYNA_LOG_DEBUG("Stop WAKE-ON watcher...");

				(void) g_source_remove(
						 device->wake_on_timeout_id);
				device->wake_on_timeout_id = 0;
			}
			dls_device_delete_context(device->sleeping_context);
			device->sleeping_context = NULL;
			device->sleeping = FALSE;
			subscribe = TRUE;
		}
	}

	if (!device) {
		priv_t = g_hash_table_lookup(upnp->device_uc_map, udn);

		if (priv_t)
			device = priv_t->device;
	}

	if (!device) {
		DLEYNA_LOG_DEBUG("Device not found. Adding");
		DLEYNA_LOG_DEBUG_NL();

		queue_id = prv_create_device_queue(&priv_t);

		device = dls_device_new(upnp->connection,
					proxy,
					device_info,
					ip_address,
					upnp->interface_info,
					upnp->property_map, 
					udn,
					queue_id);

		prv_update_device_context(priv_t, upnp, udn, device, ip_address,
					  queue_id);
	} else {
		DLEYNA_LOG_DEBUG("Device Found");

		for (i = 0; i < device->contexts->len; ++i) {
			context = g_ptr_array_index(device->contexts, i);
			if (!strcmp(context->ip_address, ip_address))
				break;
		}

		if (i == device->contexts->len) {
			DLEYNA_LOG_DEBUG("Adding Context");
			(void) dls_device_append_new_context(device,
							     ip_address,
							     proxy,
							     device_info);
			if (subscribe)
				dls_device_subscribe_to_service_changes(device);
		}

		DLEYNA_LOG_DEBUG_NL();
	}

on_error:

	return;
}