~brand-nmapsi4/nmapsi4/master

« back to all changes in this revision

Viewing changes to src/app/monitor/monitor.h

  • Committer: Francesco Cecconi
  • Date: 2011-12-18 11:02:04 UTC
  • Revision ID: git-v1:60a69e132c8ffeb2727e558b2b2e8ac1713e332e
Removed nmapsi4-logr (dedicate repository) but it could be deprecated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2011 by Francesco Cecconi                               *
 
3
 *   francesco.cecconi@gmail.com                                           *
 
4
 *                                                                         *
 
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.        *
 
8
 *                                                                         *
 
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.                          *
 
13
 *                                                                         *
 
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
 ***************************************************************************/
 
19
 
 
20
#ifndef MONITOR_H
 
21
#define MONITOR_H
 
22
 
 
23
// Qt include
 
24
#include <QtGui/QTreeWidget>
 
25
#include <QtCore/QObject>
 
26
#include <QtCore/QList>
 
27
#include <QtCore/QHash>
 
28
 
 
29
#ifdef Q_WS_X11
 
30
#include <QtDBus/QDBusConnection>
 
31
#endif
 
32
 
 
33
// local include
 
34
#include "memorytools.h"
 
35
#include "qprocessthread.h"
 
36
#include "details.h"
 
37
#include "lookupmanager.h"
 
38
#include "digmanager.h"
 
39
 
 
40
using namespace memory;
 
41
 
 
42
class nmapClass;
 
43
 
 
44
class monitor : public QObject
 
45
{
 
46
    Q_OBJECT
 
47
 
 
48
#ifdef Q_WS_X11
 
49
    Q_CLASSINFO("D-Bus Interface", "org.nmapsi4.Nmapsi4")
 
50
#endif
 
51
 
 
52
public:
 
53
    monitor(QTreeWidget* monitor, nmapClass* parent);
 
54
    ~monitor();
 
55
 
 
56
    enum LookupType
 
57
    {
 
58
        DigLookup,
 
59
        InternalLookup,
 
60
        DisabledLookup
 
61
    };
 
62
    /*
 
63
     * Add host in the monitor and start scan.
 
64
     */
 
65
    void addMonitorHost(const QString hostName, const QStringList parameters, LookupType option);
 
66
    /*
 
67
     * Return true if host is present in the monitor, otherwise return false.
 
68
     */
 
69
    bool isHostOnMonitor(const QString hostname);
 
70
    /*
 
71
     * Return current number of scanning host in the monitor.
 
72
     */
 
73
    int monitorHostNumber();
 
74
    /*
 
75
     * Clear all host in monitor
 
76
     */
 
77
    void clearHostMonitor();
 
78
    /*
 
79
     * Clear all scan host details
 
80
     */
 
81
    void clearHostMonitorDetails();
 
82
 
 
83
private:
 
84
    void startScan(const QString hostname, QStringList parameters);
 
85
    void startLookup(const QString hostname, LookupType option);
 
86
    void updateMonitorHost(const QString hostName, int valueIndex, const QString newData);
 
87
    /*
 
88
     * This method remove scanThread elem from scan hashTable
 
89
     */
 
90
    QProcessThread* takeMonitorElem(const QString hostName);
 
91
    /*
 
92
     * Delete host from monitor
 
93
     */
 
94
    void delMonitorHost(const QString hostName);
 
95
 
 
96
protected:
 
97
    QList<QTreeWidgetItem*> monitorElem;
 
98
    QHash<QString, QProcessThread*> _scanHashList;
 
99
    QHash<QString, QStringList> _scanHashListFlow;
 
100
    QList<lookupManager*> internealLookupList;
 
101
    QList<digManager*> digLookupList;
 
102
    QTreeWidget* _monitor;
 
103
    nmapClass* _ui;
 
104
 
 
105
signals:
 
106
    /*
 
107
     * Exported with dbus
 
108
     */
 
109
    Q_SCRIPTABLE void monitorUpdated(int hostNumber);
 
110
    /*
 
111
     * Return scan result
 
112
     */
 
113
    void hostFinisced(const QStringList parametersList, QByteArray dataBuffer, QByteArray errorBuffer);
 
114
 
 
115
private slots:
 
116
    void readFlowFromThread(const QString hostname, QString lineData);
 
117
    void scanFinisced(const QStringList parametersList, QByteArray dataBuffer, QByteArray errorBuffer);
 
118
    void lookupFinisced(QHostInfo info, int state, const QString hostname);
 
119
 
 
120
public slots:
 
121
        /*
 
122
     * Stop host scan selected in the QTreeWidget.
 
123
     */
 
124
    void stopSelectedScan();
 
125
    void showSelectedScanDetails();
 
126
};
 
127
 
 
128
#endif