]> git.street.me.uk Git - andy/viking.git/blame - src/modules.c
Add support for dynamic copyright
[andy/viking.git] / src / modules.c
CommitLineData
cdcaf41c
QT
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
a482007a 4 * Copyright (C) 2006-2010, Guilhem Bonnefille <guilhem.bonnefille@gmail.com>
cdcaf41c
QT
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21
22#ifdef HAVE_CONFIG_H
23#include "config.h"
24#endif
25
54b5d793
GB
26#include <glib.h>
27#include <glib/gstdio.h>
28#ifdef HAVE_UNISTD_H
29#include <unistd.h>
30#endif
31
cdcaf41c
QT
32#include "modules.h"
33
dd84b6d1 34#include "spotmaps.h"
cdcaf41c 35#include "google.h"
cdcaf41c 36#include "terraserver.h"
cdcaf41c 37#include "expedia.h"
67209ca8 38#include "osm.h"
843b99df 39#include "osm-traces.h"
7363caa7 40#include "bluemarble.h"
bf5cef41 41#include "geonames.h"
54b5d793 42#include "file.h"
df82a41c 43#include "vikmapslayer.h"
54b5d793 44#include "vikexttools.h"
4c629122 45#include "vikgoto.h"
54b5d793
GB
46#include "vikgobjectbuilder.h"
47
df82a41c 48#define VIKING_MAPS_FILE "maps.xml"
54b5d793 49#define VIKING_EXTTOOLS_FILE "external_tools.xml"
4c629122 50#define VIKING_GOTOTOOLS_FILE "goto_tools.xml"
54b5d793 51
df82a41c
GB
52static void
53modules_register_map_source(VikGobjectBuilder *self, GObject *object)
54{
55 g_debug (__FUNCTION__);
56 VikMapSource *mapsource = VIK_MAP_SOURCE (object);
57 /* FIXME label should be hosted by object */
58 maps_layer_register_map_source (mapsource);
59}
60
54b5d793
GB
61static void
62modules_register_exttools(VikGobjectBuilder *self, GObject *object)
63{
64 g_debug (__FUNCTION__);
65 VikExtTool *tool = VIK_EXT_TOOL (object);
66 vik_ext_tools_register (tool);
67}
68
4c629122
GB
69static void
70modules_register_gototools(VikGobjectBuilder *self, GObject *object)
71{
72 g_debug (__FUNCTION__);
73 VikGotoTool *tool = VIK_GOTO_TOOL (object);
74 vik_goto_register (tool);
75}
76
54b5d793
GB
77static void
78modules_load_config(void)
79{
df82a41c
GB
80 /* Maps sources */
81 gchar *maps = g_build_filename(a_get_viking_dir(), VIKING_MAPS_FILE, NULL);
82 if (g_access (maps, R_OK) == 0)
83 {
84 VikGobjectBuilder *builder = vik_gobject_builder_new ();
85 g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_map_source), NULL);
86 vik_gobject_builder_parse (builder, maps);
87 g_object_unref (builder);
88 }
89
54b5d793
GB
90 /* External tools */
91 gchar *tools = g_build_filename(a_get_viking_dir(), VIKING_EXTTOOLS_FILE, NULL);
92 if (g_access (tools, R_OK) == 0)
93 {
94 VikGobjectBuilder *builder = vik_gobject_builder_new ();
95 g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_exttools), NULL);
96 vik_gobject_builder_parse (builder, tools);
97 g_object_unref (builder);
98 }
4c629122
GB
99
100 /* Go-to search engines */
101 gchar *go_to = g_build_filename(a_get_viking_dir(), VIKING_GOTOTOOLS_FILE, NULL);
102 if (g_access (go_to, R_OK) == 0)
103 {
104 VikGobjectBuilder *builder = vik_gobject_builder_new ();
105 g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_gototools), NULL);
106 vik_gobject_builder_parse (builder, go_to);
107 g_object_unref (builder);
108 }
54b5d793 109}
cdcaf41c
QT
110
111void modules_init()
112{
36c78d6d
QT
113#ifdef VIK_CONFIG_GOOGLE
114 google_init();
115#endif
cdcaf41c
QT
116#ifdef VIK_CONFIG_EXPEDIA
117 expedia_init();
118#endif
119#ifdef VIK_CONFIG_TERRASERVER
120 terraserver_init();
121#endif
ca9eb04a 122#ifdef VIK_CONFIG_OPENSTREETMAP
67209ca8 123 osm_init();
843b99df 124 osm_traces_init();
ca9eb04a 125#endif
7363caa7
GB
126#ifdef VIK_CONFIG_BLUEMARBLE
127 bluemarble_init();
128#endif
bf5cef41
GB
129#ifdef VIK_CONFIG_GEONAMES
130 geonames_init();
131#endif
dd84b6d1
GB
132#ifdef VIK_CONFIG_SPOTMAPS
133 spotmaps_init();
134#endif
135
54b5d793
GB
136 /* As modules are loaded, we can load configuration files */
137 modules_load_config ();
cdcaf41c
QT
138}
139