/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/util/simplemapi.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
LPLHANDLE = POINTER(LHANDLE)
47
47
 
48
48
# Return codes
49
 
SUCCESS_SUCCESS                 = 0
50
 
MAPI_USER_ABORT                 = 1
51
 
MAPI_E_USER_ABORT               = MAPI_USER_ABORT
52
 
MAPI_E_FAILURE                  = 2
53
 
MAPI_E_LOGON_FAILURE            = 3
54
 
MAPI_E_LOGIN_FAILURE            = MAPI_E_LOGON_FAILURE
55
 
MAPI_E_DISK_FULL                = 4
56
 
MAPI_E_INSUFFICIENT_MEMORY      = 5
57
 
MAPI_E_ACCESS_DENIED            = 6
58
 
MAPI_E_TOO_MANY_SESSIONS        = 8
59
 
MAPI_E_TOO_MANY_FILES           = 9
60
 
MAPI_E_TOO_MANY_RECIPIENTS      = 10
61
 
MAPI_E_ATTACHMENT_NOT_FOUND     = 11
62
 
MAPI_E_ATTACHMENT_OPEN_FAILURE  = 12
 
49
SUCCESS_SUCCESS = 0
 
50
MAPI_USER_ABORT = 1
 
51
MAPI_E_USER_ABORT = MAPI_USER_ABORT
 
52
MAPI_E_FAILURE = 2
 
53
MAPI_E_LOGON_FAILURE = 3
 
54
MAPI_E_LOGIN_FAILURE = MAPI_E_LOGON_FAILURE
 
55
MAPI_E_DISK_FULL = 4
 
56
MAPI_E_INSUFFICIENT_MEMORY = 5
 
57
MAPI_E_ACCESS_DENIED = 6
 
58
MAPI_E_TOO_MANY_SESSIONS = 8
 
59
MAPI_E_TOO_MANY_FILES = 9
 
60
MAPI_E_TOO_MANY_RECIPIENTS = 10
 
61
MAPI_E_ATTACHMENT_NOT_FOUND = 11
 
62
MAPI_E_ATTACHMENT_OPEN_FAILURE = 12
63
63
MAPI_E_ATTACHMENT_WRITE_FAILURE = 13
64
 
MAPI_E_UNKNOWN_RECIPIENT        = 14
65
 
MAPI_E_BAD_RECIPTYPE            = 15
66
 
MAPI_E_NO_MESSAGES              = 16
67
 
MAPI_E_INVALID_MESSAGE          = 17
68
 
MAPI_E_TEXT_TOO_LARGE           = 18
69
 
MAPI_E_INVALID_SESSION          = 19
70
 
MAPI_E_TYPE_NOT_SUPPORTED       = 20
71
 
MAPI_E_AMBIGUOUS_RECIPIENT      = 21
72
 
MAPI_E_AMBIG_RECIP              = MAPI_E_AMBIGUOUS_RECIPIENT
73
 
MAPI_E_MESSAGE_IN_USE           = 22
74
 
MAPI_E_NETWORK_FAILURE          = 23
75
 
MAPI_E_INVALID_EDITFIELDS       = 24
76
 
MAPI_E_INVALID_RECIPS           = 25
77
 
MAPI_E_NOT_SUPPORTED            = 26
 
64
MAPI_E_UNKNOWN_RECIPIENT = 14
 
65
MAPI_E_BAD_RECIPTYPE = 15
 
66
MAPI_E_NO_MESSAGES = 16
 
67
MAPI_E_INVALID_MESSAGE = 17
 
68
MAPI_E_TEXT_TOO_LARGE = 18
 
69
MAPI_E_INVALID_SESSION = 19
 
70
MAPI_E_TYPE_NOT_SUPPORTED = 20
 
71
MAPI_E_AMBIGUOUS_RECIPIENT = 21
 
72
MAPI_E_AMBIG_RECIP = MAPI_E_AMBIGUOUS_RECIPIENT
 
73
MAPI_E_MESSAGE_IN_USE = 22
 
74
MAPI_E_NETWORK_FAILURE = 23
 
75
MAPI_E_INVALID_EDITFIELDS = 24
 
76
MAPI_E_INVALID_RECIPS = 25
 
77
MAPI_E_NOT_SUPPORTED = 26
78
78
# Recipient class
79
 
MAPI_ORIG       = 0
80
 
MAPI_TO         = 1
 
79
MAPI_ORIG = 0
 
80
MAPI_TO = 1
81
81
# Send flags
82
 
MAPI_LOGON_UI   = 1
83
 
MAPI_DIALOG     = 8
 
82
MAPI_LOGON_UI = 1
 
83
MAPI_DIALOG = 8
 
84
 
84
85
 
85
86
class MapiRecipDesc(Structure):
86
87
    _fields_ = [
87
 
        ('ulReserved',      c_ulong),
88
 
        ('ulRecipClass',    c_ulong),
89
 
        ('lpszName',        c_char_p),
90
 
        ('lpszAddress',     c_char_p),
91
 
        ('ulEIDSize',       c_ulong),
92
 
        ('lpEntryID',       c_void_p),
 
88
        ('ulReserved', c_ulong),
 
89
        ('ulRecipClass', c_ulong),
 
90
        ('lpszName', c_char_p),
 
91
        ('lpszAddress', c_char_p),
 
92
        ('ulEIDSize', c_ulong),
 
93
        ('lpEntryID', c_void_p),
93
94
    ]
94
 
lpMapiRecipDesc  = POINTER(MapiRecipDesc)
 
