1 /*
2  * channel.h - proxy for a Telepathy channel
3  *
4  * Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
5  * Copyright (C) 2007 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 #if defined (TP_DISABLE_SINGLE_INCLUDE) && !defined (_TP_IN_META_HEADER) && !defined (_TP_COMPILATION)
23 #error "Only <telepathy-glib/telepathy-glib.h> and <telepathy-glib/telepathy-glib-dbus.h> can be included directly."
24 #endif
25 
26 #ifndef __TP_CHANNEL_H__
27 #define __TP_CHANNEL_H__
28 
29 #include <telepathy-glib/connection.h>
30 #include <telepathy-glib/defs.h>
31 #include <telepathy-glib/enums.h>
32 #include <telepathy-glib/handle.h>
33 #include <telepathy-glib/intset.h>
34 #include <telepathy-glib/proxy.h>
35 
36 G_BEGIN_DECLS
37 
38 typedef struct _TpChannel TpChannel;
39 typedef struct _TpChannelPrivate TpChannelPrivate;
40 typedef struct _TpChannelClass TpChannelClass;
41 
42 struct _TpChannelClass {
43     TpProxyClass parent_class;
44     /*<private>*/
45     GCallback _1;
46     GCallback _2;
47     GCallback _3;
48     GCallback _4;
49 };
50 
51 struct _TpChannel {
52     /*<private>*/
53     TpProxy parent;
54 
55     TpChannelPrivate *priv;
56 };
57 
58 GType tp_channel_get_type (void);
59 
60 #define TP_ERRORS_REMOVED_FROM_GROUP (tp_errors_removed_from_group_quark ())
61 GQuark tp_errors_removed_from_group_quark (void);
62 
63 /* TYPE MACROS */
64 #define TP_TYPE_CHANNEL \
65   (tp_channel_get_type ())
66 #define TP_CHANNEL(obj) \
67   (G_TYPE_CHECK_INSTANCE_CAST((obj), TP_TYPE_CHANNEL, \
68                               TpChannel))
69 #define TP_CHANNEL_CLASS(klass) \
70   (G_TYPE_CHECK_CLASS_CAST((klass), TP_TYPE_CHANNEL, \
71                            TpChannelClass))
72 #define TP_IS_CHANNEL(obj) \
73   (G_TYPE_CHECK_INSTANCE_TYPE((obj), TP_TYPE_CHANNEL))
74 #define TP_IS_CHANNEL_CLASS(klass) \
75   (G_TYPE_CHECK_CLASS_TYPE((klass), TP_TYPE_CHANNEL))
76 #define TP_CHANNEL_GET_CLASS(obj) \
77   (G_TYPE_INSTANCE_GET_CLASS ((obj), TP_TYPE_CHANNEL, \
78                               TpChannelClass))
79 
80 _TP_DEPRECATED_IN_0_20_FOR(tp_simple_client_factory_ensure_channel)
81 TpChannel *tp_channel_new (TpConnection *conn,
82     const gchar *object_path, const gchar *optional_channel_type,
83     TpHandleType optional_handle_type, TpHandle optional_handle,
84     GError **error) G_GNUC_WARN_UNUSED_RESULT;
85 
86 _TP_DEPRECATED_IN_0_20_FOR(tp_simple_client_factory_ensure_channel)
87 TpChannel *tp_channel_new_from_properties (TpConnection *conn,
88     const gchar *object_path, const GHashTable *immutable_properties,
89     GError **error) G_GNUC_WARN_UNUSED_RESULT;
90 
91 #ifndef TP_DISABLE_DEPRECATED
92 _TP_DEPRECATED_IN_0_18
93 gboolean tp_channel_run_until_ready (TpChannel *self, GError **error,
94     GMainLoop **loop);
95 
96 typedef void (*TpChannelWhenReadyCb) (TpChannel *channel, const GError *error,
97     gpointer user_data);
98 
99 _TP_DEPRECATED_IN_0_18_FOR (tp_proxy_prepare_async)
100 void tp_channel_call_when_ready (TpChannel *self,
101     TpChannelWhenReadyCb callback,
102     gpointer user_data);
103 
104 _TP_DEPRECATED_IN_0_18_FOR (tp_proxy_is_prepared)
105 gboolean tp_channel_is_ready (TpChannel *self);
106 #endif
107 
108 void tp_channel_init_known_interfaces (void);
109 
110 #ifndef TP_DISABLE_DEPRECATED
111 _TP_DEPRECATED_IN_0_20_FOR(tp_channel_get_connection)
112 TpConnection *tp_channel_borrow_connection (TpChannel *self);
113 _TP_DEPRECATED_IN_0_20_FOR(tp_channel_dup_immutable_properties)
114 GHashTable *tp_channel_borrow_immutable_properties (TpChannel *self);
115 #endif
116 
117 _TP_AVAILABLE_IN_0_20
118 TpConnection *tp_channel_get_connection (TpChannel *self);
119 _TP_AVAILABLE_IN_0_20
120 GVariant *tp_channel_dup_immutable_properties (TpChannel *self);
121 
122 void tp_channel_leave_async (TpChannel *self,
123     TpChannelGroupChangeReason reason,
124     const gchar *message,
125     GAsyncReadyCallback callback,
126     gpointer user_data);
127 
128 gboolean tp_channel_leave_finish (TpChannel *self,
129     GAsyncResult *result,
130     GError **error);
131 
132 void tp_channel_close_async (TpChannel *self,
133     GAsyncReadyCallback callback,
134     gpointer user_data);
135 
136 gboolean tp_channel_close_finish (TpChannel *self,
137     GAsyncResult *result,
138     GError **error);
139 
140 _TP_AVAILABLE_IN_0_16
141 void tp_channel_destroy_async (TpChannel *self,
142     GAsyncReadyCallback callback,
143     gpointer user_data);
144 
145 _TP_AVAILABLE_IN_0_16
146 gboolean tp_channel_destroy_finish (TpChannel *self,
147     GAsyncResult *result,
148     GError **error);
149 
150 gboolean tp_channel_get_requested (TpChannel *self);
151 
152 #define TP_CHANNEL_FEATURE_CORE \
153   tp_channel_get_feature_quark_core ()
154 
155 GQuark tp_channel_get_feature_quark_core (void) G_GNUC_CONST;
156 
157 const gchar *tp_channel_get_channel_type (TpChannel *self);
158 GQuark tp_channel_get_channel_type_id (TpChannel *self);
159 TpHandle tp_channel_get_handle (TpChannel *self, TpHandleType *handle_type);
160 const gchar *tp_channel_get_identifier (TpChannel *self);
161 
162 #ifndef TP_DISABLE_DEPRECATED
163 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_get_initiator_contact)
164 TpHandle tp_channel_get_initiator_handle (TpChannel *self);
165 
166 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_get_initiator_contact)
167 const gchar * tp_channel_get_initiator_identifier (TpChannel *self);
168 #endif
169 
170 #define TP_CHANNEL_FEATURE_GROUP \
171   tp_channel_get_feature_quark_group ()
172 GQuark tp_channel_get_feature_quark_group (void) G_GNUC_CONST;
173 
174 TpChannelGroupFlags tp_channel_group_get_flags (TpChannel *self);
175 
176 #ifndef TP_DISABLE_DEPRECATED
177 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_get_self_contact)
178 TpHandle tp_channel_group_get_self_handle (TpChannel *self);
179 
180 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_dup_members_contacts)
181 const TpIntset *tp_channel_group_get_members (TpChannel *self);
182 
183 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_dup_local_pending_contacts)
184 const TpIntset *tp_channel_group_get_local_pending (TpChannel *self);
185 
186 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_dup_remote_pending_contacts)
187 const TpIntset *tp_channel_group_get_remote_pending (TpChannel *self);
188 
189 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_get_local_pending_contact_info)
190 gboolean tp_channel_group_get_local_pending_info (TpChannel *self,
191     TpHandle local_pending, TpHandle *actor,
192     TpChannelGroupChangeReason *reason, const gchar **message);
193 
194 _TP_DEPRECATED_IN_0_20_FOR (tp_channel_group_get_contact_owner)
195 TpHandle tp_channel_group_get_handle_owner (TpChannel *self, TpHandle handle);
196 #endif
197 
198 _TP_AVAILABLE_IN_0_16
199 void tp_channel_join_async (TpChannel *self,
200     const gchar *message,
201     GAsyncReadyCallback callback,
202     gpointer user_data);
203 
204 _TP_AVAILABLE_IN_0_16
205 gboolean tp_channel_join_finish (TpChannel *self,
206     GAsyncResult *result,
207     GError **error);
208 
209 #define TP_CHANNEL_FEATURE_CONTACTS \
210   tp_channel_get_feature_quark_contacts ()
211 _TP_AVAILABLE_IN_0_16
212 GQuark tp_channel_get_feature_quark_contacts (void) G_GNUC_CONST;
213 
214 _TP_AVAILABLE_IN_0_16
215 TpContact *tp_channel_get_target_contact (TpChannel *self);
216 _TP_AVAILABLE_IN_0_16
217 TpContact *tp_channel_get_initiator_contact (TpChannel *self);
218 _TP_AVAILABLE_IN_0_16
219 TpContact *tp_channel_group_get_self_contact (TpChannel *self);
220 _TP_AVAILABLE_IN_0_16
221 GPtrArray *tp_channel_group_dup_members_contacts (TpChannel *self);
222 _TP_AVAILABLE_IN_0_16
223 GPtrArray *tp_channel_group_dup_local_pending_contacts (TpChannel *self);
224 _TP_AVAILABLE_IN_0_16
225 GPtrArray *tp_channel_group_dup_remote_pending_contacts (TpChannel *self);
226 _TP_AVAILABLE_IN_0_16
227 gboolean tp_channel_group_get_local_pending_contact_info (TpChannel *self,
228     TpContact *local_pending, TpContact **actor,
229     TpChannelGroupChangeReason *reason, const gchar **message);
230 _TP_AVAILABLE_IN_0_16
231 TpContact *tp_channel_group_get_contact_owner (TpChannel *self,
232     TpContact *contact);
233 
234 #define TP_CHANNEL_FEATURE_CHAT_STATES \
235   tp_channel_get_feature_quark_chat_states ()
236 _TP_DEPRECATED_IN_0_20_FOR(tp_text_channel_get_feature_quark_chat_states)
237 GQuark tp_channel_get_feature_quark_chat_states (void) G_GNUC_CONST;
238 
239 _TP_DEPRECATED_IN_0_20_FOR(tp_text_channel_get_chat_state)
240 TpChannelChatState tp_channel_get_chat_state (TpChannel *self,
241     TpHandle contact);
242 
243 /* Channel.Interface.Password */
244 #define TP_CHANNEL_FEATURE_PASSWORD \
245   tp_channel_get_feature_quark_password ()
246 _TP_AVAILABLE_IN_0_16
247 GQuark tp_channel_get_feature_quark_password (void) G_GNUC_CONST;
248 
249 _TP_AVAILABLE_IN_0_16
250 gboolean tp_channel_password_needed (TpChannel *self);
251 
252 _TP_AVAILABLE_IN_0_16
253 void tp_channel_provide_password_async (TpChannel *self,
254     const gchar *password,
255     GAsyncReadyCallback callback,
256     gpointer user_data);
257 
258 _TP_AVAILABLE_IN_0_16
259 gboolean tp_channel_provide_password_finish (TpChannel *self,
260     GAsyncResult *result,
261     GError **error);
262 
263 G_END_DECLS
264 
265 #include <telepathy-glib/_gen/tp-cli-channel.h>
266 
267 #endif
268