Search in sources :

Example 16 with ServiceEvent

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

the class HistoryService method getCallAndTextAsyncForAccount.

public void getCallAndTextAsyncForAccount(final String accountId) {
    mApplicationExecutor.submit(() -> {
        try {
            List<HistoryCall> historyCalls = getAllForAccount(accountId);
            List<HistoryText> historyTexts = getAllTextMessagesForAccount(accountId);
            List<DataTransfer> historyTransfers = getHistoryDataTransfers(accountId);
            ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.HISTORY_LOADED);
            event.addEventInput(ServiceEvent.EventInput.HISTORY_CALLS, historyCalls);
            event.addEventInput(ServiceEvent.EventInput.HISTORY_TEXTS, historyTexts);
            event.addEventInput(ServiceEvent.EventInput.HISTORY_TRANSFERS, historyTransfers);
            setChanged();
            notifyObservers(event);
        } catch (SQLException e) {
            Log.e(TAG, "Can't load calls and texts", e);
        }
    });
}
Also used : HistoryText(cx.ring.model.HistoryText) DataTransfer(cx.ring.model.DataTransfer) SQLException(java.sql.SQLException) ServiceEvent(cx.ring.model.ServiceEvent) HistoryCall(cx.ring.model.HistoryCall)

Example 17 with ServiceEvent

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

the class PresenceService method newBuddyNotification.

public void newBuddyNotification(String accountId, String buddyUri, int status, String lineStatus) {
    Log.d(TAG, "newBuddyNotification: " + accountId + ", " + buddyUri + ", " + status + ", " + lineStatus);
    mPresenceMap.put(CallContact.PREFIX_RING + buddyUri, status == 1);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.NEW_BUDDY_NOTIFICATION);
    event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
    event.addEventInput(ServiceEvent.EventInput.BUDDY_URI, buddyUri);
    event.addEventInput(ServiceEvent.EventInput.STATE, status);
    event.addEventInput(ServiceEvent.EventInput.LINE_STATE, lineStatus);
    notifyObservers(event);
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent)

Example 18 with ServiceEvent

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

the class PresenceService method serverError.

public void serverError(String accountId, String error, String message) {
    Log.d(TAG, "serverError: " + accountId + ", " + error + ", " + message);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.SERVER_ERROR);
    event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
    event.addEventInput(ServiceEvent.EventInput.ERROR, error);
    event.addEventInput(ServiceEvent.EventInput.MESSAGE, message);
    notifyObservers(event);
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent)

Example 19 with ServiceEvent

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

the class CallService method incomingCall.

void incomingCall(String accountId, String callId, String from) {
    Log.d(TAG, "incoming call: " + accountId + ", " + callId + ", " + from);
    SipCall call = addCall(accountId, callId, from, SipCall.Direction.INCOMING);
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.INCOMING_CALL);
    event.addEventInput(ServiceEvent.EventInput.CALL, call);
    notifyObservers(event);
}
Also used : SipCall(cx.ring.model.SipCall) ServiceEvent(cx.ring.model.ServiceEvent)

Example 20 with ServiceEvent

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

the class ContactService method loadContacts.

/**
 * Load contacts from system and generate a local contact cache
 *
 * @param loadRingContacts if true, ring contacts will be taken care of
 * @param loadSipContacts  if true, sip contacts will be taken care of
 */
public void loadContacts(final boolean loadRingContacts, final boolean loadSipContacts, final Account account) {
    mApplicationExecutor.submit(() -> {
        Settings settings = mPreferencesService.loadSettings();
        if (settings.isAllowSystemContacts() && mDeviceRuntimeService.hasContactPermission()) {
            mContactList = loadContactsFromSystem(loadRingContacts, loadSipContacts);
        }
        mContactsRing.clear();
        mAccountId = account.getAccountID();
        Map<String, CallContact> ringContacts = account.getContacts();
        for (CallContact contact : ringContacts.values()) {
            mContactsRing.put(contact.getPhones().get(0).getNumber().getRawUriString(), contact);
        }
        setChanged();
        ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.CONTACTS_CHANGED);
        notifyObservers(event);
    });
}
Also used : ServiceEvent(cx.ring.model.ServiceEvent) Settings(cx.ring.model.Settings) CallContact(cx.ring.model.CallContact)

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