~ubuntu-branches/ubuntu/raring/grilo/raring

« back to all changes in this revision

Viewing changes to libs/net/grl-net-private.c

  • Committer: Package Import Robot
  • Author(s): Alberto Garcia
  • Date: 2012-05-24 18:05:32 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20120524180532-ccftaeh72upen313
Tags: 0.1.19-1
* New upstream release.
* Build using Vala 0.16:
  - debian/control: update build dependencies.
  - debian/rules: install Vala API files in /usr/share/vala/vapi.
  - debian/libgrilo-0.1-dev.install: update path of Vala API files.
* Create a new libgrilo-0.1-bin package and move grl-inspect-0.1 there.
  - debian/rules: rename manpage to match the binary name.
* Drop libgrilo-0.1-0.shlibs and use dh_makeshlibs to generate a shlibs
  file.
* Multi-arch support:
  - debian/compat: set compatibility level to 9.
  - debian/control: build depend on debhelper >= 9.
  - debian/control: Add Multi-Arch and Pre-Depends fields to
    libgrilo-0.1-0.
  - debian/libgrilo-0.1-{0,dev}.install: replace usr/lib/ with
    usr/lib/*/.
  - bump shlibs to 0.1.19 and break grilo-plugins-0.1 << 0.1.19.
* libgrilo-0.1-{0,bin}.lintian-overrides: ignore the
  hardening-no-stackprotector warning, Grilo does not use character
  arrays on the stack.
* debian/copyright: update copyright years and add section for Debian
  files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Igalia S.L.
 
3
 *
 
4
 * Contact: Iago Toral Quiroga <itoral@igalia.com>
 
5
 *
 
6
 * Authors: Víctor M. Jáquez L. <vjaquez@igalia.com>
 
7
 *          Juan A. Suarez Romero <jasuarez@igalia.com>
 
8
 *
 
9
 * This library is free software; you can redistribute it and/or
 
10
 * modify it under the terms of the GNU Lesser General Public License
 
11
 * as published by the Free Software Foundation; version 2.1 of
 
12
 * the License, or (at your option) any later version.
 
13
 *
 
14
 * This library is distributed in the hope that it will be useful, but
 
15
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 
17
 * Lesser General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU Lesser General Public
 
20
 * License along with this library; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 
22
 * 02110-1301 USA
 
23
 *
 
24
 */
 
25
 
 
26
#ifdef HAVE_CONFIG_H
 
27
#include "config.h"
 
28
#endif
 
29
 
 
30
#include "grl-net-private.h"
 
31
 
 
32
void
 
33
parse_error (guint status,
 
34
             const gchar *reason,
 
35
             const gchar *response,
 
36
             GSimpleAsyncResult *result)
 
37
{
 
38
  if (!response || *response == '\0')
 
39
    response = reason;
 
40
 
 
41
  switch (status) {
 
42
  case SOUP_STATUS_CANT_RESOLVE:
 
43
  case SOUP_STATUS_CANT_CONNECT:
 
44
  case SOUP_STATUS_SSL_FAILED:
 
45
  case SOUP_STATUS_IO_ERROR:
 
46
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
47
                                     GRL_NET_WC_ERROR_NETWORK_ERROR,
 
48
                                     "Cannot connect to the server");
 
49
    return;
 
50
  case SOUP_STATUS_CANT_RESOLVE_PROXY:
 
51
  case SOUP_STATUS_CANT_CONNECT_PROXY:
 
52
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
53
                                     GRL_NET_WC_ERROR_PROXY_ERROR,
 
54
                                     "Cannot connect to the proxy server");
 
55
    return;
 
56
  case SOUP_STATUS_INTERNAL_SERVER_ERROR: /* 500 */
 
57
  case SOUP_STATUS_MALFORMED:
 
58
  case SOUP_STATUS_BAD_REQUEST: /* 400 */
 
59
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
60
                                     GRL_NET_WC_ERROR_PROTOCOL_ERROR,
 
61
                                     "Invalid request URI or header: %s",
 
62
                                     response);
 
63
    return;
 
64
  case SOUP_STATUS_UNAUTHORIZED: /* 401 */
 
65
  case SOUP_STATUS_FORBIDDEN: /* 403 */
 
66
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
67
                                     GRL_NET_WC_ERROR_AUTHENTICATION_REQUIRED,
 
68
                                     "Authentication required: %s", response);
 
69
    return;
 
70
  case SOUP_STATUS_NOT_FOUND: /* 404 */
 
71
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
72
                                     GRL_NET_WC_ERROR_NOT_FOUND,
 
73
                                     "The requested resource was not found: %s",
 
74
                                     response);
 
75
    return;
 
76
  case SOUP_STATUS_CONFLICT: /* 409 */
 
77
  case SOUP_STATUS_PRECONDITION_FAILED: /* 412 */
 
78
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
79
                                     GRL_NET_WC_ERROR_CONFLICT,
 
80
                                     "The entry has been modified since it was downloaded: %s",
 
81
                                     response);
 
82
    return;
 
83
  case SOUP_STATUS_CANCELLED:
 
84
    g_simple_async_result_set_error (result, GRL_NET_WC_ERROR,
 
85
                                     GRL_NET_WC_ERROR_CANCELLED,
 
86
                                     "Operation was cancelled");
 
87
    return;
 
88
  default:
 
89
    g_message ("Unhandled status: %s", soup_status_get_phrase (status));
 
90
  }
 
91
}