2 * Copyright (C) 2006 John (J5) Palmieri <johnp@redhat.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef __GTK_CUPS_UTILS_H__
21 #define __GTK_CUPS_UTILS_H__
24 #include <cups/cups.h>
25 #include <cups/language.h>
26 #include <cups/http.h>
31 typedef struct _GtkCupsRequest GtkCupsRequest;
32 typedef struct _GtkCupsResult GtkCupsResult;
42 * Direction we should be polling the http socket on.
43 * We are either reading or writting at each state.
44 * This makes it easy for mainloops to connect to poll.
54 struct _GtkCupsRequest
56 GtkCupsRequestType type;
59 http_status_t last_status;
67 GtkCupsResult *result;
70 GtkCupsPollState poll_state;
75 #define GTK_CUPS_REQUEST_START 0
76 #define GTK_CUPS_REQUEST_DONE 500
81 GTK_CUPS_POST_CONNECT = GTK_CUPS_REQUEST_START,
83 GTK_CUPS_POST_WRITE_REQUEST,
84 GTK_CUPS_POST_WRITE_DATA,
86 GTK_CUPS_POST_READ_RESPONSE,
87 GTK_CUPS_POST_DONE = GTK_CUPS_REQUEST_DONE
93 GTK_CUPS_GET_CONNECT = GTK_CUPS_REQUEST_START,
96 GTK_CUPS_GET_READ_DATA,
97 GTK_CUPS_GET_DONE = GTK_CUPS_REQUEST_DONE
100 GtkCupsRequest * gtk_cups_request_new (http_t *connection,
101 GtkCupsRequestType req_type,
105 const char *resource);
106 void gtk_cups_request_ipp_add_string (GtkCupsRequest *request,
112 gboolean gtk_cups_request_read_write (GtkCupsRequest *request);
113 GtkCupsPollState gtk_cups_request_get_poll_state (GtkCupsRequest *request);
114 void gtk_cups_request_free (GtkCupsRequest *request);
115 GtkCupsResult * gtk_cups_request_get_result (GtkCupsRequest *request);
116 gboolean gtk_cups_request_is_done (GtkCupsRequest *request);
117 void gtk_cups_request_encode_option (GtkCupsRequest *request,
120 gboolean gtk_cups_result_is_error (GtkCupsResult *result);
121 ipp_t * gtk_cups_result_get_response (GtkCupsResult *result);
122 const char * gtk_cups_result_get_error_string (GtkCupsResult *result);