summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/bluebase.cpp
blob: e3b9e534e50fd3a14942c115ca3118a86b8ee1d1 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * bluebase.cpp *
 * ---------------------
 *
 * begin       : Sun 10 17:20:00 CEST 2002
 * copyright   : (c) 2002 by Maximilian Reiß
 * email       : max.reiss@gmx.de
 *
 */
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "bluebase.h"
#include "scandialog.h"

#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qtabwidget.h>
#include <qscrollview.h>
#include <qvbox.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qcheckbox.h>
#include <qlineedit.h>

#include <qpe/resource.h>
#include <qpe/config.h>


namespace OpieTooth {


    BlueBase::BlueBase( QWidget* parent,  const char* name, WFlags fl )
        : BluetoothBase( parent, name, fl ) {


        QObject::connect( (QObject*) PushButton2,  SIGNAL( clicked() ), this, SLOT(startScan()));
        QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges()));

        QPalette pal = this->palette();
        QColor col = pal.color(QPalette::Active, QColorGroup::Background);
        pal.setColor(QPalette::Active, QColorGroup::Button, col);
        pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
        pal.setColor(QPalette::Normal, QColorGroup::Button, col);
        pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
        this->setPalette(pal);

        setCaption( tr( "Bluetooth Manager" ) );

        readConfig();
        initGui();
    }

/**
 * Reads all options from the config file
 */
    void BlueBase::readConfig() {

        Config cfg("bluetoothmanager");
        cfg.setGroup("bluezsettings");


        deviceName = cfg.readEntry("name", "No name"); // name the device should identify with
        defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak
        useEncryption = cfg.readNumEntry("useEncryption", 1);
        enableAuthentification = cfg.readNumEntry("enableAuthentification", 1);
        enablePagescan = cfg.readNumEntry("enablePagescan",1);
        enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1);

    }

/**
 * Writes all options to the config file
 */
    void BlueBase::writeConfig() {


        Config cfg("bluetoothmanager");
        cfg.setGroup("bluezsettings");


        cfg.writeEntry("name", deviceName);
        cfg.writeEntryCrypt("passkey", defaultPasskey);
        cfg.writeEntry("useEncryption", useEncryption);
        cfg.writeEntry("enableAuthentification", enableAuthentification);
        cfg.writeEntry("enablePagescan",enablePagescan);
        cfg.writeEntry("enableInquiryscan", enableInquiryscan);
}


/**
 * Set up the gui
 */
    void BlueBase::initGui() {

        StatusLabel->setText(getStatus()); // maybe move it to getStatus()

        cryptCheckBox->setChecked(useEncryption);
        authCheckBox->setChecked(enableAuthentification);
        pagescanCheckBox->setChecked(enablePagescan);
        inquiryscanCheckBox->setChecked(enableInquiryscan);
        deviceNameLine->setText(deviceName);
        passkeyLine->setText(defaultPasskey);
}


/**
 * Get the status informations and returns it
 * @return QString the status informations gathered
 */
    QString BlueBase::getStatus(){

        return ("manger.h need also a status method");

    }


/**
 * Read the current values from the gui and invoke writeConfig()
 */
    void BlueBase::applyConfigChanges() {

        deviceName =  deviceNameLine->text();
        defaultPasskey = passkeyLine->text();
        useEncryption = cryptCheckBox->isChecked();
        enableAuthentification = authCheckBox->isChecked();
        enablePagescan = pagescanCheckBox->isChecked();
        enableInquiryscan = inquiryscanCheckBox->isChecked();

        writeConfig();

        QMessageBox*  box = new QMessageBox(this, "Test");
        box->setText(tr("Changes applied"));
        box->show();

  // falls nötig hcid killhupen - die funktionalität adden
}


/**
 * Open the "scan for devices"  dialog
 */
    void BlueBase::startScan() {
        ScanDialog *scan = new ScanDialog( this, "", true);
        scan->showMaximized();
    }

/**
 * Decontructor
 */
    BlueBase::~BlueBase(){
    }

}