FreeRDP
Loading...
Searching...
No Matches
PrintJobMonitor.java
1/*
2 Print Job Monitor
3
4 Copyright 2026 Ibrahim Sevinc
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9*/
10
11package com.freerdp.freerdpcore.presentation;
12
13import android.os.FileObserver;
14
15import androidx.annotation.Nullable;
16
17import java.io.File;
18
23public class PrintJobMonitor extends FileObserver
24{
25 public interface Listener
26 {
27 void onPrintJobComplete(File pdfFile);
28 }
29
30 private static final String WATCH_DIR = "/sdcard/Download";
31 private static final String PREFIX = "rdp_print_";
32 private static final String SUFFIX = ".pdf";
33
34 private final Listener listener;
35
36 public PrintJobMonitor(Listener listener)
37 {
38 super(new File(WATCH_DIR), CLOSE_WRITE);
39 this.listener = listener;
40 }
41
42 @Override public void onEvent(int event, @Nullable String path)
43 {
44 if (path == null)
45 return;
46 if (!path.startsWith(PREFIX) || !path.endsWith(SUFFIX))
47 return;
48 listener.onPrintJobComplete(new File(WATCH_DIR, path));
49 }
50}