1
/***************************************************************************
2
* Copyright (C) 2007-2011 by Francesco Cecconi *
3
* francesco.cecconi@gmail.com *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18
***************************************************************************/
22
void nmapClass::openBrowser()
24
_utilities->openFileBrowser(lineInputFile);
27
QFile* nmapClass::create_logFile(const QString Path)
29
QFile *Pfile = new QFile();
30
QDir::setCurrent(Path);
31
Pfile->setFileName(FileName);
35
void nmapClass::fileSession()
39
if ((!_logFilePath) || (_logFilePath && (firstPath != logPath) && (FLAGS = 1)))
44
QDir::setCurrent(firstPath);
45
#ifndef TOOLS_NO_DEBUG
46
qDebug() << "DEBUG::SESSION:: " << _logFilePath << firstPath << logPath;
48
_logFilePath->remove();
51
FileName = QDate::currentDate().toString("[dd-MM-yyyy]");
52
FileName.append(QTime::currentTime().toString("[h-m-s]"));
53
FileName.append("-nmapsi4.log");
55
_logFilePath = create_logFile(logPath);
56
_logFilePath->open(QIODevice::WriteOnly | QIODevice::Text);
60
void nmapClass::isEmptyLog()
62
qint64 tmp = _logFilePath->size();
66
QDir::setCurrent(logPath);
67
_logFilePath->setFileName(FileName);
68
_logFilePath->remove();
70
else if (firstPath.compare(logPath))
72
QString pathTmp = logPath;
74
pathTmp = QDir::toNativeSeparators(pathTmp);
75
pathTmp.append(FileName);
77
if (!_logFilePath->copy(FileName, pathTmp))
79
QMessageBox::critical(this, "NmapSI4",
80
tr("Save File permission Error (Log stored in /tmp)\n"), tr("Close"));
84
_logFilePath->remove();
89
void nmapClass::saveAsLog()
91
if (FileName.isNull() || listClearFlag)
93
QMessageBox::critical(this, tr("Save Log"), tr("No Scan found\n"), tr("Close"));
97
QFile *tmpFile = new QFile();
98
QString newFilePath = logPath;
99
newFilePath.append("/");
100
newFilePath = QDir::toNativeSeparators(newFilePath);
101
newFilePath.append(FileName);
102
tmpFile->setFileName(newFilePath);
104
if (!tmpFile->size())
106
QMessageBox::critical(this, tr("Save Log"),tr("No Scan found\n"), tr("Close"));
112
url = QDir::homePath();
114
url = QDir::toNativeSeparators(url);
116
url.append(_VERSION_);
118
url.append(hostEdit->currentText());
122
FileNameTmp = QFileDialog::getSaveFileName(this, tr("Save Log"), url, tr("Log (*.log)"));
124
if (!FileNameTmp.isEmpty())
127
QFile *freeFile = new QFile();
128
freeFile->setFileName(FileNameTmp);
129
if (freeFile->exists())
135
if (!tmpFile->copy(FileNameTmp))
137
QMessageBox::critical(this, tr("Information"),
138
tr("Save File permission Error (Log stored in /tmp)\n"), tr("Close"));
141
logSessionFile = FileNameTmp;
147
void nmapClass::saveLog()
150
if (logSessionFile.isEmpty())
155
QFile *tmpFile = new QFile();
156
QString newFile = logPath;
158
newFile = QDir::toNativeSeparators(newFile);
159
newFile.append(FileName);
160
tmpFile->setFileName(newFile);
162
QFile *freeFile = new QFile();
163
freeFile->setFileName(logSessionFile);
165
if (freeFile->exists())
172
if (!tmpFile->copy(logSessionFile))
174
QMessageBox::critical(this, tr("Information"),
175
tr("Save File permission Error\n"), tr("Close"));