Search in sources :

Example 31 with ServiceEvent

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

the class AccountService method addAccount.

/**
 * Adds a new Account in the Daemon (also sends an ACCOUNT_ADDED event)
 * Sets the new account as the current one
 *
 * @param map the account details
 * @return the created Account
 */
@SuppressWarnings("unchecked")
public // Hashmap runtime cast
Account addAccount(final Map map) {
    String accountId = FutureUtils.executeDaemonThreadCallable(mExecutor, mDeviceRuntimeService.provideDaemonThreadId(), true, () -> {
        Log.i(TAG, "addAccount() thread running...");
        return Ringservice.addAccount(StringMap.toSwig(map));
    });
    if (accountId == null) {
        return null;
    }
    Map<String, String> accountDetails = getAccountDetails(accountId);
    Map<String, String> accountVolatileDetails = getVolatileAccountDetails(accountId);
    List<Map<String, String>> accountCredentials = getCredentials(accountId);
    Map<String, String> accountDevices = getKnownRingDevices(accountId);
    Account account = getAccount(accountId);
    if (account == null) {
        account = new Account(accountId, accountDetails, accountCredentials, accountVolatileDetails);
        account.setDevices(accountDevices);
        if (account.isSip()) {
            account.setRegistrationState(AccountConfig.STATE_READY, -1);
        }
    }
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNT_ADDED);
    event.addEventInput(ServiceEvent.EventInput.ACCOUNT_ID, accountId);
    event.addEventInput(ServiceEvent.EventInput.STATE, account.getRegistrationState());
    notifyObservers(event);
    setCurrentAccount(account);
    return account;
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent) HashMap(java.util.HashMap) Map(java.util.Map) StringMap(cx.ring.daemon.StringMap)

Example 32 with ServiceEvent

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

the class AccountService method accountsChanged.

public void accountsChanged() {
    String currentAccountId = mCurrentAccount == null ? "" : mCurrentAccount.getAccountID();
    // Accounts have changed in Daemon, we have to update our local cache
    refreshAccountsCacheFromDaemon();
    // if there was a current account we restore it according to the new list
    Account currentAccount = getAccount(currentAccountId);
    if (currentAccount != null) {
        mCurrentAccount = currentAccount;
    } else if (!mAccountList.isEmpty()) {
        // no current account, by default it will be the first one
        mCurrentAccount = mAccountList.get(0);
    } else {
        mCurrentAccount = null;
    }
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.ACCOUNTS_CHANGED);
    notifyObservers(event);
}
Also used : Account(cx.ring.model.Account) ServiceEvent(cx.ring.model.ServiceEvent)

Example 33 with ServiceEvent

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

the class ConferenceService method conferenceCreated.

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

Example 34 with ServiceEvent

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

the class ConferenceService method conferenceChanged.

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

Example 35 with ServiceEvent

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

the class HistoryService method deleteFileHistory.

public void deleteFileHistory(long id) {
    try {
        getDataHistoryDao().deleteById(id);
    } catch (SQLException e) {
        Log.e(TAG, "deleteFileHistory: SQL error occurred", e);
    }
    setChanged();
    ServiceEvent event = new ServiceEvent(ServiceEvent.EventType.HISTORY_MODIFIED);
    notifyObservers(event);
}
Also used : SQLException(java.sql.SQLException) 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