Search in sources :

Example 11 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class OnlineReplayVaultController method displayReplaysFromSupplier.

private void displayReplaysFromSupplier(Supplier<CompletableFuture<List<Replay>>> mapsSupplier) {
    currentPage = 1;
    this.currentSupplier = mapsSupplier;
    mapsSupplier.get().thenAccept(this::displaySearchResult).exceptionally(e -> {
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("vault.replays.searchError"), Severity.ERROR, e, Collections.singletonList(new DismissAction(i18n))));
        enterResultState();
        return null;
    });
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction)

Example 12 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class GameServiceImpl method notifyCantPlayReplay.

private void notifyCantPlayReplay(@Nullable Integer replayId, Throwable throwable) {
    logger.error("Could not play replay '" + replayId + "'", throwable);
    notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("replayCouldNotBeStarted", replayId), ERROR, throwable, singletonList(new Action(i18n.get("report")))));
}
Also used : DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Action(com.faforever.client.notification.Action) ImmediateNotification(com.faforever.client.notification.ImmediateNotification)

Example 13 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class FafServerAccessorImpl method onUIDNotExecuted.

@VisibleForTesting
protected void onUIDNotExecuted(Exception e) {
    logger.error("UID.exe not executed", e);
    if (e.getMessage() == null) {
        return;
    }
    notificationService.addNotification(new ImmediateNotification(i18n.get("UIDNotExecuted"), e.getMessage(), Severity.ERROR, Collections.singletonList(new ReportAction(i18n, reportingService, e))));
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ReportAction(com.faforever.client.notification.ReportAction) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 14 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class ReplayServiceImpl method getLocalReplays.

@Override
@SneakyThrows
public Collection<Replay> getLocalReplays() {
    Collection<Replay> replayInfos = new ArrayList<>();
    String replayFileGlob = clientProperties.getReplay().getReplayFileGlob();
    Path replaysDirectory = preferencesService.getReplaysDirectory();
    if (Files.notExists(replaysDirectory)) {
        noCatch(() -> createDirectories(replaysDirectory));
    }
    try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(replaysDirectory, replayFileGlob)) {
        for (Path replayFile : directoryStream) {
            try {
                LocalReplayInfo replayInfo = replayFileReader.parseMetaData(replayFile);
                FeaturedMod featuredMod = modService.getFeaturedMod(replayInfo.getFeaturedMod()).getNow(FeaturedMod.UNKNOWN);
                mapService.findByMapFolderName(replayInfo.getMapname()).thenAccept(mapBean -> {
                    if (!mapBean.isPresent()) {
                        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("mapNotFound", replayInfo.getMapname()), WARN));
                        return;
                    }
                    replayInfos.add(new Replay(replayInfo, replayFile, featuredMod, mapBean.get()));
                });
            } catch (Exception e) {
                logger.warn("Could not read replay file '{}'", replayFile, e);
                moveCorruptedReplayFile(replayFile);
            }
        }
    }
    return replayInfos;
}
Also used : Path(java.nio.file.Path) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ArrayList(java.util.ArrayList) FeaturedMod(com.faforever.client.mod.FeaturedMod) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) SneakyThrows(lombok.SneakyThrows)

Example 15 with ImmediateNotification

use of com.faforever.client.notification.ImmediateNotification in project downlords-faf-client by FAForever.

the class ReplayServiceImpl method runLiveReplay.

@Override
public void runLiveReplay(URI uri) {
    logger.debug("Running replay from URL: {}", uri);
    if (!uri.getScheme().equals(FAF_LIFE_PROTOCOL)) {
        throw new IllegalArgumentException("Invalid protocol: " + uri.getScheme());
    }
    Map<String, String> queryParams = Splitter.on('&').trimResults().withKeyValueSeparator("=").split(uri.getQuery());
    String gameType = queryParams.get("mod");
    String mapName = noCatch(() -> decode(queryParams.get("map"), UTF_8.name()));
    Integer gameId = Integer.parseInt(uri.getPath().split("/")[1]);
    try {
        URI replayUri = new URI(GPGNET_SCHEME, null, uri.getHost(), uri.getPort(), uri.getPath(), null, null);
        gameService.runWithLiveReplay(replayUri, gameId, gameType, mapName).exceptionally(throwable -> {
            notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("liveReplayCouldNotBeStarted"), Severity.ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
            return null;
        });
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
}
Also used : ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

ImmediateNotification (com.faforever.client.notification.ImmediateNotification)22 DismissAction (com.faforever.client.notification.DismissAction)12 ReportAction (com.faforever.client.notification.ReportAction)12 I18n (com.faforever.client.i18n.I18n)7 NotificationService (com.faforever.client.notification.NotificationService)7 Severity (com.faforever.client.notification.Severity)7 EventBus (com.google.common.eventbus.EventBus)6 MethodHandles (java.lang.invoke.MethodHandles)6 Path (java.nio.file.Path)6 Inject (javax.inject.Inject)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 PreferencesService (com.faforever.client.preferences.PreferencesService)5 List (java.util.List)5 Component (org.springframework.stereotype.Component)5 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)4 NavigateEvent (com.faforever.client.main.event.NavigateEvent)4 Action (com.faforever.client.notification.Action)4 Subscribe (com.google.common.eventbus.Subscribe)4 IOException (java.io.IOException)4