Permalink
Browse files

change machine required pic sipc message

  • Loading branch information...
1 parent 31b6941 commit a87db8d8f1abab35608357558e5584a32b85f669 @flyerhzm committed May 31, 2010
Showing with 18 additions and 4 deletions.
  1. +1 −1 lib/rfetion/fetion.rb
  2. +17 −3 lib/rfetion/sipc_message.rb
View
@@ -173,7 +173,7 @@ def login
url = FETION_LOGIN_URL.sub('%sid%', @sid).sub('mobileno=%mobileno%', '')
end
url.sub!('%digest%', Digest::SHA1.hexdigest("#{DOMAIN}:#{@password}"))
- url += "&pid=#@pid&pic=#@pic&algorithm=#@algorithm" if @pic
+ url += "&pid=#@pid&pic=#@pic&algorithm=#@algorithm" if @pic and !@pic.empty?
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
@@ -7,7 +7,12 @@ def self.register_first(fetion)
def self.register_second(fetion)
body = %Q|<args><device machine-code="#{fetion.machine_code}" /><caps value="ff" /><events value="7f" /><user-info mobile-no="#{fetion.mobile_no}" user-id="#{fetion.uid}"><personal version="0" attributes="v4default" /><custom-config version="0" /><contact-list version="0" buddy-attributes="v4default" /></user-info><credentials domains="fetion.com.cn;m161.com.cn;www.ikuwa.cn;games.fetion.com.cn" /><presence><basic value="400" desc="" /></presence></args>|
- sipc_create(:command => 'R', :F => fetion.sid, :I => 1, :Q => "#{fetion.next_alive} R", :A => %Q|Digest response="#{fetion.response}",algorithm="SHA1-sess-v4"|, :AK => 'ak-value', :body => body)
+ if fetion.pic and !fetion.pic.empty?
+ verify = %Q|Verify response="#{fetion.pic}",algorithm="#{fetion.algorithm}",type="GeneralPic",chid="#{fetion.pid}"|
+ sipc_create(:command => 'R', :F => fetion.sid, :I => 1, :Q => "#{fetion.next_alive} R", :A => [%Q|Digest response="#{fetion.response}",algorithm="SHA1-sess-v4"|, verify], :AK => 'ak-value', :body => body)
+ else
+ sipc_create(:command => 'R', :F => fetion.sid, :I => 1, :Q => "#{fetion.next_alive} R", :A => %Q|Digest response="#{fetion.response}",algorithm="SHA1-sess-v4"|, :AK => 'ak-value', :body => body)
+ end
end
def self.get_group_list(fetion)
@@ -188,9 +193,18 @@ def self.sipc_create(options)
body = options.delete(:body)
with_l = options.delete(:with_l)
- sorted_key = [:F, :I, :Q, :CN, :CL, :A, :AK, :X, :T, :K, :N, :SV]
+ sorted_key = [:F, :I, :Q, :CN, :CL, :A, :AK, :A, :X, :T, :K, :N, :SV]
sipc = "#{options.delete(:command)} fetion.com.cn SIP-C/4.0\r\n"
- sorted_key.each {|k| sipc += "#{k}: #{options[k]}\r\n" if options[k]}
+ sorted_key.each do |k|
+ if options[k]
+ if k == :A
+ value = options[k].is_a?(Array) ? options[k].shift : options.delete(k)
+ sipc += "#{k}: #{value}\r\n"
+ else
+ sipc += "#{k}: #{options[k]}\r\n"
+ end
+ end
+ end
sipc += "L: #{body == '' ? 4 : body.size}\r\n" if with_l
sipc += "\r\n#{body}#{Fetion::SIPP}"
sipc

0 comments on commit a87db8d

Please sign in to comment.