/** * Shows an error and a short description. * * @param ex the exception */ static void showError(Throwable ex, String title, String message) { try { if (title == null) title = "Error in SIP contactlist storage"; if (message == null) message = title + "\n" + ex.getClass().getName() + ": " + ex.getLocalizedMessage(); if (SipActivator.getUIService() != null) SipActivator.getUIService() .getPopupDialog() .showMessagePopupDialog(message, title, PopupDialog.ERROR_MESSAGE); } catch (Throwable t) { logger.error("Error for error dialog", t); } }
/** Handles new incoming object. */ private void handle(JSONObject incomingObject) { if (!incomingObject.containsKey("class")) return; try { String classField = (String) incomingObject.get("class"); if (classField.equals("loginko")) { showError(null, null, "Unauthorized. Cannot login: "******"errorstring")); logger.error("Error login: "******"errorstring")); destroy(); return; } else if (classField.equals("login_id_ok")) { SipAccountIDImpl accountID = (SipAccountIDImpl) sipProvider.getAccountID(); boolean useSipCredentials = accountID.isClistOptionUseSipCredentials(); String password; if (useSipCredentials) { password = SipActivator.getProtocolProviderFactory().loadPassword(accountID); } else { password = accountID.getClistOptionPassword(); } if (!authorize((String) incomingObject.get("sessionid"), password)) logger.error("Error login authorization!"); return; } else if (classField.equals("login_pass_ok")) { if (!sendCapas((JSONArray) incomingObject.get("capalist"))) logger.error("Error send capas!"); return; } else if (classField.equals("login_capas_ok")) { if (!sendFeatures( (String) incomingObject.get("astid"), (String) incomingObject.get("xivo_userid"))) logger.error("Problem send features get!"); return; } else if (classField.equals("features")) { if (!getPhoneList()) logger.error("Problem send get phones!"); return; } else if (classField.equals("phones")) { phonesRecieved(incomingObject); return; } else if (classField.equals("disconn")) { destroy(); return; } else { if (logger.isTraceEnabled()) logger.trace("unhandled classField: " + incomingObject); return; } } catch (Throwable t) { logger.error("Error handling incoming object", t); } }