[rygel] core,plugins: Port generate_random_udn() to Vala



commit d899947c212f751d88f4ad41185983574ac5253c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Jun 21 03:44:00 2010 +0300

    core,plugins: Port generate_random_udn() to Vala
    
    Since this was the last piece of code in C, this commit also removes the
    whole 'CStuff' module (vapi,C and header file) and all its references.

 src/plugins/external/Makefile.am                   |    2 +-
 .../external/rygel-external-plugin-factory.vala    |    1 -
 src/plugins/gst-launch/Makefile.am                 |    2 +-
 .../gst-launch/rygel-gst-launch-plugin.vala        |    1 -
 .../rygel-gst-launch-root-container.vala           |    1 -
 src/plugins/media-export/Makefile.am               |    1 -
 src/plugins/mediathek/Makefile.am                  |    1 -
 src/plugins/test/Makefile.am                       |    2 +-
 src/plugins/test/rygel-test-plugin.vala            |    1 -
 src/rygel/Makefile.am                              |   10 ++---
 src/rygel/cstuff.c                                 |   42 --------------------
 src/rygel/cstuff.h                                 |   36 -----------------
 src/rygel/cstuff.vapi                              |   34 ----------------
 src/rygel/rygel-cmdline-config.vala                |    1 -
 src/rygel/rygel-configuration.vala                 |    2 -
 src/rygel/rygel-environment-config.vala            |    1 -
 src/rygel/rygel-meta-config.vala                   |    1 -
 src/rygel/rygel-plugin-loader.vala                 |    1 -
 src/rygel/rygel-plugin.vala                        |    1 -
 src/rygel/rygel-root-device-factory.vala           |   31 ++++++++++++--
 src/rygel/rygel-root-device.vala                   |    1 -
 src/rygel/rygel-user-config.vala                   |    2 -
 src/rygel/rygel-xbox-hacks.vala                    |    1 -
 23 files changed, 33 insertions(+), 143 deletions(-)
---
diff --git a/src/plugins/external/Makefile.am b/src/plugins/external/Makefile.am
index d031f6e..1307c11 100644
--- a/src/plugins/external/Makefile.am
+++ b/src/plugins/external/Makefile.am
@@ -29,7 +29,7 @@ librygel_external_la_SOURCES = rygel-external-content-dir.vala \
 
 rygel-external.stamp: $(librygel_external_la_VALASOURCES)
 librygel_external_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
-				 --pkg rygel-1.0 --pkg cstuff --pkg gupnp-1.0 \
+				 --pkg rygel-1.0 --pkg gupnp-1.0 \
 				 --pkg gupnp-av-1.0 --pkg dbus-glib-1 \
 				 --pkg gee-1.0 --pkg gstreamer-0.10 \
 				 --pkg gconf-2.0 -g
diff --git a/src/plugins/external/rygel-external-plugin-factory.vala b/src/plugins/external/rygel-external-plugin-factory.vala
index b9740d0..469a15a 100644
--- a/src/plugins/external/rygel-external-plugin-factory.vala
+++ b/src/plugins/external/rygel-external-plugin-factory.vala
@@ -24,7 +24,6 @@
 
 using Rygel;
 using Gee;
-using CStuff;
 using FreeDesktop;
 
 private ExternalPluginFactory plugin_factory;
diff --git a/src/plugins/gst-launch/Makefile.am b/src/plugins/gst-launch/Makefile.am
index 1ddcb98..a512eac 100644
--- a/src/plugins/gst-launch/Makefile.am
+++ b/src/plugins/gst-launch/Makefile.am
@@ -18,7 +18,7 @@ librygel_gst_launch_la_SOURCES = rygel-gst-launch-plugin.vala \
 				rygel-gst-launch-item.vala
 
 librygel_gst_launch_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
-			     --pkg rygel-1.0 --pkg cstuff --pkg gconf-2.0 \
+			     --pkg rygel-1.0 --pkg gconf-2.0 \
 			     --pkg gupnp-1.0 --pkg gupnp-av-1.0 \
 			     --pkg dbus-glib-1 --pkg gee-1.0 \
 			     --pkg gstreamer-0.10 -g
diff --git a/src/plugins/gst-launch/rygel-gst-launch-plugin.vala b/src/plugins/gst-launch/rygel-gst-launch-plugin.vala
index 6860379..0af87b7 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-plugin.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-plugin.vala
@@ -22,7 +22,6 @@
 
 using Rygel;
 using Gee;
