⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gupnp-device-info.c

📁 另一 UPNP SDK 支持在UNIX/LINUX上运行。 UPnP是一种网络协议
💻 C
📖 第 1 页 / 共 3 页
字号:
/** * gupnp_device_info_get_url_base * @info: A #GUPnPDeviceInfo * * Get the URL base of this device. * * Returns: A #SoupURI. **/const SoupURI *gupnp_device_info_get_url_base (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return info->priv->url_base;}/** * gupnp_device_info_get_udn * @info: A #GUPnPDeviceInfo * * Get the Unique Device Name of the device. * * Returns: A constant string. **/const char *gupnp_device_info_get_udn (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        if (!info->priv->udn) {                info->priv->udn =                        xml_util_get_child_element_content_glib                                (info->priv->element, "UDN");        }        return info->priv->udn;}/** * gupnp_device_info_get_device_type * @info: A #GUPnPDeviceInfo * * Get the UPnP device type. * * Returns: A constant string, or %NULL. **/const char *gupnp_device_info_get_device_type (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        if (!info->priv->device_type) {                info->priv->device_type =                        xml_util_get_child_element_content_glib                                (info->priv->element, "deviceType");        }        return info->priv->device_type;}/** * gupnp_device_info_get_friendly_name * @info: A #GUPnPDeviceInfo * * Get the friendly name of the device. *  * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_friendly_name (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "friendlyName");}/** * gupnp_device_info_get_manufacturer * @info: A #GUPnPDeviceInfo * * Get the manufacturer of the device. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_manufacturer (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "manufacturer");}/** * gupnp_device_info_get_manufacturer_url * @info: A #GUPnPDeviceInfo * * Get a URL pointing to the manufacturer's website. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_manufacturer_url (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_url (info->priv->element,                                                       "manufacturerURL",                                                       info->priv->url_base);}/** * gupnp_device_info_get_model_description * @info: A #GUPnPDeviceInfo * * Get the description of the device model. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_model_description (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "modelDescription");}/** * gupnp_device_info_get_model_name * @info: A #GUPnPDeviceInfo * * Get the model name of the device. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_model_name (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "modelName");}/** * gupnp_device_info_get_model_number * @info: A #GUPnPDeviceInfo * * Get the model number of the device. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_model_number (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "modelNumber");}/** * gupnp_device_info_get_model_url * @info: A #GUPnPDeviceInfo * * Get a URL pointing to the device model's website. *  * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_model_url (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_url (info->priv->element,                                                       "modelURL",                                                       info->priv->url_base);}/** * gupnp_device_info_get_serial_number * @info: A #GUPnPDeviceInfo * * Get the serial number of the device. *  * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_serial_number (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "serialNumber");}/** * gupnp_device_info_get_upc * @info: A #GUPnPDeviceInfo * * Get the Universal Product Code of the device. * * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_upc (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_glib (info->priv->element,                                                        "UPC");}/** * gupnp_device_info_get_presentation_url * @info: A #GUPnPDeviceInfo * * Get a URL pointing to the device's presentation page, for web-based * administration. *  * Return value: A string, or %NULL. g_free() after use. **/char *gupnp_device_info_get_presentation_url (GUPnPDeviceInfo *info){        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        return xml_util_get_child_element_content_url (info->priv->element,                                                       "presentationURL",                                                       info->priv->url_base);}typedef struct {        xmlChar *mime_type;        int      width;        int      height;        int      depth;        xmlChar *url;        int      weight;} Icon;static Icon *icon_parse (GUPnPDeviceInfo *info, xmlNode *element){        Icon *icon;        icon = g_slice_new0 (Icon);        icon->mime_type = xml_util_get_child_element_content     (element,                                                                  "mimetype");        icon->width     = xml_util_get_child_element_content_int (element,                                                                  "width");        icon->height    = xml_util_get_child_element_content_int (element,                                                                  "height");        icon->depth     = xml_util_get_child_element_content_int (element,                                                                  "depth");        icon->url       = xml_util_get_child_element_content     (element,                                                                  "url");        return icon;}static voidicon_free (Icon *icon){        if (icon->mime_type)                xmlFree (icon->mime_type);        if (icon->url)                xmlFree (icon->url);        g_slice_free (Icon, icon);}/** * gupnp_device_info_get_icon_url * @info: A #GUPnPDeviceInfo * @requested_mime_type: The requested file format, or %NULL for any * @requested_depth: The requested color depth, or -1 for any * @requested_width: The requested width, or -1 for any * @requested_height: The requested height, or -1 for any * @prefer_bigger: %TRUE if a bigger, rather than a smaller icon should be * returned if no exact match could be found * @mime_type: The location where to store the the format of the returned icon, * or %NULL. The returned string should be freed after use * @depth: The location where to store the depth of the returned icon, or %NULL * @width: The location where to store the width of the returned icon, or %NULL * @height: The location where to store the height of the returned icon, or %NULL * * Get a URL pointing to the icon most closely matching the * given criteria, or %NULL. If @requested_mime_type is set, only icons with * this mime type will be returned. If @requested_depth is set, only icons with * this or lower depth will be returned. If @requested_width and/or * @requested_height are set, only icons that are this size or smaller are * returned, unless @prefer_bigger is set, in which case the next biggest icon * will be returned. The returned strings should be freed. * * Return value: a string, or %NULL.  g_free() after use. **/char *gupnp_device_info_get_icon_url (GUPnPDeviceInfo *info,                                const char      *requested_mime_type,                                int              requested_depth,                                int              requested_width,                                int              requested_height,                                gboolean         prefer_bigger,                                char           **mime_type,                                int             *depth,                                int             *width,                                int             *height){        GList *icons, *l;        xmlNode *element;        Icon *icon, *closest;        char *ret;        g_return_val_if_fail (GUPNP_IS_DEVICE_INFO (info), NULL);        /* List available icons */        icons = NULL;        element = xml_util_get_element (info->priv->element,                                        "iconList",                                        NULL);        if (!element)                return NULL;        for (element = element->children; element; element = element->next) {                if (!strcmp ("icon", (char *) element->name)) {                        gboolean mime_type_ok;                        icon = icon_parse (info, element);                        if (requested_mime_type) {                                mime_type_ok =                                        !strcmp (requested_mime_type,                                                 (char *) icon->mime_type);                        } else                                mime_type_ok = TRUE;                        if (requested_depth >= 0)                                icon->weight = requested_depth - icon->depth;                        /* Filter out icons with incorrect mime type or                         * incorrect depth. */                        if (mime_type_ok && icon->weight >= 0) {                                if (requested_width >= 0) {                                        if (prefer_bigger) {                                                icon->weight +=                                                        icon->width -                                                        requested_width;                                        } else {                                                icon->weight +=                                                        requested_width -                                                        icon->width;                                        }                                }                                if (requested_height >= 0) {                                        if (prefer_bigger) {                                                icon->weight +=                                                        icon->height -                                                        requested_height;                                        } else {                                                icon->weight +=                                                        requested_height -                                                        icon->height;                                        }                                }                                icons = g_list_prepend (icons, icon);                        } else                                icon_free (icon);                }        }        /* Find closest match */        closest = NULL;        for (l = icons; l; l = l->next) {                icon = l->data;                /* Look between icons with positive weight first */                if (icon->weight >= 0) {                        if (!closest || icon->weight < closest->weight)                                closest = icon;                }        }        if (!closest) {                icon = l->data;                /* No icons with positive weight, look at ones with                 * negative weight */                if (!closest || icon->weight > closest->weight)                        closest = icon;        }        /* Fill in return values */        if (closest) {                if (mime_type) {                        if (icon->mime_type) {                                *mime_type = g_strdup                                                ((char *) icon->mime_type);                        } else                                *mime_type = NULL;                }                if (depth)                        *depth = icon->depth;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -