Skip to content

Commit

Permalink
Only ignore the MOTD once.
Browse files Browse the repository at this point in the history
  • Loading branch information
Darren Salt authored and pocmo committed Jul 2, 2011
1 parent a6da497 commit 23ca120
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions application/res/values/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<string name="key_reconnect_interval">reconnect_interval</string>
<string name="default_reconnect_interval">5</string>

<string name="key_ignore_motd">ignore_motd</string>
<string name="default_ignore_motd">true</string>

<string name="key_quitmessage">quitmessage</string>
<string name="default_quitmessage">Yaaic - Yet another Android IRC client - http://www.yaaic.org</string>

Expand Down
4 changes: 4 additions & 0 deletions application/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,14 @@
<string name="settings_connection">Connection</string>
<string name="settings_reconnect_title">Reconnect</string>
<string name="settings_reconnect_desc">Automatically reconnect on disconnect</string>

<string name="settings_reconnect_interval_title">Reconnect interval</string>
<string name="settings_reconnect_interval_desc">Number of minutes between reconnection tries</string>
<string name="settings_reconnect_interval_dialog_title">Reconnect interval</string>

<string name="settings_ignore_motd_title">Ignore MOTD</string>
<string name="settings_ignore_motd_desc">Don\'t show the automatic ‘Message of the Day’ sent by the server</string>

<string name="settings_chat">Chat</string>
<string name="settings_icons_title">Show icons</string>
<string name="settings_icons_desc">Show icons to highlight special events</string>
Expand Down
5 changes: 5 additions & 0 deletions application/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:entryValues="@array/reconnect_interval_values"
android:key="@string/key_reconnect_interval"
android:defaultValue="@string/default_reconnect_interval" />
<CheckBoxPreference
android:title="@string/settings_ignore_motd_title"
android:summary="@string/settings_ignore_motd_desc"
android:key="@string/key_ignore_motd"
android:defaultValue="@string/default_ignore_motd" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/settings_chat">
Expand Down
12 changes: 10 additions & 2 deletions application/src/org/yaaic/irc/IRCConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class IRCConnection extends PircBot
private ArrayList<String> autojoinChannels;
private Pattern mNickMatch;

private boolean ignoreMOTD = true;

private boolean isQuitting = false;
private boolean disposeRequested = false;
private final Object isQuittingLock = new Object();
Expand Down Expand Up @@ -140,8 +142,11 @@ public void setIdent(String ident)
public void onConnect()
{
server.setStatus(Status.CONNECTED);

server.setMayReconnect(true);

ignoreMOTD = service.getSettings().isIgnoreMOTDEnabled();

service.sendBroadcast(
Broadcast.createServerIntent(Broadcast.SERVER_UPDATE, server.getId())
);
Expand Down Expand Up @@ -1089,8 +1094,11 @@ protected void onServerResponse(int code, String response)
onRegister();
return;
}
if (code == 372 || code == 375 || code == 376) {
// Skip MOTD
if ((code == 372 || code == 375) && ignoreMOTD) {
return;
}
if (code == 376 && ignoreMOTD) {
ignoreMOTD = false;
return;
}

Expand Down
13 changes: 13 additions & 0 deletions application/src/org/yaaic/model/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ public int getReconnectInterval()
resources.getString(R.string.default_reconnect_interval)
));
}

/**
* Ignore the automatic MOTD?
*
* @return
*/
public boolean isIgnoreMOTDEnabled()
{
return preferences.getBoolean(
resources.getString(R.string.key_ignore_motd),
Boolean.parseBoolean(resources.getString(R.string.default_ignore_motd))
);
}

/**
* Get the quit message
Expand Down

0 comments on commit 23ca120

Please sign in to comment.