mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
feat(Core): use for (var : list) syntax when possible (coreapi)
This commit is contained in:
parent
d460e32a0f
commit
e78064859a
3 changed files with 45 additions and 61 deletions
|
|
@ -45,7 +45,7 @@ void TunnelManager::addServer(const char *ip, int port) {
|
|||
ms_warning("TunnelManager is configured in dual mode, use addServerPair instead");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mServerAddrs.push_back(ServerAddr(ip,port));
|
||||
if (mTunnelClient && !mUseDualClient) {
|
||||
static_cast<TunnelClient*>(mTunnelClient)->addServer(ip,port);
|
||||
|
|
@ -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");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mDualServerAddrs.push_back(DualServerAddr(ip1, port1, ip2, port2));
|
||||
if (mTunnelClient && mUseDualClient) {
|
||||
static_cast<DualTunnelClient*>(mTunnelClient)->addServerPair(ip1, port1, ip2, port2);
|
||||
|
|
@ -84,11 +84,8 @@ void TunnelManager::cleanServers() {
|
|||
sal_end_background_task(mLongRunningTaskId);
|
||||
mLongRunningTaskId = 0;
|
||||
}
|
||||
UdpMirrorClientList::iterator it;
|
||||
for (it = mUdpMirrorClients.begin(); it != mUdpMirrorClients.end();) {
|
||||
UdpMirrorClient& s=*it++;
|
||||
s.stop();
|
||||
}
|
||||
for (auto &udpMirrorClient : mUdpMirrorClients)
|
||||
udpMirrorClient.stop();
|
||||
mUdpMirrorClients.clear();
|
||||
mCurrentUdpMirrorClient = mUdpMirrorClients.end();
|
||||
if (mTunnelClient) mTunnelClient->cleanServers();
|
||||
|
|
@ -141,7 +138,7 @@ RtpTransport *TunnelManager::createRtpTransport(int port){
|
|||
dualSocket->recvSocket = ((DualTunnelClient *)mTunnelClient)->createSocket(TunnelRecvOnly, port);
|
||||
dualSocket->recvSocket->setUserPointer(this);
|
||||
}
|
||||
|
||||
|
||||
RtpTransport *t = ms_new0(RtpTransport,1);
|
||||
t->t_getsocket=NULL;
|
||||
t->t_recvfrom=customRecvfrom;
|
||||
|
|
@ -161,7 +158,7 @@ void TunnelManager::startClient() {
|
|||
} else {
|
||||
mTunnelClient = TunnelClient::create(TRUE);
|
||||
}
|
||||
|
||||
|
||||
sal_set_tunnel(mCore->sal, mTunnelClient);
|
||||
if (!mUseDualClient) {
|
||||
static_cast<TunnelClient*>(mTunnelClient)->setCallback(tunnelCallback,this);
|
||||
|
|
@ -169,7 +166,7 @@ void TunnelManager::startClient() {
|
|||
static_cast<DualTunnelClient*>(mTunnelClient)->setCallback(tunnelCallback2,this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (mVerifyServerCertificate) {
|
||||
const char *rootCertificatePath = linphone_core_get_root_ca(mCore);
|
||||
if (rootCertificatePath != NULL) {
|
||||
|
|
@ -193,7 +190,7 @@ void TunnelManager::startClient() {
|
|||
static_cast<TunnelClient*>(mTunnelClient)->addServer(addr.mAddr.c_str(), addr.mPort);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mTunnelClient->setHttpProxy(mHttpProxyHost.c_str(), mHttpProxyPort, mHttpUserName.c_str(), mHttpPasswd.c_str());
|
||||
if (!mTunnelClient->isStarted()) {
|
||||
ms_message("Starting tunnel client");
|
||||
|
|
@ -380,7 +377,7 @@ void TunnelManager::setMode(LinphoneTunnelMode mode) {
|
|||
linphone_tunnel_mode_to_string(mode));
|
||||
mMode = mode;
|
||||
applyMode();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void TunnelManager::stopLongRunningTask() {
|
||||
|
|
@ -393,7 +390,7 @@ void TunnelManager::stopLongRunningTask() {
|
|||
void TunnelManager::tunnelCallback(bool connected, void *user_pointer){
|
||||
TunnelManager *zis = static_cast<TunnelManager*>(user_pointer);
|
||||
Event ev;
|
||||
|
||||
|
||||
ev.mType=TunnelEvent;
|
||||
ev.mData.mConnected=connected;
|
||||
zis->postEvent(ev);
|
||||
|
|
@ -402,7 +399,7 @@ void TunnelManager::tunnelCallback(bool connected, void *user_pointer){
|
|||
void TunnelManager::tunnelCallback2(TunnelDirection direction, bool connected, void *user_pointer){
|
||||
TunnelManager *zis = static_cast<TunnelManager*>(user_pointer);
|
||||
Event ev;
|
||||
|
||||
|
||||
ev.mType=TunnelEvent;
|
||||
ev.mData.mConnected=connected;
|
||||
zis->postEvent(ev);
|
||||
|
|
@ -515,7 +512,7 @@ void TunnelManager::sUdpMirrorClientCallback(bool isUdpAvailable, void* data) {
|
|||
|
||||
void TunnelManager::networkReachableCb(LinphoneCore *lc, bool_t reachable) {
|
||||
TunnelManager *tunnel = bcTunnel(linphone_core_get_tunnel(lc));
|
||||
|
||||
|
||||
if (reachable) {
|
||||
linphone_core_get_local_ip_for(AF_INET, NULL,tunnel->mLocalAddr);
|
||||
if (tunnel->getMode() == LinphoneTunnelModeAuto){
|
||||
|
|
|
|||
|
|
@ -32,11 +32,13 @@
|
|||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Linphone {
|
||||
|
||||
template <typename _type>
|
||||
inline std::list<_type> toStd(const bctbx_list_t *l){
|
||||
std::list<_type> ret;
|
||||
inline list<_type> toStd(const bctbx_list_t *l){
|
||||
list<_type> ret;
|
||||
for(; l != NULL; l = l->next){
|
||||
ret.push_back(static_cast<_type>(l->data));
|
||||
}
|
||||
|
|
@ -108,7 +110,7 @@ public:
|
|||
|
||||
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 removeParticipant(LinphoneCall *call) = 0;
|
||||
virtual int removeParticipant(const LinphoneAddress *uri) = 0;
|
||||
|
|
@ -124,7 +126,7 @@ public:
|
|||
float getInputVolume() const;
|
||||
|
||||
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 stopRecording() = 0;
|
||||
|
|
@ -152,11 +154,11 @@ protected:
|
|||
Participant *findParticipant(const LinphoneAddress *uri) const;
|
||||
|
||||
protected:
|
||||
std::string m_conferenceID;
|
||||
string m_conferenceID;
|
||||
LinphoneCore *m_core;
|
||||
AudioStream *m_localParticipantStream;
|
||||
bool m_isMuted;
|
||||
std::list<Participant *> m_participants;
|
||||
list<Participant *> m_participants;
|
||||
Params m_currentParams;
|
||||
LinphoneConferenceState m_state;
|
||||
LinphoneConference *m_conference;
|
||||
|
|
@ -167,7 +169,7 @@ public:
|
|||
LocalConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
|
||||
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 removeParticipant(LinphoneCall *call);
|
||||
virtual int removeParticipant(const LinphoneAddress *uri);
|
||||
|
|
@ -205,7 +207,7 @@ public:
|
|||
RemoteConference(LinphoneCore *core, LinphoneConference *conf, const Params *params = NULL);
|
||||
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 removeParticipant(LinphoneCall *call) {return -1;}
|
||||
virtual int removeParticipant(const LinphoneAddress *uri);
|
||||
|
|
@ -234,8 +236,8 @@ private:
|
|||
char *m_focusContact;
|
||||
LinphoneCall *m_focusCall;
|
||||
LinphoneCoreCbs *m_coreCbs;
|
||||
std::list<LinphoneCall *> m_pendingCalls;
|
||||
std::list<LinphoneCall *> m_transferingCalls;
|
||||
list<LinphoneCall *> m_pendingCalls;
|
||||
list<LinphoneCall *> m_transferingCalls;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
@ -408,20 +410,18 @@ void LocalConference::addLocalEndpoint() {
|
|||
ms_audio_conference_add_member(m_conf,m_localEndpoint);
|
||||
}
|
||||
|
||||
int LocalConference::inviteAddresses(const std::list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params){
|
||||
|
||||
for (std::list<const LinphoneAddress*>::const_iterator it = addresses.begin(); it != addresses.end(); ++it){
|
||||
const LinphoneAddress *addr = *it;
|
||||
LinphoneCall * call = linphone_core_get_call_by_remote_address2(m_core, addr);
|
||||
if (!call){
|
||||
int LocalConference::inviteAddresses (const list<const LinphoneAddress*> &addresses, const LinphoneCallParams *params) {
|
||||
for (const auto &address : addresses) {
|
||||
LinphoneCall * call = linphone_core_get_call_by_remote_address2(m_core, address);
|
||||
if (!call) {
|
||||
/*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);
|
||||
LinphoneCall *call;
|
||||
/*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_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);
|
||||
if (!call){
|
||||
call = linphone_core_invite_address_with_params(m_core, address, new_params);
|
||||
if (!call) {
|
||||
ms_error("LocalConference::inviteAddresses(): could not invite participant");
|
||||
}
|
||||
linphone_call_params_unref(new_params);
|
||||
|
|
@ -712,7 +712,7 @@ RemoteConference::~RemoteConference() {
|
|||
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");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
if (belCards) {
|
||||
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
|
||||
shared_ptr<belcard::BelCard> belCard = (*it);
|
||||
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
|
||||
result = bctbx_list_append(result, vCard);
|
||||
}
|
||||
for (auto &belCard : belCards->getCards())
|
||||
result = bctbx_list_append(result, linphone_vcard_new_from_belcard(belCard));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -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);
|
||||
if (belCards) {
|
||||
for (auto it = belCards->getCards().begin(); it != belCards->getCards().end(); ++it) {
|
||||
shared_ptr<belcard::BelCard> belCard = (*it);
|
||||
LinphoneVcard *vCard = linphone_vcard_new_from_belcard(belCard);
|
||||
result = bctbx_list_append(result, vCard);
|
||||
}
|
||||
for (auto &belCard : belCards->getCards())
|
||||
result = bctbx_list_append(result, linphone_vcard_new_from_belcard(belCard));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -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) {
|
||||
if (!vCard) return;
|
||||
|
||||
shared_ptr<belcard::BelCardImpp> impp;
|
||||
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
|
||||
const char *value = (*it)->getValue().c_str();
|
||||
for (auto &impp : vCard->belCard->getImpp()) {
|
||||
const char *value = impp->getValue().c_str();
|
||||
if (strcmp(value, sip_address) == 0) {
|
||||
impp = *it;
|
||||
vCard->belCard->removeImpp(impp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (impp) {
|
||||
vCard->belCard->removeImpp(impp);
|
||||
}
|
||||
}
|
||||
|
||||
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_
|
|||
const bctbx_list_t* linphone_vcard_get_sip_addresses(LinphoneVcard *vCard) {
|
||||
if (!vCard) return NULL;
|
||||
if (!vCard->sip_addresses_cache) {
|
||||
for (auto it = vCard->belCard->getImpp().begin(); it != vCard->belCard->getImpp().end(); ++it) {
|
||||
LinphoneAddress* addr = linphone_address_new((*it)->getValue().c_str());
|
||||
for (auto &impp : vCard->belCard->getImpp()) {
|
||||
LinphoneAddress* addr = linphone_address_new(impp->getValue().c_str());
|
||||
if (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)
|
|||
if (!vCard) return;
|
||||
|
||||
shared_ptr<belcard::BelCardPhoneNumber> tel;
|
||||
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
|
||||
const char *value = (*it)->getValue().c_str();
|
||||
for (auto &phoneNumber : vCard->belCard->getPhoneNumbers()) {
|
||||
const char *value = phoneNumber->getValue().c_str();
|
||||
if (strcmp(value, phone) == 0) {
|
||||
tel = *it;
|
||||
vCard->belCard->removePhoneNumber(phoneNumber);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tel) {
|
||||
vCard->belCard->removePhoneNumber(tel);
|
||||
}
|
||||
}
|
||||
|
||||
bctbx_list_t* linphone_vcard_get_phone_numbers(const LinphoneVcard *vCard) {
|
||||
bctbx_list_t *result = NULL;
|
||||
if (!vCard) return NULL;
|
||||
|
||||
for (auto it = vCard->belCard->getPhoneNumbers().begin(); it != vCard->belCard->getPhoneNumbers().end(); ++it) {
|
||||
const char *value = (*it)->getValue().c_str();
|
||||
for (auto &phoneNumber : vCard->belCard->getPhoneNumbers()) {
|
||||
const char *value = phoneNumber->getValue().c_str();
|
||||
result = bctbx_list_append(result, (char *)value);
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue