1 /* libquvi
2 * Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
3 *
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
5 *
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
21 #include "config.h"
22
23 #include <glib.h>
24
25 #include "quvi.h"
26 /* -- */
27 #include "_quvi_s.h"
28 #include "_quvi_playlist_s.h"
29 /* -- */
30 #include "misc/playlist.h"
31 #include "misc/slst.h"
32 #include "misc/url.h"
33
m_playlist_new(_quvi_t q,const gchar * url)34 gpointer m_playlist_new(_quvi_t q, const gchar *url)
35 {
36 _quvi_playlist_t qp;
37 gchar *u;
38
39 qp = g_new0(struct _quvi_playlist_s, 1);
40
41 qp->url.thumbnail = g_string_new(NULL);
42 qp->id.playlist = g_string_new(NULL);
43
44 /*
45 * Store the input URL in the unescaped form which is what the `ident'
46 * functions of the scripts expect when the support check is run
47 * offline.
48 */
49 u = m_url_unescaped_form(url);
50 qp->url.input = g_string_new(u);
51 g_free(u);
52
53 qp->title = g_string_new(NULL);
54 qp->handle.quvi = q;
55
56 return (qp);
57 }
58
m_playlist_media_free(_quvi_playlist_media_t qpm)59 void m_playlist_media_free(_quvi_playlist_media_t qpm)
60 {
61 if (qpm == NULL)
62 return;
63
64 g_string_free(qpm->title, TRUE);
65 qpm->title = NULL;
66
67 g_string_free(qpm->url, TRUE);
68 qpm->url = NULL;
69
70 g_free(qpm);
71 qpm = NULL;
72 }
73
_playlist_media_free(gpointer p,gpointer userdata)74 static void _playlist_media_free(gpointer p, gpointer userdata)
75 {
76 m_playlist_media_free(p);
77 }
78
m_playlist_free(_quvi_playlist_t qp)79 void m_playlist_free(_quvi_playlist_t qp)
80 {
81 if (qp == NULL)
82 return;
83
84 m_slist_free_full(qp->media, _playlist_media_free);
85 qp->media = NULL;
86
87 /* URL */
88
89 g_string_free(qp->url.thumbnail, TRUE);
90 qp->url.thumbnail = NULL;
91
92 g_string_free(qp->url.input, TRUE);
93 qp->url.input = NULL;
94
95 /* ID */
96
97 g_string_free(qp->id.playlist, TRUE);
98 qp->id.playlist = NULL;
99
100 /* Other */
101
102 g_string_free(qp->title, TRUE);
103 qp->title = NULL;
104
105 g_free(qp);
106 qp = NULL;
107 }
108
109 /* vim: set ts=2 sw=2 tw=72 expandtab: */
110