1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 * Copyright (C) 2016 Mopria Alliance, Inc.
4 * Copyright (C) 2013 Hewlett-Packard Development Company, L.P.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18#ifndef __IFC_PRINT_JOB_H__
19#define __IFC_PRINT_JOB_H__
20
21#include "lib_wprint.h"
22#include "ifc_wprint.h"
23
24/*
25 * Interface for handling jobs
26 */
27typedef struct ifc_print_job_st {
28    /*
29     * Initializes print job handle with given connection params.
30     */
31    status_t (*init)(const struct ifc_print_job_st *this_p, const char *printer_address, int port,
32            const char *printer_uri);
33
34    /*
35     * Validates job and connection params, updating parameters as necessary.
36     */
37    status_t (*validate_job)(const struct ifc_print_job_st *this_p,
38            wprint_job_params_t *job_params);
39
40    /*
41     * Start a print job with given params
42     */
43    status_t (*start_job)(const struct ifc_print_job_st *this_p,
44            const wprint_job_params_t *job_params);
45
46    /*
47     * Sends data to the ip address set on initialization, returning the amount of data
48     * written or -1 for an error.
49     */
50    int (*send_data)(const struct ifc_print_job_st *this_p, const char *buffer,
51            size_t bufferLength);
52
53    /*
54     * Returns print job status
55     */
56    status_t (*check_status)(const struct ifc_print_job_st *this_p);
57
58    /*
59     * Ends a print job
60     */
61    status_t (*end_job)(const struct ifc_print_job_st *this_p);
62
63    /*
64     * Destroys a print job handle
65     */
66    void (*destroy)(const struct ifc_print_job_st *this_p);
67
68    /*
69     * Enable a timeout for a print job
70     */
71    void (*enable_timeout)(const struct ifc_print_job_st *this_p,
72            int enable);
73} ifc_print_job_t;
74
75/*
76 * Connect to a printer with a given protocol. Returns a job handle.
77 */
78const ifc_print_job_t *printer_connect(int port_num);
79
80/*
81 * Opens a socket to printer:port and returns it.
82 */
83int wConnect(const char *printer_addr, int port_num, long int timeout_msec);
84
85#endif // __IFC_PRINT_JOB_H__