summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@novell.com>2008-11-21 00:40:45 +0100
committerVincent Untz <vuntz@novell.com>2008-11-21 00:40:45 +0100
commit0045b8483c9a55ff46c9a5b994b58f6157a46803 (patch)
treeda77ed916902b8be74508c3d020726ab68f41d2b
parente6e79a9b02b9a1f530b76d8016dd45c207461c25 (diff)
Add cph_cups_is_printer_local(), to make life easier.
-rw-r--r--src/cups.c30
-rw-r--r--src/cups.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/src/cups.c b/src/cups.c
index 1cad376..c1fae3a 100644
--- a/src/cups.c
+++ b/src/cups.c
@@ -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,
diff --git a/src/cups.h b/src/cups.h
index 57964c5..1b069dd 100644
--- a/src/cups.h
+++ b/src/cups.h
@@ -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);