~ubuntu-branches/ubuntu/precise/tumbler/precise

« back to all changes in this revision

Viewing changes to tumbler/tumbler-util.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2010-11-07 16:34:58 UTC
  • Revision ID: james.westby@ubuntu.com-20101107163458-skwfq34vnuavipne
Tags: upstream-0.1.4
ImportĀ upstreamĀ versionĀ 0.1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi:set et ai sw=2 sts=2 ts=2: */
 
2
/*-
 
3
 * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Library General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 
13
 * GNU Library General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Library General 
 
16
 * Public License along with this library; if not, write to the 
 
17
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
18
 * Boston, MA 02110-1301, USA.
 
19
 */
 
20
 
 
21
#ifdef HAVE_CONFIG_H
 
22
#include <config.h>
 
23
#endif
 
24
 
 
25
#include <glib.h>
 
26
#include <gio/gio.h>
 
27
 
 
28
#include <tumbler/tumbler-util.h>
 
29
 
 
30
 
 
31
 
 
32
GStrv
 
33
tumbler_util_get_supported_uri_schemes (void)
 
34
{
 
35
  const gchar *const *vfs_schemes;
 
36
  GStrv               uri_schemes;
 
37
  gboolean            file_scheme_found = FALSE;
 
38
  guint               length;
 
39
  guint               n;
 
40
  GVfs               *vfs;
 
41
 
 
42
  /* determine the URI schemes supported by GIO */
 
43
  vfs = g_vfs_get_default ();
 
44
  vfs_schemes = g_vfs_get_supported_uri_schemes (vfs);
 
45
 
 
46
  /* search for the "file" scheme */
 
47
  for (n = 0; !file_scheme_found && vfs_schemes[n] != NULL; ++n)
 
48
    if (g_strcmp0 (vfs_schemes[n], "file") == 0)
 
49
      file_scheme_found = TRUE;
 
50
 
 
51
  /* check if the "file" scheme is included */
 
52
  if (file_scheme_found)
 
53
    {
 
54
      /* it is, so simply copy the array */
 
55
      uri_schemes = g_strdupv ((GStrv) vfs_schemes);
 
56
    }
 
57
  else
 
58
    {
 
59
      /* it is not, so we need to copy the array and add "file" */
 
60
      length = g_strv_length ((GStrv) vfs_schemes);
 
61
      uri_schemes = g_new0 (gchar *, length + 2);
 
62
      uri_schemes[0] = g_strdup ("file");
 
63
      for (n = 1; n <= length; ++n)
 
64
        uri_schemes[n] = g_strdup (vfs_schemes[n-1]);
 
65
      uri_schemes[n] = NULL;
 
66
    }
 
67
 
 
68
  return uri_schemes;
 
69
}