本文整理汇总了Java中org.jivesoftware.smack.packet.Presence.Mode类的典型用法代码示例。如果您正苦于以下问题:Java Mode类的具体用法?Java Mode怎么用?Java Mode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mode类属于org.jivesoftware.smack.packet.Presence包,在下文中一共展示了Mode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setStatusFromConfig
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
@Override
public void setStatusFromConfig() {// 设置自己的当前状态,供外部服务调用
boolean messageCarbons = PreferenceUtils.getPrefBoolean(mService,
PreferenceConstants.MESSAGE_CARBONS, true);
String statusMode = PreferenceUtils.getPrefString(mService,
PreferenceConstants.STATUS_MODE, PreferenceConstants.AVAILABLE);
String statusMessage = PreferenceUtils.getPrefString(mService,
PreferenceConstants.STATUS_MESSAGE,
mService.getString(R.string.status_online));
int priority = PreferenceUtils.getPrefInt(mService,
PreferenceConstants.PRIORITY, 0);
if (messageCarbons)
CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled(
true);
Presence presence = new Presence(Presence.Type.available);
Mode mode = Mode.valueOf(statusMode);
presence.setMode(mode);
presence.setStatus(statusMessage);
presence.setPriority(priority);
mXMPPConnection.sendPacket(presence);
}
示例2: xmppPresence2UserStatus
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
public byte xmppPresence2UserStatus(Presence presence) {
if (presence == null || presence.getType() != Type.available){
return -1;
}
if (presence.getMode() == null || presence.getMode() == Mode.available){
return 0;
}
for (byte i=0; i<presenceModes.length; i++) {
Mode m = presenceModes[i];
if (m == presence.getMode()){
return i;
}
}
return -1;
}
示例3: getPresenceModeFromStatus
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
/**
* Get the smack presence mode for a status.
* @param status the status in beem
* @return the presence mode to use in presence packet or null if there is no mode to use
*/
public static Presence.Mode getPresenceModeFromStatus(final int status) {
Presence.Mode res;
switch (status) {
case CONTACT_STATUS_AVAILABLE:
res = Presence.Mode.available;
break;
case CONTACT_STATUS_AVAILABLE_FOR_CHAT:
res = Presence.Mode.chat;
break;
case CONTACT_STATUS_AWAY:
res = Presence.Mode.away;
break;
case CONTACT_STATUS_BUSY:
res = Presence.Mode.dnd;
break;
case CONTACT_STATUS_UNAVAILABLE:
res = Presence.Mode.xa;
break;
default:
return null;
}
return res;
}
示例4: updateContactInformations
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
/**
* Update the contact informations.
*/
private void updateContactInformations() {
// Check for a contact name update
String name = mContact.getName();
String res = mContact.getSelectedRes();
if (!"".equals(res))
name += "(" + res + ")";
if (!mCompact) {
if (!(mContactNameTextView.getText().toString().equals(name)))
mContactNameTextView.setText(name);
//Check for a contact status message update
if (!(mContactStatusMsgTextView.getText().toString().equals(mContact.getMsgState()))) {
mContactStatusMsgTextView.setText(mContact.getMsgState());
Linkify.addLinks(mContactStatusMsgTextView, Linkify.WEB_URLS);
}
} else {
Mode m = Status.getPresenceModeFromStatus(mContact.getStatus());
if (m == null)
setTitle(getString(R.string.chat_name) + " " + name + " ("
+ getString(R.string.contact_status_msg_offline) + ")");
else
setTitle(getString(R.string.chat_name) + " " + name + " (" + m.name() + ")");
}
}
示例5: sendPresence
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
@Override
public void sendPresence(JID jabberId, PresenceType type, PresenceShow show, String status, JID fromJid)
{
checkNotNull(jabberId);
final Type presenceType = type == null ? Type.available : Type.valueOf(type.name().toLowerCase());
final Mode presenceMode = show == null ? null : Mode.valueOf(show.name().toLowerCase());
org.jivesoftware.smack.packet.Presence presence = new org.jivesoftware.smack.packet.Presence(presenceType, status, 1, presenceMode);
presence.setFrom(fromJid == null ? null : fromJid.getId());
presence.setTo(jabberId.getId());
this.session_.getConnection().sendPacket(presence);
}
示例6: setStatusFromConfig
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
public void setStatusFromConfig() {
// TODO: only call this when carbons changed, not on every presence change
CarbonManager.getInstanceFor(mXMPPConnection).sendCarbonsEnabled(mConfig.messageCarbons);
Presence presence = new Presence(Presence.Type.available);
Mode mode = Mode.valueOf(mConfig.statusMode);
presence.setMode(mode);
presence.setStatus(mConfig.statusMessage);
presence.setPriority(mConfig.priority);
mXMPPConnection.sendPacket(presence);
mConfig.presence_required = false;
}
示例7: parsePresence
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
protected static int parsePresence(org.jivesoftware.smack.packet.Presence presence) {
int type = Presence.AVAILABLE;
Mode rmode = presence.getMode();
Type rtype = presence.getType();
if (rmode == Mode.away || rmode == Mode.xa)
type = Presence.AWAY;
else if (rmode == Mode.dnd)
type = Presence.DO_NOT_DISTURB;
else if (rtype == Type.unavailable || rtype == Type.error)
type = Presence.OFFLINE;
return type;
}
示例8: getStatusFromPresence
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
/**
* Get the status of from a presence packet.
* @param presence the presence containing status
* @return an int representing the status
*/
public static int getStatusFromPresence(final Presence presence) {
int res = Status.CONTACT_STATUS_DISCONNECT;
if (presence.getType().equals(Presence.Type.unavailable)) {
res = Status.CONTACT_STATUS_DISCONNECT;
} else {
Mode mode = presence.getMode();
if (mode == null) {
res = Status.CONTACT_STATUS_AVAILABLE;
} else {
switch (mode) {
case available:
res = Status.CONTACT_STATUS_AVAILABLE;
break;
case away:
res = Status.CONTACT_STATUS_AWAY;
break;
case chat:
res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
break;
case dnd:
res = Status.CONTACT_STATUS_BUSY;
break;
case xa:
res = Status.CONTACT_STATUS_UNAVAILABLE;
break;
default:
res = Status.CONTACT_STATUS_DISCONNECT;
break;
}
}
}
return res;
}
示例9: XmppLoginRunnable
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
public XmppLoginRunnable(XmppListener listener) {
super(listener);
mType = Type.available;
mMode = Mode.available;
mStatus = null;
}
示例10: setMode
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
public void setMode(Mode mode) {
this.mMode = mode;
}
示例11: sendPresence
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
/**
* @param type
* @param status
* @param priority
* @param mode
*/
public void sendPresence(final Type type, final String status, final int priority, final Mode mode) {
imc.sendPresence(type, status, priority, mode);
}
示例12: sendPresenceAvailable
import org.jivesoftware.smack.packet.Presence.Mode; //导入依赖的package包/类
/**
* send a presence packet "available" with a certain mode e.g. "away" to all buddies
*
* @param mode
*/
public void sendPresenceAvailable(final Presence.Mode mode) {
imc.sendPresence(Presence.Type.available, null, 0, mode);
}