sound-juicer r2283 - in trunk: . libjuicer
- From: hadess svn gnome org
- To: svn-commits-list gnome org
- Subject: sound-juicer r2283 - in trunk: . libjuicer
- Date: Wed, 3 Sep 2008 23:53:10 +0000 (UTC)
Author: hadess
Date: Wed Sep 3 23:53:10 2008
New Revision: 2283
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2283&view=rev
Log:
2008-09-04 Bastien Nocera <hadess hadess net>
* libjuicer/sj-metadata-musicbrainz.c (mb_list_albums):
* libjuicer/sj-metadata-musicbrainz3.c (mb_list_albums):
* libjuicer/sj-metadata-musicbrainz3.h:
* libjuicer/sj-metadata.c (sj_metadata_helper_check_media):
* libjuicer/sj-metadata.h: Move the nautilus-burn assisted
media type checking to a shared location
Modified:
trunk/ChangeLog
trunk/libjuicer/sj-metadata-musicbrainz.c
trunk/libjuicer/sj-metadata-musicbrainz3.c
trunk/libjuicer/sj-metadata-musicbrainz3.h
trunk/libjuicer/sj-metadata.c
trunk/libjuicer/sj-metadata.h
Modified: trunk/libjuicer/sj-metadata-musicbrainz.c
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz.c (original)
+++ trunk/libjuicer/sj-metadata-musicbrainz.c Wed Sep 3 23:53:10 2008
@@ -32,9 +32,7 @@
#include <gconf/gconf-client.h>
#include <musicbrainz/queries.h>
#include <musicbrainz/mb_c.h>
-#include <nautilus-burn.h>
#include <stdlib.h>
-#include <unistd.h>
#include "sj-metadata-musicbrainz.h"
#include "sj-structures.h"
@@ -281,40 +279,13 @@
GList *al, *tl;
char data[256];
int num_albums, i, j;
- NautilusBurnMediaType type;
- NautilusBurnDriveMonitor *monitor;
- NautilusBurnDrive *drive;
g_return_val_if_fail (metadata != NULL, NULL);
g_return_val_if_fail (SJ_IS_METADATA_MUSICBRAINZ (metadata), NULL);
priv = SJ_METADATA_MUSICBRAINZ (metadata)->priv;
g_return_val_if_fail (priv->cdrom != NULL, NULL);
- if (! nautilus_burn_initialized ()) {
- nautilus_burn_init ();
- }
- monitor = nautilus_burn_get_drive_monitor ();
- drive = nautilus_burn_drive_monitor_get_drive_for_device (monitor, priv->cdrom);
- if (drive == NULL) {
- return NULL;
- }
- type = nautilus_burn_drive_get_media_type (drive);
- nautilus_burn_drive_unref (drive);
-
- if (type == NAUTILUS_BURN_MEDIA_TYPE_ERROR) {
- char *msg;
- SjError err;
-
- if (access (priv->cdrom, W_OK) == 0) {
- msg = g_strdup_printf (_("Device '%s' does not contain any media"), priv->cdrom);
- err = SJ_ERROR_CD_NO_MEDIA;
- } else {
- msg = g_strdup_printf (_("Device '%s' could not be opened. Check the access permissions on the device."), priv->cdrom);
- err = SJ_ERROR_CD_PERMISSION_ERROR;
- }
- g_set_error (error, SJ_ERROR, err, _("Cannot read CD: %s"), msg);
- g_free (msg);
-
+ if (sj_metadata_helper_check_media (priv->cdrom, error) == FALSE) {
priv->albums = NULL;
return NULL;
}
Modified: trunk/libjuicer/sj-metadata-musicbrainz3.c
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz3.c (original)
+++ trunk/libjuicer/sj-metadata-musicbrainz3.c Wed Sep 3 23:53:10 2008
@@ -1,6 +1,7 @@
/*
* sj-metadata-musicbrainz3.c
* Copyright (C) 2008 Ross Burton <ross burtonini com>
+ * Copyright (C) 2008 Bastien Nocera <hadess hadess net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -24,12 +25,9 @@
#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
#include <glib.h>
#include <glib-object.h>
-#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
-#include <nautilus-burn.h>
#include <musicbrainz3/mb_c.h>
#include "sj-metadata-musicbrainz3.h"
@@ -223,39 +221,11 @@
char *id = NULL;
char buffer[512];
int i;
- NautilusBurnMediaType type;
- NautilusBurnDriveMonitor *monitor;
- NautilusBurnDrive *drive;
-
g_return_val_if_fail (SJ_IS_METADATA_MUSICBRAINZ3 (metadata), FALSE);
priv = GET_PRIVATE (metadata);
- if (! nautilus_burn_initialized ()) {
- nautilus_burn_init ();
- }
- monitor = nautilus_burn_get_drive_monitor ();
- drive = nautilus_burn_drive_monitor_get_drive_for_device (monitor, priv->cdrom);
- if (drive == NULL) {
- return NULL;
- }
- type = nautilus_burn_drive_get_media_type (drive);
- nautilus_burn_drive_unref (drive);
-
- if (type == NAUTILUS_BURN_MEDIA_TYPE_ERROR) {
- char *msg;
- SjError err;
-
- if (access (priv->cdrom, W_OK) == 0) {
- msg = g_strdup_printf (_("Device '%s' does not contain any media"), priv->cdrom);
- err = SJ_ERROR_CD_NO_MEDIA;
- } else {
- msg = g_strdup_printf (_("Device '%s' could not be opened. Check the access permissions on the device."), priv->cdrom);
- err = SJ_ERROR_CD_PERMISSION_ERROR;
- }
- g_set_error (error, SJ_ERROR, err, _("Cannot read CD: %s"), msg);
- g_free (msg);
-
+ if (sj_metadata_helper_check_media (priv->cdrom, error) == FALSE) {
priv->albums = NULL;
return NULL;
}
Modified: trunk/libjuicer/sj-metadata-musicbrainz3.h
==============================================================================
--- trunk/libjuicer/sj-metadata-musicbrainz3.h (original)
+++ trunk/libjuicer/sj-metadata-musicbrainz3.h Wed Sep 3 23:53:10 2008
@@ -1,6 +1,7 @@
/*
* sj-metadata-musicbrainz3.h
* Copyright (C) 2008 Ross Burton <ross burtonini com>
+ * Copyright (C) 2008 Bastien Nocera <hadess hadess net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Modified: trunk/libjuicer/sj-metadata.c
==============================================================================
--- trunk/libjuicer/sj-metadata.c (original)
+++ trunk/libjuicer/sj-metadata.c Wed Sep 3 23:53:10 2008
@@ -21,8 +21,16 @@
#include <glib-object.h>
#include <stdlib.h>
#include <stdio.h>
+
+#ifndef USE_TOTEM_PL_PARSER
+#include <unistd.h>
+#include <glib/gi18n.h>
+#include <nautilus-burn.h>
+#endif /* USE_TOTEM_PL_PARSER */
+
#include "sj-metadata.h"
#include "sj-metadata-marshal.h"
+#include "sj-error.h"
enum {
METADATA,
@@ -149,3 +157,41 @@
return NULL;
}
+gboolean
+sj_metadata_helper_check_media (const char *cdrom, GError **error)
+{
+ NautilusBurnMediaType type;
+ NautilusBurnDriveMonitor *monitor;
+ NautilusBurnDrive *drive;
+
+ if (! nautilus_burn_initialized ()) {
+ nautilus_burn_init ();
+ }
+ monitor = nautilus_burn_get_drive_monitor ();
+ drive = nautilus_burn_drive_monitor_get_drive_for_device (monitor, cdrom);
+ if (drive == NULL) {
+ return FALSE;
+ }
+ type = nautilus_burn_drive_get_media_type (drive);
+ nautilus_burn_drive_unref (drive);
+
+ if (type == NAUTILUS_BURN_MEDIA_TYPE_ERROR) {
+ char *msg;
+ SjError err;
+
+ if (access (cdrom, W_OK) == 0) {
+ msg = g_strdup_printf (_("Device '%s' does not contain any media"), cdrom);
+ err = SJ_ERROR_CD_NO_MEDIA;
+ } else {
+ msg = g_strdup_printf (_("Device '%s' could not be opened. Check the access permissions on the device."), cdrom);
+ err = SJ_ERROR_CD_PERMISSION_ERROR;
+ }
+ g_set_error (error, SJ_ERROR, err, _("Cannot read CD: %s"), msg);
+ g_free (msg);
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
Modified: trunk/libjuicer/sj-metadata.h
==============================================================================
--- trunk/libjuicer/sj-metadata.h (original)
+++ trunk/libjuicer/sj-metadata.h Wed Sep 3 23:53:10 2008
@@ -52,6 +52,7 @@
char * sj_metadata_helper_scan_disc_number (const char *album_title, int *disc_number);
GDate * sj_metadata_helper_scan_date (const char *date);
+gboolean sj_metadata_helper_check_media (const char *cdrom, GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]