/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2531 by schoenebeck, Wed Mar 5 00:02:21 2014 UTC revision 2534 by schoenebeck, Sun Mar 9 21:34:03 2014 UTC
# Line 716  extern yyparse_param_t* GetCurrentYaccSe Line 716  extern yyparse_param_t* GetCurrentYaccSe
716  }  }
717    
718  /**  /**
719     * Generate the relevant LSCP documentation reference section if necessary.
720     * The documentation section for the currently active command on the LSCP
721     * shell's command line will be encoded in a special format, specifically for
722     * the LSCP shell application.
723     *
724     * @param line - current LSCP command line
725     * @param param - reentrant Bison parser parameters
726     *
727     * @return encoded reference string or empty string if nothing shall be sent
728     *         to LSCP shell (client) at this point
729     */
730    String LSCPServer::generateLSCPDocReply(const String& line, yyparse_param_t* param) {
731        String result;
732        lscp_ref_entry_t* ref = lscp_reference_for_command(line.c_str());
733        // Pointer comparison works here, since the function above always
734        // returns the same constant pointer for the respective LSCP
735        // command ... Only send the LSCP reference section to the client if
736        // another LSCP reference section became relevant now:
737        if (ref != param->pLSCPDocRef) {
738            param->pLSCPDocRef = ref;
739            if (ref) { // send a new LSCP doc section to client ...
740                result += "SHD:" + ToString(LSCP_SHD_MATCH) + ":" + String(ref->name) + "\n";
741                result += String(ref->section) + "\n";
742                result += "."; // dot line marks the end of the text for client
743            } else { // inform client that no LSCP doc section matches right now ...
744                result = "SHD:" + ToString(LSCP_SHD_NO_MATCH);
745            }
746        }
747        dmsg(4,("LSCP doc reply -> '%s'\n", result.c_str()));
748        return result;
749    }
750    
751    /**
752   * Will be called to try to read the command from the socket   * Will be called to try to read the command from the socket
753   * If command is read, it will return true. Otherwise false is returned.   * If command is read, it will return true. Otherwise false is returned.
754   * In any case the received portion (complete or incomplete) is saved into bufferedCommand map.   * In any case the received portion (complete or incomplete) is saved into bufferedCommand map.
# Line 750  bool LSCPServer::GetLSCPCommand( std::ve Line 783  bool LSCPServer::GetLSCPCommand( std::ve
783                                  String s = lscpParserProcessShellInteraction(bufferedCommands[socket], &(*iter), false);                                  String s = lscpParserProcessShellInteraction(bufferedCommands[socket], &(*iter), false);
784                                  if (!s.empty() && (*iter).bShellInteract) AnswerClient(s + "\n");                                  if (!s.empty() && (*iter).bShellInteract) AnswerClient(s + "\n");
785                          }                          }
786                            // if other side is LSCP shell application, send the relevant LSCP
787                            // documentation section of the current command line (if necessary)
788                            if ((*iter).bShellSendLSCPDoc && (*iter).bShellInteract) {
789                                    String s = generateLSCPDocReply(bufferedCommands[socket], &(*iter));
790                                    if (!s.empty()) AnswerClient(s + "\n");
791                            }
792                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket));                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket));
793                          bufferedCommands[socket] += "\r\n";                          bufferedCommands[socket] += "\r\n";
794                          return true; //Complete command was read                          return true; //Complete command was read
# Line 780  bool LSCPServer::GetLSCPCommand( std::ve Line 818  bool LSCPServer::GetLSCPCommand( std::ve
818                          if (!s.empty() && (*iter).bShellInteract && i == input.size() - 1)                          if (!s.empty() && (*iter).bShellInteract && i == input.size() - 1)
819                                  AnswerClient(s + "\n");                                  AnswerClient(s + "\n");
820                  }                  }
821                    // if other side is LSCP shell application, send the relevant LSCP
822                    // documentation section of the current command line (if necessary)
823                    if ((*iter).bShellSendLSCPDoc && (*iter).bShellInteract) {
824                            String s = generateLSCPDocReply(bufferedCommands[socket], &(*iter));
825                            if (!s.empty()) AnswerClient(s + "\n");
826                    }
827          }          }
828    
829          // handle network errors ...          // handle network errors ...
# Line 4048  String LSCPServer::SetShellAutoCorrect(y Line 4092  String LSCPServer::SetShellAutoCorrect(y
4092          else throw Exception("Not a boolean value, must either be 0 or 1");          else throw Exception("Not a boolean value, must either be 0 or 1");
4093      } catch (Exception e) {      } catch (Exception e) {
4094          result.Error(e);          result.Error(e);
4095        }
4096        return result.Produce();
4097    }
4098    
4099    String LSCPServer::SetShellDoc(yyparse_param_t* pSession, double boolean_value) {
4100        dmsg(2,("LSCPServer: SetShellDoc(val=%f)\n", boolean_value));
4101        LSCPResultSet result;
4102        try {
4103            if      (boolean_value == 0) pSession->bShellSendLSCPDoc = false;
4104            else if (boolean_value == 1) pSession->bShellSendLSCPDoc = true;
4105            else throw Exception("Not a boolean value, must either be 0 or 1");
4106        } catch (Exception e) {
4107            result.Error(e);
4108      }      }
4109      return result.Produce();      return result.Produce();
4110  }  }

Legend:
Removed from v.2531  
changed lines
  Added in v.2534

  ViewVC Help
Powered by ViewVC