43
45
ippAddString (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
44
46
"notify-recipient-uri", NULL, "dbus://");
45
47
ippAddInteger (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
46
"notify-lease-duration", 0);
48
"notify-lease-duration", NOTIFY_LEASE_DURATION);
48
50
resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/");
49
51
if (!resp || cupsLastError() != IPP_OK) {
70
renew_subscription (int id)
75
req = ippNewRequest (IPP_RENEW_SUBSCRIPTION);
76
ippAddInteger (req, IPP_TAG_OPERATION, IPP_TAG_INTEGER,
77
"notify-subscription-id", id);
78
ippAddString (req, IPP_TAG_OPERATION, IPP_TAG_URI,
79
"printer-uri", NULL, "/");
80
ippAddString (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_URI,
81
"notify-recipient-uri", NULL, "dbus://");
82
ippAddInteger (req, IPP_TAG_SUBSCRIPTION, IPP_TAG_INTEGER,
83
"notify-lease-duration", NOTIFY_LEASE_DURATION);
85
resp = cupsDoRequest (CUPS_HTTP_DEFAULT, req, "/");
86
if (!resp || cupsLastError() != IPP_OK) {
87
g_warning ("Error renewing CUPS subscription %d: %s\n",
88
id, cupsLastErrorString ());
98
renew_subscription_timeout (gpointer userdata)
100
int *subscription_id = userdata;
102
if (*subscription_id <= 0 || !renew_subscription (*subscription_id))
103
*subscription_id = create_subscription ();
68
110
cancel_subscription (int id)
115
157
gtk_init (&argc, &argv);
117
159
subscription_id = create_subscription ();
160
g_timeout_add_seconds (NOTIFY_LEASE_DURATION - 60,
161
renew_subscription_timeout,
119
164
service = indicator_service_new_version (INDICATOR_PRINTERS_DBUS_NAME,
120
165
INDICATOR_PRINTERS_DBUS_VERSION);