Skip to content
Snippets Groups Projects
Commit dfb49fab authored by Adrien Béraud's avatar Adrien Béraud
Browse files

remove PresenceService

Unused, rewire events to AccountService

Change-Id: I069299ecc06427e53730a820f63b262e933d4928
parent acadbcc2
No related branches found
No related tags found
No related merge requests found
Showing
with 12 additions and 142 deletions
......@@ -62,7 +62,6 @@ import cx.ring.services.DaemonService;
import cx.ring.services.DeviceRuntimeService;
import cx.ring.services.HardwareService;
import cx.ring.services.PreferencesService;
import cx.ring.services.PresenceService;
public abstract class RingApplication extends Application {
private static final String TAG = RingApplication.class.getSimpleName();
......@@ -91,8 +90,6 @@ public abstract class RingApplication extends Application {
@Inject
ContactService mContactService;
@Inject
PresenceService mPresenceService;
@Inject
ConversationFacade mConversationFacade;
private RingInjectionComponent mRingInjectionComponent;
......
......@@ -21,7 +21,6 @@ package cx.ring.dependencyinjection;
import javax.inject.Singleton;
import cx.ring.about.AboutFragment;
import cx.ring.account.AccountEditionActivity;
import cx.ring.account.AccountWizardActivity;
import cx.ring.account.HomeAccountCreationFragment;
......@@ -61,7 +60,6 @@ import cx.ring.services.DeviceRuntimeServiceImpl;
import cx.ring.services.HardwareService;
import cx.ring.services.HistoryServiceImpl;
import cx.ring.services.NotificationServiceImpl;
import cx.ring.services.PresenceService;
import cx.ring.services.RingChooserTargetService;
import cx.ring.services.SharedPreferencesServiceImpl;
import cx.ring.settings.SettingsFragment;
......@@ -151,8 +149,6 @@ public interface RingInjectionComponent {
void inject(ConversationFacade service);
void inject(PresenceService service);
void inject(BootReceiver receiver);
void inject(AdvancedAccountFragment fragment);
......
......@@ -20,9 +20,7 @@
package cx.ring.dependencyinjection;
import android.content.Context;
import androidx.annotation.NonNull;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
......@@ -48,7 +46,6 @@ import cx.ring.services.LogServiceImpl;
import cx.ring.services.NotificationService;
import cx.ring.services.NotificationServiceImpl;
import cx.ring.services.PreferencesService;
import cx.ring.services.PresenceService;
import cx.ring.services.SharedPreferencesServiceImpl;
import cx.ring.services.VCardService;
import cx.ring.services.VCardServiceImpl;
......@@ -158,14 +155,6 @@ public class ServiceInjectionModule {
return contactService;
}
@Provides
@Singleton
PresenceService providePresenceService() {
PresenceService presenceService = new PresenceService();
mRingApplication.getRingInjectionComponent().inject(presenceService);
return presenceService;
}
@Provides
@Singleton
ConversationFacade provideConversationFacade(
......
......@@ -36,7 +36,6 @@ import cx.ring.navigation.RingNavigationViewModel;
import cx.ring.services.AccountService;
import cx.ring.services.ContactService;
import cx.ring.services.HardwareService;
import cx.ring.services.PresenceService;
import cx.ring.tv.model.TVListViewModel;
import cx.ring.utils.Log;
import io.reactivex.Observable;
......@@ -48,7 +47,6 @@ public class MainPresenter extends RootPresenter<MainView> {
private final AccountService mAccountService;
private final ContactService mContactService;
private final PresenceService mPresenceService;
private final HardwareService mHardwareService;
private List<TVListViewModel> mTvListViewModels;
......@@ -62,12 +60,10 @@ public class MainPresenter extends RootPresenter<MainView> {
public MainPresenter(AccountService accountService,
ContactService contactService,
ConversationFacade conversationFacade,
PresenceService presenceService,
HardwareService hardwareService,
@Named("UiScheduler") Scheduler uiScheduler) {
mAccountService = accountService;
mContactService = contactService;
mPresenceService = presenceService;
mHardwareService = hardwareService;
mUiScheduler = uiScheduler;
......@@ -146,9 +142,6 @@ public class MainPresenter extends RootPresenter<MainView> {
}
}
}));
mCompositeDisposable.add(mPresenceService.getPresenceUpdates()
.observeOn(mUiScheduler)
.subscribe(this::refreshContact));
Log.d(TAG, "getPendingSubject subscribe");
mCompositeDisposable.add(accountSubject
......@@ -158,7 +151,7 @@ public class MainPresenter extends RootPresenter<MainView> {
Log.d(TAG, "getPendingSubject " + pending.size());
ArrayList<TVListViewModel> viewmodel = new ArrayList<>(pending.size());
for (Conversation c : pending) {
mContactService.loadContactData(c.getContact());
mContactService.loadContactData(c.getContact()).subscribe();
viewmodel.add(modelToViewModel(c.getContact()));
}
return viewmodel;
......@@ -170,7 +163,7 @@ public class MainPresenter extends RootPresenter<MainView> {
}
private TVListViewModel modelToViewModel(CallContact callContact) {
mContactService.loadContactData(callContact);
mContactService.loadContactData(callContact).subscribe();
return new TVListViewModel(callContact);
}
......
......@@ -50,7 +50,6 @@ import cx.ring.services.HardwareService;
import cx.ring.services.HistoryService;
import cx.ring.services.NotificationService;
import cx.ring.services.PreferencesService;
import cx.ring.services.PresenceService;
import cx.ring.utils.FileUtils;
import cx.ring.utils.Log;
import cx.ring.utils.VCardUtils;
......@@ -72,9 +71,6 @@ public class ConversationFacade {
private final HistoryService mHistoryService;
private final CallService mCallService;
@Inject
PresenceService mPresenceService;
@Inject
HardwareService mHardwareService;
......@@ -121,14 +117,14 @@ public class ConversationFacade {
CallContact contact = conversation.getContact();
Uri id = contact.getPrimaryUri();
if (enabled) {
mPresenceService.subscribeBuddy(a.getAccountID(), id.getRawUriString(), true);
mAccountService.subscribeBuddy(a.getAccountID(), id.getRawUriString(), true);
if (contact.subscribe()) {
mContactService.loadContactData(contact)
.subscribe(() -> {}, e -> Log.e(TAG, "Error loading contact data", e));
mAccountService.lookupAddress(a.getAccountID(), "", id.getRawRingId());
}
} else {
mPresenceService.subscribeBuddy(a.getAccountID(), id.getRawUriString(), false);
mAccountService.subscribeBuddy(a.getAccountID(), id.getRawUriString(), false);
}
}
})))
......
......@@ -436,6 +436,10 @@ public class AccountService {
return currentAccountSubject;
}
public void subscribeBuddy(final String accountID, final String uri, final boolean flag) {
mExecutor.execute(() -> Ringservice.subscribeBuddy(accountID, uri, flag));
}
/**
* Send profile through SIP
*/
......
......@@ -59,9 +59,6 @@ public class DaemonService {
@Inject
protected HardwareService mHardwareService;
@Inject
protected PresenceService mPresenceService;
@Inject
protected AccountService mAccountService;
......@@ -276,22 +273,22 @@ public class DaemonService {
@Override
public void newServerSubscriptionRequest(String remote) {
mPresenceService.newServerSubscriptionRequest(remote);
Log.d(TAG, "newServerSubscriptionRequest: " + remote);
}
@Override
public void serverError(String accountId, String error, String message) {
mPresenceService.serverError(accountId, error, message);
Log.d(TAG, "serverError: " + accountId + ", " + error + ", " + message);
}
@Override
public void newBuddyNotification(String accountId, String buddyUri, int status, String lineStatus) {
mPresenceService.newBuddyNotification(accountId, buddyUri, status, lineStatus);
mAccountService.getAccount(accountId).presenceUpdate(buddyUri, status == 1);
}
@Override
public void subscriptionStateChanged(String accountId, String buddyUri, int state) {
mPresenceService.subscriptionStateChanged(accountId, buddyUri, state);
Log.d(TAG, "subscriptionStateChanged: " + accountId + ", " + buddyUri + ", " + state);
}
}
......
/*
* Copyright (C) 2004-2019 Savoir-faire Linux Inc.
*
* Author: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
package cx.ring.services;
import java.util.concurrent.ScheduledExecutorService;
import javax.inject.Inject;
import javax.inject.Named;
import cx.ring.daemon.Ringservice;
import cx.ring.daemon.StringVect;
import cx.ring.daemon.VectMap;
import cx.ring.model.Account;
import cx.ring.model.CallContact;
import cx.ring.utils.Log;
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
public class PresenceService {
private static final String TAG = PresenceService.class.getSimpleName();
@Inject
@Named("DaemonExecutor")
ScheduledExecutorService mExecutor;
@Inject
DeviceRuntimeService mDeviceRuntimeService;
@Inject
ContactService mContactService;
@Inject
AccountService mAccountService;
private final PublishSubject<CallContact> presentSubject = PublishSubject.create();
public Observable<CallContact> getPresenceUpdates() {
return presentSubject;
}
public void publish(final String accountID, final boolean status, final String note) {
mExecutor.execute(() -> Ringservice.publish(accountID, status, note));
}
public void answerServerRequest(final String uri, final boolean flag) {
mExecutor.execute(() -> Ringservice.answerServerRequest(uri, flag));
}
public void subscribeBuddy(final String accountID, final String uri, final boolean flag) {
mExecutor.execute(() -> Ringservice.subscribeBuddy(accountID, uri, flag));
}
public VectMap getSubscriptions(final String accountID) {
try {
return mExecutor.submit(() -> Ringservice.getSubscriptions(accountID)).get();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void setSubscriptions(final String accountID, final StringVect uris) {
mExecutor.execute(() -> Ringservice.setSubscriptions(accountID, uris));
}
public void newServerSubscriptionRequest(String remote) {
Log.d(TAG, "newServerSubscriptionRequest: " + remote);
}
public void serverError(String accountId, String error, String message) {
Log.d(TAG, "serverError: " + accountId + ", " + error + ", " + message);
}
public void newBuddyNotification(String accountId, String buddyUri, int status, String lineStatus) {
Account account = mAccountService.getAccount(accountId);
account.presenceUpdate(buddyUri, status == 1);
}
public void subscriptionStateChanged(String accountId, String buddyUri, int state) {
Log.d(TAG, "subscriptionStateChanged: " + accountId + ", " + buddyUri + ", " + state);
}
}
......@@ -39,7 +39,6 @@ import cx.ring.services.ContactService;
import cx.ring.services.DeviceRuntimeService;
import cx.ring.services.HardwareService;
import cx.ring.services.PreferencesService;
import cx.ring.services.PresenceService;
import cx.ring.utils.Log;
import cx.ring.utils.StringUtils;
import io.reactivex.Observable;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment