本文整理汇总了C++中CNetworkInterface类的典型用法代码示例。如果您正苦于以下问题:C++ CNetworkInterface类的具体用法?C++ CNetworkInterface怎么用?C++ CNetworkInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CNetworkInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StartAirPlayServer
bool CNetworkServices::StartAirPlayServer()
{
#ifdef HAS_AIRPLAY
if (!g_application.getNetwork().IsAvailable() || !CSettings::Get().GetBool("services.airplay"))
return false;
if (IsAirPlayServerRunning())
return true;
if (!CAirPlayServer::StartServer(g_advancedSettings.m_airPlayPort, true))
return false;
if (!CAirPlayServer::SetCredentials(CSettings::Get().GetBool("services.useairplaypassword"),
CSettings::Get().GetString("services.airplaypassword")))
return false;
#ifdef HAS_ZEROCONF
std::vector<std::pair<std::string, std::string> > txt;
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
txt.push_back(make_pair("deviceid", iface != NULL ? iface->GetMacAddress() : "FF:FF:FF:FF:FF:F2"));
txt.push_back(make_pair("features", "0x77"));
txt.push_back(make_pair("model", "Xbmc,1"));
txt.push_back(make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR));
CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME), g_advancedSettings.m_airPlayPort, txt);
#endif // HAS_ZEROCONF
return true;
#endif // HAS_AIRPLAY
return false;
}
示例2: msg
void CGUIWindowBoxeeWizardNetwork::ShowWirelessNetworksIfNeeded()
{
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_INTERFACES );
OnMessage(msg);
int iItem = msg.GetParam1();
CNetworkInterface* interface = m_interfaces[iItem];
if (interface->IsWireless())
{
SET_CONTROL_VISIBLE(CONTROL_WIRELESS);
SET_CONTROL_VISIBLE(CONTROL_SEP1);
ShowWirelessNetworks(interface);
SET_CONTROL_FOCUS(CONTROL_WIRELESS, 0);
CONTROL_DISABLE(CONTROL_NEXT);
}
else
{
SET_CONTROL_HIDDEN(CONTROL_SEP1);
SET_CONTROL_HIDDEN(CONTROL_WIRELESS);
SET_CONTROL_HIDDEN(CONTROL_SEP2);
SET_CONTROL_HIDDEN(CONTROL_PASSWORD_GROUP);
SET_CONTROL_HIDDEN(CONTROL_ENC_GROUP);
CONTROL_ENABLE(CONTROL_NEXT);
SET_CONTROL_FOCUS(CONTROL_NEXT, 0);
}
}
示例3: msgReset
void CGUIDialogAccessPoints::OnInitWindow()
{
m_wasItemSelected = false;
CGUIDialog::OnInitWindow();
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ACCESS_POINTS);
OnMessage(msgReset);
CStdString ifaceName(m_interfaceName);
CNetworkInterface* iface = g_application.getNetwork().GetInterfaceByName(ifaceName);
m_aps = iface->GetAccessPoints();
for (int i = 0; i < (int) m_aps.size(); i++)
{
CFileItem *item = new CFileItem(m_aps[i].getEssId());
int q = m_aps[i].getQuality();
if (q <= 20) item->SetThumbnailImage("ap-signal1.png");
else if (q <= 40) item->SetThumbnailImage("ap-signal2.png");
else if (q <= 60) item->SetThumbnailImage("ap-signal3.png");
else if (q <= 80) item->SetThumbnailImage("ap-signal4.png");
else if (q <= 100) item->SetThumbnailImage("ap-signal5.png");
if (m_aps[i].getEncryptionMode() != ENC_NONE)
item->SetIconImage("ap-lock.png");
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ACCESS_POINTS, 0, 0, item);
OnMessage(msg);
}
CFileItem *item = new CFileItem(g_localizeStrings.Get(1047));
CGUIMessage msg(GUI_MSG_LABEL_ADD, GetID(), CONTROL_ACCESS_POINTS, 0, 0, item);
OnMessage(msg);
}
示例4: Process
void CAirPlayServer::Process()
{
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
apw = APW_Method_Create(
MicroStackChain, ILib_Pool, m_port, "LeoChenPlayer", iface ? iface->GetMacAddress().c_str() : "FF:FF:FF:FF:FF:F2", m_usePassword ? m_password.c_str():"");
if (apw == NULL) { // ´´½¨Ê§°Ü
ILibThreadPool_Destroy(ILib_Pool);
return;
}
apw->Event_SetAVTransportURI = APW_Callback_SetAVTransportURI;
apw->Event_GetAVProtocolInfo = APW_Callback_GetAVProtocolInfo;
apw->Event_SetPlayMode = APW_Callback_SetPlayMode;
apw->Event_Stop = APW_Callback_Stop;
apw->Event_Play = APW_Callback_Play;
apw->Event_Pause = APW_Callback_Pause;
apw->Event_SeekTrack = APW_Callback_SeekTrack;
apw->Event_SeekTrackPosition = APW_Callback_SeekTrackPosition;
apw->Event_SeekMediaPosition = APW_Callback_SeekMediaPosition;
apw->Event_Next = APW_Callback_Next;
apw->Event_Previous = APW_Callback_Previous;
apw->Event_SelectPreset = APW_Callback_SelectPreset;
apw->Event_SetVolume = APW_Callback_SetVolume;
apw->Event_SetMute = APW_Callback_SetMute;
apw->Event_SetContrast = APW_Callback_SetContrast;
apw->Event_SetBrightness = APW_Callback_SetBrightness;
ILibStartChain(MicroStackChain);
}
示例5: GetUserConfiguration
bool CGUIWindowBoxeeWizardNetwork::NetworkConfigurationChanged()
{
if (!m_foundCurrnetNetwork)
return true;
CStdString currentEssId;
CStdString currentKey;
EncMode currentEnc;
CStdString currentInterfaceName;
GetUserConfiguration(currentInterfaceName, currentEssId, currentKey, currentEnc);
CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_INTERFACES);
OnMessage(msg);
int iItem = msg.GetParam1();
CNetworkInterface* interface = m_interfaces[iItem];
// Do the actual comparison
if (m_interfaceName != currentInterfaceName)
return true;
bool result = false;
if (interface->IsWireless())
{
result = (currentEssId != m_essId || currentEnc != m_encryptionMode);
if (currentEnc != ENC_NONE)
result = result || (currentKey != m_key);
}
return result;
}
示例6: defined
std::string CSysInfoJob::GetMACAddress()
{
#if defined(HAS_LINUX_NETWORK) || defined(HAS_WIN32_NETWORK) || defined(HAS_WIN10_NETWORK)
CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface();
if (iface)
return iface->GetMacAddress();
#endif
return "";
}
示例7: StartServer
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const std::string &password/*=""*/)
{
bool success = false;
std::string pw = password;
CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface();
StopServer(true);
if (net)
{
m_macAddress = net->GetMacAddress();
StringUtils::Replace(m_macAddress, ":","");
while (m_macAddress.size() < 12)
{
m_macAddress = '0' + m_macAddress;
}
}
else
{
m_macAddress = "000102030405";
}
if (!usePassword)
{
pw.clear();
}
ServerInstance = new CAirTunesServer(port, nonlocal);
if (ServerInstance->Initialize(pw))
{
success = true;
std::string appName = StringUtils::Format("%[email protected]%s",
m_macAddress.c_str(),
CSysInfo::GetDeviceName().c_str());
std::vector<std::pair<std::string, std::string> > txt;
txt.push_back(std::make_pair("txtvers", "1"));
txt.push_back(std::make_pair("cn", "0,1"));
txt.push_back(std::make_pair("ch", "2"));
txt.push_back(std::make_pair("ek", "1"));
txt.push_back(std::make_pair("et", "0,1"));
txt.push_back(std::make_pair("sv", "false"));
txt.push_back(std::make_pair("tp", "UDP"));
txt.push_back(std::make_pair("sm", "false"));
txt.push_back(std::make_pair("ss", "16"));
txt.push_back(std::make_pair("sr", "44100"));
txt.push_back(std::make_pair("pw", usePassword?"true":"false"));
txt.push_back(std::make_pair("vn", "3"));
txt.push_back(std::make_pair("da", "true"));
txt.push_back(std::make_pair("md", "0,1,2"));
txt.push_back(std::make_pair("am", "Kodi,1"));
txt.push_back(std::make_pair("vs", "130.14"));
CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt);
}
return success;
}
示例8: StartServer
bool CAirTunesServer::StartServer(int port, bool nonlocal, bool usePassword, const CStdString &password/*=""*/)
{
bool success = false;
CStdString pw = password;
CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface();
StopServer(true);
if (net)
{
m_macAddress = net->GetMacAddress();
m_macAddress.Replace(":","");
while (m_macAddress.size() < 12)
{
m_macAddress = CStdString("0") + m_macAddress;
}
}
else
{
m_macAddress = "000102030405";
}
if (!usePassword)
{
pw.Empty();
}
ServerInstance = new CAirTunesServer(port, nonlocal);
if (ServerInstance->Initialize(password))
{
ServerInstance->Create();
success = true;
}
if (success)
{
CStdString appName;
appName.Format("%[email protected]", m_macAddress.c_str());
std::map<std::string, std::string> txt;
txt["cn"] = "0,1";
txt["ch"] = "2";
txt["ek"] = "1";
txt["et"] = "0,1";
txt["sv"] = "false";
txt["tp"] = "UDP";
txt["sm"] = "false";
txt["ss"] = "16";
txt["sr"] = "44100";
txt["pw"] = "false";
txt["vn"] = "3";
txt["txtvers"] = "1";
CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt);
}
return success;
}
示例9: defined
std::string CSysInfoJob::GetMACAddress()
{
#if defined(HAS_LINUX_NETWORK)
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface)
return iface->GetMacAddress();
#endif
return "";
}
示例10: XBMC_GetIPAddress
PyObject* XBMC_GetIPAddress(PyObject *self, PyObject *args)
{
char cTitleIP[32];
sprintf(cTitleIP, "127.0.0.1");
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
if (iface)
return PyString_FromString(iface->GetCurrentIPAddress().c_str());
return PyString_FromString(cTitleIP);
}
示例11: Deinitialize
bool CAirTunesServer::Initialize(const std::string &password)
{
bool ret = false;
Deinitialize();
if (m_pLibShairplay->Load())
{
raop_callbacks_t ao = {};
ao.cls = m_pPipe;
ao.audio_init = AudioOutputFunctions::audio_init;
ao.audio_set_volume = AudioOutputFunctions::audio_set_volume;
ao.audio_set_metadata = AudioOutputFunctions::audio_set_metadata;
ao.audio_set_coverart = AudioOutputFunctions::audio_set_coverart;
ao.audio_process = AudioOutputFunctions::audio_process;
ao.audio_destroy = AudioOutputFunctions::audio_destroy;
ao.audio_remote_control_id = AudioOutputFunctions::audio_remote_control_id;
ao.audio_set_progress = AudioOutputFunctions::audio_set_progress;
m_pLibShairplay->EnableDelayedUnload(false);
m_pRaop = m_pLibShairplay->raop_init(1, &ao, RSA_KEY);//1 - we handle one client at a time max
ret = m_pRaop != NULL;
if(ret)
{
char macAdr[6];
unsigned short port = (unsigned short)m_port;
m_pLibShairplay->raop_set_log_level(m_pRaop, RAOP_LOG_WARNING);
if(g_advancedSettings.CanLogComponent(LOGAIRTUNES))
{
m_pLibShairplay->raop_set_log_level(m_pRaop, RAOP_LOG_DEBUG);
}
m_pLibShairplay->raop_set_log_callback(m_pRaop, shairplay_log, NULL);
CNetworkInterface *net = g_application.getNetwork().GetFirstConnectedInterface();
if (net)
{
net->GetMacAddressRaw(macAdr);
}
ret = m_pLibShairplay->raop_start(m_pRaop, &port, macAdr, 6, password.c_str()) >= 0;
}
}
return ret;
}
示例12: IsInSubNet
static bool IsInSubNet(CURL url)
{
bool rtn = false;
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
in_addr_t localMask = ntohl(inet_addr(iface->GetCurrentNetmask().c_str()));
in_addr_t testAddress = ntohl(inet_addr(url.GetHostName().c_str()));
in_addr_t localAddress = ntohl(inet_addr(iface->GetCurrentIPAddress().c_str()));
in_addr_t temp1 = testAddress & localMask;
in_addr_t temp2 = localAddress & localMask;
if (temp1 == temp2)
{
// we are on the same subnet
// now make sure it is a plex server
rtn = CPlexUtils::GetIdentity(url, 1);
}
return rtn;
}
示例13: StartAirPlayServer
bool CNetworkServices::StartAirPlayServer()
{
#ifdef HAS_AIRPLAY
if (!g_application.getNetwork().IsAvailable() || !CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_AIRPLAY))
return false;
if (IsAirPlayServerRunning())
return true;
if (!CAirPlayServer::StartServer(g_advancedSettings.m_airPlayPort, true))
return false;
if (!CAirPlayServer::SetCredentials(CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_USEAIRPLAYPASSWORD),
CSettings::GetInstance().GetString(CSettings::SETTING_SERVICES_AIRPLAYPASSWORD)))
return false;
#ifdef HAS_ZEROCONF
std::vector<std::pair<std::string, std::string> > txt;
CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface();
txt.push_back(make_pair("deviceid", iface != NULL ? iface->GetMacAddress() : "FF:FF:FF:FF:FF:F2"));
txt.push_back(make_pair("model", "Xbmc,1"));
txt.push_back(make_pair("srcvers", AIRPLAY_SERVER_VERSION_STR));
if (CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_AIRPLAYIOS8COMPAT))
{
// for ios8 clients we need to announce mirroring support
// else we won't get video urls anymore.
// We also announce photo caching support (as it seems faster and
// we have implemented it anyways).
txt.push_back(make_pair("features", "0x20F7"));
}
else
{
txt.push_back(make_pair("features", "0x77"));
}
CZeroconf::GetInstance()->PublishService("servers.airplay", "_airplay._tcp", CSysInfo::GetDeviceName(), g_advancedSettings.m_airPlayPort, txt);
#endif // HAS_ZEROCONF
return true;
#endif // HAS_AIRPLAY
return false;
}
示例14: msgReset
void CGUIDialogAccessPoints::OnInitWindow()
{
m_wasItemSelected = false;
CGUIDialog::OnInitWindow();
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_ACCESS_POINTS);
OnMessage(msgReset);
m_accessPoints->Clear();
std::string ifaceName(m_interfaceName);
CNetworkInterface* iface = CServiceBroker::GetNetwork().GetInterfaceByName(ifaceName);
m_aps = iface->GetAccessPoints();
for (int i = 0; i < (int) m_aps.size(); i++)
{
CFileItemPtr item(new CFileItem(m_aps[i].getEssId()));
int q = m_aps[i].getQuality();
if (q <= 20) item->SetArt("thumb", "ap-signal1.png");
else if (q <= 40) item->SetArt("thumb", "ap-signal2.png");
else if (q <= 60) item->SetArt("thumb", "ap-signal3.png");
else if (q <= 80) item->SetArt("thumb", "ap-signal4.png");
else if (q <= 100) item->SetArt("thumb", "ap-signal5.png");
if (m_aps[i].getEncryptionMode() != ENC_NONE)
item->SetIconImage("ap-lock.png");
m_accessPoints->Add(item);
}
CFileItemPtr item(new CFileItem(g_localizeStrings.Get(1047)));
m_accessPoints->Add(item);
CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_ACCESS_POINTS, 0, 0, m_accessPoints);
OnMessage(msg);
}
示例15: switch
//.........这里部分代码省略.........
case SYSTEM_LANGUAGE:
value = g_langInfo.GetEnglishLanguageName();
return true;
case SYSTEM_TEMPERATURE_UNITS:
value = g_langInfo.GetTemperatureUnitString();
return true;
case SYSTEM_FRIENDLY_NAME:
value = CSysInfo::GetDeviceName();
return true;
case SYSTEM_STEREOSCOPIC_MODE:
{
int iStereoMode = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_VIDEOSCREEN_STEREOSCOPICMODE);
value = StringUtils::Format("%i", iStereoMode);
return true;
}
case SYSTEM_GET_CORE_USAGE:
value = StringUtils::Format("%4.2f", g_cpuInfo.GetCoreInfo(std::atoi(info.GetData3().c_str())).m_fPct);
return true;
case SYSTEM_RENDER_VENDOR:
value = CServiceBroker::GetRenderSystem()->GetRenderVendor();
return true;
case SYSTEM_RENDER_RENDERER:
value = CServiceBroker::GetRenderSystem()->GetRenderRenderer();
return true;
case SYSTEM_RENDER_VERSION:
value = CServiceBroker::GetRenderSystem()->GetRenderVersionString();
return true;
///////////////////////////////////////////////////////////////////////////////////////////////
// NETWORK_*
///////////////////////////////////////////////////////////////////////////////////////////////
case NETWORK_IP_ADDRESS:
{
CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface();
if (iface)
{
value = iface->GetCurrentIPAddress();
return true;
}
break;
}
case NETWORK_SUBNET_MASK:
{
CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface();
if (iface)
{
value = iface->GetCurrentNetmask();
return true;
}
break;
}
case NETWORK_GATEWAY_ADDRESS:
{
CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface();
if (iface)
{
value = iface->GetCurrentDefaultGateway();
return true;
}
break;
}
case NETWORK_DNS1_ADDRESS:
{
const std::vector<std::string> nss = CServiceBroker::GetNetwork().GetNameServers();
if (nss.size() >= 1)
{