1 /*<private_header>*/
2 /*
3  * TpChannel - proxy for a Telepathy channel (internals)
4  *
5  * Copyright (C) 2007-2008 Collabora Ltd. <http://www.collabora.co.uk/>
6  * Copyright (C) 2007-2008 Nokia Corporation
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 #ifndef TP_CHANNEL_INTERNAL_H
24 #define TP_CHANNEL_INTERNAL_H
25 
26 #include <telepathy-glib/channel.h>
27 
28 G_BEGIN_DECLS
29 
30 typedef void (*TpChannelProc) (TpChannel *self);
31 
32 typedef struct {
33     TpContact *actor_contact;
34     TpHandle actor;
35     TpChannelGroupChangeReason reason;
36     gchar *message;
37 } LocalPendingInfo;
38 
39 typedef struct _ContactsQueueItem ContactsQueueItem;
40 
41 struct _TpChannelPrivate {
42     gulong conn_invalidated_id;
43 
44     TpConnection *connection;
45 
46     /* GQueue of TpChannelProc */
47     GQueue *introspect_needed;
48 
49     GQuark channel_type;
50     TpHandleType handle_type;
51     TpHandle handle;
52     gchar *identifier;
53     /* owned string (iface + "." + prop) => slice-allocated GValue */
54     GHashTable *channel_properties;
55 
56     /* Set until introspection discovers which to use; both NULL after one has
57      * been disconnected.
58      */
59     TpProxySignalConnection *members_changed_sig;
60     TpProxySignalConnection *members_changed_detailed_sig;
61     TpProxySignalConnection *self_handle_changed_sig;
62     TpProxySignalConnection *self_contact_changed_sig;
63     TpProxySignalConnection *handle_owners_changed_sig;
64     TpProxySignalConnection *handle_owners_changed_detailed_sig;
65 
66     TpHandle group_self_handle;
67     TpChannelGroupFlags group_flags;
68     /* NULL if members not discovered yet */
69     TpIntset *group_members;
70     TpIntset *group_local_pending;
71     TpIntset *group_remote_pending;
72     /* (TpHandle => LocalPendingInfo), or NULL if members not discovered yet */
73     GHashTable *group_local_pending_info;
74 
75     /* reason the self-handle left */
76     GError *group_remove_error /* implicitly zero-initialized */ ;
77     /* guint => guint, NULL if not discovered yet */
78     GHashTable *group_handle_owners;
79 
80     /* reffed TpContact */
81     TpContact *target_contact;
82     TpContact *initiator_contact;
83     TpContact *group_self_contact;
84     /* TpHandle -> reffed TpContact */
85     GHashTable *group_members_contacts;
86     GHashTable *group_local_pending_contacts;
87     GHashTable *group_remote_pending_contacts;
88     /* the TpContact can be NULL if the owner is unknown */
89     GHashTable *group_contact_owners;
90     gboolean cm_too_old_for_contacts;
91 
92     /* Queue of GSimpleAsyncResult with ContactsQueueItem payload */
93     GQueue *contacts_queue;
94     /* Item currently being prepared, not part of contacts_queue anymore */
95     GSimpleAsyncResult *current_contacts_queue_result;
96 
97     /* NULL, or TpHandle => TpChannelChatState;
98      * if non-NULL, we're watching for ChatStateChanged */
99     GHashTable *chat_states;
100 
101     /* These are really booleans, but gboolean is signed. Thanks, GLib */
102 
103     /* channel-ready */
104     unsigned ready:1;
105     /* Enough method calls have succeeded that we believe that the channel
106      * exists (implied by ready) */
107     unsigned exists:1;
108     /* GetGroupFlags has returned */
109     unsigned have_group_flags:1;
110 
111     TpChannelPasswordFlags password_flags;
112 };
113 
114 /* channel.c internals */
115 
116 void _tp_channel_continue_introspection (TpChannel *self);
117 void _tp_channel_abort_introspection (TpChannel *self,
118     const gchar *debug,
119     const GError *error);
120 GHashTable *_tp_channel_get_immutable_properties (TpChannel *self);
121 
122 /* channel-group.c internals */
123 
124 void _tp_channel_get_group_properties (TpChannel *self);
125 
126 /* channel-contacts.c internals */
127 
128 void _tp_channel_contacts_init (TpChannel *self);
129 void _tp_channel_contacts_group_init (TpChannel *self, GHashTable *identifiers);
130 void _tp_channel_contacts_members_changed (TpChannel *self,
131     const GArray *added, const GArray *removed, const GArray *local_pending,
132     const GArray *remote_pending, guint actor, GHashTable *details);
133 void _tp_channel_contacts_handle_owners_changed (TpChannel *self,
134     GHashTable *added, const GArray *removed, GHashTable *identifiers);
135 void _tp_channel_contacts_self_contact_changed (TpChannel *self,
136     guint self_handle, const gchar *identifier);
137 void _tp_channel_contacts_prepare_async (TpProxy *proxy,
138     const TpProxyFeature *feature,
139     GAsyncReadyCallback callback,
140     gpointer user_data);
141 
142 void _tp_channel_contacts_queue_prepare_async (TpChannel *self,
143     GPtrArray *contacts,
144     GAsyncReadyCallback callback,
145     gpointer user_data);
146 void _tp_channel_contacts_queue_prepare_by_id_async (TpChannel *self,
147     GPtrArray *ids,
148     GAsyncReadyCallback callback,
149     gpointer user_data);
150 void _tp_channel_contacts_queue_prepare_by_handle_async (TpChannel *self,
151     GArray *handles,
152     GAsyncReadyCallback callback,
153     gpointer user_data);
154 gboolean _tp_channel_contacts_queue_prepare_finish (TpChannel *self,
155     GAsyncResult *result,
156     GPtrArray **contacts,
157     GError **error);
158 
159 G_END_DECLS
160 
161 #endif
162