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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
/***************************************************************************
printerdlgimpl.cpp - description
-------------------
begin : Tue June 6 2002
copyright : (C) 2002 by Jan Sch�fer
email : [email protected]
***************************************************************************/
/******************************************************************************
* *
* This file is part of KSambaPlugin. *
* *
* KSambaPlugin 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. *
* *
* KSambaPlugin is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with KSambaPlugin; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
* *
******************************************************************************/
/**
* @author Jan Sch�fer
**/
#include <tqcheckbox.h>
#include <tqlineedit.h>
#include <tqcombobox.h>
#include <tqlabel.h>
#include <tqlistbox.h>
#include <tqpainter.h>
#include <tqgroupbox.h>
#include <tqpixmap.h>
#include <tqbitmap.h>
#include <tqlayout.h>
#include <tqtabwidget.h>
#include <klineedit.h>
#include <kurlrequester.h>
#include <knuminput.h>
#include <kdebug.h>
#include <kdeprint/kmmanager.h>
#include <kdeprint/kmprinter.h>
#include <kcombobox.h>
#include <kiconloader.h>
#include <klocale.h>
#include <assert.h>
#include "sambafile.h"
#include "printerdlgimpl.h"
#include "usertabimpl.h"
#include "passwd.h"
#include "dictmanager.h"
PrinterDlgImpl::PrinterDlgImpl(TQWidget* tqparent, SambaShare* share)
: KcmPrinterDlg(tqparent,"sharedlgimpl")
{
if (!share) {
kdWarning() << "PrinterDlgImpl::Constructor : share parameter is null!" << endl;
return;
}
_share = share;
_dictMngr = new DictManager(share);
initDialog();
}
void PrinterDlgImpl::initDialog()
{
// Base settings
if (!_share)
return;
TQPtrList<KMPrinter> *printerList = KMManager::self()->printerListComplete();
for (TQPtrListIterator<KMPrinter> it(*printerList); it.current(); ++it)
{
if (!it.current()->isSpecial()){
queueCombo->insertItem(it.current()->printerName());
}
}
setComboToString(queueCombo,_share->getValue("printer name"));
_dictMngr->add("path",pathUrlRq);
printersChk->setChecked( _share->getName() == "printers" );
shareNameEdit->setText( _share->getName() );
_dictMngr->add("comment",commentEdit);
_dictMngr->add("available",availableBaseChk);
_dictMngr->add("browseable",browseableBaseChk);
_dictMngr->add("public",publicBaseChk);
// Users
_userTab = new UserTabImpl(this,_share);
_tabs->insertTab(_userTab,i18n("&Users"),1);
_userTab->load();
connect(_userTab, TQT_SIGNAL(changed()), this, TQT_SLOT(changedSlot()));
// Printing
_dictMngr->add("postscript",postscriptChk);
_dictMngr->add("use client driver",useClientDriverChk);
_dictMngr->add("default devmode",defaultDevmodeChk);
_dictMngr->add("max print jobs",maxPrintJobsSpin);
_dictMngr->add("max reported print jobs",maxReportedPrintJobsSpin);
_dictMngr->add("printing",printingCombo,
new TQStringList(TQStringList()
<< "sysv" << "aix" << "hpux" << "bsd" << "qnx"
<< "plp" << "lprng" << "softq" << "cups" << "nt" << "os2"));
_dictMngr->add("printer driver",printerDriverEdit);
_dictMngr->add("printer driver location",printerDriverLocationEdit);
// Commands
_dictMngr->add("print command",printCommandEdit);
_dictMngr->add("lpq command",lpqCommandEdit);
_dictMngr->add("lprm command",lprmCommandEdit);
_dictMngr->add("lppause",lppauseEdit);
_dictMngr->add("lpresume",lpresumeEdit);
_dictMngr->add("queuepause",queuepauseEdit);
_dictMngr->add("queueresume",queueresumeEdit);
// Security
_dictMngr->add("printer admin",printerAdminEdit);
_dictMngr->add("hosts allow",hostsAllowEdit);
_dictMngr->add("hosts deny",hostsDenyEdit);
guestAccountCombo->insertStringList( getUnixUsers() );
setComboToString(guestAccountCombo,_share->getValue("guest account"));
// Advanced
_dictMngr->add("min print space",minPrintSpaceSpin);
_dictMngr->add("status",statusChk);
_dictMngr->add("preexec",preExecEdit);
_dictMngr->add("postexec",postExecEdit);
_dictMngr->add("root preexec",rootPreExecEdit);
_dictMngr->add("root postexec",rootPostExecEdit);
_dictMngr->load( _share );
connect(_dictMngr, TQT_SIGNAL(changed()), this, TQT_SLOT(changedSlot()));
}
void PrinterDlgImpl::accept()
{
if (!_share)
return;
// Security
_share->setValue("guest account",guestAccountCombo->currentText( ) );
_share->setValue("printer name",queueCombo->currentText());
if (printersChk->isChecked())
{
_share->setName("printers");
}
else
_share->setName(shareNameEdit->text());
_userTab->save();
_dictMngr->save( _share );
KcmPrinterDlg::accept();
}
PrinterDlgImpl::~PrinterDlgImpl()
{
}
void PrinterDlgImpl::printersChkToggled(bool b)
{
if (b)
{
shareNameEdit->setText("printers");
shareNameEdit->setEnabled(false);
int dist = 10;
int w = 64 + dist;
int h = 64 + 2*dist;
TQPixmap pix(w,h);
pix.fill(); // fill with white
TQPixmap pix2 = DesktopIcon("printer1");
// Draw the printericon three times
TQPainter p(&pix);
p.drawPixmap(dist+dist/2,0,pix2);
p.drawPixmap(dist/2,dist,pix2);
p.drawPixmap(dist+dist/2,2*dist,pix2);
p.end();
TQBitmap tqmask(w,h);
tqmask.fill(TQt::black); // everything is transparent
p.begin(&tqmask);
p.setRasterOp(TQt::OrROP);
p.drawPixmap(dist+dist/2,0,*pix2.tqmask());
p.drawPixmap(dist/2,dist,*pix2.tqmask());
p.drawPixmap(dist+dist/2,2*dist,*pix2.tqmask());
p.end();
pix.setMask(tqmask);
printerPixLbl->setPixmap(pix);
pixFrame->tqlayout()->setMargin( 2 );
}
else
{
shareNameEdit->setEnabled(true);
shareNameEdit->setText( _share->getName() );
printerPixLbl->setPixmap(DesktopIcon("printer1"));
pixFrame->tqlayout()->setMargin( 11 );
}
}
#include "printerdlgimpl.moc"
|