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
|
/***************************************************************************
wpeditaccount.cpp - description
-------------------
begin : Fri Apr 26 2002
copyright : (C) 2002 by Gav Wood
email : gav@kde.org
Based on code from : (C) 2002 by Duncan Mac-Vicar Prett
email : duncan@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// Standard Unix Includes
#include <unistd.h>
// QT Includes
#include <tqcheckbox.h>
#include <tqfile.h>
// KDE Includes
#include <kdebug.h>
#include <klocale.h>
#include <kurlrequester.h>
#include <knuminput.h>
#include <klineedit.h>
#include <kmessagebox.h>
#include <kconfig.h>
#include <kapplication.h>
#include <kstandarddirs.h>
// Kopete Includes
#include <addcontactpage.h>
// Local Includes
#include "wpaccount.h"
#include "wpeditaccount.h"
#include "wpprotocol.h"
WPEditAccount::WPEditAccount(TQWidget *tqparent, Kopete::Account *theAccount)
: WPEditAccountBase(tqparent), KopeteEditAccountWidget(theAccount)
{
kdDebug(14170) << "WPEditAccount::WPEditAccount(<tqparent>, <theAccount>)";
mProtocol = WPProtocol::protocol();
TQString tmpSmbcPath = KStandardDirs::findExe("smbclient");
if(account()) {
mHostName->setText(account()->accountId());
// mAutoConnect->setChecked(account()->excludeConnect());
mHostName->setReadOnly(true);
KGlobal::config()->setGroup("WinPopup");
mHostCheckFreq->setValue(KGlobal::config()->readNumEntry("HostCheckFreq", 60));
mSmbcPath->setURL(KGlobal::config()->readEntry("SmbcPath", tmpSmbcPath));
}
else {
// no QT/KDE function? GF
TQString theHostName = TQString();
char *tmp = new char[255];
if (tmp != 0) {
gethostname(tmp, 255);
theHostName = tmp;
if (theHostName.contains('.') != 0) theHostName.remove(theHostName.find('.'), theHostName.length());
theHostName = theHostName.upper();
}
if (!theHostName.isEmpty())
mHostName->setText(theHostName);
else
mHostName->setText("LOCALHOST");
mHostCheckFreq->setValue(60);
mSmbcPath->setURL(tmpSmbcPath);
}
show();
}
void WPEditAccount::installSamba()
{
mProtocol->installSamba();
}
bool WPEditAccount::validateData()
{
kdDebug(14170) << "WPEditAccount::validateData()";
if(mHostName->text().isEmpty()) {
KMessageBox::sorry(this, i18n("<qt>You must enter a valid screen name.</qt>"), i18n("WinPopup"));
return false;
}
TQFile smbc(mSmbcPath->url());
if (!smbc.exists()) {
KMessageBox::sorry(this, i18n("<qt>You must enter a valid smbclient path.</qt>"), i18n("WinPopup"));
return false;
}
return true;
}
void WPEditAccount::writeConfig()
{
KGlobal::config()->setGroup("WinPopup");
KGlobal::config()->writeEntry("SmbcPath", mSmbcPath->url());
KGlobal::config()->writeEntry("HostCheckFreq", mHostCheckFreq->text());
}
Kopete::Account *WPEditAccount::apply()
{
kdDebug(14170) << "WPEditAccount::apply()";
if(!account())
setAccount(new WPAccount(mProtocol, mHostName->text()));
// account()->setExcludeConnect(mAutoConnect->isChecked());
writeConfig();
mProtocol->settingsChanged();
return account();
}
#include "wpeditaccount.moc"
// vim: set noet ts=4 sts=4 sw=4:
// kate: tab-width 4; indent-width 4; replace-trailing-space-save on;
|