The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
state.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 - 2016 by Ignacio Riquelme Morelle <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #include "addon/state.hpp"
16 #include "config.hpp"
17 
18 #include "addon/manager.hpp"
19 #include "font.hpp"
20 #include "log.hpp"
21 #include "marked-up_text.hpp"
22 
23 static lg::log_domain log_addons_client("addons-client");
24 #define LOG_AC LOG_STREAM(info, log_addons_client)
25 
27 {
28  const std::string& id = addon.id;
30 
33  //t.installed_version = version_info();
34 
35  if(is_addon_installed(id)) {
36  if(t.can_publish) {
37  // Try to obtain the version number from the .pbl first.
38  config pbl;
39  get_addon_pbl_info(id, pbl);
40 
41  if(pbl.has_attribute("version")) {
42  t.installed_version = pbl["version"].str();
43  }
44  } else {
45  // We normally use the _info.cfg version instead.
47  }
48 
49  t.remote_version = addon.version;
50 
53  } else if(t.remote_version > t.installed_version) {
55  } else /* if(remote_version < t.installed_version) */ {
57  }
58  } else {
59  t.state = ADDON_NONE;
60  }
61 
62  return t;
63 }
64 
ADDON_STATUS state
Definition: state.hpp:55
bool is_addon_installed(const std::string &addon_name)
Check whether the specified add-on is currently installed.
Definition: manager.cpp:166
bool have_addon_in_vcs_tree(const std::string &addon_name)
Returns true if the specified add-ons appear to be managed by a 'supported' VCS.
Definition: manager.cpp:71
GLdouble GLdouble t
Definition: glew.h:1366
Definitions for the interface to Wesnoth Markup Language (WML).
version_info installed_version
Definition: state.hpp:58
version_info get_addon_version_info(const std::string &addon)
Returns a particular installed add-on's version information.
Definition: manager.cpp:379
Add-on is not installed.
Definition: state.hpp:24
Version in the server is older than local installation.
Definition: state.hpp:30
std::string id
Definition: info.hpp:31
Version in the server is newer than local installation.
Definition: state.hpp:28
bool in_version_control
Definition: state.hpp:57
static lg::log_domain log_addons_client("addons-client")
bool have_addon_pbl_info(const std::string &addon_name)
Returns true if there's a local .pbl file stored for the specified add-on.
Definition: manager.cpp:80
void get_addon_pbl_info(const std::string &addon_name, config &cfg)
Gets the publish information for an add-on.
Definition: manager.cpp:85
bool has_attribute(const std::string &key) const
Definition: config.cpp:514
addon_tracking_info get_addon_tracking_info(const addon_info &addon)
Get information about an add-on comparing its local state with the add-ons server entry...
Definition: state.cpp:26
Standard logging facilities (interface).
version_info version
Definition: info.hpp:37
Stores additional status information about add-ons.
Definition: state.hpp:44
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
GLsizei const GLcharARB ** string
Definition: glew.h:4503
version_info remote_version
Definition: state.hpp:59
Version in the server matches local installation.
Definition: state.hpp:26