Improve proper handling of wrong password. MSN now handles "Login from other location". Some method removes in codec ilbc impl

cusax-fix
Damian Minkov 19 years ago
parent d546c903ca
commit 4a3c769376

@ -1,148 +0,0 @@
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3)
// Source File Name: FormatInfo.java
package com.sun.media.rtp;
import javax.media.Format;
import javax.media.format.AudioFormat;
import javax.media.format.VideoFormat;
// Referenced classes of package com.sun.media.rtp:
// SSRCCache
public class FormatInfo
{
public FormatInfo()
{
cache = null;
formatList = new Format[111];
initFormats();
}
public void setCache(SSRCCache ssrccache)
{
cache = ssrccache;
}
public void add(int i, Format format)
{
if(i >= formatList.length)
expandTable(i);
Format format1;
if((format1 = formatList[i]) != null)
return;
formatList[i] = format;
if(cache != null && (format instanceof VideoFormat))
cache.clockrate[i] = 0x15f90;
if(cache != null && (format instanceof AudioFormat))
if(mpegAudio.matches(format))
cache.clockrate[i] = 0x15f90;
else
cache.clockrate[i] = (int)((AudioFormat)format).getSampleRate();
}
private void expandTable(int i)
{
Format aformat[] = new Format[i + 1];
for(int j = 0; j < formatList.length; j++)
aformat[j] = formatList[j];
formatList = aformat;
}
public Format get(int i)
{
return i < formatList.length ? formatList[i] : null;
}
public int getPayload(Format format)
{
if(format.getEncoding() != null && format.getEncoding().equals("g729a/rtp"))
format = new AudioFormat("g729/rtp");
for(int i = 0; i < formatList.length; i++)
if(format.matches(formatList[i]))
return i;
return -1;
}
public void initFormats()
{
formatList[0] = new AudioFormat("ULAW/rtp", 8000D, 8, 1);
formatList[3] = new AudioFormat("gsm/rtp", 8000D, -1, 1);
formatList[4] = new AudioFormat("g723/rtp", 8000D, -1, 1);
formatList[5] = new AudioFormat("dvi/rtp", 8000D, 4, 1);
formatList[8] = new AudioFormat("ALAW/rtp", 8000D, 8, 1);
formatList[14] = new AudioFormat("mpegaudio/rtp", -1D, -1, -1);
formatList[15] = new AudioFormat("g728/rtp", 8000D, -1, 1);
formatList[16] = new AudioFormat("dvi/rtp", 11025D, 4, 1);
formatList[17] = new AudioFormat("dvi/rtp", 22050D, 4, 1);
formatList[18] = new AudioFormat("g729/rtp", 8000D, -1, 1);
formatList[26] = new VideoFormat("jpeg/rtp");
formatList[31] = new VideoFormat("h261/rtp");
formatList[32] = new VideoFormat("mpeg/rtp");
formatList[34] = new VideoFormat("h263/rtp");
formatList[42] = new VideoFormat("h263-1998/rtp");
formatList[97] = new AudioFormat("ilbc/rtp", 8000D, -1, 1);
formatList[98] = new AudioFormat("ilbc/rtp", 8000D, -1, 1);
formatList[110] = new AudioFormat("speex/rtp", 8000D, 8, 1);
}
public static boolean isSupported(int i)
{
switch(i)
{
case 0: // '\0'
case 3: // '\003'
case 4: // '\004'
case 5: // '\005'
case 6: // '\006'
case 8: // '\b'
case 14: // '\016'
case 15: // '\017'
case 16: // '\020'
case 17: // '\021'
case 18: // '\022'
case 26: // '\032'
case 31: // '\037'
case 32: // ' '
case 34: // '"'
case 97:
case 98:
case 110:
return true;
case 1: // '\001'
case 2: // '\002'
case 7: // '\007'
case 9: // '\t'
case 10: // '\n'
case 11: // '\013'
case 12: // '\f'
case 13: // '\r'
case 19: // '\023'
case 20: // '\024'
case 21: // '\025'
case 22: // '\026'
case 23: // '\027'
case 24: // '\030'
case 25: // '\031'
case 27: // '\033'
case 28: // '\034'
case 29: // '\035'
case 30: // '\036'
case 33: // '!'
default:
return false;
}
}
private SSRCCache cache;
public static final int PAYLOAD_NOTFOUND = -1;
Format formatList[];
static AudioFormat mpegAudio = new AudioFormat("mpegaudio/rtp");
}

