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
=== modified file 'UnityMail/application.py'
--- UnityMail/application.py 2014-05-05 12:08:00 +0000
+++ UnityMail/application.py 2015-02-17 06:12:02 +0000
@@ -85,7 +85,7 @@
85class Message(object):85class Message(object):
86 """Message object"""86 """Message object"""
87 def __init__(self, account_id, account_position, title, folder, message_id,87 def __init__(self, account_id, account_position, title, folder, message_id,
88 timestamp):88 timestamp, thread_id=None):
89 self.is_active = True89 self.is_active = True
90 self.account_id = account_id90 self.account_id = account_id
91 self.account_position = account_position91 self.account_position = account_position
@@ -93,6 +93,7 @@
93 self.folder = folder93 self.folder = folder
94 self.message_id = message_id94 self.message_id = message_id
95 self.timestamp = timestamp95 self.timestamp = timestamp
96 self.thread_id = thread_id
9697
97class UnityMail(object):98class UnityMail(object):
98 """Main Unity Mail Application"""99 """Main Unity Mail Application"""
@@ -165,7 +166,7 @@
165 if message.message_id == sourceid:166 if message.message_id == sourceid:
166 urlid = self.get_urlid(message.account_id)167 urlid = self.get_urlid(message.account_id)
167 if urlid:168 if urlid:
168 open_url_or_command(urlid)169 open_url_or_command(name=urlid, thread=message.thread_id)
169 else:170 else:
170 self.mark_message_as_read(message)171 self.mark_message_as_read(message)
171 if message.is_active and with_unity:172 if message.is_active and with_unity:
@@ -377,6 +378,14 @@
377 for m in ui:378 for m in ui:
378 signal.alarm(3)379 signal.alarm(3)
379 typ, msg_data = self.mail_client[cn].fetch(m, '(BODY.PEEK[HEADER])')380 typ, msg_data = self.mail_client[cn].fetch(m, '(BODY.PEEK[HEADER])')
381 thread_id = None
382 if "gmail" in self.login[cn]:
383 try:
384 temp, thread_id = self.mail_client[cn].fetch(m, '(X-GM-THRID X-GM-MSGID)')
385 thread_id = bytes.decode(thread_id[0])
386 thread_id = hex(int(thread_id[thread_id.index('X-GM-THRID')+10:thread_id.index('X-GM-MSGID')].strip()))[2:]
387 except Exception:
388 thread_id = None
380 msg = None389 msg = None
381 for response_part in msg_data:390 for response_part in msg_data:
382 if isinstance(response_part, tuple):391 if isinstance(response_part, tuple):
@@ -416,7 +425,7 @@
416 sender = sender[1:pos+1]+sender[pos+2:]425 sender = sender[1:pos+1]+sender[pos+2:]
417 ilabel = subj if subj else _('No subject')426 ilabel = subj if subj else _('No subject')
418 message = Message(account_id=cn, account_position=m, title=ilabel,427 message = Message(account_id=cn, account_position=m, title=ilabel,
419 folder=folder_name, message_id=message_id, timestamp=timestamp)428 folder=folder_name, message_id=message_id, timestamp=timestamp, thread_id=thread_id)
420 self.unread_messages.append(message)429 self.unread_messages.append(message)
421 if self.enable_notifications:430 if self.enable_notifications:
422 self.notifications_queue.append((sender, subj, cn))431 self.notifications_queue.append((sender, subj, cn))
423432
=== modified file 'UnityMail/config.py'
--- UnityMail/config.py 2014-05-05 12:08:00 +0000
+++ UnityMail/config.py 2015-02-17 06:12:02 +0000
@@ -57,13 +57,17 @@
57 'Inbox': 'https://mail.google.com/mail/#inbox',57 'Inbox': 'https://mail.google.com/mail/#inbox',
58 'Sent': 'https://mail.google.com/mail/#sent' }58 'Sent': 'https://mail.google.com/mail/#sent' }
5959
60def open_url_or_command(name):60def open_url_or_command(name, thread=None):
61 config = ConfigFile(config_file_path)61 config = ConfigFile(config_file_path)
62 if config.has_option('URLs', name):62 if config.has_option('URLs', name):
63 url = config.get('URLs', name)63 url = config.get('URLs', name)
64 if url.startswith('Exec:'):64 if url.startswith('Exec:'):
65 subprocess.call(url[5:], shell=True)65 subprocess.call(url[5:], shell=True)
66 else:66 else:
67 if thread:
68 if url[-1] != '/':
69 thread = '/' + thread
70 url = url + thread
67 webbrowser.open(url)71 webbrowser.open(url)
68 else:72 else:
69 try:73 try:
7074
=== modified file 'unity-mail'
--- unity-mail 2012-08-13 10:15:00 +0000
+++ unity-mail 2015-02-17 06:12:02 +0000
@@ -1,9 +1,21 @@
1#!/usr/bin/python31#!/usr/bin/python3
2# Unity Mail2# Unity Mail, QuickList URL processor
3# Author: Dmitry Shachnev <mitya57@gmail.com>3# Author: Dmitry Shachnev <mitya57@gmail.com>
4# License: GNU GPL 3 or higher; http://www.gnu.org/licenses/gpl.html4# License: GNU GPL 3 or higher; http://www.gnu.org/licenses/gpl.html
55
6from UnityMail.application import UnityMail6import sys
77import subprocess
8if __name__ == '__main__':8
9 UnityMail()9from os.path import exists
10from UnityMail.config import config_dir, open_url_or_command, print_names
11
12if (exists('/usr/share/unity-mail/unity-mail-autostart.desktop') and
13not exists(config_dir+'/autostart/unity-mail-autostart.desktop')):
14 # First run of Unity Mail, open um-config
15 subprocess.call('um-config')
16elif len(sys.argv) > 1:
17 open_url_or_command(sys.argv[1])
18else:
19 print('Error: please specify URL name.')
20 print_names()
21 sys.exit(1)

Subscribers

People subscribed via source and target branches

to all changes: