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

contactservice: reduce dependency to accountservice

Change-Id: Id5396932a0f5a97e9fece567ad2ff9e31f9d945f
parent aacf9e34
No related branches found
No related tags found
No related merge requests found
......@@ -268,15 +268,17 @@ public class ConversationPresenter extends RootPresenter<ConversationView> {
public void sendTrustRequest() {
final String accountId = mAccountId;
final Uri contactId = mContactRingId;
mVCardService.loadSmallVCard(accountId, VCardService.MAX_SIZE_REQUEST).subscribe(vCard -> {
mAccountService.sendTrustRequest(accountId, contactId.getRawRingId(), Blob.fromString(VCardUtils.vcardToString(vCard)));
CallContact contact = mContactService.findContact(accountId, contactId);
if (contact == null) {
Log.e(TAG, "sendTrustRequest: not able to find contact");
return;
}
contact.setStatus(CallContact.Status.REQUEST_SENT);
});
mVCardService.loadSmallVCard(accountId, VCardService.MAX_SIZE_REQUEST)
.subscribeOn(Schedulers.computation())
.subscribe(vCard -> {
mAccountService.sendTrustRequest(accountId, contactId.getRawRingId(), Blob.fromString(VCardUtils.vcardToString(vCard)));
CallContact contact = mContactService.findContact(mAccountService.getAccount(accountId), contactId);
if (contact == null) {
Log.e(TAG, "sendTrustRequest: not able to find contact");
return;
}
contact.setStatus(CallContact.Status.REQUEST_SENT);
});
}
public void clickOnGoingPane() {
......
......@@ -96,7 +96,7 @@ public class CallService {
if (audioOnly) {
Ringservice.muteLocalMedia(callId, "MEDIA_TYPE_VIDEO", true);
}
CallContact contact = mContactService.findContactByNumber(account, number);
CallContact contact = mContactService.findContactByNumber(mAccountService.getAccount(account), number);
SipCall call = addCall(account, callId, number, SipCall.Direction.OUTGOING);
call.muteVideo(audioOnly);
call.setContact(contact);
......@@ -305,7 +305,7 @@ public class CallService {
return null;
}
sipCall.setCallState(callState);
CallContact contact = mContactService.findContact(sipCall.getAccount(), sipCall.getNumberUri());
CallContact contact = mContactService.findContact(mAccountService.getAccount(sipCall.getAccount()), sipCall.getNumberUri());
String registeredName = callDetails.get("REGISTERED_NAME");
if (registeredName != null && !registeredName.isEmpty()) {
contact.setUsername(registeredName);
......
......@@ -117,11 +117,11 @@ public abstract class ContactService {
*
* @return The found/created contact
*/
public CallContact findContactByNumber(String accountId, String number) {
if (StringUtils.isEmpty(number) || StringUtils.isEmpty(accountId)) {
public CallContact findContactByNumber(Account account, String number) {
if (StringUtils.isEmpty(number) || account == null) {
return null;
}
return findContact(accountId, new Uri(number));
return findContact(account, new Uri(number));
}
public CallContact findContact(Account account, Uri uri) {
......@@ -136,8 +136,4 @@ public abstract class ContactService {
}
return contact;
}
public CallContact findContact(String accountId, Uri uri) {
return findContact(mAccountService.getAccount(accountId), uri);
}
}
\ No newline at end of file
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