public class UserManager extends AbstractPacketForwarder implements PacketCollector
UserManager is the top level entity which has all the convinience
method required to add, retrieve and update user related data. Most of the
times, UserManager processes IQ packets. Primary
responsibility includes user login, user signup, user logout, roster
management and Chatroom/Group related APIs.
UserManager allows both asynchronous and synchronous invocation of
exposed APIs. Additionally, developer can supply a Callback instance
to be invoked once the request to server is complete.
| Constructor and Description |
|---|
UserManager(XMPPStreamManager streamManager,
ResponseCorrelator correlator) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addChatRoomAdmin(JID roomJID,
JID userJID)
Request to add chat room admin.
|
boolean |
addChatRoomMember(JID roomJID,
JID userJID)
Request to add chat room member.
|
boolean |
addChatRoomOwner(JID roomJID,
JID userJID)
Request to add chat room owner.
|
boolean |
addRosterMember(JID jid,
String name)
Request to add a memeber to the user Roster.
|
boolean |
changePassword(String newPassword)
Use it change user login password and refer XEP-0077.
|
boolean |
changeUserAvatar(File file)
User it to change user avatar.
|
boolean |
changeUserAvatar(File file,
String imageType)
User it to change user avatar.
|
boolean |
changeUserAvatar(URL url)
User it to change user avatar.
|
boolean |
changeUserAvatar(URL url,
String imageType)
User it to change user avatar.
|
void |
collect(Packet packet)
This collector takes the given packet.
|
boolean |
createInstantRoom(String roomName)
It create instant Room with default configurations.
|
boolean |
createPrivateRoom(String roomName)
Create public room with given room name.
|
boolean |
createPublicRoom(String roomName)
Create public room with given room name.
|
boolean |
createReservedRoom(String roomName,
Map<ChatRoom.RoomConfigParam,String> configs)
Request to create group with some configurations rather than default
configuration (private group)
|
boolean |
destroyChatRoom(JID roomJID,
String reason)
Destroy chat room.
|
boolean |
discardDeviceToken(String regId,
PushNotificationService service,
DeviceType deviceType,
String deviceId)
On log out Client app developer have to un register device token.
|
Set<ChatRoom.RoomConfigParam> |
getChatRoomConfigParams(JID roomJID)
Request to get list of room configurations which can be updated.
|
boolean |
getFullRoster(Callback<Roster,Exception> callback)
Retrieve full user roster from server.
|
IQ |
getRoster(int version)
Retrieve user Roster from server.
|
UserProfileData |
getUserProfileData()
It return logged in user's data.
|
UserProfileData |
getUserProfileData(JID userJID)
It return given user's data.
|
Set<String> |
getUserRegistrationAttributes()
Returns all required attributes to register new user.
|
Set<String> |
getUserSearchAttributes()
It Returns all server supported attributes for searching a user.
|
boolean |
registerNewUser(String userName,
String email,
String password)
Uses it for In-Band User Registration and refer XEP-0077.
|
void |
registerNewUser(String userName,
String email,
String password,
Callback<String,String> callback)
Register a new user
|
boolean |
removeChatRoomMember(JID roomJID,
JID userJID)
Request to Remove member from chat room.
|
boolean |
removeRosterMember(JID jid)
Remove Roster member from logged-in user Roster.
|
IQ |
removeRosterMember(JID jid,
String name,
Callback<IQ,Exception> callback)
Remove a roster member from logged-in user roster.
|
boolean |
removeUserAvatar()
Use it to remove user avatar.
|
List<UserSearchData.Item> |
searchUser(String firstName,
String lastName,
String nickName,
String email)
This method returns list of matched users.
|
List<UserSearchData.Item> |
searchUserWithEmail(String email)
This method returns list of matched users.
|
List<UserSearchData.Item> |
searchUserWithFirstName(String firstName)
This method returns list of matched users.
|
List<UserSearchData.Item> |
searchUserWithLastName(String lastName)
This method returns list of matched users.
|
List<UserSearchData.Item> |
searchUserWithNickName(String nickName)
This method returns list of matched users.
|
void |
sendAddChatRoomMemberRequest(JID roomJID,
JID userJID)
Request to add chat room member.
|
boolean |
sendAddRosterMemberRequest(JID jid,
String name)
Send request to add a memeber to the user Roster.
|
boolean |
sendChangeUserNicknameRequest(JID roomJID,
String nickName)
Request to change user nick name in given chat room
|
boolean |
sendGetChatRoomInfoRequest(JID roomJID)
Request to get info of chat room.
|
boolean |
sendGetChatRoomMembersRequest(JID roomJID)
Send request to retrieve memebers list of a chatroom.
|
boolean |
sendGetChatRoomsRequest()
Send a request to retreive list of availave chat rooms on server.
|
void |
sendGetChatRoomsRequest(Callback<List<ChatRoom>,Exception> callback)
Send a request to retrieve list of available chat rooms on server.
|
boolean |
sendGetFullRosterRequest()
Retrieve full user roster from server.
|
boolean |
sendGetRosterRequest(int version)
Send a request to server to retrieve a particular version of user Roster.
|
boolean |
sendJoinChatRoomRequest(JID roomJID,
String nickName)
Request to join a ChatRoom.
|
boolean |
sendLeaveChatRoomRequest(JID roomJID)
Request to leave a ChatRoom
|
boolean |
sendRemoveRosterMemberRequest(JID jid,
String name)
Send request to remove Roster member from logged-in user Roster.
|
boolean |
sendUpdateRosterMemberNameRequest(JID jid,
String name)
Send request to server to update Roster member name.
|
boolean |
unRegisterUser()
Use it deactivate logged in user account and refer XEP-0077.
|
boolean |
updateChatRoomMember(JID roomJID,
JID userJID,
String nickName,
ChatRoom.Affiliation affiliation,
ChatRoom.Role role)
Request to update chat room member.
|
boolean |
updateDeviceToken(String token,
PushNotificationService service,
DeviceType deviceType,
String deviceId)
Update device push notification registration id on server.
|
boolean |
updateRoomSubject(JID roomJID,
String subject)
Send a request to change Chat room subject.
|
boolean |
updateRosterMemberName(JID jid,
String name)
Request to server to update Roster member name.
|
IQ |
updateRosterMemberName(JID jid,
String name,
Callback<IQ,Exception> callback)
Update name of a roster member.
|
boolean |
updateUserProfileData(String firstName,
String middleName,
String lastName,
String nickName,
String email,
String phone,
String gender,
String birthDay,
String addressHome,
String addressStreet,
String addressLocality,
String addressCity,
String addressState,
String addressCountry,
String addressPCode,
String about)
Use it to update user profile data.
|
boolean |
updateUserProfileData(UserProfileData userProfileData)
return true if user data is updated successfully.
|
addPacketCollector, addPacketCollector, forwardDefault, forwardPacket, removePacketCollector, removePacketCollectorpublic UserManager(XMPPStreamManager streamManager, ResponseCorrelator correlator)
public boolean sendGetFullRosterRequest()
Event.EventType.ROSTER_RECEIVE is pushed on to EventBus.
Application can write an EventHandler for the event type and
handle the received Roster.public boolean getFullRoster(Callback<Roster,Exception> callback)
Event.EventType.ROSTER_RECEIVE is pushed on to EventBus.
Application can write an EventHandler for the event type and
handle the received Roster.callback - callback instancepublic boolean sendGetRosterRequest(int version)
Event.EventType.ROSTER_RECEIVE event is pushed on to
EventBus. Applications can create and subscribe an
EventHandler for this event type.version - Roster version to be retrievedpublic IQ getRoster(int version) throws TimeoutException
version - Roster version; 0 indicates full RosterIQ packet with Roster responseTimeoutException - if server does not reply in configured time.public boolean sendAddRosterMemberRequest(JID jid, String name)
jid - JID of the user who will be added to Rostername - name of user who will be added to Rosterpublic IQ updateRosterMemberName(JID jid, String name, Callback<IQ,Exception> callback)
Callback will be invoked once response arrives. If
Server fails to respond in stipulated reply time, Callback will
be invoked with TimeoutExceptionpublic boolean sendUpdateRosterMemberNameRequest(JID jid, String name)
IQ packet to server with supplied correlation id as the
packet id.jid - JID of the membername - new name of the memberpublic IQ removeRosterMember(JID jid, String name, Callback<IQ,Exception> callback)
Callback will be invoked once
response arrives. If Server fails to respond in stipulated reply time,
Callback will be invoked with TimeoutExceptionpublic boolean sendRemoveRosterMemberRequest(JID jid, String name)
IQ packet to server with supplied
correlation id as the packet id.jid - JID of the membername - new name of the memberpublic boolean addRosterMember(JID jid, String name)
jid - JID of the user who will be added to Rostername - name of the member if name is not specified that Roster
member name will be default name of that user.public boolean removeRosterMember(JID jid)
IQ packet to server with supplied correlation id as the packet
id.jid - JID of the memberpublic boolean updateRosterMemberName(JID jid, String name)
IQ packet to server with supplied correlation id as the packet
id.jid - JID of the membername - new name of the member if name is not specified that Roster
member name will be default name of that user.public boolean sendGetChatRoomsRequest()
public void sendGetChatRoomsRequest(Callback<List<ChatRoom>,Exception> callback)
callback - Callback instance for invocationpublic boolean sendGetChatRoomMembersRequest(JID roomJID)
roomJID - room JIDpublic boolean sendGetChatRoomInfoRequest(JID roomJID)
roomJID - JID of the chatroompublic boolean sendChangeUserNicknameRequest(JID roomJID, String nickName)
roomJID - JID of the chatroomnickName - nickNamepublic boolean sendJoinChatRoomRequest(JID roomJID, String nickName)
roomJID - JID of the chatroomnickName - nickNamepublic boolean sendLeaveChatRoomRequest(JID roomJID)
roomJID - JID of the roompublic void sendAddChatRoomMemberRequest(JID roomJID, JID userJID)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER. otherwise request
will failedpublic boolean addChatRoomAdmin(JID roomJID, JID userJID)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER otherwise request
will failedpublic boolean addChatRoomOwner(JID roomJID, JID userJID)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER otherwise request
will failedpublic boolean addChatRoomMember(JID roomJID, JID userJID)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER otherwise request
will failedpublic boolean removeChatRoomMember(JID roomJID, JID userJID)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER. otherwise request
will failedpublic boolean updateChatRoomMember(JID roomJID, JID userJID, String nickName, ChatRoom.Affiliation affiliation, ChatRoom.Role role)
ChatRoom.Affiliation.ADMIN or ChatRoom.Affiliation.OWNER. otherwise request
will failedpublic boolean createInstantRoom(String roomName)
sendJoinChatRoomRequest(JID, String) request.roomName - name of the chatroompublic boolean createReservedRoom(String roomName, Map<ChatRoom.RoomConfigParam,String> configs)
roomName - chatroom nameconfigs - configurationspublic boolean createPrivateRoom(String roomName)
sendJoinChatRoomRequest(JID, String). Only room
admin and owner can add or remove other members.roomName - chatroom namepublic boolean createPublicRoom(String roomName)
sendJoinChatRoomRequest(JID, String).roomName - chatroom namepublic Set<ChatRoom.RoomConfigParam> getChatRoomConfigParams(JID roomJID)
IQ. And method returns null.public boolean updateRoomSubject(JID roomJID, String subject)
roomJID - chatroom JIDsubject - subjectpublic boolean destroyChatRoom(JID roomJID, String reason)
roomJID - chatroom JIDreason - reason stringpublic boolean updateDeviceToken(String token, PushNotificationService service, DeviceType deviceType, String deviceId)
token - Registration Id of the deviceservice - External Push Notification Service NamedeviceType - DeviceTypedeviceId - unique id of the devicepublic boolean discardDeviceToken(String regId, PushNotificationService service, DeviceType deviceType, String deviceId)
regId - Registration Id of the deviceservice - External Push Notification Service NamedeviceType - DeviceTypedeviceId - unique deviceIdpublic Set<String> getUserRegistrationAttributes() throws NetworkException
Set of registration attributesNetworkException - if encounters any network related issuespublic void registerNewUser(String userName, String email, String password, Callback<String,String> callback) throws NetworkException
userName - userNameemail - email of the userpassword - password of the usercallback - Callback instanceNetworkException - if network related error occurredpublic boolean registerNewUser(String userName, String email, String password) throws NetworkException
userName - user nameemail - email of the userpassword - password of the userNetworkException - if network related error occurredpublic boolean changePassword(String newPassword)
newPassword - new password of the userpublic boolean unRegisterUser()
public UserProfileData getUserProfileData()
UserProfileData instancepublic UserProfileData getUserProfileData(JID userJID)
userJID - JID of the userUserProfileData instancepublic boolean updateUserProfileData(String firstName, String middleName, String lastName, String nickName, String email, String phone, String gender, String birthDay, String addressHome, String addressStreet, String addressLocality, String addressCity, String addressState, String addressCountry, String addressPCode, String about)
We do not validate data. It's client responsibility to pass all details in correct way or format.
firstName - firstName of the usermiddleName - middleName of the userlastName - last name of the usernickName - nickName if anyemail - email of the userphone - phone no of the usergender - gender of the suerbirthDay - birthDate(dd-mm-yyyy)addressHome - home addressaddressStreet - Street addressaddressLocality - localityaddressCity - City nameaddressState - stateaddressCountry - countryaddressPCode - Postal codeabout - brief about the userpublic boolean updateUserProfileData(UserProfileData userProfileData)
userProfileData - UserProfileDatapublic boolean changeUserAvatar(File file)
The image SHOULD use less than eight kilobytes (8k) of data; And it's height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.
We Only verify total size of file which should be less than eight kilobytes (8k). and other verifications like height, width, pixels client have to do.
Please refer XEP-0153: vCard-Based Avatars.file - avtar filepublic boolean changeUserAvatar(URL url)
The image SHOULD use less than eight kilobytes (8k) of data; And it's height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.
We Only verify total size of file which should be less than eight kilobytes (8k). and other verifications like height, width, pixels client have to do.
Please refer XEP-0153: vCard-Based Avatars.url - url of the user avtar imagepublic boolean changeUserAvatar(URL url, String imageType)
The image SHOULD use less than eight kilobytes (8k) of data; And it's height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.
We Only verify total size of file which should be less than eight kilobytes (8k). and other verifications like height, width, pixels client have to do.
Please refer XEP-0153: vCard-Based Avatars.url - Avtar image urlimageType - ContyentType of the imagepublic boolean changeUserAvatar(File file, String imageType)
The image SHOULD use less than eight kilobytes (8k) of data; And it's height and width SHOULD be between thirty-two (32) and ninety-six (96) pixels; the recommended size is sixty-four (64) pixels high and sixty-four (64) pixels wide.
We Only verify total size of file which should be less than eight kilobytes (8k). and other verifications like height, width, pixels client have to do.
Please refer XEP-0153: vCard-Based Avatars.file - Avtar fileimageType - content type of the filepublic boolean removeUserAvatar()
public Set<String> getUserSearchAttributes()
Please refer XEP-0055.
public List<UserSearchData.Item> searchUser(String firstName, String lastName, String nickName, String email)
Please refer XEP-0055.
firstName - firstName of the userlastName - lastName of the usernickName - nickName of the useremail - email of the userpublic List<UserSearchData.Item> searchUserWithFirstName(String firstName)
Please refer XEP-0055.
firstName - firstName of the userList of users matching the search criteriapublic List<UserSearchData.Item> searchUserWithLastName(String lastName)
Please refer XEP-0055.
lastName - lastNameList of users matching the search criteriapublic List<UserSearchData.Item> searchUserWithNickName(String nickName)
Please refer XEP-0055.
nickName - nickNameList of users matching the search criteriapublic List<UserSearchData.Item> searchUserWithEmail(String email)
Please refer XEP-0055.
email - email of the userList of users matching the search criteriapublic void collect(Packet packet)
PacketCollectorcollect in interface PacketCollectorpacket - packet instance to be collectedCopyright © 2019. All rights reserved.