summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/protolistview.cpp
blob: 1e3d195fdbe0e59f6e5f8452342ba1ccda800f9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/**********************************************************************
** Copyright (C) 2002-2004 Michael 'Mickey' Lauer.  All rights reserved.
**
** This file is part of Wellenreiter II.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/

/* LOCAL */
#include "protolistview.h"

#include <qcheckbox.h>
#include <qcombobox.h>
#include <qvbox.h>
#include <qlabel.h>

ProtocolListView::ProtocolListView( QWidget* parent, const char* name, WFlags f )
                 :QScrollView( parent, name, f )
{
    parse = ( QString( "parsePackets" ) == QString( name ) );

    setMargins( 3, 3, 0, 0 );
    viewport()->setBackgroundColor( QCheckBox(0).palette().color( QPalette::Active, QColorGroup::Background ) );

    vbox = new QVBox( viewport() );
    vbox->setSpacing( 1 );
    addChild( vbox );

    QHBox* hbox = new QHBox( vbox );
    hbox->setSpacing( 40 );
    new QLabel( tr( "Protocol Family" ), hbox );
    new QLabel( tr( "Perform Action" ), hbox );
    QFrame* frame = new QFrame( vbox );
    frame->setFrameStyle( QFrame::HLine + QFrame::Sunken );

    //TODO: hardcoded for now...a protocol database would be nice!?

    //addProtocol(  "Ethernet" );
    addProtocol(  "Prism" );
    //addProtocol(  "802.11" );
    addProtocol(  "802.11 Management" );
    addProtocol(  "802.11 SSID" );
    addProtocol(  "802.11 Rates" );
    addProtocol(  "802.11 CF" );
    addProtocol(  "802.11 FH" );
    addProtocol(  "802.11 DS" );
    addProtocol(  "802.11 Tim" );
    addProtocol(  "802.11 IBSS" );
    addProtocol(  "802.11 Challenge" );
    addProtocol(  "802.11 Data" );
    addProtocol(  "802.11 LLC" );
    addProtocol(  "802.11 Data" );
    addProtocol(  "IP" );
    addProtocol(  "ARP" );
    addProtocol(  "UDP" );
    addProtocol(  "TCP" );
}


ProtocolListView::~ProtocolListView()
{
}


void ProtocolListView::addProtocol( const QString& name )
{
    QHBox* hbox = new QHBox( vbox );
    new QCheckBox( name, hbox, name.local8Bit() );

    if ( parse )
    {
        QComboBox* combo = new QComboBox( hbox, name.local8Bit() );
        #ifdef QWS
        combo->setFixedWidth( 75 );
        #endif
        combo->insertItem( "Pass" );
        combo->insertItem( "Discard!" );
        combo->insertItem( "TouchSound" );
        combo->insertItem( "AlarmSound" );
        combo->insertItem( "KeySound" );
        combo->insertItem( "LedOn" );
        combo->insertItem( "LedOff" );
        combo->insertItem( "LogMessage" );
        combo->insertItem( "MessageBox" );
    }
    else
    {
        QComboBox* combo = new QComboBox( hbox, name.local8Bit() );
        #ifdef QWS
        combo->setFixedWidth( 75 );
        #endif
        combo->insertItem( "Pass" );
        combo->insertItem( "Discard!" );
    }
}


bool ProtocolListView::isProtocolChecked( const QString& name )
{
    QCheckBox* box = (QCheckBox*) child( name.local8Bit() );
    return ( box && box->isOn() );
}


QString ProtocolListView::protocolAction( const QString& name )
{
    QComboBox* combo = (QComboBox*) child( name.local8Bit(), "QComboBox" );
    if ( combo )
        return combo->currentText();
    else
        return "<unknown>";
}