Author: derek Date: Tue Sep 26 01:10:29 2006 New Revision: 130 Modified: sofaswitch/trunk/callflow/src/Makefile.am sofaswitch/trunk/callflow/src/Makefile.in sofaswitch/trunk/callflow/src/callflow.cpp sofaswitch/trunk/callflow/src/dnd.h sofaswitch/trunk/callflow/src/readfromfile.cpp sofaswitch/trunk/callflow/src/readfromfile.h sofaswitch/trunk/callflow/src/writetofile.cpp sofaswitch/trunk/callflow/src/writetofile.h Log: Add read from file/write to file for answering machine. Fixes, to get it working corectly. Modified: sofaswitch/trunk/callflow/src/Makefile.am ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.am (original) +++ sofaswitch/trunk/callflow/src/Makefile.am Tue Sep 26 01:10:29 2006 @@ -59,6 +59,8 @@ endhere.h \ eventer.cpp \ eventer.h \ + fileio.cpp \ + fileio.h \ information.cpp \ information.h \ joinblocks.cpp \ Modified: sofaswitch/trunk/callflow/src/Makefile.in ============================================================================== --- sofaswitch/trunk/callflow/src/Makefile.in (original) +++ sofaswitch/trunk/callflow/src/Makefile.in Tue Sep 26 01:10:29 2006 @@ -51,12 +51,13 @@ am_callflow_OBJECTS = callflow.$(OBJEXT) canvas.$(OBJEXT) \ conditional.$(OBJEXT) dnd.$(OBJEXT) drawshape.$(OBJEXT) \ endcall.$(OBJEXT) endfor.$(OBJEXT) endhere.$(OBJEXT) \ - eventer.$(OBJEXT) information.$(OBJEXT) joinblocks.$(OBJEXT) \ - listpoints.$(OBJEXT) loadnewgraph.$(OBJEXT) makecall.$(OBJEXT) \ - python.$(OBJEXT) requestnode.$(OBJEXT) senddtmf.$(OBJEXT) \ - shapelist.$(OBJEXT) shapeselect.$(OBJEXT) startfor.$(OBJEXT) \ - starthere.$(OBJEXT) stoptimer.$(OBJEXT) timer.$(OBJEXT) \ - transfermedia.$(OBJEXT) + eventer.$(OBJEXT) fileio.$(OBJEXT) information.$(OBJEXT) \ + joinblocks.$(OBJEXT) listpoints.$(OBJEXT) \ + loadnewgraph.$(OBJEXT) makecall.$(OBJEXT) python.$(OBJEXT) \ + readfromfile.$(OBJEXT) requestnode.$(OBJEXT) \ + senddtmf.$(OBJEXT) shapelist.$(OBJEXT) shapeselect.$(OBJEXT) \ + startfor.$(OBJEXT) starthere.$(OBJEXT) stoptimer.$(OBJEXT) \ + timer.$(OBJEXT) transfermedia.$(OBJEXT) writetofile.$(OBJEXT) callflow_OBJECTS = $(am_callflow_OBJECTS) am__DEPENDENCIES_1 = callflow_DEPENDENCIES = $(am__DEPENDENCIES_1) @@ -216,6 +217,8 @@ ../bitmaps/newshape.xpm \ ../bitmaps/senddtmf.xpm \ ../bitmaps/stoptimer.xpm \ + ../bitmaps/readfromfile.xpm \ + ../bitmaps/writetofile.xpm \ ../bitmaps/transfermedia.xpm \ callflow.cpp \ callflow.h \ @@ -235,6 +238,8 @@ endhere.h \ eventer.cpp \ eventer.h \ + fileio.cpp \ + fileio.h \ information.cpp \ information.h \ joinblocks.cpp \ @@ -247,6 +252,8 @@ makecall.h \ python.cpp \ python.h \ + readfromfile.cpp \ + readfromfile.h \ requestnode.cpp \ requestnode.h \ senddtmf.cpp \ @@ -264,7 +271,9 @@ timer.cpp \ timer.h \ transfermedia.cpp \ - transfermedia.h + transfermedia.h \ + writetofile.cpp \ + writetofile.h all: all-am @@ -346,12 +355,14 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/endfor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/endhere.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eventer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/information.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/joinblocks.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listpoints.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loadnewgraph.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makecall.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/python.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readfromfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/requestnode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/senddtmf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapelist.Po@am__quote@ @@ -361,6 +372,7 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stoptimer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transfermedia.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writetofile.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ Modified: sofaswitch/trunk/callflow/src/callflow.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.cpp (original) +++ sofaswitch/trunk/callflow/src/callflow.cpp Tue Sep 26 01:10:29 2006 @@ -86,7 +86,7 @@ EVT_MENU ( wxH_CONTROLSTIMER, MyFrame::OnControlsTimer) EVT_MENU ( wxH_CONTROLSTRANSFERMEDIA, MyFrame::OnControlsTransferMedia) EVT_MENU ( wxH_CONTROLSREADFROMFILE, MyFrame::OnControlsReadFromFile) - EVT_MENU ( wxH_CONTROLSWRITETOFILE, MyFrame::onControlsWriteToFile) + EVT_MENU ( wxH_CONTROLSWRITETOFILE, MyFrame::OnControlsWriteToFile) EVT_MENU ( wxH_EDITCOPY, MyFrame::OnEditCopy) EVT_MENU ( wxH_EDITCUT, MyFrame::OnEditCut) EVT_MENU ( wxH_EDITPASTE, MyFrame::OnEditPaste) Modified: sofaswitch/trunk/callflow/src/dnd.h ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.h (original) +++ sofaswitch/trunk/callflow/src/dnd.h Tue Sep 26 01:10:29 2006 @@ -267,7 +267,7 @@ /**14*/ Eventer /**Mark me as registering for an event. Possibly, wait for the registered for event */, /**15*/ TransferMedia /**Transfer media from one sofaswitch entity to another */, /**16*/ ReadFromFile /**Read audio from a .wav file (answering machine specific) */, - /**17*/ WriteToFile /**Write audio into a .wav file (answering machine specific) */ + /**17*/ WriteToFile /**Write audio into a .wav file (answering machine specific) */, /**18*/ LoadNewGraph /**Read in an existing graph file (pre compiled) for a new thread of exeuction */, /**19*/ SendDtmf /**Send a dtmf symbol to some sofaswitch worker node */, /* 20*/ KnownShapes /**Indicates the number of known shapes we can manage */ Modified: sofaswitch/trunk/callflow/src/readfromfile.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/readfromfile.cpp (original) +++ sofaswitch/trunk/callflow/src/readfromfile.cpp Tue Sep 26 01:10:29 2006 @@ -13,103 +13,25 @@ #include "shapelist.h" -#include "requestnode.h" +#include "readfromfile.h" ///////////////////////////////////////////////////////////////////////////// - - - -DndShapeRequestNode::DndShapeRequestNode() - : DndShape(RequestNode) +DndShapeReadFromFile::DndShapeReadFromFile() + : DndShapeFileIo(ReadFromFile) { wxSize newSize(50, 50); SetSize(newSize); displayData[displayData.size()] = - InformationSection(wxT("Request node from"), wxT("voip")); + InformationSection(wxT("Filename to read audio from"), wxT("src_audio.wav")); + displayData[displayData.size()] = - InformationSection(wxT("Timer period (seconds)"), wxT("1")); - - displayData[displayData.size()] = - InformationSection(wxT("Timer label"), wxT("request node")); + InformationSection(wxT("answering machine node"), wxT("Answering machine worker node")); - relInputPoints.Add(25, 0); relOutputPoints.Add(25, 50); AdjustIoPoints(); -} - -void DndShapeRequestNode::Draw(wxDC& dc) -{ - DrawCompileError(dc); - dc.SetPen(*wxBLACK_PEN); - - wxPoint p1(m_rect.GetPosition()); - wxPoint pA(p1.x + 25, p1.y + 0); - wxPoint pB(p1.x + 25, p1.y + 50); - - - dc.DrawLine(pA, pB); - - wxString text("R ?"); - wxFont f = wxFont(*wxITALIC_FONT); - f.SetPointSize(20); - dc.SetFont(f);//*wxITALIC_FONT); - wxCoord w, h; - dc.GetTextExtent(text, &w, &h); - - int xPos = m_rect.x + 0 + ((50 - w)/2); - int yPos = m_rect.y + 10 + ((21 - h)/2); - dc.DrawText(text, xPos, yPos); - - DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); - DrawArrow(dc, pB, ArrowDown, OutputPointConnected(0) ? Connected : Loose); - - DndShape::Draw(dc); -} - -bool DndShapeRequestNode::WriteSystemCode(wxTextFile & file) -{ - file.AddLine(" def Request_Node(self, aTuple): "); - file.AddLine(" a,y,z = aTuple "); - file.AddLine(" eName = self.data[a][\"Timer label\"] "); - file.AddLine(" self.pendingEvents[eName] = a "); - file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"); - file.AddLine(" rhost = self.data[a][\"Request node from\"] "); - file.AddLine(" rhost += \":REQUESTNEWID\\0\" "); - file.AddLine(" self.transport.write(rhost) "); - file.AddLine(" return self.data[a][\"Output\"] "); - file.AddLine(""); - return true; -} - -bool DndShapeRequestNode::WriteThisShapeInfo(wxTextFile & file) -{ - file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); - - wxNode *inputNode = (wxNode *)GetInputPoints().GetFirst(); - const wxString & inputLabel = ((LabelledPoint *)inputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Input\" : ")); - file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); - - wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); - const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Output\" : ")); - file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); - - file.AddLine(wxString::Format(" \"Request node from\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); - - file.AddLine(wxString::Format(" \"Timer period\" : ")); - file.AddLine(wxString::Format(" %s, ", displayData[2].data.c_str())); - - file.AddLine(wxString::Format(" \"Timer label\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[3].data.c_str())); - - file.AddLine(wxString::Format(" },")); - - return true; } Modified: sofaswitch/trunk/callflow/src/readfromfile.h ============================================================================== --- sofaswitch/trunk/callflow/src/readfromfile.h (original) +++ sofaswitch/trunk/callflow/src/readfromfile.h Tue Sep 26 01:10:29 2006 @@ -1,39 +1,24 @@ -#ifndef REQUEST_NODE_H +#ifndef READ_FROM_FILE_H -#define REQUEST_NODE_H +#define READ_FROM_FILE_H -#include "dnd.h" +#include "fileio.h" /////////////////////////////////////////////////////////////////////////// -/**Define a request node shape. This code will return almost immediately, and - we leave it to the timer object to recover from if there was an answer, or - noting Store values for size, location, input & output points. This - instance has the ability to draw this shape to a specified location on the - canvas */ -class DndShapeRequestNode : public DndShape +/**Define a "read from file" node shape. This shape is answering machine + specific, and is used when the answering machine is sending audio to some + other sofaswitch worker. The file read from is the source of audio. + The file is a .wav file */ +class DndShapeReadFromFile : public DndShapeFileIo { public: /**Construtor, Define this shape in terms of size and points etc */ - DndShapeRequestNode(); + DndShapeReadFromFile(); - /**Destroy this shape, and log it */ - virtual ~DndShapeRequestNode() - { - } - - /**Draw this particular shape to the screen..*/ - virtual void Draw(wxDC& dc); - /** Used to report the name of this particular class. */ - static wxString GetKindName() { return wxString("Request Node"); } - - /**Write the code generic to this StartHere shape */ - virtual bool WriteSystemCode(wxTextFile & file); - - /**Write the dictionary containing relevant points for this shape */ - virtual bool WriteThisShapeInfo(wxTextFile & file); + static wxString GetKindName() { return wxString("Read From File"); } }; -#endif +#endif //READ_FROM_FILE_H Modified: sofaswitch/trunk/callflow/src/writetofile.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/writetofile.cpp (original) +++ sofaswitch/trunk/callflow/src/writetofile.cpp Tue Sep 26 01:10:29 2006 @@ -13,103 +13,25 @@ #include "shapelist.h" -#include "requestnode.h" +#include "writetofile.h" ///////////////////////////////////////////////////////////////////////////// - - - -DndShapeRequestNode::DndShapeRequestNode() - : DndShape(RequestNode) +DndShapeWriteToFile::DndShapeWriteToFile() + : DndShapeFileIo(WriteToFile) { wxSize newSize(50, 50); SetSize(newSize); displayData[displayData.size()] = - InformationSection(wxT("Request node from"), wxT("voip")); + InformationSection(wxT("Filename to contain new audio"), wxT("empty_file.wav")); + displayData[displayData.size()] = - InformationSection(wxT("Timer period (seconds)"), wxT("1")); - - displayData[displayData.size()] = - InformationSection(wxT("Timer label"), wxT("request node")); + InformationSection(wxT("answering machine node"), wxT("Answering machine worker node")); - relInputPoints.Add(25, 0); relOutputPoints.Add(25, 50); AdjustIoPoints(); -} - -void DndShapeRequestNode::Draw(wxDC& dc) -{ - DrawCompileError(dc); - dc.SetPen(*wxBLACK_PEN); - - wxPoint p1(m_rect.GetPosition()); - wxPoint pA(p1.x + 25, p1.y + 0); - wxPoint pB(p1.x + 25, p1.y + 50); - - - dc.DrawLine(pA, pB); - - wxString text("R ?"); - wxFont f = wxFont(*wxITALIC_FONT); - f.SetPointSize(20); - dc.SetFont(f);//*wxITALIC_FONT); - wxCoord w, h; - dc.GetTextExtent(text, &w, &h); - - int xPos = m_rect.x + 0 + ((50 - w)/2); - int yPos = m_rect.y + 10 + ((21 - h)/2); - dc.DrawText(text, xPos, yPos); - - DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); - DrawArrow(dc, pB, ArrowDown, OutputPointConnected(0) ? Connected : Loose); - - DndShape::Draw(dc); -} - -bool DndShapeRequestNode::WriteSystemCode(wxTextFile & file) -{ - file.AddLine(" def Request_Node(self, aTuple): "); - file.AddLine(" a,y,z = aTuple "); - file.AddLine(" eName = self.data[a][\"Timer label\"] "); - file.AddLine(" self.pendingEvents[eName] = a "); - file.AddLine(" reactor.callLater(self.data[a][\"Timer period\"], self.timerObjectExpired, eName)"); - file.AddLine(" rhost = self.data[a][\"Request node from\"] "); - file.AddLine(" rhost += \":REQUESTNEWID\\0\" "); - file.AddLine(" self.transport.write(rhost) "); - file.AddLine(" return self.data[a][\"Output\"] "); - file.AddLine(""); - return true; -} - -bool DndShapeRequestNode::WriteThisShapeInfo(wxTextFile & file) -{ - file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); - - wxNode *inputNode = (wxNode *)GetInputPoints().GetFirst(); - const wxString & inputLabel = ((LabelledPoint *)inputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Input\" : ")); - file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); - - wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); - const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Output\" : ")); - file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); - - file.AddLine(wxString::Format(" \"Request node from\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); - - file.AddLine(wxString::Format(" \"Timer period\" : ")); - file.AddLine(wxString::Format(" %s, ", displayData[2].data.c_str())); - - file.AddLine(wxString::Format(" \"Timer label\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[3].data.c_str())); - - file.AddLine(wxString::Format(" },")); - - return true; } Modified: sofaswitch/trunk/callflow/src/writetofile.h ============================================================================== --- sofaswitch/trunk/callflow/src/writetofile.h (original) +++ sofaswitch/trunk/callflow/src/writetofile.h Tue Sep 26 01:10:29 2006 @@ -1,39 +1,25 @@ -#ifndef REQUEST_NODE_H +#ifndef WRITE_TO_FILE_H -#define REQUEST_NODE_H +#define WRITE_TO_FILE_H -#include "dnd.h" - +#include "fileio.h" /////////////////////////////////////////////////////////////////////////// -/**Define a request node shape. This code will return almost immediately, and - we leave it to the timer object to recover from if there was an answer, or - noting Store values for size, location, input & output points. This - instance has the ability to draw this shape to a specified location on the - canvas */ -class DndShapeRequestNode : public DndShape +/**Define a "write audio to file" node shape. This shape is answering machine + specific, and is used when the answering machine is collecting audio from + some other sofaswitch worker (which is then stored on disk). The file + written to is the audio.received from the other sofa sofaswitch worker. + The file is a .wav file */ +class DndShapeWriteToFile : public DndShapeFileIo { public: /**Construtor, Define this shape in terms of size and points etc */ - DndShapeRequestNode(); + DndShapeWriteToFile(); - /**Destroy this shape, and log it */ - virtual ~DndShapeRequestNode() - { - } - /**Draw this particular shape to the screen..*/ - virtual void Draw(wxDC& dc); - /** Used to report the name of this particular class. */ - static wxString GetKindName() { return wxString("Request Node"); } - - /**Write the code generic to this StartHere shape */ - virtual bool WriteSystemCode(wxTextFile & file); - - /**Write the dictionary containing relevant points for this shape */ - virtual bool WriteThisShapeInfo(wxTextFile & file); + static wxString GetKindName() { return wxString("Write To File"); } }; -#endif +#endif // WRITE_TO_FILE_H