@@ -49,6 +49,24 @@ module SGXcatapult
iq do |i|
puts "IQ: #{i.inspect}"
+
+ if i.type == :set
+ puts "received set, likely for jabber:iq:register"
+
+ # success (for now)
+ msg = Blather::Stanza::Iq.new
+ msg.id = i.id
+ msg.to = i.from
+ msg.type = 'result'
+
+ puts "RESPONSE3: #{msg.inspect}"
+ write_to_stream msg
+ puts "SENT"
+
+ # TODO: implement this (verify/save data, return result)
+ next
+ end
+
query_node = i.children.find { |v| v.element_name == "query" }
if query_node.namespace.href ==
'http://jabber.org/protocol/disco#items'
@@ -106,6 +124,67 @@ module SGXcatapult
msg.add_child(n4)
msg.add_child(n5)
+ x = Nokogiri::XML::Node.new 'x',orig.document
+ x['xmlns'] = 'jabber:x:data'
+ x['type'] = 'form'
+ msg.add_child(x)
+
+ title = Nokogiri::XML::Node.new 'title',orig.document
+ title.content= 'Register for ' +
+ 'Soprani.ca Gateway to XMPP - Catapult'
+ x.add_child(title)
+
+ instr = Nokogiri::XML::Node.new 'instructions',
+ orig.document
+ instr.content= "Enter the details from your Account " +
+ "page as well as the Phone Number\nin your " +
+ "account you want to use (ie. '+12345678901')" +
+ ".\n\nThe source code for this gateway is at " +
+ "https://github.com/ossguy/sgx-catapult ." +
+ "\nCopyright (C) 2017 Denver Gingerich, " +
+ "licensed under AGPLv3+."
+ x.add_child(instr)
+
+ f1 = Nokogiri::XML::Node.new 'field',orig.document
+ f1['type'] = 'hidden'
+ f1['var'] = 'FORM_TYPE'
+ v1 = Nokogiri::XML::Node.new 'value',orig.document
+ v1.content= 'jabber:iq:register'
+ f1.add_child(v1)
+ x.add_child(f1)
+
+ f2 = Nokogiri::XML::Node.new 'field',orig.document
+ f2['type'] = 'text-single'
+ f2['label'] = 'User Id'
+ f2['var'] = 'user_id'
+ v2 = Nokogiri::XML::Node.new 'required',orig.document
+ f2.add_child(v2)
+ x.add_child(f2)
+
+ f3 = Nokogiri::XML::Node.new 'field',orig.document
+ f3['type'] = 'text-single'
+ f3['label'] = 'API Token'
+ f3['var'] = 'api_token'
+ v3 = Nokogiri::XML::Node.new 'required',orig.document
+ f3.add_child(v3)
+ x.add_child(f3)
+
+ f4 = Nokogiri::XML::Node.new 'field',orig.document
+ f4['type'] = 'text-private'
+ f4['label'] = 'API Secret'
+ f4['var'] = 'api_secret'
+ v4 = Nokogiri::XML::Node.new 'required',orig.document
+ f4.add_child(v4)
+ x.add_child(f4)
+
+ f5 = Nokogiri::XML::Node.new 'field',orig.document
+ f5['type'] = 'text-single'
+ f5['label'] = 'Phone Number'
+ f5['var'] = 'phone_number'
+ v5 = Nokogiri::XML::Node.new 'required',orig.document
+ f5.add_child(v5)
+ x.add_child(f5)
+
orig.add_child(msg)
puts "RESPONSE2: #{orig.inspect}"
write_to_stream orig