Merge branch 'master' into 'master'
[brasero.git] / libbrasero-media / scsi-error.c
blob335854489909af2cdf5abf9a69af5577c2b75127
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3 * Libbrasero-media
4 * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
6 * Libbrasero-media is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * The Libbrasero-media authors hereby grant permission for non-GPL compatible
12 * GStreamer plugins to be used and distributed together with GStreamer
13 * and Libbrasero-media. This permission is above and beyond the permissions granted
14 * by the GPL license by which Libbrasero-media is covered. If you modify this code
15 * you may extend this exception to your version of the code, but you are not
16 * obligated to do so. If you do not wish to do so, delete this exception
17 * statement from your version.
19 * Libbrasero-media is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to:
26 * The Free Software Foundation, Inc.,
27 * 51 Franklin Street, Fifth Floor
28 * Boston, MA 02110-1301, USA.
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
35 #include <errno.h>
37 #include <glib.h>
38 #include <glib/gi18n-lib.h>
40 #include "brasero-media.h"
41 #include "scsi-error.h"
43 static const gchar *error_string [] = { N_("Unknown error"),
44 N_("Size mismatch"),
45 N_("Type mismatch"),
46 N_("Bad argument"),
47 N_("The drive is busy"),
48 N_("Outrange address"),
49 N_("Invalid address"),
50 N_("Invalid command"),
51 N_("Invalid parameter in command"),
52 N_("Invalid field in command"),
53 N_("The device timed out"),
54 N_("Key not established"),
55 N_("Invalid track mode"),
56 NULL }; /* errno */
58 const gchar *
59 brasero_scsi_strerror (BraseroScsiErrCode code)
61 if (code > BRASERO_SCSI_ERROR_LAST || code < 0)
62 return NULL;
64 /* FIXME: this is for errors that don't have any message yet */
65 if (code > BRASERO_SCSI_ERRNO)
66 return NULL;
68 if (code == BRASERO_SCSI_ERRNO)
69 return g_strerror (errno);
71 return _(error_string [code]);
74 void
75 brasero_scsi_set_error (GError **error, BraseroScsiErrCode code)
77 g_set_error (error,
78 BRASERO_MEDIA_ERROR,
79 BRASERO_MEDIA_ERROR_GENERAL,
80 "%s",
81 brasero_scsi_strerror (code));