24 from .Ui_EmailDialog import Ui_EmailDialog |
24 from .Ui_EmailDialog import Ui_EmailDialog |
25 |
25 |
26 from .Info import BugAddress, FeatureAddress |
26 from .Info import BugAddress, FeatureAddress |
27 import Preferences |
27 import Preferences |
28 import Utilities |
28 import Utilities |
29 from base64 import b64encode as _bencode |
29 |
30 |
|
31 from email import encoders |
|
32 from email.mime.text import MIMEText |
30 from email.mime.text import MIMEText |
33 from email.mime.image import MIMEImage |
31 from email.mime.image import MIMEImage |
34 from email.mime.audio import MIMEAudio |
32 from email.mime.audio import MIMEAudio |
35 from email.mime.application import MIMEApplication |
33 from email.mime.application import MIMEApplication |
36 from email.mime.multipart import MIMEMultipart |
34 from email.mime.multipart import MIMEMultipart |
41 |
39 |
42 ############################################################ |
40 ############################################################ |
43 ## This code is to work around a bug in the Python email ## |
41 ## This code is to work around a bug in the Python email ## |
44 ## package for Image and Audio mime messages. ## |
42 ## package for Image and Audio mime messages. ## |
45 ############################################################ |
43 ############################################################ |
46 |
|
47 |
|
48 def _encode_base64(msg): |
|
49 """ |
|
50 Function to encode the message's payload in Base64. |
|
51 |
|
52 Note: It adds an appropriate Content-Transfer-Encoding header. |
|
53 |
|
54 @param msg reference to the message object (email.Message) |
|
55 """ |
|
56 orig = msg.get_payload() |
|
57 encdata = str(_bencode(orig), "ASCII") |
|
58 msg.set_payload(encdata) |
|
59 msg['Content-Transfer-Encoding'] = 'base64' |
|
60 |
|
61 encoders.encode_base64 = _encode_base64 |
|
62 # WORK AROUND: implement our corrected encoder |
|
63 # TODO: check, if this work-around is still needed |
|
64 |
44 |
65 |
45 |
66 class EmailDialog(QDialog, Ui_EmailDialog): |
46 class EmailDialog(QDialog, Ui_EmailDialog): |
67 """ |
47 """ |
68 Class implementing a dialog to send bug reports or feature requests. |
48 Class implementing a dialog to send bug reports or feature requests. |