Exemplo n.º 1
0
def add_account():
	global g_acc_id

	acc_domain = ""
	acc_username = ""
	acc_passwd =""
	confirm = ""
	
	# Input account configs
	print "Your SIP domain (e.g. myprovider.com): ",
	acc_domain = sys.stdin.readline()
	if acc_domain == "\n": 
		return
	acc_domain = acc_domain.replace("\n", "")

	print "Your username (e.g. alice): ",
	acc_username = sys.stdin.readline()
	if acc_username == "\n":
		return
	acc_username = acc_username.replace("\n", "")

	print "Your password (e.g. secret): ",
	acc_passwd = sys.stdin.readline()
	if acc_passwd == "\n":
		return
	acc_passwd = acc_passwd.replace("\n", "")

	# Configure account configuration
	acc_cfg = py_pjsua.acc_config_default()
	acc_cfg.id = "sip:" + acc_username + "@" + acc_domain
	acc_cfg.reg_uri = "sip:" + acc_domain

	cred_info = py_pjsua.Pjsip_Cred_Info()
	cred_info.realm = "*"
	cred_info.scheme = "digest"
	cred_info.username = acc_username
	cred_info.data_type = 0
	cred_info.data = acc_passwd

	acc_cfg.cred_info.append(1)
	acc_cfg.cred_info[0] = cred_info

	# Add new SIP account
	status, acc_id = py_pjsua.acc_add(acc_cfg, 1)
	if status != 0:
		py_pjsua.perror(THIS_FILE, "Error adding SIP account", status)
	else:
		g_acc_id = acc_id
		write_log(3, "Account " + acc_cfg.id + " added")
Exemplo n.º 2
0
status = py_pjsua.transport_set_enable(id,1)
print "py transport set enable status " + `status`
if status != 0 :
	py_pjsua.perror("py_pjsua","set enable",status)


status = py_pjsua.transport_close(id,1)
print "py transport close status " + `status`
if status != 0 :
	py_pjsua.perror("py_pjsua","close",status)

# end of lib transport

# lib account 

accfg = py_pjsua.acc_config_default()
status, accid = py_pjsua.acc_add(accfg, 1)
print "py acc add status " + `status`
if status != 0 :
	py_pjsua.perror("py_pjsua","add acc",status)
count = py_pjsua.acc_get_count()
print "acc count " + `count`

accid = py_pjsua.acc_get_default()

print "acc id default " + `accid`

# end of lib account

#lib buddy