Commit 0105c75e authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #6655: more constness, cleaned up/simplified methods

parent 13a24dfc
......@@ -71,14 +71,13 @@ void ConfigTree::addDefaultValue (const std::pair<std::string, std::string>& tok
}
}
std::string ConfigTree::getDefaultValue (const std::string& key)
std::string ConfigTree::getDefaultValue (const std::string& key) const
{
std::map<std::string, std::string>::iterator it;
std::map<std::string, std::string>::const_iterator it;
it = _defaultValueMap.find (key);
if (it == _defaultValueMap.end()) {
return std::string ("");
}
if (it == _defaultValueMap.end())
return "";
return it->second;
}
......@@ -152,20 +151,19 @@ ConfigTree::addConfigTreeItem (const std::string& section, const ConfigTreeItem
}
std::string
ConfigTree::getConfigTreeItemValue (const std::string& section, const std::string& itemName)
ConfigTree::getConfigTreeItemValue (const std::string& section, const std::string& itemName) const
{
ConfigTreeItem* item = getConfigTreeItem (section, itemName);
const ConfigTreeItem* item = getConfigTreeItem (section, itemName);
if (item != NULL) {
if (item)
return item->getValue();
}
return getDefaultValue (itemName);
}
// throw a ConfigTreeItemException if not found
int
ConfigTree::getConfigTreeItemIntValue (const std::string& section, const std::string& itemName)
ConfigTree::getConfigTreeItemIntValue (const std::string& section, const std::string& itemName) const
{
std::string configItem = getConfigTreeItemValue (section, itemName);
int retval = atoi (configItem.data());
......@@ -174,7 +172,7 @@ ConfigTree::getConfigTreeItemIntValue (const std::string& section, const std::st
}
bool
ConfigTree::getConfigTreeItemBoolValue (const std::string& section, const std::string& itemName)
ConfigTree::getConfigTreeItemBoolValue (const std::string& section, const std::string& itemName) const
{
std::string configItem = getConfigTreeItemValue (section, itemName);
......@@ -186,9 +184,9 @@ ConfigTree::getConfigTreeItemBoolValue (const std::string& section, const std::s
}
bool
ConfigTree::getConfigTreeItemToken (const std::string& section, const std::string& itemName, TokenList& arg)
ConfigTree::getConfigTreeItemToken (const std::string& section, const std::string& itemName, TokenList& arg) const
{
ConfigTreeItem *item = getConfigTreeItem (section, itemName);
const ConfigTreeItem *item = getConfigTreeItem (section, itemName);
if (item) {
arg.clear();
......@@ -206,22 +204,18 @@ ConfigTree::getConfigTreeItemToken (const std::string& section, const std::strin
/**
* Return a ConfigTreeItem or NULL if not found
*/
ConfigTreeItem*
ConfigTree::getConfigTreeItem (const std::string& section, const std::string& itemName)
const ConfigTreeItem*
ConfigTree::getConfigTreeItem (const std::string& section, const std::string& itemName) const
{
SectionMap::iterator iter = _sections.find (section);
SectionMap::const_iterator iter = _sections.find (section);
if (iter == _sections.end()) {
// _error("ConfigTree: Error: Did not found section %s in config tree", section.c_str());
if (iter == _sections.end())
return NULL;
}
ItemMap::iterator iterItem = iter->second->find (itemName);
ItemMap::const_iterator iterItem = iter->second->find (itemName);
if (iterItem == iter->second->end()) {
// _error("ConfigTree: Error: Did not found item %s in config tree", itemName.c_str());
if (iterItem == iter->second->end())
return NULL;
}
return & (iterItem->second);
}
......
......@@ -159,9 +159,9 @@ class ConfigTree
* @return The value of the corresponding item. The default value if the section exists
* but the item doesn't.
*/
std::string getConfigTreeItemValue (const std::string& section, const std::string& itemName);
int getConfigTreeItemIntValue (const std::string& section, const std::string& itemName);
bool getConfigTreeItemBoolValue (const std::string& section, const std::string& itemName);
std::string getConfigTreeItemValue (const std::string& section, const std::string& itemName) const;
int getConfigTreeItemIntValue (const std::string& section, const std::string& itemName) const;
bool getConfigTreeItemBoolValue (const std::string& section, const std::string& itemName) const;
/**
* Flush data to .ini file
......@@ -173,11 +173,11 @@ class ConfigTree
*/
int populateFromFile (const std::string& fileName);
bool getConfigTreeItemToken (const std::string& section, const std::string& itemName, TokenList& arg);
bool getConfigTreeItemToken (const std::string& section, const std::string& itemName, TokenList& arg) const;
private:
std::string getDefaultValue (const std::string& key);
ConfigTreeItem* getConfigTreeItem (const std::string& section, const std::string& itemName);
std::string getDefaultValue (const std::string& key) const;
const ConfigTreeItem* getConfigTreeItem (const std::string& section, const std::string& itemName) const;
/**
* List of sections. Each sections has an ItemList as child
......
This diff is collapsed.
......@@ -484,7 +484,7 @@ class ManagerImpl
* Get account list
* @return std::vector<std::string> A list of accoundIDs
*/
std::vector< std::string > getAccountList();
std::vector< std::string > getAccountList() const;
/**
* Set the account order in the config file
......@@ -495,14 +495,14 @@ class ManagerImpl
* Load the accounts order set by the user from the sflphonedrc config file
* @return std::vector<std::string> A vector containing the account ID's
*/
std::vector<std::string> loadAccountOrder ();
std::vector<std::string> loadAccountOrder () const;
/**
* Retrieve details about a given account
* @param accountID The account identifier
* @return std::map< std::string, std::string > The account details
*/
std::map< std::string, std::string > getAccountDetails (const std::string& accountID);
std::map< std::string, std::string > getAccountDetails (const std::string& accountID) const;
/**
* Retrieve details about a given call
......@@ -515,27 +515,27 @@ class ManagerImpl
* Get call list
* @return std::vector<std::string> A list of call IDs
*/
std::vector< std::string > getCallList (void);
std::vector< std::string > getCallList (void) const;
/**
* Retrieve details about a given call
* @param callID The account identifier
* @return std::map< std::string, std::string > The call details
*/
std::map< std::string, std::string > getConferenceDetails (const std::string& callID);
std::map< std::string, std::string > getConferenceDetails (const std::string& callID) const;
/**
* Get call list
* @return std::vector<std::string> A list of call IDs
*/
std::vector< std::string > getConferenceList (void);
std::vector< std::string > getConferenceList (void) const;
/**
* Get a list of participant to a conference
* @return std::vector<std::string> A list of call IDs
*/
std::vector< std::string > getParticipantList (const std::string& confID);
std::vector< std::string > getParticipantList (const std::string& confID) const;
/**
* Save the details of an existing account, given the account ID
......@@ -604,42 +604,42 @@ class ManagerImpl
* @param name The string description of an audio device
* @return int His index
*/
int getAudioDeviceIndex (const std::string name);
int getAudioDeviceIndex (const std::string &name);
/**
* Get current alsa plugin
* @return std::string The Alsa plugin
*/
std::string getCurrentAudioOutputPlugin (void);
std::string getCurrentAudioOutputPlugin (void) const;
/**
* Get the noise reduction engin state from
* the current audio layer.
*/
std::string getNoiseSuppressState (void);
std::string getNoiseSuppressState (void) const;
/**
* Set the noise reduction engin state in the current
* audio layer.
*/
void setNoiseSuppressState (std::string state);
void setNoiseSuppressState (const std::string &state);
/**
* Get the echo canceller engin state from
* the current audio layer
*/
std::string getEchoCancelState(void);
std::string getEchoCancelState(void) const;
/**
* Set the echo canceller engin state
*/
void setEchoCancelState(std::string state);
void setEchoCancelState(const std::string &state);
int getEchoCancelTailLength(void);
int getEchoCancelTailLength(void) const;
void setEchoCancelTailLength(int);
int getEchoCancelDelay(void);
int getEchoCancelDelay(void) const;
void setEchoCancelDelay(int);
......@@ -648,7 +648,7 @@ class ManagerImpl
* Required format: payloads separated with one slash.
* @return std::string The serializabled string
*/
static std::string serialize (std::vector<std::string> v);
static std::string serialize (const std::vector<std::string> &v);
static std::vector<std::string> unserialize (std::string v);
......@@ -677,7 +677,7 @@ class ManagerImpl
* Get the ringtone
* @return gchar* The file name selected as a ringtone
*/
std::string getRingtoneChoice (const std::string& id);
std::string getRingtoneChoice (const std::string& id) const;
/**
* Set a ringtone
......@@ -689,7 +689,7 @@ class ManagerImpl
* Get the recording path from configuration tree
* @return the string correspoding to the path
*/
std::string getRecordPath (void);
std::string getRecordPath (void) const;
/**
* Set the recoding path in the configuration tree
......@@ -700,7 +700,7 @@ class ManagerImpl
/**
* Get is always recording functionality
*/
bool getIsAlwaysRecording(void);
bool getIsAlwaysRecording(void) const;
/**
* Set is always recording functionality, every calls will then be set in RECORDING mode
......@@ -742,12 +742,7 @@ class ManagerImpl
* Get the maximum number of days to keep in the history
* @return double The number of days
*/
int getHistoryLimit (void);
// void setHistoryEnabled (void);
// std::string getHistoryEnabled (void);
int getHistoryLimit (void) const;
/**
* Configure the start-up option
......@@ -762,41 +757,6 @@ class ManagerImpl
*/
void startHidden (void);
/**
* Configure the popup behaviour
* @return int 1 if it should popup on incoming calls
* 0 if it should never popups
*/
// int popupMode( void );
/**
* Configure the popup behaviour
* When SFLphone is in the system tray, you can configure when it popups
* Never or only on incoming calls
*/
// void switchPopupMode( void );
/**
* Determine whether or not the search bar (history) should be displayed
*/
// int getSearchbar( void );
/**
* Configure the search bar behaviour
*/
// void setSearchbar( void );
/**
* Set the desktop notification level
*/
// void setNotify( void );
/**
* Get the desktop notification level
* @return int The notification level
*/
// int32_t getNotify( void );
/**
* Set the desktop mail notification level
*/
......@@ -806,7 +766,7 @@ class ManagerImpl
/**
* Addressbook configuration
*/
std::map<std::string, int32_t> getAddressbookSettings (void);
std::map<std::string, int32_t> getAddressbookSettings (void) const;
/**
* Addressbook configuration
......@@ -821,12 +781,12 @@ class ManagerImpl
/**
* Addressbook list
*/
std::vector <std::string> getAddressbookList (void);
std::vector <std::string> getAddressbookList (void) const;
/**
* Hook configuration
*/
std::map<std::string, std::string> getHookSettings (void);
std::map<std::string, std::string> getHookSettings (void) const;
/**
* Hook configuration
......@@ -840,7 +800,7 @@ class ManagerImpl
* 0 ALSA
* 1 PULSEAUDIO
*/
int32_t getAudioManager (void);
int32_t getAudioManager (void) const;
/**
* Set the audio manager
......@@ -859,13 +819,13 @@ class ManagerImpl
* Get the desktop mail notification level
* @return int The mail notification level
*/
int32_t getMailNotify (void);
int32_t getMailNotify (void) const;
/**
* Get the list of the active codecs
* @return std::vector< ::std::string > The list of active codecs
*/
std::vector< ::std::string > getActiveCodecList (void);
std::vector< ::std::string > getActiveCodecList (void) const;
/*
* Notify the client that an error occured
......@@ -882,7 +842,7 @@ class ManagerImpl
* @return bool true on success
* false otherwise
*/
bool getConfig (const std::string& section, const std::string& name, TokenList& arg);
bool getConfig (const std::string& section, const std::string& name, TokenList& arg) const;
/**
* Change a specific value in the configuration tree.
......@@ -926,7 +886,7 @@ class ManagerImpl
* @return int The int value
*/
int getConfigInt (const std::string& section, const std::string& name);
int getConfigInt (const std::string& section, const std::string& name) const;
/**
* Get a bool from the configuration tree
......@@ -936,7 +896,7 @@ class ManagerImpl
* @return bool The bool value
*/
bool getConfigBool (const std::string& section, const std::string& name);
bool getConfigBool (const std::string& section, const std::string& name) const;
/**
* Get a string from the configuration tree
......@@ -945,7 +905,7 @@ class ManagerImpl
* @param name The parameter name
* @return sdt::string The string value
*/
std::string getConfigString (const std::string& section, const std::string& name);
std::string getConfigString (const std::string& section, const std::string& name) const;
/**
* Retrieve the soundcards index in the user config file and try to open audio devices
......@@ -1009,7 +969,7 @@ class ManagerImpl
* Write by main thread only
* @return unsigned short The volume value
*/
unsigned short getSpkrVolume (void) {
unsigned short getSpkrVolume (void) const {
return _spkr_volume;
}
......@@ -1027,7 +987,7 @@ class ManagerImpl
* Write by main thread only
* @return unsigned short The volume value
*/
unsigned short getMicVolume (void) {
unsigned short getMicVolume (void) const {
return _mic_volume;
}
......@@ -1065,7 +1025,7 @@ class ManagerImpl
* Get the current call id
* @return std::string The call id or ""
*/
const std::string& getCurrentCallId();
const std::string& getCurrentCallId() const;
/**
* Check if a call is the current one
......@@ -1112,7 +1072,7 @@ class ManagerImpl
/**
* Create config directory in home user and return configuration file path
*/
std::string getConfigFile (void);
std::string getConfigFile (void) const;
/*
* Initialize audiocodec with config setting
......@@ -1243,7 +1203,7 @@ class ManagerImpl
bool associateConfigToCall (const std::string& callID, Call::CallConfiguration config);
Call::CallConfiguration getConfigFromCall (const std::string& callID);
Call::CallConfiguration getConfigFromCall (const std::string& callID) const;
bool removeCallConfig (const std::string& callID);
......@@ -1276,14 +1236,6 @@ class ManagerImpl
*/
MainBuffer _mainBuffer;
/**
* Instant messaging module, resposible to initiate, format, parse,
* send, and receive instant messages.
*/
sfl::InstantMessaging *_imModule;
public:
/** Associate a new std::string to a std::string
......@@ -1319,7 +1271,7 @@ class ManagerImpl
/**
* Return a pointer to the instance of InstantMessaging
*/
sfl::InstantMessaging *getInstantMessageModule (void) {
sfl::InstantMessaging *getInstantMessageModule (void) const {
return _imModule;
}
......@@ -1350,7 +1302,7 @@ class ManagerImpl
* Get a list of serialized history entries
* @return A list of serialized entry
*/
std::vector<std::string> getHistorySerialized (void);
std::vector<std::string> getHistorySerialized (void) const;
/**
* Set a list of serialized history entries
......@@ -1362,7 +1314,7 @@ class ManagerImpl
* @param accountID account ID to get
* @return Account* The account pointer or 0
*/
Account* getAccount (const std::string& accountID);
Account* getAccount (const std::string& accountID) const;
/** Return the std::string from a CallID
* Protected by mutex
......@@ -1376,13 +1328,13 @@ class ManagerImpl
* @param accountID Account ID to get
* @return VoIPLink* The voip link from the account pointer or 0
*/
VoIPLink* getAccountLink (const std::string& accountID="");
VoIPLink* getAccountLink (const std::string& accountID="") const;
std::string getAccountIdFromNameAndServer (const std::string& userName, const std::string& server);
std::string getAccountIdFromNameAndServer (const std::string& userName, const std::string& server) const;
int getLocalIp2IpPort();
int getLocalIp2IpPort() const;
std::string getStunServer (void);
std::string getStunServer (void) const;
void setStunServer (const std::string &server);
int isStunEnabled (void);
......@@ -1416,6 +1368,12 @@ class ManagerImpl
*/
HistoryManager * _history;
/**
* Instant messaging module, resposible to initiate, format, parse,
* send, and receive instant messages.
*/
sfl::InstantMessaging *_imModule;
/**
* Check if the call is a classic call or a direct IP-to-IP call
*/
......
......@@ -157,14 +157,13 @@ void ManagerImpl::restartPJSIP (void)
this->registerCurSIPAccounts ();
}
VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID)
VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID) const
{
if (accountID!="") {
if (not accountID.empty()) {
Account* acc = getAccount (accountID);
if (acc) {
if (acc)
return acc->getVoIPLink();
}
return 0;
} else
......@@ -173,10 +172,6 @@ VoIPLink* ManagerImpl::getAccountLink (const std::string& accountID)
pjsip_regc *getSipRegcFromID (const std::string& id UNUSED)
{
/*SIPAccount *tmp = dynamic_cast<SIPAccount *>getAccount(id);
if(tmp != NULL)
return tmp->getSipRegc();
else*/
return NULL;
}
......
......@@ -450,16 +450,15 @@ ShortcutPreferences::ShortcutPreferences() : _hangup ("")
ShortcutPreferences::~ShortcutPreferences() {}
std::map<std::string, std::string> ShortcutPreferences::getShortcuts()
std::map<std::string, std::string> ShortcutPreferences::getShortcuts() const
{
std::map<std::string, std::string> shortcutsMap;
shortcutsMap.insert (std::pair<std::string, std::string> (hangupShortKey, _hangup));
shortcutsMap.insert (std::pair<std::string, std::string> (pickupShortKey, _pickup));
shortcutsMap.insert (std::pair<std::string, std::string> (popupShortKey, _popup));
shortcutsMap.insert (std::pair<std::string, std::string> (toggleHoldShortKey, _toggleHold));
shortcutsMap.insert (std::pair<std::string, std::string> (togglePickupHangupShortKey, _togglePickupHangup));
shortcutsMap[hangupShortKey] = _hangup;
shortcutsMap[pickupShortKey] = _pickup;
shortcutsMap[popupShortKey] = _popup;
shortcutsMap[toggleHoldShortKey] = _toggleHold;
shortcutsMap[togglePickupHangupShortKey] = _togglePickupHangup;
return shortcutsMap;
}
......@@ -472,15 +471,6 @@ void ShortcutPreferences::setShortcuts (std::map<std::string, std::string> map)
_popup = map[popupShortKey];
_toggleHold = map[toggleHoldShortKey];
_togglePickupHangup = map[togglePickupHangupShortKey];
/*
for (int i = 0; i < (int)shortcutsKeys.size(); i++) {
std::string key = shortcutsKeys.at(i);
std::string val = map[key];
if (val != "")
Manager::instance().setConfig("Shortcuts", key, val);
}
*/
}
......
......@@ -115,77 +115,77 @@ class Preferences : public Serializable
virtual void unserialize (Conf::MappingNode *map);
std::string getAccountOrder (void) {
std::string getAccountOrder (void) const {
return _accountOrder;
}
void setAccountOrder (std::string ord) {
_accountOrder = ord;
}
int getAudioApi (void) {
int getAudioApi (void) const {
return _audioApi;
}
void setAudioApi (int api) {
_audioApi = api;
}
int getHistoryLimit (void) {
int getHistoryLimit (void) const {
return _historyLimit;
}
void setHistoryLimit (int lim) {
_historyLimit = lim;
}
int getHistoryMaxCalls (void) {
int getHistoryMaxCalls (void) const {
return _historyMaxCalls;
}
void setHistoryMaxCalls (int max) {
_historyMaxCalls = max;
}
bool getNotifyMails (void) {
bool getNotifyMails (void) const {
return _notifyMails;