blob: 77c157c3b76a23bf597b2e4aa55ab4270053fc94 [file] [log] [blame]
Alexandre Lision270c8752013-10-01 17:25:39 -04001/**
2 * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr)
Alexandre Lisionfed2a642014-01-10 12:05:47 -05003 * Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
Alexandre Lision270c8752013-10-01 17:25:39 -04004 *
5 * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 * If you own a pjsip commercial license you can also redistribute it
12 * and/or modify it under the terms of the GNU Lesser General Public License
13 * as an android library.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23package org.sflphone.service;
24
Alexandre Lision270c8752013-10-01 17:25:39 -040025import android.content.Intent;
Alexandre Lision270c8752013-10-01 17:25:39 -040026
27public class ConfigurationManagerCallback extends ConfigurationCallback {
Alexandre Lision48b49eb2014-02-11 13:37:33 -050028
Alexandre Lisionb4e60612014-01-14 17:47:23 -050029 private SipService mService;
Alexandre Lision270c8752013-10-01 17:25:39 -040030
Alexandre Lision270c8752013-10-01 17:25:39 -040031 static public final String ACCOUNTS_CHANGED = "accounts-changed";
32 static public final String ACCOUNT_STATE_CHANGED = "account-state-changed";
33
Alexandre Lisiona9ee4eb2014-01-15 16:20:35 -050034 public ConfigurationManagerCallback(SipService context) {
Alexandre Lisionb4e60612014-01-14 17:47:23 -050035 mService = context;
Alexandre Lision270c8752013-10-01 17:25:39 -040036 }
37
38 @Override
39 public void on_accounts_changed() {
40 sendAccountsChangedMessage();
41 }
42
43 @Override
44 public void on_account_state_changed(String accoundID, int state) {
45 String strState = "";
46 switch (state){
47 case 0:
48 strState = "UNREGISTERED";
49 break;
50 case 1:
51 strState = "TRYING";
52 break;
53 case 2:
54 strState = "REGISTERED";
55 break;
56 case 3:
57 strState = "ERROR_GENERIC";
58 break;
59 case 4:
60 strState = "ERROR_AUTH";
61 break;
62 case 5:
63 strState = "ERROR_NETWORK";
64 break;
65 case 6:
66 strState = "ERROR_HOST";
67 break;
68 case 7:
69 strState = "ERROR_EXIST_STUN";
70 break;
71 case 8:
72 strState = "ERROR_NOT_ACCEPTABLE";
73 break;
74 case 9:
75 strState = "NUMBER_OF_STATES";
76 break;
77 }
78
79
80 sendAccountsStateChangedMessage(accoundID, strState, 0);
81 }
82
83 @Override
84 public void on_account_state_changed_with_code(String accoundID, String state, int code) {
Alexandre Lision48cf8a72013-12-11 15:00:43 -050085// sendAccountsStateChangedMessage(accoundID, state, code);
Alexandre Lision270c8752013-10-01 17:25:39 -040086 }
87
88 private void sendAccountsStateChangedMessage(String accoundID, String state, int code) {
89 Intent intent = new Intent(ACCOUNT_STATE_CHANGED);
90 intent.putExtra("Account", accoundID);
91 intent.putExtra("state", state);
92 intent.putExtra("code", code);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050093 mService.sendBroadcast(intent);
Alexandre Lision270c8752013-10-01 17:25:39 -040094 }
95
96 private void sendAccountsChangedMessage() {
97 Intent intent = new Intent(ACCOUNTS_CHANGED);
Alexandre Lisionb4e60612014-01-14 17:47:23 -050098 mService.sendBroadcast(intent);
Alexandre Lision270c8752013-10-01 17:25:39 -040099 }
100
Alexandre Lision0d77a512014-01-31 16:17:09 -0500101 public IntVect get_hardware_audio_format(){
102 IntVect result = new IntVect();
103
104 OpenSlParams audioParams = OpenSlParams.createInstance(mService);
105 result.add(audioParams.getSampleRate());
106 result.add(audioParams.getBufferSize());
107
108 return result;
109 }
110
Alexandre Lision270c8752013-10-01 17:25:39 -0400111}