use of cx.ring.model.TrustRequest in project ring-client-android by savoirfairelinux.
the class AccountService method registeredNameFound.
public void registeredNameFound(String accountId, int state, String address, String name) {
Log.d(TAG, "registeredNameFound: " + accountId + ", " + state + ", " + name + ", " + address);
Account account = getAccount(accountId);
if (account != null) {
if (state == 0) {
CallContact contact = account.getContact(address);
if (contact != null) {
contact.setUsername(name);
}
}
TrustRequest request = account.getRequest(address);
if (request != null) {
Log.d(TAG, "registeredNameFound: updating TrustRequest " + name);
boolean resolved = request.isNameResolved();
request.setUsername(name);
if (!resolved) {
Log.d(TAG, "registeredNameFound: TrustRequest resolved " + name);
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_TRUST_REQUEST);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.FROM, request.getContactId());
notifyObservers(event);
}
}
}
setChanged();
ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.REGISTERED_NAME_FOUND);
event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
event.addEventInput(ServiceEvent.EventInput.STATE, state);
event.addEventInput(ServiceEvent.EventInput.ADDRESS, address);
event.addEventInput(ServiceEvent.EventInput.NAME, name);
notifyObservers(event);
}
use of cx.ring.model.TrustRequest in project ring-client-android by savoirfairelinux.
the class AccountService method incomingTrustRequest.
public void incomingTrustRequest(String accountId, String from, String message, long received) {
Log.d(TAG, "incomingTrustRequest: " + accountId + ", " + from + ", " + message + ", " + received);
Account account = getAccount(accountId);
if (account != null) {
TrustRequest request = new TrustRequest(accountId, from, received, message);
account.addRequest(request);
lookupAddress(accountId, "", from);
}
}
use of cx.ring.model.TrustRequest in project ring-client-android by savoirfairelinux.
the class ContactRequestsPresenter method updateList.
public void updateList(boolean clear) {
if (getView() == null) {
return;
}
Log.d(TAG, "updateList");
Account currentAccount = ((mAccountID == null) ? mAccountService.getCurrentAccount() : mAccountService.getAccount(mAccountID));
if (currentAccount == null) {
return;
}
boolean hasPane = !currentAccount.equals(mAccountService.getCurrentAccount());
if (clear) {
mTrustRequests.clear();
mTrustRequests.addAll(currentAccount.getRequests());
}
if (mContactRequestsViewModels == null) {
mContactRequestsViewModels = new ArrayList<>();
} else {
mContactRequestsViewModels.clear();
}
for (TrustRequest request : mTrustRequests) {
mContactRequestsViewModels.add(new PendingContactRequestsViewModel(currentAccount, request, hasPane));
}
getView().updateView(mContactRequestsViewModels);
mNotificationService.cancelTrustRequestNotification(currentAccount.getAccountID());
}
use of cx.ring.model.TrustRequest in project ring-client-android by savoirfairelinux.
the class TVContactRequestPresenter method acceptTrustRequest.
public void acceptTrustRequest(TVContactRequestViewModel viewModel) {
String accountId = mAccountService.getCurrentAccount().getAccountID();
String contactId = viewModel.getContactId();
List<TrustRequest> trustRequests = mAccountService.getCurrentAccount().getRequests();
for (Iterator<TrustRequest> it = trustRequests.iterator(); it.hasNext(); ) {
TrustRequest request = it.next();
if (accountId.equals(request.getAccountId()) && contactId.equals(request.getContactId())) {
VCard vCard = request.getVCard();
if (vCard != null) {
VCardUtils.savePeerProfileToDisk(vCard, contactId + ".vcf", mDeviceRuntimeService.provideFilesDir());
}
it.remove();
}
}
mAccountService.acceptTrustRequest(accountId, contactId);
mPreferencesService.removeRequestPreferences(accountId, contactId);
getView().finishView();
}
Aggregations