Commit e7806485 authored by Ronan's avatar Ronan

feat(Core): use `for (var : list)` syntax when possible (coreapi)

parent d460e32a
...@@ -45,7 +45,7 @@ void TunnelManager::addServer(const char *ip, int port) { ...@@ -45,7 +45,7 @@ void TunnelManager::addServer(const char *ip, int port) {
ms_warning("TunnelManager is configured in dual mode, use addServerPair instead"); ms_warning("TunnelManager is configured in dual mode, use addServerPair instead");
return; return;
} }
mServerAddrs.push_back(ServerAddr(ip,port)); mServerAddrs.push_back(ServerAddr(ip,port));
if (mTunnelClient && !mUseDualClient) { if (mTunnelClient && !mUseDualClient) {
static_cast<TunnelClient*>(mTunnelClient)->addServer(ip,port); static_cast<TunnelClient*>(mTunnelClient)->addServer(ip,port);
...@@ -70,7 +70,7 @@ void TunnelManager::addServerPair(const char *ip1, int port1, const char *ip2, i ...@@ -70,7 +70,7 @@ void TunnelManager::addServerPair(const char *ip1, int port1, const char *ip2, i
ms_warning("TunnelManager is configured in single mode, use addServer instead"); ms_warning("TunnelManager is configured in single mode, use addServer instead");
return; return;
} }
mDualServerAddrs.push_back(DualServerAddr(ip1, port1, ip2, port2)); mDualServerAddrs.push_back(DualServerAddr(ip1, port1, ip2, port2));
if (mTunnelClient && mUseDualClient) { if (mTunnelClient && mUseDualClient) {
static_cast<DualTunnelClient*>(mTunnelClient)->addServerPair(ip1, port1, ip2, port2); static_cast<DualTunnelClient*>(mTunnelClient)->addServerPair(ip1, port1, ip2, port2);
...@@ -84,11 +84,8 @@ void TunnelManager::cleanServers() { ...@@ -84,11 +84,8 @@ void TunnelManager::cleanServers() {
sal_end_background_task(mLongRunningTaskId); sal_end_background_task(mLongRunningTaskId);
mLongRunningTaskId = 0; mLongRunningTaskId = 0;
} }
UdpMirrorClientList::iterator it; for (auto &udpMirrorClient : mUdpMirrorClients)
for (it = mUdpMirrorClients.begin(); it != mUdpMirrorClients.end();) { udpMirrorClient.stop();
UdpMirrorClient& s=*it++;
s.stop();
}
mUdpMirrorClients.clear(); mUdpMirrorClients.clear();
mCurrentUdpMirrorClient = mUdpMirrorClients.end(); mCurrentUdpMirrorClient = mUdpMirrorClients.end();
if (mTunnelClient) mTunnelClient->cleanServers(); if (mTunnelClient) mTunnelClient->cleanServers();
...@@ -141,7 +138,7 @@ RtpTransport *TunnelManager::createRtpTransport(int port){ ...@@ -141,7 +138,7 @@ RtpTransport *TunnelManager::createRtpTransport(int port){
dualSocket->recvSocket = ((DualTunnelClient *)mTunnelClient)->createSocket(TunnelRecvOnly, port); dualSocket->recvSocket = ((DualTunnelClient *)mTunnelClient)->createSocket(TunnelRecvOnly, port);
dualSocket->recvSocket->setUserPointer(this); dualSocket->recvSocket->setUserPointer(this);
} }
RtpTransport *t = ms_new0(RtpTransport,1); RtpTransport *t = ms_new0(RtpTransport,1);
t->t_getsocket=NULL; t->t_getsocket=NULL;
t->t_recvfrom=customRecvfrom; t->t_recvfrom=customRecvfrom;
...@@ -161,7 +158,7 @@ void TunnelManager::startClient() { ...@@ -161,7 +158,7 @@ void TunnelManager::startClient() {
} else { } else {
mTunnelClient = TunnelClient::create(TRUE); mTunnelClient = TunnelClient::create(TRUE);
} }
sal_set_tunnel(mCore->sal, mTunnelClient); sal_set_tunnel(mCore->sal, mTunnelClient);
if (!mUseDualClient) { if (!mUseDualClient) {
static_cast<TunnelClient*>(mTunnelClient)->setCallback(tunnelCallback,this); static_cast<TunnelClient*>(mTunnelClient)->setCallback(tunnelCallback,this);
...@@ -169,7 +166,7 @@ void TunnelManager::startClient() { ...@@ -169,7 +166,7 @@ void TunnelManager::startClient() {
static_cast<DualTunnelClient*>(mTunnelClient)->setCallback(tunnelCallback2,this); static_cast<DualTunnelClient*>(mTunnelClient)->setCallback(tunnelCallback2,this);
} }
} }
if (mVerifyServerCertificate) { if (mVerifyServerCertificate) {
const char *rootCertificatePath = linphone_core_get_root_ca(mCore); const char *rootCertificatePath = linphone_core_get_root_ca(mCore);
if (rootCertificatePath != NULL) { if (rootCertificatePath != NULL) {
...@@ -193,7 +190,7 @@ void TunnelManager::startClient() { ...@@ -193,7 +190,7 @@ void TunnelManager::startClient() {
static_cast<TunnelClient*>(mTunnelClient)->addServer(addr.mAddr.c_str(), addr.mPort); static_cast<TunnelClient*>(mTunnelClient)->addServer(addr.mAddr.c_str(), addr.mPort);
} }
} }
mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str()); mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str());
if (!mTunnelClient->isStarted()) { if (!mTunnelClient->isStarted()) {
ms_message("Starting tunnel client"); ms_message("Starting tunnel client");
...@@ -380,7 +377,7 @@ void TunnelManager::setMode(LinphoneTunnelMode mode) { ...@@ -380,7 +377,7 @@ void TunnelManager::setMode(LinphoneTunnelMode mode) {
linphone_tunnel_mode_to_string(mode)); linphone_tunnel_mode_to_string(mode));
mMode = mode; mMode = mode;
applyMode(); applyMode();
} }
void TunnelManager::stopLongRunningTask() { void TunnelManager::stopLongRunningTask() {
...@@ -393,7 +390,7 @@ void TunnelManager::stopLongRunningTask() { ...@@ -393,7 +390,7 @@ void TunnelManager::stopLongRunningTask() {
void TunnelManager::tunnelCallback(bool connected, void *user_pointer){ void TunnelManager::tunnelCallback(bool connected, void *user_pointer){
TunnelManager *zis = static_cast<TunnelManager*>(user_pointer); TunnelManager *zis = static_cast<TunnelManager*>(user_pointer);
Event ev; Event ev;
ev.mType=TunnelEvent; ev.mType=TunnelEvent;
ev.mData.mConnected=connected; ev.mData.mConnected=connected;
zis->postEvent(ev); zis->postEvent(ev);
...@@ -402,7 +399,7 @@ void TunnelManager::tunnelCallback(bool connected, void *user_pointer){ ...@@ -402,7 +399,7 @@ void TunnelManager::tunnelCallback(bool connected, void *user_pointer){
void TunnelManager::tunnelCallback2(TunnelDirection direction, bool connected, void *user_pointer){ void TunnelManager::tunnelCallback2(TunnelDirection direction, bool connected, void *user_pointer){
TunnelManager *zis = static_cast<TunnelManager*>(user_pointer); TunnelManager *zis = static_cast<TunnelManager*>(user_pointer);
Event ev; Event ev;
ev.mType=TunnelEvent; ev.mType=TunnelEvent;
ev.mData.mConnected=connected; ev.mData.mConnected=connected;
zis->postEvent(ev); zis->postEvent(ev);
...@@ -515,7 +512,7 @@ void TunnelManager::sUdpMirrorClientCallback(bool isUdpAvailable, void* data) { ...@@ -515,7 +512,7 @@ void TunnelManager::sUdpMirrorClientCallback(bool isUdpAvailable, void* data) {
void TunnelManager::networkReachableCb(LinphoneCore *lc, bool_t reachable) { void TunnelManager::networkReachableCb(LinphoneCore *lc, bool_t reachable) {
TunnelManager *tunnel = bcTunnel(linphone_core_get_tunnel(lc)); TunnelManager *tunnel = bcTunnel(linphone_core_get_tunnel(lc));
if (reachable) { if (reachable) {
linphone_core_get_local_ip_for(AF_INET, NULL,tunnel->mLocalAddr); linphone_core_get_local_ip_for(AF_INET, NULL,tunnel->mLocalAddr);
if (tunnel->getMode() == LinphoneTunnelModeAuto){ if (tunnel->getMode() == LinphoneTunnelModeAuto){
......
...@@ -32,11 +32,13 @@ ...@@ -32,11 +32,13 @@
#include <algorithm> #include <algorithm>
#include <string> #include <string>
using namespace std;
namespace Linphone { namespace Linphone {
template <typename _type> template <typename _type>
inline std::list<_type> toStd(const bctbx_list_t *l){ inline list<_type> toStd(const bctbx_list_t *l){
std::list<_type> ret; list<_type> ret;
for(; l != NULL; l = l->next){ for(; l != NULL; l = l->next){
ret.push_back(static_cast<_type>(l->data)); ret.push_back(static_cast<_type>(l->data));
} }
...@@ -108,7 +110,7 @@ public: ...@@ -108,7 +110,7 @@ public:
const Params &getCurrentParams() const {return m_currentParams;} const Params &getCurrentParams() const {return m_currentParams;}
virtual int inviteAddresses(const std::list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) = 0; virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) = 0;
virtual int addParticipant(LinphoneCall *call) = 0; virtual int addParticipant(LinphoneCall *call) = 0;
virtual int removeParticipant(LinphoneCall *call) = 0; virtual int removeParticipant(LinphoneCall *call) = 0;
virtual int removeParticipant(const LinphoneAddress *uri) = 0; virtual int removeParticipant(const LinphoneAddress *uri) = 0;
...@@ -124,7 +126,7 @@ public: ...@@ -124,7 +126,7 @@ public:
float getInputVolume() const; float getInputVolume() const;
virtual int getSize() const {return (int)m_participants.size() + (isIn()?1:0);} virtual int getSize() const {return (int)m_participants.size() + (isIn()?1:0);}
const std::list<Participant *> &getParticipants() const {return m_participants;} const list<Participant *> &getParticipants() const {return m_participants;}
virtual int startRecording(const char *path) = 0; virtual int startRecording(const char *path) = 0;
virtual int stopRecording() = 0; virtual int stopRecording() = 0;
...@@ -152,11 +154,11 @@ protected: ...@@ -152,11 +154,11 @@ protected:
Participant *findParticipant(const LinphoneAddress *uri) const; Participant *findParticipant(const LinphoneAddress *uri) const;
protected: protected:
std::string m_conferenceID; string m_conferenceID;
LinphoneCore *m_core; LinphoneCore *m_core;
AudioStream *m_localParticipantStream; AudioStream *m_localParticipantStream;
bool m_isMuted; bool m_isMuted;
std::list<Participant *> m_participants; list<Participant *> m_participants;
Params m_currentParams; Params m_currentParams;
LinphoneConferenceState m_state; LinphoneConferenceState m_state;
LinphoneConference *m_conference; LinphoneConference *m_conference;
...@@ -167,7 +169,7 @@ public: ...@@ -167,7 +169,7 @@ public:
LocalConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL); LocalConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
virtual ~LocalConference(); virtual ~LocalConference();
virtual int inviteAddresses(const std::list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params); virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params);
virtual int addParticipant(LinphoneCall *call); virtual int addParticipant(LinphoneCall *call);
virtual int removeParticipant(LinphoneCall *call); virtual int removeParticipant(LinphoneCall *call);
virtual int removeParticipant(const LinphoneAddress *uri); virtual int removeParticipant(const LinphoneAddress *uri);
...@@ -205,7 +207,7 @@ public: ...@@ -205,7 +207,7 @@ public:
RemoteConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL); RemoteConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
virtual ~RemoteConference(); virtual ~RemoteConference();
virtual int inviteAddresses(const std::list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params); virtual int inviteAddresses(const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params);
virtual int addParticipant(LinphoneCall *call); virtual int addParticipant(LinphoneCall *call);
virtual int removeParticipant(LinphoneCall *call) {return -1;} virtual int removeParticipant(LinphoneCall *call) {return -1;}
virtual int removeParticipant(const LinphoneAddress *uri); virtual int removeParticipant(const LinphoneAddress *uri);
...@@ -234,8 +236,8 @@ private: ...@@ -234,8 +236,8 @@ private:
char *m_focusContact; char *m_focusContact;
LinphoneCall *m_focusCall; LinphoneCall *m_focusCall;
LinphoneCoreCbs *m_coreCbs; LinphoneCoreCbs *m_coreCbs;
std::list<LinphoneCall *> m_pendingCalls; list<LinphoneCall *> m_pendingCalls;
std::list<LinphoneCall *> m_transferingCalls; list<LinphoneCall *> m_transferingCalls;
}; };
}; };
...@@ -408,20 +410,18 @@ void LocalConference::addLocalEndpoint() { ...@@ -408,20 +410,18 @@ void LocalConference::addLocalEndpoint() {
ms_audio_conference_add_member(m_conf,m_localEndpoint); ms_audio_conference_add_member(m_conf,m_localEndpoint);
} }
int LocalConference::inviteAddresses(const std::list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params){ int LocalConference::inviteAddresses (const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) {
for (const auto &address : addresses) {
for (std::list<const LinphoneAddress*>::const_iterator it = addresses.begin(); it != addresses.end(); ++it){ LinphoneCall * call = linphone_core_get_call_by_remote_address2(m_core, address);
const LinphoneAddress *addr = *it; if (!call) {
LinphoneCall * call = linphone_core_get_call_by_remote_address2(m_core, addr);
if (!call){
/*start a new call by indicating that it has to be put into the conference directlly*/ /*start a new call by indicating that it has to be put into the conference directlly*/
LinphoneCallParams * new_params = params ? linphone_call_params_copy(params) : linphone_core_create_call_params(m_core, NULL); LinphoneCallParams * new_params = params ? linphone_call_params_copy(params) : linphone_core_create_call_params(m_core, NULL);
LinphoneCall *call; LinphoneCall *call;
/*toggle this flag so the call is immediately added to the conference upon acceptance*/ /*toggle this flag so the call is immediately added to the conference upon acceptance*/
linphone_call_params_set_in_conference(new_params, TRUE); linphone_call_params_set_in_conference(new_params, TRUE);
linphone_call_params_enable_video(new_params, FALSE); /*turn off video as it is not supported for conferencing at this time*/ linphone_call_params_enable_video(new_params, FALSE); /*turn off video as it is not supported for conferencing at this time*/
call = linphone_core_invite_address_with_params(m_core, addr, new_params); call = linphone_core_invite_address_with_params(m_core, address, new_params);
if (!call){ if (!call) {
ms_error("LocalConference::inviteAddresses(): could not invite participant"); ms_error("LocalConference::inviteAddresses(): could not invite participant");
} }
linphone_call_params_unref(new_params); linphone_call_params_unref(new_params);
...@@ -712,7 +712,7 @@ RemoteConference::~RemoteConference() { ...@@ -712,7 +712,7 @@ RemoteConference::~RemoteConference() {
linphone_core_cbs_unref(m_coreCbs); linphone_core_cbs_unref(m_coreCbs);
} }
int RemoteConference::inviteAddresses(const std::list<const LinphoneAddress *> &addresses, const LinphoneCallParams *params){ int RemoteConference::inviteAddresses(const list<const LinphoneAddress *> &addresses, const LinphoneCallParams *params){
ms_error("RemoteConference::inviteAddresses() not implemented"); ms_error("RemoteConference::inviteAddresses() not implemented");
return -1; return -1;
} }
......
...@@ -139,11 +139,8 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardConte ...@@ -139,11 +139,8 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_file(LinphoneVcardConte
} }
shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename); shared_ptr<belcard::BelCardList> belCards = context->parser->parseFile(filename);
if (belCards) { if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { for (auto &belCard : belCards->getCards())
shared_ptr<belcard::BelCard> belCard = (*it); result = bctbx_list_append(result, linphone_vcard_new_from_belcard(belCard));
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
} }
} }
return result; return result;
...@@ -157,11 +154,8 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardCon ...@@ -157,11 +154,8 @@ bctbx_list_t* linphone_vcard_context_get_vcard_list_from_buffer(LinphoneVcardCon
} }
shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer); shared_ptr<belcard::BelCardList> belCards = context->parser->parse(buffer);
if (belCards) { if (belCards) {
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) { for (auto &belCard : belCards->getCards())
shared_ptr<belcard::BelCard> belCard = (*it); result = bctbx_list_append(result, linphone_vcard_new_from_belcard(belCard));
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
result = bctbx_list_append(result, vCard);
}
} }
} }
return result; return result;
...@@ -274,17 +268,13 @@ void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_addres ...@@ -274,17 +268,13 @@ void linphone_vcard_add_sip_address(LinphoneVcard *vCard, const char *sip_addres
void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) { void linphone_vcard_remove_sip_address(LinphoneVcard *vCard, const char *sip_address) {
if (!vCard) return; if (!vCard) return;
shared_ptr<belcard::BelCardImpp> impp; for (auto &impp : vCard->belCard->getImpp()) {
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { const char *value = impp->getValue().c_str();
const char *value = (*it)->getValue().c_str();
if (strcmp(value, sip_address) == 0) { if (strcmp(value, sip_address) == 0) {
impp = *it; vCard->belCard->removeImpp(impp);
break; break;
} }
} }
if (impp) {
vCard->belCard->removeImpp(impp);
}
} }
void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) { void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_address) {
...@@ -303,8 +293,8 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_ ...@@ -303,8 +293,8 @@ void linphone_vcard_edit_main_sip_address(LinphoneVcard *vCard, const char *sip_
const bctbx_list_t* linphone_vcard_get_sip_addresses(LinphoneVcard *vCard) { const bctbx_list_t* linphone_vcard_get_sip_addresses(LinphoneVcard *vCard) {
if (!vCard) return NULL; if (!vCard) return NULL;
if (!vCard->sip_addresses_cache) { if (!vCard->sip_addresses_cache) {
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) { for (auto &impp : vCard->belCard->getImpp()) {
LinphoneAddress* addr = linphone_address_new((*it)->getValue().c_str()); LinphoneAddress* addr = linphone_address_new(impp->getValue().c_str());
if (addr) { if (addr) {
vCard->sip_addresses_cache = bctbx_list_append(vCard->sip_addresses_cache, addr); vCard->sip_addresses_cache = bctbx_list_append(vCard->sip_addresses_cache, addr);
} }
...@@ -325,24 +315,21 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone) ...@@ -325,24 +315,21 @@ void linphone_vcard_remove_phone_number(LinphoneVcard *vCard, const char *phone)
if (!vCard) return; if (!vCard) return;
shared_ptr<belcard::BelCardPhoneNumber> tel; shared_ptr<belcard::BelCardPhoneNumber> tel;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) { for (auto &phoneNumber : vCard->belCard->getPhoneNumbers()) {
const char *value = (*it)->getValue().c_str(); const char *value = phoneNumber->getValue().c_str();
if (strcmp(value, phone) == 0) { if (strcmp(value, phone) == 0) {
tel = *it; vCard->belCard->removePhoneNumber(phoneNumber);
break; break;
} }
} }
if (tel) {
vCard->belCard->removePhoneNumber(tel);
}
} }
bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) { bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
bctbx_list_t *result = NULL; bctbx_list_t *result = NULL;
if (!vCard) return NULL; if (!vCard) return NULL;
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) { for (auto &phoneNumber : vCard->belCard->getPhoneNumbers()) {
const char *value = (*it)->getValue().c_str(); const char *value = phoneNumber->getValue().c_str();
result = bctbx_list_append(result, (char *)value); result = bctbx_list_append(result, (char *)value);
} }
return result; return result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment