use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class ConversationFacade method placeCall.
public SipCall placeCall(String accountId, String number, boolean video) {
String rawId = new Uri(number).getRawRingId();
Account account = mAccountService.getAccount(accountId);
if (account != null) {
CallContact contact = account.getContact(rawId);
if (contact == null)
mAccountService.addContact(accountId, rawId);
}
return mCallService.placeCall(rawId, number, video);
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class ConversationFacade method aggregateHistory.
private void aggregateHistory() {
Map<String, ArrayList<String>> conferences = mConferenceService.getConferenceList();
for (Map.Entry<String, ArrayList<String>> conferenceEntry : conferences.entrySet()) {
Conference conference = new Conference(conferenceEntry.getKey());
for (String callId : conferenceEntry.getValue()) {
SipCall call = getCall(callId).second;
if (call == null) {
call = new SipCall(callId, mCallService.getCallDetails(callId));
}
Account account = mAccountService.getAccount(call.getAccount());
if (account.isRing() || account.getDetailBoolean(ConfigKey.SRTP_ENABLE) || account.getDetailBoolean(ConfigKey.TLS_ENABLE)) {
call = new SecureSipCall(call, account.getDetail(ConfigKey.SRTP_KEY_EXCHANGE));
}
conference.addParticipant(call);
}
List<SipCall> calls = conference.getParticipants();
if (calls.size() == 1) {
SipCall call = calls.get(0);
CallContact contact = call.getContact();
if (call.getContact() == null) {
contact = mContactService.findContact(call.getNumberUri());
call.setContact(contact);
}
Conversation conv = null;
ArrayList<String> ids = contact.getIds();
for (String id : ids) {
conv = mConversationMap.get(id);
if (conv != null) {
break;
}
}
if (conv != null) {
conv.addConference(conference);
} else {
conv = new Conversation(contact);
conv.addConference(conference);
mConversationMap.put(ids.get(0), conv);
}
}
}
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method acceptTrustRequest.
/**
* Accepts a pending trust request
*/
public Boolean acceptTrustRequest(final String accountId, final String from) {
Account account = getAccount(accountId);
account.removeRequest(from);
return FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, () -> {
Log.i(TAG, "acceptTrustRequest() thread running...");
boolean ok = Ringservice.acceptTrustRequest(accountId, from);
if (ok) {
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_TRUST_REQUEST);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
notifyObservers(event);
}
return ok;
});
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method enableRingProxy.
public void enableRingProxy() {
FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, () -> {
for (Account acc : mAccountList) {
if (acc.isRing() && !acc.isDhtProxyEnabled()) {
Log.d(TAG, "Enabling proxy for account " + acc.getAccountID());
StringMap details = Ringservice.getAccountDetails(acc.getAccountID());
details.set(ConfigKey.PROXY_ENABLED.key(), "true");
Ringservice.setAccountDetails(acc.getAccountID(), details);
acc.setDhtProxyEnabled(true);
}
}
return true;
});
}
use of cx.ring.model.Account in project ring-client-android by savoirfairelinux.
the class AccountService method nameRegistrationEnded.
public void nameRegistrationEnded(String accountId, int state, String name) {
Log.d(TAG, "nameRegistrationEnded: " + accountId + ", " + state + ", " + name);
Account acc = getAccount(accountId);
if (acc == null) {
Log.w(TAG, "Can't find account for name registration callback");
return;
}
acc.registeringUsername = false;
acc.setVolatileDetails(getVolatileAccountDetails(acc.getAccountID()));
acc.setDetail(ConfigKey.ACCOUNT_REGISTERED_NAME, name);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.NAME_REGISTRATION_ENDED);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.STATE, state);
event.addEventInput(ServiceEvent.EventInput.NAME, name);
notifyObservers(event);
}
Aggregations