2007-01-08 00:03:05 +01:00
// Copyright (c) 2007, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
2009-07-29 07:43:02 +02:00
// Aegisub Project http://www.aegisub.org/
2007-01-08 00:03:05 +01:00
//
2009-07-29 07:43:02 +02:00
// $Id$
/// @file dialog_version_check.cpp
/// @brief Version Checker dialogue box and logic
/// @ingroup configuration_ui
///
2007-01-08 00:03:05 +01:00
2009-01-04 07:31:48 +01:00
# include "config.h"
2012-02-10 01:03:46 +01:00
# include "dialog_version_check.h"
2009-09-10 15:06:40 +02:00
# ifndef AGI_PRE
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
# ifdef WIN32
// Congratulation wx, you forgot to include a header somewhere
# include <winsock2.h>
# endif
2010-01-31 15:55:03 +01:00
# include <wx/app.h>
# include <wx/button.h>
2012-02-10 01:03:46 +01:00
# include <wx/checkbox.h>
2010-01-31 15:55:03 +01:00
# include <wx/dialog.h>
2012-02-10 01:03:46 +01:00
# include <wx/event.h>
# include <wx/hyperlink.h>
# include <wx/intl.h>
# include <wx/platinfo.h>
# include <wx/protocol/http.h>
2010-01-31 15:55:03 +01:00
# include <wx/sizer.h>
# include <wx/statline.h>
2012-02-10 01:03:46 +01:00
# include <wx/stattext.h>
# include <wx/string.h>
2010-01-31 15:55:03 +01:00
# include <wx/textctrl.h>
2012-02-10 01:03:46 +01:00
# include <wx/thread.h>
# include <wx/tokenzr.h>
# include <wx/txtstrm.h>
# include <algorithm>
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
# include <memory>
2010-06-05 22:16:30 +02:00
# include <set>
2012-02-10 01:03:46 +01:00
# include <tr1/functional>
2010-01-31 15:55:03 +01:00
# include <vector>
2009-09-10 15:06:40 +02:00
# endif
2010-05-21 03:13:36 +02:00
# include "compat.h"
# include "main.h"
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
# include "string_codec.h"
2009-09-10 15:06:40 +02:00
# include "version.h"
2007-01-08 00:03:05 +01:00
2010-05-21 03:13:36 +02:00
# include <libaegisub/exception.h>
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
/* *** Public API is implemented here *** */
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
// Allocate global lock mutex declared in header
wxMutex VersionCheckLock ;
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
class AegisubVersionCheckerThread : public wxThread {
bool interactive ;
void DoCheck ( ) ;
void PostErrorEvent ( const wxString & error_text ) ;
2012-02-10 01:03:46 +01:00
ExitCode Entry ( ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
public :
AegisubVersionCheckerThread ( bool interactive ) ;
} ;
// Public API for version checker
void PerformVersionCheck ( bool interactive )
2007-01-08 00:03:05 +01:00
{
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
new AegisubVersionCheckerThread ( interactive ) ;
}
/* *** The actual implementation begins here *** */
struct AegisubUpdateDescription {
wxString url ;
wxString friendly_name ;
wxString description ;
} ;
class AegisubVersionCheckResultEvent : public wxEvent {
wxString main_text ;
std : : vector < AegisubUpdateDescription > updates ;
public :
2012-02-10 01:03:46 +01:00
AegisubVersionCheckResultEvent ( wxString message = wxString ( ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
2012-02-10 01:03:46 +01:00
wxEvent * Clone ( ) const
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
return new AegisubVersionCheckResultEvent ( * this ) ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
const wxString & GetMainText ( ) const { return main_text ; }
// If there are no updates in the list, either none were found or an error occurred,
// either way it means "failure" if it's empty
const std : : vector < AegisubUpdateDescription > & GetUpdates ( ) const { return updates ; }
void AddUpdate ( const wxString & url , const wxString & friendly_name , const wxString & description )
{
updates . push_back ( AegisubUpdateDescription ( ) ) ;
AegisubUpdateDescription & desc = updates . back ( ) ;
desc . url = url ;
desc . friendly_name = friendly_name ;
desc . description = description ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
} ;
2007-01-08 00:03:05 +01:00
2012-02-10 01:03:46 +01:00
wxDEFINE_EVENT ( AEGISUB_EVENT_VERSIONCHECK_RESULT , AegisubVersionCheckResultEvent ) ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2012-02-10 01:03:46 +01:00
AegisubVersionCheckResultEvent : : AegisubVersionCheckResultEvent ( wxString message )
: wxEvent ( AEGISUB_EVENT_VERSIONCHECK_RESULT )
, main_text ( message )
{
}
2007-01-08 00:03:05 +01:00
2012-02-10 01:03:46 +01:00
DEFINE_SIMPLE_EXCEPTION_NOINNER ( VersionCheckError , agi : : Exception , " versioncheck " )
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
2012-02-10 01:03:46 +01:00
static void register_event_handler ( ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
AegisubVersionCheckerThread : : AegisubVersionCheckerThread ( bool interactive )
: wxThread ( wxTHREAD_DETACHED )
, interactive ( interactive )
{
2012-02-10 01:03:46 +01:00
register_event_handler ( ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
if ( ! wxSocketBase : : IsInitialized ( ) )
wxSocketBase : : Initialize ( ) ;
Create ( ) ;
Run ( ) ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxThread : : ExitCode AegisubVersionCheckerThread : : Entry ( )
{
if ( ! interactive )
{
// Automatic checking enabled?
2010-08-26 20:38:03 +02:00
if ( ! OPT_GET ( " App/Auto/Check For Updates " ) - > GetBool ( ) )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
return 0 ;
// Is it actually time for a check?
2010-05-21 03:13:36 +02:00
time_t next_check = OPT_GET ( " Version/Next Check " ) - > GetInt ( ) ;
2012-02-10 01:03:46 +01:00
if ( next_check > wxDateTime : : GetTimeNow ( ) )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
return 0 ;
}
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
if ( VersionCheckLock . TryLock ( ) ! = wxMUTEX_NO_ERROR ) return 0 ;
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
try {
DoCheck ( ) ;
}
2010-05-21 03:13:36 +02:00
catch ( const agi : : Exception & e ) {
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
PostErrorEvent ( wxString : : Format (
_ ( " There was an error checking for updates to Aegisub: \n %s \n \n If other applications can access the Internet fine, this is probably a temporary server problem on our end. " ) ,
2010-05-21 03:13:36 +02:00
e . GetMessage ( ) ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
catch ( . . . ) {
PostErrorEvent ( _ ( " An unknown error occurred while checking for updates to Aegisub. " ) ) ;
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
VersionCheckLock . Unlock ( ) ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
// While Options isn't perfectly thread safe, this should still be okay.
// Traversing the std::map to find the key-value pair doesn't modify any data as long as
// the key already exists (which it does at this point), and modifying the value only
// touches that specific key-value pair and will never cause a rebalancing of the tree,
// because the tree only depends on the keys.
// Lastly, writing options to disk only happens when Options.Save() is called.
time_t new_next_check_time = wxDateTime : : GetTimeNow ( ) + 60 * 60 ; // in one hour
2010-05-21 03:13:36 +02:00
OPT_SET ( " Version/Next Check " ) - > SetInt ( ( int ) new_next_check_time ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
return 0 ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
void AegisubVersionCheckerThread : : PostErrorEvent ( const wxString & error_text )
{
2012-02-10 01:03:46 +01:00
if ( interactive )
wxTheApp - > AddPendingEvent ( AegisubVersionCheckResultEvent ( error_text ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
2011-09-28 21:43:11 +02:00
static const char * GetOSShortName ( )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
int osver_maj , osver_min ;
wxOperatingSystemId osid = wxGetOsVersion ( & osver_maj , & osver_min ) ;
if ( osid & wxOS_WINDOWS_NT )
{
if ( osver_maj = = 5 & & osver_min = = 0 )
2011-09-28 21:43:11 +02:00
return " win2k " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osver_maj = = 5 & & osver_min = = 1 )
2011-09-28 21:43:11 +02:00
return " winxp " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osver_maj = = 5 & & osver_min = = 2 )
2011-09-28 21:43:11 +02:00
return " win2k3 " ; // this is also xp64
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osver_maj = = 6 & & osver_min = = 0 )
2011-09-28 21:43:11 +02:00
return " win60 " ; // vista and server 2008
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osver_maj = = 6 & & osver_min = = 1 )
2011-09-28 21:43:11 +02:00
return " win61 " ; // 7 and server 2008r2
2012-02-10 01:03:46 +01:00
else if ( osver_maj = = 6 & & osver_min = = 2 )
return " win62 " ; // 8
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else
2011-09-28 21:43:11 +02:00
return " windows " ; // future proofing? I doubt we run on nt4
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
else if ( osid & wxOS_MAC_OSX_DARWIN & & osver_maj = = 0x10 ) // yes 0x10, not decimal 10, don't ask me
{
// ugliest hack in the world? nah.
2011-09-28 21:43:11 +02:00
static char osxstring [ ] = " osx00 " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
char minor = osver_min > > 4 ;
char patch = osver_min & 0x0F ;
osxstring [ 3 ] = minor + ( ( minor < = 9 ) ? ' 0 ' : ( ' a ' - 1 ) ) ;
osxstring [ 4 ] = patch + ( ( patch < = 9 ) ? ' 0 ' : ( ' a ' - 1 ) ) ;
return osxstring ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_LINUX )
2011-09-28 21:43:11 +02:00
return " linux " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_FREEBSD )
2011-09-28 21:43:11 +02:00
return " freebsd " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_OPENBSD )
2011-09-28 21:43:11 +02:00
return " openbsd " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_NETBSD )
2011-09-28 21:43:11 +02:00
return " netbsd " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_SOLARIS )
2011-09-28 21:43:11 +02:00
return " solaris " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_AIX )
2011-09-28 21:43:11 +02:00
return " aix " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX_HPUX )
2011-09-28 21:43:11 +02:00
return " hpux " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_UNIX )
2011-09-28 21:43:11 +02:00
return " unix " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_OS2 )
2011-09-28 21:43:11 +02:00
return " os2 " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else if ( osid & wxOS_DOS )
2011-09-28 21:43:11 +02:00
return " dos " ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
else
2011-09-28 21:43:11 +02:00
return " unknown " ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
# ifdef WIN32
typedef BOOL ( WINAPI * PGetUserPreferredUILanguages ) ( DWORD dwFlags , PULONG pulNumLanguages , wchar_t * pwszLanguagesBuffer , PULONG pcchLanguagesBuffer ) ;
2012-02-10 01:03:46 +01:00
// Try using Win 6+ functions if available
static wxString GetUILanguage ( )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
2012-02-20 19:22:12 +01:00
agi : : scoped_holder < HMODULE , BOOL ( __stdcall * ) ( HMODULE ) > kernel32 ( LoadLibraryW ( L " kernel32.dll " ) , FreeLibrary ) ;
if ( ! kernel32 ) return " " ;
2012-02-10 01:03:46 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
PGetUserPreferredUILanguages gupuil = ( PGetUserPreferredUILanguages ) GetProcAddress ( kernel32 , " GetUserPreferredUILanguages " ) ;
2012-02-20 19:22:12 +01:00
if ( ! gupuil ) return " " ;
2012-02-10 01:03:46 +01:00
ULONG numlang = 0 , output_len = 0 ;
2012-02-20 19:22:12 +01:00
if ( gupuil ( MUI_LANGUAGE_NAME , & numlang , 0 , & output_len ) ! = TRUE | | ! output_len )
return " " ;
std : : vector < wchar_t > output ( output_len ) ;
if ( ! gupuil ( MUI_LANGUAGE_NAME , & numlang , & output [ 0 ] , & output_len ) | | numlang < 1 )
return " " ;
2012-02-10 01:03:46 +01:00
2012-02-20 19:22:12 +01:00
// We got at least one language, just treat it as the only, and a null-terminated string
return & output [ 0 ] ;
2012-02-10 01:03:46 +01:00
}
static wxString GetSystemLanguage ( )
{
wxString res = GetUILanguage ( ) ;
if ( ! res )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
// On an old version of Windows, let's just return the LANGID as a string
2012-02-10 01:03:46 +01:00
res = wxString : : Format ( " x-win%04x " , GetUserDefaultUILanguage ( ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
return res ;
}
# else
static wxString GetSystemLanguage ( )
2007-01-08 00:03:05 +01:00
{
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
return wxLocale : : GetLanguageInfo ( wxLocale : : GetSystemLanguage ( ) ) - > CanonicalName ;
2007-01-08 00:03:05 +01:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
# endif
2012-02-10 01:03:46 +01:00
template < class OutIter >
static void split_str ( wxString const & str , wxString const & sep , bool empty , OutIter out )
{
wxStringTokenizer tk ( str , sep , empty ? wxTOKEN_DEFAULT : wxTOKEN_RET_EMPTY_ALL ) ;
while ( tk . HasMoreTokens ( ) )
{
* out + + = tk . GetNextToken ( ) ;
}
}
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
void AegisubVersionCheckerThread : : DoCheck ( )
{
2010-06-05 22:16:30 +02:00
std : : set < wxString > accept_tags ;
# ifdef UPDATE_CHECKER_ACCEPT_TAGS
2012-02-10 01:03:46 +01:00
split_str ( wxString ( UPDATE_CHECKER_ACCEPT_TAGS , wxConvUTF8 ) , " " , false ,
inserter ( accept_tags , accept_tags . end ( ) ) ) ;
2010-06-05 22:16:30 +02:00
# endif
2011-09-28 21:43:11 +02:00
const wxString servername = " updates.aegisub.org " ;
const wxString base_updates_path = " /trunk " ;
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxString querystring = wxString : : Format (
2011-09-28 21:43:11 +02:00
" ?rev=%d&rel=%d&os=%s&lang=%s " ,
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
GetSVNRevision ( ) ,
GetIsOfficialRelease ( ) ? 1 : 0 ,
GetOSShortName ( ) ,
2011-09-28 21:43:48 +02:00
GetSystemLanguage ( ) ) ;
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxString path = base_updates_path + querystring ;
wxHTTP http ;
2011-11-03 23:50:54 +01:00
http . SetHeader ( " User-Agent " , wxString ( " Aegisub " ) + GetAegisubLongVersionString ( ) ) ;
2011-09-28 21:43:11 +02:00
http . SetHeader ( " Connection " , " Close " ) ;
2012-02-10 01:03:46 +01:00
http . SetFlags ( wxSOCKET_WAITALL | wxSOCKET_BLOCK ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
if ( ! http . Connect ( servername ) )
2010-05-21 03:13:36 +02:00
throw VersionCheckError ( STD_STR ( _ ( " Could not connect to updates server. " ) ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
2012-02-10 01:03:46 +01:00
agi : : scoped_ptr < wxInputStream > stream ( http . GetInputStream ( path ) ) ;
if ( ! stream ) // check for null-pointer
2010-06-05 22:16:30 +02:00
throw VersionCheckError ( STD_STR ( _ ( " Could not download from updates server. " ) ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
2010-05-21 03:13:36 +02:00
if ( http . GetResponse ( ) < 200 | | http . GetResponse ( ) > = 300 ) {
2012-02-10 01:03:46 +01:00
throw VersionCheckError ( STD_STR ( wxString : : Format ( _ ( " HTTP request failed, got HTTP response %d. " ) , http . GetResponse ( ) ) ) ) ;
2010-05-21 03:13:36 +02:00
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxTextInputStream text ( * stream ) ;
AegisubVersionCheckResultEvent result_event ;
while ( ! stream - > Eof ( ) & & stream - > GetSize ( ) > 0 )
{
wxArrayString parsed ;
2012-02-10 01:03:46 +01:00
split_str ( text . ReadLine ( ) , " | " , true , std : : back_inserter ( parsed ) ) ;
if ( parsed . size ( ) ! = 6 ) continue ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxString line_type = parsed [ 0 ] ;
wxString line_revision = parsed [ 1 ] ;
2010-06-05 22:16:30 +02:00
wxString line_tags_str = parsed [ 2 ] ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxString line_url = inline_string_decode ( parsed [ 3 ] ) ;
wxString line_friendlyname = inline_string_decode ( parsed [ 4 ] ) ;
wxString line_description = inline_string_decode ( parsed [ 5 ] ) ;
2012-02-10 01:03:46 +01:00
// stable runners don't want unstable, not interesting, skip
2011-09-28 21:43:11 +02:00
if ( ( line_type = = " branch " | | line_type = = " dev " ) & & GetIsOfficialRelease ( ) )
2007-01-08 00:03:05 +01:00
continue ;
2010-06-05 22:16:30 +02:00
// check if the tags match
2012-02-10 01:03:46 +01:00
if ( line_tags_str . empty ( ) | | line_tags_str = = " all " )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
2010-06-05 22:16:30 +02:00
// looking good
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
2010-06-05 22:16:30 +02:00
else
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
2012-02-10 01:03:46 +01:00
std : : set < wxString > tags ;
split_str ( line_tags_str , " " , false , inserter ( tags , tags . end ( ) ) ) ;
if ( ! includes ( accept_tags . begin ( ) , accept_tags . end ( ) , tags . begin ( ) , tags . end ( ) ) )
2010-06-05 22:16:30 +02:00
continue ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
2007-01-08 00:03:05 +01:00
2011-09-28 21:43:11 +02:00
if ( line_type = = " upgrade " | | line_type = = " bugfix " )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
// de facto interesting
}
else
{
// maybe interesting, check revision
long new_revision = 0 ;
if ( ! line_revision . ToLong ( & new_revision ) ) continue ;
if ( new_revision < = GetSVNRevision ( ) )
{
// too old, not interesting, skip
continue ;
2007-01-08 00:03:05 +01:00
}
}
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
// it's interesting!
result_event . AddUpdate ( line_url , line_friendlyname , line_description ) ;
}
2007-01-08 00:03:05 +01:00
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
if ( result_event . GetUpdates ( ) . size ( ) > 0 | | interactive )
{
wxTheApp - > AddPendingEvent ( result_event ) ;
}
}
class VersionCheckerResultDialog : public wxDialog {
void OnCloseButton ( wxCommandEvent & evt ) ;
void OnRemindMeLater ( wxCommandEvent & evt ) ;
void OnClose ( wxCloseEvent & evt ) ;
wxCheckBox * automatic_check_checkbox ;
public :
VersionCheckerResultDialog ( const wxString & main_text , const std : : vector < AegisubUpdateDescription > & updates ) ;
bool ShouldPreventAppExit ( ) const { return false ; }
} ;
VersionCheckerResultDialog : : VersionCheckerResultDialog ( const wxString & main_text , const std : : vector < AegisubUpdateDescription > & updates )
: wxDialog ( 0 , - 1 , _ ( " Version Checker " ) )
{
2012-02-03 01:54:09 +01:00
const int controls_width = 500 ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxSizer * main_sizer = new wxBoxSizer ( wxVERTICAL ) ;
wxStaticText * text = new wxStaticText ( this , - 1 , main_text ) ;
text - > Wrap ( controls_width ) ;
main_sizer - > Add ( text , 0 , wxBOTTOM | wxEXPAND , 6 ) ;
std : : vector < AegisubUpdateDescription > : : const_iterator upd_iterator = updates . begin ( ) ;
for ( ; upd_iterator ! = updates . end ( ) ; + + upd_iterator )
{
main_sizer - > Add ( new wxStaticLine ( this ) , 0 , wxEXPAND | wxALL , 6 ) ;
text = new wxStaticText ( this , - 1 , upd_iterator - > friendly_name ) ;
wxFont boldfont = text - > GetFont ( ) ;
boldfont . SetWeight ( wxFONTWEIGHT_BOLD ) ;
text - > SetFont ( boldfont ) ;
main_sizer - > Add ( text , 0 , wxEXPAND | wxBOTTOM , 6 ) ;
wxTextCtrl * descbox = new wxTextCtrl ( this , - 1 , upd_iterator - > description , wxDefaultPosition , wxSize ( controls_width , 60 ) , wxTE_MULTILINE | wxTE_READONLY ) ;
main_sizer - > Add ( descbox , 0 , wxEXPAND | wxBOTTOM , 6 ) ;
main_sizer - > Add ( new wxHyperlinkCtrl ( this , - 1 , upd_iterator - > url , upd_iterator - > url ) , 0 , wxALIGN_LEFT | wxBOTTOM , 6 ) ;
}
2011-11-18 19:49:09 +01:00
automatic_check_checkbox = new wxCheckBox ( this , - 1 , _ ( " &Auto Check for Updates " ) ) ;
2011-10-29 07:12:19 +02:00
automatic_check_checkbox - > SetValue ( OPT_GET ( " App/Auto/Check For Updates " ) - > GetBool ( ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
wxButton * remind_later_button = 0 ;
if ( updates . size ( ) > 0 )
remind_later_button = new wxButton ( this , wxID_NO , _ ( " Remind me again in a &week " ) ) ;
wxButton * close_button = new wxButton ( this , wxID_OK , _ ( " &Close " ) ) ;
SetAffirmativeId ( wxID_OK ) ;
SetEscapeId ( wxID_OK ) ;
2012-02-10 01:03:46 +01:00
if ( updates . size ( ) )
main_sizer - > Add ( new wxStaticLine ( this ) , 0 , wxEXPAND | wxALL , 6 ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
main_sizer - > Add ( automatic_check_checkbox , 0 , wxEXPAND | wxBOTTOM , 6 ) ;
wxStdDialogButtonSizer * button_sizer = new wxStdDialogButtonSizer ( ) ;
button_sizer - > AddButton ( close_button ) ;
if ( remind_later_button )
button_sizer - > AddButton ( remind_later_button ) ;
button_sizer - > Realize ( ) ;
main_sizer - > Add ( button_sizer , 0 , wxEXPAND , 0 ) ;
wxSizer * outer_sizer = new wxBoxSizer ( wxVERTICAL ) ;
outer_sizer - > Add ( main_sizer , 0 , wxALL | wxEXPAND , 12 ) ;
SetSizerAndFit ( outer_sizer ) ;
Centre ( ) ;
2012-02-10 01:03:46 +01:00
Show ( ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
2012-02-10 01:03:46 +01:00
Bind ( wxEVT_COMMAND_BUTTON_CLICKED , std : : tr1 : : bind ( & VersionCheckerResultDialog : : Close , this , false ) , wxID_OK ) ;
Bind ( wxEVT_COMMAND_BUTTON_CLICKED , & VersionCheckerResultDialog : : OnRemindMeLater , this , wxID_NO ) ;
Bind ( wxEVT_CLOSE_WINDOW , & VersionCheckerResultDialog : : OnClose , this ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
2011-12-22 22:09:31 +01:00
void VersionCheckerResultDialog : : OnRemindMeLater ( wxCommandEvent & )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
// In one week
time_t new_next_check_time = wxDateTime : : Today ( ) . GetTicks ( ) + 7 * 24 * 60 * 60 ;
2010-05-21 03:13:36 +02:00
OPT_SET ( " Version/Next Check " ) - > SetInt ( ( int ) new_next_check_time ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
Close ( ) ;
2007-01-08 00:03:05 +01:00
}
2009-07-29 07:43:02 +02:00
2011-12-22 22:09:31 +01:00
void VersionCheckerResultDialog : : OnClose ( wxCloseEvent & )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
2011-10-29 07:12:19 +02:00
OPT_SET ( " App/Auto/Check For Updates " ) - > SetBool ( automatic_check_checkbox - > GetValue ( ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
Destroy ( ) ;
}
2012-02-10 01:03:46 +01:00
static void on_update_result ( AegisubVersionCheckResultEvent & evt )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
2012-02-10 01:03:46 +01:00
wxString text = evt . GetMainText ( ) ;
if ( ! text )
{
if ( evt . GetUpdates ( ) . size ( ) = = 1 )
{
text = _ ( " An update to Aegisub was found. " ) ;
}
else if ( evt . GetUpdates ( ) . size ( ) > 1 )
{
text = _ ( " Several possible updates to Aegisub were found. " ) ;
}
else
{
text = _ ( " There are no updates to Aegisub. " ) ;
}
}
new VersionCheckerResultDialog ( text , evt . GetUpdates ( ) ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
}
2012-02-10 01:03:46 +01:00
static void register_event_handler ( )
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
{
static bool is_registered = false ;
if ( is_registered ) return ;
2012-02-10 01:03:46 +01:00
wxTheApp - > Bind ( AEGISUB_EVENT_VERSIONCHECK_RESULT , on_update_result ) ;
Merge 3906,r3909,r3910,r3912,r3928,r3931,r3932,r3933,r3935,r3936: merge update checker from 2.1.8, this also needs to be documented for doxygen. closes #1084.
Originally committed to SVN as r4042.
2010-01-26 14:14:05 +01:00
is_registered = true ;
}