| 1 | /*:VRX         Main | 
|---|
| 2 | */ | 
|---|
| 3 | /*  Main | 
|---|
| 4 | */ | 
|---|
| 5 | Main: | 
|---|
| 6 | /*  Process the arguments. | 
|---|
| 7 | Get the parent window. | 
|---|
| 8 | */ | 
|---|
| 9 | parse source . calledAs . | 
|---|
| 10 | parent = "" | 
|---|
| 11 | argCount = arg() | 
|---|
| 12 | argOff = 0 | 
|---|
| 13 | if( calledAs \= "COMMAND" )then do | 
|---|
| 14 | if argCount >= 1 then do | 
|---|
| 15 | parent = arg(1) | 
|---|
| 16 | argCount = argCount - 1 | 
|---|
| 17 | argOff = 1 | 
|---|
| 18 | end | 
|---|
| 19 | end; else do | 
|---|
| 20 | call VROptions 'ImplicitNames' | 
|---|
| 21 | call VROptions 'NoEchoQuit' | 
|---|
| 22 | end | 
|---|
| 23 | InitArgs.0 = argCount | 
|---|
| 24 | if( argCount > 0 )then do i = 1 to argCount | 
|---|
| 25 | InitArgs.i = arg( i + argOff ) | 
|---|
| 26 | end | 
|---|
| 27 | drop calledAs argCount argOff | 
|---|
| 28 |  | 
|---|
| 29 | /*  Load the windows | 
|---|
| 30 | */ | 
|---|
| 31 | call VRInit | 
|---|
| 32 | parse source . . spec | 
|---|
| 33 | _VREPrimaryWindowPath = , | 
|---|
| 34 | VRParseFileName( spec, "dpn" ) || ".VRW" | 
|---|
| 35 | _VREPrimaryWindow = , | 
|---|
| 36 | VRLoad( parent, _VREPrimaryWindowPath ) | 
|---|
| 37 | drop parent spec | 
|---|
| 38 | if( _VREPrimaryWindow == "" )then do | 
|---|
| 39 | call VRMessage "", "Cannot load window:" VRError(), , | 
|---|
| 40 | "Error!" | 
|---|
| 41 | _VREReturnValue = 32000 | 
|---|
| 42 | signal _VRELeaveMain | 
|---|
| 43 | end | 
|---|
| 44 |  | 
|---|
| 45 | /*  Process events | 
|---|
| 46 | */ | 
|---|
| 47 | call Init | 
|---|
| 48 | signal on halt | 
|---|
| 49 | do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) | 
|---|
| 50 | _VREEvent = VREvent() | 
|---|
| 51 | interpret _VREEvent | 
|---|
| 52 | end | 
|---|
| 53 | _VREHalt: | 
|---|
| 54 | _VREReturnValue = Fini() | 
|---|
| 55 | call VRDestroy _VREPrimaryWindow | 
|---|
| 56 | _VRELeaveMain: | 
|---|
| 57 | call VRFini | 
|---|
| 58 | exit _VREReturnValue | 
|---|
| 59 |  | 
|---|
| 60 | VRLoadSecondary: | 
|---|
| 61 | __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) | 
|---|
| 62 | if __vrlsWait then do | 
|---|
| 63 | call VRFlush | 
|---|
| 64 | end | 
|---|
| 65 | __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) | 
|---|
| 66 | if __vrlsHWnd = '' then signal __vrlsDone | 
|---|
| 67 | if __vrlsWait \= 1 then signal __vrlsDone | 
|---|
| 68 | call VRSet __vrlsHWnd, 'WindowMode', 'Modal' | 
|---|
| 69 | __vrlsTmp = __vrlsWindows.0 | 
|---|
| 70 | if( DataType(__vrlsTmp) \= 'NUM' ) then do | 
|---|
| 71 | __vrlsTmp = 1 | 
|---|
| 72 | end | 
|---|
| 73 | else do | 
|---|
| 74 | __vrlsTmp = __vrlsTmp + 1 | 
|---|
| 75 | end | 
|---|
| 76 | __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) | 
|---|
| 77 | __vrlsWindows.0 = __vrlsTmp | 
|---|
| 78 | do while( VRIsValidObject( VRWindow() ) = 1 ) | 
|---|
| 79 | __vrlsEvent = VREvent() | 
|---|
| 80 | interpret __vrlsEvent | 
|---|
| 81 | end | 
|---|
| 82 | __vrlsTmp = __vrlsWindows.0 | 
|---|
| 83 | __vrlsWindows.0 = __vrlsTmp - 1 | 
|---|
| 84 | call VRWindow __vrlsWindows.__vrlsTmp | 
|---|
| 85 | __vrlsHWnd = '' | 
|---|
| 86 | __vrlsDone: | 
|---|
| 87 | return __vrlsHWnd | 
|---|
| 88 |  | 
|---|
| 89 | /*:VRX         __VXREXX____APPENDS__ | 
|---|
| 90 | */ | 
|---|
| 91 | __VXREXX____APPENDS__: | 
|---|
| 92 | /* | 
|---|
| 93 | #append U:\Develop\Samba\guitools-1.0\shared\SambaInit.vrs | 
|---|
| 94 | #append U:\Develop\Samba\guitools-1.0\shared\nlv.vrs | 
|---|
| 95 | #append U:\Develop\Samba\guitools-1.0\shared\InitTempDir.VRS | 
|---|
| 96 | */ | 
|---|
| 97 | return | 
|---|
| 98 | /*:VRX         _EnumSections | 
|---|
| 99 | */ | 
|---|
| 100 | _EnumSections: | 
|---|
| 101 | Sections.0 = 0 | 
|---|
| 102 | I = 0 | 
|---|
| 103 | do until lines(smbconf) = 0 | 
|---|
| 104 | smbline = strip(linein(smbconf)) | 
|---|
| 105 | smbline = strip(smbline,,'09'x) | 
|---|
| 106 | smbline = strip(smbline) | 
|---|
| 107 | say smbline | 
|---|
| 108 | /*      do while left(smbline,1) = ' ' | left(smbline,1) = '09'x | 
|---|
| 109 | smbline = substr(smbline,2) | 
|---|
| 110 | end */ | 
|---|
| 111 | if left(smbline,1) = '[' then do /* we got a section */ | 
|---|
| 112 | I = I + 1 | 
|---|
| 113 | parse var smbline '['sections.I']' | 
|---|
| 114 | end | 
|---|
| 115 | end | 
|---|
| 116 | ok = stream(smbconf,'c','close') | 
|---|
| 117 | Sections.0 = I | 
|---|
| 118 | return | 
|---|
| 119 |  | 
|---|
| 120 | /*:VRX         _GUIInit | 
|---|
| 121 | */ | 
|---|
| 122 | _GUIInit: | 
|---|
| 123 | CurDir = filespec("N",SharePath) | 
|---|
| 124 | CurDrive = filespec('D',SharePath) | 
|---|
| 125 | if CurDrive <> "" then FileSys = SysFileSystemType(CurDrive) | 
|---|
| 126 | else FileSys = 'unknown' | 
|---|
| 127 |  | 
|---|
| 128 | if SharePath <> "" then ok = VRSet("EF_ShareName","Value", strip(left(CurDir,12))) | 
|---|
| 129 | else ok = VRSet("EF_ShareName","Value", "") | 
|---|
| 130 |  | 
|---|
| 131 | if VRGet("EF_ShareName","Value") = "" then do /* This is a root directory !! */ | 
|---|
| 132 | ok = VRSet("EF_ShareName","Value",translate(left(CurDrive,1))) | 
|---|
| 133 | ok = VRset("EF_Comment","Value", Drive' 'CurDrive' ('FileSys')') | 
|---|
| 134 | end | 
|---|
| 135 | else  ok = VRset("EF_Comment","Value", Folder' 'CurDir' ('Drive' 'CurDrive', 'FileSys')') | 
|---|
| 136 | ok = VRSet("EF_Path","Value", SharePath) | 
|---|
| 137 | if VRGet("EF_Comment","Value") = "Drive  (unknown)" then ok = VRSet("EF_Comment","Value","") | 
|---|
| 138 | if FileSys = "CDFS" then ok = VRSet("CB_Read_Only","set",1) | 
|---|
| 139 | ok = VRSet("EF_Hide_Files","Value", "/*. SF/") | 
|---|
| 140 | return | 
|---|
| 141 |  | 
|---|
| 142 | /*:VRX         _GUIInitNLV | 
|---|
| 143 | */ | 
|---|
| 144 | _GUIInitNLV: | 
|---|
| 145 | CALL NLVSetText 'Main',             'Caption',  65 | 
|---|
| 146 | Drive  = NLVGetMessage(38) | 
|---|
| 147 | Folder = NLVGetMessage(39) | 
|---|
| 148 | CALL NLVSetText 'PB_Share',         'Caption',  13 | 
|---|
| 149 | CALL NLVSetText 'PB_Share',         'Hinttext',112 | 
|---|
| 150 |  | 
|---|
| 151 | CALL NLVSetText 'PB_Cancel',        'Caption',   3 | 
|---|
| 152 | CALL NLVSetText 'PB_Cancel',        'Hinttext',103 | 
|---|
| 153 | return | 
|---|
| 154 |  | 
|---|
| 155 | /*:VRX         _INIRead | 
|---|
| 156 | */ | 
|---|
| 157 | _INIRead: | 
|---|
| 158 | indent = '09'x | 
|---|
| 159 | return | 
|---|
| 160 |  | 
|---|
| 161 | /*:VRX         _NLVSetup | 
|---|
| 162 | */ | 
|---|
| 163 | _NLVSetup: PROCEDURE EXPOSE settings. options. | 
|---|
| 164 | /* This subroutine is (c) by Alex Taylor */ | 
|---|
| 165 | IF options.!debug == 1 THEN SAY 'NLVSetup() started' | 
|---|
| 166 | IF options.!debug == 1 THEN SAY '  NLVSetup() is (c) Alex Taylor' | 
|---|
| 167 | filestem = 'sscc_' | 
|---|
| 168 |  | 
|---|
| 169 | /* Sets all UI text from the message file.  Any string that can't be loaded | 
|---|
| 170 | * will default to the built-in English. | 
|---|
| 171 | */ | 
|---|
| 172 | execPath = VRGet("Application", "Program") | 
|---|
| 173 | execDir  = VRParseFileName( execPath, "DP") | 
|---|
| 174 |  | 
|---|
| 175 | /* First, figure out what language/message file to use. | 
|---|
| 176 | */ | 
|---|
| 177 | Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT')) | 
|---|
| 178 | SELECT | 
|---|
| 179 | WHEN Syslang == 'ZH_TW' THEN nlv = 'tw' | 
|---|
| 180 | WHEN Syslang == 'ZH_CN' THEN nlv = 'cx' | 
|---|
| 181 | OTHERWISE PARSE VAR Syslang nlv '_' . | 
|---|
| 182 | END | 
|---|
| 183 | IF ( STREAM( execDir'\'filestem||nlv'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', filestem||nlv'.msg') \= '') THEN DO | 
|---|
| 184 | settings.!messages = filestem||nlv'.msg' | 
|---|
| 185 | settings.!helpfile = filestem||nlv'.hlp' | 
|---|
| 186 | END | 
|---|
| 187 | ELSE DO | 
|---|
| 188 | settings.!messages = filestem||'en.msg' | 
|---|
| 189 | settings.!helpfile = filestem||'en.hlp' | 
|---|
| 190 | END | 
|---|
| 191 | settings.!messages = VRParseFileName(settings.!messages,"DPNE") | 
|---|
| 192 | settings.!helpfile = VRParseFileName(settings.!helpfile,"DPNE") | 
|---|
| 193 |  | 
|---|
| 194 | IF options.!debug == 1 THEN SAY '  NLVMessageFile = "'settings.!helpfile'"' | 
|---|
| 195 | IF options.!debug == 1 THEN SAY '  NLVHelpFile    = "'settings.!helpfile'"' | 
|---|
| 196 |  | 
|---|
| 197 | CALL NLVSetText 'Main',        'Caption', 1 | 
|---|
| 198 |  | 
|---|
| 199 | IF options.!debug == 1 THEN SAY 'NLVSetup() done' | 
|---|
| 200 | RETURN | 
|---|
| 201 |  | 
|---|
| 202 | /*:VRX         _ParseCommandLine | 
|---|
| 203 | */ | 
|---|
| 204 | _ParseCommandLine: | 
|---|
| 205 | SharePath = strip(VRGet("Application","Commandline"),,'"') | 
|---|
| 206 | if SharePath = "" then do | 
|---|
| 207 | Msg.Title= "Samba directory share wizard" | 
|---|
| 208 | Msg.Text = "No directory provided - please enter manually!" | 
|---|
| 209 | Msg.Type = "I" | 
|---|
| 210 | call _ShowMsg | 
|---|
| 211 | end | 
|---|
| 212 | return | 
|---|
| 213 |  | 
|---|
| 214 | /*:VRX         _ShowMsg | 
|---|
| 215 | */ | 
|---|
| 216 | _ShowMsg: | 
|---|
| 217 | Buttons.1 = "OK" | 
|---|
| 218 | Buttons.0 = 1 | 
|---|
| 219 | id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) | 
|---|
| 220 | return | 
|---|
| 221 | /*:VRX         EF_ShareName_Change | 
|---|
| 222 | */ | 
|---|
| 223 | EF_ShareName_Change: | 
|---|
| 224 | if VRGet("EF_ShareName","Value") = "" then do | 
|---|
| 225 | ok = VRset("PB_Share","Enabled",0) | 
|---|
| 226 | ok = VRSet("EF_ShareName","Forecolor", "Red") | 
|---|
| 227 | return | 
|---|
| 228 | end | 
|---|
| 229 | ok = VRset("PB_Share","Enabled",1) | 
|---|
| 230 |  | 
|---|
| 231 | do JJ = 1 to sections.0 | 
|---|
| 232 | if translate(VRGet("EF_ShareName","Value")) = translate(sections.JJ) | VRGet("EF_ShareName","Value") ="" then do | 
|---|
| 233 | ok = VRset("PB_Share","Enabled",0) | 
|---|
| 234 | ok = VRSet("EF_ShareName","Forecolor", "Red") | 
|---|
| 235 | leave | 
|---|
| 236 | end | 
|---|
| 237 | else ok = VRSet("EF_ShareName","Forecolor", "<DEFAULT>") | 
|---|
| 238 | end | 
|---|
| 239 | if VRGet("EF_ShareName","Value") <> translate(VRGet("EF_ShareName","Value")) then ok = VRset("EF_ShareName","Value",translate(VRGet("EF_ShareName","Value"))) | 
|---|
| 240 | if pos('\',VRGet("EF_ShareName","Value")) > 0 | pos('/',VRGet("EF_ShareName","Value")) > 0 then ok = VRset("EF_ShareName","Value",translate(VRGet("EF_ShareName","Value"),'__','/\')) | 
|---|
| 241 | if VRGet("EF_ShareName","Value") = " " then ok = VRSet("EF_ShareName","Value","") | 
|---|
| 242 | return | 
|---|
| 243 |  | 
|---|
| 244 | /*:VRX         Fini | 
|---|
| 245 | */ | 
|---|
| 246 | Fini: | 
|---|
| 247 | window = VRWindow() | 
|---|
| 248 | call VRSet window, "Visible", 0 | 
|---|
| 249 | drop window | 
|---|
| 250 | return 0 | 
|---|
| 251 |  | 
|---|
| 252 | /*:VRX         Halt | 
|---|
| 253 | */ | 
|---|
| 254 | Halt: | 
|---|
| 255 | signal _VREHalt | 
|---|
| 256 | return | 
|---|
| 257 |  | 
|---|
| 258 | /*:VRX         Init | 
|---|
| 259 | */ | 
|---|
| 260 | Init: | 
|---|
| 261 | window = VRWindow() | 
|---|
| 262 | call VRMethod window, "CenterWindow" | 
|---|
| 263 | call VRSet window, "Visible", 1 | 
|---|
| 264 | call VRMethod window, "Activate" | 
|---|
| 265 | drop window | 
|---|
| 266 | return | 
|---|
| 267 |  | 
|---|
| 268 | /*:VRX         Main_Close | 
|---|
| 269 | */ | 
|---|
| 270 | Main_Close: | 
|---|
| 271 | call Quit | 
|---|
| 272 | return | 
|---|
| 273 |  | 
|---|
| 274 | /*:VRX         Main_Create | 
|---|
| 275 | */ | 
|---|
| 276 | Main_Create: | 
|---|
| 277 | options.!debug = 0 | 
|---|
| 278 | ok = VRRedirectStdio('OFF') | 
|---|
| 279 |  | 
|---|
| 280 | call _INIRead | 
|---|
| 281 | call _NLVSetup | 
|---|
| 282 | call _GUIInitNLV | 
|---|
| 283 | call _InitTempDir | 
|---|
| 284 | call _ParseCommandLine | 
|---|
| 285 |  | 
|---|
| 286 | call _SambaInit | 
|---|
| 287 | smbconf = samba.!smbconf | 
|---|
| 288 |  | 
|---|
| 289 | call _enumsections | 
|---|
| 290 | call _GUIInit | 
|---|
| 291 | return | 
|---|
| 292 |  | 
|---|
| 293 | /*:VRX         PB_Cancel_Click | 
|---|
| 294 | */ | 
|---|
| 295 | PB_Cancel_Click: | 
|---|
| 296 | Call Quit | 
|---|
| 297 | return | 
|---|
| 298 |  | 
|---|
| 299 | /*:VRX         PB_Share_Click | 
|---|
| 300 | */ | 
|---|
| 301 | PB_Share_Click: | 
|---|
| 302 | section    = '['VRGet("EF_ShareName","Value")']' | 
|---|
| 303 | comment    = 'comment = 'VRGet("EF_Comment","Value") | 
|---|
| 304 | path       = 'path = 'translate(VRGet("EF_Path","Value"),'/','\') | 
|---|
| 305 |  | 
|---|
| 306 | if VRGet("CB_read_only","Set") then read_write = 'read only = Yes' | 
|---|
| 307 | else read_write = 'read only = No' | 
|---|
| 308 |  | 
|---|
| 309 | if VRGet("CB_Guest_OK","Set") then guest_ok = 'guest ok = Yes' | 
|---|
| 310 | else guest_ok = 'guest ok = No' | 
|---|
| 311 |  | 
|---|
| 312 | if VRGet("CB_browseable","Set") then browseable = 'browseable = Yes' | 
|---|
| 313 | else browseable = 'browseable = No' | 
|---|
| 314 |  | 
|---|
| 315 | if VRGet("EF_Hide_files","Value") <> "" then hide_files = 'hide files = 'VRGet("EF_Hide_files","Value") | 
|---|
| 316 | else hide_files = '' | 
|---|
| 317 | if VRGet("EF_valid_users","Value") <> "" then valid_users = 'valid users = 'VRGet("EF_valid_users","Value") | 
|---|
| 318 | else valid_users = '' | 
|---|
| 319 | if VRGet("EF_invalid_users","Value") <> "" then invalid_users = 'invalid users = 'VRGet("EF_invalid_users","Value") | 
|---|
| 320 | else invalid_users = '' | 
|---|
| 321 |  | 
|---|
| 322 | call lineout smbconf, section | 
|---|
| 323 | call lineout smbconf, Indent||comment | 
|---|
| 324 | call lineout smbconf, Indent||path | 
|---|
| 325 | call lineout smbconf, Indent||read_write | 
|---|
| 326 | call lineout smbconf, Indent||guest_ok | 
|---|
| 327 | call lineout smbconf, Indent||browseable | 
|---|
| 328 | if hide_files <> "" then call lineout smbconf, Indent||hide_files | 
|---|
| 329 | if valid_users <> "" then call lineout smbconf, Indent||valid_users | 
|---|
| 330 | if invalid_users <> "" then call lineout smbconf, Indent||invalid_users | 
|---|
| 331 | call lineout smbconf, Indent | 
|---|
| 332 | ok = stream(smbconf,'c','close') | 
|---|
| 333 | Msg.Title = "Samba directory share wizard" | 
|---|
| 334 | Msg.Text  = 'Added share ['VRGet("EF_ShareName","Value")'] to "'smbconf'" successfully!' | 
|---|
| 335 | Msg.Type  = 'I' | 
|---|
| 336 | call _showMsg | 
|---|
| 337 | return | 
|---|
| 338 |  | 
|---|
| 339 | /*:VRX         Quit | 
|---|
| 340 | */ | 
|---|
| 341 | Quit: | 
|---|
| 342 | window = VRWindow() | 
|---|
| 343 | call VRSet window, "Shutdown", 1 | 
|---|
| 344 | drop window | 
|---|
| 345 | return | 
|---|
| 346 |  | 
|---|