Commit e44b0a5f authored by Alexandre Savard's avatar Alexandre Savard

[#2841] Add ringtone path and ringtone enabled to account

parent e27080fc
......@@ -40,6 +40,8 @@ Account::Account (const AccountID& accountID, std::string type) :
, _type (type)
, _codecOrder ()
, _codecStr("")
, _ringtonePath("/usr/share/sflphone/ringtones/konga.ul")
, _ringtoneEnabled(true)
, _displayName("")
, _useragent("SFLphone")
{
......
......@@ -259,9 +259,15 @@ class Account : public Serializable{
* Accessor to data structures
* @return CodecOrder& The list that reflects the user's choice
*/
inline CodecOrder& getActiveCodecs() { return _codecOrder; }
inline CodecOrder& getActiveCodecs(void) { return _codecOrder; }
void setActiveCodecs (const std::vector <std::string>& list);
inline std::string getRingtonePath(void) { return _ringtonePath; }
inline void setRingtonePath(std::string path) { _ringtonePath = path; }
inline bool getRingtoneEnabled(void) { return _ringtoneEnabled; }
inline void setRingtoneEnabled(bool enabl) { _ringtoneEnabled = enabl; }
inline std::string getDisplayName(void) { return _displayName; }
inline void setDisplayName(std::string name) { _displayName = name; }
......@@ -344,9 +350,24 @@ class Account : public Serializable{
*/
std::string _codecStr;
// Display Name that can be used in SIP URI.
/**
* Ringtone .au file used for this account
*/
std::string _ringtonePath;
/**
* Play ringtone when receiving a call
*/
bool _ringtoneEnabled;
/**
* Display name when calling
*/
std::string _displayName;
/**
* Useragent used for registration
*/
std::string _useragent;
};
......
......@@ -2361,8 +2361,17 @@ void ManagerImpl::ringtoneEnabled (void) {
}
std::string ManagerImpl::getRingtoneChoice (void) {
// we need the absolute path
std::string tone_name = audioPreference.getRingchoice();
// retreive specified account id
Account *account = getAccount(IP2IP_PROFILE);
if(!account) {
_warn("Manager: Warning: Not a valid account ID for ringone choice");
return std::string("");
}
// we need the absolute path
std::string tone_name = account->getRingtonePath();
std::string tone_path;
if (tone_name.find(DIR_SEPARATOR_CH) == std::string::npos) {
......@@ -2374,14 +2383,23 @@ std::string ManagerImpl::getRingtoneChoice (void) {
tone_path = tone_name;
}
_debug ("%s", tone_path.c_str());
_debug ("Manager: get ringtone path %s", tone_path.c_str());
return tone_path;
}
void ManagerImpl::setRingtoneChoice (const std::string& tone) {
// retreive specified account id
Account *account = getAccount(IP2IP_PROFILE);
if(!account) {
_warn("Manager: Warning: Not a valid account ID for ringtone choice");
return;
}
// we save the absolute path
audioPreference.setRingchoice(tone);
account->setRingtonePath(tone);
}
std::string ManagerImpl::getRecordPath (void) {
......@@ -2389,7 +2407,7 @@ std::string ManagerImpl::getRecordPath (void) {
}
void ManagerImpl::setRecordPath (const std::string& recPath) {
_debug ("ManagerImpl::setRecordPath(%s)! ", recPath.c_str());
_debug ("Manager: Set record path %s", recPath.c_str());
audioPreference.setRecordpath(recPath);
}
......@@ -3952,3 +3970,4 @@ std::vector<std::string> ManagerImpl::getParticipantList (
return v;
}
......@@ -31,13 +31,14 @@
#include "preferences.h"
#include <sstream>
#include "global.h"
#include "user_cfg.h"
Preferences::Preferences() : _accountOrder("")
, _audioApi(0)
, _historyLimit(30)
, _historyMaxCalls(20)
, _notifyMails(false)
, _zoneToneChoice("North America") // DFT_ZONE
, _zoneToneChoice(DFT_ZONE) // DFT_ZONE
, _registrationExpire(180)
, _ringtoneEnabled(true) // CONFIG_RINGTONE
, _portNum(5060)
......@@ -131,10 +132,10 @@ void Preferences::unserialize(Conf::MappingNode *map)
VoipPreference::VoipPreference() : _playDtmf(true)
, _playTones(true)
, _pulseLength(250)// DFT_PULSE_LENGTH_STR
, _pulseLength(atoi(DFT_PULSE_LENGTH_STR))// DFT_PULSE_LENGTH_STR
, _sendDtmfAs(0)
, _symmetricRtp(true)
, _zidFile("zidFile")// ZRTP_ZID_FILENAME
, _zidFile(ZRTP_ZIDFILE)// ZRTP_ZID_FILENAME
{
}
......@@ -314,10 +315,10 @@ void HookPreference::unserialize(Conf::MappingNode *map)
AudioPreference::AudioPreference() : _cardin(0) // ALSA_DFT_CARD
, _cardout(0) // ALSA_DFT_CARD
, _cardring(0) // ALSA_DFT_CARD
, _framesize(20) // DFT_FRAME_SIZE
AudioPreference::AudioPreference() : _cardin(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD
, _cardout(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD
, _cardring(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD
, _framesize(atoi(DFT_FRAME_SIZE)) // DFT_FRAME_SIZE
, _plugin("default") // PCM_DEFAULT
, _smplrate(44100) // DFT_SAMPLE_RATE
, _devicePlayback("")
......@@ -325,8 +326,8 @@ AudioPreference::AudioPreference() : _cardin(0) // ALSA_DFT_CARD
, _deviceRingtone("")
, _recordpath("") // DFT_RECORD_PATH
, _ringchoice("/usr/share/sflphone/ringtones/konga.ul") //DFT_RINGTONE
, _volumemic(100) // DFT_VOL_SPKR_STR
, _volumespkr(100) // DFT_VOL_MICRO_STR
, _volumemic(atoi(DFT_VOL_SPKR_STR)) // DFT_VOL_SPKR_STR
, _volumespkr(atoi(DFT_VOL_MICRO_STR)) // DFT_VOL_MICRO_STR
{
}
......
......@@ -72,7 +72,7 @@ const Conf::Key sipEnabledKey("sipEnabled"); //: false
const Conf::Key urlCommandKey("urlCommand"); //: x-www-browser
const Conf::Key urlSipFieldKey("urlSipField"); //: X-sflphone-url
// audio preferences
const Conf::Key alsamapKey("alsa");
const Conf::Key pulsemapKey("pulse");
const Conf::Key cardinKey("cardin");// : 0
......
......@@ -84,7 +84,7 @@
#define IP2IP_PROFILE "IP2IP"
#define SIGNALISATION "VoIPLink" /** Section Signalisation */
#define ZRTP_ZIDFILE "ZRTP.zidFile" /** The filename used for storing ZIDs */
#define ZRTP_ZIDFILE "zidFile" /** The filename used for storing ZIDs */
#define PLAY_DTMF "DTMF.playDtmf" /** Whether or not should play dtmf */
#define PLAY_TONES "DTMF.playTones" /** Whether or not should play tones */
#define PULSE_LENGTH "DTMF.pulseLength" /** Length of the DTMF in millisecond */
......
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