Updated to release 1.7.1
[siplcs.git] / src / sipe-dialog.h
blobd0efe3d1ed1ecb6b768ed51562db7345aee039c2
1 /**
2 * @file sipe-dialog.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 dialog list in a SIP session */
24 #define SIPE_DIALOG_FOREACH { \
25 GSList *entry = session->dialogs; \
26 while (entry) { \
27 struct sip_dialog *dialog = entry->data; \
28 entry = entry->next;
29 #define SIPE_DIALOG_FOREACH_END }}
31 /* dialog is the new term for call-leg */
32 struct sip_dialog {
33 gchar *with; /* URI */
34 gchar *endpoint_GUID;
35 /**
36 * >0 - pro
37 * <0 - contra
38 * 0 - didn't participate
39 */
40 int election_vote;
41 gchar *ourtag;
42 gchar *theirtag;
43 gchar *theirepid;
44 gchar *callid;
45 GSList *routes;
46 gchar *request;
47 GSList *supported; /* counterparty capabilities */
48 int cseq;
49 /** corresponds to Session-Expires SIP header value */
50 int expires;
51 gboolean is_established;
52 struct transaction *outgoing_invite;
55 /* RFC3265 subscription */
56 struct sip_subscription {
57 struct sip_dialog dialog;
58 gchar *event;
61 /* Forward declaration */
62 struct sip_session;
64 /**
65 * Free dialog structure
67 * @param dialog (in) Dialog to be freed. May be NULL.
69 void sipe_dialog_free(struct sip_dialog *dialog);
71 /**
72 * Free subscription structure
74 * @param subscription (in) Subscription to be freed. May be NULL.
76 void sipe_subscription_free(struct sip_subscription *subscription);
78 /**
79 * Add a new, empty dialog to a session
81 * @param session (in)
83 * @return dialog the new dialog structure
85 struct sip_dialog *sipe_dialog_add(struct sip_session *session);
87 /**
88 * Find a dialog in a session
90 * @param session (in) may be NULL
91 * @param who (in) dialog identifier. May be NULL
93 * @return dialog the requested dialog or NULL
95 struct sip_dialog *sipe_dialog_find(struct sip_session *session,
96 const gchar *who);
98 /**
99 * Remove a dialog from a session
101 * @param session (in) may be NULL
102 * @param who (in) dialog identifier. May be NULL
104 void sipe_dialog_remove(struct sip_session *session, const gchar *who);
107 * Remove a dialog from a session
109 * @param session (in) may be NULL
110 * @param dialog (in) dialog identifier. Should contain Call-ID, to-tag and from-tag
111 * to unambiguously identify dialog. May be NULL
113 void
114 sipe_dialog_remove_3(struct sip_session *session,
115 struct sip_dialog *dialog_in);
118 * Remove all dialogs frome a session
120 * @param session (in)
122 void sipe_dialog_remove_all(struct sip_session *session);
125 * Does a session have any dialogs?
127 * @param session (in)
129 #define sipe_dialog_any(session) (session->dialogs != NULL)
132 * Return first dialog of a session
134 * @param session (in)
136 #define sipe_dialog_first(session) ((struct sip_dialog *)session->dialogs->data)
139 * Fill dialog structure from SIP message
141 * @param msg (in) mesage
142 * @param dialog (in,out) dialog to fill
143 * @param outgoing (in) outgoing or incoming message
145 void sipe_dialog_parse(struct sip_dialog *dialog,
146 const struct sipmsg *msg,
147 gboolean outgoing);