interface cleanup: flatten interface dependencies
[siplcs.git] / src / core / sipe-session.h
blobea12b0f673b5d8ceab25a5f4f72ea469f4b28ca6
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
24 * Interface dependencies:
26 * <glib.h>
27 * "conversation.h"
30 /* Forward declarations */
31 struct sipe_account_data;
33 /* Helper macros to iterate over session list in a SIP account */
34 #define SIPE_SESSION_FOREACH { \
35 GSList *entry = sip->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 gchar *with; /* For IM sessions only (not multi-party) . A URI.*/
44 /** key is user (URI) */
45 GSList *dialogs;
46 /** Link to purple chat or IM */
47 PurpleConversation *conv;
48 GSList *outgoing_message_queue;
49 /** Key is <Call-ID><CSeq><METHOD><To> */
50 GHashTable *unconfirmed_messages;
53 * Multiparty conversation related fields
55 gboolean is_multiparty;
56 /** purple chat id */
57 int chat_id;
58 /** purple indexes chats by names */
59 //gchar *chat_name;
60 /** Human readable chat name */
61 gchar *chat_title;
62 /** Call-Id identifying the conversation */
63 gchar *callid; /* For multiparty conversations */
64 /** Roster Manager URI */
65 gchar *roster_manager;
66 int bid;
67 gboolean is_voting_in_progress;
68 GSList *pending_invite_queue;
71 * Conference related fields
73 gchar *focus_uri;
74 gchar *im_mcu_uri;
75 gchar *subject;
76 gboolean locked;
77 guint request_id;
78 struct sip_dialog *focus_dialog;
79 /** Key is Message-Id */
80 GHashTable *conf_unconfirmed_messages;
83 /**
84 * An item in outgoing message queue.
86 * Messages are put in the queue until a response to initial INVITE is received
87 * from remote dialog participant.
89 struct queued_message {
90 /** Body of the message. */
91 gchar *body;
92 /**
93 * Content type of message body, e.g. text/plain for chat messages,
94 * text/x-msmsgsinvite for filetransfer initialization. Setting this to NULL
95 * means default value text/plain.
97 gchar *content_type;
100 /** Frees queued_message
102 void
103 sipe_free_queued_message(struct queued_message *message);
106 * Add a new chat session
108 * @param sip (in) SIP account data. May be NULL
110 * @return pointer to new session
112 struct sip_session *
113 sipe_session_add_chat(struct sipe_account_data *sip);
116 * Find chat session by Call ID
118 * @param sip (in) SIP account data. May be NULL
119 * @param callid (in) Call ID. May be NULL
121 * @return pointer to session or NULL
123 struct sip_session *
124 sipe_session_find_chat_by_callid(struct sipe_account_data *sip,
125 const gchar *callid);
128 * Find or add new chat session by Call ID
130 * @param sip (in) SIP account data
131 * @param callid (in) Call ID
133 * @return pointer to session
135 struct sip_session *
136 sipe_session_find_or_add_chat_by_callid(struct sipe_account_data *sip,
137 const gchar *callid);
140 * Find chat session by ID
142 * @param sip (in) SIP account data. May be NULL
143 * @param id (in) Chat ID
145 * @return pointer to session or NULL
147 struct sip_session *
148 sipe_session_find_chat_by_id(struct sipe_account_data *sip, int id);
151 * Find chat session by name
153 * @param sip (in) SIP account data. May be NULL
154 * @param name (in) Chat name. May be NULL
156 * @return pointer to session or NULL
158 struct sip_session *
159 sipe_session_find_chat_by_title(struct sipe_account_data *sip,
160 const gchar *name);
163 * Find Conference session
165 * @param sip (in) SIP account data. May be NULL
166 * @param focus_uri (in) URI of conference focus. May be NULL
168 * @return pointer to session or NULL
170 struct sip_session *
171 sipe_session_find_conference(struct sipe_account_data *sip,
172 const gchar *focus_uri);
175 * Find IM session
177 * @param sip (in) SIP account data. May be NULL
178 * @param who (in) remote partner. May be NULL
180 * @return pointer to session or NULL
182 struct sip_session *
183 sipe_session_find_im(struct sipe_account_data *sip, const gchar *who);
186 * Find or add new IM session
188 * @param sip (in) SIP account data
189 * @param who (in) remote partner
191 * @return pointer to session
193 struct sip_session *
194 sipe_session_find_or_add_im(struct sipe_account_data *sip,
195 const gchar *who);
198 * Remove a session from a SIP account
200 * @param sip (in) SIP account data
201 * @param session (in) pointer to session
203 void
204 sipe_session_remove(struct sipe_account_data *sip,
205 struct sip_session *session);
208 * Remove all sessions from a SIP account
210 * @param sip (in) SIP account data
212 void
213 sipe_session_remove_all(struct sipe_account_data *sip);
216 * Add a message to outgoing queue.
218 * @param session (in) SIP session
219 * @param body (in) message to send
220 * @param content_type (in) content type of the message body
222 void
223 sipe_session_enqueue_message(struct sip_session *session,
224 const gchar *body, const gchar *content_type);
227 * Removes and deallocates the first item in outgoing message queue.
229 * @param session (in) SIP session
231 * @return pointer to new message queue head
233 GSList *
234 sipe_session_dequeue_message(struct sip_session *session);