Merge lp:~botevmg/unity-mail/gmailThread into lp:~mitya57/unity-mail/unity-mail

Proposed by Alex Botev
Status: Merged
Merged at revision: 471
Proposed branch: lp:~botevmg/unity-mail/gmailThread
Merge into: lp:~mitya57/unity-mail/unity-mail
Diff against target: 107 lines (+34/-9)
3 files modified
UnityMail/application.py (+12/-3)
UnityMail/config.py (+5/-1)
unity-mail (+17/-5)
To merge this branch: bzr merge lp:~botevmg/unity-mail/gmailThread
Reviewer Review Type Date Requested Status
Dmitry Shachnev Pending
Review via email: mp+249778@code.launchpad.net

Description of the change

Feature added: So far if you edit the unity-mail.conf and add Inbox[] url when you click on a message it opens the mail inbox. For gmail it is possible to directly open the message thread, which is what I added. Might be a bit clumsy solution, but works great for me.

To post a comment you must log in.
Revision history for this message
Dmitry Shachnev (mitya57) wrote :

Thanks! In general looks good, but I will be able to test/merge it only next week.

lp:~botevmg/unity-mail/gmailThread updated
472. By Alex Botev

Change _ to temp as it is in fact used for gettext

Revision history for this message
Dmitry Shachnev (mitya57) wrote :

I have now merged your branch with some changes/simplifications. Thanks a lot again!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityMail/application.py'
2--- UnityMail/application.py 2014-05-05 12:08:00 +0000
3+++ UnityMail/application.py 2015-02-17 06:12:02 +0000
4@@ -85,7 +85,7 @@
5 class Message(object):
6 """Message object"""
7 def __init__(self, account_id, account_position, title, folder, message_id,
8- timestamp):
9+ timestamp, thread_id=None):
10 self.is_active = True
11 self.account_id = account_id
12 self.account_position = account_position
13@@ -93,6 +93,7 @@
14 self.folder = folder
15 self.message_id = message_id
16 self.timestamp = timestamp
17+ self.thread_id = thread_id
18
19 class UnityMail(object):
20 """Main Unity Mail Application"""
21@@ -165,7 +166,7 @@
22 if message.message_id == sourceid:
23 urlid = self.get_urlid(message.account_id)
24 if urlid:
25- open_url_or_command(urlid)
26+ open_url_or_command(name=urlid, thread=message.thread_id)
27 else:
28 self.mark_message_as_read(message)
29 if message.is_active and with_unity:
30@@ -377,6 +378,14 @@
31 for m in ui:
32 signal.alarm(3)
33 typ, msg_data = self.mail_client[cn].fetch(m, '(BODY.PEEK[HEADER])')
34+ thread_id = None
35+ if "gmail" in self.login[cn]:
36+ try:
37+ temp, thread_id = self.mail_client[cn].fetch(m, '(X-GM-THRID X-GM-MSGID)')
38+ thread_id = bytes.decode(thread_id[0])
39+ thread_id = hex(int(thread_id[thread_id.index('X-GM-THRID')+10:thread_id.index('X-GM-MSGID')].strip()))[2:]
40+ except Exception:
41+ thread_id = None
42 msg = None
43 for response_part in msg_data:
44 if isinstance(response_part, tuple):
45@@ -416,7 +425,7 @@
46 sender = sender[1:pos+1]+sender[pos+2:]
47 ilabel = subj if subj else _('No subject')
48 message = Message(account_id=cn, account_position=m, title=ilabel,
49- folder=folder_name, message_id=message_id, timestamp=timestamp)
50+ folder=folder_name, message_id=message_id, timestamp=timestamp, thread_id=thread_id)
51 self.unread_messages.append(message)
52 if self.enable_notifications:
53 self.notifications_queue.append((sender, subj, cn))
54
55=== modified file 'UnityMail/config.py'
56--- UnityMail/config.py 2014-05-05 12:08:00 +0000
57+++ UnityMail/config.py 2015-02-17 06:12:02 +0000
58@@ -57,13 +57,17 @@
59 'Inbox': 'https://mail.google.com/mail/#inbox',
60 'Sent': 'https://mail.google.com/mail/#sent' }
61
62-def open_url_or_command(name):
63+def open_url_or_command(name, thread=None):
64 config = ConfigFile(config_file_path)
65 if config.has_option('URLs', name):
66 url = config.get('URLs', name)
67 if url.startswith('Exec:'):
68 subprocess.call(url[5:], shell=True)
69 else:
70+ if thread:
71+ if url[-1] != '/':
72+ thread = '/' + thread
73+ url = url + thread
74 webbrowser.open(url)
75 else:
76 try:
77
78=== modified file 'unity-mail'
79--- unity-mail 2012-08-13 10:15:00 +0000
80+++ unity-mail 2015-02-17 06:12:02 +0000
81@@ -1,9 +1,21 @@
82 #!/usr/bin/python3
83-# Unity Mail
84+# Unity Mail, QuickList URL processor
85 # Author: Dmitry Shachnev <mitya57@gmail.com>
86 # License: GNU GPL 3 or higher; http://www.gnu.org/licenses/gpl.html
87
88-from UnityMail.application import UnityMail
89-
90-if __name__ == '__main__':
91- UnityMail()
92+import sys
93+import subprocess
94+
95+from os.path import exists
96+from UnityMail.config import config_dir, open_url_or_command, print_names
97+
98+if (exists('/usr/share/unity-mail/unity-mail-autostart.desktop') and
99+not exists(config_dir+'/autostart/unity-mail-autostart.desktop')):
100+ # First run of Unity Mail, open um-config
101+ subprocess.call('um-config')
102+elif len(sys.argv) > 1:
103+ open_url_or_command(sys.argv[1])
104+else:
105+ print('Error: please specify URL name.')
106+ print_names()
107+ sys.exit(1)

Subscribers

People subscribed via source and target branches

to all changes: