Commit c1660179 authored by Tristan Matthews's avatar Tristan Matthews

* #28351: daemon: rename iter to item for range-based for loops

"item" correctly reflects that in these loops, the object in question
is not an iterator but a reference to the actual object in the
collection.
parent 04080fc7
......@@ -236,8 +236,8 @@ void Account::setActiveAudioCodecs(const vector<string> &list)
// list contains the ordered payload of active codecs picked by the user for this account
// we used the codec vector to save the order.
for (const auto &iter : list) {
int payload = std::atoi(iter.c_str());
for (const auto &item : list) {
int payload = std::atoi(item.c_str());
audioCodecList_.push_back(payload);
}
......
......@@ -47,8 +47,8 @@ MainBuffer::MainBuffer() : ringBufferMap_(), callIDMap_(), mutex_(), internalSam
MainBuffer::~MainBuffer()
{
// delete any ring buffers that didn't get removed
for (auto &iter : ringBufferMap_)
delete iter.second;
for (auto &item : ringBufferMap_)
delete item.second;
pthread_mutex_destroy(&mutex_);
}
......@@ -230,8 +230,8 @@ void MainBuffer::unBindAll(const std::string & call_id)
CallIDSet temp_set(*callid_set);
for (const auto &iter_set : temp_set)
unBindCallID(call_id, iter_set);
for (const auto &item_set : temp_set)
unBindCallID(call_id, item_set);
}
//void MainBuffer::putData(void *buffer, size_t toCopy, const std::string &call_id)
......@@ -270,8 +270,8 @@ size_t MainBuffer::getData(AudioBuffer& buffer, const std::string &call_id)
size_t size = 0;
AudioBuffer mixBuffer(buffer);
for (const auto &iter_id : *callid_set) {
size = getDataByID(mixBuffer, iter_id, call_id);
for (const auto &item_id : *callid_set) {
size = getDataByID(mixBuffer, item_id, call_id);
if (size > 0) {
buffer.mix(mixBuffer);
......@@ -399,15 +399,15 @@ void MainBuffer::dumpInfo()
sfl::ScopedLock guard(mutex_);
// print each call and bound call ids
for (const auto &iter_call : callIDMap_) {
for (const auto &item_call : callIDMap_) {
std::string dbg_str(" Call: \t");
dbg_str.append(iter_call.first);
dbg_str.append(item_call.first);
dbg_str.append(" is bound to: \t");
CallIDSet *call_id_set = iter_call.second;
CallIDSet *call_id_set = item_call.second;
for (const auto &iter : *call_id_set) {
dbg_str.append(iter);
for (const auto &item : *call_id_set) {
dbg_str.append(item);
dbg_str.append(", ");
}
......@@ -415,20 +415,20 @@ void MainBuffer::dumpInfo()
}
// Print ringbuffers ids and readpointers
for (const auto &iter_buffer : ringBufferMap_) {
for (const auto &item_buffer : ringBufferMap_) {
std::string dbg_str(" Buffer: \t");
dbg_str.append(iter_buffer.first);
dbg_str.append(item_buffer.first);
dbg_str.append(" as read pointer: \t");
RingBuffer* rbuffer = iter_buffer.second;
RingBuffer* rbuffer = item_buffer.second;
if (rbuffer) {
ReadPointer* rpointer = rbuffer->getReadPointerList();
if (rpointer) {
for (const auto &iter : *rpointer) {
dbg_str.append(iter.first);
for (const auto &item : *rpointer) {
dbg_str.append(item.first);
dbg_str.append(", ");
}
}
......
......@@ -52,8 +52,8 @@ void NetworkManager::StateChanged(const uint32_t &state)
void NetworkManager::PropertiesChanged(const std::map<std::string, ::DBus::Variant> &argin0)
{
WARN("Properties changed: ");
for (const auto &iter : argin0)
WARN("%s", iter.first.c_str());
for (const auto &item : argin0)
WARN("%s", item.first.c_str());
Manager::instance().registerAccounts();
}
......
......@@ -66,9 +66,9 @@ void Conference::remove(const std::string &participant_id)
void Conference::bindParticipant(const std::string &participant_id)
{
for (const auto &iter : participants_)
if (participant_id != iter)
Manager::instance().getMainBuffer().bindCallID(participant_id, iter);
for (const auto &item : participants_)
if (participant_id != item)
Manager::instance().getMainBuffer().bindCallID(participant_id, item);
Manager::instance().getMainBuffer().bindCallID(participant_id, MainBuffer::DEFAULT_ID);
}
......@@ -107,15 +107,15 @@ bool Conference::toggleRecording()
// start recording
if (startRecording) {
for (const auto &iter : participants_)
mbuffer.bindHalfDuplexOut(process_id, iter);
for (const auto &item : participants_)
mbuffer.bindHalfDuplexOut(process_id, item);
mbuffer.bindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
Recordable::recorder_.start();
} else {
for (const auto &iter : participants_)
mbuffer.unBindHalfDuplexOut(process_id, iter);
for (const auto &item : participants_)
mbuffer.unBindHalfDuplexOut(process_id, item);
mbuffer.unBindHalfDuplexOut(process_id, MainBuffer::DEFAULT_ID);
}
......
......@@ -91,8 +91,8 @@ ConfigTree::getSections() const
{
std::list<std::string> sections;
for (const auto &iter : sections_)
sections.push_back(iter.first);
for (const auto &item : sections_)
sections.push_back(item.first);
return sections;
}
......
......@@ -380,8 +380,8 @@ void YamlParser::constructNativeData()
{
Sequence *seq = doc_.getSequence();
for (const auto &iter : *seq) {
YamlNode *yamlNode = static_cast<YamlNode *>(iter);
for (const auto &item : *seq) {
YamlNode *yamlNode = static_cast<YamlNode *>(item);
if (yamlNode == NULL) {
ERROR("Could not retrieve yaml node from document sequence");
continue;
......
......@@ -86,8 +86,8 @@ bool History::save()
std::ofstream outfile(path_.c_str());
if (outfile.fail())
return false;
for (const auto &iter : items_)
outfile << iter << std::endl;
for (const auto &item : items_)
outfile << item << std::endl;
return true;
}
......@@ -128,8 +128,8 @@ vector<map<string, string> > History::getSerialized()
{
sfl::ScopedLock lock(historyItemsMutex_);
vector<map<string, string> > result;
for (const auto &iter : items_)
result.push_back(iter.toMap());
for (const auto &item : items_)
result.push_back(item.toMap());
return result;
}
......
......@@ -103,12 +103,12 @@ bool HistoryItem::hasPeerNumber() const
void HistoryItem::print(std::ostream &o) const
{
// every entry starts with "[" + random integer = "]"
for (const auto &iter : entryMap_) {
for (const auto &item : entryMap_) {
// if the file does not exist anymore, we do not save it
if (iter.first == RECORDING_PATH_KEY and not file_exists(iter.second))
o << iter.first << "=" << "" << std::endl;
if (item.first == RECORDING_PATH_KEY and not file_exists(item.second))
o << item.first << "=" << "" << std::endl;
else
o << iter.first << "=" << iter.second << std::endl;
o << item.first << "=" << item.second << std::endl;
}
}
......
......@@ -105,8 +105,8 @@ IAXVoIPLink::terminate()
sfl::ScopedLock m(iaxCallMapMutex_);
for (auto &iter : iaxCallMap_) {
IAXCall *call = static_cast<IAXCall*>(iter.second);
for (auto &item : iaxCallMap_) {
IAXCall *call = static_cast<IAXCall*>(item.second);
if (call) {
sfl::ScopedLock lock(mutexIAX_);
......@@ -182,8 +182,8 @@ IAXVoIPLink::getCallIDs()
void
IAXVoIPLink::sendAudioFromMic()
{
for (const auto &iter : iaxCallMap_) {
IAXCall *currentCall = static_cast<IAXCall*>(iter.second);
for (const auto &item : iaxCallMap_) {
IAXCall *currentCall = static_cast<IAXCall*>(item.second);
if (!currentCall or currentCall->getState() != Call::ACTIVE)
continue;
......@@ -460,8 +460,8 @@ IAXVoIPLink::clearIaxCallMap()
{
sfl::ScopedLock m(iaxCallMapMutex_);
for (const auto &iter : iaxCallMap_)
delete iter.second;
for (const auto &item : iaxCallMap_)
delete item.second;
iaxCallMap_.clear();
......@@ -539,8 +539,8 @@ IAXVoIPLink::iaxFindCallBySession(iax_session* session)
{
sfl::ScopedLock m(iaxCallMapMutex_);
for (const auto &iter : iaxCallMap_) {
IAXCall* call = static_cast<IAXCall*>(iter.second);
for (const auto &item : iaxCallMap_) {
IAXCall* call = static_cast<IAXCall*>(item.second);
if (call and call->session == session)
return call;
......
......@@ -99,8 +99,8 @@ void InstantMessaging::sip_send(pjsip_inv_session *session, const std::string& i
void InstantMessaging::send_sip_message(pjsip_inv_session *session, const std::string &id, const std::string &message)
{
std::vector<std::string> msgs(split_message(message));
for (const auto &iter : msgs)
sip_send(session, id, iter);
for (const auto &item : msgs)
sip_send(session, id, item);
}
#if HAVE_IAX
......@@ -108,8 +108,8 @@ void InstantMessaging::send_iax_message(iax_session *session, const std::string
{
std::vector<std::string> msgs(split_message(message));
for (const auto &iter : msgs)
iax_send_text(session, iter.c_str());
for (const auto &item : msgs)
iax_send_text(session, item.c_str());
}
#endif
......@@ -135,8 +135,8 @@ std::string InstantMessaging::generateXmlUriList(UriList &list)
"<resource-lists xmlns=\"urn:ietf:params:xml:ns:resource-lists\" xmlns:cp=\"urn:ietf:params:xml:ns:copycontrol\">"
"<list>";
for (auto &iter : list)
xmlbuffer += "<entry uri=" + iter[sfl::IM_XML_URI] + " cp:copyControl=\"to\" />";
for (auto &item : list)
xmlbuffer += "<entry uri=" + item[sfl::IM_XML_URI] + " cp:copyControl=\"to\" />";
return xmlbuffer + "</list></resource-lists>";
}
......
......@@ -245,8 +245,8 @@ void ManagerImpl::finish()
std::vector<std::string> callList(getCallList());
DEBUG("Hangup %zu remaining call(s)", callList.size());
for (const auto &iter : callList)
hangupCall(iter);
for (const auto &item : callList)
hangupCall(item);
saveConfig();
......@@ -525,8 +525,8 @@ bool ManagerImpl::hangupConference(const std::string& id)
if (conf) {
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter : participants)
hangupCall(iter);
for (const auto &item : participants)
hangupCall(item);
} else {
ERROR("No such conference %s", id.c_str());
return false;
......@@ -817,9 +817,9 @@ ManagerImpl::holdConference(const std::string& id)
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter : participants) {
switchCall(iter);
onHoldCall(iter);
for (const auto &item : participants) {
switchCall(item);
onHoldCall(item);
}
conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD);
......@@ -845,14 +845,14 @@ ManagerImpl::unHoldConference(const std::string& id)
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter : participants) {
Call *call = getCallFromCallID(iter);
for (const auto &item : participants) {
Call *call = getCallFromCallID(item);
if (call) {
// if one call is currently recording, the conference is in state recording
isRec |= call->isRecording();
switchCall(iter);
offHoldCall(iter);
switchCall(item);
offHoldCall(item);
}
}
......@@ -977,10 +977,10 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter_p : participants) {
getMainBuffer().bindCallID(iter_p, MainBuffer::DEFAULT_ID);
for (const auto &item_p : participants) {
getMainBuffer().bindCallID(item_p, MainBuffer::DEFAULT_ID);
// Reset ringbuffer's readpointers
getMainBuffer().flush(iter_p);
getMainBuffer().flush(item_p);
}
getMainBuffer().flush(MainBuffer::DEFAULT_ID);
......@@ -1391,12 +1391,12 @@ void ManagerImpl::saveConfig()
try {
Conf::YamlEmitter emitter(path_.c_str());
for (auto &iter : SIPVoIPLink::instance()->getAccounts())
iter.second->serialize(emitter);
for (auto &item : SIPVoIPLink::instance()->getAccounts())
item.second->serialize(emitter);
#if HAVE_IAX
for (auto &iter : IAXVoIPLink::getAccounts())
iter.second->serialize(emitter);
for (auto &item : IAXVoIPLink::getAccounts())
item.second->serialize(emitter);
#endif
preferences.serialize(emitter);
......@@ -1551,14 +1551,14 @@ void ManagerImpl::incomingMessage(const std::string& callID,
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter_p : participants) {
for (const auto &item_p : participants) {
if (iter_p == callID)
if (item_p == callID)
continue;
std::string accountId(getAccountFromCall(iter_p));
std::string accountId(getAccountFromCall(item_p));
DEBUG("Send message to %s, (%s)", iter_p.c_str(), accountId.c_str());
DEBUG("Send message to %s, (%s)", item_p.c_str(), accountId.c_str());
Account *account = getAccount(accountId);
......@@ -1621,9 +1621,9 @@ bool ManagerImpl::sendTextMessage(const std::string& callID, const std::string&
ParticipantSet participants(conf->getParticipantList());
for (const auto &iter_p : participants) {
for (const auto &item_p : participants) {
const std::string accountId(getAccountFromCall(iter_p));
const std::string accountId(getAccountFromCall(item_p));
Account *account = getAccount(accountId);
......@@ -1632,7 +1632,7 @@ bool ManagerImpl::sendTextMessage(const std::string& callID, const std::string&
return false;
}
account->getVoIPLink()->sendTextMessage(iter_p, message, from);
account->getVoIPLink()->sendTextMessage(item_p, message, from);
}
} else {
Account *account = getAccount(getAccountFromCall(callID));
......@@ -2387,20 +2387,20 @@ std::vector<std::string> ManagerImpl::getAccountList() const
// If no order has been set, load the default one ie according to the creation date.
if (account_order.empty()) {
for (const auto &iter : allAccounts) {
if (iter.first == SIPAccount::IP2IP_PROFILE || iter.first.empty())
for (const auto &item : allAccounts) {
if (item.first == SIPAccount::IP2IP_PROFILE || item.first.empty())
continue;
if (iter.second)
v.push_back(iter.second->getAccountID());
if (item.second)
v.push_back(item.second->getAccountID());
}
}
else {
for (const auto &iter : account_order) {
if (iter == SIPAccount::IP2IP_PROFILE or iter.empty())
for (const auto &item : account_order) {
if (item == SIPAccount::IP2IP_PROFILE or item.empty())
continue;
AccountMap::const_iterator account_iter = allAccounts.find(iter);
AccountMap::const_iterator account_iter = allAccounts.find(item);
if (account_iter != allAccounts.end() and account_iter->second)
v.push_back(account_iter->second->getAccountID());
......
......@@ -37,8 +37,8 @@
namespace {
void strip_chars(const std::string &to_strip, std::string &num)
{
for (const auto &iter : to_strip)
num.erase(std::remove(num.begin(), num.end(), iter), num.end());
for (const auto &item : to_strip)
num.erase(std::remove(num.begin(), num.end(), item), num.end());
}
}
......
......@@ -93,13 +93,13 @@ std::vector<CryptoAttribute *> SdesNegotiator::parse()
std::vector<CryptoAttribute *> cryptoAttributeVector;
for (const auto &iter : remoteAttribute_) {
for (const auto &item : remoteAttribute_) {
// Split the line into its component
// that we will analyze further down.
std::vector<std::string> sdesLine;
*generalSyntaxPattern << iter;
*generalSyntaxPattern << item;
try {
sdesLine = generalSyntaxPattern->split();
......
......@@ -533,9 +533,9 @@ string Sdp::getLineFromSession(const pjmedia_sdp_session *sess, const string &ke
int size = pjmedia_sdp_print(sess, buffer, sizeof buffer);
string sdp(buffer, size);
const vector<string> tokens(split(sdp, '\n'));
for (const auto &iter : tokens)
if (iter.find(keyword) != string::npos)
return iter;
for (const auto &item : tokens)
if (item.find(keyword) != string::npos)
return item;
return "";
}
......@@ -647,8 +647,8 @@ Sdp::getProfileLevelID(const pjmedia_sdp_session *session,
void Sdp::addSdesAttribute(const vector<std::string>& crypto)
{
for (const auto &iter : crypto) {
pj_str_t val = { (char*) iter.c_str(), static_cast<pj_ssize_t>(iter.size()) };
for (const auto &item : crypto) {
pj_str_t val = { (char*) item.c_str(), static_cast<pj_ssize_t>(item.size()) };
pjmedia_sdp_attr *attr = pjmedia_sdp_attr_create(memPool_, "crypto", &val);
for (unsigned i = 0; i < localSession_->media_count; i++)
......
......@@ -596,8 +596,8 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
if (hasCredentials()) {
for (const auto &vect_iter : credentials_) {
const std::string password = retrievePassword(vect_iter, username_);
for (const auto &vect_item : credentials_) {
const std::string password = retrievePassword(vect_item, username_);
if (not password.empty())
a[CONFIG_ACCOUNT_PASSWORD] = password;
......@@ -799,8 +799,8 @@ void SIPAccount::trimCiphers()
// PJSIP aborts if our cipher list exceeds 1010 characters
static const int MAX_CIPHERS_STRLEN = 1010;
for (const auto &iter : ciphers_) {
sum += strlen(pj_ssl_cipher_name(iter));
for (const auto &item : ciphers_) {
sum += strlen(pj_ssl_cipher_name(item));
if (sum > MAX_CIPHERS_STRLEN)
break;
......@@ -1142,23 +1142,23 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str
size_t i = 0;
for (const auto &iter : credentials_) {
map<string, string>::const_iterator val = iter.find(CONFIG_ACCOUNT_PASSWORD);
const std::string password = val != iter.end() ? val->second : "";
for (const auto &item : credentials_) {
map<string, string>::const_iterator val = item.find(CONFIG_ACCOUNT_PASSWORD);
const std::string password = val != item.end() ? val->second : "";
int dataType = (md5HashingEnabled and password.length() == 32)
? PJSIP_CRED_DATA_DIGEST
: PJSIP_CRED_DATA_PLAIN_PASSWD;
val = iter.find(CONFIG_ACCOUNT_USERNAME);
val = item.find(CONFIG_ACCOUNT_USERNAME);
if (val != iter.end())
if (val != item.end())
cred_[i].username = pj_str((char*) val->second.c_str());
cred_[i].data = pj_str((char*) password.c_str());
val = iter.find(CONFIG_ACCOUNT_REALM);
val = item.find(CONFIG_ACCOUNT_REALM);
if (val != iter.end())
if (val != item.end())
cred_[i].realm = pj_str((char*) val->second.c_str());
cred_[i].data_type = dataType;
......
......@@ -656,10 +656,10 @@ SIPVoIPLink::getAccountIdFromNameAndServer(const std::string &userName,
DEBUG("username = %s, server = %s", userName.c_str(), server.c_str());
// Try to find the account id from username and server name by full match
for (const auto &iter : sipAccountMap_) {
SIPAccount *account = static_cast<SIPAccount*>(iter.second);
for (const auto &item : sipAccountMap_) {
SIPAccount *account = static_cast<SIPAccount*>(item.second);
if (account and account->matches(userName, server, endpt_, pool_))
return iter.first;
return item.first;
}
DEBUG("Username %s or server %s doesn't match any account, using IP2IP", userName.c_str(), server.c_str());
......@@ -1250,8 +1250,8 @@ SIPVoIPLink::clearSipCallMap()
{
sfl::ScopedLock m(sipCallMapMutex_);
for (const auto &iter : sipCallMap_)
delete iter.second;
for (const auto &item : sipCallMap_)
delete item.second;
sipCallMap_.clear();
}
......
......@@ -160,14 +160,14 @@ getDefaultCodecs()
const char * const DEFAULT_BITRATE = "400";
sfl_avcodec_init();
std::vector<std::map<std::string, std::string> > result;
for (const auto &iter : installed_video_codecs_) {
for (const auto &item : installed_video_codecs_) {
std::map<std::string, std::string> codec;
// FIXME: get these keys from proper place
codec["name"] = iter;
codec["name"] = item;
codec["bitrate"] = DEFAULT_BITRATE;
codec["enabled"] = "true";
// FIXME: make a nicer version of this
if (iter == "H264")
if (item == "H264")
codec["parameters"] = DEFAULT_H264_PROFILE_LEVEL_ID;
result.push_back(codec);
}
......
......@@ -121,9 +121,9 @@ static const unsigned pixelformats_supported[] = {
namespace {
unsigned int pixelformat_score(unsigned pixelformat)
{
for (const auto &iter : pixelformats_supported)
if (iter == pixelformat)
return iter;
for (const auto &item : pixelformats_supported)
if (item == pixelformat)
return item;
return UINT_MAX - 1;
}
......@@ -136,9 +136,9 @@ vector<string> VideoV4l2Size::getRateList()
{
vector<string> v;
for (const auto &iter : rates_) {
for (const auto &item : rates_) {
std::stringstream ss;