[612] | 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 _ShowMsg
|
---|
| 90 | */
|
---|
| 91 | _ShowMsg:
|
---|
| 92 | Buttons.1 = "OK"
|
---|
| 93 | Buttons.0 = 1
|
---|
| 94 | id = VRMessage( VRWindow(), Msg.Text, Msg.Title, Msg.Type, "Buttons.", buttons.1, buttons.1 )
|
---|
| 95 | return/*:VRX Fini
|
---|
| 96 | */
|
---|
| 97 | Fini:
|
---|
| 98 | window = VRWindow()
|
---|
| 99 | call VRSet window, "Visible", 0
|
---|
| 100 | drop window
|
---|
| 101 | return 0
|
---|
| 102 |
|
---|
| 103 | /*:VRX Halt
|
---|
| 104 | */
|
---|
| 105 | Halt:
|
---|
| 106 | signal _VREHalt
|
---|
| 107 | return
|
---|
| 108 |
|
---|
| 109 | /*:VRX Init
|
---|
| 110 | */
|
---|
| 111 | Init:
|
---|
| 112 | window = VRWindow()
|
---|
| 113 | /* call VRMethod window, "CenterWindow" */
|
---|
| 114 | call VRSet window, "Visible", 1
|
---|
| 115 | call VRMethod window, "Activate"
|
---|
| 116 | drop window
|
---|
| 117 | return
|
---|
| 118 |
|
---|
| 119 | /*:VRX Main_Close
|
---|
| 120 | */
|
---|
| 121 | Main_Close:
|
---|
| 122 | call Quit
|
---|
| 123 | return
|
---|
| 124 |
|
---|
| 125 | /*:VRX Main_Create
|
---|
| 126 | */
|
---|
| 127 | Main_Create:
|
---|
[981] | 128 | debug = 0
|
---|
| 129 | if debug = 1 then ok = VRRedirectStdIO("ON")
|
---|
| 130 | else ok = VRRedirectStdIO("OFF")
|
---|
[612] | 131 | PrintParms = VRGet("Application","Commandline")
|
---|
[981] | 132 | spooldir = directory()
|
---|
[982] | 133 | if debug = 1 then say 'Printparms: "'Printparms'"'
|
---|
| 134 | if debug = 1 then say 'Length : 'length(PrintParms)
|
---|
[612] | 135 | if PrintParms <> "" then do
|
---|
| 136 | parse var PrintParms '"'spoolfile'" "'smbprintername'" "'Jobname'" "'pages'" "'JobSize'"'
|
---|
[982] | 137 | if debug = 1 then say 'Directory: "'spooldir'"'
|
---|
| 138 | if debug = 1 then say 'Spoolfile: "'spoolfile'"'
|
---|
| 139 | if debug = 1 then say 'Smbprinter: "'smbprintername'"'
|
---|
[612] | 140 |
|
---|
| 141 | ok = VRMethod( "Application", "ListPrinters", "printer." )
|
---|
| 142 | FoundQueue = 0
|
---|
| 143 | if ok = 1 then do
|
---|
| 144 | do i = 1 to printer.0
|
---|
[981] | 145 | if debug = 1 then say printer.i
|
---|
[612] | 146 | parse value printer.i with PName';'PQueue';'Rest
|
---|
[982] | 147 | if debug = 1 then say 'Queue: 'PName'<-->'PQueue
|
---|
[612] | 148 | if translate(PQueue) = translate(smbprintername) then do
|
---|
| 149 | FoundQueue = 1
|
---|
| 150 | leave
|
---|
| 151 | end
|
---|
| 152 | end
|
---|
| 153 | end
|
---|
| 154 |
|
---|
| 155 | if FoundQueue then do
|
---|
| 156 | ok = VRset("DT_Job","Caption", 'Print "'Jobname'" ('Pages', 'JobSize' bytes) to "'PName'"')
|
---|
[981] | 157 | ok = VRPrintFile( smbprintername, spooldir'\'spoolfile, , JobName )
|
---|
[982] | 158 | if debug = 1 then say " ->"smbprintername", "spooldir"\"spoolfile", , "JobName
|
---|
[981] | 159 | ok = SysSleep(10)
|
---|
| 160 | if debug = 1 then ok = VRRedirectStdIO("OFF")
|
---|
[612] | 161 | end
|
---|
| 162 | else do
|
---|
| 163 | Msg.Title = "Samba Print Command for OS/2"
|
---|
| 164 | Msg.Type = "E"
|
---|
| 165 | Msg.Text = 'Invalid (non existent) print queue specified in smb.conf: "'smbprintername'"'
|
---|
| 166 | call _ShowMsg
|
---|
| 167 | end
|
---|
[982] | 168 | ok = SysFileDelete(Spoolfile)
|
---|
[612] | 169 | end
|
---|
| 170 | else do
|
---|
| 171 | Msg.Title = "Samba Print Command for OS/2"
|
---|
| 172 | Msg.Type = "I"
|
---|
| 173 | Msg.Text = 'smbprint.exe "spoolfile" "printerqueue" "jobname" "pages" "jobsize"'
|
---|
| 174 | call _ShowMsg
|
---|
| 175 | end
|
---|
| 176 | call Quit
|
---|
| 177 | return
|
---|
| 178 |
|
---|
| 179 | /*:VRX Quit
|
---|
| 180 | */
|
---|
| 181 | Quit:
|
---|
| 182 | window = VRWindow()
|
---|
| 183 | call VRSet window, "Shutdown", 1
|
---|
| 184 | drop window
|
---|
| 185 | return
|
---|
| 186 |
|
---|