|
ali@109
|
1 |
/*
|
|
ali@109
|
2 |
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
|
ali@109
|
3 |
* Copyright (C) 2023 J. Ali Harlow <ali@juiblex.co.uk>
|
|
ali@109
|
4 |
*
|
|
ali@109
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
ali@109
|
6 |
* it under the terms of the GNU General Public License as published by
|
|
ali@109
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
ali@109
|
8 |
* (at your option) any later version.
|
|
ali@109
|
9 |
*
|
|
ali@109
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
ali@109
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
ali@109
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
ali@109
|
13 |
* GNU General Public License for more details.
|
|
ali@109
|
14 |
*
|
|
ali@109
|
15 |
* You should have received a copy of the GNU General Public License along
|
|
ali@109
|
16 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
ali@109
|
17 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
ali@109
|
18 |
*/
|
|
ali@109
|
19 |
|
|
ali@109
|
20 |
#include "config.h"
|
|
ali@109
|
21 |
#include <stdlib.h>
|
|
ali@109
|
22 |
#include <string.h>
|
|
ali@109
|
23 |
#include <glib-object.h>
|
|
ali@109
|
24 |
#include <gtk/gtk.h>
|
|
ali@109
|
25 |
#include <plover/plover.h>
|
|
ali@109
|
26 |
#include "localdistributions.h"
|
|
ali@109
|
27 |
|
|
ali@109
|
28 |
#define VALID_ITER(iter,local) ((iter) && (iter)->user_data && \
|
|
ali@109
|
29 |
PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(local)->stamp==(iter)->stamp)
|
|
ali@109
|
30 |
|
|
ali@109
|
31 |
static GType column_types[PLOVER_LOCAL_DISTRIBUTIONS_NO_COLUMNS];
|
|
ali@109
|
32 |
|
|
ali@109
|
33 |
static void
|
|
ali@109
|
34 |
plover_local_distributions_tree_model_init(GtkTreeModelIface *iface);
|
|
ali@109
|
35 |
|
|
ali@109
|
36 |
G_DEFINE_TYPE_WITH_CODE(PloverLocalDistributions,plover_local_distributions,
|
|
ali@109
|
37 |
G_TYPE_OBJECT,G_IMPLEMENT_INTERFACE(GTK_TYPE_TREE_MODEL,
|
|
ali@109
|
38 |
plover_local_distributions_tree_model_init));
|
|
ali@109
|
39 |
|
|
ali@109
|
40 |
typedef struct _PloverLocalDistribution {
|
|
ali@109
|
41 |
gchar *vendor,*distribution,*prefix,*user_friendly,*database_uri;
|
|
ali@109
|
42 |
} PloverLocalDistribution;
|
|
ali@109
|
43 |
|
|
ali@109
|
44 |
typedef struct _PloverLocalDistributionsPrivate {
|
|
ali@109
|
45 |
GList *distributions;
|
|
ali@109
|
46 |
int stamp;
|
|
ali@109
|
47 |
} PloverLocalDistributionsPrivate;
|
|
ali@109
|
48 |
|
|
ali@109
|
49 |
#define PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(obj)\
|
|
ali@109
|
50 |
G_TYPE_INSTANCE_GET_PRIVATE(obj,\
|
|
ali@109
|
51 |
PLOVER_TYPE_LOCAL_DISTRIBUTIONS,\
|
|
ali@109
|
52 |
PloverLocalDistributionsPrivate)
|
|
ali@109
|
53 |
|
|
ali@109
|
54 |
PloverLocalDistribution *plover_local_distribution_new(const char *vendor,
|
|
ali@109
|
55 |
const char *distribution)
|
|
ali@109
|
56 |
{
|
|
ali@109
|
57 |
gchar *s;
|
|
ali@109
|
58 |
struct comps *comps;
|
|
ali@109
|
59 |
PloverLocalDistribution *ld;
|
|
ali@109
|
60 |
ld=g_new0(PloverLocalDistribution,1);
|
|
ali@109
|
61 |
ld->vendor=g_strdup(vendor);
|
|
ali@109
|
62 |
if (distribution)
|
|
ali@109
|
63 |
{
|
|
ali@109
|
64 |
ld->distribution=g_strdup(distribution);
|
|
ali@109
|
65 |
ld->user_friendly=g_strdup_printf("%s (%s)",distribution,vendor);
|
|
ali@109
|
66 |
}
|
|
ali@109
|
67 |
else
|
|
ali@109
|
68 |
ld->user_friendly=g_strdup(vendor);
|
|
ali@109
|
69 |
comps=plover_comps_new();
|
|
ali@109
|
70 |
plover_comps_set_vendor(comps,vendor);
|
|
ali@109
|
71 |
if (distribution)
|
|
ali@109
|
72 |
plover_comps_set_distribution(comps,distribution);
|
|
ali@109
|
73 |
ld->prefix=plover_comps_get_default_prefix(comps);
|
|
ali@109
|
74 |
plover_comps_free(comps);
|
|
ali@109
|
75 |
s=g_build_filename(ld->prefix,"var","lib","razor",NULL);
|
|
ali@109
|
76 |
ld->database_uri=razor_path_to_uri(s);
|
|
ali@109
|
77 |
g_free(s);
|
|
ali@109
|
78 |
return ld;
|
|
ali@109
|
79 |
}
|
|
ali@109
|
80 |
|
|
ali@109
|
81 |
void plover_local_distribution_free(PloverLocalDistribution *ld)
|
|
ali@109
|
82 |
{
|
|
ali@109
|
83 |
if (ld)
|
|
ali@109
|
84 |
{
|
|
ali@109
|
85 |
g_free(ld->vendor);
|
|
ali@109
|
86 |
g_free(ld->distribution);
|
|
ali@109
|
87 |
g_free(ld->prefix);
|
|
ali@109
|
88 |
g_free(ld->user_friendly);
|
|
ali@109
|
89 |
g_free(ld->database_uri);
|
|
ali@109
|
90 |
g_free(ld);
|
|
ali@109
|
91 |
}
|
|
ali@109
|
92 |
}
|
|
ali@109
|
93 |
|
|
ali@109
|
94 |
static void plover_local_distributions_finalize(GObject *obj)
|
|
ali@109
|
95 |
{
|
|
ali@109
|
96 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
97 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(obj);
|
|
ali@109
|
98 |
g_list_foreach(priv->distributions,(GFunc)plover_local_distribution_free,
|
|
ali@109
|
99 |
NULL);
|
|
ali@109
|
100 |
g_list_free(priv->distributions);
|
|
ali@109
|
101 |
if (G_OBJECT_CLASS(plover_local_distributions_parent_class)->finalize)
|
|
ali@109
|
102 |
G_OBJECT_CLASS(plover_local_distributions_parent_class)->finalize(obj);
|
|
ali@109
|
103 |
}
|
|
ali@109
|
104 |
|
|
ali@109
|
105 |
static void
|
|
ali@109
|
106 |
plover_local_distributions_class_init(PloverLocalDistributionsClass *klass)
|
|
ali@109
|
107 |
{
|
|
ali@109
|
108 |
GObjectClass *oclass=G_OBJECT_CLASS(klass);
|
|
ali@109
|
109 |
oclass->finalize=plover_local_distributions_finalize;
|
|
ali@109
|
110 |
g_type_class_add_private(klass,sizeof(PloverLocalDistributionsPrivate));
|
|
ali@109
|
111 |
column_types[PLOVER_LOCAL_DISTRIBUTIONS_VENDOR_COLUMN]=G_TYPE_STRING;
|
|
ali@109
|
112 |
column_types[PLOVER_LOCAL_DISTRIBUTIONS_DISTRIBUTION_COLUMN]=G_TYPE_STRING;
|
|
ali@109
|
113 |
column_types[PLOVER_LOCAL_DISTRIBUTIONS_PREFIX_COLUMN]=G_TYPE_STRING;
|
|
ali@109
|
114 |
column_types[PLOVER_LOCAL_DISTRIBUTIONS_USER_FRIENDLY_COLUMN]=G_TYPE_STRING;
|
|
ali@109
|
115 |
column_types[PLOVER_LOCAL_DISTRIBUTIONS_DATABASE_URI_COLUMN]=G_TYPE_STRING;
|
|
ali@109
|
116 |
}
|
|
ali@109
|
117 |
|
|
ali@109
|
118 |
static GtkTreeModelFlags
|
|
ali@109
|
119 |
plover_local_distributions_get_flags(GtkTreeModel *tree_model)
|
|
ali@109
|
120 |
{
|
|
ali@109
|
121 |
return GTK_TREE_MODEL_ITERS_PERSIST|GTK_TREE_MODEL_LIST_ONLY;
|
|
ali@109
|
122 |
}
|
|
ali@109
|
123 |
|
|
ali@109
|
124 |
static gint plover_local_distributions_get_n_columns(GtkTreeModel *tree_model)
|
|
ali@109
|
125 |
{
|
|
ali@109
|
126 |
return PLOVER_LOCAL_DISTRIBUTIONS_NO_COLUMNS;
|
|
ali@109
|
127 |
}
|
|
ali@109
|
128 |
|
|
ali@109
|
129 |
static GType
|
|
ali@109
|
130 |
plover_local_distributions_get_column_type(GtkTreeModel *tree_model,gint indx)
|
|
ali@109
|
131 |
{
|
|
ali@109
|
132 |
g_return_val_if_fail(indx>=0 && indx<PLOVER_LOCAL_DISTRIBUTIONS_NO_COLUMNS,
|
|
ali@109
|
133 |
G_TYPE_INVALID);
|
|
ali@109
|
134 |
return column_types[indx];
|
|
ali@109
|
135 |
}
|
|
ali@109
|
136 |
|
|
ali@109
|
137 |
static gboolean plover_local_distributions_get_iter(GtkTreeModel *tree_model,
|
|
ali@109
|
138 |
GtkTreeIter *iter,GtkTreePath *path)
|
|
ali@109
|
139 |
{
|
|
ali@109
|
140 |
int i;
|
|
ali@109
|
141 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
142 |
PloverLocalDistributions *local=(PloverLocalDistributions *)tree_model;
|
|
ali@109
|
143 |
PloverLocalDistribution *ld;
|
|
ali@109
|
144 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(local);
|
|
ali@109
|
145 |
i=gtk_tree_path_get_indices(path)[0];
|
|
ali@109
|
146 |
ld=g_list_nth_data(priv->distributions,i);
|
|
ali@109
|
147 |
if (!ld)
|
|
ali@109
|
148 |
return FALSE;
|
|
ali@109
|
149 |
iter->stamp=priv->stamp;
|
|
ali@109
|
150 |
iter->user_data=ld;
|
|
ali@109
|
151 |
return TRUE;
|
|
ali@109
|
152 |
}
|
|
ali@109
|
153 |
|
|
ali@109
|
154 |
static GtkTreePath *
|
|
ali@109
|
155 |
plover_local_distributions_get_path(GtkTreeModel *tree_model,
|
|
ali@109
|
156 |
GtkTreeIter *iter)
|
|
ali@109
|
157 |
{
|
|
ali@109
|
158 |
GtkTreePath *path;
|
|
ali@109
|
159 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
160 |
PloverLocalDistributions *local=(PloverLocalDistributions *)tree_model;
|
|
ali@109
|
161 |
g_return_val_if_fail(VALID_ITER(iter,tree_model),NULL);
|
|
ali@109
|
162 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(local);
|
|
ali@109
|
163 |
path=gtk_tree_path_new();
|
|
ali@109
|
164 |
gtk_tree_path_append_index(path,
|
|
ali@109
|
165 |
g_list_index(priv->distributions,iter->user_data));
|
|
ali@109
|
166 |
return path;
|
|
ali@109
|
167 |
}
|
|
ali@109
|
168 |
|
|
ali@109
|
169 |
static void plover_local_distributions_get_value(GtkTreeModel *tree_model,
|
|
ali@109
|
170 |
GtkTreeIter *iter,gint column,GValue *value)
|
|
ali@109
|
171 |
{
|
|
ali@109
|
172 |
gchar *s;
|
|
ali@109
|
173 |
PloverLocalDistributions *local=(PloverLocalDistributions *)tree_model;
|
|
ali@109
|
174 |
PloverLocalDistribution *ld;
|
|
ali@109
|
175 |
g_return_if_fail(column>=0 && column<PLOVER_LOCAL_DISTRIBUTIONS_NO_COLUMNS);
|
|
ali@109
|
176 |
g_return_if_fail(VALID_ITER(iter,local));
|
|
ali@109
|
177 |
ld=iter->user_data;
|
|
ali@109
|
178 |
g_value_init(value,column_types[column]);
|
|
ali@109
|
179 |
switch((PloverLocalDistributionsColumn)column)
|
|
ali@109
|
180 |
{
|
|
ali@109
|
181 |
case PLOVER_LOCAL_DISTRIBUTIONS_VENDOR_COLUMN:
|
|
ali@109
|
182 |
g_value_set_string(value,ld->vendor);
|
|
ali@109
|
183 |
break;
|
|
ali@109
|
184 |
case PLOVER_LOCAL_DISTRIBUTIONS_DISTRIBUTION_COLUMN:
|
|
ali@109
|
185 |
g_value_set_string(value,ld->distribution);
|
|
ali@109
|
186 |
break;
|
|
ali@109
|
187 |
case PLOVER_LOCAL_DISTRIBUTIONS_PREFIX_COLUMN:
|
|
ali@109
|
188 |
g_value_set_string(value,ld->prefix);
|
|
ali@109
|
189 |
break;
|
|
ali@109
|
190 |
case PLOVER_LOCAL_DISTRIBUTIONS_USER_FRIENDLY_COLUMN:
|
|
ali@109
|
191 |
g_value_set_string(value,ld->user_friendly);
|
|
ali@109
|
192 |
break;
|
|
ali@109
|
193 |
case PLOVER_LOCAL_DISTRIBUTIONS_DATABASE_URI_COLUMN:
|
|
ali@109
|
194 |
g_value_set_string(value,ld->database_uri);
|
|
ali@109
|
195 |
break;
|
|
ali@109
|
196 |
case PLOVER_LOCAL_DISTRIBUTIONS_NO_COLUMNS:
|
|
ali@109
|
197 |
/* Quieten compiler warning */
|
|
ali@109
|
198 |
break;
|
|
ali@109
|
199 |
}
|
|
ali@109
|
200 |
}
|
|
ali@109
|
201 |
|
|
ali@109
|
202 |
static gboolean
|
|
ali@109
|
203 |
plover_local_distributions_iter_next(GtkTreeModel *tree_model,
|
|
ali@109
|
204 |
GtkTreeIter *iter)
|
|
ali@109
|
205 |
{
|
|
ali@109
|
206 |
GList *lnk;
|
|
ali@109
|
207 |
PloverLocalDistributions *local=(PloverLocalDistributions *)tree_model;
|
|
ali@109
|
208 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
209 |
g_return_val_if_fail(VALID_ITER(iter,tree_model),FALSE);
|
|
ali@109
|
210 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(local);
|
|
ali@109
|
211 |
lnk=g_list_find(priv->distributions,iter->user_data);
|
|
ali@109
|
212 |
iter->user_data=lnk->next?lnk->next->data:NULL;
|
|
ali@109
|
213 |
return !!iter->user_data;
|
|
ali@109
|
214 |
}
|
|
ali@109
|
215 |
|
|
ali@109
|
216 |
static gboolean
|
|
ali@109
|
217 |
plover_local_distributions_iter_children(GtkTreeModel *tree_model,
|
|
ali@109
|
218 |
GtkTreeIter *iter,GtkTreeIter *parent)
|
|
ali@109
|
219 |
{
|
|
ali@109
|
220 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
221 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(tree_model);
|
|
ali@109
|
222 |
/* this is a list, nodes have no children */
|
|
ali@109
|
223 |
if (parent)
|
|
ali@109
|
224 |
return FALSE;
|
|
ali@109
|
225 |
if (priv->distributions)
|
|
ali@109
|
226 |
{
|
|
ali@109
|
227 |
iter->stamp=priv->stamp;
|
|
ali@109
|
228 |
iter->user_data=priv->distributions->data;
|
|
ali@109
|
229 |
return TRUE;
|
|
ali@109
|
230 |
}
|
|
ali@109
|
231 |
else
|
|
ali@109
|
232 |
return FALSE;
|
|
ali@109
|
233 |
}
|
|
ali@109
|
234 |
|
|
ali@109
|
235 |
static gboolean
|
|
ali@109
|
236 |
plover_local_distributions_iter_has_child(GtkTreeModel *tree_model,
|
|
ali@109
|
237 |
GtkTreeIter *iter)
|
|
ali@109
|
238 |
{
|
|
ali@109
|
239 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
240 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(tree_model);
|
|
ali@109
|
241 |
return !!priv->distributions;
|
|
ali@109
|
242 |
}
|
|
ali@109
|
243 |
|
|
ali@109
|
244 |
static gint plover_local_distributions_iter_n_children(GtkTreeModel *tree_model,
|
|
ali@109
|
245 |
GtkTreeIter *iter)
|
|
ali@109
|
246 |
{
|
|
ali@109
|
247 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
248 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(tree_model);
|
|
ali@109
|
249 |
if (!iter)
|
|
ali@109
|
250 |
return g_list_length(priv->distributions);
|
|
ali@109
|
251 |
g_return_val_if_fail(VALID_ITER(iter,tree_model),-1);
|
|
ali@109
|
252 |
return 0;
|
|
ali@109
|
253 |
}
|
|
ali@109
|
254 |
|
|
ali@109
|
255 |
static gboolean
|
|
ali@109
|
256 |
plover_local_distributions_iter_nth_child(GtkTreeModel *tree_model,
|
|
ali@109
|
257 |
GtkTreeIter *iter,GtkTreeIter *parent,gint n)
|
|
ali@109
|
258 |
{
|
|
ali@109
|
259 |
GList *lnk;
|
|
ali@109
|
260 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
261 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(tree_model);
|
|
ali@109
|
262 |
if (parent)
|
|
ali@109
|
263 |
return FALSE;
|
|
ali@109
|
264 |
lnk=g_list_nth(priv->distributions,n);
|
|
ali@109
|
265 |
if (!lnk)
|
|
ali@109
|
266 |
return FALSE;
|
|
ali@109
|
267 |
iter->stamp=priv->stamp;
|
|
ali@109
|
268 |
iter->user_data=lnk->data;
|
|
ali@109
|
269 |
return TRUE;
|
|
ali@109
|
270 |
}
|
|
ali@109
|
271 |
|
|
ali@109
|
272 |
static gboolean plover_local_distributions_iter_parent(GtkTreeModel *tree_model,
|
|
ali@109
|
273 |
GtkTreeIter *iter,GtkTreeIter *child)
|
|
ali@109
|
274 |
{
|
|
ali@109
|
275 |
return FALSE;
|
|
ali@109
|
276 |
}
|
|
ali@109
|
277 |
|
|
ali@109
|
278 |
static void plover_local_distributions_tree_model_init(GtkTreeModelIface *iface)
|
|
ali@109
|
279 |
{
|
|
ali@109
|
280 |
iface->get_flags=plover_local_distributions_get_flags;
|
|
ali@109
|
281 |
iface->get_n_columns=plover_local_distributions_get_n_columns;
|
|
ali@109
|
282 |
iface->get_column_type=plover_local_distributions_get_column_type;
|
|
ali@109
|
283 |
iface->get_iter=plover_local_distributions_get_iter;
|
|
ali@109
|
284 |
iface->get_path=plover_local_distributions_get_path;
|
|
ali@109
|
285 |
iface->get_value=plover_local_distributions_get_value;
|
|
ali@109
|
286 |
iface->iter_next=plover_local_distributions_iter_next;
|
|
ali@109
|
287 |
iface->iter_children=plover_local_distributions_iter_children;
|
|
ali@109
|
288 |
iface->iter_has_child=plover_local_distributions_iter_has_child;
|
|
ali@109
|
289 |
iface->iter_n_children=plover_local_distributions_iter_n_children;
|
|
ali@109
|
290 |
iface->iter_nth_child=plover_local_distributions_iter_nth_child;
|
|
ali@109
|
291 |
iface->iter_parent=plover_local_distributions_iter_parent;
|
|
ali@109
|
292 |
}
|
|
ali@109
|
293 |
|
|
ali@109
|
294 |
static void plover_local_distributions_init(PloverLocalDistributions *store)
|
|
ali@109
|
295 |
{
|
|
ali@109
|
296 |
gchar *s;
|
|
ali@109
|
297 |
const char *vendor_prefix,*vendor,*distribution;
|
|
ali@109
|
298 |
GDir *vendor_dir,*distribution_dir,*database_dir;
|
|
ali@109
|
299 |
PloverLocalDistributionsPrivate *priv;
|
|
ali@109
|
300 |
PloverLocalDistribution *ld;
|
|
ali@109
|
301 |
priv=PLOVER_LOCAL_DISTRIBUTIONS_GET_PRIVATE(store);
|
|
ali@109
|
302 |
/*
|
|
ali@109
|
303 |
* local distribution databases may be found in
|
|
ali@109
|
304 |
* <vendor-prefix>/$VENDOR/$DISTRIBUTION/var/lib/razor and
|
|
ali@109
|
305 |
* <vendor-prefix>/$VENDOR/var/lib/razor
|
|
ali@109
|
306 |
*/
|
|
ali@109
|
307 |
vendor_prefix=plover_get_vendor_prefix();
|
|
ali@109
|
308 |
g_message("Vendor prefix is %s",vendor_prefix);
|
|
ali@109
|
309 |
vendor_dir=g_dir_open(vendor_prefix,0,NULL);
|
|
ali@109
|
310 |
if (!vendor_dir)
|
|
ali@109
|
311 |
{
|
|
ali@109
|
312 |
g_warning("Failed to open %s",vendor_prefix);
|
|
ali@109
|
313 |
return;
|
|
ali@109
|
314 |
}
|
|
ali@109
|
315 |
while((vendor=g_dir_read_name(vendor_dir)))
|
|
ali@109
|
316 |
{
|
|
ali@109
|
317 |
g_message("Candidate for vendor is %s",vendor);
|
|
ali@109
|
318 |
s=g_build_filename(vendor_prefix,vendor,NULL);
|
|
ali@109
|
319 |
distribution_dir=g_dir_open(s,0,NULL);
|
|
ali@109
|
320 |
g_free(s);
|
|
ali@109
|
321 |
if (!distribution_dir)
|
|
ali@109
|
322 |
{
|
|
ali@109
|
323 |
g_warning("Failed to open %s/%s",vendor_prefix,vendor);
|
|
ali@109
|
324 |
continue;
|
|
ali@109
|
325 |
}
|
|
ali@109
|
326 |
while((distribution=g_dir_read_name(distribution_dir)))
|
|
ali@109
|
327 |
{
|
|
ali@109
|
328 |
g_message("Candidate for distribution is %s",distribution);
|
|
ali@109
|
329 |
if (!strcmp(distribution,"var"))
|
|
ali@109
|
330 |
{
|
|
ali@109
|
331 |
s=g_build_filename(vendor_prefix,vendor,"var","lib","razor",
|
|
ali@109
|
332 |
NULL);
|
|
ali@109
|
333 |
database_dir=g_dir_open(s,0,NULL);
|
|
ali@109
|
334 |
g_free(s);
|
|
ali@109
|
335 |
if (database_dir)
|
|
ali@109
|
336 |
{
|
|
ali@109
|
337 |
ld=plover_local_distribution_new(vendor,NULL);
|
|
ali@109
|
338 |
g_message("Found vendor-specific razor database at %s",
|
|
ali@109
|
339 |
ld->database_uri);
|
|
ali@109
|
340 |
priv->distributions=g_list_prepend(priv->distributions,ld);
|
|
ali@109
|
341 |
g_dir_close(database_dir);
|
|
ali@109
|
342 |
}
|
|
ali@109
|
343 |
else
|
|
ali@109
|
344 |
g_warning("Failed to open %s/%s/var/lib/razor",
|
|
ali@109
|
345 |
vendor_prefix,vendor);
|
|
ali@109
|
346 |
}
|
|
ali@109
|
347 |
s=g_build_filename(vendor_prefix,vendor,distribution,
|
|
ali@109
|
348 |
"var","lib","razor",NULL);
|
|
ali@109
|
349 |
database_dir=g_dir_open(s,0,NULL);
|
|
ali@109
|
350 |
g_free(s);
|
|
ali@109
|
351 |
if (database_dir)
|
|
ali@109
|
352 |
{
|
|
ali@109
|
353 |
ld=plover_local_distribution_new(vendor,distribution);
|
|
ali@109
|
354 |
g_message("Found local-distribution razor database at %s",
|
|
ali@109
|
355 |
ld->database_uri);
|
|
ali@109
|
356 |
priv->distributions=g_list_prepend(priv->distributions,ld);
|
|
ali@109
|
357 |
g_dir_close(database_dir);
|
|
ali@109
|
358 |
}
|
|
ali@109
|
359 |
else
|
|
ali@109
|
360 |
g_warning("Failed to open %s/%s/%s/var/lib/razor",
|
|
ali@109
|
361 |
vendor_prefix,vendor,distribution);
|
|
ali@109
|
362 |
}
|
|
ali@109
|
363 |
g_dir_close(distribution_dir);
|
|
ali@109
|
364 |
}
|
|
ali@109
|
365 |
g_dir_close(vendor_dir);
|
|
ali@109
|
366 |
priv->stamp=g_random_int();
|
|
ali@109
|
367 |
}
|
|
ali@109
|
368 |
|
|
ali@109
|
369 |
PloverLocalDistributions *plover_local_distributions_new(void)
|
|
ali@109
|
370 |
{
|
|
ali@109
|
371 |
return g_object_new(PLOVER_TYPE_LOCAL_DISTRIBUTIONS,NULL);
|
|
ali@109
|
372 |
}
|