Commit faad0752 authored by ivoire's avatar ivoire
Browse files

Alert the user when something wrong accure during the update.

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