From 3a41ef71d6e0a36ee8e2ffa043be029fdb36f002 Mon Sep 17 00:00:00 2001 From: Tristan Matthews <tristan.matthews@savoirfairelinux.com> Date: Tue, 11 Oct 2011 17:01:28 -0400 Subject: [PATCH] * #7131: removed underscore prefix in call, other cleanup --- daemon/src/account.h | 20 +++++----- daemon/src/call.cpp | 54 ++++++++++++------------- daemon/src/call.h | 82 +++++++++++++++++--------------------- daemon/src/eventthread.cpp | 6 +-- daemon/src/eventthread.h | 4 +- daemon/src/managerimpl.cpp | 7 +++- 6 files changed, 83 insertions(+), 90 deletions(-) diff --git a/daemon/src/account.h b/daemon/src/account.h index 3a5aaaae84..c8eff7fb53 100644 --- a/daemon/src/account.h +++ b/daemon/src/account.h @@ -223,25 +223,25 @@ class Account : public Serializable { void setRegistrationState(const RegistrationState &state); /* They should be treated like macro definitions by the C++ compiler */ - std::string getUsername(void) const { + std::string getUsername() const { return username_; } - std::string getHostname(void) const { + std::string getHostname() const { return hostname_; } void setHostname(const std::string &hostname) { hostname_ = hostname; } - std::string getAlias(void) const { + std::string getAlias() const { return alias_; } void setAlias(const std::string &alias) { alias_ = alias; } - std::string getType(void) const { + std::string getType() const { return type_; } void setType(const std::string &type) { @@ -252,7 +252,7 @@ class Account : public Serializable { * Accessor to data structures * @return CodecOrder& The list that reflects the user's choice */ - const CodecOrder& getActiveCodecs(void) const { + const CodecOrder& getActiveCodecs() const { return codecOrder_; } @@ -262,28 +262,28 @@ class Account : public Serializable { */ void setActiveCodecs(const std::vector <std::string>& list); - std::string getRingtonePath(void) const { + std::string getRingtonePath() const { return ringtonePath_; } void setRingtonePath(const std::string &path) { ringtonePath_ = path; } - bool getRingtoneEnabled(void) const { + bool getRingtoneEnabled() const { return ringtoneEnabled_; } void setRingtoneEnabled(bool enable) { ringtoneEnabled_ = enable; } - std::string getDisplayName(void) const { + std::string getDisplayName() const { return displayName_; } void setDisplayName(const std::string &name) { displayName_ = name; } - std::string getMailBox(void) const { + std::string getMailBox() const { return mailBox_; } @@ -302,7 +302,7 @@ class Account : public Serializable { * Helper function used to load the default codec order from the codec factory * setActiveCodecs is called to sync both codecOrder_ and codecStr_ */ - void loadDefaultCodecs(void); + void loadDefaultCodecs(); protected: static std::string mapStateNumberToString(RegistrationState state); diff --git a/daemon/src/call.cpp b/daemon/src/call.cpp index 2fa6249ccd..839f70b94c 100644 --- a/daemon/src/call.cpp +++ b/daemon/src/call.cpp @@ -35,19 +35,18 @@ const char * const Call::DEFAULT_ID = "audiolayer_id"; Call::Call(const std::string& id, Call::CallType type) - : _callMutex() - , _localIPAddress("") - , _localAudioPort(0) - , _id(id) - , _confID("") - , _type(type) - , _connectionState(Call::Disconnected) - , _callState(Call::Inactive) - , _callConfig(Call::Classic) - , _peerName() - , _peerNumber() + : callMutex_() + , localIPAddress_("") + , localAudioPort_(0) + , id_(id) + , confID_("") + , type_(type) + , connectionState_(Call::Disconnected) + , callState_(Call::Inactive) + , callConfig_(Call::Classic) + , peerName_() + , peerNumber_() { - } @@ -58,30 +57,30 @@ Call::~Call() void Call::setConnectionState(ConnectionState state) { - ost::MutexLock m(_callMutex); - _connectionState = state; + ost::MutexLock m(callMutex_); + connectionState_ = state; } Call::ConnectionState Call::getConnectionState() { - ost::MutexLock m(_callMutex); - return _connectionState; + ost::MutexLock m(callMutex_); + return connectionState_; } void Call::setState(CallState state) { - ost::MutexLock m(_callMutex); - _callState = state; + ost::MutexLock m(callMutex_); + callState_ = state; } Call::CallState Call::getState() { - ost::MutexLock m(_callMutex); - return _callState; + ost::MutexLock m(callMutex_); + return callState_; } std::string @@ -89,7 +88,6 @@ Call::getStateStr() { switch (getState()) { case Active: - switch (getConnectionState()) { case Ringing: return isIncoming() ? "INCOMING" : "RINGING"; @@ -123,18 +121,18 @@ Call::getStateStr() } -const std::string& +std::string Call::getLocalIp() { - ost::MutexLock m(_callMutex); - return _localIPAddress; + ost::MutexLock m(callMutex_); + return localIPAddress_; } unsigned int Call::getLocalAudioPort() { - ost::MutexLock m(_callMutex); - return _localAudioPort; + ost::MutexLock m(callMutex_); + return localAudioPort_; } bool @@ -147,12 +145,12 @@ Call::setRecording() std::string process_id = Recordable::recorder.getRecorderID(); if (!recordStatus) { - mbuffer->bindHalfDuplexOut(process_id, _id); + mbuffer->bindHalfDuplexOut(process_id, id_); mbuffer->bindHalfDuplexOut(process_id); Recordable::recorder.start(); } else { - mbuffer->unBindHalfDuplexOut(process_id, _id); + mbuffer->unBindHalfDuplexOut(process_id, id_); mbuffer->unBindHalfDuplexOut(process_id); } diff --git a/daemon/src/call.h b/daemon/src/call.h index 85469a154f..fcb5bba734 100644 --- a/daemon/src/call.h +++ b/daemon/src/call.h @@ -37,17 +37,12 @@ #include "audio/recordable.h" -#define SIP_SCHEME "sip:" -#define SIPS_SCHEME "sips:" - -#define CallConfigNULL 0 - /* * @file call.h * @brief A call is the base class for protocol-based calls */ -class Call: public Recordable { +class Call : public Recordable { public: static const char * const DEFAULT_ID; @@ -90,7 +85,7 @@ class Call: public Recordable { * @return call id */ std::string getCallId() const { - return _id; + return id_; } /** @@ -98,15 +93,15 @@ class Call: public Recordable { * @return call id */ std::string getConfId() const { - return _confID; + return confID_; } void setConfId(const std::string &id) { - _confID = id; + confID_ = id; } - CallType getCallType(void) const { - return _type; + CallType getCallType() const { + return type_; } /** @@ -115,7 +110,7 @@ class Call: public Recordable { * @param number peer number */ void setPeerNumber(const std::string& number) { - _peerNumber = number; + peerNumber_ = number; } /** @@ -123,8 +118,8 @@ class Call: public Recordable { * not protected by mutex (when created) * @return std::string The peer number */ - const std::string& getPeerNumber() const { - return _peerNumber; + std::string getPeerNumber() const { + return peerNumber_; } /** @@ -133,7 +128,7 @@ class Call: public Recordable { * @param name The peer name */ void setPeerName(const std::string& name) { - _peerName = name; + peerName_ = name; } /** @@ -141,8 +136,8 @@ class Call: public Recordable { * not protected by mutex (when created) * @return std::string The peer name */ - const std::string& getPeerName() const { - return _peerName; + std::string getPeerName() const { + return peerName_; } /** @@ -151,7 +146,7 @@ class Call: public Recordable { * @return std::string The peer display name */ void setDisplayName(const std::string& name) { - _displayName = name; + displayName_ = name; } /** @@ -160,7 +155,7 @@ class Call: public Recordable { * @return std::string The peer name */ const std::string& getDisplayName() const { - return _displayName; + return displayName_; } /** @@ -169,7 +164,7 @@ class Call: public Recordable { * false otherwise */ bool isIncoming() { - return _type == Incoming; + return type_ == Incoming; } /** @@ -199,11 +194,11 @@ class Call: public Recordable { std::string getStateStr(); void setCallConfiguration(Call::CallConfiguration callConfig) { - _callConfig = callConfig; + callConfig_ = callConfig; } - Call::CallConfiguration getCallConfiguration(void) const { - return _callConfig; + Call::CallConfiguration getCallConfiguration() const { + return callConfig_; } /** @@ -211,7 +206,7 @@ class Call: public Recordable { * @param ip The local IP address */ void setLocalIp(const std::string& ip) { - _localIPAddress = ip; + localIPAddress_ = ip; } /** @@ -219,14 +214,14 @@ class Call: public Recordable { * @param port The local audio port */ void setLocalAudioPort(unsigned int port) { - _localAudioPort = port; + localAudioPort_ = port; } /** * Return my IP [mutex protected] * @return std::string The local IP */ - const std::string& getLocalIp(); + std::string getLocalIp(); /** * Return port used locally (for my machine) [mutex protected] @@ -234,57 +229,54 @@ class Call: public Recordable { */ unsigned int getLocalAudioPort(); - std::string getRecFileId(void) const { + std::string getRecFileId() const { return getPeerName(); } - std::string getFileName(void) const { - return _peerNumber; + std::string getFileName() const { + return peerNumber_; } - virtual bool setRecording(void); + virtual bool setRecording(); private: /** Protect every attribute that can be changed by two threads */ - ost::Mutex _callMutex; + ost::Mutex callMutex_; // Informations about call socket / audio /** My IP address */ - std::string _localIPAddress; + std::string localIPAddress_; /** Local audio port, as seen by me. */ - unsigned int _localAudioPort; + unsigned int localAudioPort_; /** Unique ID of the call */ - std::string _id; + std::string id_; /** Unique conference ID, used exclusively in case of a conferece */ - std::string _confID; + std::string confID_; /** Type of the call */ - CallType _type; + CallType type_; /** Disconnected/Progressing/Trying/Ringing/Connected */ - ConnectionState _connectionState; + ConnectionState connectionState_; /** Inactive/Active/Hold/Busy/Refused/Error */ - CallState _callState; + CallState callState_; /** Direct IP-to-IP or classic call */ - CallConfiguration _callConfig; + CallConfiguration callConfig_; /** Name of the peer */ - std::string _peerName; + std::string peerName_; /** Number of the peer */ - std::string _peerNumber; + std::string peerNumber_; /** Display Name */ - std::string _displayName; - - /** File name for his call, should be peer number */ - std::string _filename; + std::string displayName_; }; #endif diff --git a/daemon/src/eventthread.cpp b/daemon/src/eventthread.cpp index ee69f8221a..bb72e8505b 100644 --- a/daemon/src/eventthread.cpp +++ b/daemon/src/eventthread.cpp @@ -33,7 +33,7 @@ /********************************** Voiplink thread *************************************/ EventThread::EventThread(VoIPLink *link) - : Thread(), _link(link) + : Thread(), link_(link) { setCancel(cancelDeferred); } @@ -42,9 +42,9 @@ EventThread::EventThread(VoIPLink *link) /** * Reimplementation of run() */ -void EventThread::run(void) +void EventThread::run() { while (!testCancel()) - _link->getEvent(); + link_->getEvent(); } diff --git a/daemon/src/eventthread.h b/daemon/src/eventthread.h index 2cdbed3e94..b854a37f87 100644 --- a/daemon/src/eventthread.h +++ b/daemon/src/eventthread.h @@ -48,7 +48,7 @@ class EventThread : public ost::Thread { */ EventThread(VoIPLink* link); - ~EventThread(void) { + ~EventThread() { terminate(); } @@ -59,7 +59,7 @@ class EventThread : public ost::Thread { EventThread& operator= (const EventThread& rh); // assignment operator /** VoIPLink is the object being called by getEvents() method */ - VoIPLink* _link; + VoIPLink* link_; }; #endif // __EVENT_THREAD_H__ diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 8014cc2b0e..fcf3ea506d 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -208,6 +208,9 @@ bool ManagerImpl::outgoingCall(const std::string& account_id, std::string to_cleaned(NumberCleaner::clean(to, prefix)); + static const char * const SIP_SCHEME = "sip:"; + static const char * const SIPS_SCHEME = "sips:"; + Call::CallConfiguration callConfig = (to_cleaned.find(SIP_SCHEME) == 0 or to_cleaned.find(SIPS_SCHEME) == 0) ? Call::IPtoIP : Call::Classic; associateConfigToCall(call_id, callConfig); @@ -2890,7 +2893,7 @@ void ManagerImpl::setHookSettings(const std::map<std::string, std::string>& sett bool ManagerImpl::associateConfigToCall(const std::string& callID, Call::CallConfiguration config) { - if (getConfigFromCall(callID) == CallConfigNULL) { // nothing with the same ID + if (getConfigFromCall(callID) == 0) { // nothing with the same ID callConfigMap_[callID] = config; _debug("Manager: Associate call %s with config %d", callID.c_str(), config); return true; @@ -2903,7 +2906,7 @@ Call::CallConfiguration ManagerImpl::getConfigFromCall(const std::string& callID CallConfigMap::const_iterator iter = callConfigMap_.find(callID); if (iter == callConfigMap_.end()) - return (Call::CallConfiguration) CallConfigNULL; + return (Call::CallConfiguration) 0; else return iter->second; } -- GitLab