/* dvdrwmediainfo.c * Copyright (C) 2005 Sylvain Cresto * * This file is part of graveman! * * graveman! is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or * (at your option) any later version. * * graveman! is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with program; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * URL: http://www.nongnu.org/graveman/ * */ #include "graveman.h" /* communication avec dvd+rw-mediainfo */ #define DVDRWMEDIAINFO_MEDIA " Mounted Media:" #define DVDRWMEDIAINFO_DVDR "DVD+R" #define DVDRWMEDIAINFO_DVD "DVD" #define DVDRWMEDIAINFO_DVDPRW "DVD+RW" #define DVDRWMEDIAINFO_DVDMRW "DVD-RW" #define DVDRWMEDIAINFO_DISCSTATUS " Disc status:" #define DVDRWMEDIAINFO_BLANK "blank" #define DVDRWMEDIAINFO_COMPLETE "complete" /* retourne les infos sur le media inseré dans le lecteur */ gint get_dvdinfo(gchar *Adevice, GError **Aerror) { gchar Lcommandline[_BUF_SIZE]; gboolean Lstatus; gint Lexit = 0; gchar *Lout = NULL, *Lerr = NULL; gchar **Larrbuf; gint i; gint Llu = _MEDIA_NONE; g_snprintf(Lcommandline, sizeof(Lcommandline)-1, "%s %s", conf_get_string("dvd+rw-mediainfo"), Adevice); Lstatus = g_spawn_command_line_sync(Lcommandline, &Lout, &Lerr, &Lexit, Aerror); if (Lstatus == FALSE || Lexit != 0) { g_free(Lout); g_free(Lerr); return FALSE; } Larrbuf = g_strsplit(Lout, "\n", 0); for (i=0; Larrbuf[i]; i++) { if (!*Larrbuf[i]) continue; if (!strncmp(Larrbuf[i], DVDRWMEDIAINFO_MEDIA, strlen(DVDRWMEDIAINFO_MEDIA)-1)) { if (strstr(Larrbuf[i], DVDRWMEDIAINFO_DVDPRW)) { Llu |= _MEDIA_DVDPRW; } else if (strstr(Larrbuf[i], DVDRWMEDIAINFO_DVDMRW)) { Llu |= _MEDIA_DVDMRW; } else if (strstr(Larrbuf[i], DVDRWMEDIAINFO_DVDR)) { Llu |= _MEDIA_DVDR; } else if (strstr(Larrbuf[i], DVDRWMEDIAINFO_DVD)) { Llu |= _MEDIA_DVD; } } else if (!strncmp(Larrbuf[i], DVDRWMEDIAINFO_DISCSTATUS, strlen(DVDRWMEDIAINFO_DISCSTATUS)-1)) { if (strstr(Larrbuf[i], DVDRWMEDIAINFO_BLANK)) { Llu |= _MEDIA_BLANK; } } } g_strfreev(Larrbuf); return Llu; } /* * vim:et:ts=8:sts=2:sw=2 */