# 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
		name is not know also the raw name will be used.
		"""
		if Helper.getRevMappedHFH(Helper.getMappedHFH(hfName)):
			self.headerFields[Helper.getMappedHFH(hfName)] = hfValue
		else:
			self.headerFields[hfName] = hfValue

	def removeHeaderField(self, hfName):
		"""Removes the given header field from the message.
		"""
		if self.headerFields.has_key (hfName.replace("-", "").capitalize()):
			del self.headerFields[hfName.replace("-", "").capitalize()]
	
	def parseHeaderField(self, headerStr, checkHeaderNames):
		"""Trys to genericly seperate the given line into the header field 
		name and the value. If the second parameter is True the header field
		name is checked if is written like in the BNF of RFC3261. In case
		it is not written like in the RFC3261 a sequence of TestResults
		(result CAUTION) will be returned.
		"""
		ret = []
		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):

# 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

		name is not know also the raw name will be used.
		"""
		if Helper.getRevMappedHFH(Helper.getMappedHFH(hfName)):
			self.headerFields[Helper.getMappedHFH(hfName)] = hfValue
		else:
			self.headerFields[hfName] = hfValue

	def removeHeaderField(self, hfName):
		"""Removes the given header field from the message.
		"""
		if self.headerFields.has_key (hfName.replace("-", "").capitalize()):
			del self.headerFields[hfName.replace("-", "").capitalize()]
	
	def parseHeaderField(self, headerStr, checkHeaderNames):
		"""Trys to genericly seperate the given line into the header field 
		name and the value. If the second parameter is True the header field
		name is checked if is written like in the BNF of RFC3261. In case
		it is not written like in the RFC3261 a sequence of TestResults
		(result CAUTION) will be returned.
		"""
		ret = []
		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"))