Commit 09b9702d authored by Rémi Duraffort's avatar Rémi Duraffort

Modify the update system : I will add more functionnality but this is the beginning

parent 1f94c930
......@@ -36,45 +36,11 @@
* @{
*/
#define UPDATE_FILE_TYPE_ALL (~0)
#define UPDATE_FILE_TYPE_NONE 0
#define UPDATE_FILE_TYPE_UNDEF 1
#define UPDATE_FILE_TYPE_INFO 2
#define UPDATE_FILE_TYPE_SOURCE 4
#define UPDATE_FILE_TYPE_BINARY 8
#define UPDATE_FILE_TYPE_PLUGIN 16
#define UPDATE_RELEASE_STATUS_ALL (~0)
#define UPDATE_RELEASE_STATUS_NONE 0
#define UPDATE_RELEASE_STATUS_OLDER 1
#define UPDATE_RELEASE_STATUS_EQUAL 2
#define UPDATE_RELEASE_STATUS_NEWER 4
#define UPDATE_RELEASE_TYPE_STABLE 1
#define UPDATE_RELEASE_TYPE_TESTING 2
#define UPDATE_RELEASE_TYPE_UNSTABLE 4
#define UPDATE_FAIL 0
#define UPDATE_SUCCESS 1
#define UPDATE_NEXT 0
#define UPDATE_PREV 2
#define UPDATE_MIRROR 4
#define UPDATE_RELEASE 8
#define UPDATE_FILE 16
#define UPDATE_RESET 32
/**
* Describes an update file
*/
struct update_file_t
enum
{
int i_type; ///< File type
char* psz_md5; ///< MD5 hash
long int l_size; ///< File size in bytes
char* psz_url; ///< Relative (to a mirror) or absolute url
char* psz_description; ///< Plain text description
UpdateReleaseStatusOlder,
UpdateReleaseStatusEqual,
UpdateReleaseStatusNewer
};
/**
......@@ -82,32 +48,13 @@ struct update_file_t
*/
struct update_release_t
{
char* psz_major; ///< Version major string
char* psz_minor; ///< Version minor string
char* psz_revision; ///< Version revision string
char* psz_extra; ///< Version extra string
char* psz_svn_revision; ///< SVN revision
int i_type; ///< Release type
int i_status; ///< Release status compared to current VLC version
struct update_file_t* p_files; ///< Files list
int i_files; ///< Number of files in the files list
};
/**
* Describes a mirror
*/
struct update_mirror_t
{
char *psz_name; ///< Mirror name
char *psz_location; ///< Mirror geographical location
char *psz_type; ///< Mirror type (FTP, HTTP, ...)
char *psz_base_url; ///< Mirror base url
int i_major; ///< Version major
int i_minor; ///< Version minor
int i_revision; ///< Version revision
char* psz_svnrev; ///< SVN revision
char* psz_extra; ///< Version extra
char* psz_url; ///< Download URL
char* psz_desc; ///< Release description
};
/**
......@@ -116,60 +63,17 @@ struct update_mirror_t
struct update_t
{
libvlc_int_t *p_libvlc;
vlc_mutex_t lock;
struct update_release_t *p_releases; ///< Releases (version) list
int i_releases; ///< Number of releases
vlc_bool_t b_releases; ///< True if we have a releases list
struct update_mirror_t *p_mirrors; ///< Mirrors list
int i_mirrors; ///< Number of mirrors
vlc_bool_t b_mirrors; ///< True if we have a mirrors list
struct update_release_t release; ///< Release (version)
};
/**
* The update iterator structure. Usefull to browse the update object seamlessly
*/
struct update_iterator_t
{
update_t *p_u; ///< Pointer to VLC update object
int i_r; ///< Position in the releases list
int i_f; ///< Position in the release's files list
int i_m; ///< Position in the mirrors list
int i_t; ///< File type bitmask
int i_rs; ///< Release status bitmask
int i_rt; ///< Release type bitmask
struct update_file_t file; ///< Local copy of the current file's information
struct
{
char *psz_version; ///< Version string
char *psz_svn_revision; ///< SVN revision
int i_status; ///< Status
int i_type; ///< Type
} release; ///< Local 'copy' of the current release's information
struct
{
char *psz_name; ///< Name
char *psz_location; ///< Geographical location
char *psz_type; ///< Type (HTTP, FTP, ...)
} mirror; ///< Local 'copy' of the current mirror's information
};
#define update_New( a ) __update_New( VLC_OBJECT( a ) )
VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
VLC_EXPORT( void, update_Delete, (update_t * ) );
VLC_EXPORT( void, update_Check, ( update_t *, vlc_bool_t ) );
VLC_EXPORT( update_iterator_t *, update_iterator_New, ( update_t * ) );
VLC_EXPORT( void, update_iterator_Delete, ( update_iterator_t * ) );
VLC_EXPORT( unsigned int, update_iterator_Action, ( update_iterator_t *, int ) );
VLC_EXPORT( unsigned int, update_iterator_ChooseMirrorAndFile, ( update_iterator_t *, int, int, int ) );
VLC_EXPORT( void, update_download, ( update_iterator_t *, const char * ) );
VLC_EXPORT( void, update_Delete, ( update_t * ) );
VLC_EXPORT( void, update_Check, ( update_t * ) );
VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) );
/**
* @}
......
......@@ -96,7 +96,7 @@ static int AudioConfig ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static int Menu ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static void checkUpdates( intf_thread_t *p_intf, char *psz_arg );
static void checkUpdates( intf_thread_t *p_intf );
/* Status Callbacks */
static int TimeOffsetChanged( vlc_object_t *, char const *,
......@@ -752,7 +752,7 @@ static void Run( intf_thread_t *p_intf )
}
else if( !strcmp( psz_cmd, "check-updates" ) )
{
checkUpdates( p_intf, psz_arg );
checkUpdates( p_intf );
}
else if( !strcmp( psz_cmd, "key" ) || !strcmp( psz_cmd, "hotkey" ) )
{
......@@ -2105,116 +2105,20 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
/*****************************************************************************
* checkUpdates : check for updates
****************************************************************************/
static void checkUpdates( intf_thread_t *p_intf, char *psz_arg )
static void checkUpdates( intf_thread_t *p_intf )
{
update_iterator_t *p_uit;
update_t *p_u = update_New( p_intf );
if( p_u == NULL ) return;
p_uit = update_iterator_New( p_u );
if( p_uit )
{
int s = 0, t = 0;
if( strstr( psz_arg, "newer" ) )
s |= UPDATE_RELEASE_STATUS_NEWER;
if( strstr( psz_arg, "equal" ) )
s |= UPDATE_RELEASE_STATUS_EQUAL;
if( strstr( psz_arg, "older" ) )
s |= UPDATE_RELEASE_STATUS_OLDER;
if( s ) p_uit->i_rs = s;
else p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
if( strstr( psz_arg, "undef" ) )
t |= UPDATE_FILE_TYPE_UNDEF;
if( strstr( psz_arg, "info" ) )
t |= UPDATE_FILE_TYPE_INFO;
if( strstr( psz_arg, "source" ) )
t |= UPDATE_FILE_TYPE_SOURCE;
if( strstr( psz_arg, "binary" ) )
t |= UPDATE_FILE_TYPE_BINARY;
if( strstr( psz_arg, "plugin" ) )
t |= UPDATE_FILE_TYPE_PLUGIN;
if( t ) p_uit->i_t = t;
update_Check( p_u, VLC_FALSE );
update_iterator_Action( p_uit, UPDATE_MIRROR );
msg_rc( "\nUsing mirror: %s (%s) [%s]",
p_uit->mirror.psz_name,
p_uit->mirror.psz_location,
p_uit->mirror.psz_type );
while( (s = update_iterator_Action( p_uit, UPDATE_FILE )) != UPDATE_FAIL )
{
char *psz_tmp;
if( s & UPDATE_RELEASE )
{
switch( p_uit->release.i_status )
{
case UPDATE_RELEASE_STATUS_OLDER:
psz_tmp = strdup( "older" );
break;
case UPDATE_RELEASE_STATUS_EQUAL:
psz_tmp = strdup( "equal" );
break;
case UPDATE_RELEASE_STATUS_NEWER:
psz_tmp = strdup( "newer" );
break;
default:
psz_tmp = strdup( "?!?" );
break;
}
msg_rc( "\n+----[ VLC %s %s (%s) ] ",
p_uit->release.psz_version,
p_uit->release.psz_svn_revision,
psz_tmp );
free( psz_tmp );
}
switch( p_uit->file.i_type )
{
case UPDATE_FILE_TYPE_UNDEF:
psz_tmp = strdup( "undef" );
break;
case UPDATE_FILE_TYPE_INFO:
psz_tmp = strdup( "info" );
break;
case UPDATE_FILE_TYPE_SOURCE:
psz_tmp = strdup( "source" );
break;
case UPDATE_FILE_TYPE_BINARY:
psz_tmp = strdup( "binary" );
break;
case UPDATE_FILE_TYPE_PLUGIN:
psz_tmp = strdup( "plugin" );
break;
default:
psz_tmp = strdup( "?!?" );
break;
}
msg_rc( "| %s (%s)", p_uit->file.psz_description, psz_tmp );
free( psz_tmp );
if( p_uit->file.l_size )
{
if( p_uit->file.l_size > 1024 * 1024 * 1024 )
asprintf( &psz_tmp, "(%ld GB)",
p_uit->file.l_size / (1024*1024*1024) );
if( p_uit->file.l_size > 1024 * 1024 )
asprintf( &psz_tmp, "(%ld MB)",
p_uit->file.l_size / (1024*1024) );
else if( p_uit->file.l_size > 1024 )
asprintf( &psz_tmp, "(%ld kB)",
p_uit->file.l_size / 1024 );
else
asprintf( &psz_tmp, "(%ld B)", p_uit->file.l_size );
}
else
{
psz_tmp = strdup( "" );
}
msg_rc( "| %s %s", p_uit->file.psz_url, psz_tmp );
msg_rc( "+----" );
free( psz_tmp );
}
msg_rc( "" );
update_iterator_Delete( p_uit );
}
update_Check( p_u );
msg_rc( "\nChecking for updates" );
if( update_CompareReleaseToCurrent( p_u ) == UpdateReleaseStatusNewer )
msg_rc( "\n+----[ VLC %i.%i.%i%s ] ", p_u->release.i_major,
p_u->release.i_minor,
p_u->release.i_revision,
p_u->release.psz_extra );
else
msg_rc( "\n+----Last version" );
update_Delete( p_u );
}
......@@ -35,15 +35,12 @@
#include <QFile>
#include <QLabel>
#include <QString>
#include <QCheckBox>
#include <QGroupBox>
#include <QDialogButtonBox>
#include <QFileDialog>
HelpDialog *HelpDialog::instance = NULL;
HelpDialog::HelpDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
HelpDialog::HelpDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
setWindowTitle( qtr( "Help" ) );
resize( 600, 560 );
......@@ -98,20 +95,20 @@ AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
QLabel *infoLabel = new QLabel( "VLC media player " PACKAGE_VERSION "\n\n"
"(c) 1996-2007 - the VideoLAN Team\n\n" +
qtr( "VLC media player is a free media player, made by the "
"VideoLAN Team.\nIt is a standalone multimedia player, "
"encoder and streamer, that can read from many supports "
"(files, CDs, DVDs, networks, capture cards...) and that "
"works on many platforms.\n\n" )
"VideoLAN Team.\nIt is a standalone multimedia player, "
"encoder and streamer, that can read from many supports "
"(files, CDs, DVDs, networks, capture cards...) and that "
"works on many platforms.\n\n" )
+ qtr( "You are using the new Qt4 Interface.\n" )
+ qtr( "Compiled by " ) + qfu( VLC_CompileBy() )+ "@"
+ qfu( VLC_CompileDomain() ) + ".\n"
+ "Compiler: " + qfu( VLC_Compiler() ) +".\n"
+ "Compiler: " + qfu( VLC_Compiler() ) + ".\n"
+ qtr( "Based on SVN revision: " ) + qfu( VLC_Changeset() )
+ ".\n\n"
+ qtr( "This program comes with NO WARRANTY, to the extent "
"permitted by the law; read the distribution tab.\n\n" )
+ "The VideoLAN team <videolan@videolan.org> \n"
"http://www.videolan.org/\n") ;
"http://www.videolan.org/\n" );
infoLabel->setWordWrap( infoLabel );
QLabel *iconVLC2 = new QLabel;
......@@ -129,7 +126,7 @@ AboutDialog::AboutDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
QWidget *thanksWidget = new QWidget( this );
QVBoxLayout *thanksLayout = new QVBoxLayout( thanksWidget );
QLabel *thanksLabel = new QLabel( qtr("We would like to thank the whole "
QLabel *thanksLabel = new QLabel( qtr( "We would like to thank the whole "
"community, the testers, our users and the following people "
"(and the missing ones...) for their collaboration to "
"provide the best software." ) );
......@@ -165,45 +162,32 @@ void AboutDialog::close()
UpdateDialog *UpdateDialog::instance = NULL;
UpdateDialog::UpdateDialog( intf_thread_t *_p_intf) : QVLCFrame( _p_intf )
UpdateDialog::UpdateDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{
setWindowTitle( qtr( "Update" ) );
resize( 230, 180 );
resize( 320, 120 );
QGridLayout *layout = new QGridLayout( this );
updateBrowser = new QTextBrowser( this );
updateBrowser->setOpenExternalLinks( true );
updateBrowser->setHtml( qtr( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
<body><center>Push the update button to get the updates</center></body></html>" ) );
QPushButton *closeButton = new QPushButton( qtr( "&Close" ) );
updateButton = new QPushButton( qtr( "&Update List" ) );
QPushButton *updateButton = new QPushButton( qtr( "&Update List" ) );
updateButton->setDefault( true );
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal);
QDialogButtonBox *buttonBox = new QDialogButtonBox( Qt::Horizontal );
buttonBox->addButton( updateButton, QDialogButtonBox::ActionRole );
buttonBox->addButton( closeButton, QDialogButtonBox::AcceptRole );
QGroupBox *checkGroup = new QGroupBox( qtr( "Select Package" ) );
QGridLayout *checkLayout = new QGridLayout( checkGroup );
checkInfo = new QCheckBox( qtr( "Information" ) );
checkSource = new QCheckBox( qtr( "Sources" ) );
checkBinary = new QCheckBox( qtr( "Binary" ) );
checkPlugin = new QCheckBox( qtr( "Plugin" ) );
checkInfo->setDisabled( true );
checkSource->setDisabled( true );
checkBinary->setDisabled( true );
checkPlugin->setDisabled( true );
checkLayout->addWidget( checkInfo, 0, 0 );
checkLayout->addWidget( checkSource, 1, 0 );
checkLayout->addWidget( checkBinary, 2, 0 );
checkLayout->addWidget( checkPlugin, 3, 0 );
layout->addWidget( checkGroup, 0, 0 );
layout->addWidget( updateBrowser, 0, 0 );
layout->addWidget( buttonBox, 1, 0 );
BUTTONACT( updateButton, updateOrUpload() );
BUTTONACT( closeButton, close() );
p_update = update_New( _p_intf );
b_updated = false;
}
UpdateDialog::~UpdateDialog()
......@@ -218,101 +202,18 @@ void UpdateDialog::close()
void UpdateDialog::updateOrUpload()
{
if( !p_update ) return;
if( !b_updated )
update_Check( p_update );
if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
{
update_Check( p_update, VLC_FALSE );
update_iterator_t *p_updateit = update_iterator_New( p_update );
bool b_download = false;
if( p_updateit )
{
p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
update_iterator_Action( p_updateit, UPDATE_MIRROR );
while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
{
switch( p_updateit->file.i_type )
{
case UPDATE_FILE_TYPE_INFO:
checkInfo->setText( qtr( "Information" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkInfo->setDisabled( false );
checkInfo->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_SOURCE:
checkSource->setText( qtr( "Source" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkSource->setDisabled( false );
checkSource->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_BINARY:
checkBinary->setText( qtr( "Binary" ) + " (" + qfu( p_updateit->release.psz_version ) + ")" );
checkBinary->setDisabled( false );
checkBinary->setCheckState( Qt::Checked );
b_download = true;
break;
case UPDATE_FILE_TYPE_PLUGIN:
checkPlugin->setText( qtr( "Plugin" ) + " (" + qfu( p_updateit->release.psz_version ) + ")");
checkPlugin->setDisabled( false );
checkPlugin->setCheckState( Qt::Checked );
b_download = true;
break;
default:
break;
}
}
}
if( b_download )
{
updateButton->setText(qtr( "Download" ) );
b_updated = true;
}
update_iterator_Delete( p_updateit );
updateBrowser->setHtml( qtr( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
<body><center><p>" ) + qtu( (QString)p_update->release.psz_desc ) +
qtr( "</p>You can download the latest version of VLC <a href=\"" ) +
qtu( (QString)p_update->release.psz_url ) + qtr( "\">here</a></center></body></html>" ) );
}
else
{
update_iterator_t *p_updateit = update_iterator_New( p_update );
bool b_download = false;
if( p_updateit )
{
QString saveDir = QFileDialog::getExistingDirectory( this, qtr( "Choose a directory..." ),
qfu( p_intf->p_libvlc->psz_homedir ) );
p_updateit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
p_updateit->i_t = UPDATE_FILE_TYPE_ALL;
update_iterator_Action( p_updateit, UPDATE_MIRROR );
while( update_iterator_Action( p_updateit, UPDATE_FILE ) != UPDATE_FAIL )
{
b_download = false;
switch( p_updateit->file.i_type )
{
case UPDATE_FILE_TYPE_INFO:
if( checkInfo->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_SOURCE:
if( checkSource->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_BINARY:
if( checkBinary->isChecked() )
b_download = true;
break;
case UPDATE_FILE_TYPE_PLUGIN:
if( checkPlugin->isChecked() )
b_download = true;
break;
default:
break;
}
if( b_download )
{
QString strFileName = p_updateit->file.psz_url;
strFileName.remove( 0, strFileName.lastIndexOf( "/" ) + 1 );
update_download( p_updateit, qtu( ( saveDir + strFileName ) ) );
}
}
}
updateBrowser->setHtml( "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=\"utf-8\" /></head> \
<body><center>You have the latest version of VLC.</center></body></html>" );
}
}
......@@ -29,7 +29,7 @@
#include "util/qvlcframe.hpp"
class QPushButton;
class QCheckBox;
class QTextBrowser;
class HelpDialog : public QVLCFrame
{
......@@ -44,7 +44,7 @@ public:
virtual ~HelpDialog();
private:
HelpDialog( intf_thread_t *);
HelpDialog( intf_thread_t * );
static HelpDialog *instance;
public slots:
void close();
......@@ -58,13 +58,13 @@ public:
static AboutDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new AboutDialog( p_intf);
instance = new AboutDialog( p_intf );
return instance;
}
virtual ~AboutDialog();
private:
AboutDialog( intf_thread_t *);
AboutDialog( intf_thread_t * );
static AboutDialog *instance;
public slots:
void close();
......@@ -77,22 +77,17 @@ class UpdateDialog : public QVLCFrame
public:
static UpdateDialog * getInstance( intf_thread_t *p_intf )
{
if( !instance)
instance = new UpdateDialog( p_intf);
if( !instance )
instance = new UpdateDialog( p_intf );
return instance;
}
virtual ~UpdateDialog();
private:
UpdateDialog( intf_thread_t *);
UpdateDialog( intf_thread_t * );
static UpdateDialog *instance;
QPushButton *updateButton;
QCheckBox *checkInfo;
QCheckBox *checkSource;
QCheckBox *checkBinary;
QCheckBox *checkPlugin;
update_t *p_update;
bool b_updated;
QTextBrowser *updateBrowser;
private slots:
void close();
void updateOrUpload();
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment