Search in sources :

Example 21 with IRequester

use of de.janrufmonitor.service.commons.http.IRequester in project janrufmonitor by tbrandt77.

the class ClientDialerDialog method okPressed.

protected void okPressed() {
    if (dialBox != null) {
        String dial = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toCallable(dialBox.getText());
        // added 2010/03/06: check for dial prefix for outgoing calls
        if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length() > 0) {
            if (this.m_logger.isLoggable(Level.INFO))
                this.m_logger.info("Using dial prefix: " + this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
            dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
        }
        if (dial.trim().length() > 0) {
            String text = getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "description", getLanguage());
            text = StringUtils.replaceString(text, "{%1}", dial);
            String text2 = this.getI18nManager().getString("ui.jface.application.dialer.ClientDialerCommand", "success", "label", this.getLanguage());
            text2 = StringUtils.replaceString(text2, "{%1}", line.getText());
            if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), text2, text)) {
                String selectedTapi = line.getText();
                ClientHandle th = (ClientHandle) handlemap.get(selectedTapi);
                if (th != null && th.getLine().length() > 0) {
                    // save the handle for next time selection
                    getRuntime().getConfigManagerFactory().getConfigManager().setProperty(NAMESPACE, "lineselection", selectedTapi);
                    getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
                    if (m_logger.isLoggable(Level.INFO)) {
                        m_logger.info("Selected Client handle: " + th.toString());
                    }
                    try {
                        IRequester r = this.getRequester(new Dial(dial, URLEncoder.encode(th.getLine(), "UTF-8")));
                        IHttpResponse resp = r.request();
                        if (resp.getCode() != 200) {
                            m_logger.severe("Invalid client call to server. Error code " + resp.getCode());
                        }
                    } catch (UnsupportedEncodingException e) {
                        m_logger.log(Level.SEVERE, e.getMessage(), e);
                    }
                } else {
                    m_logger.warning("Invalid Client line for outgoing call selected.");
                }
            }
        }
    }
    super.okPressed();
}
Also used : Dial(de.janrufmonitor.service.client.request.handler.Dial) Shell(org.eclipse.swt.widgets.Shell) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IRequester(de.janrufmonitor.service.commons.http.IRequester) IHttpResponse(de.janrufmonitor.service.commons.http.IHttpResponse)

Aggregations

IRequester (de.janrufmonitor.service.commons.http.IRequester)21 IHttpResponse (de.janrufmonitor.service.commons.http.IHttpResponse)14 UnknownHostException (java.net.UnknownHostException)4 ICallerList (de.janrufmonitor.framework.ICallerList)3 GetDialExtensions (de.janrufmonitor.service.client.request.handler.GetDialExtensions)3 IHttpRequest (de.janrufmonitor.service.commons.http.IHttpRequest)3 IOException (java.io.IOException)3 CallerListGetHandler (de.janrufmonitor.service.client.request.handler.CallerListGetHandler)2 GetImageHandler (de.janrufmonitor.service.client.request.handler.GetImageHandler)2 FileNotFoundException (java.io.FileNotFoundException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 MalformedURLException (java.net.MalformedURLException)2 Message (de.janrufmonitor.exception.Message)1 ICall (de.janrufmonitor.framework.ICall)1 ICallList (de.janrufmonitor.framework.ICallList)1 ICaller (de.janrufmonitor.framework.ICaller)1 IMsn (de.janrufmonitor.framework.IMsn)1 ClientHandler (de.janrufmonitor.service.client.http.simple.ClientHandler)1 CallListCountGetHandler (de.janrufmonitor.service.client.request.handler.CallListCountGetHandler)1 CallListGetHandler (de.janrufmonitor.service.client.request.handler.CallListGetHandler)1