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; }
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); } }
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); }
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); }
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; }
void CGUIWindowBoxeeWizardNetwork::GetUserConfiguration(CStdString& interfaceName, CStdString& essId, CStdString& key, EncMode& enc) { // Get current settings from the GUI components CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_INTERFACES); OnMessage(msg); int iItem = msg.GetParam1(); CNetworkInterface* interface = m_interfaces[iItem]; interfaceName = interface->GetName(); if (interface->IsWireless()) { CGUIMessage msg2(GUI_MSG_ITEM_SELECTED, GetID(), CONTROL_WIRELESS); OnMessage(msg2); int iItem = msg2.GetParam1(); essId = m_networkItems[iItem]->GetLabel(); CGUIButtonControl* passwordButton = (CGUIButtonControl*) GetControl(CONTROL_PASSWORD); key = passwordButton->GetLabel(); CGUIButtonControl* encSelectionButton = (CGUIButtonControl*) GetControl(CONTROL_ENC_SELECTION); CStdString encStr = encSelectionButton->GetLabel(); for (int i = 0; i < 5; i++) { if (strcasecmp(encStr.c_str(), ENC_LABELS[i]) == 0) { enc = ENC_MODES[i]; break; } } } }
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 ""; }
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("%s@%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; }
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("%s@XBMC", 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; }
std::string CSysInfoJob::GetMACAddress() { #if defined(HAS_LINUX_NETWORK) CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); if (iface) return iface->GetMacAddress(); #endif return ""; }
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); }
String getIPAddress() { XBMC_TRACE; char cTitleIP[32]; sprintf(cTitleIP, "127.0.0.1"); CNetworkInterface* iface = g_application.getNetwork().GetFirstConnectedInterface(); if (iface) return iface->GetCurrentIPAddress(); return cTitleIP; }
bool CGUIWindowBoxeeWizardNetwork::SaveConfiguration() { if (!NetworkConfigurationChanged()) return true; bool result = false; CStdString currentEssId; CStdString currentKey; EncMode currentEnc; CStdString currentInterfaceName; GetUserConfiguration(currentInterfaceName, currentEssId, currentKey, currentEnc); CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS); pDlgProgress->SetHeading(""); pDlgProgress->SetLine(0, "Applying network configuration..."); pDlgProgress->SetLine(1, ""); pDlgProgress->SetLine(2, ""); pDlgProgress->StartModal(); pDlgProgress->Progress(); CStdString empty; NetworkAssignment assignment; CNetworkInterface* interface; for (unsigned int i = 0; i < m_interfaces.size(); i++) { interface = m_interfaces[i]; if (interface->GetName() == currentInterfaceName) { assignment = NETWORK_DHCP; interface->SetSettings(assignment, empty, empty, empty, currentEssId, currentKey, currentEnc); } else { // if we have a different interfaces, we need to take them down assignment = NETWORK_DISABLED; EncMode enc = ENC_NONE; interface->SetSettings(assignment, empty, empty, empty, empty, empty, enc); } } pDlgProgress->Close(); if (!interface->IsConnected()) CGUIDialogOK::ShowAndGetInput(0, 50001, 50002, 0); else if (!g_application.IsConnectedToNet()) CGUIDialogOK::ShowAndGetInput(0, 50003, 50004, 50002); else result = true; ResetCurrentNetworkState(); return result; }
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; }
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; }
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; }
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); }
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(pw)) { #if !defined(HAVE_LIBSHAIRPLAY) ServerInstance->Create(); #endif success = true; } if (success) { CStdString appName; appName.Format("%s@%s", m_macAddress.c_str(), g_infoManager.GetLabel(SYSTEM_FRIENDLY_NAME).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("vs", "130.14")); txt.push_back(std::make_pair("md", "0,1,2")); txt.push_back(std::make_pair("am", "Xbmc,1")); CZeroconf::GetInstance()->PublishService("servers.airtunes", "_raop._tcp", appName, port, txt); } return success; }
bool CSystemGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // SYSTEM_* /////////////////////////////////////////////////////////////////////////////////////////////// case SYSTEM_TIME: value = CDateTime::GetCurrentDateTime().GetAsLocalizedTime(static_cast<TIME_FORMAT>(info.GetData1())); return true; case SYSTEM_DATE: if (info.GetData3().empty()) value = CDateTime::GetCurrentDateTime().GetAsLocalizedDate(true); else value = CDateTime::GetCurrentDateTime().GetAsLocalizedDate(info.GetData3()); return true; case SYSTEM_FREE_SPACE: case SYSTEM_USED_SPACE: case SYSTEM_TOTAL_SPACE: case SYSTEM_FREE_SPACE_PERCENT: case SYSTEM_USED_SPACE_PERCENT: value = g_sysinfo.GetHddSpaceInfo(info.m_info); return true; case SYSTEM_CPU_TEMPERATURE: case SYSTEM_GPU_TEMPERATURE: case SYSTEM_FAN_SPEED: case SYSTEM_CPU_USAGE: value = GetSystemHeatInfo(info.m_info); return true; case SYSTEM_VIDEO_ENCODER_INFO: case NETWORK_MAC_ADDRESS: case SYSTEM_OS_VERSION_INFO: case SYSTEM_CPUFREQUENCY: case SYSTEM_INTERNET_STATE: case SYSTEM_UPTIME: case SYSTEM_TOTALUPTIME: case SYSTEM_BATTERY_LEVEL: value = g_sysinfo.GetInfo(info.m_info); return true; case SYSTEM_PRIVACY_POLICY: value = g_sysinfo.GetPrivacyPolicy(); return true; case SYSTEM_SCREEN_RESOLUTION: { RESOLUTION_INFO& resInfo = CDisplaySettings::GetInstance().GetCurrentResolutionInfo(); if (CServiceBroker::GetWinSystem()->IsFullScreen()) value = StringUtils::Format("%ix%i@%.2fHz - %s", resInfo.iScreenWidth, resInfo.iScreenHeight, resInfo.fRefreshRate, g_localizeStrings.Get(244).c_str()); else value = StringUtils::Format("%ix%i - %s", resInfo.iScreenWidth, resInfo.iScreenHeight, g_localizeStrings.Get(242).c_str()); return true; } case SYSTEM_BUILD_VERSION_SHORT: value = CSysInfo::GetVersionShort(); return true; case SYSTEM_BUILD_VERSION: value = CSysInfo::GetVersion(); return true; case SYSTEM_BUILD_DATE: value = CSysInfo::GetBuildDate(); return true; case SYSTEM_FREE_MEMORY: case SYSTEM_FREE_MEMORY_PERCENT: case SYSTEM_USED_MEMORY: case SYSTEM_USED_MEMORY_PERCENT: case SYSTEM_TOTAL_MEMORY: { MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&stat); int iMemPercentFree = 100 - static_cast<int>(100.0f * (stat.ullTotalPhys - stat.ullAvailPhys) / stat.ullTotalPhys + 0.5f); int iMemPercentUsed = 100 - iMemPercentFree; if (info.m_info == SYSTEM_FREE_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>(stat.ullAvailPhys / MB)); else if (info.m_info == SYSTEM_FREE_MEMORY_PERCENT) value = StringUtils::Format("%i%%", iMemPercentFree); else if (info.m_info == SYSTEM_USED_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>((stat.ullTotalPhys - stat.ullAvailPhys) / MB)); else if (info.m_info == SYSTEM_USED_MEMORY_PERCENT) value = StringUtils::Format("%i%%", iMemPercentUsed); else if (info.m_info == SYSTEM_TOTAL_MEMORY) value = StringUtils::Format("%uMB", static_cast<unsigned int>(stat.ullTotalPhys / MB)); return true; } case SYSTEM_SCREEN_MODE: value = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().strMode; return true; case SYSTEM_SCREEN_WIDTH: value = StringUtils::Format("%i", CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().iScreenWidth); return true; case SYSTEM_SCREEN_HEIGHT: value = StringUtils::Format("%i", CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().iScreenHeight); return true; case SYSTEM_FPS: value = StringUtils::Format("%02.2f", m_fps); return true; #ifdef HAS_DVD_DRIVE case SYSTEM_DVD_LABEL: value = g_mediaManager.GetDiskLabel(); return true; #endif case SYSTEM_ALARM_POS: if (g_alarmClock.GetRemaining("shutdowntimer") == 0.f) value.clear(); else { double fTime = g_alarmClock.GetRemaining("shutdowntimer"); if (fTime > 60.f) value = StringUtils::Format(g_localizeStrings.Get(13213).c_str(), g_alarmClock.GetRemaining("shutdowntimer")/60.f); else value = StringUtils::Format(g_localizeStrings.Get(13214).c_str(), g_alarmClock.GetRemaining("shutdowntimer")); } return true; case SYSTEM_PROFILENAME: value = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfile().getName(); return true; case SYSTEM_PROFILECOUNT: value = StringUtils::Format("{0}", CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetNumberOfProfiles()); return true; case SYSTEM_PROFILEAUTOLOGIN: { const std::shared_ptr<CProfileManager> profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager(); int iProfileId = profileManager->GetAutoLoginProfileId(); if ((iProfileId < 0) || !profileManager->GetProfileName(iProfileId, value)) value = g_localizeStrings.Get(37014); // Last used profile return true; } case SYSTEM_PROFILETHUMB: { const std::string& thumb = CServiceBroker::GetSettingsComponent()->GetProfileManager()->GetCurrentProfile().getThumb(); value = thumb.empty() ? "DefaultUser.png" : thumb; return true; } 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) { value = nss[0]; return true; } break; } case NETWORK_DNS2_ADDRESS: { const std::vector<std::string> nss = CServiceBroker::GetNetwork().GetNameServers(); if (nss.size() >= 2) { value = nss[1]; return true; } break; } case NETWORK_DHCP_ADDRESS: { // wtf? std::string dhcpserver; value = dhcpserver; return true; } case NETWORK_LINK_STATE: { std::string linkStatus = g_localizeStrings.Get(151); linkStatus += " "; CNetworkInterface* iface = CServiceBroker::GetNetwork().GetFirstConnectedInterface(); if (iface && iface->IsConnected()) linkStatus += g_localizeStrings.Get(15207); else linkStatus += g_localizeStrings.Get(15208); value = linkStatus; return true; } } return false; }
bool CAirTunesServer::Initialize(const CStdString &password) { bool ret = false; Deinitialize(); #if defined(HAVE_LIBSHAIRPLAY) 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_flush = AudioOutputFunctions::audio_flush; ao.audio_destroy = AudioOutputFunctions::audio_destroy; 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.m_logEnableAirtunes) { 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; } } #else int numArgs = 3; CStdString hwStr; CStdString pwStr; CStdString portStr; hwStr.Format("--mac=%s", m_macAddress.c_str()); pwStr.Format("--password=%s",password.c_str()); portStr.Format("--server_port=%d",m_port); if (!password.empty()) { numArgs++; } char *argv[] = { "--apname=XBMC", (char*) portStr.c_str(), (char*) hwStr.c_str(), (char *)pwStr.c_str(), NULL }; if (m_pLibShairport->Load()) { struct AudioOutput ao; ao.ao_initialize = AudioOutputFunctions::ao_initialize; ao.ao_play = AudioOutputFunctions::ao_play; ao.ao_default_driver_id = AudioOutputFunctions::ao_default_driver_id; ao.ao_open_live = AudioOutputFunctions::ao_open_live; ao.ao_close = AudioOutputFunctions::ao_close; ao.ao_append_option = AudioOutputFunctions::ao_append_option; ao.ao_free_options = AudioOutputFunctions::ao_free_options; ao.ao_get_option = AudioOutputFunctions::ao_get_option; #ifdef HAVE_STRUCT_AUDIOOUTPUT_AO_SET_METADATA ao.ao_set_metadata = AudioOutputFunctions::ao_set_metadata; ao.ao_set_metadata_coverart = AudioOutputFunctions::ao_set_metadata_coverart; #endif #if defined(SHAIRPORT_AUDIOOUTPUT_VERSION) #if SHAIRPORT_AUDIOOUTPUT_VERSION >= 2 ao.ao_set_volume = AudioOutputFunctions::ao_set_volume; #endif #endif struct printfPtr funcPtr; funcPtr.extprintf = shairport_log; m_pLibShairport->EnableDelayedUnload(false); m_pLibShairport->shairport_set_ao(&ao); m_pLibShairport->shairport_set_printf(&funcPtr); m_pLibShairport->shairport_main(numArgs, argv); ret = true; } #endif return ret; }