Examples of HylaFAXClient


Examples of gnu.hylafax.HylaFAXClient

  public HylaFAXClient getConnection(ProgressMonitor monitor) throws IOException, ServerResponseException {
        synchronized (connectionLock) {
            monitor.setText(i18n.tr("Connecting to {0}", Settings.HOSTNAME.getValue() + ":" + Settings.PORT.getValue()));

            if (connection == null) {
                connection = new HylaFAXClient();
                connection.addConnectionListener(connectionHandler);
                connection.setPassive(Settings.USE_PASSIVE.getValue());
            }

            logger.info("Connecting to HylaFAX server at " + Settings.HOSTNAME.getValue() + ":" + Settings.PORT.getValue());
View Full Code Here

Examples of gnu.hylafax.HylaFAXClient

    Job<?> ioJob = new Job() {
      public Object run(ProgressMonitor monitor) throws Exception
      {
        monitor.setTotalSteps(13 + fax.documents.size() * 10);
       
        HylaFAXClient client = JHylaFAX.getInstance().getConnection(monitor);
        monitor.work(1);

        client.mode(HylaFAXClient.MODE_STREAM);
        client.type(HylaFAXClient.TYPE_IMAGE);

        String serverCoverFilename = null;
        if (fax.cover != null && fax.coverIn != null) {
          monitor.setText(i18n.tr("Generating cover"));
          SubTaskProgressMonitor coverMonitor = new SubTaskProgressMonitor(monitor, 5, 0);
          StringBuffer data = fax.cover.generate(fax.coverIn, coverMonitor);
          coverMonitor.done();
         
            // Cover senden
                    byte[] buffer = data.toString().getBytes(FaxCover.CHARSET);
          TransferMonitor transferMonitor = new TransferMonitor(monitor, 5, buffer.length);
          client.addTransferListener(transferMonitor);
          InputStream in = new ByteArrayInputStream(buffer);
          try {
              serverCoverFilename = client.putTemporary(in);
          }
          finally {
            transferMonitor.transferCompleted();
            client.removeTransferListener(transferMonitor);
            in.close();
          }
          // check if monitor was cancelled
          monitor.work(0);
        }
        else {
          monitor.work(10);
        }

        monitor.setText(i18n.tr("Uploading documents"));
        List<String> serverFilenames = new ArrayList<String>();
        for (File file : fax.documents) {
          TransferMonitor transferMonitor = new TransferMonitor(monitor, 10, file.length());
          client.addTransferListener(transferMonitor);
          InputStream in = new BufferedInputStream(new FileInputStream(file));
          try {
            serverFilenames.add(client.putTemporary(in));
          }
          finally {
            transferMonitor.transferCompleted();
            client.removeTransferListener(transferMonitor);
            in.close();
          }
          // check if monitor was cancelled
          monitor.work(0);
        }
       
        gnu.hylafax.Job sendJob = client.createJob();
        HylaFAXClientHelper.applyParameter(sendJob, getJob());
          if (serverCoverFilename != null) {
            if (Settings.SEND_COVER_AS_DOCUMENT.getValue()) {
              sendJob.addDocument(serverCoverFilename);
            }
            else {
              sendJob.setProperty("COVER ", serverCoverFilename);
            }
          }
          for (String filename : serverFilenames) {
            sendJob.addDocument(filename);
          }
        monitor.work(1);
       
        client.submit(sendJob);
        monitor.work(1);
       
        return null;
      }
    };
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.