[gupnp-dlna/wip/new-api: 7/46] Expose GUPnPDLNANativeRestriction.



commit 7f3e47dcd4b9b0993c9d0b000edbf268d1a78ba8
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Tue Nov 27 19:30:30 2012 +0100

    Expose GUPnPDLNANativeRestriction.

 libgupnp-dlna/Makefile.am                          |    6 +-
 libgupnp-dlna/gupnp-dlna-profile-private.h         |   41 +++
 libgupnp-dlna/gupnp-dlna-profile.c                 |  189 +++++++++++++--
 libgupnp-dlna/gupnp-dlna-profile.h                 |   12 +
 .../gupnp-dlna-native-profile-guesser-impl.c       |   83 +++----
 .../native/gupnp-dlna-native-profile-loader.c      |   73 +++----
 .../native/gupnp-dlna-native-profile.c             |  260 --------------------
 .../native/gupnp-dlna-native-profile.h             |   93 -------
 .../native/gupnp-dlna-native-sets.h                |    2 +-
 libgupnp-dlna/profile-backends/native/native.am    |    2 -
 .../sets/gupnp-dlna-native-restriction-private.h   |   47 ++++
 .../native/sets/gupnp-dlna-native-restriction.h    |   15 --
 .../native/sets/gupnp-dlna-native-sets-private.h   |    2 +-
 13 files changed, 343 insertions(+), 482 deletions(-)
---
diff --git a/libgupnp-dlna/Makefile.am b/libgupnp-dlna/Makefile.am
index 1eb6510..5197932 100644
--- a/libgupnp-dlna/Makefile.am
+++ b/libgupnp-dlna/Makefile.am
@@ -34,7 +34,8 @@ metadata_log_cflags = \
 
 common_cflags = \
 	$(GLIB_CFLAGS) \
-	$(GOBJECT_CFLAGS)
+	$(GOBJECT_CFLAGS) \
+	-I$(top_srcdir)/libgupnp-dlna/profile-backends/native/sets
 
 metadata_cflags = \
 	-I$(top_srcdir)/libgupnp-dlna/metadata
@@ -125,7 +126,8 @@ libgupnp_dlna_incdir = \
 	$(includedir)/gupnp-dlna-2.0/libgupnp-dlna
 libgupnp_dlna_inc_HEADERS = \
 	gupnp-dlna-profile-guesser.h \
-	gupnp-dlna-profile.h
+	gupnp-dlna-profile.h \
+	profile-backends/native/sets/gupnp-dlna-native-restriction.h
 
 libgupnp_dlna_metadata_incdir = \
 	$(libgupnp_dlna_incdir)/metadata
diff --git a/libgupnp-dlna/gupnp-dlna-profile-private.h b/libgupnp-dlna/gupnp-dlna-profile-private.h
new file mode 100644
index 0000000..f583317
--- /dev/null
+++ b/libgupnp-dlna/gupnp-dlna-profile-private.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Authors: Krzesimir Nowak <krnowak openismus com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GUPNP_DLNA_PROFILE_PRIVATE_H__
+#define __GUPNP_DLNA_PROFILE_PRIVATE_H__
+
+#include <glib-object.h>
+#include "gupnp-dlna-profile.h"
+
+G_BEGIN_DECLS
+
+GUPnPDLNAProfile *
+gupnp_dlna_profile_new (const gchar *name,
+                        const gchar *mime,
+                        GList       *audio_restrictions,
+                        GList       *container_restrictions,
+                        GList       *image_restrictions,
+                        GList       *video_restrictions,
+                        gboolean     extended);
+
+G_END_DECLS
+
+#endif /* __GUPNP_DLNA_PROFILE_PRIVATE_H__ */
diff --git a/libgupnp-dlna/gupnp-dlna-profile.c b/libgupnp-dlna/gupnp-dlna-profile.c
index 79f49a9..5f0bcde 100644
--- a/libgupnp-dlna/gupnp-dlna-profile.c
+++ b/libgupnp-dlna/gupnp-dlna-profile.c
@@ -22,6 +22,7 @@
  */
 
 #include "gupnp-dlna-profile.h"
