live555: dtsgen: reset depth on seek
[vlc.git] / include / vlc_addons.h
blobc1131e0715107465eb463b73c63634c17e22094a
1 /*****************************************************************************
2 * vlc_addons.h : addons handling and describing
3 *****************************************************************************
4 * Copyright (C) 2013 VideoLAN and authors
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.
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.
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 *****************************************************************************/
21 #ifndef VLC_ADDONS_H
22 #define VLC_ADDONS_H 1
24 #include <vlc_arrays.h>
25 #include <vlc_events.h>
27 # ifdef __cplusplus
28 extern "C" {
29 # endif
31 typedef enum addon_type_t
33 ADDON_UNKNOWN = 0,
34 ADDON_EXTENSION,
35 ADDON_PLAYLIST_PARSER,
36 ADDON_SERVICE_DISCOVERY,
37 ADDON_SKIN2,
38 ADDON_PLUGIN,
39 ADDON_INTERFACE,
40 ADDON_META,
41 ADDON_OTHER
42 } addon_type_t;
44 typedef enum addon_state_t
46 ADDON_NOTINSTALLED = 0,
47 ADDON_INSTALLING,
48 ADDON_INSTALLED,
49 ADDON_UNINSTALLING
50 } addon_state_t;
52 typedef enum addon_flags_t
54 ADDON_BROKEN = 1, /* Have install inconsistency */
55 ADDON_MANAGEABLE = 1 << 1, /* Have manifest, can install or uninstall files */
56 ADDON_UPDATABLE = 1 << 2,
57 } addon_flags_t;
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];
64 typedef struct addon_file_t
66 addon_type_t e_filetype;
67 char *psz_download_uri;
68 char *psz_filename;
69 } addon_file_t;
71 struct addon_entry_t
73 vlc_mutex_t lock;
75 addon_type_t e_type;
76 addon_state_t e_state;
77 addon_flags_t e_flags;
79 /* data describing addon */
80 addon_uuid_t uuid;
81 char *psz_name;
82 char *psz_summary;
83 char *psz_description;
84 char *psz_author;
85 char *psz_source_uri; /* webpage, ... */
86 char *psz_image_uri;
87 char *psz_image_data; /* base64, png */
88 char *psz_version;
90 /* stats */
91 long int i_downloads;
92 int i_score; /* score 0..5 in hundredth */
94 /* Lister */
95 char *psz_source_module;
97 /* files list */
98 char *psz_archive_uri; /* Archive */
99 DECL_ARRAY(addon_file_t *) files;
101 /* custom data storage (if needed by module/source) */
102 void * p_custom;
105 typedef struct addons_finder_t addons_finder_t;
106 typedef struct addons_finder_sys_t addons_finder_sys_t;
107 struct addons_finder_t
109 struct vlc_common_members obj;
111 int ( * pf_find )( addons_finder_t * );
112 int ( * pf_retrieve )( addons_finder_t *, addon_entry_t * );
113 DECL_ARRAY( addon_entry_t * ) entries;
114 char *psz_uri;
116 addons_finder_sys_t *p_sys;
119 typedef struct addons_storage_t addons_storage_t;
120 typedef struct addons_storage_sys_t addons_storage_sys_t;
121 struct addons_storage_t
123 struct vlc_common_members obj;
125 int ( * pf_install )( addons_storage_t *, addon_entry_t * );
126 int ( * pf_remove )( addons_storage_t *, addon_entry_t * );
127 int ( * pf_catalog ) ( addons_storage_t *, addon_entry_t **, int );
129 addons_storage_sys_t *p_sys;
132 typedef struct addons_manager_t addons_manager_t;
134 struct addons_manager_owner
136 void *sys;
137 void (*addon_found)(struct addons_manager_t *, struct addon_entry_t *);
138 void (*discovery_ended)(struct addons_manager_t *);
139 void (*addon_changed)(struct addons_manager_t *, struct addon_entry_t *);
142 typedef struct addons_manager_private_t addons_manager_private_t;
143 struct addons_manager_t
145 struct addons_manager_owner owner;
146 addons_manager_private_t *p_priv;
150 * addon entry lifecycle
152 VLC_API addon_entry_t *addon_entry_New( void );
153 VLC_API addon_entry_t *addon_entry_Hold(addon_entry_t *);
154 VLC_API void addon_entry_Release(addon_entry_t *);
157 * addons manager lifecycle
159 VLC_API addons_manager_t *addons_manager_New( vlc_object_t *,
160 const struct addons_manager_owner * );
161 VLC_API void addons_manager_Delete( addons_manager_t * );
164 * Charge currently installed, usable and manageable addons
165 * (default "addons storage" module)
167 VLC_API int addons_manager_LoadCatalog( addons_manager_t * );
170 * Gather addons info from repository (default "addons finder" module)
171 * If psz_uri is not NULL, only gather info from the pointed package.
173 VLC_API void addons_manager_Gather( addons_manager_t *, const char *psz_uri );
176 * Install or Remove the addon identified by its uuid
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 );
182 * String uuid to binary uuid helpers
184 static inline bool addons_uuid_read( const char *psz_uuid, addon_uuid_t *p_uuid )
186 if ( !psz_uuid ) return false;
187 if ( strlen( psz_uuid ) < ADDON_UUID_PSZ_SIZE ) return false;
189 int i = 0, j = 0;
190 while ( i<ADDON_UUID_PSZ_SIZE )
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;
200 return true;
203 static inline char * addons_uuid_to_psz( const addon_uuid_t * p_uuid )
205 char *psz = (char*) calloc( ADDON_UUID_PSZ_SIZE + 1 , sizeof(char) );
206 if ( psz )
208 int i=0;
209 char *p = psz;
210 while ( i < ADDON_UUID_SIZE )
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++;
220 return psz;
223 # ifdef __cplusplus
225 # endif
227 #endif