commit 939fcb4f4d4eaff2d1f462270afadc13a95798b4
Author: nonamedotc <nonamedotc(a)fedoraproject.org>
Date: Sat Feb 28 17:17:44 2015 -0600
Update to 0.10.3
- Remove upstreamed patches
.gitignore | 3 -
internet-mail-24.png | Bin 0 -> 1371 bytes
internet-mail-48.png | Bin 0 -> 2231 bytes
mailtoparse.py | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 178 insertions(+), 3 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ff6f91d..e36b1df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,6 @@
exo-0.3.107.tar.bz2
/exo-0.5.6.tar.bz2
/exo-0.6.0.tar.bz2
-/internet-mail-24.png
-/internet-mail-48.png
/exo-0.6.1.tar.bz2
/exo-0.6.2.tar.bz2
/exo-0.7.2.tar.bz2
@@ -11,5 +9,4 @@ exo-0.3.107.tar.bz2
/exo-0.10.0.tar.bz2
/exo-0.10.1.tar.bz2
/exo-0.10.2.tar.bz2
-/mailtoparse.py
/exo-0.10.3.tar.bz2
diff --git a/internet-mail-24.png b/internet-mail-24.png
new file mode 100644
index 0000000..aeb54ec
Binary files /dev/null and b/internet-mail-24.png differ
diff --git a/internet-mail-48.png b/internet-mail-48.png
new file mode 100644
index 0000000..d06fdf5
Binary files /dev/null and b/internet-mail-48.png differ
diff --git a/mailtoparse.py b/mailtoparse.py
new file mode 100644
index 0000000..63a621e
--- /dev/null
+++ b/mailtoparse.py
@@ -0,0 +1,178 @@
+#!/usr/bin/python -tt
+# skvidal(a)fedoraproject.org
+# (c) red hat, inc 2013
+# gpl whatever
+# this is a direct port of exo-compos-mail-1 from xfce
+# from perl to python
+# the idea is to dump the 2000000000 perl pkgs pulled in
+# by this for a single item :(
+# it should handle all the behaviour the same
+# it probably has bugs
+
+# TODO:
+# - figure out what the attachment parsing is trying to do
+# - figure out if rebuilding the mailto for evo, sylpheed and balsa
+# is actually necessary or not - feels silly but I'm not shocked by silly
+# - would be nice to have an actual set of tests :)
+
+
+
+import sys
+import posix
+import os
+import urlparse
+import urllib
+
+
+def parse_url(mailto):
+ urlparse.uses_query.append('mailto')
+ url = urlparse.urlparse(mailto)
+ res = {}
+ to = []
+ query = None
+
+ if url.query or '?' not in url.path:
+ if url.path:
+ to.append(urlparse.unquote(url.path))
+
+ else:
+ (thisto, ques, query) = url.path.partition('?')
+ if thisto.strip():
+ to.append(urlparse.unquote(thisto))
+
+ if not query:
+ query = url.query
+
+ q_dict = urlparse.parse_qs(query)
+ to.extend(q_dict.get('to', []))
+ res['to'] = to
+ if 'to' in q_dict:
+ del(q_dict['to'])
+
+ res.update(q_dict)
+ return res
+
+
+
+if len(sys.argv) < 3:
+ print >> sys.stderr, "Usage: %s <style> <binary> <mailto>" % (sys.argv[0])
+ sys.exit(1)
+
+
+style = sys.argv[1]
+binary = sys.argv[2]
+raw_mailto = sys.argv[3]
+mailto = parse_url(raw_mailto)
+
+
+to = mailto.get('to', [])
+cc = mailto.get('cc', [])
+bcc = mailto.get('bcc', [])
+subject = mailto.get('subject', '')
+body = '\n'.join(mailto.get('body', []))
+attachments = mailto.get('attachment',[])
+
+args = []
+if style == 'mozilla':
+
+ command = "to='" + ','.join(to) + "'"
+ command += ",cc='" + ','.join(cc) + "'"
+ command += ",bcc='" + ','.join(bcc) + "'"
+ command += ",attachment='" + ','.join(attachments) + "'"
+ if subject:
+ command += ",subject='" + subject + "'"
+ if body:
+ command += ",body='" + body + "'"
+
+ args.append('-compose')
+ args.append(command)
+
+elif style == 'mozilla-remote':
+ # generate xfeDoCommand(composeMessage, ...) string
+ command = 'xfeDoCommand(composeMessage'
+ command += ",to='" + ','.join(to) + "'"
+ command += ",cc='" + ','.join(cc) + "'";
+ command += ",bcc='" + ','.join(bcc) + "'"
+ command += ",attachment='" + ','.join(attachments) + "'"
+ if subject:
+ command += ",subject='" + subject + "'"
+ if body:
+ command += ",body='" + body + "'"
+
+ command += ')';
+
+ # and add the parameters to the argv
+ args.append('-remote')
+ args.append(command)
+
+elif style == 'evolution':
+ # evo takes a mailto uri and parses it itself
+ # just hand back what we were handed originally
+ # note - it my want them to be url_escaped first? or not?
+ args.append(raw_mailto)
+
+elif style == 'kmail':
+ if len(to) >= 1:
+ baseaddr = to[0]
+ cc.extend(to[1:])
+ else:
+ baseaddr = " "
+
+ for item in cc:
+ args.append('--cc')
+ args.append(item)
+ for item in bcc:
+ args.append('--bcc')
+ args.append(item)
+ for item in attachments:
+ args.append('--attach')
+ args.append(item)
+ if subject:
+ args.append('--subject')
+ args.append(subject)
+ if body:
+ args.append('--body')
+ args.append('\n'.join(body))
+ args.append('--composer')
+ args.append(baseaddr)
+
+elif style == 'sylpheed':
+ args.append('--compose')
+ args.append(raw_mailto)
+ # fixme - do attachments separately
+
+elif style == 'balsa': # cmon, balsa? really?
+ args.append('--compose')
+ args.append(raw_mailto)
+ # fixme - do attachments separately
+
+elif style == 'mutt':
+ for item in cc:
+ args.append('-c')
+ args.append(item)
+ for item in attachments:
+ args.append('-a')
+ args.append(item)
+ if subject:
+ args.append('-s')
+ args.append(subject)
+ for item in to:
+ args.append(item)
+ if to:
+ args.append('')
+
+
+
+else:
+ print >> sys.stderr, "%s: Unsupported style '%s'." % (sys.argv[0], style)
+ sys.exit(1)
+
+# try to execute the generated command
+posix.execv(binary,args)
+#DEBUG
+#print binary,
+#print ' '.join(args)
+#sys.exit(0)
+#ENDDEBUG
+# something went wrong
+sys.exit(1)
\ No newline at end of file