Merge lp:~robert-ancell/unity-settings-daemon/no-xdg-desktop into lp:unity-settings-daemon

Proposed by Robert Ancell
Status: Rejected
Rejected by: Robert Ancell
Proposed branch: lp:~robert-ancell/unity-settings-daemon/no-xdg-desktop
Merge into: lp:unity-settings-daemon
Diff against target: 3279 lines (+2/-3176)
13 files modified
configure.ac (+0/-46)
debian/control (+0/-1)
gnome-settings-daemon/gnome-settings-plugin-info.c (+0/-29)
plugins/Makefile.am (+0/-6)
plugins/keyboard/gsd-keyboard-manager.c (+1/-2)
plugins/print-notifications/Makefile.am (+0/-87)
plugins/print-notifications/gsd-print-notifications-manager.c (+0/-1467)
plugins/print-notifications/gsd-print-notifications-manager.h (+0/-57)
plugins/print-notifications/gsd-print-notifications-plugin.c (+0/-29)
plugins/print-notifications/gsd-printer.c (+0/-1403)
plugins/print-notifications/print-notifications.gnome-settings-plugin.in (+0/-10)
plugins/print-notifications/test-print-notifications.c (+0/-7)
plugins/xsettings/gsd-xsettings-manager.c (+1/-32)
To merge this branch: bzr merge lp:~robert-ancell/unity-settings-daemon/no-xdg-desktop
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Fixing
Review via email: mp+288724@code.launchpad.net

Commit message

Drop usage of XDG_CURRENT_DESKTOP - we should always expect to be in Unity.

This means we can drop the disabled print notification plugin.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks but there is an issue there, at least the display scaling changes are needed for the greeter, unity handles that correctly but unity-greeter doesn't without the code you deleted. Otherwise +1 on removing the print plugin since we don't use it

review: Needs Fixing
Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Robert Ancell (robert-ancell) wrote :
Revision history for this message
Robert Ancell (robert-ancell) wrote :

Instead of removing the scaling check, I fixed it to correctly check XDG_CURRENT_DESKTOP:
https://code.launchpad.net/~robert-ancell/unity-settings-daemon/xdg-current-desktop/+merge/289105

Unmerged revisions

4133. By Robert Ancell

Drop usage of XDG_CURRENT_DESKTOP - we should always expect to be in Unity.

