Commits

Hector Miuler Malpica Gallegos committed f8f9ed6

agregando la libreria qtjambi-4.7.0 y primeras pruebas de qt con boton para iniciar y parar

Comments (0)

Files changed (9)

 target
 \.idea
 .*\.iml
+.*\.swp
     "junit" % "junit" % "4.10" % "test",
     "org.specs2" %% "specs2" % "1.12.1" % "test",
     "net.liftweb" %% "lift-json" % "2.5-M1",
-    "org.jboss.netty" % "netty" % "3.2.7.Final"
+    "io.netty" % "netty" % "4.0.0.Alpha5"
 )
 
 resolvers ++= Seq("snapshots" at "http://oss.sonatype.org/content/repositories/snapshots",

lib/qtjambi-4.7.0.jar

Binary file added.

src/main/scala/com/miuler/mocksmtp/Constant.scala

-package com.miuler.mocksmtp
-
-/**
- * Created with IntelliJ IDEA.
- * User: miuler
- * Date: 17/09/12
- * Time: 03:01 PM
- * To change this template use File | Settings | File Templates.
- */
-object Constant {
-  val PORT = 80
-}

src/main/scala/com/miuler/mocksmtp/Main.scala

 package com.miuler.mocksmtp
 
+import com.miuler.mocksmtp.gui.MainGUI
+
 /**
  * Created with IntelliJ IDEA.
  * User: miuler
 object Main {
 
   def main(argv : Array[String]) {
-    var mockSMTP = new MockSMTP(Array("a1", "b2", "c3"))
+    val mainGUI = new MainGUI()
+    mainGUI.run()
   }
 
 }

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

-package com.miuler.mocksmtp
-
-import java.util.concurrent.Executors
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory
-import org.jboss.netty.channel.{ChannelPipeline, ChannelPipelineFactory, ChannelFactory}
-import org.jboss.netty.bootstrap.ClientBootstrap
-import org.jboss.netty.handler.codec.frame.{Delimiters, DelimiterBasedFrameDecoder}
-
-
-/**
- * Created with IntelliJ IDEA.
- * User: miuler
- * Date: 13/09/12
- * Time: 08:16 PM
- * To change this template use File | Settings | File Templates.
- */
-class MockSMTP(id: String, serverId: String) {
-
-
-  def initSMTP() {
-    val bossPoll = Executors.newCachedThreadPool()
-    val workerPoll = Executors.newCachedThreadPool()
-    val factory = new NioClientSocketChannelFactory(bossPoll, workerPoll)
-    val frameDecoder = new DelimiterBasedFrameDecoder(Integer.MAX_VALUE, Delimiters.lineDelimiter():_*)
-    val bootstrap = new ClientBootstrap(factory)
-
-    bootstrap.setPipelineFactory(new ChannelPipelineFactory {
-
-      def getPipeline: ChannelPipeline = {
-        //val byteCounter = new ByteCounter("+++ SERVER-COUNTER :: ")
-        //val messageCounter = new MessageCounter("+++ SERVER-MSGCOUNTER :: ")
-        //new ClientHandshakeHandler(id, serverId, 5000)
-      }
-
-    })
-
-  }
-
-
-}

src/main/scala/com/miuler/mocksmtp/core/Constant.scala

+package com.miuler.mocksmtp.core
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: miuler
+ * Date: 17/09/12
+ * Time: 03:01 PM
+ * To change this template use File | Settings | File Templates.
+ */
+object Constant {
+  val PORT = 80
+}

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

+package com.miuler.mocksmtp.core
+
+import io.netty.bootstrap.ServerBootstrap
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: miuler
+ * Date: 30/09/12
+ * Time: 11:03 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class MockSMTP {
+
+  var server: ServerBootstrap = _
+
+  //    println("initSMTP - inicio")
+  //    server = new ServerBootstrap()
+  //    server.localAddress(8080)
+  //    println("initSMTP - fin")
+
+  private def start = server.bind().sync()
+
+  private def stop = server.shutdown()
+
+}

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

+package com.miuler.mocksmtp.gui
+
+import com.trolltech.qt.gui._
+
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: miuler
+ * Date: 13/09/12
+ * Time: 08:16 PM
+ * To change this template use File | Settings | File Templates.
+ */
+class MainGUI(id: String = null, serverId: String = null) {
+
+  var btnInitSMTP: QPushButton = _
+  var btnStopSMTP: QPushButton = _
+
+  def run() {
+    println("Hola Mundo")
+    QApplication.initialize(Array())
+    initGUI
+    QApplication.exec()
+  }
+
+  def initGUI {
+    btnInitSMTP = new QPushButton()
+    btnInitSMTP.setCheckable(true)
+    btnInitSMTP.setText("Iniciar servidor SMTP")
+    btnInitSMTP.toggled.connect(this, "startSMTP()")
+
+    btnStopSMTP = new QPushButton()
+    btnStopSMTP.setCheckable(true)
+    btnStopSMTP.setText("Parar servidor SMTP")
+    btnStopSMTP.toggle()
+    btnStopSMTP.setDisabled(true)
+    btnStopSMTP.toggled.connect(this, "stopSMTP()")
+
+    val layout = new QVBoxLayout()
+    layout.addWidget(btnInitSMTP)
+    layout.addWidget(btnStopSMTP)
+
+    val window = new QWidget()
+    window.setLayout(layout)
+    window.show()
+  }
+
+  def startSMTP() {
+    println("\ninitSMTP ==============")
+    if (btnInitSMTP.isChecked()) {
+      btnInitSMTP.setDisabled(true)
+      btnStopSMTP.toggle()
+      btnStopSMTP.setDisabled(false)
+    }
+  }
+
+  def stopSMTP() {
+    println("\nstopSMTP ==============")
+    println("btnInitSMTP.isChecked: " + btnInitSMTP.isChecked())
+    println("btnStopSMTP.isChecked: " + btnStopSMTP.isChecked())
+    if (btnStopSMTP.isChecked()) {
+      btnInitSMTP.setDisabled(false)
+      btnInitSMTP.toggle()
+      btnStopSMTP.setDisabled(true)
+    }
+  }
+
+}