/
eMailService.py
executable file
·61 lines (48 loc) · 2.2 KB
/
eMailService.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'''
This package defines class for fetching GMail feeds.
Author : Naresh Pratap Singh
E-Mail : MAIL2NARESH@GMAIL.COM
Date : Jan 18 2011
Project Advisor : Prof. Steven Skiena
'''
import xoauth
import debugTrace
import errorStrings
class eMailService:
userIdentity = None
oAuthConsumer = None
oAuthAccess = None
eMailProtocol = None
xoAuthString = None
debugEnabled = False
eMailProtocol = None
serviceProvider = None
# debugTrace instance for trace logging.
debugTraceInst = None
# errorStrings instance for fetching error message strings.
errorStringsInst = None
def __init__(self, userIdentity, oAuthConsumer, oAuthAccess, eMailProtocol, serviceProvider, debugEnabled = False):
self.userIdentity = userIdentity
self.oAuthConsumer = oAuthConsumer
self.oAuthAccess = oAuthAccess
self.debugEnabled = debugEnabled
self.eMailProtocol = eMailProtocol
self.serviceProvider = serviceProvider
self.debugTraceInst = debugTrace.debugTrace(self.debugEnabled)
self.errorStringsInst = errorStrings.errorStrings()
def doGenerateXOAuthString(self):
if self.oAuthAccess is not None and self.oAuthConsumer is not None:
self.xoAuthString = xoauth.GenerateXOauthString(
self.oAuthConsumer,
self.oAuthAccess,
self.userIdentity,
self.eMailProtocol,
None, None, None
)
#self.debugTraceInst.doPrintTrace('xoAuthString: ' + self.xoAuthString, True)
return self.xoAuthString
else:
self.debugTraceInst.doPrintTrace(self.errorStringsInst.getKeySecretMissingError())
return None
def getXOAuthString(self):
return self.xoAuthString