+#include "gupnp-dlna-native-restriction.h"
 
 /**
  * SECTION:gupnp-dlna-profile
@@ -41,6 +42,10 @@ struct _GUPnPDLNAProfilePrivate {
         gchar    *name;
         gchar    *mime;
         gboolean  extended;
+        GList    *audio_restrictions;
+        GList    *container_restrictions;
+        GList    *image_restrictions;
+        GList    *video_restrictions;
 };
 
 enum {
@@ -48,6 +53,10 @@ enum {
         PROP_DLNA_NAME,
         PROP_DLNA_MIME,
         PROP_DLNA_EXTENDED,
+        PROP_AUDIO_RESTRICTIONS,
+        PROP_CONTAINER_RESTRICTIONS,
+        PROP_IMAGE_RESTRICTIONS,
+        PROP_VIDEO_RESTRICTIONS
 };
 
 static void
@@ -60,27 +69,52 @@ gupnp_dlna_profile_get_property (GObject    *object,
         GUPnPDLNAProfilePrivate *priv = self->priv;
 
         switch (property_id) {
-                case PROP_DLNA_NAME:
-                        g_value_set_string (value, priv->name);
-                        break;
-
-                case PROP_DLNA_MIME:
-                        g_value_set_string (value, priv->mime);
-                        break;
-
-                case PROP_DLNA_EXTENDED:
-                        g_value_set_boolean (value, priv->extended);
-                        break;
-
-                default:
-                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
-                                                           property_id,
-                                                           pspec);
-                        break;
+        case PROP_DLNA_NAME:
+                g_value_set_string (value, priv->name);
+
+                break;
+        case PROP_DLNA_MIME:
+                g_value_set_string (value, priv->mime);
+
+                break;
+        case PROP_DLNA_EXTENDED:
+                g_value_set_boolean (value, priv->extended);
+
+                break;
+        case PROP_AUDIO_RESTRICTIONS:
+                g_value_set_pointer (value, priv->audio_restrictions);
+
+                break;
+        case PROP_CONTAINER_RESTRICTIONS:
+                g_value_set_pointer (value, priv->container_restrictions);
+
+                break;
+        case PROP_IMAGE_RESTRICTIONS:
+                g_value_set_pointer (value, priv->image_restrictions);
+
+                break;
+        case PROP_VIDEO_RESTRICTIONS:
+                g_value_set_pointer (value, priv->video_restrictions);
+
+                break;
+        default:
+                G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
+                                                   property_id,
+                                                   pspec);
+                break;
         }
 }
 
 static void
+free_restrictions (GList *list)
+{
+        if (list == NULL)
+                return;
+        g_list_free_full (list,
+                          (GDestroyNotify) gupnp_dlna_native_restriction_free);
+}
+
+static void
 gupnp_dlna_profile_set_property (GObject      *object,
                                  guint         property_id,
                                  const GValue *value,
@@ -93,17 +127,38 @@ gupnp_dlna_profile_set_property (GObject      *object,
         case PROP_DLNA_NAME:
                 g_free (priv->name);
                 priv->name = g_value_dup_string (value);
-                break;
 
+                break;
         case PROP_DLNA_MIME:
                 g_free (priv->mime);
                 priv->mime = g_value_dup_string (value);
-                break;
 
+                break;
         case PROP_DLNA_EXTENDED:
                 priv->extended = g_value_get_boolean (value);
+
+                break;
+        case PROP_AUDIO_RESTRICTIONS:
+                free_restrictions (priv->audio_restrictions);
+                priv->audio_restrictions = g_value_get_pointer (value);
+
+                break;
+        case PROP_CONTAINER_RESTRICTIONS:
+                free_restrictions (priv->container_restrictions);
+                priv->container_restrictions =
+                        g_value_get_pointer (value);
+
+                break;
+        case PROP_IMAGE_RESTRICTIONS:
+                free_restrictions (priv->image_restrictions);
+                priv->image_restrictions = g_value_get_pointer (value);
+
                 break;
+        case PROP_VIDEO_RESTRICTIONS:
+                free_restrictions (priv->video_restrictions);
+                priv->video_restrictions = g_value_get_pointer (value);
 
+                break;
         default:
                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                 break;
@@ -118,6 +173,10 @@ gupnp_dlna_profile_finalize (GObject *object)
 
         g_free (priv->name);
         g_free (priv->mime);
+        free_restrictions (priv->audio_restrictions);
+        free_restrictions (priv->container_restrictions);
+        free_restrictions (priv->image_restrictions);
+        free_restrictions (priv->video_restrictions);
 
         G_OBJECT_CLASS (gupnp_dlna_profile_parent_class)->finalize (object);
 }
@@ -173,6 +232,39 @@ gupnp_dlna_profile_class_init (GUPnPDLNAProfileClass *klass)
         g_object_class_install_property (object_class,
                                          PROP_DLNA_EXTENDED,
                                          pspec);
+        pspec = g_param_spec_pointer ("audio-restrictions",
+                                      "Audio restrictions",
+                                      "Audio restrictions for the DLNA Profile",
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT_ONLY);
+        g_object_class_install_property (object_class,
+                                         PROP_AUDIO_RESTRICTIONS,
+                                         pspec);
+        pspec = g_param_spec_pointer ("container-restrictions",
+                                      "Container restrictions",
+                                      "Container restrictions for the DLNA "
+                                      "Profile",
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT_ONLY);
+        g_object_class_install_property (object_class,
+                                         PROP_CONTAINER_RESTRICTIONS,
+                                         pspec);
+        pspec = g_param_spec_pointer ("image-restrictions",
+                                      "Image restrictions",
+                                      "Image restrictions for the DLNA Profile",
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT_ONLY);
+        g_object_class_install_property (object_class,
+                                         PROP_IMAGE_RESTRICTIONS,
+                                         pspec);
+        pspec = g_param_spec_pointer ("video-restrictions",
+                                      "Video restrictions",
+                                      "Video restrictions for the DLNA Profile",
+                                      G_PARAM_READWRITE |
+                                      G_PARAM_CONSTRUCT_ONLY);
+        g_object_class_install_property (object_class,
+                                         PROP_VIDEO_RESTRICTIONS,
+                                         pspec);
 
         g_type_class_add_private (klass, sizeof (GUPnPDLNAProfilePrivate));
 }
@@ -187,6 +279,10 @@ gupnp_dlna_profile_init (GUPnPDLNAProfile *self)
         priv->name = NULL;
         priv->mime = NULL;
         priv->extended = FALSE;
+        priv->audio_restrictions = NULL;
+        priv->container_restrictions = NULL;
+        priv->image_restrictions = NULL;
+        priv->video_restrictions = NULL;
         self->priv = priv;
 }
 
@@ -231,3 +327,58 @@ gupnp_dlna_profile_get_extended (GUPnPDLNAProfile *profile)
 
         return profile->priv->extended;
 }
+
+GList *
+gupnp_dlna_profile_get_audio_restrictions (GUPnPDLNAProfile *self)
+{
+        g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE (self), NULL);
+
+        return self->priv->audio_restrictions;
+}
+
+GList *
+gupnp_dlna_profile_get_container_restrictions
+                                        (GUPnPDLNAProfile *self)
+{
+        g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE (self), NULL);
+
+        return self->priv->container_restrictions;
+}
+
+GList *
+gupnp_dlna_profile_get_image_restrictions (GUPnPDLNAProfile *self)
+{
+        g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE (self), NULL);
+
+        return self->priv->image_restrictions;
+}
+
+GList *
+gupnp_dlna_profile_get_video_restrictions (GUPnPDLNAProfile *self)
+{
+        g_return_val_if_fail (GUPNP_IS_DLNA_PROFILE (self), NULL);
+
+        return self->priv->video_restrictions;
+}
+
+GUPnPDLNAProfile *
+gupnp_dlna_profile_new (const gchar *name,
+                        const gchar *mime,
+                        GList       *audio_restrictions,
+                        GList       *container_restrictions,
+                        GList       *image_restrictions,
+                        GList       *video_restrictions,
+                        gboolean     extended)
+{
+        return GUPNP_DLNA_PROFILE
+                             (g_object_new
+                              (GUPNP_TYPE_DLNA_PROFILE,
+                               "name", name,
+                               "mime", mime,
+                               "audio-restrictions", audio_restrictions,
+                               "container-restrictions", container_restrictions,
+                               "image-restrictions", image_restrictions,
+                               "video-restrictions", video_restrictions,
+                               "extended", extended,
+                               NULL));
+}
diff --git a/libgupnp-dlna/gupnp-dlna-profile.h b/libgupnp-dlna/gupnp-dlna-profile.h
index a03af9f..5e3fe48 100644
--- a/libgupnp-dlna/gupnp-dlna-profile.h
+++ b/libgupnp-dlna/gupnp-dlna-profile.h
@@ -87,6 +87,18 @@ gupnp_dlna_profile_get_mime (GUPnPDLNAProfile *profile);
 gboolean
 gupnp_dlna_profile_get_extended (GUPnPDLNAProfile *profile);
 
+GList *
+gupnp_dlna_profile_get_container_restrictions (GUPnPDLNAProfile *self);
+
+GList *
+gupnp_dlna_profile_get_audio_restrictions (GUPnPDLNAProfile *self);
+
+GList *
+gupnp_dlna_profile_get_image_restrictions (GUPnPDLNAProfile *self);
+
+GList *
+gupnp_dlna_profile_get_video_restrictions (GUPnPDLNAProfile *self);
+
 G_END_DECLS
 
 #endif /* __GUPNP_DLNA_PROFILE_H__ */
