mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-12-21 06:58:51 -05:00
Add setting to debug IRC traffic. Refs #91.
After this setting has been enabled all IRC traffic will be written to the verbose log (only for new connections).
This commit is contained in:
parent
f9ef1c65ec
commit
a39a4259ea
@ -65,4 +65,7 @@
|
||||
|
||||
<string name="key_history_size" translatable="false">history_size</string>
|
||||
<string name="default_history_size" translatable="false">50</string>
|
||||
|
||||
<string name="key_debug_traffic" translatable="false">debug_traffic</string>
|
||||
<string name="default_debug_traffic" translatable="false">false</string>
|
||||
</resources>
|
||||
|
@ -234,6 +234,8 @@
|
||||
<string name="settings_ime_extract_desc">Use fullscreen keyboard when in landscape mode</string>
|
||||
<string name="settings_history_size_title">History size</string>
|
||||
<string name="settings_history_size_desc">Number of lines of conversation history to keep</string>
|
||||
<string name="settings_debug_traffic_title">Debug IRC traffic</string>
|
||||
<string name="settings_debug_traffic_desc">Log IRC traffic to the verbose log. This may be a security risk!</string>
|
||||
|
||||
<string name="minute_1">1 minute</string>
|
||||
<string name="minutes_5">5 minutes</string>
|
||||
|
@ -154,5 +154,10 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
android:defaultValue="@string/default_quitmessage"
|
||||
android:dialogTitle="@string/settings_quitmessage_dialog_title"
|
||||
android:dialogMessage="@string/settings_quitmessage_dialog_desc" />
|
||||
<CheckBoxPreference
|
||||
android:title="@string/settings_debug_traffic_title"
|
||||
android:summary="@string/settings_debug_traffic_desc"
|
||||
android:key="@string/key_debug_traffic"
|
||||
android:defaultValue="@string/default_debug_traffic" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
@ -21,11 +21,13 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.yaaic.irc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jibble.pircbot.NickAlreadyInUseException;
|
||||
import org.jibble.pircbot.PircBot;
|
||||
import org.jibble.pircbot.User;
|
||||
import org.yaaic.R;
|
||||
@ -41,6 +43,7 @@ import org.yaaic.model.ServerInfo;
|
||||
import org.yaaic.model.Status;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* The class that actually handles the connection to an IRC server
|
||||
@ -49,13 +52,14 @@ import android.content.Intent;
|
||||
*/
|
||||
public class IRCConnection extends PircBot
|
||||
{
|
||||
private static final String TAG = "Yaaic/IRCConnection";
|
||||
private final IRCService service;
|
||||
private final Server server;
|
||||
private ArrayList<String> autojoinChannels;
|
||||
private Pattern mNickMatch;
|
||||
|
||||
private boolean ignoreMOTD = true;
|
||||
|
||||
private boolean debugTraffic = false;
|
||||
private boolean isQuitting = false;
|
||||
private boolean disposeRequested = false;
|
||||
private final Object isQuittingLock = new Object();
|
||||
@ -71,6 +75,8 @@ public class IRCConnection extends PircBot
|
||||
this.server = Yaaic.getInstance().getServerById(serverId);
|
||||
this.service = service;
|
||||
|
||||
this.debugTraffic = service.getSettings().debugTraffic();
|
||||
|
||||
// XXX: Should be configurable via settings
|
||||
this.setAutoNickChange(true);
|
||||
|
||||
@ -78,6 +84,21 @@ public class IRCConnection extends PircBot
|
||||
this.updateNickMatchPattern();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method handles events when any line of text arrives from the server.
|
||||
*
|
||||
* We are intercepting this method call for logging the IRC traffic if
|
||||
* this debug option is set.
|
||||
*/
|
||||
@Override
|
||||
protected void handleLine(String line) throws NickAlreadyInUseException, IOException {
|
||||
if (debugTraffic) {
|
||||
Log.v(TAG, server.getTitle() + " :: " + line);
|
||||
}
|
||||
|
||||
super.handleLine(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nickname of the user
|
||||
*
|
||||
|
@ -299,6 +299,17 @@ public class Settings
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should IRC traffic be logged to the verbose log?
|
||||
* @return
|
||||
*/
|
||||
public boolean debugTraffic() {
|
||||
return preferences.getBoolean(
|
||||
resources.getString(R.string.key_debug_traffic),
|
||||
Boolean.parseBoolean(resources.getString(R.string.default_debug_traffic))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether sentences in messages should be automatically capitalized.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user