EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)
- /* CtrlList events */
- EVT_LIST_ITEM_ACTIVATED( ChooseItem_Event, UpdateVLC::OnChooseItem )
-
/* Hide the window when the user closes the window */
EVT_CLOSE(UpdateVLC::OnClose)
main_sizer->Add( update_button );
SetSizerAndFit( main_sizer );
- p_u = update_New( p_intf );
+ p_update = update_New( p_intf );
}
UpdateVLC::~UpdateVLC()
{
- update_Delete( p_u );
+ update_Delete( p_update );
}
void UpdateVLC::OnButtonClose( wxCommandEvent& event )
void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
{
- update_Check( p_u, VLC_FALSE );
- update_iterator_t *p_uit = update_iterator_New( p_u );
- if( p_uit )
- {
- wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
-
- p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
- p_uit->i_t = UPDATE_FILE_TYPE_ALL;
- update_iterator_Action( p_uit, UPDATE_MIRROR );
-
- DestroyChildren();
-
- wxListCtrl *list =
- new wxListCtrl( this, ChooseItem_Event,
- wxDefaultPosition, wxSize( 400, 300 ),
- wxLC_SINGLE_SEL|wxLC_LIST );
- wxImageList *images = new wxImageList( 32, 32, TRUE );
- images->Add( wxIcon( update_ascii_xpm ) );
- images->Add( wxIcon( update_info_xpm ) );
- images->Add( wxIcon( update_source_xpm ) );
- images->Add( wxIcon( update_binary_xpm ) );
- images->Add( wxIcon( update_document_xpm ) );
- list->AssignImageList( images, wxIMAGE_LIST_SMALL );
- while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
- {
- int i_image;
- switch( p_uit->file.i_type )
- {
- case UPDATE_FILE_TYPE_INFO:
- i_image = 1;
- break;
- case UPDATE_FILE_TYPE_SOURCE:
- i_image = 2;
- break;
- case UPDATE_FILE_TYPE_BINARY:
- i_image = 3;
- break;
- case UPDATE_FILE_TYPE_PLUGIN:
- i_image = 4;
- break;
- default:
- i_image = 0;
- }
- char *psz_tmp = NULL;
- 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 );
- }
- list->InsertItem( list->GetItemCount(),
- wxU(p_uit->file.psz_description)+wxU("\n")
- + wxU(p_uit->release.psz_version)+wxU(" ")
- + wxU(psz_tmp),
- i_image );
- if( psz_tmp ) free( psz_tmp );
- }
-
- main_sizer->Add( new wxStaticText( this, -1, wxU( _("\nAvailable "
- "updates and related downloads.\n"
- "(Double click on a file to download it)\n" ) ) ) );
- main_sizer->Add( list );
- SetSizerAndFit( main_sizer );
- Layout();
- update_iterator_Delete( p_uit );
- }
-}
+ update_Check( p_update );
+ wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
-void UpdateVLC::OnChooseItem( wxListEvent& event )
-{
- update_iterator_t *p_uit = update_iterator_New( p_u );
- if( p_uit )
- {
- p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
- p_uit->i_t = UPDATE_FILE_TYPE_ALL;
- update_iterator_Action( p_uit, UPDATE_MIRROR );
-
- int i_count = 0;
- while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
- {
- if( i_count == event.GetIndex() )
- break;
- i_count++;
- }
- wxString url = wxU( p_uit->file.psz_url );
- wxFileDialog *filedialog =
- new wxFileDialog( this, wxU(_("Save file...")),
- wxT(""), url.AfterLast( '/' ), wxT("*.*"),
- wxSAVE | wxOVERWRITE_PROMPT );
- if( filedialog->ShowModal() == wxID_OK )
- {
- update_download( p_uit, filedialog->GetPath().mb_str(wxConvUTF8) );
- }
- update_iterator_Delete( p_uit );
- delete filedialog;
- }
+ DestroyChildren();
+
+ /*list->InsertItem( list->GetItemCount(),
+ wxU(p_uit->file.psz_description)+wxU("\n")
+ + wxU(p_uit->release.psz_version)+wxU(" ")
+ + wxU(psz_tmp),
+ i_image );*/
+
+ if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer )
+ main_sizer->Add( new wxStaticText( this, -1, wxU( p_update->release.psz_desc )
+ + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
+ + wxU( p_update->release.psz_url ) ) );
+ else
+ main_sizer->Add( new wxStaticText( this, -1,
+ wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );
+
+ SetSizerAndFit( main_sizer );
+ Layout();
}