コード例 #1
0
ファイル: DropDaemon.java プロジェクト: jmt85/qabel-desktop
  void receiveMessages() throws PersistenceException, EntityNotFoundExcepion {
    Identity identity = config.getSelectedIdentity();
    if (identity == null) {
      return;
    }
    java.util.List<DropMessage> dropMessages;
    try {
      dropMessages = httpDropConnector.receive(identity, lastDate);
    } catch (NullPointerException e) {
      return;
    }
    Contact sender = null;

    for (DropMessage d : dropMessages) {

      lastDate = config.getLastDropPoll(identity);
      if (lastDate.getTime() < d.getCreationDate().getTime()) {
        try {
          sender = contactRepository.findByKeyId(identity, d.getSenderKeyId());
        } catch (EntityNotFoundExcepion e) {
          logger.error(
              "Contact: with ID: " + d.getSenderKeyId() + " not found " + e.getMessage(), e);
          continue;
        }
        dropMessageRepository.addMessage(d, sender, identity, false);
        config.setLastDropPoll(identity, d.getCreationDate());
      }
    }
  }
コード例 #2
0
  private void updateIdentity() {
    Identity identity = clientConfiguration.getSelectedIdentity();

    browseNav.setManaged(identity != null);
    contactsNav.setManaged(identity != null);
    syncNav.setManaged(identity != null);
    // inviteNav.setManaged(identity != null);
    selectedIdentity.setVisible(identity != null);
    // feebbackNav.setVisible(identity != null);

    avatarContainer.setVisible(identity != null);
    if (identity == null) {
      return;
    }

    final String currentAlias = identity.getAlias();
    if (currentAlias.equals(lastAlias)) {
      return;
    }

    new AvatarView(e -> currentAlias).getViewAsync(avatarContainer.getChildren()::setAll);
    alias.setText(currentAlias);
    lastAlias = currentAlias;

    if (clientConfiguration.getAccount() == null) {
      return;
    }
    mail.setText(clientConfiguration.getAccount().getUser());
  }
コード例 #3
0
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    this.resourceBundle = resources;

    navi.getChildren().clear();
    AccountingView accountingView = new AccountingView();
    actionlogView = new ActionlogView();
    accountingNav = createNavItem(resourceBundle.getString("layoutIdentity"), accountingView);
    navi.getChildren().add(accountingNav);

    browseNav = createNavItem(resourceBundle.getString("layoutBrowse"), new RemoteFSView());
    contactsNav = createNavItem(resourceBundle.getString("layoutContacts"), new ContactView());
    syncNav = createNavItem(resourceBundle.getString("layoutSync"), new SyncView());

    navi.getChildren().add(browseNav);
    navi.getChildren().add(contactsNav);
    navi.getChildren().add(syncNav);

    scrollContent.setFillWidth(true);

    if (clientConfiguration.getSelectedIdentity() == null) {
      accountingView.getView(scrollContent.getChildren()::setAll);
      setActiveNavItem(accountingNav);
    }

    updateIdentity();
    clientConfiguration.addObserver((o, arg) -> Platform.runLater(this::updateIdentity));

    uploadProgress.setProgress(0);
    uploadProgress.setDisable(true);

    WindowedTransactionGroup progress = new WindowedTransactionGroup();
    if (transferManager instanceof MonitoredTransferManager) {
      MonitoredTransferManager tm = (MonitoredTransferManager) transferManager;
      tm.onAdd(progress::add);
    }
    FxProgressModel progressModel = new FxProgressModel(progress);
    uploadProgress.progressProperty().bind(progressModel.progressProperty());
    progress.onProgress(
        () -> {
          if (progress.isEmpty()) {
            uploadProgress.setVisible(false);
          } else {
            uploadProgress.setVisible(true);
          }
        });

    createButtonGraphics();
  }
コード例 #4
0
  @Override
  public void start(Stage stage) throws Exception {
    primaryStage = stage;
    setUserAgentStylesheet(STYLESHEET_MODENA);

    config = initDiContainer();

    SceneAntialiasing aa = SceneAntialiasing.BALANCED;
    primaryStage
        .getIcons()
        .setAll(
            new javafx.scene.image.Image(getClass().getResourceAsStream("/logo-invert_small.png")));
    Scene scene;

    Platform.setImplicitExit(false);
    primaryStage.setTitle(TITLE);
    scene = new Scene(new LoginView().getView(), 370, 550, true, aa);
    primaryStage.setScene(scene);

    config.addObserver(
        (o, arg) -> {
          Platform.runLater(
              () -> {
                if (arg instanceof Account) {
                  try {
                    ClientConfiguration configuration =
                        (ClientConfiguration) customProperties.get("clientConfiguration");
                    Account acc = (Account) arg;
                    AccountingServer server =
                        new AccountingServer(
                            new URI(acc.getProvider()), acc.getUser(), acc.getAuth());
                    AccountingHTTP accountingHTTP =
                        new AccountingHTTP(server, new AccountingProfile());

                    BoxVolumeFactory factory =
                        new BlockBoxVolumeFactory(
                            configuration.getDeviceId().getBytes(),
                            accountingHTTP,
                            identityRepository);
                    boxVolumeFactory = new CachedBoxVolumeFactory(factory);
                    customProperties.put("boxVolumeFactory", boxVolumeFactory);
                    sharingService = new BlockSharingService(dropMessageRepository, dropConnector);
                    customProperties.put("sharingService", sharingService);

                    new Thread(getSyncDaemon(config)).start();
                    new Thread(getDropDaemon(config)).start();
                    view = new LayoutView();
                    Parent view = this.view.getView();
                    Scene layoutScene = new Scene(view, 800, 600, true, aa);
                    Platform.runLater(() -> primaryStage.setScene(layoutScene));

                    if (config.getSelectedIdentity() != null) {
                      addShareMessageRenderer(config.getSelectedIdentity());
                    }
                  } catch (Exception e) {
                    logger.error("failed to init background services: " + e.getMessage(), e);
                    // TODO to something with the fault
                  }
                } else if (arg instanceof Identity) {
                  addShareMessageRenderer((Identity) arg);
                }
              });
        });

    dropMessageRepository.addObserver(new ShareNotificationHandler(config));

    setTrayIcon(primaryStage);

    Runtime.getRuntime()
        .addShutdownHook(
            new Thread() {
              public void run() {
                Platform.exit();
              }
            });
    primaryStage.show();
  }