em-imap 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of em-imap might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- An [EventMachine](http://eventmachine.org/) based [IMAP](http://tools.ietf.org/html/rfc3501) client.
1
+ An [EventMachine](http://rubyeventmachine.com/) based [IMAP](http://tools.ietf.org/html/rfc3501) client.
2
2
 
3
3
  ## Installation
4
4
 
@@ -11,6 +11,7 @@ require 'em-imap/continuation_synchronisation'
11
11
  require 'em-imap/formatter'
12
12
  require 'em-imap/command_sender'
13
13
  require 'em-imap/response_parser'
14
+ require 'em-imap/deferrable_ssl'
14
15
  require 'em-imap/connection'
15
16
 
16
17
  require 'em-imap/authenticators'
@@ -61,12 +61,22 @@ module EventMachine
61
61
 
62
62
  ## 6.2 Client Commands - Not Authenticated State
63
63
 
64
- # This would start tls negotiations, until this is implemented,
65
- # simply pass true as the first parameter to EM::IMAP.connect.
64
+ # Run a STARTTLS handshake.
66
65
  #
66
+ # C: "STARTTLS\r\n"
67
+ # S: "OK go ahead\r\n"
68
+ # C: <tls handshake>
69
+ # S: <tls handshake>
70
+ #
71
+ # Succeeds with the OK response after the TLS handshake is complete.
67
72
  def starttls
68
- raise NotImplementedError
73
+ tagged_response("STARTTLS").bind! do |response|
74
+ @connection.start_tls.transform{ response }
75
+ end
69
76
  end
77
+ # the IMAP command is STARTTLS, the eventmachine method is start_tls.
78
+ # Let's be nice to everyone and make both work.
79
+ alias_method :start_tls, :starttls
70
80
 
71
81
  # Authenticate using a custom authenticator.
72
82
  #
@@ -7,6 +7,7 @@ module EventMachine
7
7
 
8
8
  include IMAP::CommandSender
9
9
  include IMAP::ResponseParser
10
+ include IMAP::DeferrableSSL
10
11
 
11
12
  # Create a new connection to an IMAP server.
12
13
  #
@@ -0,0 +1,29 @@
1
+ module EventMachine
2
+ module IMAP
3
+
4
+ # By default it's hard to tell when the SSL handshake has finished.
5
+ # We thus wrap start_tls so that it returns a deferrable that will
6
+ # tell us when it's done.
7
+ module DeferrableSSL
8
+ # Run a TLS handshake and return a deferrable that succeeds when it's
9
+ # finished
10
+ #
11
+ # TODO: expose certificates so they can be verified.
12
+ def start_tls
13
+ unless @ssl_deferrable
14
+ @ssl_deferrable = DG::blank
15
+ bothback{ @ssl_deferrable.fail }
16
+ super
17
+ end
18
+ @ssl_deferrable
19
+ end
20
+
21
+ # Hook into ssl_handshake_completed so that we know when to succeed
22
+ # the deferrable we returned above.
23
+ def ssl_handshake_completed
24
+ @ssl_deferrable.succeed
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,49 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
4
  prerelease:
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Conrad Irwin
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-03 00:00:00.000000000Z
12
+ date: 2013-02-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: eventmachine
16
- requirement: &22042360 !ruby/object:Gem::Requirement
15
+ type: :runtime
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: *22042360
25
- - !ruby/object:Gem::Dependency
26
- name: deferrable_gratification
27
- requirement: &22041860 !ruby/object:Gem::Requirement
23
+ version_requirements: !ruby/object:Gem::Requirement
28
24
  none: false
29
25
  requirements:
30
26
  - - ! '>='
31
27
  - !ruby/object:Gem::Version
32
28
  version: '0'
29
+ name: eventmachine
30
+ - !ruby/object:Gem::Dependency
33
31
  type: :runtime
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
34
38
  prerelease: false
35
- version_requirements: *22041860
36
- - !ruby/object:Gem::Dependency
37
- name: rspec
38
- requirement: &22041400 !ruby/object:Gem::Requirement
39
+ version_requirements: !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ! '>='
42
43
  - !ruby/object:Gem::Version
43
44
  version: '0'
45
+ name: deferrable_gratification
46
+ - !ruby/object:Gem::Dependency
44
47
  type: :development
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
45
54
  prerelease: false
46
- version_requirements: *22041400
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ name: rspec
47
62
  description: Allows you to connect to an IMAP4rev1 server in a non-blocking fashion.
48
63
  email:
49
64
  - conrad@rapportive.com
@@ -53,13 +68,14 @@ extra_rdoc_files: []
53
68
  files:
54
69
  - lib/em-imap.rb
55
70
  - lib/em-imap/listener.rb
71
+ - lib/em-imap/response_parser.rb
72
+ - lib/em-imap/client.rb
73
+ - lib/em-imap/continuation_synchronisation.rb
74
+ - lib/em-imap/deferrable_ssl.rb
56
75
  - lib/em-imap/formatter.rb
76
+ - lib/em-imap/connection.rb
57
77
  - lib/em-imap/command_sender.rb
58
78
  - lib/em-imap/authenticators.rb
59
- - lib/em-imap/connection.rb
60
- - lib/em-imap/continuation_synchronisation.rb
61
- - lib/em-imap/client.rb
62
- - lib/em-imap/response_parser.rb
63
79
  - LICENSE.MIT
64
80
  - README.md
65
81
  homepage: http://github.com/rapportive-oss/em-imap
@@ -83,8 +99,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
99
  version: '0'
84
100
  requirements: []
85
101
  rubyforge_project:
86
- rubygems_version: 1.8.10
102
+ rubygems_version: 1.8.24
87
103
  signing_key:
88
104
  specification_version: 3
89
105
  summary: An EventMachine based IMAP client.
90
106
  test_files: []
107
+ has_rdoc: