Debian Codegraph @

HercUtilities/TapeCopy.cpp

raw symbols SCIP
1 /*
2 * File: TapeCopy.cpp
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 31, 2010
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24 #include "TapeCopy.h"
25 #include "Preferences.h"
26 #include "UtilityExecutor.h"
27 #include "UtilityRunner.h"
28 #include "StringTokenizer.h"
29
30 #include <QFileDialog>
31 #include <QFile>
32 #include <QMessageBox>
33 #include <QTimer>
34
35 #include <csignal>
36
37
38 TapeCopy::TapeCopy(QWidget *parent)
39 : GenericUtility("tapecopy",parent)
40 {
41 ui.setupUi(this);
42 mUpperGeometry = ui.FileBox->geometry();
43 mLowerGeometry = ui.ScsiBox->geometry();
44 connect(ui.scsiToFileRadio, SIGNAL(clicked()), this, SLOT(scsiToTape()));
45 connect(ui.fileToScsiRadio, SIGNAL(clicked()), this, SLOT(tapeToScsi()));
46 connect(ui.runButton, SIGNAL(clicked()), this, SLOT(runClicked()));
47 connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(cancelClicked()));
48 connect(ui.browseFileButton, SIGNAL(clicked()), this, SLOT(browseFileClicked()));
49 }
50
51 TapeCopy::~TapeCopy()
52 {
53
54 }
55
56 void TapeCopy::runClicked()
57 {
58 if (!runOrStopClicked())
59 {
60 ui.runButton->setText("Run");
61 return;
62 }
63 if (ui.filename->text().isEmpty())
64 {
65 QMessageBox::warning(this, "tapecopy", "Please specify tape file to process",
66 QMessageBox::Ok, QMessageBox::NoButton);
67 return;
68 }
69 if (!QFile::exists(ui.filename->text()))
70 {
71 QMessageBox::warning(this, "tapecopy", "The specified file does not exist",
72 QMessageBox::Ok, QMessageBox::NoButton);
73 return;
74 }
75
76 std::vector<std::string> parameters;
77 parameters.push_back(ui.filename->text().toStdString());
78 std::string scsi="/dev/st";
79 scsi+=ui.spinBox->text().toStdString();
80 parameters.push_back(scsi.c_str());
81 std::string command = "tapecopy";
82
83 execute(command, Preferences::getInstance().hercDir(), parameters);
84
85 ui.runButton->setText("Stop");
86 }
87
88 void TapeCopy::browseFileClicked()
89 {
90 QString dir = ui.filename->text();
91 if (dir.isEmpty())
92 dir = Preferences::getInstance().configDir().c_str();
93 QString s = QFileDialog::getOpenFileName(this,"Browse for tape to map",dir);
94 ui.filename->setText(s);
95 }
96
97 void TapeCopy::cancelClicked()
98 {
99 deleteLater();
100 }
101
102 void TapeCopy::tapeToScsi()
103 {
104 ui.FileBox->setGeometry(mUpperGeometry);
105 ui.ScsiBox->setGeometry(mLowerGeometry);
106 ui.FileBox->setTitle("Input Tape");
107 ui.ScsiBox->setTitle("Output Tape");
108 }
109
110 void TapeCopy::scsiToTape()
111 {
112 ui.FileBox->setGeometry(mLowerGeometry);
113 ui.ScsiBox->setGeometry(mUpperGeometry);
114 ui.FileBox->setTitle("Output Tape");
115 ui.ScsiBox->setTitle("Input Tape");
116 }
117
118 void TapeCopy::finishedSlot()
119 {
120
121 }