本文整理汇总了Java中org.jxmpp.jid.Jid类的典型用法代码示例。如果您正苦于以下问题:Java Jid类的具体用法?Java Jid怎么用?Java Jid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Jid类属于org.jxmpp.jid包,在下文中一共展示了Jid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequest
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public void processRequest(Jid from, Collection<SetData> setDatas) throws XMPPException.XMPPErrorException {
SetBoolData flashControlData = null;
for (SetData setData : setDatas) {
if (!(setData instanceof SetBoolData)) continue;
if (!setData.getName().equals(Constants.NOTIFICATION_ALARM)) continue;
flashControlData = (SetBoolData) setData;
break;
}
if (flashControlData == null) {
return;
}
if (flashControlData.getBooleanValue()) {
setNotifcationAlarm(NotificationAlarm.on);
} else {
setNotifcationAlarm(NotificationAlarm.off);
}
}
示例2: rosterRequestNotification
import org.jxmpp.jid.Jid; //导入依赖的package包/类
public static void rosterRequestNotification(Jid sender) {
// show notification only if the app is closed
if (!MangostaApplication.getInstance().isClosed()) {
new Event(Event.Type.PRESENCE_SUBSCRIPTION_REQUEST, sender).post();
return;
}
Context context = XMPPSessionService.CONTEXT;
String text = String.format(Locale.getDefault(), context.getString(R.string.roster_subscription_request), sender.toString());
PendingIntent chatPendingIntent = preparePendingIntent(context, sender.toString());
Notification.Builder mNotifyBuilder = new Notification.Builder(context)
.setContentTitle(context.getString(R.string.roster_subscription_request_notification_title))
.setContentText(text)
.setSmallIcon(R.mipmap.ic_launcher_empty_back)
.setContentIntent(chatPendingIntent)
.setVibrate(new long[]{0, 200, 0, 200})
.setAutoCancel(true)
.setOngoing(true);
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(sender.toString(), NotificationsControl.ROSTER_NOTIFICATION, mNotifyBuilder.build());
}
示例3: sendBlogPostComment
import org.jxmpp.jid.Jid; //导入依赖的package包/类
public BlogPostComment sendBlogPostComment(String content, BlogPost blogPost)
throws SmackException.NotConnectedException, InterruptedException,
XMPPException.XMPPErrorException, SmackException.NoResponseException {
Jid jid = XMPPSession.getInstance().getUser().asEntityBareJid();
String userName = XMPPUtils.fromJIDToUserName(jid.toString());
Jid pubSubServiceJid = XMPPSession.getInstance().getPubSubService();
// create stanza
PublishCommentExtension publishCommentExtension = new PublishCommentExtension(blogPost.getId(), userName, jid, content, new Date());
PubSub publishCommentPubSub = PubSub.createPubsubPacket(pubSubServiceJid, IQ.Type.set, publishCommentExtension, null);
// send stanza
XMPPSession.getInstance().sendStanza(publishCommentPubSub);
return new BlogPostComment(publishCommentExtension.getId(),
blogPost.getId(),
content,
userName,
jid.toString(),
publishCommentExtension.getPublished());
}
示例4: manageCallFromRosterRequestNotification
import org.jxmpp.jid.Jid; //导入依赖的package包/类
private void manageCallFromRosterRequestNotification() {
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
boolean newRosterRequest = bundle.getBoolean(NEW_ROSTER_REQUEST, false);
if (newRosterRequest) {
try {
String sender = bundle.getString(NEW_ROSTER_REQUEST_SENDER);
Jid jid = JidCreate.from(sender);
RosterNotifications.cancelRosterRequestNotification(this, sender);
answerSubscriptionRequest(jid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
示例5: getStatusFromContact
import org.jxmpp.jid.Jid; //导入依赖的package包/类
public Presence.Type getStatusFromContact(String name) {
try {
HashMap<Jid, Presence.Type> buddies = getContacts();
for (Map.Entry<Jid, Presence.Type> pair : buddies.entrySet()) {
if (XMPPUtils.fromJIDToUserName(pair.getKey().toString()).equals(name)) {
return pair.getValue();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return Presence.Type.unavailable;
}
示例6: checkXMPPLoggedUserSaved
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Test
public void checkXMPPLoggedUserSaved() throws Exception {
assumeTrue(isUserLoggedIn());
IdlingResource resource = startTiming(SplashActivity.WAIT_TIME);
assumeNotNull(XMPPSession.getInstance().getXMPPConnection());
assumeNotNull(XMPPSession.getInstance().getXMPPConnection().getUser());
Jid jid = XMPPSession.getInstance().getXMPPConnection().getUser().asBareJid();
assertTrue(XMPPUtils.isAutenticatedJid(jid));
String userName = XMPPUtils.fromJIDToUserName(jid.toString());
assertTrue(XMPPUtils.isAutenticatedUser(userName));
stopTiming(resource);
}
示例7: joined
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public void joined(EntityFullJid entityFullJid) {
XmppAddress xa = new XmppAddress(entityFullJid.toString());
ChatGroup chatGroup = mChatGroupManager.getChatGroup(xa);
MultiUserChat muc = mChatGroupManager.getMultiUserChat(entityFullJid.asBareJid().toString());
Occupant occupant = muc.getOccupant(entityFullJid);
Jid jidSource = (occupant != null) ? occupant.getJid() : null;
if (jidSource != null)
xa = new XmppAddress(jidSource.toString());
else
xa = new XmppAddress(entityFullJid.toString());
Contact mucContact = new Contact(xa, xa.getUser(), Imps.Contacts.TYPE_NORMAL);
chatGroup.notifyMemberJoined(entityFullJid.toString(),mucContact);
if (occupant != null) {
chatGroup.notifyMemberRoleUpdate(mucContact, occupant.getRole().name(), occupant.getAffiliation().toString());
}
}
示例8: resourceSupportsOmemo
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public boolean resourceSupportsOmemo(Jid jid) {
try {
if (mConnection == null || getState() != ImConnection.LOGGED_IN)
return false;
if (getOmemo().resourceSupportsOmemo(jid)) {
// if (getOmemo().getFingerprints(jid.asBareJid(), false).size() == 0) {
// getOmemo().getManager().requestDeviceListUpdateFor(jid.asBareJid());
// return false;
// }
return true;
}
}
catch (Exception e)
{
debug("OMEMO","There was a problem checking the resource",e);
}
return false;
}
示例9: entriesDeleted
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public void entriesDeleted(Collection<Jid> addresses) {
ContactList cl;
try {
cl = mContactListManager.getDefaultContactList();
for (Jid address : addresses) {
Contact contact = new Contact(new XmppAddress(address.toString()),address.toString(), Imps.Contacts.TYPE_NORMAL);
mContactListManager.notifyContactListUpdated(cl, ContactListListener.LIST_CONTACT_REMOVED, contact);
}
} catch (ImException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例10: setPresence
import org.jxmpp.jid.Jid; //导入依赖的package包/类
private void setPresence (Jid from, int presenceType) {
Presence p = null;
Contact contact = mContactListManager.getContact(from.asBareJid().toString());
if (contact == null)
return;
p = new Presence(presenceType, "", null, null,
Presence.CLIENT_TYPE_MOBILE);
if (from.hasResource())
p.setResource(from.getResourceOrEmpty().toString());
if (presenceType == Presence.AVAILABLE)
p.setLastSeen(new Date());
else if (contact.getPresence() != null)
p.setLastSeen(contact.getPresence().getLastSeen());
contact.setPresence(p);
Collection<Contact> contactsUpdate = new ArrayList<Contact>();
contactsUpdate.add(contact);
mContactListManager.notifyContactsPresenceUpdated(contactsUpdate.toArray(new Contact[contactsUpdate.size()]));
}
示例11: handleSubscribeRequest
import org.jxmpp.jid.Jid; //导入依赖的package包/类
private void handleSubscribeRequest (Jid jid) throws ImException, RemoteException {
ContactList cList = getContactListManager().getDefaultContactList();
XmppAddress xAddr = new XmppAddress(jid.toString());
Contact contact = new Contact(xAddr, xAddr.getUser(), Imps.Contacts.TYPE_NORMAL);
mContactListManager.doAddContactToListAsync(contact, cList, false);
mContactListManager.getSubscriptionRequestListener().onSubScriptionRequest(contact, mProviderId, mAccountId);
ChatSession session = findOrCreateSession(jid.toString(), false);
org.jivesoftware.smack.packet.Message msg = new org.jivesoftware.smack.packet.Message();
msg.setStanzaId((Math.random()*10000f)+"subscribe");
msg.setTo(mUserJid);
msg.setFrom(jid);
String message = mContext.getString(R.string.subscription_notify_text, contact.getName());
msg.setBody(message);
handleMessage(msg, false, false);
}
示例12: getChatSessionManager
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public ChatSessionManager getChatSessionManager() {
return new ChatSessionManager() {
@Override
public void sendMessageAsync(ChatSession session, Message message) {
// Echo
Message rec = new Message(message.getBody());
rec.setFrom(message.getTo());
rec.setDateTime(new Date());
session.onReceiveMessage(rec, true);
}
@Override
public boolean resourceSupportsOmemo(Jid jid) {
return false;
}
};
}
示例13: entriesUpdated
import org.jxmpp.jid.Jid; //导入依赖的package包/类
@Override
public void entriesUpdated(Collection<Jid> addresses) {
final MessageCenterService service = mService.get();
final PresenceListener presenceListener = mPresenceListener.get();
if (service == null || presenceListener == null)
return;
// we got an updated roster entry
// check if it's a subscription "both"
for (Jid jid : addresses) {
RosterEntry e = service.getRosterEntry(jid.asBareJid());
if (e != null && e.canSeeHisPresence()) {
userSubscribed(service, presenceListener, jid);
}
}
}
示例14: entriesAdded
import org.jxmpp.jid.Jid; //导入依赖的package包/类
/**
* NOTE: on every (re-)connect all entries are added again (loaded),
* one method call for all contacts.
*/
@Override
public void entriesAdded(Collection<Jid> addresses) {
if (mRoster == null || !mLoaded)
return;
for (Jid jid: addresses) {
RosterEntry entry = mRoster.getEntry(jid.asBareJid());
if (entry == null) {
LOGGER.warning("jid not in roster: "+jid);
return;
}
LOGGER.config("entry: "+entry.toString());
mHandler.onEntryAdded(clientToModel(entry));
}
}
示例15: initiateSession
import org.jxmpp.jid.Jid; //导入依赖的package包/类
/**
* Sends 'session-initiate' to the peer identified by given <tt>address</tt>
*
* @param useBundle <tt>true</tt> if invite IQ should include
* {@link GroupPacketExtension}
* @param address the XMPP address where 'session-initiate' will be sent.
* @param contents the list of <tt>ContentPacketExtension</tt> describing
* media offer.
* @param requestHandler <tt>JingleRequestHandler</tt> that will be used
* to process request related to newly created
* JingleSession.
* @param startMuted if the first element is <tt>true</tt> the participant
* will start audio muted. if the second element is <tt>true</tt> the
* participant will start video muted.
* {@inheritDoc}
*/
@Override
public boolean initiateSession(boolean useBundle,
Jid address,
List<ContentPacketExtension> contents,
JingleRequestHandler requestHandler,
boolean[] startMuted)
throws OperationFailedException
{
logger.info("INVITE PEER: " + address);
String sid = JingleIQ.generateSID();
JingleSession session = new JingleSession(sid, address, requestHandler);
sessions.put(sid, session);
JingleIQ inviteIQ
= createInviteIQ(JingleAction.SESSION_INITIATE,
sid, useBundle, address, contents, startMuted);
IQ reply = (IQ) getConnection().sendPacketAndGetReply(inviteIQ);
return wasInviteAccepted(session, reply);
}