Class: Contacts::InboxLt
Constant Summary collapse
- DETECTED_DOMAINS =
[ /inbox\.lt/i ]
- URL =
"http://www.inbox.lt/?language=lt"
- LOGIN_URL =
"https://login.inbox.lt/redirect.php"
- ADDRESS_BOOK_URL =
"http://mail.inbox.lt/horde/turba/?char=&sort=name&page=%d"
- PROTOCOL_ERROR =
"inbox.lt has changed its protocols"
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
Instance Method Summary collapse
Methods inherited from Base
#connect, #connected?, #initialize, #login, #password
Constructor Details
This class inherits a constructor from Contacts::Base
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
9 10 11 |
# File 'lib/contacts/inbox_lt.rb', line 9 def @cookies end |
Instance Method Details
#contacts ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/contacts/inbox_lt.rb', line 42 def contacts @contacts = [] page = 0 until page.nil? url = ADDRESS_BOOK_URL % page data, resp, self., forward = get(url, self.) doc = Nokogiri(data) (doc/"form#contactsForm table table[1] tr").each do |tr| name_td = tr.at('td[2]') email_td = tr.at('td[3]') next if name_td.nil? || email_td.nil? name = name_td.text.strip email = email_td.text.strip next unless email.match('@') @contacts << [ name, email ] end page+= 1 page = nil unless data.match("&page=#{page}") end @contacts end |
#real_connect ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/contacts/inbox_lt.rb', line 11 def real_connect data, resp, self., forward = get(URL, "") doc = Nokogiri(data) salt_el = doc.at('input[name=salt]') if salt_el.nil? raise ConnectionError, PROTOCOL_ERROR end salt = salt_el['value'] postdata = "language=lt&passhash=&salt=%s&redirect_url=%s&redirect_vars=imapuser,usessl&imapuser=%s&pass=%s&usessl=1" % [ CGI.escape(salt), CGI.escape('http://www.inbox.lt/index.php?actionID=imp_login'), CGI.escape(username), CGI.escape(password) ] data, resp, self., forward = post(LOGIN_URL, postdata, "") if forward.nil? || !forward.match("logged_in=1") raise AuthenticationError, "Username and password do not match" end until forward.nil? data, resp, self., forward = get(forward, self.) end end |
#skip_gzip? ⇒ Boolean
74 75 76 |
# File 'lib/contacts/inbox_lt.rb', line 74 def skip_gzip? false end |