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