1 /*****************************************************************************
2 * updatevlc.cpp : VLC Update checker
3 *****************************************************************************
4 * Copyright (C) 2000-2004 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include "updatevlc.hpp"
28 #include <wx/imaglist.h>
30 #include "bitmaps/update_ascii.xpm"
31 #include "bitmaps/update_binary.xpm"
32 #include "bitmaps/update_document.xpm"
33 #include "bitmaps/update_info.xpm"
34 #include "bitmaps/update_source.xpm"
36 /*****************************************************************************
38 *****************************************************************************/
40 /* IDs for the controls and the menu commands */
48 BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
50 EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
51 EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)
54 EVT_LIST_ITEM_ACTIVATED( ChooseItem_Event, UpdateVLC::OnChooseItem )
56 /* Hide the window when the user closes the window */
57 EVT_CLOSE(UpdateVLC::OnClose)
61 /*****************************************************************************
63 *****************************************************************************/
64 UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
65 wxFrame( p_parent, -1, wxU(_("VLC media player - Updates")),
66 wxDefaultPosition, wxDefaultSize,
67 wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT|wxFRAME_TOOL_WINDOW)
71 SetIcon( *p_intf->p_sys->p_icon );
72 SetAutoLayout( TRUE );
74 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
75 wxButton *update_button =
76 new wxButton( this, CheckForUpdate_Event,
77 wxU(_("Check for updates now !")) );
78 main_sizer->Add( update_button );
79 SetSizerAndFit( main_sizer );
81 p_u = update_New( p_intf );
85 UpdateVLC::~UpdateVLC()
90 void UpdateVLC::OnButtonClose( wxCommandEvent& event )
96 void UpdateVLC::OnClose( wxCloseEvent& WXUNUSED(event) )
101 void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
103 update_Check( p_u, VLC_FALSE );
104 update_iterator_t *p_uit = update_iterator_New( p_u );
107 wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
109 p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
110 p_uit->i_t = UPDATE_FILE_TYPE_ALL;
111 update_iterator_Action( p_uit, UPDATE_MIRROR );
116 new wxListCtrl( this, ChooseItem_Event,
117 wxDefaultPosition, wxSize( 400, 300 ),
118 wxLC_AUTOARRANGE|wxLC_SINGLE_SEL );
119 wxImageList *images = new wxImageList( 32, 32, TRUE );
120 images->Add( wxIcon( update_ascii_xpm ) );
121 images->Add( wxIcon( update_info_xpm ) );
122 images->Add( wxIcon( update_source_xpm ) );
123 images->Add( wxIcon( update_binary_xpm ) );
124 images->Add( wxIcon( update_document_xpm ) );
125 list->AssignImageList( images, wxIMAGE_LIST_SMALL );
126 while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
129 switch( p_uit->file.i_type )
131 case UPDATE_FILE_TYPE_INFO:
134 case UPDATE_FILE_TYPE_SOURCE:
137 case UPDATE_FILE_TYPE_BINARY:
140 case UPDATE_FILE_TYPE_PLUGIN:
146 list->InsertItem( list->GetItemCount(),
147 wxU(p_uit->file.psz_description)+wxU("\n")
148 + wxU(p_uit->release.psz_version)+wxU(" (")
149 + wxU(p_uit->release.psz_svn_revision)+wxU(")"),
153 main_sizer->Add( new wxStaticText( this, -1, wxU( _("\nAvailable updates and related downloads:\n(Double click on a file to download it)\n" ) ) ) );
154 main_sizer->Add( list );
155 SetSizerAndFit( main_sizer );
157 update_iterator_Delete( p_uit );
161 void UpdateVLC::OnChooseItem( wxListEvent& event )
163 update_iterator_t *p_uit = update_iterator_New( p_u );
166 p_uit->i_rs = UPDATE_RELEASE_STATUS_NEWER;
167 p_uit->i_t = UPDATE_FILE_TYPE_ALL;
168 update_iterator_Action( p_uit, UPDATE_MIRROR );
171 while( update_iterator_Action( p_uit, UPDATE_FILE ) != UPDATE_FAIL )
173 if( i_count == event.GetIndex() )
177 wxString url = wxU( p_uit->file.psz_url );
178 wxFileDialog *filedialog =
179 new wxFileDialog( this, wxU(_("Save file...")),
180 wxT(""), url.AfterLast( '/' ), wxT("*.*"),
181 wxSAVE | wxOVERWRITE_PROMPT );
182 if( filedialog->ShowModal() == wxID_OK )
184 char *psz_dest = ToLocale( filedialog->GetPath().mb_str() );
186 update_download( p_uit, psz_dest );
187 LocaleFree( psz_dest );
189 update_iterator_Delete( p_uit );