Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 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 | */ |
| 31 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 32 | package org.sflphone.fragments; |
| 33 | |
| 34 | import android.content.BroadcastReceiver; |
| 35 | import android.content.Context; |
| 36 | import android.content.Intent; |
| 37 | import android.content.IntentFilter; |
| 38 | import android.os.Bundle; |
| 39 | import android.support.v4.app.Fragment; |
| 40 | import android.util.Log; |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 41 | import org.sflphone.interfaces.CallInterface; |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 42 | import org.sflphone.model.Conference; |
| 43 | import org.sflphone.model.SipCall; |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 44 | import org.sflphone.service.CallManagerCallBack; |
| 45 | |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 46 | public abstract class CallableWrapperFragment extends Fragment implements CallInterface { |
| 47 | |
| 48 | |
| 49 | private CallReceiver mReceiver; |
| 50 | |
| 51 | |
| 52 | @Override |
| 53 | public void onCreate(Bundle savedInstanceState) { |
| 54 | super.onCreate(savedInstanceState); |
| 55 | mReceiver = new CallReceiver(); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public void onResume() { |
Alexandre Lision | 48b49eb | 2014-02-11 13:37:33 -0500 | [diff] [blame] | 60 | super.onResume(); |
| 61 | IntentFilter intentFilter = new IntentFilter(); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 62 | intentFilter.addAction(CallManagerCallBack.INCOMING_CALL); |
| 63 | intentFilter.addAction(CallManagerCallBack.INCOMING_TEXT); |
| 64 | intentFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED); |
| 65 | intentFilter.addAction(CallManagerCallBack.CONF_CREATED); |
| 66 | intentFilter.addAction(CallManagerCallBack.CONF_REMOVED); |
| 67 | intentFilter.addAction(CallManagerCallBack.CONF_CHANGED); |
| 68 | intentFilter.addAction(CallManagerCallBack.RECORD_STATE_CHANGED); |
| 69 | intentFilter.addAction(CallManagerCallBack.ZRTP_OFF); |
| 70 | intentFilter.addAction(CallManagerCallBack.ZRTP_ON); |
| 71 | intentFilter.addAction(CallManagerCallBack.DISPLAY_SAS); |
| 72 | getActivity().registerReceiver(mReceiver, intentFilter); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | @Override |
| 77 | public void onPause() { |
| 78 | super.onPause(); |
| 79 | getActivity().unregisterReceiver(mReceiver); |
| 80 | } |
| 81 | |
| 82 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 83 | public void callStateChanged(Conference c, String callID, String state) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 84 | |
| 85 | } |
| 86 | |
| 87 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 88 | public void incomingText(Conference c, String ID, String from, String msg) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 89 | |
| 90 | } |
| 91 | |
| 92 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 93 | public void confCreated(Conference c, String id) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 94 | |
| 95 | } |
| 96 | |
| 97 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 98 | public void confRemoved(Conference c, String id) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 99 | |
| 100 | } |
| 101 | |
| 102 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 103 | public void confChanged(Conference c, String id, String state) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 104 | |
| 105 | } |
| 106 | |
| 107 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 108 | public void recordingChanged(Conference c, String callID, String filename) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 109 | |
| 110 | } |
| 111 | |
| 112 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 113 | public void secureZrtpOn(Conference c, String id) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 114 | |
| 115 | } |
| 116 | |
| 117 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 118 | public void secureZrtpOff(Conference c, String id) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 119 | |
| 120 | } |
| 121 | |
| 122 | @Override |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 123 | public void displaySAS(Conference c, String securedCallID) { |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 124 | |
| 125 | } |
| 126 | |
| 127 | public class CallReceiver extends BroadcastReceiver { |
| 128 | |
| 129 | private final String TAG = CallReceiver.class.getSimpleName(); |
| 130 | |
| 131 | @Override |
| 132 | public void onReceive(Context context, Intent intent) { |
| 133 | if (intent.getAction().contentEquals(CallManagerCallBack.INCOMING_TEXT)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 134 | incomingText((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("CallID"), intent.getStringExtra("From"), intent.getStringExtra("Msg")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 135 | } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 136 | callStateChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("CallID"), intent.getStringExtra("State")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 137 | } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CREATED)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 138 | confCreated((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 139 | } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_REMOVED)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 140 | confRemoved((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 141 | } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CHANGED)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 142 | confChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID"), intent.getStringExtra("state")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 143 | } else if (intent.getAction().contentEquals(CallManagerCallBack.RECORD_STATE_CHANGED)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 144 | recordingChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID"), intent.getStringExtra("file")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 145 | } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_OFF)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 146 | secureZrtpOff((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 147 | } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_ON)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 148 | secureZrtpOn((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 149 | } else if (intent.getAction().contentEquals(CallManagerCallBack.DISPLAY_SAS)) { |
Alexandre Lision | a7ab2e3 | 2014-02-14 15:33:33 -0500 | [diff] [blame] | 150 | displaySAS((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID")); |
Alexandre Lision | 5f144b8 | 2014-02-11 09:59:36 -0500 | [diff] [blame] | 151 | } else { |
| 152 | Log.e(TAG, "Unknown action: " + intent.getAction()); |
| 153 | } |
| 154 | |
| 155 | } |
| 156 | |
| 157 | } |
| 158 | |
| 159 | |
| 160 | } |