File: icqconfig.cpp

package info (click to toggle)
sim 0.9.5~svn20080806-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 18,108 kB
  • ctags: 11,570
  • sloc: cpp: 119,605; sh: 9,986; ansic: 3,312; perl: 2,752; lex: 1,533; makefile: 839; xml: 206; python: 56
file content (156 lines) | stat: -rw-r--r-- 5,771 bytes parent folder | download
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
/***************************************************************************
                          icqconfig.cpp  -  description
                             -------------------
    begin                : Sun Mar 17 2002
    copyright            : (C) 2002 by Vladimir Shutoff
    email                : vovan@shutoff.ru
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 "icqconfig.h"
#include "icq.h"
#include "core.h"

#include <qtimer.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qspinbox.h>
#include <qvalidator.h>
#include <qtabwidget.h>
#include <qcombobox.h>

using namespace SIM;

ICQConfig::ICQConfig(QWidget *parent, ICQClient *client, bool bConfig)
        : ICQConfigBase(parent)
{
    m_client = client;
    m_bConfig = bConfig;
    EventGetPluginInfo ePlugin("_core");
    ePlugin.process();
    const pluginInfo *info = ePlugin.info();
    core = static_cast<CorePlugin*>(info->plugin);
    if (m_bConfig){
        QTimer::singleShot(0, this, SLOT(changed()));
        connect(chkNew, SIGNAL(toggled(bool)), this, SLOT(newToggled(bool)));
        if (m_client->data.owner.Uin.toULong()){
            edtUin->setText(QString::number(m_client->data.owner.Uin.toULong()));
            chkNew->setChecked(false);
            edtPasswd->setText(m_client->getPassword());
        }else if(core->getRegNew()) {
          edtUin->setText(core->getICQUIN());
          edtPasswd->setText(core->getICQPassword());
        }else{
            chkNew->setChecked(true);
        }
        edtUin->setValidator(new QIntValidator(1000, 0x1FFFFFFF, edtUin));
        connect(edtUin, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
        connect(edtPasswd, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
    }else{
        tabConfig->removePage(tabICQ);
    }
    edtServer->setText(QString::fromLocal8Bit(m_client->getServer()));
    edtPort->setValue(m_client->getPort());
    edtMinPort->setValue(m_client->getMinPort());
    edtMaxPort->setValue(m_client->getMaxPort());
    connect(edtServer, SIGNAL(textChanged(const QString&)), this, SLOT(changed(const QString&)));
    connect(edtPort, SIGNAL(valueChanged(const QString&)), this, SLOT(changed(const QString&)));
    cmbFormat->insertItem(i18n("RTF"));
    cmbFormat->insertItem(i18n("UTF"));
    cmbFormat->insertItem(i18n("Plain text"));
    cmbFormat->setCurrentItem(client->getSendFormat());
    chkPlugins->setChecked(client->getDisablePlugins());
    chkUpdate->setChecked(client->getDisableAutoUpdate());
    chkAutoReply->setChecked(client->getDisableAutoReplyUpdate());
    chkTyping->setChecked(client->getDisableTypingNotification());
    chkInvisible->hide();
    edtInvisible->hide();
    lblInvisible->hide();
    lblInvisible2->hide();
    chkDND->setChecked(client->getAcceptInDND());
    chkOccupied->setChecked(client->getAcceptInOccupied());
    chkHTTP->setChecked(client->getUseHTTP());
    connect(chkAuto, SIGNAL(toggled(bool)), this, SLOT(autoToggled(bool)));
    connect(chkInvisible, SIGNAL(toggled(bool)), this, SLOT(invisibleToggled(bool)));
    chkAuto->setChecked(client->getAutoHTTP());
    chkKeepAlive->setChecked(client->getKeepAlive());
    cmbAck->setCurrentItem(client->getAckMode());
}

void ICQConfig::autoToggled(bool bState)
{
    chkHTTP->setEnabled(!bState);
}

void ICQConfig::invisibleToggled(bool bState)
{
    lblInvisible->setEnabled(bState);
    lblInvisible2->setEnabled(bState);
    edtInvisible->setEnabled(bState);
}

void ICQConfig::apply(Client*, void*)
{
}

void ICQConfig::apply()
{
    if (m_bConfig){
        m_client->setUin(edtUin->text().toULong());
        m_client->setPassword(edtPasswd->text());
    }
    m_client->setServer(edtServer->text());
    m_client->setPort(edtPort->text().toUShort());
    m_client->setMinPort(edtMinPort->text().toUShort());
    m_client->setMaxPort(edtMaxPort->text().toUShort());
    m_client->setSendFormat(cmbFormat->currentItem());
    m_client->setDisablePlugins(chkPlugins->isChecked());
    m_client->setDisableAutoUpdate(chkUpdate->isChecked());
    m_client->setDisableAutoReplyUpdate(chkAutoReply->isChecked());
    m_client->setDisableTypingNotification(chkTyping->isChecked());
    m_client->setAcceptInDND(chkDND->isChecked());
    m_client->setAcceptInOccupied(chkOccupied->isChecked());
    m_client->setUseHTTP(chkHTTP->isChecked());
    m_client->setAutoHTTP(chkAuto->isChecked());
    m_client->setKeepAlive(chkKeepAlive->isChecked());
    m_client->setAckMode(cmbAck->currentItem());
}

void ICQConfig::changed(const QString&)
{
    changed();
}

void ICQConfig::newToggled(bool bNew)
{
    if (bNew)
        edtUin->setText(QString::null);
    lblUin->setEnabled(!bNew);
    edtUin->setEnabled(!bNew);
}

void ICQConfig::changed()
{
    bool bOK = true;
    if (!chkNew->isChecked())
        bOK = (edtUin->text().toLong() > 1000);
    bOK =  bOK && !edtPasswd->text().isEmpty() &&
           !edtServer->text().isEmpty() &&
           edtPort->text().toUShort();
    emit okEnabled(bOK);
}

#ifndef NO_MOC_INCLUDES
#include "icqconfig.moc"
#endif