bool EndPoint::init() { PTRACE( 1, "Initializing endpoint" ); #ifdef ENTERPRISE if( !ldapQueried ) { PError << "LDAP was not queried successfuly." << endl; return false; } if( ldapAliases.IsEmpty() ) { PError << "Aliases were not fetched from LDAP." << endl; return false; } SetLocalUserName( ldapAliases[0] ); for (int i = 1; i < ldapAliases.GetSize(); i++) AddAliasName( ldapAliases[i]); if( ldapAttrs.HasKey("h323IdentitydialedDigits") ) AddAliasName( ldapAttrs.GetString("h323IdentitydialedDigits") ); #else if( args.HasOption('u')) { PStringArray aliases = args.GetOptionString('u').Lines(); SetLocalUserName(aliases[0]); for (int i = 1; i < aliases.GetSize(); i++) AddAliasName(aliases[i]); } else { QStringList userAliases = ancaConf->readListEntry( USER_ALIASES ); SetLocalUserName( userAliases[ 0 ].latin1() ); for ( unsigned i = 1; i < userAliases.size(); i++ ) AddAliasName( userAliases[ i ].latin1() ); } #endif bool disableFastStart = !ancaConf->readBoolEntry( FAST_START, FAST_START_DEFAULT ); bool disableTunneling = !ancaConf->readBoolEntry( H245_TUNNELING, H245_TUNNELING_DEFAULT ); bool disableH245InSetup = !ancaConf->readBoolEntry( H245_IN_SETUP, H245_IN_SETUP_DEFAULT ); if( args.HasOption("fast-disable") ) disableFastStart = true; if( args.HasOption("h245tunneldisable") ) disableTunneling = true; if( args.HasOption("disable-h245-in-setup") ) disableH245InSetup = true; DisableFastStart( disableFastStart ); DisableH245Tunneling( disableTunneling ); DisableH245inSetup( disableH245InSetup ); // Codecs AudioPlugin *audioPlugin = (AudioPlugin*)pluginFactory->getPlugin(Plugin::Audio); if( audioPlugin ) { audioPlugin->addCapabilities(); } VideoInPlugin *videoPlugin = (VideoInPlugin*)pluginFactory->getPlugin(Plugin::VideoIn); if( videoPlugin ) { videoPlugin->addCapabilities(); } AddAllUserInputCapabilities( 0, 1 ); PTRACE( 1, "Capabilities:\n" << setprecision( 2 ) << capabilities ); ancaInfo->set( ADDRESS, ( const char * ) (GetLocalUserName() + "@" + PIPSocket::GetHostName()) ); // Initialise the security info if( args.HasOption("password") ) { SetGatekeeperPassword( args.GetOptionString("password") ); PTRACE( 1, "Enabling H.235 security access to gatekeeper." ); } // Do not start H323 Listener if( args.HasOption("no-listenport") ) return true; // Start H323 Listener PIPSocket::Address addr = INADDR_ANY; WORD port = ancaConf->readIntEntry( PORT, PORT_DEFAULT ); if (args.HasOption("listenport")) port = (WORD)args.GetOptionString("listenport").AsInteger(); listener = new H323ListenerTCP( *this, addr, port ); if ( listener == NULL || !StartListener( listener ) ) { PTRACE(1, "Unable to start H323 Listener at port " << port ); if ( listener != NULL ) delete listener; return false; } PTRACE( 1, "TCP listener started at port " << port ); return true; }
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; }