FileDocCategorySizeDatePackage
ImpsConnectionConfig.javaAPI DocAndroid 1.5 API14509Wed May 06 22:42:46 BST 2009com.android.im.imps

ImpsConnectionConfig

public class ImpsConnectionConfig extends com.android.im.engine.ConnectionConfig
The configuration for IMPS connection.

Fields Summary
private static final int
DEFAULT_KEEPALIVE_SECONDS
private static final int
DEFAULT_MIN_SERVER_POLL
private static final int
DEFAULT_SMS_PORT
private static final int
DEFAULT_SMS_CIR_PORT
private static final long
DEFAULT_PRESENCE_POLL_INTERVAL
private static final boolean
NEED_DELIVERY_REPORT
private com.android.im.imps.ImpsConstants.ImpsVersion
mImpsVersion
private TransportType
mDataChannelBinding
private CirMethod
mCirChannelBinding
private EncodingType
mDataEncoding
private boolean
mSecureLogin
private boolean
mBasicPresenceOnly
private String
mHost
private String
mClientId
private String
mMsisdn
private int
mUdpPort
private int
mReplyTimeout
private String
mContentType
private String
mVersionNs
private String
mTransactionNs
private String
mPresenceNs
private PresenceMapping
mPresenceMapping
private PasswordDigest
mPasswordDigest
private String
mDefaultDomain
private String
mCustomPasswordDigest
private String
mCustomPresenceMapping
private String
mPluginPath
private Map
mOthers
Constructors Summary
public ImpsConnectionConfig()


      
        setupVersionStrings();
    
public ImpsConnectionConfig(Map map)

        String dataChannel = map.get(ImpsConfigNames.DATA_CHANNEL);
        try {
            mDataChannelBinding = TransportType.valueOf(dataChannel);
        } catch (IllegalArgumentException e) {
            ImpsLog.log("Unknown DataChannel: " + dataChannel +", using HTTP");
            mDataChannelBinding = TransportType.HTTP;
        }

        String dataEncoding = map.get(ImpsConfigNames.DATA_ENCODING);
        try {
            mDataEncoding = EncodingType.valueOf(dataEncoding);
        } catch (IllegalArgumentException e) {
            ImpsLog.log("Unknown DataEncoding: " + dataEncoding +", using WBXML");
            mDataEncoding = EncodingType.WBXML;
        }

        String cirChannel = map.get(ImpsConfigNames.CIR_CHANNEL);
        try {
            mCirChannelBinding = CirMethod.valueOf(cirChannel);
        } catch (IllegalArgumentException e) {
            ImpsLog.log("Unknown CirChannel: " + cirChannel +", using TCP");
            mCirChannelBinding = CirMethod.STCP;
        }

        mHost = map.get(ImpsConfigNames.HOST);

        if (map.get(ImpsConfigNames.CLIENT_ID) != null) {
            mClientId = map.get(ImpsConfigNames.CLIENT_ID);
        }

        if (map.get(ImpsConfigNames.MSISDN) != null) {
            mMsisdn = map.get(ImpsConfigNames.MSISDN);
        }
        if (map.get(ImpsConfigNames.SECURE_LOGIN) != null) {
            mSecureLogin = isTrue(map.get(ImpsConfigNames.SECURE_LOGIN));
        }
        if (map.get(ImpsConfigNames.BASIC_PA_ONLY) != null) {
            mBasicPresenceOnly = isTrue(map.get(ImpsConfigNames.BASIC_PA_ONLY));
        }
        if (map.containsKey(ImpsConfigNames.VERSION)) {
            mImpsVersion = ImpsVersion.fromString(
                    map.get(ImpsConfigNames.VERSION));
        }
        setupVersionStrings();

        mDefaultDomain = map.get(ImpsConfigNames.DEFAULT_DOMAIN);

        mPluginPath = map.get(ImpsConfigNames.PLUGIN_PATH);
        mCustomPasswordDigest = map.get(ImpsConfigNames.CUSTOM_PASSWORD_DIGEST);
        mCustomPresenceMapping = map.get(ImpsConfigNames.CUSTOM_PRESENCE_MAPPING);

        mOthers = map;
    
