Skip to content

Commit

Permalink
preference for remote mosh server path
Browse files Browse the repository at this point in the history
  • Loading branch information
ddrown committed Jan 18, 2013
1 parent b7005ed commit a5a5c9e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
5 changes: 5 additions & 0 deletions res/values/strings.xml
Expand Up @@ -315,6 +315,11 @@
<!-- mosh port preference summary -->
<string name="hostpref_moshport_summary">"Port to request mosh-server use, or 0 for automatic"</string>

<!-- mosh server preference title -->
<string name="hostpref_moshserver_title">"Requested Mosh Server"</string>
<!-- mosh server preference summary -->
<string name="hostpref_moshserver_summary">"Path to mosh-server on the remote host"</string>

<!-- locale preference title -->
<string name="hostpref_locale_title">"Locale to send to server"</string>
<!-- locale preference summary -->
Expand Down
6 changes: 6 additions & 0 deletions res/xml/host_prefs.xml
Expand Up @@ -105,6 +105,12 @@
android:summary="@string/hostpref_moshport_summary"
/>

<EditTextPreference
android:key="moshserver"
android:title="@string/hostpref_moshserver_title"
android:summary="@string/hostpref_moshserver_summary"
/>

<EditTextPreference
android:key="locale"
android:title="@string/hostpref_locale_title"
Expand Down
1 change: 1 addition & 0 deletions src/org/woltage/irssiconnectbot/HostEditorActivity.java
Expand Up @@ -377,6 +377,7 @@ private void removeIrrelevantPrefs() {
if (!prot.equals(Mosh.PROTOCOL)) {
removePref(HostDatabase.FIELD_HOST_MOSHPORT);
removePref(HostDatabase.FIELD_HOST_LOCALE);
removePref(HostDatabase.FIELD_HOST_MOSH_SERVER);
}
if (!prot.equals(Mosh.PROTOCOL) && !prot.equals(SSH.PROTOCOL)) {
removePref(HostDatabase.FIELD_HOST_COMPRESSION);
Expand Down
12 changes: 12 additions & 0 deletions src/org/woltage/irssiconnectbot/bean/HostBean.java
Expand Up @@ -51,6 +51,7 @@ public class HostBean extends AbstractBean {
private String encoding = HostDatabase.ENCODING_DEFAULT;
private boolean stayConnected = false;
private int moshPort = -1;
private String moshServer = null;
private String locale = HostDatabase.LOCALE_DEFAULT;

public HostBean() {
Expand Down Expand Up @@ -211,6 +212,13 @@ public int getMoshPort() {
return moshPort;
}

public void setMoshServer(String moshServer) {
this.moshServer = moshServer;
}
public String getMoshServer() {
return moshServer;
}

public void setLocale(String locale) {
this.locale = locale;
}
Expand Down Expand Up @@ -251,6 +259,7 @@ public ContentValues getValues() {
values.put(HostDatabase.FIELD_HOST_ENCODING, encoding);
values.put(HostDatabase.FIELD_HOST_STAYCONNECTED, stayConnected);
values.put(HostDatabase.FIELD_HOST_MOSHPORT, moshPort);
values.put(HostDatabase.FIELD_HOST_MOSH_SERVER, moshServer);
values.put(HostDatabase.FIELD_HOST_LOCALE, locale);

return values;
Expand Down Expand Up @@ -296,6 +305,9 @@ public boolean equals(Object o) {
if (moshPort != host.getMoshPort())
return false;

if (moshServer != host.getMoshServer())
return false;

if (locale != host.getLocale())
return false;

Expand Down
7 changes: 5 additions & 2 deletions src/org/woltage/irssiconnectbot/transport/Mosh.java
Expand Up @@ -160,8 +160,11 @@ protected void finishConnection() {
bridge.outputLine("ssh rejected our LANG environment variable: "+e.getMessage());
}

String serverCommand = "mosh-server new -s";
serverCommand += " -l LANG="+host.getLocale();
String serverCommand = host.getMoshServer();
if(serverCommand == null) {
serverCommand = "mosh-server";
}
serverCommand += " new -s -l LANG="+host.getLocale();
if(host.getMoshPort() > 0) {
serverCommand += " -p "+host.getMoshPort();
}
Expand Down
10 changes: 9 additions & 1 deletion src/org/woltage/irssiconnectbot/util/HostDatabase.java
Expand Up @@ -47,7 +47,7 @@ public class HostDatabase extends RobustSQLiteOpenHelper {
public final static String TAG = "ConnectBot.HostDatabase";

public final static String DB_NAME = "hosts";
public final static int DB_VERSION = 24;
public final static int DB_VERSION = 25;

public final static String TABLE_HOSTS = "hosts";
public final static String FIELD_HOST_NICKNAME = "nickname";
Expand All @@ -70,6 +70,7 @@ public class HostDatabase extends RobustSQLiteOpenHelper {
public final static String FIELD_HOST_ENCODING = "encoding";
public final static String FIELD_HOST_STAYCONNECTED = "stayconnected";
public final static String FIELD_HOST_MOSHPORT = "moshport";
public final static String FIELD_HOST_MOSH_SERVER = "moshserver";
public final static String FIELD_HOST_LOCALE = "locale";

public final static String TABLE_PORTFORWARDS = "portforwards";
Expand Down Expand Up @@ -112,6 +113,7 @@ public class HostDatabase extends RobustSQLiteOpenHelper {

public final static String ENCODING_DEFAULT = Charset.defaultCharset().name();
public final static String LOCALE_DEFAULT = "en_US.UTF-8";
public final static String MOSH_SERVER_DEFAULT = "mosh-server";

public final static long PUBKEYID_NEVER = -2;
public final static long PUBKEYID_ANY = -1;
Expand Down Expand Up @@ -176,6 +178,7 @@ public void onCreate(SQLiteDatabase db) {
+ FIELD_HOST_STAYCONNECTED + " TEXT, "
+ FIELD_HOST_MOSHPORT + " INTEGER DEFAULT 0, "
+ FIELD_HOST_LOCALE + " TEXT DEFAULT '" + LOCALE_DEFAULT + "' "
+ FIELD_HOST_MOSH_SERVER + " TEXT DEFAULT '" + MOSH_SERVER_DEFAULT + "', "
+ ")");

db.execSQL("CREATE TABLE " + TABLE_PORTFORWARDS
Expand Down Expand Up @@ -275,6 +278,9 @@ public void onRobustUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) t
case 23:
db.execSQL("ALTER TABLE " + TABLE_PORTFORWARDS
+ " ADD COLUMN " + FIELD_PORTFORWARD_BINDADDR + " TEXT");
case 24:
db.execSQL("ALTER TABLE " + TABLE_HOSTS
+ " ADD COLUMN " + FIELD_HOST_MOSH_SERVER + " TEXT DEFAULT '" + MOSH_SERVER_DEFAULT + "'");
}
}

Expand Down Expand Up @@ -400,6 +406,7 @@ private List<HostBean> createHostBeans(Cursor c) {
COL_ENCODING = c.getColumnIndexOrThrow(FIELD_HOST_ENCODING),
COL_STAYCONNECTED = c.getColumnIndexOrThrow(FIELD_HOST_STAYCONNECTED),
COL_MOSHPORT = c.getColumnIndexOrThrow(FIELD_HOST_MOSHPORT),
COL_MOSH_SERVER = c.getColumnIndexOrThrow(FIELD_HOST_MOSH_SERVER),
COL_LOCALE = c.getColumnIndexOrThrow(FIELD_HOST_LOCALE);


Expand All @@ -425,6 +432,7 @@ private List<HostBean> createHostBeans(Cursor c) {
host.setEncoding(c.getString(COL_ENCODING));
host.setStayConnected(Boolean.valueOf(c.getString(COL_STAYCONNECTED)));
host.setMoshPort(c.getInt(COL_MOSHPORT));
host.setMoshServer(c.getString(COL_MOSH_SERVER));
host.setLocale(c.getString(COL_LOCALE));

hosts.add(host);
Expand Down

0 comments on commit a5a5c9e

Please sign in to comment.