~ubuntu-branches/ubuntu/lucid/brasero/lucid-updates

« back to all changes in this revision

Viewing changes to libbrasero-burn/brasero-session.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-06-24 11:22:46 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100624112246-s5ubbf8tafqkir0m
Tags: 2.30.2-0ubuntu1
* New upstream release
  - Lot's of memleak fixes
  - Fixed a runtime warning related to cancelling tracker searches
  - Crash in brasero_data_project_node_removed at
    brasero-data-project.c:1163
  - brasero crashed with SIGSEGV in brasero_data_project_remove_node()
    (LP: #561319)
  - Fix a few runtime warnings with the Cover Editor
  - Text in cover editor does not show up automatically (LP: #469459)
  - Removed use of deprecated flags
  - Use accessor functions instead direct access (use GSEAL GnomeGoal)
  - Fix a bug in the layout on first start (side pane was hidden and
    remained so until the user moved it)
  - Save printer settings for cover printing
  - Write the contents of the GtkTextBuffer displayed line by displayed
    line which should improve the layout
  - "Write to Disc" button sensitivity regression
  - Fix flaw in mask that led libburn plugin not to work (not to be picked
    up actually) in some circumstances
  - Fails to burn ANY audio project
  - Move columns doesn't work (LP: #581759)
  - Brasero does not correctly handle double clicking on column separators
    (LP: #581885)
  - Bad info when burning, high CPU usage and slow burn
  - Change the priority for cdrdao and raised the one of cdda2wav plugin
  - brasero crashed with SIGSEGV in
    brasero_mmc3_get_performa nce_wrt_spd_desc() (LP: #564766)
  - brasero crashed with SIGSEGV in brasero_scsi_command_issue_sync()
    (LP: #444832)
  - Do not check for symlinks on cdda2wav so the plugin can use icedax.
  - Brasero's failure with some file names (LP: #380643)
  - Pressing create audio cd does nothing
  - Empty project not available
  - can't actually save error logs
  - doesn't handle incorrect temp dirs properly
  - Fix multi DND in GtkFileChooser
  - Displays "starting to record" during whole burn process
  - Fix wrong report of speed with both cdrecord and wodim
  - Disk project doesn't save the disk title (LP: #587924)
  - Brasero reports outdated cdrtools on cdrtools-3.00 (LP: #592075)
  - misc bug fixes
  - Updated Translations
* Removed upstream patches:
  - debian/patches/90_git_audio_project_creation.patch,
    debian/patches/91_git_audio_project_creation.patch,
    debian/patches/92_git_audio_cd_recording.patch,
    debian/patches/93_git_new_caps_function_definition.patch
* debian/patches/99_autoconf.patch:
  - refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#endif
34
34
 
35
35
#include <errno.h>
36
 
#include <stdio.h>
37
36
#include <string.h>
38
37
#include <stdlib.h>
39
38
#include <unistd.h>
 
39
#include <fcntl.h>
40
40
 
41
41
#include <glib.h>
42
42
#include <glib-object.h>
43
43
#include <glib/gstdio.h>
44
44
#include <glib/gi18n-lib.h>
45
45
 
 
46
#include <gconf/gconf-client.h>
 
47
 
46
48
#include "brasero-session.h"
47
49
#include "brasero-session-helper.h"
48
50
 
91
93
        gchar *label;
92
94
        guint64 rate;
93
95
 
94
 
        gchar *tmpdir;
95
 
 
96
96
        BraseroBurnFlag flags;
97
97
};
98
98
typedef struct _BraseroSessionSetting BraseroSessionSetting;
99
99
 
100
100
struct _BraseroBurnSessionPrivate {
101
 
        FILE *session;
 
101
        int session;
102
102
        gchar *session_path;
103
103
 
 
104
        gchar *tmpdir;
104
105
        GSList *tmpfiles;
105
106
 
106
107
        BraseroSessionSetting settings [1];
137
138
static guint brasero_burn_session_signals [LAST_SIGNAL] = { 0 };
138
139
static GObjectClass *parent_class = NULL;
139
140
 
 
141
#define  BRASERO_TEMPORARY_DIRECTORY_KEY    "/apps/brasero/drives/tmpdir"
 
142
 
140
143
static void
141
144
brasero_session_settings_clean (BraseroSessionSetting *settings)
142
145
{
146
149
        if (settings->toc)
147
150
                g_free (settings->toc);
148
151
 
149
 
        if (settings->tmpdir)
150
 
                g_free (settings->tmpdir);
151
 
 
152
152
        if (settings->label)
153
153
                g_free (settings->label);
154
154
 
170
170
        dest->image = g_strdup (original->image);
171
171
        dest->toc = g_strdup (original->toc);
172
172
        dest->label = g_strdup (original->label);
173
 
        dest->tmpdir = g_strdup (original->tmpdir);
174
173
}
175
174
 
176
175
static void
1185
1184
                                 const gchar *path)
1186
1185
{
1187
1186
        BraseroBurnSessionPrivate *priv;
 
1187
        GConfClient *client;
1188
1188
 
1189
1189
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), BRASERO_BURN_ERR);
1190
1190
 
1191
1191
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
1192
1192
 
1193
 
        if (priv->settings->tmpdir && path
1194
 
        && !strcmp (priv->settings->tmpdir, path))
 
1193
        if (!g_strcmp0 (priv->tmpdir, path))
1195
1194
                return BRASERO_BURN_OK;
1196
1195
 
1197
 
        if (priv->settings->tmpdir)
1198
 
                g_free (priv->settings->tmpdir);
 
1196
        if (priv->tmpdir)
 
1197
                g_free (priv->tmpdir);
1199
1198
 
1200
1199
        if (path)
1201
 
                priv->settings->tmpdir = g_strdup (path);
 
1200
                priv->tmpdir = g_strdup (path);
1202
1201
        else
1203
 
                priv->settings->tmpdir = NULL;
 
1202
                priv->tmpdir = NULL;
 
1203
 
 
1204
        client = gconf_client_get_default ();
 
1205
        gconf_client_set_string (client, BRASERO_TEMPORARY_DIRECTORY_KEY, priv->tmpdir, NULL);
 
1206
        g_object_unref (client);
1204
1207
 
1205
1208
        return BRASERO_BURN_OK;
1206
1209
}
1222
1225
        g_return_val_if_fail (BRASERO_IS_BURN_SESSION (self), NULL);
1223
1226
 
1224
1227
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
1225
 
        return priv->settings->tmpdir? priv->settings->tmpdir:g_get_tmp_dir ();
 
1228
        return priv->tmpdir? priv->tmpdir:g_get_tmp_dir ();
1226
1229
}
1227
1230
 
1228
1231
/**
1254
1257
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
1255
1258
 
1256
1259
        /* create a working directory in tmp */
1257
 
        tmpdir = priv->settings->tmpdir ?
1258
 
                 priv->settings->tmpdir :
 
1260
        tmpdir = priv->tmpdir ?
 
1261
                 priv->tmpdir :
1259
1262
                 g_get_tmp_dir ();
1260
1263
 
1261
1264
        tmp = g_build_path (G_DIR_SEPARATOR_S,
1272
1275
                if (errsv != EACCES)
1273
1276
                        g_set_error (error, 
1274
1277
                                     BRASERO_BURN_ERROR,
1275
 
                                     BRASERO_BURN_ERROR_GENERAL,
 
1278
                                     BRASERO_BURN_ERROR_TMP_DIRECTORY,
1276
1279
                                     "%s",
1277
1280
                                     g_strerror (errsv));
1278
1281
                else
1279
1282
                        g_set_error (error,
1280
1283
                                     BRASERO_BURN_ERROR,
1281
 
                                     BRASERO_BURN_ERROR_PERMISSION,
 
1284
                                     BRASERO_BURN_ERROR_TMP_DIRECTORY,
1282
1285
                                     _("You do not have the required permission to write at this location"));
1283
1286
                return BRASERO_BURN_ERR;
1284
1287
        }
1326
1329
                return BRASERO_BURN_OK;
1327
1330
 
1328
1331
        /* takes care of the output file */
1329
 
        tmpdir = priv->settings->tmpdir ?
1330
 
                 priv->settings->tmpdir :
 
1332
        tmpdir = priv->tmpdir ?
 
1333
                 priv->tmpdir :
1331
1334
                 g_get_tmp_dir ();
1332
1335
 
1333
1336
        name = g_strconcat (BRASERO_BURN_TMP_FILE_NAME, suffix, NULL);
1347
1350
                if (errsv != EACCES)
1348
1351
                        g_set_error (error, 
1349
1352
                                     BRASERO_BURN_ERROR,
1350
 
                                     BRASERO_BURN_ERROR_GENERAL,
 
1353
                                     BRASERO_BURN_ERROR_TMP_DIRECTORY,
1351
1354
                                     "%s",
1352
1355
                                     g_strerror (errsv));
1353
1356
                else
1354
1357
                        g_set_error (error, 
1355
1358
                                     BRASERO_BURN_ERROR,
1356
 
                                     BRASERO_BURN_ERROR_PERMISSION,
 
1359
                                     BRASERO_BURN_ERROR_TMP_DIRECTORY,
1357
1360
                                     _("You do not have the required permission to write at this location"));
1358
1361
 
1359
1362
                return BRASERO_BURN_ERR;
2131
2134
                           const gchar *format,
2132
2135
                           va_list arg_list)
2133
2136
{
 
2137
        int len;
2134
2138
        gchar *message;
2135
2139
        gchar *offending;
2136
2140
        BraseroBurnSessionPrivate *priv;
2151
2155
        if (!g_utf8_validate (message, -1, (const gchar**) &offending))
2152
2156
                *offending = '\0';
2153
2157
 
2154
 
        if (fwrite (message, strlen (message), 1, priv->session) != 1)
 
2158
        len = strlen (message);
 
2159
        if (write (priv->session, message, len) != len)
2155
2160
                g_warning ("Some log data couldn't be written: %s\n", message);
2156
2161
 
2157
2162
        g_free (message);
2158
2163
 
2159
 
        if (fwrite ("\n", 1, 1, priv->session) != 1)
 
2164
        if (write (priv->session, "\n", 1) != 1)
2160
2165
                g_warning ("Some log data could not be written");
2161
2166
}
2162
2167
 
2177
2182
        va_end (args);
2178
2183
}
2179
2184
 