Methods Summary
public PrimitiveParsercreatePrimitiveParser()

        if(mDataEncoding == EncodingType.WBXML) {
            return new WbxmlPrimitiveParser();
        } else if (mDataEncoding == EncodingType.XML) {
            return new XmlPrimitiveParser();
        } else if (mDataEncoding == EncodingType.SMS) {
            return new PtsPrimitiveParser();
        }

        ImpsLog.log("Unknown DataEncoding: " + mDataEncoding);
        return null;
    
public PrimitiveSerializercreatePrimitiveSerializer()

        if(mDataEncoding == EncodingType.WBXML) {
            return new WbxmlPrimitiveSerializer(mImpsVersion,
                    mVersionNs, mTransactionNs);
        } else if (mDataEncoding == EncodingType.XML) {
            return new XmlPrimitiveSerializer(mVersionNs, mTransactionNs);
        } else if (mDataEncoding == EncodingType.SMS) {
            try {
                return new PtsPrimitiveSerializer(mImpsVersion);
            } catch (SerializerException e) {
                ImpsLog.logError(e);
                return null;
            }
        }

        ImpsLog.log("Unknown DataEncoding: " + mDataEncoding);
        return null;
    
public com.android.im.imps.ImpsConnectionConfig$CirMethodgetCirChannelBinding()
Gets the type of protocol binding for CIR channel.

return
the type of protocol binding for CIR channel.

        return mCirChannelBinding;
    
public java.lang.StringgetClientId()

        return mClientId;
    
public com.android.im.imps.ImpsConnectionConfig$TransportTypegetDataChannelBinding()
Gets the type of protocol binding for data channel.

return
the type of protocol binding for data channel.

        return mDataChannelBinding;
    
public java.lang.StringgetDefaultDomain()

        return mDefaultDomain;
    
public intgetDefaultKeepAliveInterval()

        return DEFAULT_KEEPALIVE_SECONDS;
    
public intgetDefaultServerPollMin()

        return DEFAULT_MIN_SERVER_POLL;
    
public java.lang.StringgetHost()
Gets the host name of the server.

return
the host name of the server.

        return mHost;
    
public com.android.im.imps.ImpsConstants.ImpsVersiongetImpsVersion()

        return mImpsVersion;
    
public java.lang.StringgetMsisdn()

        return mMsisdn;
    
public PasswordDigestgetPasswordDigest()

        if (mPasswordDigest != null) {
            return mPasswordDigest;
        }

        if (mCustomPasswordDigest != null) {
            try {
                mPasswordDigest = new CustomPasswordDigest(mPluginPath, mCustomPasswordDigest);
            } catch (ImException e) {
                ImpsLog.logError("Can't load custom password digest method", e);
            }
        }

        if (mPasswordDigest == null) {
            mPasswordDigest = new StandardPasswordDigest();
        }
        return mPasswordDigest;
    
public PresenceMappinggetPresenceMapping()

        if (mPresenceMapping != null) {
            return mPresenceMapping;
        }

        if (mCustomPresenceMapping != null) {
            try {
                mPresenceMapping = new CustomPresenceMapping(mPluginPath,
                        mCustomPresenceMapping);
            } catch (ImException e) {
                ImpsLog.logError("Failed to load custom presence mapping", e);
            }
        }

        if (mPresenceMapping == null) {
            mPresenceMapping = new DefaultPresenceMapping();
        }
        return mPresenceMapping;
    
public java.lang.StringgetPresenceNs()

        return mPresenceNs;
    
public longgetPresencePollInterval()

        String value = mOthers.get(ImpsConfigNames.PRESENCE_POLLING_INTERVAL);
        if (value == null) {
            return DEFAULT_PRESENCE_POLL_INTERVAL;
        }
        try {
            return Long.parseLong(value);
        } catch (NumberFormatException e) {
            return DEFAULT_PRESENCE_POLL_INTERVAL;
        }
    
public java.lang.StringgetProtocolName()

        return "IMPS";
    
public intgetReplyTimeout()
Gets the number of milliseconds to wait for a response from the server. The default value is 45 seconds.

