本文整理汇总了Java中org.jivesoftware.smack.Roster.createEntry方法的典型用法代码示例。如果您正苦于以下问题:Java Roster.createEntry方法的具体用法?Java Roster.createEntry怎么用?Java Roster.createEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.Roster
的用法示例。
在下文中一共展示了Roster.createEntry方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: perform
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
Action action = Action.valueOf(sampler.getPropertyAsString(ACTION, Action.get_roster.toString()));
Roster roster = sampler.getXMPPConnection().getRoster();
String entry = sampler.getPropertyAsString(ENTRY);
res.setSamplerData(action.toString() + ": " + entry);
if (action == Action.get_roster) {
res.setResponseData(rosterToString(roster).getBytes());
} else if (action == Action.add_item) {
roster.createEntry(entry, entry, new String[0]);
} else if (action == Action.delete_item) {
RosterEntry rosterEntry = roster.getEntry(entry);
if (rosterEntry != null) {
roster.removeEntry(rosterEntry);
}
}
return res;
}
示例2: addBuddy
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
void addBuddy(final Buddy buddy) {
Runnable r = new Runnable() {
@Override
public void run() {
try {
XMPPCommonService service = getInternalService().getService();
Roster roster = getInternalService().getConnection().getRoster();
roster.createEntry(buddy.getProtocolUid(), buddy.getName(), (buddy.getGroupId() != null && !buddy.getGroupId().equals(ApiConstants.NO_GROUP_ID)) ? new String[] { buddy.getGroupId() } : new String[0]);
service.getCoreService().buddyAction(
ItemAction.ADDED,
service.getEntityAdapter().rosterEntry2Buddy(
roster.getEntry(buddy.getProtocolUid()),
service.getProtocolUid(),
service.getContext(),
service.getServiceId()));
} catch (XMPPException e) {
Logger.log(e);
getInternalService().getService().getCoreService().notification( e.getLocalizedMessage());
}
}
};
Executors.defaultThreadFactory().newThread(r).start();
}
示例3: doAddContactToListAsync
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
@Override
protected void doAddContactToListAsync(String address, ContactList list) throws ImException {
debug(TAG, "add contact to " + list.getName());
org.jivesoftware.smack.packet.Presence response = new org.jivesoftware.smack.packet.Presence(
org.jivesoftware.smack.packet.Presence.Type.subscribed);
response.setTo(address);
sendPacket(response);
Roster roster = mConnection.getRoster();
String[] groups = new String[] { list.getName() };
try {
Contact contact = makeContact(address);
roster.createEntry(address, contact.getName(), groups);
// If contact exists locally, don't create another copy
if (!list.containsContact(contact))
notifyContactListUpdated(list, ContactListListener.LIST_CONTACT_ADDED, contact);
else
debug(TAG, "skip adding existing contact locally " + contact.getName());
} catch (XMPPException e) {
throw new RuntimeException(e);
}
}
示例4: addUser
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 添加好友
*
* @param
* @param userName
* @param name
* @param groupName 是否有分组
* @return
*/
public boolean addUser(String userName, String name, String groupName) {
Roster roster = con.getRoster();
try {
roster.createEntry(userName, name, null == groupName ? null
: new String[]{groupName});
return true;
} catch (XMPPException e) {
SLog.e(tag, Log.getStackTraceString(e));
}
return false;
}
示例5: addUser
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 添加一个好友 无分组
*/
public static boolean addUser(Roster roster,String userName,String name)
{
try {
roster.createEntry(userName, name, null);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例6: addUsers
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* 添加一个好友到分组
* @param roster
* @param userName
* @param name
* @return
*/
public static boolean addUsers(Roster roster,String userName,String name,String groupName)
{
try {
roster.createEntry(userName, name,new String[]{ groupName});
return true;
} catch (Exception e) {
e.printStackTrace();
Log.e("jj", "添加好友异常:"+e.getMessage());
return false;
}
}
示例7: becomeFriends
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
Roster r0 = con0.getRoster();
Roster r1 = con1.getRoster();
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
r0.createEntry(con1.getUser(), "u2", null);
r1.createEntry(con0.getUser(), "u1", null);
}
示例8: addUser
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* ��Ӻ���
*
* @param roster
* @param userName
* @param name
* @param groupName
* �Ƿ��з���
* @return
*/
public boolean addUser(Roster roster, String userName, String name,
String groupName) {
try {
roster.createEntry(userName, name, null == groupName ? null
: new String[] { groupName });
return true;
} catch (XMPPException e) {
SLog.e(tag, Log.getStackTraceString(e));
}
return false;
}
示例9: addUser
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* ���һ������ ����
*/
public static boolean addUser(Roster roster,String userName,String name)
{
try {
roster.createEntry(userName, name, null);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例10: getImage
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getImage(String requestAgent, String workgroup, HttpServletRequest request, HttpServletResponse response) {
ChatManager chatManager = ChatManager.getInstance();
boolean isOnline = WorkgroupStatus.isOnline(workgroup);
final SettingsManager imageManager = SettingsManager.getInstance();
final Roster roster = chatManager.getGlobalConnection().getRoster();
final Presence presence = roster.getPresence(requestAgent);
isOnline = isOnline && presence != null && presence.getType() == Presence.Type.available;
if (!isOnline) {
Object o = roster.getEntry(requestAgent);
if (o == null) {
try {
roster.createEntry(requestAgent, requestAgent, null);
}
catch (XMPPException e) {
WebLog.logError("Error creating new roster entry:", e);
}
}
}
byte[] image;
if (isOnline) {
image = imageManager.getImage("personalonline", workgroup, getServletContext());
}
else {
image = imageManager.getImage("personaloffline", workgroup, getServletContext());
}
imageManager.writeBytesToStream(image, response);
}
示例11: getRoster
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
private void getRoster(){
/*
* get the Roster and add the logaccount as a contact
*/
Roster roster = conn.getRoster();
roster.setDefaultSubscriptionMode(Roster.SubscriptionMode.accept_all);
roster.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
String[] groups= {"admins"};
try {
roster.createEntry(logAccount, logAccount,groups );
} catch (XMPPException e) {
e.printStackTrace();
}
}
示例12: becomeFriends
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public static void becomeFriends(Connection con0, Connection con1) throws XMPPException {
Roster r0 = con0.getRoster();
Roster r1 = con1.getRoster();
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
r1.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
r0.createEntry(con1.getUser(), "u2", null);
r1.createEntry(con0.getUser(), "u1", null);
}
示例13: createEntry
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
public void createEntry(String user, String name) throws Exception {
log.info(String.format("Creating entry for buddy '%1$s' with name %2$s", user, name));
connect();
Roster roster = connection.getRoster();
roster.createEntry(user, name, null);
}
示例14: addEntry
import org.jivesoftware.smack.Roster; //导入方法依赖的package包/类
/**
* Adds a new entry to the users Roster.
*
* @param jid the jid.
* @param nickname the nickname.
* @param group the contact group.
* @return the new RosterEntry.
*/
public RosterEntry addEntry(String jid, String nickname, String group) {
String[] groups = {group};
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry userEntry = roster.getEntry(jid);
boolean isSubscribed = true;
if (userEntry != null) {
isSubscribed = userEntry.getGroups().size() == 0;
}
if (isSubscribed) {
try {
roster.createEntry(jid, nickname, new String[]{group});
}
catch (XMPPException e) {
Log.error("Unable to add new entry " + jid, e);
}
return roster.getEntry(jid);
}
try {
RosterGroup rosterGroup = roster.getGroup(group);
if (rosterGroup == null) {
rosterGroup = roster.createGroup(group);
}
if (userEntry == null) {
roster.createEntry(jid, nickname, groups);
userEntry = roster.getEntry(jid);
}
else {
userEntry.setName(nickname);
rosterGroup.addEntry(userEntry);
}
userEntry = roster.getEntry(jid);
}
catch (XMPPException ex) {
Log.error(ex);
}
return userEntry;
}