rpms/cups-pk-helper/F-11 get_devices.patch, NONE, 1.1 cups-pk-helper.spec, 1.7, 1.8
Marek Kašík
mkasik at fedoraproject.org
Thu Jul 16 12:19:49 UTC 2009
Author: mkasik
Update of /cvs/pkgs/rpms/cups-pk-helper/F-11
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16889
Modified Files:
cups-pk-helper.spec
Added Files:
get_devices.patch
Log Message:
* Thu Jul 16 2009 Marek Kasik <mkasik at redhat.com> - 0.0.4-2
- Add devices_get() function.
get_devices.patch:
--- NEW FILE get_devices.patch ---
--- 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 10:41:03.000000000 +0200
@@ -58,7 +58,7 @@
getPPDs
getServerPPD
getDocument
- getDevices
+~!+* getDevices
getJobs
getJobAttributes
~!+* cancelJob
@@ -1807,6 +1807,89 @@ cph_cups_job_get_status (CphCups *cup
return status;
}
+void get_devices_cb (const char *device_class,
+ const char *device_id,
+ const char *device_info,
+ const char *device_make_and_model,
+ const char *device_uri,
+ const char *device_location,
+ void *user_data)
+{
+ GHashTable *hash = (GHashTable*) user_data;
+ int iter;
+
+ g_return_if_fail (hash != NULL);
+
+ iter = atoi (g_hash_table_lookup (hash, "iter"));
+ iter++;
+
+ if (device_class && strlen (device_class) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-class:%d", iter),
+ g_strdup (device_class));
+ if (device_id && strlen (device_id) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-id:%d", iter),
+ g_strdup (device_id));
+ if (device_info && strlen (device_info) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-info:%d", iter),
+ g_strdup (device_info));
+ if (device_make_and_model && strlen (device_make_and_model) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-make-and-model:%d", iter),
+ g_strdup (device_make_and_model));
+ if (device_uri && strlen (device_uri) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-uri:%d", iter),
+ g_strdup (device_uri));
+ if (device_location && strlen (device_location) > 0)
+ g_hash_table_replace (hash,
+ g_strdup_printf ("device-location:%d ", iter),
+ g_strdup (device_location));
+ g_hash_table_replace (hash,
+ g_strdup ("iter"),
+ g_strdup_printf ("%d", iter));
+}
+
+GHashTable *cph_cups_devices_get (CphCups *cups)
+{
+ int retval;
+ GHashTable *hash;
+ cups_option_t *settings;
+ int num_settings, i;
+
+ g_return_val_if_fail (CPH_IS_CUPS (cups), NULL);
+
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_free);
+
+ g_hash_table_replace (hash,
+ g_strdup ("iter"),
+ g_strdup ("-1"));
+
+ retval = cupsGetDevices (cups->priv->connection,
+ CUPS_TIMEOUT_DEFAULT,
+ CUPS_INCLUDE_ALL,
+ CUPS_EXCLUDE_NONE,
+ get_devices_cb,
+ hash);
+
+ if (retval != IPP_OK) {
+ char *error;
+
+ error = g_strdup_printf ("Can not get devices.");
+ _cph_cups_set_internal_status (cups, error);
+ g_free (error);
+
+ return NULL;
+ }
+
+ g_hash_table_remove (hash, "iter");
+
+ return hash;
+}
+
/******************************************************
* 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-07-14 16:27:13.000000000 +0200
@@ -184,6 +184,8 @@ CphJobStatus cph_cups_job_get_status (Cp
int job_id,
const char *user);
+GHashTable *cph_cups_devices_get (CphCups *cups);
+
G_END_DECLS
#endif /* CPH_CUPS_H */
--- cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-02-28 03:38:13.000000000 +0100
+++ cups-pk-helper-0.0.4/src/cups-pk-helper-mechanism.c 2009-07-16 11:07:49.000000000 +0200
@@ -1166,3 +1166,21 @@ cph_mechanism_job_set_hold_until (CphMec
return TRUE;
}
+
+gboolean
+cph_mechanism_devices_get (CphMechanism *mechanism,
+ DBusGMethodInvocation *context)
+{
+ GHashTable *devices;
+
+ reset_killtimer (mechanism);
+
+ if (!_check_polkit_for_action (mechanism, context, "devices-get"))
+ return FALSE;
+
+ devices = cph_cups_devices_get (mechanism->priv->cups);
+ _cph_mechanism_return_error_and_value (mechanism, context,
+ devices == NULL, devices);
+
+ 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-07-14 15:08:09.000000000 +0200
@@ -236,6 +236,10 @@ cph_mechanism_job_set_hold_until (CphMec
const char *job_hold_until,
DBusGMethodInvocation *context);
+gboolean
+cph_mechanism_devices_get (CphMechanism *mechanism,
+ DBusGMethodInvocation *context);
+
G_END_DECLS
#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-07-15 16:29:56.000000000 +0200
@@ -192,5 +192,11 @@
<arg name="job_hold_until" direction="in" type="s"/>
<arg name="error" direction="out" type="s"/>
</method>
+
+ <method name="DevicesGet">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg name="error" direction="out" type="s"/>
+ <arg name="devices" direction="out" type="a{ss}"/>
+ </method>
</interface>
</node>
--- cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-02-28 03:38:13.000000000 +0100
+++ cups-pk-helper-0.0.4/src/org.opensuse.cupspkhelper.mechanism.policy.in 2009-07-16 11:07:12.000000000 +0200
@@ -86,6 +86,15 @@
</defaults>
</action>
+ <action id="org.opensuse.cupspkhelper.mechanism.devices-get">
+ <_description>Get devices</_description>
+ <_message>Privileges are required to get devices.</_message>
+ <defaults>
+ <allow_inactive>no</allow_inactive>
+ <allow_active>auth_admin</allow_active>
+ </defaults>
+ </action>
+
<!-- Deprecated -->
<action id="org.opensuse.cupspkhelper.mechanism.printeraddremove">
<_description>Add/Remove/Edit a printer</_description>
Index: cups-pk-helper.spec
===================================================================
RCS file: /cvs/pkgs/rpms/cups-pk-helper/F-11/cups-pk-helper.spec,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- cups-pk-helper.spec 31 Mar 2009 13:11:35 -0000 1.7
+++ cups-pk-helper.spec 16 Jul 2009 12:19:49 -0000 1.8
@@ -1,6 +1,6 @@
Name: cups-pk-helper
Version: 0.0.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: A helper that makes system-config-printer use PolicyKit
Group: System Environment/Base
@@ -8,6 +8,8 @@ License: GPLv2+
URL: http://www.vuntz.net/download/cups-pk-helper/
Source0: http://www.vuntz.net/download/cups-pk-helper/cups-pk-helper-%{version}.tar.bz2
+Patch0: get_devices.patch
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: cups-devel >= 1.2
@@ -33,6 +35,8 @@ interfaces available under control of Po
%prep
%setup -q
+%patch0 -p1 -b .get-devices
+
%build
%configure
make %{?_smp_mflags}
@@ -58,6 +62,9 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Thu Jul 16 2009 Marek Kasik <mkasik at redhat.com> - 0.0.4-2
+- Add devices_get() function.
+
* Tue Mar 31 2009 Marek Kasik <mkasik at redhat.com> - 0.0.4-1
- Update to 0.0.4
More information about the fedora-extras-commits
mailing list