/*:VRX Main */ /* Main */ Main: /* Process the arguments. Get the parent window. */ parse source . calledAs . parent = "" argCount = arg() argOff = 0 if( calledAs \= "COMMAND" )then do if argCount >= 1 then do parent = arg(1) argCount = argCount - 1 argOff = 1 end end; else do call VROptions 'ImplicitNames' call VROptions 'NoEchoQuit' end InitArgs.0 = argCount if( argCount > 0 )then do i = 1 to argCount InitArgs.i = arg( i + argOff ) end drop calledAs argCount argOff /* Load the windows */ call VRInit parse source . . spec _VREPrimaryWindowPath = , VRParseFileName( spec, "dpn" ) || ".VRW" _VREPrimaryWindow = , VRLoad( parent, _VREPrimaryWindowPath ) drop parent spec if( _VREPrimaryWindow == "" )then do call VRMessage "", "Cannot load window:" VRError(), , "Error!" _VREReturnValue = 32000 signal _VRELeaveMain end /* Process events */ call Init signal on halt do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) ) _VREEvent = VREvent() interpret _VREEvent end _VREHalt: _VREReturnValue = Fini() call VRDestroy _VREPrimaryWindow _VRELeaveMain: call VRFini exit _VREReturnValue VRLoadSecondary: __vrlsWait = abbrev( 'WAIT', translate(arg(2)), 1 ) if __vrlsWait then do call VRFlush end __vrlsHWnd = VRLoad( VRWindow(), VRWindowPath(), arg(1) ) if __vrlsHWnd = '' then signal __vrlsDone if __vrlsWait \= 1 then signal __vrlsDone call VRSet __vrlsHWnd, 'WindowMode', 'Modal' __vrlsTmp = __vrlsWindows.0 if( DataType(__vrlsTmp) \= 'NUM' ) then do __vrlsTmp = 1 end else do __vrlsTmp = __vrlsTmp + 1 end __vrlsWindows.__vrlsTmp = VRWindow( __vrlsHWnd ) __vrlsWindows.0 = __vrlsTmp do while( VRIsValidObject( VRWindow() ) = 1 ) __vrlsEvent = VREvent() interpret __vrlsEvent end __vrlsTmp = __vrlsWindows.0 __vrlsWindows.0 = __vrlsTmp - 1 call VRWindow __vrlsWindows.__vrlsTmp __vrlsHWnd = '' __vrlsDone: return __vrlsHWnd /*:VRX __VXREXX____APPENDS__ */ __VXREXX____APPENDS__: /* #append U:\Develop\Samba\guitools-1.0\shared\SambaInit.vrs #append U:\Develop\Samba\guitools-1.0\shared\nlv.vrs #append U:\Develop\Samba\guitools-1.0\shared\InitTempDir.VRS */ return /*:VRX _EnumSections */ _EnumSections: Sections.0 = 0 I = 0 do until lines(smbconf) = 0 smbline = strip(linein(smbconf)) smbline = strip(smbline,,'09'x) smbline = strip(smbline) say smbline /* do while left(smbline,1) = ' ' | left(smbline,1) = '09'x smbline = substr(smbline,2) end */ if left(smbline,1) = '[' then do /* we got a section */ I = I + 1 parse var smbline '['sections.I']' end end ok = stream(smbconf,'c','close') Sections.0 = I return /*:VRX _GUIInit */ _GUIInit: CurDir = filespec("N",SharePath) CurDrive = filespec('D',SharePath) if CurDrive <> "" then FileSys = SysFileSystemType(CurDrive) else FileSys = 'unknown' if SharePath <> "" then ok = VRSet("EF_ShareName","Value", strip(left(CurDir,12))) else ok = VRSet("EF_ShareName","Value", "") if VRGet("EF_ShareName","Value") = "" then do /* This is a root directory !! */ ok = VRSet("EF_ShareName","Value",translate(left(CurDrive,1))) ok = VRset("EF_Comment","Value", Drive' 'CurDrive' ('FileSys')') end else ok = VRset("EF_Comment","Value", Folder' 'CurDir' ('Drive' 'CurDrive', 'FileSys')') ok = VRSet("EF_Path","Value", SharePath) if VRGet("EF_Comment","Value") = "Drive (unknown)" then ok = VRSet("EF_Comment","Value","") if FileSys = "CDFS" then ok = VRSet("CB_Read_Only","set",1) ok = VRSet("EF_Hide_Files","Value", "/*. SF/") return /*:VRX _GUIInitNLV */ _GUIInitNLV: CALL NLVSetText 'Main', 'Caption', 65 Drive = NLVGetMessage(38) Folder = NLVGetMessage(39) CALL NLVSetText 'PB_Share', 'Caption', 13 CALL NLVSetText 'PB_Share', 'Hinttext',112 CALL NLVSetText 'PB_Cancel', 'Caption', 3 CALL NLVSetText 'PB_Cancel', 'Hinttext',103 return /*:VRX _INIRead */ _INIRead: indent = '09'x return /*:VRX _NLVSetup */ _NLVSetup: PROCEDURE EXPOSE settings. options. /* This subroutine is (c) by Alex Taylor */ IF options.!debug == 1 THEN SAY 'NLVSetup() started' IF options.!debug == 1 THEN SAY ' NLVSetup() is (c) Alex Taylor' filestem = 'sscc_' /* Sets all UI text from the message file. Any string that can't be loaded * will default to the built-in English. */ execPath = VRGet("Application", "Program") execDir = VRParseFileName( execPath, "DP") /* First, figure out what language/message file to use. */ Syslang = TRANSLATE( VALUE('LANG',,'OS2ENVIRONMENT')) SELECT WHEN Syslang == 'ZH_TW' THEN nlv = 'tw' WHEN Syslang == 'ZH_CN' THEN nlv = 'cx' OTHERWISE PARSE VAR Syslang nlv '_' . END IF ( STREAM( execDir'\'filestem||nlv'.msg', 'C', 'QUERY EXISTS') \= '') | ( SysSearchPath('DPATH', filestem||nlv'.msg') \= '') THEN DO settings.!messages = filestem||nlv'.msg' settings.!helpfile = filestem||nlv'.hlp' END ELSE DO settings.!messages = filestem||'en.msg' settings.!helpfile = filestem||'en.hlp' END settings.!messages = VRParseFileName(settings.!messages,"DPNE") settings.!helpfile = VRParseFileName(settings.!helpfile,"DPNE") IF options.!debug == 1 THEN SAY ' NLVMessageFile = "'settings.!helpfile'"' IF options.!debug == 1 THEN SAY ' NLVHelpFile = "'settings.!helpfile'"' CALL NLVSetText 'Main', 'Caption', 1 IF options.!debug == 1 THEN SAY 'NLVSetup() done' RETURN /*:VRX _ParseCommandLine */ _ParseCommandLine: SharePath = strip(VRGet("Application","Commandline"),,'"') if SharePath = "" then do Msg.Title= "Samba directory share wizard" Msg.Text = "No directory provided - please enter manually!" Msg.Type = "I" call _ShowMsg end return /*:VRX _ShowMsg */ _ShowMsg: Buttons.1 = "OK" Buttons.0 = 1 id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 ) return /*:VRX EF_ShareName_Change */ EF_ShareName_Change: if VRGet("EF_ShareName","Value") = "" then do ok = VRset("PB_Share","Enabled",0) ok = VRSet("EF_ShareName","Forecolor", "Red") return end ok = VRset("PB_Share","Enabled",1) do JJ = 1 to sections.0 if translate(VRGet("EF_ShareName","Value")) = translate(sections.JJ) | VRGet("EF_ShareName","Value") ="" then do ok = VRset("PB_Share","Enabled",0) ok = VRSet("EF_ShareName","Forecolor", "Red") leave end else ok = VRSet("EF_ShareName","Forecolor", "") end if VRGet("EF_ShareName","Value") <> translate(VRGet("EF_ShareName","Value")) then ok = VRset("EF_ShareName","Value",translate(VRGet("EF_ShareName","Value"))) if pos('\',VRGet("EF_ShareName","Value")) > 0 | pos('/',VRGet("EF_ShareName","Value")) > 0 then ok = VRset("EF_ShareName","Value",translate(VRGet("EF_ShareName","Value"),'__','/\')) if VRGet("EF_ShareName","Value") = " " then ok = VRSet("EF_ShareName","Value","") return /*:VRX Fini */ Fini: window = VRWindow() call VRSet window, "Visible", 0 drop window return 0 /*:VRX Halt */ Halt: signal _VREHalt return /*:VRX Init */ Init: window = VRWindow() call VRMethod window, "CenterWindow" call VRSet window, "Visible", 1 call VRMethod window, "Activate" drop window return /*:VRX Main_Close */ Main_Close: call Quit return /*:VRX Main_Create */ Main_Create: options.!debug = 0 ok = VRRedirectStdio('OFF') call _INIRead call _NLVSetup call _GUIInitNLV call _InitTempDir call _ParseCommandLine call _SambaInit smbconf = samba.!smbconf call _enumsections call _GUIInit return /*:VRX PB_Cancel_Click */ PB_Cancel_Click: Call Quit return /*:VRX PB_Share_Click */ PB_Share_Click: section = '['VRGet("EF_ShareName","Value")']' comment = 'comment = 'VRGet("EF_Comment","Value") path = 'path = 'translate(VRGet("EF_Path","Value"),'/','\') if VRGet("CB_read_only","Set") then read_write = 'read only = Yes' else read_write = 'read only = No' if VRGet("CB_Guest_OK","Set") then guest_ok = 'guest ok = Yes' else guest_ok = 'guest ok = No' if VRGet("CB_browseable","Set") then browseable = 'browseable = Yes' else browseable = 'browseable = No' if VRGet("EF_Hide_files","Value") <> "" then hide_files = 'hide files = 'VRGet("EF_Hide_files","Value") else hide_files = '' if VRGet("EF_valid_users","Value") <> "" then valid_users = 'valid users = 'VRGet("EF_valid_users","Value") else valid_users = '' if VRGet("EF_invalid_users","Value") <> "" then invalid_users = 'invalid users = 'VRGet("EF_invalid_users","Value") else invalid_users = '' call lineout smbconf, section call lineout smbconf, Indent||comment call lineout smbconf, Indent||path call lineout smbconf, Indent||read_write call lineout smbconf, Indent||guest_ok call lineout smbconf, Indent||browseable if hide_files <> "" then call lineout smbconf, Indent||hide_files if valid_users <> "" then call lineout smbconf, Indent||valid_users if invalid_users <> "" then call lineout smbconf, Indent||invalid_users call lineout smbconf, Indent ok = stream(smbconf,'c','close') Msg.Title = "Samba directory share wizard" Msg.Text = 'Added share ['VRGet("EF_ShareName","Value")'] to "'smbconf'" successfully!' Msg.Type = 'I' call _showMsg return /*:VRX Quit */ Quit: window = VRWindow() call VRSet window, "Shutdown", 1 drop window return