void NetworkClient::GetGroups() { rMessage->Reset(); peer->RPC("ServerPeer::GetGroups", NULL , NULL, HIGH_PRIORITY, RELIABLE, 0, UNASSIGNED_SYSTEM_ADDRESS, true, 0, UNASSIGNED_NETWORK_ID,rMessage); if( (rMessage->GetNumberOfUnreadBits()) > 0) { int count, groupId, len = 0; char* groupName = ""; GroupMap g; g.clear(); rMessage->Read(count); for(int j = 0;j<count;j++) { rMessage->Read(groupId); rMessage->Read(len); groupName = new char[len+1]; groupName[len] = 0; rMessage->Read(groupName, len); g.insert(GroupMap::value_type(groupId, groupName)); } if(!g.empty()) { dataMan->setGroups(g); } } }
void ResultsTree::GroupSortProxyModel::setSourceModel(QAbstractItemModel* sourceModel) { QAbstractProxyModel::setSourceModel(sourceModel); groupItems.clear(); if (sourceModel) { // Create group items typedef std::map< QVariant, int, QVariantCompare > GroupMap; GroupMap groupMap; int numRows = sourceModel->rowCount(); for (int i = 0; i < numRows; ++i) { QModelIndex ind = sourceModel->index(i, groupByCol, QModelIndex()); QVariant v = sourceModel->data(ind, Qt::DisplayRole); GroupMap::iterator it = groupMap.find(v); if (it == groupMap.end()) { it = groupMap.insert(GroupMap::value_type(v, groupItems.size())).first; groupItems.push_back(GroupItem(v)); } groupItems[it->second].children.push_back(ind); } } }
static void CountSSMJoin(const address &group, const address &source) { address source_addr; char tmp[64], tmp2[64], tmp3[64]; source_addr.set_family(source.family()); source_addr.copy_address(source); source_addr.set_port(0); GroupMap::iterator g = groupMap.find(group); if (g == groupMap.end()) { if (verbose) info("Registering SSM group %s", group.to_string(tmp, sizeof(tmp))); g = groupMap.insert(std::make_pair(group, SourceMap())).first; } SourceMap::iterator s = g->second.find(source_addr); if (s == g->second.end()) { if (verbose) info("Joining (%s, %s)", source_addr.to_string(tmp, sizeof(tmp)), group.to_string(tmp2, sizeof(tmp2))); if (SSMJoin(ssmMcastSock, group, source_addr) < 0) { if (verbose) info("Join failed, reason: %s", strerror(errno)); return; } else { s = g->second.insert(std::make_pair(source_addr, SourceSet())).first; } } SourceSet::iterator ss = s->second.find(source); if (ss == s->second.end()) { if (verbose) info("Adding beacon %s to (%s, %s)", source.to_string(tmp, sizeof(tmp)), source_addr.to_string(tmp2, sizeof(tmp2)), group.to_string(tmp3, sizeof(tmp3))); s->second.insert(source); } }