]> git.sesse.net Git - vlc/commitdiff
Alert the user when something wrong accure during the update.
authorRémi Duraffort <ivoire@videolan.org>
Sun, 13 Jan 2008 23:04:23 +0000 (23:04 +0000)
committerRémi Duraffort <ivoire@videolan.org>
Sun, 13 Jan 2008 23:04:23 +0000 (23:04 +0000)
include/vlc_update.h
modules/gui/qt4/dialogs/help.cpp
modules/gui/qt4/dialogs/help.hpp
src/misc/update.c

index 7cb37f16ae041bdb0cf8d8937b406378d7b9d60e..ed87a863a8f08a4b3a60e038570bb8b217ffea1c 100644 (file)
@@ -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* ) );
 
index 5f14227a553c12bb35b1823419beca76de011b7c..c30365b767abd3781edeb3e5bf3ed9843152827d 100644 (file)
@@ -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 );
 }
index 8669646d16f6f37399eb16208bed5745aadb81cb..e71534f60820e4e0dcf567beedd6bd3bda2661d4 100644 (file)
@@ -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 * );
index bf6c6b9576e750fc0fc996b3b8db41f8e649d7f5..08aae887bb4f61a6954f40aaabaa0f8baefd13f1 100644 (file)
@@ -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 );
 }