88 void session_add_content(JingleSession *sess, const gchar *name, |
88 void session_add_content(JingleSession *sess, const gchar *name, |
89 SessionState state) |
89 SessionState state) |
90 { |
90 { |
91 SessionContent *sc = g_new0(SessionContent, 1); |
91 SessionContent *sc = g_new0(SessionContent, 1); |
92 |
92 |
93 sc->name = name; |
93 sc->name = g_strdup(name); |
94 sc->state = state; |
94 sc->state = state; |
95 |
95 |
96 sess->content = g_slist_append(sess->content, sc); |
96 sess->content = g_slist_append(sess->content, sc); |
97 } |
97 } |
98 |
98 |
99 void session_add_app(JingleSession *sess, const gchar *name, |
99 void session_add_app(JingleSession *sess, const gchar *name, |
100 const gchar *xmlns, gconstpointer data) |
100 const gchar *xmlns, gconstpointer data) |
101 { |
101 { |
102 SessionContent *sc = session_find_sessioncontent(sess, name); |
102 SessionContent *sc = session_find_sessioncontent(sess, name); |
103 |
103 |
104 sc->xmlns_desc = xmlns; |
104 sc->xmlns_desc = g_strdup(xmlns); |
105 sc->appfuncs = jingle_get_appfuncs(xmlns); |
105 sc->appfuncs = jingle_get_appfuncs(xmlns); |
106 sc->description = data; |
106 sc->description = data; |
107 } |
107 } |
108 |
108 |
109 void session_add_trans(JingleSession *sess, const gchar *name, |
109 void session_add_trans(JingleSession *sess, const gchar *name, |
110 const gchar *xmlns, gconstpointer data) |
110 const gchar *xmlns, gconstpointer data) |
111 { |
111 { |
112 SessionContent *sc = session_find_sessioncontent(sess, name); |
112 SessionContent *sc = session_find_sessioncontent(sess, name); |
113 |
113 |
114 sc->xmlns_trans = xmlns; |
114 sc->xmlns_trans = g_strdup(xmlns); |
115 sc->transfuncs = jingle_get_transportfuncs(xmlns); |
115 sc->transfuncs = jingle_get_transportfuncs(xmlns); |
116 sc->transport = data; |
116 sc->transport = data; |
117 } |
117 } |
118 |
118 |
119 void session_add_content_from_jinglecontent(JingleSession *sess, JingleContent *cn, |
119 void session_add_content_from_jinglecontent(JingleSession *sess, |
120 SessionState state) |
120 JingleContent *cn, |
|
121 SessionState state) |
121 { |
122 { |
122 const gchar *xmlns; |
123 const gchar *xmlns; |
123 JingleAppFuncs *app_funcs; |
124 JingleAppFuncs *app_funcs; |
124 JingleTransportFuncs *trans_funcs; |
125 JingleTransportFuncs *trans_funcs; |
125 session_add_content(sess, cn->name, state); |
126 session_add_content(sess, cn->name, state); |
166 { |
167 { |
167 SessionContent *sc; |
168 SessionContent *sc; |
168 sc = session_find_sessioncontent(sess, name); |
169 sc = session_find_sessioncontent(sess, name); |
169 if(sc == NULL) return; |
170 if(sc == NULL) return; |
170 |
171 |
171 if (sc->state == JINGLE_SESSION_STATE_ACTIVE); // We should stop the transfer |
172 if (sc->state == JINGLE_SESSION_STATE_ACTIVE) { |
172 |
173 // TODO: stop the transfer |
|
174 } |
|
175 |
173 sess->content = g_slist_remove(sess->content, sc); |
176 sess->content = g_slist_remove(sess->content, sc); |
174 |
177 |
175 return g_slist_length(sess->content); |
178 return g_slist_length(sess->content); |
176 } |
179 } |
177 |
180 |
204 /** |
207 /** |
205 * Free a session. |
208 * Free a session. |
206 */ |
209 */ |
207 void session_free(JingleSession *sess) |
210 void session_free(JingleSession *sess) |
208 { |
211 { |
|
212 GSList *el; |
|
213 SessionContent *sc; |
|
214 |
209 g_free(sess->sid); |
215 g_free(sess->sid); |
210 g_free(sess->from); |
216 g_free(sess->from); |
|
217 g_free(sess->to); |
|
218 |
|
219 // Remove and free contents |
|
220 for (el = sess->content; el; el = el->next) { |
|
221 sc = (SessionContent*)el->data; |
|
222 session_remove_sessioncontent(sess, sc->name); |
|
223 } |
|
224 |
211 g_free(sess); |
225 g_free(sess); |
212 } |
226 } |
213 |
227 |
214 void jingle_handle_app(JingleSession *sess, const gchar *name, |
228 void jingle_handle_app(JingleSession *sess, const gchar *name, |
215 const gchar *xmlns_app, gconstpointer app, |
229 const gchar *xmlns_app, gconstpointer app, |