hohieukn / asmack

Automatically exported from code.google.com/p/asmack
Other
0 stars 0 forks source link

conn.getAccountManager().deleteAccount() - No response from server in AccountManager.java:304 #63

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What are you doing to produce the error?
1. Code in Smack (for Java - working)
        XMPPConnection x=new XMPPConnection("192.168.1.42");
        try {
            x.connect();
            x.login("markus-565-234-123", "markus");
            x.getAccountManager().deleteAccount();
        } catch (XMPPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
2. Code in ASmack - Exactly the same

What is the expected output?
A deletet user in my Openfire-Db/No Exception.

What do you see instead? (Please attach a debug enabled logcat)
Exception: No response from server.: at 
org.jivesoftware.smack.AccountManager.deleteAccount(AccountManager.java:304) ..

What version of aSmack / Android / Device do you use?
Android Emulator by Google, OS-Version: 2.2
asmack-2010.05.07.jar

What server do you use? Is there a public server to reproduce the problem?
Openfire 3.7.0 for Windows

W

Original issue reported on code.google.com by vog...@gmail.com on 10 Aug 2011 at 12:39

GoogleCodeExporter commented 8 years ago
Because i really needed it i wrote a stand-alone-fix, using the original 
smack-code.

    public void deleteFix() throws XMPPException {
        if (!con.isAuthenticated()) {
            throw new IllegalStateException("Must be logged in to delete a account.");
        }
        Registration reg = new Registration();
        reg.setType(IQ.Type.SET);
        reg.setTo(con.getServiceName());
        //Map<String, String> attributes = new HashMap<String, String>();
        // To delete an account, we add a single attribute, "remove", that is blank.
        reg.addAttribute("remove", "");
        PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
                new PacketTypeFilter(IQ.class));
        PacketCollector collector = con.createPacketCollector(filter);
        con.sendPacket(reg);
        IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
        // Stop queuing results
        collector.cancel();
        if (result == null) {
            throw new XMPPException("No response from server.");
        }
        else if (result.getType() == IQ.Type.ERROR) {
            throw new XMPPException(result.getError());
        }
    }

To fix this it should be enough to change

    public void setRemove(boolean remove){
        this.remove = remove;
    }

to

    public void setRemove(boolean remove){
        attributes.put("remove", "");
    }

in packet/Registration.java

Original comment by vog...@gmail.com on 10 Aug 2011 at 1:02