updatevlc.cpp 4.16 KB
Newer Older
1
/*****************************************************************************
2
 * updatevlc.cpp : VLC Update checker
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *****************************************************************************
 * Copyright (C) 2000-2004 the VideoLAN team
 * $Id$
 *
 * Authors: Antoine Cellerier <dionoea@videolan.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
dionoea's avatar
dionoea committed
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23
 *****************************************************************************/

24

25 26 27
/*****************************************************************************
 * Preamble
 *****************************************************************************/
28
#include "updatevlc.hpp"
29 30

#ifdef UPDATE_CHECK
31 32 33 34 35 36 37
#include <wx/imaglist.h>

#include "bitmaps/update_ascii.xpm"
#include "bitmaps/update_binary.xpm"
#include "bitmaps/update_document.xpm"
#include "bitmaps/update_info.xpm"
#include "bitmaps/update_source.xpm"
38 39 40 41 42 43 44 45 46 47

/*****************************************************************************
 * Event Table.
 *****************************************************************************/

/* IDs for the controls and the menu commands */
enum
{
    Close_Event,
    CheckForUpdate_Event,
48
    ChooseItem_Event
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
};

BEGIN_EVENT_TABLE(UpdateVLC, wxFrame)
    /* Button events */
    EVT_BUTTON(wxID_OK, UpdateVLC::OnButtonClose)
    EVT_BUTTON(CheckForUpdate_Event, UpdateVLC::OnCheckForUpdate)

    /* Hide the window when the user closes the window */
    EVT_CLOSE(UpdateVLC::OnClose)

END_EVENT_TABLE()

/*****************************************************************************
 * Constructor.
 *****************************************************************************/
UpdateVLC::UpdateVLC( intf_thread_t *_p_intf, wxWindow *p_parent ):
zorglub's avatar
zorglub committed
65
    wxFrame( p_parent, -1, wxU(_("Updates")),
66
             wxDefaultPosition, wxDefaultSize,
dionoea's avatar
dionoea committed
67 68
             wxSYSTEM_MENU|wxCLOSE_BOX|wxFRAME_FLOAT_ON_PARENT
             |wxFRAME_TOOL_WINDOW|wxCAPTION )
69 70 71 72 73 74
{
    /* Initializations */
    p_intf = _p_intf;
    SetIcon( *p_intf->p_sys->p_icon );
    SetAutoLayout( TRUE );

zorglub's avatar
zorglub committed
75 76 77
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
    wxButton *update_button =
        new wxButton( this, CheckForUpdate_Event,
zorglub's avatar
zorglub committed
78
                      wxU(_("Check for updates")) );
zorglub's avatar
zorglub committed
79 80
    main_sizer->Add( update_button );
    SetSizerAndFit( main_sizer );
81

82
    p_update = update_New( p_intf );
83 84 85 86 87
}


UpdateVLC::~UpdateVLC()
{
88
    update_Delete( p_update );
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
}

void UpdateVLC::OnButtonClose( wxCommandEvent& event )
{
    wxCloseEvent cevent;
    OnClose(cevent);
}

void UpdateVLC::OnClose( wxCloseEvent& WXUNUSED(event) )
{
    Hide();
}

void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event )
{
104
    update_Check( p_update, NULL, this );
105
    wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL );
106

107 108 109 110 111 112 113 114
    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 );*/

ivoire's avatar
ivoire committed
115
    if( update_NeedUpgrade( p_update ) )
116 117 118 119
    {
        update_release_t *p_release = update_GetRelease( p_update );
        assert( p_release );
        main_sizer->Add( new wxStaticText( this, -1, wxU( p_release->psz_desc )
120
                         + wxU( "\nYou can download the latest version of VLC at the adress :\n" )
121 122
                         + wxU( p_release->psz_url ) ) );
    }
123 124 125 126 127 128
    else
        main_sizer->Add( new wxStaticText( this, -1,
                         wxU( _( "\nYou have the latest version of VLC\n" ) ) ) );

    SetSizerAndFit( main_sizer );
    Layout();
129
}
130
#endif