# Path: EventHandler.py
# class EventHandler:
# 	"""An abstract class for SIP event handling classes."""
# 
# 	def __init__(self):
# 		pass
# 
# 	def readEvent(self):
# 		"""This function will be called to get a SIP event as return value.
# 		"""
# 		raise SCNotImplemented("EventHandler", "readEvent", "not implemented")
# 
# 	def writeEvent(self, event):
# 		"""This function will be called to write the given SIP event to the
# 		destination.
# 		"""
# 		raise SCNotImplemented("EventHandler", "writeEvent", "not implemented")


from EventHandler import EventHandler
import Log, Config
import SCException
import SipEvent as SE
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SIP Forum Test Framework; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# $Id: FileEventHandler.py,v 1.7 2004/03/19 18:37:25 lando Exp $
#

def fixCRLF(_input):
	pos = _input.find("\n")
	while pos != -1:
		if _input[pos-1] != "\r":
			_input = _input[:pos] + "\r\n" + _input[pos+1:]
			pos = pos+1
		pos = _input.find("\n", pos+1)
	return _input

class FileEventHandler (EventHandler):
	"""This class implements the EventHandler class for files. It can read in
	SIP messages from files and can write SIP event to a file.
	"""

	def __init__(self, _filename=None, _fixLF=True, addResource=True):
		"""If a filename is given as parameter that file will be opened
		for reading. If the second parameter is True single line-feeds will 
		be replaced	by carriage-return line-feed while reading in and writing
		to a file.
		"""

# Path: EventHandler.py
# class EventHandler:
# 	"""An abstract class for SIP event handling classes."""
# 
# 	def __init__(self):
# 		pass
# 
# 	def readEvent(self):
# 		"""This function will be called to get a SIP event as return value.
# 		"""
# 		raise SCNotImplemented("EventHandler", "readEvent", "not implemented")
# 
# 	def writeEvent(self, event):
# 		"""This function will be called to write the given SIP event to the
# 		destination.
# 		"""
# 		raise SCNotImplemented("EventHandler", "writeEvent", "not implemented")


# Path: FileEventHandler.py
from EventHandler import EventHandler
import Log, Config
import SCException
import SipEvent as SE

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SIP Forum Test Framework; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# $Id: FileEventHandler.py,v 1.7 2004/03/19 18:37:25 lando Exp $
#

def fixCRLF(_input):
	pos = _input.find("\n")
	while pos != -1:
		if _input[pos-1] != "\r":
			_input = _input[:pos] + "\r\n" + _input[pos+1:]
			pos = pos+1
		pos = _input.find("\n", pos+1)
	return _input

class FileEventHandler (EventHandler):
	"""This class implements the EventHandler class for files. It can read in
	SIP messages from files and can write SIP event to a file.
	"""

	def __init__(self, _filename=None, _fixLF=True, addResource=True):
		"""If a filename is given as parameter that file will be opened
		for reading. If the second parameter is True single line-feeds will 
		be replaced	by carriage-return line-feed while reading in and writing
		to a file.
		"""

		EventHandler.__init__(self)