From cf95f5d26363d4cd3815d31f5798f932a7720c17 Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Mon, 23 Aug 2010 21:36:14 +0800 Subject: SipProfile: add isOutgoingCallAllowed() and new builder constructor Change-Id: I7ced47079fd2b00c7160b152eb4c1d34399e39dc --- voip/java/android/net/sip/SipProfile.java | 41 ++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/voip/java/android/net/sip/SipProfile.java b/voip/java/android/net/sip/SipProfile.java index e71c293..ec8d0ed 100644 --- a/voip/java/android/net/sip/SipProfile.java +++ b/voip/java/android/net/sip/SipProfile.java @@ -35,7 +35,7 @@ import javax.sip.address.URI; * Class containing a SIP account, domain and server information. * @hide */ -public class SipProfile implements Parcelable, Serializable { +public class SipProfile implements Parcelable, Serializable, Cloneable { private static final long serialVersionUID = 1L; private static final int DEFAULT_PORT = 5060; private Address mAddress; @@ -46,6 +46,7 @@ public class SipProfile implements Parcelable, Serializable { private String mProfileName; private boolean mSendKeepAlive = false; private boolean mAutoRegistration = true; + private boolean mAllowOutgoingCall = false; /** @hide */ public static final Parcelable.Creator CREATOR = @@ -79,6 +80,23 @@ public class SipProfile implements Parcelable, Serializable { } /** + * Creates a builder based on the given profile. + */ + public Builder(SipProfile profile) { + if (profile == null) throw new NullPointerException(); + try { + mProfile = (SipProfile) profile.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException("should not occur", e); + } + mProfile.mAddress = null; + mUri = profile.getUri(); + mUri.setUserPassword(profile.getPassword()); + mDisplayName = profile.getDisplayName(); + mProxyAddress = profile.getProxyAddress(); + } + + /** * Constructor. * * @param uriString the URI string as "sip:@" @@ -226,6 +244,18 @@ public class SipProfile implements Parcelable, Serializable { } /** + * Sets the allow-outgoing-call flag. + * + * @param flag true if allowing to make outgoing call on the profile; + * false otherwise + * @return this builder object + */ + public Builder setOutgoingCallAllowed(boolean flag) { + mProfile.mAllowOutgoingCall = flag; + return this; + } + + /** * Builds and returns the SIP profile object. * * @return the profile object created @@ -262,6 +292,7 @@ public class SipProfile implements Parcelable, Serializable { mProfileName = in.readString(); mSendKeepAlive = (in.readInt() == 0) ? false : true; mAutoRegistration = (in.readInt() == 0) ? false : true; + mAllowOutgoingCall = (in.readInt() == 0) ? false : true; } /** @hide */ @@ -274,6 +305,7 @@ public class SipProfile implements Parcelable, Serializable { out.writeString(mProfileName); out.writeInt(mSendKeepAlive ? 1 : 0); out.writeInt(mAutoRegistration ? 1 : 0); + out.writeInt(mAllowOutgoingCall ? 1 : 0); } /** @hide */ @@ -398,4 +430,11 @@ public class SipProfile implements Parcelable, Serializable { public boolean getAutoRegistration() { return mAutoRegistration; } + + /** + * Returns true if allowing to make outgoing calls on this profile. + */ + public boolean isOutgoingCallAllowed() { + return mAllowOutgoingCall; + } } -- cgit v1.1