mournmail 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3e35ed64af5fb25eeedad4c3c901b93125baf6b561b8e2384da7a9ed602b367
4
- data.tar.gz: 9174888f40a57d0cffe48d13fef7cc0d2892be312d3ff0b95a0df7aef098c726
3
+ metadata.gz: 9e37a11a19a93dfc9f11a9b9bb98bf3c4c20454668a1d6315627500ec313dc88
4
+ data.tar.gz: b8d099a3e67cd35761dab9789f5a3af7c13ebb98f152bf1c031d48d88e4ad69a
5
5
  SHA512:
6
- metadata.gz: f85ebaadd8f97a43e45856347ad0149594ab17db31c04ba66d85db61b336f3c7cd4548c725868a44522d87941297edc5ad5656901440400f834017ed2e650733
7
- data.tar.gz: ddff53280fad3432e0bf0da11cf58c57a60586886828fa512b1bf54cba8e57afc8e2687561ae8b289d95fde271b1679f7da4de56e451b4fd6c00ec9787ccd095
6
+ metadata.gz: 999cb57363f9df4f2bc00eca563b93c61d32c7409e27d628d2ed2c27763af80688886d9b034570ed4291bd92251c5a7c4ae2a8942ea35aa01e7928d365675e8b
7
+ data.tar.gz: 96c435e264104b3ebbd1b71d5d561f7a7c207a8c1ee05f1b687192e4811b3b2ef1c7f476a8d2c0655ce452f2e577cfaff5a4c79a9fd28e9d9dc5fbe51944ed3a
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "groonga"
4
+
5
+ if ARGV.size < 1
6
+ STDERR.puts "Usage: mournmail_reindex <path to messages.db>"
7
+ exit 1
8
+ end
9
+
10
+ Groonga::Database.open(ARGV[0])
11
+ Groonga["Messages"].columns.each do |c|
12
+ print "Reindexing #{c.name}... "
13
+ STDOUT.flush
14
+ c.reindex
15
+ puts "done"
16
+ end
@@ -7,6 +7,7 @@ module Mournmail
7
7
  MAIL_MODE_MAP.define_key("\t", :draft_complete_or_insert_tab_command)
8
8
  MAIL_MODE_MAP.define_key("\C-c\C-xv", :draft_pgp_sign_command)
9
9
  MAIL_MODE_MAP.define_key("\C-c\C-xe", :draft_pgp_encrypt_command)
10
+ MAIL_MODE_MAP.define_key("\C-c\t", :insert_signature_command)
10
11
 
11
12
  define_syntax :field_name, /^[A-Za-z\-]+: /
12
13
  define_syntax :quotation, /^>.*/
@@ -78,7 +79,7 @@ module Mournmail
78
79
  conf[:delivery_method],
79
80
  options)
80
81
  bury_buffer(@buffer)
81
- background do
82
+ Mournmail.background do
82
83
  begin
83
84
  if !attached_messages.empty?
84
85
  attached_messages.each do |attached_message|
@@ -181,6 +182,10 @@ module Mournmail
181
182
  end
182
183
  end
183
184
 
185
+ define_local_command(:insert_signature, doc: "Insert signature.") do
186
+ @buffer.insert(CONFIG[:signature])
187
+ end
188
+
184
189
  private
185
190
 
186
191
  def end_of_header
@@ -167,7 +167,7 @@ module Mournmail
167
167
 
168
168
  define_local_command(:summary_toggle_deleted,
169
169
  doc: <<~EOD) do
170
- Toggle Deleted. Type `x` to expunge deleted messages.
170
+ Toggle Deleted. Type `X` to expunge deleted messages.
171
171
  EOD
172
172
  toggle_flag(selected_uid, :Deleted)
173
173
  end
@@ -66,7 +66,9 @@ module Mournmail
66
66
  define_variable :current_uid, attr: :accessor
67
67
  define_variable :current_mail, attr: :accessor
68
68
  define_variable :background_thread, attr: :accessor
69
+ define_variable :background_thread_mutex, initial_value: Mutex.new
69
70
  define_variable :keep_alive_thread, attr: :accessor
71
+ define_variable :keep_alive_thread_mutex, initial_value: Mutex.new
70
72
  define_variable :imap
71
73
  define_variable :imap_mutex, initial_value: Mutex.new
72
74
  define_variable :mailboxes, initial_value: []
@@ -75,42 +77,52 @@ module Mournmail
75
77
  define_variable :groonga_db
76
78
 
77
79
  def self.background(skip_if_busy: false)
78
- if background_thread&.alive?
79
- return if skip_if_busy
80
- end
81
- self.background_thread = Utils.background {
82
- begin
83
- yield
84
- ensure
85
- self.background_thread = nil
80
+ @background_thread_mutex.synchronize do
81
+ if background_thread&.alive?
82
+ if skip_if_busy
83
+ return
84
+ else
85
+ raise EditorError, "Another background thread is running"
86
+ end
86
87
  end
87
- }
88
+ self.background_thread = Utils.background {
89
+ begin
90
+ yield
91
+ ensure
92
+ self.background_thread = nil
93
+ end
94
+ }
95
+ end
88
96
  end
