summaryrefslogtreecommitdiff
path: root/engine/dconf-engine.h
blob: d2058d5742438c0c29464289acfce8b72eab59cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright © 2010 Codethink Limited
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the licence, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: Ryan Lortie <desrt@desrt.ca>
 */

#ifndef __dconf_engine_h__
#define __dconf_engine_h__

#include <dconf-readtype.h>
#include <dconf-resetlist.h>
#include <glib.h>

typedef struct _DConfEngine DConfEngine;

/**
 * DConfEngineMessage:
 *
 * This structure represents a number of DBus method call messages that #DConfEngine would like to send.
 *
 * #DConfEngine itself is unaware of a particular DBus or main loop implementation.  As such, all requests are
 * synchronous and non-blocking, but most of them produce a #DConfEngineMessage describing messages that must be
 * sent in order for the operation to be completed.
 *
 * @bus_name, @object_path, @interface_name, @method_name specify the respective header fields of the method
 * call.  These are always equal for all of the calls contained within a single #DConfEngineMessage.
 *
 * @reply_type is the expected reply type of the method call.  This is also the same for all calls contained
 * within a single #DConfEngineMessage.
 *
 * @n_messages is the number of messages to send.
 *
 * @bus_types and @parameters are both arrays, of length @n_messages.  Each element of @bus_type is the bus type
 * to send each method call on and each of @parameters is the body of that call.  The reason that there may be
 * several messages is that a single dconf "watch" operation may need to send multiple DBus "AddMatch" calls
 * (and usually to multiple busses).
 *
 * Each element in @bus_types is either 'y' for system bus or 'e' for session bus.
 *
 * A #DConfEngineMessage is always stack-allocated by the caller.  It must be cleared using
 * dconf_engine_message_destroy() when done.  It may be copied using dconf_engine_message_copy().
 */
typedef struct
{
  const gchar         *bus_name;
  const gchar         *object_path;
  const gchar         *interface_name;
  const gchar         *method_name;

  gint                 n_messages;
  GVariant           **parameters;
  const gchar         *bus_types;

  const GVariantType  *reply_type;
} DConfEngineMessage;

typedef GVariant *    (*DConfEngineServiceFunc)                         (DConfEngineMessage      *message);
G_GNUC_INTERNAL
void                    dconf_engine_message_copy                       (DConfEngineMessage      *orig,
                                                                         DConfEngineMessage      *copy);
G_GNUC_INTERNAL
void                    dconf_engine_message_destroy                    (DConfEngineMessage      *message);

G_GNUC_INTERNAL
void                    dconf_engine_set_service_func                   (DConfEngineServiceFunc   func);
G_GNUC_INTERNAL
DConfEngine *           dconf_engine_new                                (const gchar             *profile);
G_GNUC_INTERNAL
DConfEngine *           dconf_engine_new_for_db                         (DConfEngineServiceFunc  *service,
                                                                         const gchar             *db_name);
G_GNUC_INTERNAL
guint64                 dconf_engine_get_state                          (DConfEngine             *engine);

G_GNUC_INTERNAL
void                    dconf_engine_free                               (DConfEngine             *engine);

G_GNUC_INTERNAL
GVariant *              dconf_engine_read                               (DConfEngine             *engine,
                                                                         const gchar             *key);
G_GNUC_INTERNAL
GVariant *              dconf_engine_read_default                       (DConfEngine             *engine,
                                                                         const gchar             *key);
G_GNUC_INTERNAL
GVariant *              dconf_engine_read_no_default                    (DConfEngine             *engine,
                                                                         const gchar             *key);
G_GNUC_INTERNAL
gchar **                dconf_engine_list                               (DConfEngine             *engine,
                                                                         const gchar             *path,
                                                                         DConfResetList          *resets,
                                                                         gint                    *length);

G_GNUC_INTERNAL
void                    dconf_engine_get_service_info                   (DConfEngine             *engine,
                                                                         const gchar            **bus_type,
                                                                         const gchar            **destination,
                                                                         const gchar            **object_path);
G_GNUC_INTERNAL
gboolean                dconf_engine_is_writable                        (DConfEngine             *engine,
                                                                         const gchar             *name);
G_GNUC_INTERNAL
gboolean                dconf_engine_write                              (DConfEngine             *engine,
                                                                         const gchar             *key,
                                                                         GVariant                *value,
                                                                         DConfEngineMessage      *message,
                                                                         GError                 **error);
G_GNUC_INTERNAL
gboolean                dconf_engine_write_many                         (DConfEngine             *engine,
                                                                         const gchar             *prefix,
                                                                         const gchar * const     *keys,
                                                                         GVariant               **values,
                                                                         DConfEngineMessage      *message,
                                                                         GError                 **error);
G_GNUC_INTERNAL
void                    dconf_engine_watch                              (DConfEngine             *engine,
                                                                         const gchar             *name,
                                                                         DConfEngineMessage      *message);
G_GNUC_INTERNAL
void                    dconf_engine_unwatch                            (DConfEngine             *engine,
                                                                         const gchar             *name,
                                                                         DConfEngineMessage      *message);
G_GNUC_INTERNAL
gboolean                dconf_engine_decode_notify                      (DConfEngine             *engine,
                                                                         const gchar             *anti_expose,
                                                                         const gchar            **prefix,
                                                                         const gchar           ***keys,
                                                                         guint                    bus_type,
                                                                         const gchar             *sender,
                                                                         const gchar             *interface,
                                                                         const gchar             *member,
                                                                         GVariant                *body);
G_GNUC_INTERNAL
void                    dconf_engine_set_locked                         (DConfEngine             *engine,
                                                                         const gchar             *path,
                                                                         gboolean                 locked,
                                                                         DConfEngineMessage      *message);

G_GNUC_INTERNAL
gboolean                dconf_engine_interpret_reply                    (DConfEngineMessage      *message,
                                                                         const gchar             *sender,
                                                                         GVariant                *body,
                                                                         gchar                  **tag,
                                                                         GError                 **error);

#endif /* __dconf_engine_h__ */