Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 1 | /* |
Alexandre Lision | c1024c0 | 2014-01-06 11:12:53 -0500 | [diff] [blame] | 2 | * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 3 | * |
Alexandre Lision | 6885547 | 2013-10-10 16:20:46 -0400 | [diff] [blame] | 4 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux> |
| 5 | * Alexandre Savard <alexandre.savard@gmail.com> |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 20 | * |
| 21 | * Additional permission under GNU GPL version 3 section 7: |
| 22 | * |
| 23 | * If you modify this program, or any covered work, by linking or |
| 24 | * combining it with the OpenSSL project's OpenSSL library (or a |
| 25 | * modified version of that library), containing parts covered by the |
| 26 | * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. |
| 27 | * grants you additional permission to convey the resulting work. |
| 28 | * Corresponding Source for a non-source form of such a combination |
| 29 | * shall include the source code for the parts of OpenSSL used as well |
| 30 | * as that of the covered work. |
| 31 | */ |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 32 | package org.sflphone.model; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 33 | |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 34 | import java.io.InvalidObjectException; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 35 | import java.util.Random; |
alision | a432515 | 2013-04-19 11:10:03 -0400 | [diff] [blame] | 36 | |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 37 | import android.os.Parcel; |
alision | a432515 | 2013-04-19 11:10:03 -0400 | [diff] [blame] | 38 | import android.os.Parcelable; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 39 | import android.util.Log; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 40 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 41 | public class SipCall implements Parcelable { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 42 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 43 | private static final String TAG = SipCall.class.getSimpleName(); |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 44 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 45 | private String mCallID = ""; |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 46 | private Account mAccount = null; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 47 | private CallContact contact = null; |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 48 | private boolean isRecording = false; |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 49 | private long timestampStart_ = 0; |
| 50 | private long timestampEnd_ = 0; |
| 51 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 52 | private int mCallType; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 53 | private int mCallState = state.CALL_STATE_NONE; |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 54 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 55 | private boolean isSecured; |
| 56 | private String SAS; |
| 57 | private boolean confirmedSAS; |
| 58 | |
| 59 | |
| 60 | public boolean isSecured() { |
| 61 | return isSecured; |
| 62 | } |
| 63 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 64 | /** |
| 65 | * ********************* |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 66 | * Construtors |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 67 | * ********************* |
| 68 | */ |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 69 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 70 | private SipCall(Parcel in) { |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 71 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 72 | mCallID = in.readString(); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 73 | mAccount = in.readParcelable(Account.class.getClassLoader()); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 74 | contact = in.readParcelable(CallContact.class.getClassLoader()); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 75 | isRecording = in.readByte() == 1; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 76 | mCallType = in.readInt(); |
| 77 | mCallState = in.readInt(); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 78 | timestampStart_ = in.readLong(); |
| 79 | timestampEnd_ = in.readLong(); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 80 | SAS = in.readString(); |
| 81 | confirmedSAS = in.readByte() == 1; |
| 82 | isSecured = in.readByte() == 1; |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 83 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 84 | |
Alexandre Lision | 3e1e06f | 2014-02-10 12:13:25 -0500 | [diff] [blame] | 85 | private SipCall(String id, Account account, int call_type, int call_state, CallContact c) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 86 | mCallID = id; |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 87 | mAccount = account; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 88 | mCallType = call_type; |
| 89 | mCallState = call_state; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 90 | contact = c; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 91 | } |
| 92 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 93 | public long getTimestampEnd_() { |
| 94 | return timestampEnd_; |
| 95 | } |
| 96 | |
| 97 | public String getRecordPath() { |
| 98 | return ""; |
| 99 | } |
| 100 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 101 | public int getCallType() { |
| 102 | return mCallType; |
| 103 | } |
| 104 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 105 | public void setSecured(boolean secured) { |
| 106 | isSecured = secured; |
| 107 | } |
| 108 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 109 | public interface direction { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 110 | public static final int CALL_TYPE_INCOMING = 1; |
| 111 | public static final int CALL_TYPE_OUTGOING = 2; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 112 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 113 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 114 | public interface state { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 115 | public static final int CALL_STATE_NONE = 0; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 116 | public static final int CALL_STATE_RINGING = 2; |
| 117 | public static final int CALL_STATE_CURRENT = 3; |
| 118 | public static final int CALL_STATE_HUNGUP = 4; |
| 119 | public static final int CALL_STATE_BUSY = 5; |
| 120 | public static final int CALL_STATE_FAILURE = 6; |
| 121 | public static final int CALL_STATE_HOLD = 7; |
| 122 | public static final int CALL_STATE_UNHOLD = 8; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 123 | } |
| 124 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 125 | @Override |
| 126 | public int describeContents() { |
| 127 | return 0; |
| 128 | } |
| 129 | |
| 130 | @Override |
| 131 | public void writeToParcel(Parcel out, int flags) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 132 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 133 | out.writeString(mCallID); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 134 | out.writeParcelable(mAccount, 0); |
| 135 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 136 | out.writeParcelable(contact, 0); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 137 | out.writeByte((byte) (isRecording ? 1 : 0)); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 138 | out.writeInt(mCallType); |
| 139 | out.writeInt(mCallState); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 140 | out.writeLong(timestampStart_); |
| 141 | out.writeLong(timestampEnd_); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 142 | out.writeString(SAS); |
| 143 | out.writeByte((byte) (confirmedSAS ? 1 : 0)); |
| 144 | out.writeByte((byte) (isSecured ? 1 : 0)); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | public static final Parcelable.Creator<SipCall> CREATOR = new Parcelable.Creator<SipCall>() { |
| 148 | public SipCall createFromParcel(Parcel in) { |
| 149 | return new SipCall(in); |
| 150 | } |
| 151 | |
| 152 | public SipCall[] newArray(int size) { |
| 153 | return new SipCall[size]; |
| 154 | } |
| 155 | }; |
| 156 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 157 | public void setCallID(String callID) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 158 | mCallID = callID; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | public String getCallId() { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 162 | return mCallID; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 163 | } |
| 164 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 165 | public long getTimestampStart_() { |
| 166 | return timestampStart_; |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 169 | public void setTimestampStart_(long timestampStart_) { |
| 170 | this.timestampStart_ = timestampStart_; |
| 171 | } |
| 172 | |
| 173 | public void setTimestampEnd_(long timestampEnd_) { |
| 174 | this.timestampEnd_ = timestampEnd_; |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 175 | } |
| 176 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 177 | public void setAccount(Account account) { |
| 178 | mAccount = account; |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 179 | } |
| 180 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 181 | public Account getAccount() { |
| 182 | return mAccount; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 183 | } |
| 184 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 185 | public String getCallTypeString() { |
| 186 | switch (mCallType) { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 187 | case direction.CALL_TYPE_INCOMING: |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 188 | return "CALL_TYPE_INCOMING"; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 189 | case direction.CALL_TYPE_OUTGOING: |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 190 | return "CALL_TYPE_OUTGOING"; |
| 191 | default: |
| 192 | return "CALL_TYPE_UNDETERMINED"; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 196 | public void setCallState(int callState) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 197 | mCallState = callState; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 198 | } |
| 199 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 200 | public CallContact getContact() { |
| 201 | return contact; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 202 | } |
| 203 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 204 | public void setContact(CallContact contacts) { |
| 205 | contact = contacts; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 206 | } |
| 207 | |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 208 | public String getCallStateString() { |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 209 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 210 | String text_state; |
| 211 | |
| 212 | switch (mCallState) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 213 | case state.CALL_STATE_RINGING: |
| 214 | text_state = "RINGING"; |
| 215 | break; |
| 216 | case state.CALL_STATE_CURRENT: |
| 217 | text_state = "CURRENT"; |
| 218 | break; |
| 219 | case state.CALL_STATE_HUNGUP: |
| 220 | text_state = "HUNGUP"; |
| 221 | break; |
| 222 | case state.CALL_STATE_BUSY: |
| 223 | text_state = "BUSY"; |
| 224 | break; |
| 225 | case state.CALL_STATE_FAILURE: |
| 226 | text_state = "FAILURE"; |
| 227 | break; |
| 228 | case state.CALL_STATE_HOLD: |
| 229 | text_state = "HOLD"; |
| 230 | break; |
| 231 | case state.CALL_STATE_UNHOLD: |
| 232 | text_state = "UNHOLD"; |
| 233 | break; |
| 234 | default: |
| 235 | text_state = "NULL"; |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 236 | } |
| 237 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 238 | return text_state; |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 239 | } |
| 240 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 241 | public boolean isRecording() { |
| 242 | return isRecording; |
| 243 | } |
| 244 | |
| 245 | public void setRecording(boolean isRecording) { |
| 246 | this.isRecording = isRecording; |
| 247 | } |
| 248 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 249 | public static class SipCallBuilder { |
| 250 | |
| 251 | private String bCallID = ""; |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 252 | private Account bAccount = null; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 253 | private CallContact bContact = null; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 254 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 255 | private int bCallType; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 256 | private int bCallState = state.CALL_STATE_NONE; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 257 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 258 | public SipCallBuilder setCallType(int bCallType) { |
| 259 | this.bCallType = bCallType; |
| 260 | return this; |
| 261 | } |
| 262 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 263 | public SipCallBuilder setCallState(int state) { |
| 264 | this.bCallState = state; |
| 265 | return this; |
| 266 | } |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 267 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 268 | public SipCallBuilder startCallCreation(String id) { |
| 269 | bCallID = id; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 270 | bCallType = direction.CALL_TYPE_INCOMING; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 271 | return this; |
| 272 | } |
| 273 | |
| 274 | public SipCallBuilder startCallCreation() { |
| 275 | Random random = new Random(); |
Tristan Matthews | 1a4962d | 2013-07-18 16:27:10 -0400 | [diff] [blame] | 276 | bCallID = Integer.toString(Math.abs(random.nextInt())); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 277 | return this; |
| 278 | } |
| 279 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 280 | public SipCallBuilder setAccount(Account a) { |
| 281 | bAccount = a; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 282 | return this; |
| 283 | } |
| 284 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 285 | public SipCallBuilder setContact(CallContact c) { |
| 286 | bContact = c; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 287 | return this; |
| 288 | } |
| 289 | |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 290 | public SipCall build() throws InvalidObjectException { |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 291 | if (bCallID.contentEquals("") || bAccount == null || bContact == null) { |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 292 | throw new InvalidObjectException("SipCallBuilder's parameters missing"); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 293 | } |
Alexandre Lision | 3e1e06f | 2014-02-10 12:13:25 -0500 | [diff] [blame] | 294 | return new SipCall(bCallID, bAccount, bCallType, bCallState, bContact); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | public static SipCallBuilder getInstance() { |
| 298 | return new SipCallBuilder(); |
| 299 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 300 | } |
| 301 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 302 | public void printCallInfo() { |
| 303 | Log.i(TAG, "CallInfo: CallID: " + mCallID); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 304 | Log.i(TAG, " AccountID: " + mAccount.getAccountID()); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 305 | Log.i(TAG, " CallState: " + mCallState); |
| 306 | Log.i(TAG, " CallType: " + mCallType); |
| 307 | } |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 308 | |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 309 | /** |
| 310 | * Compare sip calls based on call ID |
| 311 | */ |
| 312 | @Override |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 313 | public boolean equals(Object c) { |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 314 | if (c instanceof SipCall && ((SipCall) c).mCallID.contentEquals((mCallID))) { |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 315 | return true; |
| 316 | } |
| 317 | return false; |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 318 | |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 319 | } |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 320 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 321 | public boolean isOutGoing() { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 322 | if (mCallType == direction.CALL_TYPE_OUTGOING) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 323 | return true; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 324 | return false; |
| 325 | } |
| 326 | |
| 327 | public boolean isRinging() { |
| 328 | if (mCallState == state.CALL_STATE_RINGING || mCallState == state.CALL_STATE_NONE) |
| 329 | return true; |
| 330 | |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | public boolean isIncoming() { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 335 | if (mCallType == direction.CALL_TYPE_INCOMING) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 336 | return true; |
| 337 | |
| 338 | return false; |
| 339 | } |
| 340 | |
| 341 | public void setCallState(String newState) { |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 342 | if (newState.equals("RINGING")) { |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 343 | setCallState(SipCall.state.CALL_STATE_RINGING); |
| 344 | } else if (newState.equals("CURRENT")) { |
| 345 | setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 346 | } else if (newState.equals("HUNGUP")) { |
| 347 | setCallState(SipCall.state.CALL_STATE_HUNGUP); |
| 348 | } else if (newState.equals("BUSY")) { |
| 349 | setCallState(SipCall.state.CALL_STATE_BUSY); |
| 350 | } else if (newState.equals("FAILURE")) { |
| 351 | setCallState(SipCall.state.CALL_STATE_FAILURE); |
| 352 | } else if (newState.equals("HOLD")) { |
| 353 | setCallState(SipCall.state.CALL_STATE_HOLD); |
| 354 | } else if (newState.equals("UNHOLD")) { |
| 355 | setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 356 | } else { |
| 357 | setCallState(SipCall.state.CALL_STATE_NONE); |
| 358 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 359 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | public boolean isOngoing() { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 363 | if (mCallState == state.CALL_STATE_RINGING || mCallState == state.CALL_STATE_NONE || mCallState == state.CALL_STATE_FAILURE |
| 364 | || mCallState == state.CALL_STATE_BUSY || mCallState == state.CALL_STATE_HUNGUP) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 365 | return false; |
| 366 | |
| 367 | return true; |
| 368 | } |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 369 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 370 | public boolean isOnHold() { |
| 371 | return mCallState == state.CALL_STATE_HOLD; |
| 372 | } |
| 373 | |
Alexandre Lision | 6ae652d | 2013-09-26 16:39:20 -0400 | [diff] [blame] | 374 | public boolean isCurrent() { |
| 375 | return mCallState == state.CALL_STATE_CURRENT; |
| 376 | } |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 377 | |
| 378 | public boolean isConfirmedSAS() { |
| 379 | return confirmedSAS; |
| 380 | } |
| 381 | |
| 382 | public void setConfirmedSAS(boolean confirmedSAS) { |
| 383 | this.confirmedSAS = confirmedSAS; |
| 384 | } |
| 385 | |
| 386 | public String getSAS() { |
| 387 | return SAS; |
| 388 | } |
| 389 | |
| 390 | public void setSAS(String SAS) { |
| 391 | this.SAS = SAS; |
| 392 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 393 | } |