1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-29 15:32:06 +01:00

Support for getting and setting private data for other users.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2064 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-08-24 14:20:44 +00:00 committed by mtucker
parent 948ab3cbb8
commit 779f6ab82f

View file

@ -134,6 +134,13 @@ public class PrivateDataManager {
private XMPPConnection connection;
/**
* The user to get and set private data for. In most cases, this value should
* be <tt>null</tt>, as the typical use of private data is to get and set
* your own private data and not others.
*/
private String user;
/**
* Creates a new private data manager. The connection must have
* undergone a successful login before being used to construct an instance of
@ -149,6 +156,26 @@ public class PrivateDataManager {
this.connection = connection;
}
/**
* Creates a new private data manager for a specific user (special case). Most
* servers only support getting and setting private data for the user that
* authenticated via the connection. However, some servers support the ability
* to get and set private data for other users (for example, if you are the
* administrator). The connection must have undergone a successful login before
* being used to construct an instance of this class.
*
* @param connection an XMPP connection which must have already undergone a
* successful login.
* @param user the XMPP address of the user to get and set private data for.
*/
public PrivateDataManager(XMPPConnection connection, String user) {
if (!connection.isAuthenticated()) {
throw new IllegalStateException("Must be logged in to XMPP server.");
}
this.connection = connection;
this.user = user;
}
/**
* Returns the private data specified by the given element name and namespace. Each chunk
* of private data is uniquely identified by an element name and namespace pair.<p>
@ -176,6 +203,10 @@ public class PrivateDataManager {
}
};
privateDataGet.setType(IQ.Type.GET);
// Address the packet to the other account if user has been set.
if (user != null) {
privateDataGet.setTo(user);
}
// Setup a listener for the reply to the set operation.
String packetID = privateDataGet.getPacketID();
@ -216,6 +247,10 @@ public class PrivateDataManager {
}
};
privateDataSet.setType(IQ.Type.SET);
// Address the packet to the other account if user has been set.
if (user != null) {
privateDataSet.setTo(user);
}
// Setup a listener for the reply to the set operation.
String packetID = privateDataSet.getPacketID();