mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-08 05:24:39 +01:00
make md5sum calculation available everywhere
I want to log sums to see when they arrive on relay. And also add some missing @Overrides I noticed.
This commit is contained in:
parent
236be21a78
commit
9f7899cd7c
4 changed files with 41 additions and 26 deletions
|
@ -347,9 +347,10 @@ public class CommsTransport implements TransportProcs,
|
|||
}
|
||||
|
||||
// TransportProcs interface
|
||||
|
||||
@Override
|
||||
public int getFlags() { return COMMS_XPORT_FLAGS_NONE; }
|
||||
|
||||
@Override
|
||||
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
|
||||
CommsConnType conType, int gameID )
|
||||
{
|
||||
|
@ -386,17 +387,20 @@ public class CommsTransport implements TransportProcs,
|
|||
return nSent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relayConnd( String room, int devOrder, boolean allHere,
|
||||
int nMissing )
|
||||
{
|
||||
m_tpHandler.tpmRelayConnd( room, devOrder, allHere, nMissing );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relayErrorProc( XWRELAY_ERROR relayErr )
|
||||
{
|
||||
m_tpHandler.tpmRelayErrorProc( relayErr );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relayNoConnProc( byte[] buf, String msgNo, String relayID )
|
||||
{
|
||||
Assert.fail();
|
||||
|
|
|
@ -84,9 +84,10 @@ public class MultiMsgSink implements TransportProcs {
|
|||
}
|
||||
|
||||
/***** TransportProcs interface *****/
|
||||
|
||||
@Override
|
||||
public int getFlags() { return COMMS_XPORT_FLAGS_HASNOCONN; }
|
||||
|
||||
@Override
|
||||
public int transportSend( byte[] buf, String msgNo, CommsAddrRec addr,
|
||||
CommsConnType typ, int gameID )
|
||||
{
|
||||
|
@ -118,15 +119,18 @@ public class MultiMsgSink implements TransportProcs {
|
|||
return nSent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relayErrorProc( XWRELAY_ERROR relayErr )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void relayConnd( String room, int devOrder, boolean allHere,
|
||||
int nMissing )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean relayNoConnProc( byte[] buf, String msgNo, String relayID )
|
||||
{
|
||||
// Assert.fail();
|
||||
|
|
|
@ -68,13 +68,13 @@ import java.io.InputStreamReader;
|
|||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
import org.eehouse.android.xw4.Perms23.Perm;
|
||||
import org.eehouse.android.xw4.jni.CommonPrefs;
|
||||
import org.eehouse.android.xw4.loc.LocUtils;
|
||||
|
@ -359,6 +359,32 @@ public class Utils {
|
|||
return str;
|
||||
}
|
||||
|
||||
public static String getMD5SumFor( byte[] bytes )
|
||||
{
|
||||
String result = null;
|
||||
if ( bytes != null ) {
|
||||
byte[] digest = null;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] buf = new byte[128];
|
||||
int nLeft = bytes.length;
|
||||
int offset = 0;
|
||||
while ( 0 < nLeft ) {
|
||||
int len = Math.min( buf.length, nLeft );
|
||||
System.arraycopy( bytes, offset, buf, 0, len );
|
||||
md.update( buf, 0, len );
|
||||
nLeft -= len;
|
||||
offset += len;
|
||||
}
|
||||
digest = md.digest();
|
||||
} catch ( java.security.NoSuchAlgorithmException nsae ) {
|
||||
Log.ex( TAG, nsae );
|
||||
}
|
||||
result = Utils.digestToString( digest );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void setChecked( View parent, int id, boolean value )
|
||||
{
|
||||
CheckBox cbx = (CheckBox)parent.findViewById( id );
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.eehouse.android.xw4.Utils;
|
|||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class JNIUtilsImpl implements JNIUtils {
|
||||
|
@ -62,6 +61,7 @@ public class JNIUtilsImpl implements JNIUtils {
|
|||
* <letter>[<delim><letter]*, so for each loop until the delim
|
||||
* isn't found.
|
||||
*/
|
||||
@Override
|
||||
public String[][] splitFaces( byte[] chars, boolean isUTF8 )
|
||||
{
|
||||
ArrayList<String[]> faces = new ArrayList<String[]>();
|
||||
|
@ -130,32 +130,13 @@ public class JNIUtilsImpl implements JNIUtils {
|
|||
faces.add( face.toArray( new String[face.size()] ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMD5SumFor( byte[] bytes )
|
||||
{
|
||||
String result = null;
|
||||
if ( bytes != null ) {
|
||||
byte[] digest = null;
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] buf = new byte[128];
|
||||
int nLeft = bytes.length;
|
||||
int offset = 0;
|
||||
while ( 0 < nLeft ) {
|
||||
int len = Math.min( buf.length, nLeft );
|
||||
System.arraycopy( bytes, offset, buf, 0, len );
|
||||
md.update( buf, 0, len );
|
||||
nLeft -= len;
|
||||
offset += len;
|
||||
}
|
||||
digest = md.digest();
|
||||
} catch ( java.security.NoSuchAlgorithmException nsae ) {
|
||||
Log.ex( TAG, nsae );
|
||||
}
|
||||
result = Utils.digestToString( digest );
|
||||
}
|
||||
return result;
|
||||
return Utils.getMD5SumFor( bytes );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMD5SumFor( String dictName, byte[] bytes )
|
||||
{
|
||||
String result = null;
|
||||
|
|
Loading…
Reference in a new issue