Author: derek Date: Tue Sep 26 01:11:42 2006 New Revision: 131 Added: sofaswitch/trunk/callflow/src/fileio.cpp sofaswitch/trunk/callflow/src/fileio.h Log: Add these files, which are the base of the answering machine specific nodes of WriteToFile/ReadFromFile. Added: sofaswitch/trunk/callflow/src/fileio.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/fileio.cpp Tue Sep 26 01:11:42 2006 @@ -0,0 +1,128 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "fileio.h" + +///////////////////////////////////////////////////////////////////////////// + + + + +DndShapeFileIo::DndShapeFileIo(Kind kindToMake) + : DndShape(kindToMake) +{ +} + +void DndShapeFileIo::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetPen(*wxBLACK_PEN); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); + + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 25, p1.y + 0); + wxPoint pB(p1.x + 25, p1.y + 15); + dc.DrawLine(pA, pB); + DrawArrow(dc, pB, ArrowDown, InputPointConnected(0) ? Connected : Loose); + wxPoint pC(p1.x + 25, p1.y + 35); + wxPoint pD(p1.x + 25, p1.y + 50); + dc.DrawLine(pC, pD); + DrawArrow(dc, pD, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + + wxPoint ptl (p1.x, p1.y + 20); + wxPoint ptl1(p1.x + 15, p1.y + 20); + wxPoint ptr (p1.x + 50, p1.y + 20); + wxPoint ptr1(p1.x + 35, p1.y + 20); + + wxPoint pbl (p1.x, p1.y + 30); + wxPoint pbl1(p1.x + 15, p1.y + 30); + wxPoint pbr (p1.x + 50, p1.y + 30); + wxPoint pbr1(p1.x + 35, p1.y + 30); + + dc.DrawLine(ptl, ptl1); + dc.DrawLine(ptr, ptr1); + dc.DrawLine(pbl, pbl1); + dc.DrawLine(pbr, pbr1); + + if (kind == WriteToFile) { + DrawArrow(dc, ptl1, ArrowRight, Loose); + DrawArrow(dc, pbl1, ArrowRight, Loose); + DrawArrow(dc, ptr1, ArrowLeft, Loose); + DrawArrow(dc, pbr1, ArrowLeft, Loose); + } else { + DrawArrow(dc, ptl, ArrowLeft, Loose); + DrawArrow(dc, pbl, ArrowLeft, Loose); + DrawArrow(dc, ptr, ArrowRight, Loose); + DrawArrow(dc, pbr, ArrowRight, Loose); + } + + DrawBox(dc, 15, 15, 20, 20); + int xl = p1.x + 15 + 4; + int xr = p1.x + 15 + 16; + for (int i = 1; i < 5; i++) { + int y = p1.y + 15 + (i * 4); + wxPoint a(xl, y); + wxPoint b(xr, y); + dc.DrawLine(a, b); + } + + DndShape::Draw(dc); +} + + +bool DndShapeFileIo::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(" \"File Name\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + file.AddLine(wxString::Format(" \"answering machine node\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + + file.AddLine(wxString::Format(" },")); + + return true; +} + +bool DndShapeFileIo::WriteSystemCode(wxTextFile & file) +{ + if (kind == WriteToFile) + file.AddLine(" def Write_To_File(self, aTuple): "); + else + file.AddLine(" def Read_From_File(self, aTuple): "); + file.AddLine(" a,y,z = aTuple "); + file.AddLine(" fName = self.data[a][\"File Name\"] "); + file.AddLine(" rhost = eval(self.data[a][\"answering machine node\"]) "); + if (kind == WriteToFile) + file.AddLine(" rhost += \":SETRECEIVEDMSGFILE \" "); + else + file.AddLine(" rhost += \":SETANNOUNCEMENTFILE \" "); + file.AddLine(" rhost += eval(self.data[a][\"File Name\"]) + \" \\0\" "); + file.AddLine(" self.transport.write(rhost) "); + file.AddLine(" return self.data[a][\"Output\"] "); + file.AddLine(""); + return true; +} Added: sofaswitch/trunk/callflow/src/fileio.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/fileio.h Tue Sep 26 01:11:42 2006 @@ -0,0 +1,35 @@ +#ifndef FILE_IO_H + +#define FILE_IO_H + +#include "dnd.h" + +/////////////////////////////////////////////////////////////////////////// +/**Define a "audio to/from file" shape. Well, not quite. This shape is created + solely for the benefit of the DndShapeWriteToFile and DndShapeReadFromfile + shapes. This class is used in rendering the WriteToFile and ReadFromFile + shapes to the drawing area on screen. */ +class DndShapeFileIo : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapeFileIo(Kind kindToWrite); + + /**Draw this particular shape to the screen. This method examines the + local kind variable to determine which direction to draw the arrows..*/ + virtual void Draw(wxDC& dc); + + /**Write the dictionary containing relevant points for this shape. This + shape info is identical for when we are putting audio in a file, or + reading audio from a file.*/ + virtual bool WriteThisShapeInfo(wxTextFile & file); + + /**Write the code generic to this shape. If it is a write to file, or read + from file type, is determined by the kind member variable in the + ancesort class DndShape. */ + virtual bool WriteSystemCode(wxTextFile & file); +}; + + +#endif // FILE_IO_H +
participants (1)
-
SofaSWITCH SVN