From bce9a50cb830d72f913c124e5493f1eca85bb61a Mon Sep 17 00:00:00 2001 From: smorlat Date: Wed, 18 Feb 2009 20:22:45 +0000 Subject: [PATCH] wip for buddy lookup. git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@265 3f6dc0c8-ddfe-455d-9043-3cd528dc4637 --- linphone/coreapi/linphonecore.h | 2 +- linphone/coreapi/proxy.c | 33 ++++++++++++++------------------- linphone/coreapi/sipsetup.c | 6 ++++++ linphone/coreapi/sipsetup.h | 19 +++++++++++++++++++ 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/linphone/coreapi/linphonecore.h b/linphone/coreapi/linphonecore.h index b15016fbf..0652fb834 100644 --- a/linphone/coreapi/linphonecore.h +++ b/linphone/coreapi/linphonecore.h @@ -316,7 +316,7 @@ bool_t linphone_proxy_config_is_registered(const LinphoneProxyConfig *obj); 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); +void linphone_proxy_config_set_setup_object(LinphoneProxyConfig *cfg, const char *type); typedef struct _LinphoneAuthInfo diff --git a/linphone/coreapi/proxy.c b/linphone/coreapi/proxy.c index 53f9d658a..b9c03f42e 100644 --- a/linphone/coreapi/proxy.c +++ b/linphone/coreapi/proxy.c @@ -539,19 +539,14 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config if (!lp_config_has_section(config,key)){ return NULL; } - identity=lp_config_get_string(config,key,"reg_identity",NULL); - tmp=lp_config_get_string(config,key,"type",NULL); + + cfg=linphone_proxy_config_new(); + + identity=lp_config_get_string(config,key,"reg_identity",NULL); proxy=lp_config_get_string(config,key,"reg_proxy",NULL); - if (tmp!=NULL && strlen(tmp)>0){ - cfg=linphone_proxy_config_new_from_setup(tmp,identity); - if (cfg==NULL) return NULL; - }else{ - if (!identity || !proxy) return NULL; - cfg=linphone_proxy_config_new(); - linphone_proxy_config_set_identity(cfg,identity); - linphone_proxy_config_set_server_addr(cfg,proxy); - - } + + linphone_proxy_config_set_identity(cfg,identity); + linphone_proxy_config_set_server_addr(cfg,proxy); tmp=lp_config_get_string(config,key,"reg_route",NULL); if (tmp!=NULL) linphone_proxy_config_set_route(cfg,tmp); @@ -561,25 +556,25 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0)); + tmp=lp_config_get_string(config,key,"type",NULL); + if (tmp!=NULL && strlen(tmp)>0) + linphone_proxy_config_set_setup_object(cfg,tmp); + return cfg; } -LinphoneProxyConfig *linphone_proxy_config_new_from_setup(const char *type, const char *identity){ +void linphone_proxy_config_set_setup_object(LinphoneProxyConfig *cfg, const char *type){ SipSetup *ss=sip_setup_lookup(type); - LinphoneProxyConfig *cfg; SipSetupContext *ssc; - if (!ss) return NULL; - cfg=linphone_proxy_config_new(); - linphone_proxy_config_set_identity(cfg,identity); + if (!ss) return ; ssc=sip_setup_context_new(ss); - if (sip_setup_context_login_account(ssc,identity,NULL)==0){ + if (sip_setup_context_login_account(ssc,cfg->reg_identity,NULL)==0){ char proxy[256]; if (sip_setup_context_get_proxy(ssc,NULL,proxy,sizeof(proxy))==0){ linphone_proxy_config_set_server_addr(cfg,proxy); } } cfg->ssctx=ssc; - return cfg; } diff --git a/linphone/coreapi/sipsetup.c b/linphone/coreapi/sipsetup.c index af80ea48f..7b9a02671 100644 --- a/linphone/coreapi/sipsetup.c +++ b/linphone/coreapi/sipsetup.c @@ -93,6 +93,12 @@ int sip_setup_context_get_relay(SipSetupContext *ctx,char *relay, size_t size){ return -1; } +int sip_setup_context_lookup_buddy(SipSetupContext *ctx, const char *key, BuddyInfo *binfo){ + if (ctx->funcs->lookup_buddy) + return ctx->funcs->lookup_buddy(ctx,key,binfo); + return -1; +} + void sip_setup_context_free(SipSetupContext *ctx){ ms_free(ctx); } diff --git a/linphone/coreapi/sipsetup.h b/linphone/coreapi/sipsetup.h index 48e763c72..5d85e3525 100644 --- a/linphone/coreapi/sipsetup.h +++ b/linphone/coreapi/sipsetup.h @@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. struct _SipSetup; +struct _BuddyInfo; + struct _SipSetupContext{ struct _SipSetup *funcs; char domain[128]; @@ -41,12 +43,28 @@ struct _SipSetup{ 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); + int (*lookup_buddy)(SipSetupContext *ctx, const char *key, struct _BuddyInfo *info); void (*exit)(void); bool_t initialized; }; typedef struct _SipSetup SipSetup; +typedef struct _BuddyAddress{ + char street[64]; + char zip[64]; + char town[64]; + char country[64]; +} BuddyAddress; + +typedef struct _BuddyInfo{ + char firstname[64]; + char lastname[64]; + char displayname[64]; + char sip_uri[128]; + BuddyAddress address; +}BuddyInfo; + void sip_setup_register_all(void); SipSetup *sip_setup_lookup(const char *type_name); void sip_setup_unregister_all(void); @@ -57,6 +75,7 @@ int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, cons 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); +int sip_setup_context_lookup_buddy(SipSetupContext *ctx, const char *key, BuddyInfo *binfo); void sip_setup_context_free(SipSetupContext *ctx); #endif