Commit bce9a50c authored by smorlat's avatar smorlat

wip for buddy lookup.



git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@265 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 06167bd9
......@@ -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
......
......@@ -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;
}
......@@ -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);
}
......@@ -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
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