2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 /** @file supports.c */
29 #include "_quvi_media_s.h"
30 #include "_quvi_playlist_s.h"
32 #include "misc/match_playlist_script.h"
33 #include "misc/match_media_script.h"
35 static QuviBoolean
_supports_playlist(_quvi_t q
, const gchar
*url
,
36 const QuviSupportsMode mode
)
38 _quvi_playlist_t qp
= NULL
;
40 q
->status
.rc
= m_match_playlist_script(q
, &qp
, url
,
41 (mode
== QUVI_SUPPORTS_MODE_OFFLINE
)
42 ? QM_MATCH_PS_SUPPORTED_OFFLINE
43 : QM_MATCH_PS_SUPPORTED_ONLINE
,
47 quvi_playlist_free((quvi_playlist_t
) qp
);
53 static QuviBoolean
_supports_media(_quvi_t q
, const gchar
*url
,
54 const QuviSupportsMode mode
)
56 _quvi_media_t qm
= NULL
;
58 q
->status
.rc
= m_match_media_script(q
, &qm
, url
,
59 (mode
== QUVI_SUPPORTS_MODE_OFFLINE
)
60 ? QM_MATCH_MS_SUPPORTED_OFFLINE
61 : QM_MATCH_MS_SUPPORTED_ONLINE
,
65 quvi_media_free((quvi_media_t
) qm
);
71 /** @brief Check whether the URL is supported
73 Check if any of the scripts accepts the URL. Both offline and online
74 checking is supported.
77 - Offline check will fail with most @ref sh_url
78 - Online check will resolve @ref sh_url
80 Type may be a combination.
83 quvi_supports(q, URL, QUVI_SUPPORTS_OFFLINE,
84 QUVI_SUPPORTS_TYPE_PLAYLIST | QUVI_SUPPORTS_TYPE_MEDIA);
89 QuviBoolean
quvi_supports(quvi_t handle
, const char *url
,
90 QuviSupportsMode mode
, QuviSupportsType type
)
95 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
96 g_return_val_if_fail(handle
!= NULL
, QUVI_FALSE
);
97 g_return_val_if_fail(url
!= NULL
, QUVI_FALSE
);
100 q
->status
.rc
= QUVI_OK
;
103 if (type
& QUVI_SUPPORTS_TYPE_PLAYLIST
)
104 found
= _supports_playlist(q
, url
, mode
);
106 if (q
->status
.rc
== QUVI_OK
|| q
->status
.rc
== QUVI_ERROR_NO_SUPPORT
)
108 if (type
& QUVI_SUPPORTS_TYPE_MEDIA
)
109 found
= _supports_media(q
, url
, mode
);
114 /* vim: set ts=2 sw=2 tw=72 expandtab: */