Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.Registration


            if (!BuddyList.getInstance().checkConnection()) {
                BuddyList.getInstance().connectionError();
                return;
            }

            register = new Registration();
            register.setType(IQ.Type.SET);
            register.setTo(server);

            Hashtable map = new Hashtable();
            map.put("key", regKey);
View Full Code Here


            if (!BuddyList.getInstance().checkConnection()) {
                BuddyList.getInstance().connectionError();
                return;
            }

            register = new Registration();
            register.setType(IQ.Type.GET);
            register.setTo(server);
            PacketFilter filter = new AndFilter(new PacketIDFilter(register
                    .getPacketID()), new PacketTypeFilter(IQ.class));
View Full Code Here

          return;
        if (addressid == null)
          return;
        if (!info.containsFeature("jabber:iq:register"))
          return;
        Registration reg = new Registration();
        reg.setTo(addressid);
        IQ result;
        try {
          result = account.xmpp.sendIQPacketAndWaitForReply(reg);
        } catch (XMPPException e) {
          e.printStackTrace();
          ErrorDialog.openError(sShell,"Error while retrieving registration information","Could not retrieve registration information from " + reg.getFrom() + ": " + e.getLocalizedMessage(),new Status(IStatus.ERROR,GOIMPlugin.ID,IStatus.OK,"Error while retrieving registration information.",e));
          return;
        }
        Form form = Form.getFormFrom(result);
        new FormAnswerDialog(sShell, (Registration)result, form).open();
      }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Override
    protected void okPressed() {
      setReturnCode(OK);
      Registration registration = new Registration();
      registration.setType(IQ.Type.SET);
      HashMap attributes = new HashMap();
      if(reg != null)
        registration.setTo(reg.getFrom());
      if(form == null) {
//        Text username = (Text)dialogArea.getData("username");
//        Text password = (Text)dialogArea.getData("password");
//        registration.setUsername(username.getText());
//        registration.setPassword(password.getText());
        Map<String,String> atts = reg.getAttributes();
        for(String key : atts.keySet()) {
          Text input = (Text)dialogArea.getData(key);
          if(input != null)
            attributes.put(key,input.getText());
        }
      } else {
        Form reply = form.createAnswerForm();
        Iterator i = reply.getFields();
        while(i.hasNext()) {
          FormField field = (FormField)i.next();
          if(field.getType().equals(FormField.TYPE_HIDDEN)) continue;
          Object obj = (Control)dialogArea.getData(field.getVariable());
          if(obj instanceof Text) {
            String val;
            reply.setAnswer(val = field.getVariable(),((Text)obj).getText());
//            if(field.getVariable().equals("username"))
//              registration.setUsername(val);
//            else if(field.getVariable().equals("password"))
//              registration.setPassword(val);
            if(reg != null && reg.getAttributes().containsKey(field.getVariable()))
              attributes.put(field.getVariable(),val);
          } else if(obj instanceof Button) {
            reply.setAnswer(field.getVariable(),((Button)obj).getSelection());
          }
        }
        replyValue = reply;
        if(reg != null)
          registration.addExtension(reply.getDataFormToSend());
      }
      if(reg == null) { close(); return; }
      registration.setAttributes(attributes);
      @SuppressWarnings("unused") IQ result;
      try {
        result = account.xmpp.sendIQPacketAndWaitForReply(registration);
      } catch (XMPPException e) {
        e.printStackTrace();
View Full Code Here

          PreferenceConstants.CONTACTLIST_CONFIRM_REMOVE_ENTRY_TOGGLE
          );
      if(dialog.getReturnCode() != IDialogConstants.OK_ID) return;
    }
    if(selectedEntry.getUser().indexOf('@') == -1) {
      Registration reg = new Registration();
      Map<String,String> map = new HashMap<String,String>();
      map.put("remove","");
      reg.setAttributes(map);
      reg.setType(IQ.Type.SET);
      reg.setTo(selectedEntry.getUser());
      conn.sendPacket(reg);
    }
    try {
      getRoster().removeEntry(selectedEntry);
    } catch (XMPPException e) {
View Full Code Here

     * instrucions or <tt>null</tt> if no registration is possible.
     * @throws XMPPException if an error occurs asking the registration form for the room or a
     * 405 error if the user is not allowed to register with the room.
     */
    public Form getRegistrationForm() throws XMPPException {
        Registration reg = new Registration();
        reg.setType(IQ.Type.GET);
        reg.setTo(room);

        PacketFilter filter =
            new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
        PacketCollector collector = connection.createPacketCollector(filter);
        connection.sendPacket(reg);
        IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (result == null) {
View Full Code Here

     * @throws XMPPException if an error occurs submitting the registration form. In particular, a
     *      409 error can occur if the desired room nickname is already reserved for that room;
     *      or a 503 error can occur if the room does not support registration.
     */
    public void sendRegistrationForm(Form form) throws XMPPException {
        Registration reg = new Registration();
        reg.setType(IQ.Type.SET);
        reg.setTo(room);
        reg.addExtension(form.getDataFormToSend());

        PacketFilter filter =
            new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
        PacketCollector collector = connection.createPacketCollector(filter);
        connection.sendPacket(reg);
        IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        collector.cancel();
        if (result == null) {
View Full Code Here

            throws XMPPException
    {
        if (!supportsAccountCreation()) {
            throw new XMPPException("Server does not support account creation.");
        }
        Registration reg = new Registration();
        reg.setType(IQ.Type.SET);
        reg.setTo(connection.getServiceName());
        attributes.put("username",username);
        attributes.put("password",password);
        reg.setAttributes(attributes);
        PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
                new PacketTypeFilter(IQ.class));
        PacketCollector collector = connection.createPacketCollector(filter);
        connection.sendPacket(reg);
        IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
View Full Code Here

     *
     * @throws IllegalStateException if not currently logged-in to the server.
     * @throws XMPPException if an error occurs when changing the password.
     */
    public void changePassword(String newPassword) throws XMPPException {
        Registration reg = new Registration();
        reg.setType(IQ.Type.SET);
        reg.setTo(connection.getServiceName());
        Map<String, String> map = new HashMap<String, String>();
        map.put("username",StringUtils.parseName(connection.getUser()));
        map.put("password",newPassword);
        reg.setAttributes(map);
        PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
                new PacketTypeFilter(IQ.class));
        PacketCollector collector = connection.createPacketCollector(filter);
        connection.sendPacket(reg);
        IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
View Full Code Here

     */
    public void deleteAccount() throws XMPPException {
        if (!connection.isAuthenticated()) {
            throw new IllegalStateException("Must be logged in to delete a account.");
        }
        Registration reg = new Registration();
        reg.setType(IQ.Type.SET);
        reg.setTo(connection.getServiceName());
        Map<String, String> attributes = new HashMap<String, String>();
        // To delete an account, we add a single attribute, "remove", that is blank.
        attributes.put("remove", "");
        reg.setAttributes(attributes);
        PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
                new PacketTypeFilter(IQ.class));
        PacketCollector collector = connection.createPacketCollector(filter);
        connection.sendPacket(reg);
        IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.Registration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.