~khurshid-alam/unity-control-center/sharing-panel

« back to all changes in this revision

Viewing changes to panels/sharing/vino-preferences.c

  • Committer: Khurshid Alam
  • Date: 2018-03-12 14:06:28 UTC
  • Revision ID: khurshid.alam@linuxmail.org-20180312140628-rsnrcib4gttusg2w
Import sharing panel from gnome-control-center
This commit imports sharing panel from gnome-control-center and removes old screen-sharing panel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2003 Sun Microsystems, Inc.
 
3
 * Copyright (C) 2006 Jonh Wendell <wendell@bani.com.br> 
 
4
 * Copyright © 2010 Codethink Limited
 
5
 * Copyright (C) 2013 Intel, Inc
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU General Public License as
 
9
 * published by the Free Software Foundation; either version 2 of the
 
10
 * License, or (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 * Authors:
 
21
 *      Mark McLoughlin <mark@skynet.ie>
 
22
 *      Jonh Wendell <wendell@bani.com.br>
 
23
 *      Ryan Lortie <desrt@desrt.ca>
 
24
 */
 
25
 
 
26
#include "vino-preferences.h"
 
27
#include <string.h>
 
28
 
 
29
#include <glib/gi18n.h>
 
30
 
 
31
gboolean
 
32
vino_get_authtype (GValue   *value,
 
33
                   GVariant *variant,
 
34
                   gpointer  user_data)
 
35
{
 
36
  GVariantIter iter;
 
37
  const gchar *type;
 
38
 
 
39
  g_variant_iter_init (&iter, variant);
 
40
  g_value_set_boolean (value, TRUE);
 
41
 
 
42
  while (g_variant_iter_next (&iter, "s", &type))
 
43
    if (strcmp (type, "none") == 0)
 
44
      g_value_set_boolean (value, FALSE);
 
45
 
 
46
  return TRUE;
 
47
}
 
48
 
 
49
GVariant *
 
50
vino_set_authtype (const GValue       *value,
 
51
                   const GVariantType *type,
 
52
                   gpointer            user_data)
 
53
{
 
54
  const gchar *authtype;
 
55
 
 
56
  if (g_value_get_boolean (value))
 
57
    authtype = "vnc";
 
58
  else
 
59
    authtype = "none";
 
60
 
 
61
  return g_variant_new_strv (&authtype, 1);
 
62
}
 
63
 
 
64
gboolean
 
65
vino_get_password (GValue   *value,
 
66
                   GVariant *variant,
 
67
                   gpointer  user_data)
 
68
{
 
69
  const gchar *setting;
 
70
 
 
71
  setting = g_variant_get_string (variant, NULL);
 
72
 
 
73
  if (strcmp (setting, "keyring") == 0)
 
74
    {
 
75
      /* "keyring" is the default value, even though vino doesn't support it at
 
76
       * the moment */
 
77
 
 
78
      g_value_set_static_string (value, "");
 
79
      return TRUE;
 
80
    }
 
81
  else
 
82
    {
 
83
      gchar *decoded;
 
84
      gsize length;
 
85
      gboolean ok;
 
86
 
 
87
      decoded = (gchar *) g_base64_decode (setting, &length);
 
88
 
 
89
      if ((ok = g_utf8_validate (decoded, length, NULL)))
 
90
        g_value_take_string (value, g_strndup (decoded, length));
 
91
 
 
92
      return ok;
 
93
    }
 
94
}
 
95
 
 
96
GVariant *
 
97
vino_set_password (const GValue       *value,
 
98
                   const GVariantType *type,
 
99
                   gpointer            user_data)
 
100
{
 
101
  const gchar *string;
 
102
  gchar *base64;
 
103
 
 
104
  string = g_value_get_string (value);
 
105
 
 
106
  base64 = g_base64_encode ((guchar *) string, strlen (string));
 
107
  return g_variant_new_from_data (G_VARIANT_TYPE_STRING,
 
108
                                  base64, strlen (base64) + 1,
 
109
                                  TRUE, g_free, base64);
 
110
}
 
111