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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations