Commit 3a1871b7 authored by smorlat's avatar smorlat

setups and fonis in progress.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@224 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 89e7cd93
......@@ -24,7 +24,8 @@ liblinphone_la_SOURCES=\
authentication.c \
lpconfig.c lpconfig.h \
chat.c \
general_state.c
general_state.c \
sipsetup.c sipsetup.h
liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION)
......
/*
linphone
Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sipsetup.h"
#include "p2pproxy.h"
static ms_thread_t fonis_thread;
typedef struct _FonisContext{
char domain[128];
char username[128];
} FonisContext;
static void *fonis_thread_func(void *arg){
if (p2pproxy_application_start(0,NULL)!=0){
ms_error("Fail to start fonis thread !");
}
return NULL;
}
static bool_t fonis_init(void){
static bool_t initd=FALSE;
if (!initd){
ms_thread_create(&fonis_thread,NULL,fonis_thread_func,NULL);
initd=TRUE;
}
return TRUE;
}
static int fonis_create_account(const char *uri, const char *passwd){
int err=p2pproxy_accountmgt_createAccount(uri);
if (err<0) return -1;
return 0;
}
static int fonis_login_account(SipSetupContext * ctx,const char *uri, const char *passwd){
if (p2pproxy_accountmgt_isValidAccount==P2PPROXY_ACCOUNTMGT_USER_EXIST) {
FonisContext *fc;
osip_from_t *from;
ctx->data=fc=(FonisContext*)ms_new0(FonisContext,1);
osip_from_init(&from);
osip_from_parse(from,uri);
strncpy(fc->domain,uri->url->host,sizeof(fc->domain);
strncpy(fc->username,uri->url->username,sizeof(fc->username));
osip_from_free(from);
return 0;
}
else return -1;
}
static int fonis_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz){
int err=p2pproxy_resourcemgt_lookup_sip_proxy(proxy,sz,(char*)domain);
if (err==0) return 0;
else return -1;
}
static int fonis_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size){
FonisContext *fc=(FonisContext*)ctx->data;
int ret=-1;
p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
if (p2pproxy_resourcemgt_lookup_media_resource(l,fc->domain)==0){
if (l->size>0) strncpy(stun1,l->resource_uri[0],size);
if (l->size>1) strncpy(stun2,l->resource_uri[1],size);
ret=0;
}
p2pproxy_resourcemgt_delete_resource_list(l);
return ret;
}
static int fonis_get_stun_relay(SipSetupContext *ctx, char *relay, size_t size){
FonisContext *fc=(FonisContext*)ctx->data;
int ret=-1;
p2pproxy_resourcemgt_resource_list_t* l=p2pproxy_resourcemgt_new_resource_list();
if (p2pproxy_resourcemgt_lookup_media_resource(l,fc->domain)==0){
if (l->size>0) strncpy(relay,l->resource_uri[0],size);
ret=0;
}
p2pproxy_resourcemgt_delete_resource_list(l);
return ret;
}
SipSetup fonis_sip_setup={
.name="fonis",
.init=fonis_init,
.create_account=fonis_create_account,
.login_account=fonis_login_account,
.get_proxy=fonis_get_proxy,
.get_stun_servers=fonis_get_stun_servers,
.get_relay=fonis_get_relay,
.exit=p2pproxy_application_stop
};
......@@ -284,6 +284,7 @@ typedef struct _LinphoneProxyConfig
int expires;
int reg_time;
int rid;
char *type;
bool_t frozen;
bool_t reg_sendregister;
bool_t auth_pending;
......@@ -312,6 +313,8 @@ void linphone_proxy_config_enable_publish(LinphoneProxyConfig *obj, bool_t val);
void linphone_proxy_config_destroy(LinphoneProxyConfig *cfg);
LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(struct _LpConfig *config, int index);
void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index);
LinphoneProxyConfig *linphone_proxy_config_new_from_setup(const char *type, const char *identity);
typedef struct _LinphoneAuthInfo
{
......
......@@ -546,3 +546,9 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config
return cfg;
}
LinphoneProxyConfig *linphone_proxy_config_new_from_setup(const char *type, const char *identity){
return NULL;
}
/*
linphone
Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "sipsetup.h"
#ifdef HAVE_FONIS
extern SipSetup fonis_sip_setup;
#endif
SipSetup *sip_setup_lookup(const char *type_name){
#ifdef HAVE_FONIS
if (strcmp(type_name,"fonis")==0){
if (!fonis_sip_setup.initialized){
if (fonis_sip_setup.init()){
fonis_sip_setup.initialized=TRUE;
}
}
return &fonis_sip_setup;
}
#endif
ms_warning("no %s setup manager declared.",type_name);
return NULL;
}
SipSetupContext *sip_setup_context_new(SipSetup *s){
SipSetupContext *obj=(SipSetupContext*)ms_new(SipSetupContext,1);
obj->funcs=s;
obj->data=NULL;
return obj;
}
int sip_setup_new_account(SipSetup *funcs, const char *uri, const char *passwd){
if (funcs->create_account)
return funcs->create_account(uri, passwd);
else return -1;
}
int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd){
if (ctx->funcs->login_account)
return ctx->funcs->login_account(ctx,uri,passwd);
return -1;
}
int sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz){
if (ctx->funcs->get_proxy)
return ctx->funcs->get_proxy(ctx,domain,proxy,sz);
return -1;
}
int sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size){
if (ctx->funcs->get_stun_servers)
return ctx->funcs->get_stun_servers(ctx,stun1,stun2,size);
return -1;
}
int sip_setup_context_get_relay(SipSetupContext *ctx,char *relay, size_t size){
if (ctx->funcs->get_relay)
return ctx->funcs->get_relay(ctx,relay,size);
return -1;
}
void sip_setup_context_free(SipSetupContext *ctx){
ms_free(ctx);
}
/*
linphone
Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef sipsetup_h
#define sipsetup_h
#include "linphonecore.h"
struct _SipSetup;
struct _SipSetupContext{
struct _SipSetup *funcs;
void *data;
};
typedef struct _SipSetupContext SipSetupContext;
struct _SipSetup{
char *name;
bool_t (*init)(void);
int (*create_account)( const char *uri, const char *passwd);
int (*login_account)(SipSetupContext *ctx, const char *uri, const char *passwd);
int (*get_proxy)(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz);
int (*get_stun_servers)(SipSetupContext *ctx, char *stun1, char *stun2, size_t size);
int (*get_relay)(SipSetupContext *ctx, char *relay, size_t size);
void (*exit)(void);
bool_t initialized;
};
typedef struct _SipSetup SipSetup;
SipSetup *sip_setup_lookup(const char *type_name);
int sip_setup_new_account(SipSetup *s, const char *uri, const char *passwd);
SipSetupContext * sip_setup_context_new(SipSetup *s);
int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd);
int sip_setup_context_get_proxy(SipSetupContext *ctx, const char *domain, char *proxy, size_t sz);
int sip_setup_context_get_stun_servers(SipSetupContext *ctx, char *stun1, char *stun2, size_t size);
int sip_setup_context_get_relay(SipSetupContext *ctx,char *relay, size_t size);
void sip_setup_context_free(SipSetupContext *ctx);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment