# Path: TestResult.py
# class TestResult:
# 	"""This class just provides a generic container for test results, with
# 	an integer as test result and a string as descriptionale reason for
# 	this result.
# 	"""
# 
# 	TR_INIT = 0
# 	TR_PASSED = 1
# 	TR_FAILED = 2
# 	TR_WARN = 4
# 	TR_CAUT = 8
# 	TR_CANC = 16
# 	TR_ERROR = 32
# 
# 	def __init__(self, res=None, reason=None):
# 		self.name = None
# 		self.description = None
# 		self.result = TestResult.TR_INIT
# 		self.reason = None
# 		if res is not None and reason is not None:
# 			self.setResult(res, reason)
# 
# 	def __str__(self):
# 		return "[name:'" + str(self.name) + "', " \
# 				"description:'" + str(self.description) + "', " \
# 				"result:'" + getResultString(self.result) + "', " \
# 				"reason:'" + str(self.reason) + "']"
# 
# 	def setResult(self, res, reason):
# 		"""Sets the given result number and reason phrase for the instance."""
# 		if (res < TestResult.TR_INIT) or (res > TestResult.TR_ERROR):
# 			raise SCException("TestResult", "setResult", "unknown/unsupported test case result")
# 		self.result = res
# 		self.reason = reason
# 
# Path: SCException.py
# class SCException(Exception):
# 	"""Generic internal exception class. Consits out of class name, function
# 	name and the reason phrase.
# 	"""
# 
# 	def __init__(self, cls, funct, reason):
# 		Exception.__init__(self)
# 		self.cls = cls
# 		self.funct = funct
# 		self.reason = reason
# 
# 	def __str__(self):
# 		return str(self.cls) + '.' + str(self.funct) + '(): ' + str(self.reason)
# 
# class SCNotImplemented (SCException):
# 	"""See SCException. Called if implementation is missing."""
# 
# 	def __init__(self, cls, function, reason):
# 		SCException.__init__(self, cls, function, reason)


import SipEvent, Log, Helper
from TestResult import TestResult
from SCException import SCException, SCNotImplemented
		try:
			index = headerStr.index(':')
		except:
			Log.logDebug("SipMessage.parseHeaderField(): failed to find the name-value sperator in: " + str(headerStr), 2)
			return ret
		if checkHeaderNames:
			hfn_raw = headerStr[0:index].strip()
			if hfn_raw.capitalize() in Helper.rfc_headers:
				if not (hfn_raw in Helper.rfc_bfn_headers):
					ret.append(TestResult(TestResult.TR_CAUT, "header name '" + str(hfn_raw) + "' is not exactly written as in RFC3261's BNF"))
			else:
				Log.logDebug("SipMessage.parseHeaderFiled(): header field name '" + str(hfn_raw) + "' is not in RFC3261", 2)
		hfn = Helper.getMappedHFH(headerStr[0:index].rstrip())
		if (self.headerFields.has_key(hfn) and (hfn in Helper.multiple_headers)):
			self.setHeaderValue(hfn, self.getHeaderValue(hfn).rstrip() + \
				", " + headerStr[index+1:].lstrip())
		else:
			self.setHeaderValue(hfn, headerStr[index+1:].lstrip())
		return ret

	def parseFirstLine(self, fLine):
		"""Trys to parse the first line of the message. Not implemented in
		this class.
		"""
		raise SCNotImplemented("SipMessage", "parseFirstLine", "not implemented")

	def createFirstLine(self):
		"""Generates the first line of a message. Not implemented in this 
		class.
		"""

# Path: TestResult.py
# class TestResult:
# 	"""This class just provides a generic container for test results, with
# 	an integer as test result and a string as descriptionale reason for
# 	this result.
# 	"""
# 
# 	TR_INIT = 0
# 	TR_PASSED = 1
# 	TR_FAILED = 2
# 	TR_WARN = 4
# 	TR_CAUT = 8
# 	TR_CANC = 16
# 	TR_ERROR = 32
# 
# 	def __init__(self, res=None, reason=None):
# 		self.name = None
# 		self.description = None
# 		self.result = TestResult.TR_INIT
# 		self.reason = None
# 		if res is not None and reason is not None:
# 			self.setResult(res, reason)
# 
# 	def __str__(self):
# 		return "[name:'" + str(self.name) + "', " \
# 				"description:'" + str(self.description) + "', " \
# 				"result:'" + getResultString(self.result) + "', " \
# 				"reason:'" + str(self.reason) + "']"
# 
# 	def setResult(self, res, reason):
# 		"""Sets the given result number and reason phrase for the instance."""
# 		if (res < TestResult.TR_INIT) or (res > TestResult.TR_ERROR):
# 			raise SCException("TestResult", "setResult", "unknown/unsupported test case result")
# 		self.result = res
# 		self.reason = reason
# 
# Path: SCException.py
# class SCException(Exception):
# 	"""Generic internal exception class. Consits out of class name, function
# 	name and the reason phrase.
# 	"""
# 
# 	def __init__(self, cls, funct, reason):
# 		Exception.__init__(self)
# 		self.cls = cls
# 		self.funct = funct
# 		self.reason = reason
# 
# 	def __str__(self):
# 		return str(self.cls) + '.' + str(self.funct) + '(): ' + str(self.reason)
# 
# class SCNotImplemented (SCException):
# 	"""See SCException. Called if implementation is missing."""
# 
# 	def __init__(self, cls, function, reason):
# 		SCException.__init__(self, cls, function, reason)


# Path: SipMessage.py
import SipEvent, Log, Helper
from TestResult import TestResult
from SCException import SCException, SCNotImplemented

		try:
			index = headerStr.index(':')
		except:
			Log.logDebug("SipMessage.parseHeaderField(): failed to find the name-value sperator in: " + str(headerStr), 2)
			return ret
		if checkHeaderNames:
			hfn_raw = headerStr[0:index].strip()
			if hfn_raw.capitalize() in Helper.rfc_headers:
				if not (hfn_raw in Helper.rfc_bfn_headers):
					ret.append(TestResult(TestResult.TR_CAUT, "header name '" + str(hfn_raw) + "' is not exactly written as in RFC3261's BNF"))
			else:
				Log.logDebug("SipMessage.parseHeaderFiled(): header field name '" + str(hfn_raw) + "' is not in RFC3261", 2)
		hfn = Helper.getMappedHFH(headerStr[0:index].rstrip())
		if (self.headerFields.has_key(hfn) and (hfn in Helper.multiple_headers)):
			self.setHeaderValue(hfn, self.getHeaderValue(hfn).rstrip() + \
				", " + headerStr[index+1:].lstrip())
		else:
			self.setHeaderValue(hfn, headerStr[index+1:].lstrip())
		return ret

	def parseFirstLine(self, fLine):
		"""Trys to parse the first line of the message. Not implemented in
		this class.
		"""
		raise SCNotImplemented("SipMessage", "parseFirstLine", "not implemented")

	def createFirstLine(self):
		"""Generates the first line of a message. Not implemented in this 
		class.
		"""

		raise SCNotImplemented("SipMessage", "createFirstLine", "not implemented")