Hi,
How can i get the username of a contact, that is available in the contact list?
Thanks?
f2r
Hi,
How can i get the username of a contact, that is available in the contact list?
Thanks?
f2r
Hi,
I can’'t get the JID or nickname of a contact. I can obtain the status or if it is available but not the JID.
The code is here, do you find why can’t retrieve the JID?
Thanks
#######################################
public class myplugin implements Plugin {
public myplugin(){}
private String SessionUsername;
private String SessionPass;
public void initialize() {
JOptionPane.showMessageDialog(null, “Welcome To Spark”);
getSessionUsername(SparkManager.getSessionManager());
addContactListListener();
// searchManager.addSearchService(new SearchMe());
}
/////////////////// My Funciotn ////////////
private void addContactListListener(){
// Get Workspace UI from SparkManager
Workspace workspace = SparkManager.getWorkspace();
// Retrieve the ContactList from the Workspace
ContactList contactList = workspace.getContactList();
class sayHelloAction extends AbstractAction {
String myUsername;
ContactItem contacto;
public sayHelloAction(String s1,ContactItem s2) {
this.myUsername = s1;
this.contacto = s2;
}
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), "My username “myUsername” contactItemUsername "+ contacto.getFullJID());
}
}
// Add own Tab.
contactList.addContextMenuListener(new ContextMenuListener() {
public void poppingUp(Object object, JPopupMenu popup) {
if(object instanceof ContactItem){
ContactItem obj = (ContactItem) object;
Action user = new sayHelloAction(SessionUsername,obj);
user.putValue(Action.NAME, “Call User”);
popup.add(user);
}
}
public void poppingDown(JPopupMenu popup) {
}
public boolean handleDefaultAction(MouseEvent e) {
return false;
}
});
}
/////////////////////End /My Function/ End//////////////////////////////
private void getSessionUsername(SessionManager sMan){
this.SessionUsername = sMan.getUsername();
return;
}
private void getSessionPassword(SessionManager sMan){
this.SessionPass = sMan.getPassword();
return;
}
public void shutdown() {
}
public boolean canShutDown() {
return true;
}
public void uninstall() {
// Remove all resources and components.
}
}
I’'m assuming you want to get it programatically.
RosterEntry.getUser() gives you their jid, and RosterEntry.getName() gives you their real name