This means we can drop the disabled print notification plugin.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2015-02-12 15:37:32 +0000
3+++ configure.ac 2016-03-10 23:12:09 +0000
4@@ -375,52 +375,6 @@
5
6 AC_SUBST(NSS_DATABASE)
7
8-
9-# ---------------------------------------------------------------------------
10-# CUPS
11-# ---------------------------------------------------------------------------
12-
13-AC_ARG_ENABLE(cups,
14- AS_HELP_STRING([--disable-cups], [disable CUPS support (default: enabled)]),,
15- enable_cups=yes)
16-
17-if test x"$enable_cups" != x"no" ; then
18- AC_PROG_SED
19-
20- AC_PATH_PROG(CUPS_CONFIG, cups-config)
21-
22- if test x$CUPS_CONFIG = x; then
23- AC_MSG_ERROR([cups-config not found but CUPS support requested])
24- fi
25-
26- CUPS_API_VERSION=`$CUPS_CONFIG --api-version`
27- CUPS_API_MAJOR=`echo $ECHO_N $CUPS_API_VERSION | cut -d . -f 1`
28- CUPS_API_MINOR=`echo $ECHO_N $CUPS_API_VERSION | cut -d . -f 2`
29-
30- AC_CHECK_HEADERS([cups/cups.h cups/http.h cups/ipp.h],,
31- AC_MSG_ERROR([CUPS headers not found but CUPS support requested]))
32-
33- if ! test $CUPS_API_MAJOR -gt 1 -o \
34- $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 4 ; then
35- AC_MSG_ERROR([CUPS 1.4 or newer not found, but CUPS support requested])
36- fi
37-
38- # https://bugzilla.gnome.org/show_bug.cgi?id=696571
39- CUPS_CPPFLAGS=""
40- if test $CUPS_API_MAJOR -gt 1 -o \
41- $CUPS_API_MAJOR -eq 1 -a $CUPS_API_MINOR -ge 6 ; then
42- CUPS_CPPFLAGS=-D_PPD_DEPRECATED=""
43- fi
44-
45- CUPS_CFLAGS=`$CUPS_CONFIG --cflags | $SED -e 's/-O\w*//g' -e 's/-m\w*//g'`
46- CUPS_LIBS=`$CUPS_CONFIG --libs`
47- AC_SUBST(CUPS_CPPFLAGS)
48- AC_SUBST(CUPS_CFLAGS)
49- AC_SUBST(CUPS_LIBS)
50-fi
51-
52-AM_CONDITIONAL(BUILD_PRINT_NOTIFICATIONS, [test x"$enable_cups" = x"yes"])
53-
54 # ---------------------------------------------------------------------------
55 # Enable Profiling
56 # ---------------------------------------------------------------------------
57
58=== modified file 'debian/control'
59--- debian/control 2016-01-29 18:10:00 +0000
60+++ debian/control 2016-03-10 23:12:09 +0000
61@@ -25,7 +25,6 @@
62 libasound2-dev,
63 librsvg2-dev (>= 2.36.2),
64 libcanberra-gtk3-dev,
65- libcups2-dev,
66 libpolkit-gobject-1-dev,
67 libaccountsservice-dev (>= 0.6.34),
68 libappindicator3-dev (>= 0.4.90),
69
70=== modified file 'gnome-settings-daemon/gnome-settings-plugin-info.c'
71--- gnome-settings-daemon/gnome-settings-plugin-info.c 2013-11-13 01:45:23 +0000
72+++ gnome-settings-daemon/gnome-settings-plugin-info.c 2016-03-10 23:12:09 +0000
73@@ -381,35 +381,6 @@
74 goto out;
75 }
76
77- if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0
78- && g_strcmp0 (info->priv->name, "Print-notifications") == 0) {
79-
80- g_warning ("Disable print plugin under Unity");
81-
82- g_object_unref (G_OBJECT (info->priv->module));
83- info->priv->module = NULL;
84-
85- /* Mark plugin as unavailable */
86- info->priv->available = FALSE;
87-
88- goto out;
89- }
90-
91- if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "GNOME") == 0
92- && g_strcmp0 (info->priv->name, "Background") == 0) {
93-
94- g_warning ("Disable background plugin when under gnome-shell");
95-
96- g_object_unref (G_OBJECT (info->priv->module));
97- info->priv->module = NULL;
98-
99- /* Mark plugin as unavailable */
100- info->priv->available = FALSE;
101-
102- goto out;
103- }
104-
105-
106 info->priv->plugin = GNOME_SETTINGS_PLUGIN (gnome_settings_module_new_object (GNOME_SETTINGS_MODULE (info->priv->module)));
107
108 g_type_module_unuse (info->priv->module);
109
110=== modified file 'plugins/Makefile.am'
111--- plugins/Makefile.am 2013-11-13 01:59:14 +0000
112+++ plugins/Makefile.am 2016-03-10 23:12:09 +0000
113@@ -47,11 +47,5 @@
114 disabled_plugins += wacom
115 endif
116
117-if BUILD_PRINT_NOTIFICATIONS
118-enabled_plugins += print-notifications
119-else
120-disabled_plugins += print-notifications
121-endif
122-
123 SUBDIRS = common $(enabled_plugins)
124 DIST_SUBDIRS = $(SUBDIRS) $(disabled_plugins)
125
126=== modified file 'plugins/keyboard/gsd-keyboard-manager.c'
127--- plugins/keyboard/gsd-keyboard-manager.c 2016-01-21 10:58:12 +0000
128+++ plugins/keyboard/gsd-keyboard-manager.c 2016-03-10 23:12:09 +0000
129@@ -1001,8 +1001,7 @@
130 * and doesn't call us so we can't set the group switching XKB
131 * option in the first place otherwise the X server's switch
132 * will take effect and we get a broken configuration. */
133- if (n_sources < 2 || g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
134- strip_xkb_option (options, "grp:");
135+ strip_xkb_option (options, "grp:");
136
137 options_str = build_xkb_options_string (options);
138 g_strfreev (options);
139
140=== removed directory 'plugins/print-notifications'
141=== removed file 'plugins/print-notifications/Makefile.am'
142--- plugins/print-notifications/Makefile.am 2013-12-04 23:55:26 +0000
143+++ plugins/print-notifications/Makefile.am 1970-01-01 00:00:00 +0000
144@@ -1,87 +0,0 @@
145-plugin_name = print-notifications
146-
147-plugin_LTLIBRARIES = \
148- libprint-notifications.la
149-
150-libprint_notifications_la_SOURCES = \
151- gsd-print-notifications-manager.c \
152- gsd-print-notifications-manager.h \
153- gsd-print-notifications-plugin.c
154-
155-libprint_notifications_la_CPPFLAGS = \
156- -I$(top_srcdir)/gnome-settings-daemon \
157- -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
158- -DLIBEXECDIR=\""$(libexecdir)"\" \
159- $(AM_CPPFLAGS) \
160- $(CUPS_CPPFLAGS)
161-
162-libprint_notifications_la_CFLAGS = \
163- $(PLUGIN_CFLAGS) \
164- $(SETTINGS_PLUGIN_CFLAGS) \
165- $(AM_CFLAGS)
166-
167-libprint_notifications_la_LDFLAGS = \
168- $(GSD_PLUGIN_LDFLAGS)
169-
170-libprint_notifications_la_LIBADD = \
171- $(CUPS_LIBS) \
172- $(SETTINGS_PLUGIN_LIBS)
173-
174-plugin_in_files = \
175- print-notifications.gnome-settings-plugin.in
176-
177-plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
178-
179-libexec_PROGRAMS = usd-printer
180-
181-usd_printer_SOURCES = \
182- gsd-printer.c
183-
184-usd_printer_CFLAGS = \
185- $(SETTINGS_PLUGIN_CFLAGS) \
186- $(LIBNOTIFY_CFLAGS) \
187- -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
188- $(AM_CFLAGS)
189-
190-usd_printer_LDADD = \
191- $(SETTINGS_PLUGIN_LIBS) \
192- $(CUPS_LIBS) \
193- $(LIBNOTIFY_LIBS)
194-
195-libexec_PROGRAMS += usd-test-print-notifications
196-
197-usd_test_print_notifications_SOURCES = \
198- gsd-print-notifications-manager.c \
199- gsd-print-notifications-manager.h \
200- test-print-notifications.c
201-
202-usd_test_print_notifications_CPPFLAGS = \
203- -I$(top_srcdir)/gnome-settings-daemon \
204- -I$(top_srcdir)/plugins/common \
205- -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
206- -DLIBEXECDIR=\""$(libexecdir)"\" \
207- $(AM_CPPFLAGS) \
208- $(CUPS_CPPFLAGS)
209-
210-usd_test_print_notifications_CFLAGS = \
211- $(PLUGIN_CFLAGS) \
212- $(SETTINGS_PLUGIN_CFLAGS) \
213- $(AM_CFLAGS)
214-
215-usd_test_print_notifications_LDADD = \
216- $(top_builddir)/gnome-settings-daemon/libgsd.la \
217- $(SETTINGS_DAEMON_LIBS) \
218- $(SETTINGS_PLUGIN_LIBS) \
219- $(CUPS_LIBS) \
220- $(LIBNOTIFY_LIBS)
221-
222-EXTRA_DIST = \
223- $(plugin_in_files)
224-
225-CLEANFILES = \
226- $(plugin_DATA)
227-
228-DISTCLEANFILES = \
229- $(plugin_DATA)
230-
231-@GSD_INTLTOOL_PLUGIN_RULE@
232
233=== removed file 'plugins/print-notifications/gsd-print-notifications-manager.c'
234--- plugins/print-notifications/gsd-print-notifications-manager.c 2013-12-04 23:55:26 +0000
235+++ plugins/print-notifications/gsd-print-notifications-manager.c 1970-01-01 00:00:00 +0000
236@@ -1,1467 +0,0 @@
237-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
238- *
239- * Copyright (C) 2011 Red Hat, Inc.
240- *
241- * This program is free software; you can redistribute it and/or modify
242- * it under the terms of the GNU General Public License as published by
243- * the Free Software Foundation; either version 2 of the License, or
244- * (at your option) any later version.
245- *
246- * This program is distributed in the hope that it will be useful,
247- * but WITHOUT ANY WARRANTY; without even the implied warranty of
248- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
249- * GNU General Public License for more details.
250- *
251- * You should have received a copy of the GNU General Public License
252- * along with this program; if not, write to the Free Software
253- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
254- *
255- */
256-
257-#include "config.h"
258-
259-#include <sys/types.h>
260-#include <sys/wait.h>
261-#include <stdlib.h>
262-#include <stdio.h>
263-#include <unistd.h>
264-#include <string.h>
265-#include <errno.h>
266-
267-#include <locale.h>
268-
269-#include <glib.h>
270-#include <glib/gi18n.h>
271-#include <glib/gstdio.h>
272-
273-#include <cups/cups.h>
274-#include <cups/ppd.h>
275-#include <libnotify/notify.h>
276-
277-#include "gnome-settings-profile.h"
278-#include "gsd-print-notifications-manager.h"
279-
280-#define GSD_PRINT_NOTIFICATIONS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER, GsdPrintNotificationsManagerPrivate))
281-
282-#define CUPS_DBUS_NAME "org.cups.cupsd.Notifier"
283-#define CUPS_DBUS_PATH "/org/cups/cupsd/Notifier"
284-#define CUPS_DBUS_INTERFACE "org.cups.cupsd.Notifier"
285-
286-#define RENEW_INTERVAL 3500
287-#define SUBSCRIPTION_DURATION 3600
288-#define CONNECTING_TIMEOUT 60
289-#define REASON_TIMEOUT 15000
290-#define CUPS_CONNECTION_TEST_INTERVAL 300
291-#define CHECK_INTERVAL 60 /* secs */
292-
293-#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
294-#define HAVE_CUPS_1_6 1
295-#endif
296-
297-#ifndef HAVE_CUPS_1_6
298-#define ippGetStatusCode(ipp) ipp->request.status.status_code
299-#define ippGetInteger(attr, element) attr->values[element].integer
300-#define ippGetString(attr, element, language) attr->values[element].string.text
301-#define ippGetName(attr) attr->name
302-#define ippGetCount(attr) attr->num_values
303-#define ippGetBoolean(attr, index) attr->values[index].boolean
304-
305-static ipp_attribute_t *
306-ippNextAttribute (ipp_t *ipp)
307-{
308- if (!ipp || !ipp->current)
309- return (NULL);
310- return (ipp->current = ipp->current->next);
311-}
312-#endif
313-
314-struct GsdPrintNotificationsManagerPrivate
315-{
316- GDBusConnection *cups_bus_connection;
317- gint subscription_id;
318- cups_dest_t *dests;
319- gint num_dests;
320- gboolean scp_handler_spawned;
321- GPid scp_handler_pid;
322- GList *timeouts;
323- GHashTable *printing_printers;
324- GList *active_notifications;
325- guint cups_connection_timeout_id;
326- guint check_source_id;
327- guint cups_dbus_subscription_id;
328- guint renew_source_id;
329- gint last_notify_sequence_number;
330-};
331-
332-enum {
333- PROP_0,
334-};
335-
336-static void gsd_print_notifications_manager_class_init (GsdPrintNotificationsManagerClass *klass);
337-static void gsd_print_notifications_manager_init (GsdPrintNotificationsManager *print_notifications_manager);
338-static void gsd_print_notifications_manager_finalize (GObject *object);
339-static gboolean cups_connection_test (gpointer user_data);
340-static gboolean process_new_notifications (gpointer user_data);
341-
342-G_DEFINE_TYPE (GsdPrintNotificationsManager, gsd_print_notifications_manager, G_TYPE_OBJECT)
343-
344-static gpointer manager_object = NULL;
345-
346-static char *
347-get_dest_attr (const char *dest_name,
348- const char *attr,
349- cups_dest_t *dests,
350- int num_dests)
351-{
352- cups_dest_t *dest;
353- const char *value;
354- char *ret;
355-
356- if (dest_name == NULL)
357- return NULL;
358-
359- ret = NULL;
360-
361- dest = cupsGetDest (dest_name, NULL, num_dests, dests);
362- if (dest == NULL) {
363- g_debug ("Unable to find a printer named '%s'", dest_name);
364- goto out;
365- }
366-
367- value = cupsGetOption (attr, dest->num_options, dest->options);
368- if (value == NULL) {
369- g_debug ("Unable to get %s for '%s'", attr, dest_name);
370- goto out;
371- }
372- ret = g_strdup (value);
373- out:
374- return ret;
375-}
376-
377-static gboolean
378-is_local_dest (const char *name,
379- cups_dest_t *dests,
380- int num_dests)
381-{
382- char *type_str;
383- cups_ptype_t type;
384- gboolean is_remote;
385-
386- is_remote = TRUE;
387-
388- type_str = get_dest_attr (name, "printer-type", dests, num_dests);
389- if (type_str == NULL) {
390- goto out;
391- }
392-
393- type = atoi (type_str);
394- is_remote = type & (CUPS_PRINTER_REMOTE | CUPS_PRINTER_IMPLICIT);
395- g_free (type_str);
396- out:
397- return !is_remote;
398-}
399-
400-static gboolean
401-server_is_local (const gchar *server_name)
402-{
403- if (server_name != NULL &&
404- (g_ascii_strncasecmp (server_name, "localhost", 9) == 0 ||
405- g_ascii_strncasecmp (server_name, "127.0.0.1", 9) == 0 ||
406- g_ascii_strncasecmp (server_name, "::1", 3) == 0 ||
407- server_name[0] == '/')) {
408- return TRUE;
409- } else {
410- return FALSE;
411- }
412-}
413-
414-static int
415-strcmp0(const void *a, const void *b)
416-{
417- return g_strcmp0 (*((gchar **) a), *((gchar **) b));
418-}
419-
420-struct
421-{
422- gchar *printer_name;
423- gchar *primary_text;
424- gchar *secondary_text;
425- guint timeout_id;
426- GsdPrintNotificationsManager *manager;
427-} typedef TimeoutData;
428-
429-struct
430-{
431- gchar *printer_name;
432- gchar *reason;
433- NotifyNotification *notification;
434- gulong notification_close_id;
435- GsdPrintNotificationsManager *manager;
436-} typedef ReasonData;
437-
438-static void
439-free_timeout_data (gpointer user_data)
440-{
441- TimeoutData *data = (TimeoutData *) user_data;
442-
443- if (data) {
444- g_free (data->printer_name);
445- g_free (data->primary_text);
446- g_free (data->secondary_text);
447- g_free (data);
448- }
449-}
450-
451-static void
452-free_reason_data (gpointer user_data)
453-{
454- ReasonData *data = (ReasonData *) user_data;
455-
456- if (data) {
457- if (data->notification_close_id > 0 &&
458- g_signal_handler_is_connected (data->notification,
459- data->notification_close_id))
460- g_signal_handler_disconnect (data->notification, data->notification_close_id);
461-
462- g_object_unref (data->notification);
463-
464- g_free (data->printer_name);
465- g_free (data->reason);
466-
467- g_free (data);
468- }
469-}
470-
471-static void
472-notification_closed_cb (NotifyNotification *notification,
473- gpointer user_data)
474-{
475- ReasonData *data = (ReasonData *) user_data;
476-
477- if (data) {
478- data->manager->priv->active_notifications =
479- g_list_remove (data->manager->priv->active_notifications, data);
480-
481- free_reason_data (data);
482- }
483-}
484-
485-static gboolean
486-show_notification (gpointer user_data)
487-{
488- NotifyNotification *notification;
489- TimeoutData *data = (TimeoutData *) user_data;
490- ReasonData *reason_data;
491- GList *tmp;
492-
493- if (!data)
494- return FALSE;
495-
496- notification = notify_notification_new (data->primary_text,
497- data->secondary_text,
498- "printer-symbolic");
499-
500- notify_notification_set_app_name (notification, _("Printers"));
501- notify_notification_set_hint (notification,
502- "resident",
503- g_variant_new_boolean (TRUE));
504- notify_notification_set_timeout (notification, REASON_TIMEOUT);
505-
506- reason_data = g_new0 (ReasonData, 1);
507- reason_data->printer_name = g_strdup (data->printer_name);
508- reason_data->reason = g_strdup ("connecting-to-device");
509- reason_data->notification = notification;
510- reason_data->manager = data->manager;
511-
512- reason_data->notification_close_id =
513- g_signal_connect (notification,
514- "closed",
515- G_CALLBACK (notification_closed_cb),
516- reason_data);
517-
518- reason_data->manager->priv->active_notifications =
519- g_list_append (reason_data->manager->priv->active_notifications, reason_data);
520-
521- notify_notification_show (notification, NULL);
522-
523- tmp = g_list_find (data->manager->priv->timeouts, data);
524- if (tmp) {
525- data->manager->priv->timeouts = g_list_remove_link (data->manager->priv->timeouts, tmp);
526- g_list_free_full (tmp, free_timeout_data);
527- }
528-
529- return FALSE;
530-}
531-
532-static gboolean
533-reason_is_blacklisted (const gchar *reason) {
534- if (g_str_equal (reason, "none"))
535- return TRUE;
536- if (g_str_equal (reason, "other"))
537- return TRUE;
538- if (g_str_equal (reason, "com.apple.print.recoverable"))
539- return TRUE;
540- /* https://bugzilla.redhat.com/show_bug.cgi?id=883401 */
541- if (g_str_has_prefix (reason, "cups-remote-"))
542- return TRUE;
543- return FALSE;
544-}
545-
546-static void
547-on_cups_notification (GDBusConnection *connection,
548- const char *sender_name,
549- const char *object_path,
550- const char *interface_name,
551- const char *signal_name,
552- GVariant *parameters,
553- gpointer user_data)
554-{
555- process_new_notifications (user_data);
556-}
557-
558-static void
559-process_cups_notification (GsdPrintNotificationsManager *manager,
560- const char *notify_subscribed_event,
561- const char *notify_text,
562- const char *notify_printer_uri,
563- const char *printer_name,
564- gint printer_state,
565- const char *printer_state_reasons,
566- gboolean printer_is_accepting_jobs,
567- guint notify_job_id,
568- gint job_state,
569- const char *job_state_reasons,
570- const char *job_name,
571- gint job_impressions_completed)
572-{
573- ipp_attribute_t *attr;
574- gboolean my_job = FALSE;
575- gboolean known_reason;
576- http_t *http;
577- gchar *primary_text = NULL;
578- gchar *secondary_text = NULL;
579- gchar *job_uri = NULL;
580- ipp_t *request, *response;
581- static const char * const reasons[] = {
582- "toner-low",
583- "toner-empty",
584- /*"connecting-to-device",*/
585- "cover-open",
586- "cups-missing-filter",
587- "door-open",
588- "marker-supply-low",
589- "marker-supply-empty",
590- "media-low",
591- "media-empty",
592- "offline",
593- "other"};
594-
595- static const char * statuses_first[] = {
596- /* Translators: The printer is low on toner (same as in system-config-printer) */
597- N_("Toner low"),
598- /* Translators: The printer has no toner left (same as in system-config-printer) */
599- N_("Toner empty"),
600- /* Translators: The printer is in the process of connecting to a shared network output device (same as in system-config-printer) */
601- /*N_("Not connected?"),*/
602- /* Translators: One or more covers on the printer are open (same as in system-config-printer) */
603- N_("Cover open"),
604- /* Translators: A filter or backend is not installed (same as in system-config-printer) */
605- N_("Printer configuration error"),
606- /* Translators: One or more doors on the printer are open (same as in system-config-printer) */
607- N_("Door open"),
608- /* Translators: "marker" is one color bin of the printer */
609- N_("Marker supply low"),
610- /* Translators: "marker" is one color bin of the printer */
611- N_("Out of a marker supply"),
612- /* Translators: At least one input tray is low on media (same as in system-config-printer) */
613- N_("Paper low"),
614- /* Translators: At least one input tray is empty (same as in system-config-printer) */
615- N_("Out of paper"),
616- /* Translators: The printer is offline (same as in system-config-printer) */
617- N_("Printer off-line"),
618- /* Translators: The printer has detected an error (same as in system-config-printer) */
619- N_("Printer error") };
620-
621- static const char * statuses_second[] = {
622- /* Translators: The printer is low on toner (same as in system-config-printer) */
623- N_("Printer '%s' is low on toner."),
624- /* Translators: The printer has no toner left (same as in system-config-printer) */
625- N_("Printer '%s' has no toner left."),
626- /* Translators: The printer is in the process of connecting to a shared network output device (same as in system-config-printer) */
627- /*N_("Printer '%s' may not be connected."),*/
628- /* Translators: One or more covers on the printer are open (same as in system-config-printer) */
629- N_("The cover is open on printer '%s'."),
630- /* Translators: A filter or backend is not installed (same as in system-config-printer) */
631- N_("There is a missing print filter for "
632- "printer '%s'."),
633- /* Translators: One or more doors on the printer are open (same as in system-config-printer) */
634- N_("The door is open on printer '%s'."),
635- /* Translators: "marker" is one color bin of the printer */
636- N_("Printer '%s' is low on a marker supply."),
637- /* Translators: "marker" is one color bin of the printer */
638- N_("Printer '%s' is out of a marker supply."),
639- /* Translators: At least one input tray is low on media (same as in system-config-printer) */
640- N_("Printer '%s' is low on paper."),
641- /* Translators: At least one input tray is empty (same as in system-config-printer) */
642- N_("Printer '%s' is out of paper."),
643- /* Translators: The printer is offline (same as in system-config-printer) */
644- N_("Printer '%s' is currently off-line."),
645- /* Translators: The printer has detected an error (same as in system-config-printer) */
646- N_("There is a problem on printer '%s'.") };
647-
648- if (g_strcmp0 (notify_subscribed_event, "printer-added") != 0 &&
649- g_strcmp0 (notify_subscribed_event, "printer-deleted") != 0 &&
650- g_strcmp0 (notify_subscribed_event, "printer-state-changed") != 0 &&
651- g_strcmp0 (notify_subscribed_event, "job-completed") != 0 &&
652- g_strcmp0 (notify_subscribed_event, "job-state-changed") != 0 &&
653- g_strcmp0 (notify_subscribed_event, "job-created") != 0)
654- return;
655-
656- if (notify_job_id > 0) {
657- if ((http = httpConnectEncrypt (cupsServer (), ippPort (),
658- cupsEncryption ())) == NULL) {
659- g_debug ("Connection to CUPS server \'%s\' failed.", cupsServer ());
660- } else {
661- job_uri = g_strdup_printf ("ipp://localhost/jobs/%d", notify_job_id);
662-
663- request = ippNewRequest (IPP_GET_JOB_ATTRIBUTES);
664- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
665- "job-uri", NULL, job_uri);
666- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
667- "requesting-user-name", NULL, cupsUser ());
668- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
669- "requested-attributes", NULL, "job-originating-user-name");
670- response = cupsDoRequest (http, request, "/");
671-
672- if (response) {
673- if (ippGetStatusCode (response) <= IPP_OK_CONFLICT &&
674- (attr = ippFindAttribute(response, "job-originating-user-name",
675- IPP_TAG_NAME))) {
676- if (g_strcmp0 (ippGetString (attr, 0, NULL), cupsUser ()) == 0)
677- my_job = TRUE;
678- }
679- ippDelete(response);
680- }
681- g_free (job_uri);
682- }
683- }
684-
685- if (g_strcmp0 (notify_subscribed_event, "printer-added") == 0) {
686- cupsFreeDests (manager->priv->num_dests, manager->priv->dests);
687- manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
688-
689- if (is_local_dest (printer_name,
690- manager->priv->dests,
691- manager->priv->num_dests)) {
692- /* Translators: New printer has been added */
693- primary_text = g_strdup (_("Printer added"));
694- secondary_text = g_strdup (printer_name);
695- }
696- } else if (g_strcmp0 (notify_subscribed_event, "printer-deleted") == 0) {
697- if (is_local_dest (printer_name,
698- manager->priv->dests,
699- manager->priv->num_dests)) {
700- /* Translators: A printer has been removed */
701- primary_text = g_strdup (_("Printer removed"));
702- secondary_text = g_strdup (printer_name);
703- }
704-
705- cupsFreeDests (manager->priv->num_dests, manager->priv->dests);
706- manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
707- } else if (g_strcmp0 (notify_subscribed_event, "job-completed") == 0 && my_job) {
708- g_hash_table_remove (manager->priv->printing_printers,
709- printer_name);
710-
711- switch (job_state) {
712- case IPP_JOB_PENDING:
713- case IPP_JOB_HELD:
714- case IPP_JOB_PROCESSING:
715- break;
716- case IPP_JOB_STOPPED:
717- /* Translators: A print job has been stopped */
718- primary_text = g_strdup (_("Printing stopped"));
719- /* Translators: "print-job xy" on a printer */
720- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
721- break;
722- case IPP_JOB_CANCELED:
723- /* Translators: A print job has been canceled */
724- primary_text = g_strdup (_("Printing canceled"));
725- /* Translators: "print-job xy" on a printer */
726- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
727- break;
728- case IPP_JOB_ABORTED:
729- /* Translators: A print job has been aborted */
730- primary_text = g_strdup (_("Printing aborted"));
731- /* Translators: "print-job xy" on a printer */
732- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
733- break;
734- case IPP_JOB_COMPLETED:
735- /* Translators: A print job has been completed */
736- primary_text = g_strdup (_("Printing completed"));
737- /* Translators: "print-job xy" on a printer */
738- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
739- break;
740- }
741- } else if (g_strcmp0 (notify_subscribed_event, "job-state-changed") == 0 && my_job) {
742- switch (job_state) {
743- case IPP_JOB_PROCESSING:
744- g_hash_table_insert (manager->priv->printing_printers,
745- g_strdup (printer_name), NULL);
746-
747- /* Translators: A job is printing */
748- primary_text = g_strdup (_("Printing"));
749- /* Translators: "print-job xy" on a printer */
750- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
751- break;
752- case IPP_JOB_STOPPED:
753- g_hash_table_remove (manager->priv->printing_printers,
754- printer_name);
755- /* Translators: A print job has been stopped */
756- primary_text = g_strdup (_("Printing stopped"));
757- /* Translators: "print-job xy" on a printer */
758- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
759- break;
760- case IPP_JOB_CANCELED:
761- g_hash_table_remove (manager->priv->printing_printers,
762- printer_name);
763- /* Translators: A print job has been canceled */
764- primary_text = g_strdup (_("Printing canceled"));
765- /* Translators: "print-job xy" on a printer */
766- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
767- break;
768- case IPP_JOB_ABORTED:
769- g_hash_table_remove (manager->priv->printing_printers,
770- printer_name);
771- /* Translators: A print job has been aborted */
772- primary_text = g_strdup (_("Printing aborted"));
773- /* Translators: "print-job xy" on a printer */
774- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
775- break;
776- case IPP_JOB_COMPLETED:
777- g_hash_table_remove (manager->priv->printing_printers,
778- printer_name);
779- /* Translators: A print job has been completed */
780- primary_text = g_strdup (_("Printing completed"));
781- /* Translators: "print-job xy" on a printer */
782- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
783- break;
784- default:
785- break;
786- }
787- } else if (g_strcmp0 (notify_subscribed_event, "job-created") == 0 && my_job) {
788- if (job_state == IPP_JOB_PROCESSING) {
789- g_hash_table_insert (manager->priv->printing_printers,
790- g_strdup (printer_name), NULL);
791-
792- /* Translators: A job is printing */
793- primary_text = g_strdup (_("Printing"));
794- /* Translators: "print-job xy" on a printer */
795- secondary_text = g_strdup_printf (_("\"%s\" on %s"), job_name, printer_name);
796- }
797- } else if (g_strcmp0 (notify_subscribed_event, "printer-state-changed") == 0) {
798- cups_dest_t *dest = NULL;
799- const gchar *tmp_printer_state_reasons = NULL;
800- GSList *added_reasons = NULL;
801- GSList *tmp_list = NULL;
802- GList *tmp;
803- gchar **old_state_reasons = NULL;
804- gchar **new_state_reasons = NULL;
805- gint i, j;
806-
807- /* Remove timeout which shows notification about possible disconnection of printer
808- * if "connecting-to-device" has vanished.
809- */
810- if (printer_state_reasons == NULL ||
811- g_strrstr (printer_state_reasons, "connecting-to-device") == NULL) {
812- TimeoutData *data;
813-
814- for (tmp = manager->priv->timeouts; tmp; tmp = g_list_next (tmp)) {
815- data = (TimeoutData *) tmp->data;
816- if (g_strcmp0 (printer_name, data->printer_name) == 0) {
817- g_source_remove (data->timeout_id);
818- manager->priv->timeouts = g_list_remove_link (manager->priv->timeouts, tmp);
819- g_list_free_full (tmp, free_timeout_data);
820- break;
821- }
822- }
823- }
824-
825- for (tmp = manager->priv->active_notifications; tmp; tmp = g_list_next (tmp)) {
826- ReasonData *reason_data = (ReasonData *) tmp->data;
827- GList *remove_list;
828-
829- if (printer_state_reasons == NULL ||
830- (g_strcmp0 (printer_name, reason_data->printer_name) == 0 &&
831- g_strrstr (printer_state_reasons, reason_data->reason) == NULL)) {
832-
833- if (reason_data->notification_close_id > 0 &&
834- g_signal_handler_is_connected (reason_data->notification,
835- reason_data->notification_close_id)) {
836- g_signal_handler_disconnect (reason_data->notification,
837- reason_data->notification_close_id);
838- reason_data->notification_close_id = 0;
839- }
840-
841- notify_notification_close (reason_data->notification, NULL);
842-
843- remove_list = tmp;
844- tmp = g_list_next (tmp);
845- manager->priv->active_notifications =
846- g_list_remove_link (manager->priv->active_notifications, remove_list);
847-
848- g_list_free_full (remove_list, free_reason_data);
849- }
850- }
851-
852- /* Check whether we are printing on this printer right now. */
853- if (g_hash_table_lookup_extended (manager->priv->printing_printers, printer_name, NULL, NULL)) {
854- dest = cupsGetDest (printer_name,
855- NULL,
856- manager->priv->num_dests,
857- manager->priv->dests);
858- if (dest)
859- tmp_printer_state_reasons = cupsGetOption ("printer-state-reasons",
860- dest->num_options,
861- dest->options);
862-
863- if (tmp_printer_state_reasons)
864- old_state_reasons = g_strsplit (tmp_printer_state_reasons, ",", -1);
865-
866- cupsFreeDests (manager->priv->num_dests, manager->priv->dests);
867- manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
868-
869- dest = cupsGetDest (printer_name,
870- NULL,
871- manager->priv->num_dests,
872- manager->priv->dests);
873- if (dest)
874- tmp_printer_state_reasons = cupsGetOption ("printer-state-reasons",
875- dest->num_options,
876- dest->options);
877-
878- if (tmp_printer_state_reasons)
879- new_state_reasons = g_strsplit (tmp_printer_state_reasons, ",", -1);
880-
881- if (new_state_reasons)
882- qsort (new_state_reasons,
883- g_strv_length (new_state_reasons),
884- sizeof (gchar *),
885- strcmp0);
886-
887- if (old_state_reasons) {
888- qsort (old_state_reasons,
889- g_strv_length (old_state_reasons),
890- sizeof (gchar *),
891- strcmp0);
892-
893- j = 0;
894- for (i = 0; new_state_reasons && i < g_strv_length (new_state_reasons); i++) {
895- while (old_state_reasons[j] &&
896- g_strcmp0 (old_state_reasons[j], new_state_reasons[i]) < 0)
897- j++;
898-
899- if (old_state_reasons[j] == NULL ||
900- g_strcmp0 (old_state_reasons[j], new_state_reasons[i]) != 0)
901- added_reasons = g_slist_append (added_reasons,
902- new_state_reasons[i]);
903- }
904- } else {
905- for (i = 0; new_state_reasons && i < g_strv_length (new_state_reasons); i++) {
906- added_reasons = g_slist_append (added_reasons,
907- new_state_reasons[i]);
908- }
909- }
910-
911- for (tmp_list = added_reasons; tmp_list; tmp_list = tmp_list->next) {
912- gchar *data = (gchar *) tmp_list->data;
913- known_reason = FALSE;
914- for (j = 0; j < G_N_ELEMENTS (reasons); j++) {
915- if (strncmp (data,
916- reasons[j],
917- strlen (reasons[j])) == 0) {
918- NotifyNotification *notification;
919- known_reason = TRUE;
920-
921- if (g_strcmp0 (reasons[j], "connecting-to-device") == 0) {
922- TimeoutData *data;
923-
924- data = g_new0 (TimeoutData, 1);
925- data->printer_name = g_strdup (printer_name);
926- data->primary_text = g_strdup ( _(statuses_first[j]));
927- data->secondary_text = g_strdup_printf ( _(statuses_second[j]), printer_name);
928- data->manager = manager;
929-
930- data->timeout_id = g_timeout_add_seconds (CONNECTING_TIMEOUT, show_notification, data);
931- manager->priv->timeouts = g_list_append (manager->priv->timeouts, data);
932- } else {
933- ReasonData *reason_data;
934- gchar *second_row = g_strdup_printf ( _(statuses_second[j]), printer_name);
935-
936- notification = notify_notification_new ( _(statuses_first[j]),
937- second_row,
938- "printer-symbolic");
939- notify_notification_set_app_name (notification, _("Printers"));
940- notify_notification_set_hint (notification,
941- "resident",
942- g_variant_new_boolean (TRUE));
943- notify_notification_set_timeout (notification, REASON_TIMEOUT);
944-
945- reason_data = g_new0 (ReasonData, 1);
946- reason_data->printer_name = g_strdup (printer_name);
947- reason_data->reason = g_strdup (reasons[j]);
948- reason_data->notification = notification;
949- reason_data->manager = manager;
950-
951- reason_data->notification_close_id =
952- g_signal_connect (notification,
953- "closed",
954- G_CALLBACK (notification_closed_cb),
955- reason_data);
956-
957- manager->priv->active_notifications =
958- g_list_append (manager->priv->active_notifications, reason_data);
959-
960- notify_notification_show (notification, NULL);
961-
962- g_free (second_row);
963- }
964- }
965- }
966-
967- if (!known_reason &&
968- !reason_is_blacklisted (data)) {
969- NotifyNotification *notification;
970- ReasonData *reason_data;
971- gchar *first_row;
972- gchar *second_row;
973- gchar *text = NULL;
974- gchar *ppd_file_name;
975- ppd_file_t *ppd_file;
976- char buffer[8192];
977-
978- ppd_file_name = g_strdup (cupsGetPPD (printer_name));
979- if (ppd_file_name) {
980- ppd_file = ppdOpenFile (ppd_file_name);
981- if (ppd_file) {
982- gchar **tmpv;
983- static const char * const schemes[] = {
984- "text", "http", "help", "file"
985- };
986-
987- tmpv = g_new0 (gchar *, G_N_ELEMENTS (schemes) + 1);
988- i = 0;
989- for (j = 0; j < G_N_ELEMENTS (schemes); j++) {
990- if (ppdLocalizeIPPReason (ppd_file, data, schemes[j], buffer, sizeof (buffer))) {
991- tmpv[i++] = g_strdup (buffer);
992- }
993- }
994-
995- if (i > 0)
996- text = g_strjoinv (", ", tmpv);
997- g_strfreev (tmpv);
998-
999- ppdClose (ppd_file);
1000- }
1001-
1002- g_unlink (ppd_file_name);
1003- g_free (ppd_file_name);
1004- }
1005-
1006-
1007- if (g_str_has_suffix (data, "-report"))
1008- /* Translators: This is a title of a report notification for a printer */
1009- first_row = g_strdup (_("Printer report"));
1010- else if (g_str_has_suffix (data, "-warning"))
1011- /* Translators: This is a title of a warning notification for a printer */
1012- first_row = g_strdup (_("Printer warning"));
1013- else
1014- /* Translators: This is a title of an error notification for a printer */
1015- first_row = g_strdup (_("Printer error"));
1016-
1017-
1018- if (text == NULL)
1019- text = g_strdup (data);
1020-
1021- /* Translators: "Printer 'MyPrinterName': 'Description of the report/warning/error from a PPD file'." */
1022- second_row = g_strdup_printf (_("Printer '%s': '%s'."), printer_name, text);
1023- g_free (text);
1024-
1025-
1026- notification = notify_notification_new (first_row,
1027- second_row,
1028- "printer-symbolic");
1029- notify_notification_set_app_name (notification, _("Printers"));
1030- notify_notification_set_hint (notification,
1031- "resident",
1032- g_variant_new_boolean (TRUE));
1033- notify_notification_set_timeout (notification, REASON_TIMEOUT);
1034-
1035- reason_data = g_new0 (ReasonData, 1);
1036- reason_data->printer_name = g_strdup (printer_name);
1037- reason_data->reason = g_strdup (data);
1038- reason_data->notification = notification;
1039- reason_data->manager = manager;
1040-
1041- reason_data->notification_close_id =
1042- g_signal_connect (notification,
1043- "closed",
1044- G_CALLBACK (notification_closed_cb),
1045- reason_data);
1046-
1047- manager->priv->active_notifications =
1048- g_list_append (manager->priv->active_notifications, reason_data);
1049-
1050- notify_notification_show (notification, NULL);
1051-
1052- g_free (first_row);
1053- g_free (second_row);
1054- }
1055- }
1056- g_slist_free (added_reasons);
1057- }
1058-
1059- if (new_state_reasons)
1060- g_strfreev (new_state_reasons);
1061-
1062- if (old_state_reasons)
1063- g_strfreev (old_state_reasons);
1064- }
1065-
1066-
1067- if (primary_text) {
1068- NotifyNotification *notification;
1069- notification = notify_notification_new (primary_text,
1070- secondary_text,
1071- "printer-symbolic");
1072- notify_notification_set_app_name (notification, _("Printers"));
1073- notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
1074- notify_notification_show (notification, NULL);
1075- g_object_unref (notification);
1076- g_free (primary_text);
1077- g_free (secondary_text);
1078- }
1079-}
1080-
1081-static gboolean
1082-process_new_notifications (gpointer user_data)
1083-{
1084- GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) user_data;
1085- ipp_attribute_t *attr;
1086- const gchar *notify_subscribed_event = NULL;
1087- const gchar *printer_name = NULL;
1088- const gchar *notify_text = NULL;
1089- const gchar *notify_printer_uri = NULL;
1090- const gchar *job_state_reasons = NULL;
1091- const gchar *job_name = NULL;
1092- const char *attr_name;
1093- gboolean printer_is_accepting_jobs = FALSE;
1094- gchar *printer_state_reasons = NULL;
1095- gchar **reasons;
1096- guint notify_job_id = 0;
1097- ipp_t *request;
1098- ipp_t *response;
1099- gint printer_state = -1;
1100- gint job_state = -1;
1101- gint job_impressions_completed = -1;
1102- gint notify_sequence_number = -1;
1103- gint i;
1104-
1105- request = ippNewRequest (IPP_GET_NOTIFICATIONS);
1106-
1107- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1108- "requesting-user-name", NULL, cupsUser ());
1109-
1110- ippAddInteger (request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
1111- "notify-subscription-ids", manager->priv->subscription_id);
1112-
1113- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
1114- "/printers/");
1115-
1116- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI, "job-uri", NULL,
1117- "/jobs/");
1118-
1119- ippAddInteger (request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
1120- "notify-sequence-numbers",
1121- manager->priv->last_notify_sequence_number + 1);
1122-
1123-
1124- response = cupsDoRequest (CUPS_HTTP_DEFAULT, request, "/");
1125-
1126-
1127- for (attr = ippFindAttribute (response, "notify-sequence-number", IPP_TAG_INTEGER);
1128- attr != NULL;
1129- attr = ippNextAttribute (response)) {
1130-
1131- attr_name = ippGetName (attr);
1132- if (g_strcmp0 (attr_name, "notify-sequence-number") == 0) {
1133- notify_sequence_number = ippGetInteger (attr, 0);
1134-
1135- if (notify_sequence_number > manager->priv->last_notify_sequence_number)
1136- manager->priv->last_notify_sequence_number = notify_sequence_number;
1137-
1138- if (notify_subscribed_event != NULL) {
1139- process_cups_notification (manager,
1140- notify_subscribed_event,
1141- notify_text,
1142- notify_printer_uri,
1143- printer_name,
1144- printer_state,
1145- printer_state_reasons,
1146- printer_is_accepting_jobs,
1147- notify_job_id,
1148- job_state,
1149- job_state_reasons,
1150- job_name,
1151- job_impressions_completed);
1152-
1153- g_clear_pointer (&printer_state_reasons, g_free);
1154- g_clear_pointer (&job_state_reasons, g_free);
1155- }
1156-
1157- notify_subscribed_event = NULL;
1158- notify_text = NULL;
1159- notify_printer_uri = NULL;
1160- printer_name = NULL;
1161- printer_state = -1;
1162- printer_state_reasons = NULL;
1163- printer_is_accepting_jobs = FALSE;
1164- notify_job_id = 0;
1165- job_state = -1;
1166- job_state_reasons = NULL;
1167- job_name = NULL;
1168- job_impressions_completed = -1;
1169- } else if (g_strcmp0 (attr_name, "notify-subscribed-event") == 0) {
1170- notify_subscribed_event = ippGetString (attr, 0, NULL);
1171- } else if (g_strcmp0 (attr_name, "notify-text") == 0) {
1172- notify_text = ippGetString (attr, 0, NULL);
1173- } else if (g_strcmp0 (attr_name, "notify-printer-uri") == 0) {
1174- notify_printer_uri = ippGetString (attr, 0, NULL);
1175- } else if (g_strcmp0 (attr_name, "printer-name") == 0) {
1176- printer_name = ippGetString (attr, 0, NULL);
1177- } else if (g_strcmp0 (attr_name, "printer-state") == 0) {
1178- printer_state = ippGetInteger (attr, 0);
1179- } else if (g_strcmp0 (attr_name, "printer-state-reasons") == 0) {
1180- reasons = g_new0 (gchar *, ippGetCount (attr) + 1);
1181- for (i = 0; i < ippGetCount (attr); i++)
1182- reasons[i] = g_strdup (ippGetString (attr, i, NULL));
1183- printer_state_reasons = g_strjoinv (",", reasons);
1184- g_strfreev (reasons);
1185- } else if (g_strcmp0 (attr_name, "printer-is-accepting-jobs") == 0) {
1186- printer_is_accepting_jobs = ippGetBoolean (attr, 0);
1187- } else if (g_strcmp0 (attr_name, "notify-job-id") == 0) {
1188- notify_job_id = ippGetInteger (attr, 0);
1189- } else if (g_strcmp0 (attr_name, "job-state") == 0) {
1190- job_state = ippGetInteger (attr, 0);
1191- } else if (g_strcmp0 (attr_name, "job-state-reasons") == 0) {
1192- reasons = g_new0 (gchar *, ippGetCount (attr) + 1);
1193- for (i = 0; i < ippGetCount (attr); i++)
1194- reasons[i] = g_strdup (ippGetString (attr, i, NULL));
1195- job_state_reasons = g_strjoinv (",", reasons);
1196- g_strfreev (reasons);
1197- } else if (g_strcmp0 (attr_name, "job-name") == 0) {
1198- job_name = ippGetString (attr, 0, NULL);
1199- } else if (g_strcmp0 (attr_name, "job-impressions-completed") == 0) {
1200- job_impressions_completed = ippGetInteger (attr, 0);
1201- }
1202- }
1203-
1204- if (notify_subscribed_event != NULL) {
1205- process_cups_notification (manager,
1206- notify_subscribed_event,
1207- notify_text,
1208- notify_printer_uri,
1209- printer_name,
1210- printer_state,
1211- printer_state_reasons,
1212- printer_is_accepting_jobs,
1213- notify_job_id,
1214- job_state,
1215- job_state_reasons,
1216- job_name,
1217- job_impressions_completed);
1218-
1219- g_clear_pointer (&printer_state_reasons, g_free);
1220- g_clear_pointer (&job_state_reasons, g_free);
1221- }
1222-
1223- if (response != NULL)
1224- ippDelete (response);
1225-
1226- return TRUE;
1227-}
1228-
1229-static void
1230-scp_handler (GsdPrintNotificationsManager *manager,
1231- gboolean start)
1232-{
1233- if (start) {
1234- GError *error = NULL;
1235- char *args[2];
1236-
1237- if (manager->priv->scp_handler_spawned)
1238- return;
1239-
1240- args[0] = LIBEXECDIR "/usd-printer";
1241- args[1] = NULL;
1242-
1243- g_spawn_async (NULL, args, NULL,
1244- 0, NULL, NULL,
1245- &manager->priv->scp_handler_pid, &error);
1246-
1247- manager->priv->scp_handler_spawned = (error == NULL);
1248-
1249- if (error) {
1250- g_warning ("Could not execute system-config-printer-udev handler: %s",
1251- error->message);
1252- g_error_free (error);
1253- }
1254- } else if (manager->priv->scp_handler_spawned) {
1255- kill (manager->priv->scp_handler_pid, SIGHUP);
1256- g_spawn_close_pid (manager->priv->scp_handler_pid);
1257- manager->priv->scp_handler_spawned = FALSE;
1258- }
1259-}
1260-
1261-static void
1262-cancel_subscription (gint id)
1263-{
1264- http_t *http;
1265- ipp_t *request;
1266-
1267- if (id >= 0 &&
1268- ((http = httpConnectEncrypt (cupsServer (), ippPort (),
1269- cupsEncryption ())) != NULL)) {
1270- request = ippNewRequest (IPP_CANCEL_SUBSCRIPTION);
1271- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
1272- "printer-uri", NULL, "/");
1273- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1274- "requesting-user-name", NULL, cupsUser ());
1275- ippAddInteger (request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
1276- "notify-subscription-id", id);
1277- ippDelete (cupsDoRequest (http, request, "/"));
1278- }
1279-}
1280-
1281-static gboolean
1282-renew_subscription (gpointer data)
1283-{
1284- GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) data;
1285- ipp_attribute_t *attr = NULL;
1286- http_t *http;
1287- ipp_t *request;
1288- ipp_t *response;
1289- gint num_events = 7;
1290- static const char * const events[] = {
1291- "job-created",
1292- "job-completed",
1293- "job-state-changed",
1294- "job-state",
1295- "printer-added",
1296- "printer-deleted",
1297- "printer-state-changed"};
1298-
1299- if ((http = httpConnectEncrypt (cupsServer (), ippPort (),
1300- cupsEncryption ())) == NULL) {
1301- g_debug ("Connection to CUPS server \'%s\' failed.", cupsServer ());
1302- } else {
1303- if (manager->priv->subscription_id >= 0) {
1304- request = ippNewRequest (IPP_RENEW_SUBSCRIPTION);
1305- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
1306- "printer-uri", NULL, "/");
1307- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1308- "requesting-user-name", NULL, cupsUser ());
1309- ippAddInteger (request, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
1310- "notify-subscription-id", manager->priv->subscription_id);
1311- ippAddInteger (request, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
1312- "notify-lease-duration", SUBSCRIPTION_DURATION);
1313- ippDelete (cupsDoRequest (http, request, "/"));
1314- } else {
1315- request = ippNewRequest (IPP_CREATE_PRINTER_SUBSCRIPTION);
1316- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_URI,
1317- "printer-uri", NULL,
1318- "/");
1319- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME,
1320- "requesting-user-name", NULL, cupsUser ());
1321- ippAddStrings (request, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD,
1322- "notify-events", num_events, NULL, events);
1323- ippAddString (request, IPP_TAG_SUBSCRIPTION, IPP_TAG_KEYWORD,
1324- "notify-pull-method", NULL, "ippget");
1325- if (server_is_local (cupsServer ())) {
1326- ippAddString (request, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
1327- "notify-recipient-uri", NULL, "dbus://");
1328- }
1329- ippAddInteger (request, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
1330- "notify-lease-duration", SUBSCRIPTION_DURATION);
1331- response = cupsDoRequest (http, request, "/");
1332-
1333- if (response != NULL && ippGetStatusCode (response) <= IPP_OK_CONFLICT) {
1334- if ((attr = ippFindAttribute (response, "notify-subscription-id",
1335- IPP_TAG_INTEGER)) == NULL)
1336- g_debug ("No notify-subscription-id in response!\n");
1337- else
1338- manager->priv->subscription_id = ippGetInteger (attr, 0);
1339- }
1340-
1341- if (response)
1342- ippDelete (response);
1343- }
1344- httpClose (http);
1345- }
1346- return TRUE;
1347-}
1348-
1349-static void
1350-renew_subscription_with_connection_test_cb (GObject *source_object,
1351- GAsyncResult *res,
1352- gpointer user_data)
1353-{
1354- GSocketConnection *connection;
1355- GError *error = NULL;
1356-
1357- connection = g_socket_client_connect_to_host_finish (G_SOCKET_CLIENT (source_object),
1358- res,
1359- &error);
1360-
1361- if (connection) {
1362- g_debug ("Test connection to CUPS server \'%s:%d\' succeeded.", cupsServer (), ippPort ());
1363-
1364- g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
1365- g_object_unref (connection);
1366-
1367- renew_subscription (user_data);
1368- } else {
1369- g_debug ("Test connection to CUPS server \'%s:%d\' failed.", cupsServer (), ippPort ());
1370- }
1371-}
1372-
1373-static gboolean
1374-renew_subscription_with_connection_test (gpointer user_data)
1375-{
1376- GSocketClient *client;
1377- gchar *address;
1378- int port;
1379-
1380- port = ippPort ();
1381-
1382- address = g_strdup_printf ("%s:%d", cupsServer (), port);
1383-
1384- if (address && address[0] != '/') {
1385- client = g_socket_client_new ();
1386-
1387- g_debug ("Initiating test connection to CUPS server \'%s:%d\'.", cupsServer (), port);
1388-
1389- g_socket_client_connect_to_host_async (client,
1390- address,
1391- port,
1392- NULL,
1393- renew_subscription_with_connection_test_cb,
1394- user_data);
1395-
1396- g_object_unref (client);
1397- } else {
1398- renew_subscription (user_data);
1399- }
1400-
1401- g_free (address);
1402-
1403- return TRUE;
1404-}
1405-
1406-static void
1407-renew_subscription_timeout_enable (GsdPrintNotificationsManager *manager,
1408- gboolean enable,
1409- gboolean with_connection_test)
1410-{
1411- if (manager->priv->renew_source_id > 0)
1412- g_source_remove (manager->priv->renew_source_id);
1413-
1414- if (enable) {
1415- renew_subscription (manager);
1416- if (with_connection_test)
1417- manager->priv->renew_source_id =
1418- g_timeout_add_seconds (RENEW_INTERVAL,
1419- renew_subscription_with_connection_test,
1420- manager);
1421- else
1422- manager->priv->renew_source_id =
1423- g_timeout_add_seconds (RENEW_INTERVAL,
1424- renew_subscription,
1425- manager);
1426- } else {
1427- manager->priv->renew_source_id = 0;
1428- }
1429-}
1430-
1431-static void
1432-cups_connection_test_cb (GObject *source_object,
1433- GAsyncResult *res,
1434- gpointer user_data)
1435-{
1436- GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) user_data;
1437- GSocketConnection *connection;
1438- GError *error = NULL;
1439-
1440- connection = g_socket_client_connect_to_host_finish (G_SOCKET_CLIENT (source_object),
1441- res,
1442- &error);
1443-
1444- if (connection) {
1445- g_debug ("Test connection to CUPS server \'%s:%d\' succeeded.", cupsServer (), ippPort ());
1446-
1447- g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
1448- g_object_unref (connection);
1449-
1450- manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
1451- g_debug ("Got dests from remote CUPS server.");
1452-
1453- renew_subscription_timeout_enable (manager, TRUE, TRUE);
1454- manager->priv->check_source_id = g_timeout_add_seconds (CHECK_INTERVAL, process_new_notifications, manager);
1455- } else {
1456- g_debug ("Test connection to CUPS server \'%s:%d\' failed.", cupsServer (), ippPort ());
1457- if (manager->priv->cups_connection_timeout_id == 0)
1458- manager->priv->cups_connection_timeout_id =
1459- g_timeout_add_seconds (CUPS_CONNECTION_TEST_INTERVAL, cups_connection_test, manager);
1460- }
1461-}
1462-
1463-static gboolean
1464-cups_connection_test (gpointer user_data)
1465-{
1466- GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) user_data;
1467- GSocketClient *client;
1468- gchar *address;
1469- int port = ippPort ();
1470-
1471- if (!manager->priv->dests) {
1472- address = g_strdup_printf ("%s:%d", cupsServer (), port);
1473-
1474- client = g_socket_client_new ();
1475-
1476- g_debug ("Initiating test connection to CUPS server \'%s:%d\'.", cupsServer (), port);
1477-
1478- g_socket_client_connect_to_host_async (client,
1479- address,
1480- port,
1481- NULL,
1482- cups_connection_test_cb,
1483- manager);
1484-
1485- g_object_unref (client);
1486- g_free (address);
1487- }
1488-
1489- if (manager->priv->dests) {
1490- manager->priv->cups_connection_timeout_id = 0;
1491-
1492- return FALSE;
1493- } else {
1494- return TRUE;
1495- }
1496-}
1497-
1498-static void
1499-gsd_print_notifications_manager_got_dbus_connection (GObject *source_object,
1500- GAsyncResult *res,
1501- gpointer user_data)
1502-{
1503- GsdPrintNotificationsManager *manager = (GsdPrintNotificationsManager *) user_data;
1504- GError *error = NULL;
1505-
1506- manager->priv->cups_bus_connection = g_bus_get_finish (res, &error);
1507-
1508- if (manager->priv->cups_bus_connection != NULL) {
1509- manager->priv->cups_dbus_subscription_id =
1510- g_dbus_connection_signal_subscribe (manager->priv->cups_bus_connection,
1511- NULL,
1512- CUPS_DBUS_INTERFACE,
1513- NULL,
1514- CUPS_DBUS_PATH,
1515- NULL,
1516- 0,
1517- on_cups_notification,
1518- manager,
1519- NULL);
1520- } else {
1521- g_warning ("Connection to message bus failed: %s", error->message);
1522- g_error_free (error);
1523- }
1524-}
1525-
1526-static gboolean
1527-gsd_print_notifications_manager_start_idle (gpointer data)
1528-{
1529- GsdPrintNotificationsManager *manager = data;
1530-
1531- gnome_settings_profile_start (NULL);
1532-
1533- manager->priv->printing_printers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
1534-
1535-
1536- if (server_is_local (cupsServer ())) {
1537- manager->priv->num_dests = cupsGetDests (&manager->priv->dests);
1538- g_debug ("Got dests from local CUPS server.");
1539-
1540- renew_subscription_timeout_enable (manager, TRUE, FALSE);
1541-
1542- g_bus_get (G_BUS_TYPE_SYSTEM,
1543- NULL,
1544- gsd_print_notifications_manager_got_dbus_connection,
1545- data);
1546- } else {
1547- cups_connection_test (manager);
1548- }
1549-
1550- scp_handler (manager, TRUE);
1551-
1552- gnome_settings_profile_end (NULL);
1553-
1554- return G_SOURCE_REMOVE;
1555-}
1556-
1557-gboolean
1558-gsd_print_notifications_manager_start (GsdPrintNotificationsManager *manager,
1559- GError **error)
1560-{
1561- g_debug ("Starting print-notifications manager");
1562-
1563- gnome_settings_profile_start (NULL);
1564-
1565- manager->priv->subscription_id = -1;
1566- manager->priv->dests = NULL;
1567- manager->priv->num_dests = 0;
1568- manager->priv->scp_handler_spawned = FALSE;
1569- manager->priv->timeouts = NULL;
1570- manager->priv->printing_printers = NULL;
1571- manager->priv->active_notifications = NULL;
1572- manager->priv->cups_bus_connection = NULL;
1573- manager->priv->cups_connection_timeout_id = 0;
1574- manager->priv->last_notify_sequence_number = -1;
1575-
1576- g_idle_add (gsd_print_notifications_manager_start_idle, manager);
1577-
1578- gnome_settings_profile_end (NULL);
1579-
1580- return TRUE;
1581-}
1582-
1583-void
1584-gsd_print_notifications_manager_stop (GsdPrintNotificationsManager *manager)
1585-{
1586- TimeoutData *data;
1587- ReasonData *reason_data;
1588- GList *tmp;
1589-
1590- g_debug ("Stopping print-notifications manager");
1591-
1592- cupsFreeDests (manager->priv->num_dests, manager->priv->dests);
1593- manager->priv->num_dests = 0;
1594- manager->priv->dests = NULL;
1595-
1596- if (manager->priv->cups_dbus_subscription_id > 0 &&
1597- manager->priv->cups_bus_connection != NULL) {
1598- g_dbus_connection_signal_unsubscribe (manager->priv->cups_bus_connection,
1599- manager->priv->cups_dbus_subscription_id);
1600- manager->priv->cups_dbus_subscription_id = 0;
1601- }
1602-
1603- renew_subscription_timeout_enable (manager, FALSE, FALSE);
1604-
1605- if (manager->priv->check_source_id > 0) {
1606- g_source_remove (manager->priv->check_source_id);
1607- manager->priv->check_source_id = 0;
1608- }
1609-
1610- if (manager->priv->subscription_id >= 0)
1611- cancel_subscription (manager->priv->subscription_id);
1612-
1613- if (manager->priv->printing_printers)
1614- g_hash_table_destroy (manager->priv->printing_printers);
1615-
1616- g_clear_object (&manager->priv->cups_bus_connection);
1617-
1618- for (tmp = manager->priv->timeouts; tmp; tmp = g_list_next (tmp)) {
1619- data = (TimeoutData *) tmp->data;
1620- if (data)
1621- g_source_remove (data->timeout_id);
1622- }
1623- g_list_free_full (manager->priv->timeouts, free_timeout_data);
1624-
1625- for (tmp = manager->priv->active_notifications; tmp; tmp = g_list_next (tmp)) {
1626- reason_data = (ReasonData *) tmp->data;
1627- if (reason_data) {
1628- if (reason_data->notification_close_id > 0 &&
1629- g_signal_handler_is_connected (reason_data->notification,
1630- reason_data->notification_close_id)) {
1631- g_signal_handler_disconnect (reason_data->notification,
1632- reason_data->notification_close_id);
1633- reason_data->notification_close_id = 0;
1634- }
1635-
1636- notify_notification_close (reason_data->notification, NULL);
1637- }
1638- }
1639- g_list_free_full (manager->priv->active_notifications, free_reason_data);
1640-
1641- scp_handler (manager, FALSE);
1642-}
1643-
1644-static GObject *
1645-gsd_print_notifications_manager_constructor (GType type,
1646- guint n_construct_properties,
1647- GObjectConstructParam *construct_properties)
1648-{
1649- GsdPrintNotificationsManager *print_notifications_manager;
1650-
1651- print_notifications_manager = GSD_PRINT_NOTIFICATIONS_MANAGER (G_OBJECT_CLASS (gsd_print_notifications_manager_parent_class)->constructor (type,
1652- n_construct_properties,
1653- construct_properties));
1654-
1655- return G_OBJECT (print_notifications_manager);
1656-}
1657-
1658-static void
1659-gsd_print_notifications_manager_class_init (GsdPrintNotificationsManagerClass *klass)
1660-{
1661- GObjectClass *object_class = G_OBJECT_CLASS (klass);
1662-
1663- object_class->constructor = gsd_print_notifications_manager_constructor;
1664- object_class->finalize = gsd_print_notifications_manager_finalize;
1665-
1666- g_type_class_add_private (klass, sizeof (GsdPrintNotificationsManagerPrivate));
1667-}
1668-
1669-static void
1670-gsd_print_notifications_manager_init (GsdPrintNotificationsManager *manager)
1671-{
1672- manager->priv = GSD_PRINT_NOTIFICATIONS_MANAGER_GET_PRIVATE (manager);
1673-
1674-}
1675-
1676-static void
1677-gsd_print_notifications_manager_finalize (GObject *object)
1678-{
1679- GsdPrintNotificationsManager *manager;
1680-
1681- g_return_if_fail (object != NULL);
1682- g_return_if_fail (GSD_IS_PRINT_NOTIFICATIONS_MANAGER (object));
1683-
1684- manager = GSD_PRINT_NOTIFICATIONS_MANAGER (object);
1685-
1686- g_return_if_fail (manager->priv != NULL);
1687-
1688- G_OBJECT_CLASS (gsd_print_notifications_manager_parent_class)->finalize (object);
1689-}
1690-
1691-GsdPrintNotificationsManager *
1692-gsd_print_notifications_manager_new (void)
1693-{
1694- if (manager_object != NULL) {
1695- g_object_ref (manager_object);
1696- } else {
1697- manager_object = g_object_new (GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER, NULL);
1698- g_object_add_weak_pointer (manager_object,
1699- (gpointer *) &manager_object);
1700- }
1701-
1702- return GSD_PRINT_NOTIFICATIONS_MANAGER (manager_object);
1703-}
1704
1705=== removed file 'plugins/print-notifications/gsd-print-notifications-manager.h'
1706--- plugins/print-notifications/gsd-print-notifications-manager.h 2011-01-29 00:21:34 +0000
1707+++ plugins/print-notifications/gsd-print-notifications-manager.h 1970-01-01 00:00:00 +0000
1708@@ -1,57 +0,0 @@
1709-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
1710- *
1711- * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu>
1712- *
1713- * This program is free software; you can redistribute it and/or modify
1714- * it under the terms of the GNU General Public License as published by
1715- * the Free Software Foundation; either version 2 of the License, or
1716- * (at your option) any later version.
1717- *
1718- * This program is distributed in the hope that it will be useful,
1719- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1720- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1721- * GNU General Public License for more details.
1722- *
1723- * You should have received a copy of the GNU General Public License
1724- * along with this program; if not, write to the Free Software
1725- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1726- *
1727- */
1728-
1729-#ifndef __GSD_PRINT_NOTIFICATIONS_MANAGER_H
1730-#define __GSD_PRINT_NOTIFICATIONS_MANAGER_H
1731-
1732-#include <glib-object.h>
1733-
1734-G_BEGIN_DECLS
1735-
1736-#define GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER (gsd_print_notifications_manager_get_type ())
1737-#define GSD_PRINT_NOTIFICATIONS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER, GsdPrintNotificationsManager))
1738-#define GSD_PRINT_NOTIFICATIONS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER, GsdPrintNotificationsManagerClass))
1739-#define GSD_IS_PRINT_NOTIFICATIONS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER))
1740-#define GSD_IS_PRINT_NOTIFICATIONS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER))
1741-#define GSD_PRINT_NOTIFICATIONS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_PRINT_NOTIFICATIONS_MANAGER, GsdPrintNotificationsManagerClass))
1742-
1743-typedef struct GsdPrintNotificationsManagerPrivate GsdPrintNotificationsManagerPrivate;
1744-
1745-typedef struct
1746-{
1747- GObject parent;
1748- GsdPrintNotificationsManagerPrivate *priv;
1749-} GsdPrintNotificationsManager;
1750-
1751-typedef struct
1752-{
1753- GObjectClass parent_class;
1754-} GsdPrintNotificationsManagerClass;
1755-
1756-GType gsd_print_notifications_manager_get_type (void);
1757-
1758-GsdPrintNotificationsManager *gsd_print_notifications_manager_new (void);
1759-gboolean gsd_print_notifications_manager_start (GsdPrintNotificationsManager *manager,
1760- GError **error);
1761-void gsd_print_notifications_manager_stop (GsdPrintNotificationsManager *manager);
1762-
1763-G_END_DECLS
1764-
1765-#endif /* __GSD_PRINT_NOTIFICATIONS_MANAGER_H */
1766
1767=== removed file 'plugins/print-notifications/gsd-print-notifications-plugin.c'
1768--- plugins/print-notifications/gsd-print-notifications-plugin.c 2012-12-13 16:25:59 +0000
1769+++ plugins/print-notifications/gsd-print-notifications-plugin.c 1970-01-01 00:00:00 +0000
1770@@ -1,29 +0,0 @@
1771-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
1772- *
1773- * Copyright (C) 2011 Red Hat, Inc.
1774- *
1775- * This program is free software; you can redistribute it and/or modify
1776- * it under the terms of the GNU General Public License as published by
1777- * the Free Software Foundation; either version 2, or (at your option)
1778- * any later version.
1779- *
1780- * This program is distributed in the hope that it will be useful,
1781- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1782- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1783- * GNU General Public License for more details.
1784- *
1785- * You should have received a copy of the GNU General Public License
1786- * along with this program; if not, write to the Free Software
1787- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1788- *
1789- */
1790-
1791-#include "config.h"
1792-
1793-#include <glib/gi18n-lib.h>
1794-#include <gmodule.h>
1795-
1796-#include "gnome-settings-plugin.h"
1797-#include "gsd-print-notifications-manager.h"
1798-
1799-GNOME_SETTINGS_PLUGIN_REGISTER (GsdPrintNotifications, gsd_print_notifications)
1800
1801=== removed file 'plugins/print-notifications/gsd-printer.c'
1802--- plugins/print-notifications/gsd-printer.c 2013-12-04 23:55:26 +0000
1803+++ plugins/print-notifications/gsd-printer.c 1970-01-01 00:00:00 +0000
1804@@ -1,1403 +0,0 @@
1805-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
1806- *
1807- * Copyright (C) 2011 Red Hat, Inc.
1808- *
1809- * This program is free software; you can redistribute it and/or modify
1810- * it under the terms of the GNU General Public License as published by
1811- * the Free Software Foundation; either version 2, or (at your option)
1812- * any later version.
1813- *
1814- * This program is distributed in the hope that it will be useful,
1815- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1816- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1817- * GNU General Public License for more details.
1818- *
1819- * You should have received a copy of the GNU General Public License
1820- * along with this program; if not, write to the Free Software
1821- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1822- *
1823- */
1824-
1825-#include "config.h"
1826-#include <gio/gio.h>
1827-#include <stdlib.h>
1828-#include <libnotify/notify.h>
1829-#include <glib/gi18n.h>
1830-#include <glib/gstdio.h>
1831-#include <gtk/gtk.h>
1832-#include <cups/cups.h>
1833-#include <cups/ppd.h>
1834-
1835-static GDBusNodeInfo *npn_introspection_data = NULL;
1836-static GDBusNodeInfo *pdi_introspection_data = NULL;
1837-
1838-#define SCP_DBUS_NPN_NAME "com.redhat.NewPrinterNotification"
1839-#define SCP_DBUS_NPN_PATH "/com/redhat/NewPrinterNotification"
1840-#define SCP_DBUS_NPN_INTERFACE "com.redhat.NewPrinterNotification"
1841-
1842-#define SCP_DBUS_PDI_NAME "com.redhat.PrinterDriversInstaller"
1843-#define SCP_DBUS_PDI_PATH "/com/redhat/PrinterDriversInstaller"
1844-#define SCP_DBUS_PDI_INTERFACE "com.redhat.PrinterDriversInstaller"
1845-
1846-#define PACKAGE_KIT_BUS "org.freedesktop.PackageKit"
1847-#define PACKAGE_KIT_PATH "/org/freedesktop/PackageKit"
1848-#define PACKAGE_KIT_MODIFY_IFACE "org.freedesktop.PackageKit.Modify"
1849-#define PACKAGE_KIT_QUERY_IFACE "org.freedesktop.PackageKit.Query"
1850-
1851-#define SCP_BUS "org.fedoraproject.Config.Printing"
1852-#define SCP_PATH "/org/fedoraproject/Config/Printing"
1853-#define SCP_IFACE "org.fedoraproject.Config.Printing"
1854-
1855-#define MECHANISM_BUS "org.opensuse.CupsPkHelper.Mechanism"
1856-
1857-#define ALLOWED_CHARACTERS "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
1858-
1859-#define DBUS_TIMEOUT 60000
1860-#define DBUS_INSTALL_TIMEOUT 3600000
1861-
1862-#define GNOME_SESSION_DBUS_NAME "org.gnome.SessionManager"
1863-#define GNOME_SESSION_DBUS_PATH "/org/gnome/SessionManager"
1864-#define GNOME_SESSION_DBUS_IFACE "org.gnome.SessionManager"
1865-#define GNOME_SESSION_CLIENT_PRIVATE_DBUS_IFACE "org.gnome.SessionManager.ClientPrivate"
1866-
1867-#define GNOME_SESSION_PRESENCE_DBUS_PATH "/org/gnome/SessionManager/Presence"
1868-#define GNOME_SESSION_PRESENCE_DBUS_IFACE "org.gnome.SessionManager.Presence"
1869-
1870-#if (CUPS_VERSION_MAJOR > 1) || (CUPS_VERSION_MINOR > 5)
1871-#define HAVE_CUPS_1_6 1
1872-#endif
1873-
1874-#ifndef HAVE_CUPS_1_6
1875-#define ippGetState(ipp) ipp->state
1876-#endif
1877-
1878-enum {
1879- PRESENCE_STATUS_AVAILABLE = 0,
1880- PRESENCE_STATUS_INVISIBLE,
1881- PRESENCE_STATUS_BUSY,
1882- PRESENCE_STATUS_IDLE,
1883- PRESENCE_STATUS_UNKNOWN
1884-};
1885-
1886-static const gchar npn_introspection_xml[] =
1887- "<node name='/com/redhat/NewPrinterNotification'>"
1888- " <interface name='com.redhat.NewPrinterNotification'>"
1889- " <method name='GetReady'>"
1890- " </method>"
1891- " <method name='NewPrinter'>"
1892- " <arg type='i' name='status' direction='in'/>"
1893- " <arg type='s' name='name' direction='in'/>"
1894- " <arg type='s' name='mfg' direction='in'/>"
1895- " <arg type='s' name='mdl' direction='in'/>"
1896- " <arg type='s' name='des' direction='in'/>"
1897- " <arg type='s' name='cmd' direction='in'/>"
1898- " </method>"
1899- " </interface>"
1900- "</node>";
1901-
1902-static const gchar pdi_introspection_xml[] =
1903- "<node name='/com/redhat/PrinterDriversInstaller'>"
1904- " <interface name='com.redhat.PrinterDriversInstaller'>"
1905- " <method name='InstallDrivers'>"
1906- " <arg type='s' name='mfg' direction='in'/>"
1907- " <arg type='s' name='mdl' direction='in'/>"
1908- " <arg type='s' name='cmd' direction='in'/>"
1909- " </method>"
1910- " </interface>"
1911- "</node>";
1912-
1913-static GMainLoop *main_loop;
1914-static guint npn_registration_id;
1915-static guint pdi_registration_id;
1916-static guint npn_owner_id;
1917-static guint pdi_owner_id;
1918-
1919-static GHashTable *
1920-get_missing_executables (const gchar *ppd_file_name)
1921-{
1922- GHashTable *executables = NULL;
1923- GDBusProxy *proxy;
1924- GVariant *output;
1925- GVariant *array;
1926- GError *error = NULL;
1927- gint i;
1928-
1929- if (!ppd_file_name)
1930- return NULL;
1931-
1932- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1933- G_DBUS_PROXY_FLAGS_NONE,
1934- NULL,
1935- SCP_BUS,
1936- SCP_PATH,
1937- SCP_IFACE,
1938- NULL,
1939- &error);
1940-
1941- if (!proxy) {
1942- g_warning ("%s", error->message);
1943- g_error_free (error);
1944- return NULL;
1945- }
1946-
1947- output = g_dbus_proxy_call_sync (proxy,
1948- "MissingExecutables",
1949- g_variant_new ("(s)",
1950- ppd_file_name),
1951- G_DBUS_CALL_FLAGS_NONE,
1952- DBUS_TIMEOUT,
1953- NULL,
1954- &error);
1955-
1956- if (output && g_variant_n_children (output) == 1) {
1957- array = g_variant_get_child_value (output, 0);
1958- if (array) {
1959- executables = g_hash_table_new_full (g_str_hash, g_str_equal,
1960- g_free, NULL);
1961- for (i = 0; i < g_variant_n_children (array); i++) {
1962- g_hash_table_insert (executables,
1963- g_strdup (g_variant_get_string (
1964- g_variant_get_child_value (array, i),
1965- NULL)),
1966- NULL);
1967- }
1968- }
1969- }
1970-
1971- if (output) {
1972- g_variant_unref (output);
1973- } else {
1974- g_warning ("%s", error->message);
1975- g_error_free (error);
1976- }
1977-
1978- g_object_unref (proxy);
1979-
1980- return executables;
1981-}
1982-
1983-static GHashTable *
1984-find_packages_for_executables (GHashTable *executables)
1985-{
1986- GHashTableIter exec_iter;
1987- GHashTable *packages = NULL;
1988- GDBusProxy *proxy;
1989- GVariant *output;
1990- gpointer key, value;
1991- GError *error = NULL;
1992-
1993- if (!executables || g_hash_table_size (executables) <= 0)
1994- return NULL;
1995-
1996- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
1997- G_DBUS_PROXY_FLAGS_NONE,
1998- NULL,
1999- PACKAGE_KIT_BUS,
2000- PACKAGE_KIT_PATH,
2001- PACKAGE_KIT_QUERY_IFACE,
2002- NULL,
2003- &error);
2004-
2005- if (!proxy) {
2006- g_warning ("%s", error->message);
2007- g_error_free (error);
2008- return NULL;
2009- }
2010-
2011- packages = g_hash_table_new_full (g_str_hash, g_str_equal,
2012- g_free, NULL);
2013-
2014- g_hash_table_iter_init (&exec_iter, executables);
2015- while (g_hash_table_iter_next (&exec_iter, &key, &value)) {
2016- output = g_dbus_proxy_call_sync (proxy,
2017- "SearchFile",
2018- g_variant_new ("(ss)",
2019- (gchar *) key,
2020- ""),
2021- G_DBUS_CALL_FLAGS_NONE,
2022- DBUS_TIMEOUT,
2023- NULL,
2024- &error);
2025-
2026- if (output) {
2027- gboolean installed;
2028- gchar *package;
2029-
2030- g_variant_get (output,
2031- "(bs)",
2032- &installed,
2033- &package);
2034- if (!installed)
2035- g_hash_table_insert (packages, g_strdup (package), NULL);
2036-
2037- g_variant_unref (output);
2038- } else {
2039- g_warning ("%s", error->message);
2040- g_error_free (error);
2041- }
2042- }
2043-
2044- g_object_unref (proxy);
2045-
2046- return packages;
2047-}
2048-
2049-static void
2050-install_packages (GHashTable *packages)
2051-{
2052- GVariantBuilder array_builder;
2053- GHashTableIter pkg_iter;
2054- GDBusProxy *proxy;
2055- GVariant *output;
2056- gpointer key, value;
2057- GError *error = NULL;
2058-
2059- if (!packages || g_hash_table_size (packages) <= 0)
2060- return;
2061-
2062- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
2063- G_DBUS_PROXY_FLAGS_NONE,
2064- NULL,
2065- PACKAGE_KIT_BUS,
2066- PACKAGE_KIT_PATH,
2067- PACKAGE_KIT_MODIFY_IFACE,
2068- NULL,
2069- &error);
2070-
2071- if (!proxy) {
2072- g_warning ("%s", error->message);
2073- g_error_free (error);
2074- return;
2075- }
2076-
2077- g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("as"));
2078-
2079- g_hash_table_iter_init (&pkg_iter, packages);
2080- while (g_hash_table_iter_next (&pkg_iter, &key, &value)) {
2081- g_variant_builder_add (&array_builder,
2082- "s",
2083- (gchar *) key);
2084- }
2085-
2086- output = g_dbus_proxy_call_sync (proxy,
2087- "InstallPackageNames",
2088- g_variant_new ("(uass)",
2089- 0,
2090- &array_builder,
2091- "hide-finished"),
2092- G_DBUS_CALL_FLAGS_NONE,
2093- DBUS_INSTALL_TIMEOUT,
2094- NULL,
2095- &error);
2096-
2097- if (output) {
2098- g_variant_unref (output);
2099- } else {
2100- g_warning ("%s", error->message);
2101- g_error_free (error);
2102- }
2103-
2104- g_object_unref (proxy);
2105-}
2106-
2107-static gchar *
2108-get_best_ppd (gchar *device_id,
2109- gchar *device_make_and_model,
2110- gchar *device_uri)
2111-{
2112- GDBusProxy *proxy;
2113- GVariant *output;
2114- GVariant *array;
2115- GVariant *tuple;
2116- GError *error = NULL;
2117- gchar *ppd_name = NULL;
2118- gint i, j;
2119- static const char * const match_levels[] = {
2120- "exact-cmd",
2121- "exact",
2122- "close",
2123- "generic",
2124- "none"};
2125-
2126- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
2127- G_DBUS_PROXY_FLAGS_NONE,
2128- NULL,
2129- SCP_BUS,
2130- SCP_PATH,
2131- SCP_IFACE,
2132- NULL,
2133- &error);
2134-
2135- if (!proxy) {
2136- g_warning ("%s", error->message);
2137- g_error_free (error);
2138- return NULL;
2139- }
2140-
2141- output = g_dbus_proxy_call_sync (proxy,
2142- "GetBestDrivers",
2143- g_variant_new ("(sss)",
2144- device_id ? device_id : "",
2145- device_make_and_model ? device_make_and_model : "",
2146- device_uri ? device_uri : ""),
2147- G_DBUS_CALL_FLAGS_NONE,
2148- DBUS_TIMEOUT,
2149- NULL,
2150- &error);
2151-
2152- if (output && g_variant_n_children (output) >= 1) {
2153- array = g_variant_get_child_value (output, 0);
2154- if (array)
2155- for (j = 0; j < G_N_ELEMENTS (match_levels) && ppd_name == NULL; j++)
2156- for (i = 0; i < g_variant_n_children (array) && ppd_name == NULL; i++) {
2157- tuple = g_variant_get_child_value (array, i);
2158- if (tuple && g_variant_n_children (tuple) == 2) {
2159- if (g_strcmp0 (g_variant_get_string (
2160- g_variant_get_child_value (tuple, 1),
2161- NULL), match_levels[j]) == 0)
2162- ppd_name = g_strdup (g_variant_get_string (
2163- g_variant_get_child_value (tuple, 0),
2164- NULL));
2165- }
2166- }
2167- }
2168-
2169- if (output) {
2170- g_variant_unref (output);
2171- } else {
2172- g_warning ("%s", error->message);
2173- g_error_free (error);
2174- }
2175-
2176- g_object_unref (proxy);
2177-
2178- return ppd_name;
2179-}
2180-
2181-static gchar *
2182-get_tag_value (const gchar *tag_string,
2183- const gchar *tag_name)
2184-{
2185- gchar **tag_string_splitted;
2186- gchar *tag_value = NULL;
2187- gint tag_name_length;
2188- gint i;
2189-
2190- if (!tag_string ||
2191- !tag_name)
2192- return NULL;
2193-
2194- tag_name_length = strlen (tag_name);
2195- tag_string_splitted = g_strsplit (tag_string, ";", 0);
2196- if (tag_string_splitted) {
2197- for (i = 0; i < g_strv_length (tag_string_splitted); i++)
2198- if (g_ascii_strncasecmp (tag_string_splitted[i], tag_name, tag_name_length) == 0)
2199- if (strlen (tag_string_splitted[i]) > tag_name_length + 1)
2200- tag_value = g_strdup (tag_string_splitted[i] + tag_name_length + 1);
2201-
2202- g_strfreev (tag_string_splitted);
2203- }
2204-
2205- return tag_value;
2206-}
2207-
2208-static gchar *
2209-create_name (gchar *device_id)
2210-{
2211- cups_dest_t *dests;
2212- gboolean already_present = FALSE;
2213- gchar *name = NULL;
2214- gchar *new_name = NULL;
2215- gint num_dests;
2216- gint name_index = 2;
2217- gint j;
2218-
2219- g_return_val_if_fail (device_id != NULL, NULL);
2220-
2221- name = get_tag_value (device_id, "mdl");
2222- if (!name)
2223- name = get_tag_value (device_id, "model");
2224-
2225- if (name)
2226- name = g_strcanon (name, ALLOWED_CHARACTERS, '-');
2227-
2228- num_dests = cupsGetDests (&dests);
2229- do {
2230- if (already_present) {
2231- new_name = g_strdup_printf ("%s-%d", name, name_index);
2232- name_index++;
2233- } else {
2234- new_name = g_strdup (name);
2235- }
2236-
2237- already_present = FALSE;
2238- for (j = 0; j < num_dests; j++)
2239- if (g_strcmp0 (dests[j].name, new_name) == 0)
2240- already_present = TRUE;
2241-
2242- if (already_present) {
2243- g_free (new_name);
2244- } else {
2245- g_free (name);
2246- name = new_name;
2247- }
2248- } while (already_present);
2249- cupsFreeDests (num_dests, dests);
2250-
2251- return name;
2252-}
2253-
2254-static gboolean
2255-add_printer (gchar *printer_name,
2256- gchar *device_uri,
2257- gchar *ppd_name,
2258- gchar *info,
2259- gchar *location)
2260-{
2261- cups_dest_t *dests;
2262- GDBusProxy *proxy;
2263- gboolean success = FALSE;
2264- GVariant *output;
2265- GError *error = NULL;
2266- gint num_dests;
2267- gint i;
2268-
2269- if (!printer_name || !device_uri || !ppd_name)
2270- return FALSE;
2271-
2272- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2273- G_DBUS_PROXY_FLAGS_NONE,
2274- NULL,
2275- MECHANISM_BUS,
2276- "/",
2277- MECHANISM_BUS,
2278- NULL,
2279- &error);
2280-
2281- if (!proxy) {
2282- g_warning ("%s", error->message);
2283- g_error_free (error);
2284- return FALSE;
2285- }
2286-
2287- output = g_dbus_proxy_call_sync (proxy,
2288- "PrinterAdd",
2289- g_variant_new ("(sssss)",
2290- printer_name,
2291- device_uri,
2292- ppd_name,
2293- info ? info : "",
2294- location ? location : ""),
2295- G_DBUS_CALL_FLAGS_NONE,
2296- DBUS_TIMEOUT,
2297- NULL,
2298- &error);
2299-
2300- if (output) {
2301- g_variant_unref (output);
2302- } else {
2303- g_warning ("%s", error->message);
2304- g_error_free (error);
2305- }
2306-
2307- g_object_unref (proxy);
2308-
2309- num_dests = cupsGetDests (&dests);
2310- for (i = 0; i < num_dests; i++)
2311- if (g_strcmp0 (dests[i].name, printer_name) == 0)
2312- success = TRUE;
2313- cupsFreeDests (num_dests, dests);
2314-
2315- return success;
2316-}
2317-
2318-static gboolean
2319-printer_set_enabled (const gchar *printer_name,
2320- gboolean enabled)
2321-{
2322- GDBusProxy *proxy;
2323- gboolean result = TRUE;
2324- GVariant *output;
2325- GError *error = NULL;
2326-
2327- if (!printer_name)
2328- return FALSE;
2329-
2330- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2331- G_DBUS_PROXY_FLAGS_NONE,
2332- NULL,
2333- MECHANISM_BUS,
2334- "/",
2335- MECHANISM_BUS,
2336- NULL,
2337- &error);
2338-
2339- if (!proxy) {
2340- g_warning ("%s", error->message);
2341- g_error_free (error);
2342- return FALSE;
2343- }
2344-
2345- output = g_dbus_proxy_call_sync (proxy,
2346- "PrinterSetEnabled",
2347- g_variant_new ("(sb)",
2348- printer_name,
2349- enabled),
2350- G_DBUS_CALL_FLAGS_NONE,
2351- DBUS_TIMEOUT,
2352- NULL,
2353- &error);
2354-
2355- if (output) {
2356- g_variant_unref (output);
2357- } else {
2358- g_warning ("%s", error->message);
2359- g_error_free (error);
2360- result = FALSE;
2361- }
2362-
2363- g_object_unref (proxy);
2364-
2365- return result;
2366-}
2367-
2368-static gboolean
2369-printer_set_accepting_jobs (const gchar *printer_name,
2370- gboolean accepting_jobs,
2371- const gchar *reason)
2372-{
2373- GDBusProxy *proxy;
2374- gboolean result = TRUE;
2375- GVariant *output;
2376- GError *error = NULL;
2377-
2378- if (!printer_name)
2379- return FALSE;
2380-
2381- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2382- G_DBUS_PROXY_FLAGS_NONE,
2383- NULL,
2384- MECHANISM_BUS,
2385- "/",
2386- MECHANISM_BUS,
2387- NULL,
2388- &error);
2389-
2390- if (!proxy) {
2391- g_warning ("%s", error->message);
2392- g_error_free (error);
2393- return FALSE;
2394- }
2395-
2396- output = g_dbus_proxy_call_sync (proxy,
2397- "PrinterSetAcceptJobs",
2398- g_variant_new ("(sbs)",
2399- printer_name,
2400- accepting_jobs,
2401- reason ? reason : ""),
2402- G_DBUS_CALL_FLAGS_NONE,
2403- DBUS_TIMEOUT,
2404- NULL,
2405- &error);
2406-
2407- if (output) {
2408- g_variant_unref (output);
2409- } else {
2410- g_warning ("%s", error->message);
2411- g_error_free (error);
2412- result = FALSE;
2413- }
2414-
2415- g_object_unref (proxy);
2416-
2417- return result;
2418-}
2419-
2420-static ipp_t *
2421-execute_maintenance_command (const char *printer_name,
2422- const char *command,
2423- const char *title)
2424-{
2425- http_t *http;
2426- GError *error = NULL;
2427- ipp_t *request = NULL;
2428- ipp_t *response = NULL;
2429- gchar *file_name = NULL;
2430- char *uri;
2431- int fd = -1;
2432-
2433- http = httpConnectEncrypt (cupsServer (),
2434- ippPort (),
2435- cupsEncryption ());
2436-
2437- if (!http)
2438- return NULL;
2439-
2440- request = ippNewRequest (IPP_PRINT_JOB);
2441-
2442- uri = g_strdup_printf ("ipp://localhost/printers/%s",
2443- printer_name);
2444-
2445- ippAddString (request,
2446- IPP_TAG_OPERATION,
2447- IPP_TAG_URI,
2448- "printer-uri",
2449- NULL,
2450- uri);
2451-
2452- g_free (uri);
2453-
2454- ippAddString (request, IPP_TAG_OPERATION, IPP_TAG_NAME, "job-name",
2455- NULL, title);
2456-
2457- ippAddString (request, IPP_TAG_JOB, IPP_TAG_MIMETYPE, "document-format",
2458- NULL, "application/vnd.cups-command");
2459-
2460- fd = g_file_open_tmp ("ccXXXXXX", &file_name, &error);
2461-
2462- if (fd != -1) {
2463- FILE *file;
2464-
2465- file = fdopen (fd, "w");
2466- fprintf (file, "#CUPS-COMMAND\n");
2467- fprintf (file, "%s\n", command);
2468- fclose (file);
2469-
2470- response = cupsDoFileRequest (http, request, "/", file_name);
2471- g_unlink (file_name);
2472- } else {
2473- g_warning ("%s", error->message);
2474- g_error_free (error);
2475- }
2476-
2477- g_free (file_name);
2478- httpClose (http);
2479-
2480- return response;
2481-}
2482-
2483-static char *
2484-get_dest_attr (const char *dest_name,
2485- const char *attr)
2486-{
2487- cups_dest_t *dests;
2488- int num_dests;
2489- cups_dest_t *dest;
2490- const char *value;
2491- char *ret;
2492-
2493- if (dest_name == NULL)
2494- return NULL;
2495-
2496- ret = NULL;
2497-
2498- num_dests = cupsGetDests (&dests);
2499- if (num_dests < 1) {
2500- g_debug ("Unable to get printer destinations");
2501- return NULL;
2502- }
2503-
2504- dest = cupsGetDest (dest_name, NULL, num_dests, dests);
2505- if (dest == NULL) {
2506- g_debug ("Unable to find a printer named '%s'", dest_name);
2507- goto out;
2508- }
2509-
2510- value = cupsGetOption (attr, dest->num_options, dest->options);
2511- if (value == NULL) {
2512- g_debug ("Unable to get %s for '%s'", attr, dest_name);
2513- goto out;
2514- }
2515- ret = g_strdup (value);
2516-out:
2517- cupsFreeDests (num_dests, dests);
2518-
2519- return ret;
2520-}
2521-
2522-static void
2523-printer_autoconfigure (gchar *printer_name)
2524-{
2525- gchar *commands;
2526- gchar *commands_lowercase;
2527- ipp_t *response = NULL;
2528-
2529- if (!printer_name)
2530- return;
2531-
2532- commands = get_dest_attr (printer_name, "printer-commands");
2533- commands_lowercase = g_ascii_strdown (commands, -1);
2534-
2535- if (g_strrstr (commands_lowercase, "autoconfigure")) {
2536- response = execute_maintenance_command (printer_name,
2537- "AutoConfigure",
2538- ("Automatic configuration"));
2539- if (response) {
2540- if (ippGetState (response) == IPP_ERROR)
2541- g_warning ("An error has occured during automatic configuration of new printer.");
2542- ippDelete (response);
2543- }
2544- }
2545- g_free (commands);
2546- g_free (commands_lowercase);
2547-}
2548-
2549-/* Return default media size for current locale */
2550-static const gchar *
2551-get_paper_size_from_locale ()
2552-{
2553- if (g_str_equal (gtk_paper_size_get_default (), GTK_PAPER_NAME_LETTER))
2554- return "na-letter";
2555- else
2556- return "iso-a4";
2557-}
2558-
2559-static void
2560-set_default_paper_size (const gchar *printer_name,
2561- const gchar *ppd_file_name)
2562-{
2563- GDBusProxy *proxy;
2564- GVariant *output;
2565- GError *error = NULL;
2566- GVariantBuilder *builder;
2567-
2568- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
2569- G_DBUS_PROXY_FLAGS_NONE,
2570- NULL,
2571- MECHANISM_BUS,
2572- "/",
2573- MECHANISM_BUS,
2574- NULL,
2575- &error);
2576-
2577- if (!proxy) {
2578- g_warning ("%s", error->message);
2579- g_error_free (error);
2580- return;
2581- }
2582-
2583- /* Set default media size according to the locale
2584- * FIXME: Handle more than A4 and Letter:
2585- * https://bugzilla.gnome.org/show_bug.cgi?id=660769 */
2586- builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
2587- g_variant_builder_add (builder, "s", get_paper_size_from_locale ());
2588-
2589- output = g_dbus_proxy_call_sync (proxy,
2590- "PrinterAddOption",
2591- g_variant_new ("(ssas)",
2592- printer_name ? printer_name : "",
2593- "media",
2594- builder),
2595- G_DBUS_CALL_FLAGS_NONE,
2596- DBUS_TIMEOUT,
2597- NULL,
2598- &error);
2599-
2600- if (output) {
2601- g_variant_unref (output);
2602- } else {
2603- if (!(error->domain == G_DBUS_ERROR &&
2604- (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
2605- error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
2606- g_warning ("%s", error->message);
2607- g_error_free (error);
2608- }
2609-
2610- g_object_unref (proxy);
2611-}
2612-
2613-/*
2614- * Setup new printer and returns TRUE if successful.
2615- */
2616-static gboolean
2617-setup_printer (gchar *device_id,
2618- gchar *device_make_and_model,
2619- gchar *device_uri)
2620-{
2621- gboolean success = FALSE;
2622- gchar *ppd_name;
2623- gchar *printer_name;
2624-
2625- ppd_name = get_best_ppd (device_id, device_make_and_model, device_uri);
2626- printer_name = create_name (device_id);
2627-
2628- if (!ppd_name || !printer_name || !device_uri) {
2629- g_free (ppd_name);
2630- g_free (printer_name);
2631- return FALSE;
2632- }
2633-
2634- success = add_printer (printer_name, device_uri,
2635- ppd_name, NULL, NULL);
2636-
2637- /* Set some options of the new printer */
2638- if (success) {
2639- const char *ppd_file_name;
2640-
2641- printer_set_accepting_jobs (printer_name, TRUE, NULL);
2642- printer_set_enabled (printer_name, TRUE);
2643- printer_autoconfigure (printer_name);
2644-
2645- ppd_file_name = cupsGetPPD (printer_name);
2646-
2647- if (ppd_file_name) {
2648- GHashTable *executables;
2649- GHashTable *packages;
2650-
2651- set_default_paper_size (printer_name, ppd_file_name);
2652-
2653- executables = get_missing_executables (ppd_file_name);
2654- packages = find_packages_for_executables (executables);
2655- install_packages (packages);
2656-
2657- if (executables)
2658- g_hash_table_destroy (executables);
2659- if (packages)
2660- g_hash_table_destroy (packages);
2661- g_unlink (ppd_file_name);
2662- }
2663- }
2664-
2665- g_free (printer_name);
2666- g_free (ppd_name);
2667-
2668- return success;
2669-}
2670-
2671-static void
2672-handle_method_call (GDBusConnection *connection,
2673- const gchar *sender,
2674- const gchar *object_path,
2675- const gchar *interface_name,
2676- const gchar *method_name,
2677- GVariant *parameters,
2678- GDBusMethodInvocation *invocation,
2679- gpointer user_data)
2680-{
2681- gchar *primary_text = NULL;
2682- gchar *secondary_text = NULL;
2683- gchar *name = NULL;
2684- gchar *mfg = NULL;
2685- gchar *mdl = NULL;
2686- gchar *des = NULL;
2687- gchar *cmd = NULL;
2688- gchar *device = NULL;
2689- gchar *device_id;
2690- gchar *make_and_model;
2691- gint status = 0;
2692-
2693- if (g_strcmp0 (method_name, "GetReady") == 0) {
2694- /* Translators: We are configuring new printer */
2695- primary_text = g_strdup (_("Configuring new printer"));
2696- /* Translators: Just wait */
2697- secondary_text = g_strdup (_("Please wait..."));
2698-
2699- g_dbus_method_invocation_return_value (invocation,
2700- NULL);
2701- }
2702- else if (g_strcmp0 (method_name, "NewPrinter") == 0) {
2703- if (g_variant_n_children (parameters) == 6) {
2704- g_variant_get (parameters, "(i&s&s&s&s&s)",
2705- &status,
2706- &name,
2707- &mfg,
2708- &mdl,
2709- &des,
2710- &cmd);
2711- }
2712-
2713- if (g_strrstr (name, "/")) {
2714- /* name is a URI, no queue was generated, because no suitable
2715- * driver was found
2716- */
2717-
2718- device_id = g_strdup_printf ("MFG:%s;MDL:%s;DES:%s;CMD:%s;", mfg, mdl, des, cmd);
2719- make_and_model = g_strdup_printf ("%s %s", mfg, mdl);
2720-
2721- if (!setup_printer (device_id, make_and_model, name)) {
2722-
2723- /* Translators: We have no driver installed for this printer */
2724- primary_text = g_strdup (_("Missing printer driver"));
2725-
2726- if ((mfg && mdl) || des) {
2727- if (mfg && mdl)
2728- device = g_strdup_printf ("%s %s", mfg, mdl);
2729- else
2730- device = g_strdup (des);
2731-
2732- /* Translators: We have no driver installed for the device */
2733- secondary_text = g_strdup_printf (_("No printer driver for %s."), device);
2734- g_free (device);
2735- }
2736- else
2737- /* Translators: We have no driver installed for this printer */
2738- secondary_text = g_strdup (_("No driver for this printer."));
2739- }
2740-
2741- g_free (make_and_model);
2742- g_free (device_id);
2743- }
2744- else {
2745- /* name is the name of the queue which hal_lpadmin has set up
2746- * automatically.
2747- */
2748-
2749- const char *ppd_file_name;
2750-
2751- ppd_file_name = cupsGetPPD (name);
2752- if (ppd_file_name) {
2753- GHashTable *executables;
2754- GHashTable *packages;
2755-
2756- executables = get_missing_executables (ppd_file_name);
2757- packages = find_packages_for_executables (executables);
2758- install_packages (packages);
2759-
2760- if (executables)
2761- g_hash_table_destroy (executables);
2762- if (packages)
2763- g_hash_table_destroy (packages);
2764- g_unlink (ppd_file_name);
2765- }
2766- }
2767-
2768- g_dbus_method_invocation_return_value (invocation,
2769- NULL);
2770- }
2771- else if (g_strcmp0 (method_name, "InstallDrivers") == 0) {
2772- GDBusProxy *proxy;
2773- GError *error = NULL;
2774-
2775- if (g_variant_n_children (parameters) == 3) {
2776- g_variant_get (parameters, "(&s&s&s)",
2777- &mfg,
2778- &mdl,
2779- &cmd);
2780- }
2781-
2782- if (mfg && mdl)
2783- device = g_strdup_printf ("MFG:%s;MDL:%s;", mfg, mdl);
2784-
2785- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
2786- G_DBUS_PROXY_FLAGS_NONE,
2787- NULL,
2788- PACKAGE_KIT_BUS,
2789- PACKAGE_KIT_PATH,
2790- PACKAGE_KIT_MODIFY_IFACE,
2791- NULL,
2792- &error);
2793-
2794- if (!proxy) {
2795- g_warning ("%s", error->message);
2796- g_error_free (error);
2797- }
2798-
2799- if (proxy && device) {
2800- GVariantBuilder *builder;
2801- GVariant *output;
2802-
2803- builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
2804- g_variant_builder_add (builder, "s", device);
2805-
2806- output = g_dbus_proxy_call_sync (proxy,
2807- "InstallPrinterDrivers",
2808- g_variant_new ("(uass)",
2809- 0,
2810- builder,
2811- "hide-finished"),
2812- G_DBUS_CALL_FLAGS_NONE,
2813- DBUS_INSTALL_TIMEOUT,
2814- NULL,
2815- &error);
2816-
2817- if (output) {
2818- g_variant_unref (output);
2819- } else {
2820- g_warning ("%s", error->message);
2821- g_error_free (error);
2822- }
2823-
2824- g_object_unref (proxy);
2825- }
2826-
2827- g_dbus_method_invocation_return_value (invocation,
2828- NULL);
2829- }
2830-
2831- if (primary_text) {
2832- NotifyNotification *notification;
2833- notification = notify_notification_new (primary_text,
2834- secondary_text,
2835- "printer-symbolic");
2836- notify_notification_set_app_name (notification, _("Printers"));
2837- notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
2838-
2839- notify_notification_show (notification, NULL);
2840- g_object_unref (notification);
2841- g_free (primary_text);
2842- g_free (secondary_text);
2843- }
2844-}
2845-
2846-static const GDBusInterfaceVTable interface_vtable =
2847-{
2848- handle_method_call,
2849- NULL,
2850- NULL
2851-};
2852-
2853-static void
2854-unregister_objects ()
2855-{
2856- GDBusConnection *system_connection;
2857- GError *error = NULL;
2858-
2859- system_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
2860-
2861- if (npn_registration_id > 0) {
2862- g_dbus_connection_unregister_object (system_connection, npn_registration_id);
2863- npn_registration_id = 0;
2864- }
2865-
2866- if (pdi_registration_id > 0) {
2867- g_dbus_connection_unregister_object (system_connection, pdi_registration_id);
2868- pdi_registration_id = 0;
2869- }
2870-}
2871-
2872-static void
2873-unown_names ()
2874-{
2875- if (npn_owner_id > 0) {
2876- g_bus_unown_name (npn_owner_id);
2877- npn_owner_id = 0;
2878- }
2879-
2880- if (pdi_owner_id > 0) {
2881- g_bus_unown_name (pdi_owner_id);
2882- pdi_owner_id = 0;
2883- }
2884-}
2885-
2886-static void
2887-on_npn_bus_acquired (GDBusConnection *connection,
2888- const gchar *name,
2889- gpointer user_data)
2890-{
2891- GError *error = NULL;
2892-
2893- npn_registration_id = g_dbus_connection_register_object (connection,
2894- SCP_DBUS_NPN_PATH,
2895- npn_introspection_data->interfaces[0],
2896- &interface_vtable,
2897- NULL,
2898- NULL,
2899- &error);
2900-
2901- if (npn_registration_id == 0) {
2902- g_warning ("Failed to register object: %s\n", error->message);
2903- g_error_free (error);
2904- }
2905-}
2906-
2907-static void
2908-on_pdi_bus_acquired (GDBusConnection *connection,
2909- const gchar *name,
2910- gpointer user_data)
2911-{
2912- GError *error = NULL;
2913-
2914- pdi_registration_id = g_dbus_connection_register_object (connection,
2915- SCP_DBUS_PDI_PATH,
2916- pdi_introspection_data->interfaces[0],
2917- &interface_vtable,
2918- NULL,
2919- NULL,
2920- &error);
2921-
2922- if (pdi_registration_id == 0) {
2923- g_warning ("Failed to register object: %s\n", error->message);
2924- g_error_free (error);
2925- }
2926-}
2927-
2928-static void
2929-on_name_acquired (GDBusConnection *connection,
2930- const gchar *name,
2931- gpointer user_data)
2932-{
2933-}
2934-
2935-static void
2936-on_name_lost (GDBusConnection *connection,
2937- const gchar *name,
2938- gpointer user_data)
2939-{
2940- unregister_objects ();
2941-}
2942-
2943-static void
2944-session_signal_handler (GDBusConnection *connection,
2945- const gchar *sender_name,
2946- const gchar *object_path,
2947- const gchar *interface_name,
2948- const gchar *signal_name,
2949- GVariant *parameters,
2950- gpointer user_data)
2951-{
2952- guint new_status;
2953-
2954- g_variant_get (parameters, "(u)", &new_status);
2955-
2956- if (new_status == PRESENCE_STATUS_IDLE ||
2957- new_status == PRESENCE_STATUS_AVAILABLE) {
2958- unregister_objects ();
2959- unown_names ();
2960-
2961- if (new_status == PRESENCE_STATUS_AVAILABLE) {
2962- npn_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
2963- SCP_DBUS_NPN_NAME,
2964- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
2965- G_BUS_NAME_OWNER_FLAGS_REPLACE,
2966- on_npn_bus_acquired,
2967- on_name_acquired,
2968- on_name_lost,
2969- NULL,
2970- NULL);
2971-
2972- pdi_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
2973- SCP_DBUS_PDI_NAME,
2974- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
2975- G_BUS_NAME_OWNER_FLAGS_REPLACE,
2976- on_pdi_bus_acquired,
2977- on_name_acquired,
2978- on_name_lost,
2979- NULL,
2980- NULL);
2981- }
2982- }
2983-}
2984-
2985-static void
2986-client_signal_handler (GDBusConnection *connection,
2987- const gchar *sender_name,
2988- const gchar *object_path,
2989- const gchar *interface_name,
2990- const gchar *signal_name,
2991- GVariant *parameters,
2992- gpointer user_data)
2993-{
2994- GDBusProxy *proxy;
2995- GError *error = NULL;
2996- GVariant *output;
2997-
2998- if (g_strcmp0 (signal_name, "QueryEndSession") == 0 ||
2999- g_strcmp0 (signal_name, "EndSession") == 0) {
3000- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
3001- G_DBUS_PROXY_FLAGS_NONE,
3002- NULL,
3003- sender_name,
3004- object_path,
3005- interface_name,
3006- NULL,
3007- &error);
3008-
3009- if (proxy) {
3010- output = g_dbus_proxy_call_sync (proxy,
3011- "EndSessionResponse",
3012- g_variant_new ("(bs)", TRUE, ""),
3013- G_DBUS_CALL_FLAGS_NONE,
3014- -1,
3015- NULL,
3016- &error);
3017-
3018- if (output) {
3019- g_variant_unref (output);
3020- }
3021- else {
3022- g_warning ("%s", error->message);
3023- g_error_free (error);
3024- }
3025-
3026- g_object_unref (proxy);
3027- }
3028- else {
3029- g_warning ("%s", error->message);
3030- g_error_free (error);
3031- }
3032-
3033- if (g_strcmp0 (signal_name, "EndSession") == 0) {
3034- g_main_loop_quit (main_loop);
3035- g_debug ("Exiting usd-printer");
3036- }
3037- }
3038-}
3039-
3040-static gchar *
3041-register_gnome_session_client (const gchar *app_id,
3042- const gchar *client_startup_id)
3043-{
3044- GDBusProxy *proxy;
3045- GVariant *output = NULL;
3046- GError *error = NULL;
3047- const gchar *client_id = NULL;
3048- gchar *result = NULL;
3049-
3050- proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
3051- G_DBUS_PROXY_FLAGS_NONE,
3052- NULL,
3053- GNOME_SESSION_DBUS_NAME,
3054- GNOME_SESSION_DBUS_PATH,
3055- GNOME_SESSION_DBUS_IFACE,
3056- NULL,
3057- &error);
3058-
3059- if (proxy) {
3060- output = g_dbus_proxy_call_sync (proxy,
3061- "RegisterClient",
3062- g_variant_new ("(ss)", app_id, client_startup_id),
3063- G_DBUS_CALL_FLAGS_NONE,
3064- -1,
3065- NULL,
3066- &error);
3067-
3068- if (output) {
3069- g_variant_get (output, "(o)", &client_id);
3070- if (client_id)
3071- result = g_strdup (client_id);
3072- g_variant_unref (output);
3073- }
3074- else {
3075- g_warning ("%s", error->message);
3076- g_error_free (error);
3077- }
3078-
3079- g_object_unref (proxy);
3080- }
3081- else {
3082- g_warning ("%s", error->message);
3083- g_error_free (error);
3084- }
3085-
3086- return result;
3087-}
3088-
3089-int
3090-main (int argc, char *argv[])
3091-{
3092- GDBusConnection *connection;
3093- gboolean client_signal_subscription_set = FALSE;
3094- GError *error = NULL;
3095- guint client_signal_subscription_id;
3096- guint session_signal_subscription_id;
3097- gchar *object_path;
3098-
3099- bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
3100- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
3101- textdomain (GETTEXT_PACKAGE);
3102- setlocale (LC_ALL, "");
3103-
3104- npn_registration_id = 0;
3105- pdi_registration_id = 0;
3106- npn_owner_id = 0;
3107- pdi_owner_id = 0;
3108-
3109- notify_init ("gnome-settings-daemon-printer");
3110-
3111- npn_introspection_data =
3112- g_dbus_node_info_new_for_xml (npn_introspection_xml, &error);
3113-
3114- if (npn_introspection_data == NULL) {
3115- g_warning ("Error parsing introspection XML: %s\n", error->message);
3116- g_error_free (error);
3117- goto error;
3118- }
3119-
3120- pdi_introspection_data =
3121- g_dbus_node_info_new_for_xml (pdi_introspection_xml, &error);
3122-
3123- if (pdi_introspection_data == NULL) {
3124- g_warning ("Error parsing introspection XML: %s\n", error->message);
3125- g_error_free (error);
3126- goto error;
3127- }
3128-
3129- connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
3130-
3131- session_signal_subscription_id =
3132- g_dbus_connection_signal_subscribe (connection,
3133- NULL,
3134- GNOME_SESSION_PRESENCE_DBUS_IFACE,
3135- "StatusChanged",
3136- GNOME_SESSION_PRESENCE_DBUS_PATH,
3137- NULL,
3138- G_DBUS_SIGNAL_FLAGS_NONE,
3139- session_signal_handler,
3140- NULL,
3141- NULL);
3142-
3143- object_path = register_gnome_session_client ("usd-printer", "");
3144- if (object_path) {
3145- client_signal_subscription_id =
3146- g_dbus_connection_signal_subscribe (connection,
3147- NULL,
3148- GNOME_SESSION_CLIENT_PRIVATE_DBUS_IFACE,
3149- NULL,
3150- object_path,
3151- NULL,
3152- G_DBUS_SIGNAL_FLAGS_NONE,
3153- client_signal_handler,
3154- NULL,
3155- NULL);
3156- client_signal_subscription_set = TRUE;
3157- }
3158-
3159- if (npn_owner_id == 0)
3160- npn_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
3161- SCP_DBUS_NPN_NAME,
3162- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
3163- G_BUS_NAME_OWNER_FLAGS_REPLACE,
3164- on_npn_bus_acquired,
3165- on_name_acquired,
3166- on_name_lost,
3167- NULL,
3168- NULL);
3169-
3170- if (pdi_owner_id == 0)
3171- pdi_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
3172- SCP_DBUS_PDI_NAME,
3173- G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
3174- G_BUS_NAME_OWNER_FLAGS_REPLACE,
3175- on_pdi_bus_acquired,
3176- on_name_acquired,
3177- on_name_lost,
3178- NULL,
3179- NULL);
3180-
3181- main_loop = g_main_loop_new (NULL, FALSE);
3182- g_main_loop_run (main_loop);
3183-
3184- unregister_objects ();
3185- unown_names ();
3186-
3187- if (client_signal_subscription_set)
3188- g_dbus_connection_signal_unsubscribe (connection, client_signal_subscription_id);
3189- g_dbus_connection_signal_unsubscribe (connection, session_signal_subscription_id);
3190-
3191- g_free (object_path);
3192-
3193- g_dbus_node_info_unref (npn_introspection_data);
3194- g_dbus_node_info_unref (pdi_introspection_data);
3195-
3196- return 0;
3197-
3198-error:
3199-
3200- if (npn_introspection_data)
3201- g_dbus_node_info_unref (npn_introspection_data);
3202-
3203- if (pdi_introspection_data)
3204- g_dbus_node_info_unref (pdi_introspection_data);
3205-
3206- return 1;
3207-}
3208
3209=== removed file 'plugins/print-notifications/print-notifications.gnome-settings-plugin.in'
3210--- plugins/print-notifications/print-notifications.gnome-settings-plugin.in 2013-02-20 23:32:45 +0000
3211+++ plugins/print-notifications/print-notifications.gnome-settings-plugin.in 1970-01-01 00:00:00 +0000
3212@@ -1,10 +0,0 @@
3213-[GNOME Settings Plugin]
3214-Module=print-notifications
3215-IAge=0
3216-# Default Priority
3217-# Priority=100
3218-_Name=Print-notifications
3219-_Description=Print-notifications plugin
3220-Authors=Marek Kasik
3221-Copyright=Copyright © 2011 Marek Kasik <mkasik@redhat.com>
3222-Website=
3223
3224=== removed file 'plugins/print-notifications/test-print-notifications.c'
3225--- plugins/print-notifications/test-print-notifications.c 2012-05-25 13:00:54 +0000
3226+++ plugins/print-notifications/test-print-notifications.c 1970-01-01 00:00:00 +0000
3227@@ -1,7 +0,0 @@
3228-#define NEW gsd_print_notifications_manager_new
3229-#define START gsd_print_notifications_manager_start
3230-#define STOP gsd_print_notifications_manager_stop
3231-#define MANAGER GsdPrintNotificationsManager
3232-#include "gsd-print-notifications-manager.h"
3233-
3234-#include "test-plugin.h"
3235
3236=== modified file 'plugins/xsettings/gsd-xsettings-manager.c'
3237--- plugins/xsettings/gsd-xsettings-manager.c 2016-02-09 09:56:17 +0000
3238+++ plugins/xsettings/gsd-xsettings-manager.c 2016-03-10 23:12:09 +0000
3239@@ -449,40 +449,9 @@
3240 interface_settings = g_hash_table_lookup (manager->priv->settings, INTERFACE_SETTINGS_SCHEMA);
3241 window_scale =
3242 g_settings_get_uint (interface_settings, SCALING_FACTOR_KEY);
3243- if (window_scale == 0) {
3244+ if (window_scale == 0)
3245 window_scale = 1;
3246
3247- /* Under Unity let the shell handle the scaling */
3248- if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)
3249- goto out;
3250-
3251- display = gdk_display_get_default ();
3252- screen = gdk_display_get_default_screen (display);
3253- gdk_screen_get_monitor_geometry (screen, 0, &rect);
3254- width_mm = gdk_screen_get_monitor_width_mm (screen, 0);
3255- height_mm = gdk_screen_get_monitor_height_mm (screen, 0);
3256- monitor_scale = gdk_screen_get_monitor_scale_factor (screen, 0);
3257-
3258- /* Somebody encoded the aspect ratio (16/9 or 16/10)
3259- * instead of the physical size */
3260- if ((width_mm == 160 && height_mm == 90) ||
3261- (width_mm == 160 && height_mm == 100) ||
3262- (width_mm == 16 && height_mm == 9) ||
3263- (width_mm == 16 && height_mm == 10))
3264- goto out;
3265-
3266- if (width_mm > 0 && height_mm > 0) {
3267- dpi_x = (double)rect.width * monitor_scale / (width_mm / 25.4);
3268- dpi_y = (double)rect.height * monitor_scale / (height_mm / 25.4);
3269- /* We don't completely trust these values so both
3270- must be high, and never pick higher ratio than
3271- 2 automatically */
3272- if (dpi_x > HIDPI_LIMIT && dpi_y > HIDPI_LIMIT)
3273- window_scale = 2;
3274- }
3275- }
3276-
3277-out:
3278 return window_scale;
3279 }
3280

Subscribers

People subscribed via source and target branches