From a2691090813151dbd155cce9de6e190afd9f0c57 Mon Sep 17 00:00:00 2001 From: yanmorin <yanmorin> Date: Tue, 18 Oct 2005 13:23:41 +0000 Subject: [PATCH] Fixes for check inside global ringtones directory if the preference don't have a path Remove warning inside request.h Add two constants for directory seperator inside user_cfg --- src/audio/tonegenerator.cpp | 10 +++++----- src/audio/tonegenerator.h | 6 +++--- src/gui/server/request.h | 4 ++-- src/managerimpl.cpp | 21 +++++++++++++-------- src/user_cfg.h | 11 ++++------- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/audio/tonegenerator.cpp b/src/audio/tonegenerator.cpp index 615efc6fe8..1c116b9946 100644 --- a/src/audio/tonegenerator.cpp +++ b/src/audio/tonegenerator.cpp @@ -39,7 +39,7 @@ int AMPLITUDE = 32767; /////////////////////////////////////////////////////////////////////////////// ToneThread::ToneThread (int16 *buf, int size) : ost::Thread () { this->buffer = buf; - this->size = size; + this->_size = size; // channels is 2 (global.h) this->buf_ctrl_vol = new int16[size*CHANNELS]; } @@ -60,13 +60,13 @@ ToneThread::run (void) { bool started = false; // How long do 'size' samples play ? - unsigned int play_time = (size * 1000) / SAMPLING_RATE - 10; + unsigned int play_time = (_size * 1000) / SAMPLING_RATE - 10; ManagerImpl& manager = Manager::instance(); manager.getAudioDriver()->flushMain(); // this loop can be outside the stream, since we put the volume inside the ringbuffer - for (int j = 0; j < size; j++) { + for (int j = 0; j < _size; j++) { k = j<<1; // channels is 2 (global.h) // split in two buf_ctrl_vol[k] = buf_ctrl_vol[k+1] = buffer[j]; @@ -81,8 +81,8 @@ ToneThread::run (void) { // int16 are the buf_ctrl_vol // unsigned char are the sample_ptr inside ringbuffer - int size_in_char = size * 2 * (sizeof(int16)/sizeof(unsigned char)); - _debug(" size : %d\t size_in_char : %d\n", size, size_in_char); + int size_in_char = _size * 2 * (sizeof(int16)/sizeof(unsigned char)); + _debug(" size : %d\t size_in_char : %d\n", _size, size_in_char); while (!testCancel()) { manager.getAudioDriver()->putMain(buf_ctrl_vol, size_in_char); diff --git a/src/audio/tonegenerator.h b/src/audio/tonegenerator.h index 4e4f0158c4..dd9ae6c54f 100644 --- a/src/audio/tonegenerator.h +++ b/src/audio/tonegenerator.h @@ -56,9 +56,9 @@ public: virtual void run (); private: - int16* buffer; - int16* buf_ctrl_vol; - int size; + int16* buffer; + int16* buf_ctrl_vol; + int _size; }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/gui/server/request.h b/src/gui/server/request.h index 5ad2f89470..37c5491516 100644 --- a/src/gui/server/request.h +++ b/src/gui/server/request.h @@ -41,8 +41,8 @@ public: Request(const std::string &sequenceId, const TokenList& argList) : _sequenceId(sequenceId), _argList(argList) {} virtual ~Request() {} virtual ResponseMessage execute() = 0; - ResponseMessage message(const std::string &code, const std::string &message) { - ResponseMessage response(code, _sequenceId, message); + ResponseMessage message(const std::string &code, const std::string &aMessage) { + ResponseMessage response(code, _sequenceId, aMessage); return response; } ResponseMessage message(const std::string &code, TokenList& arg) { diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp index 45bbce69f9..12a384f521 100644 --- a/src/managerimpl.cpp +++ b/src/managerimpl.cpp @@ -449,10 +449,9 @@ ManagerImpl::registerVoIPLink (void) int returnValue = 0; if ( !useStun() ) { if (_voIPLinkVector.at(DFT_VOIP_LINK)->setRegister() >= 0) { - returnValue = true; + returnValue = 1; _registerState = REGISTERED; } else { - _debug("ManagerImpl::registerVoIPLink: Registration failed\n"); _registerState = FAILED; } } else { @@ -890,7 +889,13 @@ ManagerImpl::ringtone() if (isDriverLoaded()) { _toneMutex.enterMutex(); _toneType = ZT_TONE_FILE; - int play = _tone->playRingtone(getConfigString(AUDIO, RING_CHOICE).c_str()); + std::string ringchoice = getConfigString(AUDIO, RING_CHOICE); + // if there is no / inside the path + if ( ringchoice.find(DIR_SEPARATOR_CH) == std::string::npos ) { + // check inside global share directory + ringchoice = std::string(PROGSHAREDIR) + DIR_SEPARATOR_STR + RINGDIR + DIR_SEPARATOR_STR + ringchoice; + } + int play = _tone->playRingtone(ringchoice.c_str()); _toneMutex.leaveMutex(); if (play!=1) { ringback(); @@ -997,7 +1002,7 @@ ManagerImpl::generateNewCallId (void) */ int ManagerImpl::createSettingsPath (void) { - _path = std::string(HOMEDIR) + "/." + PROGDIR; + _path = std::string(HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR; if (mkdir (_path.data(), 0755) != 0) { // If directory creation failed @@ -1008,7 +1013,7 @@ ManagerImpl::createSettingsPath (void) { } // Load user's configuration - _path = _path + "/" + PROGNAME + "rc"; + _path = _path + DIR_SEPARATOR_STR + PROGNAME + "rc"; return _config.populateFromFile(_path); } @@ -1379,11 +1384,11 @@ ManagerImpl::getConfigList(const std::string& sequenceId, const std::string& nam } returnValue = true; } else if (name=="ringtones") { - std::string path = std::string(PROGSHAREDIR) + "/" + RINGDIR; + std::string path = std::string(PROGSHAREDIR) + DIR_SEPARATOR_STR + RINGDIR; int nbFile = 0; returnValue = getDirListing(sequenceId, path, &nbFile); - path = std::string(HOMEDIR) + "/." + PROGDIR + "/" + RINGDIR; + path = std::string(HOMEDIR) + DIR_SEPARATOR_STR + "." + PROGDIR + DIR_SEPARATOR_STR + RINGDIR; getDirListing(sequenceId, path, &nbFile); } else if (name=="audiodevice") { returnValue = getAudioDeviceList(sequenceId); @@ -1455,7 +1460,7 @@ ManagerImpl::getDirListing(const std::string& sequenceId, const std::string& pat std::string filePathName; while ( (cFileName=dir++) != NULL ) { fileName = cFileName; - filePathName = path + "/" + cFileName; + filePathName = path + DIR_SEPARATOR_STR + cFileName; if (fileName.length() && fileName[0]!='.' && !ost::isDir(filePathName.c_str())) { tk.clear(); std::ostringstream str; diff --git a/src/user_cfg.h b/src/user_cfg.h index 6f04c2f9e2..5953613874 100644 --- a/src/user_cfg.h +++ b/src/user_cfg.h @@ -21,13 +21,15 @@ #ifndef __USER_CFG_H__ #define __USER_CFG_H__ -#define GUI_QT - #include <stdlib.h> // Home directory #define HOMEDIR (getenv ("HOME")) +// TODO: change for a \ in Windows Environment +#define DIR_SEPARATOR_CH '/' +#define DIR_SEPARATOR_STR "/" + // Main menu #define SIGNALISATION "VoIPLink" #define AUDIO "Audio" @@ -64,11 +66,6 @@ // speakers and volume 0 to 100 #define VOLUME_SPKR "Volume.speakers" #define VOLUME_MICRO "Volume.micro" - -#define VOLUME_SPKR_X "Volume.speakers_x" -#define VOLUME_SPKR_Y "Volume.speakers_y" -#define VOLUME_MICRO_X "Volume.micro_x" -#define VOLUME_MICRO_Y "Volume.micro_y" #define SKIN_CHOICE "Themes.skinChoice" #define CONFIRM_QUIT "Options.confirmQuit" #define ZONE_TONE "Options.zoneToneChoice" -- GitLab