diff --git a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-guesser-impl.c b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-guesser-impl.c
index f12a7e3..45938e4 100644
--- a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-guesser-impl.c
+++ b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-guesser-impl.c
@@ -23,7 +23,7 @@
 
 #include <glib.h>
 
-#include "gupnp-dlna-native-profile.h"
+#include "gupnp-dlna-profile.h"
 #include "gupnp-dlna-native-profile-guesser-impl.h"
 #include "gupnp-dlna-information.h"
 #include "gupnp-dlna-audio-information.h"
@@ -43,23 +43,22 @@ struct _GUPnPDLNANativeProfileGuesserImplPrivate {
 
 
 static gboolean
-is_video_profile (GUPnPDLNANativeProfile *profile)
+is_video_profile (GUPnPDLNAProfile *profile)
 {
         GList *container_restrictions =
-                 gupnp_dlna_native_profile_get_container_restrictions (profile);
+                 gupnp_dlna_profile_get_container_restrictions (profile);
         GList *video_restrictions =
-                     gupnp_dlna_native_profile_get_video_restrictions (profile);
+                     gupnp_dlna_profile_get_video_restrictions (profile);
 
         return (container_restrictions != NULL && video_restrictions != NULL);
 }
 
 static gboolean
-match_profile (GUPnPDLNANativeProfile *profile,
+match_profile (GUPnPDLNAProfile       *profile,
                GUPnPDLNANativeInfoSet *stream_info_set,
                GList                  *profile_restrictions)
 {
-        GUPnPDLNAProfile *dlna_profile = GUPNP_DLNA_PROFILE (profile);
-        const gchar *name = gupnp_dlna_profile_get_name (dlna_profile);
+        const gchar *name = gupnp_dlna_profile_get_name (profile);
         GList *iter;
         gchar *stream_dump;
         gchar *restrictions_dump;
@@ -309,14 +308,14 @@ info_set_from_container_information (GUPnPDLNAContainerInformation *info)
 }
 
 static gboolean
-check_container_profile (GUPnPDLNAInformation   *info,
-                         GUPnPDLNANativeProfile *profile)
+check_container_profile (GUPnPDLNAInformation *info,
+                         GUPnPDLNAProfile     *profile)
 {
         GUPnPDLNAContainerInformation *container_info =
                         gupnp_dlna_information_get_container_information (info);
         gboolean matched = FALSE;
         GList *profile_restrictions =
-                 gupnp_dlna_native_profile_get_container_restrictions (profile);
+                 gupnp_dlna_profile_get_container_restrictions (profile);
 
         if (profile_restrictions != NULL && container_info != NULL) {
                 GUPnPDLNANativeInfoSet *stream_info_set =
@@ -405,8 +404,8 @@ info_set_from_audio_information (GUPnPDLNAAudioInformation *info)
 }
 
 static gboolean
-check_audio_profile (GUPnPDLNAInformation   *info,
-                     GUPnPDLNANativeProfile *profile)
+check_audio_profile (GUPnPDLNAInformation *info,
+                     GUPnPDLNAProfile     *profile)
 {
         GUPnPDLNANativeInfoSet *info_set;
         gboolean matched;
@@ -419,8 +418,7 @@ check_audio_profile (GUPnPDLNAInformation   *info,
         matched = FALSE;
         audio_info = gupnp_dlna_information_get_audio_information (info);
         info_set = info_set_from_audio_information (audio_info);
-        restrictions =
-                     gupnp_dlna_native_profile_get_audio_restrictions (profile);
+        restrictions = gupnp_dlna_profile_get_audio_restrictions (profile);
         if (match_profile (profile, info_set, restrictions))
                 matched = TRUE;
         else
@@ -497,7 +495,7 @@ info_set_from_video_information (GUPnPDLNAVideoInformation *info)
 
 static gboolean
 check_video_profile (GUPnPDLNAInformation *info,
-                     GUPnPDLNANativeProfile *profile)
+                     GUPnPDLNAProfile     *profile)
 {
         GUPnPDLNAVideoInformation *video_info =
                             gupnp_dlna_information_get_video_information (info);
@@ -510,8 +508,7 @@ check_video_profile (GUPnPDLNAInformation *info,
         if (video_info == NULL || audio_info == NULL)
                 goto out;
 
-        restrictions = gupnp_dlna_native_profile_get_video_restrictions
-                                        (profile);
+        restrictions = gupnp_dlna_profile_get_video_restrictions (profile);
         info_set = info_set_from_video_information (video_info);
         if (!match_profile (profile, info_set, restrictions)) {
                 g_debug ("Video did not match");
@@ -520,8 +517,7 @@ check_video_profile (GUPnPDLNAInformation *info,
         }
         gupnp_dlna_native_info_set_free (info_set);
 
-        restrictions = gupnp_dlna_native_profile_get_audio_restrictions
-                                        (profile);
+        restrictions = gupnp_dlna_profile_get_audio_restrictions (profile);
         info_set = info_set_from_audio_information (audio_info);
         if (!match_profile (profile, info_set, restrictions)) {
                 g_debug ("Audio did not match");
@@ -576,27 +572,24 @@ backend_guess_image_profile
         GUPnPDLNAImageInformation *image_info =
                             gupnp_dlna_information_get_image_information (info);
         GUPnPDLNANativeInfoSet *info_set;
-        GUPnPDLNAProfile *profile;
+        GUPnPDLNAProfile *found_profile;
 
         if (!image_info)
                 return NULL;
 
         info_set = info_set_from_image_information (image_info);
-        profile = NULL;
+        found_profile = NULL;
 
         for (iter = profiles; iter; iter = iter->next) {
-                GUPnPDLNANativeProfile *native_profile =
-                                        GUPNP_DLNA_NATIVE_PROFILE (iter->data);
+                GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (iter->data);
                 GList *restrictions =
-                                gupnp_dlna_native_profile_get_image_restrictions
-                                        (native_profile);
+                            gupnp_dlna_profile_get_image_restrictions (profile);
 
                 g_debug ("Matching image against profile: %s",
-                         gupnp_dlna_profile_get_name
-                                        (GUPNP_DLNA_PROFILE (native_profile)));
+                         gupnp_dlna_profile_get_name (profile));
 
-                if (match_profile (native_profile, info_set, restrictions)) {
-                        profile = GUPNP_DLNA_PROFILE (native_profile);
+                if (match_profile (profile, info_set, restrictions)) {
+                        found_profile = profile;
 
                         break;
                 } else
@@ -605,7 +598,7 @@ backend_guess_image_profile
 
         gupnp_dlna_native_info_set_free (info_set);
 
-        return profile;
+        return found_profile;
 }
 
 static GUPnPDLNAProfile *
@@ -614,25 +607,23 @@ backend_guess_video_profile
                         GUPnPDLNAInformation        *info,
                         GList                       *profiles)
 {
-        GUPnPDLNAProfile *profile = NULL;
+        GUPnPDLNAProfile *found_profile = NULL;
         GList *iter;
 
         for (iter = profiles; iter; iter = iter->next) {
-                GUPnPDLNANativeProfile *native_profile =
-                                        GUPNP_DLNA_NATIVE_PROFILE (iter->data);
+                GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (iter->data);
 
                 g_debug ("Matching video against profile: %s",
-                         gupnp_dlna_profile_get_name
-                                        (GUPNP_DLNA_PROFILE (native_profile)));
+                         gupnp_dlna_profile_get_name (profile));
 
-                if (check_video_profile (info, native_profile)) {
-                        profile = GUPNP_DLNA_PROFILE (native_profile);
+                if (check_video_profile (info, profile)) {
+                        found_profile = profile;
 
                         break;
                 }
         }
 
-        return profile;
+        return found_profile;
 }
 
 static GUPnPDLNAProfile *
@@ -642,25 +633,23 @@ backend_guess_audio_profile
                         GList                       *profiles)
 {
         GList *iter;
-        GUPnPDLNAProfile *profile = NULL;
+        GUPnPDLNAProfile *found_profile = NULL;
 
         for (iter = profiles; iter != NULL; iter = iter->next) {
-                GUPnPDLNANativeProfile *native_profile =
-                                        GUPNP_DLNA_NATIVE_PROFILE (iter->data);
+                GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (iter->data);
 
                 g_debug ("Matching audio against profile: %s",
-                         gupnp_dlna_profile_get_name
-                                        (GUPNP_DLNA_PROFILE (native_profile)));
+                         gupnp_dlna_profile_get_name (profile));
 
-                if (check_audio_profile (info, native_profile) &&
-                    check_container_profile (info, native_profile)) {
-                        profile = GUPNP_DLNA_PROFILE (native_profile);
+                if (check_audio_profile (info, profile) &&
+                    check_container_profile (info, profile)) {
+                        found_profile = profile;
 
                         break;
                 }
         }
 
-        return profile;
+        return found_profile;
 }
 
 static void
diff --git a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-loader.c b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-loader.c
index d42cb7e..79ec47d 100644
--- a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-loader.c
+++ b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-profile-loader.c
@@ -25,7 +25,7 @@
 #include "config.h"
 #endif /* HAVE_CONFIG_H_ */
 #include "gupnp-dlna-native-profile-loader.h"
-#include "gupnp-dlna-native-profile.h"
+#include "gupnp-dlna-profile-private.h"
 #include "gupnp-dlna-native-sets.h"
 #include "gupnp-dlna-native-utils.h"
 
@@ -605,16 +605,16 @@ copy_restrictions_list (GList *list)
 
 static void
 merge_base_restrictions (GUPnPDLNANativeProfileData *data,
-                         GUPnPDLNANativeProfile     *profile)
+                         GUPnPDLNAProfile           *profile)
 {
         GList *audio_restrictions =
-                     gupnp_dlna_native_profile_get_audio_restrictions (profile);
+                     gupnp_dlna_profile_get_audio_restrictions (profile);
         GList *container_restrictions =
-                 gupnp_dlna_native_profile_get_container_restrictions (profile);
+                 gupnp_dlna_profile_get_container_restrictions (profile);
         GList *image_restrictions =
-                     gupnp_dlna_native_profile_get_image_restrictions (profile);
+                     gupnp_dlna_profile_get_image_restrictions (profile);
         GList *video_restrictions =
-                     gupnp_dlna_native_profile_get_video_restrictions (profile);
+                     gupnp_dlna_profile_get_video_restrictions (profile);
 
         if (audio_restrictions != NULL) {
                 GList *copy = copy_restrictions_list (audio_restrictions);
@@ -667,16 +667,15 @@ backend_create_profile (GUPnPDLNAProfileLoader *loader,
         GUPnPDLNANativeProfileLoaderPrivate *priv = native_loader->priv;
         GUPnPDLNANativeProfileData *data =
              (GUPnPDLNANativeProfileData *) priv->dlna_profile_data_stack->data;
-        GUPnPDLNANativeProfile *profile;
+        GUPnPDLNAProfile *profile;
         GList *audio_restrictions = NULL;
         GList *container_restrictions = NULL;
         GList *image_restrictions = NULL;
         GList *video_restrictions = NULL;
 
         /* Inherit from base profile, if it exists */
-        if (GUPNP_IS_DLNA_NATIVE_PROFILE (base))
-                merge_base_restrictions (data,
-                                         GUPNP_DLNA_NATIVE_PROFILE (base));
+        if (base != NULL)
+                merge_base_restrictions (data, base);
 
         /* The merged caps will be our new GUPnPDLNAProfile */
         if (!restrictions_list_is_empty (data->audios)) {
@@ -696,13 +695,13 @@ backend_create_profile (GUPnPDLNAProfileLoader *loader,
                 data->videos = NULL;
         }
 
-        profile = gupnp_dlna_native_profile_new (name,
-                                                 mime,
-                                                 audio_restrictions,
-                                                 container_restrictions,
-                                                 image_restrictions,
-                                                 video_restrictions,
-                                                 extended);
+        profile = gupnp_dlna_profile_new (name,
+                                          mime,
+                                          audio_restrictions,
+                                          container_restrictions,
+                                          image_restrictions,
+                                          video_restrictions,
+                                          extended);
 
         return GUPNP_DLNA_PROFILE (profile);
 }
@@ -734,51 +733,41 @@ backend_cleanup (GUPnPDLNAProfileLoader *loader G_GNUC_UNUSED,
 
         while (iter != NULL) {
                 GList *next = iter->next;
+                GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (iter->data);
+                const gchar *name = gupnp_dlna_profile_get_name (profile);
 
-                if (GUPNP_IS_DLNA_NATIVE_PROFILE (iter->data)) {
-                        GUPnPDLNANativeProfile *profile =
-                                        GUPNP_DLNA_NATIVE_PROFILE (iter->data);
-                        const gchar *name = gupnp_dlna_profile_get_name
-                                        (GUPNP_DLNA_PROFILE (profile));
-
-                        if (name == NULL || name[0] == '\0') {
-                                profiles = g_list_delete_link (profiles, iter);
-                                g_object_unref (profile);
-                        } else {
-                                /* TODO: simplify restrictions in
-                                 * profile if possible.
-                                 */
-                        }
+                if (name == NULL || name[0] == '\0') {
+                        profiles = g_list_delete_link (profiles, iter);
+                        g_object_unref (profile);
                 } else {
-                        g_critical
-                                  ("Profile in list is not from this backend.");
+                        /* TODO: simplify restrictions in profile if
+                         * possible.
+                         */
                 }
 
                 iter = next;
         }
 
         for (iter = profiles; iter != NULL; iter = iter->next) {
-                GUPnPDLNANativeProfile *profile = GUPNP_DLNA_NATIVE_PROFILE
-                                        (iter->data);
-                GUPnPDLNAProfile *dlna_profile = GUPNP_DLNA_PROFILE (profile);
+                GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (iter->data);
                 gchar *acaps =
                              gupnp_dlna_native_utils_restrictions_list_to_string
-                   (gupnp_dlna_native_profile_get_audio_restrictions (profile));
+                   (gupnp_dlna_profile_get_audio_restrictions (profile));
                 gchar *ccaps =
                              gupnp_dlna_native_utils_restrictions_list_to_string
-                           (gupnp_dlna_native_profile_get_container_restrictions
+                           (gupnp_dlna_profile_get_container_restrictions
                                         (profile));
                 gchar *icaps =
                              gupnp_dlna_native_utils_restrictions_list_to_string
-                   (gupnp_dlna_native_profile_get_image_restrictions (profile));
+                   (gupnp_dlna_profile_get_image_restrictions (profile));
                 gchar *vcaps =
                              gupnp_dlna_native_utils_restrictions_list_to_string
-                   (gupnp_dlna_native_profile_get_video_restrictions (profile));
+                   (gupnp_dlna_profile_get_video_restrictions (profile));
 
                 g_debug ("Loaded profile: %s\nMIME: %s\naudio caps: %s\n"
                          "container caps: %s\nimage caps: %s\nvideo caps: %s\n",
-                         gupnp_dlna_profile_get_name (dlna_profile),
-                         gupnp_dlna_profile_get_mime (dlna_profile),
+                         gupnp_dlna_profile_get_name (profile),
+                         gupnp_dlna_profile_get_mime (profile),
                          acaps,
                          ccaps,
                          icaps,
diff --git a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-sets.h b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-sets.h
index 2ef015b..d35b8d0 100644
--- a/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-sets.h
+++ b/libgupnp-dlna/profile-backends/native/gupnp-dlna-native-sets.h
@@ -24,7 +24,7 @@
 
 #include "gupnp-dlna-native-value-type.h"
 #include "gupnp-dlna-native-value-list.h"
-#include "gupnp-dlna-native-restriction.h"
+#include "gupnp-dlna-native-restriction-private.h"
 #include "gupnp-dlna-native-info-set.h"
 
 #endif /* __GUPNP_DLNA_NATIVE_SETS_H__ */
diff --git a/libgupnp-dlna/profile-backends/native/native.am b/libgupnp-dlna/profile-backends/native/native.am
index 2991cbe..59d4268 100644
--- a/libgupnp-dlna/profile-backends/native/native.am
+++ b/libgupnp-dlna/profile-backends/native/native.am
@@ -44,8 +44,6 @@ profile_backends_native_libnativeguesser_la_CFLAGS = \
 profile_backends_native_libnativeprofilebackend_la_SOURCES = \
 	profile-backends/native/gupnp-dlna-native-profile-backend.c \
 	profile-backends/native/gupnp-dlna-native-profile-backend.h \
-	profile-backends/native/gupnp-dlna-native-profile.c \
-	profile-backends/native/gupnp-dlna-native-profile.h \
 	profile-backends/native/gupnp-dlna-native-sets.h \
 	profile-backends/native/gupnp-dlna-native-utils.c \
 	profile-backends/native/gupnp-dlna-native-utils.h
diff --git a/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction-private.h b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction-private.h
new file mode 100644
index 0000000..2768334
--- /dev/null
+++ b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction-private.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Authors: Krzesimir Nowak <krnowak openismus com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GUPNP_DLNA_NATIVE_RESTRICTION_PRIVATE_H__
+#define __GUPNP_DLNA_NATIVE_RESTRICTION_PRIVATE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "gupnp-dlna-native-restriction.h"
+#include "gupnp-dlna-native-value-list.h"
+
+G_BEGIN_DECLS
+
+GUPnPDLNANativeRestriction *
+gupnp_dlna_native_restriction_new (const gchar *mime);
+
+gboolean
+gupnp_dlna_native_restriction_add_value_list
+                                       (GUPnPDLNANativeRestriction *restriction,
+                                        const gchar                *name,
+                                        GUPnPDLNANativeValueList   *list);
+
+void
+gupnp_dlna_native_restriction_merge (GUPnPDLNANativeRestriction *restriction,
+                                     GUPnPDLNANativeRestriction *merged);
+
+G_END_DECLS
+
+#endif /* __GUPNP_DLNA_NATIVE_RESTRICTION_PRIVATE_H__ */
diff --git a/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction.h b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction.h
index e550693..85b4ed2 100644
--- a/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction.h
+++ b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-restriction.h
@@ -23,8 +23,6 @@
 #define __GUPNP_DLNA_NATIVE_RESTRICTION_H__
 
 #include <glib.h>
-#include <glib-object.h>
-#include "gupnp-dlna-native-value-list.h"
 
 G_BEGIN_DECLS
 
@@ -34,25 +32,12 @@ typedef struct _GUPnPDLNANativeRestriction GUPnPDLNANativeRestriction;
         ((GUPnPDLNANativeRestriction *) x)
 
 GUPnPDLNANativeRestriction *
-gupnp_dlna_native_restriction_new (const gchar *mime);
-
-GUPnPDLNANativeRestriction *
 gupnp_dlna_native_restriction_copy (GUPnPDLNANativeRestriction *restriction);
 
 void
 gupnp_dlna_native_restriction_free (GUPnPDLNANativeRestriction *restriction);
 
 gboolean
-gupnp_dlna_native_restriction_add_value_list
-                                       (GUPnPDLNANativeRestriction *restriction,
-                                        const gchar                *name,
-                                        GUPnPDLNANativeValueList   *list);
-
-void
-gupnp_dlna_native_restriction_merge (GUPnPDLNANativeRestriction *restriction,
-                                     GUPnPDLNANativeRestriction *merged);
-
-gboolean
 gupnp_dlna_native_restriction_is_empty
                                       (GUPnPDLNANativeRestriction *restriction);
 
diff --git a/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-sets-private.h b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-sets-private.h
index fd8c4a8..053b20c 100644
--- a/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-sets-private.h
+++ b/libgupnp-dlna/profile-backends/native/sets/gupnp-dlna-native-sets-private.h
@@ -26,7 +26,7 @@
 #include "gupnp-dlna-native-value-type.h"
 #include "gupnp-dlna-native-value-list.h"
 #include "gupnp-dlna-native-info-value.h"
-#include "gupnp-dlna-native-restriction.h"
+#include "gupnp-dlna-native-restriction-private.h"
 
 G_BEGIN_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]