-using CStuff;
 
 public void module_init (PluginLoader loader) {
     var plugin = new Plugin.MediaServer ("GstLaunch",
diff --git a/src/plugins/gst-launch/rygel-gst-launch-root-container.vala b/src/plugins/gst-launch/rygel-gst-launch-root-container.vala
index a18b6e6..d24eadd 100644
--- a/src/plugins/gst-launch/rygel-gst-launch-root-container.vala
+++ b/src/plugins/gst-launch/rygel-gst-launch-root-container.vala
@@ -24,7 +24,6 @@ using Rygel;
 using GUPnP;
 using Gee;
 using Gst;
-using CStuff;
 
 /**
  * Represents the root container for GstLaunch content hierarchy.
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 3374c96..ed059ae 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -40,7 +40,6 @@ librygel_media_export_la_SOURCES = rygel-media-export-plugin.vala \
 librygel_media_export_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
 				     --pkg dbus-glib-1 \
                                      --pkg rygel-1.0 \
-                                     --pkg cstuff \
                                      --pkg gupnp-1.0 \
                                      --pkg gupnp-av-1.0 \
                                      --pkg libsoup-2.4 \
diff --git a/src/plugins/mediathek/Makefile.am b/src/plugins/mediathek/Makefile.am
index a8067c1..8c60639 100644
--- a/src/plugins/mediathek/Makefile.am
+++ b/src/plugins/mediathek/Makefile.am
@@ -26,7 +26,6 @@ librygel_mediathek_la_SOURCES = rygel-mediathek-asx-playlist.vala \
 
 librygel_mediathek_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
 				  --pkg rygel-1.0 \
-				  --pkg cstuff \
 				  --pkg gupnp-1.0 \
 				  --pkg gupnp-av-1.0 \
 				  --pkg libsoup-2.4 \
diff --git a/src/plugins/test/Makefile.am b/src/plugins/test/Makefile.am
index 917cabb..9c6078b 100644
--- a/src/plugins/test/Makefile.am
+++ b/src/plugins/test/Makefile.am
@@ -25,7 +25,7 @@ librygel_test_la_SOURCES = rygel-test-content-dir.vala \
 			   rygel-test-plugin.vala
 
 librygel_test_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
-			     --pkg rygel-1.0 --pkg cstuff --pkg gconf-2.0 \
+			     --pkg rygel-1.0 --pkg gconf-2.0 \
 			     --pkg gupnp-1.0 --pkg gupnp-av-1.0 \
 			     --pkg dbus-glib-1 --pkg gee-1.0 \
 			     --pkg gstreamer-0.10 -g
diff --git a/src/plugins/test/rygel-test-plugin.vala b/src/plugins/test/rygel-test-plugin.vala
index fc28a85..bb0860b 100644
--- a/src/plugins/test/rygel-test-plugin.vala
+++ b/src/plugins/test/rygel-test-plugin.vala
@@ -24,7 +24,6 @@
 
 using Rygel;
 using Gee;
-using CStuff;
 
 public void module_init (PluginLoader loader) {
     var plugin = new Plugin.MediaServer ("Test",
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index 902e0ff..4fe846b 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -103,7 +103,7 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \
 
 rygel_VALAFLAGS = \
 	-H rygel.h -C --library=rygel-1.0 --vapidir=$(srcdir) --thread \
-	--pkg cstuff --pkg rygel-build-config --pkg gupnp-1.0 \
+	--pkg rygel-build-config --pkg gupnp-1.0 \
 	--pkg gupnp-av-1.0 --pkg dbus-glib-1 --pkg gstreamer-0.10 \
 	--pkg gio-2.0 --pkg gee-1.0 --pkg posix -g
 
@@ -132,12 +132,10 @@ librygel_configuration_a_SOURCES = rygel-configuration.c \
 				   rygel-user-config.c \
 				   rygel-meta-config.c \
 				   rygel-cmdline-config.c \
-				   rygel-environment-config.c \
-				   cstuff.c
+				   rygel-environment-config.c
 
 MAINTAINERCLEANFILES = Makefile.in $(BUILT_SOURCES)
-EXTRA_DIST = cstuff.vapi \
-             rygel-build-config.vapi \
+EXTRA_DIST = rygel-build-config.vapi \
              $(VAPI_FILES) \
              $(DEPS_FILES) \
-             $(BUILT_SOURCES) cstuff.h
+             $(BUILT_SOURCES)
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index 8f39ec8..2fa41e5 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -22,7 +22,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using CStuff;
 using Gee;
 
 public errordomain Rygel.CmdlineConfigError {
diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala
index 1669e2c..5795580 100644
--- a/src/rygel/rygel-configuration.vala
+++ b/src/rygel/rygel-configuration.vala
@@ -22,8 +22,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using CStuff;
-
 public errordomain Rygel.ConfigurationError {
     NO_VALUE_SET,
     VALUE_OUT_OF_RANGE
diff --git a/src/rygel/rygel-environment-config.vala b/src/rygel/rygel-environment-config.vala
index da09e16..9b35343 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -22,7 +22,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using CStuff;
 using Gee;
 
 /**
diff --git a/src/rygel/rygel-meta-config.vala b/src/rygel/rygel-meta-config.vala
index d9c9e8b..ba6b0c4 100644
--- a/src/rygel/rygel-meta-config.vala
+++ b/src/rygel/rygel-meta-config.vala
@@ -23,7 +23,6 @@
  */
 
 using Gee;
-using CStuff;
 
 /**
  * Manages all the configuration sources for Rygel.
diff --git a/src/rygel/rygel-plugin-loader.vala b/src/rygel/rygel-plugin-loader.vala
index 7c1028d..188b5c2 100644
--- a/src/rygel/rygel-plugin-loader.vala
+++ b/src/rygel/rygel-plugin-loader.vala
@@ -21,7 +21,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using CStuff;
 using GUPnP;
 using Gee;
 
diff --git a/src/rygel/rygel-plugin.vala b/src/rygel/rygel-plugin.vala
index 6d8aca1..03cccb0 100644
--- a/src/rygel/rygel-plugin.vala
+++ b/src/rygel/rygel-plugin.vala
@@ -23,7 +23,6 @@
 
 using Gee;
 using GUPnP;
-using CStuff;
 
 /**
  * Represents a Rygel plugin. Plugins are supposed to provide an object of this
diff --git a/src/rygel/rygel-root-device-factory.vala b/src/rygel/rygel-root-device-factory.vala
index d54d0da..6ff9723 100644
--- a/src/rygel/rygel-root-device-factory.vala
+++ b/src/rygel/rygel-root-device-factory.vala
@@ -1,9 +1,11 @@
 /*
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2010 Nokia Corporation.
  * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2007 OpenedHand Ltd.
  *
- * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *                               <zeeshan ali nokia com>
+ * Authors: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                                <zeeshan ali nokia com>
+ *          Jorn Baayen <jorn openedhand com>
  *
  * This file is part of Rygel.
  *
@@ -23,7 +25,15 @@
  */
 
 using GUPnP;
-using CStuff;
+
+[CCode (cname = "uuid_generate", cheader_filename = "uuid/uuid.h")]
+public extern static void uuid_generate ([CCode (array_length = false)]
+                                         uchar[] uuid);
+[CCode (cname = "uuid_unparse", cheader_filename = "uuid/uuid.h")]
+public extern static void uuid_unparse ([CCode (array_length = false)]
+                                        uchar[] uuid,
+                                        [CCode (array_length = false)]
+                                        uchar[] output);
 
 public errordomain RootDeviceFactoryError {
     XML_PARSE,
@@ -161,7 +171,7 @@ internal class Rygel.RootDeviceFactory {
 
         var udn = element->get_content ();
         if (udn == null || udn == "") {
-            udn = Utils.generate_random_udn ();
+            udn = this.generate_random_udn ();
 
             element->set_content (udn);
         }
@@ -313,5 +323,16 @@ internal class Rygel.RootDeviceFactory {
             file.make_directory (null);
         }
     }
+
+    private string generate_random_udn () {
+        var udn = new uchar[50];
+        var id = new uchar[16];
+
+        /* Generate new UUID */
+        uuid_generate (id);
+        uuid_unparse (id, udn);
+
+        return "uuid:" + (string) udn;
+    }
 }
 
diff --git a/src/rygel/rygel-root-device.vala b/src/rygel/rygel-root-device.vala
index 26fc0ed..d1fb494 100644
--- a/src/rygel/rygel-root-device.vala
+++ b/src/rygel/rygel-root-device.vala
@@ -22,7 +22,6 @@
  */
 
 using GUPnP;
-using CStuff;
 using Gee;
 
 /**
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 331828d..39cbace 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -22,8 +22,6 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-using CStuff;
-
 /**
  * Manages the user configuration for Rygel.
  */
diff --git a/src/rygel/rygel-xbox-hacks.vala b/src/rygel/rygel-xbox-hacks.vala
index 0ea4029..c55315c 100644
--- a/src/rygel/rygel-xbox-hacks.vala
+++ b/src/rygel/rygel-xbox-hacks.vala
@@ -23,7 +23,6 @@
 
 using Soup;
 using GUPnP;
-using CStuff;
 
 internal errordomain Rygel.XBoxHacksError {
     NA



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