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; |
| 34 | |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 35 | import android.content.Intent; |
| 36 | import android.os.Bundle; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 37 | import android.os.Environment; |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 38 | import android.os.Parcel; |
alision | a432515 | 2013-04-19 11:10:03 -0400 | [diff] [blame] | 39 | import android.os.Parcelable; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 40 | import android.os.RemoteException; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 41 | import android.util.Log; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 42 | |
alision | a432515 | 2013-04-19 11:10:03 -0400 | [diff] [blame] | 43 | import com.savoirfairelinux.sflphone.service.ISipService; |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 44 | |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 45 | public class SipCall |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 46 | { |
| 47 | final static String TAG = "SipCall"; |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 48 | public CallInfo mCallInfo; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 49 | |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 50 | |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 51 | public static final int CALL_TYPE_UNDETERMINED = 0; |
| 52 | public static final int CALL_TYPE_INCOMING = 1; |
| 53 | public static final int CALL_TYPE_OUTGOING = 2; |
| 54 | |
Alexandre Savard | 27a5113 | 2012-10-25 18:35:14 -0400 | [diff] [blame] | 55 | public static final int CALL_STATE_NONE = 0; |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 56 | public static final int CALL_STATE_INCOMING = 1; |
| 57 | public static final int CALL_STATE_RINGING = 2; |
| 58 | public static final int CALL_STATE_CURRENT = 3; |
| 59 | public static final int CALL_STATE_HUNGUP = 4; |
| 60 | public static final int CALL_STATE_BUSY = 5; |
| 61 | public static final int CALL_STATE_FAILURE = 6; |
| 62 | public static final int CALL_STATE_HOLD = 7; |
| 63 | public static final int CALL_STATE_UNHOLD = 8; |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 64 | |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 65 | public static final int MEDIA_STATE_NONE = 0; // No media currently |
| 66 | public static final int MEDIA_STATE_ACTIVE = 1; // Media is active |
| 67 | public static final int MEDIA_STATE_LOCAL_HOLD = 2; // Media is put on hold bu user |
| 68 | public static final int MEDIA_STATE_REMOTE_HOLD = 3; // Media is put on hold by peer |
| 69 | public static final int MEDIA_STATE_ERROR = 5; // Media is in error state |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 70 | |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 71 | public static class CallInfo implements Parcelable |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 72 | { |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 73 | public String mCallID = ""; |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 74 | public String mAccountID = ""; |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 75 | public String mDisplayName = ""; |
| 76 | public String mPhone = ""; |
| 77 | public String mEmail = ""; |
Alexandre Savard | 2b01c82 | 2012-09-20 15:00:37 -0400 | [diff] [blame] | 78 | public String mRemoteContact = ""; |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 79 | public int mCallType = CALL_TYPE_UNDETERMINED; |
Alexandre Savard | 27a5113 | 2012-10-25 18:35:14 -0400 | [diff] [blame] | 80 | public int mCallState = CALL_STATE_NONE; |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 81 | public int mMediaState = MEDIA_STATE_NONE; |
| 82 | |
| 83 | @Override |
| 84 | public int describeContents() { |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public void writeToParcel(Parcel out, int flags) { |
| 90 | ArrayList<String> list = new ArrayList<String>(); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 91 | |
| 92 | // Don't mess with this order!!! |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 93 | list.add(mCallID); |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 94 | list.add(mAccountID); |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 95 | list.add(mDisplayName); |
| 96 | list.add(mPhone); |
| 97 | list.add(mEmail); |
| 98 | list.add(mRemoteContact); |
| 99 | |
| 100 | out.writeStringList(list); |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 101 | out.writeInt(mCallType); |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 102 | out.writeInt(mCallState); |
| 103 | out.writeInt(mMediaState); |
| 104 | } |
| 105 | |
Adrien Béraud | ea28cd5 | 2013-04-26 17:40:46 +1000 | [diff] [blame] | 106 | public static final Parcelable.Creator<CallInfo> CREATOR = new Parcelable.Creator<CallInfo>() { |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 107 | public CallInfo createFromParcel(Parcel in) { |
| 108 | return new CallInfo(in); |
| 109 | } |
| 110 | |
| 111 | public CallInfo[] newArray(int size) { |
| 112 | return new CallInfo[size]; |
| 113 | } |
| 114 | }; |
| 115 | |
| 116 | public CallInfo() {} |
| 117 | |
| 118 | private CallInfo(Parcel in) { |
| 119 | ArrayList<String> list = in.createStringArrayList(); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 120 | |
| 121 | // Don't mess with this order!!! |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 122 | mCallID = list.get(0); |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 123 | mAccountID = list.get(1); |
| 124 | mDisplayName = list.get(2); |
| 125 | mPhone = list.get(3); |
| 126 | mEmail = list.get(4); |
| 127 | mRemoteContact = list.get(5); |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 128 | |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 129 | mCallType = in.readInt(); |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 130 | mCallState = in.readInt(); |
| 131 | mMediaState = in.readInt(); |
| 132 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 133 | |
| 134 | public CallInfo(Intent call) { |
| 135 | Bundle b = call.getBundleExtra("com.savoirfairelinux.sflphone.service.newcall"); |
| 136 | mAccountID = b.getString("AccountID"); |
| 137 | mCallID = b.getString("CallID"); |
| 138 | mDisplayName = b.getString("From"); |
| 139 | } |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 140 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 141 | |
| 142 | public SipCall() |
| 143 | { |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 144 | mCallInfo = new CallInfo(); |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 145 | } |
| 146 | |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 147 | public SipCall(CallInfo info) |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 148 | { |
Alexandre Savard | 7a46f54 | 2012-09-20 11:23:33 -0400 | [diff] [blame] | 149 | mCallInfo = info; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 150 | } |
| 151 | |
Alexandre Savard | a140465 | 2012-09-20 13:34:08 -0400 | [diff] [blame] | 152 | |
Alexandre Savard | d197653 | 2012-10-26 15:32:45 -0400 | [diff] [blame] | 153 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 154 | public void setCallID(String callID) { |
| 155 | mCallInfo.mCallID = callID; |
| 156 | } |
| 157 | |
| 158 | public String getCallId() { |
| 159 | return mCallInfo.mCallID; |
| 160 | } |
| 161 | |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 162 | public void setAccountID(String accountID) { |
| 163 | mCallInfo.mAccountID = accountID; |
| 164 | } |
| 165 | |
| 166 | public String getAccountID() { |
| 167 | return mCallInfo.mAccountID; |
| 168 | } |
| 169 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 170 | public void setDisplayName(String displayName) { |
| 171 | mCallInfo.mDisplayName = displayName; |
| 172 | } |
| 173 | |
| 174 | public String getDisplayName() { |
| 175 | return mCallInfo.mDisplayName; |
| 176 | } |
| 177 | |
| 178 | public void setPhone(String phone) { |
| 179 | mCallInfo.mPhone = phone; |
| 180 | } |
| 181 | |
| 182 | public String getPhone() { |
| 183 | return mCallInfo.mPhone; |
| 184 | } |
| 185 | |
| 186 | public void setEmail(String email) { |
| 187 | mCallInfo.mEmail = email; |
| 188 | } |
| 189 | |
| 190 | public String getEmail() { |
| 191 | return mCallInfo.mEmail; |
| 192 | } |
| 193 | |
| 194 | public void setRemoteContact(String remoteContact) { |
| 195 | mCallInfo.mRemoteContact = remoteContact; |
| 196 | } |
| 197 | |
| 198 | public String getRemoteContact() { |
| 199 | return mCallInfo.mRemoteContact; |
| 200 | } |
| 201 | |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 202 | public void setCallType(int callType) { |
| 203 | mCallInfo.mCallType = callType; |
| 204 | } |
| 205 | |
| 206 | public int getCallType() { |
| 207 | return mCallInfo.mCallType; |
| 208 | } |
| 209 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 210 | public void setCallState(int callState) { |
| 211 | mCallInfo.mCallState = callState; |
| 212 | } |
| 213 | |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 214 | public int getCallStateInt() { |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 215 | return mCallInfo.mCallState; |
| 216 | } |
| 217 | |
Alexandre Savard | df54426 | 2012-10-25 14:24:08 -0400 | [diff] [blame] | 218 | public String getCallStateString() { |
| 219 | String state; |
| 220 | |
| 221 | switch(mCallInfo.mCallState) { |
| 222 | case CALL_STATE_INCOMING: |
| 223 | state = "INCOMING"; |
| 224 | break; |
| 225 | case CALL_STATE_RINGING: |
| 226 | state = "RINGING"; |
| 227 | break; |
| 228 | case CALL_STATE_CURRENT: |
| 229 | state = "CURRENT"; |
| 230 | break; |
| 231 | case CALL_STATE_HUNGUP: |
| 232 | state = "HUNGUP"; |
| 233 | break; |
| 234 | case CALL_STATE_BUSY: |
| 235 | state = "BUSY"; |
| 236 | break; |
| 237 | case CALL_STATE_FAILURE: |
| 238 | state = "FAILURE"; |
| 239 | break; |
| 240 | case CALL_STATE_HOLD: |
| 241 | state = "HOLD"; |
| 242 | break; |
| 243 | case CALL_STATE_UNHOLD: |
| 244 | state = "UNHOLD"; |
| 245 | break; |
| 246 | default: |
| 247 | state = "NULL"; |
| 248 | } |
| 249 | |
| 250 | return state; |
| 251 | } |
| 252 | |
| 253 | |
Alexandre Savard | c58c0fd | 2012-10-25 10:44:08 -0400 | [diff] [blame] | 254 | public void setMediaState(int mediaState) { |
| 255 | mCallInfo.mMediaState = mediaState; |
| 256 | } |
| 257 | |
| 258 | public int getMediaState() { |
| 259 | return mCallInfo.mMediaState; |
| 260 | } |
| 261 | |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 262 | |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 263 | |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 264 | public boolean notifyServiceAnswer(ISipService service) |
Alexandre Savard | f17e317 | 2012-10-25 16:09:09 -0400 | [diff] [blame] | 265 | { |
Alexandre Savard | 27a5113 | 2012-10-25 18:35:14 -0400 | [diff] [blame] | 266 | int callState = getCallStateInt(); |
| 267 | if((callState != CALL_STATE_RINGING) && |
| 268 | (callState != CALL_STATE_NONE)) { |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 269 | return false; |
Alexandre Savard | 27a5113 | 2012-10-25 18:35:14 -0400 | [diff] [blame] | 270 | } |
Alexandre Savard | f17e317 | 2012-10-25 16:09:09 -0400 | [diff] [blame] | 271 | |
| 272 | try { |
| 273 | service.accept(mCallInfo.mCallID); |
| 274 | } catch (RemoteException e) { |
| 275 | Log.e(TAG, "Cannot call service method", e); |
| 276 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 277 | |
| 278 | return true; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 279 | } |
| 280 | |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 281 | /** |
| 282 | * Perform hangup action without sending request to the service |
Alexandre Savard | a949eec | 2012-10-25 17:30:49 -0400 | [diff] [blame] | 283 | * Used when SipService haved been notified that this call hung up |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 284 | */ |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 285 | // public void hangupUpdateUi() { |
| 286 | // Log.i(TAG, "Hangup call " + mCallInfo.mCallID); |
| 287 | // |
| 288 | // if(mCallElementList != null) |
| 289 | // mCallElementList.removeCall(this); |
| 290 | // |
| 291 | // if(mHome != null) |
| 292 | // mHome.onUnselectedCallAction(); |
| 293 | // } |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 294 | |
| 295 | /** |
| 296 | * Perform hangup action and send request to the service |
| 297 | */ |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 298 | public boolean notifyServiceHangup(ISipService service) |
Alexandre Savard | 4f42ade | 2012-10-24 18:03:31 -0400 | [diff] [blame] | 299 | { |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 300 | try { |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 301 | if((getCallStateInt() == CALL_STATE_NONE) || |
| 302 | (getCallStateInt() == CALL_STATE_CURRENT) || |
| 303 | (getCallStateInt() == CALL_STATE_HOLD)) { |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 304 | service.hangUp(mCallInfo.mCallID); |
| 305 | return true; |
| 306 | |
| 307 | } |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 308 | else if(getCallStateInt() == CALL_STATE_RINGING) { |
| 309 | if(getCallType() == CALL_TYPE_INCOMING) { |
| 310 | service.refuse(mCallInfo.mCallID); |
| 311 | return true; |
| 312 | } |
| 313 | else if(getCallType() == CALL_TYPE_OUTGOING) { |
| 314 | service.hangUp(mCallInfo.mCallID); |
| 315 | return true; |
| 316 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 317 | } |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame] | 318 | } catch (RemoteException e) { |
| 319 | Log.e(TAG, "Cannot call service method", e); |
| 320 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 321 | |
| 322 | return false; |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 323 | } |
Alexandre Savard | aef9d80 | 2012-09-20 17:31:32 -0400 | [diff] [blame] | 324 | |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 325 | public boolean notifyServiceRefuse(ISipService service) |
Alexandre Savard | 8386985 | 2012-10-26 09:14:12 -0400 | [diff] [blame] | 326 | { |
| 327 | try { |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 328 | if(getCallStateInt() == CALL_STATE_RINGING) { |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 329 | service.refuse(mCallInfo.mCallID); |
| 330 | return true; |
| 331 | } |
Alexandre Savard | 8386985 | 2012-10-26 09:14:12 -0400 | [diff] [blame] | 332 | } catch (RemoteException e) { |
| 333 | Log.e(TAG, "Cannot call service method", e); |
| 334 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 335 | |
| 336 | return false; |
Alexandre Savard | 8386985 | 2012-10-26 09:14:12 -0400 | [diff] [blame] | 337 | } |
| 338 | |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 339 | public boolean notifyServiceHold(ISipService service) |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 340 | { |
| 341 | try { |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 342 | if(getCallStateInt() == CALL_STATE_CURRENT) { |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 343 | service.hold(mCallInfo.mCallID); |
| 344 | return true; |
| 345 | } |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 346 | } catch (RemoteException e) { |
| 347 | Log.e(TAG, "Cannot call service method", e); |
| 348 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 349 | |
| 350 | return false; |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 351 | } |
| 352 | |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 353 | public boolean notifyServiceUnhold(ISipService service) |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 354 | { |
| 355 | try { |
Alexandre Savard | 2f1ae54 | 2012-10-26 17:05:00 -0400 | [diff] [blame] | 356 | if(getCallStateInt() == CALL_STATE_HOLD) { |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 357 | service.unhold(mCallInfo.mCallID); |
| 358 | return true; |
| 359 | } |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 360 | } catch (RemoteException e) { |
| 361 | Log.e(TAG, "Cannot call service method", e); |
| 362 | } |
Alexandre Savard | 08545ae | 2012-10-26 16:11:42 -0400 | [diff] [blame] | 363 | |
| 364 | return false; |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 365 | } |
Alexandre Savard | 8386985 | 2012-10-26 09:14:12 -0400 | [diff] [blame] | 366 | |
Alexandre Savard | aef9d80 | 2012-09-20 17:31:32 -0400 | [diff] [blame] | 367 | public void addToConference() |
| 368 | { |
| 369 | Log.i(TAG, "Add call to conference"); |
| 370 | } |
| 371 | |
| 372 | public void sendTextMessage() |
| 373 | { |
| 374 | Log.i(TAG, "Send text message"); |
| 375 | } |
Alexandre Savard | 3bdce7b | 2012-10-24 18:27:45 -0400 | [diff] [blame] | 376 | |
Alexandre Savard | 73bc56f | 2012-10-25 13:35:54 -0400 | [diff] [blame] | 377 | public void printCallInfo() |
| 378 | { |
| 379 | Log.i(TAG, "CallInfo: CallID: " + mCallInfo.mCallID); |
| 380 | Log.i(TAG, " AccountID: " + mCallInfo.mAccountID); |
| 381 | Log.i(TAG, " Display Name: " + mCallInfo.mDisplayName); |
| 382 | Log.i(TAG, " Phone: " + mCallInfo.mPhone); |
| 383 | Log.i(TAG, " Email: " + mCallInfo.mEmail); |
| 384 | Log.i(TAG, " Contact: " + mCallInfo.mRemoteContact); |
| 385 | } |
| 386 | |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 387 | |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 388 | |
| 389 | /** |
| 390 | * Compare sip calls based on call ID |
| 391 | */ |
| 392 | @Override |
| 393 | public boolean equals(Object c){ |
| 394 | if(c instanceof SipCall && ((SipCall) c).mCallInfo.mCallID == mCallInfo.mCallID){ |
| 395 | return true; |
| 396 | } |
| 397 | return false; |
| 398 | |
| 399 | } |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 400 | |
| 401 | public void notifyServiceTransfer(ISipService service, String to) { |
| 402 | try { |
| 403 | if(getCallStateInt() == CALL_STATE_CURRENT) { |
| 404 | service.transfer(mCallInfo.mCallID, to); |
| 405 | } |
| 406 | } catch (RemoteException e) { |
| 407 | Log.e(TAG, "Cannot call service method", e); |
| 408 | } |
| 409 | } |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 410 | |
| 411 | public void notifyServiceRecord(ISipService service) { |
| 412 | try { |
| 413 | if(getCallStateInt() == CALL_STATE_CURRENT) { |
| 414 | service.setRecordPath(Environment.getExternalStorageDirectory().getAbsolutePath()); |
| 415 | Log.w(TAG,"Recording path"+service.getRecordPath()); |
| 416 | service.setRecordingCall(mCallInfo.mCallID); |
| 417 | } |
| 418 | } catch (RemoteException e) { |
| 419 | Log.e(TAG, "Cannot call service method", e); |
| 420 | } |
| 421 | |
| 422 | } |
| 423 | |
| 424 | public void notifyServiceSendMsg(ISipService service,String msg) { |
| 425 | try { |
| 426 | if(getCallStateInt() == CALL_STATE_CURRENT) { |
| 427 | service.sendTextMessage(mCallInfo.mCallID, msg, mCallInfo.mDisplayName); |
| 428 | } |
| 429 | } catch (RemoteException e) { |
| 430 | Log.e(TAG, "Cannot call service method", e); |
| 431 | } |
| 432 | |
| 433 | } |
Alexandre Savard | 4a19d75 | 2012-09-19 13:19:24 -0400 | [diff] [blame] | 434 | } |