/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-06-14 17:59:16 UTC
  • mto: This revision was merged to the branch mainline in revision 7065.
  • Revision ID: jelmer@jelmer.uk-20180614175916-a2e2xh5k533guq1x
Move breezy.plugins.git to breezy.git.

Show diffs side-by-side

added added

removed removed

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