1 /* vi: set et sw=4 ts=8 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
3 /*
4  * mcd-account.h - the Telepathy Account D-Bus interface (service side)
5  *
6  * Copyright © 2008–2011 Collabora Ltd. <http://www.collabora.co.uk/>
7  * Copyright © 2008 Nokia Corporation
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  */
23 
24 #ifndef __MCD_ACCOUNT_H__
25 #define __MCD_ACCOUNT_H__
26 
27 #include <telepathy-glib/telepathy-glib.h>
28 
29 G_BEGIN_DECLS
30 #define MCD_TYPE_ACCOUNT         (mcd_account_get_type ())
31 #define MCD_ACCOUNT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), MCD_TYPE_ACCOUNT, McdAccount))
32 #define MCD_ACCOUNT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), MCD_TYPE_ACCOUNT, McdAccountClass))
33 #define MCD_IS_ACCOUNT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), MCD_TYPE_ACCOUNT))
34 #define MCD_IS_ACCOUNT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), MCD_TYPE_ACCOUNT))
35 #define MCD_ACCOUNT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MCD_TYPE_ACCOUNT, McdAccountClass))
36 
37 typedef struct _McdAccount McdAccount;
38 typedef struct _McdAccountPrivate McdAccountPrivate;
39 typedef struct _McdAccountClass McdAccountClass;
40 
41 #include "mcd-connection.h"
42 #include "mcd-account-manager.h"
43 
44 struct _McdAccount
45 {
46     GObject parent;
47     McdAccountPrivate *priv;
48 };
49 
50 typedef enum
51 {
52   MCD_ACCOUNT_ERROR_SET_PARAMETER,
53   MCD_ACCOUNT_ERROR_GET_PARAMETER,
54 } McdAccountError;
55 
56 GQuark mcd_account_error_quark (void);
57 
58 #define MCD_ACCOUNT_ERROR (mcd_account_error_quark ())
59 
60 typedef void (*McdAccountLoadCb) (McdAccount *account,
61                                   const GError *error,
62                                   gpointer user_data);
63 typedef void (*McdAccountDeleteCb) (McdAccount *account,
64                                     const GError *error,
65                                     gpointer user_data);
66 
67 struct _McdAccountClass
68 {
69     GObjectClass parent_class;
70     /* Used to be get_parameter; set_parameter; delete; load. These are not
71      * implementeed in any known subclass of this class, so have been removed;
72      * these padding fields are to preserve ABI compatibility.
73      */
74     GCallback dummy[4];
75     gboolean (*check_request) (McdAccount *account, GHashTable *request,
76                                GError **error);
77     void (*_mc_reserved6) (void);
78     void (*_mc_reserved7) (void);
79 };
80 
81 GType mcd_account_get_type (void);
82 
83 McdAccount *mcd_account_new (McdAccountManager *account_manager,
84     const gchar *name,
85     McdConnectivityMonitor *minotaur);
86 
87 void mcd_account_delete (McdAccount *account, McdAccountDeleteCb callback,
88                          gpointer user_data);
89 
90 const gchar *mcd_account_get_unique_name (McdAccount *account);
91 const gchar *mcd_account_get_object_path (McdAccount *account);
92 
93 gboolean mcd_account_is_valid (McdAccount *account);
94 
95 typedef void (*McdAccountCheckValidityCb) (McdAccount *account,
96                                            const GError *invalid_reason,
97                                            gpointer user_data);
98 void mcd_account_check_validity (McdAccount *account,
99                                  McdAccountCheckValidityCb callback,
100                                  gpointer user_data);
101 
102 gboolean mcd_account_is_enabled (McdAccount *account);
103 
104 const gchar *mcd_account_get_manager_name (McdAccount *account);
105 const gchar *mcd_account_get_protocol_name (McdAccount *account);
106 TpConnectionManager *mcd_account_get_cm (McdAccount *account);
107 
108 void mcd_account_request_presence (McdAccount *account,
109 				   TpConnectionPresenceType type,
110 				   const gchar *status, const gchar *message);
111 void mcd_account_get_current_presence (McdAccount *account,
112 				       TpConnectionPresenceType *presence,
113 				       const gchar **status,
114 				       const gchar **message);
115 void mcd_account_get_requested_presence (McdAccount *account,
116 					 TpConnectionPresenceType *presence,
117 					 const gchar **status,
118 					 const gchar **message);
119 
120 gboolean mcd_account_would_like_to_connect (McdAccount *account);
121 
122 TpConnectionStatus mcd_account_get_connection_status (McdAccount *account);
123 
124 McdConnection *mcd_account_get_connection (McdAccount *account);
125 
126 gboolean mcd_account_check_request (McdAccount *account, GHashTable *request,
127                                     GError **error);
128 
129 gboolean mcd_account_parameter_is_secret (McdAccount *self,
130                                               const gchar *name);
131 
132 void mcd_account_altered_by_plugin (McdAccount *account, const gchar *name);
133 
134 gchar * mcd_account_dup_display_name (McdAccount *self);
135 
136 gboolean mcd_account_get_parameter (McdAccount *account, const gchar *name,
137                            GValue *parameter,
138                            GError **error);
139 
140 gboolean mcd_account_get_parameter_of_known_type (McdAccount *account,
141                                                   const gchar *name,
142                                                   GType type,
143                                                   GValue *parameter,
144                                                   GError **error);
145 
146 gchar * mcd_account_dup_icon (McdAccount *self);
147 
148 gchar * mcd_account_dup_nickname (McdAccount *self);
149 
150 McdConnectivityMonitor *mcd_account_get_connectivity_monitor (
151     McdAccount *self);
152 
153 gboolean mcd_account_get_waiting_for_connectivity (McdAccount *self);
154 void mcd_account_set_waiting_for_connectivity (McdAccount *self,
155     gboolean waiting);
156 
157 void mcd_account_connection_proceed (McdAccount *account, gboolean success);
158 void mcd_account_connection_proceed_with_reason
159     (McdAccount *account, gboolean success, TpConnectionStatusReason reason);
160 
161 G_END_DECLS
162 
163 #endif
164