~ubuntu-branches/ubuntu/maverick/telepathy-glib/maverick

« back to all changes in this revision

Viewing changes to telepathy-glib/account-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-06-26 18:39:28 UTC
  • mfrom: (1.4.1 upstream) (17.2.5 karmic)
  • Revision ID: james.westby@ubuntu.com-20090626183928-8mvdxsfsak23eqcp
Tags: 0.7.33-1
* New upstream version (API, ABI unchanged)
  + Should fix builds on powerpc, sparc etc.
* Standards-Version: 3.8.2 (no changes required)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * account-manager.c - proxy for the Telepathy account manager
 
3
 *
 
4
 * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
 
5
 * Copyright (C) 2009 Nokia Corporation
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2.1 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 */
 
21
 
 
22
#include "telepathy-glib/account-manager.h"
 
23
 
 
24
#include <telepathy-glib/dbus.h>
 
25
#include <telepathy-glib/defs.h>
 
26
#include <telepathy-glib/errors.h>
 
27
#include <telepathy-glib/interfaces.h>
 
28
#include <telepathy-glib/proxy-subclass.h>
 
29
 
 
30
#define DEBUG_FLAG TP_DEBUG_ACCOUNTS
 
31
#include "telepathy-glib/debug-internal.h"
 
32
 
 
33
#include "telepathy-glib/_gen/tp-cli-account-manager-body.h"
 
34
 
 
35
/**
 
36
 * SECTION:account-manager
 
37
 * @title: TpAccountManager
 
38
 * @short_description: proxy object for the Telepathy account manager
 
39
 * @see_also: #TpAccount
 
40
 *
 
41
 * The #TpAccountManager object is used to communicate with the Telepathy
 
42
 * AccountManager service.
 
43
 *
 
44
 * Since: 0.7.32
 
45
 */
 
46
 
 
47
/**
 
48
 * TpAccountManager:
 
49
 *
 
50
 * The Telepathy Account Manager stores real-time communication accounts and
 
51
 * their configuration, places accounts online on request, and manipulates
 
52
 * accounts' presence, nicknames and avatars.
 
53
 *
 
54
 * This proxy is usable but incomplete: GObject signals and accessors for the
 
55
 * D-Bus properties will be added in a later version of telepathy-glib, along
 
56
 * with a mechanism similar to tp_connection_call_when_ready().
 
57
 *
 
58
 * Until suitable convenience methods are implemented, the generic
 
59
 * tp_cli_dbus_properties_call_get_all() method can be used to get the D-Bus
 
60
 * properties.
 
61
 *
 
62
 * Since: 0.7.32
 
63
 */
 
64
 
 
65
/**
 
66
 * TpAccountManagerClass:
 
67
 *
 
68
 * The class of a #TpAccount.
 
69
 */
 
70
 
 
71
struct _TpAccountManagerPrivate {
 
72
    gpointer dummy;
 
73
};
 
74
 
 
75
G_DEFINE_TYPE (TpAccountManager, tp_account_manager, TP_TYPE_PROXY);
 
76
 
 
77
static void
 
78
tp_account_manager_init (TpAccountManager *self)
 
79
{
 
80
  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_ACCOUNT_MANAGER,
 
81
      TpAccountManagerPrivate);
 
82
}
 
83
 
 
84
static void
 
85
tp_account_manager_constructed (GObject *object)
 
86
{
 
87
  TpAccountManager *self = TP_ACCOUNT_MANAGER (object);
 
88
  void (*chain_up) (GObject *) =
 
89
    ((GObjectClass *) tp_account_manager_parent_class)->constructed;
 
90
 
 
91
  if (chain_up != NULL)
 
92
    chain_up (object);
 
93
 
 
94
  g_return_if_fail (tp_proxy_get_dbus_daemon (self) != NULL);
 
95
}
 
96
 
 
97
static void
 
98
tp_account_manager_class_init (TpAccountManagerClass *klass)
 
99
{
 
100
  TpProxyClass *proxy_class = (TpProxyClass *) klass;
 
101
  GObjectClass *object_class = (GObjectClass *) klass;
 
102
 
 
103
  g_type_class_add_private (klass, sizeof (TpAccountManagerPrivate));
 
104
 
 
105
  object_class->constructed = tp_account_manager_constructed;
 
106
 
 
107
  proxy_class->interface = TP_IFACE_QUARK_ACCOUNT_MANAGER;
 
108
  tp_account_manager_init_known_interfaces ();
 
109
}
 
110
 
 
111
/**
 
112
 * tp_account_manager_init_known_interfaces:
 
113
 *
 
114
 * Ensure that the known interfaces for TpAccountManager have been set up.
 
115
 * This is done automatically when necessary, but for correct
 
116
 * overriding of library interfaces by local extensions, you should
 
117
 * call this function before calling
 
118
 * tp_proxy_or_subclass_hook_on_interface_add() with first argument
 
119
 * %TP_TYPE_ACCOUNT_MANAGER.
 
120
 *
 
121
 * Since: 0.7.32
 
122
 */
 
123
void
 
124
tp_account_manager_init_known_interfaces (void)
 
125
{
 
126
  static gsize once = 0;
 
127
 
 
128
  if (g_once_init_enter (&once))
 
129
    {
 
130
      GType tp_type = TP_TYPE_ACCOUNT_MANAGER;
 
131
 
 
132
      tp_proxy_init_known_interfaces ();
 
133
      tp_proxy_or_subclass_hook_on_interface_add (tp_type,
 
134
          tp_cli_account_manager_add_signals);
 
135
      tp_proxy_subclass_add_error_mapping (tp_type,
 
136
          TP_ERROR_PREFIX, TP_ERRORS, TP_TYPE_ERROR);
 
137
 
 
138
      g_once_init_leave (&once, 1);
 
139
    }
 
140
}
 
141
 
 
142
/**
 
143
 * tp_account_manager_new:
 
144
 * @bus_daemon: Proxy for the D-Bus daemon
 
145
 *
 
146
 * Convenience function to create a new account manager proxy.
 
147
 *
 
148
 * Returns: a new reference to an account manager proxy
 
149
 */
 
150
TpAccountManager *
 
151
tp_account_manager_new (TpDBusDaemon *bus_daemon)
 
152
{
 
153
  TpAccountManager *self;
 
154
 
 
155
  g_return_val_if_fail (bus_daemon != NULL, NULL);
 
156
 
 
157
  self = TP_ACCOUNT_MANAGER (g_object_new (TP_TYPE_ACCOUNT_MANAGER,
 
158
        "dbus-daemon", bus_daemon,
 
159
        "dbus-connection", ((TpProxy *) bus_daemon)->dbus_connection,
 
160
        "bus-name", TP_ACCOUNT_MANAGER_BUS_NAME,
 
161
        "object-path", TP_ACCOUNT_MANAGER_OBJECT_PATH,
 
162
        NULL));
 
163
 
 
164
  return self;
 
165
}