/** * Creates a shell channel to the remote machine a new jsch session is also created if the current * one is invalid * * @param sshContact the contact of the remote machine * @param firstMessage the first message */ public void connectShell(final ContactSSH sshContact, final Message firstMessage) { sshContact.setConnectionInProgress(true); final UIService uiService = this.uiService; final Thread newConnection = new Thread( (new Runnable() { public void run() { OperationSetPersistentPresenceSSHImpl persistentPresence = (OperationSetPersistentPresenceSSHImpl) sshContact.getParentPresenceOperationSet(); persistentPresence.changeContactPresenceStatus( sshContact, SSHStatusEnum.CONNECTING); try { if (!isSessionValid(sshContact)) createSSHSessionAndLogin(sshContact); createShellChannel(sshContact); // initalizing the reader and writers of ssh contact persistentPresence.changeContactPresenceStatus( sshContact, SSHStatusEnum.CONNECTED); showWelcomeMessage(sshContact); sshContact.setMessageType(sshContact.CONVERSATION_MESSAGE_RECEIVED); sshContact.setConnectionInProgress(false); Thread.sleep(1500); sshContact.setCommandSent(true); basicInstantMessaging.sendInstantMessage(sshContact, firstMessage); } // rigoruos Exception Checking in future catch (Exception ex) { persistentPresence.changeContactPresenceStatus( sshContact, SSHStatusEnum.NOT_AVAILABLE); ex.printStackTrace(); } finally { sshContact.setConnectionInProgress(false); } } })); newConnection.start(); }
void start() { if (timeoutThread != null) { throw new IllegalStateException(); } timeoutThread = new Thread( new Runnable() { @Override public void run() { expireLoop(); } }, "FocusExpireThread"); enabled = true; timeoutThread.start(); }
/** * Initializes the server stored list. Synchronize server stored groups and contacts with the * local groups and contacts. */ @Override public void init() { try { SipAccountIDImpl accountID = (SipAccountIDImpl) sipProvider.getAccountID(); if (!accountID.isXiVOEnable()) return; boolean useSipCredentials = accountID.isClistOptionUseSipCredentials(); String serverAddress = accountID.getClistOptionServerUri(); String username = accountID.getAccountPropertyString(ProtocolProviderFactory.USER_ID); Address userAddress = sipProvider.parseAddressString(username); if (useSipCredentials) { username = ((SipUri) userAddress.getURI()).getUser(); } else { username = accountID.getClistOptionUser(); } try { connect(serverAddress); } catch (Throwable ex) { showError(ex, null, null); logger.error("Error connecting to server", ex); return; } Thread thread = new Thread(this, this.getClass().getName()); thread.setDaemon(true); thread.start(); if (!login(username)) { showError(null, null, "Unauthorized. Cannot login."); logger.error("Cannot login."); return; } } catch (Throwable t) { logger.error("Error init clist from xivo server"); } }