Binary file not shown.

@ -29,8 +29,8 @@ public class Utils
* @throws java.lang.ArrayIndexOutOfBoundsException
*/
public static short[] byteToShortArray
(byte[] byteArray, int offset, int length) throws
ArrayIndexOutOfBoundsException
(byte[] byteArray, int offset, int length, boolean little)
throws ArrayIndexOutOfBoundsException
{
if (0 < length && (offset + length) <= byteArray.length)
@ -41,8 +41,17 @@ public class Utils
for (int i = offset, j = 0; j < shortLength;
j++, temp = 0x00000000)
{
temp = byteArray[i++] << 8;
temp |= 0x000000FF & byteArray[i++];
if(little)
{
temp = byteArray[i++] & 0x000000FF;
temp |= 0x0000FF00 & (byteArray[i++] << 8);
}
else
{
temp = byteArray[i++] << 8;
temp |= 0x000000FF & byteArray[i++];
}
shortArray[j] = (short) temp;
}
return shortArray;
@ -97,35 +106,4 @@ public static byte[] shortToBytes(short v, boolean little)
}
return rtn;
}
public static void byteToShortArr(byte[] in, int inOffset, short[] dst)
{
for (int i = 0; i < dst.length; i++)
{
if (in[inOffset + 2 * i + 1] >= 0)
{
dst[i] = in[inOffset + 2 * i + 1];
dst[i] *= (short) 256;
if ( (in[inOffset + 2 * i + 1] >= 0) && (in[inOffset + 2 * i] < 0))
dst[i] += (in[inOffset + 2 * i] + 256);
else
dst[i] += (in[inOffset + 2 * i]);
}
else
{
dst[i] = (in[inOffset + 2 * i + 1]);
dst[i]++;
dst[i] *= (short) 256;
if (in[inOffset + 2 * i] < 0)
{
dst[i] += (in[inOffset + 2 * i]);
}
else
{
dst[i] += (in[inOffset + 2 * i]);
dst[i] -= 256;
}
}
}
}
}

@ -45,7 +45,8 @@ public JavaDecoder()
16,
1,
Format.NOT_SPECIFIED,
Format.NOT_SPECIFIED)};
Format.NOT_SPECIFIED
)};
defaultOutputFormats = new AudioFormat[]
{
@ -114,11 +115,7 @@ public int process(Buffer inputBuffer, Buffer outputBuffer)
initConverter( (AudioFormat) newFormat, inpLength);
}
short[] data = Utils.byteToShortArray(inData, inOffset, inpLength);
//
// short[] data = new short[inpLength/2];
// Utils.byteToShortArr(inData, inOffset, data);
short[] data = Utils.byteToShortArray(inData, inOffset, inpLength, false);
short[] decodedData = new short[dec.ULP_inst.blockl];
dec.decode(decodedData, data, (short) 1);

@ -123,14 +123,12 @@ else if(inpLength < enc.ULP_inst.blockl*2)
return OUTPUT_BUFFER_NOT_FILLED;
}
short[] data = new short[enc.ULP_inst.blockl];
short[] encoded_data = new short[ILBC_NO_OF_BYTES / 2];
int outLength = ILBC_NO_OF_BYTES;
byte[] outdata = validateByteArraySize(outputBuffer, outLength);
Utils.byteToShortArr(inpData, inOffset, data);
short[] data = Utils.byteToShortArray(inpData, inOffset, inpLength, true);
enc.encode(encoded_data, data);
Utils.shortArrToByteArr(encoded_data, outdata, false);

