src/api/: Use intended license header
[libquvi.git] / src / api / new.c
blob694fbc15d5e202de9d31128b44d9f1c2259bbcee
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 new.c */
22 #include "config.h"
24 #include <string.h>
25 #include <proxy.h>
26 #include <glib.h>
28 #include "quvi.h"
29 /* -- */
30 #include "_quvi_s.h"
32 static gpointer _quvi_new()
34 _quvi_t q = g_new0(struct _quvi_s, 1);
35 q->opt.scripts.category = QUVI_MEDIA_SCRIPT_PROTOCOL_CATEGORY_ALL;
36 q->status.errmsg = g_string_new(NULL);
37 return (q);
40 /** @cond NODOC */
41 extern QuviError m_scan_scripts(_quvi_t q);
42 extern QuviError l_init(_quvi_t q);
43 extern QuviError c_init(_quvi_t q);
44 /** @endcond */
46 /** @brief Create a new library handle
47 @return New handle, @ref quvi_free it when done using it
48 @note Use @ref quvi_ok for checking if an error occurred
49 @sa @ref getting_started
50 @ingroup lib
52 quvi_t quvi_new()
54 _quvi_t q = _quvi_new();
56 q->status.rc = l_init(q);
58 if (q->status.rc == QUVI_OK)
59 q->status.rc = m_scan_scripts(q);
61 if (q->status.rc == QUVI_OK)
62 q->status.rc = c_init(q);
64 if (q->status.rc == QUVI_OK)
66 q->handle.proxy = px_proxy_factory_new();
67 if (q->handle.proxy == NULL)
68 q->status.rc = QUVI_ERROR_PROXY_INIT;
71 if (q->status.rc == QUVI_OK)
73 const gchar *v = g_getenv("LIBQUVI_VERBOSE_SCRIPTS");
74 if (v != NULL && strlen(v) >0)
75 q->opt.scripts.verbose = TRUE;
78 return (q);
81 /* vim: set ts=2 sw=2 tw=72 expandtab: */