]>
Commit | Line | Data |
---|---|---|
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 | ||
9f58c4b4 | 34 | #include "bing.h" |
dd84b6d1 | 35 | #include "spotmaps.h" |
cdcaf41c | 36 | #include "google.h" |
cdcaf41c | 37 | #include "terraserver.h" |
cdcaf41c | 38 | #include "expedia.h" |
67209ca8 | 39 | #include "osm.h" |
843b99df | 40 | #include "osm-traces.h" |
7363caa7 | 41 | #include "bluemarble.h" |
bf5cef41 | 42 | #include "geonames.h" |
54b5d793 | 43 | #include "file.h" |
df82a41c | 44 | #include "vikmapslayer.h" |
54b5d793 | 45 | #include "vikexttools.h" |
4c629122 | 46 | #include "vikgoto.h" |
54b5d793 GB |
47 | #include "vikgobjectbuilder.h" |
48 | ||
df82a41c | 49 | #define VIKING_MAPS_FILE "maps.xml" |
54b5d793 | 50 | #define VIKING_EXTTOOLS_FILE "external_tools.xml" |
4c629122 | 51 | #define VIKING_GOTOTOOLS_FILE "goto_tools.xml" |
54b5d793 | 52 | |
df82a41c GB |
53 | static void |
54 | modules_register_map_source(VikGobjectBuilder *self, GObject *object) | |
55 | { | |
56 | g_debug (__FUNCTION__); | |
57 | VikMapSource *mapsource = VIK_MAP_SOURCE (object); | |
58 | /* FIXME label should be hosted by object */ | |
59 | maps_layer_register_map_source (mapsource); | |
60 | } | |
61 | ||
54b5d793 GB |
62 | static void |
63 | modules_register_exttools(VikGobjectBuilder *self, GObject *object) | |
64 | { | |
65 | g_debug (__FUNCTION__); | |
66 | VikExtTool *tool = VIK_EXT_TOOL (object); | |
67 | vik_ext_tools_register (tool); | |
68 | } | |
69 | ||
4c629122 GB |
70 | static void |
71 | modules_register_gototools(VikGobjectBuilder *self, GObject *object) | |
72 | { | |
73 | g_debug (__FUNCTION__); | |
74 | VikGotoTool *tool = VIK_GOTO_TOOL (object); | |
75 | vik_goto_register (tool); | |
76 | } | |
77 | ||
54b5d793 GB |
78 | static void |
79 | modules_load_config(void) | |
80 | { | |
df82a41c GB |
81 | /* Maps sources */ |
82 | gchar *maps = g_build_filename(a_get_viking_dir(), VIKING_MAPS_FILE, NULL); | |
83 | if (g_access (maps, R_OK) == 0) | |
84 | { | |
85 | VikGobjectBuilder *builder = vik_gobject_builder_new (); | |
86 | g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_map_source), NULL); | |
87 | vik_gobject_builder_parse (builder, maps); | |
88 | g_object_unref (builder); | |
89 | } | |
90 | ||
54b5d793 GB |
91 | /* External tools */ |
92 | gchar *tools = g_build_filename(a_get_viking_dir(), VIKING_EXTTOOLS_FILE, NULL); | |
93 | if (g_access (tools, R_OK) == 0) | |
94 | { | |
95 | VikGobjectBuilder *builder = vik_gobject_builder_new (); | |
96 | g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_exttools), NULL); | |
97 | vik_gobject_builder_parse (builder, tools); | |
98 | g_object_unref (builder); | |
99 | } | |
4c629122 GB |
100 | |
101 | /* Go-to search engines */ | |
102 | gchar *go_to = g_build_filename(a_get_viking_dir(), VIKING_GOTOTOOLS_FILE, NULL); | |
103 | if (g_access (go_to, R_OK) == 0) | |
104 | { | |
105 | VikGobjectBuilder *builder = vik_gobject_builder_new (); | |
106 | g_signal_connect (builder, "new-object", G_CALLBACK (modules_register_gototools), NULL); | |
107 | vik_gobject_builder_parse (builder, go_to); | |
108 | g_object_unref (builder); | |
109 | } | |
54b5d793 | 110 | } |
cdcaf41c QT |
111 | |
112 | void modules_init() | |
113 | { | |
9f58c4b4 GB |
114 | #ifdef VIK_CONFIG_BING |
115 | bing_init(); | |
116 | #endif | |
36c78d6d QT |
117 | #ifdef VIK_CONFIG_GOOGLE |
118 | google_init(); | |
119 | #endif | |
cdcaf41c QT |
120 | #ifdef VIK_CONFIG_EXPEDIA |
121 | expedia_init(); | |
122 | #endif | |
123 | #ifdef VIK_CONFIG_TERRASERVER | |
124 | terraserver_init(); | |
125 | #endif | |
ca9eb04a | 126 | #ifdef VIK_CONFIG_OPENSTREETMAP |
67209ca8 | 127 | osm_init(); |
843b99df | 128 | osm_traces_init(); |
ca9eb04a | 129 | #endif |
7363caa7 GB |
130 | #ifdef VIK_CONFIG_BLUEMARBLE |
131 | bluemarble_init(); | |
132 | #endif | |
bf5cef41 GB |
133 | #ifdef VIK_CONFIG_GEONAMES |
134 | geonames_init(); | |
135 | #endif | |
dd84b6d1 GB |
136 | #ifdef VIK_CONFIG_SPOTMAPS |
137 | spotmaps_init(); | |
138 | #endif | |
139 | ||
54b5d793 GB |
140 | /* As modules are loaded, we can load configuration files */ |
141 | modules_load_config (); | |
cdcaf41c QT |
142 | } |
143 |