home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2000 December
/
PCWorld_2000-12_cd.bin
/
Komunikace
/
Comanche
/
plugins
/
samba
/
samba.tcl
< prev
Wrap
Text File
|
2000-11-02
|
10KB
|
401 lines
class sambaPlugIn {
inherit basePlugIn
public variable dumper
public variable ppManager
public variable ppDef
public variable configurationFilesManager
public variable namespace
public variable nodeManagement
public variable confDoc
public variable rootNode
variable shares
variable printers
variable status
variable homes
method _registerWithNamespace {}
method _inquiryForPropertyPages { node }
method _inquiryForMenu { node }
method _inquiryForWizard { type node }
method _inquiryForRightPaneContent { node }
method _receivedWizard { node xuiPropertyPages }
method _receivedPropertyPages { node xuiPropertyPages }
method _receivedCommand { node command }
method init
method _createAllNodes { }
method _createShare {container}
method _createShares {}
method _createHomes { container }
method _createStatus {}
method _createPrinters {}
method _createAllPrinters { container }
method _createPrinter {container}
method _saveConfig
}
body sambaPlugIn::_saveConfig {} {
# set f [open $::comanche::globals(smb.conf) w]
# puts $f [$dumper dump $confDoc]
# close $f
$dumper dump $confDoc $::comanche::globals(smb.conf)
}
body sambaPlugIn::_receivedPropertyPages { node xuiPropertyPages } {
set container [ $nodeManagement getContainer $node ]
if [string length $container] {
foreach pp [$xuiPropertyPages getComponents] {
$ppManager savePropertyPage $pp $confDoc $container
}
}
_saveConfig
}
body sambaPlugIn::_receivedWizard { node xuiPropertyPages } {
set container [ $nodeManagement getContainer $node ]
set name [ $nodeManagement getNodeName $node ]
switch $name {
shares {
set name [[[$xuiPropertyPages getComponents] \
getComponentByName share_name] getValue]
set cont [$confDoc addContainer \
[$confDoc getRootContainer] $name share]
$confDoc addDirective [[[$xuiPropertyPages getComponents] \
getComponentByName comment] clone] $cont
$confDoc addDirective [[[$xuiPropertyPages getComponents] \
getComponentByName path] clone] $cont
_createShare $cont
} printers {
set name [[[$xuiPropertyPages getComponents] \
getComponentByName section_name] getValue]
set cont [$confDoc addContainer \
[$confDoc getRootContainer] $name share]
$confDoc addDirective [[[$xuiPropertyPages getComponents] \
getComponentByName comment] clone] $cont
$confDoc addDirective [[[$xuiPropertyPages getComponents] \
getComponentByName path] clone] $cont
_createPrinter $cont
} default {
error "Container: $name "
}
}
_saveConfig
}
body sambaPlugIn::init {} {
_createAllNodes
}
body sambaPlugIn::_inquiryForPropertyPages { node } {
set result {}
set name [$nodeManagement getNodeName $node]
set container [$nodeManagement getContainer $node]
switch $name {
shares {
foreach pp { newbieBaseOptions newbieLog \
newbieBrowse newbieSecurity } {
set mypp [$ppDef getPPByName $pp]
lappend result $mypp
$ppManager loadPropertyPage $mypp $confDoc $container
}
} share - homes {
foreach pp { newbieShareBase
newbieShareBrowse newbieShareSecurity } {
set mypp [$ppDef getPPByName $pp]
lappend result $mypp
$ppManager loadPropertyPage $mypp $confDoc $container
}
} printer - printers {
foreach pp { newbieShareBase
newbieShareBrowse newbieShareSecurity newbiePrintingOptions} {
set mypp [$ppDef getPPByName $pp]
lappend result $mypp
$ppManager loadPropertyPage $mypp $confDoc $container
}
}
}
return $result
}
body sambaPlugIn::_inquiryForWizard { type node } {
set result {}
set name [$nodeManagement getNodeName $node]
set container [$nodeManagement getContainer $node]
switch $name {
shares {
set mypp [$ppDef getPPByName shareAddWizard]
return $mypp
} rootNode - status {
return {}
} printers {
set mypp [$ppDef getPPByName printerAddWizard]
return $mypp
}
}
return $result
}
body sambaPlugIn::_inquiryForRightPaneContent { node } {
set container [$nodeManagement getContainer $node]
set name [$nodeManagement getNodeName $node]
switch $name {
rootNode {
set result {
<img src="samba_logo">
<h1>Samba</h1>
<br>
This plugin configures the <b>Samba file and printing services</b>.
<br>You can configure existing printers and shares:<br><br>}
append result { <img src="sharesBig" ><a href="command selectNode -namespaceNode }
append result $shares
append result { " >Shares</a> <br><br>}
append result { <img src="printerBig"> <a href="command selectNode -namespaceNode }
append result $printers
append result { " >Printers</a> <br><br>}
} shares {
set result {
<img src="samba_logo"><br>
<h1>Shares</h1>
<br>
<img src="sharesBig">
Here you can configure the
<a href="command propertyPages">global properties</a> that apply to all shares and <a href="command addNewNode">create</a> new ones
<br>}
} printers {
set result {
<img src="samba_logo"><br>
<h1>Printers</h1>
<br>
<img src="printerBig">
Here you can configure the
<a href="command propertyPages">global properties</a> that apply to all printers and <a href="command addNewNode">create</a> new ones.
<br>}
} share {
append result {
<img src="samba_logo"><br>
<h1>Share }
append result [ $container getName ]
append result {</h1><br>}
catch [list append result "Path: [[$confDoc getDirectiveByName $container path] getValue]<br>"]
catch [list append result "Comment: [[$confDoc getDirectiveByName $container comment] getValue]<br>"]
append result {
<br><br>
<img src="folderBig">
You can configure the properties of this share <a href="command
propertyPages" >here</a>}
} homes {
append result {
<img src="samba_logo"><br>
<h1>Homes</h1> <br>
<img src="kfmHomeBig>
If a section called 'homes' is created, services connecting clients to their home directories can be created on the fly by the server.
You can configure the properties of this share <a href="command
propertyPages" >here</a>}
} printer {
append result {
<img src="samba_logo"><br>
<h1>Share }
append result [ $container getName ]
append result {</h1><br>}
catch [list append result "Path: [[$confDoc getDirectiveByName $container path] getValue]<br>"]
catch [list append result "Comment: [[$confDoc getDirectiveByName $container comment] getValue]<br>"]
append result {
<br><br>
<img src="printerBig">
You can configure the properties of this printer <a href="command
propertyPages" >here</a>}
} status {
append result {
<img src="samba_logo"><br>
<h1>Info</h1>
<img src="informationBig"> Here you will be able to find information about active connections and shares and open folders.
}
} default {
set result kkk
}
}
return $result
}
body sambaPlugIn::_createAllNodes { } {
_createStatus
_createShares
_createPrinters
foreach container [$confDoc getContainers [$confDoc getRootContainer]] {
switch [$container getName] {
global {
$nodeManagement setContainer $shares $container
} printers {
$nodeManagement setContainer $printers $container
} homes {
_createHomes $container
} default {
if [string length \
[$confDoc getDirectiveByName $container printer]] {
_createPrinter $container
} else {
_createShare $container
}
}
}
}
}
body sambaPlugIn::_createShares { } {
set shares [ $nodeManagement addNode $rootNode\
-label "Shares" \
-openIcon shares\
-classes {container samba} \
-closedIcon shares\
-container {} \
-nodeName shares ]
}
body sambaPlugIn::_createShare { container } {
set label [$container getName]
if [string length \
[set cdir [$confDoc getDirectiveByName $container comment]]] {
append label " - [$cdir getValue]"
}
$nodeManagement addNode $shares\
-label $label \
-openIcon openFolder\
-classes {leaf samba} \
-closedIcon closedFolder\
-container $container \
-nodeName share
}
body sambaPlugIn::_createPrinter { container } {
set label [$container getName]
if [string length \
[set cdir [$confDoc getDirectiveByName $container comment]]] {
append label " - [$cdir getValue]"
}
$nodeManagement addNode $printers\
-label $label \
-openIcon openFolder\
-classes {leaf samba} \
-closedIcon printer\
-container $container \
-nodeName printer
}
body sambaPlugIn::_createHomes { container } {
set homes [ $nodeManagement addNode $shares\
-label "Homes" \
-openIcon kfmHome\
-classes {leaf samba} \
-closedIcon kfmHome\
-container $container \
-nodeName homes ]
}
body sambaPlugIn::_createAllPrinters { container } {
}
body sambaPlugIn::_createPrinters { } {
set printers [ $nodeManagement addNode $rootNode\
-label "Printers" \
-openIcon printer\
-classes {container samba} \
-closedIcon printer\
-container {}\
-nodeName printers ]
}
body sambaPlugIn::_createStatus {} {
set status [ $nodeManagement addNode $rootNode\
-label "Status" \
-openIcon information\
-classes {leaf samba} \
-closedIcon information \
-container {}\
-nodeName status ]
}
body sambaPlugIn::_registerWithNamespace {} {
set node $rootNode
set rootNode [$nodeManagement addNode $node\
-label "Samba 2.0.0" \
-openIcon samba\
-closedIcon samba\
-container {}\
-nodeName rootNode]
}