Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
924283da
Commit
924283da
authored
May 30, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the old update checker again (with #ifdef)
parent
f3a680f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
101 additions
and
22 deletions
+101
-22
src/data/settings.cpp
src/data/settings.cpp
+3
-0
src/data/settings.hpp
src/data/settings.hpp
+6
-0
src/gui/update_checker.cpp
src/gui/update_checker.cpp
+92
-22
No files found.
src/data/settings.cpp
View file @
924283da
...
...
@@ -153,6 +153,9 @@ Settings::Settings()
,
symbol_grid_size
(
30
)
,
symbol_grid
(
true
)
,
symbol_grid_snap
(
false
)
#if USE_OLD_STYLE_UPDATE_CHECKER
,
updates_url
(
_
(
"http://magicseteditor.sourceforge.net/updates"
))
#endif
,
package_versions_url
(
_
(
"http://magicseteditor.sourceforge.net/packages"
))
,
installer_list_url
(
_
(
"http://magicseteditor.sourceforge.net/installers"
))
,
check_updates
(
CHECK_IF_CONNECTED
)
...
...
src/data/settings.hpp
View file @
924283da
...
...
@@ -24,6 +24,9 @@ DECLARE_POINTER_TYPE(Field);
DECLARE_POINTER_TYPE
(
Value
);
DECLARE_POINTER_TYPE
(
AutoReplace
);
// For now, use the old style update checker
#define USE_OLD_STYLE_UPDATE_CHECKER 1
// ----------------------------------------------------------------------------- : Extra data structures
/// When to check for updates?
...
...
@@ -167,6 +170,9 @@ class Settings {
String
apprentice_location
;
// --------------------------------------------------- : Update checking
#if USE_OLD_STYLE_UPDATE_CHECKER
String
updates_url
;
#endif
String
package_versions_url
;
///< latest package versions
String
installer_list_url
;
///< available installers
CheckUpdates
check_updates
;
...
...
src/gui/update_checker.cpp
View file @
924283da
...
...
@@ -24,19 +24,41 @@ DECLARE_TYPEOF_COLLECTION(PackageDependencyP);
// ----------------------------------------------------------------------------- : Update data
/// Information on the latest available versions
class
VersionData
:
public
IntrusivePtrBase
<
VersionData
>
{
public:
vector
<
PackageDependencyP
>
packages
;
///< Available packages + versions
String
new_updates_url
;
///< updates url has moved?
DECLARE_REFLECTION
();
};
#if !USE_OLD_STYLE_UPDATE_CHECKER
IMPLEMENT_REFLECTION_NO_SCRIPT
(
VersionData
)
{
REFLECT_NO_SCRIPT
(
packages
);
REFLECT_NO_SCRIPT
(
new_updates_url
);
}
/// Information on the latest available versions
class
VersionData
:
public
IntrusivePtrBase
<
VersionData
>
{
public:
vector
<
PackageDependencyP
>
packages
;
///< Available packages + versions
String
new_updates_url
;
///< updates url has moved?
DECLARE_REFLECTION
();
};
IMPLEMENT_REFLECTION_NO_SCRIPT
(
VersionData
)
{
REFLECT_NO_SCRIPT
(
packages
);
REFLECT_NO_SCRIPT
(
new_updates_url
);
}
#else
/// Information on the latest available version
class
VersionData
:
public
IntrusivePtrBase
<
VersionData
>
{
public:
Version
version
;
///< Latest version number of MSE
String
description
;
///< html description of the latest MSE release
String
new_updates_url
;
///< updates url has moved?
DECLARE_REFLECTION
();
};
IMPLEMENT_REFLECTION
(
VersionData
)
{
REFLECT
(
version
);
REFLECT
(
description
);
REFLECT
(
new_updates_url
);
}
#endif
// The information for the latest version
VersionDataP
update_version_data
;
...
...
@@ -48,15 +70,19 @@ volatile bool checking_updates = false;
bool
update_data_found
()
{
return
!!
update_version_data
;
}
bool
update_available
()
{
if
(
!
update_version_data
)
return
false
;
// updates to any installed package?
FOR_EACH_CONST
(
p
,
update_version_data
->
packages
)
{
if
(
!
settings
.
check_updates_all
&&
p
->
package
!=
mse_package
)
continue
;
Version
v
;
if
(
packages
.
installedVersion
(
p
->
package
,
v
)
&&
v
<
p
->
version
)
{
return
true
;
#if !USE_OLD_STYLE_UPDATE_CHECKER
// updates to any installed package?
FOR_EACH_CONST
(
p
,
update_version_data
->
packages
)
{
if
(
!
settings
.
check_updates_all
&&
p
->
package
!=
mse_package
)
continue
;
Version
v
;
if
(
packages
.
installedVersion
(
p
->
package
,
v
)
&&
v
<
p
->
version
)
{
return
true
;
}
}
}
return
false
;
return
false
;
#else
return
update_version_data
->
version
>
app_version
;
#endif
}
// ----------------------------------------------------------------------------- : Update checking
...
...
@@ -75,7 +101,12 @@ class CheckUpdateThread : public wxThread {
if
(
checking_updates
)
return
;
// don't check multiple times simultaniously
checking_updates
=
true
;
try
{
wxURL
url
(
settings
.
package_versions_url
);
#if !USE_OLD_STYLE_UPDATE_CHECKER
String
&
the_url
=
settings
.
package_versions_url
;
#else
String
&
the_url
=
settings
.
updates_url
;
#endif
wxURL
url
(
the_url
);
wxInputStream
*
isP
=
url
.
GetInputStream
();
if
(
!
isP
)
return
;
// failed to get data
InputStreamP
is
(
isP
);
...
...
@@ -86,7 +117,7 @@ class CheckUpdateThread : public wxThread {
reader
.
handle
(
version_data
);
// has the updates url changed?
if
(
!
version_data
->
new_updates_url
.
empty
())
{
settings
.
package_versions
_url
=
version_data
->
new_updates_url
;
the
_url
=
version_data
->
new_updates_url
;
}
// Make available
update_version_data
=
version_data
;
...
...
@@ -123,9 +154,48 @@ void check_updates_now(bool async) {
// ----------------------------------------------------------------------------- : Dialog
#if !USE_OLD_STYLE_UPDATE_CHECKER
void
show_update_dialog
(
Window
*
parent
)
{
if
(
!
update_available
()
||
shown_dialog
)
return
;
// we already have the latest version, or this has already been displayed.
shown_dialog
=
true
;
(
new
PackagesWindow
(
parent
))
->
Show
();
}
// ----------------------------------------------------------------------------- : Dialog (old style)
#else // !USE_OLD_STYLE_UPDATE_CHECKER
#include <wx/html/htmlwin.h>
// A HTML control that opens all pages in an actual browser
struct
HtmlWindowToBrowser
:
public
wxHtmlWindow
{
HtmlWindowToBrowser
(
Window
*
parent
,
int
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
long
flags
)
:
wxHtmlWindow
(
parent
,
id
,
pos
,
size
,
flags
)
{}
virtual
void
OnLinkClicked
(
const
wxHtmlLinkInfo
&
info
)
{
wxLaunchDefaultBrowser
(
info
.
GetHref
()
);
}
};
void
show_update_dialog
(
Window
*
parent
)
{
if
(
!
update_available
()
||
shown_dialog
)
return
;
// we already have the latest version, or this has already been displayed.
// Show update dialog
wxDialog
*
dlg
=
new
wxDialog
(
parent
,
wxID_ANY
,
_TITLE_
(
"updates available"
),
wxDefaultPosition
);
// controls
wxHtmlWindow
*
html
=
new
HtmlWindowToBrowser
(
dlg
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
wxHW_SCROLLBAR_AUTO
|
wxSUNKEN_BORDER
);
html
->
SetPage
(
update_version_data
->
description
);
wxButton
*
close
=
new
wxButton
(
dlg
,
wxID_OK
,
_BUTTON_
(
"close"
));
close
->
SetDefault
();
// layout
wxSizer
*
s
=
new
wxBoxSizer
(
wxVERTICAL
);
s
->
Add
(
html
,
1
,
wxEXPAND
|
wxALL
,
8
);
s
->
Add
(
close
,
0
,
wxALIGN_RIGHT
|
wxALL
&
~
wxTOP
,
8
);
dlg
->
SetSizer
(
s
);
dlg
->
SetSize
(
400
,
400
);
dlg
->
Show
();
// And never show it again this run
shown_dialog
=
true
;
}
#endif // !USE_OLD_STYLE_UPDATE_CHECKER
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment