4 * This file is part of maevies
5 * Copyright (C) 2010 Simón Pena <spenap@gmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
19 #include "mvs-minfo-provider.h"
21 #define TMDB_API_KEY "249e1a42df9bee09fac5e92d3a51396b"
22 #define TMDB_LANGUAGE "en"
23 #define TMDB_FORMAT "xml"
24 #define TMDB_METHOD "Movie.search"
25 #define TMDB_BASE_URL "http://api.themoviedb.org/2.1/%s/%s/%s/%s/%s"
27 G_DEFINE_TYPE (MvsMInfoProvider, mvs_minfo_provider, G_TYPE_OBJECT)
34 #define GET_PRIVATE(o) \
35 (G_TYPE_INSTANCE_GET_PRIVATE ((o), MVS_TYPE_MINFO_PROVIDER, MvsMInfoProviderPrivate))
37 struct _MvsMInfoProviderPrivate {
42 mvs_minfo_provider_get_property (GObject *object, guint property_id,
43 GValue *value, GParamSpec *pspec)
45 MvsMInfoProvider *self = MVS_MINFO_PROVIDER (object);
47 switch (property_id) {
49 g_value_set_string (value, self->priv->format);
52 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
57 mvs_minfo_provider_set_property (GObject *object, guint property_id,
58 const GValue *value, GParamSpec *pspec)
60 MvsMInfoProvider *self = MVS_MINFO_PROVIDER (object);
62 switch (property_id) {
64 mvs_minfo_provider_set_format (self,
65 g_value_get_string (value));
68 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
73 mvs_minfo_provider_finalize (GObject *object)
75 MvsMInfoProvider *self = MVS_MINFO_PROVIDER (object);
77 g_free (self->priv->format);
79 G_OBJECT_CLASS (mvs_minfo_provider_parent_class)->finalize (object);
83 mvs_minfo_provider_class_init (MvsMInfoProviderClass *klass)
85 GObjectClass *object_class = G_OBJECT_CLASS (klass);
87 g_type_class_add_private (klass, sizeof (MvsMInfoProviderPrivate));
89 object_class->get_property = mvs_minfo_provider_get_property;
90 object_class->set_property = mvs_minfo_provider_set_property;
91 object_class->finalize = mvs_minfo_provider_finalize;
93 g_object_class_install_property
94 (object_class, PROP_FORMAT,
95 g_param_spec_string ("format", "The format", "The format",
97 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
102 mvs_minfo_provider_init (MvsMInfoProvider *self)
104 self->priv = GET_PRIVATE (self);
105 self->priv->format = NULL;
109 mvs_minfo_provider_new (void)
111 return g_object_new (MVS_TYPE_MINFO_PROVIDER, NULL);
115 mvs_minfo_provider_query (MvsMInfoProvider *self,
122 mvs_minfo_provider_set_format (MvsMInfoProvider *self,
125 g_return_val_if_fail (MVS_IS_MINFO_PROVIDER (self), FALSE);
127 g_free (self->priv->format);
129 self->priv->format = g_strdup (format);