Package jnode.protocol.io

Examples of jnode.protocol.io.Message


    flag_reob = true;
    checkEOB();
  }

  private void m_skip(String arg) {
    Message found = null;
    for (Message message : messages) {
      if (messageEquals(message, arg)) {
        logger.l3(String.format("Skip file: %s (%d)",
            message.getMessageName(), message.getMessageLength()));
        found = message;
View Full Code Here


      }
    }
  }

  private void m_got(String arg) {
    Message found = null;
    for (Message message : messages) {
      if (messageEquals(message, arg)) {
        logger.l3(String.format("Sent file: %s (%d)",
            message.getMessageName(), message.getMessageLength()));
        found = message;
        break;
      }
    }
    if (found != null) {
      total_sent_files++;
      found.delete();
      messages.remove(found);
    } else {
      logger.l3("M_GOT for file we haven't sent: " + arg);
    }
  }
View Full Code Here

  }

  protected boolean startNextFile() {
    logger.l5("startNextFile()");
    try {
      Message nextMessage = messages.get(messages_index);
      sendMessage(nextMessage, 0);
      return true;
    } catch (IndexOutOfBoundsException e) {
      return false;
    }
View Full Code Here

      try {
        for (FtnMessage net : packedNetmail) {
          FtnPkt head = new FtnPkt(header.getFromAddr(), to,
              password, new Date());
          Message m = new Message(createZipFile(head, link,
              Arrays.asList(net)));
          m.setMessageName(generateEchoBundle());
          ret.add(m);
        }
      } catch (Exception e) {
        logger.l1(
            "Error while writing netmail to link #" + link.getId(),
            e);
      }

    }
    if (!packedEchomail.isEmpty()) {
      try {
        Message m = new Message(createZipFile(header, link,
            packedEchomail));
        m.setMessageName(generateEchoBundle());
        ret.add(m);
      } catch (Exception e) {
        logger.l1(
            "Error while writing echomail to link #" + link.getId(),
            e);
      }
    }
    if (!unpackedNetmail.isEmpty()) {
      try {
        for (FtnMessage net : unpackedNetmail) {
          FtnPkt head = new FtnPkt(header.getFromAddr(), to,
              password, new Date());
          File out = createOutboundFile(link);
          FileOutputStream fos = new FileOutputStream(out);
          fos.write(head.pack());
          fos.write(net.pack());
          fos.write(head.finalz());
          fos.close();
          Message m = new Message(out);
          m.setMessageName(generate8d() + ".pkt");
          ret.add(m);
        }
      } catch (Exception e) {
        logger.l1(
            "Error while writing netmail to link #" + link.getId(),
            e);
      }
    }
    if (!unpackedEchomail.isEmpty()) {
      try {
        File out = createOutboundFile(link);
        FileOutputStream fos = new FileOutputStream(out);
        fos.write(header.pack());
        for (FtnMessage m : unpackedEchomail) {
          fos.write(m.pack());
        }
        fos.write(header.finalz());
        fos.close();
        Message m = new Message(out);
        m.setMessageName(generate8d() + ".pkt");
        ret.add(m);
      } catch (Exception e) {
        logger.l1(
            "Error while writing netmail to link #" + link.getId(),
            e);
View Full Code Here

   * @param pkt
   */
  @Deprecated
  protected static void moveToBad(FtnPkt pkt) {
    ByteArrayInputStream bis = new ByteArrayInputStream(pkt.pack());
    Message message = new Message(String.format("%s_%d.pkt", generate8d(),
        new Date().getTime() / 1000), bis.available());
    message.setInputStream(bis);
    try {
      unpack(message);
    } catch (IOException e) {
      logger.l2("fail move to bad", e);
    }
View Full Code Here

  public static Message createMessage(String arg, boolean secure) {
    String[] args = arg.split(" ");
    try {
      Long len = Long.valueOf(args[1]);
      Long unixtime = Long.valueOf(args[2]);
      Message message = new Message(args[0], len);
      message.setUnixtime(unixtime);
      message.setSecure(secure);
      return message;
    } catch (RuntimeException e) {
      return null;
    }
  }
View Full Code Here

    if (listFiles != null) {
      for (File file : listFiles) {
        String loname = file.getName().toLowerCase();
        if (loname.matches("^[a-f0-9]{8}\\.pkt$")) {
          try {
            Message m = new Message(file);
            logger.l4("Tossing file " + file.getAbsolutePath());
            FtnMessage ftnm;
            FtnPkt pkt = new FtnPkt();
            pkt.unpack(m.getInputStream());
            while ((ftnm = pkt.getNextMessage()) != null) {
              if (ftnm.isNetmail()) {
                tossNetmail(ftnm, true);
              } else {
                tossEchomail(ftnm, null, true);
              }
            }
            file.delete();
          } catch (Exception e) {
            markAsBad(file, "Tossing failed");
            logger.l2(
                "Error while tossing: "
                    + e.getLocalizedMessage(), e);
          }
        } else if (loname.matches("(s|u)inb\\d*.pkt")) {
          try {
            Message m = new Message(file);
            logger.l4("Tossing file " + file.getAbsolutePath());
            FtnPkt pkt = new FtnPkt();
            pkt.unpack(m.getInputStream());
            Link link = getLinkByFtnAddress(pkt.getFromAddr());
            boolean secure = loname.charAt(0) == 's'
                && link != null;
            if (secure) {
              if (!getOptionBooleanDefTrue(link,
View Full Code Here

              num++;
              if ((n.getAttr() & FtnMessage.ATTR_FILEATT) >= FtnMessage.ATTR_FILEATT) {
                String filename = n.getSubject();
                File file = guessFilename(filename, true);
                if (file != null && file.canRead()) {
                  messages.add(new Message(file));
                  logger.l5("Netmail with attached file "
                      + filename);
                }
              }
            }
            for (Netmail n : mail) {
              n.setSend(true);
              ORMManager.get(Netmail.class).update(n);
              logger.l4(String
                  .format("Netmail #%d %s -> %s for %s flags %d was packed",
                      n.getId(), n.getFromFTN(),
                      n.getToFTN(),
                      link.getLinkAddress(), n.getAttr()));
            }
          } catch (IOException e) {
            logger.l2("Error while packing netmail", e);
          }
          mail.clear();
        }
      } while (mail != null && !mail.isEmpty());
      header.finalz(os);
      fos.close();
      if (num == 0) {
        f.delete();
      } else {
        Message m = new Message(f);
        if (pack) {
          m.setMessageName(generateEchoBundle());
        } else {
          m.setMessageName(generate8d() + ".pkt");
        }
        messages.add(m);
      }
    } catch (IOException e) {
      logger.l2("Error while packing messages", e);
View Full Code Here

      header.finalz(os);
      fos.close();
      if (num == 0) {
        f.delete();
      } else {
        Message m = new Message(f);
        if (pack) {
          m.setMessageName(generateEchoBundle());
        } else {
          m.setMessageName(generate8d() + ".pkt");
        }
        messages.add(m);
      }
    } catch (IOException e) {
      logger.l2("Error while packing echomails ", e);
View Full Code Here

            File tmp = File.createTempFile("outtic", ".tic",
                new File(getInbound()));
            FileOutputStream fos = new FileOutputStream(tmp);
            fos.write(tic.pack());
            fos.close();
            Message message = new Message(tmp);
            message.setMessageName(generateTic());
            msgs.add(message);
            Message m2 = new Message(mail.getFilename(),
                attach.length());
            m2.setInputStream(new FileInputStream(attach));
            msgs.add(m2);
            deleteFAMail(f);
          } catch (IOException e) {
            logger.l2("Error while packing tic:", e);
          }
        }
      }
    } while (!filemail.isEmpty());
    List<FileForLink> ffls = ORMManager.get(FileForLink.class).getAnd(
        "link_id", "eq", link);
    for (FileForLink ffl : ffls) {
      try {
        File file = new File(ffl.getFilename());
        Message m = new Message(file);
        ORMManager.get(FileForLink.class).delete("link_id", "=", link,
            "filename", "=", ffl.getFilename());
        msgs.add(m);
      } catch (Exception ex) {
        logger.l1(MessageFormat
View Full Code Here

TOP

Related Classes of jnode.protocol.io.Message

Copyright © 2018 www.massapicom. 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.