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* ) );
* 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 );
}
/* 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 );
}
#ifdef UPDATE_CHECK
+static int UDOkEvent = QEvent::User + 1;
+static int UDErrorEvent = QEvent::User + 2;
+
class UpdateDialog : public QVLCFrame
{
Q_OBJECT;
return instance;
}
virtual ~UpdateDialog();
- void updateNotify();
+ void updateNotify( bool );
private:
UpdateDialog( intf_thread_t * );
{
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;
* \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 );
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 );
}