- Add parameters to DevicesGet method.
This commit is contained in:
parent
e3be48c509
commit
9f092f3bd3
@ -1,6 +1,6 @@
|
|||||||
Name: cups-pk-helper
|
Name: cups-pk-helper
|
||||||
Version: 0.0.4
|
Version: 0.0.4
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
Summary: A helper that makes system-config-printer use PolicyKit
|
Summary: A helper that makes system-config-printer use PolicyKit
|
||||||
|
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
@ -70,6 +70,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 13 2009 Marek Kasik <mkasik@redhat.com> - 0.0.4-5
|
||||||
|
- Add parameters to DevicesGet method.
|
||||||
|
|
||||||
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.4-4
|
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.0.4-4
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- cups-pk-helper-0.0.4/src/cups.c 2009-03-04 13:41:53.000000000 +0100
|
--- cups-pk-helper-0.0.4/src/cups.c 2009-03-04 13:41:53.000000000 +0100
|
||||||
+++ cups-pk-helper-0.0.4/src/cups.c 2009-07-16 12:49:46.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/cups.c 2009-08-13 12:15:47.000000000 +0200
|
||||||
@@ -58,7 +58,7 @@
|
@@ -58,7 +58,7 @@
|
||||||
getPPDs
|
getPPDs
|
||||||
getServerPPD
|
getServerPPD
|
||||||
@ -9,11 +9,17 @@
|
|||||||
getJobs
|
getJobs
|
||||||
getJobAttributes
|
getJobAttributes
|
||||||
~!+* cancelJob
|
~!+* cancelJob
|
||||||
@@ -1807,6 +1807,89 @@ cph_cups_job_get_status (CphCups *cup
|
@@ -1807,6 +1807,192 @@ cph_cups_job_get_status (CphCups *cup
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
+void get_devices_cb (const char *device_class,
|
+struct _CphCupsGetDevices {
|
||||||
|
+ int iter;
|
||||||
|
+ GHashTable *hash;
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+_cph_cups_get_devices_cb (const char *device_class,
|
||||||
+ const char *device_id,
|
+ const char *device_id,
|
||||||
+ const char *device_info,
|
+ const char *device_info,
|
||||||
+ const char *device_make_and_model,
|
+ const char *device_make_and_model,
|
||||||
@ -21,104 +27,207 @@
|
|||||||
+ const char *device_location,
|
+ const char *device_location,
|
||||||
+ void *user_data)
|
+ void *user_data)
|
||||||
+{
|
+{
|
||||||
+ GHashTable *hash = (GHashTable*) user_data;
|
+ struct _CphCupsGetDevices *data = user_data;
|
||||||
+ int iter;
|
|
||||||
+
|
+
|
||||||
+ g_return_if_fail (hash != NULL);
|
+ g_return_if_fail (data != NULL);
|
||||||
+
|
+
|
||||||
+ iter = atoi (g_hash_table_lookup (hash, "iter"));
|
+ if (device_class && device_class[0] != '\0')
|
||||||
+ iter++;
|
+ g_hash_table_replace (data->hash,
|
||||||
+
|
+ g_strdup_printf ("device-class:%d",
|
||||||
+ if (device_class && strlen (device_class) > 0)
|
+ data->iter),
|
||||||
+ g_hash_table_replace (hash,
|
|
||||||
+ g_strdup_printf ("device-class:%d", iter),
|
|
||||||
+ g_strdup (device_class));
|
+ g_strdup (device_class));
|
||||||
+ if (device_id && strlen (device_id) > 0)
|
+ if (device_id && device_id[0] != '\0')
|
||||||
+ g_hash_table_replace (hash,
|
+ g_hash_table_replace (data->hash,
|
||||||
+ g_strdup_printf ("device-id:%d", iter),
|
+ g_strdup_printf ("device-id:%d",
|
||||||
|
+ data->iter),
|
||||||
+ g_strdup (device_id));
|
+ g_strdup (device_id));
|
||||||
+ if (device_info && strlen (device_info) > 0)
|
+ if (device_info && device_info[0] != '\0')
|
||||||
+ g_hash_table_replace (hash,
|
+ g_hash_table_replace (data->hash,
|
||||||
+ g_strdup_printf ("device-info:%d", iter),
|
+ g_strdup_printf ("device-info:%d",
|
||||||
|
+ data->iter),
|
||||||
+ g_strdup (device_info));
|
+ g_strdup (device_info));
|
||||||
+ if (device_make_and_model && strlen (device_make_and_model) > 0)
|
+ if (device_make_and_model && device_make_and_model[0] != '\0')
|
||||||
+ g_hash_table_replace (hash,
|
+ g_hash_table_replace (data->hash,
|
||||||
+ g_strdup_printf ("device-make-and-model:%d", iter),
|
+ g_strdup_printf ("device-make-and-model:%d",
|
||||||
|
+ data->iter),
|
||||||
+ g_strdup (device_make_and_model));
|
+ g_strdup (device_make_and_model));
|
||||||
+ if (device_uri && strlen (device_uri) > 0)
|
+ if (device_uri && device_uri[0] != '\0')
|
||||||
+ g_hash_table_replace (hash,
|
+ g_hash_table_replace (data->hash,
|
||||||
+ g_strdup_printf ("device-uri:%d", iter),
|
+ g_strdup_printf ("device-uri:%d",
|
||||||
|
+ data->iter),
|
||||||
+ g_strdup (device_uri));
|
+ g_strdup (device_uri));
|
||||||
+ if (device_location && strlen (device_location) > 0)
|
+ if (device_location && device_location[0] != '\0')
|
||||||
+ g_hash_table_replace (hash,
|
+ g_hash_table_replace (data->hash,
|
||||||
+ g_strdup_printf ("device-location:%d ", iter),
|
+ g_strdup_printf ("device-location:%d ",
|
||||||
|
+ data->iter),
|
||||||
+ g_strdup (device_location));
|
+ g_strdup (device_location));
|
||||||
+ g_hash_table_replace (hash,
|
+
|
||||||
+ g_strdup ("iter"),
|
+ data->iter++;
|
||||||
+ g_strdup_printf ("%d", iter));
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+GHashTable *cph_cups_devices_get (CphCups *cups)
|
+GHashTable *
|
||||||
|
+cph_cups_devices_get (CphCups *cups,
|
||||||
|
+ int timeout,
|
||||||
|
+ const char *include_schemes,
|
||||||
|
+ const char *exclude_schemes)
|
||||||
+{
|
+{
|
||||||
+ int retval;
|
+ struct _CphCupsGetDevices data;
|
||||||
+ GHashTable *hash;
|
+ char *error_str;
|
||||||
+ cups_option_t *settings;
|
|
||||||
+ int num_settings, i;
|
|
||||||
+
|
+
|
||||||
+ g_return_val_if_fail (CPH_IS_CUPS (cups), NULL);
|
+ g_return_val_if_fail (CPH_IS_CUPS (cups), NULL);
|
||||||
+
|
+
|
||||||
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
+ data.iter = 0;
|
||||||
|
+ data.hash = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||||
+ g_free, g_free);
|
+ g_free, g_free);
|
||||||
+
|
+
|
||||||
+ g_hash_table_replace (hash,
|
+#if (CUPS_VERSION_MAJOR == 1 && CUPS_VERSION_MINOR >= 4) || CUPS_VERSION_MAJOR > 1
|
||||||
+ g_strdup ("iter"),
|
+ ipp_status_t retval;
|
||||||
+ g_strdup ("-1"));
|
+ int timeout_param = CUPS_TIMEOUT_DEFAULT;
|
||||||
|
+ char *include_schemes_param = (char *) CUPS_INCLUDE_ALL;
|
||||||
|
+ char *exclude_schemes_param = (char *) CUPS_EXCLUDE_NONE;
|
||||||
|
+
|
||||||
|
+ if (timeout > 0)
|
||||||
|
+ timeout_param = timeout;
|
||||||
|
+
|
||||||
|
+ if (include_schemes && strlen (include_schemes) > 0)
|
||||||
|
+ include_schemes_param = g_strdup (include_schemes);
|
||||||
|
+
|
||||||
|
+ if (exclude_schemes && strlen (exclude_schemes) > 0)
|
||||||
|
+ exclude_schemes_param = g_strdup (exclude_schemes);
|
||||||
+
|
+
|
||||||
+ retval = cupsGetDevices (cups->priv->connection,
|
+ retval = cupsGetDevices (cups->priv->connection,
|
||||||
+ CUPS_TIMEOUT_DEFAULT,
|
+ timeout_param,
|
||||||
+ CUPS_INCLUDE_ALL,
|
+ include_schemes_param,
|
||||||
+ CUPS_EXCLUDE_NONE,
|
+ exclude_schemes_param,
|
||||||
+ get_devices_cb,
|
+ _cph_cups_get_devices_cb,
|
||||||
+ hash);
|
+ &data);
|
||||||
+
|
+
|
||||||
+ if (retval != IPP_OK) {
|
+ g_free (include_schemes_param);
|
||||||
+ char *error;
|
+ g_free (exclude_schemes_param);
|
||||||
+
|
+
|
||||||
+ error = g_strdup_printf ("Can not get devices.");
|
+ if (retval != IPP_OK)
|
||||||
+ _cph_cups_set_internal_status (cups, error);
|
+ goto error;
|
||||||
+ g_free (error);
|
+#else
|
||||||
|
+ ipp_t *request;
|
||||||
|
+ const char *resource_char;
|
||||||
|
+ ipp_t *reply;
|
||||||
|
+ ipp_attribute_t *attr;
|
||||||
|
+ const char *device_class;
|
||||||
|
+ const char *device_id;
|
||||||
|
+ const char *device_info;
|
||||||
|
+ const char *device_location;
|
||||||
|
+ const char *device_make_and_model;
|
||||||
|
+ const char *device_uri;
|
||||||
+
|
+
|
||||||
+ return NULL;
|
+ request = ippNewRequest (CUPS_GET_DEVICES);
|
||||||
|
+ resource_char = _cph_cups_get_resource (CPH_RESOURCE_ROOT);
|
||||||
|
+ reply = cupsDoRequest (cups->priv->connection,
|
||||||
|
+ request, resource_char);
|
||||||
|
+
|
||||||
|
+ if (!reply)
|
||||||
|
+ goto error;
|
||||||
|
+
|
||||||
|
+ for (attr = reply->attrs; attr; attr = attr->next) {
|
||||||
|
+ while (attr && attr->group_tag != IPP_TAG_PRINTER)
|
||||||
|
+ attr = attr->next;
|
||||||
|
+
|
||||||
|
+ if (attr == NULL)
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ device_class = NULL;
|
||||||
|
+ device_id = NULL;
|
||||||
|
+ device_info = NULL;
|
||||||
|
+ device_location = "";
|
||||||
|
+ device_make_and_model = NULL;
|
||||||
|
+ device_uri = NULL;
|
||||||
|
+
|
||||||
|
+ while (attr && attr->group_tag == IPP_TAG_PRINTER) {
|
||||||
|
+ g_message ("name: %s", attr->name);
|
||||||
|
+ if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-class") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_KEYWORD)
|
||||||
|
+ device_class = g_strdup (attr->values[0].string.text);
|
||||||
|
+ else if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-id") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_TEXT)
|
||||||
|
+ device_id = g_strdup (attr->values[0].string.text);
|
||||||
|
+ else if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-info") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_TEXT)
|
||||||
|
+ device_info = g_strdup (attr->values[0].string.text);
|
||||||
|
+ else if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-location") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_TEXT)
|
||||||
|
+ device_location = g_strdup (attr->values[0].string.text);
|
||||||
|
+ else if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-make-and-model") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_TEXT)
|
||||||
|
+ device_make_and_model = g_strdup (attr->values[0].string.text);
|
||||||
|
+ else if (attr->name &&
|
||||||
|
+ strcmp (attr->name, "device-uri") == 0 &&
|
||||||
|
+ attr->value_tag == IPP_TAG_URI)
|
||||||
|
+ device_uri = g_strdup (attr->values[0].string.text);
|
||||||
|
+
|
||||||
|
+ attr = attr->next;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ g_hash_table_remove (hash, "iter");
|
+ if (device_class && device_id && device_info && device_make_and_model &&
|
||||||
|
+ device_uri)
|
||||||
|
+ _cph_cups_get_devices_cb (device_class,
|
||||||
|
+ device_id,
|
||||||
|
+ device_info,
|
||||||
|
+ device_make_and_model,
|
||||||
|
+ device_uri,
|
||||||
|
+ device_location,
|
||||||
|
+ &data);
|
||||||
+
|
+
|
||||||
+ return hash;
|
+ if (attr == NULL)
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ ippDelete (reply);
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ return data.hash;
|
||||||
|
+
|
||||||
|
+error:
|
||||||
|
+ error_str = g_strdup ("Can not get devices.");
|
||||||
|
+ _cph_cups_set_internal_status (cups, error_str);
|
||||||
|
+ g_hash_table_destroy (data.hash);
|
||||||
|
+ g_free (error_str);
|
||||||
|
+
|
||||||
|
+ return NULL;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
/******************************************************
|
/******************************************************
|
||||||
* Non-object functions
|
* Non-object functions
|
||||||
******************************************************/
|
******************************************************/
|
||||||
--- cups-pk-helper-0.0.4/src/cups.h 2009-02-28 03:38:13.000000000 +0100
|
--- cups-pk-helper-0.0.4/src/cups.h 2009-02-28 03:38:13.000000000 +0100
|
||||||
+++ cups-pk-helper-0.0.4/src/cups.h 2009-07-16 12:50:44.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/cups.h 2009-08-13 12:16:08.000000000 +0200
|
||||||
@@ -184,6 +184,8 @@ CphJobStatus cph_cups_job_get_status (Cp
|
@@ -184,6 +184,11 @@ CphJobStatus cph_cups_job_get_status (Cp
|
||||||
int job_id,
|
int job_id,
|
||||||
const char *user);
|
const char *user);
|
||||||
|
|
||||||
+GHashTable *cph_cups_devices_get (CphCups *cups);
|
+GHashTable *cph_cups_devices_get (CphCups *cups,
|
||||||
|
+ int timeout,
|
||||||
|
+ const char *include_schemes,
|
||||||
|
+ const char *exclude_schemes);
|
||||||
+
|
+
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* CPH_CUPS_H */
|
#endif /* CPH_CUPS_H */
|
||||||
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-07-16 12:46:03.000000000 +0200
|
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-08-13 12:14:09.000000000 +0200
|
||||||
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-07-16 12:52:02.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-08-13 12:16:48.000000000 +0200
|
||||||
@@ -1103,3 +1103,21 @@ cph_mechanism_job_set_hold_until (CphMec
|
@@ -1103,3 +1103,27 @@ cph_mechanism_job_set_hold_until (CphMec
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
+
|
+
|
||||||
+gboolean
|
+gboolean
|
||||||
+cph_mechanism_devices_get (CphMechanism *mechanism,
|
+cph_mechanism_devices_get (CphMechanism *mechanism,
|
||||||
|
+ int timeout,
|
||||||
|
+ const char *include_schemes,
|
||||||
|
+ const char *exclude_schemes,
|
||||||
+ DBusGMethodInvocation *context)
|
+ DBusGMethodInvocation *context)
|
||||||
+{
|
+{
|
||||||
+ GHashTable *devices;
|
+ GHashTable *devices;
|
||||||
@ -128,41 +237,50 @@
|
|||||||
+ if (!_check_polkit_for_action (mechanism, context, "devices-get"))
|
+ if (!_check_polkit_for_action (mechanism, context, "devices-get"))
|
||||||
+ return FALSE;
|
+ return FALSE;
|
||||||
+
|
+
|
||||||
+ devices = cph_cups_devices_get (mechanism->priv->cups);
|
+ devices = cph_cups_devices_get (mechanism->priv->cups,
|
||||||
|
+ timeout,
|
||||||
|
+ include_schemes,
|
||||||
|
+ exclude_schemes);
|
||||||
+ _cph_mechanism_return_error_and_value (mechanism, context,
|
+ _cph_mechanism_return_error_and_value (mechanism, context,
|
||||||
+ devices == NULL, devices);
|
+ devices == NULL, devices);
|
||||||
+
|
+
|
||||||
+ return TRUE;
|
+ return TRUE;
|
||||||
+}
|
+}
|
||||||
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.h 2009-02-28 03:38:13.000000000 +0100
|
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.h 2009-02-28 03:38:13.000000000 +0100
|
||||||
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.h 2009-07-16 12:52:37.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.h 2009-08-13 12:17:10.000000000 +0200
|
||||||
@@ -236,6 +236,10 @@ cph_mechanism_job_set_hold_until (CphMec
|
@@ -236,6 +236,13 @@ cph_mechanism_job_set_hold_until (CphMec
|
||||||
const char *job_hold_until,
|
const char *job_hold_until,
|
||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
|
|
||||||
+gboolean
|
+gboolean
|
||||||
+cph_mechanism_devices_get (CphMechanism *mechanism,
|
+cph_mechanism_devices_get (CphMechanism *mechanism,
|
||||||
|
+ int timeout,
|
||||||
|
+ const char *include_schemes,
|
||||||
|
+ const char *exclude_schemes,
|
||||||
+ DBusGMethodInvocation *context);
|
+ DBusGMethodInvocation *context);
|
||||||
+
|
+
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* CPH_MECHANISM_H */
|
#endif /* CPH_MECHANISM_H */
|
||||||
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.xml 2009-02-28 03:38:13.000000000 +0100
|
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.xml 2009-02-28 03:38:13.000000000 +0100
|
||||||
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.xml 2009-07-16 12:53:27.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.xml 2009-08-13 12:17:36.000000000 +0200
|
||||||
@@ -192,5 +192,11 @@
|
@@ -192,5 +192,14 @@
|
||||||
<arg name="job_hold_until" direction="in" type="s"/>
|
<arg name="job_hold_until" direction="in" type="s"/>
|
||||||
<arg name="error" direction="out" type="s"/>
|
<arg name="error" direction="out" type="s"/>
|
||||||
</method>
|
</method>
|
||||||
+
|
+
|
||||||
+ <method name="DevicesGet">
|
+ <method name="DevicesGet">
|
||||||
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
|
||||||
|
+ <arg name="timeout" direction="in" type="i"/>
|
||||||
|
+ <arg name="include_schemes" direction="in" type="s"/>
|
||||||
|
+ <arg name="exclude_schemes" direction="in" type="s"/>
|
||||||
+ <arg name="error" direction="out" type="s"/>
|
+ <arg name="error" direction="out" type="s"/>
|
||||||
+ <arg name="devices" direction="out" type="a{ss}"/>
|
+ <arg name="devices" direction="out" type="a{ss}"/>
|
||||||
+ </method>
|
+ </method>
|
||||||
</interface>
|
</interface>
|
||||||
</node>
|
</node>
|
||||||
--- cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-07-16 12:46:03.000000000 +0200
|
--- cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-08-13 12:14:09.000000000 +0200
|
||||||
+++ cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-07-16 12:53:57.000000000 +0200
|
+++ cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-08-13 12:18:24.000000000 +0200
|
||||||
@@ -86,6 +86,15 @@
|
@@ -86,6 +86,15 @@
|
||||||
</defaults>
|
</defaults>
|
||||||
</action>
|
</action>
|
||||||
|
Loading…
Reference in New Issue
Block a user