Commit faad0752 authored by ivoire's avatar ivoire

Alert the user when something wrong accure during the update.

parent 6162f894
......@@ -232,7 +232,7 @@ struct update_t
VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) );
VLC_EXPORT( void, update_Delete, ( update_t * ) );
VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void* ), void * ) );
VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, vlc_bool_t ), void * ) );
VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) );
VLC_EXPORT( void, update_Download, ( update_t *, char* ) );
......
......@@ -180,10 +180,16 @@ void AboutDialog::close()
* UpdateDialog
*****************************************************************************/
/* callback to get information from the core */
static void UpdateCallback( void *data )
static void UpdateCallback( void *data, vlc_bool_t b_ret )
{
UpdateDialog* UDialog = (UpdateDialog *)data;
QEvent *event = new QEvent( QEvent::User );
QEvent* event;
if( b_ret )
event = new QEvent( (QEvent::Type)UDOkEvent );
else
event = new QEvent( (QEvent::Type)UDErrorEvent );
QApplication::postEvent( UDialog, event );
}
......@@ -254,22 +260,30 @@ void UpdateDialog::UpdateOrDownload()
/* Handle the events */
void UpdateDialog::customEvent( QEvent *event )
{
updateNotify();
if( event->type() == UDOkEvent )
updateNotify( true );
else
updateNotify( false );
}
/* Notify the end of the update_Check */
void UpdateDialog::updateNotify()
void UpdateDialog::updateNotify( bool b_result )
{
if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
/* The update finish without errors */
if( b_result )
{
b_checked = true;
updateButton->setText( "Download" );
updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
{
b_checked = true;
updateButton->setText( "Download" );
updateLabel->setText( qtr( "There is a new version of vlc :\n" ) + qfu( p_update->release.psz_desc ) );
}
else
updateLabel->setText( qtr( "You have the latest version of vlc" ) );
}
else
{
updateLabel->setText( qtr( "You have the latest version of vlc" ) );
}
updateLabel->setText( qtr( "An error occure while checking for updates" ) );
adjustSize();
updateButton->setEnabled( true );
}
......
......@@ -75,6 +75,9 @@ public slots:
#ifdef UPDATE_CHECK
static int UDOkEvent = QEvent::User + 1;
static int UDErrorEvent = QEvent::User + 2;
class UpdateDialog : public QVLCFrame
{
Q_OBJECT;
......@@ -86,7 +89,7 @@ public:
return instance;
}
virtual ~UpdateDialog();
void updateNotify();
void updateNotify( bool );
private:
UpdateDialog( intf_thread_t * );
......
......@@ -1007,7 +1007,7 @@ typedef struct
{
VLC_COMMON_MEMBERS
update_t *p_update;
void (*pf_callback)( void * );
void (*pf_callback)( void *, vlc_bool_t );
void *p_data;
} update_check_thread_t;
......@@ -1021,7 +1021,7 @@ void update_CheckReal( update_check_thread_t *p_uct );
* \param p_data pointer to some datas to give to the callback
* \returns nothing
*/
void update_Check( update_t *p_update, void (*pf_callback)( void* ), void *p_data )
void update_Check( update_t *p_update, void (*pf_callback)( void*, vlc_bool_t ), void *p_data )
{
assert( p_update );
......@@ -1044,9 +1044,8 @@ void update_CheckReal( update_check_thread_t *p_uct )
b_ret = GetUpdateFile( p_uct->p_update );
vlc_mutex_unlock( &p_uct->p_update->lock );
/* FIXME: return b_ret in pf_callback */
if( b_ret && p_uct->pf_callback )
(p_uct->pf_callback)( p_uct->p_data );
if( p_uct->pf_callback )
(p_uct->pf_callback)( p_uct->p_data, b_ret );
vlc_object_destroy( p_uct );
}
......
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