func (w *MainWindow) createActions() { newAct := ui.NewActionWithTextParent(w.Tr("&New"), w) newAct.SetIcon(ui.NewIconWithFilename(":/images/new.png")) newAct.SetShortcuts(ui.QKeySequence_New) newAct.SetStatusTip("Create a new file") newAct.OnTriggered(func() { w.newFile() }) openAct := ui.NewActionWithTextParent("&Open...", w) openAct.SetIcon(ui.NewIconWithFilename(":/images/open.png")) openAct.SetShortcuts(ui.QKeySequence_Open) openAct.SetStatusTip("Open an existing file") openAct.OnTriggered(func() { w.open() }) saveAct := ui.NewActionWithTextParent("&Save", w) saveAct.SetIcon(ui.NewIconWithFilename(":/images/save.png")) saveAct.SetShortcuts(ui.QKeySequence_Save) saveAct.SetStatusTip("Save the document to disk") saveAct.OnTriggered(func() { w.save() }) saveAsAct := ui.NewActionWithTextParent("&SaveAs...", w) saveAsAct.SetShortcuts(ui.QKeySequence_SaveAs) saveAsAct.SetStatusTip("Save the document under a new name") saveAsAct.OnTriggered(func() { w.saveAs() }) exitAct := ui.NewActionWithTextParent("&Exit", w) exitAct.SetShortcuts(ui.QKeySequence_Quit) exitAct.SetStatusTip("Exit the application") exitAct.OnTriggered(func() { w.Close() }) copyAct := ui.NewActionWithTextParent("&Copy", w) copyAct.SetIcon(ui.NewIconWithFilename(":/images/copy.png")) copyAct.SetShortcuts(ui.QKeySequence_Copy) copyAct.SetStatusTip("Copy the current selection's contents to the clipboard") copyAct.OnTriggered(func() { w.edit.Copy() }) w.edit.OnCopyAvailable(func(b bool) { copyAct.SetEnabled(b) }) cutAct := ui.NewActionWithTextParent("&Cut", w) cutAct.SetIcon(ui.NewIconWithFilename(":/images/cut.png")) cutAct.SetShortcuts(ui.QKeySequence_Cut) cutAct.SetStatusTip("Cut the current selection's contents to the clipboard") cutAct.OnTriggered(func() { w.edit.Cut() }) w.edit.OnCopyAvailable(func(b bool) { cutAct.SetEnabled(b) }) pasteAct := ui.NewActionWithTextParent("&Paste", w) pasteAct.SetIcon(ui.NewIconWithFilename(":/images/paste.png")) pasteAct.SetShortcuts(ui.QKeySequence_Paste) pasteAct.SetStatusTip("Paste the clipboard's contents into the current selection") pasteAct.OnTriggered(func() { w.edit.Paste() }) aboutAct := ui.NewActionWithTextParent("&About", w) aboutAct.SetStatusTip("Show the application's About box") aboutAct.OnTriggered(func() { ui.QMessageBoxAbout(w, "About Application", w.Tr("The <b>Application</b> example demonstrates how to "+ "write modern GUI applications using Qt, with a menu bar, "+ "toolbars, and a status bar.")) }) aboutQtAct := ui.NewActionWithTextParent("About &Qt", w) aboutQtAct.SetStatusTip("Show the Qt library's About box") aboutQtAct.OnTriggered(func() { ui.QApplicationAboutQt() }) fileMenu := w.MenuBar().AddMenuWithTitle("&File") fileMenu.AddAction(newAct) fileMenu.AddAction(openAct) fileMenu.AddAction(saveAct) fileMenu.AddAction(saveAsAct) fileMenu.AddSeparator() fileMenu.AddAction(exitAct) editMenu := w.MenuBar().AddMenuWithTitle("&Edit") editMenu.AddAction(copyAct) editMenu.AddAction(cutAct) editMenu.AddAction(pasteAct) helpMenu := w.MenuBar().AddMenuWithTitle("&Help") helpMenu.AddAction(aboutAct) helpMenu.AddSeparator() helpMenu.AddAction(aboutQtAct) fileToolBar := w.AddToolBar("File") fileToolBar.AddAction(newAct) fileToolBar.AddAction(openAct) fileToolBar.AddAction(saveAct) editToolBar := w.AddToolBar("Edit") editToolBar.AddAction(copyAct) editToolBar.AddAction(cutAct) editToolBar.AddAction(pasteAct) copyAct.SetEnabled(false) cutAct.SetEnabled(false) w.StatusBar().ShowMessage("Ready") }
func main_ui() { app := ui.Application() app.SetOrganizationName("?") app.SetApplicationName("Recoil") w := &MainWindow{} w.QMainWindow = ui.NewMainWindow() // Widgets w.targetSectionLabel = ui.NewLabel() w.targetSectionLabel.SetText("Target Test Settings") font := w.Font() font.SetPointSize(font.PointSize() + 1) w.targetSectionLabel.SetFont(font) w.labelTarget = ui.NewLabel() w.labelTarget.SetText(fmt.Sprintf("Target Address")) w.labelTarget.SetFixedWidth(400) w.editTarget = ui.NewLineEdit() w.editTarget.SetPlaceholderText(fmt.Sprintf("target.onion")) w.labelAction = ui.NewLabel() w.labelAction.SetText(fmt.Sprintf("Action")) w.editAction = ui.NewComboBox() w.editAction.AddItem(fmt.Sprintf("ping")) w.editAction.AddItem(fmt.Sprintf("contact-request")) w.editAction.AddItem(fmt.Sprintf("send-messages")) w.editAction.AddItem(fmt.Sprintf("spamchannel")) w.editAction.SetFixedWidth(400) w.localSectionLabel = ui.NewLabel() w.localSectionLabel.SetText(fmt.Sprintf("Local Test Settings")) w.localSectionLabel.SetFont(font) w.labelHostname = ui.NewLabel() w.labelHostname.SetText(fmt.Sprintf("Onion Hostname")) w.labelHostname.SetFixedWidth(400) w.editHostname = ui.NewLineEdit() w.editHostname.SetPlaceholderText(fmt.Sprintf("something.onion")) w.editHostname.SetFixedWidth(400) w.labelName = ui.NewLabel() w.labelName.SetText(fmt.Sprintf("Ricochet Name")) w.labelName.SetFixedWidth(400) w.editName = ui.NewLineEdit() w.editName.SetText("recoil") w.editName.SetPlaceholderText(fmt.Sprintf("Ricochet Name")) w.editName.SetFixedWidth(400) w.labelKey = ui.NewLabel() w.labelKey.SetText(fmt.Sprintf("Onion Private Key")) w.labelKey.SetFixedWidth(400) w.editKey = ui.NewPlainTextEdit() w.editKey.SetFixedWidth(400) w.editKey.SetFixedHeight(99) w.labelMessage = ui.NewLabel() w.labelMessage.SetText(fmt.Sprintf("Message")) w.editMessage = ui.NewPlainTextEdit() w.editMessage.SetFixedHeight(100) w.editMessage.AppendPlainText(fmt.Sprintf("I am the recoil testing tool")) w.sendButton = ui.NewPushButton() w.sendButton.SetText("Send") w.clearLogsButton = ui.NewPushButton() w.clearLogsButton.SetText("Clear Logs") w.sendButton.OnClicked(func() { // Need to add back in debug target := w.editTarget.DisplayText() //debug := false action := w.editAction.CurrentText() hostname := w.editHostname.DisplayText() privateKey := w.editKey.ToPlainText() name := w.editName.DisplayText() message := w.editMessage.ToPlainText() if target == "" { w.logsBox.AppendPlainText(fmt.Sprintf("[ERROR] Target must be specified.")) w.StatusBar().ShowMessage("Error: Target must be specified.") return } else if hostname == "" { w.logsBox.AppendPlainText(fmt.Sprintf("[ERROR] Hostname must be specified.")) w.StatusBar().ShowMessage("Error: Hostname must be specified.") return } else if privateKey == "" { w.logsBox.AppendPlainText(fmt.Sprintf("[ERROR] Onion key must be specified.")) w.StatusBar().ShowMessage("Error: Onion key must be specified.") return } recoil := new(recoil.Recoil) recoil.Ready = make(chan bool) if action == "ping" { online := recoil.Ping(privateKey, hostname, target) if online == true { w.logsBox.AppendPlainText(fmt.Sprintf("[INFO] Target appears to be online.")) w.StatusBar().ShowMessage(fmt.Sprintf("%s appers to be online.", target)) } else { w.logsBox.AppendPlainText(fmt.Sprintf("[INFO] Target appears to be offline.")) w.StatusBar().ShowMessage(fmt.Sprintf("%s appers to be offline.", target)) } } else { go recoil.Authenticate(privateKey, hostname, target) log.Printf("Running Recoil...") ready := <-recoil.Ready log.Printf("Received Authentication Result %v", ready) if ready == true { if action == "contact-request" { recoil.SendContactRequest(name, message) w.logsBox.AppendPlainText(fmt.Sprintf("[INFO] Sent contact request to %s.", target)) w.StatusBar().ShowMessage(fmt.Sprintf("Sent contact request to %s.", target)) } else if action == "spamchannel" { // go recoil.SpamChannel() // w.logsBox.AppendPlainText("[ERROR] spamchannel action not functional.") // w.StatusBar().ShowMessage("Error: spamchannel action not functional.") } } } }) w.labelLogs = ui.NewLabel() w.labelLogs.SetText(fmt.Sprintf("Logs")) w.logsBox = ui.NewPlainTextEdit() w.logsBox.SetFixedWidth(800) w.logsBox.AppendPlainText(fmt.Sprintf("[Recoil] Ricochet testing toolkit")) w.logsBox.SetReadOnly(true) targetRow := ui.NewHBoxLayout() targetSection := ui.NewVBoxLayout() targetSection.AddWidget(w.labelTarget) targetSection.AddWidget(w.editTarget) actionSection := ui.NewVBoxLayout() actionSection.AddWidget(w.labelAction) actionSection.AddWidget(w.editAction) targetRow.AddLayout(targetSection) targetRow.AddLayout(actionSection) localRow := ui.NewHBoxLayout() localCol1 := ui.NewVBoxLayout() localCol1.AddWidget(w.labelName) localCol1.AddWidget(w.editName) localCol1.AddWidget(w.labelHostname) localCol1.AddWidget(w.editHostname) localRow.AddLayout(localCol1) localCol2 := ui.NewVBoxLayout() localCol2.AddWidget(w.labelKey) localCol2.AddWidget(w.editKey) localRow.AddLayout(localCol2) buttonRow := ui.NewHBoxLayout() buttonRow.AddWidget(w.sendButton) buttonRow.AddWidget(w.clearLogsButton) inputLayout := ui.NewVBoxLayout() inputLayout.AddWidget(w.localSectionLabel) inputLayout.AddLayout(localRow) inputLayout.AddWidget(w.targetSectionLabel) inputLayout.AddLayout(targetRow) inputLayout.AddWidget(w.labelMessage) inputLayout.AddWidget(w.editMessage) inputLayout.AddWidget(w.labelLogs) inputLayout.AddWidget(w.logsBox) inputLayout.AddLayout(buttonRow) centralWidget := ui.NewWidget() centralWidget.SetLayout(inputLayout) w.SetCentralWidget(centralWidget) w.clearLogsButton.OnClicked(func() { w.logsBox.Clear() }) //splash := ui.NewSplashScreen() //splash.ShowMessage("test") openMessageAct := ui.NewActionWithTextParent("&Open Message File...", w) openMessageAct.OnTriggered(func() { w.openMessage() }) openOnionHostnameAct := ui.NewActionWithTextParent("&Open Onion Service Hostname...", w) openOnionHostnameAct.OnTriggered(func() { w.openOnionHostname() }) openOnionKeyAct := ui.NewActionWithTextParent("&Open Onion Service Key...", w) openOnionKeyAct.OnTriggered(func() { w.openOnionKey() }) saveMessageAct := ui.NewActionWithTextParent("&Save Message File...", w) saveMessageAct.OnTriggered(func() { w.saveMessage() }) saveMessageAsAct := ui.NewActionWithTextParent("&Save Message File As...", w) saveMessageAsAct.OnTriggered(func() { w.saveMessageAs() }) exitAct := ui.NewActionWithTextParent("&Exit", w) exitAct.OnTriggered(func() { os.Exit(0) }) fileMenu := w.MenuBar().AddMenuWithTitle("&File") fileMenu.AddAction(openMessageAct) fileMenu.AddAction(openOnionHostnameAct) fileMenu.AddAction(openOnionKeyAct) fileMenu.AddSeparator() fileMenu.AddAction(saveMessageAct) fileMenu.AddAction(saveMessageAsAct) fileMenu.AddSeparator() fileMenu.AddAction(exitAct) w.setCurrentMessageFile("") w.StatusBar().ShowMessage("Ready") w.Show() }