blob: 0dc3c736bcb528477563bee0ccfc786872954150 [file] [log] [blame]
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -05001/*
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 Lision5f144b82014-02-11 09:59:36 -050032package org.sflphone.fragments;
33
34import android.content.BroadcastReceiver;
35import android.content.Context;
36import android.content.Intent;
37import android.content.IntentFilter;
38import android.os.Bundle;
39import android.support.v4.app.Fragment;
40import android.util.Log;
Alexandre Lision5f144b82014-02-11 09:59:36 -050041import org.sflphone.interfaces.CallInterface;
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050042import org.sflphone.model.Conference;
43import org.sflphone.model.SipCall;
Alexandre Lision5f144b82014-02-11 09:59:36 -050044import org.sflphone.service.CallManagerCallBack;
45
Alexandre Lision5f144b82014-02-11 09:59:36 -050046public 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 Lision48b49eb2014-02-11 13:37:33 -050060 super.onResume();
61 IntentFilter intentFilter = new IntentFilter();
Alexandre Lision5f144b82014-02-11 09:59:36 -050062 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 Lisiona7ab2e32014-02-14 15:33:33 -050083 public void callStateChanged(Conference c, String callID, String state) {
Alexandre Lision5f144b82014-02-11 09:59:36 -050084
85 }
86
87 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050088 public void incomingText(Conference c, String ID, String from, String msg) {
Alexandre Lision5f144b82014-02-11 09:59:36 -050089
90 }
91
92 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050093 public void confCreated(Conference c, String id) {
Alexandre Lision5f144b82014-02-11 09:59:36 -050094
95 }
96
97 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -050098 public void confRemoved(Conference c, String id) {
Alexandre Lision5f144b82014-02-11 09:59:36 -050099
100 }
101
102 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500103 public void confChanged(Conference c, String id, String state) {
Alexandre Lision5f144b82014-02-11 09:59:36 -0500104
105 }
106
107 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500108 public void recordingChanged(Conference c, String callID, String filename) {
Alexandre Lision5f144b82014-02-11 09:59:36 -0500109
110 }
111
112 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500113 public void secureZrtpOn(Conference c, String id) {
Alexandre Lision5f144b82014-02-11 09:59:36 -0500114
115 }
116
117 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500118 public void secureZrtpOff(Conference c, String id) {
Alexandre Lision5f144b82014-02-11 09:59:36 -0500119
120 }
121
122 @Override
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500123 public void displaySAS(Conference c, String securedCallID) {
Alexandre Lision5f144b82014-02-11 09:59:36 -0500124
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 Lisiona7ab2e32014-02-14 15:33:33 -0500134 incomingText((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("CallID"), intent.getStringExtra("From"), intent.getStringExtra("Msg"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500135 } else if (intent.getAction().contentEquals(CallManagerCallBack.CALL_STATE_CHANGED)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500136 callStateChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("CallID"), intent.getStringExtra("State"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500137 } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CREATED)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500138 confCreated((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500139 } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_REMOVED)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500140 confRemoved((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500141 } else if (intent.getAction().contentEquals(CallManagerCallBack.CONF_CHANGED)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500142 confChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("confID"), intent.getStringExtra("state"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500143 } else if (intent.getAction().contentEquals(CallManagerCallBack.RECORD_STATE_CHANGED)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500144 recordingChanged((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID"), intent.getStringExtra("file"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500145 } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_OFF)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500146 secureZrtpOff((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500147 } else if (intent.getAction().contentEquals(CallManagerCallBack.ZRTP_ON)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500148 secureZrtpOn((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500149 } else if (intent.getAction().contentEquals(CallManagerCallBack.DISPLAY_SAS)) {
Alexandre Lisiona7ab2e32014-02-14 15:33:33 -0500150 displaySAS((Conference) intent.getParcelableExtra("conference"), intent.getStringExtra("callID"));
Alexandre Lision5f144b82014-02-11 09:59:36 -0500151 } else {
152 Log.e(TAG, "Unknown action: " + intent.getAction());
153 }
154
155 }
156
157 }
158
159
160}