Fix #3198585: Extra line breaks
[siplcs.git] / src / core / sipe-session.h
blob10aa508346de20bb038dffbca1fc44e249e7f2d3
1 /**
2 * @file sipe-sesion.h
4 * pidgin-sipe
6 * Copyright (C) 2009-11 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_chat_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 /** chat session */
44 struct sipe_chat_session *chat_session;
46 gchar *with; /* For IM or call 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 /** Call-Id identifying the conversation */
57 gchar *callid; /* For multiparty conversations */
58 int bid;
59 gboolean is_voting_in_progress;
60 GSList *pending_invite_queue;
63 * Conference related fields
65 gchar *im_mcu_uri;
66 gchar *subject;
67 gboolean locked;
68 guint request_id;
69 struct sip_dialog *focus_dialog;
70 /** Key is Message-Id */
71 GHashTable *conf_unconfirmed_messages;
74 * Media call related fields
76 gboolean is_call;
79 * Group Chat related fields
81 gboolean is_groupchat;
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;
99 guint cseq;
103 * Add a new chat session
105 * @param sipe_private (in) SIPE core data. May be NULL
106 * @param chat_session (in) non-NULL to rejoin existing chat
107 * @param multiparty (in) multiparty or conference
108 * @param id (in) new chat session identifier (ignored for rejoin).
110 * @return pointer to new session
112 struct sip_session *
113 sipe_session_add_chat(struct sipe_core_private *sipe_private,
114 struct sipe_chat_session *chat_session,
115 gboolean multiparty,
116 const gchar *id);
118 #ifdef HAVE_VV
121 * Add a new media call session
123 * @param sipe_private (in) SIPE core data.
124 * @param who (in) remote partner.
126 * @return pointer to new session
128 struct sip_session *
129 sipe_session_add_call(struct sipe_core_private *sipe_private,
130 const gchar *who);
133 * Find media call session
135 * @param sipe_private (in) SIPE core data. May be NULL.
136 * @param who (in) remote partner.
138 * @return pointer to session or NULL
140 struct sip_session *
141 sipe_session_find_call(struct sipe_core_private *sipe_private,
142 const gchar *who);
144 #endif
147 * Find chat session
149 * @param sipe_private (in) SIPE core data. May be NULL
150 * @param chat_session (in) chat session data. May be NULL
152 * @return pointer to session or NULL
154 struct sip_session *
155 sipe_session_find_chat(struct sipe_core_private *sipe_private,
156 struct sipe_chat_session *chat_session);
159 * Find chat session by Call ID
161 * @param sipe_private (in) SIPE core data. May be NULL
162 * @param callid (in) Call ID. May be NULL
164 * @return pointer to session or NULL
166 struct sip_session *
167 sipe_session_find_chat_by_callid(struct sipe_core_private *sipe_private,
168 const gchar *callid);
171 * Find Conference session
173 * @param sipe_private (in) SIPE core data. May be NULL
174 * @param focus_uri (in) URI of conference focus. May be NULL
176 * @return pointer to session or NULL
178 struct sip_session *
179 sipe_session_find_conference(struct sipe_core_private *sipe_private,
180 const gchar *focus_uri);
183 * Find IM session
185 * @param sipe_private (in) SIPE core data. May be NULL
186 * @param who (in) remote partner. May be NULL
188 * @return pointer to session or NULL
190 struct sip_session *
191 sipe_session_find_im(struct sipe_core_private *sipe_private,
192 const gchar *who);
195 * Find or add new IM session
197 * @param sipe_private (in) SIPE core data
198 * @param who (in) remote partner
200 * @return pointer to session
202 struct sip_session *
203 sipe_session_find_or_add_im(struct sipe_core_private *sipe_private,
204 const gchar *who);
207 * Find Chat by Call ID or IM session
209 * @param sipe_private (in) SIPE core data. May be NULL
210 * @param callid (in) Call ID. May be NULL
211 * @param who (in) remote partner. May be NULL
213 * @return pointer to session or NULL
215 struct sip_session *
216 sipe_session_find_chat_or_im(struct sipe_core_private *sipe_private,
217 const gchar *callid,
218 const gchar *who);
221 * Close a session
223 * @param sipe_private (in) SIPE core data
224 * @param session (in) pointer to session
226 void
227 sipe_session_close(struct sipe_core_private *sipe_private,
228 struct sip_session *session);
231 * Remove a session from a SIP account
233 * @param sipe_private (in) SIPE core data
234 * @param session (in) pointer to session
236 void
237 sipe_session_remove(struct sipe_core_private *sipe_private,
238 struct sip_session *session);
241 * Add a message to outgoing queue.
243 * @param session (in) SIP session
244 * @param body (in) message to send
245 * @param content_type (in) content type of the message body
247 void
248 sipe_session_enqueue_message(struct sip_session *session,
249 const gchar *body, const gchar *content_type);
252 * Removes and deallocates the first item in outgoing message queue.
254 * @param session (in) SIP session
256 * @return pointer to new message queue head
258 GSList *
259 sipe_session_dequeue_message(struct sip_session *session);