Example #1
0
/**
 * owplLineAdd
 *
 * add a virtual line 
 * 
 * @param  displayname
 * @param  username
 * @param  server
 * @param  proxy
 * @param  regTimeout	The value that will be put in Expire header of register message
 * @param(out)  phLine  The newly created line handle
 * @return				OWPL_RESULT_SUCCESS in case of success
 */
MY_DLLEXPORT OWPL_RESULT
owplLineAdd(const char* displayname,
			 const char* username, 
			 const char* server, 
			 const char*  proxy,  
			 int regTimeout,
			 OWPL_LINE * phLine)
{	
	int ret;
	phVLine *vl;

	vl = ph_find_matching_vline2(username, server, 0);

	if (vl) {
		vl->regTimeout = regTimeout;
		*phLine = ph_vline2vlid(vl);
	}
	else {
		/* Call phAddVline2 with timeout = 0 to avoid sending right away the REGISTER message.
		 * (this function send a REGISTER message if timeout > 0 and we have shouldn't change it
		 * for backward compatibility
		 */
		ret = phAddVline2(displayname, username, server, proxy, 0); 
		if (ret < 0) {
			return OWPL_RESULT_FAILURE;
		}
		vl = ph_vlid2vline(ret);
		if (vl)	{
			vl->regTimeout = regTimeout;
		}
		*phLine = ret;
	}
	return OWPL_RESULT_SUCCESS;
}
Example #2
0
OWPL_RESULT
owplCallConnectWithBody(const OWPL_CALL hCall,
				const char* szAddress,
				const char* szContentType,
				const char* szBody,
				int BodySize)
{
	int i;
	osip_message_t *invite;
	char *proxy ;
	phVLine *vl;
	char from[512];
	OWSIPAccount account ;

	phcall_t *ca = ph_locate_call_by_cid(hCall);
	if (ca == NULL)
	{
		return OWPL_RESULT_INVALID_ARGS ;
	}

	account = owplLineSipAccountGet (ca->vlid) ;
	if (account <= 0)
	{
		return OWPL_RESULT_INVALID_ARGS ;
	}

	// TODO verif des arguments
	if (!szAddress){
		return OWPL_RESULT_INVALID_ARGS;
	}

	vl = ph_valid_vlid(ca->vlid);
	if (!vl) {
		return OWPL_RESULT_INVALID_ARGS;
	}

	ph_vline_get_from(from, sizeof(from), vl);

	proxy = owsip_account_proxy_get (account) ;

	if((i = eXosip_build_initial_invite(&invite, (char *)szAddress, from, proxy, "")) != 0){
		return -1;
	}

	eXosip_lock();

	i = eXosip_initiate_call_with_body(account, invite, szContentType, szBody, 0);
	if (i <= 0) {
		return OWPL_RESULT_FAILURE;
	}

	ca->extern_cid = i;
	ca->vlid = ph_vline2vlid(vl);

	eXosip_unlock(); 

	owplAssociateCall2PluginByContentType(ca->cid, szContentType);

	return OWPL_RESULT_SUCCESS;
}
Example #3
0
/**
 * owplLineAdd
 *
 * add a virtual line 
 * 
 * @param  displayname
 * @param  username
 * @param  server
 * @param  proxy
 * @param  regTimeout	The value that will be put in Expire header of register message
 * @param(out)  phLine  The newly created line handle
 * @return				OWPL_RESULT_SUCCESS in case of success
 */
OWPL_RESULT
owplLineAdd(const char * displayname,
			 const char * sipUsername,
			 const char * sipServer,
			 const char * sipProxy,
			 OWPL_TRANSPORT_PROTOCOL sipTransport,
			 int regTimeout,
			 OWPL_LINE * phLine)
{	
	int ret;
	phVLine *vl;

	vl = ph_find_matching_vline2(sipUsername, sipServer, 0);

	if (vl) {
		vl->regTimeout = regTimeout;
		*phLine = ph_vline2vlid(vl);
	}
	else {
		/* Call phAddVline2 with timeout = 0 to avoid sending right away the REGISTER message.
		 * (this function send a REGISTER message if timeout > 0 and we have shouldn't change it
		 * for backward compatibility
		 */
		ret = phAddVline2(displayname, sipUsername, sipServer, sipProxy, sipTransport, 0); 
		if (ret < 0) {
			return OWPL_RESULT_FAILURE;
		}
		vl = ph_vlid2vline(ret);
		if (vl)	{
			vl->regTimeout = regTimeout;
		}
		*phLine = ret;
		owplLineSetAutoKeepAlive(ret, 1, 30);
	}
	return OWPL_RESULT_SUCCESS;
}
Example #4
0
void ph_refresh_vlines()
{
	int i;
	phVLine *vl;

	time_t now = time(NULL);

	if (now - last_vline_refresh > 5)
	{
		for (i = 0; i < PH_MAX_VLINES; i++)
		{
			vl = ph_vlines + i;
			if (!vl->used)
				continue;

			if (vl->LineState == LINESTATE_REGISTERED)
			{
				if (vl->server && vl->server[0] && vl->regTimeout > 0)
				{
					if ((now - vl->lastRegTime) > (vl->regTimeout - 5))
					{
						phvlRegister(ph_vline2vlid(vl));
					}

					if ((now - vl->publishInfo.lastPublishTime) > (vl->publishInfo.publishTimeout - 5))
					{
						owplPresencePublish(ph_vline2vlid(vl), vl->publishInfo.onlineState, vl->publishInfo.szStatus, vl->publishInfo.hPub);
					}

				}
			}
		}
		last_vline_refresh = time(0);
	}

	//if (!phcfg.use_tunnel && phcfg.nat_refresh_time > 0)
	if (phcfg.nat_refresh_time > 0) 
	{
		// This is to support a deprecated mode when using the function owplConfigSetNat. 
		// This if block is to be removed (but keep the else block)		

		if (now - last_nat_refresh > phcfg.nat_refresh_time)
		{
			for( i = 0; i < PH_MAX_VLINES; i++)
			{
				vl = ph_vlines + i;  
				if (!vl->used) {
					continue;
				}

				if (vl->server && vl->server[0] && vl->regTimeout > 0)
				{
					ph_nat_refresh(vl);
				}
			}
			last_nat_refresh = time(0);
		}
	}
	else {
		for( i = 0; i < PH_MAX_VLINES; i++)
		{
			vl = ph_vlines + i;  
			if (!vl->used) {
				continue;
			}
			if ((now - vl->keepAliveInfo.lastSentTime) > (vl->keepAliveInfo.period)) {
				if (vl->server && vl->server[0] && vl->LineState == LINESTATE_REGISTERED) {
					phLineSendOptions(ph_vline2vlid(vl) , vl->proxy);
					vl->keepAliveInfo.lastSentTime = time(0);
				}
			}
		}
	}
}