Skip to content

Commit 7a2381e

Browse files
committed
add setup
add proto
1 parent af1cad0 commit 7a2381e

File tree

8 files changed

+318
-7
lines changed

8 files changed

+318
-7
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
bin/
2+
.settings/
3+
target/
4+
setup/Output/
5+
setup/Files/gsdll32.dll
6+
setup/Files/gswin32c.exe
7+
setup/Files/prunmgr.exe
8+
setup/Files/prunsrv.exe
9+
setup/Files/PrintServer.jar
10+
setup/Files/LICENSE.txt
11+
12+
# Eclipse Core
13+
.project
14+
15+
# JDT-specific (Eclipse Java Development Tools)
16+
.classpath
17+
18+
gsdll32.dll
19+
gswin32c.exe

proto/print.proto

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
syntax = "proto3";
2+
3+
option java_package = "com.solvaig.print";
4+
5+
package print;
6+
7+
// The print service definition.
8+
service ServerPrintService {
9+
rpc GetPrintServices (Empty) returns (PrintServices) {}
10+
// Print
11+
rpc Print (stream PrintContent) returns (PrintResponse) {}
12+
}
13+
14+
// The request message containing the print content.
15+
message PrintContent {
16+
oneof print_content_type {
17+
PrintInfo printInfo = 1;
18+
bytes content = 2;
19+
}
20+
}
21+
22+
message PrintInfo {
23+
string printerName = 1;
24+
string mediaSize = 2;
25+
int32 orientation = 3;
26+
int32 pageSizeWidth = 4;
27+
int32 pageSizeHeight = 5;
28+
29+
int32 colorMode = 6;
30+
int32 duplexMode = 7;
31+
repeated PageRange pageRange = 8;
32+
int32 copies = 9;
33+
string label = 10;
34+
int64 creationTime = 11;
35+
}
36+
37+
message PageRange {
38+
int32 startPage = 1;
39+
int32 endPage = 2;
40+
}
41+
42+
// The response message containing the result
43+
message PrintResponse {
44+
int32 result = 1;
45+
}
46+
47+
message Empty {}
48+
49+
message PrintServices {
50+
repeated string name = 1;
51+
}

setup/DirectPrintServer.iss

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
; Script generated by the Inno Setup Script Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
#define MyAppName "Direct Print Server"
5+
#define MyAppVersion "1.0"
6+
#define MyAppPublisher "JSC Solvaig"
7+
#define MyAppURL "https://github.com/procks/direct_print_server"
8+
9+
[Setup]
10+
; NOTE: The value of AppId uniquely identifies this application.
11+
; Do not use the same AppId value in installers for other applications.
12+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
13+
AppId={{215ED57E-4DC9-40EA-85E2-4A326D2C0419}
14+
AppName={#MyAppName}
15+
AppVersion={#MyAppVersion}
16+
;AppVerName={#MyAppName} {#MyAppVersion}
17+
AppPublisher={#MyAppPublisher}
18+
AppPublisherURL={#MyAppURL}
19+
AppSupportURL={#MyAppURL}
20+
AppUpdatesURL={#MyAppURL}
21+
DefaultDirName={pf}\DirectPrintServer
22+
DefaultGroupName={#MyAppName}
23+
DisableProgramGroupPage=yes
24+
OutputDir=Output
25+
OutputBaseFilename=DirectPrintServerSetup
26+
Compression=lzma
27+
SolidCompression=yes
28+
29+
[Languages]
30+
Name: "en"; MessagesFile: "compiler:Default.isl"
31+
Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl"
32+
Name: "uk"; MessagesFile: "compiler:Languages\Ukrainian.isl"
33+
34+
[CustomMessages]
35+
en.ServiceAccountInformation=Log on Service as:
36+
ru.ServiceAccountInformation=Çàïóñêàòü ñåðâèñ îò èìåíè:
37+
uk.ServiceAccountInformation=Log on Service as:
38+
39+
[Files]
40+
Source: "Files\prunsrv.exe"; DestDir: "{app}"; Flags: ignoreversion
41+
Source: "Files\gsdll32.dll"; DestDir: "{app}"; Flags: ignoreversion
42+
Source: "Files\gswin32c.exe"; DestDir: "{app}"; Flags: ignoreversion
43+
Source: "Files\install.cmd"; DestDir: "{app}"; Flags: ignoreversion
44+
Source: "Files\install_ex.cmd"; DestDir: "{app}"; Flags: ignoreversion
45+
Source: "Files\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
46+
Source: "Files\PrintServer.jar"; DestDir: "{app}"; Flags: ignoreversion
47+
Source: "Files\prunmgr.exe"; DestDir: "{app}"; Flags: ignoreversion
48+
Source: "Files\prunsrv.exe"; DestDir: "{app}"; Flags: ignoreversion
49+
Source: "Files\uninstall.cmd"; DestDir: "{app}"; Flags: ignoreversion
50+
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
51+
52+
[Icons]
53+
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
54+
55+
[Run]
56+
Filename: "{app}\install.cmd"; Parameters: "{code:GetUserName} {code:GetPassword}"; WorkingDir: "{app}"; Flags: runhidden; StatusMsg: "Installing service"
57+
58+
[UninstallRun]
59+
Filename: "{app}\uninstall.cmd"; WorkingDir: "{app}"; Flags: runhidden; StatusMsg: "Uninstalling service"
60+
61+
[Code]
62+
var
63+
Page: TInputQueryWizardPage;
64+
LocalSystemAccountCheckBox: TNewCheckBox;
65+
LabelFolder: TLabel;
66+
// MainPage: TWizardPage;
67+
UserEdit: TNewEdit;
68+
PassEdit: TNewEdit;
69+
ConfPassEdit: TNewEdit;
70+
UserStaticText: TNewStaticText;
71+
PassStaticText: TNewStaticText;
72+
ConfPassStaticText: TNewStaticText;
73+
74+
procedure LocalSystemAccountCheckBoxOnClick(Sender: TObject);
75+
begin
76+
if LocalSystemAccountCheckBox.Checked then begin
77+
UserStaticText.Enabled := false;
78+
UserEdit.Enabled := false;
79+
PassStaticText.Enabled := false;
80+
PassEdit.Enabled := false;
81+
ConfPassStaticText.Enabled := false;
82+
ConfPassEdit.Enabled := false;
83+
end
84+
else begin
85+
UserStaticText.Enabled := true;
86+
UserEdit.Enabled := true;
87+
PassStaticText.Enabled := true;
88+
PassEdit.Enabled := true;
89+
ConfPassStaticText.Enabled := true;
90+
ConfPassEdit.Enabled := true;
91+
end;
92+
end;
93+
94+
procedure InitializeWizard;
95+
begin
96+
Page := CreateInputQueryPage(wpWelcome, //wpSelectComponents,
97+
CustomMessage('ServiceAccountInformation'), 'Please enter account information',
98+
'');
99+
100+
LocalSystemAccountCheckBox := TNewCheckBox.Create(Page);
101+
LocalSystemAccountCheckBox.Parent := Page.Surface;
102+
LocalSystemAccountCheckBox.Width := ScaleX(200);
103+
LocalSystemAccountCheckBox.Caption := 'Local system account';
104+
LocalSystemAccountCheckBox.Checked := true;
105+
LocalSystemAccountCheckBox.OnClick := @LocalSystemAccountCheckBoxOnClick;
106+
107+
UserStaticText := TNewStaticText.Create(Page);
108+
UserStaticText.Top := LocalSystemAccountCheckBox.Top + LocalSystemAccountCheckBox.Height + ScaleY(12);
109+
UserStaticText.Caption := 'User';
110+
UserStaticText.AutoSize := True;
111+
UserStaticText.Parent := Page.Surface;
112+
UserStaticText.Enabled := false;
113+
114+
UserEdit := TNewEdit.Create(Page);
115+
UserEdit.Parent := Page.Surface;
116+
UserEdit.Top := LocalSystemAccountCheckBox.Top + LocalSystemAccountCheckBox.Height + ScaleY(8);
117+
UserEdit.Left := ScaleX(100);
118+
UserEdit.Width := ScaleX(150);
119+
UserEdit.Enabled := false;
120+
121+
PassStaticText := TNewStaticText.Create(Page);
122+
PassStaticText.Top := UserEdit.Top + UserEdit.Height + ScaleY(12);
123+
PassStaticText.Caption := 'Password';
124+
PassStaticText.AutoSize := True;
125+
PassStaticText.Parent := Page.Surface;
126+
PassStaticText.Enabled := false;
127+
128+
PassEdit := TNewEdit.Create(Page);
129+
PassEdit.Parent := Page.Surface;
130+
PassEdit.Top := UserEdit.Top + UserEdit.Height + ScaleY(8);
131+
PassEdit.Left := UserEdit.Left;
132+
PassEdit.Width := UserEdit.Width;
133+
PassEdit.PasswordChar := '*';
134+
PassEdit.Enabled := false;
135+
136+
ConfPassStaticText := TNewStaticText.Create(Page);
137+
ConfPassStaticText.Top := PassEdit.Top + PassEdit.Height + ScaleY(12);
138+
ConfPassStaticText.Caption := 'Confirm password';
139+
ConfPassStaticText.AutoSize := True;
140+
ConfPassStaticText.Parent := Page.Surface;
141+
ConfPassStaticText.Enabled := false;
142+
143+
ConfPassEdit := TNewEdit.Create(Page);
144+
ConfPassEdit.Parent := Page.Surface;
145+
ConfPassEdit.Top := PassEdit.Top + PassEdit.Height + ScaleY(8);
146+
ConfPassEdit.Left := UserEdit.Left;
147+
ConfPassEdit.Width := UserEdit.Width;
148+
ConfPassEdit.PasswordChar := '*';
149+
ConfPassEdit.Enabled := false;
150+
end;
151+
152+
function NextButtonClick(CurPageID: Integer): Boolean;
153+
var
154+
ResultCode: Integer;
155+
begin
156+
Result := true;
157+
Log('NextButtonClick(' + IntToStr(CurPageID) + ') called');
158+
case CurPageID of
159+
Page.ID: begin
160+
if not LocalSystemAccountCheckBox.Checked then begin
161+
if UserEdit.Text = '' then begin
162+
Result := false;
163+
MsgBox('Pleas enter User', mbInformation, MB_OK);
164+
exit;
165+
end;
166+
if not (ConfPassEdit.Text = PassEdit.Text) then begin
167+
Result := false;
168+
MsgBox('Password does not match the confirm password', mbInformation, MB_OK);
169+
exit;
170+
end;
171+
end;
172+
end;
173+
end;
174+
end;
175+
176+
function GetUserName(Param: String): string;
177+
begin
178+
result := '.\' + UserEdit.Text;
179+
end;
180+
181+
function GetPassword(Param: String): string;
182+
begin
183+
result := PassEdit.Text;
184+
end;
185+
186+
procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
187+
var
188+
mres : integer;
189+
ResultCode: Integer;
190+
begin
191+
case CurUninstallStep of
192+
usPostUninstall:
193+
begin
194+
// mres := MsgBox('Do you want to delete saved files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
195+
// if mres = IDYES then
196+
DelTree(ExpandConstant('{userappdata}\DirectPrintServiceLogs'), True, True, True);
197+
end;
198+
end;
199+
end;

setup/Files/install.cmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
netsh firewall add portopening TCP 9188 "Direct Print Service" ENABLE ALL
2+
netsh firewall add portopening UDP 9188 "Direct Print Service" ENABLE ALL
3+
prunsrv //US//DirectPrintService --DisplayName="Direct Print Service" ^
4+
--Install="%~dp0prunsrv.exe" --Jvm=auto --StartMode=jvm --StopMode=jvm ^
5+
--StartClass=com.solvaig.print.PrintServer --StartParams=start ^
6+
--StopClass=com.solvaig.print.PrintServer --StopParams=stop ^
7+
--Startup=auto --Classpath=%CLASSPATH%;PrintServer.jar ^
8+
--ServiceUser=%1 --ServicePassword=%2
9+
net start DirectPrintService

setup/Files/install_ex.cmd

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
:: BatchGotAdmin
2+
:-------------------------------------
3+
REM --> Check for permissions
4+
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
5+
6+
REM --> If error flag set, we do not have admin.
7+
if '%errorlevel%' NEQ '0' (
8+
echo Requesting administrative privileges...
9+
goto UACPrompt
10+
) else ( goto gotAdmin )
11+
12+
:UACPrompt
13+
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
14+
echo UAC.ShellExecute "%~s0", "", "", "runas", 1 >> "%temp%\getadmin.vbs"
15+
16+
"%temp%\getadmin.vbs"
17+
exit /B
18+
19+
:gotAdmin
20+
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
21+
pushd "%CD%"
22+
CD /D "%~dp0"
23+
:--------------------------------------
24+
netsh firewall add portopening TCP 9188 "Direct Print Service" ENABLE ALL
25+
netsh firewall add portopening UDP 9188 "Direct Print Service" ENABLE ALL
26+
prunsrv //US//DirectPrintService --DisplayName="Direct Print Service" ^
27+
--Install="%~dp0prunsrv.exe" --Jvm=auto --StartMode=jvm --StopMode=jvm ^
28+
--StartClass=com.solvaig.print.PrintServer --StartParams=start ^
29+
--StopClass=com.solvaig.print.PrintServer --StopParams=stop ^
30+
--Startup=auto --Classpath=%CLASSPATH%;PrintServer.jar ^
31+
--LogPrefix=%SERVICE_NAME% ^
32+
--LogPath="%APPDATA%\DirectPrintServiceLogs" ^
33+
--StdOutput=auto ^
34+
--StdError=auto ^
35+
--LogLevel=INFO
36+
net start DirectPrintService
37+
pause

setup/Files/uninstall.cmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
prunsrv //DS//DirectPrintService

src/com/solvaig/print/PrintServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ public void run() {
212212
// Packet received
213213
System.out.println(getClass().getName() + ">>>Discovery packet received from: "
214214
+ packet.getAddress().getHostAddress());
215-
System.out.println(
216-
getClass().getName() + ">>>Packet received; data: " + new String(packet.getData()));
215+
// System.out.println(
216+
// getClass().getName() + ">>>Packet received; data: " + new String(packet.getData()));
217217

218218
// See if the packet holds the right command (message)
219219
String message = new String(packet.getData()).trim();

src/com/solvaig/print/ServerPrintServiceGrpc.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
package com.solvaig.print;
22

33
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
4-
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
54
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
6-
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
75
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
8-
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
96
import static io.grpc.stub.ClientCalls.futureUnaryCall;
107
import static io.grpc.MethodDescriptor.generateFullMethodName;
118
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
12-
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
139
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
14-
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
1510

1611
@javax.annotation.Generated("by gRPC proto compiler")
1712
public class ServerPrintServiceGrpc {

0 commit comments

Comments
 (0)