89
97
 
90
98
  def self.start_keep_alive_thread
91
- if keep_alive_thread
92
- raise EditorError, "Keep alive thread already running"
93
- end
94
- self.keep_alive_thread = Thread.start {
95
- loop do
96
- sleep(CONFIG[:mournmail_keep_alive_interval])
97
- background(skip_if_busy: true) do
98
- begin
99
- imap_connect do |imap|
100
- imap.noop
99
+ @keep_alive_thread_mutex.synchronize do
100
+ if keep_alive_thread
101
+ raise EditorError, "Keep alive thread already running"
102
+ end
103
+ self.keep_alive_thread = Thread.start {
104
+ loop do
105
+ sleep(CONFIG[:mournmail_keep_alive_interval])
106
+ background(skip_if_busy: true) do
107
+ begin
108
+ imap_connect do |imap|
109
+ imap.noop
110
+ end
111
+ rescue => e
112
+ message("Error in IMAP NOOP: #{e.class}: #{e.message}")
101
113
  end
102
- rescue => e
103
- message("Error in IMAP NOOP: #{e.class}: #{e.message}")
104
114
  end
105
115
  end
106
- end
107
- }
116
+ }
117
+ end
108
118
  end
109
119
 
110
120
  def self.stop_keep_alive_thread
111
- if keep_alive_thread
112
- keep_alive_thread&.kill
113
- self.keep_alive_thread = nil
121
+ @keep_alive_thread_mutex.synchronize do
122
+ if keep_alive_thread
123
+ keep_alive_thread&.kill
124
+ self.keep_alive_thread = nil
125
+ end
114
126
  end
115
127
  end
116
128
 
@@ -228,14 +240,22 @@ module Mournmail
228
240
  :scope => 'https://mail.google.com/',
229
241
  :redirect_uri => 'urn:ietf:wg:oauth:2.0:oob'
230
242
  )
231
-
232
243
  auth_uri = auth_client.authorization_uri.to_s
233
- Launchy.open(auth_uri)
234
-
235
244
  auth_client.code = foreground! {
236
- Window.echo_area.clear_message
237
- Window.redisplay
238
- read_from_minibuffer("Code: ").chomp
245
+ begin
246
+ Launchy.open(auth_uri)
247
+ rescue Launchy::CommandNotFoundError
248
+ buffer = show_google_auth_uri(auth_uri)
249
+ end
250
+ begin
251
+ Window.echo_area.clear_message
252
+ Window.redisplay
253
+ read_from_minibuffer("Code: ").chomp
254
+ ensure
255
+ if buffer
256
+ kill_buffer(buffer, force: true)
257
+ end
258
+ end
239
259
  }
240
260
  auth_client.fetch_access_token!
241
261
  old_umask = File.umask(077)
@@ -249,6 +269,23 @@ module Mournmail
249
269
  end
250
270
  auth_client.access_token
251
271
  end
272
+
273
+ def self.show_google_auth_uri(auth_uri)
274
+ buffer = Buffer.find_or_new("*message*",
275
+ undo_limit: 0, read_only: true)
276
+ buffer.apply_mode(Mournmail::MessageMode)
277
+ buffer.read_only_edit do
278
+ buffer.clear
279
+ buffer.insert(<<~EOF)
280
+ Open the following URI in your browser and type obtained code:
281
+
282
+ #{auth_uri}
283
+ EOF
284
+ end
285
+ window = Mournmail.message_window
286
+ window.buffer = buffer
287
+ buffer
288
+ end
252
289
 
253
290
  def self.xoauth2_string(user, access_token)
254
291
  "user=#{user}\1auth=Bearer #{access_token}\1\1"
@@ -1,3 +1,3 @@
1
1
  module Mournmail
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mournmail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: textbringer
@@ -125,7 +125,8 @@ dependencies:
125
125
  description: A message user agent for Textbringer.
126
126
  email:
127
127
  - shugo@ruby-lang.org
128
- executables: []
128
+ executables:
129
+ - mournmail_reindex
129
130
  extensions: []
130
131
  extra_rdoc_files: []
131
132
  files:
@@ -136,6 +137,7 @@ files:
136
137
  - Rakefile
137
138
  - bin/console
138
139
  - bin/setup
140
+ - exe/mournmail_reindex
139
141
  - lib/mournmail.rb
140
142
  - lib/mournmail/commands.rb
141
143
  - lib/mournmail/config.rb
@@ -155,7 +157,7 @@ homepage: https://github.com/shugo/mournmail
155
157
  licenses:
156
158
  - MIT
157
159
  metadata: {}
158
- post_install_message:
160
+ post_install_message:
159
161
  rdoc_options: []
160
162
  require_paths:
161
163
  - lib
@@ -170,8 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
172
  - !ruby/object:Gem::Version
171
173
  version: '0'
172
174
  requirements: []
173
- rubygems_version: 3.2.0.pre1
174
- signing_key:
175
+ rubygems_version: 3.2.3
176
+ signing_key:
175
177
  specification_version: 4
176
178
  summary: A message user agent for Textbringer.
177
179
  test_files: []