protected void updatePageCompletion() { JID ownJid = connectionService.getJID(); JID foreignJid = getContact(); if (foreignJid.isValid() && !foreignJid.equals(ownJid) && !foreignJid.isResourceQualifiedJID()) { /* * Page is complete */ wasJIDValid = true; Roster roster = connectionService.getRoster(); if (roster != null && roster.contains(foreignJid.getBase())) { setMessage( Messages.roster_alreadyadded_errorMessage + "\n" + Messages.wizard_finish_noeffect, // $NON-NLS-1$ IMessageProvider.INFORMATION); isContactAlreadyAdded = true; } else { setMessage(DESCRIPTION); isContactAlreadyAdded = false; } setErrorMessage(null); setPageComplete(true); } else { /* * Page is incomplete */ if (foreignJid.equals(ownJid)) { setErrorMessage(Messages.roster_addself_errorMessage); } else if (wasJIDValid) { setErrorMessage(Messages.jid_format_errorMessage); } setPageComplete(false); } }
protected void updateEnablement() { try { List<JID> contacts = SelectionRetrieverFactory.getSelectionRetriever(JID.class).getSelection(); this.setEnabled(connectionService.isConnected() && contacts.size() == 1); } catch (NullPointerException e) { this.setEnabled(false); } catch (Exception e) { if (!PlatformUI.getWorkbench().isClosing()) LOG.error("Unexpected error while updating enablement", e); // $NON-NLS-1$ } }
public DataTransferManager( XMPPConnectionService connectionService, IReceiver receiver, @Nullable @Socks5Transport ITransport mainTransport, @Nullable @IBBTransport ITransport fallbackTransport) { this.receiver = receiver; this.fallbackTransport = fallbackTransport; this.mainTransport = mainTransport; this.initTransports(); connectionService.addListener(this); }
public void runDeleteAction() { RosterEntry rosterEntry = null; List<RosterEntry> selectedRosterEntries = SelectionRetrieverFactory.getSelectionRetriever(RosterEntry.class).getSelection(); if (selectedRosterEntries.size() == 1) { rosterEntry = selectedRosterEntries.get(0); } if (rosterEntry == null) { LOG.error("RosterEntry should not be null at this point!"); // $NON-NLS-1$ return; } if (sessionManager != null) { // Is the chosen user currently in the session? ISarosSession sarosSession = sessionManager.getSarosSession(); String entryJid = rosterEntry.getUser(); if (sarosSession != null) { for (User p : sarosSession.getUsers()) { String pJid = p.getJID().getBase(); // If so, stop the deletion from completing if (entryJid.equals(pJid)) { MessageDialog.openError( null, Messages.DeleteContactAction_error_title, DELETE_ERROR_IN_SESSION); return; } } } } if (MessageDialog.openQuestion( null, Messages.DeleteContactAction_confirm_title, MessageFormat.format( Messages.DeleteContactAction_confirm_message, toString(rosterEntry)))) { try { XMPPUtils.removeFromRoster(connectionService.getConnection(), rosterEntry); } catch (XMPPException e) { LOG.error( "could not delete contact " + toString(rosterEntry) // $NON-NLS-1$ + ":", e); //$NON-NLS-1$ } } }
public DeleteContactAction() { super(Messages.DeleteContactAction_title); setId(ACTION_ID); setToolTipText(Messages.DeleteContactAction_tooltip); IWorkbench workbench = PlatformUI.getWorkbench(); setImageDescriptor( workbench.getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)); SarosPluginContext.initComponent(this); connectionService.addListener(connectionListener); SelectionUtils.getSelectionService().addSelectionListener(selectionListener); updateEnablement(); }
/** * Perform a ServiceDiscovery [1] and check if the given resource is among the features supported * by the given recipient. * * <p>[1] XEP-0030 http://xmpp.org/extensions/xep-0030.html * * @param jid The JID must have a resource identifier (user@host/resource), otherwise you get a * blame StackTrace in your logs. * @return DiscoverInfo from recipient or null if an XMPPException was thrown. * @blocking This method blocks until the ServiceDiscovery returns. * @reentrant This method can be called concurrently. * @nonCaching This method does not use a cache, but queries the server directly. */ private DiscoverInfo performServiceDiscovery(final JID jid) { if (jid.isBareJID()) { LOG.warn( "cannot perform service discovery on a non resource qualified jid: " + jid.toString(), new StackTrace()); return null; } final Connection connection = connectionService.getConnection(); if (connection == null) { LOG.warn("cannot not perform a service discovery because not connected to a XMPP server"); return null; } ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); try { return sdm.discoverInfo(jid.toString()); } catch (XMPPException e) { LOG.warn( "Service Discovery failed on recipient " + jid.toString() + " server: " + connection.getHost(), e); /* * FIXME handle timeouts and error conditions differently ! see * http://xmpp.org/extensions/xep-0030.html#errors */ return null; } }
@Override public void dispose() { SelectionUtils.getSelectionService().removeSelectionListener(selectionListener); connectionService.removeListener(connectionListener); }