static QUrl findIconForObject(GUPnPDIDLLiteObject *object) { QUrl thumbnail; GList* resources = gupnp_didl_lite_object_get_resources(object); GList* it = resources; const char *upnp_class = gupnp_didl_lite_object_get_upnp_class (object); if (upnp_class == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-file-unknown-inverse")); return thumbnail; } if (strncmp(upnp_class, AUDIO_PREFIX, sizeof(AUDIO_PREFIX) - 1) == 0 || strncmp(upnp_class, MUSIC_ALBUM_CLASS, sizeof(MUSIC_ALBUM_CLASS) - 1) == 0) { const char *album_art_uri = gupnp_didl_lite_object_get_album_art(object); thumbnail.setUrl(QString::fromUtf8(album_art_uri)); } else { while (it) { GUPnPDIDLLiteResource *res = (GUPnPDIDLLiteResource*) it->data; GUPnPProtocolInfo *info = gupnp_didl_lite_resource_get_protocol_info(res); const char *profile = gupnp_protocol_info_get_dlna_profile(info); if (profile != 0 && (strncmp(profile, "JPEG_TN", 7) == 0 || strncmp(profile, "PNG_TN", 6) == 0)) { thumbnail.setUrl(QString::fromUtf8(gupnp_didl_lite_resource_get_uri(res))); break; } it = it->next; } } if (thumbnail.isEmpty()) { if (strncmp(upnp_class, IMAGE_PREFIX, sizeof(IMAGE_PREFIX) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-image-inverse")); } else if (strncmp(upnp_class, VIDEO_PREFIX, sizeof(VIDEO_PREFIX) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-videos-inverse")); } else if (strncmp(upnp_class, AUDIO_PREFIX, sizeof(AUDIO_PREFIX) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-audio-inverse")); } else if (strncmp(upnp_class, MUSIC_ALBUM_CLASS, sizeof(MUSIC_ALBUM_CLASS) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-album-inverse")); } else if (strncmp(upnp_class, ARTIST_CLASS, sizeof(ARTIST_CLASS) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-artist-inverse")); } else if (strncmp(upnp_class, GENRE_CLASS, sizeof(GENRE_CLASS) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-genre-inverse")); } else if (strncmp(upnp_class, CONTAINER_PREFIX, sizeof(CONTAINER_PREFIX) - 1) == 0) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-toolbar-directory-white")); } } g_list_free_full(resources, g_object_unref); if (thumbnail.isEmpty()) { thumbnail.setUrl(QLatin1String("image://theme/icon-m-content-file-unknown-inverse")); } return thumbnail; }
static void add_dlna_info (GString *str, GUPnPProtocolInfo *info) { const char *dlna_profile; const char **speeds; GUPnPDLNAConversion conversion; GUPnPDLNAFlags flags; dlna_profile = gupnp_protocol_info_get_dlna_profile (info); if (dlna_profile == NULL) { g_string_append_printf (str, ":*"); return; } g_string_append_printf (str, ":DLNA.ORG_PN=%s", dlna_profile); /* the OP parameter is only allowed for the "http-get" * and "rtsp-rtp-udp" protocols */ if (strcmp (gupnp_protocol_info_get_protocol (info), "http-get") == 0 || strcmp (gupnp_protocol_info_get_protocol (info), "rtsp-rtp-udp") == 0) g_string_append_printf (str, ";DLNA.ORG_OP=%.2x", gupnp_protocol_info_get_dlna_operation (info)); /* Specify PS parameter if list of play speeds is provided */ speeds = gupnp_protocol_info_get_play_speeds (info); if (speeds != NULL) { int i; g_string_append_printf (str, ";DLNA.ORG_PS="); for (i = 0; speeds[i]; i++) { g_string_append (str, speeds[i]); if (speeds[i + 1]) g_string_append_c (str, ','); } } conversion = gupnp_protocol_info_get_dlna_conversion (info); /* omit the CI parameter for non-converted content */ if (conversion != GUPNP_DLNA_CONVERSION_NONE) g_string_append_printf (str, ";DLNA.ORG_CI=%d", conversion); flags = gupnp_protocol_info_get_dlna_flags (info); /* Omit the FLAGS parameter if no flags set */ if (flags != GUPNP_DLNA_FLAGS_NONE) { g_string_append_printf (str, ";DLNA.ORG_FLAGS=%.8x", flags); /* append 24 reserved hex-digits */ g_string_append_printf (str, "0000" "0000" "0000" "0000" "0000" "0000"); } }
static gboolean is_additional_info_compat (GUPnPProtocolInfo *info1, GUPnPProtocolInfo *info2) { const char *profile1; const char *profile2; profile1 = gupnp_protocol_info_get_dlna_profile (info1); profile2 = gupnp_protocol_info_get_dlna_profile (info2); if (profile1 == NULL || profile2 == NULL || profile1 [0] == '*' || profile2 [0] == '*' || g_ascii_strcasecmp (profile1, profile2) == 0) return TRUE; else return FALSE; }
static void gupnp_protocol_info_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { GUPnPProtocolInfo *info; info = GUPNP_PROTOCOL_INFO (object); switch (property_id) { case PROP_PROTOCOL: g_value_set_string (value, gupnp_protocol_info_get_protocol (info)); break; case PROP_NETWORK: g_value_set_string (value, gupnp_protocol_info_get_network (info)); break; case PROP_MIME_TYPE: g_value_set_string (value, gupnp_protocol_info_get_mime_type (info)); break; case PROP_DLNA_PROFILE: g_value_set_string (value, gupnp_protocol_info_get_dlna_profile (info)); break; case PROP_PLAY_SPEEDS: g_value_set_boxed (value, gupnp_protocol_info_get_play_speeds (info)); break; case PROP_DLNA_CONVERSION: g_value_set_flags (value, gupnp_protocol_info_get_dlna_conversion (info)); break; case PROP_DLNA_OPERATION: g_value_set_flags (value, gupnp_protocol_info_get_dlna_operation (info)); break; case PROP_DLNA_FLAGS: g_value_set_flags (value, gupnp_protocol_info_get_dlna_flags (info)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
static void add_dlna_info (GString *str, GUPnPProtocolInfo *info) { const char *dlna_profile; const char **speeds; GUPnPDLNAConversion conversion; GUPnPDLNAOperation operation; GUPnPDLNAFlags flags; dlna_profile = gupnp_protocol_info_get_dlna_profile (info); if (dlna_profile == NULL) { g_string_append_printf (str, ":"); } else { g_string_append_printf (str, ":DLNA.ORG_PN=%s;", dlna_profile); } operation = gupnp_protocol_info_get_dlna_operation (info); if (operation != GUPNP_DLNA_OPERATION_NONE && /* the OP parameter is only allowed for the "http-get" * and "rtsp-rtp-udp" protocols */ (strcmp (gupnp_protocol_info_get_protocol (info), "http-get") == 0 || strcmp (gupnp_protocol_info_get_protocol (info), "rtsp-rtp-udp") == 0)) g_string_append_printf (str, "DLNA.ORG_OP=%.2x;", operation); /* Specify PS parameter if list of play speeds is provided */ speeds = gupnp_protocol_info_get_play_speeds (info); if (speeds != NULL) { int i; g_string_append (str, "DLNA.ORG_PS="); for (i = 0; speeds[i]; i++) { g_string_append (str, speeds[i]); if (speeds[i + 1]) g_string_append_c (str, ','); } g_string_append_c (str, ';'); } conversion = gupnp_protocol_info_get_dlna_conversion (info); /* omit the CI parameter for non-converted content */ if (conversion != GUPNP_DLNA_CONVERSION_NONE) g_string_append_printf (str, "DLNA.ORG_CI=%d;", conversion); flags = gupnp_protocol_info_get_dlna_flags (info); /* Omit the FLAGS parameter if no or DLNA profile are set */ if (flags != GUPNP_DLNA_FLAGS_NONE && dlna_profile != NULL) { g_string_append_printf (str, "DLNA.ORG_FLAGS=%.8x", flags); /* append 24 reserved hex-digits */ g_string_append_printf (str, "0000" "0000" "0000" "0000" "0000" "0000"); } /* if nothing of the above was set, use the "match all" rule */ switch (str->str[str->len - 1]) { case ':': g_string_append_c (str, '*'); break; case ';': g_string_erase (str, str->len - 1, 1); break; default: break; } }