2 * Copyright © 2010 Codethink Limited
3 * Copyright © 2012 Canonical Limited
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the licence, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ryan Lortie <desrt@desrt.ca>
23 #include "dconf-engine-source-private.h"
25 #include "dconf-engine.h"
31 dconf_engine_source_service_init (DConfEngineSource
*source
)
33 source
->bus_type
= G_BUS_TYPE_SESSION
;
34 source
->bus_name
= g_strdup ("ca.desrt.dconf");
35 source
->object_path
= g_strdup_printf ("/ca/desrt/dconf/%s", source
->name
);
36 source
->writable
= TRUE
;
38 dconf_engine_dbus_call_sync_func (source
->bus_type
, source
->bus_name
, source
->object_path
,
39 "ca.desrt.dconf.Writer", "Init", NULL
, NULL
, NULL
);
43 dconf_engine_source_service_needs_reopen (DConfEngineSource
*source
)
45 return !source
->values
|| !gvdb_table_is_valid (source
->values
);
49 dconf_engine_source_service_reopen (DConfEngineSource
*source
)
51 static gboolean did_warn
;
56 filename
= g_build_filename (g_get_user_runtime_dir (), "dconf-service", source
->name
, NULL
);
57 table
= gvdb_table_new (filename
, FALSE
, &error
);
63 g_critical ("unable to open file '%s': %s; expect degraded performance", filename
, error
->message
);
76 dconf_engine_source_service_finalize (DConfEngineSource
*source
)
81 const DConfEngineSourceVTable dconf_engine_source_service_vtable
= {
82 .instance_size
= sizeof (DConfEngineSource
),
83 .init
= dconf_engine_source_service_init
,
84 .finalize
= dconf_engine_source_service_finalize
,
85 .needs_reopen
= dconf_engine_source_service_needs_reopen
,
86 .reopen
= dconf_engine_source_service_reopen