Commits

Hector Miuler Malpica Gallegos  committed ab99dff

ya esta la grilla pero aún falta afinar más

  • Participants
  • Parent commits 50979f6

Comments (0)

Files changed (3)

     "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" % "0.7.2"
+    "org.apache.james" % "apache-mime4j-project" % "0.7.2"
 )
 
 resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",

File src/main/resources/logback.xml

             <pattern>%d{MMM dd, HH:mm:ss} [%p] - [%t] - %c.%M\(%F:%L\) %m %n</pattern>
         </encoder>
     </appender>
-    <logger name="com.miuler.mocksmtp.core" level="DEBUG">
+    <logger name="com.miuler.mocksmtp.gui" level="DEBUG">
         <appender-ref ref="stdout"/>
         <!--<appender-ref ref="logfile"/>-->
     </logger>

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

 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
 
 
 /**
   private var btnInitSMTP: QPushButton = _
   private var btnStopSMTP: QPushButton = _
   private var emails = ListBuffer[Message]()
+  private var treeView = new QTreeView
+  private var model: QStandardItemModel = _
 
   private var mockSMTP: MockSMTP = _
   private val connectionTheadNetty = new QConnectionThreadNetty
     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"))
+    model.setHeaderData(2, Qt.Orientation.Horizontal, tr("Asunto"))
+    treeView.setRootIsDecorated(false)
+    treeView.setAlternatingRowColors(true)
+    treeView.setModel(model)
+    treeView.setSortingEnabled(true)
+    treeView.sortByColumn(1, Qt.SortOrder.AscendingOrder)
+    // =============================================================
+
     val hlayout = new QHBoxLayout()
     hlayout.addWidget(btnInitSMTP)
     hlayout.addWidget(btnStopSMTP)
 
     val vlayout = new QVBoxLayout()
     vlayout.addItem(hlayout)
-    setLayout(hlayout)
+    vlayout.addWidget(treeView)
+    setLayout(vlayout)
     setWindowTitle("MOCK SMTP")
     show()
   }
   }
 
   def addEmail(msg: String) {
+//    val mimeStream = new MimeStreamParser
+//    mimeStream.parse(new ByteArrayInputStream(msg.getBytes()))
+    //new Message(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.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())
+    model.setData(model.index(0, 1), new Date toString)
+    model.setData(model.index(0, 2), email.getSubject())
+    model.setData(model.index(0, 3), email)
     lcd.display(emails.size)
   }