Skip to content
Snippets Groups Projects
Commit 14411841 authored by yanmorin's avatar yanmorin
Browse files

list countrytones Implementation
encoding of string token
fix for getevents-end sequence-id bug
parent 7762581d
No related branches found
No related tags found
No related merge requests found
...@@ -340,7 +340,7 @@ AudioRtpRTX::run (void) { ...@@ -340,7 +340,7 @@ AudioRtpRTX::run (void) {
} }
while (!testCancel() && _ca->enable_audio != -1) { while (!testCancel() && _ca->enable_audio != -1) {
micVolume = manager.getMicroVolume(); micVolume = manager.getMicVolume();
spkrVolume = manager.getSpkrVolume(); spkrVolume = manager.getSpkrVolume();
//////////////////////////// ////////////////////////////
......
...@@ -252,3 +252,28 @@ GuiFramework::getConfigList(const std::string& sequenceId, const std::string& na ...@@ -252,3 +252,28 @@ GuiFramework::getConfigList(const std::string& sequenceId, const std::string& na
return Manager::instance().getConfigList(sequenceId, name); return Manager::instance().getConfigList(sequenceId, name);
} }
bool
GuiFramework::setSpkrVolume(int volume)
{
Manager::instance().setSpkrVolume(volume);
return true;
}
bool
GuiFramework::setMicVolume(int volume)
{
Manager::instance().setMicVolume(volume);
return true;
}
int
GuiFramework::getSpkrVolume()
{
return Manager::instance().getSpkrVolume();
}
int
GuiFramework::getMicVolume()
{
return Manager::instance().getMicVolume();
}
...@@ -90,6 +90,10 @@ public: ...@@ -90,6 +90,10 @@ public:
bool getConfig(const std::string& section, const std::string& name, TokenList& arg); bool getConfig(const std::string& section, const std::string& name, TokenList& arg);
bool setConfig(const std::string& section, const std::string& name, const std::string& value); bool setConfig(const std::string& section, const std::string& name, const std::string& value);
bool getConfigList(const std::string& sequenceId, const std::string& name); bool getConfigList(const std::string& sequenceId, const std::string& name);
bool setSpkrVolume(int volume);
bool setMicVolume(int volume);
int getSpkrVolume();
int getMicVolume();
// Observer methods // Observer methods
virtual void update() {} virtual void update() {}
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "argtokenizer.h" #include "argtokenizer.h"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cc++/url.h>
#include <cstring>
TokenList TokenList
ArgTokenizer::tokenize(const std::string& str) { ArgTokenizer::tokenize(const std::string& str) {
...@@ -28,8 +30,11 @@ ArgTokenizer::tokenize(const std::string& str) { ...@@ -28,8 +30,11 @@ ArgTokenizer::tokenize(const std::string& str) {
TokenList args; TokenList args;
while(s.good()) { while(s.good()) {
s >> output; s >> output;
//TODO: add urlDecode here char *tmp = new char[output.length()+1];
args.push_back(output); strcpy(tmp, output.c_str());
ost::urlDecode(tmp, NULL);
args.push_back(tmp);
delete[] tmp;
} }
return args; return args;
} }
...@@ -112,12 +112,29 @@ bool ...@@ -112,12 +112,29 @@ bool
GUIServerImpl::getEvents(const std::string& sequenceId) GUIServerImpl::getEvents(const std::string& sequenceId)
{ {
_getEventsSequenceId=sequenceId; _getEventsSequenceId=sequenceId;
TokenList tk;
std::ostringstream percentSpkr;
// 021 <CSeq> <percentage of speaker volume> Speaker volume changed.
percentSpkr << GuiFramework::getSpkrVolume();
tk.push_back(percentSpkr.str());
tk.push_back("Speaker volume changed");
_requestManager.sendResponse(ResponseMessage("021", sequenceId,tk));
// 022 <CSeq> <percentage of microphone volume> Microphone volume changed.
tk.clear();
std::ostringstream percentMic;
percentMic << GuiFramework::getMicVolume();
tk.push_back(percentMic.str());
tk.push_back("Microphone volume changed");
_requestManager.sendResponse(ResponseMessage("022", sequenceId,tk));
return true; return true;
} }
bool bool
GUIServerImpl::sendGetEventsEnd(const std::string& sequenceId) GUIServerImpl::sendGetEventsEnd()
{ {
_requestManager.sendResponse(ResponseMessage("202", sequenceId, _requestManager.sendResponse(ResponseMessage("202", _getEventsSequenceId,
"getcallstatus request stopped me")); "getcallstatus request stopped me"));
return true; return true;
} }
......
...@@ -65,7 +65,7 @@ arg); ...@@ -65,7 +65,7 @@ arg);
void callFailure(short id); void callFailure(short id);
bool getEvents(const std::string& sequenceId); bool getEvents(const std::string& sequenceId);
bool sendGetEventsEnd(const std::string& sequenceId); bool sendGetEventsEnd();
bool outgoingCall (const std::string& seq, bool outgoingCall (const std::string& seq,
const std::string& callid, const std::string& callid,
......
...@@ -63,7 +63,7 @@ RequestZeroconfEvent::update() ...@@ -63,7 +63,7 @@ RequestZeroconfEvent::update()
ResponseMessage ResponseMessage
RequestCallStatus::execute() RequestCallStatus::execute()
{ {
GUIServer::instance().sendGetEventsEnd(_sequenceId); GUIServer::instance().sendGetEventsEnd();
TokenList tk; TokenList tk;
tk.push_back("OK"); tk.push_back("OK");
std::string code = "205"; std::string code = "205";
...@@ -185,3 +185,56 @@ RequestList::execute() ...@@ -185,3 +185,56 @@ RequestList::execute()
return message("500","Server Error"); return message("500","Server Error");
} }
} }
RequestVolumeSpkr::RequestVolumeSpkr(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList)
{
TokenList::iterator iter = _argList.begin();
bool error = true;
if (iter != _argList.end()) {
_percent = atoi(iter->c_str());
if (_percent >= 0 && _percent <= 100) {
_argList.pop_front();
error = false;
}
}
if (error) {
throw RequestConstructorException();
}
}
ResponseMessage
RequestVolumeSpkr::execute()
{
if (GUIServer::instance().setSpkrVolume(_percent)) {
return message("200", "OK");
} else {
return message("500","Server Error");
}
}
RequestVolumeMic::RequestVolumeMic(const std::string &sequenceId, const TokenList& argList) : RequestGlobal(sequenceId,argList)
{
TokenList::iterator iter = _argList.begin();
bool error = true;
if (iter != _argList.end()) {
_percent = atoi(iter->c_str());
if (_percent >= 0 && _percent <= 100) {
_argList.pop_front();
error = false;
}
}
if (error) {
throw RequestConstructorException();
}
}
ResponseMessage
RequestVolumeMic::execute()
{
if (GUIServer::instance().setMicVolume(_percent)) {
return message("200", "OK");
} else {
return message("500","Server Error");
}
}
...@@ -94,4 +94,20 @@ private: ...@@ -94,4 +94,20 @@ private:
std::string _name; std::string _name;
}; };
class RequestVolumeSpkr : public RequestGlobal {
public:
RequestVolumeSpkr(const std::string &sequenceId, const TokenList& argList);
ResponseMessage execute();
private:
int _percent;
};
class RequestVolumeMic : public RequestGlobal {
public:
RequestVolumeMic(const std::string &sequenceId, const TokenList& argList);
ResponseMessage execute();
private:
int _percent;
};
#endif // __REQUESTCONFIG_H__ #endif // __REQUESTCONFIG_H__
...@@ -123,4 +123,6 @@ RequestFactory::registerAll() { ...@@ -123,4 +123,6 @@ RequestFactory::registerAll() {
registerRequest<RequestConfigSet> ("configset"); registerRequest<RequestConfigSet> ("configset");
registerRequest<RequestConfigSave> ("configsave"); registerRequest<RequestConfigSave> ("configsave");
registerRequest<RequestList> ("list"); registerRequest<RequestList> ("list");
registerRequest<RequestVolumeSpkr> ("setspkrvolume");
registerRequest<RequestVolumeMic> ("setmicvolume");
} }
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include "responsemessage.h" #include "responsemessage.h"
#include <cc++/url.h>
/** /**
* Used by isFinal() to check for the first digit * Used by isFinal() to check for the first digit
...@@ -46,8 +47,14 @@ ResponseMessage::ResponseMessage(const std::string& code, ...@@ -46,8 +47,14 @@ ResponseMessage::ResponseMessage(const std::string& code,
// add space between each // add space between each
while(iter!=arg.end()) { while(iter!=arg.end()) {
_message.append(" "); _message.append(" ");
// TODO: encode string here int len = iter->length();
_message.append(*iter); if (len) {
char *tmp = new char[len*3+2];
ost::urlEncode(iter->c_str(), tmp, len*3+2);
// we don't have to put a '\0' right?
_message.append(tmp);
delete [] tmp;
}
iter++; iter++;
} }
} }
......
...@@ -563,6 +563,9 @@ ManagerImpl::refuseCall (short id) ...@@ -563,6 +563,9 @@ ManagerImpl::refuseCall (short id)
int int
ManagerImpl::saveConfig (void) ManagerImpl::saveConfig (void)
{ {
setConfig(AUDIO, VOLUME_SPKR, getSpkrVolume());
setConfig(AUDIO, VOLUME_MICRO, getMicVolume());
return (_config.saveConfigTree(_path.data()) ? 1 : 0); return (_config.saveConfigTree(_path.data()) ? 1 : 0);
} }
...@@ -1303,7 +1306,7 @@ void ...@@ -1303,7 +1306,7 @@ void
ManagerImpl::initVolume() ManagerImpl::initVolume()
{ {
setSpkrVolume(getConfigInt(AUDIO, VOLUME_SPKR)); setSpkrVolume(getConfigInt(AUDIO, VOLUME_SPKR));
setMicroVolume(getConfigInt(AUDIO, VOLUME_MICRO)); setMicVolume(getConfigInt(AUDIO, VOLUME_MICRO));
} }
/** /**
...@@ -1510,8 +1513,7 @@ ManagerImpl::setConfig(const std::string& section, const std::string& name, cons ...@@ -1510,8 +1513,7 @@ ManagerImpl::setConfig(const std::string& section, const std::string& name, cons
* Main Thread * Main Thread
*/ */
bool bool
ManagerImpl::setConfig(const std::string& section, const std::string& name, ManagerImpl::setConfig(const std::string& section, const std::string& name, int value)
int value)
{ {
std::ostringstream valueStream; std::ostringstream valueStream;
valueStream << value; valueStream << value;
...@@ -1548,10 +1550,8 @@ ManagerImpl::getConfigList(const std::string& sequenceId, const std::string& nam ...@@ -1548,10 +1550,8 @@ ManagerImpl::getConfigList(const std::string& sequenceId, const std::string& nam
getDirListing(sequenceId, path, &nbFile); getDirListing(sequenceId, path, &nbFile);
} else if (name=="audiodevice") { } else if (name=="audiodevice") {
returnValue = getAudioDeviceList(sequenceId); returnValue = getAudioDeviceList(sequenceId);
} else if (name=="") { } else if (name=="countrytones") {
returnValue = true; returnValue = getCountryTones(sequenceId);
} else if (name=="") {
returnValue = true;
} }
return returnValue; return returnValue;
} }
...@@ -1582,6 +1582,29 @@ ManagerImpl::getAudioDeviceList(const std::string& sequenceId) ...@@ -1582,6 +1582,29 @@ ManagerImpl::getAudioDeviceList(const std::string& sequenceId)
return true; return true;
} }
bool
ManagerImpl::getCountryTones(const std::string& sequenceId)
{
// see ToneGenerator for the list...
sendCountryTone(sequenceId, 1, "North America");
sendCountryTone(sequenceId, 2, "France");
sendCountryTone(sequenceId, 3, "Australia");
sendCountryTone(sequenceId, 4, "United Kingdom");
sendCountryTone(sequenceId, 5, "Spain");
sendCountryTone(sequenceId, 6, "Italy");
sendCountryTone(sequenceId, 7, "Japan");
return true;
}
void
ManagerImpl::sendCountryTone(const std::string& sequenceId, int index, const std::string& name) {
TokenList tk;
std::ostringstream str; str << index; tk.push_back(str.str());
tk.push_back(name);
_gui->sendMessage("100", sequenceId, tk);
}
/** /**
* User action : main thread * User action : main thread
*/ */
......
...@@ -243,8 +243,8 @@ name); ...@@ -243,8 +243,8 @@ name);
*/ */
inline int getSpkrVolume (void) { ost::MutexLock m(_mutex); return _spkr_volume; } inline int getSpkrVolume (void) { ost::MutexLock m(_mutex); return _spkr_volume; }
inline void setSpkrVolume (int spkr_vol) { ost::MutexLock m(_mutex); _spkr_volume = spkr_vol; } inline void setSpkrVolume (int spkr_vol) { ost::MutexLock m(_mutex); _spkr_volume = spkr_vol; }
inline int getMicroVolume (void) { ost::MutexLock m(_mutex); return _mic_volume; } inline int getMicVolume (void) { ost::MutexLock m(_mutex); return _mic_volume; }
inline void setMicroVolume (int mic_vol) { ost::MutexLock m(_mutex); _mic_volume = _mic_volume_before_mute = mic_vol; } inline void setMicVolume (int mic_vol) { ost::MutexLock m(_mutex); _mic_volume = _mic_volume_before_mute = mic_vol; }
/* /*
* Manage information about firewall * Manage information about firewall
...@@ -322,6 +322,9 @@ private: ...@@ -322,6 +322,9 @@ private:
bool getDirListing(const std::string& sequenceId, const std::string& path, int *nbFile); bool getDirListing(const std::string& sequenceId, const std::string& path, int *nbFile);
bool getAudioDeviceList(const std::string& sequenceId); bool getAudioDeviceList(const std::string& sequenceId);
Conf::ConfigTree _config; Conf::ConfigTree _config;
bool getCountryTones(const std::string& sequenceId);
void sendCountryTone(const std::string& sequenceId, int index, const std::string& name);
/* /*
* Play one tone * Play one tone
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment