Search in sources :

Example 6 with TrustRequest

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);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent) TrustRequest(cx.ring.model.TrustRequest) CallContact(cx.ring.model.CallContact)

Example 7 with TrustRequest

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);
    }
}
Also used : Account(cx.ring.model.Account) TrustRequest(cx.ring.model.TrustRequest)

Example 8 with TrustRequest

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());
}
Also used : Account(cx.ring.model.Account) TrustRequest(cx.ring.model.TrustRequest)

Example 9 with TrustRequest

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();
}
Also used : TrustRequest(cx.ring.model.TrustRequest) VCard(ezvcard.VCard)

Aggregations

TrustRequest (cx.ring.model.TrustRequest)9 Account (cx.ring.model.Account)4 VCard (ezvcard.VCard)3 ArrayList (java.util.ArrayList)3 CallContact (cx.ring.model.CallContact)2 List (java.util.List)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 NotificationCompat (android.support.v4.app.NotificationCompat)1 HomeActivity (cx.ring.client.HomeActivity)1 StringMap (cx.ring.daemon.StringMap)1 ServiceEvent (cx.ring.model.ServiceEvent)1 DRingService (cx.ring.service.DRingService)1 TVContactRequestViewModel (cx.ring.tv.model.TVContactRequestViewModel)1 NonNull (io.reactivex.annotations.NonNull)1 ResourceSingleObserver (io.reactivex.observers.ResourceSingleObserver)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1