Skip to content

Commit

Permalink
add MinimumVersion support: ignore modules needing support newer than…
Browse files Browse the repository at this point in the history
… Sword itself.
  • Loading branch information
karlkleinpaste committed Aug 20, 2017
1 parent 38ef582 commit 71df457
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
@@ -1,4 +1,9 @@
2017-08-210 karl <charcoal@users.sf.net>
2017-08-20 karl <charcoal@users.sf.net>

* added MinimumVersion support:
ignore modules that require support newer than Sword itself.

2017-08-20 karl <charcoal@users.sf.net>

* added -fno-delete-null-pointer-checks to stop stupid crash.
somebody please tell the gnu people that this is just plain wrong.
Expand Down
3 changes: 3 additions & 0 deletions src/backend/module_manager.cc
Expand Up @@ -189,6 +189,9 @@ MOD_MGR *backend_module_mgr_get_next_module(void)
char *vers = (char *)module->getConfigEntry("Version");
mod_info->new_version = strdup(vers ? vers : " ");

vers = (char *)module->getConfigEntry("MinimumVersion");
mod_info->min_version = strdup(vers ? vers : " ");

char *installsize = (char *)module->getConfigEntry("InstallSize");
if (installsize && (isdigit(*installsize))) {
int isize = atoi(installsize);
Expand Down
1 change: 1 addition & 0 deletions src/gnome2/mod_mgr.c
Expand Up @@ -1682,6 +1682,7 @@ static void load_module_tree(GtkTreeView *treeview, gboolean install)
g_free(info->type);
g_free(info->new_version);
g_free(info->old_version);
g_free(info->min_version);
g_free(info->installsize);
g_free(info);
tmp2 = g_list_next(tmp2);
Expand Down
33 changes: 31 additions & 2 deletions src/main/mod_mgr.cc
Expand Up @@ -27,6 +27,7 @@
#include <swmodule.h>
#include <localemgr.h>
#include <swlocale.h>
#include <swversion.h>
#include "main/mod_mgr.h"
#include "main/sword.h"
#include "main/parallel_view.h"
Expand Down Expand Up @@ -266,12 +267,26 @@ GList *mod_mgr_list_local_modules(const char *dir,
{
GList *list = NULL;
MOD_MGR *mod_info;
SWVersion version = SWVersion::currentVersion;

backend_init_module_mgr(dir, augment, augment);

backend_module_mgr_list_local_modules_init(!augment);
while ((mod_info = backend_module_mgr_get_next_module()) != NULL) {
list = g_list_append(list, (MOD_MGR *)mod_info);
if (version.compare(mod_info->min_version) < 0) {
/* Sword is too old for this new module. */
g_free(mod_info->name);
g_free(mod_info->about);
g_free(mod_info->abbreviation);
g_free(mod_info->type);
g_free(mod_info->new_version);
g_free(mod_info->old_version);
g_free(mod_info->min_version);
g_free(mod_info->installsize);
g_free(mod_info);
} else {
list = g_list_append(list, (MOD_MGR *)mod_info);
}
}
return list;
}
Expand All @@ -296,10 +311,24 @@ GList *mod_mgr_remote_list_modules(const char *source_name)
{
GList *list = NULL;
MOD_MGR *mod_info;
SWVersion version = SWVersion::currentVersion;

backend_module_mgr_remote_list_modules_init(source_name);
while ((mod_info = backend_module_mgr_get_next_module()) != NULL) {
list = g_list_append(list, (MOD_MGR *)mod_info);
if (version.compare(mod_info->min_version) < 0) {
/* Sword is too old for this new module. */
g_free(mod_info->name);
g_free(mod_info->about);
g_free(mod_info->abbreviation);
g_free(mod_info->type);
g_free(mod_info->new_version);
g_free(mod_info->old_version);
g_free(mod_info->min_version);
g_free(mod_info->installsize);
g_free(mod_info);
} else {
list = g_list_append(list, (MOD_MGR *)mod_info);
}
}
return list;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/mod_mgr.h
Expand Up @@ -41,6 +41,7 @@ struct _mm
const char *language;
char *old_version;
char *new_version;
char *min_version; /* req'd level of sword support */
char *description;
int installed;
int is_devotional;
Expand Down

0 comments on commit 71df457

Please sign in to comment.