Reworked way of using core listener
This commit is contained in:
parent
34047d1885
commit
d227adbd1b
12 changed files with 140 additions and 367 deletions
|
@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
|
@ -277,11 +276,11 @@ public class BluetoothManager extends BroadcastReceiver {
|
||||||
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, 0);
|
int state = intent.getIntExtra(AudioManager.EXTRA_SCO_AUDIO_STATE, 0);
|
||||||
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
|
if (state == AudioManager.SCO_AUDIO_STATE_CONNECTED) {
|
||||||
Log.d("Bluetooth sco state => connected");
|
Log.d("Bluetooth sco state => connected");
|
||||||
LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
|
// LinphoneManager.getInstance().audioStateChanged(AudioState.BLUETOOTH);
|
||||||
isScoConnected = true;
|
isScoConnected = true;
|
||||||
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
|
} else if (state == AudioManager.SCO_AUDIO_STATE_DISCONNECTED) {
|
||||||
Log.d("Bluetooth sco state => disconnected");
|
Log.d("Bluetooth sco state => disconnected");
|
||||||
LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
|
// LinphoneManager.getInstance().audioStateChanged(AudioState.SPEAKER);
|
||||||
isScoConnected = false;
|
isScoConnected = false;
|
||||||
} else {
|
} else {
|
||||||
Log.d("Bluetooth sco state => " + state);
|
Log.d("Bluetooth sco state => " + state);
|
||||||
|
|
|
@ -33,13 +33,13 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.http.util.ByteArrayBuffer;
|
import org.apache.http.util.ByteArrayBuffer;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
import org.linphone.core.LinphoneChatMessage.State;
|
import org.linphone.core.LinphoneChatMessage.State;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneComposingListener;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import org.linphone.ui.BubbleChat;
|
import org.linphone.ui.BubbleChat;
|
||||||
|
@ -87,7 +87,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.StateListener, LinphoneOnComposingReceivedListener {
|
public class ChatFragment extends Fragment implements OnClickListener, LinphoneChatMessage.StateListener, LinphoneComposingListener {
|
||||||
private static final int ADD_PHOTO = 1337;
|
private static final int ADD_PHOTO = 1337;
|
||||||
private static final int MENU_DELETE_MESSAGE = 0;
|
private static final int MENU_DELETE_MESSAGE = 0;
|
||||||
private static final int MENU_SAVE_PICTURE = 1;
|
private static final int MENU_SAVE_PICTURE = 1;
|
||||||
|
@ -520,8 +520,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
|
|
||||||
LinphoneService.instance().removeMessageNotification();
|
LinphoneService.instance().removeMessageNotification();
|
||||||
|
|
||||||
if (LinphoneManager.isInstanciated())
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
LinphoneManager.getInstance().setOnComposingReceivedListener(null);
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
|
@ -535,11 +537,13 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
message.addTextChangedListener(textWatcher);
|
message.addTextChangedListener(textWatcher);
|
||||||
addVirtualKeyboardVisiblityListener();
|
addVirtualKeyboardVisiblityListener();
|
||||||
|
|
||||||
if (LinphoneManager.isInstanciated())
|
|
||||||
LinphoneManager.getInstance().setOnComposingReceivedListener(this);
|
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT);
|
LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHAT);
|
||||||
LinphoneActivity.instance().updateChatFragment(this);
|
LinphoneActivity.instance().updateChatFragment(this);
|
||||||
|
@ -671,7 +675,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMessageReceived(final int id, LinphoneAddress from, final LinphoneChatMessage message) {
|
public void onMessageReceived(LinphoneAddress from, final LinphoneChatMessage message) {
|
||||||
if (from.asStringUriOnly().equals(sipUri)) {
|
if (from.asStringUriOnly().equals(sipUri)) {
|
||||||
if (message.getText() != null) {
|
if (message.getText() != null) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
|
@ -1086,7 +1090,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComposingReceived(LinphoneChatRoom room) {
|
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom room) {
|
||||||
if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly().equals(room.getPeerAddress().asStringUriOnly())) {
|
if (chatRoom != null && room != null && chatRoom.getPeerAddress().asStringUriOnly().equals(room.getPeerAddress().asStringUriOnly())) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,8 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallEncryptionChangedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
|
@ -29,6 +27,8 @@ import org.linphone.core.LinphoneCallParams;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneCallEncryptionStateListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
||||||
import org.linphone.core.LinphonePlayer;
|
import org.linphone.core.LinphonePlayer;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
|
@ -70,10 +70,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class InCallActivity extends FragmentActivity implements
|
public class InCallActivity extends FragmentActivity implements LinphoneCallStateListener, LinphoneCallEncryptionStateListener, OnClickListener {
|
||||||
LinphoneOnCallStateChangedListener,
|
|
||||||
LinphoneOnCallEncryptionChangedListener,
|
|
||||||
OnClickListener {
|
|
||||||
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
|
private final static int SECONDS_BEFORE_HIDING_CONTROLS = 3000;
|
||||||
private final static int SECONDS_BEFORE_DENYING_CALL_UPDATE = 30000;
|
private final static int SECONDS_BEFORE_DENYING_CALL_UPDATE = 30000;
|
||||||
|
|
||||||
|
@ -1085,7 +1082,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(final LinphoneCall call, State state, String message) {
|
public void callState(LinphoneCore lc, final LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
if (LinphoneManager.getLc().getCallsNb() == 0) {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
|
@ -1209,7 +1206,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallEncryptionChanged(final LinphoneCall call, boolean encrypted, String authenticationToken) {
|
public void callEncryptionChanged(LinphoneCore lc, final LinphoneCall call, boolean encrypted, String authenticationToken) {
|
||||||
if (status != null) {
|
if (status != null) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1223,6 +1220,7 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
if (isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
displayVideoCallControlsIfHidden();
|
displayVideoCallControlsIfHidden();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1232,7 +1230,10 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
LinphoneManager.addListener(this);
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
refreshCallList(getResources());
|
refreshCallList(getResources());
|
||||||
|
|
||||||
|
@ -1273,6 +1274,11 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mControlsHandler != null && mControls != null) {
|
if (mControlsHandler != null && mControls != null) {
|
||||||
|
@ -1283,8 +1289,6 @@ public class InCallActivity extends FragmentActivity implements
|
||||||
if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
if (!isVideoEnabled(LinphoneManager.getLc().getCurrentCall())) {
|
||||||
LinphoneManager.stopProximitySensorForActivity(this);
|
LinphoneManager.stopProximitySensorForActivity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneManager.removeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,11 +20,12 @@ package org.linphone;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
import org.linphone.core.LinphoneCallParams;
|
||||||
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
import org.linphone.ui.LinphoneSliders;
|
import org.linphone.ui.LinphoneSliders;
|
||||||
|
@ -44,7 +45,7 @@ import android.widget.Toast;
|
||||||
*
|
*
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*/
|
*/
|
||||||
public class IncomingCallActivity extends Activity implements LinphoneOnCallStateChangedListener, LinphoneSliderTriggered {
|
public class IncomingCallActivity extends Activity implements LinphoneCallStateListener, LinphoneSliderTriggered {
|
||||||
|
|
||||||
private static IncomingCallActivity instance;
|
private static IncomingCallActivity instance;
|
||||||
|
|
||||||
|
@ -87,7 +88,10 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
instance = this;
|
instance = this;
|
||||||
LinphoneManager.addListener(this);
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
// Only one call ringing at a time is allowed
|
// Only one call ringing at a time is allowed
|
||||||
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
if (LinphoneManager.getLcIfManagerNotDestroyedOrNull() != null) {
|
||||||
|
@ -120,8 +124,11 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
LinphoneManager.removeListener(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -140,7 +147,7 @@ public class IncomingCallActivity extends Activity implements LinphoneOnCallStat
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(LinphoneCall call, State state, String msg) {
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (call == mCall && State.CallEnd == state) {
|
if (call == mCall && State.CallEnd == state) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,24 +27,25 @@ import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.linphone.LinphoneManager.AddressType;
|
import org.linphone.LinphoneManager.AddressType;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnCallStateChangedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.CallDirection;
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
|
||||||
import org.linphone.core.LinphoneCall.State;
|
import org.linphone.core.LinphoneCall.State;
|
||||||
import org.linphone.core.LinphoneCallLog;
|
import org.linphone.core.LinphoneCallLog;
|
||||||
import org.linphone.core.LinphoneCallLog.CallStatus;
|
import org.linphone.core.LinphoneCallLog.CallStatus;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneMessageListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.setup.RemoteProvisioningLoginActivity;
|
import org.linphone.setup.RemoteProvisioningLoginActivity;
|
||||||
import org.linphone.setup.SetupActivity;
|
import org.linphone.setup.SetupActivity;
|
||||||
|
@ -88,10 +89,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class LinphoneActivity extends FragmentActivity implements
|
public class LinphoneActivity extends FragmentActivity implements OnClickListener, ContactPicked, LinphoneCallStateListener, LinphoneMessageListener, LinphoneRegistrationStateListener {
|
||||||
OnClickListener, ContactPicked, LinphoneOnCallStateChangedListener,
|
|
||||||
LinphoneOnMessageReceivedListener,
|
|
||||||
LinphoneOnRegistrationStateChangedListener {
|
|
||||||
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
public static final String PREF_FIRST_LAUNCH = "pref_first_launch";
|
||||||
private static final int SETTINGS_ACTIVITY = 123;
|
private static final int SETTINGS_ACTIVITY = 123;
|
||||||
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
private static final int FIRST_LOGIN_ACTIVITY = 101;
|
||||||
|
@ -735,11 +733,11 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReceived(LinphoneAddress from, LinphoneChatMessage message, int id) {
|
public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
|
||||||
|
LinphoneAddress from = cr.getPeerAddress();
|
||||||
ChatFragment chatFragment = ((ChatFragment) messageListenerFragment);
|
ChatFragment chatFragment = ((ChatFragment) messageListenerFragment);
|
||||||
if (messageListenerFragment != null && messageListenerFragment.isVisible() && chatFragment.getSipUri().equals(from.asStringUriOnly())) {
|
if (messageListenerFragment != null && messageListenerFragment.isVisible() && chatFragment.getSipUri().equals(from.asStringUriOnly())) {
|
||||||
chatFragment.onMessageReceived(id, from, message);
|
chatFragment.onMessageReceived(from, message);
|
||||||
getChatStorage().markMessageAsRead(id);
|
|
||||||
} else if (LinphoneService.isReady()) {
|
} else if (LinphoneService.isReady()) {
|
||||||
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
displayMissedChats(getChatStorage().getUnreadMessageCount());
|
||||||
if (messageListFragment != null && messageListFragment.isVisible()) {
|
if (messageListFragment != null && messageListFragment.isVisible()) {
|
||||||
|
@ -770,8 +768,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
getChatStorage().updateMessageStatus(to, id, newState);
|
getChatStorage().updateMessageStatus(to, id, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message) {
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
|
||||||
if (statusFragment != null) {
|
if (statusFragment != null) {
|
||||||
if (lc != null)
|
if (lc != null)
|
||||||
if(lc.getDefaultProxyConfig() == null)
|
if(lc.getDefaultProxyConfig() == null)
|
||||||
|
@ -833,7 +830,7 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCallStateChanged(LinphoneCall call, State state, String message) {
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (state == State.IncomingReceived) {
|
if (state == State.IncomingReceived) {
|
||||||
startActivity(new Intent(this, IncomingCallActivity.class));
|
startActivity(new Intent(this, IncomingCallActivity.class));
|
||||||
} else if (state == State.OutgoingInit) {
|
} else if (state == State.OutgoingInit) {
|
||||||
|
@ -1266,6 +1263,11 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
getIntent().putExtra("PreviousActivity", 0);
|
getIntent().putExtra("PreviousActivity", 0);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
@ -1278,9 +1280,10 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
startService(new Intent(ACTION_MAIN).setClass(this, LinphoneService.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove to avoid duplication of the listeners
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
LinphoneManager.removeListener(this);
|
if (lc != null) {
|
||||||
LinphoneManager.addListener(this);
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
prepareContactsInBackground();
|
prepareContactsInBackground();
|
||||||
|
|
||||||
|
@ -1310,8 +1313,6 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
LinphoneManager.removeListener(this);
|
|
||||||
|
|
||||||
if (mOrientationHelper != null) {
|
if (mOrientationHelper != null) {
|
||||||
mOrientationHelper.disable();
|
mOrientationHelper.disable();
|
||||||
mOrientationHelper = null;
|
mOrientationHelper = null;
|
||||||
|
|
|
@ -28,22 +28,11 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.ConnectivityChangedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnAudioChangedListener.AudioState;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnNotifyReceivedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnComposingReceivedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnDTMFReceivedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnMessageReceivedListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.CallDirection;
|
import org.linphone.core.CallDirection;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
|
@ -63,6 +52,7 @@ import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreFactoryImpl;
|
import org.linphone.core.LinphoneCoreFactoryImpl;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneListener;
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneFriend;
|
import org.linphone.core.LinphoneFriend;
|
||||||
import org.linphone.core.LinphoneInfoMessage;
|
import org.linphone.core.LinphoneInfoMessage;
|
||||||
|
@ -78,7 +68,6 @@ import org.linphone.mediastream.Version;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration.AndroidCamera;
|
||||||
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
import org.linphone.mediastream.video.capture.hwconf.Hacks;
|
||||||
import org.linphone.setup.RemoteProvisioningActivity;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
|
@ -128,7 +117,7 @@ import android.widget.Toast;
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LinphoneManager implements LinphoneCoreListener {
|
public class LinphoneManager implements LinphoneListener {
|
||||||
|
|
||||||
private static LinphoneManager instance;
|
private static LinphoneManager instance;
|
||||||
private Context mServiceContext;
|
private Context mServiceContext;
|
||||||
|
@ -148,20 +137,9 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
public String wizardLoginViewDomain = null;
|
public String wizardLoginViewDomain = null;
|
||||||
|
|
||||||
private static List<LinphoneSimpleListener> simpleListeners = new ArrayList<LinphoneSimpleListener>();
|
protected LinphoneManager(final Context c) {
|
||||||
public static void addListener(LinphoneSimpleListener listener) {
|
|
||||||
if (!simpleListeners.contains(listener)) {
|
|
||||||
simpleListeners.add(listener);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static void removeListener(LinphoneSimpleListener listener) {
|
|
||||||
simpleListeners.remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LinphoneManager(final Context c, LinphoneServiceListener listener) {
|
|
||||||
sExited=false;
|
sExited=false;
|
||||||
mServiceContext = c;
|
mServiceContext = c;
|
||||||
mListenerDispatcher = new ListenerDispatcher(listener);
|
|
||||||
basePath = c.getFilesDir().getAbsolutePath();
|
basePath = c.getFilesDir().getAbsolutePath();
|
||||||
mLPConfigXsd = basePath + "/lpconfig.xsd";
|
mLPConfigXsd = basePath + "/lpconfig.xsd";
|
||||||
mLinphoneFactoryConfigFile = basePath + "/linphonerc";
|
mLinphoneFactoryConfigFile = basePath + "/linphonerc";
|
||||||
|
@ -203,13 +181,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
BluetoothManager.getInstance().disableBluetoothSCO();
|
BluetoothManager.getInstance().disableBluetoothSCO();
|
||||||
|
|
||||||
mLc.enableSpeaker(speakerOn);
|
mLc.enableSpeaker(speakerOn);
|
||||||
audioStateChanged(speakerOn ? AudioState.SPEAKER : AudioState.EARPIECE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void audioStateChanged(AudioState state) {
|
|
||||||
for (LinphoneOnAudioChangedListener listener : getSimpleListeners(LinphoneOnAudioChangedListener.class)) {
|
|
||||||
listener.onAudioStateChanged(state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void routeAudioToSpeaker() {
|
public void routeAudioToSpeaker() {
|
||||||
|
@ -230,11 +201,11 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
routeAudioToSpeakerHelper(false);
|
routeAudioToSpeakerHelper(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static final LinphoneManager createAndStart(Context c, LinphoneServiceListener listener) {
|
public synchronized static final LinphoneManager createAndStart(Context c) {
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
throw new RuntimeException("Linphone Manager is already initialized");
|
throw new RuntimeException("Linphone Manager is already initialized");
|
||||||
|
|
||||||
instance = new LinphoneManager(c, listener);
|
instance = new LinphoneManager(c);
|
||||||
instance.startLibLinphone(c);
|
instance.startLibLinphone(c);
|
||||||
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) c.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
boolean gsmIdle = tm.getCallState() == TelephonyManager.CALL_STATE_IDLE;
|
||||||
|
@ -315,11 +286,9 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
LinphoneProxyConfig lpc = mLc.getDefaultProxyConfig();
|
LinphoneProxyConfig lpc = mLc.getDefaultProxyConfig();
|
||||||
|
|
||||||
if (mR.getBoolean(R.bool.forbid_self_call) && lpc!=null && lAddress.asStringUriOnly().equals(lpc.getIdentity())) {
|
if (mR.getBoolean(R.bool.forbid_self_call) && lpc!=null && lAddress.asStringUriOnly().equals(lpc.getIdentity())) {
|
||||||
mListenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
mListenerDispatcher.tryingNewOutgoingCallButWrongDestinationAddress();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lAddress.setDisplayName(displayName);
|
lAddress.setDisplayName(displayName);
|
||||||
|
@ -338,7 +307,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
|
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
mListenerDispatcher.tryingNewOutgoingCallButCannotGetCallParameters();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (LinphoneActivity.isInstanciated()) {
|
} else if (LinphoneActivity.isInstanciated()) {
|
||||||
|
@ -475,6 +443,7 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
LinphoneCoreFactory.instance().setDebugMode(isDebugLogEnabled, getString(R.string.app_name));
|
||||||
|
|
||||||
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneFactoryConfigFile, null, c);
|
mLc = LinphoneCoreFactory.instance().createLinphoneCore(this, mLinphoneConfigFile, mLinphoneFactoryConfigFile, null, c);
|
||||||
|
mLc.addListener((LinphoneCoreListener) c);
|
||||||
//initLiblinphone();
|
//initLiblinphone();
|
||||||
|
|
||||||
TimerTask lTask = new TimerTask() {
|
TimerTask lTask = new TimerTask() {
|
||||||
|
@ -683,24 +652,13 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
I/Linphone( 8397): WIFI connected: setting network reachable
|
I/Linphone( 8397): WIFI connected: setting network reachable
|
||||||
*/
|
*/
|
||||||
public void connectivityChanged(ConnectivityManager cm, boolean noConnectivity) {
|
public void connectivityChanged(ConnectivityManager cm, boolean noConnectivity) {
|
||||||
NetworkInfo eventInfo = cm.getActiveNetworkInfo();
|
|
||||||
updateNetworkReachability();
|
updateNetworkReachability();
|
||||||
|
|
||||||
if (connectivityListener != null) {
|
|
||||||
connectivityListener.onConnectivityChanged(mServiceContext, eventInfo, cm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConnectivityChangedListener connectivityListener;
|
|
||||||
public void addConnectivityChangedListener(ConnectivityChangedListener l) {
|
|
||||||
connectivityListener = l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface EcCalibrationListener {
|
public interface EcCalibrationListener {
|
||||||
void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs);
|
void onEcCalibrationStatus(EcCalibratorStatus status, int delayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ListenerDispatcher mListenerDispatcher;
|
|
||||||
private LinphoneCall ringingCall;
|
private LinphoneCall ringingCall;
|
||||||
|
|
||||||
private MediaPlayer mRingerPlayer;
|
private MediaPlayer mRingerPlayer;
|
||||||
|
@ -713,15 +671,9 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
public void show(LinphoneCore lc) {}
|
public void show(LinphoneCore lc) {}
|
||||||
|
|
||||||
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {
|
public void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url) {
|
||||||
for (LinphoneSimpleListener listener : getSimpleListeners(LinphoneActivity.class)) {
|
|
||||||
((LinphoneActivity) listener).onNewSubscriptionRequestReceived(lf, url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
public void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf) {
|
||||||
for (LinphoneSimpleListener listener : getSimpleListeners(LinphoneActivity.class)) {
|
|
||||||
((LinphoneActivity) listener).onNotifyPresenceReceived(lf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,
|
public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,
|
||||||
|
@ -732,13 +684,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
@Override
|
@Override
|
||||||
public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {
|
public void dtmfReceived(LinphoneCore lc, LinphoneCall call, int dtmf) {
|
||||||
Log.d("DTMF received: " + dtmf);
|
Log.d("DTMF received: " + dtmf);
|
||||||
if (dtmfReceivedListener != null)
|
|
||||||
dtmfReceivedListener.onDTMFReceived(call, dtmf);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LinphoneOnDTMFReceivedListener dtmfReceivedListener;
|
|
||||||
public void setOnDTMFReceivedListener(LinphoneOnDTMFReceivedListener listener) {
|
|
||||||
dtmfReceivedListener = listener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -751,12 +696,10 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
|
|
||||||
String textMessage = message.getText();
|
String textMessage = message.getText();
|
||||||
String url = message.getExternalBodyUrl();
|
String url = message.getExternalBodyUrl();
|
||||||
int id = -1;
|
|
||||||
if (textMessage != null && textMessage.length() > 0) {
|
if (textMessage != null && textMessage.length() > 0) {
|
||||||
id = ChatStorage.getInstance().saveTextMessage(from.asStringUriOnly(), "", textMessage, message.getTime());
|
ChatStorage.getInstance().saveTextMessage(from.asStringUriOnly(), "", textMessage, message.getTime());
|
||||||
} else if (url != null && url.length() > 0) {
|
} else if (url != null && url.length() > 0) {
|
||||||
//Bitmap bm = ChatFragment.downloadImage(url);
|
ChatStorage.getInstance().saveImageMessage(from.asStringUriOnly(), "", null, message.getExternalBodyUrl(), message.getTime());
|
||||||
id = ChatStorage.getInstance().saveImageMessage(from.asStringUriOnly(), "", null, message.getExternalBodyUrl(), message.getTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -765,10 +708,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getDisplayName(), textMessage);
|
LinphoneService.instance().displayMessageNotification(from.asStringUriOnly(), from.getDisplayName(), textMessage);
|
||||||
}
|
}
|
||||||
} catch (Exception e) { }
|
} catch (Exception e) { }
|
||||||
|
|
||||||
for (LinphoneSimpleListener listener : getSimpleListeners(LinphoneOnMessageReceivedListener.class)) {
|
|
||||||
((LinphoneOnMessageReceivedListener) listener).onMessageReceived(from, message, id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLastLcStatusMessage() {
|
public String getLastLcStatusMessage() {
|
||||||
|
@ -778,7 +717,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
public void displayStatus(final LinphoneCore lc, final String message) {
|
public void displayStatus(final LinphoneCore lc, final String message) {
|
||||||
Log.i(message);
|
Log.i(message);
|
||||||
lastLcStatusMessage=message;
|
lastLcStatusMessage=message;
|
||||||
mListenerDispatcher.onDisplayStatus(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void globalState(final LinphoneCore lc, final GlobalState state, final String message) {
|
public void globalState(final LinphoneCore lc, final GlobalState state, final String message) {
|
||||||
|
@ -798,13 +736,10 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mListenerDispatcher.onGlobalStateChanged(state, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig proxy,final RegistrationState state,final String message) {
|
public void registrationState(final LinphoneCore lc, final LinphoneProxyConfig proxy,final RegistrationState state,final String message) {
|
||||||
Log.i("new state ["+state+"]");
|
Log.i("new state ["+state+"]");
|
||||||
mListenerDispatcher.onRegistrationStateChanged(proxy, state, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int savedMaxCallWhileGsmIncall;
|
private int savedMaxCallWhileGsmIncall;
|
||||||
|
@ -954,14 +889,12 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
Log.i("New call active while incall (CPU only) wake lock already active");
|
Log.i("New call active while incall (CPU only) wake lock already active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mListenerDispatcher.onCallStateChanged(call, state, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callStatsUpdated(final LinphoneCore lc, final LinphoneCall call, final LinphoneCallStats stats) {}
|
public void callStatsUpdated(final LinphoneCore lc, final LinphoneCall call, final LinphoneCallStats stats) {}
|
||||||
|
|
||||||
public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,
|
public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,
|
||||||
boolean encrypted, String authenticationToken) {
|
boolean encrypted, String authenticationToken) {
|
||||||
mListenerDispatcher.onCallEncryptionChanged(call, encrypted, authenticationToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ecCalibrationStatus(final LinphoneCore lc,final EcCalibratorStatus status, final int delayMs,
|
public void ecCalibrationStatus(final LinphoneCore lc,final EcCalibratorStatus status, final int delayMs,
|
||||||
|
@ -1246,73 +1179,6 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
return getLc();
|
return getLc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
private <T> List<T> getSimpleListeners(Class<T> clazz) {
|
|
||||||
List<T> list = new ArrayList<T>();
|
|
||||||
for (LinphoneSimpleListener l : simpleListeners) {
|
|
||||||
if (clazz.isInstance(l)) list.add((T) l);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ListenerDispatcher implements LinphoneServiceListener {
|
|
||||||
private LinphoneServiceListener serviceListener;
|
|
||||||
|
|
||||||
public ListenerDispatcher(LinphoneServiceListener listener) {
|
|
||||||
this.serviceListener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCallEncryptionChanged(LinphoneCall call,
|
|
||||||
boolean encrypted, String authenticationToken) {
|
|
||||||
if (serviceListener != null) {
|
|
||||||
serviceListener.onCallEncryptionChanged(call, encrypted, authenticationToken);
|
|
||||||
}
|
|
||||||
for (LinphoneOnCallEncryptionChangedListener l : getSimpleListeners(LinphoneOnCallEncryptionChangedListener.class)) {
|
|
||||||
l.onCallEncryptionChanged(call, encrypted, authenticationToken);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCallStateChanged(LinphoneCall call, State state, String message) {
|
|
||||||
if (state == State.OutgoingInit || state == State.IncomingReceived) {
|
|
||||||
boolean sendCamera = mLc.getConferenceSize() == 0;
|
|
||||||
enableCamera(call, sendCamera);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceListener != null) serviceListener.onCallStateChanged(call, state, message);
|
|
||||||
for (LinphoneOnCallStateChangedListener l : getSimpleListeners(LinphoneOnCallStateChangedListener.class)) {
|
|
||||||
l.onCallStateChanged(call, state, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onDisplayStatus(String message) {
|
|
||||||
if (serviceListener != null) serviceListener.onDisplayStatus(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onGlobalStateChanged(GlobalState state, String message) {
|
|
||||||
if (serviceListener != null) serviceListener.onGlobalStateChanged( state, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state,
|
|
||||||
String message) {
|
|
||||||
if (serviceListener != null) serviceListener.onRegistrationStateChanged(proxy, state, message);
|
|
||||||
for (LinphoneOnRegistrationStateChangedListener listener : getSimpleListeners(LinphoneOnRegistrationStateChangedListener.class)) {
|
|
||||||
listener.onRegistrationStateChanged(proxy, state, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButAlreadyInCall() {
|
|
||||||
if (serviceListener != null) serviceListener.tryingNewOutgoingCallButAlreadyInCall();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButCannotGetCallParameters() {
|
|
||||||
if (serviceListener != null) serviceListener.tryingNewOutgoingCallButCannotGetCallParameters();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryingNewOutgoingCallButWrongDestinationAddress() {
|
|
||||||
if (serviceListener != null) serviceListener.tryingNewOutgoingCallButWrongDestinationAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final boolean isInstanciated() {
|
public static final boolean isInstanciated() {
|
||||||
return instance != null;
|
return instance != null;
|
||||||
}
|
}
|
||||||
|
@ -1374,17 +1240,11 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
Log.d("Subscription state changed to "+state+" event name is "+ev.getEventName());
|
Log.d("Subscription state changed to "+state+" event name is "+ev.getEventName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphoneOnNotifyReceivedListener notifyReceivedListener;
|
|
||||||
public void setNotifyReceivedListener(LinphoneOnNotifyReceivedListener listener) {
|
|
||||||
notifyReceivedListener = listener;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev,
|
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev,
|
||||||
String eventName, LinphoneContent content) {
|
String eventName, LinphoneContent content) {
|
||||||
Log.d("Notify received for event "+eventName);
|
Log.d("Notify received for event "+eventName);
|
||||||
if (content!=null) Log.d("with content "+content.getType()+"/"+content.getSubtype()+" data:"+content.getDataAsString());
|
if (content!=null) Log.d("with content "+content.getType()+"/"+content.getSubtype()+" data:"+content.getDataAsString());
|
||||||
if (notifyReceivedListener != null)
|
|
||||||
notifyReceivedListener.onNotifyReceived(ev,eventName,content);
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
|
public void publishStateChanged(LinphoneCore lc, LinphoneEvent ev,
|
||||||
|
@ -1392,32 +1252,15 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
Log.d("Publish state changed to " + state + " for event name " + ev.getEventName());
|
Log.d("Publish state changed to " + state + " for event name " + ev.getEventName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphoneOnComposingReceivedListener composingReceivedListener;
|
|
||||||
public void setOnComposingReceivedListener(LinphoneOnComposingReceivedListener listener) {
|
|
||||||
composingReceivedListener = listener;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr) {
|
public void isComposingReceived(LinphoneCore lc, LinphoneChatRoom cr) {
|
||||||
Log.d("Composing received for chatroom " + cr.getPeerAddress().asStringUriOnly());
|
Log.d("Composing received for chatroom " + cr.getPeerAddress().asStringUriOnly());
|
||||||
if (composingReceivedListener != null)
|
|
||||||
composingReceivedListener.onComposingReceived(cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LinphoneOnRemoteProvisioningListener remoteProvisioningListener;
|
|
||||||
public void setOnRemoteProvisioningListener(LinphoneOnRemoteProvisioningListener listener) {
|
|
||||||
remoteProvisioningListener = listener;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void configuringStatus(LinphoneCore lc,
|
public void configuringStatus(LinphoneCore lc,
|
||||||
RemoteProvisioningState state, String message) {
|
RemoteProvisioningState state, String message) {
|
||||||
Log.d("Remote provisioning status = " + state.toString() + " (" + message + ")");
|
Log.d("Remote provisioning status = " + state.toString() + " (" + message + ")");
|
||||||
if (RemoteProvisioningActivity.getInstance() != null) {
|
|
||||||
RemoteProvisioningActivity.getInstance().onConfiguringStatus(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (remoteProvisioningListener != null) {
|
|
||||||
remoteProvisioningListener.onConfiguringStatus(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
if (state == RemoteProvisioningState.ConfiguringSuccessful) {
|
||||||
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
|
if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.linphone;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneServiceListener;
|
|
||||||
import org.linphone.compatibility.Compatibility;
|
import org.linphone.compatibility.Compatibility;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
|
@ -31,6 +30,9 @@ import org.linphone.core.LinphoneCore.GlobalState;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactoryImpl;
|
import org.linphone.core.LinphoneCoreFactoryImpl;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneCallStateListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneGlobalStateListener;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneRegistrationStateListener;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
@ -71,7 +73,8 @@ import android.provider.MediaStore;
|
||||||
* @author Guillaume Beraudo
|
* @author Guillaume Beraudo
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class LinphoneService extends Service implements LinphoneServiceListener {
|
public final class LinphoneService extends Service implements LinphoneCallStateListener,
|
||||||
|
LinphoneGlobalStateListener, LinphoneRegistrationStateListener {
|
||||||
/* Listener needs to be implemented in the Service as it calls
|
/* Listener needs to be implemented in the Service as it calls
|
||||||
* setLatestEventInfo and startActivity() which needs a context.
|
* setLatestEventInfo and startActivity() which needs a context.
|
||||||
*/
|
*/
|
||||||
|
@ -156,7 +159,7 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
UIThreadDispatcher.Dispatch(new Runnable() {
|
UIThreadDispatcher.Dispatch(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
LinphoneManager.createAndStart(LinphoneService.this, LinphoneService.this);
|
LinphoneManager.createAndStart(LinphoneService.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -483,6 +486,11 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onDestroy() {
|
public synchronized void onDestroy() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
LinphoneManager.destroy();
|
LinphoneManager.destroy();
|
||||||
|
|
||||||
|
@ -498,17 +506,15 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisplayStatus(final String message) {
|
@Override
|
||||||
}
|
public void globalState(LinphoneCore lc,LinphoneCore.GlobalState state, String message) {
|
||||||
|
|
||||||
public void onGlobalStateChanged(final GlobalState state, final String message) {
|
|
||||||
if (state == GlobalState.GlobalOn) {
|
if (state == GlobalState.GlobalOn) {
|
||||||
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onRegistrationStateChanged(final LinphoneProxyConfig proxy, final RegistrationState state,
|
@Override
|
||||||
final String message) {
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
// if (instance == null) {
|
// if (instance == null) {
|
||||||
// Log.i("Service not ready, discarding registration state change to ",state.toString());
|
// Log.i("Service not ready, discarding registration state change to ",state.toString());
|
||||||
// return;
|
// return;
|
||||||
|
@ -526,14 +532,6 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
sendNotification(IC_LEVEL_OFFLINE, R.string.notification_started);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mHandler.post(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
|
||||||
LinphoneActivity.instance().onRegistrationStateChanged(proxy,state,message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActivityToLaunchOnIncomingReceived(Class<? extends Activity> activity) {
|
public void setActivityToLaunchOnIncomingReceived(Class<? extends Activity> activity) {
|
||||||
|
@ -558,7 +556,8 @@ public final class LinphoneService extends Service implements LinphoneServiceLis
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCallStateChanged(final LinphoneCall call, final State state, final String message) {
|
@Override
|
||||||
|
public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
Log.i("Service not ready, discarding call state change to ",state.toString());
|
Log.i("Service not ready, discarding call state change to ",state.toString());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
/*
|
|
||||||
LinphoneServiceListener.java
|
|
||||||
Copyright (C) 2011 Belledonne Communications, Grenoble, France
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
package org.linphone;
|
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAddress;
|
|
||||||
import org.linphone.core.LinphoneCall;
|
|
||||||
import org.linphone.core.LinphoneContent;
|
|
||||||
import org.linphone.core.LinphoneEvent;
|
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
|
||||||
import org.linphone.core.LinphoneCall.State;
|
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
|
||||||
import org.linphone.core.LinphoneCore.GlobalState;
|
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
|
||||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.ConnectivityManager;
|
|
||||||
import android.net.NetworkInfo;
|
|
||||||
|
|
||||||
public interface LinphoneSimpleListener {
|
|
||||||
|
|
||||||
public static interface LinphoneServiceListener extends
|
|
||||||
LinphoneOnGlobalStateChangedListener,
|
|
||||||
LinphoneOnCallStateChangedListener,
|
|
||||||
LinphoneOnCallEncryptionChangedListener
|
|
||||||
{
|
|
||||||
void tryingNewOutgoingCallButCannotGetCallParameters();
|
|
||||||
void tryingNewOutgoingCallButWrongDestinationAddress();
|
|
||||||
void tryingNewOutgoingCallButAlreadyInCall();
|
|
||||||
void onDisplayStatus(String message);
|
|
||||||
void onRegistrationStateChanged(LinphoneProxyConfig proxy,RegistrationState state, String message);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static interface LinphoneOnCallEncryptionChangedListener extends LinphoneSimpleListener {
|
|
||||||
void onCallEncryptionChanged(LinphoneCall call, boolean encrypted, String authenticationToken);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnGlobalStateChangedListener extends LinphoneSimpleListener {
|
|
||||||
void onGlobalStateChanged(GlobalState state, String message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnCallStateChangedListener extends LinphoneSimpleListener {
|
|
||||||
void onCallStateChanged(LinphoneCall call, State state, String message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnAudioChangedListener extends LinphoneSimpleListener {
|
|
||||||
public enum AudioState {EARPIECE, SPEAKER, BLUETOOTH}
|
|
||||||
void onAudioStateChanged(AudioState state);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnMessageReceivedListener extends LinphoneSimpleListener {
|
|
||||||
void onMessageReceived(LinphoneAddress from, LinphoneChatMessage message, int id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnRegistrationStateChangedListener extends LinphoneSimpleListener {
|
|
||||||
void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface ConnectivityChangedListener extends LinphoneSimpleListener {
|
|
||||||
void onConnectivityChanged(Context context, NetworkInfo eventInfo, ConnectivityManager cm);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface LinphoneOnDTMFReceivedListener extends LinphoneSimpleListener {
|
|
||||||
void onDTMFReceived(LinphoneCall call, int dtmf);
|
|
||||||
}
|
|
||||||
public static interface LinphoneOnNotifyReceivedListener extends LinphoneSimpleListener {
|
|
||||||
void onNotifyReceived(LinphoneEvent ev,String eventName, LinphoneContent content);
|
|
||||||
}
|
|
||||||
public static interface LinphoneOnComposingReceivedListener extends LinphoneSimpleListener {
|
|
||||||
void onComposingReceived(LinphoneChatRoom room);
|
|
||||||
}
|
|
||||||
public static interface LinphoneOnRemoteProvisioningListener extends LinphoneSimpleListener {
|
|
||||||
void onConfiguringStatus(RemoteProvisioningState state);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,6 @@ import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnNotifyReceivedListener;
|
|
||||||
import org.linphone.core.LinphoneCall;
|
import org.linphone.core.LinphoneCall;
|
||||||
import org.linphone.core.LinphoneCallParams;
|
import org.linphone.core.LinphoneCallParams;
|
||||||
import org.linphone.core.LinphoneCallStats;
|
import org.linphone.core.LinphoneCallStats;
|
||||||
|
@ -30,6 +29,7 @@ import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.MediaEncryption;
|
import org.linphone.core.LinphoneCore.MediaEncryption;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneNotifyListener;
|
||||||
import org.linphone.core.LinphoneEvent;
|
import org.linphone.core.LinphoneEvent;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.PayloadType;
|
import org.linphone.core.PayloadType;
|
||||||
|
@ -45,7 +45,6 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -59,7 +58,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class StatusFragment extends Fragment implements LinphoneOnNotifyReceivedListener {
|
public class StatusFragment extends Fragment implements LinphoneNotifyListener {
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private Handler refreshHandler = new Handler();
|
private Handler refreshHandler = new Handler();
|
||||||
private TextView statusText, exit, voicemailCount;
|
private TextView statusText, exit, voicemailCount;
|
||||||
|
@ -99,13 +98,12 @@ public class StatusFragment extends Fragment implements LinphoneOnNotifyReceived
|
||||||
voicemailCount = (TextView) view.findViewById(R.id.voicemailCount);
|
voicemailCount = (TextView) view.findViewById(R.id.voicemailCount);
|
||||||
|
|
||||||
exit = (TextView) view.findViewById(R.id.exit);
|
exit = (TextView) view.findViewById(R.id.exit);
|
||||||
exit.setOnTouchListener(new View.OnTouchListener() {
|
exit.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public void onClick(View v) {
|
||||||
if (LinphoneActivity.isInstanciated()) {
|
if (LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().exit();
|
LinphoneActivity.instance().exit();
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getResources().getBoolean(R.bool.exit_button_on_dialer))
|
if (getResources().getBoolean(R.bool.exit_button_on_dialer))
|
||||||
|
@ -327,7 +325,10 @@ public class StatusFragment extends Fragment implements LinphoneOnNotifyReceived
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
LinphoneCore lc = LinphoneManager.getLc();
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
LinphoneCall call = lc.getCurrentCall();
|
LinphoneCall call = lc.getCurrentCall();
|
||||||
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
if (isInCall && (call != null || lc.getConferenceSize() > 1 || lc.getCallsNb() > 0)) {
|
||||||
|
@ -360,6 +361,11 @@ public class StatusFragment extends Fragment implements LinphoneOnNotifyReceived
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (mCallQualityUpdater != null) {
|
if (mCallQualityUpdater != null) {
|
||||||
|
@ -628,8 +634,7 @@ public class StatusFragment extends Fragment implements LinphoneOnNotifyReceived
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNotifyReceived(LinphoneEvent ev, String eventName,
|
public void notifyReceived(LinphoneCore lc, LinphoneEvent ev, String eventName, LinphoneContent content) {
|
||||||
LinphoneContent content) {
|
|
||||||
|
|
||||||
if(!content.getType().equals("application")) return;
|
if(!content.getType().equals("application")) return;
|
||||||
if(!content.getSubtype().equals("imple-message-summary")) return;
|
if(!content.getSubtype().equals("imple-message-summary")) return;
|
||||||
|
|
|
@ -25,9 +25,10 @@ import org.linphone.LinphoneLauncherActivity;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphoneService;
|
import org.linphone.LinphoneService;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRemoteProvisioningListener;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
import org.linphone.core.LinphoneCore.RemoteProvisioningState;
|
||||||
|
import org.linphone.core.LinphoneCoreListener.LinphoneRemoteProvisioningListener;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -44,17 +45,11 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class RemoteProvisioningActivity extends Activity implements LinphoneOnRemoteProvisioningListener {
|
public class RemoteProvisioningActivity extends Activity implements LinphoneRemoteProvisioningListener {
|
||||||
private static RemoteProvisioningActivity instance = null;
|
|
||||||
|
|
||||||
private Handler mHandler = new Handler();
|
private Handler mHandler = new Handler();
|
||||||
private String configUriParam = null;
|
private String configUriParam = null;
|
||||||
private ProgressBar spinner;
|
private ProgressBar spinner;
|
||||||
|
|
||||||
public static RemoteProvisioningActivity getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -65,7 +60,10 @@ public class RemoteProvisioningActivity extends Activity implements LinphoneOnRe
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
instance = this;
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
LinphonePreferences.instance().setContext(this);
|
LinphonePreferences.instance().setContext(this);
|
||||||
|
|
||||||
checkIntentForConfigUri(getIntent());
|
checkIntentForConfigUri(getIntent());
|
||||||
|
@ -73,12 +71,15 @@ public class RemoteProvisioningActivity extends Activity implements LinphoneOnRe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
instance = null;
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.removeListener(this);
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfiguringStatus(final RemoteProvisioningState state) {
|
public void configuringStatus(LinphoneCore lc, final RemoteProvisioningState state, String message) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -20,11 +20,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.LinphonePreferences;
|
import org.linphone.LinphonePreferences;
|
||||||
import org.linphone.LinphonePreferences.AccountBuilder;
|
import org.linphone.LinphonePreferences.AccountBuilder;
|
||||||
import org.linphone.LinphoneSimpleListener.LinphoneOnRegistrationStateChangedListener;
|
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneAddress.TransportType;
|
import org.linphone.core.LinphoneAddress.TransportType;
|
||||||
import org.linphone.core.LinphoneCore.RegistrationState;
|
import org.linphone.core.LinphoneCore.RegistrationState;
|
||||||
|
import org.linphone.core.LinphoneCore;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -44,7 +45,7 @@ import android.widget.Toast;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
public class SetupActivity extends FragmentActivity implements OnClickListener {
|
public class SetupActivity extends FragmentActivity implements OnClickListener, LinphoneCoreListener {
|
||||||
private static SetupActivity instance;
|
private static SetupActivity instance;
|
||||||
private RelativeLayout back, next, cancel;
|
private RelativeLayout back, next, cancel;
|
||||||
private SetupFragmentsEnum currentFragment;
|
private SetupFragmentsEnum currentFragment;
|
||||||
|
@ -200,11 +201,9 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, LinphoneCore.RegistrationState state, String smessage) {
|
||||||
private LinphoneOnRegistrationStateChangedListener registrationListener = new LinphoneOnRegistrationStateChangedListener() {
|
|
||||||
public void onRegistrationStateChanged(LinphoneProxyConfig proxy, RegistrationState state, String message) {
|
|
||||||
if (state == RegistrationState.RegistrationOk) {
|
if (state == RegistrationState.RegistrationOk) {
|
||||||
LinphoneManager.removeListener(registrationListener);
|
lc.removeListener(this);
|
||||||
|
|
||||||
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
|
||||||
mHandler .post(new Runnable () {
|
mHandler .post(new Runnable () {
|
||||||
|
@ -214,7 +213,7 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (state == RegistrationState.RegistrationFailed) {
|
} else if (state == RegistrationState.RegistrationFailed) {
|
||||||
LinphoneManager.removeListener(registrationListener);
|
lc.removeListener(this);
|
||||||
mHandler.post(new Runnable () {
|
mHandler.post(new Runnable () {
|
||||||
public void run() {
|
public void run() {
|
||||||
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
Toast.makeText(SetupActivity.this, getString(R.string.first_launch_bad_login_password), Toast.LENGTH_LONG).show();
|
||||||
|
@ -222,10 +221,14 @@ public class SetupActivity extends FragmentActivity implements OnClickListener {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
public void checkAccount(String username, String password, String domain) {
|
public void checkAccount(String username, String password, String domain) {
|
||||||
LinphoneManager.removeListener(registrationListener);
|
// LinphoneManager.removeListener(registrationListener);
|
||||||
LinphoneManager.addListener(registrationListener);
|
// LinphoneManager.addListener(registrationListener);
|
||||||
|
LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
|
||||||
|
if (lc != null) {
|
||||||
|
lc.addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
saveCreatedAccount(username, password, domain);
|
saveCreatedAccount(username, password, domain);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1bb6ebed6cc02fef789f1d1fb091cef50a9858d5
|
Subproject commit de2e98bd9635c49acd45d1d5b7d2bb900383e235
|
Loading…
Reference in a new issue