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
160
161
162
163
164
165
166
167
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */
/*
* This file is part of mission-control
*
* Copyright (C) 2007 Nokia Corporation.
*
* Contact: Naba Kumar <naba.kumar@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* 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., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <glib/gi18n.h>
#include <config.h>
#include "mcd-account-manager.h"
#include "mcd-account.h"
#include "mcd-account-priv.h"
#define MCD_ACCOUNT_MANAGER_PRIV(account_manager) \
(MCD_ACCOUNT_MANAGER (account_manager)->priv)
static void account_manager_iface_init (McSvcAccountManagerClass *iface,
gpointer iface_data);
G_DEFINE_TYPE_WITH_CODE (McdAccountManager, mcd_account_manager, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (MC_TYPE_SVC_ACCOUNT_MANAGER,
account_manager_iface_init);
)
struct _McdAccountManagerPrivate
{
/* DBUS connection */
TpDBusDaemon *dbus_daemon;
};
enum
{
PROP_0,
PROP_DBUS_DAEMON,
};
static void
account_manager_iface_init (McSvcAccountManagerClass *iface,
gpointer iface_data)
{
}
static void
register_dbus_service (McdAccountManager *account_manager)
{
McdAccountManagerPrivate *priv = account_manager->priv;
DBusGConnection *dbus_connection;
dbus_connection = TP_PROXY (priv->dbus_daemon)->dbus_connection;
if (G_LIKELY (dbus_connection))
dbus_g_connection_register_g_object (dbus_connection,
MC_ACCOUNT_MANAGER_DBUS_OBJECT,
G_OBJECT (account_manager));
}
static void
set_property (GObject *obj, guint prop_id,
const GValue *val, GParamSpec *pspec)
{
McdAccountManagerPrivate *priv = MCD_ACCOUNT_MANAGER_PRIV (obj);
switch (prop_id)
{
case PROP_DBUS_DAEMON:
if (priv->dbus_daemon)
g_object_unref (priv->dbus_daemon);
priv->dbus_daemon = TP_DBUS_DAEMON (g_value_dup_object (val));
if (priv->dbus_daemon)
register_dbus_service (MCD_ACCOUNT_MANAGER (obj));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static void
get_property (GObject *obj, guint prop_id,
GValue *val, GParamSpec *pspec)
{
McdAccountManagerPrivate *priv = MCD_ACCOUNT_MANAGER_PRIV (obj);
switch (prop_id)
{
case PROP_DBUS_DAEMON:
g_value_set_object (val, priv->dbus_daemon);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
}
}
static void
_mcd_account_manager_finalize (GObject *object)
{
G_OBJECT_CLASS (mcd_account_manager_parent_class)->finalize (object);
}
static void
_mcd_account_manager_dispose (GObject *object)
{
G_OBJECT_CLASS (mcd_account_manager_parent_class)->dispose (object);
}
static void
mcd_account_manager_class_init (McdAccountManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (McdAccountManagerPrivate));
object_class->dispose = _mcd_account_manager_dispose;
object_class->finalize = _mcd_account_manager_finalize;
object_class->set_property = set_property;
object_class->get_property = get_property;
g_object_class_install_property (object_class, PROP_DBUS_DAEMON,
g_param_spec_object ("dbus-daemon",
_("DBus daemon"),
_("DBus daemon"),
TP_TYPE_DBUS_DAEMON,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
mcd_account_manager_init (McdAccountManager *account_manager)
{
McdAccountManagerPrivate *priv;
priv = G_TYPE_INSTANCE_GET_PRIVATE ((account_manager),
MCD_TYPE_ACCOUNT_MANAGER,
McdAccountManagerPrivate);
account_manager->priv = priv;
}
McdAccountManager *
mcd_account_manager_new (TpDBusDaemon *dbus_daemon)
{
gpointer *obj;
obj = g_object_new (MCD_TYPE_ACCOUNT_MANAGER,
"dbus-daemon", &dbus_daemon,
NULL);
return MCD_ACCOUNT_MANAGER (obj);
}
|