X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgunixvolumemonitor.c;h=130ca626dcc33111b3d70dd9325ca7368f86b7cf;hb=c3842d1969feace4bfb12919be730e75e53877d9;hp=69b8e3663f77d4b998ffea67d1da9b8e3ef0caa9;hpb=28d1c8e0ad86253c84de1ee948a338eec98ae701;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gunixvolumemonitor.c b/gio/gunixvolumemonitor.c
index 69b8e36..130ca62 100644
--- a/gio/gunixvolumemonitor.c
+++ b/gio/gunixvolumemonitor.c
@@ -15,15 +15,13 @@
* 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., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: Alexander Larsson
* David Zeuthen
*/
-#include
+#include "config.h"
#include
@@ -32,10 +30,11 @@
#include "gunixmounts.h"
#include "gunixmount.h"
#include "gunixvolume.h"
+#include "gmount.h"
#include "gmountprivate.h"
+#include "giomodule.h"
#include "glibintl.h"
-#include "gioalias.h"
struct _GUnixVolumeMonitor {
GNativeVolumeMonitor parent;
@@ -57,7 +56,11 @@ static void update_volumes (GUnixVolumeMonitor *monitor);
static void update_mounts (GUnixVolumeMonitor *monitor);
#define g_unix_volume_monitor_get_type _g_unix_volume_monitor_get_type
-G_DEFINE_TYPE (GUnixVolumeMonitor, g_unix_volume_monitor, G_TYPE_NATIVE_VOLUME_MONITOR);
+G_DEFINE_TYPE_WITH_CODE (GUnixVolumeMonitor, g_unix_volume_monitor, G_TYPE_NATIVE_VOLUME_MONITOR,
+ g_io_extension_point_implement (G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME,
+ g_define_type_id,
+ "unix",
+ 0));
static void
g_unix_volume_monitor_finalize (GObject *object)
@@ -71,46 +74,49 @@ g_unix_volume_monitor_finalize (GObject *object)
g_object_unref (monitor->mount_monitor);
- g_list_foreach (monitor->last_mountpoints, (GFunc)g_unix_mount_point_free, NULL);
- g_list_free (monitor->last_mountpoints);
- g_list_foreach (monitor->last_mounts, (GFunc)g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
+ g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
+ g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
- g_list_foreach (monitor->volumes, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->volumes);
- g_list_foreach (monitor->mounts, (GFunc)g_object_unref, NULL);
- g_list_free (monitor->mounts);
+ g_list_free_full (monitor->volumes, g_object_unref);
+ g_list_free_full (monitor->mounts, g_object_unref);
+
+ G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize (object);
+}
+
+static void
+g_unix_volume_monitor_dispose (GObject *object)
+{
+ GUnixVolumeMonitor *monitor;
+
+ monitor = G_UNIX_VOLUME_MONITOR (object);
+
+ g_list_free_full (monitor->volumes, g_object_unref);
+ monitor->volumes = NULL;
+
+ g_list_free_full (monitor->mounts, g_object_unref);
+ monitor->mounts = NULL;
- if (G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize)
- (*G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->finalize) (object);
+ G_OBJECT_CLASS (g_unix_volume_monitor_parent_class)->dispose (object);
}
static GList *
get_mounts (GVolumeMonitor *volume_monitor)
{
GUnixVolumeMonitor *monitor;
- GList *l;
monitor = G_UNIX_VOLUME_MONITOR (volume_monitor);
- l = g_list_copy (monitor->mounts);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
+ return g_list_copy_deep (monitor->mounts, (GCopyFunc) g_object_ref, NULL);
}
static GList *
get_volumes (GVolumeMonitor *volume_monitor)
{
GUnixVolumeMonitor *monitor;
- GList *l;
monitor = G_UNIX_VOLUME_MONITOR (volume_monitor);
- l = g_list_copy (monitor->volumes);
- g_list_foreach (l, (GFunc)g_object_ref, NULL);
-
- return l;
+ return g_list_copy_deep (monitor->volumes, (GCopyFunc) g_object_ref, NULL);
}
static GList *
@@ -145,10 +151,15 @@ get_mount_for_mount_path (const char *mount_path,
GUnixMount *mount;
mount_entry = g_unix_mount_at (mount_path, NULL);
-
+
+ if (!mount_entry)
+ return NULL;
+
/* TODO: Set mountable volume? */
mount = _g_unix_mount_new (NULL, mount_entry, NULL);
+ g_unix_mount_free (mount_entry);
+
return G_MOUNT (mount);
}
@@ -160,6 +171,7 @@ g_unix_volume_monitor_class_init (GUnixVolumeMonitorClass *klass)
GNativeVolumeMonitorClass *native_class = G_NATIVE_VOLUME_MONITOR_CLASS (klass);
gobject_class->finalize = g_unix_volume_monitor_finalize;
+ gobject_class->dispose = g_unix_volume_monitor_dispose;
monitor_class->get_mounts = get_mounts;
monitor_class->get_volumes = get_volumes;
@@ -168,8 +180,6 @@ g_unix_volume_monitor_class_init (GUnixVolumeMonitorClass *klass)
monitor_class->get_mount_for_uuid = get_mount_for_uuid;
monitor_class->is_supported = is_supported;
- native_class->priority = 0;
- native_class->name = "unix";
native_class->get_mount_for_mount_path = get_mount_for_mount_path;
}
@@ -202,22 +212,17 @@ g_unix_volume_monitor_init (GUnixVolumeMonitor *unix_monitor)
unix_monitor->mount_monitor = g_unix_mount_monitor_new ();
g_signal_connect (unix_monitor->mount_monitor,
- "mounts_changed", G_CALLBACK (mounts_changed),
+ "mounts-changed", G_CALLBACK (mounts_changed),
unix_monitor);
g_signal_connect (unix_monitor->mount_monitor,
- "mountpoints_changed", G_CALLBACK (mountpoints_changed),
+ "mountpoints-changed", G_CALLBACK (mountpoints_changed),
unix_monitor);
update_volumes (unix_monitor);
update_mounts (unix_monitor);
}
-/**
- * g_unix_volume_monitor_new:
- *
- * Returns: a new #GVolumeMonitor.
- **/
GVolumeMonitor *
_g_unix_volume_monitor_new (void)
{
@@ -272,13 +277,6 @@ diff_sorted_lists (GList *list1,
}
}
-/**
- * _g_unix_volume_monitor_lookup_volume_for_mount_path:
- * @monitor:
- * @mount_path:
- *
- * Returns: #GUnixVolume for the given @mount_path.
- **/
GUnixVolume *
_g_unix_volume_monitor_lookup_volume_for_mount_path (GUnixVolumeMonitor *monitor,
const char *mount_path)
@@ -339,7 +337,7 @@ update_volumes (GUnixVolumeMonitor *monitor)
{
_g_unix_volume_disconnected (volume);
monitor->volumes = g_list_remove (monitor->volumes, volume);
- g_signal_emit_by_name (monitor, "volume_removed", volume);
+ g_signal_emit_by_name (monitor, "volume-removed", volume);
g_signal_emit_by_name (volume, "removed");
g_object_unref (volume);
}
@@ -353,15 +351,13 @@ update_volumes (GUnixVolumeMonitor *monitor)
if (volume)
{
monitor->volumes = g_list_prepend (monitor->volumes, volume);
- g_signal_emit_by_name (monitor, "volume_added", volume);
+ g_signal_emit_by_name (monitor, "volume-added", volume);
}
}
g_list_free (added);
g_list_free (removed);
- g_list_foreach (monitor->last_mountpoints,
- (GFunc)g_unix_mount_point_free, NULL);
- g_list_free (monitor->last_mountpoints);
+ g_list_free_full (monitor->last_mountpoints, (GDestroyNotify) g_unix_mount_point_free);
monitor->last_mountpoints = new_mountpoints;
}
@@ -392,7 +388,7 @@ update_mounts (GUnixVolumeMonitor *monitor)
{
_g_unix_mount_unmounted (mount);
monitor->mounts = g_list_remove (monitor->mounts, mount);
- g_signal_emit_by_name (monitor, "mount_removed", mount);
+ g_signal_emit_by_name (monitor, "mount-removed", mount);
g_signal_emit_by_name (mount, "unmounted");
g_object_unref (mount);
}
@@ -409,14 +405,12 @@ update_mounts (GUnixVolumeMonitor *monitor)
if (mount)
{
monitor->mounts = g_list_prepend (monitor->mounts, mount);
- g_signal_emit_by_name (monitor, "mount_added", mount);
+ g_signal_emit_by_name (monitor, "mount-added", mount);
}
}
g_list_free (added);
g_list_free (removed);
- g_list_foreach (monitor->last_mounts,
- (GFunc)g_unix_mount_free, NULL);
- g_list_free (monitor->last_mounts);
+ g_list_free_full (monitor->last_mounts, (GDestroyNotify) g_unix_mount_free);
monitor->last_mounts = new_mounts;
}