# -*- coding: utf-8 -*-
from email.mime.text import MIMEText
from email.header import Header
class Message:
def __init__(self,content, typ="Message"):
self.content=content
self.typ = typ
def getContent(self):
return self.content
def __eq__(self,other):
return self.content == other.content
def __ne__(self,other):
return not self.__eq__(other)
class SMS(Message):
def __init__(self, cont):
Message.__init__(self, cont, typ="sms")
def sendto(self,anbieter,recipients):
anbieter.sendSMS(self,recipients)
class Fax(Message):
def __init__(self,header,cont,attachments):
Message.__init__(self,cont, typ="fax")
self.header=header
self.attachments=attachments
def getAttachment(self,i):
return self.attachments[i]
def __eq__(self,other):
if not Message.__eq__(self,other):
return False
if self.header != other.header:
return False
if len(self.attachments) != len(other.attachments):
return False
for i in range(len(self.attachments)):
if self.attachments[i] != other.attachments[i]:
return False
return True
class Mail(Message):
def __init__(self, subject, body, frm):
con=MIMEText(body.encode("utf-8"), _charset='utf-8')
sub=Header(subject.encode('utf-8'), 'utf-8')
con['Subject']=sub
self.frm=frm
Message.__init__(self, con, typ='mail')
def as_string(self):
return self.Message.as_string()
def getFrom(self):
return self.frm
def __eq__(self,other):
if self.as_string() != other.as_string():
return False
if self.frm != other.frm:
return False
return True