]> sjero.net Git - linphone/blob - p2pproxy/launcher/src/p2pproxy.h
158f014df0d37d338aa2cd6625219a8055f0edc0
[linphone] / p2pproxy / launcher / src / p2pproxy.h
1 /*
2 p2pproxy Copyright (C) 2007  Jehan Monnier ()
3
4 p2pproxy.h - sip proxy.
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 */
20 #ifndef P2PPROXY_LAUNCHER_H_
21 #define P2PPROXY_LAUNCHER_H_
22
23 #include <stdio.h>
24 #ifdef SWIG
25 %module P2pProxylauncher
26 %javaconst(1);
27 %include "p2pproxy.h"
28 #endif /*SWIG*/
29 #define P2PPROXY_EWOULDBLOCK  4
30 #define P2PPROXY_ACCOUNTMGT_USER_EXIST 1
31 #define P2PPROXY_ACCOUNTMGT_USER_NOT_EXIST 0 
32 #define P2PPROXY_RESOURCEMGT_SERVER_NOT_FOUND  3
33 /* state code*/
34 #define P2PPROXY_CONNECTED 2
35 #define P2PPROXY_NOT_CONNECTED 1
36 /* status code*/
37 #define P2PPROXY_NO_ERROR 0
38 /*error codes*/
39 #define P2PPROXY_ERROR -1
40 #define P2PPROXY_ERROR_APPLICATION_NOT_STARTED  -2
41 #define P2PPROXY_ERROR_APPLICATION_ALREADY_STARTED  -3
42 #define P2PPROXY_ERROR_ACCOUNTMGT_USER_ALREADY_EXIST  -4
43 #define P2PPROXY_ERROR_ACCOUNTMGT_BAD_SIP_URI  -5
44 #define P2PPROXY_ERROR_RESOURCEMGT_SERVER_NOT_FOUND  -6
45
46 #ifndef SWIG
47 /**
48  *  start p2pproxy application
49  *  blocking call
50  *  @param argc number of argument
51  *  @param argv arguments
52  *      @return status code
53  * 
54  */
55 int p2pproxy_application_start(int argc, char **argv);
56
57 /**
58  *  return status
59  *      @return P2PPROXY_CONNECTED, P2PPROXY_NOT_ERROR
60  * 
61  */
62 int p2pproxy_application_get_state(void);
63
64 /**
65  *  stop p2pproxy application
66  * 
67  */
68 int p2pproxy_application_stop(void);
69
70 /**
71  * return the status string corresponding to the status code
72  */
73 /*const char* p2pproxy_status_string(int status_code);*/
74
75 /************************/
76 /***account management***/
77 /************************/
78
79 /**
80 * create an account with the given name (must be unique)
81 * @param user_name user sip uri (sip:joe@p2p.linphone.org)
82 *  
83 * @return  P2PPROXY_NO_ERROR, P2PPROXY_ERROR_APPLICATIONNOTSTARTED, P2PPROXY_ERROR_ACCOUNTMGT_USERALREADYEXIST, P2PPROXY_ERROR_ACCOUNTMGT_BADSIPURI
84 */
85 int p2pproxy_accountmgt_createAccount(const char* user_name);
86 /**
87 * check if a user name has been already created
88 * @param user_name user sip uri (sip:joe@p2p.linphone.org)
89 * @return P2PPROXY_ACCOUNTMGT_USEREXIST, P2PPROXY_ACCOUNTMGT_USERNOTEXIST , P2PPROXY_ERROR_APPLICATIONNOTSTARTED
90 */
91 int p2pproxy_accountmgt_isValidAccount(const char* user_name);
92
93 /**
94 * delete an account with the given name 
95 * @param user_name  user sip uri (sip:joe@p2p.linphone.org)
96 * @return P2PPROXY_NO_ERROR, P2PPROXY_ERROR_APPLICATIONNOTSTARTED
97 */
98 int p2pproxy_accountmgt_deleteAccount(const char* user_name);
99
100 /****************************/
101 /***resource management******/
102 /****************************/
103 /**
104  * Structure to store resource list, must be instanciated by 
105  * p2pproxy_resourcemgt_new_resource_list and deleted by p2pproxy_resourcemgt_delete_resource_list.
106  * 
107  */
108 #define P2PPROXY_MAX_RESOURCE_LIST_SIZE 10
109 typedef struct p2pproxy_resourcemgt_resource_list {
110         char* resource_uri[P2PPROXY_MAX_RESOURCE_LIST_SIZE]; /* uri list*/
111         unsigned char size;   /*number of element in the list*/
112 } p2pproxy_resourcemgt_resource_list_t;
113
114 /**
115  * Instanciate a p2pproxy_resourcemgt_resource_list
116  */
117 p2pproxy_resourcemgt_resource_list_t* p2pproxy_resourcemgt_new_resource_list(void);
118 /**
119  * delete a p2pproxy_resourcemgt_resource_list 
120  */
121 void p2pproxy_resourcemgt_delete_resource_list(p2pproxy_resourcemgt_resource_list_t* resource_list);
122
123 /**
124 * access a proxy registrar sip addreess for a given domaine name 
125 * @param [out] proxy_uri buffer allocated by the user
126 * @param [in] size buffer size
127 * @param [in] domaine name
128 * @return status code P2PPROXY_NO_ERROR, P2PPROXY_ERROR_RESOURCELOCATOR_SERVER_NOT_FOUND
129 */
130 int p2pproxy_resourcemgt_lookup_sip_proxy(char* proxy_uri,size_t size, const char* domain) ;
131 /**
132 * access a media ressource addresses for a given domaine name 
133 * @param [out] p2pproxy_resourcemgt_resource_list_t  allocated by the user (size = 0)
134 * @param [in] domaine name
135 * @return status code P2PPROXY_NO_ERROR, P2PPROXY_ERROR_RESOURCELOCATOR_SERVER_NOT_FOUND
136 */
137 int p2pproxy_resourcemgt_lookup_media_resource(p2pproxy_resourcemgt_resource_list_t* resource_list, const char* domain) ;
138 /*
139  * notify the library at a given proxy is no longuer reachable 
140 * @param [in] proxy sip uri
141 * @return status code P2PPROXY_NO_ERROR
142 */
143 int p2pproxy_resourcemgt_revoke_sip_proxy(const char* proxy_uri);
144
145 /*
146  * notify the library at a given Media resoure is no longuer reachable 
147 * @param [in] media resource uri (udp://hostname:port)
148 * @return status code P2PPROXY_NO_ERROR
149 */
150 int p2pproxy_resourcemgt_revoke_media_resource(const char* resource_uri);
151
152 #endif /*SWIG*/
153
154 #endif /*P2PPROXY_LAUNCHER_H_*/