Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr) |
| 3 | * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. |
| 4 | * |
| 5 | * Author: Regis Montoya <r3gis.3R@gmail.com> |
| 6 | * Author: Emeric Vigier <emeric.vigier@savoirfairelinux.com> |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation, either version 3 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * If you own a pjsip commercial license you can also redistribute it |
| 13 | * and/or modify it under the terms of the GNU Lesser General Public License |
| 14 | * as an android library. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | */ |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 24 | package com.savoirfairelinux.sflphone.service; |
| 25 | |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 26 | import java.lang.ref.WeakReference; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 27 | import java.util.ArrayList; |
| 28 | import java.util.HashMap; |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 29 | import java.util.List; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 30 | import java.util.Map; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 31 | |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 32 | import android.app.Service; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 33 | import android.content.BroadcastReceiver; |
| 34 | import android.content.Context; |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 35 | import android.content.Intent; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 36 | import android.content.IntentFilter; |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 37 | import android.os.Bundle; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 38 | import android.os.Handler; |
| 39 | import android.os.HandlerThread; |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 40 | import android.os.IBinder; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 41 | import android.os.Looper; |
| 42 | import android.os.Message; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 43 | import android.os.RemoteException; |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 44 | import android.os.Vibrator; |
alision | 17052d4 | 2013-04-22 10:39:38 -0400 | [diff] [blame] | 45 | import android.support.v4.content.LocalBroadcastManager; |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 46 | import android.util.Log; |
| 47 | import android.widget.Toast; |
| 48 | |
alision | f76de3b | 2013-04-16 15:35:22 -0400 | [diff] [blame] | 49 | import com.savoirfairelinux.sflphone.account.AccountDetailsHandler; |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 50 | import com.savoirfairelinux.sflphone.account.AudioHandler; |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 51 | import com.savoirfairelinux.sflphone.account.HistoryHandler; |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 52 | import com.savoirfairelinux.sflphone.client.SFLphoneApplication; |
Alexandre Savard | 713a34d | 2012-09-26 15:50:41 -0400 | [diff] [blame] | 53 | |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 54 | public class SipService extends Service { |
| 55 | |
| 56 | static final String TAG = "SipService"; |
| 57 | static final int DELAY = 5000; /* 5 sec */ |
| 58 | private boolean runFlag = false; |
| 59 | private SipServiceThread sipServiceThread; |
Emeric Vigier | 84e05da | 2012-09-20 14:53:05 -0400 | [diff] [blame] | 60 | private SFLphoneApplication sflphoneApp; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 61 | private SipServiceExecutor mExecutor; |
| 62 | private static HandlerThread executorThread; |
| 63 | private CallManagerJNI callManagerJNI; |
Emeric Vigier | 0007dee | 2012-09-24 11:35:58 -0400 | [diff] [blame] | 64 | private CallManagerCallBack callManagerCallBack; |
Alexandre Savard | c1b08fe | 2012-09-25 16:24:47 -0400 | [diff] [blame] | 65 | private ConfigurationManagerJNI configurationManagerJNI; |
Alexandre Savard | fccd1dc | 2012-10-17 17:31:38 -0400 | [diff] [blame] | 66 | private ConfigurationManagerCallback configurationManagerCallback; |
Emeric Vigier | 0007dee | 2012-09-24 11:35:58 -0400 | [diff] [blame] | 67 | private ManagerImpl managerImpl; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 68 | private boolean isPjSipStackStarted = false; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 69 | ISipClient client; |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 70 | |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 71 | int clients = 0; |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 72 | |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 73 | private BroadcastReceiver IncomingReceiver = new BroadcastReceiver() { |
| 74 | |
| 75 | @Override |
| 76 | public void onReceive(Context context, Intent intent) { |
| 77 | // Get instance of Vibrator from current Context |
| 78 | |
| 79 | if (client != null) { |
| 80 | try { |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 81 | if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED)) { |
| 82 | Log.i(TAG, "Received" + intent.getAction()); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 83 | } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_LOADED)) { |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 84 | Log.i(TAG, "Received" + intent.getAction()); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 85 | } else if (intent.getAction().contentEquals(ConfigurationManagerCallback.ACCOUNTS_CHANGED)) { |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 86 | Log.i(TAG, "Received" + intent.getAction()); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 87 | } else if(intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) { |
| 88 | Log.i(TAG, "Received" + intent.getAction()); |
| 89 | client.incomingText(intent); |
| 90 | } else if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)) { |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 91 | Log.i(TAG, "Received" + intent.getAction()); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 92 | client.incomingCall(intent); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 93 | } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) { |
| 94 | Log.i(TAG, "Received" + intent.getAction()); |
| 95 | client.callStateChanged(intent); |
| 96 | } else if (intent.getAction().contentEquals(CallManagerCallBack.NEW_CALL_CREATED)) { |
| 97 | Log.i(TAG, "Received" + intent.getAction()); |
| 98 | Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); |
| 99 | mVibrator.vibrate(300); |
| 100 | } |
| 101 | } catch (RemoteException e) { |
| 102 | Log.e(TAG, e.toString()); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | } |
| 107 | }; |
| 108 | |
| 109 | @Override |
| 110 | public boolean onUnbind(Intent i) { |
| 111 | super.onUnbind(i); |
| 112 | Log.i(TAG, "onUnbind(intent)"); |
| 113 | return false; |
| 114 | |
| 115 | } |
| 116 | |
| 117 | /* called once by startService() */ |
| 118 | @Override |
| 119 | public void onCreate() { |
| 120 | Log.i(TAG, "onCreated"); |
| 121 | super.onCreate(); |
| 122 | |
| 123 | sflphoneApp = (SFLphoneApplication) getApplication(); |
| 124 | sipServiceThread = new SipServiceThread(); |
| 125 | |
| 126 | IntentFilter callFilter = new IntentFilter(CallManagerCallBack.CALL_STATE_CHANGED); |
| 127 | callFilter.addAction(CallManagerCallBack.INCOMING_CALL); |
| 128 | callFilter.addAction(CallManagerCallBack.NEW_CALL_CREATED); |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 129 | callFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED); |
| 130 | callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_CHANGED); |
| 131 | callFilter.addAction(ConfigurationManagerCallback.ACCOUNTS_LOADED); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 132 | callFilter.addAction(CallManagerCallBack.INCOMING_TEXT); |
| 133 | |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 134 | LocalBroadcastManager.getInstance(this).registerReceiver(IncomingReceiver, callFilter); |
| 135 | getExecutor().execute(new StartRunnable()); |
| 136 | } |
| 137 | |
| 138 | /* called for each startService() */ |
| 139 | @Override |
| 140 | public int onStartCommand(Intent intent, int flags, int startId) { |
| 141 | Log.i(TAG, "onStarted"); |
| 142 | super.onStartCommand(intent, flags, startId); |
| 143 | |
| 144 | if (!runFlag) { |
| 145 | sipServiceThread.start(); |
| 146 | runFlag = true; |
| 147 | sflphoneApp.setServiceRunning(true); |
| 148 | Toast.makeText(this, "Sflphone Service started", Toast.LENGTH_SHORT).show(); |
| 149 | } |
| 150 | |
| 151 | return START_STICKY; /* started and stopped explicitly */ |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public void onDestroy() { |
| 156 | /* called once by stopService() */ |
| 157 | sipServiceThread.interrupt(); |
| 158 | sipServiceThread = null; |
| 159 | runFlag = false; |
| 160 | sflphoneApp.setServiceRunning(false); |
| 161 | Toast.makeText(this, "Sflphone Service stopped", Toast.LENGTH_SHORT).show(); |
| 162 | super.onDestroy(); |
| 163 | |
| 164 | Log.i(TAG, "onDestroyed"); |
| 165 | } |
| 166 | |
| 167 | @Override |
| 168 | public IBinder onBind(Intent arg0) { |
| 169 | Log.i(TAG, "onBound"); |
| 170 | return mBinder; |
| 171 | } |
| 172 | |
| 173 | private static Looper createLooper() { |
| 174 | if (executorThread == null) { |
| 175 | Log.d(TAG, "Creating new handler thread"); |
| 176 | // ADT gives a fake warning due to bad parse rule. |
| 177 | executorThread = new HandlerThread("SipService.Executor"); |
| 178 | executorThread.start(); |
| 179 | } |
| 180 | return executorThread.getLooper(); |
| 181 | } |
| 182 | |
| 183 | public SipServiceExecutor getExecutor() { |
| 184 | // create mExecutor lazily |
| 185 | if (mExecutor == null) { |
| 186 | mExecutor = new SipServiceExecutor(this); |
| 187 | } |
| 188 | return mExecutor; |
| 189 | } |
| 190 | |
| 191 | // Executes immediate tasks in a single executorThread. |
| 192 | public static class SipServiceExecutor extends Handler { |
| 193 | WeakReference<SipService> handlerService; |
| 194 | |
| 195 | SipServiceExecutor(SipService s) { |
| 196 | super(createLooper()); |
| 197 | handlerService = new WeakReference<SipService>(s); |
| 198 | } |
| 199 | |
| 200 | public void execute(Runnable task) { |
| 201 | // TODO: add wakelock |
| 202 | Message.obtain(this, 0/* don't care */, task).sendToTarget(); |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public void handleMessage(Message msg) { |
| 207 | if (msg.obj instanceof Runnable) { |
| 208 | executeInternal((Runnable) msg.obj); |
| 209 | } else { |
| 210 | Log.w(TAG, "can't handle msg: " + msg); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | private void executeInternal(Runnable task) { |
| 215 | try { |
| 216 | task.run(); |
| 217 | } catch (Throwable t) { |
| 218 | Log.e(TAG, "run task: " + task, t); |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | private void startPjSipStack() throws SameThreadException { |
| 224 | if (isPjSipStackStarted) |
| 225 | return; |
| 226 | |
| 227 | try { |
| 228 | System.loadLibrary("gnustl_shared"); |
| 229 | System.loadLibrary("expat"); |
| 230 | System.loadLibrary("yaml"); |
| 231 | System.loadLibrary("ccgnu2"); |
| 232 | System.loadLibrary("crypto"); |
| 233 | System.loadLibrary("ssl"); |
| 234 | System.loadLibrary("ccrtp1"); |
| 235 | System.loadLibrary("dbus"); |
| 236 | System.loadLibrary("dbus-c++-1"); |
| 237 | System.loadLibrary("samplerate"); |
| 238 | System.loadLibrary("codec_ulaw"); |
| 239 | System.loadLibrary("codec_alaw"); |
alision | d8c8388 | 2013-05-17 17:00:42 -0400 | [diff] [blame] | 240 | System.loadLibrary("codec_g722"); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 241 | System.loadLibrary("speexresampler"); |
| 242 | System.loadLibrary("sflphone"); |
| 243 | isPjSipStackStarted = true; |
| 244 | } catch (UnsatisfiedLinkError e) { |
| 245 | Log.e(TAG, "Problem with the current Pj stack...", e); |
| 246 | isPjSipStackStarted = false; |
| 247 | return; |
| 248 | } catch (Exception e) { |
| 249 | Log.e(TAG, "Problem with the current Pj stack...", e); |
| 250 | } |
| 251 | |
| 252 | /* get unique instance of managerImpl */ |
| 253 | managerImpl = SFLPhoneservice.instance(); |
| 254 | |
| 255 | /* set static AppPath before calling manager.init */ |
| 256 | managerImpl.setPath(sflphoneApp.getAppPath()); |
| 257 | |
| 258 | callManagerJNI = new CallManagerJNI(); |
| 259 | callManagerCallBack = new CallManagerCallBack(this); |
| 260 | SFLPhoneservice.setCallbackObject(callManagerCallBack); |
| 261 | |
| 262 | configurationManagerJNI = new ConfigurationManagerJNI(); |
| 263 | configurationManagerCallback = new ConfigurationManagerCallback(this); |
| 264 | SFLPhoneservice.setConfigurationCallbackObject(configurationManagerCallback); |
| 265 | |
| 266 | managerImpl.init(""); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | // Enforce same thread contract to ensure we do not call from somewhere else |
| 271 | public class SameThreadException extends Exception { |
| 272 | private static final long serialVersionUID = -905639124232613768L; |
| 273 | |
| 274 | public SameThreadException() { |
| 275 | super("Should be launched from a single worker thread"); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | public abstract static class SipRunnable implements Runnable { |
| 280 | protected abstract void doRun() throws SameThreadException, RemoteException; |
| 281 | |
| 282 | public void run() { |
| 283 | try { |
| 284 | doRun(); |
| 285 | } catch (SameThreadException e) { |
| 286 | Log.e(TAG, "Not done from same thread"); |
| 287 | } catch (RemoteException e) { |
| 288 | Log.e(TAG, e.toString()); |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | public abstract static class SipRunnableWithReturn implements Runnable { |
| 294 | Object obj = null; |
| 295 | boolean done = false; |
| 296 | |
| 297 | protected abstract Object doRun() throws SameThreadException; |
| 298 | |
| 299 | public Object getVal() { |
| 300 | return obj; |
| 301 | } |
| 302 | |
| 303 | public boolean isDone() { |
| 304 | return done; |
| 305 | } |
| 306 | |
| 307 | public void run() { |
| 308 | try { |
| 309 | obj = doRun(); |
| 310 | done = true; |
| 311 | } catch (SameThreadException e) { |
| 312 | Log.e(TAG, "Not done from same thread"); |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | class StartRunnable extends SipRunnable { |
| 318 | @Override |
| 319 | protected void doRun() throws SameThreadException { |
| 320 | startPjSipStack(); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | private class SipServiceThread extends Thread { |
| 325 | |
| 326 | public SipServiceThread() { |
| 327 | super("sipServiceThread"); |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public void run() { |
| 332 | Log.i(TAG, "SipService thread running..."); |
| 333 | SipService sipService = SipService.this; |
| 334 | while (sipService.runFlag) { |
| 335 | try { |
| 336 | Thread.sleep(DELAY); |
| 337 | } catch (InterruptedException e) { |
| 338 | sipService.runFlag = false; |
| 339 | Log.w(TAG, "service thread interrupted!"); |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | /* ************************************ |
| 346 | * |
| 347 | * Implement public interface for the service |
| 348 | * |
| 349 | * |
| 350 | * ********************************** |
| 351 | */ |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 352 | private final ISipService.Stub mBinder = new ISipService.Stub() { |
| 353 | |
| 354 | @Override |
| 355 | public void placeCall(final String accountID, final String callID, final String to) { |
| 356 | getExecutor().execute(new SipRunnable() { |
| 357 | @Override |
| 358 | protected void doRun() throws SameThreadException { |
| 359 | Log.i(TAG, "SipService.placeCall() thread running..."); |
| 360 | callManagerJNI.placeCall(accountID, callID, to); |
| 361 | } |
| 362 | }); |
| 363 | } |
| 364 | |
| 365 | @Override |
| 366 | public void refuse(final String callID) { |
| 367 | getExecutor().execute(new SipRunnable() { |
| 368 | @Override |
| 369 | protected void doRun() throws SameThreadException { |
| 370 | Log.i(TAG, "SipService.refuse() thread running..."); |
| 371 | callManagerJNI.refuse(callID); |
| 372 | } |
| 373 | }); |
| 374 | } |
| 375 | |
| 376 | @Override |
| 377 | public void accept(final String callID) { |
| 378 | getExecutor().execute(new SipRunnable() { |
| 379 | @Override |
| 380 | protected void doRun() throws SameThreadException { |
| 381 | Log.i(TAG, "SipService.placeCall() thread running..."); |
| 382 | callManagerJNI.accept(callID); |
| 383 | } |
| 384 | }); |
| 385 | } |
| 386 | |
| 387 | @Override |
| 388 | public void hangUp(final String callID) { |
| 389 | getExecutor().execute(new SipRunnable() { |
| 390 | @Override |
| 391 | protected void doRun() throws SameThreadException { |
| 392 | Log.i(TAG, "SipService.hangUp() thread running..."); |
| 393 | callManagerJNI.hangUp(callID); |
| 394 | } |
| 395 | }); |
| 396 | } |
Alexandre Savard | c1b08fe | 2012-09-25 16:24:47 -0400 | [diff] [blame] | 397 | |
| 398 | @Override |
Alexandre Savard | e9dc899 | 2012-10-26 12:12:27 -0400 | [diff] [blame] | 399 | public void hold(final String callID) { |
| 400 | getExecutor().execute(new SipRunnable() { |
| 401 | @Override |
| 402 | protected void doRun() throws SameThreadException { |
| 403 | Log.i(TAG, "SipService.hold() thread running..."); |
| 404 | callManagerJNI.hold(callID); |
| 405 | } |
| 406 | }); |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public void unhold(final String callID) { |
| 411 | getExecutor().execute(new SipRunnable() { |
| 412 | @Override |
| 413 | protected void doRun() throws SameThreadException { |
| 414 | Log.i(TAG, "SipService.unhold() thread running..."); |
| 415 | callManagerJNI.unhold(callID); |
| 416 | } |
| 417 | }); |
| 418 | } |
| 419 | |
| 420 | @Override |
Alexandre Savard | c1b08fe | 2012-09-25 16:24:47 -0400 | [diff] [blame] | 421 | public void setAudioPlugin(final String audioPlugin) { |
| 422 | getExecutor().execute(new SipRunnable() { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 423 | @Override |
| 424 | protected void doRun() throws SameThreadException { |
| 425 | Log.i(TAG, "SipService.setAudioPlugin() thread running..."); |
| 426 | configurationManagerJNI.setAudioPlugin(audioPlugin); |
| 427 | } |
Alexandre Savard | 31d27c6 | 2012-10-04 16:05:08 -0400 | [diff] [blame] | 428 | }); |
| 429 | } |
| 430 | |
| 431 | @Override |
| 432 | public String getCurrentAudioOutputPlugin() { |
| 433 | class CurrentAudioPlugin extends SipRunnableWithReturn { |
| 434 | @Override |
| 435 | protected String doRun() throws SameThreadException { |
| 436 | Log.i(TAG, "SipService.getCurrentAudioOutputPlugin() thread running..."); |
| 437 | return configurationManagerJNI.getCurrentAudioOutputPlugin(); |
| 438 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 439 | } |
| 440 | ; |
Alexandre Savard | 31d27c6 | 2012-10-04 16:05:08 -0400 | [diff] [blame] | 441 | |
| 442 | CurrentAudioPlugin runInstance = new CurrentAudioPlugin(); |
| 443 | getExecutor().execute(runInstance); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 444 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 445 | // Log.e(TAG, "Waiting for Nofing"); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 446 | } |
Alexandre Savard | 7a902bc | 2012-10-04 16:32:35 -0400 | [diff] [blame] | 447 | return (String) runInstance.getVal(); |
Alexandre Savard | c1b08fe | 2012-09-25 16:24:47 -0400 | [diff] [blame] | 448 | } |
Alexandre Savard | 713a34d | 2012-09-26 15:50:41 -0400 | [diff] [blame] | 449 | |
| 450 | @Override |
Alexandre Savard | 6b85e7e | 2012-09-27 15:43:14 -0400 | [diff] [blame] | 451 | public ArrayList<String> getAccountList() { |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 452 | class AccountList extends SipRunnableWithReturn { |
| 453 | @Override |
| 454 | protected StringVect doRun() throws SameThreadException { |
| 455 | Log.i(TAG, "SipService.getAccountList() thread running..."); |
| 456 | return configurationManagerJNI.getAccountList(); |
| 457 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 458 | } |
| 459 | ; |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 460 | AccountList runInstance = new AccountList(); |
| 461 | getExecutor().execute(runInstance); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 462 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 463 | // Log.e(TAG, "Waiting for Nofing"); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 464 | } |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 465 | StringVect swigvect = (StringVect) runInstance.getVal(); |
| 466 | |
Alexandre Savard | 6b85e7e | 2012-09-27 15:43:14 -0400 | [diff] [blame] | 467 | ArrayList<String> nativelist = new ArrayList<String>(); |
Alexandre Savard | 52a7252 | 2012-09-27 16:40:13 -0400 | [diff] [blame] | 468 | |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 469 | for (int i = 0; i < swigvect.size(); i++) |
| 470 | nativelist.add(swigvect.get(i)); |
Alexandre Savard | 52a7252 | 2012-09-27 16:40:13 -0400 | [diff] [blame] | 471 | |
Alexandre Savard | 6b85e7e | 2012-09-27 15:43:14 -0400 | [diff] [blame] | 472 | return nativelist; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 473 | } |
Alexandre Savard | 6b85e7e | 2012-09-27 15:43:14 -0400 | [diff] [blame] | 474 | |
| 475 | @Override |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 476 | public HashMap<String, String> getAccountDetails(final String accountID) { |
Alexandre Savard | 7a902bc | 2012-10-04 16:32:35 -0400 | [diff] [blame] | 477 | class AccountDetails extends SipRunnableWithReturn { |
| 478 | private String id; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 479 | |
| 480 | AccountDetails(String accountId) { |
| 481 | id = accountId; |
| 482 | } |
| 483 | |
Alexandre Savard | 7a902bc | 2012-10-04 16:32:35 -0400 | [diff] [blame] | 484 | @Override |
| 485 | protected StringMap doRun() throws SameThreadException { |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 486 | Log.i(TAG, "SipService.getAccountDetails() thread running..."); |
Alexandre Savard | 7a902bc | 2012-10-04 16:32:35 -0400 | [diff] [blame] | 487 | return configurationManagerJNI.getAccountDetails(id); |
| 488 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 489 | } |
Alexandre Savard | 7a902bc | 2012-10-04 16:32:35 -0400 | [diff] [blame] | 490 | |
| 491 | AccountDetails runInstance = new AccountDetails(accountID); |
| 492 | getExecutor().execute(runInstance); |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 493 | clients++; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 494 | while (!runInstance.isDone()) { |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 495 | Log.w(TAG, "Waiting for Details " + clients); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 496 | } |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 497 | clients--; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 498 | StringMap swigmap = (StringMap) runInstance.getVal(); |
Alexandre Savard | 713a34d | 2012-09-26 15:50:41 -0400 | [diff] [blame] | 499 | |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 500 | HashMap<String, String> nativemap = AccountDetailsHandler.convertSwigToNative(swigmap); |
Alexandre Savard | 713a34d | 2012-09-26 15:50:41 -0400 | [diff] [blame] | 501 | |
| 502 | return nativemap; |
| 503 | } |
Alexandre Savard | 8b7d433 | 2012-09-30 20:02:11 -0400 | [diff] [blame] | 504 | |
| 505 | @Override |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 506 | public void setAccountDetails(final String accountId, Map map) { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 507 | HashMap<String, String> nativemap = (HashMap<String, String>) map; |
Alexandre Savard | 8b7d433 | 2012-09-30 20:02:11 -0400 | [diff] [blame] | 508 | |
Alexandre Savard | 3bbb479 | 2012-10-05 11:30:01 -0400 | [diff] [blame] | 509 | final StringMap swigmap = AccountDetailsHandler.convertFromNativeToSwig(nativemap); |
Alexandre Savard | 718d49f | 2012-10-02 15:17:13 -0400 | [diff] [blame] | 510 | |
Alexandre Savard | 7a2b220 | 2012-10-04 17:07:33 -0400 | [diff] [blame] | 511 | getExecutor().execute(new SipRunnable() { |
| 512 | @Override |
| 513 | protected void doRun() throws SameThreadException { |
| 514 | Log.i(TAG, "SipService.setAccountDetails() thread running..."); |
| 515 | configurationManagerJNI.setAccountDetails(accountId, swigmap); |
| 516 | } |
| 517 | }); |
Alexandre Savard | 8b7d433 | 2012-09-30 20:02:11 -0400 | [diff] [blame] | 518 | } |
| 519 | |
Alexandre Savard | 4603657 | 2012-10-05 13:56:49 -0400 | [diff] [blame] | 520 | @Override |
| 521 | public String addAccount(Map map) { |
| 522 | class AddAccount extends SipRunnableWithReturn { |
| 523 | StringMap map; |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 524 | |
| 525 | AddAccount(StringMap m) { |
| 526 | map = m; |
| 527 | } |
| 528 | |
Alexandre Savard | 4603657 | 2012-10-05 13:56:49 -0400 | [diff] [blame] | 529 | @Override |
| 530 | protected String doRun() throws SameThreadException { |
| 531 | Log.i(TAG, "SipService.getAccountDetails() thread running..."); |
| 532 | return configurationManagerJNI.addAccount(map); |
| 533 | } |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 534 | } |
Alexandre Savard | 4603657 | 2012-10-05 13:56:49 -0400 | [diff] [blame] | 535 | |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 536 | final StringMap swigmap = AccountDetailsHandler.convertFromNativeToSwig((HashMap<String, String>) map); |
Alexandre Savard | 4603657 | 2012-10-05 13:56:49 -0400 | [diff] [blame] | 537 | |
| 538 | AddAccount runInstance = new AddAccount(swigmap); |
| 539 | getExecutor().execute(runInstance); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 540 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 541 | // Log.e(TAG, "Waiting for Nofing"); |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 542 | } |
Alexandre Savard | 4603657 | 2012-10-05 13:56:49 -0400 | [diff] [blame] | 543 | String accountId = (String) runInstance.getVal(); |
| 544 | |
| 545 | return accountId; |
| 546 | } |
| 547 | |
| 548 | @Override |
| 549 | public void removeAccount(final String accountId) { |
| 550 | getExecutor().execute(new SipRunnable() { |
| 551 | @Override |
| 552 | protected void doRun() throws SameThreadException { |
| 553 | Log.i(TAG, "SipService.setAccountDetails() thread running..."); |
| 554 | configurationManagerJNI.removeAccount(accountId); |
| 555 | } |
| 556 | }); |
| 557 | } |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 558 | |
| 559 | @Override |
| 560 | public void registerClient(ISipClient callback) throws RemoteException { |
alision | 371b77e | 2013-04-23 14:51:26 -0400 | [diff] [blame] | 561 | client = callback; |
alision | 5f89963 | 2013-04-22 17:26:56 -0400 | [diff] [blame] | 562 | } |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 563 | |
| 564 | @Override |
| 565 | public ArrayList<HashMap<String, String>> getHistory() throws RemoteException { |
| 566 | class History extends SipRunnableWithReturn { |
| 567 | |
| 568 | @Override |
| 569 | protected VectMap doRun() throws SameThreadException { |
| 570 | Log.i(TAG, "SipService.getHistory() thread running..."); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 571 | |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 572 | return configurationManagerJNI.getHistory(); |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | History runInstance = new History(); |
| 577 | getExecutor().execute(runInstance); |
| 578 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 579 | // Log.w(TAG, "Waiting for getHistory"); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 580 | } |
| 581 | VectMap swigmap = (VectMap) runInstance.getVal(); |
| 582 | |
| 583 | ArrayList<HashMap<String, String>> nativemap = HistoryHandler.convertSwigToNative(swigmap); |
| 584 | |
| 585 | return nativemap; |
| 586 | } |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 587 | |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 588 | /************************* |
| 589 | * Transfer related API |
| 590 | *************************/ |
| 591 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 592 | @Override |
| 593 | public void transfer(final String callID, final String to) throws RemoteException { |
| 594 | getExecutor().execute(new SipRunnable() { |
| 595 | @Override |
| 596 | protected void doRun() throws SameThreadException, RemoteException { |
| 597 | Log.i(TAG, "SipService.transfer() thread running..."); |
| 598 | if (callManagerJNI.transfer(callID, to)) { |
| 599 | Bundle bundle = new Bundle(); |
| 600 | bundle.putString("CallID", callID); |
| 601 | bundle.putString("State", "HUNGUP"); |
| 602 | Intent intent = new Intent(CallManagerCallBack.CALL_STATE_CHANGED); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 603 | intent.putExtra(CallManagerCallBack.SIGNAL_NAME, CallManagerCallBack.CALL_STATE_CHANGED); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 604 | intent.putExtra("com.savoirfairelinux.sflphone.service.newstate", bundle); |
| 605 | client.callStateChanged(intent); |
| 606 | } else |
| 607 | Log.i(TAG, "NOT OK"); |
| 608 | } |
| 609 | }); |
| 610 | |
| 611 | } |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 612 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 613 | @Override |
| 614 | public void attendedTransfer(final String transferID, final String targetID) throws RemoteException { |
| 615 | getExecutor().execute(new SipRunnable() { |
| 616 | @Override |
| 617 | protected void doRun() throws SameThreadException, RemoteException { |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 618 | Log.i(TAG, "SipService.attendedTransfer() thread running..."); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 619 | if (callManagerJNI.attendedTransfer(transferID, targetID)) { |
| 620 | Log.i(TAG, "OK"); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 621 | } else |
| 622 | Log.i(TAG, "NOT OK"); |
| 623 | } |
| 624 | }); |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 625 | |
| 626 | } |
| 627 | |
| 628 | /************************* |
| 629 | * Conference related API |
| 630 | *************************/ |
| 631 | |
| 632 | @Override |
| 633 | public void removeConference(final String confID) throws RemoteException { |
| 634 | getExecutor().execute(new SipRunnable() { |
| 635 | @Override |
| 636 | protected void doRun() throws SameThreadException, RemoteException { |
| 637 | Log.i(TAG, "SipService.createConference() thread running..."); |
| 638 | callManagerJNI.removeConference(confID); |
| 639 | } |
| 640 | }); |
| 641 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 645 | public void joinParticipant(final String sel_callID, final String drag_callID) throws RemoteException { |
| 646 | getExecutor().execute(new SipRunnable() { |
| 647 | @Override |
| 648 | protected void doRun() throws SameThreadException, RemoteException { |
| 649 | Log.i(TAG, "SipService.joinParticipant() thread running..."); |
| 650 | callManagerJNI.joinParticipant(sel_callID, drag_callID); |
| 651 | } |
| 652 | }); |
| 653 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 654 | } |
| 655 | |
| 656 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 657 | public void createConfFromParticipantList(final List participants) throws RemoteException { |
| 658 | getExecutor().execute(new SipRunnable() { |
| 659 | @Override |
| 660 | protected void doRun() throws SameThreadException, RemoteException { |
| 661 | Log.i(TAG, "SipService.createConfFromParticipantList() thread running..."); |
| 662 | // callManagerJNI.createConfFromParticipantList(participants); |
| 663 | } |
| 664 | }); |
| 665 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 666 | } |
| 667 | |
| 668 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 669 | public void addParticipant(final String callID, final String confID) throws RemoteException { |
| 670 | getExecutor().execute(new SipRunnable() { |
| 671 | @Override |
| 672 | protected void doRun() throws SameThreadException, RemoteException { |
| 673 | Log.i(TAG, "SipService.addParticipant() thread running..."); |
| 674 | callManagerJNI.addParticipant(callID, confID); |
| 675 | } |
| 676 | }); |
| 677 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 681 | public void addMainParticipant(final String confID) throws RemoteException { |
| 682 | getExecutor().execute(new SipRunnable() { |
| 683 | @Override |
| 684 | protected void doRun() throws SameThreadException, RemoteException { |
| 685 | Log.i(TAG, "SipService.addMainParticipant() thread running..."); |
| 686 | callManagerJNI.addMainParticipant(confID); |
| 687 | } |
| 688 | }); |
| 689 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 693 | public void detachParticipant(final String callID) throws RemoteException { |
| 694 | getExecutor().execute(new SipRunnable() { |
| 695 | @Override |
| 696 | protected void doRun() throws SameThreadException, RemoteException { |
| 697 | Log.i(TAG, "SipService.detachParticipant() thread running..."); |
| 698 | callManagerJNI.detachParticipant(callID); |
| 699 | } |
| 700 | }); |
| 701 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 702 | } |
| 703 | |
| 704 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 705 | public void joinConference(final String sel_confID, final String drag_confID) throws RemoteException { |
| 706 | getExecutor().execute(new SipRunnable() { |
| 707 | @Override |
| 708 | protected void doRun() throws SameThreadException, RemoteException { |
| 709 | Log.i(TAG, "SipService.joinConference() thread running..."); |
| 710 | callManagerJNI.joinConference(sel_confID, drag_confID); |
| 711 | } |
| 712 | }); |
| 713 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 717 | public void hangUpConference(final String confID) throws RemoteException { |
| 718 | getExecutor().execute(new SipRunnable() { |
| 719 | @Override |
| 720 | protected void doRun() throws SameThreadException, RemoteException { |
| 721 | Log.i(TAG, "SipService.joinConference() thread running..."); |
| 722 | callManagerJNI.hangUpConference(confID); |
| 723 | } |
| 724 | }); |
| 725 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 726 | } |
| 727 | |
| 728 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 729 | public void holdConference(final String confID) throws RemoteException { |
| 730 | getExecutor().execute(new SipRunnable() { |
| 731 | @Override |
| 732 | protected void doRun() throws SameThreadException, RemoteException { |
| 733 | Log.i(TAG, "SipService.holdConference() thread running..."); |
| 734 | callManagerJNI.holdConference(confID); |
| 735 | } |
| 736 | }); |
| 737 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | @Override |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 741 | public void unholdConference(final String confID) throws RemoteException { |
| 742 | getExecutor().execute(new SipRunnable() { |
| 743 | @Override |
| 744 | protected void doRun() throws SameThreadException, RemoteException { |
| 745 | Log.i(TAG, "SipService.unholdConference() thread running..."); |
| 746 | callManagerJNI.unholdConference(confID); |
| 747 | } |
| 748 | }); |
| 749 | |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | @Override |
| 753 | public List getConferenceList() throws RemoteException { |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 754 | class ConfList extends SipRunnableWithReturn { |
| 755 | @Override |
| 756 | protected StringVect doRun() throws SameThreadException { |
| 757 | Log.i(TAG, "SipService.getAccountList() thread running..."); |
| 758 | return callManagerJNI.getConferenceList(); |
| 759 | } |
| 760 | } |
| 761 | ; |
| 762 | ConfList runInstance = new ConfList(); |
| 763 | getExecutor().execute(runInstance); |
| 764 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 765 | // Log.w(TAG, "Waiting for getConferenceList"); |
alision | 4a0eb09 | 2013-05-07 13:52:03 -0400 | [diff] [blame] | 766 | } |
| 767 | StringVect swigvect = (StringVect) runInstance.getVal(); |
| 768 | |
| 769 | ArrayList<String> nativelist = new ArrayList<String>(); |
| 770 | |
| 771 | for (int i = 0; i < swigvect.size(); i++) |
| 772 | nativelist.add(swigvect.get(i)); |
| 773 | |
| 774 | return nativelist; |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | @Override |
| 778 | public List getParticipantList(String confID) throws RemoteException { |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 779 | Log.e(TAG, "getConferenceList not implemented"); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 780 | return null; |
| 781 | } |
| 782 | |
| 783 | @Override |
| 784 | public String getConferenceId(String callID) throws RemoteException { |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 785 | Log.e(TAG, "getConferenceList not implemented"); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 786 | return null; |
| 787 | } |
| 788 | |
| 789 | @Override |
| 790 | public Map getConferenceDetails(String callID) throws RemoteException { |
alision | 43a9b36 | 2013-05-01 16:30:15 -0400 | [diff] [blame] | 791 | Log.e(TAG, "getConferenceList not implemented"); |
alision | 7f18fc8 | 2013-05-01 09:37:33 -0400 | [diff] [blame] | 792 | return null; |
| 793 | } |
| 794 | |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 795 | @Override |
| 796 | public String getRecordPath() throws RemoteException { |
| 797 | class RecordPath extends SipRunnableWithReturn { |
| 798 | |
| 799 | @Override |
| 800 | protected String doRun() throws SameThreadException { |
| 801 | Log.i(TAG, "SipService.getRecordPath() thread running..."); |
| 802 | return configurationManagerJNI.getRecordPath(); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | RecordPath runInstance = new RecordPath(); |
| 807 | getExecutor().execute(runInstance); |
| 808 | while (!runInstance.isDone()) { |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 809 | // Log.w(TAG, "Waiting for getRecordPath"); |
alision | 04a0018 | 2013-05-10 17:05:29 -0400 | [diff] [blame] | 810 | } |
| 811 | String path = (String) runInstance.getVal(); |
| 812 | |
| 813 | return path; |
| 814 | } |
| 815 | |
| 816 | @Override |
| 817 | public void setRecordingCall(final String id) throws RemoteException { |
| 818 | getExecutor().execute(new SipRunnable() { |
| 819 | @Override |
| 820 | protected void doRun() throws SameThreadException, RemoteException { |
| 821 | Log.i(TAG, "SipService.setRecordingCall() thread running..."); |
| 822 | callManagerJNI.setRecordingCall(id); |
| 823 | } |
| 824 | }); |
| 825 | |
| 826 | } |
| 827 | |
| 828 | @Override |
| 829 | public void setRecordPath(final String path) throws RemoteException { |
| 830 | getExecutor().execute(new SipRunnable() { |
| 831 | @Override |
| 832 | protected void doRun() throws SameThreadException, RemoteException { |
| 833 | Log.i(TAG, "SipService.setRecordingCall() thread running..."); |
| 834 | configurationManagerJNI.setRecordPath(path); |
| 835 | } |
| 836 | }); |
| 837 | } |
| 838 | |
| 839 | @Override |
| 840 | public void sendTextMessage(final String callID, final String message, final String from) throws RemoteException { |
| 841 | getExecutor().execute(new SipRunnable() { |
| 842 | @Override |
| 843 | protected void doRun() throws SameThreadException, RemoteException { |
| 844 | Log.i(TAG, "SipService.sendTextMessage() thread running..."); |
| 845 | callManagerJNI.sendTextMessage(callID, message, from); |
| 846 | } |
| 847 | }); |
| 848 | |
| 849 | } |
| 850 | |
alision | d295ec2 | 2013-05-17 10:12:13 -0400 | [diff] [blame] | 851 | @Override |
| 852 | public List getAudioCodecList(String accountID) throws RemoteException { |
| 853 | class AudioCodecList extends SipRunnableWithReturn { |
| 854 | |
| 855 | @Override |
| 856 | protected IntVect doRun() throws SameThreadException { |
| 857 | Log.i(TAG, "SipService.getAudioCodecList() thread running..."); |
| 858 | return configurationManagerJNI.getAudioCodecList(); |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | AudioCodecList runInstance = new AudioCodecList(); |
| 863 | getExecutor().execute(runInstance); |
| 864 | while (!runInstance.isDone()) { |
| 865 | Log.w(TAG, "Waiting for getAudioCodecList"); |
| 866 | } |
| 867 | IntVect swigmap = (IntVect) runInstance.getVal(); |
| 868 | |
| 869 | ArrayList<Integer> codecs = AudioHandler.convertSwigToNative(swigmap); |
| 870 | |
| 871 | return codecs; |
| 872 | } |
| 873 | |
Emeric Vigier | 6119d78 | 2012-09-21 18:04:14 -0400 | [diff] [blame] | 874 | }; |
Emeric Vigier | eaf2c49 | 2012-09-19 14:38:20 -0400 | [diff] [blame] | 875 | } |