1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright 2009-2010 Red Hat, Inc,
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
#include <gtk/gtk.h>
#include <cups/cups.h>
#include "pp-print-device.h"
#define ALLOWED_CHARACTERS "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
#define MECHANISM_BUS "org.opensuse.CupsPkHelper.Mechanism"
#define SCP_BUS "org.fedoraproject.Config.Printing"
#define SCP_PATH "/org/fedoraproject/Config/Printing"
#define SCP_IFACE "org.fedoraproject.Config.Printing"
G_BEGIN_DECLS
typedef void (*UserResponseCallback) (GtkDialog *dialog, gint response_id, gpointer user_data);
/*
* Match level of PPD driver.
*/
enum
{
PPD_NO_MATCH = 0,
PPD_GENERIC_MATCH,
PPD_CLOSE_MATCH,
PPD_EXACT_MATCH,
PPD_EXACT_CMD_MATCH
};
enum
{
ACQUISITION_METHOD_DEFAULT_CUPS_SERVER = 0,
ACQUISITION_METHOD_REMOTE_CUPS_SERVER,
ACQUISITION_METHOD_SNMP,
ACQUISITION_METHOD_SAMBA,
ACQUISITION_METHOD_SAMBA_HOST,
ACQUISITION_METHOD_JETDIRECT,
ACQUISITION_METHOD_LPD
};
typedef struct
{
gchar *ppd_name;
gchar *ppd_display_name;
gint ppd_match_level;
} PPDName;
typedef struct
{
gchar *manufacturer_name;
gchar *manufacturer_display_name;
PPDName **ppds;
gsize num_of_ppds;
} PPDManufacturerItem;
typedef struct
{
PPDManufacturerItem **manufacturers;
gsize num_of_manufacturers;
} PPDList;
gchar *get_tag_value (const gchar *tag_string,
const gchar *tag_name);
char *get_dest_attr (const char *dest_name,
const char *attr);
gchar *get_ppd_attribute (const gchar *ppd_file_name,
const gchar *attribute_name);
void set_local_default_printer (const gchar *printer_name);
gboolean printer_set_location (const gchar *printer_name,
const gchar *location);
gboolean printer_set_accepting_jobs (const gchar *printer_name,
gboolean accepting_jobs,
const gchar *reason);
gboolean printer_set_enabled (const gchar *printer_name,
gboolean enabled);
gboolean printer_rename (const gchar *old_name,
const gchar *new_name);
gboolean printer_delete (const gchar *printer_name);
gboolean printer_set_default (const gchar *printer_name);
gboolean printer_set_shared (const gchar *printer_name,
gboolean shared);
gboolean printer_set_job_sheets (const gchar *printer_name,
const gchar *start_sheet,
const gchar *end_sheet);
gboolean printer_set_policy (const gchar *printer_name,
const gchar *policy,
gboolean error_policy);
gboolean printer_set_users (const gchar *printer_name,
gchar **users,
gboolean allowed);
gboolean class_add_printer (const gchar *class_name,
const gchar *printer_name);
gboolean printer_is_local (cups_ptype_t printer_type,
const gchar *device_uri);
gchar *printer_get_hostname (cups_ptype_t printer_type,
const gchar *device_uri,
const gchar *printer_uri);
typedef void (*PSPCallback) (const gchar *printer_name,
gboolean success,
gpointer user_data);
void printer_set_ppd_async (const gchar *printer_name,
const gchar *ppd_name,
GCancellable *cancellable,
PSPCallback callback,
gpointer user_data);
void printer_set_ppd_file_async (const gchar *printer_name,
const gchar *ppd_filename,
GCancellable *cancellable,
PSPCallback callback,
gpointer user_data);
typedef void (*GPNCallback) (PPDName **names,
const gchar *printer_name,
gboolean cancelled,
gpointer user_data);
void get_ppd_names_async (gchar *printer_name,
gint count,
GCancellable *cancellable,
GPNCallback callback,
gpointer user_data);
typedef void (*GAPCallback) (PPDList *ppds,
gpointer user_data);
void get_all_ppds_async (GCancellable *cancellable,
GAPCallback callback,
gpointer user_data);
PPDList *ppd_list_copy (PPDList *list);
void ppd_list_free (PPDList *list);
enum
{
IPP_ATTRIBUTE_TYPE_INTEGER = 0,
IPP_ATTRIBUTE_TYPE_STRING,
IPP_ATTRIBUTE_TYPE_RANGE,
IPP_ATTRIBUTE_TYPE_BOOLEAN
};
typedef struct
{
gboolean boolean_value;
gchar *string_value;
gint integer_value;
gint lower_range;
gint upper_range;
} IPPAttributeValue;
typedef struct
{
gchar *attribute_name;
IPPAttributeValue *attribute_values;
gint num_of_values;
gint attribute_type;
} IPPAttribute;
typedef void (*GIACallback) (GHashTable *table,
gpointer user_data);
void get_ipp_attributes_async (const gchar *printer_name,
gchar **attributes_names,
GIACallback callback,
gpointer user_data);
IPPAttribute *ipp_attribute_copy (IPPAttribute *attr);
void ipp_attribute_free (IPPAttribute *attr);
gchar *get_standard_manufacturers_name (const gchar *name);
typedef void (*PGPCallback) (const gchar *ppd_filename,
gpointer user_data);
void printer_get_ppd_async (const gchar *printer_name,
const gchar *host_name,
gint port,
PGPCallback callback,
gpointer user_data);
/* NOTE: 'destination' is passed with ownership as cupsCopyDest doesn't seem to work as expected */
typedef void (*GNDCallback) (cups_dest_t *destination,
gpointer user_data);
void get_named_dest_async (const gchar *printer_name,
GNDCallback callback,
gpointer user_data);
typedef void (*PAOCallback) (gboolean success,
gpointer user_data);
void printer_add_option_async (const gchar *printer_name,
const gchar *option_name,
gchar **values,
gboolean set_default,
GCancellable *cancellable,
PAOCallback callback,
gpointer user_data);
const gchar *get_page_size_from_locale (void);
typedef void (*GCDCallback) (GPtrArray *devices,
gboolean finished,
gboolean cancelled,
gpointer user_data);
void get_cups_devices_async (GCancellable *cancellable,
GCDCallback callback,
gpointer user_data);
gchar *guess_device_hostname (PpPrintDevice *device);
gchar *canonicalize_device_name (GList *device_names,
GPtrArray *local_cups_devices,
cups_dest_t *dests,
gint num_of_dests,
PpPrintDevice *device);
void shift_string_left (gchar *str);
gboolean printer_name_is_valid (const gchar *str);
G_END_DECLS
|