Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions assets/themes/app.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@
}
]
},
"systemNotificationsEnabled": true,
"sipPresenceEnabled": true
"systemNotificationsEnabled": true
},
"settingsConfig": {
"sections": [
Expand Down
3 changes: 2 additions & 1 deletion dart_define.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
"WEBTRIT_APP_EXTERNAL_CONTACTS_REPOSITORY_POLLING_INTERVAL_SECONDS": 60,
"WEBTRIT_APP_VOICEMAIL_REPOSITORY_POLLING_INTERVAL_SECONDS": 300,
"WEBTRIT_APP_CALLER_ID_SETTINGS_REPOSITORY_POLLING_INTERVAL_SECONDS": 300,
"WEBTRIT_APP_FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS": 300
"WEBTRIT_APP_FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS": 300,
"WEBTRIT_APP_SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS": 300
}
1 change: 1 addition & 0 deletions lib/app/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const kVoicemailFeatureFlag = 'voicemail';
const kSystemNotificationsFeatureFlag = 'notifications';
const kSystemNotificationsPushFeatureFlag = 'notificationsPush';
const kSipPresenceFeatureFlag = 'sipPresence';
const kSipDialogsFeatureFlag = 'sipDialogs';

const kSystemNotificationsTask = 'systemNotificationsTask';
const kSystemNotificationsTaskId = 'systemNotificationsTask-id';
Expand Down
47 changes: 39 additions & 8 deletions lib/app/router/main_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,23 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
);
},
),
RepositoryProvider<SipSubscriptionsRepository>(
create: (context) {
final appDatabase = context.read<AppDatabase>();
final apiClient = context.read<WebtritApiClient>();
final apiToken = context.read<AppBloc>().state.session.token!;

final localDataSource = SipSubscriptionsLocalDataSourceDriftImpl(appDatabase);
final remoteDataSource = SipSubscriptionsRemoteDataSourceApiImpl(apiClient: apiClient, apiToken: apiToken);

return SipSubscriptionsRepositorySyncableImpl(
localDataSource: localDataSource,
remoteDataSource: remoteDataSource,
connectivityService: context.read<ConnectivityService>(),
remoteSyncEnabled: featureAccess.sipPresenceConfig.subsSyncEnabled,
);
},
),
RepositoryProvider<RecentsRepository>(
create: (context) => RecentsRepository(appDatabase: context.read<AppDatabase>()),
),
Expand Down Expand Up @@ -258,11 +275,13 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
_sessionGuard,
),
),
RepositoryProvider<CallPullRepository>(create: (context) => CallPullRepositoryMemoryImpl()),
RepositoryProvider<LinesStateRepository>(create: (context) => LinesStateRepositoryInMemoryImpl()),
RepositoryProvider<PresenceInfoRepository>(
create: (context) => PresenceInfoRepositoryDriftImpl(context.read<AppDatabase>()),
),
RepositoryProvider<DialogInfoRepository>(
create: (context) => DialogInfoRepositoryDriftImpl(context.read<AppDatabase>()),
),
RepositoryProvider<CdrsLocalRepository>(
create: (context) => CdrsLocalRepositoryDriftImpl(context.read<AppDatabase>()),
),
Expand Down Expand Up @@ -447,9 +466,9 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
token: appBloc.state.session.token!,
trustedCertificates: appCertificates.trustedCertificates,
callLogsRepository: context.read<CallLogsRepository>(),
callPullRepository: context.read<CallPullRepository>(),
linesStateRepository: context.read<LinesStateRepository>(),
presenceInfoRepository: context.read<PresenceInfoRepository>(),
dialogInfoRepository: context.read<DialogInfoRepository>(),
presenceSettingsRepository: context.read<PresenceSettingsRepository>(),
userRepository: context.read<UserRepository>(),
submitNotification: (n) => notificationsBloc.add(NotificationsSubmitted(n)),
Expand All @@ -469,7 +488,7 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
),
iceFilter: FilterWithAppSettings(iceSettingsRepository),
peerConnectionPolicyApplier: pearConnectionPolicyApplier,
sipPresenceEnabled: featureAccess.sipPresenceConfig.sipPresenceSupport,
sendPresenceSettings: featureAccess.sipPresenceConfig.hybridPresenceSupport,
onCallEnded: () => cdrsSyncWorker?.forceSync(const Duration(seconds: 1)),
onDiagnosticReportRequested: (id, error) => diagnosticService.request(
DiagnosticType.androidCallkeepOnly,
Expand Down Expand Up @@ -546,7 +565,14 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
create: (_) =>
SystemNotificationsCounterCubit(context.read<SystemNotificationsLocalRepository>()),
),
BlocProvider(lazy: false, create: (_) => CallPullCubit(context.read<CallPullRepository>())),
BlocProvider(
lazy: false,
create: (_) => CallPullCubit(
userRepository: context.read<UserRepository>(),
dialogInfoRepository: context.read<DialogInfoRepository>(),
linesStateRepository: context.read<LinesStateRepository>(),
)..init(),
),
BlocProvider<CallRoutingCubit>(
lazy: false,
create: (_) => CallRoutingCubit(
Expand All @@ -562,10 +588,9 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
final sipPresenceFeature = featureAccess.sipPresenceConfig;

return PresenceViewParams(
viewSource: switch (sipPresenceFeature.sipPresenceSupport) {
true => PresenceViewSource.sipPresence,
false => PresenceViewSource.contactInfo,
},
hybridPresenceSupport: sipPresenceFeature.hybridPresenceSupport,
blfViaSipSupport: sipPresenceFeature.dialogsViaSipBlfSupport,
presenceViaSipSupport: sipPresenceFeature.presenceViaSipSupport,
child: CallConfigSynchronizer(
child: CallShell(
child: MessagingShell(
Expand Down Expand Up @@ -611,6 +636,7 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
final isVoicemailsEnabled = context.read<FeatureAccess>().settingsConfig.voicemailsEnabled;
final cliSettingsRepository = context.read<CallerIdSettingsRepository>();
final favoritesRepository = context.read<FavoritesRepository>();
final sipSubscriptionsRepository = context.read<SipSubscriptionsRepository>();

return [
PollingRegistration(
Expand Down Expand Up @@ -640,6 +666,11 @@ class _MainShellState extends State<MainShell> with WidgetsBindingObserver {
listener: favoritesRepository,
interval: const Duration(seconds: EnvironmentConfig.FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
if (sipSubscriptionsRepository is SipSubscriptionsRepositorySyncableImpl)
PollingRegistration(
listener: sipSubscriptionsRepository,
interval: const Duration(seconds: EnvironmentConfig.SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS),
),
];
}

Expand Down
24 changes: 14 additions & 10 deletions lib/data/feature_access.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class FeatureAccess extends Equatable {
AppConfig appConfig,
List<EmbeddedResource> embeddedResources,
CoreSupport coreSupport,
WebtritSystemInfo? systemInfo,
FeatureOverrides featureOverrides,
) {
try {
Expand All @@ -113,7 +114,7 @@ class FeatureAccess extends Equatable {
final messagingConfig = MessagingMapper.map(appConfig, coreSupport);
final contactsConfig = ContactsMapper.map(appConfig);
final systemNotificationsConfig = SystemNotificationsMapper.map(coreSupport, appConfig, featureOverrides);
final sipPresenceConfig = SipPresenceMapper.map(coreSupport, appConfig, featureOverrides);
final sipPresenceConfig = SipPresenceMapper.map(systemInfo, appConfig, featureOverrides);
final loggingConfig = LoggingMapper.map(appConfig, featureOverrides);

final supportedConfig = SupportedMapper.map(appConfig.supported);
Expand Down Expand Up @@ -504,18 +505,21 @@ abstract final class SystemNotificationsMapper {
/// Mapper responsible for evaluating SIP presence support based on config and core capabilities.
abstract final class SipPresenceMapper {
/// Maps [CoreSupport] and [AppConfig] to [SipPresenceConfig].
static SipPresenceConfig map(CoreSupport coreSupport, AppConfig appConfig, FeatureOverrides featureOverrides) {
final supportedFeature = appConfig.supported.whereType<SupportedSipPresence>().firstOrNull;
static SipPresenceConfig map(WebtritSystemInfo? systemInfo, AppConfig appConfig, FeatureOverrides featureOverrides) {
final appSupportsBase = appConfig.supported.whereType<SupportedHybridPresence>().isNotEmpty;
final appSupports = featureOverrides.hybridPresenceSupport ?? appSupportsBase;

// TODO: Migrate client configurations first before fully removing this property.
// ignore: deprecated_member_use_from_same_package, deprecated_member_use
final baseEnabled = supportedFeature?.enabled ?? appConfig.mainConfig.sipPresenceEnabled;
final backendSupports = systemInfo?.core.hybridPresenceAware ?? false;

// Apply remote overrides
final isEnabled = featureOverrides.isSipPresenceEnabled ?? baseEnabled;
final coreSupportEnabled = coreSupport.supportsSipPresence;
final isSupported = appSupports && backendSupports;
final withBlfViaSip = isSupported && (systemInfo?.adapter?.supportsSipDialogs ?? false);
final withpresenceViaSip = isSupported && (systemInfo?.adapter?.supportsSipPresence ?? false);

return SipPresenceConfig(sipPresenceSupport: isEnabled && coreSupportEnabled);
return SipPresenceConfig(
hybridPresenceSupport: isSupported,
dialogsViaSipBlfSupport: withBlfViaSip,
presenceViaSipSupport: withpresenceViaSip,
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/data/feature_access_stream_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ class FeatureAccessStreamFactory {
final coreSupport = CoreSupportFactory.create(systemInfo);
final overrides = FeatureOverridesFactory.create(remoteConfig);

return FeatureAccess.create(appThemes.appConfig, appThemes.embeddedResources, coreSupport, overrides);
return FeatureAccess.create(appThemes.appConfig, appThemes.embeddedResources, coreSupport, systemInfo, overrides);
}
}
7 changes: 7 additions & 0 deletions lib/environment_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,11 @@ class EnvironmentConfig {
FAVORITES_REPOSITORY_POLLING_INTERVAL_SECONDS__NAME,
defaultValue: 300,
);

static const SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS__NAME =
'WEBTRIT_APP_SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS';
static const SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS = int.fromEnvironment(
SIP_SUBSCRIPTIONS_REPOSITORY_POLLING_INTERVAL_SECONDS__NAME,
defaultValue: 300,
);
}
Loading
Loading