Host user's home directory as '/media' and update paths accordingly.
authorZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Wed, 23 Apr 2008 13:53:33 +0000 (13:53 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@src.gnome.org>
Wed, 23 Apr 2008 13:53:33 +0000 (13:53 +0000)
svn path=/trunk/; revision=129

ChangeLog
src/gupnp-media-server.c

index 7648972..42d237d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
        - Implement 'BrowseMetadata'.
        - Mime-type of mp3 files should be 'audio/mpeg' rather than
        'audio/mp3'.
+       - Host user's home directory as '/media' and update paths accordingly.
 
 2008-04-21  Zeeshan Ali Khattak  <zeenix@gmail.com>
 
index 5e8abe7..a4a037c 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "gupnp-media-server.h"
 
+#define HOME_DIR_ALIAS "/media"
+
 G_DEFINE_TYPE (GUPnPMediaServer,
                gupnp_media_server,
                GUPNP_TYPE_ROOT_DEVICE);
@@ -43,16 +45,19 @@ struct _GUPnPMediaServerPrivate {
         GUPnPSearchCriteriaParser *search_parser;
 };
 
-/* Hard-coded items (mime, title, path) */
+/* Hard-coded items (mime, title, path)
+ *
+ * paths are relative to home directory
+ * */
 char *items[3][4] = {
         { "4000",
           "audio/mpeg",
           "Maa",
-          "/home/zeenix/entertainment/songs/Maa.mp3" },
+          "entertainment/songs/Maa.mp3" },
         { "4001",
           "audio/mpeg",
           "Hoo",
-          "/home/zeenix/entertainment/songs/Ho.mp3" },
+          "entertainment/songs/Ho.mp3" },
         { NULL }
 };
 
@@ -108,6 +113,7 @@ gupnp_media_server_constructor (GType                  type,
         GObjectClass *object_class;
         GUPnPMediaServer *server;
         GUPnPServiceInfo *service;
+        GUPnPContext *context;
 
         object_class = G_OBJECT_CLASS (gupnp_media_server_parent_class);
         object = object_class->constructor (type,
@@ -139,6 +145,11 @@ gupnp_media_server_constructor (GType                  type,
                 }
         }
 
+        context = gupnp_device_info_get_context (GUPNP_DEVICE_INFO (server));
+
+        /* Host user's home dir */
+        gupnp_context_host_path (context, g_get_home_dir (), HOME_DIR_ALIAS);
+
         return object;
 }
 
@@ -223,9 +234,10 @@ add_item (GUPnPContext        *context,
         gupnp_didl_lite_resource_reset (&res);
 
         /* URI */
-        res.uri = g_strdup_printf ("http://%s:%d%s",
+        res.uri = g_strdup_printf ("http://%s:%d%s/%s",
                                    gupnp_context_get_host_ip (context),
                                    gupnp_context_get_port (context),
+                                   HOME_DIR_ALIAS,
                                    path);
 
         /* Protocol info */