org.jivesoftware.smack.SmackException Java Examples
The following examples show how to use
org.jivesoftware.smack.SmackException.
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: MainWindow.java From Spark with Apache License 2.0 | 6 votes |
/** * Closes the current connection and restarts Spark. * * @param reason the reason for logging out. This can be if user gave no reason. */ public void closeConnectionAndInvoke(String reason) { final XMPPConnection con = SparkManager.getConnection(); if (con.isConnected()) { if (reason != null) { Presence byePresence = new Presence(Presence.Type.unavailable, reason, -1, null); try { ((AbstractXMPPConnection)con).disconnect(byePresence); } catch ( SmackException.NotConnectedException e ) { Log.error( "Unable to sign out with presence.", e); ((AbstractXMPPConnection)con).disconnect(); } } else { ((AbstractXMPPConnection)con).disconnect(); } } if (!restartApplicationWithScript()) { restartApplicationWithJava(); } }
Example #2
Source File: InvitationManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Invite or transfer a queue. * * @param chatRoom the <code>ChatRoom</code> to invite or transfer. * @param sessionID the sessionID of this Fastpath session. * @param jid the jid of the room. * @param messageText the message to send to the user. * @param transfer true if this is a transfer. */ public static void transferOrInviteToWorkgroup(ChatRoom chatRoom, String workgroup, String sessionID, final Jid jid, String messageText, final boolean transfer) { String msg = messageText != null ? StringUtils.escapeForXml(messageText).toString() : FpRes.getString("message.please.join.me.in.conference"); try { if (!transfer) { // TODO : CHECK FASHPATH FastpathPlugin.getAgentSession().sendRoomInvitation(RoomInvitation.Type.workgroup, jid, sessionID, msg); } else { FastpathPlugin.getAgentSession().sendRoomTransfer(RoomTransfer.Type.workgroup, jid.toString(), sessionID, msg); } } catch (XMPPException | SmackException | InterruptedException e) { Log.error(e); } String username = SparkManager.getUserManager().getUserNicknameFromJID(jid.asBareJid()); String notification = FpRes.getString("message.user.has.been.invited", username); if (transfer) { notification = FpRes.getString("message.waiting.for.user", username); } chatRoom.getTranscriptWindow().insertNotificationMessage(notification, ChatManager.NOTIFICATION_COLOR); }
Example #3
Source File: XMPPSession.java From mangosta-android with Apache License 2.0 | 6 votes |
/** * This method is not necessary on this app, is only to show how BoB could be used */ private void sendResponse(BoBIQ bobIQ) { BoBHash bobHash = bobIQ.getBoBHash(); Resources resources = MangostaApplication.getInstance().getResources(); final int resourceId = resources.getIdentifier("sticker_" + Base64.decodeToString(bobHash.getHash()), "drawable", MangostaApplication.getInstance().getPackageName()); Drawable drawable = resources.getDrawable(resourceId); Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.WEBP, 100, stream); byte[] bitMapData = stream.toByteArray(); try { BoBData bobData = new BoBData(0, "image/png", bitMapData); getBoBManager().responseBoB(bobIQ, bobData); } catch (InterruptedException | SmackException.NotConnectedException | SmackException.NotLoggedInException e) { e.printStackTrace(); } }
Example #4
Source File: OmemoService.java From Smack with Apache License 2.0 | 6 votes |
/** * Refresh and merge device list of contact. * * @param connection authenticated XMPP connection * @param userDevice our OmemoDevice * @param contact contact we want to fetch the deviceList from * @return cached device list after refresh. * * @throws InterruptedException if the calling thread was interrupted. * @throws PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node. * @throws XMPPException.XMPPErrorException if there was an XMPP error returned. * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws SmackException.NoResponseException if there was no response from the remote entity. * @throws IOException if an I/O error occurred. */ OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, IOException { // refreshOmemoDeviceList; OmemoDeviceListElement publishedList; try { publishedList = fetchDeviceList(connection, contact); } catch (PubSubException.NotAPubSubNodeException e) { LOGGER.log(Level.WARNING, "Error refreshing deviceList: ", e); publishedList = null; } if (publishedList == null) { publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet()); } return getOmemoStoreBackend().mergeCachedDeviceList( userDevice, contact, publishedList); }
Example #5
Source File: XMPPTCPConnection.java From Smack with Apache License 2.0 | 6 votes |
/** * Establishes a connection to the XMPP server. It basically * creates and maintains a socket connection to the server. * <p> * Listeners will be preserved from a previous connection if the reconnection * occurs after an abrupt termination. * </p> * * @throws XMPPException if an error occurs while trying to establish the connection. * @throws SmackException if Smack detected an exceptional situation. * @throws IOException if an I/O error occurred. * @throws InterruptedException if the calling thread was interrupted. */ @Override protected void connectInternal() throws SmackException, IOException, XMPPException, InterruptedException { // Establishes the TCP connection to the server and does setup the reader and writer. Throws an exception if // there is an error establishing the connection connectUsingConfiguration(); // We connected successfully to the servers TCP port initConnection(); // TLS handled will be true either if TLS was established, or if it was not mandatory. waitForConditionOrThrowConnectionException(() -> tlsHandled, "establishing TLS"); // Wait with SASL auth until the SASL mechanisms have been received waitForConditionOrThrowConnectionException(() -> saslFeatureReceived, "SASL mechanisms stream feature from server"); }
Example #6
Source File: HttpFileUploadManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Discover upload service. * * Called automatically when connection is authenticated. * * Note that this is a synchronous call -- Smack must wait for the server response. * * @return true if upload service was discovered * @throws XMPPException.XMPPErrorException if there was an XMPP error returned. * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws SmackException.NoResponseException if there was no response from the remote entity. */ public boolean discoverUploadService() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); List<DiscoverInfo> servicesDiscoverInfo = sdm .findServicesDiscoverInfo(NAMESPACE, true, true); if (servicesDiscoverInfo.isEmpty()) { servicesDiscoverInfo = sdm.findServicesDiscoverInfo(NAMESPACE_0_2, true, true); if (servicesDiscoverInfo.isEmpty()) { return false; } } DiscoverInfo discoverInfo = servicesDiscoverInfo.get(0); defaultUploadService = uploadServiceFrom(discoverInfo); return true; }
Example #7
Source File: Socks5TransferNegotiator.java From Smack with Apache License 2.0 | 6 votes |
@Override InputStream negotiateIncomingStream(Stanza streamInitiation) throws InterruptedException, SmackException, XMPPErrorException { // build SOCKS5 Bytestream request Socks5BytestreamRequest request = new ByteStreamRequest(this.manager, (Bytestream) streamInitiation); // always accept the request Socks5BytestreamSession session = request.accept(); // test input stream try { PushbackInputStream stream = new PushbackInputStream(session.getInputStream()); int firstByte = stream.read(); stream.unread(firstByte); return stream; } catch (IOException e) { throw new SmackException.SmackWrappedException("Error establishing input stream", e); } }
Example #8
Source File: IoT.java From Smack with Apache License 2.0 | 6 votes |
private static ThingState actAsDataThing(XMPPTCPConnection connection) throws XMPPException, SmackException, InterruptedException { final String key = StringUtils.randomString(12); final String sn = StringUtils.randomString(12); Thing dataThing = Thing.builder() .setKey(key) .setSerialNumber(sn) .setManufacturer("IgniteRealtime") .setModel("Smack") .setVersion("0.1") .setMomentaryReadOutRequestHandler(new ThingMomentaryReadOutRequest() { @Override public void momentaryReadOutRequest(ThingMomentaryReadOutResult callback) { IoTDataField.IntField field = new IntField("timestamp", (int) (System.currentTimeMillis() / 1000)); callback.momentaryReadOut(Collections.singletonList(field)); } }) .build(); IoTDiscoveryManager iotDiscoveryManager = IoTDiscoveryManager.getInstanceFor(connection); ThingState state = IoTDiscoveryIntegrationTest.registerThing(iotDiscoveryManager, dataThing); printStatus("SUCCESS: Thing registered:" + dataThing); return state; }
Example #9
Source File: ChatManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Returns the default conference service. (ex. conference.jivesoftware.com) * * @return the default conference service to interact with MUC. */ public String getDefaultConferenceService() { if (conferenceService == null) { try { final MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ); List<DomainBareJid> col = multiUserChatManager.getMucServiceDomains(); if (col.size() > 0) { conferenceService = col.iterator().next().toString(); } } catch (XMPPException | SmackException | InterruptedException e) { Log.error(e); } } return conferenceService; }
Example #10
Source File: ChatRoom.java From Spark with Apache License 2.0 | 6 votes |
/** * Sets the chat state, causing an update to be sent to all peers if the new state warrants an update. * * @param state the chat state (never null). */ public final void setChatState(ChatState state) { if ( state == null ) { throw new IllegalArgumentException( "Argument 'state' cannot be null." ); } // Only sent out a chat state notification when it is different from the last one that was transmitted... final boolean isDifferentState = lastNotificationSent != state; // ... unless it's 'composing' - that can be repeated every so many seconds. final boolean isStillComposing = state == ChatState.composing && System.currentTimeMillis() - lastNotificationSentTime > 2000; final long now = System.currentTimeMillis(); if ( isDifferentState || isStillComposing ) { try { sendChatState( state ); } catch ( SmackException.NotConnectedException | InterruptedException e ) { Log.warning( "Unable to update the chat state to " + state, e ); } lastNotificationSent = state; lastNotificationSentTime = now; } }
Example #11
Source File: MessageListener.java From Yahala-Messenger with MIT License | 6 votes |
@Override public void processPacket(Stanza packet) throws SmackException.NotConnectedException { Message m = (Message) packet; if (m.getType() == Message.Type.chat || m.getType() == Message.Type.normal) { // somebody has news for us FileLog.e(LOGGER.getName(), "got message: " + m); MessagesController.getInstance().processChatMessage(m); } // error message else if (m.getType() == Message.Type.error) { FileLog.e(LOGGER.getName(), "got error message: " + m); } else { FileLog.e(LOGGER.getName(), "unknown message type: " + m.getType()); } }
Example #12
Source File: OmemoStore.java From Smack with Apache License 2.0 | 6 votes |
/** * Return the fingerprint of the given devices announced identityKey. * If we have no local copy of the identityKey of the contact, build a fresh session in order to get the key. * * @param managerGuard authenticated OmemoManager * @param contactsDevice OmemoDevice we want to get the fingerprint from * @return fingerprint of the contacts OMEMO device * * @throws CannotEstablishOmemoSessionException If we have no local copy of the identityKey of the contact * and are unable to build a fresh session * @throws CorruptedOmemoKeyException If the identityKey we have of the contact is corrupted * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws SmackException.NoResponseException if there was no response from the remote entity. * @throws IOException if an I/O error occurred. */ public OmemoFingerprint getFingerprintAndMaybeBuildSession(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice) throws CannotEstablishOmemoSessionException, CorruptedOmemoKeyException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, IOException { OmemoManager omemoManager = managerGuard.get(); // Load identityKey T_IdKey identityKey = loadOmemoIdentityKey(omemoManager.getOwnDevice(), contactsDevice); if (identityKey == null) { // Key cannot be loaded. Maybe it doesn't exist. Fetch a bundle to get it... OmemoService.getInstance().buildFreshSessionWithDevice(omemoManager.getConnection(), omemoManager.getOwnDevice(), contactsDevice); } // Load identityKey again identityKey = loadOmemoIdentityKey(omemoManager.getOwnDevice(), contactsDevice); if (identityKey == null) { return null; } return keyUtil().getFingerprintOfIdentityKey(identityKey); }
Example #13
Source File: OmemoService.java From Smack with Apache License 2.0 | 6 votes |
/** * Send an empty OMEMO message to contactsDevice in order to forward the ratchet. * * @param managerGuard OMEMO manager * @param contactsDevice contacts OMEMO device * * @throws CorruptedOmemoKeyException if our or their OMEMO key is corrupted. * @throws InterruptedException if the calling thread was interrupted. * @throws SmackException.NoResponseException if there was no response from the remote entity. * @throws NoSuchAlgorithmException if AES encryption fails * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws CryptoFailedException if encryption fails (should not happen though, but who knows...) * @throws CannotEstablishOmemoSessionException if we cannot establish a session with contactsDevice. * @throws IOException if an I/O error occurred. */ private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice) throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException, CannotEstablishOmemoSessionException, IOException { OmemoManager manager = managerGuard.get(); OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice); XMPPConnection connection = manager.getConnection(); Message message = connection.getStanzaFactory().buildMessageStanza() .to(contactsDevice.getJid()) .addExtension(ratchetUpdate) .build(); connection.sendStanza(message); }
Example #14
Source File: Socks5ByteStreamManagerTest.java From Smack with Apache License 2.0 | 5 votes |
/** * The SOCKS5 Bytestream feature should be removed form the service discovery manager if Socks5 * bytestream feature is disabled. * * @throws InterruptedException if the calling thread was interrupted. * @throws SmackException if Smack detected an exceptional situation. * @throws XMPPErrorException if there was an XMPP error returned. */ @Test public void shouldDisableService() throws XMPPErrorException, SmackException, InterruptedException { final Protocol protocol = new Protocol(); final XMPPConnection connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID); Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection); ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection); assertTrue(discoveryManager.includesFeature(Bytestream.NAMESPACE)); byteStreamManager.disableService(); assertFalse(discoveryManager.includesFeature(Bytestream.NAMESPACE)); }
Example #15
Source File: OpenPgpManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Fetch a secret key backup from the server and try to restore a selected secret key from it. * * @param codeCallback callback for prompting the user to provide the secret backup code. * @return fingerprint of the restored secret key * * @throws InterruptedException if the thread gets interrupted. * @throws PubSubException.NotALeafNodeException if the private node is not a {@link LeafNode}. * @throws XMPPException.XMPPErrorException in case of an XMPP protocol error. * @throws SmackException.NotConnectedException if we are not connected. * @throws SmackException.NoResponseException if the server doesn't respond. * @throws InvalidBackupCodeException if the user-provided backup code is invalid. * @throws SmackException.NotLoggedInException if we are not logged in * @throws IOException IO is dangerous * @throws MissingUserIdOnKeyException if the key that is to be imported is missing a user-id with our jid * @throws NoBackupFoundException if no secret key backup has been found * @throws PGPException in case the restored secret key is damaged. */ public OpenPgpV4Fingerprint restoreSecretKeyServerBackup(AskForBackupCodeCallback codeCallback) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, InvalidBackupCodeException, SmackException.NotLoggedInException, IOException, MissingUserIdOnKeyException, NoBackupFoundException, PGPException { throwIfNoProviderSet(); throwIfNotAuthenticated(); SecretkeyElement backup = OpenPgpPubSubUtil.fetchSecretKey(pepManager); if (backup == null) { throw new NoBackupFoundException(); } String backupCode = codeCallback.askForBackupCode(); PGPSecretKeyRing secretKeys = SecretKeyBackupHelper.restoreSecretKeyBackup(backup, backupCode); provider.getStore().importSecretKey(getJidOrThrow(), secretKeys); provider.getStore().importPublicKey(getJidOrThrow(), BCUtil.publicKeyRingFromSecretKeyRing(secretKeys)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(2048); for (PGPSecretKey sk : secretKeys) { PGPPublicKey pk = sk.getPublicKey(); if (pk != null) pk.encode(buffer); } PGPPublicKeyRing publicKeys = new PGPPublicKeyRing(buffer.toByteArray(), new BcKeyFingerprintCalculator()); provider.getStore().importPublicKey(getJidOrThrow(), publicKeys); return new OpenPgpV4Fingerprint(secretKeys); }
Example #16
Source File: QBChatHelper.java From q-municate-android with Apache License 2.0 | 5 votes |
public void sendTypingStatusToServer(boolean startTyping) { if (currentDialog != null && chatService.isLoggedIn()) { try { if (startTyping) { currentDialog.sendIsTypingNotification(); } else { currentDialog.sendStopTypingNotification(); } } catch (XMPPException | SmackException.NotConnectedException /*| QBResponseException*/ e) { ErrorUtils.logError(e); } } }
Example #17
Source File: SmackConnection.java From SmackAndroidDemo with Apache License 2.0 | 5 votes |
private void sendMessage(String body, String toJid) { Log.i(TAG, "sendMessage()"); Chat chat = ChatManager.getInstanceFor(mConnection).createChat(toJid, this); try { chat.sendMessage(body); } catch (SmackException.NotConnectedException | XMPPException e) { e.printStackTrace(); } }
Example #18
Source File: XmppTools.java From Smack with Apache License 2.0 | 5 votes |
public static boolean supportsIbr(DomainBareJid xmppDomain) throws SmackException, IOException, XMPPException, InterruptedException, KeyManagementException, NoSuchAlgorithmException { XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder() .setXmppDomain(xmppDomain); TLSUtils.acceptAllCertificates(configBuilder); XMPPTCPConnectionConfiguration config = configBuilder.build(); XMPPTCPConnection connection = new XMPPTCPConnection(config); connection.connect(); try { return supportsIbr(connection); } finally { connection.disconnect(); } }
Example #19
Source File: XmppTcpTransportModule.java From Smack with Apache License 2.0 | 5 votes |
@Override public StateTransitionResult.AttemptResult transitionInto(WalkStateGraphContext walkStateGraphContext) throws IOException, InterruptedException, SmackException, XMPPException { connectionInternal.sendAndWaitForResponse(StartTls.INSTANCE, TlsProceed.class, TlsFailure.class); SmackTlsContext smackTlsContext = connectionInternal.getSmackTlsContext(); tlsState = new TlsState(smackTlsContext); connectionInternal.addXmppInputOutputFilter(tlsState); channelSelectedCallbackLock.lock(); try { pendingOutputFilterData = true; // The beginHandshake() is possibly not really required here, but it does not hurt either. tlsState.engine.beginHandshake(); tlsState.handshakeStatus = TlsHandshakeStatus.initiated; } finally { channelSelectedCallbackLock.unlock(); } connectionInternal.setInterestOps(selectionKey, SelectionKey.OP_WRITE | SelectionKey.OP_READ); try { tlsState.waitForHandshakeFinished(); } catch (CertificateException e) { throw new SmackCertificateException(e); } connectionInternal.newStreamOpenWaitForFeaturesSequence("stream features after TLS established"); return new TlsEstablishedResult(tlsState.engine); }
Example #20
Source File: JingleUtil.java From Smack with Apache License 2.0 | 5 votes |
public IQ sendTransportReplace(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContentTransport transport) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { Jingle jingle = createTransportReplace(recipient, initiator, sessionId, contentCreator, contentName, transport); return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow(); }
Example #21
Source File: InBandBytestreamSessionTest.java From Smack with Apache License 2.0 | 5 votes |
/** * Initialize fields used in the tests. * @throws XMPPException if an XMPP protocol error was received. * @throws SmackException if Smack detected an exceptional situation. * @throws InterruptedException if the calling thread was interrupted. */ @BeforeEach public void setup() throws XMPPException, SmackException, InterruptedException { // build protocol verifier protocol = new Protocol(); // create mocked XMPP connection connection = ConnectionUtils.createMockedConnection(protocol, initiatorJID); // create a In-Band Bytestream open packet initBytestream = new Open(sessionID, blockSize); initBytestream.setFrom(initiatorJID); initBytestream.setTo(targetJID); incrementingSequence = new Verification<Data, IQ>() { long lastSeq = 0; @Override public void verify(Data request, IQ response) { assertEquals(lastSeq++, request.getDataPacketExtension().getSeq()); } }; }
Example #22
Source File: RosterManager.java From mangosta-android with Apache License 2.0 | 5 votes |
public HashMap<Jid, Presence.Type> getContactsWithSubscriptionPending() throws SmackException.NotLoggedInException, InterruptedException, SmackException.NotConnectedException { Roster roster = Roster.getInstanceFor(XMPPSession.getInstance().getXMPPConnection()); if (!roster.isLoaded()) { roster.reloadAndWait(); } String groupName = "Buddies"; RosterGroup group = roster.getGroup(groupName); if (group == null) { roster.createGroup(groupName); group = roster.getGroup(groupName); } HashMap<Jid, Presence.Type> buddiesPending = new HashMap<>(); List<RosterEntry> entries = group.getEntries(); for (RosterEntry entry : entries) { if (entry.isSubscriptionPending()) { BareJid jid = entry.getJid(); Presence.Type status = roster.getPresence(jid).getType(); buddiesPending.put(jid, status); } } return buddiesPending; }
Example #23
Source File: JingleUtil.java From Smack with Apache License 2.0 | 5 votes |
public IQ sendSessionTerminateSuccess(FullJid recipient, String sessionId) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { Jingle jingle = createSessionTerminateSuccess(recipient, sessionId); return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow(); }
Example #24
Source File: CoBrowser.java From Spark with Apache License 2.0 | 5 votes |
private void send(Message message) { GroupChatRoom groupChatRoom = (GroupChatRoom)chatRoom; try { message.setTo(groupChatRoom.getRoomname()); message.setType(Message.Type.groupchat); MessageEventManager.addNotificationsRequests(message, true, true, true, true); groupChatRoom.getMultiUserChat().sendMessage(message); } catch (SmackException | InterruptedException ex) { Log.error("Unable to send message in conference chat.", ex); } }
Example #25
Source File: JingleS5BTransportSession.java From Smack with Apache License 2.0 | 5 votes |
private UsedCandidate chooseFromProposedCandidates(JingleS5BTransport proposal) { for (JingleContentTransportCandidate c : proposal.getCandidates()) { JingleS5BTransportCandidate candidate = (JingleS5BTransportCandidate) c; try { return connectToTheirCandidate(candidate); } catch (InterruptedException | TimeoutException | XMPPException | SmackException | IOException e) { LOGGER.log(Level.WARNING, "Could not connect to " + candidate.getHost(), e); } } LOGGER.log(Level.WARNING, "Failed to connect to any candidate."); return null; }
Example #26
Source File: JingleS5BTransportSession.java From Smack with Apache License 2.0 | 5 votes |
private UsedCandidate connectToOurCandidate(JingleS5BTransportCandidate candidate) throws InterruptedException, TimeoutException, SmackException, XMPPException, IOException { Bytestream.StreamHost streamHost = candidate.getStreamHost(); InetAddress address = streamHost.getAddress().asInetAddress(); Socks5ClientForInitiator socks5Client = new Socks5ClientForInitiator( streamHost, ourProposal.getDestinationAddress(), jingleSession.getConnection(), ourProposal.getStreamId(), jingleSession.getRemote()); Socket socket = socks5Client.getSocket(10 * 1000); LOGGER.log(Level.INFO, "Connected to our StreamHost " + address + " using dstAddr " + ourProposal.getDestinationAddress()); return new UsedCandidate(ourProposal, candidate, socket); }
Example #27
Source File: UserSettings.java From Spark with Apache License 2.0 | 5 votes |
private UserSettings() { privateDataManager = PrivateDataManager.getInstanceFor(SparkManager.getConnection()); PrivateDataManager.addPrivateDataProvider("personal_settings", "jive:user:settings", new SettingsDataProvider()); try { settingsData = (SettingsData)privateDataManager.getPrivateData("personal_settings", "jive:user:settings"); } catch (XMPPException | SmackException | InterruptedException e) { Log.error("Error in User Settings", e); } }
Example #28
Source File: MamManager.java From Smack with Apache License 2.0 | 5 votes |
public boolean isAdvancedConfigurationSupported() throws InterruptedException, XMPPException, SmackException { DiscoverItems discoverItems = adHocCommandManager.discoverCommands(archiveAddress); for (DiscoverItems.Item item : discoverItems.getItems()) { if (item.getNode().equals(ADVANCED_CONFIG_NODE)) { return true; } } return false; }
Example #29
Source File: TransportResolver.java From Smack with Apache License 2.0 | 5 votes |
/** * Initialize Transport Resolver and wait until it is completely uninitialized. * * @throws XMPPException if an XMPP protocol error was received. * @throws SmackException if Smack detected an exceptional situation. * @throws InterruptedException if the calling thread was interrupted. */ public void initializeAndWait() throws XMPPException, SmackException, InterruptedException { this.initialize(); try { LOGGER.fine("Initializing transport resolver..."); while (!this.isInitialized()) { LOGGER.fine("Resolver init still pending"); Thread.sleep(1000); } LOGGER.fine("Transport resolved"); } catch (Exception e) { LOGGER.log(Level.WARNING, "exception", e); } }
Example #30
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(); } }