~ubuntu-branches/ubuntu/wily/totem-pl-parser/wily

« back to all changes in this revision

Viewing changes to plparse/totem-pl-parser.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-03-09 13:39:14 UTC
  • mfrom: (1.4.16) (1.5.12 sid)
  • Revision ID: package-import@ubuntu.com-20120309133914-e6iab9fcyg8cmw33
Tags: 3.2.0-1
* New upstream release.
* debian/patches/01-libquvi-0.4.patch: Removed, merged upstream.
* debian/control.in: Bump (Build-)Depends on libglib2.0-dev to (>= 2.31.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
#include "totem-pl-parser-misc.h"
155
155
#include "totem-pl-parser-private.h"
156
156
#include "totem-pl-parser-videosite.h"
 
157
#include "totem-pl-parser-amz.h"
157
158
 
158
159
#define READ_CHUNK_SIZE 8192
159
160
#define RECURSE_LEVEL_MAX 4
167
168
#endif
168
169
 
169
170
typedef struct {
170
 
        char *mimetype;
 
171
        const char *mimetype;
171
172
#ifndef TOTEM_PL_PARSER_MINI
172
173
        PlaylistCallback func;
173
174
#endif
190
191
/* These ones need a special treatment, mostly parser formats */
191
192
static PlaylistTypes special_types[] = {
192
193
        PLAYLIST_TYPE ("audio/x-mpegurl", totem_pl_parser_add_m3u, NULL, FALSE),
 
194
        PLAYLIST_TYPE ("video/vnd.mpegurl", totem_pl_parser_add_m4u, NULL, FALSE),
193
195
        PLAYLIST_TYPE ("audio/playlist", totem_pl_parser_add_m3u, NULL, FALSE),
194
196
        PLAYLIST_TYPE ("audio/x-scpls", totem_pl_parser_add_pls, NULL, FALSE),
195
197
        PLAYLIST_TYPE ("application/x-smil", totem_pl_parser_add_smil, NULL, FALSE),
205
207
        PLAYLIST_TYPE ("application/atom+xml", totem_pl_parser_add_atom, NULL, FALSE),
206
208
        PLAYLIST_TYPE ("application/rss+xml", totem_pl_parser_add_rss, totem_pl_parser_is_rss, FALSE),
207
209
        PLAYLIST_TYPE ("text/x-opml+xml", totem_pl_parser_add_opml, NULL, FALSE),
 
210
        PLAYLIST_TYPE ("audio/x-amzxml", totem_pl_parser_add_amz, NULL, FALSE),
208
211
#ifndef TOTEM_PL_PARSER_MINI
209
212
        PLAYLIST_TYPE ("application/x-desktop", totem_pl_parser_add_desktop, NULL, TRUE),
210
213
        PLAYLIST_TYPE ("application/x-gnome-app-info", totem_pl_parser_add_desktop, NULL, TRUE),
255
258
struct TotemPlParserPrivate {
256
259
        GList *ignore_schemes;
257
260
        GList *ignore_mimetypes;
258
 
        GMutex *ignore_mutex;
 
261
        GMutex ignore_mutex;
259
262
        GThread *main_thread; /* see CALL_ASYNC() in *-private.h */
260
263
 
261
264
        guint recurse : 1;
288
291
static void totem_pl_parser_init       (TotemPlParser *parser);
289
292
static void totem_pl_parser_finalize   (GObject *object);
290
293
 
291
 
static void totem_pl_parser_init       (TotemPlParser      *self);
292
 
static void totem_pl_parser_class_init (TotemPlParserClass *klass);
293
294
static gpointer totem_pl_parser_parent_class = NULL;
294
295
 
295
296
#define TOTEM_PL_PARSER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOTEM_TYPE_PL_PARSER, TotemPlParserPrivate))
324
325
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
325
326
 
326
327
        totem_pl_parser_parent_class = g_type_class_peek_parent (klass);
327
 
        if (!g_thread_supported ())
328
 
                g_thread_init (NULL);
329
328
 
330
329
        g_type_class_add_private (klass, sizeof (TotemPlParserPrivate));
331
330
 
395
394
         * TotemPlParser::entry-parsed:
396
395
         * @parser: the object which received the signal
397
396
         * @uri: the URI of the entry parsed
398
 
         * @metadata: a #GHashTable of metadata relating to the entry added
 
397
         * @metadata: (type TotemPlParser.ParserMetadata): a #GHashTable of metadata relating to the entry added
399
398
         *
400
399
         * The ::entry-parsed signal is emitted when a new entry is parsed.
401
400
         */
405
404
                              G_SIGNAL_RUN_LAST,
406
405
                              G_STRUCT_OFFSET (TotemPlParserClass, entry_parsed),
407
406
                              NULL, NULL,
408
 
                              totemplparser_marshal_VOID__STRING_BOXED,
 
407
                              _totemplparser_marshal_VOID__STRING_BOXED,
409
408
                              G_TYPE_NONE, 2, G_TYPE_STRING, TOTEM_TYPE_PL_PARSER_METADATA);
410
409
        /**
411
410
         * TotemPlParser::playlist-started:
412
411
         * @parser: the object which received the signal
413
412
         * @uri: the URI of the new playlist started
414
 
         * @metadata: a #GHashTable of metadata relating to the playlist that
 
413
         * @metadata: (type TotemPlParser.ParserMetadata): a #GHashTable of metadata relating to the playlist that
415
414
         * started.
416
415
         *
417
416
         * The ::playlist-started signal is emitted when a playlist parsing has
425
424
                              G_SIGNAL_RUN_LAST,
426
425
                              G_STRUCT_OFFSET (TotemPlParserClass, playlist_started),
427
426
                              NULL, NULL,
428
 
                              totemplparser_marshal_VOID__STRING_BOXED,
 
427
                              _totemplparser_marshal_VOID__STRING_BOXED,
429
428
                              G_TYPE_NONE, 2, G_TYPE_STRING, TOTEM_TYPE_PL_PARSER_METADATA);
430
429
        /**
431
430
         * TotemPlParser::playlist-ended:
1058
1057
                resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, new_relative_uri);
1059
1058
                g_object_unref (base_parent_gfile);
1060
1059
                if (!resolved_gfile) {
1061
 
                        char *base_uri;
1062
1060
                        base_uri = g_file_get_uri (base_gfile);
1063
1061
                        g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
1064
1062
                        g_free (base_uri);
1080
1078
                resolved_gfile = g_file_resolve_relative_path (base_parent_gfile, relative_uri);
1081
1079
                g_object_unref (base_parent_gfile);
1082
1080
                if (!resolved_gfile) {
1083
 
                        char *base_uri;
1084
1081
                        base_uri = g_file_get_uri (base_gfile);
1085
1082
                        g_warning ("Failed to resolve relative URI '%s' against base '%s'\n", relative_uri, base_uri);
1086
1083
                        g_free (base_uri);
1273
1270
totem_pl_parser_init (TotemPlParser *parser)
1274
1271
{
1275
1272
        parser->priv = G_TYPE_INSTANCE_GET_PRIVATE (parser, TOTEM_TYPE_PL_PARSER, TotemPlParserPrivate);
1276
 
        parser->priv->ignore_mutex = g_mutex_new ();
1277
1273
        parser->priv->main_thread = g_thread_self ();
1278
1274
}
1279
1275
 
1291
1287
        g_list_foreach (priv->ignore_mimetypes, (GFunc) g_free, NULL);
1292
1288
        g_list_free (priv->ignore_mimetypes);
1293
1289
 
1294
 
        g_mutex_free (priv->ignore_mutex);
 
1290
        g_mutex_clear (&priv->ignore_mutex);
1295
1291
 
1296
1292
        G_OBJECT_CLASS (totem_pl_parser_parent_class)->finalize (object);
1297
1293
}
1522
1518
{
1523
1519
        GList *l;
1524
1520
 
1525
 
        g_mutex_lock (parser->priv->ignore_mutex);
 
1521
        g_mutex_lock (&parser->priv->ignore_mutex);
1526
1522
 
1527
1523
        if (parser->priv->ignore_schemes == NULL) {
1528
 
                g_mutex_unlock (parser->priv->ignore_mutex);
 
1524
                g_mutex_unlock (&parser->priv->ignore_mutex);
1529
1525
                return FALSE;
1530
1526
        }
1531
1527
 
1532
1528
        for (l = parser->priv->ignore_schemes; l != NULL; l = l->next) {
1533
1529
                const char *scheme = l->data;
1534
1530
                if (g_file_has_uri_scheme (uri, scheme) != FALSE) {
1535
 
                        g_mutex_unlock (parser->priv->ignore_mutex);
 
1531
                        g_mutex_unlock (&parser->priv->ignore_mutex);
1536
1532
                        return TRUE;
1537
1533
                }
1538
1534
        }
1539
1535
 
1540
 
        g_mutex_unlock (parser->priv->ignore_mutex);
 
1536
        g_mutex_unlock (&parser->priv->ignore_mutex);
1541
1537
 
1542
1538
        return FALSE;
1543
1539
}
1548
1544
{
1549
1545
        GList *l;
1550
1546
 
1551
 
        g_mutex_lock (parser->priv->ignore_mutex);
 
1547
        g_mutex_lock (&parser->priv->ignore_mutex);
1552
1548
 
1553
1549
        if (parser->priv->ignore_mimetypes == NULL) {
1554
 
                g_mutex_unlock (parser->priv->ignore_mutex);
 
1550
                g_mutex_unlock (&parser->priv->ignore_mutex);
1555
1551
                return FALSE;
1556
1552
        }
1557
1553
 
1559
1555
        {
1560
1556
                const char *item = l->data;
1561
1557
                if (strcmp (mimetype, item) == 0) {
1562
 
                        g_mutex_unlock (parser->priv->ignore_mutex);
 
1558
                        g_mutex_unlock (&parser->priv->ignore_mutex);
1563
1559
                        return TRUE;
1564
1560
                }
1565
1561
        }
1566
1562
 
1567
 
        g_mutex_unlock (parser->priv->ignore_mutex);
 
1563
        g_mutex_unlock (&parser->priv->ignore_mutex);
1568
1564
 
1569
1565
        return FALSE;
1570
1566
}
1911
1907
                                        DEBUG(file, g_print ("URI '%s' dual type has type '%s' from data\n", uri, mimetype));
1912
1908
                                }
1913
1909
                                /* If it's _still_ a text/plain, we don't want it */
1914
 
                                if (mimetype != NULL && g_content_type_is_a (mimetype, "text/plain")) {
 
1910
                                if (mimetype != NULL &&
 
1911
                                    g_content_type_is_a (mimetype, "text/plain") &&
 
1912
                                    g_content_type_is_a (mimetype, "application/xml") == FALSE) {
 
1913
                                        DEBUG(file, g_print ("Ignoring URI '%s' dual type because '%s' is a text/plain\n", uri, mimetype));
1915
1914
                                        ret = TOTEM_PL_PARSER_RESULT_IGNORED;
1916
1915
                                        g_free (mimetype);
1917
1916
                                        mimetype = NULL;
2187
2186
 
2188
2187
        g_return_if_fail (TOTEM_IS_PL_PARSER (parser));
2189
2188
 
2190
 
        g_mutex_lock (parser->priv->ignore_mutex);
 
2189
        g_mutex_lock (&parser->priv->ignore_mutex);
2191
2190
 
2192
2191
        s = g_strdup (scheme);
2193
2192
        if (s[strlen (s) - 1] == ':')
2195
2194
        parser->priv->ignore_schemes = g_list_prepend
2196
2195
                (parser->priv->ignore_schemes, s);
2197
2196
 
2198
 
        g_mutex_unlock (parser->priv->ignore_mutex);
 
2197
        g_mutex_unlock (&parser->priv->ignore_mutex);
2199
2198
}
2200
2199
 
2201
2200
/**
2212
2211
{
2213
2212
        g_return_if_fail (TOTEM_IS_PL_PARSER (parser));
2214
2213
 
2215
 
        g_mutex_lock (parser->priv->ignore_mutex);
 
2214
        g_mutex_lock (&parser->priv->ignore_mutex);
2216
2215
 
2217
2216
        parser->priv->ignore_mimetypes = g_list_prepend
2218
2217
                (parser->priv->ignore_mimetypes, g_strdup (mimetype));
2219
2218
 
2220
 
        g_mutex_unlock (parser->priv->ignore_mutex);
 
2219
        g_mutex_unlock (&parser->priv->ignore_mutex);
2221
2220
}
2222
2221
 
2223
2222
/**