From f69018fdf7711817416c72c7b65f553505f95a9a Mon Sep 17 00:00:00 2001
From: Simon Morlat
Date: Thu, 6 Dec 2012 17:50:06 +0100
Subject: [PATCH] improve daemon's documentation added
--dump-commands-html-help
---
daemon/commands/help.cc | 2 +-
daemon/commands/msfilter-add-fmtp.cc | 4 ++
daemon/daemon.cc | 58 ++++++++++++++++++++++++++++
daemon/daemon.h | 1 +
4 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/daemon/commands/help.cc b/daemon/commands/help.cc
index e3c44edad..23c08f523 100644
--- a/daemon/commands/help.cc
+++ b/daemon/commands/help.cc
@@ -22,7 +22,7 @@ void HelpCommand::exec(Daemon *app, const char *args) {
if (args==NULL){
for (it = l.begin(); it != l.end(); ++it) {
- ost << (*it)->getHelp() << endl;
+ ost << (*it)->getProto() << endl;
}
}
Response resp;
diff --git a/daemon/commands/msfilter-add-fmtp.cc b/daemon/commands/msfilter-add-fmtp.cc
index c2198fb68..1fd2997ff 100644
--- a/daemon/commands/msfilter-add-fmtp.cc
+++ b/daemon/commands/msfilter-add-fmtp.cc
@@ -27,6 +27,10 @@ void MSFilterAddFmtpCommand::exec(Daemon *app, const char *args) {
app->sendResponse(Response("No Call with such id."));
return;
}
+ if (call->audiostream==NULL || call->audiostream->encoder==NULL){
+ app->sendResponse(Response("This call doesn't have an active audio stream."));
+ return;
+ }
ms_filter_call_method(call->audiostream->encoder, MS_FILTER_ADD_FMTP, (void*) args);
} else if(strcmp(type, "stream") == 0) {
AudioStream *stream = app->findAudioStream(id);
diff --git a/daemon/daemon.cc b/daemon/daemon.cc
index 3daa8d981..f445098a2 100644
--- a/daemon/daemon.cc
+++ b/daemon/daemon.cc
@@ -548,6 +548,59 @@ void Daemon::dumpCommandsHelp() {
}
}
+static string htmlEscape(const string &orig){
+ string ret=orig;
+ size_t pos;
+
+ while(1){
+ pos=ret.find('<');
+ if (pos!=string::npos){
+ ret.erase(pos,1);
+ ret.insert(pos,"<");
+ continue;
+ }
+ pos=ret.find('>');
+ if (pos!=string::npos){
+ ret.erase(pos,1);
+ ret.insert(pos,">");
+ continue;
+ }
+ break;
+ }
+ while(1){
+ pos=ret.find('\n');
+ if (pos!=string::npos){
+ ret.erase(pos,1);
+ ret.insert(pos,"
");
+ continue;
+ }
+ break;
+ }
+ return ret;
+}
+
+void Daemon::dumpCommandsHelpHtml(){
+ cout << endl;
+ cout << ""<List of linphone-daemon commands."<::iterator it = mCommands.begin(); it != mCommands.end(); ++it) {
+ cout<<""<getProto())<<"
"<"<<"Description"<<""<"<getDescription())<<"
"<"<<"Examples"<<""< &examples=(*it)->getExamples();
+ cout<<"";
+ for(list::const_iterator ex_it=examples.begin();ex_it!=examples.end();++ex_it){
+ cout<<""<")<getCommand())<<"
"<getOutput())<<"
"<
";
+ }
+ cout<<"
"<"<]\n"
@@ -565,6 +618,7 @@ static void printHelp() {
"where options are :\n"
"\t--help\t\t\tPrint this notice.\n"
"\t--dump-commands-help\tDump the help of every available commands.\n"
+ "\t--dump-commands-html-help\tDump the help of every available commands.\n"
"\t--pipe \tCreate an unix server socket to receive commands.\n"
"\t--log \t\tSupply a file where the log will be saved\n"
"\t--factory-config \tSupply a readonly linphonerc style config file to start with.\n"
@@ -668,6 +722,10 @@ int main(int argc, char *argv[]) {
Daemon app(NULL, NULL, NULL, NULL, false, false);
app.dumpCommandsHelp();
return 0;
+ }else if (strcmp(argv[i], "--dump-commands-html-help") == 0) {
+ Daemon app(NULL, NULL, NULL, NULL, false, false);
+ app.dumpCommandsHelpHtml();
+ return 0;
} else if (strcmp(argv[i], "--pipe") == 0) {
if (i + 1 >= argc) {
fprintf(stderr, "no pipe name specify after --pipe");
diff --git a/daemon/daemon.h b/daemon/daemon.h
index c55e50f56..10a648485 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -180,6 +180,7 @@ public:
inline int maxProxyId() { return mProxyIds; };
int updateAudioStreamId(AudioStream *audio_stream);
void dumpCommandsHelp();
+ void dumpCommandsHelpHtml();
private:
static void* iterateThread(void *arg);
static void callStateChanged(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState state, const char *msg);