Java Code Examples for org.jxmpp.jid.parts.Resourcepart#from()
The following examples show how to use
org.jxmpp.jid.parts.Resourcepart#from() .
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: WrappedJid.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
@Override public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) { final Localpart localpart = inner.getLocalpartOrNull(); try { final Resourcepart resourcepart = Resourcepart.from(resource.toString()); if (localpart == null) { return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart)); } else { return new WrappedJid( JidCreate.fullFrom( localpart, inner.getDomain(), resourcepart )); } } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }
Example 2
Source File: WrappedJid.java From Conversations with GNU General Public License v3.0 | 6 votes |
@Override public eu.siacs.conversations.xmpp.Jid withResource(CharSequence resource) { final Localpart localpart = inner.getLocalpartOrNull(); try { final Resourcepart resourcepart = Resourcepart.from(resource.toString()); if (localpart == null) { return new WrappedJid(JidCreate.domainFullFrom(inner.getDomain(),resourcepart)); } else { return new WrappedJid( JidCreate.fullFrom( localpart, inner.getDomain(), resourcepart )); } } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }
Example 3
Source File: XMPPSession.java From mangosta-android with Apache License 2.0 | 5 votes |
public void login(String userName, String password) throws Exception { try { mXMPPConnection.connect(); } catch (SmackException.AlreadyConnectedException ace) { Log.w(XMPP_TAG, "Client Already Connected"); } catch (Exception ex) { ex.printStackTrace(); } Preferences preferences = Preferences.getInstance(); try { String resourceString = Settings.Secure.getString(MangostaApplication.getInstance().getContentResolver(), Settings.Secure.ANDROID_ID); Resourcepart resourcepart = Resourcepart.from(resourceString); // login if (connectionDoneOnce && !preferences.getXmppOauthAccessToken().isEmpty() && tokenSetMinutesAgo(30)) { mXMPPConnection.login(preferences.getXmppOauthAccessToken(), resourcepart); } else { mXMPPConnection.login(userName, password, resourcepart); } preferences.setUserXMPPJid(XMPPUtils.fromUserNameToJID(userName)); preferences.setUserXMPPPassword(password); sendPresenceAvailable(); mConnectionPublisher.onNext(new ChatConnection(ChatConnection.ChatConnectionStatus.Authenticated)); } catch (SmackException.AlreadyLoggedInException ale) { sendPresenceAvailable(); mConnectionPublisher.onNext(new ChatConnection(ChatConnection.ChatConnectionStatus.Authenticated)); } }
Example 4
Source File: ParserUtils.java From Smack with Apache License 2.0 | 5 votes |
public static Resourcepart getResourcepartAttribute(XmlPullParser parser, String name) throws XmppStringprepException { final String resourcepartString = parser.getAttributeValue("", name); if (resourcepartString == null) { return null; } return Resourcepart.from(resourcepartString); }
Example 5
Source File: AgentSession.java From Smack with Apache License 2.0 | 5 votes |
/** * Get queue. * * @param queueName the name of the queue * @return an instance of WorkgroupQueue for the argument queue name, or null if none exists */ public WorkgroupQueue getQueue(String queueName) { Resourcepart queueNameResourcepart; try { queueNameResourcepart = Resourcepart.from(queueName); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } return getQueue(queueNameResourcepart); }
Example 6
Source File: MultiUserChatLowLevelIntegrationTest.java From Smack with Apache License 2.0 | 5 votes |
@SmackIntegrationTest public void testMucBookmarksAutojoin(AbstractXMPPConnection connection) throws InterruptedException, TestNotPossibleException, XMPPException, SmackException, IOException { final BookmarkManager bookmarkManager = BookmarkManager.getBookmarkManager(connection); if (!bookmarkManager.isSupported()) { throw new TestNotPossibleException("Private data storage not supported"); } final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(connection); final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6)); final String randomMucName = StringUtils.randomString(6); final DomainBareJid mucComponent = multiUserChatManager.getMucServiceDomains().get(0); final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom( Localpart.from(randomMucName), mucComponent)); MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname); if (handle != null) { handle.makeInstant(); } muc.leave(); bookmarkManager.addBookmarkedConference("Smack Inttest: " + testRunId, muc.getRoom(), true, mucNickname, null); connection.disconnect(); connection.connect().login(); // MucBookmarkAutojoinManager is also able to do its task automatically // after every login, it's not deterministic when this will be finished. // So we trigger it manually here. MucBookmarkAutojoinManager.getInstanceFor(connection).autojoinBookmarkedConferences(); assertTrue(muc.isJoined()); // If the test went well, leave the MUC muc.leave(); }
Example 7
Source File: DomainAndResourcepartJid.java From jxmpp with Apache License 2.0 | 4 votes |
DomainAndResourcepartJid(String domain, String resource, JxmppContext context) throws XmppStringprepException { this(new DomainpartJid(domain, context), Resourcepart.from(resource, context)); }
Example 8
Source File: LocalDomainAndResourcepartJid.java From jxmpp with Apache License 2.0 | 4 votes |
LocalDomainAndResourcepartJid(String localpart, String domain, String resource, JxmppContext context) throws XmppStringprepException { this(new LocalAndDomainpartJid(localpart, domain, context), Resourcepart.from(resource, context)); }
Example 9
Source File: MUCParserUtils.java From Smack with Apache License 2.0 | 4 votes |
public static MUCItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException { int initialDepth = parser.getDepth(); MUCAffiliation affiliation = MUCAffiliation.fromString(parser.getAttributeValue("", "affiliation")); Resourcepart nick = ParserUtils.getResourcepartAttribute(parser, "nick"); MUCRole role = MUCRole.fromString(parser.getAttributeValue("", "role")); Jid jid = ParserUtils.getJidAttribute(parser); Jid actor = null; Resourcepart actorNick = null; String reason = null; outerloop: while (true) { XmlPullParser.Event eventType = parser.next(); switch (eventType) { case START_ELEMENT: String name = parser.getName(); switch (name) { case "actor": actor = ParserUtils.getJidAttribute(parser); // TODO change to // actorNick = Resourcepart.from(parser.getAttributeValue("", "nick")); // once a newer version of JXMPP is used that supports from(null). String actorNickString = parser.getAttributeValue("", "nick"); if (actorNickString != null) { actorNick = Resourcepart.from(actorNickString); } break; case "reason": reason = parser.nextText(); break; } break; case END_ELEMENT: if (parser.getDepth() == initialDepth) { break outerloop; } break; default: // Catch all for incomplete switch (MissingCasesInEnumSwitch) statement. break; } } return new MUCItem(affiliation, role, actor, reason, jid, nick, actorNick); }