void Broadcast(MyConnection* excluded, T MyConnection::*pFunction, Args... args) { ReadLocker locker; const auto& connections = GetConnections(locker); for (auto& connection : connections) { if (connection != excluded) { Logger.Debug("Broadcasting from ", (int)excluded->Id, " to ", (int)connection->Id); (connection->*pFunction)(args...); } } }
bool ezQtPin::AdjustRenderingForHighlight(ezQtPinHighlightState state) { const ezColorGammaUB pinColor = GetPin()->GetColor(); switch (state) { case ezQtPinHighlightState::None: { QPen p = pen(); p.setColor(qRgb(pinColor.r, pinColor.g, pinColor.b)); setPen(p); setBrush(GetConnections().IsEmpty() ? QApplication::palette().base() : pen().color().darker(125)); } break; case ezQtPinHighlightState::CannotConnect: case ezQtPinHighlightState::CannotConnectSameDirection: { QPen p = pen(); p.setColor(QApplication::palette().base().color().lighter()); setPen(p); setBrush(QApplication::palette().base()); } break; case ezQtPinHighlightState::CanReplaceConnection: case ezQtPinHighlightState::CanAddConnection: { QPen p = pen(); p.setColor(qRgb(pinColor.r, pinColor.g, pinColor.b)); setPen(p); setBrush(QApplication::palette().base()); } break; } return true; }
void __fastcall TForm1::RefreshList(void) { lbPlayers->Clear(); for (int i = 0; i < CommandManager->RemoteProfiles->Count; i++) { TTetheringProfileInfo LProfileInfo; LProfileInfo = CommandManager->RemoteProfiles->Items[i]; if (LProfileInfo.ProfileText == "FMXMediaPlayer") lbPlayers->Items->Add(LProfileInfo.ProfileText + GetConnections(LProfileInfo.AllowedConnections)); } if (lbPlayers->Count > 0) { // Connect to the first one or the last valid index used if ((lbPlayers->ItemIndex == -1) || (lbPlayers->ItemIndex >= lbPlayers->Count)) lbPlayers->ItemIndex = 0; CommandApp->Connect(CommandManager->RemoteProfiles->Items[lbPlayers->ItemIndex]); } else { lbPlayers->ItemIndex = -1; lbPlayers->Items->Add("No Players Found!!"); } ButtonFindPlayers->Enabled = true; }
bool CAndroidNetworkManager::ReceiveNetworkEvent(INetworkEventsCallback *callback, const NetworkEventDataPtr data) { // All actions are event-driven. Android broadcasts connection events in the // form of subscribed events from XBMCApp. See CXBMCApp::onReceive const CJNIIntent intent(*boost::static_pointer_cast<const CJNIIntent>(data)); std::string action = intent.getAction(); CLog::Log(LOGDEBUG, "NetworkManager: Received event: %s",action.c_str()); if (action == CJNIWifiManager::NETWORK_STATE_CHANGED_ACTION) { GetEthernetConnection(); GetWifiAccessPoints(); GetCurrentWifiConnection(); if(m_currentWifi.get() && m_currentWifi->GetState() == NETWORK_CONNECTION_STATE_CONNECTED) { // Call the callback before setting the event so that the connection list // Is updated before leaving the wifi dialog callback->OnConnectionListChange(GetConnections()); m_wifiConnectionEvent.Set(); } else callback->OnConnectionListChange(GetConnections()); } else if(action == CJNIConnectivityManager::CONNECTIVITY_ACTION) { const CJNINetworkInfo newNetworkInfo = intent.getParcelableExtra(CJNIWifiManager::EXTRA_NETWORK_INFO); if (newNetworkInfo) { int type = newNetworkInfo.getType(); std::string typeName = newNetworkInfo.getTypeName(); std::string stateName = newNetworkInfo.getState().name(); if (type == CJNIConnectivityManager::TYPE_ETHERNET) { // This one is simple, just pass the new status along to the connection GetEthernetConnection(); if (m_ethernetConnection.get()) { if(m_ethernetConnection->GetState() == NETWORK_CONNECTION_STATE_CONNECTED) { callback->OnConnectionListChange(GetConnections()); m_ethernetConnectionEvent.Set(); } else callback->OnConnectionListChange(GetConnections()); } } else { GetWifiAccessPoints(); GetCurrentWifiConnection(); callback->OnConnectionListChange(GetConnections()); } } } else if (action == CJNIWifiManager::SCAN_RESULTS_AVAILABLE_ACTION) { GetWifiAccessPoints(); callback->OnConnectionListChange(GetConnections()); } else if (action == CJNIWifiManager::SUPPLICANT_STATE_CHANGED_ACTION) { int error = intent.getIntExtra(CJNIWifiManager::EXTRA_SUPPLICANT_ERROR, 0); if (error == 1) { CLog::Log(LOGDEBUG, "NetworkManager: authentication failed"); GetCurrentWifiConnection(); callback->OnConnectionListChange(GetConnections()); m_currentWifi->OnAuthFailed(); m_wifiConnectionEvent.Set(); } } else if (action == CJNIWifiManager::RSSI_CHANGED_ACTION) { if (!m_currentWifi.get()) GetCurrentWifiConnection(); if (m_currentWifi.get()) { int newRSSI = intent.getIntExtra(CJNIWifiManager::EXTRA_NEW_RSSI, 0); m_currentWifi->SetStrength(newRSSI); callback->OnConnectionChange(m_currentWifi); } } return true; }
void ClassManager::CalculateClasses(const std::vector<Class>& classes) { std::set<string> ids; for (const auto& item: classes) { ids.insert(item.name); } std::vector<string> utilityClasses; for (const auto& item: classes) { ClassEntry newEntry; newEntry.name = GetLastId(item.name); newEntry.data = item; string prefix = GetWithoutLastId(item.name); // newEntry.parentId if (ids.find(prefix) != ids.end()) { newEntry.parentId = prefix; // all member classes are treated as utility classes newEntry.utility = true; } /*// all templated classes are treated as utility classes if (item.templated) { newEntry.utility = true; }*/ // newEntry.namespaceId while (!prefix.empty()) { if (ids.find(prefix) == ids.end() && m_namespaces.find(prefix) != m_namespaces.end()) { newEntry.namespaceId = prefix; break; } prefix = GetWithoutLastId(prefix); } //newEntry.connections for (const auto& parent: item.inheritance) { for (auto& connection: GetConnections(parent.classId, newEntry.namespaceId, ids, parent.protLevel, parent.Virtual)) { newEntry.connections.push_back(connection); // all directly inherited classes are treated as utility classes if (connection.type == DIRECT_INHERITANCE) { utilityClasses.push_back(connection.targetId); } } } for (const auto& member: item.members) { for (auto& connection: GetConnections(member.type, newEntry.namespaceId, ids, member.protectionLevel)) { // all classes directly (not as template parameter) as members are treated as utility classes if (connection.type == DIRECT_INHERITANCE && member.type != newEntry.parentId) { utilityClasses.push_back(member.type); } connection.type = MEMBER_ITEM; connection.connectionCode += _T(" "); connection.connectionCode += member.name; connection.connectedMember = member.name; newEntry.connections.push_back(connection); } } m_classes.insert(std::map<string, ClassEntry>::value_type(item.name, std::move(newEntry))); } for (const auto& id: utilityClasses) { if (m_classes.find(id) != m_classes.end()) { m_classes[id].utility = true; } } for (auto& c: m_classes) { std::vector<ClassConnection> newConnections; for (auto& connection: c.second.connections) { if (connection.type == DIRECT_INHERITANCE) { string parentId; { string tmpCurClass = connection.targetId; do { const auto it = m_classes.find(tmpCurClass); if (it != m_classes.end()) { if (tmpCurClass != connection.targetId) { parentId = tmpCurClass; } tmpCurClass = it->second.parentId; } } while(!tmpCurClass.empty()); } if (!parentId.empty() && !m_classes[parentId].utility && !m_classes[parentId].data.interface) { ClassConnection indirectConnection = connection; indirectConnection.type = INDIRECT_INHERITANCE; indirectConnection.targetId = parentId; newConnections.push_back(std::move(indirectConnection)); } } } c.second.connections.insert(c.second.connections.end(), newConnections.begin(), newConnections.end()); } }