95
 
 
96
 
 
97
lpMapiRecipDesc = POINTER(MapiRecipDesc)
95
98
lppMapiRecipDesc = POINTER(lpMapiRecipDesc)
96
99
 
 
100
 
97
101
class MapiFileDesc(Structure):
98
102
    _fields_ = [
99
 
        ('ulReserved',      c_ulong),
100
 
        ('flFlags',         c_ulong),
101
 
        ('nPosition',       c_ulong),
102
 
        ('lpszPathName',    c_char_p),
103
 
        ('lpszFileName',    c_char_p),
104
 
        ('lpFileType',      c_void_p),
 
103
        ('ulReserved', c_ulong),
 
104
        ('flFlags', c_ulong),
 
105
        ('nPosition', c_ulong),
 
106
        ('lpszPathName', c_char_p),
 
107
        ('lpszFileName', c_char_p),
 
108
        ('lpFileType', c_void_p),
105
109
    ]
 
110
 
 
111
 
106
112
lpMapiFileDesc = POINTER(MapiFileDesc)
107
113
 
 
114
 
108
115
class MapiMessage(Structure):
109
116
    _fields_ = [
110
 
        ('ulReserved',          c_ulong),
111
 
        ('lpszSubject',         c_char_p),
112
 
        ('lpszNoteText',        c_char_p),
113
 
        ('lpszMessageType',     c_char_p),
114
 
        ('lpszDateReceived',    c_char_p),
115
 
        ('lpszConversationID',  c_char_p),
116
 
        ('flFlags',             FLAGS),
117
 
        ('lpOriginator',        lpMapiRecipDesc),
118
 
        ('nRecipCount',         c_ulong),
119
 
        ('lpRecips',            lpMapiRecipDesc),
120
 
        ('nFileCount',          c_ulong),
121
 
        ('lpFiles',             lpMapiFileDesc),
 
117
        ('ulReserved', c_ulong),
 
118
        ('lpszSubject', c_char_p),
 
119
        ('lpszNoteText', c_char_p),
 
120
        ('lpszMessageType', c_char_p),
 
121
        ('lpszDateReceived', c_char_p),
 
122
        ('lpszConversationID', c_char_p),
 
123
        ('flFlags', FLAGS),
 
124
        ('lpOriginator', lpMapiRecipDesc),
 
125
        ('nRecipCount', c_ulong),
 
126
        ('lpRecips', lpMapiRecipDesc),
 
127
        ('nFileCount', c_ulong),
 
128
        ('lpFiles', lpMapiFileDesc),
122
129
    ]
 
130
 
 
131
 
123
132
lpMapiMessage = POINTER(MapiMessage)
124
133
 
125
 
MAPI                    = windll.mapi32
126
 
MAPISendMail            = MAPI.MAPISendMail
127
 
MAPISendMail.restype    = c_ulong
128
 
MAPISendMail.argtypes   = (LHANDLE, c_ulong, lpMapiMessage, FLAGS, c_ulong)
 
134
MAPI = windll.mapi32
 
135
MAPISendMail = MAPI.MAPISendMail
 
136
MAPISendMail.restype = c_ulong
 
137
MAPISendMail.argtypes = (LHANDLE, c_ulong, lpMapiMessage, FLAGS, c_ulong)
129
138
 
130
 
MAPIResolveName         = MAPI.MAPIResolveName
 
139
MAPIResolveName = MAPI.MAPIResolveName
131
140
MAPIResolveName.restype = c_ulong
132
 
MAPIResolveName.argtypes= (LHANDLE, c_ulong, c_char_p, FLAGS, c_ulong, lppMapiRecipDesc)
 
141
MAPIResolveName.argtypes = (
 
142
    LHANDLE, c_ulong, c_char_p, FLAGS, c_ulong, lppMapiRecipDesc)
133
143
 
134
 
MAPIFreeBuffer          = MAPI.MAPIFreeBuffer
135
 
MAPIFreeBuffer.restype  = c_ulong
 
144
MAPIFreeBuffer = MAPI.MAPIFreeBuffer
 
145
MAPIFreeBuffer.restype = c_ulong
136
146
MAPIFreeBuffer.argtypes = (c_void_p, )
137
147
 
138
 
MAPILogon               = MAPI.MAPILogon
139
 
MAPILogon.restype       = c_ulong
140
 
MAPILogon.argtypes      = (LHANDLE, c_char_p, c_char_p, FLAGS, c_ulong, LPLHANDLE)
 
148
MAPILogon = MAPI.MAPILogon
 
149
MAPILogon.restype = c_ulong
 
150
MAPILogon.argtypes = (LHANDLE, c_char_p, c_char_p, FLAGS, c_ulong, LPLHANDLE)
141
151
 
142
 
MAPILogoff              = MAPI.MAPILogoff
143
 
MAPILogoff.restype      = c_ulong
144
 
MAPILogoff.argtypes     = (LHANDLE, c_ulong, FLAGS, c_ulong)
 
152
MAPILogoff = MAPI.MAPILogoff
 
153
MAPILogoff.restype = c_ulong
 
154
MAPILogoff.argtypes = (LHANDLE, c_ulong, FLAGS, c_ulong)
145
155
 
146
156
 
147
157
class MAPIError(WindowsError):
255
265
    body = "Hi,\r\n\r\nthis is a quick test message,\r\n\r\ncheers,\r\nJohn."
256
266
    attachment = sys.argv[0]
257
267
    SendMail(recipient, subject, body, attachment)
258