Commit b30d0133 authored by Thomas Wood's avatar Thomas Wood

Add initial implementation of the new Sharing panel

https://bugzilla.gnome.org/show_bug.cgi?id=687772
parent f3a35fb5
......@@ -165,6 +165,7 @@ PKG_CHECK_MODULES(USER_ACCOUNTS_PANEL, $COMMON_MODULES
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION
pwquality
accountsservice >= $ACCOUNTSSERVICE_REQUIRED_VERSION)
PKG_CHECK_MODULES(SHARING_PANEL, $COMMON_MODULES egg-list-box)
PKG_CHECK_MODULES(GVC, gobject-2.0 libpulse libpulse-mainloop-glib)
AM_CONDITIONAL(HAVE_INTROSPECTION, false)
......@@ -432,6 +433,8 @@ panels/online-accounts/icons/48x48/Makefile
panels/online-accounts/icons/256x256/Makefile
panels/search/Makefile
panels/search/gnome-search-panel.desktop.in
panels/sharing/Makefile
panels/sharing/gnome-sharing-panel.desktop.in
panels/sound/Makefile
panels/sound/gvc/Makefile
panels/sound/data/Makefile
......
......@@ -234,6 +234,14 @@
and screen lock behavior.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>sharing</option></term>
<listitem><para>The sharing panel contains
settings that control what is shared over the
network.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>sound</option></term>
......
......@@ -16,7 +16,8 @@ SUBDIRS= \
user-accounts \
datetime \
search \
privacy
privacy \
sharing
if BUILD_WACOM
SUBDIRS += wacom
......
# This is used in PANEL_CFLAGS
cappletname = sharing
uidir = $(pkgdatadir)/ui/sharing
AM_CPPFLAGS = \
$(PANEL_CFLAGS) \
$(SHARING_PANEL_CFLAGS) \
$(NULL)
noinst_LTLIBRARIES = libsharing.la
BUILT_SOURCES = \
cc-sharing-resources.c \
cc-sharing-resources.h \
$(NULL)
libsharing_la_SOURCES = \
$(BUILT_SOURCES) \
cc-sharing-panel.c \
cc-sharing-panel.h \
cc-remote-login.c \
cc-remote-login.h \
cc-media-sharing.c \
cc-media-sharing.h \
vino-preferences.c \
vino-preferences.h \
file-share-properties.c \
file-share-properties.h \
$(NULL)
resource_files = $(shell glib-compile-resources --generate-dependencies $(srcdir)/sharing.gresource.xml)
cc-sharing-resources.c: sharing.gresource.xml $(resource_files)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name cc_sharing $<
cc-sharing-resources.h: sharing.gresource.xml $(resource_files)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name cc_sharing $<
libsharing_la_LIBADD = $(PANEL_LIBS) $(SHARING_PANEL_LIBS)
libsharing_la_LDFLAGS = $(PANEL_LDFLAGS)
@INTLTOOL_DESKTOP_RULE@
desktopdir = $(datadir)/applications
desktop_in_files = gnome-sharing-panel.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
CLEANFILES = $(desktop_in_files) $(desktop_DATA)
EXTRA_DIST = $(resource_files)
-include $(top_srcdir)/git.mk
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#include "cc-media-sharing.h"
static GKeyFile*
cc_media_sharing_open_key_file (void)
{
gchar *path;
GKeyFile *file;
file = g_key_file_new ();
path = g_build_filename (g_get_user_config_dir (), "rygel.conf", NULL);
g_key_file_load_from_file (file, path,
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
NULL);
g_free (path);
return file;
}
void
cc_media_sharing_get_preferences (gboolean *enabled,
gchar ***folders)
{
GKeyFile *file;
file = cc_media_sharing_open_key_file ();
if (enabled)
*enabled = g_key_file_get_boolean (file, "general", "upnp-enabled", NULL);
if (folders)
{
gsize length;
gchar **str_list;
str_list = g_key_file_get_string_list (file, "MediaExport", "uris",
&length, NULL);
*folders = str_list;
while (str_list && *str_list)
{
if (g_str_equal (*str_list, "@MUSIC@"))
{
g_free (*str_list);
*str_list = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC));
}
if (g_str_equal (*str_list, "@VIDEOS@"))
{
g_free (*str_list);
*str_list = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS));
}
if (g_str_equal (*str_list, "@PICTURES@"))
{
g_free (*str_list);
*str_list = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES));
}
str_list++;
}
}
g_key_file_free (file);
}
void
cc_media_sharing_set_preferences (gboolean enabled,
gchar **folders)
{
GKeyFile *file;
gchar **str_list;
gchar *path;
gsize length;
gchar *data;
file = cc_media_sharing_open_key_file ();
g_key_file_set_boolean (file, "general", "upnp-enabled", enabled);
str_list = folders;
length = 0;
while (str_list && *str_list)
{
if (g_str_equal (*str_list, g_get_user_special_dir (G_USER_DIRECTORY_MUSIC)))
{
g_free (*str_list);
*str_list = g_strdup ("@MUSIC@");
}
if (g_str_equal (*str_list, g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS)))
{
g_free (*str_list);
*str_list = g_strdup ("@VIDEOS@");
}
if (g_str_equal (*str_list, g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)))
{
g_free (*str_list);
*str_list = g_strdup ("@PICTURES@");
}
str_list++;
length++;
}
g_key_file_set_string_list (file, "MediaExport", "uris", (const gchar**) folders, length);
data = g_key_file_to_data (file, NULL, NULL);
path = g_build_filename (g_get_user_config_dir (), "rygel.conf", NULL);
g_file_set_contents (path, data, -1, NULL);
g_free (path);
g_key_file_free (file);
}
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#ifndef __CC_MEDIA_SHARING_H__
#define __CC_MEDIA_SHARING_H__
#include <glib.h>
void cc_media_sharing_get_preferences (gboolean *enabled, gchar ***folders);
void cc_media_sharing_set_preferences (gboolean enabled, gchar **folders);
#endif /* __CC_MEDIA_SHARING_H__ */
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#include "cc-remote-login.h"
#include <gio/gio.h>
#define SSHD_SERVICE "sshd.service"
static void
active_state_ready_callback (GObject *source_object,
GAsyncResult *result,
gpointer gtkswitch)
{
GVariant *active_variant, *tmp_variant;
const gchar *active_state;
gboolean active;
GError *error = NULL;
active_variant = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
result, &error);
if (!active_variant)
{
g_warning ("Error getting remote login state: %s", error->message);
g_clear_error (&error);
return;
}
g_variant_get (active_variant, "(v)", &tmp_variant);
active_state = g_variant_get_string (tmp_variant, NULL);
active = g_str_equal (active_state, "active");
g_variant_unref (active_variant);
g_variant_unref (tmp_variant);
/* set the switch to the correct state */
gtk_switch_set_active (gtkswitch, active);
/* TODO: enable the switch when cc_remote_login_set_enabled is implemented */
/* gtk_widget_set_sensitive (gtkswitch, TRUE); */
}
static void
path_ready_callback (GObject *source_object,
GAsyncResult *result,
gpointer gtkswitch)
{
GVariant *path_variant;
gchar *object_path;
GError *error = NULL;
path_variant = g_dbus_connection_call_finish (G_DBUS_CONNECTION (source_object),
result, &error);
if (!path_variant)
{
g_warning ("Error getting remote login state: %s", error->message);
g_clear_error (&error);
return;
}
g_variant_get (path_variant, "(o)", &object_path);
g_dbus_connection_call (G_DBUS_CONNECTION (source_object),
"org.freedesktop.systemd1",
object_path,
"org.freedesktop.DBus.Properties",
"Get",
g_variant_new ("(ss)",
"org.freedesktop.systemd1.Unit",
"ActiveState"),
(GVariantType*) "(v)",
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
active_state_ready_callback,
gtkswitch);
g_variant_unref (path_variant);
}
static void
bus_ready_callback (GObject *source_object,
GAsyncResult *result,
gpointer gtkswitch)
{
GDBusConnection *connection;
GError *error = NULL;
connection = g_bus_get_finish (result, &error);
if (!connection)
{
g_warning ("Error getting remote login state: %s", error->message);
g_clear_error (&error);
return;
}
g_dbus_connection_call (connection,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
"GetUnit",
g_variant_new ("(s)", SSHD_SERVICE),
(GVariantType*) "(o)",
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
path_ready_callback,
gtkswitch);
}
void
cc_remote_login_get_enabled (GtkSwitch *gtkswitch)
{
/* disable the switch until the current state is known */
gtk_widget_set_sensitive (gtkswitch, FALSE);
g_bus_get (G_BUS_TYPE_SYSTEM, NULL, bus_ready_callback, gtkswitch);
}
gboolean
cc_remote_login_set_enabled (gboolean enabled)
{
/* not implemented yet */
return FALSE;
}
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#ifndef __CC_REMOTE_LOGIN_H__
#define __CC_REMOTE_LOGIN_H__
#include <gtk/gtk.h>
void cc_remote_login_get_enabled (GtkSwitch *gtkswitch);
gboolean cc_remote_login_set_enabled (gboolean enabled);
#endif /* __CC_REMOTE_LOGIN_H__ **/
This diff is collapsed.
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Author: Thomas Wood <thomas.wood@intel.com>
*
*/
#ifndef __CC_SHARING_PANEL_H__
#define __CC_SHARING_PANEL_H__
#include <shell/cc-shell.h>
G_BEGIN_DECLS
#define CC_TYPE_SHARING_PANEL cc_sharing_panel_get_type()
#define CC_SHARING_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CC_TYPE_SHARING_PANEL, CcSharingPanel))
#define CC_SHARING_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CC_TYPE_SHARING_PANEL, CcSharingPanelClass))
#define CC_SHARING_IS_PANEL(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CC_TYPE_SHARING_PANEL))
#define CC_SHARING_IS_PANEL_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CC_TYPE_SHARING_PANEL))
#define CC_SHARING_PANEL_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CC_TYPE_SHARING_PANEL, CcSharingPanelClass))
typedef struct _CcSharingPanel CcSharingPanel;
typedef struct _CcSharingPanelClass CcSharingPanelClass;
typedef struct _CcSharingPanelPrivate CcSharingPanelPrivate;
struct _CcSharingPanel
{
CcPanel parent;
CcSharingPanelPrivate *priv;
};
struct _CcSharingPanelClass
{
CcPanelClass parent_class;
};
GType cc_sharing_panel_get_type (void) G_GNUC_CONST;
CcSharingPanel *cc_sharing_panel_new (void);
G_END_DECLS
#endif /* __CC_SHARING_PANEL_H__ */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Copyright (C) 2004 Red Hat, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* Nautilus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Authors: Alexander Larsson <alexl@redhat.com>
*
*/
#include "file-share-properties.h"
#include <string.h>
#include <stdio.h>
#include <glib.h>
#define REALM "Please log in as the user guest"
#define USER "guest"
void
file_share_write_out_password (const char *password)
{
char *to_hash;
char *ascii_digest;
char *line;
char *filename;
FILE *file;
to_hash = g_strdup_printf ("%s:%s:%s", USER, REALM, password);
ascii_digest = g_compute_checksum_for_string (G_CHECKSUM_MD5, to_hash, strlen (to_hash));
g_free (to_hash);
line = g_strdup_printf ("%s:%s:%s\n", USER, REALM, ascii_digest);
g_free (ascii_digest);
filename = g_build_filename (g_get_user_config_dir (), "user-share", "passwd", NULL);
file = fopen (filename, "w");
if (file != NULL) {
fwrite (line, strlen (line), 1, file);
fclose (file);
}
g_free (filename);
g_free (line);
}
/*
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef __FILE_SHARE_PROPERTIES_H__
#define __FILE_SHARE_PROPERTIES_H__
void file_share_write_out_password (const char *password);
#endif /* __FILE_SHARE_PROPERTIES_H__ */
[Desktop Entry]
_Name=Sharing
_Comment=Sharing
Exec=gnome-control-center sharing
Icon=preferences-desktop-sharing
Terminal=false
Type=Application
StartupNotify=true
Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PersonalSettings
OnlyShowIn=GNOME;Unity;
X-GNOME-Settings-Panel=sharing
# Translators: those are keywords for the sharing control-center panel
_Keywords=Share, sharing, ssh, host, name, remote, desktop, bluetooth, obex
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/control-center/sharing">
<file preprocess="xml-stripblanks">sharing.ui</file>
</gresource>
</gresources>
This diff is collapsed.
/*
* Copyright (C) 2003 Sun Microsystems, Inc.
* Copyright (C) 2006 Jonh Wendell <wendell@bani.com.br>
* Copyright © 2010 Codethink Limited
* Copyright (C) 2013 Intel, Inc
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Authors:
* Mark McLoughlin <mark@skynet.ie>
* Jonh Wendell <wendell@bani.com.br>
* Ryan Lortie <desrt@desrt.ca>
*/
#include "vino-preferences.h"
#include <string.h>
#include <glib/gi18n.h>
gboolean
vino_get_authtype (GValue *value,
GVariant *variant,
gpointer user_data)
{
GVariantIter iter;
const gchar *type;
g_variant_iter_init (&iter, variant);
g_value_set_boolean (value, TRUE);
while (g_variant_iter_next (&iter, "s", &type))
if (strcmp (type, "none") == 0)
g_value_set_boolean (value, FALSE);
return TRUE;
}
GVariant *
vino_set_authtype (const GValue *value,
const GVariantType *type,
gpointer user_data)
{
const gchar *authtype;
if (g_value_get_boolean (value))
authtype = "vnc";
else
authtype = "none";
return g_variant_new_strv (&authtype, 1);
}
gboolean
vino_get_password (GValue *value,
GVariant *variant,
gpointer user_data)
{
const gchar *setting;
setting = g_variant_get_string (variant, NULL);
if (strcmp (setting, "keyring") == 0)
{
/* "keyring" is the default value, even though vino doesn't support it at
* the moment */
g_value_set_static_string (value, "");
return TRUE;
}
else
{
gchar *decoded;
gsize length;
gboolean ok;
decoded = (gchar *) g_base64_decode (setting, &length);
if ((ok = g_utf8_validate (decoded, length, NULL)))
g_value_take_string (value, g_strndup (decoded, length));
return ok;
}
}
GVariant *
vino_set_password (const GValue *value,
const GVariantType *type,
gpointer user_data)
{
const gchar *string;
gchar *base64;
string = g_value_get_string (value);
base64 = g_base64_encode ((guchar *) string, strlen (string));
return g_variant_new_from_data (G_VARIANT_TYPE_STRING,