VLC  3.0.21
vlc_addons.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_addons.h : addons handling and describing
3  *****************************************************************************
4  * Copyright (C) 2013 VideoLAN and authors
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20 
21 #ifndef VLC_ADDONS_H
22 #define VLC_ADDONS_H 1
23 
24 #include <vlc_arrays.h>
25 #include <vlc_events.h>
26 
27 # ifdef __cplusplus
28 extern "C" {
29 # endif
30 
31 typedef enum addon_type_t
32 {
33  ADDON_UNKNOWN = 0,
40  ADDON_META,
42 } addon_type_t;
43 
44 typedef enum addon_state_t
45 {
51 
52 typedef enum addon_flags_t
53 {
54  ADDON_BROKEN = 1, /* Have install inconsistency */
55  ADDON_MANAGEABLE = 1 << 1, /* Have manifest, can install or uninstall files */
56  ADDON_UPDATABLE = 1 << 2,
58 
59 #define ADDON_MAX_SCORE (5 * 100)
60 #define ADDON_UUID_SIZE 16
61 #define ADDON_UUID_PSZ_SIZE (ADDON_UUID_SIZE * 2 + 4)
62 typedef uint8_t addon_uuid_t[ADDON_UUID_SIZE];
63 
64 typedef struct addon_file_t
65 {
68  char *psz_filename;
69 } addon_file_t;
70 
72 {
74 
78 
79  /* data describing addon */
81  char *psz_name;
82  char *psz_summary;
84  char *psz_author;
85  char *psz_source_uri; /* webpage, ... */
87  char *psz_image_data; /* base64, png */
88  char *psz_version;
89 
90  /* stats */
91  long int i_downloads;
92  int i_score; /* score 0..5 in hundredth */
93 
94  /* Lister */
96 
97  /* files list */
98  char *psz_archive_uri; /* Archive */
100 
101  /* custom data storage (if needed by module/source) */
102  void * p_custom;
103 };
104 
108 {
110 
111  int ( * pf_find )( addons_finder_t * );
114  char *psz_uri;
115 
117 };
118 
122 {
124 
127  int ( * pf_catalog ) ( addons_storage_t *, addon_entry_t **, int );
128 
130 };
131 
133 
135 {
136  void *sys;
137  void (*addon_found)(struct addons_manager_t *, struct addon_entry_t *);
139  void (*addon_changed)(struct addons_manager_t *, struct addon_entry_t *);
140 };
141 
144 {
147 };
148 
149 /**
150  * addon entry lifecycle
151  */
155 
156 /**
157  * addons manager lifecycle
158  */
160  const struct addons_manager_owner * );
162 
163 /**
164  * Charge currently installed, usable and manageable addons
165  * (default "addons storage" module)
166  */
168 
169 /**
170  * Gather addons info from repository (default "addons finder" module)
171  * If psz_uri is not NULL, only gather info from the pointed package.
172  */
173 VLC_API void addons_manager_Gather( addons_manager_t *, const char *psz_uri );
174 
175 /**
176  * Install or Remove the addon identified by its uuid
177  */
178 VLC_API int addons_manager_Install( addons_manager_t *p_manager, const addon_uuid_t uuid );
179 VLC_API int addons_manager_Remove( addons_manager_t *p_manager, const addon_uuid_t uuid );
180 
181 /**
182  * String uuid to binary uuid helpers
183  */
184 static inline bool addons_uuid_read( const char *psz_uuid, addon_uuid_t *p_uuid )
185 {
186  if ( !psz_uuid ) return false;
187  if ( strlen( psz_uuid ) < ADDON_UUID_PSZ_SIZE ) return false;
188 
189  int i = 0, j = 0;
190  while ( i<ADDON_UUID_PSZ_SIZE )
191  {
192  if ( *( psz_uuid + i ) == '-' )
193  i++;
194  int v;
195  sscanf( psz_uuid + i, "%02x", &v );
196  (*p_uuid)[j++] = v & 0xFF;
197  i+=2;
198  }
199 
200  return true;
201 }
202 
203 static inline char * addons_uuid_to_psz( const addon_uuid_t * p_uuid )
204 {
205  char *psz = (char*) calloc( ADDON_UUID_PSZ_SIZE + 1 , sizeof(char) );
206  if ( psz )
207  {
208  int i=0;
209  char *p = psz;
210  while ( i < ADDON_UUID_SIZE )
211  {
212  if ( i == 4 || i== 7 || i== 9 || i== 11 )
213  *p++ = '-';
214  int v = 0xFF & (*p_uuid)[i];
215  sprintf( p, "%02x", v );
216  p += 2;
217  i++;
218  }
219  }
220  return psz;
221 }
222 
223 # ifdef __cplusplus
224 }
225 # endif
226 
227 #endif
addon_entry_t::psz_description
char * psz_description
Definition: vlc_addons.h:83
ADDON_UUID_PSZ_SIZE
#define ADDON_UUID_PSZ_SIZE
Definition: vlc_addons.h:61
addon_entry_t::psz_summary
char * psz_summary
Definition: vlc_addons.h:82
addons_finder_t::p_sys
addons_finder_sys_t * p_sys
Definition: vlc_addons.h:116
addon_entry_t::psz_source_uri
char * psz_source_uri
Definition: vlc_addons.h:85
VLC_API
#define VLC_API
Definition: fourcc_gen.c:30
vlc_events.h
VLC_COMMON_MEMBERS
#define VLC_COMMON_MEMBERS
Backward compatibility macro.
Definition: vlc_common.h:457
addons_finder_t
Definition: vlc_addons.h:107
addon_entry_t::psz_image_uri
char * psz_image_uri
Definition: vlc_addons.h:86
vlc_common.h
addon_entry_t::lock
vlc_mutex_t lock
Definition: vlc_addons.h:73
addon_entry_t
Definition: vlc_addons.h:71
ADDON_INSTALLED
Definition: vlc_addons.h:48
addons_storage_t::pf_install
int(* pf_install)(addons_storage_t *, addon_entry_t *)
Definition: vlc_addons.h:125
ADDON_INTERFACE
Definition: vlc_addons.h:56
addons_manager_owner::addon_found
void(* addon_found)(struct addons_manager_t *, struct addon_entry_t *)
Definition: vlc_addons.h:137
addons_storage_sys_t
struct addons_storage_sys_t addons_storage_sys_t
Definition: vlc_addons.h:120
addons_uuid_read
static bool addons_uuid_read(const char *psz_uuid, addon_uuid_t *p_uuid)
String uuid to binary uuid helpers.
Definition: vlc_addons.h:184
addons_manager_owner::sys
void * sys
Definition: vlc_addons.h:136
addon_entry_t::psz_author
char * psz_author
Definition: vlc_addons.h:84
addons_finder_t::pf_retrieve
int(* pf_retrieve)(addons_finder_t *, addon_entry_t *)
Definition: vlc_addons.h:112
addon_entry_t::e_flags
addon_flags_t e_flags
Definition: vlc_addons.h:77
ADDON_UNKNOWN
Definition: vlc_addons.h:50
addons_storage_t::pf_catalog
int(* pf_catalog)(addons_storage_t *, addon_entry_t **, int)
Definition: vlc_addons.h:127
ADDON_PLUGIN
Definition: vlc_addons.h:55
addons_manager_t::owner
struct addons_manager_owner owner
Definition: vlc_addons.h:145
ADDON_UNINSTALLING
Definition: vlc_addons.h:49
addon_entry_t::files
struct addon_entry_t::@139 files
addon_entry_t::i_downloads
long int i_downloads
Definition: vlc_addons.h:91
ADDON_UUID_SIZE
#define ADDON_UUID_SIZE
Definition: vlc_addons.h:60
addon_entry_t::psz_name
char * psz_name
Definition: vlc_addons.h:81
addons_storage_t
Definition: vlc_addons.h:121
addon_entry_t::psz_version
char * psz_version
Definition: vlc_addons.h:88
addon_entry_t::psz_source_module
char * psz_source_module
Definition: vlc_addons.h:95
addons_manager_t::p_priv
addons_manager_private_t * p_priv
Definition: vlc_addons.h:146
addons_manager_Remove
int addons_manager_Remove(addons_manager_t *p_manager, const addon_uuid_t uuid)
Definition: addons.c:560
addon_entry_t::e_state
addon_state_t e_state
Definition: vlc_addons.h:76
addons_finder_t::entries
struct addons_finder_t::@140 entries
addons_manager_LoadCatalog
int addons_manager_LoadCatalog(addons_manager_t *)
Charge currently installed, usable and manageable addons (default "addons storage" module)
Definition: addons.c:406
ADDON_OTHER
Definition: vlc_addons.h:58
addons_manager_Gather
void addons_manager_Gather(addons_manager_t *, const char *psz_uri)
Gather addons info from repository (default "addons finder" module) If psz_uri is not NULL,...
Definition: addons.c:213
addons_finder_t::psz_uri
char * psz_uri
Definition: vlc_addons.h:114
addon_entry_t::p_custom
void * p_custom
Definition: vlc_addons.h:102
DECL_ARRAY
#define DECL_ARRAY(type)
Definition: vlc_arrays.h:165
addons_manager_New
addons_manager_t * addons_manager_New(vlc_object_t *, const struct addons_manager_owner *)
addons manager lifecycle
ADDON_NOTINSTALLED
Definition: vlc_addons.h:46
addons_finder_t::pf_find
int(* pf_find)(addons_finder_t *)
Definition: vlc_addons.h:111
addon_file_t::e_filetype
addon_type_t e_filetype
Definition: vlc_addons.h:66
addons_manager_t
Definition: vlc_addons.h:143
addon_type_t
addon_type_t
Definition: vlc_addons.h:31
addon_entry_t::e_type
addon_type_t e_type
Definition: vlc_addons.h:75
vlc_object_t
The main vlc_object_t structure.
Definition: vlc_objects.h:39
addons_manager_Install
int addons_manager_Install(addons_manager_t *p_manager, const addon_uuid_t uuid)
Install or Remove the addon identified by its uuid.
Definition: addons.c:551
addon_file_t
Definition: vlc_addons.h:64
ADDON_MANAGEABLE
Definition: vlc_addons.h:55
vlc_mutex_t
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:267
addons_manager_owner
Definition: vlc_addons.h:134
addon_uuid_t
uint8_t addon_uuid_t[16]
Definition: vlc_addons.h:62
addons_manager_owner::addon_changed
void(* addon_changed)(struct addons_manager_t *, struct addon_entry_t *)
Definition: vlc_addons.h:139
addon_entry_t::uuid
addon_uuid_t uuid
Definition: vlc_addons.h:80
addon_flags_t
addon_flags_t
Definition: vlc_addons.h:52
addon_state_t
addon_state_t
Definition: vlc_addons.h:44
ADDON_PLAYLIST_PARSER
Definition: vlc_addons.h:52
ADDON_EXTENSION
Definition: vlc_addons.h:51
ADDON_SERVICE_DISCOVERY
Definition: vlc_addons.h:53
addon_file_t::psz_download_uri
char * psz_download_uri
Definition: vlc_addons.h:67
addon_entry_t::psz_image_data
char * psz_image_data
Definition: vlc_addons.h:87
addons_storage_t::pf_remove
int(* pf_remove)(addons_storage_t *, addon_entry_t *)
Definition: vlc_addons.h:126
addon_file_t
struct addon_file_t addon_file_t
addons_storage_t::p_sys
addons_storage_sys_t * p_sys
Definition: vlc_addons.h:129
addon_entry_Release
void addon_entry_Release(addon_entry_t *)
Definition: addons.c:97
ADDON_SKIN2
Definition: vlc_addons.h:54
ADDON_UPDATABLE
Definition: vlc_addons.h:56
addon_entry_Hold
addon_entry_t * addon_entry_Hold(addon_entry_t *)
Definition: addons.c:89
vlc_arrays.h
addons_manager_private_t
Definition: addons.c:43
addons_uuid_to_psz
static char * addons_uuid_to_psz(const addon_uuid_t *p_uuid)
Definition: vlc_addons.h:203
addons_finder_sys_t
struct addons_finder_sys_t addons_finder_sys_t
Definition: vlc_addons.h:106
addons_manager_Delete
void addons_manager_Delete(addons_manager_t *)
Definition: addons.c:171
addons_manager_owner::discovery_ended
void(* discovery_ended)(struct addons_manager_t *)
Definition: vlc_addons.h:138
ADDON_INSTALLING
Definition: vlc_addons.h:47
addon_entry_New
addon_entry_t * addon_entry_New(void)
addon entry lifecycle
Definition: addons.c:75
addon_entry_t::psz_archive_uri
char * psz_archive_uri
Definition: vlc_addons.h:98
ADDON_META
Definition: vlc_addons.h:57
ADDON_BROKEN
Definition: vlc_addons.h:54
addon_entry_t::i_score
int i_score
Definition: vlc_addons.h:92
p
#define p(t)
addon_file_t::psz_filename
char * psz_filename
Definition: vlc_addons.h:68