Java Code Examples for org.jivesoftware.smack.SmackException#NotConnectedException
The following examples show how to use
org.jivesoftware.smack.SmackException#NotConnectedException .
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: 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 2
Source File: QBChatHelper.java From q-municate-android with Apache License 2.0 | 6 votes |
public void sendChatMessage(QBChatMessage message, QBChatDialog chatDialog) throws QBResponseException { message.setMarkable(true); chatDialog.initForChat(chatService); if (QBDialogType.GROUP.equals(chatDialog.getType())) { if (!chatDialog.isJoined()) { tryJoinRoomChat(chatDialog); } } String error = null; try { chatDialog.sendMessage(message); } catch (SmackException.NotConnectedException e) { error = context.getString(R.string.dlg_fail_connection); } if (error != null) { throw new QBResponseException(error); } }
Example 3
Source File: OmemoService.java From Smack with Apache License 2.0 | 6 votes |
/** * Retrieve the OMEMO device list of a contact. * * @param connection authenticated XMPP connection. * @param contact BareJid of the contact of which we want to retrieve the device list from. * @return device list * * @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 SmackException.NoResponseException if there was no response from the remote entity. * @throws SmackException.NotConnectedException if the XMPP connection is not connected. * @throws XMPPException.XMPPErrorException if there was an XMPP error returned. * @throws PubSubException.NotAPubSubNodeException if a involved node is not a PubSub node. */ private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException { PubSubManager pm = PubSubManager.getInstanceFor(connection, contact); String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; LeafNode node = pm.getLeafNode(nodeName); if (node == null) { return null; } List<PayloadItem<OmemoDeviceListElement>> items = node.getItems(); if (items.isEmpty()) { return null; } return items.get(items.size() - 1).getPayload(); }
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: XmppConnection.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
private void queryArchive (EntityBareJid jid) throws XMPPException.XMPPErrorException, SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { /** MamManager mucMamManager = MamManager.getInstanceFor(mConnection, jid); MamManager.MamQueryArgs.Builder args = new MamManager.MamQueryArgs.Builder(); args.setResultPageSizeTo(20); MamManager.MamQuery result = mucMamManager.queryArchive(args.build()); if (result != null && result.getMessageCount() > 0) { for (org.jivesoftware.smack.packet.Message msg : result.getMessages()) { Log.w(TAG, "retreived archive message: " + msg); } }**/ }
Example 6
Source File: BlogPostDetailsActivity.java From mangosta-android with Apache License 2.0 | 6 votes |
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 7
Source File: ChatRoomImpl.java From Spark with Apache License 2.0 | 6 votes |
@Override protected void sendChatState(ChatState state) throws SmackException.NotConnectedException, InterruptedException { if ( !active ) { return; } final Message message = new Message(); message.setType( Message.Type.chat ); message.setTo( participantJID ); message.setFrom( SparkManager.getSessionManager().getJID()); if (threadID == null) { threadID = StringUtils.randomString(6); } message.setThread(threadID); message.addExtension( new ChatStateExtension( state ) ); SparkManager.getConnection().sendStanza( message ); }
Example 8
Source File: RoomManager.java From mangosta-android with Apache License 2.0 | 5 votes |
public void removeFromMUCLight(User user, String chatJID) { MultiUserChatLightManager multiUserChatLightManager = XMPPSession.getInstance().getMUCLightManager(); try { MultiUserChatLight mucLight = multiUserChatLightManager.getMultiUserChatLight(JidCreate.from(chatJID).asEntityBareJidIfPossible()); Jid jid = JidCreate.from(XMPPUtils.fromUserNameToJID(user.getLogin())); HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(jid, MUCLightAffiliation.none); mucLight.changeAffiliations(affiliations); } catch (XmppStringprepException | InterruptedException | SmackException.NotConnectedException | SmackException.NoResponseException | XMPPException.XMPPErrorException e) { e.printStackTrace(); } }
Example 9
Source File: OmemoMamDecryptionTest.java From Smack with Apache License 2.0 | 5 votes |
public OmemoMamDecryptionTest(SmackIntegrationTestEnvironment environment) throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, TestNotPossibleException { super(environment); MamManager bobsMamManager = MamManager.getInstanceFor(conTwo); if (!bobsMamManager.isSupported()) { throw new TestNotPossibleException("Test is not possible, because MAM is not supported on the server."); } }
Example 10
Source File: ChatActivity.java From mangosta-android with Apache License 2.0 | 5 votes |
private void removeChatGuyFromContacts() { User userNotContact = new User(); userNotContact.setLogin(XMPPUtils.fromJIDToUserName(mChat.getJid())); try { RosterManager.getInstance().removeContact(userNotContact); setMenuChatNotContact(); Toast.makeText(this, String.format(Locale.getDefault(), getString(R.string.user_removed_from_contacts), userNotContact.getLogin()), Toast.LENGTH_SHORT).show(); } catch (SmackException.NotLoggedInException | InterruptedException | SmackException.NotConnectedException | XMPPException.XMPPErrorException | XmppStringprepException | SmackException.NoResponseException e) { e.printStackTrace(); } }
Example 11
Source File: JingleUtil.java From Smack with Apache License 2.0 | 5 votes |
public IQ sendTransportAccept(FullJid recipient, FullJid initiator, String sessionId, JingleContent.Creator contentCreator, String contentName, JingleContentTransport transport) throws SmackException.NotConnectedException, InterruptedException, XMPPException.XMPPErrorException, SmackException.NoResponseException { Jingle jingle = createTransportAccept(recipient, initiator, sessionId, contentCreator, contentName, transport); return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow(); }
Example 12
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 13
Source File: JingleUtil.java From Smack with Apache License 2.0 | 4 votes |
public IQ sendSessionTerminateUnsupportedApplications(FullJid recipient, String sessionId) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { Jingle jingle = createSessionTerminateUnsupportedApplications(recipient, sessionId); return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow(); }
Example 14
Source File: JingleUtil.java From Smack with Apache License 2.0 | 4 votes |
public void sendErrorUnknownSession(Jingle request) throws SmackException.NotConnectedException, InterruptedException { connection.sendStanza(createErrorUnknownSession(request)); }
Example 15
Source File: JingleUtil.java From Smack with Apache License 2.0 | 4 votes |
public void sendErrorUnsupportedInfo(Jingle request) throws SmackException.NotConnectedException, InterruptedException { connection.sendStanza(createErrorUnsupportedInfo(request)); }
Example 16
Source File: GatewayButton.java From Spark with Apache License 2.0 | 4 votes |
public GatewayButton(final Transport transport) { setLayout(new GridBagLayout()); setOpaque(false); this.transport = transport; final StatusBar statusBar = SparkManager.getWorkspace().getStatusBar(); final JPanel commandPanel = SparkManager.getWorkspace().getCommandPanel(); if (PresenceManager.isOnline(transport.getXMPPServiceDomain())) { button.setIcon(transport.getIcon()); } else { button.setIcon(transport.getInactiveIcon()); } button.setToolTipText(transport.getName()); commandPanel.add(button); button.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { handlePopup(mouseEvent); } }); commandPanel.updateUI(); final Runnable registerThread = () -> { // Send directed presence if registered with this transport. final boolean isRegistered = TransportUtils.isRegistered(SparkManager.getConnection(), transport); if (isRegistered) { // Check if auto login is set. boolean autoJoin = TransportUtils.autoJoinService(transport.getXMPPServiceDomain()); if (autoJoin) { Presence oldPresence = statusBar.getPresence(); Presence presence = new Presence(oldPresence.getType(), oldPresence.getStatus(), oldPresence.getPriority(), oldPresence.getMode()); presence.setTo(transport.getXMPPServiceDomain()); try { SparkManager.getConnection().sendStanza(presence); } catch ( SmackException.NotConnectedException | InterruptedException e ) { Log.error( "Unable to register.", e ); } } } }; TaskEngine.getInstance().submit(registerThread); }
Example 17
Source File: Workspace.java From Spark with Apache License 2.0 | 4 votes |
private void handleIncomingPacket(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException { // We only handle message packets here. if (stanza instanceof Message) { final Message message = (Message)stanza; boolean isGroupChat = message.getType() == Message.Type.groupchat; // Check if Conference invite. If so, do not handle here. if (message.getExtension("x", "jabber:x:conference") != null) { return; } final String body = message.getBody(); final JivePropertiesExtension extension = ((JivePropertiesExtension) message.getExtension( JivePropertiesExtension.NAMESPACE )); final boolean broadcast = extension != null && extension.getProperty( "broadcast" ) != null; // Handle offline message. DelayInformation offlineInformation = message.getExtension("delay", "urn:xmpp:delay"); if (offlineInformation != null && (Message.Type.chat == message.getType() || Message.Type.normal == message.getType())) { handleOfflineMessage(message); } if (body == null || isGroupChat || broadcast || message.getType() == Message.Type.normal || message.getType() == Message.Type.headline || message.getType() == Message.Type.error) { return; } // Create new chat room for Agent Invite. final Jid from = stanza.getFrom(); final String host = SparkManager.getSessionManager().getServerAddress(); // Don't allow workgroup notifications to come through here. final BareJid bareJID = from.asBareJid(); if (host.equalsIgnoreCase(from.toString()) || from == null) { return; } ChatRoom room = null; try { room = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); } catch (ChatRoomNotFoundException e) { // Ignore } // Check for non-existent rooms. if (room == null) { EntityBareJid entityBareJid = bareJID.asEntityBareJidIfPossible(); if (entityBareJid != null) { createOneToOneRoom(entityBareJid, message); } } } }
Example 18
Source File: OmemoService.java From Smack with Apache License 2.0 | 3 votes |
/** * Publish the given device list to the server. * * @param connection authenticated XMPP connection. * @param deviceList users deviceList. * * @throws InterruptedException if the calling thread was interrupted. * @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 PubSubException.NotALeafNodeException if a PubSub leaf node operation was attempted on a non-leaf node. */ static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, NotALeafNodeException { PepManager pm = PepManager.getInstanceFor(connection); pm.publish(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList)); }
Example 19
Source File: OpenPgpPubSubUtil.java From Smack with Apache License 2.0 | 2 votes |
/** * Consult the public key metadata node and fetch a list of all of our published OpenPGP public keys. * * @see <a href="https://xmpp.org/extensions/xep-0373.html#discover-pubkey-list"> * XEP-0373 ยง4.3: Discovering Public Keys of a User</a> * * @param connection XMPP connection * @return content of our metadata node. * * @throws InterruptedException if the thread gets interrupted. * @throws XMPPException.XMPPErrorException in case of an XMPP protocol exception. * @throws PubSubException.NotAPubSubNodeException in case the queried entity is not a PubSub node * @throws PubSubException.NotALeafNodeException in case the queried node is not a {@link LeafNode} * @throws SmackException.NotConnectedException in case we are not connected * @throws SmackException.NoResponseException in case the server doesn't respond */ public static PublicKeysListElement fetchPubkeysList(XMPPConnection connection) throws InterruptedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException, PubSubException.NotALeafNodeException, SmackException.NotConnectedException, SmackException.NoResponseException { return fetchPubkeysList(connection, null); }
Example 20
Source File: SparkPrivacyItemListener.java From Spark with Apache License 2.0 | 2 votes |
/** * New Item added into PrivacyList * * @param item privacyItem jid * @param listname name of the privacy list. */ void itemAdded(PrivacyItem item, String listname) throws SmackException.NotConnectedException;