1
/***************************************************************************
4
* mer aoû 9 22:22:16 2006
5
* Copyright 2006 Rouquier Philippe
6
* brasero-app@wanadoo.fr
7
***************************************************************************/
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Library General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29
#include <glib-object.h>
30
#include <glib/gstdio.h>
32
#include "burn-basics.h"
33
#include "burn-session.h"
35
static void brasero_burn_session_class_init (BraseroBurnSessionClass *klass);
36
static void brasero_burn_session_init (BraseroBurnSession *sp);
37
static void brasero_burn_session_finalize (GObject *object);
39
struct _BraseroBurnSessionPrivate {
44
static GObjectClass *parent_class = NULL;
47
brasero_burn_session_get_type ()
49
static GType type = 0;
52
static const GTypeInfo our_info = {
53
sizeof (BraseroBurnSessionClass),
56
(GClassInitFunc)brasero_burn_session_class_init,
59
sizeof (BraseroBurnSession),
61
(GInstanceInitFunc)brasero_burn_session_init,
64
type = g_type_register_static (G_TYPE_OBJECT,
74
brasero_burn_session_class_init (BraseroBurnSessionClass *klass)
76
GObjectClass *object_class = G_OBJECT_CLASS (klass);
78
parent_class = g_type_class_peek_parent(klass);
79
object_class->finalize = brasero_burn_session_finalize;
83
brasero_burn_session_init (BraseroBurnSession *obj)
85
obj->priv = g_new0 (BraseroBurnSessionPrivate, 1);
89
brasero_burn_session_finalize (GObject *object)
91
BraseroBurnSession *cobj;
93
cobj = BRASERO_BURN_SESSION (object);
95
if (cobj->priv->session) {
96
fclose (cobj->priv->session);
97
cobj->priv->session = NULL;
100
if (cobj->priv->session_path) {
101
g_remove (cobj->priv->session_path);
102
g_free (cobj->priv->session_path);
103
cobj->priv->session_path = NULL;
107
G_OBJECT_CLASS (parent_class)->finalize (object);
111
brasero_burn_session_new ()
113
BraseroBurnSession *obj;
115
obj = BRASERO_BURN_SESSION (g_object_new (BRASERO_TYPE_BURN_SESSION, NULL));
121
brasero_burn_session_logv (BraseroBurnSession *session,
131
if (!session->priv->session)
134
message = g_strdup_vprintf (format, arg_list);
136
/* we also need to validate the messages to be in UTF-8 */
137
if (!g_utf8_validate (message, -1, (const gchar**) &offending))
140
if (fwrite (message, strlen (message), 1, session->priv->session) != 1)
141
g_warning ("Some log data couldn't be written: %s\n", message);
145
fwrite ("\n", 1, 1, session->priv->session);
149
brasero_burn_session_set_log_path (BraseroBurnSession *session,
150
const gchar *session_path)
152
if (session->priv->session_path) {
153
g_free (session->priv->session_path);
154
session->priv->session_path = NULL;
158
session->priv->session_path = g_strdup (session_path);
162
brasero_burn_session_get_log_path (BraseroBurnSession *session)
164
return session->priv->session_path;
168
brasero_burn_session_start (BraseroBurnSession *session)
170
if (!session->priv->session_path) {
173
session->priv->session_path = g_build_path (G_DIR_SEPARATOR_S,
175
BRASERO_BURN_TMP_FILE_NAME,
178
fd = g_mkstemp (session->priv->session_path);
179
session->priv->session = fdopen (fd, "w");
182
session->priv->session = fopen (session->priv->session_path, "w");
184
if (!session->priv->session) {
185
g_warning ("Impossible to open a session file\n");
193
brasero_burn_session_stop (BraseroBurnSession *session)
195
if (session->priv->session) {
196
fclose (session->priv->session);
197
session->priv->session = NULL;