Java Code Examples for org.jxmpp.jid.Jid#toString()

The following examples show how to use org.jxmpp.jid.Jid#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlogPostDetailsActivity.java    From mangosta-android with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: XmppConnection.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
@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());
    }
}
 
Example 3
Source File: XmppConnection.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
@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();
    }

}
 
Example 4
Source File: XmppConnection.java    From Zom-Android-XMPP with GNU General Public License v3.0 6 votes vote down vote up
private void handleSubscribeRequest (Jid jid) throws ImException, RemoteException {

        Contact contact = mContactListManager.getContact(jid.asBareJid().toString());
        if (contact == null) {
            XmppAddress xAddr = new XmppAddress(jid.toString());
            contact = new Contact(xAddr, xAddr.getUser(), Imps.Contacts.TYPE_NORMAL);
        }

        if (contact.getSubscriptionType() == Imps.Contacts.SUBSCRIPTION_TYPE_BOTH ||
                contact.getSubscriptionType() == Imps.Contacts.SUBSCRIPTION_TYPE_TO)
        {
            mContactListManager.approveSubscriptionRequest(contact);
        }
        else {
            ContactList cList = getContactListManager().getDefaultContactList();
            contact.setSubscriptionStatus(Imps.Contacts.SUBSCRIPTION_STATUS_SUBSCRIBE_PENDING);
            contact.setSubscriptionType(Imps.Contacts.SUBSCRIPTION_TYPE_FROM);
            mContactListManager.doAddContactToListAsync(contact, cList, false);
            mContactListManager.getSubscriptionRequestListener().onSubScriptionRequest(contact, mProviderId, mAccountId);
        }

        ChatSession session = findOrCreateSession(jid.toString(), false, true);


    }
 
Example 5
Source File: UriManager.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
    * handles the ?message URI
    * 
    * @param uri
    *            the decoded uri
    */
   public void handleMessage(URI uri) {

String query = uri.getQuery();
int bodyIndex = query.indexOf("body=");

Jid jid = retrieveJID(uri);
String body = null;

// Find body
if (bodyIndex != -1) {
    body = query.substring(bodyIndex + 5);
}

body = org.jivesoftware.spark.util.StringUtils.unescapeFromXML(body);

UserManager userManager = SparkManager.getUserManager();
String nickname = userManager.getUserNicknameFromJID(jid.asBareJid());
if (nickname == null) {
    nickname = jid.toString();
}

ChatManager chatManager = SparkManager.getChatManager();
ChatRoom chatRoom = chatManager.createChatRoom(jid.asEntityJidOrThrow(), nickname, nickname);
if (body != null) {
    Message message = new Message();
    message.setBody(body);
    chatRoom.sendMessage(message);
}

chatManager.getChatContainer().activateChatRoom(chatRoom);
   }
 
Example 6
Source File: AbstractJid.java    From jxmpp with Apache License 2.0 4 votes vote down vote up
@Override
public final int compareTo(Jid  other) {
	String otherString = other.toString();
	String myString = toString();
	return myString.compareTo(otherString);
}
 
Example 7
Source File: CallPeerJabberImpl.java    From jitsi with Apache License 2.0 4 votes vote down vote up
/**
 * Processes the source-add {@link JingleIQ} action used in Jitsi-Meet.
 * For now processing only audio, as we use single ssrc for audio and
 * using multiple ssrcs for video. ConferenceMember currently support single
 * ssrc for audio and video and adding multiple ssrcs will need a large
 * refactor.
 *
 * @param content The {@link JingleIQ} that contains content that remote
 * peer wants to be added
 */
public void processSourceAdd(final JingleIQ content)
{
    for (ContentPacketExtension c : content.getContentList())
    {
        // we are parsing only audio
        if(!MediaType.AUDIO.equals(JingleUtils.getMediaType(c)))
        {
            continue;
        }

        RtpDescriptionPacketExtension rtpDesc
            = JingleUtils.getRtpDescription(c);

        for (SourcePacketExtension src : rtpDesc
            .getChildExtensionsOfType(SourcePacketExtension.class))
        {
            SSRCInfoPacketExtension ssrcInfo
                = src.getFirstChildOfType(SSRCInfoPacketExtension.class);

            if (ssrcInfo == null)
                continue;

            Jid owner = ssrcInfo.getOwner();
            if (owner == null)
                continue;

            AbstractConferenceMember member
                = findConferenceMemberByAddress(owner);
            if (member == null)
            {
                member = new AbstractConferenceMember(
                    this,
                    owner.toString());
                this.addConferenceMember(member);
            }

            member.setAudioSsrc(src.getSSRC());
        }
    }
}