Commits

Hector Miuler Malpica Gallegos  committed 27ad751

ultimas correcciones

  • Participants
  • Parent commits ab99dff

Comments (0)

Files changed (3)

     "io.netty" % "netty" % "4.0.0.Alpha5",
     "ch.qos.logback" % "logback-classic" % "1.0.7",
     "org.slf4j" % "slf4j-api" % "1.6.6",
-    //"javax.mail" % "mail" % "1.4.5",
-    "org.apache.james" % "apache-mime4j-project" % "0.7.2"
+    "javax.mail" % "mail" % "1.4.5"
+//    "org.apache.james" % "apache-mime4j" % "0.7.2"
 )
 
 resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",

File src/main/scala/com/miuler/mocksmtp/core/MockSMTP.scala

       }
       case _ => {
         log.debug("No es un comando")
-        if (loadingData==LOADING) email += msg
+        if (loadingData==LOADING) email += msg + "\n"
       }
     }
 

File src/main/scala/com/miuler/mocksmtp/gui/MainGUI.scala

 import com.trolltech.qt.QThread
 import com.trolltech.qt.core.Qt.ConnectionType
 import collection.mutable.ListBuffer
-import org.apache.james.mime4j.message.DefaultMessageBuilder
 import java.io.ByteArrayInputStream
-import org.apache.james.mime4j.dom.Message
 import com.trolltech.qt.gui.QPalette.ColorRole
 import com.trolltech.qt.core.Qt
 import java.util.Date
-import org.apache.james.mime4j.parser.MimeStreamParser
-
+import javax.mail.Session
+import javax.mail.internet.MimeMessage
+import java.util.Properties
 
 /**
  * Created with IntelliJ IDEA.
 class MainWindowSMTP(id: String = null, serverId: String = null) extends QWidget {
 
   private val log = LoggerFactory.getLogger(classOf[MainGUI])
+  private val session = Session.getInstance(new Properties)
+  private var emails = ListBuffer[MimeMessage]()
   private val lcd = new QLCDNumber()
   private var btnInitSMTP: QPushButton = _
   private var btnStopSMTP: QPushButton = _
-  private var emails = ListBuffer[Message]()
   private var treeView = new QTreeView
   private var model: QStandardItemModel = _
 
   initConnectionThread
 
   private def initGUI {
+    // =========================================================================
     btnInitSMTP = new QPushButton()
     btnInitSMTP.setCheckable(true)
     btnInitSMTP.setText("Iniciar servidor SMTP")
     btnStopSMTP.toggle()
     btnStopSMTP.setDisabled(true)
     btnStopSMTP.toggled.connect(this, "stopSMTP()")
+    // =========================================================================
 
+    // =========================================================================
     lcd.setDigitCount(3)
     lcd.setBackgroundRole(ColorRole.Dark)
+    // =========================================================================
 
-    // ==============================================================
+    // =========================================================================
     model = new QStandardItemModel(0, 3, this)
     model.setHeaderData(0, Qt.Orientation.Horizontal, tr("id"))
     model.setHeaderData(1, Qt.Orientation.Horizontal, tr("Fecha de envio"))
     treeView.setModel(model)
     treeView.setSortingEnabled(true)
     treeView.sortByColumn(1, Qt.SortOrder.AscendingOrder)
-    // =============================================================
+    treeView.setMinimumSize(300, 200) //TODO: @Miuler: Esto es para evitar un error en algunas maquinas
+    // =========================================================================
 
+    // =========================================================================
     val hlayout = new QHBoxLayout()
     hlayout.addWidget(btnInitSMTP)
     hlayout.addWidget(btnStopSMTP)
     hlayout.addWidget(lcd)
+    // =========================================================================
 
+    // =========================================================================
     val vlayout = new QVBoxLayout()
     vlayout.addItem(hlayout)
     vlayout.addWidget(treeView)
     setLayout(vlayout)
     setWindowTitle("MOCK SMTP")
+    resize(320, 240)
     show()
+    // =========================================================================
   }
 
   def initConnectionThread {
   }
 
   def addEmail(msg: String) {
-//    val mimeStream = new MimeStreamParser
-//    mimeStream.parse(new ByteArrayInputStream(msg.getBytes()))
-    //new Message(new ByteArrayInputStream(msg.getBytes()))
+    log.debug("email_string: {}", msg)
+    val email = new MimeMessage(session, new ByteArrayInputStream(msg.getBytes()))
 
-    var email = new DefaultMessageBuilder().parseMessage(new ByteArrayInputStream(msg.getBytes()))
     log.debug("email: {}", email)
-    log.debug("email.getMimeType: {}", email.getMimeType)
+    log.debug("email.getContent: {}", email.getContent())
     log.debug("email.getSubject: {}", email.getSubject())
-    log.debug("email.getBody: {}", email.getBody)
-    log.debug("email.getBody.dispose: {}", email.getBody().dispose())
-    //log.debug("email.getBody: {}", email.getBody().)
     emails.append(email)
     model.insertRow(0)
     model.setData(model.index(0, 0), model.rowCount())