2180
 
void
2181
 
brasero_burn_session_set_log_path (BraseroBurnSession *self,
2182
 
                                   const gchar *session_path)
2183
 
{
2184
 
        BraseroBurnSessionPrivate *priv;
2185
 
 
2186
 
        g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
2187
 
 
2188
 
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
2189
 
        if (priv->session_path) {
2190
 
                g_free (priv->session_path);
2191
 
                priv->session_path = NULL;
2192
 
        }
2193
 
 
2194
 
        if (session_path)
2195
 
                priv->session_path = g_strdup (session_path);
2196
 
}
2197
 
 
2198
2185
const gchar *
2199
2186
brasero_burn_session_get_log_path (BraseroBurnSession *self)
2200
2187
{
2216
2203
 
2217
2204
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
2218
2205
 
2219
 
        if (!priv->session_path) {
2220
 
                int fd;
2221
 
                const gchar *tmpdir;
2222
 
 
2223
 
                /* takes care of the output file */
2224
 
                tmpdir = priv->settings->tmpdir ?
2225
 
                         priv->settings->tmpdir :
2226
 
                         g_get_tmp_dir ();
2227
 
 
2228
 
                /* This must obey the path of the temporary directory */
 
2206
        /* This must obey the path of the temporary directory if possible */
 
2207
        priv->session_path = g_build_path (G_DIR_SEPARATOR_S,
 
2208
                                           priv->tmpdir,
 
2209
                                           BRASERO_BURN_TMP_FILE_NAME,
 
2210
                                           NULL);
 
2211
        priv->session = g_mkstemp_full (priv->session_path,
 
2212
                                        O_CREAT|O_WRONLY,
 
2213
                                        S_IRWXU);
 
2214
 
 
2215
        if (priv->session < 0) {
 
2216
                g_free (priv->session_path);
 
2217
 
2229
2218
                priv->session_path = g_build_path (G_DIR_SEPARATOR_S,
2230
 
                                                   tmpdir,
 
2219
                                                   g_get_tmp_dir (),
2231
2220
                                                   BRASERO_BURN_TMP_FILE_NAME,
2232
2221
                                                   NULL);
2233
 
 
2234
 
                fd = g_mkstemp (priv->session_path);
2235
 
                priv->session = fdopen (fd, "w");
 
2222
                priv->session = g_mkstemp_full (priv->session_path,
 
2223
                                                O_CREAT|O_WRONLY,
 
2224
                                                S_IRWXU);
2236
2225
        }
2237
 
        else
2238
 
                priv->session = fopen (priv->session_path, "w");
2239
 
 
2240
 
        if (!priv->session) {
 
2226
 
 
2227
        if (priv->session < 0) {
 
2228
                g_free (priv->session_path);
 
2229
                priv->session_path = NULL;
 
2230
 
2241
2231
                g_warning ("Impossible to open a session file\n");
2242
2232
                return FALSE;
2243
2233
        }
2312
2302
        g_return_if_fail (BRASERO_IS_BURN_SESSION (self));
2313
2303
 
2314
2304
        priv = BRASERO_BURN_SESSION_PRIVATE (self);
2315
 
        if (priv->session) {
2316
 
                fclose (priv->session);
2317
 
                priv->session = NULL;
 
2305
        if (priv->session > 0) {
 
2306
                close (priv->session);
 
2307
                priv->session = -1;
 
2308
        }
 
2309
 
 
2310
        if (priv->session_path) {
 
2311
                g_free (priv->session_path);
 
2312
                priv->session_path = NULL;
2318
2313
        }
2319
2314
}
2320
2315
 
2321
 
/**
2322
 
 *
2323
 
 */
2324
 
 
2325
2316
static void
2326
2317
brasero_burn_session_track_list_free (GSList *list)
2327
2318
{
2395
2386
brasero_burn_session_finalize (GObject *object)
2396
2387
{
2397
2388
        BraseroBurnSessionPrivate *priv;
 
2389
        GConfClient *client;
2398
2390
        GSList *iter;
2399
2391
 
2400
2392
        BRASERO_BURN_LOG ("Cleaning session");
2445
2437
                priv->pile_settings = NULL;
2446
2438
        }
2447
2439
 
 
2440
        client = gconf_client_get_default ();
 
2441
        gconf_client_set_string (client, BRASERO_TEMPORARY_DIRECTORY_KEY, priv->tmpdir, NULL);
 
2442
        g_object_unref (client);
 
2443
 
 
2444
        if (priv->tmpdir) {
 
2445
                g_free (priv->tmpdir);
 
2446
                priv->tmpdir = NULL;
 
2447
        }
 
2448
 
2448
2449
        /* clean tmpfiles */
2449
2450
        for (iter = priv->tmpfiles; iter; iter = iter->next) {
2450
2451
                gchar *tmpfile;
2456
2457
        }
2457
2458
        g_slist_free (priv->tmpfiles);
2458
2459
 
2459
 
        if (priv->session) {
2460
 
                fclose (priv->session);
2461
 
                priv->session = NULL;
 
2460
        if (priv->session > 0) {
 
2461
                close (priv->session);
 
2462
                priv->session = -1;
2462
2463
        }
2463
2464
 
2464
2465
        if (priv->session_path) {
2474
2475
 
2475
2476
static void
2476
2477
brasero_burn_session_init (BraseroBurnSession *obj)
2477
 
{ }
 
2478
{
 
2479
        BraseroBurnSessionPrivate *priv;
 
2480
        GConfClient *client;
 
2481
 
 
2482
        priv = BRASERO_BURN_SESSION_PRIVATE (obj);
 
2483
        priv->session = -1;
 
2484
 
 
2485
        client = gconf_client_get_default ();
 
2486
        priv->tmpdir = gconf_client_get_string (client, BRASERO_TEMPORARY_DIRECTORY_KEY, NULL);
 
2487
        g_object_unref (client);
 
2488
}
2478
2489
 
2479
2490
static void
2480
2491
brasero_burn_session_class_init (BraseroBurnSessionClass *klass)