summaryrefslogtreecommitdiff
path: root/lib/net/pop.rb
diff options
context:
space:
mode:
authoraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-27 15:52:27 +0000
committeraamine <aamine@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-27 15:52:27 +0000
commit9fd5174ef3aebe3d862289b4c646e65b2400b2f9 (patch)
tree36ba0828cb3b1f2bb70a53e7661a6e9ca7162f78 /lib/net/pop.rb
parent0dcf7498b10c7fd4739b34236502efd8e0f8353c (diff)
v1.1.11
o all: use "critical" to avoid duplicated command dispatch o http.rb: change get2, post2 usage (HTTPWriter) o http.rb: entity reading algorithm is better o http.rb: more reply code (4xx, 5xx) o protocol.rb: arguments of "connect" can be omitted o protocol.rb: "quit" is not template method (now do_quit is removed) o protocol.rb: ReplyCode.error_type was not work: using module_eval git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net/pop.rb')
-rw-r--r--lib/net/pop.rb86
1 files changed, 48 insertions, 38 deletions
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 616f537..7a41e44 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -71,8 +71,9 @@ Net::Protocol
def do_start( acnt, pwd )
@command.auth( acnt, pwd )
- t = self.type.mail_type
+
@mails = []
+ t = type.mail_type
@command.list.each_with_index do |size,idx|
if size then
@mails.push t.new( idx, size, @command )
@@ -221,70 +222,81 @@ Net::POP3
def initialize( sock )
super
- check_reply SuccessCode
+ critical {
+ check_reply SuccessCode
+ }
end
def auth( acnt, pass )
- @socket.writeline 'USER ' + acnt
- check_reply_auth
-
- @socket.writeline( 'PASS ' + pass )
- ret = check_reply_auth
+ critical {
+ @socket.writeline 'USER ' + acnt
+ check_reply_auth
- return ret
+ @socket.writeline 'PASS ' + pass
+ check_reply_auth
+ }
end
def list
- getok 'LIST'
-
arr = []
- @socket.read_pendlist do |line|
- num, siz = line.split( / +/o )
- arr[ num.to_i ] = siz.to_i
- end
-
- return arr
+ critical {
+ getok 'LIST'
+ @socket.read_pendlist do |line|
+ num, siz = line.split( / +/o )
+ arr[ num.to_i ] = siz.to_i
+ end
+ }
+ arr
end
def rset
- getok 'RSET'
+ critical {
+ getok 'RSET'
+ }
end
def top( num, lines = 0, dest = '' )
- getok sprintf( 'TOP %d %d', num, lines )
- @socket.read_pendstr( dest )
+ critical {
+ getok sprintf( 'TOP %d %d', num, lines )
+ @socket.read_pendstr( dest )
+ }
end
def retr( num, dest = '', &block )
- getok sprintf( 'RETR %d', num )
- @socket.read_pendstr( dest, &block )
+ critical {
+ getok sprintf( 'RETR %d', num )
+ @socket.read_pendstr( dest, &block )
+ }
end
def dele( num )
- getok sprintf( 'DELE %d', num )
+ critical {
+ getok sprintf( 'DELE %d', num )
+ }
end
def uidl( num )
- rep = getok( sprintf 'UIDL %d', num )
- uid = rep.msg.split(' ')[1]
-
- uid
+ critical {
+ getok( sprintf 'UIDL %d', num ).msg.split(' ')[1]
+ }
end
- private
+ def quit
+ critical {
+ getok 'QUIT'
+ }
+ end
- def do_quit
- getok 'QUIT'
- end
+ private
def check_reply_auth
@@ -326,19 +338,17 @@ Net::POP3
def auth( acnt, pass )
- @socket.writeline( "APOP #{acnt} #{digest(@stamp + pass)}" )
- return check_reply_auth
+ critical {
+ @socket.writeline( "APOP #{acnt} #{digest(@stamp + pass)}" )
+ check_reply_auth
+ }
end
def digest( str )
- temp = MD5.new( str ).digest
-
ret = ''
- temp.each_byte do |i|
- ret << sprintf( '%02x', i )
- end
- return ret
+ MD5.new( str ).digest.each_byte {|i| ret << sprintf('%02x', i) }
+ ret
end
end