return
the milliseconds to wait for a response from the server

        return mReplyTimeout;
    
public java.lang.StringgetSmsAddr()

        return mOthers.get(ImpsConfigNames.SMS_ADDR);
    
public java.lang.StringgetSmsCirAddr()

        return mOthers.get(ImpsConfigNames.SMS_CIR_ADDR);
    
public intgetSmsCirPort()

        String value = mOthers.get(ImpsConfigNames.SMS_CIR_PORT);
        if (value == null) {
            return DEFAULT_SMS_CIR_PORT;
        }
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return DEFAULT_SMS_CIR_PORT;
        }
    
public intgetSmsPort()

        String value = mOthers.get(ImpsConfigNames.SMS_PORT);
        if (value == null) {
            return DEFAULT_SMS_PORT;
        }
        try {
            return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return DEFAULT_SMS_PORT;
        }
    
public java.lang.StringgetTransportContentType()

        return mContentType;
    
public intgetUdpPort()
Gets the port number for the standalone UDP/IP CIR method. This is only useful when UDP CIR method is used. The default port number is 3717.

return
the port number for the standalone UDP/IP CIR method.

        return mUdpPort;
    
private booleanisTrue(java.lang.String value)

        return "true".equalsIgnoreCase(value);
    
public booleanneedDeliveryReport()

        return NEED_DELIVERY_REPORT;
    
public voidsetHost(java.lang.String host)
Sets the host name of the server.

param
host the host name.

        mHost = host;
    
private voidsetupVersionStrings()

        if (mImpsVersion == ImpsVersion.IMPS_VERSION_11) {
            if (mDataEncoding == EncodingType.XML) {
                mContentType = "application/vnd.wv.csp.xml";
            } else if (mDataEncoding == EncodingType.WBXML) {
                mContentType = "application/vnd.wv.csp.wbxml";
            } else if (mDataEncoding == EncodingType.SMS) {
                mContentType = "application/vnd.wv.csp.sms";
            }
            mVersionNs = ImpsConstants.VERSION_11_NS;
            mTransactionNs = ImpsConstants.TRANSACTION_11_NS;
            mPresenceNs = ImpsConstants.PRESENCE_11_NS;
        } else if (mImpsVersion == ImpsVersion.IMPS_VERSION_12) {
            if (mDataEncoding == EncodingType.XML) {
                mContentType = "application/vnd.wv.csp.xml";
            } else if (mDataEncoding == EncodingType.WBXML) {
                mContentType = "application/vnd.wv.csp.wbxml";
            } else if (mDataEncoding == EncodingType.SMS) {
                mContentType = "application/vnd.wv.csp.sms";
            }

            mVersionNs = ImpsConstants.VERSION_12_NS;
            mTransactionNs = ImpsConstants.TRANSACTION_12_NS;
            mPresenceNs = ImpsConstants.PRESENCE_12_NS;
        } else if (mImpsVersion == ImpsVersion.IMPS_VERSION_13){
            if (mDataEncoding == EncodingType.XML) {
                mContentType = "application/vnd.wv.csp+xml";
            } else if (mDataEncoding == EncodingType.WBXML) {
                mContentType = "application/vnd.wv.csp+wbxml";
            } else if (mDataEncoding == EncodingType.SMS) {
                mContentType = "application/vnd.wv.csp.sms";
            }

            mVersionNs = ImpsConstants.VERSION_13_NS;
            mTransactionNs = ImpsConstants.TRANSACTION_13_NS;
            mPresenceNs = ImpsConstants.PRESENCE_13_NS;
        }
    
public booleansupportBasicPresenceOnly()
XXX: Workaround for the OZ IMPS GTalk server which supports only basic presence attributes and don't support GetAttributeList.

return
true if only basic presence attribute is supported.

        return mBasicPresenceOnly;
    
public booleanuse4wayLogin()

        return mSecureLogin;
    
public booleanusePrensencePolling()

        String value = mOthers.get(ImpsConfigNames.POLL_PRESENCE);
        return isTrue(value);
    
public booleanuseSmsAuth()

        return isTrue(mOthers.get(ImpsConfigNames.SMS_AUTH));