コード例 #1
0
/** MyH323EndPoint 
  * The fullAddress parameter is used directly in the MakeCall method so
  * the General form for the fullAddress argument is :
  * [alias@][transport$]host[:port]
  * default values:	alias = the same value as host.
  *					transport = ip.
  *					port = 1720.
  */
int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, unsigned int port, char *callerid, char *callername)
{
	PString fullAddress;
	MyH323Connection * connection;

	/* Determine whether we are using a gatekeeper or not. */
	if (GetGatekeeper() != NULL) {
		fullAddress = dest;
		if (h323debug)
			cout << " -- Making call to " << fullAddress << " using gatekeeper." << endl;
	} else {
			fullAddress = dest; /* host */
			if (h323debug)
				cout << " -- Making call to " << fullAddress << "." << endl;
	}

	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token))) {
		if (h323debug)
			cout << "Error making call to \"" << fullAddress << '"' << endl;
		return 1;
	}
	
	*callReference = connection->GetCallReference();
	
	if (callerid)
		connection->SetLocalPartyName(PString(callerid));
	if (callername) {
                localAliasNames.RemoveAll();
		connection->SetLocalPartyName(PString(callername));
	        if (callerid)
                  localAliasNames.AppendString(PString(callerid));
        } else if (callerid) {
                localAliasNames.RemoveAll();
                connection->SetLocalPartyName(PString(callerid));
        }
        
        connection->AST_Outgoing = TRUE;

	connection->Unlock(); 	

	if (h323debug) {
		cout << "	-- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
		cout << "	-- " << "Call token is " << (const char *)token << endl;
		cout << "	-- Call reference is " << *callReference << endl;
	}
	return 0;
}
/** The fullAddress parameter is used directly in the MakeCall method so
  * the General form for the fullAddress argument is :
  * [alias@][transport$]host[:port]
  * default values:	alias = the same value as host.
  *					transport = ip.
  *					port = 1720.
  */
int MyH323EndPoint::MakeCall(const PString & dest, PString & token, unsigned int *callReference, call_options_t *opts)
{
	PString fullAddress;
	MyH323Connection * connection;

	/* Determine whether we are using a gatekeeper or not. */
	if (GetGatekeeper()) {
		fullAddress = dest;
		if (h323debug) {
			cout << " -- Making call to " << fullAddress << " using gatekeeper." << endl;
		}
	} else {
		fullAddress = dest; 
		if (h323debug) {
			cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl;
		}
	}
	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token, opts))) {
		if (h323debug) {
			cout << "Error making call to \"" << fullAddress << '"' << endl;
		}
		return 1;
	}
	*callReference = connection->GetCallReference();	

	if (opts->cid_num) {
		connection->ast_cid_num = PString(opts->cid_num);
	}
	if (opts->cid_name) {
		connection->ast_cid_name = PString(opts->cid_name);
		connection->SetLocalPartyName(connection->ast_cid_name);
	}

	connection->dtmfCodec = (RTP_DataFrame::PayloadTypes)opts->dtmfcodec;

	if (h323debug) {
		cout << "\t-- " << GetLocalUserName() << " is calling host " << fullAddress << endl;
		cout << "\t-- Call token is " << (const char *)token << endl;
		cout << "\t-- Call reference is " << *callReference << endl;
		cout << "\t-- DTMF Payload is " << connection->dtmfCodec << endl;
	}
	connection->Unlock(); 	
	return 0;
}
コード例 #3
0
ファイル: MyPhoneEndPoint.cpp プロジェクト: cubemoon/myphone3
BOOL CMyPhoneEndPoint::FindGatekeeper()
{
	if (GetGatekeeper() != NULL) {
		if (gatekeeper->IsRegistered()) // If registered, then unregister
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKUNREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName());	
		RemoveGatekeeper();
	}
	
	if (!config.GetBoolean(UseGatekeeperConfigKey, FALSE))
		return TRUE;
	
	SetGatekeeperPassword(config.GetString(GatekeeperPassConfigKey));
	
	PString gkHost = config.GetString(GatekeeperHostConfigKey, "");
	PString gkid = config.GetString(GatekeeperIdConfigKey, "");
	PString iface = "";
	int iMode = config.GetInteger(DiscoverGatekeeperConfigKey, -1);
	switch(iMode)
	{
	case -1:
		return TRUE;
		break;
	case 0:
		gkHost = "";
		gkid = "";
		iface = "";
		break;
	case 1:
		gkid = "";
		iface = "";
		break;
	case 2:
		gkHost = "";
		iface = "";
		break;
	}

	m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKSRCHSTR), S_SYSTEM);	
	m_dialog->m_cstatus.UpdateWindow();
	AfxGetApp()->DoWaitCursor(1);
	if (UseGatekeeper(gkHost, gkid, iface)) {
		m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName());	
	}
	AfxGetApp()->DoWaitCursor(0);
	
	BOOL gkRequired = config.GetBoolean(RequireGatekeeperConfigKey, FALSE);
	
	if (GetGatekeeper() != NULL)
	{
		unsigned reason = gatekeeper->GetRegistrationFailReason();
		switch (reason) {
		case H323Gatekeeper::InvalidListener :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRPORTSTR));
			break;
		case H323Gatekeeper::DuplicateAlias :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRALIASSTR));
			break;
		case H323Gatekeeper::SecurityDenied :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRSECSTR));
			break;
		case H323Gatekeeper::TransportError :
			m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRTRNSTR));
			break;
		default :
			if ((reason&H323Gatekeeper::RegistrationRejectReasonMask) != 0)
			{
				CString strRes;
				strRes.Format((LPCTSTR)LoadStringLang(IDS_GKERRUNSTR),(int) reason&(H323Gatekeeper::RegistrationRejectReasonMask-1));
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR), S_SYSTEM, (LPCTSTR) strRes);
			}
			break;
		}
	}
	else
	{
		if (!gkHost.IsEmpty())
		{
			if (!gkid.IsEmpty())
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFINDSTR),
				S_SYSTEM, (const char *)gkid, (const char *)gkHost);
			else
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND1STR),
				S_SYSTEM, (const char *)gkHost);
		}
		else {
			if (!gkid.IsEmpty())
				m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND2STR),
				S_SYSTEM, (const char *)gkid);
			else
			{
				if (gkRequired)
					m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND3STR),
					S_SYSTEM);
				else
					m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND4STR),
					S_SYSTEM);
			}
		}
	}
	
	return !gkRequired; 
}