Esempio n. 1
0
static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char *passwd){
	LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
	LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
	LinphoneAuthInfo *auth;
	osip_from_t *parsed_uri;
	char *tmp;

	osip_from_init(&parsed_uri);
	osip_from_parse(parsed_uri,uri);
	if (parsed_uri->displayname==NULL || strlen(parsed_uri->displayname)==0){
		guess_display_name(parsed_uri);
	}
	osip_from_to_str(parsed_uri,&tmp);
	linphone_proxy_config_set_identity(cfg,tmp);
	if (passwd ) {
		auth=linphone_auth_info_new(parsed_uri->url->username,NULL,passwd,NULL,NULL);
		linphone_core_add_auth_info(lc,auth);
	}
	linphone_proxy_config_enable_register(cfg,TRUE);
	linphone_proxy_config_done(cfg);
	osip_free(tmp);
	osip_from_free(parsed_uri);
	ms_message("SipLogin: done");
	return 0;
}
Esempio n. 2
0
int
main (int argc, char **argv)
{
  FILE *froms_file;


  osip_from_t *from;
  char *a_from;
  char *dest;
  char *res;

  froms_file = fopen (argv[1], "r");
  if (froms_file == NULL)
    {
      fprintf (stdout, "Failed to open %s file.\nUsage: tfrom froms.txt\n",
	       argv[1]);
      exit (0);
    }

  a_from = (char *) osip_malloc (200);
  res = fgets (a_from, 200, froms_file);	/* lines are under 200 */
  while (res != NULL)
    {

      int errcode;

      /* remove the last '\n' before parsing */
      strncpy (a_from + strlen (a_from) - 1, "\0", 1);

      if (0 != strncmp (a_from, "#", 1))
	{
	  /* allocate & init from */
	  osip_from_init (&from);
	  printf ("=================================================\n");
	  printf ("FROM TO PARSE: |%s|\n", a_from);
	  errcode = osip_from_parse (from, a_from);
	  if (errcode != -1)
	    {
	      if (osip_from_to_str (from, &dest) != -1)
		{
		  printf ("result:        |%s|\n", dest);
		  osip_free (dest);
		}
	    }
	  else
	    printf ("Bad from format: %s\n", a_from);
	  osip_from_free (from);
	  printf ("=================================================\n");
	}
      res = fgets (a_from, 200, froms_file);	/* lines are under 200 */
    }
  osip_free (a_from);
  return 0;
}
Esempio n. 3
0
int sip_setup_context_login_account(SipSetupContext * ctx, const char *uri, const char *passwd){
	osip_from_t *from;
	osip_from_init(&from);
	osip_from_parse(from,uri);
	strncpy(ctx->domain,from->url->host,sizeof(ctx->domain));
	strncpy(ctx->username,from->url->username,sizeof(ctx->username));
	osip_from_free(from);
	if (ctx->funcs->login_account)
		return ctx->funcs->login_account(ctx,uri,passwd);
	return -1;
}
Esempio n. 4
0
/* returns -1 on error. */
int osip_contact_parse(osip_contact_t * contact, const char *hvalue)
{
	if (contact == NULL)
		return OSIP_BADPARAMETER;
	if (strncmp(hvalue, "*", 1) == 0) {
		contact->displayname = osip_strdup(hvalue);
		if (contact->displayname == NULL) {
			return OSIP_NOMEM;
		}
		return OSIP_SUCCESS;
	}
	return osip_from_parse((osip_from_t *) contact, hvalue);
}
Esempio n. 5
0
gchar *linphone_gtk_get_display_name(const char *sip_uri){
	osip_from_t *from;
	gchar *ret=NULL;
	if (strchr(sip_uri,'@')){
		osip_from_init(&from);
		if (osip_from_parse(from,sip_uri)==0){
			if (from->displayname!=NULL && strlen(from->displayname)>0){
				ret=g_strdup(from->displayname);
			}
		}
		osip_from_free(from);
	}
	if (ret==NULL) ret=g_strdup(sip_uri);
	return ret;
}
Esempio n. 6
0
static int jua_check_url(char *url)
{
	int i;
	osip_from_t *to;

	i = osip_from_init(&to);
	if (i!=0)
		return -1;

	i = osip_from_parse(to, url);
	if (i!=0)
		return -1;

	return 0;
}
Esempio n. 7
0
int linphone_proxy_config_set_server_addr(LinphoneProxyConfig *obj, const char *server_addr){
	int err;
	osip_from_t *url;
	if (obj->reg_proxy!=NULL) ms_free(obj->reg_proxy);
	obj->reg_proxy=NULL;
	if (server_addr!=NULL && strlen(server_addr)>0){
		osip_from_init(&url);
		err=osip_from_parse(url,server_addr);
		if (err==0 && url->url->host!=NULL){
			obj->reg_proxy=ms_strdup(server_addr);
		}else{
			ms_warning("Could not parse %s",server_addr);
		}
		osip_from_free(url);
	}
	return 0;
}
Esempio n. 8
0
static osip_from_t *ph_parse_from(const char *userid)
{
	osip_from_t *from;

	osip_from_init(&from);
	if (!from) {
		return 0;
	}

	osip_from_parse(from, userid); 
	if (from->url && from->url->port && !strcmp(from->url->port, "5060"))
	{
		osip_free(from->url->port);
		from->url->port = NULL;
	}

	return from;
}
Esempio n. 9
0
void linphone_proxy_config_set_identity(LinphoneProxyConfig *obj, const char *identity){
	int err=0;
	osip_from_t *url;
	if (identity!=NULL && strlen(identity)>0){
		osip_from_init(&url);
		err=osip_from_parse(url,identity);
		if (err<0 || url->url->host==NULL || url->url->username==NULL){
			ms_warning("Could not parse %s",identity);
			osip_from_free(url);
			return;
		}
		osip_from_free(url);
	} else err=-2;
	if (obj->reg_identity!=NULL) {
		ms_free(obj->reg_identity);
		obj->reg_identity=NULL;
	}
	if (err==-2) obj->reg_identity=NULL;
	else obj->reg_identity=ms_strdup(identity);
}
Esempio n. 10
0
/* returns -1 on error. */
int
osip_message_set_from (osip_message_t * sip, const char *hvalue)
{
  int i;

  if (hvalue == NULL || hvalue[0] == '\0')
    return 0;

  if (sip->from != NULL)
    return -1;
  i = osip_from_init (&(sip->from));
  if (i != 0)
    return -1;
  sip->message_property = 2;
  i = osip_from_parse (sip->from, hvalue);
  if (i != 0)
    {
      osip_from_free (sip->from);
      sip->from = NULL;
      return -1;
    }
  return 0;
}
Esempio n. 11
0
int
osip_route_parse (osip_route_t * route, const char *hvalue)
{
  return osip_from_parse ((osip_from_t *) route, hvalue);
}
Esempio n. 12
0
int osip_to_parse(osip_to_t * to, const char *hvalue)
{
	return osip_from_parse((osip_from_t *) to, hvalue);
}