source: mediastreamer2/p2pproxy/plugin-src/fonis.c @ 367:1dfac7fd3b66

Last change on this file since 367:1dfac7fd3b66 was 338:6fe721ca98bc, checked in by smorlat <smorlat@…>, 4 years ago
  • improve makefiles
  • add fonis plugin for liblinphone
  • clean a few char* to const char *

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@341 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File size: 3.1 KB
Line 
1/*
2linphone
3Copyright (C) 2000  Simon MORLAT (simon.morlat@linphone.org)
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18*/
19
20
21#include "sipsetup.h"
22#include "p2pproxy.h"
23
24typedef struct _FonisContext{
25        int toto;
26}FonisContext;
27
28static ms_thread_t fonis_thread;
29
30
31static void *fonis_thread_func(void *arg){
32        if (p2pproxy_application_start(0,NULL)!=0){
33                ms_error("Fail to start fonis thread !");
34        }
35        return NULL;
36}
37
38static bool_t fonis_init(void){
39        static bool_t initd=FALSE;
40        if (!initd){
41                ms_thread_create(&fonis_thread,NULL,fonis_thread_func,NULL);
42                initd=TRUE;
43        }
44        sleep(4);
45        return TRUE;
46}
47
48
49static int fonis_create_account(const char *uri, const char *passwd){
50        int err=p2pproxy_accountmgt_createAccount(uri);
51        if (err<0) return -1;
52        return 0;
53}
54
55static int fonis_login_account(SipSetupContext * ctx,const char *uri, const char *passwd){
56        if (p2pproxy_accountmgt_isValidAccount(uri)==P2PPROXY_ACCOUNTMGT_USER_EXIST) {
57                return 0;
58        }
59        else return -1;
60}
61
62static int fonis_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz){
63        int err=p2pproxy_resourcemgt_lookup_sip_proxy(proxy,sz,(char*)domain);
64        if (err==0) return 0;
65        else return -1;
66}
67
68static int fonis_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size){
69        FonisContext *fc=(FonisContext*)ctx->data;
70        int ret=-1;
71        p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
72        if (p2pproxy_resourcemgt_lookup_media_resource(l,ctx->domain)==0){
73                if (l->size>0) strncpy(stun1,l->resource_uri[0],size);
74                if (l->size>1) strncpy(stun2,l->resource_uri[1],size);
75                ret=0;
76        }
77        p2pproxy_resourcemgt_delete_resource_list(l);
78        return ret;
79}
80
81static int fonis_get_relay(SipSetupContext *ctx, char *relay, size_t size){
82        FonisContext *fc=(FonisContext*)ctx->data;
83        int ret=-1;
84        p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
85        if (p2pproxy_resourcemgt_lookup_media_resource(l,ctx->domain)==0){
86                if (l->size>0) strncpy(relay,l->resource_uri[0],size);
87                ret=0;
88        }
89        p2pproxy_resourcemgt_delete_resource_list(l);
90        return ret;
91}
92
93
94static SipSetup fonis_sip_setup={
95        .capabilities=SIP_SETUP_CAP_PROXY_PROVIDER|SIP_SETUP_CAP_STUN_PROVIDER|
96                                SIP_SETUP_CAP_RELAY_PROVIDER|SIP_SETUP_CAP_ACCOUNT_MANAGER,
97        .name="fonis",
98        .init=fonis_init,
99        .create_account=fonis_create_account,
100        .login_account=fonis_login_account,
101        .get_proxy=fonis_get_proxy,
102        .get_stun_servers=fonis_get_stun_servers,
103        .get_relay=fonis_get_relay,
104        .exit=p2pproxy_application_stop
105};
106
107void libfonisprovider_init(void){
108        sip_setup_register(&fonis_sip_setup);
109}
110
Note: See TracBrowser for help on using the repository browser.