Search in sources :

Example 11 with ServiceEvent

use of cx.ring.model.ServiceEvent in project ring-client-android by savoirfairelinux.

the class AccountService method setAccountsVideoEnabled.

/**
 * Sets the video activation state of all the accounts in the local cache
 */
public void setAccountsVideoEnabled(boolean isEnabled) {
    for (Account account : mAccountList) {
        account.setDetail(ConfigKey.VIDEO_ENABLED, isEnabled);
    }
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNTS_CHANGED);
    notifyObservers(event);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 12 with ServiceEvent

use of cx.ring.model.ServiceEvent in project ring-client-android by savoirfairelinux.

the class AccountService method dataTransferEvent.

public void dataTransferEvent(final long transferId, int eventCode) {
    DataTransferEventCode dataEvent = getDataTransferEventCode(eventCode);
    DataTransferInfo info = new DataTransferInfo();
    dataTransferInfo(transferId, info);
    boolean outgoing = info.getFlags() == 0;
    DataTransfer transfer = mDataTransfers.get(transferId);
    if (transfer == null && outgoing && mStartingTransfer != null) {
        transfer = mStartingTransfer;
        mStartingTransfer = null;
        transfer.setDataTransferId(transferId);
        mDataTransfers.put(transferId, transfer);
    }
    if (transfer == null) {
        transfer = new DataTransfer(transferId, info.getDisplayName(), outgoing, info.getTotalSize(), info.getBytesProgress(), info.getPeer(), info.getAccountId());
        mHistoryService.insertDataTransfer(transfer);
        mDataTransfers.put(transferId, transfer);
    } else {
        DataTransferEventCode oldState = transfer.getEventCode();
        if (oldState != dataEvent) {
            if (dataEvent == DataTransferEventCode.ONGOING) {
                if (mTransferRefreshTimer == null) {
                    mTransferRefreshTimer = new Timer();
                }
                mTransferRefreshTimer.scheduleAtFixedRate(new DataTransferRefreshTask(transfer), DATA_TRANSFER_REFRESH_PERIOD, DATA_TRANSFER_REFRESH_PERIOD);
            }
        }
        transfer.setEventCode(dataEvent);
        transfer.setBytesProgress(info.getBytesProgress());
        mHistoryService.updateDataTransfer(transfer);
    }
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.DATA_TRANSFER);
    event.addEventInput(ServiceEvent.EventInput.TRANSFER_EVENT_CODE, dataEvent);
    event.addEventInput(ServiceEvent.EventInput.TRANSFER_INFO, transfer);
    notifyObservers(event);
}
Also used : Timer(java.util.Timer) DataTransfer(cx.ring.model.DataTransfer) ServiceEvent(cx.ring.model.ServiceEvent) DataTransferInfo(cx.ring.daemon.DataTransferInfo) DataTransferEventCode(cx.ring.model.DataTransferEventCode)

Example 13 with ServiceEvent

use of cx.ring.model.ServiceEvent in project ring-client-android by savoirfairelinux.

the class AccountService method discardTrustRequest.

/**
 * Refuses and blocks a pending trust request
 */
public void discardTrustRequest(final String accountId, final String from) {
    Account account = getAccount(accountId);
    account.removeRequest(from);
    FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), false, (Callable<Void>) () -> {
        Log.i(TAG, "discardTrustRequest() " + accountId + " " + from);
        boolean ok = Ringservice.discardTrustRequest(accountId, from);
        if (ok) {
            setChanged();
            ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_TRUST_REQUEST);
            event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
            notifyObservers(event);
        }
        return null;
    });
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 14 with ServiceEvent

use of cx.ring.model.ServiceEvent in project ring-client-android by savoirfairelinux.

the class AccountService method contactAdded.

public void contactAdded(String accountId, String uri, boolean confirmed) {
    Log.d(TAG, "contactAdded: " + accountId + ", " + uri + ", " + confirmed);
    Account account = getAccount(accountId);
    if (account == null) {
        Log.d(TAG, "contactAdded: unknown account" + accountId);
        return;
    }
    account.addContact(uri, confirmed);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACT_ADDED);
    event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
    event.addEventInput(ServiceEvent.EventInput.CONFIRMED, confirmed);
    notifyObservers(event);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 15 with ServiceEvent

use of cx.ring.model.ServiceEvent in project ring-client-android by savoirfairelinux.

the class ConferenceService method conferenceRemoved.

void conferenceRemoved(String confId) {
    Log.d(TAG, "conference removed: " + confId);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONFERENCE_REMOVED);
    event.addEventInput(ServiceEvent.EventInput.CONF_ID, confId);
    notifyObservers(event);
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent)

Aggregations

ServiceEvent (cx.ring.model.ServiceEvent)43 Account (cx.ring.model.Account)13 DataTransfer (cx.ring.model.DataTransfer)4 HistoryText (cx.ring.model.HistoryText)4 TextMessage (cx.ring.model.TextMessage)4 SQLException (java.sql.SQLException)4 SurfaceHolder (android.view.SurfaceHolder)3 CallContact (cx.ring.model.CallContact)3 Conversation (cx.ring.model.Conversation)3 HistoryCall (cx.ring.model.HistoryCall)3 SipCall (cx.ring.model.SipCall)3 Uri (cx.ring.model.Uri)3 IOException (java.io.IOException)3 Camera (android.hardware.Camera)2 StringMap (cx.ring.daemon.StringMap)2 DataTransferEventCode (cx.ring.model.DataTransferEventCode)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Point (android.graphics.Point)1 DataTransferInfo (cx.ring.daemon.DataTransferInfo)1