Changeset 287

Show
Ignore:
Timestamp:
09/27/08 03:46:42 PM (3 months ago)
Author:
octorian
Message:

Added configurable local hostname for SMTP issue (#102)

Location:
branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/conf/GlobalConfig.java

    r191 r287  
    6060    /** Hide deleted messages */ 
    6161    private boolean hideDeletedMsg; 
     62    /** Local host name override */ 
     63    private String localHostname; 
    6264 
    6365    /** WiFi support is disabled, best for non-WiFi devices */ 
     
    9092        this.wifiMode = GlobalConfig.WIFI_DISABLED; 
    9193        this.hideDeletedMsg = true; 
     94        this.localHostname = ""; 
    9295    } 
    9396     
     
    155158        this.hideDeletedMsg = hideDeletedMsg; 
    156159    } 
    157       
     160 
     161    public String getLocalHostname() { 
     162        return this.localHostname; 
     163    } 
     164     
     165    public void setLocalHostname(String localHostname) { 
     166        this.localHostname = localHostname; 
     167    } 
     168     
    158169    public void serialize(DataOutputStream output) throws IOException { 
    159170        output.writeLong(uniqueId); 
     
    169180        table.put("global_connDebug", new Boolean(connDebug)); 
    170181        table.put("global_hideDeletedMsg", new Boolean(hideDeletedMsg)); 
     182        table.put("global_localHostname", localHostname); 
    171183 
    172184        table.serialize(output); 
     
    214226            hideDeletedMsg = ((Boolean)value).booleanValue(); 
    215227        } 
     228        value = table.get("global_localHostname"); 
     229        if(value != null && value instanceof String) { 
     230            localHostname = (String)value; 
     231        } 
    216232    } 
    217233 
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/mail/smtp/SmtpClient.java

    r282 r287  
    8989            // Eat the initial server response 
    9090            connection.receive(); 
    91             String hostname = System.getProperty("microedition.hostname"); 
    92             if(hostname == null) { 
    93                 hostname = connection.getLocalAddress(); 
     91             
     92            String hostname = globalConfig.getLocalHostname(); 
     93            if(hostname.length() == 0) { 
     94                hostname = System.getProperty("microedition.hostname"); 
     95                if(hostname == null) { 
     96                    hostname = connection.getLocalAddress(); 
     97                } 
    9498            } 
    9599 
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/ui/GlobalConfigScreen.java

    r192 r287  
    5757    private CheckboxField fldConnDebug; 
    5858    private CheckboxField fldHideDeletedMsg; 
     59    private CheckboxField fldOverrideHostname; 
     60    private BasicEditField fldLocalHostname; 
    5961    private ButtonField btSave; 
     62    private String localHostname; 
    6063 
    6164    public GlobalConfigScreen() { 
     
    6467        mailSettings = MailSettings.getInstance(); 
    6568        GlobalConfig config = mailSettings.getGlobalConfig(); 
    66  
     69        localHostname = config.getLocalHostname(); 
     70         
    6771        add(new RichTextField("Global settings:", Field.NON_FOCUSABLE)); 
    6872         
     
    100104        add(fldPopMaxLines); 
    101105 
     106        boolean overrideHostname = localHostname.length() > 0; 
     107        fldOverrideHostname = new CheckboxField("Override hostname", overrideHostname); 
     108        fldOverrideHostname.setChangeListener(this); 
     109        add(fldOverrideHostname); 
     110         
     111        if(overrideHostname) { 
     112            fldLocalHostname = new BasicEditField("  Hostname: ", localHostname); 
     113        } 
     114        else { 
     115            String hostname = System.getProperty("microedition.hostname"); 
     116            fldLocalHostname = new BasicEditField("  Hostname: ", ((hostname != null) ? hostname : "localhost")); 
     117            fldLocalHostname.setEditable(false); 
     118        } 
     119        add(fldLocalHostname); 
     120         
    102121        fldConnDebug = new CheckboxField("Connection debugging", config.getConnDebug()); 
    103122        add(fldConnDebug); 
     
    113132        if(field == btSave) { 
    114133            onClose(); 
     134        } 
     135        else if(field == fldOverrideHostname) { 
     136            if(fldOverrideHostname.getChecked()) { 
     137                fldLocalHostname.setText(localHostname); 
     138                fldLocalHostname.setEditable(true); 
     139            } 
     140            else { 
     141                String hostname = System.getProperty("microedition.hostname"); 
     142                fldLocalHostname.setText((hostname != null) ? hostname : "localhost"); 
     143                fldLocalHostname.setEditable(false); 
     144            } 
    115145        } 
    116146    } 
     
    141171            config.setPopMaxLines(Integer.parseInt(fldPopMaxLines.getText())); 
    142172        } catch (Exception e) { } 
     173         
     174        if(fldOverrideHostname.getChecked()) { 
     175            config.setLocalHostname(fldLocalHostname.getText().trim()); 
     176        } 
     177        else { 
     178            config.setLocalHostname(""); 
     179        } 
     180         
    143181        config.setConnDebug(fldConnDebug.getChecked()); 
    144182        mailSettings.saveSettings();