Author: derek Date: Wed Sep 27 00:10:22 2006 New Revision: 133 Modified: sofaswitch/trunk/callflow/src/dnd.cpp sofaswitch/trunk/callflow/src/dnd.h sofaswitch/trunk/callflow/src/eventer.cpp sofaswitch/trunk/callflow/src/makecall.cpp sofaswitch/trunk/callflow/src/python.cpp sofaswitch/trunk/callflow/src/senddtmf.cpp sofaswitch/trunk/callflow/src/shapelist.cpp sofaswitch/trunk/callflow/tests/requestnode.src sofaswitch/trunk/callflow/tests/timetest.src Log: Bug fixes bug fixes. Use a more sane approach for entering string parameters. Specify a variable in the event object, which holds data from the event. Modified: sofaswitch/trunk/callflow/src/dnd.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.cpp (original) +++ sofaswitch/trunk/callflow/src/dnd.cpp Wed Sep 27 00:10:22 2006 @@ -913,3 +913,19 @@ return true; } + +wxString DndShape::ProtectString(const wxString & src) +{ + char dq= '\"'; + char s = '\\'; + char sq = '\''; + wxString str_dq = wxString::Format("%c", dq); + wxString str_sq = wxString::Format("%c", sq); + wxString esc_sq = wxString::Format("%c%c", s, sq); + wxString esc_dq = wxString::Format("%c%c", s, dq); + wxString answer = src; + answer.Replace(str_dq, esc_dq); + answer.Replace(str_sq, esc_sq); + + return answer; +} Modified: sofaswitch/trunk/callflow/src/dnd.h ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.h (original) +++ sofaswitch/trunk/callflow/src/dnd.h Wed Sep 27 00:10:22 2006 @@ -509,6 +509,10 @@ void AdjustIoPoints(); protected: + /**Given a string (from the user command line) we need to turn all quotes + into \\\", so that when run in the python program, a quote will be + interpreted correctly. Similarily, we have to turn ' into \\\' */ + wxString ProtectString(const wxString & src); /**Store the supplied key in the list of input point, and in the list of output points. Assign the supplied key to this shape, Modified: sofaswitch/trunk/callflow/src/eventer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/eventer.cpp (original) +++ sofaswitch/trunk/callflow/src/eventer.cpp Wed Sep 27 00:10:22 2006 @@ -33,20 +33,28 @@ displayData[displayData.size()] = InformationSection(wxT("Event sought (Regular Exp)"), wxT("*DTMF")); + + displayData[displayData.size()] = + InformationSection(wxT("Python variable to hold event data"), wxT("self.eventData")); } bool DndShapeEventer::TestInternalVariables() { DndShape::TestInternalVariables(); + bool vblEmpty = displayData[3].data.IsEmpty(); + if (vblEmpty) + SetCompileError(wxT("There is no python variable to hold the output of the event")); + + bool oneEmpty = displayData[1].data.IsEmpty(); bool twoEmpty = displayData[2].data.IsEmpty(); - if (oneEmpty && (!twoEmpty)) { + if ((!vblEmpty) && oneEmpty && (!twoEmpty)) { return true; } - if (twoEmpty && (!oneEmpty)) { + if ((!vblEmpty) && twoEmpty && (!oneEmpty)) { return true; } @@ -114,6 +122,9 @@ file.AddLine(" link not be connected, a None value will be returned. "); file.AddLine(" \"\"\" "); file.AddLine(" a,b,c = sTuple "); + file.AddLine(" pVbl = self.data[a][\"Event Variable\"] "); + file.AddLine(" pVbl += \" = None\" "); + file.AddLine(" exec(pVbl) "); file.AddLine(" ePyn = self.data[a][\"Event Python\"] "); file.AddLine(" eReg = self.data[a][\"Event RegExp\"] "); file.AddLine(" if len(ePyn) > 0: "); @@ -152,6 +163,9 @@ file.AddLine(wxString::Format(" \"Event RegExp\" : ")); file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + + file.AddLine(wxString::Format(" \"Event Variable\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[3].data.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/src/makecall.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/makecall.cpp (original) +++ sofaswitch/trunk/callflow/src/makecall.cpp Wed Sep 27 00:10:22 2006 @@ -30,7 +30,7 @@ InformationSection(wxT("Worker node to activate (python code)"), wxT("\"voip1\"")); displayData[displayData.size()] = - InformationSection(wxT("Call destination (python code)"), wxT("\"h323.voxgratia.org\"")); + InformationSection(wxT("Call destination (python code)"), wxT("\"h323:h323.voxgratia.org\"")); AdjustIoPoints(); } @@ -40,7 +40,7 @@ file.AddLine(" def Make_Call(self, sTuple): "); file.AddLine(" a,b,c = sTuple "); file.AddLine(" rhost = eval(self.data[a][\"worker node\"]) "); - file.AddLine(" rhost += \":CALLNODE \" + self.data[a][\"call destination\"] + \"\\0\" "); + file.AddLine(" rhost += \":CALLNODE \" + eval(self.data[a][\"call destination\"]) + \"\\0\" "); file.AddLine(" self.transport.write(rhost) "); file.AddLine(" return self.data[a][\"Output\"] "); file.AddLine(""); @@ -59,10 +59,12 @@ file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); file.AddLine(wxString::Format(" \"worker node\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" \"call destination\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + dest = ProtectString(displayData[2].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/src/python.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/python.cpp (original) +++ sofaswitch/trunk/callflow/src/python.cpp Wed Sep 27 00:10:22 2006 @@ -97,7 +97,8 @@ file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); file.AddLine(wxString::Format(" \"Python Code\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/src/senddtmf.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/senddtmf.cpp (original) +++ sofaswitch/trunk/callflow/src/senddtmf.cpp Wed Sep 27 00:10:22 2006 @@ -30,14 +30,14 @@ InformationSection(wxT("Worker node to activate (python code)"), wxT("\"voip1\"")); displayData[displayData.size()] = - InformationSection(wxT("Call destination (python code)"), wxT("\"h323.voxgratia.org\"")); + InformationSection(wxT("DTMF to send to worker node (python code)"), wxT("\"1\"")); AdjustIoPoints(); } bool DndShapeSendDtmf::WriteSystemCode(wxTextFile & file) { - file.AddLine(" def Make_Call(self, sTuple): "); + file.AddLine(" def Send_Dtmf(self, sTuple): "); file.AddLine(" a,b,c = sTuple "); file.AddLine(" rhost = eval(self.data[a][\"worker node\"]) "); file.AddLine(" rhost += \":SENDDTMF \" + eval(self.data[a][\"dtmf to send\"]) + \"\\0\" "); @@ -59,10 +59,12 @@ file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); file.AddLine(wxString::Format(" \"worker node\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + wxString dest = ProtectString(displayData[1].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" \"dtmf to send\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[2].data.c_str())); + dest = ProtectString(displayData[2].data); + file.AddLine(wxString::Format(" \"%s\", ", dest.c_str())); file.AddLine(wxString::Format(" },")); Modified: sofaswitch/trunk/callflow/src/shapelist.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/shapelist.cpp (original) +++ sofaswitch/trunk/callflow/src/shapelist.cpp Wed Sep 27 00:10:22 2006 @@ -376,9 +376,10 @@ file.AddLine(" eventNode = self.currentHandlers[handler] "); file.AddLine(" eventData = self.generatedEvents.pop(event) "); file.AddLine(" eHandler = self.data[eventNode][\"Event Handler\"] "); - file.AddLine(" a,b,c = eHandler "); - file.AddLine(" self.data[a][\"Event Data\"] = eventData "); - file.AddLine(" self.DoWork(eHandler) "); + file.AddLine(" pVbl = self.data[eventNode][\"Event Variable\"] "); + file.AddLine(" pVbl += \" = \" + self.quote + eventData + self.quote "); + file.AddLine(" exec(pVbl) "); + file.AddLine(" self.DoWork(eHandler) "); file.AddLine(" self.generatedEvents.clear() "); file.AddLine(" "); file.AddLine(" def networkEventData(self, eName, data): "); @@ -492,8 +493,6 @@ file.AddLine(" types of messages "); file.AddLine(" \"\"\" "); file.AddLine(" thisMessage = thisMessage.strip() "); - file.AddLine(" if len(thisMessage) > 2: "); - file.AddLine(" print \"Received \", thisMessage "); file.AddLine(" for msg in self.knownNetworkMessages: "); file.AddLine(" if thisMessage.find(msg) >= 0: "); file.AddLine(" pMsg = str(thisMessage).split(\" \") "); Modified: sofaswitch/trunk/callflow/tests/requestnode.src ============================================================================== --- sofaswitch/trunk/callflow/tests/requestnode.src (original) +++ sofaswitch/trunk/callflow/tests/requestnode.src Wed Sep 27 00:10:22 2006 @@ -1 +1 @@ -13<B>231<B>340<B> extra <special>Tool Tip<ms>Stop Timer<ms><special>Timer to stop<ms>requestnode<ms><special> <B><Shape>1<B>231<B>108<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>10<B>323<B>322<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"timer has expired at \", time.asctime()<ms><special> <B><Shape>2<B>231<B>391<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>9<B>289<B>276<B>289,277,349,276<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>11<B>232<B>159<B> extra <special>Tool Tip<ms>Request Node<ms><special>Request node from<ms>voip<ms><special>Timer period (seconds)<ms>1<ms><special>Timer label<ms>requestnode<ms><special> <B><Shape>10<B>232<B>204<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"Have requested a node from voip at \", time.asctime()<ms><special> <B><Shape>10<B>231<B>295<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"have a new node on \", self.data[self.currentNode][\"Event Data\"]<ms><special> <B><Shape>9<B>259<B>371<B>347,371,259,391<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>243<B>255<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>NEWID<ms><special> <B><Shape>14<B>334<B>279<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>requestnode<ms><special> <B><Shape> +2<B>231<B>391<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>10<B>323<B>322<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "timer has expired at ", time.asctime(), " from ", self.timerData<ms><special> <B><Shape>9<B>259<B>371<B>347,371,259,391<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>244<B>255<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>NEWID<ms><special>Python variable to hold event data<ms>self.eventData<ms><special> <B><Shape>14<B>336<B>282<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>requestnode<ms><special>Python variable to hold event data<ms>self.timerData<ms><special> <B><Shape>13<B>231<B>340<B> extra <special>Tool Tip<ms>Stop Timer<ms><special>Timer to stop<ms>requestnode<ms><special> <B><Shape>9<B>290<B>279<B>290,280,350,279<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>10<B>231<B>295<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "have a new node on ", self.eventData<ms><special> <B><Shape>1<B>231<B>157<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>11<B>231<B>208<B> extra <special>Tool Tip<ms>Request Node<ms><special>Request node from<ms>voip<ms><special>Timer period (seconds)<ms>1<ms><special>Timer label<ms>requestnode<ms><special> <B><Shape> Modified: sofaswitch/trunk/callflow/tests/timetest.src ============================================================================== --- sofaswitch/trunk/callflow/tests/timetest.src (original) +++ sofaswitch/trunk/callflow/tests/timetest.src Wed Sep 27 00:10:22 2006 @@ -1 +1 @@ -12<B>207<B>202<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>2<ms><special>Timer label<ms>timer2<ms><special> <B><Shape>10<B>123<B>74<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"Start \", time.asctime()<ms><special> <B><Shape>14<B>218<B>254<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer2<ms><special> <B><Shape>2<B>207<B>352<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>14<B>137<B>175<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer1<ms><special> <B><Shape>10<B>247<B>371<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"t10 \", time.asctime(), \" data is \", self.data[self.currentNode][\"Event Data\"]<ms><special> <B><Shape>10<B>207<B>305<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"t2 \", time.asctime(), \" data is \", self.data[self.currentNode][\"Event Data\"]<ms><special> <B><Shape>10<B>126<B>221<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print \"t1 \", time.asctime(), \" data is \", self.data[self.currentNode][\"Event Data\"]<ms><special> <B><Shape>12<B>244<B>274<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>10<ms><special>Timer label (string literal)<ms>t10<ms><special> <B><Shape>9<B>188<B>201<B>188,201,231,202<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>259<B>327<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>10<ms><special> <B><Shape>9<B>175<B>354<B>275,421,175,421,181,363,228,354<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>12<B>123<B>122<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>1<ms><special>Timer label<ms>timer1<ms><special> <B><Shape>9<B>150<B>272<B>151,272,150,344,232,354<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>1<B>123<B>26<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape> +10<B>207<B>305<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t2 ", time.asctime(), " data is ", self.timer2<ms><special> <B><Shape>14<B>139<B>179<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer1<ms><special>Python variable to hold event data<ms>self.timer1Data<ms><special> <B><Shape>9<B>270<B>278<B>270,280,359,278<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>9<B>188<B>201<B>188,201,231,202<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>14<B>220<B>256<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>timer2<ms><special>Python variable to hold event data<ms>self.timer2<ms><special> <B><Shape>14<B>347<B>327<B> extra <special>Tool Tip<ms>Eventer<ms><special>Event sought (Python code)<ms><ms><special>Event sought (Regular Exp)<ms>10<ms><special>Python variable to hold event data<ms>self.timer3<ms><special> <B><Shape>10<B>126<B>221<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t1 ", time.asctime(), " data is ", self.timer1Data<ms><special> <B><Shape>12<B>127<B>125<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>1<ms><special>Timer label<ms>timer1<ms><special> <B><Shape>9<B>150<B>271<B>150,271,152,406,223,407,229,423<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>12<B>335<B>275<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>10<ms><special>Timer label (string literal)<ms>t10<ms><special> <B><Shape>9<B>228<B>419<B>228,423,358,419<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>1<B>123<B>26<B> extra <special>Tool Tip<ms>Start Processing<ms><special> <B><Shape>10<B>334<B>370<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "t10 ", time.asctime(), " data is ", self.timer3<ms><special> <B><Shape>10<B>123<B>74<B> extra <special>Tool Tip<ms>Python<ms><special>Python Code<ms>print "Start ", time.asctime()<ms><special> <B><Shape>12<B>207<B>202<B> extra <special>Tool Tip<ms>Timer<ms><special>Timer period (seconds)<ms>2<ms><special>Timer label<ms>timer2<ms><special> <B><Shape>2<B>204<B>423<B> extra <special>Tool Tip<ms>End Processing<ms><special> <B><Shape>9<B>231<B>351<B>232,351,231,422<special>Tool Tip<ms>Join blocks shape<ms><special> <B><Shape>