audio: cleanup resources on end of call
[siplcs.git] / src / core / sipe-session.h
blobc316ef8b7ebc19823ca8cfb2916d9fda67d280e5
1 /**
2 * @file sipe-sesion.h
4 * pidgin-sipe
6 * Copyright (C) 2009-10 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program 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
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * Interface dependencies:
26 * <glib.h>
29 /* Forward declarations */
30 struct sipe_core_private;
31 struct sipe_backend_session;
33 /* Helper macros to iterate over session list in a SIP account */
34 #define SIPE_SESSION_FOREACH { \
35 GSList *entry = sipe_private->sessions; \
36 while (entry) { \
37 struct sip_session *session = entry->data; \
38 entry = entry->next;
39 #define SIPE_SESSION_FOREACH_END }}
41 /** Correspond to multi-party conversation */
42 struct sip_session {
43 /** backend private data structure for IM or chat */
44 struct sipe_backend_session *backend_session;
46 gchar *with; /* For IM sessions only (not multi-party) . A URI.*/
47 /** key is user (URI) */
48 GSList *dialogs;
49 /** Key is <Call-ID><CSeq><METHOD><To> */
50 GHashTable *unconfirmed_messages;
51 GSList *outgoing_message_queue;
54 * Multiparty conversation related fields
56 gboolean is_multiparty;
57 /** purple chat id */
58 int chat_id;
59 /** purple indexes chats by names */
60 //gchar *chat_name;
61 /** Human readable chat name */
62 gchar *chat_title;
63 /** Call-Id identifying the conversation */
64 gchar *callid; /* For multiparty conversations */
65 /** Roster Manager URI */
66 gchar *roster_manager;
67 int bid;
68 gboolean is_voting_in_progress;
69 GSList *pending_invite_queue;
72 * Conference related fields
74 gchar *focus_uri;
75 gchar *im_mcu_uri;
76 gchar *subject;
77 gboolean locked;
78 guint request_id;
79 struct sip_dialog *focus_dialog;
80 /** Key is Message-Id */
81 GHashTable *conf_unconfirmed_messages;
84 /**
85 * An item in outgoing message queue.
87 * Messages are put in the queue until a response to initial INVITE is received
88 * from remote dialog participant.
90 struct queued_message {
91 /** Body of the message. */
92 gchar *body;
93 /**
94 * Content type of message body, e.g. text/plain for chat messages,
95 * text/x-msmsgsinvite for filetransfer initialization. Setting this to NULL
96 * means default value text/plain.
98 gchar *content_type;
102 * Add a new chat session
104 * @param sipe_private (in) SIPE core data. May be NULL
106 * @return pointer to new session
108 struct sip_session *
109 sipe_session_add_chat(struct sipe_core_private *sipe_private);
111 #ifdef HAVE_VV
114 * Add a new media call session
116 * @param sipe_private (in) SIPE core data.
117 * @param who (in) remote partner.
119 * @return pointer to new session
121 struct sip_session *
122 sipe_session_add_call(struct sipe_core_private *sipe_private,
123 const gchar *who);
125 #endif
128 * Find chat session by Call ID
130 * @param sipe_private (in) SIPE core data. May be NULL
131 * @param callid (in) Call ID. May be NULL
133 * @return pointer to session or NULL
135 struct sip_session *
136 sipe_session_find_chat_by_callid(struct sipe_core_private *sipe_private,
137 const gchar *callid);
140 * Find or add new chat session by Call ID
142 * @param sipe_private (in) SIPE core data
143 * @param callid (in) Call ID
145 * @return pointer to session
147 struct sip_session *
148 sipe_session_find_or_add_chat_by_callid(struct sipe_core_private *sipe_private,
149 const gchar *callid);
152 * Find chat session by ID
154 * @param sipe_private (in) SIPE core data. May be NULL
155 * @param id (in) Chat ID
157 * @return pointer to session or NULL
159 struct sip_session *
160 sipe_session_find_chat_by_id(struct sipe_core_private *sipe_private,
161 int id);
164 * Find chat session by name
166 * @param sipe_private (in) SIPE core data. May be NULL
167 * @param name (in) Chat name. May be NULL
169 * @return pointer to session or NULL
171 struct sip_session *
172 sipe_session_find_chat_by_title(struct sipe_core_private *sipe_private,
173 const gchar *name);
176 * Find Conference session
178 * @param sipe_private (in) SIPE core data. May be NULL
179 * @param focus_uri (in) URI of conference focus. May be NULL
181 * @return pointer to session or NULL
183 struct sip_session *
184 sipe_session_find_conference(struct sipe_core_private *sipe_private,
185 const gchar *focus_uri);
188 * Find IM session
190 * @param sipe_private (in) SIPE core data. May be NULL
191 * @param who (in) remote partner. May be NULL
193 * @return pointer to session or NULL
195 struct sip_session *
196 sipe_session_find_im(struct sipe_core_private *sipe_private,
197 const gchar *who);
200 * Find or add new IM session
202 * @param sipe_private (in) SIPE core data
203 * @param who (in) remote partner
205 * @return pointer to session
207 struct sip_session *
208 sipe_session_find_or_add_im(struct sipe_core_private *sipe_private,
209 const gchar *who);
212 * Find Chat by Call ID or IM session
214 * @param sipe_private (in) SIPE core data. May be NULL
215 * @param callid (in) Call ID. May be NULL
216 * @param who (in) remote partner. May be NULL
218 * @return pointer to session or NULL
220 struct sip_session *
221 sipe_session_find_chat_or_im(struct sipe_core_private *sipe_private,
222 const gchar *callid,
223 const gchar *who);
226 * Close a session
228 * @param sipe_private (in) SIPE core data
229 * @param session (in) pointer to session
231 void
232 sipe_session_close(struct sipe_core_private *sipe_private,
233 struct sip_session *session);
236 * Remove a session from a SIP account
238 * @param sipe_private (in) SIPE core data
239 * @param session (in) pointer to session
241 void
242 sipe_session_remove(struct sipe_core_private *sipe_private,
243 struct sip_session *session);
246 * Add a message to outgoing queue.
248 * @param session (in) SIP session
249 * @param body (in) message to send
250 * @param content_type (in) content type of the message body
252 void
253 sipe_session_enqueue_message(struct sip_session *session,
254 const gchar *body, const gchar *content_type);
257 * Removes and deallocates the first item in outgoing message queue.
259 * @param session (in) SIP session
261 * @return pointer to new message queue head
263 GSList *
264 sipe_session_dequeue_message(struct sip_session *session);