annotate src/dbus-server.c @ 11070:fdb8ba7a4857

[gaim-migrate @ 13069] I (apparently) don't have dbus. configure still needs to work. I'm also fixing some warnings with src/Makefile.am introduced by the dbus commits. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Fri, 08 Jul 2005 05:11:08 +0000
parents 9bd0aac996f4
children f54740547c95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
1 /*
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
2 * gaim
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
3 *
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
6 * source distribution.
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
7 *
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
11 * (at your option) any later version.
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
12 *
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
16 * GNU General Public License for more details.
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
17 *
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
21 *
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
22 */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
23
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
24 #include <dbus/dbus-glib.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
25 #include <dbus/dbus-glib-bindings.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
26 #include <stdio.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
27 #include <stdlib.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
28 #include <string.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
29 #include <glib/gi18n.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
30 #include <glib-object.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
31 #include <glib/gquark.h>
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
32
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
33 #include "account.h"
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
34 #include "blist.h"
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
35 #include "conversation.h"
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
36 #include "dbus-gaim.h"
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
37 #include "dbus-server.h"
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
38 #include "debug.h"
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
39 #include "core.h"
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
40 #include "value.h"
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
41
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
42 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
43 /** @name Lots of GObject crap I don't understand */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
44 /**************************************************************************/
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
45
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
46 typedef struct GaimObject GaimObject;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
47 typedef struct GaimObjectClass GaimObjectClass;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
48
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
49 GType gaim_object_get_type(void);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
50
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
51 struct GaimObject {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
52 GObject parent;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
53 };
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
54
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
55 struct GaimObjectClass {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
56 GObjectClass parent;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
57 };
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
58
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
59 #define GAIM_TYPE_OBJECT (gaim_object_get_type ())
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
60 #define GAIM_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GAIM_TYPE_OBJECT, GaimObject))
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
61 #define GAIM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAIM_TYPE_OBJECT, GaimObjectClass))
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
62 #define GAIM_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GAIM_TYPE_OBJECT))
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
63 #define GAIM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAIM_TYPE_OBJECT))
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
64 #define GAIM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAIM_TYPE_OBJECT, GaimObjectClass))
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
65
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
66 G_DEFINE_TYPE(GaimObject, gaim_object, G_TYPE_OBJECT)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
67
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
68
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
69 static void
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
70 gaim_object_init(GaimObject *obj)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
71 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
72 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
73
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
74 static void
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
75 gaim_object_class_init(GaimObjectClass *mobject_class)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
76 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
77 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
78
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
79 static GObject *gaim_object;
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
80 static GQuark gaim_object_error_quark;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
81
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
82
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
83
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
84 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
85 /** @name Utility functions */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
86 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
87
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
88 #define error_unless_1(condition, str, parameter) \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
89 if (!(condition)) { \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
90 g_set_error(error, gaim_object_error_quark, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
91 DBUS_ERROR_NOT_FOUND, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
92 str, parameter); \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
93 return FALSE; \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
94 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
95
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
96 #define error_unless_2(condition, str, a,b) \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
97 if (!(condition)) { \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
98 g_set_error(error, gaim_object_error_quark, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
99 DBUS_ERROR_NOT_FOUND, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
100 str, a,b); \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
101 return FALSE; \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
102 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
103
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
104 static const char* null_to_empty(const char *s) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
105 if (s)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
106 return s;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
107 else
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
108 return "";
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
109 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
110
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
111 typedef gboolean (*GaimNodeFilter)(GaimBlistNode *node, gpointer *user_data);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
112
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
113 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
114 filter_is_buddy(GaimBlistNode *node, gpointer *user_data)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
115 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
116 return GAIM_BLIST_NODE_IS_BUDDY(node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
117 }
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
118
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
119 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
120 filter_is_online_buddy(GaimBlistNode *node,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
121 gpointer *user_data)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
122 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
123 return GAIM_BLIST_NODE_IS_BUDDY(node) &&
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
124 GAIM_BUDDY_IS_ONLINE((GaimBuddy *)node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
125 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
126
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
127
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
128 static GList*
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
129 get_buddy_list (GList *created_list, /**< can be NULL */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
130 GaimBlistNode *gaim_buddy_list, /**< can be NULL */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
131 GaimNodeFilter filter,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
132 gpointer user_data)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
133 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
134 GaimBlistNode *node;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
135
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
136 for(node = gaim_buddy_list; node; node = node->next)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
137 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
138 if ((*filter)(node, user_data))
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
139 created_list = g_list_prepend(created_list, node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
140
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
141 created_list = get_buddy_list(created_list, node->child,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
142 filter, user_data);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
143 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
144
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
145 return created_list;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
146 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
147
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
148
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
149
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
150 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
151 /** @name Implementations of remote DBUS calls */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
152 /**************************************************************************/
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
153
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
154 static gboolean
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
155 gaim_object_ping(GaimObject *obj, GError **error)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
156 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
157 return TRUE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
158 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
159
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
160 static gboolean
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
161 gaim_object_quit(GaimObject *obj, GError **error)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
162 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
163 g_timeout_add(0, gaim_core_quit_cb, NULL);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
164 return TRUE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
165 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
166
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
167 static gboolean
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
168 gaim_object_connect_all(GaimObject *obj, GError **error)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
169 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
170 GList *cur;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
171
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
172 for (cur = gaim_accounts_get_all(); cur != NULL; cur = cur->next)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
173 gaim_account_connect((GaimAccount*) cur->data);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
174
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
175 return TRUE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
176 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
177
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
178
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
179
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
180 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
181 gaim_object_get_buddy_list (GaimObject *obj, GArray **out_buddy_ids,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
182 GError **error)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
183 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
184 GList *node;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
185 GList *buddy_list = get_buddy_list(NULL, gaim_get_blist()->root,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
186 &filter_is_buddy, NULL);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
187 GArray *buddy_ids = g_array_new(FALSE, TRUE, sizeof(gint32));;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
188
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
189 buddy_list = g_list_reverse(buddy_list);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
190
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
191 for (node = buddy_list; node; node = node->next) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
192 gint32 id = gaim_dbus_pointer_to_id(node->data);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
193 g_array_append_val(buddy_ids, id);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
194 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
195
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
196 g_list_free(buddy_list);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
197 *out_buddy_ids = buddy_ids;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
198
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
199 return TRUE;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
200 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
201
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
202
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
203
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
204
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
205
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
206 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
207 gaim_object_find_account(GaimObject *unused,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
208 const char *account_name, const char *protocol_name,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
209 gint *account_id, GError **error)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
210 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
211 GaimAccount *account = gaim_accounts_find(account_name, protocol_name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
212
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
213 error_unless_2(account, "Account '%s' with protocol '%s' not found",
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
214 account_name, protocol_name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
215
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
216 *account_id = gaim_dbus_pointer_to_id(account);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
217 return TRUE;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
218 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
219
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
220 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
221 gaim_object_find_buddy(GaimObject *unused, gint account_id, const char *buddy_name,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
222 gint *buddy_id, GError **error)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
223 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
224 GaimAccount *account;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
225 GaimBuddy *buddy;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
226
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
227 account = gaim_dbus_id_to_pointer(account_id, DBUS_POINTER_ACCOUNT);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
228 error_unless_1(account, "Invalid account id: %i", account_id);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
229
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
230 buddy = gaim_find_buddy(account, buddy_name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
231 error_unless_1(account, "Buddy '%s' not found.", buddy_name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
232
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
233 *buddy_id = gaim_dbus_pointer_to_id(buddy);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
234 return TRUE;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
235 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
236
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
237 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
238 gaim_object_start_im_conversation (GaimObject *obj, gint buddy_id, GError **error)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
239 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
240 GaimBuddy *buddy = (GaimBuddy*) gaim_dbus_id_to_pointer(buddy_id,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
241 DBUS_POINTER_BUDDY);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
242
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
243 error_unless_1(buddy, "Invalid buddy id: %i", buddy_id);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
244
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
245 gaim_conversation_new(GAIM_CONV_IM, buddy->account, buddy->name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
246
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
247 return TRUE;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
248 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
249
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
250
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
251
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
252 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
253 /** @name Gaim DBUS property handling functions */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
254 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
255
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
256
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
257 typedef struct _GaimDBusProperty {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
258 char *name;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
259 gint offset;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
260 GaimType type;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
261 } GaimDBusProperty;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
262
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
263 /* change GAIM_TYPE into G_TYPE */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
264
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
265 static gboolean
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
266 gaim_dbus_get_property(GaimDBusProperty *list, int list_len,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
267 gpointer data, const char *name,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
268 GValue *value, GError **error)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
269 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
270 int i;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
271
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
272 for(i=0; i<list_len; i++) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
273 if (!strcmp(list[i].name, name)) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
274 gpointer ptr = G_STRUCT_MEMBER_P(data, list[i].offset);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
275 switch(list[i].type) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
276 case GAIM_TYPE_STRING:
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
277 g_value_init(value, G_TYPE_STRING);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
278 g_value_set_string (value, g_strdup(null_to_empty(*(char **)ptr)));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
279 break;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
280
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
281 case GAIM_TYPE_INT:
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
282 g_value_init(value, G_TYPE_INT);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
283 g_value_set_int (value, *(int*) ptr);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
284 break;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
285
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
286 case GAIM_TYPE_BOOLEAN:
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
287 g_value_init(value, G_TYPE_BOOLEAN);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
288 g_value_set_int (value, *(gboolean*) ptr);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
289 break;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
290
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
291 case GAIM_TYPE_POINTER: /* registered pointers only! */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
292 g_value_init(value, G_TYPE_INT);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
293 g_value_set_int (value,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
294 gaim_dbus_pointer_to_id (*(gpointer *)ptr));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
295 break;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
296 default:
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
297 g_assert_not_reached();
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
298 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
299 return TRUE;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
300 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
301 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
302
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
303 g_value_init(value, G_TYPE_INT);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
304 g_value_set_int(value, 0);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
305 error_unless_1(FALSE, "Invalid property '%s'", name);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
306 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
307
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
308
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
309 #define DECLARE_PROPERTY(maintype, name, type) {#name, G_STRUCT_OFFSET(maintype, name), type}
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
310
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
311 GaimDBusProperty buddy_properties [] = {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
312 DECLARE_PROPERTY(GaimBuddy, name, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
313 DECLARE_PROPERTY(GaimBuddy, alias, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
314 DECLARE_PROPERTY(GaimBuddy, server_alias, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
315 DECLARE_PROPERTY(GaimBuddy, account, GAIM_TYPE_POINTER)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
316 };
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
317
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
318 GaimDBusProperty account_properties [] = {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
319 DECLARE_PROPERTY(GaimAccount, username, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
320 DECLARE_PROPERTY(GaimAccount, alias, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
321 DECLARE_PROPERTY(GaimAccount, user_info, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
322 DECLARE_PROPERTY(GaimAccount, protocol_id, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
323 };
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
324
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
325 GaimDBusProperty contact_properties [] = {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
326 DECLARE_PROPERTY(GaimContact, alias, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
327 DECLARE_PROPERTY(GaimContact, totalsize, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
328 DECLARE_PROPERTY(GaimContact, currentsize, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
329 DECLARE_PROPERTY(GaimContact, online, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
330 DECLARE_PROPERTY(GaimContact, priority, GAIM_TYPE_POINTER),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
331 DECLARE_PROPERTY(GaimContact, priority_valid, GAIM_TYPE_BOOLEAN),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
332 };
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
333
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
334 GaimDBusProperty group_properties [] = {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
335 DECLARE_PROPERTY(GaimGroup, name, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
336 DECLARE_PROPERTY(GaimGroup, totalsize, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
337 DECLARE_PROPERTY(GaimGroup, currentsize, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
338 DECLARE_PROPERTY(GaimGroup, online, GAIM_TYPE_INT),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
339 };
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
340
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
341 GaimDBusProperty chat_properties [] = {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
342 DECLARE_PROPERTY(GaimChat, alias, GAIM_TYPE_STRING),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
343 DECLARE_PROPERTY(GaimChat, account, GAIM_TYPE_POINTER),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
344 };
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
345
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
346
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
347 #define DECLARE_PROPERTY_HANDLER(type, gaim_type) \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
348 static gboolean \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
349 gaim_object_get_##type##_property (GaimObject *unused, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
350 gint id, const char *property_name, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
351 GValue *value, GError **error) \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
352 { \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
353 gpointer object = gaim_dbus_id_to_pointer(id, gaim_type); \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
354 \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
355 error_unless_1(object, "Invalid " #type " id: %i", id); \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
356 \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
357 return gaim_dbus_get_property(type##_properties, \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
358 G_N_ELEMENTS(type##_properties), \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
359 object, property_name, value, error); \
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
360 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
361
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
362 DECLARE_PROPERTY_HANDLER(buddy, DBUS_POINTER_BUDDY)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
363 DECLARE_PROPERTY_HANDLER(account, DBUS_POINTER_ACCOUNT)
11068
9bd0aac996f4 [gaim-migrate @ 13049]
Piotr Zielinski <zielaj>
parents: 11067
diff changeset
364 DECLARE_PROPERTY_HANDLER(contact, DBUS_POINTER_CONTACT)
9bd0aac996f4 [gaim-migrate @ 13049]
Piotr Zielinski <zielaj>
parents: 11067
diff changeset
365 DECLARE_PROPERTY_HANDLER(group, DBUS_POINTER_GROUP)
9bd0aac996f4 [gaim-migrate @ 13049]
Piotr Zielinski <zielaj>
parents: 11067
diff changeset
366 DECLARE_PROPERTY_HANDLER(chat, DBUS_POINTER_CHAT)
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
367
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
368 #include "dbus-server-bindings.c"
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
369
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
370
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
371
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
372 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
373 /** @name Gaim DBUS pointer registration mechanism */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
374 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
375
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
376 static GHashTable *map_id_node;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
377 static GHashTable *map_id_type;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
378 static GHashTable *map_node_id;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
379
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
380 void gaim_dbus_init_ids(void) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
381 map_id_node = g_hash_table_new (g_direct_hash, g_direct_equal);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
382 map_id_type = g_hash_table_new (g_direct_hash, g_direct_equal);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
383 map_node_id = g_hash_table_new (g_direct_hash, g_direct_equal);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
384 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
385
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
386 void gaim_dbus_register_pointer(gpointer node, GaimDBusPointerType type)
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
387 {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
388 static gint last_id = 0;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
389 g_assert(g_hash_table_lookup(map_node_id, node) == NULL);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
390
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
391
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
392 last_id++;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
393 g_hash_table_insert(map_node_id, node, GINT_TO_POINTER(last_id));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
394 g_hash_table_insert(map_id_node, GINT_TO_POINTER(last_id), node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
395 g_hash_table_insert(map_id_type, GINT_TO_POINTER(last_id),
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
396 GINT_TO_POINTER(type));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
397 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
398
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
399
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
400 void gaim_dbus_unregister_pointer(gpointer node) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
401 gpointer id = g_hash_table_lookup(map_node_id, node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
402
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
403 g_hash_table_remove(map_node_id, node);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
404 g_hash_table_remove(map_id_node, GINT_TO_POINTER(id));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
405 g_hash_table_remove(map_id_node, GINT_TO_POINTER(id));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
406 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
407
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
408 gint gaim_dbus_pointer_to_id(gpointer node) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
409 gint id = GPOINTER_TO_INT(g_hash_table_lookup(map_node_id, node));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
410 g_assert(id);
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
411 return id;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
412 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
413
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
414 gpointer gaim_dbus_id_to_pointer(gint id, GaimDBusPointerType type) {
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
415 if (type != GPOINTER_TO_INT(g_hash_table_lookup(map_id_type,
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
416 GINT_TO_POINTER(id))))
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
417 return NULL;
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
418 return g_hash_table_lookup(map_id_node, GINT_TO_POINTER(id));
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
419 }
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
420
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
421
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
422
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
423 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
424 /** @name Gaim DBUS init function */
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
425 /**************************************************************************/
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
426
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
427
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
428 gboolean
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
429 dbus_server_init(void)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
430 {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
431 DBusGConnection *connection;
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
432 GError *error = NULL;
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
433 DBusGProxy *driver_proxy;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
434 guint32 request_name_ret;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
435
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
436 gaim_object_error_quark =
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
437 g_quark_from_static_string("org.gaim.GaimError");
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
438
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
439 gaim_debug_misc("dbus", "launching dbus server\n");
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
440
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
441 /* Connect to the bus */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
442
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
443 error = NULL;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
444 connection = dbus_g_bus_get(DBUS_BUS_STARTER, &error);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
445
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
446 if (connection == NULL) {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
447 g_assert(error);
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
448 gaim_debug_error("dbus", "Failed to open connection to bus: %s\n",
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
449 error->message);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
450 g_error_free (error);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
451 return FALSE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
452 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
453
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
454 /* Instantiate the gaim dbus object and register it */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
455
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
456 gaim_object = g_object_new (GAIM_TYPE_OBJECT, NULL);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
457
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
458
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
459 dbus_g_object_type_install_info (GAIM_TYPE_OBJECT,
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
460 &dbus_glib_gaim_object_object_info);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
461
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
462 dbus_g_connection_register_g_object (connection, DBUS_PATH_GAIM,
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
463 gaim_object);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
464
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
465
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
466 /* Obtain a proxy for the DBus object */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
467
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
468 driver_proxy = dbus_g_proxy_new_for_name (connection,
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
469 DBUS_SERVICE_DBUS,
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
470 DBUS_PATH_DBUS,
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
471 DBUS_INTERFACE_DBUS);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
472
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
473 g_assert(driver_proxy);
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
474
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
475 /* Test whether the registration was successful */
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
476
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
477 org_freedesktop_DBus_request_name(driver_proxy, DBUS_SERVICE_GAIM,
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
478 DBUS_NAME_FLAG_PROHIBIT_REPLACEMENT, &request_name_ret, &error);
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
479
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
480 if (error) {
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
481 gaim_debug_error("dbus", "Failed to get name: %s\n", error->message);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
482 g_error_free (error);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
483 return FALSE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
484 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
485
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
486 if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
487 {
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
488 gaim_debug_error ("dbus", "Got result code %u from requesting name\n",
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
489 request_name_ret);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
490 return FALSE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
491 }
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
492
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
493 gaim_debug_misc ("dbus", "GLib test service has name '%s'\n",
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
494 DBUS_SERVICE_GAIM);
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
495 gaim_debug_misc ("dbus", "GLib test service entering main loop\n");
11067
2eca9ed49469 [gaim-migrate @ 13048]
Piotr Zielinski <zielaj>
parents: 11055
diff changeset
496
11055
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
497 return TRUE;
df0241eb602c [gaim-migrate @ 12996]
Piotr Zielinski <zielaj>
parents:
diff changeset
498 }