libvisual  0.5.0
lv_songinfo_c.cpp
1 /* Libvisual - The audio visualisation framework.
2  *
3  * Copyright (C) 2012 Libvisual team
4  *
5  * Authors: Chong Kai Xiong <kaixiong@codeleft.sg>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
22 #include "config.h"
23 #include "lv_songinfo.h"
24 #include "lv_common.h"
25 #include "lv_util.hpp"
26 
27 extern "C" {
28 
29  VisSongInfo *visual_songinfo_new (VisSongInfoType type)
30  {
31  return new LV::SongInfo (LV::SongInfoType (type));
32  }
33 
34  VisSongInfo *visual_songinfo_clone (VisSongInfo *src)
35  {
36  visual_return_val_if_fail (src != nullptr, nullptr);
37 
38  return new LV::SongInfo (*src);
39  }
40 
41  void visual_songinfo_free (VisSongInfo *self)
42  {
43  delete self;
44  }
45 
46  void visual_songinfo_set_type (VisSongInfo *self, VisSongInfoType type)
47  {
48  visual_return_if_fail (self != nullptr);
49 
50  self->set_type (LV::SongInfoType (type));
51  }
52 
53  VisSongInfoType visual_songinfo_get_type (VisSongInfo *self)
54  {
55  visual_return_val_if_fail (self != nullptr, VISUAL_SONGINFO_TYPE_NULL);
56 
57  return VisSongInfoType (self->get_type ());
58  }
59 
60  void visual_songinfo_set_length (VisSongInfo *self, int length)
61  {
62  visual_return_if_fail (self != nullptr);
63 
64  self->set_length (length);
65  }
66 
67  int visual_songinfo_get_length (VisSongInfo *self)
68  {
69  visual_return_val_if_fail (self != nullptr, 0);
70 
71  return self->get_length ();
72  }
73 
74  void visual_songinfo_set_elapsed (VisSongInfo *self, int elapsed)
75  {
76  visual_return_if_fail (self != nullptr);
77 
78  self->set_elapsed (elapsed);
79  }
80 
81  int visual_songinfo_get_elapsed (VisSongInfo *self)
82  {
83  return self->get_elapsed ();
84  }
85 
86  void visual_songinfo_set_simple_name (VisSongInfo *self, const char *name)
87  {
88  visual_return_if_fail (self != nullptr);
89 
90  self->set_simple_name (name);
91  }
92 
93  const char *visual_songinfo_get_simple_name (VisSongInfo *self)
94  {
95  visual_return_val_if_fail (self != nullptr, nullptr);
96 
97  return LV::string_to_c (self->get_simple_name ());
98  }
99 
100  void visual_songinfo_set_artist (VisSongInfo *self, const char *artist)
101  {
102  visual_return_if_fail (self != nullptr);
103 
104  self->set_artist (artist);
105  }
106 
107  const char *visual_songinfo_get_artist (VisSongInfo *self)
108  {
109  visual_return_val_if_fail (self != nullptr, nullptr);
110 
111  return LV::string_to_c (self->get_artist ());
112  }
113 
114  void visual_songinfo_set_album (VisSongInfo *self, const char *album)
115  {
116  visual_return_if_fail (self != nullptr);
117 
118  self->set_album (album);
119  }
120 
121  const char *visual_songinfo_get_album (VisSongInfo *self)
122  {
123  visual_return_val_if_fail (self != nullptr, nullptr);
124 
125  return LV::string_to_c (self->get_album ());
126  }
127 
128  void visual_songinfo_set_song (VisSongInfo *self, const char *song)
129  {
130  visual_return_if_fail (self != nullptr);
131 
132  self->set_song (song);
133  }
134 
135  const char *visual_songinfo_get_song (VisSongInfo *self)
136  {
137  visual_return_val_if_fail (self != nullptr, nullptr);
138 
139  return LV::string_to_c (self->get_song ());
140  }
141 
142  void visual_songinfo_set_cover (VisSongInfo *self, VisVideo *cover)
143  {
144  visual_return_if_fail (self != nullptr);
145  visual_return_if_fail (cover != nullptr);
146 
147  self->set_cover (cover);
148  }
149 
150  void visual_songinfo_mark (VisSongInfo *self)
151  {
152  visual_return_if_fail (self != nullptr);
153 
154  self->mark ();
155  }
156 
157  long visual_songinfo_get_age (VisSongInfo *self)
158  {
159  visual_return_val_if_fail (self != nullptr, 0);
160 
161  return self->get_age ();
162  }
163 
164  void visual_songinfo_copy (VisSongInfo *lhs, const VisSongInfo *rhs)
165  {
166  visual_return_if_fail (lhs != nullptr);
167  visual_return_if_fail (rhs != nullptr);
168 
169  *lhs = *rhs;
170  }
171 
172  int visual_songinfo_compare (const VisSongInfo *lhs, const VisSongInfo *rhs)
173  {
174  visual_return_val_if_fail (lhs != nullptr, FALSE);
175  visual_return_val_if_fail (rhs != nullptr, FALSE);
176 
177  return *lhs == *rhs;
178  }
179 
180 } // C extern