3 Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program 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.
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.
24 static ms_thread_t fonis_thread;
27 static void *fonis_thread_func(void *arg){
28 if (p2pproxy_application_start(0,NULL)!=0){
29 ms_error("Fail to start fonis thread !");
34 static bool_t fonis_init(void){
35 static bool_t initd=FALSE;
37 ms_thread_create(&fonis_thread,NULL,fonis_thread_func,NULL);
44 static int fonis_create_account(const char *uri, const char *passwd){
45 int err=p2pproxy_accountmgt_createAccount(uri);
50 static int fonis_login_account(SipSetupContext * ctx,const char *uri, const char *passwd){
51 if (p2pproxy_accountmgt_isValidAccount==P2PPROXY_ACCOUNTMGT_USER_EXIST) {
57 static int fonis_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz){
58 int err=p2pproxy_resourcemgt_lookup_sip_proxy(proxy,sz,(char*)domain);
63 static int fonis_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size){
64 FonisContext *fc=(FonisContext*)ctx->data;
66 p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
67 if (p2pproxy_resourcemgt_lookup_media_resource(l,ctx->domain)==0){
68 if (l->size>0) strncpy(stun1,l->resource_uri[0],size);
69 if (l->size>1) strncpy(stun2,l->resource_uri[1],size);
72 p2pproxy_resourcemgt_delete_resource_list(l);
76 static int fonis_get_stun_relay(SipSetupContext *ctx, char *relay, size_t size){
77 FonisContext *fc=(FonisContext*)ctx->data;
79 p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
80 if (p2pproxy_resourcemgt_lookup_media_resource(l,ctx->domain)==0){
81 if (l->size>0) strncpy(relay,l->resource_uri[0],size);
84 p2pproxy_resourcemgt_delete_resource_list(l);
89 SipSetup fonis_sip_setup={
92 .create_account=fonis_create_account,
93 .login_account=fonis_login_account,
94 .get_proxy=fonis_get_proxy,
95 .get_stun_servers=fonis_get_stun_servers,
96 .get_relay=fonis_get_relay,
97 .exit=p2pproxy_application_stop