src/api/: Use intended license header
[libquvi.git] / src / api / script_next.c
blob08ebd830857b51120ca8592a0133f6d4671c0db9
1 /* libquvi
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
17 * 02110-1301 USA
20 /** @file script_next.c */
22 #include "config.h"
24 #include <glib.h>
26 #include "quvi.h"
27 /* -- */
28 #include "_quvi_s.h"
30 /** @cond NODOC */
31 #ifdef _1
32 #define _W "libquvi: %s: %d"
33 #endif
34 /** @endcond */
36 /** @brief Traverse to next media script
37 @return QUVI_TRUE if succeeded, otherwise QUVI_FALSE
38 @ingroup script
40 QuviBoolean quvi_script_next(quvi_t handle, QuviScriptType type)
42 QuviBoolean r;
43 GSList *l;
44 _quvi_t q;
46 q = (_quvi_t) handle;
48 /* If G_DISABLE_CHECKS is defined then the check is not performed. */
49 g_return_val_if_fail(handle != NULL, QUVI_FALSE);
51 switch (type)
53 case QUVI_SCRIPT_TYPE_PLAYLIST:
54 l = q->scripts.playlist;
55 break;
57 default:
58 #ifdef _1
59 g_warning(_W, __func__, (gint) type);
60 #endif
61 case QUVI_SCRIPT_TYPE_MEDIA:
62 l = q->scripts.media;
63 break;
65 case QUVI_SCRIPT_TYPE_SCAN:
66 l = q->scripts.scan;
67 break;
70 r = QUVI_FALSE;
72 switch (type)
74 case QUVI_SCRIPT_TYPE_PLAYLIST:
75 q->scripts.curr.playlist = (q->scripts.curr.playlist != NULL)
76 ? g_slist_next(q->scripts.curr.playlist)
77 : l;
78 r = (q->scripts.curr.playlist != NULL)
79 ? QUVI_TRUE
80 : QUVI_FALSE;
81 break;
83 case QUVI_SCRIPT_TYPE_MEDIA:
84 default:
85 q->scripts.curr.media = (q->scripts.curr.media != NULL)
86 ? g_slist_next(q->scripts.curr.media)
87 : l;
88 r = (q->scripts.curr.media != NULL)
89 ? QUVI_TRUE
90 : QUVI_FALSE;
91 break;
93 case QUVI_SCRIPT_TYPE_SCAN:
94 q->scripts.curr.scan = (q->scripts.curr.scan != NULL)
95 ? g_slist_next(q->scripts.curr.scan)
96 : l;
97 r = (q->scripts.curr.scan != NULL)
98 ? QUVI_TRUE
99 : QUVI_FALSE;
100 break;
103 return (r);
106 #undef _W
108 /* vim: set ts=2 sw=2 tw=72 expandtab: */