diff options
author | Vincent Untz <vuntz@novell.com> | 2008-11-21 00:40:45 +0100 |
---|---|---|
committer | Vincent Untz <vuntz@novell.com> | 2008-11-21 00:40:45 +0100 |
commit | 0045b8483c9a55ff46c9a5b994b58f6157a46803 (patch) | |
tree | da77ed916902b8be74508c3d020726ab68f41d2b | |
parent | e6e79a9b02b9a1f530b76d8016dd45c207461c25 (diff) |
Add cph_cups_is_printer_local(), to make life easier.
-rw-r--r-- | src/cups.c | 30 | ||||
-rw-r--r-- | src/cups.h | 2 |
2 files changed, 32 insertions, 0 deletions
@@ -678,6 +678,9 @@ cph_cups_printer_get_uri (CphCups *cups, g_return_val_if_fail (CPH_IS_CUPS (cups), NULL); + if (!_cph_cups_is_printer_name_valid (cups, printer_name)) + return NULL; + request = ippNewRequest (IPP_GET_PRINTER_ATTRIBUTES); _cph_cups_add_printer_uri (request, printer_name); ippAddStrings (request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, @@ -720,6 +723,33 @@ cph_cups_printer_get_uri (CphCups *cups, } gboolean +cph_cups_is_printer_local (CphCups *cups, + const char *printer_name) +{ + char *uri; + gboolean retval; + + g_return_val_if_fail (CPH_IS_CUPS (cups), FALSE); + + if (!_cph_cups_is_printer_name_valid (cups, printer_name)) + return FALSE; + + uri = cph_cups_printer_get_uri (cups, printer_name); + + /* This can happen, especially since the printer might not exist, or if + * it's actually a class and not a printer. In all cases, it should be + * considered local. */ + if (!uri) + return TRUE; + + retval = cph_cups_is_printer_uri_local (uri); + + g_free (uri); + + return retval; +} + +gboolean cph_cups_printer_add (CphCups *cups, const char *printer_name, const char *printer_uri, @@ -144,6 +144,8 @@ GHashTable *cph_cups_server_get_settings (CphCups *cups); gboolean cph_cups_server_set_settings (CphCups *cups, GHashTable *settings); +gboolean cph_cups_is_printer_local (CphCups *cups, + const char *printer_name); gboolean cph_cups_is_printer_uri_local (const char *uri); |