Java Code Examples for org.jxmpp.jid.impl.JidCreate#entityBareFromOrThrowUnchecked()
The following examples show how to use
org.jxmpp.jid.impl.JidCreate#entityBareFromOrThrowUnchecked() .
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: ConferenceServices.java From Spark with Apache License 2.0 | 6 votes |
private void startConference(Collection<ContactItem> items) { final ContactList contactList = SparkManager.getWorkspace().getContactList(); List<Jid> jids = new ArrayList<>(); for (ContactItem item : items) { ContactGroup contactGroup = contactList.getContactGroup(item.getGroupName()); contactGroup.clearSelection(); if (item.isAvailable()) { jids.add(item.getJid()); } } Localpart userName = SparkManager.getSessionManager().getJID().getLocalpart(); final EntityBareJid roomName = JidCreate.entityBareFromOrThrowUnchecked(userName + "_" + StringUtils.randomString(3)); DomainBareJid serviceName = getDefaultServiceName(); if (serviceName != null) { ConferenceUtils.inviteUsersToRoom(serviceName, roomName, jids, true); } }
Example 2
Source File: BroadcastPlugin.java From Spark with Apache License 2.0 | 6 votes |
/** * Displays the Serverbroadcast like all other messages * in its on chatcontainer with transcript history * @param message * @param from */ private void broadcastInChat(Message message) { String from = message.getFrom() != null ? message.getFrom().toString() : ""; ChatManager chatManager = SparkManager.getChatManager(); ChatContainer container = chatManager.getChatContainer(); ChatRoomImpl chatRoom; try { chatRoom = (ChatRoomImpl)container.getChatRoom(from); } catch (ChatRoomNotFoundException e) { String windowtitle = message.getSubject()!=null ? message.getSubject() : Res.getString("administrator"); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked("serveralert@" + from); Resourcepart resourcepart = Resourcepart.fromOrThrowUnchecked(Res.getString("broadcast")); chatRoom = new ChatRoomImpl(jid, resourcepart, windowtitle); chatRoom.getBottomPanel().setVisible(false); chatRoom.hideToolbar(); SparkManager.getChatManager().getChatContainer().addChatRoom(chatRoom); } chatRoom.getTranscriptWindow().insertNotificationMessage(message.getBody(), ChatManager.NOTIFICATION_COLOR); broadcastRooms.add(chatRoom); }
Example 3
Source File: UserSearchResults.java From Spark with Apache License 2.0 | 6 votes |
private void openChatRoom(int row) { String jidString = (String)resultsTable.getValueAt(row, 0); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked(jidString); Localpart nickname = jid.getLocalpart(); TableColumn column; try { column = resultsTable.getColumn("nick"); int col = column.getModelIndex(); String nicknameString = (String)resultsTable.getValueAt(row, col); if (!ModelUtil.hasLength(nicknameString)) { nickname = JidCreate.from(nicknameString).getLocalpartOrThrow(); } } catch (Exception e1) { // Ignore e1 } ChatManager chatManager = SparkManager.getChatManager(); ChatRoom chatRoom = chatManager.createChatRoom(jid, nickname, nickname); ChatContainer chatRooms = chatManager.getChatContainer(); chatRooms.activateChatRoom(chatRoom); }
Example 4
Source File: WorkgroupInvitationDialog.java From Spark with Apache License 2.0 | 6 votes |
/** * Handles tree selection of an agent. * * @return the agents jid. */ private EntityBareJid getAgent() { EntityBareJid agentJID; final DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent(); if (node == null || node.getAllowsChildren()) { return null; } agentJID = roster.getAgentJID((JiveTreeNode)node); if (agentJID == null) { final Object nodeInfo = node.getUserObject(); if (!node.isLeaf()) { return null; } agentJID = JidCreate.entityBareFromOrThrowUnchecked(nodeInfo.toString()); } return agentJID; }
Example 5
Source File: OmemoClient.java From Smack with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws XMPPException, SmackException, IOException, InterruptedException, CorruptedOmemoKeyException { SmackConfiguration.DEBUG = true; if (args.length != 2) { print("Missing arguments: <jid> <password>"); return; } SignalOmemoService.acknowledgeLicense(); SignalOmemoService.setup(); SignalOmemoService omemoService = (SignalOmemoService) SignalOmemoService.getInstance(); Path omemoStoreDirectory = Files.createTempDirectory("omemo-store"); omemoService.setOmemoStoreBackend(new SignalCachingOmemoStore(new SignalFileBasedOmemoStore(omemoStoreDirectory.toFile()))); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked(args[0]); String password = args[1]; OmemoClient client = new OmemoClient(jid, password); try { client.start(); while (true) { String input = scanner.nextLine(); if (input.startsWith("/quit")) { break; } if (input.isEmpty()) { continue; } client.handleInput(input); } } finally { client.stop(); } }
Example 6
Source File: RoomCreationDialog.java From Spark with Apache License 2.0 | 5 votes |
private MultiUserChat createGroupChat(String roomName, DomainBareJid serviceName) { String roomString = roomName.replaceAll(" ", "_") + "@" + serviceName; EntityBareJid room = JidCreate.entityBareFromOrThrowUnchecked(roomString); // Create a group chat with valid information return MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getMultiUserChat( room ); }
Example 7
Source File: LocalPreferences.java From Spark with Apache License 2.0 | 5 votes |
public EntityBareJid getDefaultBookmarkedConf() { String jidString = props.getProperty("defaultBookmarkedConf"); if (jidString == null) { return null; } return JidCreate.entityBareFromOrThrowUnchecked(jidString); }
Example 8
Source File: ChatContainer.java From Spark with Apache License 2.0 | 2 votes |
/** * Returns a ChatRoom by name. * * @param roomName the name of the ChatRoom. * @return the ChatRoom * @throws ChatRoomNotFoundException if the room was not found. */ public ChatRoom getChatRoom(CharSequence roomName) throws ChatRoomNotFoundException { EntityBareJid roomAddress = JidCreate.entityBareFromOrThrowUnchecked(roomName); return getChatRoom(roomAddress); }