Merge branch 'private-after-1.9.0' into mob
[siplcs.git] / src / core / sipe-session.h
blob39c7f4f2b951f325809aec6b5dd195ddad44d364
1 /**
2 * @file sipe-sesion.h
4 * pidgin-sipe
6 * Copyright (C) 2009 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
23 /* Helper macros to iterate over session list in a SIP account */
24 #define SIPE_SESSION_FOREACH { \
25 GSList *entry = sip->sessions; \
26 while (entry) { \
27 struct sip_session *session = entry->data; \
28 entry = entry->next;
29 #define SIPE_SESSION_FOREACH_END }}
31 /** Correspond to multi-party conversation */
32 struct sip_session {
33 gchar *with; /* For IM sessions only (not multi-party) . A URI.*/
34 /** key is user (URI) */
35 GSList *dialogs;
36 /** Link to purple chat or IM */
37 PurpleConversation *conv;
38 GSList *outgoing_message_queue;
39 /** Key is <Call-ID><CSeq><METHOD><To> */
40 GHashTable *unconfirmed_messages;
43 * Multiparty conversation related fields
45 gboolean is_multiparty;
46 /** purple chat id */
47 int chat_id;
48 /** purple indexes chats by names */
49 //gchar *chat_name;
50 /** Human readable chat name */
51 gchar *chat_title;
52 /** Call-Id identifying the conversation */
53 gchar *callid; /* For multiparty conversations */
54 /** Roster Manager URI */
55 gchar *roster_manager;
56 int bid;
57 gboolean is_voting_in_progress;
58 GSList *pending_invite_queue;
61 * Conference related fields
63 gchar *focus_uri;
64 gchar *im_mcu_uri;
65 gchar *subject;
66 gboolean locked;
67 guint request_id;
68 struct sip_dialog *focus_dialog;
69 /** Key is Message-Id */
70 GHashTable *conf_unconfirmed_messages;
73 /**
74 * An item in outgoing message queue.
76 * Messages are put in the queue until a response to initial INVITE is received
77 * from remote dialog participant.
79 struct queued_message {
80 /** Body of the message. */
81 gchar *body;
82 /**
83 * Content type of message body, e.g. text/plain for chat messages,
84 * text/x-msmsgsinvite for filetransfer initialization. Setting this to NULL
85 * means default value text/plain.
87 gchar *content_type;
90 /** Frees queued_message
92 void
93 sipe_free_queued_message(struct queued_message *message);
95 /**
96 * Add a new chat session
98 * @param sip (in) SIP account data. May be NULL
100 * @return pointer to new session
102 struct sip_session *
103 sipe_session_add_chat(struct sipe_account_data *sip);
106 * Find chat session by Call ID
108 * @param sip (in) SIP account data. May be NULL
109 * @param callid (in) Call ID. May be NULL
111 * @return pointer to session or NULL
113 struct sip_session *
114 sipe_session_find_chat_by_callid(struct sipe_account_data *sip,
115 const gchar *callid);
118 * Find or add new chat session by Call ID
120 * @param sip (in) SIP account data
121 * @param callid (in) Call ID
123 * @return pointer to session
125 struct sip_session *
126 sipe_session_find_or_add_chat_by_callid(struct sipe_account_data *sip,
127 const gchar *callid);
130 * Find chat session by ID
132 * @param sip (in) SIP account data. May be NULL
133 * @param id (in) Chat ID
135 * @return pointer to session or NULL
137 struct sip_session *
138 sipe_session_find_chat_by_id(struct sipe_account_data *sip, int id);
141 * Find chat session by name
143 * @param sip (in) SIP account data. May be NULL
144 * @param name (in) Chat name. May be NULL
146 * @return pointer to session or NULL
148 struct sip_session *
149 sipe_session_find_chat_by_title(struct sipe_account_data *sip,
150 const gchar *name);
153 * Find Conference session
155 * @param sip (in) SIP account data. May be NULL
156 * @param focus_uri (in) URI of conference focus. May be NULL
158 * @return pointer to session or NULL
160 struct sip_session *
161 sipe_session_find_conference(struct sipe_account_data *sip,
162 const gchar *focus_uri);
165 * Find IM session
167 * @param sip (in) SIP account data. May be NULL
168 * @param who (in) remote partner. May be NULL
170 * @return pointer to session or NULL
172 struct sip_session *
173 sipe_session_find_im(struct sipe_account_data *sip, const gchar *who);
176 * Find or add new IM session
178 * @param sip (in) SIP account data
179 * @param who (in) remote partner
181 * @return pointer to session
183 struct sip_session *
184 sipe_session_find_or_add_im(struct sipe_account_data *sip,
185 const gchar *who);
188 * Remove a session from a SIP account
190 * @param sip (in) SIP account data
191 * @param session (in) pointer to session
193 void
194 sipe_session_remove(struct sipe_account_data *sip,
195 struct sip_session *session);
198 * Remove all sessions from a SIP account
200 * @param sip (in) SIP account data
202 void
203 sipe_session_remove_all(struct sipe_account_data *sip);
206 * Add a message to outgoing queue.
208 * @param session (in) SIP session
209 * @param body (in) message to send
210 * @param content_type (in) content type of the message body
212 void
213 sipe_session_enqueue_message(struct sip_session *session,
214 const gchar *body, const gchar *content_type);
217 * Removes and deallocates the first item in outgoing message queue.
219 * @param session (in) SIP session
221 * @return pointer to new message queue head
223 GSList *
224 sipe_session_dequeue_message(struct sip_session *session);