@ -124,6 +124,8 @@ public void register(final SecurityAuthority authority)
connection.getSASLAuthentication().isAuthenticated()) ||
!connection.isAuthenticated())
{
JabberActivator.getProtocolProviderFactory().
storePassword(getAccountID(), null);
reason
= RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED;
regState = RegistrationState.AUTHENTICATION_FAILED;

@ -64,4 +64,10 @@ public void groupRenamed(MsnGroup group){}
* @param id String the id of the removed group
*/
public void groupRemoved(String id){}
/**
* Indicates that we are logged out
* beacuse account logged in from other location
*/
public void loggingFromOtherLocation(){}
}

@ -63,4 +63,10 @@ public interface EventListener
* @param id String the id of the removed group
*/
public void groupRemoved(String id);
/**
* Indicates that we are logged out
* beacuse account logged in from other location
*/
public void loggingFromOtherLocation();
}

@ -192,6 +192,12 @@ else if(incoming instanceof IncomingREM)
}
}
}
else if(incoming instanceof IncomingOUT)
{
IncomingOUT incomingOUT = (IncomingOUT)incoming;
if(incomingOUT.isLoggingFromOtherLocation())
fireLoggingFromOtherLocation();
}
}
/**
@ -334,4 +340,19 @@ private void fireGroupRemoved(String id)
}
}
}
/**
* Fired when we recived event for logging in from other location
*/
private void fireLoggingFromOtherLocation()
{
synchronized (listeners)
{
Iterator iter = listeners.iterator();
while (iter.hasNext())
{
( (EventListener) iter.next()).loggingFromOtherLocation();
}
}
}
}

@ -188,7 +188,7 @@ public void unregister()
* Unregister and fire the event if requested
* @param fireEvent boolean
*/
private void unregister(boolean fireEvent)
void unregister(boolean fireEvent)
{
RegistrationState currRegState = getRegistrationState();
@ -449,7 +449,7 @@ public void loginCompleted(MsnMessenger msnMessenger)
public void logout(MsnMessenger msnMessenger)
{
logger.trace("logout");
unregister(false);
// if(isRegistered())
// fireRegistrationStateChanged(
// getRegistrationState(),
@ -461,11 +461,16 @@ public void logout(MsnMessenger msnMessenger)
public void exceptionCaught(MsnMessenger msnMessenger, Throwable throwable)
{
if(throwable instanceof IncorrectPasswordException)
{
unregister(false);
MsnActivator.getProtocolProviderFactory().
storePassword(getAccountID(), null);
fireRegistrationStateChanged(
getRegistrationState(),
RegistrationState.AUTHENTICATION_FAILED,
RegistrationStateChangeEvent.REASON_AUTHENTICATION_FAILED,
"Incorrect Password");
}
else
{
if(throwable instanceof MsnProtocolException)
@ -495,6 +500,8 @@ public void exceptionCaught(MsnMessenger msnMessenger, Throwable throwable)
if(isRegistered())
{
unregister(false);
MsnActivator.getProtocolProviderFactory().
storePassword(getAccountID(), null);
fireRegistrationStateChanged(
getRegistrationState(),
RegistrationState.AUTHENTICATION_FAILED,

@ -1170,6 +1170,15 @@ public void groupRemoved(String id)
rootGroup.removeSubGroup(group);
fireGroupEvent(group, ServerStoredGroupEvent.GROUP_REMOVED_EVENT);
}
public void loggingFromOtherLocation()
{
msnProvider.unregister(false);
msnProvider.fireRegistrationStateChanged(
msnProvider.getRegistrationState(),
RegistrationState.UNREGISTERED,
RegistrationStateChangeEvent.REASON_MULTIPLE_LOGINS, null);
}
}
/**

Loading…
Cancel
Save