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; |
| 54 | private int mMediaState = state.MEDIA_STATE_NONE; |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 55 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 56 | /** |
| 57 | * ********************* |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 58 | * Construtors |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 59 | * ********************* |
| 60 | */ |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 61 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 62 | private SipCall(Parcel in) { |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 63 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 64 | mCallID = in.readString(); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 65 | mAccount = in.readParcelable(Account.class.getClassLoader()); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 66 | contact = in.readParcelable(CallContact.class.getClassLoader()); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 67 | isRecording = in.readByte() == 1; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 68 | mCallType = in.readInt(); |
| 69 | mCallState = in.readInt(); |
| 70 | mMediaState = in.readInt(); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 71 | timestampStart_ = in.readLong(); |
| 72 | timestampEnd_ = in.readLong(); |
| 73 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 74 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 75 | private SipCall(String id, Account account, int call_type, int call_state, int media_state, CallContact c) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 76 | mCallID = id; |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 77 | mAccount = account; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 78 | mCallType = call_type; |
| 79 | mCallState = call_state; |
| 80 | mMediaState = media_state; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 81 | contact = c; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 82 | } |
| 83 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 84 | public long getTimestampEnd_() { |
| 85 | return timestampEnd_; |
| 86 | } |
| 87 | |
| 88 | public String getRecordPath() { |
| 89 | return ""; |
| 90 | } |
| 91 | |
Alexandre Lision | 183bf45 | 2014-01-17 11:21:59 -0500 | [diff] [blame] | 92 | public int getCallType() { |
| 93 | return mCallType; |
| 94 | } |
| 95 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 96 | public interface direction { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 97 | public static final int CALL_TYPE_INCOMING = 1; |
| 98 | public static final int CALL_TYPE_OUTGOING = 2; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 99 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 100 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 101 | public interface state { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 102 | public static final int CALL_STATE_NONE = 0; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 103 | public static final int CALL_STATE_RINGING = 2; |
| 104 | public static final int CALL_STATE_CURRENT = 3; |
| 105 | public static final int CALL_STATE_HUNGUP = 4; |
| 106 | public static final int CALL_STATE_BUSY = 5; |
| 107 | public static final int CALL_STATE_FAILURE = 6; |
| 108 | public static final int CALL_STATE_HOLD = 7; |
| 109 | public static final int CALL_STATE_UNHOLD = 8; |
| 110 | |
| 111 | public static final int MEDIA_STATE_NONE = 0; // No media currently |
| 112 | public static final int MEDIA_STATE_ACTIVE = 1; // Media is active |
| 113 | public static final int MEDIA_STATE_LOCAL_HOLD = 2; // Media is put on hold bu user |
| 114 | public static final int MEDIA_STATE_REMOTE_HOLD = 3; // Media is put on hold by peer |
| 115 | public static final int MEDIA_STATE_ERROR = 5; // Media is in error state |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 116 | } |
| 117 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 118 | @Override |
| 119 | public int describeContents() { |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public void writeToParcel(Parcel out, int flags) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 125 | |
Alexandre Lision | d568603 | 2013-10-29 11:09:21 -0400 | [diff] [blame] | 126 | out.writeString(mCallID); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 127 | out.writeParcelable(mAccount, 0); |
| 128 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 129 | out.writeParcelable(contact, 0); |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 130 | out.writeByte((byte) (isRecording ? 1 : 0)); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 131 | out.writeInt(mCallType); |
| 132 | out.writeInt(mCallState); |
| 133 | out.writeInt(mMediaState); |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 134 | out.writeLong(timestampStart_); |
| 135 | out.writeLong(timestampEnd_); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | public static final Parcelable.Creator<SipCall> CREATOR = new Parcelable.Creator<SipCall>() { |
| 139 | public SipCall createFromParcel(Parcel in) { |
| 140 | return new SipCall(in); |
| 141 | } |
| 142 | |
| 143 | public SipCall[] newArray(int size) { |
| 144 | return new SipCall[size]; |
| 145 | } |
| 146 | }; |
| 147 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 148 | public void setCallID(String callID) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 149 | mCallID = callID; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | public String getCallId() { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 153 | return mCallID; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 154 | } |
| 155 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 156 | public long getTimestampStart_() { |
| 157 | return timestampStart_; |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 158 | } |
| 159 | |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 160 | public void setTimestampStart_(long timestampStart_) { |
| 161 | this.timestampStart_ = timestampStart_; |
| 162 | } |
| 163 | |
| 164 | public void setTimestampEnd_(long timestampEnd_) { |
| 165 | this.timestampEnd_ = timestampEnd_; |
Alexandre Lision | 3c6b710 | 2013-09-16 16:56:46 -0400 | [diff] [blame] | 166 | } |
| 167 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 168 | public void setAccount(Account account) { |
| 169 | mAccount = account; |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 170 | } |
| 171 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 172 | public Account getAccount() { |
| 173 | return mAccount; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 174 | } |
| 175 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 176 | public String getCallTypeString() { |
| 177 | switch (mCallType) { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 178 | case direction.CALL_TYPE_INCOMING: |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 179 | return "CALL_TYPE_INCOMING"; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 180 | case direction.CALL_TYPE_OUTGOING: |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 181 | return "CALL_TYPE_OUTGOING"; |
| 182 | default: |
| 183 | return "CALL_TYPE_UNDETERMINED"; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 187 | public void setCallState(int callState) { |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 188 | mCallState = callState; |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 189 | } |
| 190 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 191 | public CallContact getContact() { |
| 192 | return contact; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 193 | } |
| 194 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 195 | public void setContact(CallContact contacts) { |
| 196 | contact = contacts; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 197 | } |
| 198 | |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 199 | public String getCallStateString() { |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 200 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 201 | String text_state; |
| 202 | |
| 203 | switch (mCallState) { |
Alexandre Lision | 945e461 | 2014-01-15 17:40:31 -0500 | [diff] [blame] | 204 | case state.CALL_STATE_RINGING: |
| 205 | text_state = "RINGING"; |
| 206 | break; |
| 207 | case state.CALL_STATE_CURRENT: |
| 208 | text_state = "CURRENT"; |
| 209 | break; |
| 210 | case state.CALL_STATE_HUNGUP: |
| 211 | text_state = "HUNGUP"; |
| 212 | break; |
| 213 | case state.CALL_STATE_BUSY: |
| 214 | text_state = "BUSY"; |
| 215 | break; |
| 216 | case state.CALL_STATE_FAILURE: |
| 217 | text_state = "FAILURE"; |
| 218 | break; |
| 219 | case state.CALL_STATE_HOLD: |
| 220 | text_state = "HOLD"; |
| 221 | break; |
| 222 | case state.CALL_STATE_UNHOLD: |
| 223 | text_state = "UNHOLD"; |
| 224 | break; |
| 225 | default: |
| 226 | text_state = "NULL"; |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 227 | } |
| 228 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 229 | return text_state; |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 230 | } |
| 231 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 232 | public boolean isRecording() { |
| 233 | return isRecording; |
| 234 | } |
| 235 | |
| 236 | public void setRecording(boolean isRecording) { |
| 237 | this.isRecording = isRecording; |
| 238 | } |
| 239 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 240 | public static class SipCallBuilder { |
| 241 | |
| 242 | private String bCallID = ""; |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 243 | private Account bAccount = null; |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 244 | private CallContact bContact = null; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 245 | |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 246 | private int bCallType; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 247 | private int bCallState = state.CALL_STATE_NONE; |
| 248 | private int bMediaState = state.MEDIA_STATE_NONE; |
| 249 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 250 | public SipCallBuilder setCallType(int bCallType) { |
| 251 | this.bCallType = bCallType; |
| 252 | return this; |
| 253 | } |
| 254 | |
| 255 | public SipCallBuilder setMediaState(int state) { |
| 256 | this.bMediaState = state; |
| 257 | return this; |
| 258 | } |
| 259 | |
| 260 | public SipCallBuilder setCallState(int state) { |
| 261 | this.bCallState = state; |
| 262 | return this; |
| 263 | } |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 264 | |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 265 | public SipCallBuilder startCallCreation(String id) { |
| 266 | bCallID = id; |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 267 | bCallType = direction.CALL_TYPE_INCOMING; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 268 | return this; |
| 269 | } |
| 270 | |
| 271 | public SipCallBuilder startCallCreation() { |
| 272 | Random random = new Random(); |
Tristan Matthews | 1a4962d | 2013-07-18 16:27:10 -0400 | [diff] [blame] | 273 | bCallID = Integer.toString(Math.abs(random.nextInt())); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 274 | return this; |
| 275 | } |
| 276 | |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 277 | public SipCallBuilder setAccount(Account a) { |
| 278 | bAccount = a; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 279 | return this; |
| 280 | } |
| 281 | |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 282 | public SipCallBuilder setContact(CallContact c) { |
| 283 | bContact = c; |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 284 | return this; |
| 285 | } |
| 286 | |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 287 | public SipCall build() throws InvalidObjectException { |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 288 | if (bCallID.contentEquals("") || bAccount == null || bContact == null) { |
Alexandre Lision | 5ed2c97 | 2013-10-11 15:36:33 -0400 | [diff] [blame] | 289 | throw new InvalidObjectException("SipCallBuilder's parameters missing"); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 290 | } |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 291 | return new SipCall(bCallID, bAccount, bCallType, bCallState, bMediaState, bContact); |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | public static SipCallBuilder getInstance() { |
| 295 | return new SipCallBuilder(); |
| 296 | } |
alision | fde875f | 2013-05-28 17:01:54 -0400 | [diff] [blame] | 297 | } |
| 298 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 299 | public void printCallInfo() { |
| 300 | Log.i(TAG, "CallInfo: CallID: " + mCallID); |
Alexandre Lision | 3ee516e | 2013-10-07 17:32:15 -0400 | [diff] [blame] | 301 | Log.i(TAG, " AccountID: " + mAccount.getAccountID()); |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 302 | Log.i(TAG, " CallState: " + mCallState); |
| 303 | Log.i(TAG, " CallType: " + mCallType); |
| 304 | } |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 305 | |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 306 | /** |
| 307 | * Compare sip calls based on call ID |
| 308 | */ |
| 309 | @Override |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 310 | public boolean equals(Object c) { |
alision | 465ceba | 2013-07-04 09:24:30 -0400 | [diff] [blame] | 311 | if (c instanceof SipCall && ((SipCall) c).mCallID.contentEquals((mCallID))) { |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 312 | return true; |
| 313 | } |
| 314 | return false; |
alision | 11e8e16 | 2013-05-28 10:33:14 -0400 | [diff] [blame] | 315 | |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 316 | } |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 317 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 318 | public boolean isOutGoing() { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 319 | if (mCallType == direction.CALL_TYPE_OUTGOING) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 320 | return true; |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 321 | return false; |
| 322 | } |
| 323 | |
| 324 | public boolean isRinging() { |
| 325 | if (mCallState == state.CALL_STATE_RINGING || mCallState == state.CALL_STATE_NONE) |
| 326 | return true; |
| 327 | |
| 328 | return false; |
| 329 | } |
| 330 | |
| 331 | public boolean isIncoming() { |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 332 | if (mCallType == direction.CALL_TYPE_INCOMING) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 333 | return true; |
| 334 | |
| 335 | return false; |
| 336 | } |
| 337 | |
| 338 | public void setCallState(String newState) { |
Alexandre Lision | 707f908 | 2014-01-16 15:09:07 -0500 | [diff] [blame] | 339 | if (newState.equals("RINGING")) { |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 340 | setCallState(SipCall.state.CALL_STATE_RINGING); |
| 341 | } else if (newState.equals("CURRENT")) { |
| 342 | setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 343 | } else if (newState.equals("HUNGUP")) { |
| 344 | setCallState(SipCall.state.CALL_STATE_HUNGUP); |
| 345 | } else if (newState.equals("BUSY")) { |
| 346 | setCallState(SipCall.state.CALL_STATE_BUSY); |
| 347 | } else if (newState.equals("FAILURE")) { |
| 348 | setCallState(SipCall.state.CALL_STATE_FAILURE); |
| 349 | } else if (newState.equals("HOLD")) { |
| 350 | setCallState(SipCall.state.CALL_STATE_HOLD); |
| 351 | } else if (newState.equals("UNHOLD")) { |
| 352 | setCallState(SipCall.state.CALL_STATE_CURRENT); |
| 353 | } else { |
| 354 | setCallState(SipCall.state.CALL_STATE_NONE); |
| 355 | } |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 356 | |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | public boolean isOngoing() { |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 360 | if (mCallState == state.CALL_STATE_RINGING || mCallState == state.CALL_STATE_NONE || mCallState == state.CALL_STATE_FAILURE |
| 361 | || mCallState == state.CALL_STATE_BUSY || mCallState == state.CALL_STATE_HUNGUP) |
alision | 8570418 | 2013-05-29 15:23:03 -0400 | [diff] [blame] | 362 | return false; |
| 363 | |
| 364 | return true; |
| 365 | } |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 366 | |
alision | df1dac9 | 2013-06-27 17:35:53 -0400 | [diff] [blame] | 367 | public boolean isOnHold() { |
| 368 | return mCallState == state.CALL_STATE_HOLD; |
| 369 | } |
| 370 | |
Alexandre Lision | 6ae652d | 2013-09-26 16:39:20 -0400 | [diff] [blame] | 371 | public boolean isCurrent() { |
| 372 | return mCallState == state.CALL_STATE_CURRENT; |
| 373 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 374 | } |