]> git.sesse.net Git - vlc/blob - include/vlc_update.h
src/*, include/* : update core functions. (Should make it relatively easy
[vlc] / include / vlc_update.h
1 /*****************************************************************************
2  * vlc_update.h: VLC update and plugins download
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * $Id: $
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either release 2 of the License, or
12  * (at your option) any later release.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #ifndef _VLC_UPDATE_H
25 #define _VLC_UPDATE_H
26
27 #include <vlc/vlc.h>
28
29 #define UPDATE_FILE_TYPE_ALL    (~0)
30 #define UPDATE_FILE_TYPE_NONE   0
31
32 #define UPDATE_FILE_TYPE_UNDEF      1
33 #define UPDATE_FILE_TYPE_INFO       2
34 #define UPDATE_FILE_TYPE_SOURCE     4
35 #define UPDATE_FILE_TYPE_BINARY     8
36 #define UPDATE_FILE_TYPE_PLUGIN     16
37
38 #define UPDATE_RELEASE_STATUS_ALL       (~0)
39 #define UPDATE_RELEASE_STATUS_NONE      0
40
41 #define UPDATE_RELEASE_STATUS_OLDER     1
42 #define UPDATE_RELEASE_STATUS_EQUAL     2
43 #define UPDATE_RELEASE_STATUS_NEWER     4
44
45 #define UPDATE_RELEASE_TYPE_STABLE      1
46 #define UPDATE_RELEASE_TYPE_TESTING     2
47 #define UPDATE_RELEASE_TYPE_UNSTABLE    4
48
49 #define UPDATE_FAIL     0
50 #define UPDATE_SUCCESS  1
51 #define UPDATE_NEXT     0
52 #define UPDATE_PREV     2
53 #define UPDATE_MIRROR   4
54 #define UPDATE_RELEASE  8
55 #define UPDATE_FILE     16
56 #define UPDATE_RESET    32
57
58 /**
59  * Describes an update file
60  */
61 struct update_file_t
62 {
63     int i_type;             //< File type
64     char* psz_md5;          //< MD5 hash
65     long int l_size;        //< File size in bytes
66     char* psz_url;          //< Relative (to a mirror) or absolute url
67     char* psz_description;  //< Plain text description
68 };
69
70 /**
71  * Describes an update VLC release number
72  */
73 struct update_release_t
74 {
75     char* psz_major;        //< Version major string
76     char* psz_minor;        //< Version minor string
77     char* psz_revision;     //< Version revision string
78     char* psz_extra;        //< Version extra string
79
80     char* psz_svn_revision; //< SVN revision
81
82     int i_type;             //< Release type
83
84     int i_status;           //< Release status compared to current VLC version
85
86     struct update_file_t* p_files; //< Files list
87     int i_files;            //< Number of files in the files list
88 };
89
90 /**
91  * Describes a mirror
92  */
93 struct update_mirror_t
94 {
95     char *psz_name;         //< Mirror name
96     char *psz_location;     //< Mirror geographical location
97     char *psz_type;         //< Mirror type (FTP, HTTP, ...)
98
99     char *psz_base_url;     //< Mirror base url
100
101 };
102
103 /**
104  * The update object. Stores (and caches) all information relative to updates
105  */
106 struct update_t
107 {
108     vlc_t *p_vlc;
109
110     vlc_mutex_t lock;
111
112     struct update_release_t *p_releases;    //< Releases (version) list
113     int i_releases;                         //< Number of releases
114     vlc_bool_t b_releases;                  //< True if we have a releases list
115
116     struct update_mirror_t *p_mirrors;      //< Mirrors list
117     int i_mirrors;                          //< Number of mirrors
118     vlc_bool_t b_mirrors;                   //< True if we have a mirrors list
119 };
120
121 /**
122  * The update iterator structure. Usefull to browse the update object seamlessly
123  */
124 struct update_iterator_t
125 {
126     update_t *p_u;  //< Pointer to VLC update object
127
128     int i_r;        //< Position in the releases list
129     int i_f;        //< Position in the release's files list
130     int i_m;        //< Position in the mirrors list
131
132     int i_t;        //< File type bitmask
133     int i_rs;       //< Release status bitmask
134     int i_rt;       //< Release type bitmask
135
136     struct
137     {
138         int i_type;             //< Type
139         char* psz_md5;          //< MD5 hash
140         long int l_size;        //< Size in bytes
141         char* psz_url;          //< Absolute URL
142         char* psz_description;  //< Description
143     } file;         //< Local 'copy' of the current file's information
144     struct
145     {
146         char *psz_version;      //< Version string
147         char *psz_svn_revision; //< SVN revision
148         int i_status;           //< Status
149         int i_type;             //< Type
150     } release;      //< Local 'copy' of the current release's information
151     struct
152     {
153         char *psz_name;         //< Name
154         char *psz_location;     //< Geographical location
155         char *psz_type;         //< Type (HTTP, FTP, ...)
156     } mirror;       //< Local 'copy' of the current mirror's information
157 };
158
159 #define update_New( a ) __update_New( VLC_OBJECT( a ) )
160
161 VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
162 VLC_EXPORT( void, update_Delete, (update_t * ) );
163 VLC_EXPORT( void, update_Check, ( update_t *, vlc_bool_t ) );
164
165 VLC_EXPORT( update_iterator_t *, update_iterator_New, ( update_t * ) );
166 VLC_EXPORT( void, update_iterator_Delete, ( update_iterator_t * ) );
167 VLC_EXPORT( unsigned int, update_iterator_Action, ( update_iterator_t *, int ) );
168 VLC_EXPORT( unsigned int, update_iterator_ChooseMirrorAndFile, ( update_iterator_t *, int, int, int ) );
169 VLC_EXPORT( void, update_download, ( update_iterator_t *, char * ) );
170
171 #endif