summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/media/gtkffmediafile.c6
-rw-r--r--modules/media/gtkgstmediafile.c18
-rw-r--r--modules/media/meson.build15
-rw-r--r--modules/printbackends/gtkcloudprintaccount.c30
-rw-r--r--modules/printbackends/gtkcloudprintaccount.h12
-rw-r--r--modules/printbackends/gtkcupssecretsutils.c68
-rw-r--r--modules/printbackends/gtkcupssecretsutils.h10
-rw-r--r--modules/printbackends/gtkcupsutils.c108
-rw-r--r--modules/printbackends/gtkcupsutils.h38
-rw-r--r--modules/printbackends/gtkprintbackendcloudprint.c54
-rw-r--r--modules/printbackends/gtkprintbackendcloudprint.h2
-rw-r--r--modules/printbackends/gtkprintbackendcups.c1151
-rw-r--r--modules/printbackends/gtkprintbackendcups.h2
-rw-r--r--modules/printbackends/gtkprintbackendfile.c92
-rw-r--r--modules/printbackends/gtkprintbackendfile.h2
-rw-r--r--modules/printbackends/gtkprintbackendlpr.c30
-rw-r--r--modules/printbackends/gtkprintbackendlpr.h2
-rw-r--r--modules/printbackends/gtkprintercloudprint.c4
-rw-r--r--modules/printbackends/gtkprintercloudprint.h4
-rw-r--r--modules/printbackends/gtkprintercups.c30
-rw-r--r--modules/printbackends/gtkprintercups.h59
-rw-r--r--modules/printbackends/meson.build53
22 files changed, 928 insertions, 862 deletions
diff --git a/modules/media/gtkffmediafile.c b/modules/media/gtkffmediafile.c
index 04737f7474..cf7a03489f 100644
--- a/modules/media/gtkffmediafile.c
+++ b/modules/media/gtkffmediafile.c
@@ -171,6 +171,7 @@ G_DEFINE_TYPE_EXTENDED (GtkFfMediaFile, gtk_ff_media_file, GTK_TYPE_MEDIA_FILE,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_ff_media_file_paintable_init))
+G_MODULE_EXPORT
void
g_io_module_load (GIOModule *module)
{
@@ -186,17 +187,20 @@ g_io_module_load (GIOModule *module)
0);
}
+G_MODULE_EXPORT
+G_GNUC_NORETURN
void
g_io_module_unload (GIOModule *module)
{
g_assert_not_reached ();
}
+G_MODULE_EXPORT
char **
g_io_module_query (void)
{
char *eps[] = {
- GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
+ (char *) GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
NULL
};
diff --git a/modules/media/gtkgstmediafile.c b/modules/media/gtkgstmediafile.c
index afbf637bd3..b094796fd5 100644
--- a/modules/media/gtkgstmediafile.c
+++ b/modules/media/gtkgstmediafile.c
@@ -96,6 +96,7 @@ gtk_gst_media_file_paintable_init (GdkPaintableInterface *iface)
G_DEFINE_TYPE_EXTENDED (GtkGstMediaFile, gtk_gst_media_file, GTK_TYPE_MEDIA_FILE, 0,
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
gtk_gst_media_file_paintable_init))
+
void
g_io_module_load (GIOModule *module)
{
@@ -107,6 +108,7 @@ g_io_module_load (GIOModule *module)
10);
}
+G_GNUC_NORETURN
void
g_io_module_unload (GIOModule *module)
{
@@ -117,7 +119,7 @@ char **
g_io_module_query (void)
{
char *eps[] = {
- GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
+ (char *) GTK_MEDIA_FILE_EXTENSION_POINT_NAME,
NULL
};
@@ -159,6 +161,18 @@ gtk_gst_media_file_seek_done_cb (GstPlayer *player,
}
static void
+gtk_gst_media_file_error_cb (GstPlayer *player,
+ GError *error,
+ GtkGstMediaFile *self)
+{
+ if (gtk_media_stream_get_error (GTK_MEDIA_STREAM (self)))
+ return;
+
+ gtk_media_stream_gerror (GTK_MEDIA_STREAM (self),
+ g_error_copy (error));
+}
+
+static void
gtk_gst_media_file_end_of_stream_cb (GstPlayer *player,
GtkGstMediaFile *self)
{
@@ -184,6 +198,7 @@ gtk_gst_media_file_destroy_player (GtkGstMediaFile *self)
g_signal_handlers_disconnect_by_func (self->player, gtk_gst_media_file_position_updated_cb, self);
g_signal_handlers_disconnect_by_func (self->player, gtk_gst_media_file_end_of_stream_cb, self);
g_signal_handlers_disconnect_by_func (self->player, gtk_gst_media_file_seek_done_cb, self);
+ g_signal_handlers_disconnect_by_func (self->player, gtk_gst_media_file_error_cb, self);
g_object_unref (self->player);
self->player = NULL;
}
@@ -202,6 +217,7 @@ gtk_gst_media_file_create_player (GtkGstMediaFile *file)
g_signal_connect (self->player, "position-updated", G_CALLBACK (gtk_gst_media_file_position_updated_cb), self);
g_signal_connect (self->player, "end-of-stream", G_CALLBACK (gtk_gst_media_file_end_of_stream_cb), self);
g_signal_connect (self->player, "seek-done", G_CALLBACK (gtk_gst_media_file_seek_done_cb), self);
+ g_signal_connect (self->player, "error", G_CALLBACK (gtk_gst_media_file_error_cb), self);
}
static void
diff --git a/modules/media/meson.build b/modules/media/meson.build
index 860fe467e9..59124d3154 100644
--- a/modules/media/meson.build
+++ b/modules/media/meson.build
@@ -23,6 +23,13 @@ endif
media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version)
media_install_dir = join_paths(get_option('libdir'), media_subdir)
+extra_c_args = [
+ '-DGTK_COMPILATION',
+ '-D_GLIB_EXTERN=@0@'.format(visibility_define),
+]
+
+extra_c_args += common_cflags
+
if media_backends.contains('ffmpeg')
libavfilter_dep = dependency('libavfilter', version: '>= 6.47.100', required: true)
libavformat_dep = dependency('libavformat', version: '>= 57.41.100', required: true)
@@ -34,9 +41,7 @@ if media_backends.contains('ffmpeg')
shared_module('media-ffmpeg',
'gtkffmediafile.c',
- c_args: [
- '-DGTK_COMPILATION'
- ],
+ c_args: extra_c_args,
dependencies: [ libgtk_dep, ffmpeg_deps ],
install_dir: media_install_dir,
install : true)
@@ -50,9 +55,7 @@ if media_backends.contains('gstreamer')
'gtkgstmediafile.c',
'gtkgstpaintable.c',
'gtkgstsink.c',
- c_args: [
- '-DGTK_COMPILATION'
- ],
+ c_args: extra_c_args,
dependencies: [ libgtk_dep, gstplayer_dep ],
install_dir: media_install_dir,
install : true)
diff --git a/modules/printbackends/gtkcloudprintaccount.c b/modules/printbackends/gtkcloudprintaccount.c
index ee65a18287..bc2b9ab8f1 100644
--- a/modules/printbackends/gtkcloudprintaccount.c
+++ b/modules/printbackends/gtkcloudprintaccount.c
@@ -49,11 +49,11 @@ struct _GtkCloudprintAccount
{
GObject parent_instance;
- gchar *printer_id;
- gchar *goa_path;
- gchar *presentation_identity;
+ char *printer_id;
+ char *goa_path;
+ char *presentation_identity;
RestProxy *rest_proxy;
- gchar *oauth2_access_token;
+ char *oauth2_access_token;
};
static void gtk_cloudprint_account_class_init (GtkCloudprintAccountClass *class);
@@ -100,9 +100,9 @@ gtk_cloudprint_account_get_type (void)
* Returns: the new #GtkCloudprintAccount object
**/
GtkCloudprintAccount *
-gtk_cloudprint_account_new (const gchar *id,
- const gchar *path,
- const gchar *presentation_identity)
+gtk_cloudprint_account_new (const char *id,
+ const char *path,
+ const char *presentation_identity)
{
GtkCloudprintAccount *account = g_object_new (GTK_TYPE_CLOUDPRINT_ACCOUNT,
NULL);
@@ -189,7 +189,7 @@ cloudprint_json_parse (RestProxyCall *call, JsonObject **result, GError **error)
if (!success)
{
- const gchar *message = "(no message)";
+ const char *message = "(no message)";
if (json_object_has_member (json_object, "message"))
message = json_object_get_string_member (json_object, "message");
@@ -282,7 +282,7 @@ gtk_cloudprint_account_got_oauth2_access_token_cb (GObject *source,
RestProxyCall *call;
RestProxy *rest;
GVariant *output;
- gint expires_in = 0;
+ int expires_in = 0;
GError *error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
@@ -350,7 +350,7 @@ gtk_cloudprint_account_ensure_credentials_cb (GObject *source,
GTask *task = user_data;
GtkCloudprintAccount *account = g_task_get_task_data (task);
GVariant *output;
- gint expires_in = 0;
+ int expires_in = 0;
GError *error = NULL;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source),
@@ -484,7 +484,7 @@ gtk_cloudprint_account_printer_rest_call_cb (RestProxyCall *call,
void
gtk_cloudprint_account_printer (GtkCloudprintAccount *account,
- const gchar *printerid,
+ const char *printerid,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -577,17 +577,17 @@ void
gtk_cloudprint_account_submit (GtkCloudprintAccount *account,
GtkPrinterCloudprint *printer,
GMappedFile *file,
- const gchar *title,
+ const char *title,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
RestProxyCall *call;
- gchar *printerid = NULL;
+ char *printerid = NULL;
RestParam *param;
GError *error = NULL;
- gchar *auth;
+ char *auth;
g_object_get (printer,
"printer-id", &printerid,
@@ -655,7 +655,7 @@ gtk_cloudprint_account_submit_finish (GtkCloudprintAccount *account,
return g_task_propagate_pointer (G_TASK (result), error);
}
-const gchar *
+const char *
gtk_cloudprint_account_get_presentation_identity (GtkCloudprintAccount *account)
{
return account->presentation_identity;
diff --git a/modules/printbackends/gtkcloudprintaccount.h b/modules/printbackends/gtkcloudprintaccount.h
index ef788743d3..7cb2333ac2 100644
--- a/modules/printbackends/gtkcloudprintaccount.h
+++ b/modules/printbackends/gtkcloudprintaccount.h
@@ -33,9 +33,9 @@ typedef struct _GtkPrinterCloudprint GtkPrinterCloudprint;
typedef struct _GtkCloudprintAccount GtkCloudprintAccount;
void gtk_cloudprint_account_register_type (GTypeModule *module);
-GtkCloudprintAccount *gtk_cloudprint_account_new (const gchar *id,
- const gchar *path,
- const gchar *presentation_identity);
+GtkCloudprintAccount *gtk_cloudprint_account_new (const char *id,
+ const char *path,
+ const char *presentation_identity);
GType gtk_cloudprint_account_get_type (void) G_GNUC_CONST;
void gtk_cloudprint_account_search (GtkCloudprintAccount *account,
@@ -48,7 +48,7 @@ JsonNode *gtk_cloudprint_account_search_finish (GtkCloudprintAccount *account,
GError **error);
void gtk_cloudprint_account_printer (GtkCloudprintAccount *account,
- const gchar *printerid,
+ const char *printerid,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -59,7 +59,7 @@ JsonObject *gtk_cloudprint_account_printer_finish (GtkCloudprintAccount *account
void gtk_cloudprint_account_submit (GtkCloudprintAccount *account,
GtkPrinterCloudprint *printer,
GMappedFile *file,
- const gchar *title,
+ const char *title,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -67,7 +67,7 @@ JsonObject *gtk_cloudprint_account_submit_finish (GtkCloudprintAccount *account,
GAsyncResult *result,
GError **error);
-const gchar *gtk_cloudprint_account_get_presentation_identity (GtkCloudprintAccount *account);
+const char *gtk_cloudprint_account_get_presentation_identity (GtkCloudprintAccount *account);
G_END_DECLS
diff --git a/modules/printbackends/gtkcupssecretsutils.c b/modules/printbackends/gtkcupssecretsutils.c
index 925f7d561c..47e707b114 100644
--- a/modules/printbackends/gtkcupssecretsutils.c
+++ b/modules/printbackends/gtkcupssecretsutils.c
@@ -38,7 +38,7 @@ typedef struct
{
GDBusConnection *dbus_connection;
SecretsServiceAction action;
- gchar **auth_info,
+ char **auth_info,
**auth_info_labels,
**auth_info_required,
*printer_uri,
@@ -60,9 +60,9 @@ typedef struct
* Returns: A GVariant dictionary of string pairs or NULL on error.
*/
static GVariant *
-create_attributes (const gchar *printer_uri,
- gchar **additional_attrs,
- gchar **additional_labels)
+create_attributes (const char *printer_uri,
+ const char **additional_attrs,
+ const char **additional_labels)
{
GVariantBuilder *attr_builder = NULL;
GVariant *ret = NULL;
@@ -105,12 +105,12 @@ get_secret_cb (GObject *source_object,
GError *error = NULL;
GVariant *output,
*attributes;
- gchar **auth_info = NULL,
+ char **auth_info = NULL,
*key = NULL,
*value = NULL;
GVariantIter *iter = NULL;
guint i, required_len;
- gint pw_field = -1;
+ int pw_field = -1;
task = user_data;
task_data = g_task_get_task_data (task);
@@ -137,7 +137,7 @@ get_secret_cb (GObject *source_object,
/* Iterate over the attributes to fill the auth info */
g_variant_get (attributes, "a{ss}", &iter);
- auth_info = g_new0 (gchar *,
+ auth_info = g_new0 (char *,
g_strv_length (task_data->auth_info_required) + 1);
while (g_variant_iter_loop (iter, "{ss}", &key, &value))
@@ -231,7 +231,7 @@ fail:
required_len = g_strv_length (task_data->auth_info_required);
for (i = 0; i < required_len; i++)
{
- /* Not all fields of auth_info are neccessarily written so we can not
+ /* Not all fields of auth_info are necessarily written so we can not
use strfreev here */
g_free (auth_info[i]);
}
@@ -247,7 +247,7 @@ create_item_cb (GObject *source_object,
GTask *task;
GError *error = NULL;
GVariant *output;
- gchar *item = NULL;
+ char *item = NULL;
task = user_data;
@@ -276,7 +276,7 @@ do_store_auth_info (GTask *task)
GVariant *attributes = NULL,
*properties = NULL,
*secret = NULL;
- gchar **additional_attrs = NULL,
+ const char **additional_attrs = NULL,
**additional_labels = NULL,
*password = NULL;
SecretsServiceData *task_data = g_task_get_task_data (task);
@@ -287,8 +287,8 @@ do_store_auth_info (GTask *task)
length = g_strv_length (task_data->auth_info_labels);
- additional_attrs = g_new0 (gchar *, length + 1);
- additional_labels = g_new0 (gchar *, length + 1);
+ additional_attrs = g_new0 (const char *, length + 1);
+ additional_labels = g_new0 (const char *, length + 1);
/* The labels user and server are chosen to be compatible with
the attributes used by system-config-printer */
for (i = 0; task_data->auth_info_labels[i] != NULL; i++)
@@ -364,10 +364,10 @@ do_store_auth_info (GTask *task)
static void
prompt_completed_cb (GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
+ const char *sender_name,
+ const char *object_path,
+ const char *interface_name,
+ const char *signal_name,
GVariant *parameters,
gpointer user_data)
{
@@ -402,7 +402,7 @@ prompt_completed_cb (GDBusConnection *connection,
return;
}
- /* Prompt successfull, proceed to get or store secret */
+ /* Prompt successful, proceed to get or store secret */
switch (task_data->action)
{
case SECRETS_SERVICE_ACTION_STORE:
@@ -420,6 +420,8 @@ prompt_completed_cb (GDBusConnection *connection,
get_secret_cb,
task);
break;
+ default:
+ ;
}
}
@@ -470,7 +472,7 @@ unlock_collection_cb (GObject *source_object,
SecretsServiceData *task_data;
GError *error = NULL;
GVariant *output;
- const gchar *prompt_path;
+ const char *prompt_path;
task = user_data;
task_data = g_task_get_task_data (task);
@@ -510,7 +512,7 @@ unlock_collection_cb (GObject *source_object,
break;
case SECRETS_SERVICE_ACTION_QUERY:
- /* Prompt successfull proceed to get secret */
+ /* Prompt successful proceed to get secret */
g_dbus_proxy_call (task_data->item_proxy,
"GetSecret",
g_variant_new ("(o)",
@@ -521,6 +523,8 @@ unlock_collection_cb (GObject *source_object,
get_secret_cb,
task);
break;
+ default:
+ ;
}
}
g_variant_unref (output);
@@ -536,8 +540,8 @@ unlock_read_alias_cb (GObject *source_object,
GError *error = NULL;
GVariant *output, *subresult;
gsize path_len = 0;
- const gchar *collection_path;
- const gchar *to_unlock[2];
+ const char *collection_path;
+ const char *to_unlock[2];
task = user_data;
task_data = g_task_get_task_data (task);
@@ -656,6 +660,8 @@ item_proxy_cb (GObject *source_object,
get_secret_cb,
task);
break;
+ default:
+ ;
}
}
@@ -689,7 +695,7 @@ search_items_cb (GObject *source_object,
for (i = 0; i < array_cnt; i++)
{
GVariant * const item_paths = g_variant_get_child_value (output, i);
- const gchar **items = NULL;
+ const char **items = NULL;
if (item_paths == NULL)
{
@@ -826,6 +832,8 @@ open_session_cb (GObject *source_object,
task);
break;
}
+ default:
+ ;
}
}
@@ -888,10 +896,10 @@ gtk_cups_secrets_service_watch (GBusNameAppearedCallback appeared,
NULL);
}
-void
+static void
cleanup_task_data (gpointer data)
{
- gint i;
+ int i;
SecretsServiceData *task_data = data;
g_free (task_data->collection_path);
@@ -942,7 +950,7 @@ cleanup_task_data (gpointer data)
* @source_object: Source object for this task
* @cancellable: Cancellable to cancel this task
* @callback: Callback to call once the query is finished
- * @user_data: The user_data passed to the callback
+ * @user_data: (closure): The user_data passed to the callback
* @printer_uri: URI of the printer
* @auth_info_required: Info required for authentication
*
@@ -962,8 +970,8 @@ gtk_cups_secrets_service_query_task (gpointer source_object,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
- const gchar *printer_uri,
- gchar **auth_info_required)
+ const char *printer_uri,
+ char **auth_info_required)
{
GTask *task;
SecretsServiceData *task_data;
@@ -1012,9 +1020,9 @@ store_done_cb (GObject *source_object,
* Tries to store the auth_info in a secrets service.
*/
void
-gtk_cups_secrets_service_store (gchar **auth_info,
- gchar **auth_info_labels,
- const gchar *printer_uri)
+gtk_cups_secrets_service_store (char **auth_info,
+ char **auth_info_labels,
+ const char *printer_uri)
{
GTask *task;
SecretsServiceData *task_data;
diff --git a/modules/printbackends/gtkcupssecretsutils.h b/modules/printbackends/gtkcupssecretsutils.h
index 1a0424a3bf..e8fb07b143 100644
--- a/modules/printbackends/gtkcupssecretsutils.h
+++ b/modules/printbackends/gtkcupssecretsutils.h
@@ -27,14 +27,14 @@ void gtk_cups_secrets_service_query_task (gpointer source_obj
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
- const gchar *printer_uri,
- gchar **auth_info_required);
+ const char *printer_uri,
+ char **auth_info_required);
guint gtk_cups_secrets_service_watch (GBusNameAppearedCallback appeared,
GBusNameVanishedCallback vanished,
gpointer user_data);
-void gtk_cups_secrets_service_store (gchar **auth_info,
- gchar **auth_info_labels,
- const gchar *printer_uri);
+void gtk_cups_secrets_service_store (char **auth_info,
+ char **auth_info_labels,
+ const char *printer_uri);
G_END_DECLS
diff --git a/modules/printbackends/gtkcupsutils.c b/modules/printbackends/gtkcupsutils.c
index 54239cad07..7955302819 100644
--- a/modules/printbackends/gtkcupsutils.c
+++ b/modules/printbackends/gtkcupsutils.c
@@ -47,7 +47,7 @@ static void _get_read_data (GtkCupsRequest *request);
struct _GtkCupsResult
{
- gchar *error_msg;
+ char *error_msg;
ipp_t *ipp_response;
GtkCupsErrorType error_type;
@@ -81,35 +81,13 @@ static GtkCupsRequestStateFunc get_states[] = {
_get_read_data
};
-#ifndef HAVE_CUPS_API_1_6
-#define ippSetOperation(ipp_request, ipp_op_id) ipp_request->request.op.operation_id = ipp_op_id
-#define ippSetRequestId(ipp_request, ipp_rq_id) ipp_request->request.op.request_id = ipp_rq_id
-#define ippSetState(ipp_request, ipp_state) ipp_request->state = ipp_state
-#define ippGetString(attr, index, foo) attr->values[index].string.text
-#define ippGetCount(attr) attr->num_values
-
-int
-ippSetVersion (ipp_t *ipp,
- int major,
- int minor)
-{
- if (!ipp || major < 0 || minor < 0)
- return 0;
-
- ipp->request.any.version[0] = major;
- ipp->request.any.version[1] = minor;
-
- return 1;
-}
-#endif
-
-static void
+static void G_GNUC_PRINTF (5, 6)
gtk_cups_result_set_error (GtkCupsResult *result,
GtkCupsErrorType error_type,
int error_status,
- int error_code,
+ int error_code,
const char *error_msg,
- ...)
+ ...)
{
va_list args;
@@ -127,7 +105,7 @@ gtk_cups_result_set_error (GtkCupsResult *result,
GtkCupsRequest *
gtk_cups_request_new_with_username (http_t *connection,
GtkCupsRequestType req_type,
- gint operation_id,
+ int operation_id,
GIOChannel *data_io,
const char *server,
const char *resource,
@@ -168,10 +146,10 @@ gtk_cups_request_new_with_username (http_t *connection,
}
else
{
- request->http = NULL;
- request->http = httpConnectEncrypt (request->server,
- ippPort (),
- cupsEncryption ());
+ request->http = httpConnect2 (request->server, ippPort (),
+ NULL, AF_UNSPEC,
+ cupsEncryption (),
+ 1, 30000, NULL);
if (request->http)
httpBlocking (request->http, 0);
@@ -219,7 +197,7 @@ gtk_cups_request_new_with_username (http_t *connection,
GtkCupsRequest *
gtk_cups_request_new (http_t *connection,
GtkCupsRequestType req_type,
- gint operation_id,
+ int operation_id,
GIOChannel *data_io,
const char *server,
const char *resource)
@@ -426,7 +404,7 @@ static const ipp_option_t ipp_options[] = {
static ipp_tag_t
-_find_option_tag (const gchar *option)
+_find_option_tag (const char *option)
{
int lower_bound, upper_bound, num_options;
int current_option;
@@ -478,8 +456,8 @@ _find_option_tag (const gchar *option)
*/
void
gtk_cups_request_encode_option (GtkCupsRequest *request,
- const gchar *option,
- const gchar *value)
+ const char *option,
+ const char *value)
{
ipp_tag_t option_tag;
@@ -498,7 +476,7 @@ gtk_cups_request_encode_option (GtkCupsRequest *request,
}
}
- switch (option_tag)
+ switch ((guint)option_tag)
{
case IPP_TAG_INTEGER:
case IPP_TAG_ENUM:
@@ -672,8 +650,8 @@ gtk_cups_request_encode_option (GtkCupsRequest *request,
void
gtk_cups_request_set_ipp_version (GtkCupsRequest *request,
- gint major,
- gint minor)
+ int major,
+ int minor)
{
ippSetVersion (request->ipp_request, major, minor);
}
@@ -686,10 +664,10 @@ _connect (GtkCupsRequest *request)
if (request->http == NULL)
{
- request->http = httpConnectEncrypt (request->server,
- ippPort (),
- cupsEncryption ());
-
+ request->http = httpConnect2 (request->server, ippPort (),
+ NULL, AF_UNSPEC,
+ cupsEncryption (),
+ 1, 30000, NULL);
if (request->http == NULL)
request->attempts++;
@@ -712,7 +690,7 @@ _connect (GtkCupsRequest *request)
static void
_post_send (GtkCupsRequest *request)
{
- gchar length[255];
+ char length[255];
struct stat data_info;
GTK_NOTE (PRINTING,
@@ -731,17 +709,15 @@ _post_send (GtkCupsRequest *request)
httpClearFields (request->http);
httpSetField (request->http, HTTP_FIELD_CONTENT_LENGTH, length);
httpSetField (request->http, HTTP_FIELD_CONTENT_TYPE, "application/ipp");
-#ifdef HAVE_HTTPGETAUTHSTRING
httpSetField (request->http, HTTP_FIELD_AUTHORIZATION, httpGetAuthString (request->http));
-#else
-#ifdef HAVE_HTTP_AUTHSTRING
- httpSetField (request->http, HTTP_FIELD_AUTHORIZATION, request->http->authstring);
-#endif
-#endif
if (httpPost (request->http, request->resource))
{
- if (httpReconnect (request->http))
+ int res;
+
+ res = httpReconnect2 (request->http, 30000, NULL);
+
+ if (res)
{
request->state = GTK_CUPS_POST_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
@@ -1039,7 +1015,7 @@ _post_check (GtkCupsRequest *request)
}
if (auth_result ||
- httpReconnect (request->http))
+ httpReconnect2 (request->http, 30000, NULL))
{
/* if the password has been used, reset password_state
* so that we ask for a new one next time around
@@ -1098,7 +1074,7 @@ _post_check (GtkCupsRequest *request)
request->state = GTK_CUPS_POST_CONNECT;
/* Reconnect... */
- httpReconnect (request->http);
+ httpReconnect2 (request->http, 30000, NULL);
/* Upgrade with encryption... */
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
@@ -1216,17 +1192,14 @@ _get_send (GtkCupsRequest *request)
}
httpClearFields (request->http);
-#ifdef HAVE_HTTPGETAUTHSTRING
httpSetField (request->http, HTTP_FIELD_AUTHORIZATION, httpGetAuthString (request->http));
-#else
-#ifdef HAVE_HTTP_AUTHSTRING
- httpSetField (request->http, HTTP_FIELD_AUTHORIZATION, request->http->authstring);
-#endif
-#endif
if (httpGet (request->http, request->resource))
{
- if (httpReconnect (request->http))
+ int reconnect;
+
+ reconnect = httpReconnect2 (request->http, 30000, NULL);
+ if (reconnect)
{
request->state = GTK_CUPS_GET_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
@@ -1335,7 +1308,7 @@ _get_check (GtkCupsRequest *request)
}
if (auth_result ||
- httpReconnect (request->http))
+ httpReconnect2 (request->http, 30000, NULL))
{
/* if the password has been used, reset password_state
* so that we ask for a new one next time around
@@ -1367,7 +1340,7 @@ _get_check (GtkCupsRequest *request)
request->state = GTK_CUPS_GET_CONNECT;
/* Reconnect... */
- httpReconnect (request->http);
+ httpReconnect2 (request->http, 30000, NULL);
/* Upgrade with encryption... */
httpEncryption (request->http, HTTP_ENCRYPT_REQUIRED);
@@ -1457,11 +1430,12 @@ _get_read_data (GtkCupsRequest *request)
{
request->state = GTK_CUPS_GET_DONE;
request->poll_state = GTK_CUPS_HTTP_IDLE;
-
+
gtk_cups_result_set_error (request->result,
GTK_CUPS_ERROR_IO,
io_status,
- error->code,
+ error->code,
+ "%s",
error->message);
g_error_free (error);
}
@@ -1526,7 +1500,7 @@ gtk_cups_connection_test_new (const char *server,
const int port)
{
GtkCupsConnectionTest *result = NULL;
- gchar *port_str = NULL;
+ char *port_str = NULL;
result = g_new (GtkCupsConnectionTest, 1);
@@ -1563,9 +1537,9 @@ gtk_cups_connection_test_get_state (GtkCupsConnectionTest *test)
{
GtkCupsConnectionState result = GTK_CUPS_CONNECTION_NOT_AVAILABLE;
http_addrlist_t *iter;
- gint error_code;
- gint flags;
- gint code;
+ int error_code;
+ int flags;
+ int code;
if (test == NULL)
return GTK_CUPS_CONNECTION_NOT_AVAILABLE;
diff --git a/modules/printbackends/gtkcupsutils.h b/modules/printbackends/gtkcupsutils.h
index 500bb4fecf..d14f9398d4 100644
--- a/modules/printbackends/gtkcupsutils.h
+++ b/modules/printbackends/gtkcupsutils.h
@@ -48,7 +48,7 @@ typedef enum
/**
* Direction we should be polling the http socket on.
- * We are either reading or writting at each state.
+ * We are either reading or writing at each state.
* This makes it easy for mainloops to connect to poll.
*/
typedef enum
@@ -82,25 +82,25 @@ struct _GtkCupsRequest
http_status_t last_status;
ipp_t *ipp_request;
- gchar *server;
- gchar *resource;
+ char *server;
+ char *resource;
GIOChannel *data_io;
- gint attempts;
+ int attempts;
GtkCupsResult *result;
- gint state;
+ int state;
GtkCupsPollState poll_state;
guint64 bytes_received;
- gchar *password;
- gchar *username;
+ char *password;
+ char *username;
- gint own_http : 1;
- gint need_password : 1;
- gint need_auth_info : 1;
- gchar **auth_info_required;
- gchar **auth_info;
+ int own_http : 1;
+ int need_password : 1;
+ int need_auth_info : 1;
+ char **auth_info_required;
+ char **auth_info;
GtkCupsPasswordState password_state;
};
@@ -110,7 +110,7 @@ struct _GtkCupsConnectionTest
http_addrlist_t *addrlist;
http_addrlist_t *current_addr;
http_addrlist_t *last_wrong_addr;
- gint socket;
+ int socket;
};
#define GTK_CUPS_REQUEST_START 0
@@ -142,14 +142,14 @@ enum
GtkCupsRequest * gtk_cups_request_new_with_username (http_t *connection,
GtkCupsRequestType req_type,
- gint operation_id,
+ int operation_id,
GIOChannel *data_io,
const char *server,
const char *resource,
const char *username);
GtkCupsRequest * gtk_cups_request_new (http_t *connection,
GtkCupsRequestType req_type,
- gint operation_id,
+ int operation_id,
GIOChannel *data_io,
const char *server,
const char *resource);
@@ -176,11 +176,11 @@ void gtk_cups_request_free (GtkCupsRequest *
GtkCupsResult * gtk_cups_request_get_result (GtkCupsRequest *request);
gboolean gtk_cups_request_is_done (GtkCupsRequest *request);
void gtk_cups_request_encode_option (GtkCupsRequest *request,
- const gchar *option,
- const gchar *value);
+ const char *option,
+ const char *value);
void gtk_cups_request_set_ipp_version (GtkCupsRequest *request,
- gint major,
- gint minor);
+ int major,
+ int minor);
gboolean gtk_cups_result_is_error (GtkCupsResult *result);
ipp_t * gtk_cups_result_get_response (GtkCupsResult *result);
GtkCupsErrorType gtk_cups_result_get_error_type (GtkCupsResult *result);
diff --git a/modules/printbackends/gtkprintbackendcloudprint.c b/modules/printbackends/gtkprintbackendcloudprint.c
index b5560343a2..f347fc4339 100644
--- a/modules/printbackends/gtkprintbackendcloudprint.c
+++ b/modules/printbackends/gtkprintbackendcloudprint.c
@@ -32,9 +32,9 @@
#include <glib/gi18n-lib.h>
-#include <gtk/gtkprintbackend.h>
+#include <gtk/gtkprintbackendprivate.h>
#include <gtk/gtkunixprint.h>
-#include <gtk/gtkprinter-private.h>
+#include <gtk/gtkprinterprivate.h>
#include "gtkprintbackendcloudprint.h"
#include "gtkcloudprintaccount.h"
@@ -65,14 +65,12 @@ struct _GtkPrintBackendCloudprint
struct
{
- gchar *id;
- gchar *path;
- gchar *presentation_identity;
+ char *id;
+ char *path;
+ char *presentation_identity;
} typedef TGOAAccount;
static GObjectClass *backend_parent_class;
-static void gtk_print_backend_cloudprint_class_init (GtkPrintBackendCloudprintClass *class);
-static void gtk_print_backend_cloudprint_init (GtkPrintBackendCloudprint *impl);
static void gtk_print_backend_cloudprint_finalize (GObject *object);
static void cloudprint_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
@@ -94,8 +92,8 @@ static void gtk_print_backend_cloudprint_print_stream (GtkPri
GDestroyNotify dnotify);
static cairo_surface_t * cloudprint_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io);
static void cloudprint_printer_request_details (GtkPrinter *printer);
TGOAAccount * t_goa_account_copy (TGOAAccount *account);
@@ -213,7 +211,7 @@ _cairo_write (void *closure,
while (length > 0)
{
- g_io_channel_write_chars (io, (const gchar *) data, length, &written, &error);
+ g_io_channel_write_chars (io, (const char *) data, length, &written, &error);
if (error != NULL)
{
@@ -235,8 +233,8 @@ _cairo_write (void *closure,
static cairo_surface_t *
cloudprint_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io)
{
cairo_surface_t *surface;
@@ -257,11 +255,11 @@ typedef struct {
GIOChannel *target_io;
gpointer user_data;
GDestroyNotify dnotify;
- gchar *path;
+ char *path;
/* Base64 encoding state */
- gint b64state;
- gint b64save;
+ int b64state;
+ int b64save;
} _PrintStreamData;
static void
@@ -315,7 +313,7 @@ cloudprint_print_cb (GtkPrintBackendCloudprint *print_backend,
{
_PrintStreamData *ps = (_PrintStreamData *) user_data;
gsize encodedlen;
- gchar encoded[4]; /* Up to 4 bytes are needed to finish encoding */
+ char encoded[4]; /* Up to 4 bytes are needed to finish encoding */
GError *error = NULL;
encodedlen = g_base64_encode_close (FALSE,
@@ -391,11 +389,11 @@ cloudprint_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
{
- gchar buf[_STREAM_MAX_CHUNK_SIZE];
+ char buf[_STREAM_MAX_CHUNK_SIZE];
/* Base64 converts 24 bits into 32 bits, so divide the number of
* bytes by 3 (rounding up) and multiply by 4. Also, if the previous
* call left a non-zero state we may need an extra 4 bytes. */
- gchar encoded[(_STREAM_MAX_CHUNK_SIZE / 3 + 1) * 4 + 4];
+ char encoded[(_STREAM_MAX_CHUNK_SIZE / 3 + 1) * 4 + 4];
gsize bytes_read;
GError *error = NULL;
GIOStatus read_status;
@@ -454,7 +452,7 @@ gtk_print_backend_cloudprint_print_stream (GtkPrintBackend *print_backend
gpointer user_data,
GDestroyNotify dnotify)
{
- const gchar *prefix = "data:application/pdf;base64,";
+ const char *prefix = "data:application/pdf;base64,";
GError *internal_error = NULL;
_PrintStreamData *ps;
int tmpfd;
@@ -551,7 +549,7 @@ get_accounts (GVariant *output)
{
GVariant *objects;
GList *result = NULL;
- gint i, j, k;
+ int i, j, k;
g_variant_get (output, "(@a{oa{sa{sv}}})",
&objects);
@@ -560,7 +558,7 @@ get_accounts (GVariant *output)
{
for (i = 0; i < g_variant_n_children (objects); i++)
{
- const gchar *object_name;
+ const char *object_name;
GVariant *object_variant;
g_variant_get_child (objects, i, "{&o@a{sa{sv}}}",
@@ -571,7 +569,7 @@ get_accounts (GVariant *output)
{
for (j = 0; j < g_variant_n_children (object_variant); j++)
{
- const gchar *service_name;
+ const char *service_name;
GVariant *service_variant;
g_variant_get_child (object_variant, j, "{&s@a{sv}}",
@@ -582,14 +580,14 @@ get_accounts (GVariant *output)
{
TGOAAccount *account;
gboolean printers_disabled = FALSE;
- gchar *provider_type = NULL;
+ char *provider_type = NULL;
account = g_new0 (TGOAAccount, 1);
account->path = g_strdup (object_name);
for (k = 0; k < g_variant_n_children (service_variant); k++)
{
- const gchar *property_name;
+ const char *property_name;
GVariant *property_variant;
GVariant *value;
@@ -914,7 +912,7 @@ cloudprint_printer_get_options (GtkPrinter *printer,
{
GtkPrinterOptionSet *set;
GtkPrinterOption *option;
- const gchar *n_up[] = { "1" };
+ const char *n_up[] = { "1" };
set = gtk_printer_option_set_new ();
@@ -942,7 +940,7 @@ cloudprint_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
{
- gdouble scale;
+ double scale;
gtk_print_job_set_pages (print_job, gtk_print_settings_get_print_pages (settings));
gtk_print_job_set_page_ranges (print_job, NULL, 0);
@@ -950,7 +948,7 @@ cloudprint_printer_prepare_for_print (GtkPrinter *printer,
if (gtk_print_job_get_pages (print_job) == GTK_PRINT_PAGES_RANGES)
{
GtkPageRange *page_ranges;
- gint num_page_ranges;
+ int num_page_ranges;
page_ranges = gtk_print_settings_get_page_ranges (settings, &num_page_ranges);
gtk_print_job_set_page_ranges (print_job, page_ranges, num_page_ranges);
}
@@ -1010,7 +1008,7 @@ cloudprint_printer_request_details (GtkPrinter *printer)
{
GtkPrintBackendCloudprint *backend;
GtkCloudprintAccount *account = NULL;
- gchar *printerid = NULL;
+ char *printerid = NULL;
g_object_get (printer,
"cloudprint-account", &account,
diff --git a/modules/printbackends/gtkprintbackendcloudprint.h b/modules/printbackends/gtkprintbackendcloudprint.h
index 044ad4b32b..ca7f5e0005 100644
--- a/modules/printbackends/gtkprintbackendcloudprint.h
+++ b/modules/printbackends/gtkprintbackendcloudprint.h
@@ -20,7 +20,7 @@
#define __GTK_PRINT_BACKEND_CLOUDPRINT_H__
#include <glib-object.h>
-#include "gtkprintbackend.h"
+#include "gtkprintbackendprivate.h"
G_BEGIN_DECLS
diff --git a/modules/printbackends/gtkprintbackendcups.c b/modules/printbackends/gtkprintbackendcups.c
index f530c0506e..b88d76011c 100644
--- a/modules/printbackends/gtkprintbackendcups.c
+++ b/modules/printbackends/gtkprintbackendcups.c
@@ -24,13 +24,12 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
+
/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(),
- * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This
- * turns off the warning so that it will compile.
+ * ppdFirstCustomParam(), and ppdNextCustomParam() among others.
+ * The replacement is to use the Job Ticket API, but that requires
+ * a larger refactoring of this backend.
*/
-#ifdef HAVE_CUPS_API_1_6
-# define _PPD_DEPRECATED
-#endif
#include <cups/cups.h>
#include <cups/language.h>
@@ -46,9 +45,9 @@
#include <gmodule.h>
#include <gtk/gtk.h>
-#include <gtk/gtkprintbackend.h>
+#include <gtk/gtkprintbackendprivate.h>
#include <gtk/gtkunixprint.h>
-#include <gtk/gtkprinter-private.h>
+#include <gtk/gtkprinterprivate.h>
#include "gtkprintbackendcups.h"
#include "gtkprintercups.h"
@@ -71,7 +70,6 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
#define _CUPS_MAX_ATTEMPTS 10
#define _CUPS_MAX_CHUNK_SIZE 8192
-#ifdef HAVE_CUPS_API_1_6
#define AVAHI_IF_UNSPEC -1
#define AVAHI_PROTO_INET 0
#define AVAHI_PROTO_INET6 1
@@ -81,8 +79,8 @@ typedef struct _GtkPrintBackendCupsClass GtkPrintBackendCupsClass;
#define AVAHI_SERVER_IFACE "org.freedesktop.Avahi.Server"
#define AVAHI_SERVICE_BROWSER_IFACE "org.freedesktop.Avahi.ServiceBrowser"
#define AVAHI_SERVICE_RESOLVER_IFACE "org.freedesktop.Avahi.ServiceResolver"
-#endif
+#define PRINTER_NAME_ALLOWED_CHARACTERS "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
/* define this to see warnings about ignored ppd options */
#undef PRINT_IGNORED_OPTIONS
@@ -130,27 +128,27 @@ struct _GtkPrintBackendCups
guint list_printers_poll;
guint list_printers_pending : 1;
- gint list_printers_attempts;
+ int list_printers_attempts;
guint got_default_printer : 1;
guint default_printer_poll;
GtkCupsConnectionTest *cups_connection_test;
- gint reading_ppds;
+ int reading_ppds;
GList *requests;
GHashTable *auth;
- gchar *username;
+ char *username;
gboolean authentication_lock;
#ifdef HAVE_COLORD
CdClient *colord_client;
#endif
-#ifdef HAVE_CUPS_API_1_6
+
GDBusConnection *dbus_connection;
- gchar *avahi_default_printer;
- guint avahi_service_browser_subscription_id;
- guint avahi_service_browser_subscription_ids[2];
- gchar *avahi_service_browser_paths[2];
- GCancellable *avahi_cancellable;
-#endif
+ char *avahi_default_printer;
+ guint avahi_service_browser_subscription_id;
+ guint avahi_service_browser_subscription_ids[2];
+ char *avahi_service_browser_paths[2];
+ GCancellable *avahi_cancellable;
+
gboolean secrets_service_available;
guint secrets_service_watch_id;
GCancellable *secrets_service_cancellable;
@@ -158,8 +156,6 @@ struct _GtkPrintBackendCups
static GObjectClass *backend_parent_class;
-static void gtk_print_backend_cups_class_init (GtkPrintBackendCupsClass *class);
-static void gtk_print_backend_cups_init (GtkPrintBackendCups *impl);
static void gtk_print_backend_cups_finalize (GObject *object);
static void gtk_print_backend_cups_dispose (GObject *object);
static void cups_get_printer_list (GtkPrintBackend *print_backend);
@@ -189,16 +185,16 @@ static void cups_printer_request_details (GtkPrinter
static gboolean cups_request_default_printer (GtkPrintBackendCups *print_backend);
static gboolean cups_request_ppd (GtkPrinter *printer);
static gboolean cups_printer_get_hard_margins (GtkPrinter *printer,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right);
+ double *top,
+ double *bottom,
+ double *left,
+ double *right);
static gboolean cups_printer_get_hard_margins_for_paper_size (GtkPrinter *printer,
GtkPaperSize *paper_size,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right);
+ double *top,
+ double *bottom,
+ double *left,
+ double *right);
static GtkPrintCapabilities cups_printer_get_capabilities (GtkPrinter *printer);
static void set_option_from_settings (GtkPrinterOption *option,
GtkPrintSettings *setting);
@@ -214,30 +210,28 @@ static void gtk_print_backend_cups_print_stream (GtkPrintBack
GDestroyNotify dnotify);
static cairo_surface_t * cups_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io);
static void gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
- gchar **auth_info_required,
- gchar **auth_info,
+ char **auth_info_required,
+ char **auth_info,
gboolean store_auth_info);
void overwrite_and_free (gpointer data);
-static gboolean is_address_local (const gchar *address);
+static gboolean is_address_local (const char *address);
static gboolean request_auth_info (gpointer data);
static void lookup_auth_info (gpointer data);
-#ifdef HAVE_CUPS_API_1_6
static void avahi_request_printer_list (GtkPrintBackendCups *cups_backend);
-#endif
static void secrets_service_appeared_cb (GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
+ const char *name,
+ const char *name_owner,
gpointer user_data);
static void secrets_service_vanished_cb (GDBusConnection *connection,
- const gchar *name,
+ const char *name,
gpointer user_data);
G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendCups, gtk_print_backend_cups, GTK_TYPE_PRINT_BACKEND)
@@ -265,58 +259,13 @@ char **
g_io_module_query (void)
{
char *eps[] = {
- GTK_PRINT_BACKEND_EXTENSION_POINT_NAME,
+ (char *)GTK_PRINT_BACKEND_EXTENSION_POINT_NAME,
NULL
};
return g_strdupv (eps);
}
-/* CUPS 1.6 Getter/Setter Functions CUPS 1.6 makes private most of the
- * IPP structures and enforces access via new getter functions, which
- * are unfortunately not available in earlier versions. We define
- * below those getter functions as macros for use when building
- * against earlier CUPS versions.
- */
-#ifndef HAVE_CUPS_API_1_6
-#define ippGetOperation(ipp_request) ipp_request->request.op.operation_id
-#define ippGet:Integer(attr, index) attr->values[index].integer
-#define ippGetBoolean(attr, index) attr->values[index].boolean
-#define ippGetString(attr, index, foo) attr->values[index].string.text
-#define ippGetValueTag(attr) attr->value_tag
-#define ippGetName(attr) attr->name
-#define ippGetCount(attr) attr->num_values
-#define ippGetGroupTag(attr) attr->group_tag
-#define ippGetCollection(attr, index) attr->values[index].collection
-
-static int
-ippGetRange (ipp_attribute_t *attr,
- int element,
- int *upper)
-{
- *upper = attr->values[element].range.upper;
- return (attr->values[element].range.lower);
-}
-
-static ipp_attribute_t *
-ippFirstAttribute (ipp_t *ipp)
-{
- if (!ipp)
- return (NULL);
-
- return (ipp->current = ipp->attrs);
-}
-
-static ipp_attribute_t *
-ippNextAttribute (ipp_t *ipp)
-{
- if (!ipp || !ipp->current)
- return (NULL);
-
- return (ipp->current = ipp->current->next);
-}
-#endif
-
/*
* GtkPrintBackendCups
*/
@@ -407,7 +356,7 @@ _cairo_write_to_cups (void *closure,
while (length > 0)
{
- g_io_channel_write_chars (io, (gchar *)data, length, &written, &error);
+ g_io_channel_write_chars (io, (char *)data, length, &written, &error);
if (error != NULL)
{
@@ -432,8 +381,8 @@ _cairo_write_to_cups (void *closure,
static cairo_surface_t *
cups_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io)
{
cairo_surface_t *surface;
@@ -442,8 +391,10 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
ppd_attr_t *ppd_attr_res = NULL;
ppd_attr_t *ppd_attr_screen_freq = NULL;
ppd_attr_t *ppd_attr_res_screen_freq = NULL;
- gchar *res_string = NULL;
- gint level = 2;
+ char *res_string = NULL;
+ int level = 2;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (gtk_printer_accepts_pdf (printer))
surface = cairo_pdf_surface_create_for_stream (_cairo_write_to_cups, cache_io, width, height);
@@ -515,6 +466,8 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
2.0 * gtk_print_settings_get_printer_lpi (settings),
2.0 * gtk_print_settings_get_printer_lpi (settings));
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
return surface;
}
@@ -586,20 +539,25 @@ cups_print_cb (GtkPrintBackendCups *print_backend,
typedef struct {
GtkCupsRequest *request;
+ GtkPageSetup *page_setup;
GtkPrinterCups *printer;
} CupsOptionsData;
+#define UNSIGNED_FLOAT_REGEX "([0-9]+([.,][0-9]*)?|[.,][0-9]+)([e][+-]?[0-9]+)?"
+#define SIGNED_FLOAT_REGEX "[+-]?"UNSIGNED_FLOAT_REGEX
+#define SIGNED_INTEGER_REGEX "[+-]?([0-9]+)"
+
static void
-add_cups_options (const gchar *key,
- const gchar *value,
+add_cups_options (const char *key,
+ const char *value,
gpointer user_data)
{
CupsOptionsData *data = (CupsOptionsData *) user_data;
GtkCupsRequest *request = data->request;
GtkPrinterCups *printer = data->printer;
gboolean custom_value = FALSE;
- gchar *new_value = NULL;
- gint i;
+ char *new_value = NULL;
+ int i;
if (!key || !value)
return;
@@ -612,7 +570,9 @@ add_cups_options (const gchar *key,
key = key + strlen ("cups-");
- if (printer && printer->ppd_file)
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+ if (printer && printer->ppd_file && !g_str_has_prefix (value, "Custom."))
{
ppd_coption_t *coption;
gboolean found = FALSE;
@@ -633,14 +593,77 @@ add_cups_options (const gchar *key,
}
if (custom_values_enabled && !found)
- custom_value = TRUE;
+ {
+ /* Check syntax of the invalid choice to see whether
+ it could be a custom value */
+ if (g_str_equal (key, "PageSize") ||
+ g_str_equal (key, "PageRegion"))
+ {
+ /* Handle custom page sizes... */
+ if (g_regex_match_simple ("^" UNSIGNED_FLOAT_REGEX "x" UNSIGNED_FLOAT_REGEX "(cm|mm|m|in|ft|pt)?$", value, G_REGEX_CASELESS, 0))
+ custom_value = TRUE;
+ else
+ {
+ if (data->page_setup != NULL)
+ {
+ custom_value = TRUE;
+ new_value =
+ g_strdup_printf ("Custom.%.2fx%.2fmm",
+ gtk_paper_size_get_width (gtk_page_setup_get_paper_size (data->page_setup), GTK_UNIT_MM),
+ gtk_paper_size_get_height (gtk_page_setup_get_paper_size (data->page_setup), GTK_UNIT_MM));
+ }
+ }
+ }
+ else
+ {
+ /* Handle other custom options... */
+ ppd_cparam_t *cparam;
+
+ cparam = (ppd_cparam_t *) cupsArrayFirst (coption->params);
+ if (cparam != NULL)
+ {
+ switch (cparam->type)
+ {
+ case PPD_CUSTOM_CURVE :
+ case PPD_CUSTOM_INVCURVE :
+ case PPD_CUSTOM_REAL :
+ if (g_regex_match_simple ("^" SIGNED_FLOAT_REGEX "$", value, G_REGEX_CASELESS, 0))
+ custom_value = TRUE;
+ break;
+
+ case PPD_CUSTOM_POINTS :
+ if (g_regex_match_simple ("^" SIGNED_FLOAT_REGEX "(cm|mm|m|in|ft|pt)?$", value, G_REGEX_CASELESS, 0))
+ custom_value = TRUE;
+ break;
+
+ case PPD_CUSTOM_INT :
+ if (g_regex_match_simple ("^" SIGNED_INTEGER_REGEX "$", value, G_REGEX_CASELESS, 0))
+ custom_value = TRUE;
+ break;
+
+ case PPD_CUSTOM_PASSCODE :
+ case PPD_CUSTOM_PASSWORD :
+ case PPD_CUSTOM_STRING :
+ custom_value = TRUE;
+ break;
+
+ case PPD_CUSTOM_UNKNOWN:
+ default :
+ custom_value = FALSE;
+ }
+ }
+ }
+ }
}
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
/* Add "Custom." prefix to custom values if not already added. */
- if (custom_value && !g_str_has_prefix (value, "Custom."))
+ if (custom_value)
{
- new_value = g_strdup_printf ("Custom.%s", value);
+ if (new_value == NULL)
+ new_value = g_strdup_printf ("Custom.%s", value);
gtk_cups_request_encode_option (request, key, new_value);
g_free (new_value);
}
@@ -659,9 +682,10 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
GtkPrinterCups *cups_printer;
CupsPrintStreamData *ps;
CupsOptionsData *options_data;
+ GtkPageSetup *page_setup;
GtkCupsRequest *request = NULL;
GtkPrintSettings *settings;
- const gchar *title;
+ const char *title;
char printer_absolute_uri[HTTP_MAX_URI];
http_t *http = NULL;
@@ -671,10 +695,13 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job));
settings = gtk_print_job_get_settings (job);
-#ifdef HAVE_CUPS_API_1_6
if (cups_printer->avahi_browsed)
{
- http = httpConnect (cups_printer->hostname, cups_printer->port);
+ http = httpConnect2 (cups_printer->hostname, cups_printer->port,
+ NULL, AF_UNSPEC,
+ HTTP_ENCRYPTION_IF_REQUESTED,
+ 1, 30000,
+ NULL);
if (http)
{
request = gtk_cups_request_new_with_username (http,
@@ -713,7 +740,6 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
}
}
else
-#endif
{
request = gtk_cups_request_new_with_username (NULL,
GTK_CUPS_POST,
@@ -749,7 +775,7 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
if (title_bytes >= IPP_MAX_NAME)
{
- gchar *end;
+ char *end;
end = g_utf8_find_prev_char (title, title + IPP_MAX_NAME - 1);
title_truncated = g_utf8_substring (title,
@@ -764,10 +790,16 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
g_free (title_truncated);
}
+ g_object_get (job,
+ "page-setup", &page_setup,
+ NULL);
+
options_data = g_new0 (CupsOptionsData, 1);
options_data->request = request;
options_data->printer = cups_printer;
+ options_data->page_setup = page_setup;
gtk_print_settings_foreach (settings, add_cups_options, options_data);
+ g_clear_object (&page_setup);
g_free (options_data);
ps = g_new0 (CupsPrintStreamData, 1);
@@ -805,7 +837,7 @@ gtk_print_backend_cups_print_stream (GtkPrintBackend *print_backend,
void overwrite_and_free (gpointer data)
{
- gchar *password = (gchar *) data;
+ char *password = (char *) data;
if (password != NULL)
{
@@ -817,9 +849,7 @@ void overwrite_and_free (gpointer data)
static void
gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
{
-#ifdef HAVE_CUPS_API_1_6
- gint i;
-#endif
+ int i;
backend_cups->list_printers_poll = FALSE;
backend_cups->got_default_printer = FALSE;
@@ -840,7 +870,6 @@ gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
backend_cups->colord_client = cd_client_new ();
#endif
-#ifdef HAVE_CUPS_API_1_6
backend_cups->dbus_connection = NULL;
backend_cups->avahi_default_printer = NULL;
backend_cups->avahi_service_browser_subscription_id = 0;
@@ -849,7 +878,6 @@ gtk_print_backend_cups_init (GtkPrintBackendCups *backend_cups)
backend_cups->avahi_service_browser_paths[i] = NULL;
backend_cups->avahi_service_browser_subscription_ids[i] = 0;
}
-#endif
cups_get_local_default_printer (backend_cups);
@@ -885,11 +913,9 @@ gtk_print_backend_cups_finalize (GObject *object)
g_object_unref (backend_cups->colord_client);
#endif
-#ifdef HAVE_CUPS_API_1_6
g_clear_object (&backend_cups->avahi_cancellable);
g_clear_pointer (&backend_cups->avahi_default_printer, g_free);
g_clear_object (&backend_cups->dbus_connection);
-#endif
g_clear_object (&backend_cups->secrets_service_cancellable);
if (backend_cups->secrets_service_watch_id != 0)
@@ -904,9 +930,7 @@ static void
gtk_print_backend_cups_dispose (GObject *object)
{
GtkPrintBackendCups *backend_cups;
-#ifdef HAVE_CUPS_API_1_6
- gint i;
-#endif
+ int i;
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s\n", G_STRFUNC));
@@ -922,7 +946,6 @@ gtk_print_backend_cups_dispose (GObject *object)
g_source_remove (backend_cups->default_printer_poll);
backend_cups->default_printer_poll = 0;
-#ifdef HAVE_CUPS_API_1_6
g_cancellable_cancel (backend_cups->avahi_cancellable);
for (i = 0; i < 2; i++)
@@ -958,13 +981,12 @@ gtk_print_backend_cups_dispose (GObject *object)
backend_cups->avahi_service_browser_subscription_id);
backend_cups->avahi_service_browser_subscription_id = 0;
}
-#endif
backend_parent_class->dispose (object);
}
static gboolean
-is_address_local (const gchar *address)
+is_address_local (const char *address)
{
if (address[0] == '/' ||
strcmp (address, "127.0.0.1") == 0 ||
@@ -976,18 +998,18 @@ is_address_local (const gchar *address)
static void
gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
- gchar **auth_info_required,
- gchar **auth_info,
+ char **auth_info_required,
+ char **auth_info,
gboolean store_auth_info)
{
GtkPrintBackendCups *cups_backend = GTK_PRINT_BACKEND_CUPS (backend);
GList *l;
char dispatch_hostname[HTTP_MAX_URI];
- gchar *username = NULL;
- gchar *hostname = NULL;
- gchar *password = NULL;
- gint length;
- gint i;
+ char *username = NULL;
+ char *hostname = NULL;
+ char *password = NULL;
+ int length;
+ int i;
length = g_strv_length (auth_info_required);
@@ -1004,7 +1026,7 @@ gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
if (hostname != NULL && username != NULL && password != NULL)
{
- gchar *key = g_strconcat (username, "@", hostname, NULL);
+ char *key = g_strconcat (username, "@", hostname, NULL);
g_hash_table_insert (cups_backend->auth, key, g_strdup (password));
GTK_NOTE (PRINTING,
g_print ("CUPS backend: caching password for %s\n", key));
@@ -1026,14 +1048,14 @@ gtk_print_backend_cups_set_password (GtkPrintBackend *backend,
{
if (auth_info != NULL)
{
- dispatch->request->auth_info = g_new0 (gchar *, length + 1);
+ dispatch->request->auth_info = g_new0 (char *, length + 1);
for (i = 0; i < length; i++)
dispatch->request->auth_info[i] = g_strdup (auth_info[i]);
}
/* Save the password if the user requested it */
if (password != NULL && store_auth_info)
{
- const gchar *printer_uri =
+ const char *printer_uri =
gtk_cups_request_ipp_get_string (dispatch->request,
IPP_TAG_URI,
"printer-uri");
@@ -1060,17 +1082,17 @@ static gboolean
request_password (gpointer data)
{
GtkPrintCupsDispatchWatch *dispatch = data;
- const gchar *username;
- gchar *password;
- gchar *prompt = NULL;
- gchar *key = NULL;
+ const char *username;
+ char *password;
+ char *prompt = NULL;
+ char *key = NULL;
char hostname[HTTP_MAX_URI];
- gchar **auth_info_required;
- gchar **auth_info_default;
- gchar **auth_info_display;
+ char **auth_info_required;
+ char **auth_info_default;
+ char **auth_info_display;
gboolean *auth_info_visible;
- gint length = 3;
- gint i;
+ int length = 3;
+ int i;
if (dispatch->backend->authentication_lock)
return G_SOURCE_REMOVE;
@@ -1084,16 +1106,16 @@ request_password (gpointer data)
else
username = cupsUser ();
- auth_info_required = g_new0 (gchar*, length + 1);
+ auth_info_required = g_new0 (char *, length + 1);
auth_info_required[0] = g_strdup ("hostname");
auth_info_required[1] = g_strdup ("username");
auth_info_required[2] = g_strdup ("password");
- auth_info_default = g_new0 (gchar*, length + 1);
+ auth_info_default = g_new0 (char *, length + 1);
auth_info_default[0] = g_strdup (hostname);
auth_info_default[1] = g_strdup (username);
- auth_info_display = g_new0 (gchar*, length + 1);
+ auth_info_display = g_new0 (char *, length + 1);
auth_info_display[1] = g_strdup (_("Username:"));
auth_info_display[2] = g_strdup (_("Password:"));
@@ -1130,7 +1152,7 @@ request_password (gpointer data)
dispatch->backend->authentication_lock = TRUE;
- switch (ippGetOperation (dispatch->request->ipp_request))
+ switch ((guint)ippGetOperation (dispatch->request->ipp_request))
{
case IPP_PRINT_JOB:
if (job_title != NULL && printer_name != NULL)
@@ -1246,8 +1268,8 @@ check_auth_info (gpointer user_data)
}
else
{
- gint length;
- gint i;
+ int length;
+ int i;
length = g_strv_length (dispatch->request->auth_info_required);
@@ -1281,9 +1303,9 @@ lookup_auth_info_cb (GObject *source_object,
{
GTask *task;
GtkPrintCupsDispatchWatch *dispatch;
- gchar **auth_info;
+ char **auth_info;
GError *error = NULL;
- gint i;
+ int i;
task = (GTask *) res;
dispatch = user_data;
@@ -1328,7 +1350,7 @@ lookup_auth_info (gpointer user_data)
gsize length,
i;
gboolean need_secret_auth_info = FALSE;
- const gchar *printer_uri;
+ const char *printer_uri;
dispatch = user_data;
@@ -1372,13 +1394,13 @@ request_auth_info (gpointer user_data)
GtkPrintCupsDispatchWatch *dispatch;
const char *job_title;
const char *printer_uri;
- gchar *prompt = NULL;
+ char *prompt = NULL;
char *printer_name = NULL;
- gint length;
- gint i;
+ int length;
+ int i;
gboolean *auth_info_visible = NULL;
- gchar **auth_info_default = NULL;
- gchar **auth_info_display = NULL;
+ char **auth_info_default = NULL;
+ char **auth_info_display = NULL;
dispatch = (GtkPrintCupsDispatchWatch *) user_data;
@@ -1390,8 +1412,8 @@ request_auth_info (gpointer user_data)
length = g_strv_length (dispatch->request->auth_info_required);
auth_info_visible = g_new0 (gboolean, length);
- auth_info_default = g_new0 (gchar *, length + 1);
- auth_info_display = g_new0 (gchar *, length + 1);
+ auth_info_default = g_new0 (char *, length + 1);
+ auth_info_display = g_new0 (char *, length + 1);
for (i = 0; i < length; i++)
{
@@ -1497,7 +1519,7 @@ cups_dispatch_watch_check (GSource *source)
static gboolean
cups_dispatch_watch_prepare (GSource *source,
- gint *timeout_)
+ int *timeout_)
{
GtkPrintCupsDispatchWatch *dispatch;
gboolean result;
@@ -1565,9 +1587,9 @@ cups_dispatch_watch_finalize (GSource *source)
result = gtk_cups_request_get_result (dispatch->request);
if (gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_AUTH)
{
- const gchar *username;
- gchar hostname[HTTP_MAX_URI];
- gchar *key;
+ const char *username;
+ char hostname[HTTP_MAX_URI];
+ char *key;
httpGetHostname (dispatch->request->http, hostname, sizeof (hostname));
if (is_address_local (hostname))
@@ -1636,7 +1658,7 @@ cups_request_execute (GtkPrintBackendCups *print_backend,
dispatch = (GtkPrintCupsDispatchWatch *) g_source_new (&_cups_dispatch_watch_funcs,
sizeof (GtkPrintCupsDispatchWatch));
- g_source_set_name (&dispatch->source, "GTK+ CUPS backend");
+ g_source_set_name (&dispatch->source, "GTK CUPS backend");
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s <source %p> - Executing cups request on server '%s' and resource '%s'\n", G_STRFUNC, dispatch, request->server, request->resource));
@@ -1691,8 +1713,8 @@ cups_job_poll_data_free (CupsJobPollData *data)
static void
cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
- GtkCupsResult *result,
- gpointer user_data)
+ GtkCupsResult *result,
+ gpointer user_data)
{
CupsJobPollData *data = user_data;
ipp_attribute_t *attr;
@@ -1710,20 +1732,8 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
response = gtk_cups_result_get_response (result);
- state = 0;
-
-#ifdef HAVE_CUPS_API_1_6
attr = ippFindAttribute (response, "job-state", IPP_TAG_ENUM);
state = ippGetInteger (attr, 0);
-#else
- for (attr = response->attrs; attr != NULL; attr = attr->next)
- {
- if (!attr->name)
- continue;
-
- _CUPS_MAP_ATTR_INT (attr, state, "job-state");
- }
-#endif
done = FALSE;
switch (state)
@@ -1731,24 +1741,20 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
case IPP_JOB_PENDING:
case IPP_JOB_HELD:
case IPP_JOB_STOPPED:
- gtk_print_job_set_status (data->job,
- GTK_PRINT_STATUS_PENDING);
+ gtk_print_job_set_status (data->job, GTK_PRINT_STATUS_PENDING);
break;
case IPP_JOB_PROCESSING:
- gtk_print_job_set_status (data->job,
- GTK_PRINT_STATUS_PRINTING);
+ gtk_print_job_set_status (data->job, GTK_PRINT_STATUS_PRINTING);
break;
default:
case IPP_JOB_CANCELLED:
case IPP_JOB_ABORTED:
- gtk_print_job_set_status (data->job,
- GTK_PRINT_STATUS_FINISHED_ABORTED);
+ gtk_print_job_set_status (data->job, GTK_PRINT_STATUS_FINISHED_ABORTED);
done = TRUE;
break;
case 0:
case IPP_JOB_COMPLETED:
- gtk_print_job_set_status (data->job,
- GTK_PRINT_STATUS_FINISHED);
+ gtk_print_job_set_status (data->job, GTK_PRINT_STATUS_FINISHED);
done = TRUE;
break;
}
@@ -1759,14 +1765,14 @@ cups_request_job_info_cb (GtkPrintBackendCups *print_backend,
guint id;
if (data->counter < 5)
- timeout = 100;
+ timeout = 100;
else if (data->counter < 10)
- timeout = 500;
+ timeout = 500;
else
- timeout = 1000;
+ timeout = 1000;
id = g_timeout_add (timeout, cups_job_info_poll_timeout, data);
- g_source_set_name_by_id (id, "[gtk+] cups_job_info_poll_timeout");
+ g_source_set_name_by_id (id, "[gtk] cups_job_info_poll_timeout");
}
else
cups_job_poll_data_free (data);
@@ -1776,7 +1782,7 @@ static void
cups_request_job_info (CupsJobPollData *data)
{
GtkCupsRequest *request;
- gchar *job_uri;
+ char *job_uri;
request = gtk_cups_request_new_with_username (NULL,
GTK_CUPS_POST,
@@ -1814,7 +1820,7 @@ cups_job_info_poll_timeout (gpointer user_data)
static void
cups_begin_polling_info (GtkPrintBackendCups *print_backend,
GtkPrintJob *job,
- gint job_id)
+ int job_id)
{
CupsJobPollData *data;
@@ -1838,11 +1844,11 @@ mark_printer_inactive (GtkPrinter *printer,
g_signal_emit_by_name (backend, "printer-removed", printer);
}
-static gint
+static int
find_printer (GtkPrinter *printer,
- const gchar *find_name)
+ const char *find_name)
{
- const gchar *printer_name;
+ const char *printer_name;
printer_name = gtk_printer_get_name (printer);
return g_ascii_strcasecmp (printer_name, find_name);
@@ -1942,34 +1948,33 @@ typedef struct
typedef struct
{
- const gchar *printer_name;
- const gchar *printer_uri;
- const gchar *member_uris;
- const gchar *location;
- const gchar *description;
- gchar *state_msg;
- const gchar *reason_msg;
+ const char *printer_name;
+ const char *printer_uri;
+ const char *member_uris;
+ const char *location;
+ const char *description;
+ char *state_msg;
+ const char *reason_msg;
PrinterStateLevel reason_level;
- gint state;
- gint job_count;
+ int state;
+ int job_count;
gboolean is_paused;
gboolean is_accepting_jobs;
- const gchar *default_cover_before;
- const gchar *default_cover_after;
+ const char *default_cover_before;
+ const char *default_cover_after;
gboolean default_printer;
gboolean got_printer_type;
gboolean remote_printer;
-#ifdef HAVE_CUPS_API_1_6
gboolean avahi_printer;
-#endif
- gchar **auth_info_required;
- gint default_number_up;
+ char *avahi_resource_path;
+ char **auth_info_required;
+ int default_number_up;
guchar ipp_version_major;
guchar ipp_version_minor;
gboolean supports_copies;
gboolean supports_collate;
gboolean supports_number_up;
- gchar *media_default;
+ char *media_default;
GList *media_supported;
GList *media_size_supported;
float media_bottom_margin_default;
@@ -1977,13 +1982,13 @@ typedef struct
float media_left_margin_default;
float media_right_margin_default;
gboolean media_margin_default_set;
- gchar *sides_default;
+ char *sides_default;
GList *sides_supported;
char **covers;
int number_of_covers;
- gchar *output_bin_default;
+ char *output_bin_default;
GList *output_bin_supported;
- gchar *original_device_uri;
+ char *original_device_uri;
} PrinterSetupInfo;
static void
@@ -2000,8 +2005,8 @@ get_ipp_version (const char *ipp_version_string,
guchar *ipp_version_major,
guchar *ipp_version_minor)
{
- gchar **ipp_version_strv;
- gchar *endptr;
+ char **ipp_version_strv;
+ char *endptr;
*ipp_version_major = 1;
*ipp_version_minor = 1;
@@ -2042,7 +2047,7 @@ get_server_ipp_version (guchar *ipp_version_major,
}
}
-static gint
+static int
ipp_version_cmp (guchar ipp_version_major1,
guchar ipp_version_minor1,
guchar ipp_version_major2,
@@ -2070,7 +2075,7 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
ipp_attribute_t *attr,
PrinterSetupInfo *info)
{
- gint i, j;
+ int i, j;
if (strcmp (ippGetName (attr), "printer-name") == 0 &&
ippGetValueTag (attr) == IPP_TAG_NAME)
info->printer_name = ippGetString (attr, 0, NULL);
@@ -2180,7 +2185,7 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
{
if (strcmp (ippGetString (attr, 0, NULL), "none") != 0)
{
- info->auth_info_required = g_new0 (gchar *, ippGetCount (attr) + 1);
+ info->auth_info_required = g_new0 (char *, ippGetCount (attr) + 1);
for (i = 0; i < ippGetCount (attr); i++)
info->auth_info_required[i] = g_strdup (ippGetString (attr, i, NULL));
}
@@ -2267,14 +2272,14 @@ cups_printer_handle_attribute (GtkPrintBackendCups *cups_backend,
{
ipp_attribute_t *iter;
ipp_t *col;
- gint num_of_margins = 0;
+ int num_of_margins = 0;
for (i = 0; i < ippGetCount (attr); i++)
{
col = ippGetCollection (attr, i);
for (iter = ippFirstAttribute (col); iter != NULL; iter = ippNextAttribute (col))
{
- switch (ippGetValueTag (iter))
+ switch ((guint)ippGetValueTag (iter))
{
case IPP_TAG_INTEGER:
if (g_strcmp0 (ippGetName (iter), "media-bottom-margin") == 0)
@@ -2392,13 +2397,11 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
char *cups_server; /* CUPS server */
#ifdef HAVE_COLORD
-#ifdef HAVE_CUPS_API_1_6
if (info->avahi_printer)
cups_printer = gtk_printer_cups_new (info->printer_name,
backend,
NULL);
else
-#endif
cups_printer = gtk_printer_cups_new (info->printer_name,
backend,
cups_backend->colord_client);
@@ -2406,14 +2409,22 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
cups_printer = gtk_printer_cups_new (info->printer_name, backend, NULL);
#endif
- cups_printer->device_uri = g_strdup_printf ("/printers/%s",
- info->printer_name);
+ if (info->avahi_printer)
+ {
+ cups_printer->device_uri = g_strdup_printf ("/%s",
+ info->avahi_resource_path);
+ }
+ else
+ {
+ cups_printer->device_uri = g_strdup_printf ("/printers/%s",
+ info->printer_name);
+ }
/* Check to see if we are looking at a class */
if (info->member_uris)
{
cups_printer->printer_uri = g_strdup (info->member_uris);
- /* TODO if member_uris is a class we need to recursivly find a printer */
+ /* TODO if member_uris is a class we need to recursively find a printer */
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: Found class with printer %s\n",
info->member_uris));
@@ -2458,13 +2469,25 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
cups_printer->default_cover_before = g_strdup (info->default_cover_before);
cups_printer->default_cover_after = g_strdup (info->default_cover_after);
cups_printer->original_device_uri = g_strdup (info->original_device_uri);
+ cups_printer->hostname = g_strdup (hostname);
+ cups_printer->port = port;
+
+ if (cups_printer->original_device_uri != NULL)
+ {
+ httpSeparateURI (HTTP_URI_CODING_ALL, cups_printer->original_device_uri,
+ method, sizeof (method),
+ username, sizeof (username),
+ hostname, sizeof (hostname),
+ &port,
+ resource, sizeof (resource));
+ cups_printer->original_hostname = g_strdup (hostname);
+ cups_printer->original_resource = g_strdup (resource);
+ cups_printer->original_port = port;
+ }
if (info->default_number_up > 0)
cups_printer->default_number_up = info->default_number_up;
- cups_printer->hostname = g_strdup (hostname);
- cups_printer->port = port;
-
cups_printer->auth_info_required = g_strdupv (info->auth_info_required);
g_strfreev (info->auth_info_required);
@@ -2474,9 +2497,7 @@ cups_create_printer (GtkPrintBackendCups *cups_backend,
strcmp (cups_backend->default_printer, gtk_printer_get_name (printer)) == 0)
gtk_printer_set_is_default (printer, TRUE);
-#ifdef HAVE_CUPS_API_1_6
cups_printer->avahi_browsed = info->avahi_printer;
-#endif
gtk_print_backend_add_printer (backend, printer);
return printer;
@@ -2498,11 +2519,11 @@ set_printer_icon_name_from_info (GtkPrinter *printer,
gtk_printer_set_icon_name (printer, "printer");
}
-static gchar *
+static char *
get_reason_msg_desc (guint i,
- const gchar *printer_name)
+ const char *printer_name)
{
- gchar *reason_msg_desc;
+ char *reason_msg_desc;
/* The numbers must match the indices in the printer_messages array */
switch (i)
@@ -2569,11 +2590,11 @@ get_reason_msg_desc (guint i,
static void
set_info_state_message (PrinterSetupInfo *info)
{
- gint i;
+ int i;
if (info->state_msg == NULL || strlen (info->state_msg) == 0)
{
- gchar *tmp_msg2 = NULL;
+ char *tmp_msg2 = NULL;
if (info->is_paused && !info->is_accepting_jobs)
/* Translators: this is a printer status. */
tmp_msg2 = g_strdup ( _("Paused; Rejecting Jobs"));
@@ -2594,7 +2615,7 @@ set_info_state_message (PrinterSetupInfo *info)
/* Set description of the reason and combine it with printer-state-message. */
if (info->reason_msg)
{
- gchar *reason_msg_desc = NULL;
+ char *reason_msg_desc = NULL;
gboolean found = FALSE;
for (i = 0; i < G_N_ELEMENTS (printer_messages); i++)
@@ -2621,7 +2642,7 @@ set_info_state_message (PrinterSetupInfo *info)
}
else
{
- gchar *tmp_msg = NULL;
+ char *tmp_msg = NULL;
/* Translators: this string connects multiple printer states together. */
tmp_msg = g_strjoin ( _("; "), info->state_msg,
reason_msg_desc, NULL);
@@ -2636,7 +2657,7 @@ set_info_state_message (PrinterSetupInfo *info)
static void
set_default_printer (GtkPrintBackendCups *cups_backend,
- const gchar *default_printer_name)
+ const char *default_printer_name)
{
cups_backend->default_printer = g_strdup (default_printer_name);
cups_backend->got_default_printer = TRUE;
@@ -2655,18 +2676,33 @@ set_default_printer (GtkPrintBackendCups *cups_backend,
}
}
-#ifdef HAVE_CUPS_API_1_6
+typedef struct {
+ GtkPrinterCups *printer;
+ http_t *http;
+} RequestPrinterInfoData;
+
+static void
+request_printer_info_data_free (RequestPrinterInfoData *data)
+{
+ GTK_NOTE (PRINTING,
+ g_print ("CUPS Backend: %s\n", G_STRFUNC));
+ httpClose (data->http);
+ g_object_unref (data->printer);
+ g_free (data);
+}
+
static void
cups_request_printer_info_cb (GtkPrintBackendCups *cups_backend,
GtkCupsResult *result,
gpointer user_data)
{
- PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
- GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend);
- ipp_attribute_t *attr;
- GtkPrinter *printer;
- gboolean status_changed = FALSE;
- ipp_t *response;
+ RequestPrinterInfoData *data = (RequestPrinterInfoData *) user_data;
+ PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
+ GtkPrintBackend *backend = GTK_PRINT_BACKEND (cups_backend);
+ ipp_attribute_t *attr;
+ GtkPrinter *printer = g_object_ref (GTK_PRINTER (data->printer));
+ gboolean status_changed = FALSE;
+ ipp_t *response;
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s\n", G_STRFUNC));
@@ -2699,12 +2735,6 @@ cups_request_printer_info_cb (GtkPrintBackendCups *cups_backend,
{
set_info_state_message (info);
- printer = gtk_print_backend_find_printer (backend, info->printer_name);
- if (printer != NULL)
- g_object_ref (printer);
- else
- goto done;
-
if (info->got_printer_type &&
info->default_printer &&
cups_backend->avahi_default_printer == NULL)
@@ -2752,13 +2782,12 @@ cups_request_printer_info_cb (GtkPrintBackendCups *cups_backend,
if (status_changed)
g_signal_emit_by_name (GTK_PRINT_BACKEND (backend),
"printer-status-changed", printer);
-
- /* The ref is held by GtkPrintBackend, in add_printer() */
- g_object_unref (printer);
}
}
done:
+ g_object_unref (printer);
+
if (!cups_backend->got_default_printer &&
gtk_print_backend_printer_list_is_done (backend) &&
cups_backend->avahi_default_printer != NULL)
@@ -2770,17 +2799,20 @@ done:
}
static void
-cups_request_printer_info (const gchar *printer_uri,
- const gchar *host,
- gint port,
- GtkPrintBackendCups *backend)
+cups_request_printer_info (GtkPrinterCups *printer)
{
- GtkCupsRequest *request;
- http_t *http;
+ RequestPrinterInfoData *data;
+ GtkPrintBackendCups *backend = GTK_PRINT_BACKEND_CUPS (gtk_printer_get_backend (GTK_PRINTER (printer)));
+ GtkCupsRequest *request;
+ http_t *http;
- http = httpConnect (host, port);
+ http = httpConnect2 (printer->hostname, printer->port, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
if (http)
{
+ data = g_new0 (RequestPrinterInfoData, 1);
+ data->http = http;
+ data->printer = g_object_ref (printer);
+
request = gtk_cups_request_new_with_username (http,
GTK_CUPS_POST,
IPP_GET_PRINTER_ATTRIBUTES,
@@ -2792,7 +2824,7 @@ cups_request_printer_info (const gchar *printer_uri,
gtk_cups_request_set_ipp_version (request, 1, 1);
gtk_cups_request_ipp_add_string (request, IPP_TAG_OPERATION, IPP_TAG_URI,
- "printer-uri", NULL, printer_uri);
+ "printer-uri", NULL, printer->printer_uri);
gtk_cups_request_ipp_add_strings (request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
"requested-attributes", G_N_ELEMENTS (printer_attrs_detailed),
@@ -2801,38 +2833,39 @@ cups_request_printer_info (const gchar *printer_uri,
cups_request_execute (backend,
request,
(GtkPrintCupsResponseCallbackFunc) cups_request_printer_info_cb,
- http,
- (GDestroyNotify) httpClose);
+ data,
+ (GDestroyNotify) request_printer_info_data_free);
}
}
typedef struct
{
- gchar *printer_uri;
- gchar *location;
- gchar *host;
- gint port;
- gchar *printer_name;
- gchar *name;
+ char *printer_uri;
+ char *location;
+ char *host;
+ int port;
+ char *printer_name;
+ char *name;
+ char *resource_path;
gboolean got_printer_type;
guint printer_type;
gboolean got_printer_state;
guint printer_state;
- gchar *type;
- gchar *domain;
- gchar *UUID;
+ char *type;
+ char *domain;
+ char *UUID;
GtkPrintBackendCups *backend;
} AvahiConnectionTestData;
static GtkPrinter *
find_printer_by_uuid (GtkPrintBackendCups *backend,
- const gchar *UUID)
+ const char *UUID)
{
GtkPrinterCups *printer;
GtkPrinter *result = NULL;
GList *printers;
GList *iter;
- gchar *printer_uuid;
+ char *printer_uuid;
printers = gtk_print_backend_get_printer_list (GTK_PRINT_BACKEND (backend));
for (iter = printers; iter != NULL; iter = iter->next)
@@ -2846,9 +2879,7 @@ find_printer_by_uuid (GtkPrintBackendCups *backend,
printer_uuid += 5;
printer_uuid = g_strndup (printer_uuid, 36);
-#if GLIB_CHECK_VERSION(2, 52, 0)
if (g_uuid_string_is_valid (printer_uuid))
-#endif
{
if (g_strcmp0 (printer_uuid, UUID) == 0)
{
@@ -2869,7 +2900,7 @@ find_printer_by_uuid (GtkPrintBackendCups *backend,
}
/*
- * Create new GtkPrinter from informations included in TXT records.
+ * Create new GtkPrinter from information included in TXT records.
*/
static void
create_cups_printer_from_avahi_data (AvahiConnectionTestData *data)
@@ -2880,6 +2911,10 @@ create_cups_printer_from_avahi_data (AvahiConnectionTestData *data)
info->avahi_printer = TRUE;
info->printer_name = data->printer_name;
info->printer_uri = data->printer_uri;
+ info->avahi_resource_path = data->resource_path;
+ info->default_printer = FALSE;
+ info->remote_printer = TRUE;
+ info->is_accepting_jobs = TRUE;
if (data->got_printer_state)
{
@@ -2913,7 +2948,6 @@ create_cups_printer_from_avahi_data (AvahiConnectionTestData *data)
set_info_state_message (info);
printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (data->backend), data->printer_name);
-
if (printer == NULL && data->UUID != NULL)
printer = find_printer_by_uuid (data->backend, data->UUID);
@@ -2937,6 +2971,7 @@ create_cups_printer_from_avahi_data (AvahiConnectionTestData *data)
GTK_PRINTER_CUPS (printer)->avahi_name = g_strdup (data->name);
GTK_PRINTER_CUPS (printer)->avahi_type = g_strdup (data->type);
GTK_PRINTER_CUPS (printer)->avahi_domain = g_strdup (data->domain);
+ GTK_PRINTER_CUPS (printer)->printer_uri = g_strdup (data->printer_uri);
g_free (GTK_PRINTER_CUPS (printer)->hostname);
GTK_PRINTER_CUPS (printer)->hostname = g_strdup (data->host);
GTK_PRINTER_CUPS (printer)->port = data->port;
@@ -2990,17 +3025,18 @@ avahi_connection_test_cb (GObject *source_object,
g_free (data->host);
g_free (data->printer_name);
g_free (data->name);
+ g_free (data->resource_path);
g_free (data->type);
g_free (data->domain);
g_free (data);
}
-gboolean
-avahi_txt_get_key_value_pair (const gchar *entry,
- gchar **key,
- gchar **value)
+static gboolean
+avahi_txt_get_key_value_pair (const char *entry,
+ char **key,
+ char **value)
{
- const gchar *equal_sign;
+ const char *equal_sign;
*key = NULL;
*value = NULL;
@@ -3029,29 +3065,30 @@ avahi_service_resolver_cb (GObject *source_object,
{
AvahiConnectionTestData *data;
GtkPrintBackendCups *backend;
- const gchar *name;
- const gchar *host;
- const gchar *type;
- const gchar *domain;
- const gchar *address;
- const gchar *protocol_string;
+ const char *name;
+ const char *host;
+ const char *type;
+ const char *domain;
+ const char *address;
+ const char *protocol_string;
GVariant *output;
GVariant *txt;
GVariant *child;
guint32 flags;
guint16 port;
GError *error = NULL;
- gchar *queue_name = NULL;
- gchar *tmp;
- gchar *printer_name;
- gchar *endptr;
- gchar *key;
- gchar *value;
+ char *tmp;
+ char *printer_name;
+ char **printer_name_strv;
+ char **printer_name_compressed_strv;
+ char *endptr;
+ char *key;
+ char *value;
gsize length;
- gint interface;
- gint protocol;
- gint aprotocol;
- gint i;
+ int interface;
+ int protocol;
+ int aprotocol;
+ int i, j;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -3093,13 +3130,7 @@ avahi_service_resolver_cb (GObject *source_object,
if (g_strcmp0 (key, "rp") == 0)
{
- queue_name = g_strdup (value);
-
- printer_name = g_strrstr (queue_name, "/");
- if (printer_name != NULL)
- data->printer_name = g_strdup (printer_name + 1);
- else
- data->printer_name = g_strdup (queue_name);
+ data->resource_path = g_strdup (value);
}
else if (g_strcmp0 (key, "note") == 0)
{
@@ -3135,17 +3166,51 @@ avahi_service_resolver_cb (GObject *source_object,
}
}
- if (queue_name)
+ if (data->resource_path != NULL)
{
+ if (data->got_printer_type &&
+ (g_str_has_prefix (data->resource_path, "printers/") ||
+ g_str_has_prefix (data->resource_path, "classes/")))
+ {
+ /* This is a CUPS printer advertised via Avahi */
+ printer_name = g_strrstr (data->resource_path, "/");
+ if (printer_name != NULL && printer_name[0] != '\0')
+ data->printer_name = g_strdup (printer_name + 1);
+ else
+ data->printer_name = g_strdup (data->resource_path);
+ }
+ else
+ {
+ printer_name = g_strdup (name);
+ g_strcanon (printer_name, PRINTER_NAME_ALLOWED_CHARACTERS, '-');
+
+ printer_name_strv = g_strsplit_set (printer_name, "-", -1);
+ printer_name_compressed_strv = g_new0 (char *, g_strv_length (printer_name_strv) + 1);
+ for (i = 0, j = 0; printer_name_strv[i] != NULL; i++)
+ {
+ if (printer_name_strv[i][0] != '\0')
+ {
+ printer_name_compressed_strv[j] = printer_name_strv[i];
+ j++;
+ }
+ }
+
+ data->printer_name = g_strjoinv ("-", printer_name_compressed_strv);
+
+ g_strfreev (printer_name_strv);
+ g_free (printer_name_compressed_strv);
+ g_free (printer_name);
+ }
+
if (g_strcmp0 (type, "_ipp._tcp") == 0)
protocol_string = "ipp";
else
protocol_string = "ipps";
if (aprotocol == AVAHI_PROTO_INET6)
- data->printer_uri = g_strdup_printf ("%s://[%s]:%u/%s", protocol_string, address, port, queue_name);
+ data->printer_uri = g_strdup_printf ("%s://[%s]:%u/%s", protocol_string, address, port, data->resource_path);
else
- data->printer_uri = g_strdup_printf ("%s://%s:%u/%s", protocol_string, address, port, queue_name);
+ data->printer_uri = g_strdup_printf ("%s://%s:%u/%s", protocol_string, address, port, data->resource_path);
data->host = g_strdup (address);
data->port = port;
@@ -3162,7 +3227,6 @@ avahi_service_resolver_cb (GObject *source_object,
backend->avahi_cancellable,
avahi_connection_test_cb,
data);
- g_free (queue_name);
}
else
{
@@ -3184,20 +3248,20 @@ avahi_service_resolver_cb (GObject *source_object,
static void
avahi_service_browser_signal_handler (GDBusConnection *connection,
- const gchar *sender_name,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *signal_name,
+ const char *sender_name,
+ const char *object_path,
+ const char *interface_name,
+ const char *signal_name,
GVariant *parameters,
gpointer user_data)
{
GtkPrintBackendCups *backend = GTK_PRINT_BACKEND_CUPS (user_data);
- gchar *name;
- gchar *type;
- gchar *domain;
+ char *name;
+ char *type;
+ char *domain;
guint flags;
- gint interface;
- gint protocol;
+ int interface;
+ int protocol;
if (g_strcmp0 (signal_name, "ItemNew") == 0)
{
@@ -3283,7 +3347,7 @@ avahi_service_browser_new_cb (GObject *source_object,
GtkPrintBackendCups *cups_backend;
GVariant *output;
GError *error = NULL;
- gint i;
+ int i;
output = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
res,
@@ -3349,7 +3413,7 @@ avahi_create_browsers (GObject *source_object,
if (!dbus_connection)
{
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("Couldn't connect to D-Bus system bus, %s", error->message);
+ g_message ("Couldn't connect to D-Bus system bus, avahi printers will not be available: %s", error->message);
g_error_free (error);
return;
@@ -3421,7 +3485,6 @@ avahi_request_printer_list (GtkPrintBackendCups *cups_backend)
cups_backend->avahi_cancellable = g_cancellable_new ();
g_bus_get (G_BUS_TYPE_SYSTEM, cups_backend->avahi_cancellable, avahi_create_browsers, cups_backend);
}
-#endif
static void
cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
@@ -3433,7 +3496,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
ipp_t *response;
gboolean list_has_changed;
GList *removed_printer_checklist;
- gchar *remote_default_printer = NULL;
+ char *remote_default_printer = NULL;
GList *iter;
list_has_changed = FALSE;
@@ -3470,7 +3533,6 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
removed_printer_checklist = gtk_print_backend_get_printer_list (backend);
response = gtk_cups_result_get_response (result);
-#ifdef HAVE_CUPS_API_1_6
for (attr = ippFirstAttribute (response); attr != NULL;
attr = ippNextAttribute (response))
{
@@ -3486,42 +3548,21 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
if (attr == NULL)
break;
- while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
- {
- cups_printer_handle_attribute (cups_backend, attr, info);
- attr = ippNextAttribute (response);
- }
-#else
- for (attr = response->attrs; attr != NULL; attr = attr->next)
- {
- GtkPrinter *printer;
- gboolean status_changed = FALSE;
- GList *node;
- PrinterSetupInfo *info = g_slice_new0 (PrinterSetupInfo);
- info->default_number_up = 1;
-
- /* Skip leading attributes until we hit a printer...
- */
- while (attr != NULL && ippGetGroupTag (attr) != IPP_TAG_PRINTER)
- attr = attr->next;
- if (attr == NULL)
- break;
while (attr != NULL && ippGetGroupTag (attr) == IPP_TAG_PRINTER)
- {
- cups_printer_handle_attribute (cups_backend, attr, info);
- attr = attr->next;
- }
-#endif
+ {
+ cups_printer_handle_attribute (cups_backend, attr, info);
+ attr = ippNextAttribute (response);
+ }
if (info->printer_name == NULL ||
(info->printer_uri == NULL && info->member_uris == NULL))
- {
- if (attr == NULL)
- break;
- else
- continue;
- }
+ {
+ if (attr == NULL)
+ break;
+ else
+ continue;
+ }
if (info->got_printer_type)
{
@@ -3588,6 +3629,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
GTK_PRINTER_CUPS (printer)->supports_collate = info->supports_collate;
GTK_PRINTER_CUPS (printer)->supports_number_up = info->supports_number_up;
GTK_PRINTER_CUPS (printer)->number_of_covers = info->number_of_covers;
+ g_clear_pointer (&(GTK_PRINTER_CUPS (printer)->covers), g_strfreev);
GTK_PRINTER_CUPS (printer)->covers = g_strdupv (info->covers);
status_changed = gtk_printer_set_job_count (printer, info->job_count);
status_changed |= gtk_printer_set_location (printer, info->location);
@@ -3619,9 +3661,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
{
for (iter = removed_printer_checklist; iter; iter = iter->next)
{
-#ifdef HAVE_CUPS_API_1_6
if (!GTK_PRINTER_CUPS (iter->data)->avahi_browsed)
-#endif
{
mark_printer_inactive (GTK_PRINTER (iter->data), backend);
list_has_changed = TRUE;
@@ -3643,12 +3683,8 @@ done:
g_free (remote_default_printer);
}
-#ifdef HAVE_CUPS_API_1_6
if (!cups_backend->got_default_printer && cups_backend->avahi_default_printer != NULL)
- {
- set_default_printer (cups_backend, cups_backend->avahi_default_printer);
- }
-#endif
+ set_default_printer (cups_backend, cups_backend->avahi_default_printer);
}
static void
@@ -3663,6 +3699,8 @@ update_backend_status (GtkPrintBackendCups *cups_backend,
case GTK_CUPS_CONNECTION_AVAILABLE:
g_object_set (cups_backend, "status", GTK_PRINT_BACKEND_STATUS_OK, NULL);
break;
+
+ case GTK_CUPS_CONNECTION_IN_PROGRESS:
default: ;
}
}
@@ -3685,7 +3723,7 @@ cups_request_printer_list (GtkPrintBackendCups *cups_backend)
if (cups_backend->list_printers_poll > 0)
g_source_remove (cups_backend->list_printers_poll);
cups_backend->list_printers_poll = g_timeout_add (200, (GSourceFunc) cups_request_printer_list, cups_backend);
- g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk+] cups_request_printer_list");
+ g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk] cups_request_printer_list");
}
else if (cups_backend->list_printers_attempts != -1)
cups_backend->list_printers_attempts++;
@@ -3734,12 +3772,10 @@ cups_get_printer_list (GtkPrintBackend *backend)
if (cups_request_printer_list (cups_backend))
{
cups_backend->list_printers_poll = g_timeout_add (50, (GSourceFunc) cups_request_printer_list, backend);
- g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk+] cups_request_printer_list");
+ g_source_set_name_by_id (cups_backend->list_printers_poll, "[gtk] cups_request_printer_list");
}
-#ifdef HAVE_CUPS_API_1_6
avahi_request_printer_list (cups_backend);
-#endif
}
}
@@ -3775,36 +3811,19 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
GTK_PRINTER_CUPS (printer)->reading_ppd = FALSE;
print_backend->reading_ppds--;
-#ifndef HAVE_CUPS_API_1_6
- if (gtk_cups_result_is_error (result))
- {
- gboolean success = FALSE;
-
- /* If we get a 404 then it is just a raw printer without a ppd
- and not an error. */
- if ((gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_HTTP) &&
- (gtk_cups_result_get_error_status (result) == HTTP_NOT_FOUND))
- {
- gtk_printer_set_has_details (printer, TRUE);
- success = TRUE;
- }
-
- g_signal_emit_by_name (printer, "details-acquired", success);
-
- return;
- }
-#endif
-
if (!gtk_cups_result_is_error (result))
{
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
/* let ppdOpenFd take over the ownership of the open file */
g_io_channel_seek_position (data->ppd_io, 0, G_SEEK_SET, NULL);
data->printer->ppd_file = ppdOpenFd (dup (g_io_channel_unix_get_fd (data->ppd_io)));
ppdLocalize (data->printer->ppd_file);
ppdMarkDefaults (data->printer->ppd_file);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS
}
-#ifdef HAVE_CUPS_API_1_6
fstat (g_io_channel_unix_get_fd (data->ppd_io), &data_info);
/*
* Standalone Avahi printers and raw printers don't have PPD files or have
@@ -3817,14 +3836,47 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
((gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_HTTP) &&
(gtk_cups_result_get_error_status (result) == HTTP_NOT_FOUND))))
{
- cups_request_printer_info (GTK_PRINTER_CUPS (printer)->printer_uri,
- GTK_PRINTER_CUPS (printer)->hostname,
- GTK_PRINTER_CUPS (printer)->port,
- GTK_PRINT_BACKEND_CUPS (gtk_printer_get_backend (printer)));
+ GtkPrinterCups *cups_printer = GTK_PRINTER_CUPS (printer);
+
+ /* Try to get the PPD from original host if it is not
+ * available on current CUPS server.
+ */
+ if (!cups_printer->avahi_browsed &&
+ (gtk_cups_result_is_error (result) &&
+ ((gtk_cups_result_get_error_type (result) == GTK_CUPS_ERROR_HTTP) &&
+ (gtk_cups_result_get_error_status (result) == HTTP_NOT_FOUND))) &&
+ cups_printer->remote &&
+ !cups_printer->request_original_uri &&
+ cups_printer->original_device_uri != NULL &&
+ (g_str_has_prefix (cups_printer->original_device_uri, "ipp://") ||
+ g_str_has_prefix (cups_printer->original_device_uri, "ipps://")))
+ {
+ cups_printer->request_original_uri = TRUE;
+
+ gtk_cups_connection_test_free (cups_printer->remote_cups_connection_test);
+ g_clear_handle_id (&cups_printer->get_remote_ppd_poll, g_source_remove);
+ cups_printer->get_remote_ppd_attempts = 0;
+
+ cups_printer->remote_cups_connection_test =
+ gtk_cups_connection_test_new (cups_printer->original_hostname,
+ cups_printer->original_port);
+
+ if (cups_request_ppd (printer))
+ {
+ cups_printer->get_remote_ppd_poll = g_timeout_add (50, (GSourceFunc) cups_request_ppd, printer);
+ g_source_set_name_by_id (cups_printer->get_remote_ppd_poll, "[gtk] cups_request_ppd");
+ }
+ }
+ else
+ {
+ if (cups_printer->request_original_uri)
+ cups_printer->request_original_uri = FALSE;
+
+ cups_request_printer_info (cups_printer);
+ }
return;
}
-#endif
gtk_printer_set_has_details (printer, TRUE);
g_signal_emit_by_name (printer, "details-acquired", TRUE);
@@ -3838,10 +3890,12 @@ cups_request_ppd (GtkPrinter *printer)
GtkPrinterCups *cups_printer;
GtkCupsRequest *request;
char *ppd_filename = NULL;
- gchar *resource;
+ char *resource;
http_t *http;
GetPPDData *data;
int fd;
+ const char *hostname;
+ int port;
cups_printer = GTK_PRINTER_CUPS (printer);
@@ -3850,11 +3904,7 @@ cups_request_ppd (GtkPrinter *printer)
GTK_NOTE (PRINTING,
g_print ("CUPS Backend: %s\n", G_STRFUNC));
- if (cups_printer->remote
-#ifdef HAVE_CUPS_API_1_6
- && !cups_printer->avahi_browsed
-#endif
- )
+ if (cups_printer->remote && !cups_printer->avahi_browsed)
{
GtkCupsConnectionState state;
@@ -3868,7 +3918,7 @@ cups_request_ppd (GtkPrinter *printer)
if (cups_printer->get_remote_ppd_poll > 0)
g_source_remove (cups_printer->get_remote_ppd_poll);
cups_printer->get_remote_ppd_poll = g_timeout_add (200, (GSourceFunc) cups_request_ppd, printer);
- g_source_set_name_by_id (cups_printer->get_remote_ppd_poll, "[gtk+] cups_request_ppd");
+ g_source_set_name_by_id (cups_printer->get_remote_ppd_poll, "[gtk] cups_request_ppd");
}
else if (cups_printer->get_remote_ppd_attempts != -1)
cups_printer->get_remote_ppd_attempts++;
@@ -3888,9 +3938,24 @@ cups_request_ppd (GtkPrinter *printer)
}
}
- http = httpConnectEncrypt (cups_printer->hostname,
- cups_printer->port,
- cupsEncryption ());
+ if (cups_printer->request_original_uri)
+ {
+ hostname = cups_printer->original_hostname;
+ port = cups_printer->original_port;
+ resource = g_strdup_printf ("%s.ppd", cups_printer->original_resource);
+ }
+ else
+ {
+ hostname = cups_printer->hostname;
+ port = cups_printer->port;
+ resource = g_strdup_printf ("/printers/%s.ppd",
+ gtk_printer_cups_get_ppd_name (GTK_PRINTER_CUPS (printer)));
+ }
+
+ http = httpConnect2 (hostname, port,
+ NULL, AF_UNSPEC,
+ cupsEncryption (),
+ 1, 30000, NULL);
data = g_new0 (GetPPDData, 1);
@@ -3928,16 +3993,13 @@ cups_request_ppd (GtkPrinter *printer)
data->printer = (GtkPrinterCups *) g_object_ref (printer);
- resource = g_strdup_printf ("/printers/%s.ppd",
- gtk_printer_cups_get_ppd_name (GTK_PRINTER_CUPS (printer)));
-
print_backend = gtk_printer_get_backend (printer);
request = gtk_cups_request_new_with_username (data->http,
GTK_CUPS_GET,
0,
data->ppd_io,
- cups_printer->hostname,
+ hostname,
resource,
GTK_PRINT_BACKEND_CUPS (print_backend)->username);
@@ -4038,7 +4100,7 @@ cups_parse_user_options (const char *filename,
cups_option_t **options)
{
FILE *fp;
- gchar line[1024], *lineptr, *name;
+ char line[1024], *lineptr, *name;
if ((fp = g_fopen (filename, "r")) == NULL)
return num_options;
@@ -4132,7 +4194,7 @@ cups_get_default_printer (GtkPrintBackendCups *backend)
if (cups_request_default_printer (cups_backend))
{
cups_backend->default_printer_poll = g_timeout_add (200, (GSourceFunc) cups_request_default_printer, backend);
- g_source_set_name_by_id (cups_backend->default_printer_poll, "[gtk+] cups_request_default_printer");
+ g_source_set_name_by_id (cups_backend->default_printer_poll, "[gtk] cups_request_default_printer");
}
}
}
@@ -4194,13 +4256,14 @@ cups_request_default_printer_cb (GtkPrintBackendCups *print_backend,
response = gtk_cups_result_get_response (result);
if ((attr = ippFindAttribute (response, "printer-name", IPP_TAG_NAME)) != NULL)
- print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL));
+ print_backend->default_printer = g_strdup (ippGetString (attr, 0, NULL));
print_backend->got_default_printer = TRUE;
if (print_backend->default_printer != NULL)
{
- printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (print_backend), print_backend->default_printer);
+ printer = gtk_print_backend_find_printer (GTK_PRINT_BACKEND (print_backend),
+ print_backend->default_printer);
if (printer != NULL)
{
gtk_printer_set_is_default (printer, TRUE);
@@ -4253,11 +4316,7 @@ cups_printer_request_details (GtkPrinter *printer)
if (!cups_printer->reading_ppd &&
gtk_printer_cups_get_ppd (cups_printer) == NULL)
{
- if (cups_printer->remote
-#ifdef HAVE_CUPS_API_1_6
- && !cups_printer->avahi_browsed
-#endif
- )
+ if (cups_printer->remote && !cups_printer->avahi_browsed)
{
if (cups_printer->get_remote_ppd_poll == 0)
{
@@ -4268,7 +4327,7 @@ cups_printer_request_details (GtkPrinter *printer)
if (cups_request_ppd (printer))
{
cups_printer->get_remote_ppd_poll = g_timeout_add (50, (GSourceFunc) cups_request_ppd, printer);
- g_source_set_name_by_id (cups_printer->get_remote_ppd_poll, "[gtk+] cups_request_ppd");
+ g_source_set_name_by_id (cups_printer->get_remote_ppd_poll, "[gtk] cups_request_ppd");
}
}
}
@@ -4447,11 +4506,11 @@ static const struct {
* Handles "format not a string literal" error
* https://mail.gnome.org/archives/desktop-devel-list/2016-March/msg00075.html
*/
-static gchar *
-get_ipp_choice_translation_string (gint index,
+static char *
+get_ipp_choice_translation_string (int index,
guint i)
{
- gchar *translation;
+ char *translation;
if (i < G_N_ELEMENTS (ipp_choice_translations))
translation = g_strdup (_(ipp_choice_translations[i].translation));
@@ -4494,7 +4553,7 @@ static const struct {
};
/* keep sorted when changing */
-static const char *color_option_whitelist[] = {
+static const char *color_option_allow_list[] = {
"BRColorEnhancement",
"BRColorMatching",
"BRColorMatching",
@@ -4514,7 +4573,7 @@ static const char *color_option_whitelist[] = {
};
/* keep sorted when changing */
-static const char *color_group_whitelist[] = {
+static const char *color_group_allow_list[] = {
"ColorPage",
"FPColorWise1",
"FPColorWise2",
@@ -4525,7 +4584,7 @@ static const char *color_group_whitelist[] = {
};
/* keep sorted when changing */
-static const char *image_quality_option_whitelist[] = {
+static const char *image_quality_option_allow_list[] = {
"BRDocument",
"BRHalfTonePattern",
"BRNormalPrt",
@@ -4553,7 +4612,7 @@ static const char *image_quality_option_whitelist[] = {
};
/* keep sorted when changing */
-static const char *image_quality_group_whitelist[] = {
+static const char *image_quality_group_allow_list[] = {
"FPImageQuality1",
"FPImageQuality2",
"FPImageQuality3",
@@ -4561,7 +4620,7 @@ static const char *image_quality_group_whitelist[] = {
};
/* keep sorted when changing */
-static const char * finishing_option_whitelist[] = {
+static const char * finishing_option_allow_list[] = {
"BindColor",
"BindEdge",
"BindType",
@@ -4581,7 +4640,7 @@ static const char * finishing_option_whitelist[] = {
};
/* keep sorted when changing */
-static const char *finishing_group_whitelist[] = {
+static const char *finishing_group_allow_list[] = {
"FPFinishing1",
"FPFinishing2",
"FPFinishing3",
@@ -4591,7 +4650,7 @@ static const char *finishing_group_whitelist[] = {
};
/* keep sorted when changing */
-static const char *cups_option_blacklist[] = {
+static const char *cups_option_ignore_list[] = {
"Collate",
"Copies",
"OutputOrder",
@@ -4694,7 +4753,7 @@ available_choices (ppd_file_t *ppd,
{
ppd_option_t *other_option;
int i, j;
- gchar *conflicts;
+ char *conflicts;
ppd_const_t *constraint;
const char *choice, *other_choice;
ppd_option_t *option1, *option2;
@@ -4721,6 +4780,8 @@ available_choices (ppd_file_t *ppd,
}
}
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
for (i = ppd->num_consts, constraint = ppd->consts; i > 0; i--, constraint++)
{
option1 = ppdFindOption (ppd, constraint->option1);
@@ -4780,6 +4841,8 @@ available_choices (ppd_file_t *ppd,
}
}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
num_conflicts = 0;
all_default = TRUE;
for (j = 0; j < option->num_choices; j++)
@@ -4856,7 +4919,7 @@ available_choices (ppd_file_t *ppd,
static GtkPrinterOption *
create_pickone_option (ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
- const gchar *gtk_name)
+ const char *gtk_name)
{
GtkPrinterOption *option;
ppd_choice_t **available;
@@ -4869,6 +4932,8 @@ create_pickone_option (ppd_file_t *ppd_file,
option = NULL;
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
n_choices = available_choices (ppd_file, ppd_option, &available, g_str_has_prefix (gtk_name, "gtk-"));
if (n_choices > 0)
{
@@ -4889,7 +4954,7 @@ create_pickone_option (ppd_file_t *ppd_file,
if (ppdNextCustomParam (coption) == NULL)
{
- switch (cparam->type)
+ switch ((guint)cparam->type)
{
case PPD_CUSTOM_INT:
option = gtk_printer_option_new (gtk_name, label,
@@ -4969,6 +5034,9 @@ create_pickone_option (ppd_file_t *ppd_file,
else
g_warning ("CUPS Backend: Ignoring pickone %s\n", ppd_option->text);
#endif
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
g_free (available);
return option;
@@ -4977,7 +5045,7 @@ create_pickone_option (ppd_file_t *ppd_file,
static GtkPrinterOption *
create_boolean_option (ppd_file_t *ppd_file,
ppd_option_t *ppd_option,
- const gchar *gtk_name)
+ const char *gtk_name)
{
GtkPrinterOption *option;
ppd_choice_t **available;
@@ -5013,8 +5081,8 @@ create_boolean_option (ppd_file_t *ppd_file,
return option;
}
-static gchar *
-get_ppd_option_name (const gchar *keyword)
+static char *
+get_ppd_option_name (const char *keyword)
{
int i;
@@ -5025,8 +5093,8 @@ get_ppd_option_name (const gchar *keyword)
return g_strdup_printf ("cups-%s", keyword);
}
-static gchar *
-get_lpoption_name (const gchar *lpoption)
+static char *
+get_lpoption_name (const char *lpoption)
{
int i;
@@ -5052,9 +5120,9 @@ strptr_cmp (const void *a,
static gboolean
-string_in_table (const gchar *str,
- const gchar *table[],
- gint table_len)
+string_in_table (const char *str,
+ const char *table[],
+ int table_len)
{
return bsearch (&str, table, table_len, sizeof (char *), (void *)strptr_cmp) != NULL;
}
@@ -5072,7 +5140,7 @@ handle_option (GtkPrinterOptionSet *set,
char *option_name;
int i;
- if (STRING_IN_TABLE (ppd_option->keyword, cups_option_blacklist))
+ if (STRING_IN_TABLE (ppd_option->keyword, cups_option_ignore_list))
return;
option_name = get_ppd_option_name (ppd_option->keyword);
@@ -5092,18 +5160,18 @@ handle_option (GtkPrinterOptionSet *set,
const char *name;
name = ppd_group_name (toplevel_group);
- if (STRING_IN_TABLE (name, color_group_whitelist) ||
- STRING_IN_TABLE (ppd_option->keyword, color_option_whitelist))
+ if (STRING_IN_TABLE (name, color_group_allow_list) ||
+ STRING_IN_TABLE (ppd_option->keyword, color_option_allow_list))
{
option->group = g_strdup ("ColorPage");
}
- else if (STRING_IN_TABLE (name, image_quality_group_whitelist) ||
- STRING_IN_TABLE (ppd_option->keyword, image_quality_option_whitelist))
+ else if (STRING_IN_TABLE (name, image_quality_group_allow_list) ||
+ STRING_IN_TABLE (ppd_option->keyword, image_quality_option_allow_list))
{
option->group = g_strdup ("ImageQualityPage");
}
- else if (STRING_IN_TABLE (name, finishing_group_whitelist) ||
- STRING_IN_TABLE (ppd_option->keyword, finishing_option_whitelist))
+ else if (STRING_IN_TABLE (name, finishing_group_allow_list) ||
+ STRING_IN_TABLE (ppd_option->keyword, finishing_option_allow_list))
{
option->group = g_strdup ("FinishingPage");
}
@@ -5139,8 +5207,8 @@ handle_group (GtkPrinterOptionSet *set,
ppd_group_t *toplevel_group,
GtkPrintSettings *settings)
{
- gint i;
- const gchar *name;
+ int i;
+ const char *name;
/* Ignore installable options */
name = ppd_group_name (toplevel_group);
@@ -5173,14 +5241,14 @@ colord_printer_option_set_changed_cb (GtkPrinterOptionSet *set,
#endif
/*
- * Lookup translation and Gtk+ name of given IPP option name.
+ * Lookup translation and GTK name of given IPP option name.
*/
static gboolean
-get_ipp_option_translation (const gchar *ipp_option_name,
- gchar **gtk_option_name,
- gchar **translation)
+get_ipp_option_translation (const char *ipp_option_name,
+ char **gtk_option_name,
+ char **translation)
{
- gint i;
+ int i;
*gtk_option_name = NULL;
*translation = NULL;
@@ -5203,16 +5271,16 @@ get_ipp_option_translation (const gchar *ipp_option_name,
/*
* Lookup translation of given IPP choice.
*/
-static gchar *
-get_ipp_choice_translation (const gchar *ipp_option_name,
- const gchar *ipp_choice)
+static char *
+get_ipp_choice_translation (const char *ipp_option_name,
+ const char *ipp_choice)
{
- const gchar *nptr;
+ const char *nptr;
guint64 index;
- gchar *translation = NULL;
+ char *translation = NULL;
gsize ipp_choice_length;
- gchar *endptr;
- gint i;
+ char *endptr;
+ int i;
for (i = 0; ipp_choice_translations[i].ipp_option_name != NULL; i++)
{
@@ -5254,11 +5322,11 @@ get_ipp_choice_translation (const gchar *ipp_option_name,
/*
* Format an IPP choice to a displayable string.
*/
-static gchar *
-format_ipp_choice (const gchar *ipp_choice)
+static char *
+format_ipp_choice (const char *ipp_choice)
{
gboolean after_space = TRUE;
- gchar *result = NULL;
+ char *result = NULL;
gsize i;
if (ipp_choice != NULL)
@@ -5288,15 +5356,15 @@ format_ipp_choice (const gchar *ipp_choice)
* if available.
*/
static GtkPrinterOption *
-setup_ipp_option (gchar *ipp_option_name,
- gchar *ipp_choice_default,
+setup_ipp_option (const char *ipp_option_name,
+ const char *ipp_choice_default,
GList *ipp_choices,
GtkPrinterOptionSet *set)
{
GtkPrinterOption *option = NULL;
- gchar *gtk_option_name = NULL;
- gchar *translation = NULL;
- gchar *ipp_choice;
+ char *gtk_option_name = NULL;
+ char *translation = NULL;
+ char *ipp_choice;
gsize i;
get_ipp_option_translation (ipp_option_name,
@@ -5328,7 +5396,7 @@ setup_ipp_option (gchar *ipp_option_name,
i = 0;
for (iter = ipp_choices; iter != NULL; iter = iter->next)
{
- ipp_choice = (gchar *) iter->data;
+ ipp_choice = (char *) iter->data;
choices[i] = g_strdup (ipp_choice);
@@ -5347,16 +5415,16 @@ setup_ipp_option (gchar *ipp_option_name,
{
gtk_printer_option_choices_from_array (option,
length,
- choices,
- choices_display);
+ (const char **)choices,
+ (const char **)choices_display);
}
option_set_is_ipp_option (option, TRUE);
gtk_printer_option_set_add (set, option);
- g_free (choices);
- g_free (choices_display);
+ g_strfreev (choices);
+ g_strfreev (choices_display);
}
/* The option exists. Set its default value if available. */
@@ -5379,21 +5447,21 @@ cups_printer_get_options (GtkPrinter *printer,
GtkPrinterOption *option;
ppd_file_t *ppd_file;
int i;
- char *print_at[] = { "now", "at", "on-hold" };
- char *n_up[] = {"1", "2", "4", "6", "9", "16" };
- char *prio[] = {"100", "80", "50", "30" };
+ const char *print_at[] = { "now", "at", "on-hold" };
+ const char *n_up[] = {"1", "2", "4", "6", "9", "16" };
+ const char *prio[] = {"100", "80", "50", "30" };
/* Translators: These strings name the possible values of the
* job priority option in the print dialog
*/
- char *prio_display[] = {N_("Urgent"), N_("High"), N_("Medium"), N_("Low") };
- char *n_up_layout[] = { "lrtb", "lrbt", "rltb", "rlbt", "tblr", "tbrl", "btlr", "btrl" };
+ const char *prio_display[] = {N_("Urgent"), N_("High"), N_("Medium"), N_("Low") };
+ const char *n_up_layout[] = { "lrtb", "lrbt", "rltb", "rlbt", "tblr", "tbrl", "btlr", "btrl" };
/* Translators: These strings name the possible arrangements of
* multiple pages on a sheet when printing
*/
- char *n_up_layout_display[] = { N_("Left to right, top to bottom"), N_("Left to right, bottom to top"),
- N_("Right to left, top to bottom"), N_("Right to left, bottom to top"),
- N_("Top to bottom, left to right"), N_("Top to bottom, right to left"),
- N_("Bottom to top, left to right"), N_("Bottom to top, right to left") };
+ const char *n_up_layout_display[] = { N_("Left to right, top to bottom"), N_("Left to right, bottom to top"),
+ N_("Right to left, top to bottom"), N_("Right to left, bottom to top"),
+ N_("Top to bottom, left to right"), N_("Top to bottom, right to left"),
+ N_("Bottom to top, left to right"), N_("Bottom to top, right to left") };
char *name;
int num_opts;
cups_option_t *opts = NULL;
@@ -5437,7 +5505,7 @@ cups_printer_get_options (GtkPrinter *printer,
if (backend != NULL && printer != NULL)
{
- char *cover_default[] = {
+ const char *cover_default[] = {
"none",
"classified",
"confidential",
@@ -5446,7 +5514,7 @@ cups_printer_get_options (GtkPrinter *printer,
"topsecret",
"unclassified"
};
- char *cover_display_default[] = {
+ const char *cover_display_default[] = {
/* Translators, these strings are names for various 'standard' cover
* pages that the printing system may support.
*/
@@ -5461,9 +5529,9 @@ cups_printer_get_options (GtkPrinter *printer,
char **cover = NULL;
char **cover_display = NULL;
char **cover_display_translated = NULL;
- gint num_of_covers = 0;
- gpointer value;
- gint j;
+ int num_of_covers = 0;
+ gconstpointer value;
+ int j;
/* Translators, this string is used to label the pages-per-sheet option
* in the print dialog
@@ -5522,14 +5590,14 @@ cups_printer_get_options (GtkPrinter *printer,
}
for (i = 0; i < num_of_covers; i++)
- cover_display_translated[i] = (gchar *)g_dpgettext2 (GETTEXT_PACKAGE, "cover page", cover_display[i]);
+ cover_display_translated[i] = (char *)g_dpgettext2 (GETTEXT_PACKAGE, "cover page", cover_display[i]);
/* Translators, this is the label used for the option in the print
* dialog that controls the front cover page.
*/
option = gtk_printer_option_new ("gtk-cover-before", C_("printer option", "Before"), GTK_PRINTER_OPTION_TYPE_PICKONE);
gtk_printer_option_choices_from_array (option, num_of_covers,
- cover, cover_display_translated);
+ (const char **)cover, (const char **)cover_display_translated);
if (cups_printer->default_cover_before != NULL)
gtk_printer_option_set (option, cups_printer->default_cover_before);
@@ -5544,7 +5612,7 @@ cups_printer_get_options (GtkPrinter *printer,
*/
option = gtk_printer_option_new ("gtk-cover-after", C_("printer option", "After"), GTK_PRINTER_OPTION_TYPE_PICKONE);
gtk_printer_option_choices_from_array (option, num_of_covers,
- cover, cover_display_translated);
+ (const char **)cover, (const char **)cover_display_translated);
if (cups_printer->default_cover_after != NULL)
gtk_printer_option_set (option, cups_printer->default_cover_after);
else
@@ -5585,7 +5653,9 @@ cups_printer_get_options (GtkPrinter *printer,
{
GtkPaperSize *paper_size;
ppd_option_t *ppd_option;
- const gchar *ppd_name;
+ const char *ppd_name;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
ppdMarkDefaults (ppd_file);
@@ -5603,7 +5673,7 @@ cups_printer_get_options (GtkPrinter *printer,
}
else
{
- gchar *custom_name;
+ char *custom_name;
char width[G_ASCII_DTOSTR_BUF_SIZE];
char height[G_ASCII_DTOSTR_BUF_SIZE];
@@ -5624,6 +5694,7 @@ cups_printer_get_options (GtkPrinter *printer,
g_free (custom_name);
}
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
for (i = 0; i < ppd_file->num_groups; i++)
handle_group (set, ppd_file, &ppd_file->groups[i], &ppd_file->groups[i], settings);
@@ -5654,14 +5725,14 @@ cups_printer_get_options (GtkPrinter *printer,
for (i = 0; i < num_opts; i++)
{
- if (STRING_IN_TABLE (opts[i].name, cups_option_blacklist))
+ if (STRING_IN_TABLE (opts[i].name, cups_option_ignore_list))
continue;
name = get_lpoption_name (opts[i].name);
if (strcmp (name, "cups-job-sheets") == 0)
{
- gchar **values;
- gint num_values;
+ char **values;
+ int num_values;
values = g_strsplit (opts[i].value, ",", 2);
num_values = g_strv_length (values);
@@ -5727,7 +5798,7 @@ cups_printer_get_options (GtkPrinter *printer,
#ifdef HAVE_COLORD
option = gtk_printer_option_new ("colord-profile",
- /* TRANSLATORS: this this the ICC color profile to use for this job */
+ /* TRANSLATORS: this is the ICC color profile to use for this job */
C_("printer option", "Printer Profile"),
GTK_PRINTER_OPTION_TYPE_INFO);
@@ -5769,11 +5840,15 @@ mark_option_from_set (GtkPrinterOptionSet *set,
GtkPrinterOption *option;
char *name = get_ppd_option_name (ppd_option->keyword);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
option = gtk_printer_option_set_lookup (set, name);
if (option)
ppdMarkOption (ppd_file, ppd_option->keyword, option->value);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
g_free (name);
}
@@ -5843,6 +5918,8 @@ cups_printer_mark_conflicts (GtkPrinter *printer,
if (ppd_file == NULL)
return FALSE;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
ppdMarkDefaults (ppd_file);
for (i = 0; i < ppd_file->num_groups; i++)
@@ -5856,6 +5933,8 @@ cups_printer_mark_conflicts (GtkPrinter *printer,
set_conflicts_from_group (options, ppd_file, &ppd_file->groups[i]);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
return num_conflicts > 0;
}
@@ -5874,11 +5953,11 @@ typedef struct {
static void
map_settings_to_option (GtkPrinterOption *option,
const NameMapping table[],
- gint n_elements,
+ int n_elements,
GtkPrintSettings *settings,
- const gchar *standard_name,
- const gchar *cups_name,
- const gchar *ipp_name)
+ const char *standard_name,
+ const char *cups_name,
+ const char *ipp_name)
{
int i;
char *name;
@@ -5935,13 +6014,13 @@ map_settings_to_option (GtkPrinterOption *option,
}
static void
-map_option_to_settings (const gchar *value,
+map_option_to_settings (const char *value,
const NameMapping table[],
- gint n_elements,
+ int n_elements,
GtkPrintSettings *settings,
- const gchar *standard_name,
- const gchar *cups_name,
- const gchar *ipp_name,
+ const char *standard_name,
+ const char *cups_name,
+ const char *ipp_name,
gboolean is_ipp_option)
{
int i;
@@ -6237,7 +6316,7 @@ supports_am_pm (void)
* Returns a newly allocated string holding UTC time in HH:MM:SS format
* or NULL.
*/
-gchar *
+static char *
localtime_to_utctime (const char *local_time)
{
const char *formats_0[] = {" %I : %M : %S %p ", " %p %I : %M : %S ",
@@ -6252,7 +6331,7 @@ localtime_to_utctime (const char *local_time)
struct tm local_print_time;
struct tm utc_print_time;
struct tm diff_time;
- gchar *utc_time = NULL;
+ char *utc_time = NULL;
int i, n;
if (local_time == NULL || local_time[0] == '\0')
@@ -6332,7 +6411,7 @@ cups_printer_get_settings_from_options (GtkPrinter *printer,
if (strcmp (print_at, "at") == 0)
{
- gchar *utc_time = NULL;
+ char *utc_time = NULL;
utc_time = localtime_to_utctime (print_at_time);
@@ -6357,7 +6436,7 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
{
GtkPrintPages pages;
GtkPageRange *ranges;
- gint n_ranges;
+ int n_ranges;
GtkPageSet page_set;
GtkPaperSize *paper_size;
const char *ppd_paper_name;
@@ -6452,8 +6531,6 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
switch (gtk_page_setup_get_orientation (page_setup))
{
- case GTK_PAGE_ORIENTATION_PORTRAIT:
- break;
case GTK_PAGE_ORIENTATION_LANDSCAPE:
if (layout < 4)
layout = layout + 2 + 4 * (1 - layout / 2);
@@ -6469,6 +6546,10 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
else
layout = layout - 6 + 4 * (1 - (layout - 4) / 2);
break;
+
+ case GTK_PAGE_ORIENTATION_PORTRAIT:
+ default:
+ break;
}
enum_class = g_type_class_ref (GTK_TYPE_NUMBER_UP_LAYOUT);
@@ -6489,12 +6570,14 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
static GtkPageSetup *
create_page_setup (ppd_file_t *ppd_file,
ppd_size_t *size)
- {
- char *display_name;
- GtkPageSetup *page_setup;
- GtkPaperSize *paper_size;
- ppd_option_t *option;
- ppd_choice_t *choice;
+{
+ char *display_name;
+ GtkPageSetup *page_setup;
+ GtkPaperSize *paper_size;
+ ppd_option_t *option;
+ ppd_choice_t *choice;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_name = NULL;
option = ppdFindOption (ppd_file, "PageSize");
@@ -6505,6 +6588,8 @@ create_page_setup (ppd_file_t *ppd_file,
display_name = ppd_text_to_utf8 (ppd_file, choice->text);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
if (display_name == NULL)
display_name = g_strdup (size->name);
@@ -6527,13 +6612,13 @@ create_page_setup (ppd_file_t *ppd_file,
}
static GtkPageSetup *
-create_page_setup_from_media (gchar *media,
+create_page_setup_from_media (char *media,
MediaSize *media_size,
gboolean media_margin_default_set,
- gint media_bottom_margin_default,
- gint media_top_margin_default,
- gint media_left_margin_default,
- gint media_right_margin_default)
+ int media_bottom_margin_default,
+ int media_top_margin_default,
+ int media_left_margin_default,
+ int media_right_margin_default)
{
GtkPageSetup *page_setup;
GtkPaperSize *paper_size;
@@ -6590,7 +6675,7 @@ cups_printer_list_papers (GtkPrinter *printer)
MediaSize *media_size;
GList *media_iter;
GList *media_size_iter;
- gchar *media;
+ char *media;
for (media_iter = cups_printer->media_supported,
media_size_iter = cups_printer->media_size_supported;
@@ -6598,7 +6683,7 @@ cups_printer_list_papers (GtkPrinter *printer)
media_iter = media_iter->next,
media_size_iter = media_size_iter->next)
{
- media = (gchar *) media_iter->data;
+ media = (char *) media_iter->data;
media_size = (MediaSize *) media_size_iter->data;
page_setup = create_page_setup_from_media (media,
@@ -6630,6 +6715,8 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
ppd_file = gtk_printer_cups_get_ppd (GTK_PRINTER_CUPS (printer));
if (ppd_file != NULL)
{
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
option = ppdFindOption (ppd_file, "PageSize");
if (option == NULL)
return NULL;
@@ -6638,6 +6725,8 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
if (size == NULL)
return NULL;
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
result = create_page_setup (ppd_file, size);
}
else if (cups_printer->media_default != NULL)
@@ -6645,7 +6734,7 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
MediaSize *media_size;
GList *media_iter;
GList *media_size_iter;
- gchar *media;
+ char *media;
for (media_iter = cups_printer->media_supported,
media_size_iter = cups_printer->media_size_supported;
@@ -6653,7 +6742,7 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
media_iter = media_iter->next,
media_size_iter = media_size_iter->next)
{
- media = (gchar *) media_iter->data;
+ media = (char *) media_iter->data;
media_size = (MediaSize *) media_size_iter->data;
if (g_strcmp0 (cups_printer->media_default, media) == 0)
@@ -6674,10 +6763,10 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
static gboolean
cups_printer_get_hard_margins (GtkPrinter *printer,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right)
+ double *top,
+ double *bottom,
+ double *left,
+ double *right)
{
GtkPrinterCups *cups_printer = GTK_PRINTER_CUPS (printer);
ppd_file_t *ppd_file;
@@ -6707,14 +6796,14 @@ cups_printer_get_hard_margins (GtkPrinter *printer,
static gboolean
cups_printer_get_hard_margins_for_paper_size (GtkPrinter *printer,
GtkPaperSize *paper_size,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right)
+ double *top,
+ double *bottom,
+ double *left,
+ double *right)
{
ppd_file_t *ppd_file;
ppd_size_t *size;
- const gchar *paper_name;
+ const char *paper_name;
int i;
ppd_file = gtk_printer_cups_get_ppd (GTK_PRINTER_CUPS (printer));
@@ -6777,8 +6866,8 @@ cups_printer_get_capabilities (GtkPrinter *printer)
static void
secrets_service_appeared_cb (GDBusConnection *connection,
- const gchar *name,
- const gchar *name_owner,
+ const char *name,
+ const char *name_owner,
gpointer user_data)
{
GtkPrintBackendCups *backend = GTK_PRINT_BACKEND_CUPS (user_data);
@@ -6788,7 +6877,7 @@ secrets_service_appeared_cb (GDBusConnection *connection,
static void
secrets_service_vanished_cb (GDBusConnection *connection,
- const gchar *name,
+ const char *name,
gpointer user_data)
{
GtkPrintBackendCups *backend = GTK_PRINT_BACKEND_CUPS (user_data);
diff --git a/modules/printbackends/gtkprintbackendcups.h b/modules/printbackends/gtkprintbackendcups.h
index d4e35ddf23..a37a571a35 100644
--- a/modules/printbackends/gtkprintbackendcups.h
+++ b/modules/printbackends/gtkprintbackendcups.h
@@ -20,7 +20,7 @@
#define __GTK_PRINT_BACKEND_CUPS_H__
#include <glib-object.h>
-#include "gtkprintbackend.h"
+#include "gtkprintbackendprivate.h"
G_BEGIN_DECLS
diff --git a/modules/printbackends/gtkprintbackendfile.c b/modules/printbackends/gtkprintbackendfile.c
index 64380de750..94718820c4 100644
--- a/modules/printbackends/gtkprintbackendfile.c
+++ b/modules/printbackends/gtkprintbackendfile.c
@@ -35,7 +35,7 @@
#include <glib/gi18n-lib.h>
#include "gtk/gtk.h"
-#include "gtk/gtkprinter-private.h"
+#include "gtk/gtkprinterprivate.h"
#include "gtkprintbackendfile.h"
@@ -65,7 +65,7 @@ typedef enum
N_FORMATS
} OutputFormat;
-static const gchar* formats[N_FORMATS] =
+static const char * formats[N_FORMATS] =
{
"pdf",
"ps",
@@ -74,8 +74,6 @@ static const gchar* formats[N_FORMATS] =
static GObjectClass *backend_parent_class;
-static void gtk_print_backend_file_class_init (GtkPrintBackendFileClass *class);
-static void gtk_print_backend_file_init (GtkPrintBackendFile *impl);
static void file_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings);
@@ -95,8 +93,8 @@ static void gtk_print_backend_file_print_stream (GtkPrintBack
GDestroyNotify dnotify);
static cairo_surface_t * file_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io);
static GList * file_printer_list_papers (GtkPrinter *printer);
@@ -126,7 +124,7 @@ char **
g_io_module_query (void)
{
char *eps[] = {
- GTK_PRINT_BACKEND_EXTENSION_POINT_NAME,
+ (char *)GTK_PRINT_BACKEND_EXTENSION_POINT_NAME,
NULL
};
@@ -173,8 +171,8 @@ gtk_print_backend_file_class_finalize (GtkPrintBackendFileClass *class)
static OutputFormat
format_from_settings (GtkPrintSettings *settings)
{
- const gchar *value;
- gint i;
+ const char *value;
+ int i;
if (settings == NULL)
return N_FORMATS;
@@ -193,19 +191,19 @@ format_from_settings (GtkPrintSettings *settings)
return (OutputFormat) i;
}
-static gchar *
+static char *
output_file_from_settings (GtkPrintSettings *settings,
- const gchar *default_format)
+ const char *default_format)
{
- gchar *uri = NULL;
+ char *uri = NULL;
if (settings)
uri = g_strdup (gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_URI));
if (uri == NULL)
{
- const gchar *extension, *basename = NULL, *output_dir = NULL;
- gchar *name, *locale_name, *path;
+ const char *extension, *basename = NULL, *output_dir = NULL;
+ char *name, *locale_name, *path;
if (default_format)
extension = default_format;
@@ -217,6 +215,7 @@ output_file_from_settings (GtkPrintSettings *settings,
switch (format)
{
default:
+ case N_FORMATS:
case FORMAT_PDF:
extension = "pdf";
break;
@@ -245,11 +244,11 @@ output_file_from_settings (GtkPrintSettings *settings,
output_dir = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_OUTPUT_DIR);
if (output_dir == NULL)
{
- const gchar *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
+ const char *document_dir = g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS);
if (document_dir == NULL)
{
- gchar *current_dir = g_get_current_dir ();
+ char *current_dir = g_get_current_dir ();
path = g_build_filename (current_dir, locale_name, NULL);
g_free (current_dir);
}
@@ -284,20 +283,20 @@ _cairo_write (void *closure,
error = NULL;
GTK_NOTE (PRINTING,
- g_print ("FILE Backend: Writting %u byte chunk to temp file\n", length));
+ g_print ("FILE Backend: Writing %u byte chunk to temp file\n", length));
while (length > 0)
{
GIOStatus status;
- status = g_io_channel_write_chars (io, (const gchar *) data, length, &written, &error);
+ status = g_io_channel_write_chars (io, (const char *) data, length, &written, &error);
if (status == G_IO_STATUS_ERROR)
{
if (error != NULL)
{
GTK_NOTE (PRINTING,
- g_print ("FILE Backend: Error writting to temp file, %s\n", error->message));
+ g_print ("FILE Backend: Error writing to temp file, %s\n", error->message));
g_error_free (error);
}
@@ -319,8 +318,8 @@ _cairo_write (void *closure,
static cairo_surface_t *
file_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io)
{
cairo_surface_t *surface;
@@ -333,6 +332,7 @@ file_printer_create_cairo_surface (GtkPrinter *printer,
switch (format)
{
default:
+ case N_FORMATS:
case FORMAT_PDF:
surface = cairo_pdf_surface_create_for_stream (_cairo_write, cache_io, width, height);
break;
@@ -368,7 +368,7 @@ file_print_cb (GtkPrintBackendFile *print_backend,
GError *error,
gpointer user_data)
{
- gchar *uri;
+ char *uri;
_PrintStreamData *ps = (_PrintStreamData *) user_data;
GtkRecentManager *recent_manager;
@@ -403,7 +403,7 @@ file_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
{
- gchar buf[_STREAM_MAX_CHUNK_SIZE];
+ char buf[_STREAM_MAX_CHUNK_SIZE];
gsize bytes_read;
GError *error;
GIOStatus read_status;
@@ -446,7 +446,7 @@ file_write (GIOChannel *source,
}
GTK_NOTE (PRINTING,
- g_print ("FILE Backend: Writting %"G_GSIZE_FORMAT" byte chunk to target file\n", bytes_read));
+ g_print ("FILE Backend: Writing %"G_GSIZE_FORMAT" byte chunk to target file\n", bytes_read));
return TRUE;
}
@@ -462,7 +462,7 @@ gtk_print_backend_file_print_stream (GtkPrintBackend *print_backend,
GError *internal_error = NULL;
_PrintStreamData *ps;
GtkPrintSettings *settings;
- gchar *uri;
+ char *uri;
GFile *file = NULL;
settings = gtk_print_job_get_settings (job);
@@ -534,8 +534,8 @@ set_printer_format_from_option_set (GtkPrinter *printer,
GtkPrinterOptionSet *set)
{
GtkPrinterOption *format_option;
- const gchar *value;
- gint i;
+ const char *value;
+ int i;
format_option = gtk_printer_option_set_lookup (set, "output-file-format");
if (format_option && format_option->value)
@@ -574,7 +574,7 @@ file_printer_output_file_format_changed (GtkPrinterOption *format_option,
gpointer user_data)
{
GtkPrinterOption *uri_option;
- gchar *base = NULL;
+ char *base = NULL;
_OutputFormatChangedData *data = (_OutputFormatChangedData *) user_data;
if (! format_option->value)
@@ -585,12 +585,12 @@ file_printer_output_file_format_changed (GtkPrinterOption *format_option,
if (uri_option && uri_option->value)
{
- const gchar *uri = uri_option->value;
- const gchar *dot = strrchr (uri, '.');
+ const char *uri = uri_option->value;
+ const char *dot = strrchr (uri, '.');
if (dot)
{
- gint i;
+ int i;
/* check if the file extension matches one of the known ones */
for (i = 0; i < N_FORMATS; i++)
@@ -614,7 +614,7 @@ file_printer_output_file_format_changed (GtkPrinterOption *format_option,
if (base)
{
- gchar *tmp = g_strdup_printf ("%s.%s", base, format_option->value);
+ char *tmp = g_strdup_printf ("%s.%s", base, format_option->value);
gtk_printer_option_set (uri_option, tmp);
g_free (tmp);
@@ -632,15 +632,15 @@ file_printer_get_options (GtkPrinter *printer,
{
GtkPrinterOptionSet *set;
GtkPrinterOption *option;
- const gchar *n_up[] = {"1", "2", "4", "6", "9", "16" };
- const gchar *pages_per_sheet = NULL;
- const gchar *format_names[N_FORMATS] = { N_("PDF"), N_("PostScript"), N_("SVG") };
- const gchar *supported_formats[N_FORMATS];
- gchar *display_format_names[N_FORMATS];
- gint n_formats = 0;
+ const char *n_up[] = {"1", "2", "4", "6", "9", "16" };
+ const char *pages_per_sheet = NULL;
+ const char *format_names[N_FORMATS] = { N_("PDF"), N_("PostScript"), N_("SVG") };
+ const char *supported_formats[N_FORMATS];
+ const char *display_format_names[N_FORMATS];
+ int n_formats = 0;
OutputFormat format;
- gchar *uri;
- gint current_format = 0;
+ char *uri;
+ int current_format = 0;
_OutputFormatChangedData *format_changed_data;
format = format_from_settings (settings);
@@ -649,7 +649,7 @@ file_printer_get_options (GtkPrinter *printer,
option = gtk_printer_option_new ("gtk-n-up", _("Pages per _sheet:"), GTK_PRINTER_OPTION_TYPE_PICKONE);
gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
- (char **) n_up, (char **) n_up /* FIXME i18n (localised digits)! */);
+ n_up, n_up /* FIXME i18n (localised digits)! */);
if (settings)
pages_per_sheet = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_NUMBER_UP);
if (pages_per_sheet)
@@ -686,6 +686,7 @@ file_printer_get_options (GtkPrinter *printer,
switch (format)
{
default:
+ case N_FORMATS:
case FORMAT_PDF:
current_format = FORMAT_PDF;
break;
@@ -721,8 +722,8 @@ file_printer_get_options (GtkPrinter *printer,
option->group = g_strdup ("GtkPrintDialogExtension");
gtk_printer_option_choices_from_array (option, n_formats,
- (char **) supported_formats,
- display_format_names);
+ supported_formats,
+ display_format_names);
gtk_printer_option_set (option, supported_formats[current_format]);
gtk_printer_option_set_add (set, option);
@@ -769,10 +770,10 @@ file_printer_prepare_for_print (GtkPrinter *printer,
GtkPrintSettings *settings,
GtkPageSetup *page_setup)
{
- gdouble scale;
+ double scale;
GtkPrintPages pages;
GtkPageRange *ranges;
- gint n_ranges;
+ int n_ranges;
OutputFormat format;
pages = gtk_print_settings_get_print_pages (settings);
@@ -803,6 +804,7 @@ file_printer_prepare_for_print (GtkPrinter *printer,
switch (format)
{
case FORMAT_PDF:
+ case N_FORMATS:
gtk_print_job_set_rotate (print_job, FALSE);
break;
default:
diff --git a/modules/printbackends/gtkprintbackendfile.h b/modules/printbackends/gtkprintbackendfile.h
index b4ae41a15c..0ca051b5ff 100644
--- a/modules/printbackends/gtkprintbackendfile.h
+++ b/modules/printbackends/gtkprintbackendfile.h
@@ -21,7 +21,7 @@
#define __GTK_PRINT_BACKEND_FILE_H__
#include <glib-object.h>
-#include "gtkprintbackend.h"
+#include "gtkprintbackendprivate.h"
G_BEGIN_DECLS
diff --git a/modules/printbackends/gtkprintbackendlpr.c b/modules/printbackends/gtkprintbackendlpr.c
index af1e101124..2d50971bfc 100644
--- a/modules/printbackends/gtkprintbackendlpr.c
+++ b/modules/printbackends/gtkprintbackendlpr.c
@@ -32,7 +32,7 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include "gtkprinter-private.h"
+#include "gtkprinterprivate.h"
#include "gtkprintbackendlpr.h"
@@ -56,8 +56,6 @@ struct _GtkPrintBackendLpr
static GObjectClass *backend_parent_class;
-static void gtk_print_backend_lpr_class_init (GtkPrintBackendLprClass *class);
-static void gtk_print_backend_lpr_init (GtkPrintBackendLpr *impl);
static void lpr_printer_get_settings_from_options (GtkPrinter *printer,
GtkPrinterOptionSet *options,
GtkPrintSettings *settings);
@@ -71,8 +69,8 @@ static void lpr_printer_prepare_for_print (GtkPrinter
GtkPageSetup *page_setup);
static cairo_surface_t * lpr_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io);
static void gtk_print_backend_lpr_print_stream (GtkPrintBackend *print_backend,
GtkPrintJob *job,
@@ -158,16 +156,16 @@ _cairo_write (void *closure,
error = NULL;
GTK_NOTE (PRINTING,
- g_print ("LPR Backend: Writting %i byte chunk to temp file\n", length));
+ g_print ("LPR Backend: Writing %i byte chunk to temp file\n", length));
while (length > 0)
{
- g_io_channel_write_chars (io, (const gchar*)data, length, &written, &error);
+ g_io_channel_write_chars (io, (const char *)data, length, &written, &error);
if (error != NULL)
{
GTK_NOTE (PRINTING,
- g_print ("LPR Backend: Error writting to temp file, %s\n", error->message));
+ g_print ("LPR Backend: Error writing to temp file, %s\n", error->message));
g_error_free (error);
return CAIRO_STATUS_WRITE_ERROR;
@@ -186,8 +184,8 @@ _cairo_write (void *closure,
static cairo_surface_t *
lpr_printer_create_cairo_surface (GtkPrinter *printer,
GtkPrintSettings *settings,
- gdouble width,
- gdouble height,
+ double width,
+ double height,
GIOChannel *cache_io)
{
cairo_surface_t *surface;
@@ -242,7 +240,7 @@ lpr_write (GIOChannel *source,
GIOCondition con,
gpointer user_data)
{
- gchar buf[_LPR_MAX_CHUNK_SIZE];
+ char buf[_LPR_MAX_CHUNK_SIZE];
gsize bytes_read;
GError *error;
GIOStatus status;
@@ -286,7 +284,7 @@ lpr_write (GIOChannel *source,
}
GTK_NOTE (PRINTING,
- g_print ("LPR Backend: Writting %" G_GSIZE_FORMAT " byte chunk to lpr pipe\n", bytes_read));
+ g_print ("LPR Backend: Writing %" G_GSIZE_FORMAT " byte chunk to lpr pipe\n", bytes_read));
return TRUE;
@@ -305,9 +303,9 @@ gtk_print_backend_lpr_print_stream (GtkPrintBackend *print_backend,
GError *print_error = NULL;
_PrintStreamData *ps;
GtkPrintSettings *settings;
- gint argc;
- gint in_fd;
- gchar **argv = NULL;
+ int argc;
+ int in_fd;
+ char **argv = NULL;
const char *cmd_line;
settings = gtk_print_job_get_settings (job);
@@ -454,7 +452,7 @@ lpr_printer_prepare_for_print (GtkPrinter *printer,
double scale;
GtkPrintPages pages;
GtkPageRange *ranges;
- gint n_ranges;
+ int n_ranges;
pages = gtk_print_settings_get_print_pages (settings);
gtk_print_job_set_pages (print_job, pages);
diff --git a/modules/printbackends/gtkprintbackendlpr.h b/modules/printbackends/gtkprintbackendlpr.h
index 0ba195bebd..ea8c849521 100644
--- a/modules/printbackends/gtkprintbackendlpr.h
+++ b/modules/printbackends/gtkprintbackendlpr.h
@@ -21,7 +21,7 @@
#define __GTK_PRINT_BACKEND_LPR_H__
#include <glib-object.h>
-#include "gtkprintbackend.h"
+#include "gtkprintbackendprivate.h"
G_BEGIN_DECLS
diff --git a/modules/printbackends/gtkprintercloudprint.c b/modules/printbackends/gtkprintercloudprint.c
index 4f299fdcab..306aa6360d 100644
--- a/modules/printbackends/gtkprintercloudprint.c
+++ b/modules/printbackends/gtkprintercloudprint.c
@@ -43,7 +43,7 @@ struct _GtkPrinterCloudprint
GtkPrinter parent_instance;
GtkCloudprintAccount *account;
- gchar *id;
+ char *id;
};
enum {
@@ -109,7 +109,7 @@ gtk_printer_cloudprint_new (const char *name,
gboolean is_virtual,
GtkPrintBackend *backend,
GtkCloudprintAccount *account,
- const gchar *id)
+ const char *id)
{
return g_object_new (GTK_TYPE_PRINTER_CLOUDPRINT,
"name", name,
diff --git a/modules/printbackends/gtkprintercloudprint.h b/modules/printbackends/gtkprintercloudprint.h
index 564fb150be..0d44caabe9 100644
--- a/modules/printbackends/gtkprintercloudprint.h
+++ b/modules/printbackends/gtkprintercloudprint.h
@@ -20,7 +20,7 @@
#define __GTK_PRINTER_CLOUDPRINT_H__
#include <glib-object.h>
-#include <gtk/gtkprinter-private.h>
+#include <gtk/gtkprinterprivate.h>
#include "gtkcloudprintaccount.h"
@@ -35,7 +35,7 @@ GtkPrinterCloudprint *gtk_printer_cloudprint_new (const char *name,
gboolean is_virtual,
GtkPrintBackend *backend,
GtkCloudprintAccount *account,
- const gchar *id);
+ const char *id);
GType gtk_printer_cloudprint_get_type (void) G_GNUC_CONST;
G_END_DECLS
diff --git a/modules/printbackends/gtkprintercups.c b/modules/printbackends/gtkprintercups.c
index b97da61805..83d2b0aabd 100644
--- a/modules/printbackends/gtkprintercups.c
+++ b/modules/printbackends/gtkprintercups.c
@@ -105,6 +105,10 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
printer->state = 0;
printer->hostname = NULL;
printer->port = 0;
+ printer->original_hostname = NULL;
+ printer->original_resource = NULL;
+ printer->original_port = 0;
+ printer->request_original_uri = FALSE;
printer->ppd_name = NULL;
printer->ppd_file = NULL;
printer->default_cover_before = NULL;
@@ -115,12 +119,10 @@ gtk_printer_cups_init (GtkPrinterCups *printer)
printer->remote_cups_connection_test = NULL;
printer->auth_info_required = NULL;
printer->default_number_up = 1;
-#ifdef HAVE_CUPS_API_1_6
printer->avahi_browsed = FALSE;
printer->avahi_name = NULL;
printer->avahi_type = NULL;
printer->avahi_domain = NULL;
-#endif
printer->ipp_version_major = 1;
printer->ipp_version_minor = 1;
printer->supports_copies = FALSE;
@@ -155,6 +157,8 @@ gtk_printer_cups_finalize (GObject *object)
g_free (printer->original_device_uri);
g_free (printer->printer_uri);
g_free (printer->hostname);
+ g_free (printer->original_hostname);
+ g_free (printer->original_resource);
g_free (printer->ppd_name);
g_free (printer->default_cover_before);
g_free (printer->default_cover_after);
@@ -176,17 +180,19 @@ gtk_printer_cups_finalize (GObject *object)
g_object_unref (printer->colord_profile);
#endif
-#ifdef HAVE_CUPS_API_1_6
g_free (printer->avahi_name);
g_free (printer->avahi_type);
g_free (printer->avahi_domain);
-#endif
g_strfreev (printer->covers);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
if (printer->ppd_file)
ppdClose (printer->ppd_file);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
g_free (printer->media_default);
g_list_free_full (printer->media_supported, g_free);
g_list_free_full (printer->media_size_supported, g_free);
@@ -253,7 +259,7 @@ gtk_printer_cups_get_property (GObject *object,
static void
colord_update_ui_from_settings (GtkPrinterCups *printer)
{
- const gchar *title = NULL;
+ const char *title = NULL;
/* not yet connected to colord */
if (printer->colord_client == NULL)
@@ -367,10 +373,10 @@ gtk_printer_cups_update_settings (GtkPrinterCups *printer,
GtkPrintSettings *settings,
GtkPrinterOptionSet *set)
{
- gchar *qualifier = NULL;
- gchar **qualifiers = NULL;
+ char *qualifier = NULL;
+ char **qualifiers = NULL;
GtkPrinterOption *option;
- const gchar *format[3];
+ const char *format[3];
/* nothing set yet */
if (printer->colord_device == NULL)
@@ -414,7 +420,7 @@ gtk_printer_cups_update_settings (GtkPrinterCups *printer,
qualifiers = g_strsplit (qualifier, ",", -1);
cd_device_get_profile_for_qualifiers (printer->colord_device,
- (const gchar **) qualifiers,
+ (const char **) qualifiers,
printer->colord_cancellable,
colord_client_device_get_profile_for_qualifiers_cb,
g_object_ref (printer));
@@ -491,7 +497,7 @@ out:
static void
colord_update_device (GtkPrinterCups *printer)
{
- gchar *colord_device_id = NULL;
+ char *colord_device_id = NULL;
/* not yet connected to the daemon */
if (!cd_client_get_connected (printer->colord_client))
@@ -634,10 +640,10 @@ gtk_printer_cups_get_ppd (GtkPrinterCups *printer)
return printer->ppd_file;
}
-const gchar *
+const char *
gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer)
{
- const gchar *result;
+ const char *result;
result = printer->ppd_name;
diff --git a/modules/printbackends/gtkprintercups.h b/modules/printbackends/gtkprintercups.h
index f26bbab677..83109b24cd 100644
--- a/modules/printbackends/gtkprintercups.h
+++ b/modules/printbackends/gtkprintercups.h
@@ -24,7 +24,7 @@
#include "gtkcupsutils.h"
#include <gtk/gtkunixprint.h>
-#include <gtk/gtkprinter-private.h>
+#include <gtk/gtkprinterprivate.h>
#ifdef HAVE_COLORD
#include <colord.h>
@@ -47,54 +47,59 @@ struct _GtkPrinterCups
{
GtkPrinter parent_instance;
- gchar *device_uri;
- gchar *original_device_uri;
- gchar *printer_uri;
- gchar *hostname;
- gint port;
- gchar **auth_info_required;
+ char *device_uri;
+ char *original_device_uri;
+ char *printer_uri;
+ char *hostname;
+ int port;
+ char **auth_info_required;
+ char *original_hostname;
+ char *original_resource;
+ int original_port;
+ gboolean request_original_uri; /* Request PPD from original host */
ipp_pstate_t state;
gboolean reading_ppd;
- gchar *ppd_name;
+ char *ppd_name;
ppd_file_t *ppd_file;
- gchar *media_default;
+ char *media_default;
GList *media_supported;
GList *media_size_supported;
- gint media_bottom_margin_default;
- gint media_top_margin_default;
- gint media_left_margin_default;
- gint media_right_margin_default;
+ int media_bottom_margin_default;
+ int media_top_margin_default;
+ int media_left_margin_default;
+ int media_right_margin_default;
gboolean media_margin_default_set;
- gchar *sides_default;
+ char *sides_default;
GList *sides_supported;
- gchar *output_bin_default;
+ char *output_bin_default;
GList *output_bin_supported;
- gchar *default_cover_before;
- gchar *default_cover_after;
+ char *default_cover_before;
+ char *default_cover_after;
- gint default_number_up;
+ int default_number_up;
gboolean remote;
guint get_remote_ppd_poll;
- gint get_remote_ppd_attempts;
+ int get_remote_ppd_attempts;
GtkCupsConnectionTest *remote_cups_connection_test;
+
#ifdef HAVE_COLORD
CdClient *colord_client;
CdDevice *colord_device;
CdProfile *colord_profile;
GCancellable *colord_cancellable;
- gchar *colord_title;
- gchar *colord_qualifier;
+ char *colord_title;
+ char *colord_qualifier;
#endif
-#ifdef HAVE_CUPS_API_1_6
+
gboolean avahi_browsed;
- gchar *avahi_name;
- gchar *avahi_type;
- gchar *avahi_domain;
-#endif
+ char *avahi_name;
+ char *avahi_type;
+ char *avahi_domain;
+
guchar ipp_version_major;
guchar ipp_version_minor;
gboolean supports_copies;
@@ -117,7 +122,7 @@ GtkPrinterCups *gtk_printer_cups_new (const char *name,
GtkPrintBackend *backend,
gpointer colord_client);
ppd_file_t *gtk_printer_cups_get_ppd (GtkPrinterCups *printer);
-const gchar *gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer);
+const char *gtk_printer_cups_get_ppd_name (GtkPrinterCups *printer);
#ifdef HAVE_COLORD
void gtk_printer_cups_update_settings (GtkPrinterCups *printer,
diff --git a/modules/printbackends/meson.build b/modules/printbackends/meson.build
index 338bf6a602..1cde173493 100644
--- a/modules/printbackends/meson.build
+++ b/modules/printbackends/meson.build
@@ -3,7 +3,7 @@ all_print_backends = [
'cloudprint',
]
-enabled_print_backends = get_option('print-backends').split(',')
+enabled_print_backends = get_option('print').split(',')
if enabled_print_backends.contains('none')
enabled_print_backends = []
@@ -14,42 +14,14 @@ endif
# The 'file' print backend cannot be disabled
print_backends = ['file']
-# Checks to see if we should compile with CUPS backend for GTK+
+# Checks to see if we should compile with CUPS backend for GTK
enable_cups = enabled_print_backends.contains('cups')
if enable_cups
- #cups_config = find_program('cups-config', required : true)
- #if cups_config.found()
- # FIXME: eek, see configure.ac (we're just not going to support non-standar prefix for now)
- #endif
- if cc.has_header('cups/cups.h')
- # TODO: include_directories from cups-config
- cups_major_version = cc.compute_int('CUPS_VERSION_MAJOR', prefix : '#include <cups/cups.h>')
- cups_minor_version = cc.compute_int('CUPS_VERSION_MINOR', prefix : '#include <cups/cups.h>')
- message('Found CUPS version: @0@.@1@'.format(cups_major_version, cups_minor_version))
- if cups_major_version > 1 or cups_minor_version >= 2
- if cups_major_version > 1 or cups_minor_version >= 6
- cdata.set('HAVE_CUPS_API_1_6', 1)
- endif
-
- if cc.compiles('#include <cups/http.h> \n http_t http; char *s = http.authstring;')
- cdata.set('HAVE_HTTP_AUTHSTRING', 1,
- description :'Define if cups http_t authstring field is accessible')
- endif
- libcups = cc.find_library('cups', required : true)
- if libcups.found() and cc.has_function('httpGetAuthString', dependencies : libcups)
- cdata.set('HAVE_HTTPGETAUTHSTRING', 1)
- endif
-
- print_backends += ['cups']
- else
- error('Need CUPS version >= 1.2')
- endif
- else
- error('Cannot find CUPS headers in default prefix.')
- endif
+ cups_dep = dependency('cups', version : '>=2.0', required: true)
+ print_backends += ['cups']
endif
-# Checks to see if we should compile with cloudprint backend for GTK+
+# Checks to see if we should compile with cloudprint backend for GTK
enable_cloudprint = enabled_print_backends.contains('cloudprint')
if enable_cloudprint
rest_dep = dependency('rest-0.7', required : true)
@@ -82,21 +54,12 @@ printbackends_install_dir = join_paths(get_option('libdir'), printbackends_subdi
cdata.set_quoted('GTK_PRINT_BACKENDS', ','.join(print_backends))
-
-enable_colord = get_option('colord')
-if enable_colord != 'no'
- want_colord = enable_colord == 'yes'
- colord_dep = dependency('colord', version: '>= 0.1.9', required: want_colord)
- cdata.set('HAVE_COLORD', colord_dep.found())
-else
- colord_dep = []
-endif
-
printbackends_args = [
'-DGTK_COMPILATION',
'-DGTK_DISABLE_DEPRECATION_WARNINGS',
'-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
-]
+ '-D_GLIB_EXTERN=@0@'.format(visibility_define),
+] + common_cflags
if print_backends.contains('cups')
shared_module('printbackend-cups',
@@ -105,7 +68,7 @@ if print_backends.contains('cups')
'gtkcupsutils.c',
'gtkcupssecretsutils.c',
c_args: printbackends_args,
- dependencies: [libgtk_dep, libcups, colord_dep],
+ dependencies: [libgtk_dep, cups_dep, colord_dep],
install_dir: printbackends_install_dir,
install : true)
endif