jingle/sessions.h
author Nicolas Cornu <nicolas.cornu@ensi-bourges.fr>
Wed, 04 Aug 2010 23:46:47 +0200
changeset 80 1c2ef2c5debe
parent 75 bd48c89b0a3d
child 81 8b6320ad470b
permissions -rw-r--r--
Modifications to the JingleSession struct.

#ifndef __JINGLE_SESSIONS_H__
#define __JINGLE_SESSIONS_H__ 1

#include <glib.h>

#include <jingle/register.h>


typedef enum {
  JINGLE_SESSION_STATE_ACTIVE,
  JINGLE_SESSION_STATE_PENDING,
  JINGLE_SESSION_STATE_ENDED,
} SessionState;

typedef enum {
  /* A session that was initiated by some remote entity */
  JINGLE_SESSION_INCOMING,

  /* A session that we initiated (by sending a session-initiate) */
  JINGLE_SESSION_OUTGOING
} SessionOrigin;

typedef struct {
  /* Random session identifier generated by the initator. */
  gchar *sid;

  /* We need to know who initiated the session ?
   * us or a remote entity. */
  SessionOrigin origin;

  /* jid of the xmpp entity that initiated the session. */
  gchar *from;

  /* jid of the xmpp entity that received the initiation request. */
  gchar *to;

  /* jid of the entity we send iq. point to "from" or "to" depending on
   * who initiated the session. Basically a shortcut to avoid checking
   * origin. Should not be freed when destroying a JingleSession. */
  gchar *recipient;

  /* A singly-linked list of content. */
  GSList *content;
} JingleSession;

typedef struct {
  const gchar *name;
  SessionState state;
  const gchar *xmlns_desc;
  gconstpointer description;
  JingleAppFuncs *appfuncs;
  const gchar *xmlns_trans;
  gconstpointer transport;
  JingleTransportFuncs *transfuncs;
} SessionContent;

JingleSession *session_new(const gchar *sid, const gchar *from,
                           const gchar *to, SessionOrigin origin);
JingleSession *session_new_from_jinglenode(JingleNode *jn);
JingleSession *session_find_by_sid(const gchar *sid, const gchar *from);
JingleSession *session_find(const JingleNode *jn);
void session_add_content(JingleSession *sess, const gchar *name,
                         SessionState state);
void session_add_app(JingleSession *sess, const gchar *name,
                           const gchar *xmlns, gconstpointer data);
void session_add_trans(JingleSession *sess, const gchar *name,
                           const gchar *xmlns, gconstpointer data);
void session_add_content_from_jinglecontent(JingleSession *sess, JingleContent *cn,
                         SessionState state);
SessionContent *session_find_sessioncontent(JingleSession *sess, const gchar *name);
SessionContent *session_find_transport(const gchar *xmlns_trans, gconstpointer data);
void session_remove_sessioncontent(JingleSession *sess, const gchar *name);
void session_changestate_sessioncontent(JingleSession *sess, const gchar *name,
                                        SessionState state);
void session_delete(JingleSession *sess);
void session_remove(JingleSession *sess);
void session_free(JingleSession *sess);

void jingle_handle_app(JingleSession *sess, const gchar *name,
                       const gchar *xmlns_app, gconstpointer app,
                       const gchar *to);

#endif