~ubuntu-branches/ubuntu/quantal/linphone/quantal

« back to all changes in this revision

Viewing changes to exosip/jreg.c

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Mimram
  • Date: 2006-11-15 10:34:50 UTC
  • mfrom: (1.2.1 upstream) (2.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20061115103450-qgafwcks2lkhctlj
* New upstream release.
* Enable video support.
* Fix mismatched #endif in mscommon.h, closes: #398307.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  eXosip - This is the eXtended osip library.
 
3
  Copyright (C) 2002, 2003  Aymeric MOIZARD  - jack@atosc.org
 
4
  
 
5
  eXosip is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU General Public License as published by
 
7
  the Free Software Foundation; either version 2 of the License, or
 
8
  (at your option) any later version.
 
9
  
 
10
  eXosip is distributed in the hope that it will be useful,
 
11
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
  GNU General Public License for more details.
 
14
  
 
15
  You should have received a copy of the GNU General Public License
 
16
  along with this program; if not, write to the Free Software
 
17
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
*/
 
19
 
 
20
 
 
21
#ifdef ENABLE_MPATROL
 
22
#include <mpatrol.h>
 
23
#endif
 
24
 
 
25
#include "eXosip2.h"
 
26
 
 
27
extern eXosip_t eXosip;
 
28
 
 
29
int eXosip_reg_init(eXosip_reg_t **jr, char *from, char *proxy, char *contact, char* route)
 
30
{
 
31
  static int r_id;
 
32
 
 
33
  *jr = (eXosip_reg_t*) osip_malloc(sizeof(eXosip_reg_t));
 
34
  if (*jr==NULL) return -1;
 
35
 
 
36
  if (r_id > 1000000)                   /* keep it non-negative */
 
37
        r_id = 0;
 
38
 
 
39
  (*jr)->r_id         = ++r_id;
 
40
  (*jr)->r_reg_period = 3600;      /* delay between registration */
 
41
  (*jr)->r_aor        = osip_strdup(from);      /* sip identity */
 
42
  (*jr)->r_contact    = osip_strdup(contact);   /* sip identity */
 
43
  (*jr)->r_registrar  = osip_strdup(proxy);     /* registrar */
 
44
  (*jr)->r_route  = osip_strdup(route);     /* outbound proxy */
 
45
#if 0
 
46
  (*jr)->r_realms     = NULL;      /* list of realms */
 
47
#endif
 
48
  (*jr)->r_last_tr    = NULL;
 
49
 
 
50
  (*jr)->next   = NULL;
 
51
  (*jr)->parent = NULL;
 
52
  return 0;
 
53
}
 
54
 
 
55
void eXosip_reg_free(eXosip_reg_t *jreg)
 
56
{
 
57
 
 
58
  osip_free(jreg->r_aor);
 
59
  osip_free(jreg->r_contact);
 
60
  osip_free(jreg->r_registrar);
 
61
#if 0
 
62
  osip_free(jreg->r_realms);
 
63
#endif
 
64
 
 
65
  if (jreg->r_last_tr != NULL)
 
66
    {
 
67
      if (jreg->r_last_tr->state==IST_TERMINATED ||
 
68
          jreg->r_last_tr->state==ICT_TERMINATED ||
 
69
          jreg->r_last_tr->state== NICT_TERMINATED ||
 
70
          jreg->r_last_tr->state==NIST_TERMINATED)
 
71
        {
 
72
          OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
 
73
                                "Release a terminated transaction\n"));
 
74
          __eXosip_delete_jinfo(jreg->r_last_tr);
 
75
          if (jreg->r_last_tr!=NULL)
 
76
            osip_list_add(eXosip.j_transactions, jreg->r_last_tr, 0);
 
77
        }
 
78
      else
 
79
        {
 
80
          OSIP_TRACE(osip_trace(__FILE__,__LINE__,OSIP_INFO1,NULL,
 
81
                                "Release a non-terminated transaction\n"));
 
82
          __eXosip_delete_jinfo(jreg->r_last_tr);
 
83
          if (jreg->r_last_tr!=NULL)
 
84
            osip_list_add(eXosip.j_transactions, jreg->r_last_tr, 0);
 
85
        }
 
86
    }
 
87
 
 
88
  osip_free(jreg);
 
89
}
 
90
 
 
91
int _eXosip_reg_find(eXosip_reg_t **reg, osip_transaction_t *tr)
 
92
{
 
93
  eXosip_reg_t  *jreg;
 
94
  *reg = NULL;
 
95
  if (tr==NULL) return -1;
 
96
 
 
97
  for (jreg = eXosip.j_reg; jreg!=NULL; jreg = jreg->next)
 
98
    {
 
99
      if (jreg->r_last_tr==tr)
 
100
        {
 
101
          *reg = jreg;
 
102
          return 0;
 
103
        }
 
104
    }
 
105
  return -1;
 
106
}