summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Untz <vuntz@novell.com>2008-11-13 15:36:58 +0100
committerVincent Untz <vuntz@novell.com>2008-11-13 15:36:58 +0100
commit53c720bf6cde3f8defe8f7230c4f856b2cbaea2f (patch)
tree488d487286b5cb1623f0451bd0d87d48db1e30ab
parent40726ce8d8abb6cb53fc2e1b1890ade9b0161bdd (diff)
Add infrastructure to have a non-cups internal status.
-rw-r--r--src/cups.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/cups.c b/src/cups.c
index b8d2a24..cfde3be 100644
--- a/src/cups.c
+++ b/src/cups.c
@@ -112,6 +112,7 @@ struct CphCupsPrivate
{
http_t *connection;
ipp_status_t last_status;
+ char *internal_status;
};
static GObject *cph_cups_constructor (GType type,
@@ -166,6 +167,7 @@ cph_cups_init (CphCups *cups)
cups->priv->connection = NULL;
cups->priv->last_status = IPP_OK;
+ cups->priv->internal_status = NULL;
}
static void
@@ -182,6 +184,10 @@ cph_cups_finalize (GObject *object)
httpClose (cups->priv->connection);
cups->priv->connection = NULL;
+ if (cups->priv->internal_status)
+ g_free (cups->priv->internal_status);
+ cups->priv->internal_status = NULL;
+
G_OBJECT_CLASS (cph_cups_parent_class)->finalize (object);
}
@@ -245,6 +251,19 @@ _cph_cups_add_class_uri (ipp_t *request,
}
static void
+_cph_cups_set_internal_status (CphCups *cups,
+ const char *status)
+{
+ if (cups->priv->internal_status)
+ g_free (cups->priv->internal_status);
+
+ if (status)
+ cups->priv->internal_status = g_strdup (status);
+ else
+ cups->priv->internal_status = NULL;
+}
+
+static void
_cph_cups_set_error_from_reply (CphCups *cups,
ipp_t *reply)
{
@@ -260,6 +279,9 @@ _cph_cups_handle_reply (CphCups *cups,
{
gboolean retval;
+ /* reset the internal status: we'll use the cups status */
+ _cph_cups_set_internal_status (cups, NULL);
+
if (!reply || reply->request.status.status_code > IPP_OK_CONFLICT) {
retval = FALSE;
_cph_cups_set_error_from_reply (cups, reply);
@@ -378,7 +400,10 @@ cph_cups_last_status_to_string (CphCups *cups)
{
g_return_val_if_fail (CPH_IS_CUPS (cups), "");
- return ippErrorString (cups->priv->last_status);
+ if (cups->priv->internal_status)
+ return cups->priv->internal_status;
+ else
+ return ippErrorString (cups->priv->last_status);
}
gboolean