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