diff options
author | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-05-20 20:40:37 +0800 |
---|---|---|
committer | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-08-20 19:11:11 +0800 |
commit | 07a671af77628fe419e0933e3a04dedf1f4efaa6 (patch) | |
tree | e00f0a3479649fd497d63f04ed9273d4ecb7d273 | |
parent | 3d1021753d01d973c929c8758b11a147498377cc (diff) | |
download | gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar.gz gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar.bz2 gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar.lz gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar.xz gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.tar.zst gsoc2013-empathy-07a671af77628fe419e0933e3a04dedf1f4efaa6.zip |
tp-account-widgets: remove internal copy
https://bugzilla.gnome.org/show_bug.cgi?id=699492
74 files changed, 0 insertions, 21856 deletions
diff --git a/tp-account-widgets/.gitignore b/tp-account-widgets/.gitignore deleted file mode 100644 index ac10b9d38..000000000 --- a/tp-account-widgets/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tpaw-account-widgets-resources.[ch] diff --git a/tp-account-widgets/Makefile.am b/tp-account-widgets/Makefile.am deleted file mode 100644 index d789a43d3..000000000 --- a/tp-account-widgets/Makefile.am +++ /dev/null @@ -1,167 +0,0 @@ -AM_CPPFLAGS = \ - $(ERROR_CFLAGS) \ - -DDATADIR=\""$(datadir)"\" \ - -DPKGDATADIR=\""$(pkgdatadir)"\" \ - -DG_LOG_DOMAIN=\"empathy\" \ - -DGCR_API_SUBJECT_TO_CHANGE \ - $(EMPATHY_CFLAGS) \ - $(UDEV_CFLAGS) \ - $(CHEESE_CFLAGS) \ - $(WARN_CFLAGS) \ - $(DISABLE_DEPRECATED) - -libtp_account_widgets_LIBADD = \ - $(UDEV_LIBS) \ - $(CHEESE_LIBS) \ - $(NULL) - -BUILT_SOURCES = \ - tpaw-account-widgets-resources.c \ - tpaw-account-widgets-resources.h \ - $(NULL) - -libtp_account_widgets_sources = \ - tpaw-account-settings.c \ - tpaw-account-widget.c \ - tpaw-account-widget-irc.c \ - tpaw-account-widget-private.h \ - tpaw-account-widget-sip.c \ - tpaw-avatar-chooser.c \ - tpaw-builder.c \ - tpaw-calendar-button.c \ - tpaw-camera-monitor.c \ - tpaw-connection-managers.c \ - tpaw-contactinfo-utils.c \ - tpaw-debug.c \ - tpaw-keyring.c \ - tpaw-irc-network-chooser.c \ - tpaw-irc-network-chooser-dialog.c \ - tpaw-irc-network-dialog.c \ - tpaw-irc-network-manager.c \ - tpaw-irc-network.c \ - tpaw-irc-server.c \ - tpaw-live-search.c \ - tpaw-pixbuf-utils.c \ - tpaw-protocol.c \ - tpaw-string-parser.c \ - tpaw-time.c \ - tpaw-user-info.c \ - tpaw-utils.c \ - $(NULL) - -libtp_account_widgets_headers = \ - tpaw-account-settings.h \ - tpaw-account-widget.h \ - tpaw-account-widget-irc.h \ - tpaw-account-widget-sip.h \ - tpaw-avatar-chooser.h \ - tpaw-builder.h \ - tpaw-calendar-button.h \ - tpaw-camera-monitor.h \ - tpaw-connection-managers.h \ - tpaw-contactinfo-utils.h \ - tpaw-debug.h \ - tpaw-gsettings.h \ - tpaw-images.h \ - tpaw-keyring.h \ - tpaw-irc-network-chooser-dialog.h \ - tpaw-irc-network-chooser.h \ - tpaw-irc-network-dialog.h \ - tpaw-irc-network-manager.h \ - tpaw-irc-network.h \ - tpaw-irc-server.h \ - tpaw-live-search.h \ - tpaw-pixbuf-utils.h \ - tpaw-protocol.h \ - tpaw-string-parser.h \ - tpaw-time.h \ - tpaw-user-info.h \ - tpaw-utils.h \ - $(NULL) - -nocheck_sources = \ - cheese-camera-device-monitor.c \ - cheese-camera-device-monitor.h \ - totem-subtitle-encoding.c \ - totem-subtitle-encoding.h \ - $(NULL) - -pkglib_LTLIBRARIES = libtp-account-widgets.la - -# libtp-account-widgets's API is not stable and will never be, so use -release to make the -# SONAME of the plugin library change with every Empathy release. -libtp_account_widgets_la_LDFLAGS = \ - -no-undefined \ - -release $(VERSION) \ - $(NULL) - -libtp_account_widgets_la_SOURCES = \ - $(libtp_account_widgets_sources) \ - $(libtp_account_widgets_headers) \ - $(nocheck_sources) \ - $(NULL) - -# these are sources that depend on Ubuntu Online Accounts -uoa_sources = \ - tpaw-uoa-utils.c \ - tpaw-uoa-utils.h \ - $(NULL) - -if HAVE_UOA -libtp_account_widgets_la_SOURCES += $(uoa_sources) -EXTRA_DIST = -else -EXTRA_DIST = $(uoa_sources) -endif - -# do not distribute generated files -nodist_libtp_account_widgets_la_SOURCES = \ - $(BUILT_SOURCES) - -check_c_sources = \ - $(libtp_account_widgets_sources) \ - $(libtp_account_widgets_headers) \ - $(uoa_sources) \ - $(NULL) -include $(top_srcdir)/tools/check-coding-style.mk -check-local: check-coding-style - -account_widgets_dtd_files = \ - tpaw-irc-networks.dtd \ - $(NULL) - -ircnetworksdir = $(datadir)/empathy -ircnetworks_DATA = \ - irc-networks.xml - -account_widgets_ui_files = \ - tpaw-account-widget-generic.ui \ - tpaw-account-widget-jabber.ui \ - tpaw-account-widget-msn.ui \ - tpaw-account-widget-sip.ui \ - tpaw-account-widget-local-xmpp.ui \ - tpaw-account-widget-irc.ui \ - tpaw-account-widget-icq.ui \ - tpaw-account-widget-yahoo.ui \ - tpaw-account-widget-groupwise.ui \ - tpaw-account-widget-aim.ui \ - $(NULL) - -account_widgets_resource_files = $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir=$(srcdir) $(srcdir)/tpaw-account-widgets.gresource.xml) - -tpaw-account-widgets-resources.c: tpaw-account-widgets.gresource.xml $(account_widgets_resource_files) - $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-source $< - -tpaw-account-widgets-resources.h: tpaw-account-widgets.gresource.xml $(account_widgets_resource_files) - $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate-header $< - -EXTRA_DIST += \ - tpaw-account-widgets.gresource.xml \ - $(account_widgets_dtd_files) \ - $(account_widgets_ui_files) \ - $(ircnetworks_DATA) \ - $(NULL) - -CLEANFILES = \ - $(BUILT_SOURCES) \ - $(NULL) diff --git a/tp-account-widgets/cheese-camera-device-monitor.c b/tp-account-widgets/cheese-camera-device-monitor.c deleted file mode 100644 index 76b7fd415..000000000 --- a/tp-account-widgets/cheese-camera-device-monitor.c +++ /dev/null @@ -1,406 +0,0 @@ -/* This file is a copy of cheese-camera-device-monitor.c from Tpaw. We - * just renamespaced it to avoid conflicts when linking on libcheese. */ -/* - * Copyright © 2007,2008 Jaap Haitsma <jaap@haitsma.org> - * Copyright © 2007-2009 daniel g. siegel <dgsiegel@gnome.org> - * Copyright © 2008 Ryan Zeigler <zeiglerr@gmail.com> - * Copyright © 2010 Filippo Argiolas <filippo.argiolas@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifdef HAVE_CONFIG_H - #include "config.h" -#endif - -#include <string.h> - -#ifdef HAVE_UDEV - #define G_UDEV_API_IS_SUBJECT_TO_CHANGE 1 - #include <gudev/gudev.h> -#else - #include <fcntl.h> - #include <unistd.h> - #include <sys/ioctl.h> - #if USE_SYS_VIDEOIO_H > 0 - #include <sys/types.h> - #include <sys/videoio.h> - #elif defined (__sun) - #include <sys/types.h> - #include <sys/videodev2.h> - #endif /* USE_SYS_VIDEOIO_H */ -#endif - -#include "cheese-camera-device-monitor.h" - -/** - * SECTION:cheese-camera-device-monitor - * @short_description: Simple object to enumerate v4l devices - * @include: cheese/cheese-camera-device-monitor.h - * - * #TpawCameraDeviceMonitor provides a basic interface for - * video4linux device enumeration and hotplugging. - * - * It uses either GUdev or some platform specific code to list video - * devices. It is also capable (right now in linux only, with the - * udev backend) to monitor device plugging and emit a - * TpawCameraDeviceMonitor::added or - * TpawCameraDeviceMonitor::removed signal when an event happens. - */ - -G_DEFINE_TYPE (TpawCameraDeviceMonitor, tpaw_camera_device_monitor, G_TYPE_OBJECT) - -#define TPAW_CAMERA_DEVICE_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \ - TPAW_TYPE_CAMERA_DEVICE_MONITOR, \ - TpawCameraDeviceMonitorPrivate)) - -#define TPAW_CAMERA_DEVICE_MONITOR_ERROR tpaw_camera_device_monitor_error_quark () - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -enum TpawCameraDeviceMonitorError -{ - TPAW_CAMERA_DEVICE_MONITOR_ERROR_UNKNOWN, - TPAW_CAMERA_DEVICE_MONITOR_ERROR_ELEMENT_NOT_FOUND -}; - -typedef struct -{ -#ifdef HAVE_UDEV - GUdevClient *client; -#else - guint filler; -#endif /* HAVE_UDEV */ -} TpawCameraDeviceMonitorPrivate; - -enum -{ - ADDED, - REMOVED, - LAST_SIGNAL -}; - -static guint monitor_signals[LAST_SIGNAL]; - -#if 0 -GQuark -tpaw_camera_device_monitor_error_quark (void) -{ - return g_quark_from_static_string ("tpaw-camera-error-quark"); -} -#endif - -#ifdef HAVE_UDEV -static void -tpaw_camera_device_monitor_added (TpawCameraDeviceMonitor *monitor, - GUdevDevice *udevice) -{ - const char *device_file; - const char *product_name; - const char *vendor; - const char *product; - const char *bus; - gint vendor_id = 0; - gint product_id = 0; - gint v4l_version = 0; - - const gchar *devpath = g_udev_device_get_property (udevice, "DEVPATH"); - - DEBUG ("Checking udev device '%s'", devpath); - - bus = g_udev_device_get_property (udevice, "ID_BUS"); - if (g_strcmp0 (bus, "usb") == 0) - { - vendor = g_udev_device_get_property (udevice, "ID_VENDOR_ID"); - if (vendor != NULL) - vendor_id = g_ascii_strtoll (vendor, NULL, 16); - product = g_udev_device_get_property (udevice, "ID_MODEL_ID"); - if (product != NULL) - product_id = g_ascii_strtoll (product, NULL, 16); - if (vendor_id == 0 || product_id == 0) - { - DEBUG ("Error getting vendor and product id"); - } - else - { - DEBUG ("Found device %04x:%04x, getting capabilities...", vendor_id, product_id); - } - } - else - { - DEBUG ("Not an usb device, skipping vendor and model id retrieval"); - } - - device_file = g_udev_device_get_device_file (udevice); - if (device_file == NULL) - { - DEBUG ("Error getting V4L device"); - return; - } - - /* vbi devices support capture capability too, but cannot be used, - * so detect them by device name */ - if (strstr (device_file, "vbi")) - { - DEBUG ("Skipping vbi device: %s", device_file); - return; - } - - v4l_version = g_udev_device_get_property_as_int (udevice, "ID_V4L_VERSION"); - if (v4l_version == 2 || v4l_version == 1) - { - const char *caps; - - caps = g_udev_device_get_property (udevice, "ID_V4L_CAPABILITIES"); - if (caps == NULL || strstr (caps, ":capture:") == NULL) - { - DEBUG ("Device %s seems to not have the capture capability, (radio tuner?)" - "Removing it from device list.", device_file); - return; - } - product_name = g_udev_device_get_property (udevice, "ID_V4L_PRODUCT"); - } - else if (v4l_version == 0) - { - DEBUG ("Fix your udev installation to include v4l_id, ignoring %s", device_file); - return; - } - else - { - g_assert_not_reached (); - } - - g_signal_emit (monitor, monitor_signals[ADDED], 0, - devpath, - device_file, - product_name, - v4l_version); -} - -static void -tpaw_camera_device_monitor_removed (TpawCameraDeviceMonitor *monitor, - GUdevDevice *udevice) -{ - g_signal_emit (monitor, monitor_signals[REMOVED], 0, - g_udev_device_get_property (udevice, "DEVPATH")); -} - -static void -tpaw_camera_device_monitor_uevent_cb (GUdevClient *client, - const gchar *action, - GUdevDevice *udevice, - TpawCameraDeviceMonitor *monitor) -{ - if (g_str_equal (action, "remove")) - tpaw_camera_device_monitor_removed (monitor, udevice); - else if (g_str_equal (action, "add")) - tpaw_camera_device_monitor_added (monitor, udevice); -} - -/** - * tpaw_camera_device_monitor_coldplug: - * @monitor: a #TpawCameraDeviceMonitor object. - * - * Will actively look for plugged in cameras and emit - * ::added for those new cameras. - * This is only required when your program starts, so as to connect - * to those signals before they are emitted. - */ -void -tpaw_camera_device_monitor_coldplug (TpawCameraDeviceMonitor *monitor) -{ - TpawCameraDeviceMonitorPrivate *priv = TPAW_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); - GList *devices, *l; - gint i = 0; - - if (priv->client == NULL) - return; - - DEBUG ("Probing devices with udev..."); - - devices = g_udev_client_query_by_subsystem (priv->client, "video4linux"); - - /* Initialize camera structures */ - for (l = devices; l != NULL; l = l->next) - { - tpaw_camera_device_monitor_added (monitor, l->data); - g_object_unref (l->data); - i++; - } - g_list_free (devices); - - if (i == 0) DEBUG ("No device found"); -} - -#else /* HAVE_UDEV */ -void -tpaw_camera_device_monitor_coldplug (TpawCameraDeviceMonitor *monitor) -{ - #if 0 - TpawCameraDeviceMonitorPrivate *priv = TPAW_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); - struct v4l2_capability v2cap; - struct video_capability v1cap; - int fd, ok; - - if ((fd = open (device_path, O_RDONLY | O_NONBLOCK)) < 0) - { - g_warning ("Failed to open %s: %s", device_path, strerror (errno)); - return; - } - ok = ioctl (fd, VIDIOC_QUERYCAP, &v2cap); - if (ok < 0) - { - ok = ioctl (fd, VIDIOCGCAP, &v1cap); - if (ok < 0) - { - g_warning ("Error while probing v4l capabilities for %s: %s", - device_path, strerror (errno)); - close (fd); - return; - } - g_print ("Detected v4l device: %s\n", v1cap.name); - g_print ("Device type: %d\n", v1cap.type); - gstreamer_src = "v4lsrc"; - product_name = v1cap.name; - } - else - { - guint cap = v2cap.capabilities; - g_print ("Detected v4l2 device: %s\n", v2cap.card); - g_print ("Driver: %s, version: %d\n", v2cap.driver, v2cap.version); - - /* g_print ("Bus info: %s\n", v2cap.bus_info); */ /* Doesn't seem anything useful */ - g_print ("Capabilities: 0x%08X\n", v2cap.capabilities); - if (!(cap & V4L2_CAP_VIDEO_CAPTURE)) - { - g_print ("Device %s seems to not have the capture capability, (radio tuner?)\n" - "Removing it from device list.\n", device_path); - close (fd); - return; - } - gstreamer_src = "v4l2src"; - product_name = (char *) v2cap.card; - } - close (fd); - - GList *devices, *l; - - g_print ("Probing devices with udev...\n"); - - if (priv->client == NULL) - return; - - devices = g_udev_client_query_by_subsystem (priv->client, "video4linux"); - - /* Initialize camera structures */ - for (l = devices; l != NULL; l = l->next) - { - tpaw_camera_device_monitor_added (monitor, l->data); - g_object_unref (l->data); - } - g_list_free (devices); - #endif -} - -#endif /* HAVE_UDEV */ - -static void -tpaw_camera_device_monitor_finalize (GObject *object) -{ -#ifdef HAVE_UDEV - TpawCameraDeviceMonitor *monitor = TPAW_CAMERA_DEVICE_MONITOR (object); - TpawCameraDeviceMonitorPrivate *priv = TPAW_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); - - if (priv->client != NULL) - { - g_object_unref (priv->client); - priv->client = NULL; - } -#endif /* HAVE_UDEV */ - G_OBJECT_CLASS (tpaw_camera_device_monitor_parent_class)->finalize (object); -} - -static void -tpaw_camera_device_monitor_class_init (TpawCameraDeviceMonitorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = tpaw_camera_device_monitor_finalize; - - /** - * TpawCameraDeviceMonitor::added: - * @device: A private object representing the newly added camera. - * @id: Device unique identifier. - * @device: Device file name (e.g. /dev/video2). - * @product_name: Device product name (human readable, intended to be displayed in a UI). - * @api_version: Supported video4linux API: 1 for v4l, 2 for v4l2. - * - * The ::added signal is emitted when a camera is added, or on start-up - * after #tpaw_camera_device_monitor_colplug is called. - **/ - monitor_signals[ADDED] = g_signal_new ("added", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (TpawCameraDeviceMonitorClass, added), - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT); - - /** - * TpawCameraDeviceMonitor::removed: - * @device: A private object representing the newly added camera - * @id: Device unique identifier. - * - * The ::removed signal is emitted when a camera is un-plugged, or - * disabled on the system. - **/ - monitor_signals[REMOVED] = g_signal_new ("removed", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (TpawCameraDeviceMonitorClass, removed), - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, G_TYPE_STRING); - - g_type_class_add_private (klass, sizeof (TpawCameraDeviceMonitorPrivate)); -} - -static void -tpaw_camera_device_monitor_init (TpawCameraDeviceMonitor *monitor) -{ -#ifdef HAVE_UDEV - TpawCameraDeviceMonitorPrivate *priv = TPAW_CAMERA_DEVICE_MONITOR_GET_PRIVATE (monitor); - const gchar *const subsystems[] = {"video4linux", NULL}; - - priv->client = g_udev_client_new (subsystems); - g_signal_connect (G_OBJECT (priv->client), "uevent", - G_CALLBACK (tpaw_camera_device_monitor_uevent_cb), monitor); -#endif /* HAVE_UDEV */ -} - -/** - * tpaw_camera_device_monitor_new: - * - * Returns a new #TpawCameraDeviceMonitor object. - * - * Return value: a new #TpawCameraDeviceMonitor object. - **/ -TpawCameraDeviceMonitor * -tpaw_camera_device_monitor_new (void) -{ - return g_object_new (TPAW_TYPE_CAMERA_DEVICE_MONITOR, NULL); -} - -/* - * vim: sw=2 ts=8 cindent noai bs=2 - */ diff --git a/tp-account-widgets/cheese-camera-device-monitor.h b/tp-account-widgets/cheese-camera-device-monitor.h deleted file mode 100644 index 353440226..000000000 --- a/tp-account-widgets/cheese-camera-device-monitor.h +++ /dev/null @@ -1,67 +0,0 @@ -/* This file is a copy of cheese-camera-device-monitor.h from Tpaw. We - * just renamespaced it to avoid conflicts when linking on libcheese. */ -/* - * Copyright © 2007,2008 Jaap Haitsma <jaap@haitsma.org> - * Copyright © 2007-2009 daniel g. siegel <dgsiegel@gnome.org> - * Copyright © 2008 Ryan zeigler <zeiglerr@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __TPAW_CAMERA_DEVICE_MONITOR_H__ -#define __TPAW_CAMERA_DEVICE_MONITOR_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define TPAW_TYPE_CAMERA_DEVICE_MONITOR (tpaw_camera_device_monitor_get_type ()) -#define TPAW_CAMERA_DEVICE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_CAMERA_DEVICE_MONITOR, \ - TpawCameraDeviceMonitor)) -#define TPAW_CAMERA_DEVICE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_CAMERA_DEVICE_MONITOR, \ - TpawCameraDeviceMonitorClass)) -#define TPAW_IS_CAMERA_DEVICE_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_CAMERA_DEVICE_MONITOR)) -#define TPAW_IS_CAMERA_DEVICE_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_CAMERA_DEVICE_MONITOR)) -#define TPAW_CAMERA_DEVICE_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_CAMERA_DEVICE_MONITOR, \ - TpawCameraDeviceMonitorClass)) - -typedef struct _TpawCameraDeviceMonitorClass TpawCameraDeviceMonitorClass; -typedef struct _TpawCameraDeviceMonitor TpawCameraDeviceMonitor; - -struct _TpawCameraDeviceMonitor -{ - GObject parent; -}; - -struct _TpawCameraDeviceMonitorClass -{ - GObjectClass parent_class; - - void (*added)(TpawCameraDeviceMonitor *camera, - const char *id, - const char *device_file, - const char *product_name, - int api_version); - void (*removed)(TpawCameraDeviceMonitor *camera, const char *id); -}; - -GType tpaw_camera_device_monitor_get_type (void) G_GNUC_CONST; -TpawCameraDeviceMonitor *tpaw_camera_device_monitor_new (void); -void tpaw_camera_device_monitor_coldplug (TpawCameraDeviceMonitor *monitor); - -G_END_DECLS - -#endif /* __TPAW_CAMERA_DEVICE_MONITOR_H__ */ diff --git a/tp-account-widgets/irc-networks.xml b/tp-account-widgets/irc-networks.xml deleted file mode 100644 index 2526785c2..000000000 --- a/tp-account-widgets/irc-networks.xml +++ /dev/null @@ -1,545 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<networks> - <network name="Debian Servers" id="debian_servers"> - <servers> - <server ssl="FALSE" port="6667" address="irc.debian.org"/> - </servers> - </network> - <network name="2600net" id="a2600net"> - <servers> - <server ssl="FALSE" port="6667" address="irc.2600.net"/> - </servers> - </network> - <network name="AccessIRC" id="accessirc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.accessirc.net"/> - <server ssl="FALSE" port="6667" address="eu.accessirc.net"/> - </servers> - </network> - <network name="AfterNET" id="afternet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.afternet.org"/> - <server ssl="FALSE" port="6667" address="us.afternet.org"/> - <server ssl="FALSE" port="6667" address="eu.afternet.org"/> - </servers> - </network> - <network name="Aitvaras" id="aitvaras"> - <servers> - <server ssl="TRUE" port="6668" address="irc.data.lt"/> - <server ssl="TRUE" port="6668" address="irc-ssl.omnitel.net"/> - <server ssl="TRUE" port="9999" address="irc-ssl.le.lt"/> - <server ssl="FALSE" port="6667" address="irc.data.lt"/> - <server ssl="FALSE" port="6667" address="irc.omnitel.net"/> - <server ssl="FALSE" port="6667" address="irc.ktu.lt"/> - <server ssl="FALSE" port="6667" address="irc.le.lt"/> - <server ssl="FALSE" port="6667" address="irc.takas.lt"/> - <server ssl="FALSE" port="6667" address="irc.5ci.net"/> - <server ssl="FALSE" port="6667" address="irc.kis.lt"/> - </servers> - </network> - <network name="AmigaNet" id="amiganet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.amiganet.org"/> - <server ssl="FALSE" port="6667" address="us.amiganet.org"/> - <server ssl="FALSE" port="6667" address="uk.amiganet.org"/> - </servers> - </network> - <network name="ARCNet" id="arcnet"> - <servers> - <server ssl="FALSE" port="6667" address="se1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="us1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="us2.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="us3.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="ca1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="de1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="de3.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="ch1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="be1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="nl3.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="uk1.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="uk2.arcnet.vapor.com"/> - <server ssl="FALSE" port="6667" address="fr1.arcnet.vapor.com"/> - </servers> - </network> - <network name="AstroLink" id="astrolink"> - <servers> - <server ssl="FALSE" port="6667" address="irc.astrolink.org"/> - </servers> - </network> - <network name="AustNet" id="austnet"> - <servers> - <server ssl="FALSE" port="6667" address="au.austnet.org"/> - <server ssl="FALSE" port="6667" address="us.austnet.org"/> - <server ssl="FALSE" port="6667" address="ca.austnet.org"/> - </servers> - </network> - <network name="AzzurraNet" id="azzurranet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.azzurra.org"/> - <server ssl="FALSE" port="6667" address="crypto.azzurra.org"/> - </servers> - </network> - <network name="Beirut" id="beirut"> - <servers> - <server ssl="FALSE" port="6667" address="irc.beirut.com"/> - </servers> - </network> - <network name="ChatJunkies" id="chatjunkies"> - <servers> - <server ssl="FALSE" port="6667" address="irc.chatjunkies.org"/> - <server ssl="FALSE" port="6667" address="nl.chatjunkies.org"/> - </servers> - </network> - <network name="ChatNet" id="chatnet"> - <servers> - <server ssl="FALSE" port="6667" address="US.ChatNet.Org"/> - <server ssl="FALSE" port="6667" address="EU.ChatNet.Org"/> - </servers> - </network> - <network name="ChatSociety" id="chatsociety"> - <servers> - <server ssl="FALSE" port="6667" address="us.chatsociety.net"/> - <server ssl="FALSE" port="6667" address="eu.chatsociety.net"/> - </servers> - </network> - <network name="ChatSpike" id="chatspike"> - <servers> - <server ssl="FALSE" port="6667" address="irc.chatspike.net"/> - </servers> - </network> - <network name="ChillFactory" id="chillfactory"> - <servers> - <server ssl="FALSE" port="6667" address="irc.chillfactory.net"/> - </servers> - </network> - <network name="CoolChat" id="coolchat"> - <servers> - <server ssl="FALSE" port="6667" address="irc.coolchat.net"/> - </servers> - </network> - <network name="Criten" id="criten"> - <servers> - <server ssl="FALSE" port="6667" address="irc.criten.net"/> - <server ssl="FALSE" port="6667" address="irc.eu.criten.net"/> - </servers> - </network> - <network name="DALnet" id="dalnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.dal.net"/> - <server ssl="FALSE" port="6667" address="irc.eu.dal.net"/> - </servers> - </network> - <network name="Dark-Tou-Net" id="dark-tou-net"> - <servers> - <server ssl="FALSE" port="6667" address="irc.d-t-net.de"/> - <server ssl="FALSE" port="6667" address="bw.d-t-net.de"/> - <server ssl="FALSE" port="6667" address="nc.d-t-net.de"/> - <server ssl="FALSE" port="6667" address="wakka.d-t-net.de"/> - </servers> - </network> - <network name="DarkMyst" id="darkmyst"> - <servers> - <server ssl="FALSE" port="6667" address="irc.darkmyst.org"/> - </servers> - </network> - <network name="DeepIRC" id="deepirc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.deepirc.net"/> - </servers> - </network> - <network name="DeltaAnime" id="deltaanime"> - <servers> - <server ssl="FALSE" port="6667" address="irc.deltaanime.net"/> - </servers> - </network> - <network name="EFnet" id="efnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.blackened.com"/> - <server ssl="FALSE" port="6667" address="irc.Prison.NET"/> - <server ssl="FALSE" port="6667" address="irc.Qeast.net"/> - <server ssl="FALSE" port="6667" address="irc.efnet.pl"/> - <server ssl="FALSE" port="6667" address="efnet.demon.co.uk"/> - <server ssl="FALSE" port="6667" address="irc.lightning.net"/> - <server ssl="FALSE" port="6667" address="irc.mindspring.com"/> - <server ssl="FALSE" port="6667" address="irc.easynews.com"/> - <server ssl="FALSE" port="6667" address="irc.servercentral.net"/> - </servers> - </network> - <network name="EnterTheGame" id="enterthegame"> - <servers> - <server ssl="FALSE" port="6667" address="IRC.EnterTheGame.Com"/> - </servers> - </network> - <network name="EUIrc" id="euirc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.ham.de.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.ber.de.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.ffm.de.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.bre.de.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.hes.de.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.vie.at.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.inn.at.euirc.net"/> - <server ssl="FALSE" port="6667" address="irc.bas.ch.euirc.net"/> - </servers> - </network> - <network name="EuropNet" id="europnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.europnet.org"/> - </servers> - </network> - <network name="EU-IRC" id="eu-irc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.eu-irc.net"/> - </servers> - </network> - <network name="FDFNet" id="fdfnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.fdfnet.net"/> - <server ssl="FALSE" port="6667" address="irc.eu.fdfnet.net"/> - </servers> - </network> - <network name="FEFNet" id="fefnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.fef.net"/> - <server ssl="FALSE" port="6667" address="irc.ggn.net"/> - <server ssl="FALSE" port="6667" address="irc.vendetta.com"/> - </servers> - </network> - <network name="freenode" id="freenode"> - <servers> - <server ssl="TRUE" port="6697" address="chat.freenode.net"/> - <server ssl="TRUE" port="7000" address="chat.freenode.net"/> - <server ssl="TRUE" port="7070" address="chat.freenode.net"/> - <server ssl="FALSE" port="6665" address="chat.freenode.net"/> - <server ssl="FALSE" port="6666" address="chat.freenode.net"/> - <server ssl="FALSE" port="6667" address="chat.freenode.net"/> - <server ssl="FALSE" port="8000" address="chat.freenode.net"/> - <server ssl="FALSE" port="8001" address="chat.freenode.net"/> - <server ssl="FALSE" port="8002" address="chat.freenode.net"/> - </servers> - </network> - <network name="GalaxyNet" id="galaxynet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.galaxynet.org"/> - </servers> - </network> - <network name="GamesNET" id="gamesnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.gamesnet.net"/> - <server ssl="FALSE" port="6667" address="irc.ca.gamesnet.net"/> - <server ssl="FALSE" port="6667" address="irc.eu.gamesnet.net"/> - </servers> - </network> - <network name="German-Elite" id="german-elite"> - <servers> - <server ssl="FALSE" port="6667" address="dominion.german-elite.net"/> - <server ssl="FALSE" port="6667" address="komatu.german-elite.net"/> - </servers> - </network> - <network name="GimpNet" id="gimpnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.gimp.org"/> - <server ssl="FALSE" port="6667" address="irc.us.gimp.org"/> - </servers> - </network> - <network name="HabberNet" id="habbernet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.habber.net"/> - </servers> - </network> - <network name="Hashmark" id="hashmark"> - <servers> - <server ssl="FALSE" port="6667" address="irc.hashmark.net"/> - </servers> - </network> - <network name="IdleMonkeys" id="idlemonkeys"> - <servers> - <server ssl="FALSE" port="6667" address="irc.idlemonkeys.net"/> - </servers> - </network> - <network name="insiderZ.DE" id="insiderz.de"> - <servers> - <server ssl="FALSE" port="6667" address="irc.insiderz.de"/> - <server ssl="FALSE" port="6666" address="irc.insiderz.de"/> - </servers> - </network> - <network name="IrcLink" id="irclink"> - <servers> - <server ssl="FALSE" port="6667" address="irc.irclink.net"/> - <server ssl="FALSE" port="6667" address="Alesund.no.eu.irclink.net"/> - <server ssl="FALSE" port="6667" address="Oslo.no.eu.irclink.net"/> - <server ssl="FALSE" port="6667" address="frogn.no.eu.irclink.net"/> - <server ssl="FALSE" port="6667" address="tonsberg.no.eu.irclink.net"/> - </servers> - </network> - <network name="IRCNet" id="ircnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.ircnet.com"/> - <server ssl="FALSE" port="6668" address="irc.stealth.net"/> - <server ssl="FALSE" port="6667" address="ircnet.demon.co.uk"/> - <server ssl="FALSE" port="6667" address="irc.datacomm.ch"/> - <server ssl="FALSE" port="6667" address="random.ircd.de"/> - <server ssl="FALSE" port="6667" address="ircnet.netvision.net.il"/> - <server ssl="FALSE" port="6667" address="irc.cs.hut.fi"/> - </servers> - </network> - <network name="Irctoo.net" id="irctoo.net"> - <servers> - <server ssl="FALSE" port="6667" address="irc.irctoo.net"/> - </servers> - </network> - <network name="Krstarica" id="krstarica"> - <servers> - <server ssl="FALSE" port="6667" address="irc.krstarica.com"/> - </servers> - </network> - <network name="Librenet" id="librenet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.librenet.net"/> - <server ssl="FALSE" port="6667" address="ielf.fr.librenet.net"/> - </servers> - </network> - <network name="LinkNet" id="linknet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.link-net.org"/> - <server ssl="FALSE" port="6667" address="irc.no.link-net.org"/> - <server ssl="FALSE" port="6667" address="irc.bahnhof.se"/> - </servers> - </network> - <network name="MagicStar" id="magicstar"> - <servers> - <server ssl="FALSE" port="6667" address="irc.magicstar.net"/> - </servers> - </network> - <network name="Majistic" id="majistic"> - <servers> - <server ssl="FALSE" port="6667" address="irc.majistic.net"/> - </servers> - </network> - <network name="MindForge" id="mindforge"> - <servers> - <server ssl="FALSE" port="6667" address="irc.mindforge.org"/> - </servers> - </network> - <network name="MIXXnet" id="mixxnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.mixxnet.net"/> - </servers> - </network> - <network name="NeverNET" id="nevernet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.nevernet.net"/> - <server ssl="FALSE" port="6667" address="imagine.nevernet.net"/> - <server ssl="FALSE" port="6667" address="dimension.nevernet.net"/> - <server ssl="FALSE" port="6667" address="universe.nevernet.net"/> - <server ssl="FALSE" port="6667" address="wayland.nevernet.net"/> - <server ssl="FALSE" port="6667" address="forte.nevernet.net"/> - </servers> - </network> - <network name="NixHelpNet" id="nixhelpnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="us.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="uk.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="uk2.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="uk3.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="nl.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="ca.ld.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="us.co.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="us.ca.nixhelp.org"/> - <server ssl="FALSE" port="6667" address="us.pa.nixhelp.org"/> - </servers> - </network> - <network name="NullusNet" id="nullusnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.nullus.net"/> - </servers> - </network> - <network name="Oceanius" id="oceanius"> - <servers> - <server ssl="FALSE" port="6667" address="irc.oceanius.com"/> - </servers> - </network> - <network name="OFTC" id="oftc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.oftc.net"/> - </servers> - </network> - <network name="OtherNet" id="othernet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.othernet.org"/> - </servers> - </network> - <network name="Oz.org" id="oz.org"> - <servers> - <server ssl="FALSE" port="6667" address="irc.oz.org"/> - <server ssl="FALSE" port="6667" address="germany.oz.org"/> - <server ssl="FALSE" port="6667" address="sandiego.oz.org"/> - <server ssl="FALSE" port="6667" address="us.oz.org"/> - <server ssl="FALSE" port="6667" address="au.oz.org"/> - <server ssl="FALSE" port="6667" address="rockhampton.oz.org"/> - <server ssl="FALSE" port="6667" address="wollongong.oz.org"/> - <server ssl="FALSE" port="6667" address="waix.oz.org"/> - </servers> - </network> - <network name="PTlink" id="ptlink"> - <servers> - <server ssl="FALSE" port="6667" address="irc.PTlink.net"/> - <server ssl="FALSE" port="6667" address="aaia.PTlink.net"/> - </servers> - </network> - <network name="PTNe" id="ptne"> - <servers> - <server ssl="FALSE" port="6667" address="irc.PTNet.org"/> - <server ssl="FALSE" port="6667" address="rccn.PTnet.org"/> - <server ssl="FALSE" port="6667" address="uevora.PTnet.org"/> - <server ssl="FALSE" port="6667" address="umoderna.PTnet.org"/> - <server ssl="FALSE" port="6667" address="ist.PTnet.org"/> - <server ssl="FALSE" port="6667" address="aaum.PTnet.org"/> - <server ssl="FALSE" port="6667" address="uc.PTnet.org"/> - <server ssl="FALSE" port="6667" address="ualg.ptnet.org"/> - <server ssl="FALSE" port="6667" address="madinfo.PTnet.org"/> - <server ssl="FALSE" port="6667" address="ua.PTnet.org"/> - <server ssl="FALSE" port="6667" address="ipg.PTnet.org"/> - <server ssl="FALSE" port="6667" address="isec.PTnet.org"/> - <server ssl="FALSE" port="6667" address="utad.PTnet.org"/> - <server ssl="FALSE" port="6667" address="iscte.PTnet.org"/> - <server ssl="FALSE" port="6667" address="ubi.PTnet.org"/> - </servers> - </network> - <network name="QuakeNet" id="quakenet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.se.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.dk.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.no.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.fi.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.be.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.uk.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.de.quakenet.org"/> - <server ssl="FALSE" port="6667" address="irc.it.quakenet.org"/> - </servers> - </network> - <network name="RebelChat" id="rebelchat"> - <servers> - <server ssl="FALSE" port="6667" address="irc.rebelchat.org"/> - </servers> - </network> - <network name="RizeNET" id="rizenet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.rizenet.org"/> - <server ssl="FALSE" port="6667" address="omega.rizenet.org"/> - <server ssl="FALSE" port="6667" address="evelance.rizenet.org"/> - <server ssl="FALSE" port="6667" address="lisa.rizenet.org"/> - <server ssl="FALSE" port="6667" address="scott.rizenet.org"/> - </servers> - </network> - <network name="RusNet" id="rusnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.tomsk.net"/> - <server ssl="FALSE" port="6667" address="irc.rinet.ru"/> - <server ssl="FALSE" port="6667" address="irc.run.net"/> - <server ssl="FALSE" port="6667" address="irc.ru"/> - <server ssl="FALSE" port="6667" address="irc.lucky.net"/> - </servers> - </network> - <network name="SceneNet" id="scenenet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.scene.org"/> - <server ssl="FALSE" port="6667" address="irc.eu.scene.org"/> - <server ssl="FALSE" port="6667" address="irc.us.scene.org"/> - </servers> - </network> - <network name="SlashNET" id="slashnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.slashnet.org"/> - <server ssl="FALSE" port="6667" address="area51.slashnet.org"/> - <server ssl="FALSE" port="6667" address="moo.slashnet.org"/> - <server ssl="FALSE" port="6667" address="radon.slashnet.org"/> - </servers> - </network> - <network name="Sohbet.Net" id="sohbet.net"> - <servers> - <server ssl="FALSE" port="6667" address="irc.sohbet.net"/> - </servers> - </network> - <network name="SolidIRC" id="solidirc"> - <servers> - <server ssl="FALSE" port="6667" address="irc.solidirc.com"/> - </servers> - </network> - <network name="SorceryNet" id="sorcerynet"> - <servers> - <server ssl="FALSE" port="9000" address="irc.sorcery.net"/> - <server ssl="FALSE" port="9000" address="irc.us.sorcery.net"/> - <server ssl="FALSE" port="9000" address="irc.eu.sorcery.net"/> - </servers> - </network> - <network name="Spidernet" id="spidernet"> - <servers> - <server ssl="FALSE" port="6667" address="us.spidernet.org"/> - <server ssl="FALSE" port="6667" address="eu.spidernet.org"/> - <server ssl="FALSE" port="6667" address="irc.spidernet.org"/> - </servers> - </network> - <network name="StarChat" id="starchat"> - <servers> - <server ssl="FALSE" port="6667" address="irc.starchat.net"/> - <server ssl="FALSE" port="6667" address="gainesville.starchat.net"/> - <server ssl="FALSE" port="6667" address="freebsd.starchat.net"/> - <server ssl="FALSE" port="6667" address="sunset.starchat.net"/> - <server ssl="FALSE" port="6667" address="revenge.starchat.net"/> - <server ssl="FALSE" port="6667" address="tahoma.starchat.net"/> - <server ssl="FALSE" port="6667" address="neo.starchat.net"/> - </servers> - </network> - <network name="TNI3" id="tni3"> - <servers> - <server ssl="FALSE" port="6667" address="irc.tni3.com"/> - </servers> - </network> - <network name="UnderNet" id="undernet"> - <servers> - <server ssl="FALSE" port="6667" address="us.undernet.org"/> - <server ssl="FALSE" port="6667" address="eu.undernet.org"/> - </servers> - </network> - <network name="UniBG" id="unibg"> - <servers> - <server ssl="FALSE" port="6667" address="irc.lirex.com"/> - <server ssl="FALSE" port="6667" address="irc.naturella.com"/> - <server ssl="FALSE" port="6667" address="irc.spnet.net"/> - <server ssl="FALSE" port="6667" address="irc.techno-link.com"/> - <server ssl="FALSE" port="6667" address="irc.telecoms.bg"/> - <server ssl="FALSE" port="6667" address="irc.tu-varna.edu"/> - </servers> - </network> - <network name="Whiffle" id="whiffle"> - <servers> - <server ssl="FALSE" port="6667" address="irc.whiffle.org"/> - </servers> - </network> - <network name="Worldnet" id="worldnet"> - <servers> - <server ssl="FALSE" port="6667" address="irc.worldnet.net"/> - <server ssl="FALSE" port="6667" address="irc.fr.worldnet.net"/> - </servers> - </network> - <network name="Xentonix.net" id="xentonix.net"> - <servers> - <server ssl="FALSE" port="6667" address="irc.ffm.de.eu.xentonix.net"/> - <server ssl="FALSE" port="6667" address="irc.kar.de.eu.xentonix.net"/> - <server ssl="FALSE" port="6667" address="irc.vie.at.eu.xentonix.net"/> - </servers> - </network> - <network name="XWorld" id="xworld"> - <servers> - <server ssl="FALSE" port="6667" address="Buffalo.NY.US.XWorld.org"/> - <server ssl="FALSE" port="6667" address="Minneapolis.MN.US.Xworld.Org"/> - <server ssl="FALSE" port="6667" address="Rochester.NY.US.XWorld.org"/> - <server ssl="FALSE" port="6667" address="Bayern.DE.EU.XWorld.Org"/> - <server ssl="FALSE" port="6667" address="Chicago.IL.US.XWorld.Org"/> - </servers> - </network> -</networks> diff --git a/tp-account-widgets/totem-subtitle-encoding.c b/tp-account-widgets/totem-subtitle-encoding.c deleted file mode 100644 index 2db1c23c0..000000000 --- a/tp-account-widgets/totem-subtitle-encoding.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net> - * - * encoding list copied from gnome-terminal/encoding.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add exception clause. - * See license_change file for details. - * - */ - -#include "config.h" -#include <glib/gi18n-lib.h> -#include "totem-subtitle-encoding.h" - -typedef enum -{ - SUBTITLE_ENCODING_CURRENT_LOCALE, - - SUBTITLE_ENCODING_ISO_8859_6, - SUBTITLE_ENCODING_IBM_864, - SUBTITLE_ENCODING_MAC_ARABIC, - SUBTITLE_ENCODING_WINDOWS_1256, - - SUBTITLE_ENCODING_ARMSCII_8, - - SUBTITLE_ENCODING_ISO_8859_4, - SUBTITLE_ENCODING_ISO_8859_13, - SUBTITLE_ENCODING_WINDOWS_1257, - - SUBTITLE_ENCODING_ISO_8859_14, - - SUBTITLE_ENCODING_ISO_8859_2, - SUBTITLE_ENCODING_IBM_852, - SUBTITLE_ENCODING_MAC_CE, - SUBTITLE_ENCODING_WINDOWS_1250, - - SUBTITLE_ENCODING_GB18030, - SUBTITLE_ENCODING_GB2312, - SUBTITLE_ENCODING_GBK, - SUBTITLE_ENCODING_HZ, - - SUBTITLE_ENCODING_BIG5, - SUBTITLE_ENCODING_BIG5_HKSCS, - SUBTITLE_ENCODING_EUC_TW, - - SUBTITLE_ENCODING_MAC_CROATIAN, - - SUBTITLE_ENCODING_ISO_8859_5, - SUBTITLE_ENCODING_IBM_855, - SUBTITLE_ENCODING_ISO_IR_111, - SUBTITLE_ENCODING_KOI8_R, - SUBTITLE_ENCODING_MAC_CYRILLIC, - SUBTITLE_ENCODING_WINDOWS_1251, - - SUBTITLE_ENCODING_CP_866, - - SUBTITLE_ENCODING_MAC_UKRAINIAN, - SUBTITLE_ENCODING_KOI8_U, - - SUBTITLE_ENCODING_GEOSTD8, - - SUBTITLE_ENCODING_ISO_8859_7, - SUBTITLE_ENCODING_MAC_GREEK, - SUBTITLE_ENCODING_WINDOWS_1253, - - SUBTITLE_ENCODING_MAC_GUJARATI, - - SUBTITLE_ENCODING_MAC_GURMUKHI, - - SUBTITLE_ENCODING_ISO_8859_8_I, - SUBTITLE_ENCODING_IBM_862, - SUBTITLE_ENCODING_MAC_HEBREW, - SUBTITLE_ENCODING_WINDOWS_1255, - - SUBTITLE_ENCODING_ISO_8859_8, - - SUBTITLE_ENCODING_MAC_DEVANAGARI, - - SUBTITLE_ENCODING_MAC_ICELANDIC, - - SUBTITLE_ENCODING_EUC_JP, - SUBTITLE_ENCODING_ISO_2022_JP, - SUBTITLE_ENCODING_SHIFT_JIS, - - SUBTITLE_ENCODING_EUC_KR, - SUBTITLE_ENCODING_ISO_2022_KR, - SUBTITLE_ENCODING_JOHAB, - SUBTITLE_ENCODING_UHC, - - SUBTITLE_ENCODING_ISO_8859_10, - - SUBTITLE_ENCODING_MAC_FARSI, - - SUBTITLE_ENCODING_ISO_8859_16, - SUBTITLE_ENCODING_MAC_ROMANIAN, - - SUBTITLE_ENCODING_ISO_8859_3, - - SUBTITLE_ENCODING_TIS_620, - - SUBTITLE_ENCODING_ISO_8859_9, - SUBTITLE_ENCODING_IBM_857, - SUBTITLE_ENCODING_MAC_TURKISH, - SUBTITLE_ENCODING_WINDOWS_1254, - - SUBTITLE_ENCODING_UTF_7, - SUBTITLE_ENCODING_UTF_8, - SUBTITLE_ENCODING_UTF_16, - SUBTITLE_ENCODING_UCS_2, - SUBTITLE_ENCODING_UCS_4, - - SUBTITLE_ENCODING_ISO_8859_1, - SUBTITLE_ENCODING_ISO_8859_15, - SUBTITLE_ENCODING_IBM_850, - SUBTITLE_ENCODING_MAC_ROMAN, - SUBTITLE_ENCODING_WINDOWS_1252, - - SUBTITLE_ENCODING_TCVN, - SUBTITLE_ENCODING_VISCII, - SUBTITLE_ENCODING_WINDOWS_1258, - - SUBTITLE_ENCODING_LAST -} SubtitleEncodingIndex; - - -typedef struct -{ - int index; - gboolean valid; - const char *charset; - const char *name; -} SubtitleEncoding; - - -static SubtitleEncoding encodings[] = { - - {SUBTITLE_ENCODING_CURRENT_LOCALE, TRUE, - NULL, N_("Current Locale")}, - - {SUBTITLE_ENCODING_ISO_8859_6, FALSE, - "ISO-8859-6", N_("Arabic")}, - {SUBTITLE_ENCODING_IBM_864, FALSE, - "IBM864", N_("Arabic")}, - {SUBTITLE_ENCODING_MAC_ARABIC, FALSE, - "MAC_ARABIC", N_("Arabic")}, - {SUBTITLE_ENCODING_WINDOWS_1256, FALSE, - "WINDOWS-1256", N_("Arabic")}, - - {SUBTITLE_ENCODING_ARMSCII_8, FALSE, - "ARMSCII-8", N_("Armenian")}, - - {SUBTITLE_ENCODING_ISO_8859_4, FALSE, - "ISO-8859-4", N_("Baltic")}, - {SUBTITLE_ENCODING_ISO_8859_13, FALSE, - "ISO-8859-13", N_("Baltic")}, - {SUBTITLE_ENCODING_WINDOWS_1257, FALSE, - "WINDOWS-1257", N_("Baltic")}, - - {SUBTITLE_ENCODING_ISO_8859_14, FALSE, - "ISO-8859-14", N_("Celtic")}, - - {SUBTITLE_ENCODING_ISO_8859_2, FALSE, - "ISO-8859-2", N_("Central European")}, - {SUBTITLE_ENCODING_IBM_852, FALSE, - "IBM852", N_("Central European")}, - {SUBTITLE_ENCODING_MAC_CE, FALSE, - "MAC_CE", N_("Central European")}, - {SUBTITLE_ENCODING_WINDOWS_1250, FALSE, - "WINDOWS-1250", N_("Central European")}, - - {SUBTITLE_ENCODING_GB18030, FALSE, - "GB18030", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_GB2312, FALSE, - "GB2312", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_GBK, FALSE, - "GBK", N_("Chinese Simplified")}, - {SUBTITLE_ENCODING_HZ, FALSE, - "HZ", N_("Chinese Simplified")}, - - {SUBTITLE_ENCODING_BIG5, FALSE, - "BIG5", N_("Chinese Traditional")}, - {SUBTITLE_ENCODING_BIG5_HKSCS, FALSE, - "BIG5-HKSCS", N_("Chinese Traditional")}, - {SUBTITLE_ENCODING_EUC_TW, FALSE, - "EUC-TW", N_("Chinese Traditional")}, - - {SUBTITLE_ENCODING_MAC_CROATIAN, FALSE, - "MAC_CROATIAN", N_("Croatian")}, - - {SUBTITLE_ENCODING_ISO_8859_5, FALSE, - "ISO-8859-5", N_("Cyrillic")}, - {SUBTITLE_ENCODING_IBM_855, FALSE, - "IBM855", N_("Cyrillic")}, - {SUBTITLE_ENCODING_ISO_IR_111, FALSE, - "ISO-IR-111", N_("Cyrillic")}, - {SUBTITLE_ENCODING_KOI8_R, FALSE, - "KOI8-R", N_("Cyrillic")}, - {SUBTITLE_ENCODING_MAC_CYRILLIC, FALSE, - "MAC-CYRILLIC", N_("Cyrillic")}, - {SUBTITLE_ENCODING_WINDOWS_1251, FALSE, - "WINDOWS-1251", N_("Cyrillic")}, - - {SUBTITLE_ENCODING_CP_866, FALSE, - "CP866", N_("Cyrillic/Russian")}, - - {SUBTITLE_ENCODING_MAC_UKRAINIAN, FALSE, - "MAC_UKRAINIAN", N_("Cyrillic/Ukrainian")}, - {SUBTITLE_ENCODING_KOI8_U, FALSE, - "KOI8-U", N_("Cyrillic/Ukrainian")}, - - {SUBTITLE_ENCODING_GEOSTD8, FALSE, - "GEORGIAN-PS", N_("Georgian")}, - - {SUBTITLE_ENCODING_ISO_8859_7, FALSE, - "ISO-8859-7", N_("Greek")}, - {SUBTITLE_ENCODING_MAC_GREEK, FALSE, - "MAC_GREEK", N_("Greek")}, - {SUBTITLE_ENCODING_WINDOWS_1253, FALSE, - "WINDOWS-1253", N_("Greek")}, - - {SUBTITLE_ENCODING_MAC_GUJARATI, FALSE, - "MAC_GUJARATI", N_("Gujarati")}, - - {SUBTITLE_ENCODING_MAC_GURMUKHI, FALSE, - "MAC_GURMUKHI", N_("Gurmukhi")}, - - {SUBTITLE_ENCODING_ISO_8859_8_I, FALSE, - "ISO-8859-8-I", N_("Hebrew")}, - {SUBTITLE_ENCODING_IBM_862, FALSE, - "IBM862", N_("Hebrew")}, - {SUBTITLE_ENCODING_MAC_HEBREW, FALSE, - "MAC_HEBREW", N_("Hebrew")}, - {SUBTITLE_ENCODING_WINDOWS_1255, FALSE, - "WINDOWS-1255", N_("Hebrew")}, - - {SUBTITLE_ENCODING_ISO_8859_8, FALSE, - "ISO-8859-8", N_("Hebrew Visual")}, - - {SUBTITLE_ENCODING_MAC_DEVANAGARI, FALSE, - "MAC_DEVANAGARI", N_("Hindi")}, - - {SUBTITLE_ENCODING_MAC_ICELANDIC, FALSE, - "MAC_ICELANDIC", N_("Icelandic")}, - - {SUBTITLE_ENCODING_EUC_JP, FALSE, - "EUC-JP", N_("Japanese")}, - {SUBTITLE_ENCODING_ISO_2022_JP, FALSE, - "ISO2022JP", N_("Japanese")}, - {SUBTITLE_ENCODING_SHIFT_JIS, FALSE, - "SHIFT-JIS", N_("Japanese")}, - - {SUBTITLE_ENCODING_EUC_KR, FALSE, - "EUC-KR", N_("Korean")}, - {SUBTITLE_ENCODING_ISO_2022_KR, FALSE, - "ISO2022KR", N_("Korean")}, - {SUBTITLE_ENCODING_JOHAB, FALSE, - "JOHAB", N_("Korean")}, - {SUBTITLE_ENCODING_UHC, FALSE, - "UHC", N_("Korean")}, - - {SUBTITLE_ENCODING_ISO_8859_10, FALSE, - "ISO-8859-10", N_("Nordic")}, - - {SUBTITLE_ENCODING_MAC_FARSI, FALSE, - "MAC_FARSI", N_("Persian")}, - - {SUBTITLE_ENCODING_ISO_8859_16, FALSE, - "ISO-8859-16", N_("Romanian")}, - {SUBTITLE_ENCODING_MAC_ROMANIAN, FALSE, - "MAC_ROMANIAN", N_("Romanian")}, - - {SUBTITLE_ENCODING_ISO_8859_3, FALSE, - "ISO-8859-3", N_("South European")}, - - {SUBTITLE_ENCODING_TIS_620, FALSE, - "TIS-620", N_("Thai")}, - - {SUBTITLE_ENCODING_ISO_8859_9, FALSE, - "ISO-8859-9", N_("Turkish")}, - {SUBTITLE_ENCODING_IBM_857, FALSE, - "IBM857", N_("Turkish")}, - {SUBTITLE_ENCODING_MAC_TURKISH, FALSE, - "MAC_TURKISH", N_("Turkish")}, - {SUBTITLE_ENCODING_WINDOWS_1254, FALSE, - "WINDOWS-1254", N_("Turkish")}, - - {SUBTITLE_ENCODING_UTF_7, FALSE, - "UTF-7", N_("Unicode")}, - {SUBTITLE_ENCODING_UTF_8, FALSE, - "UTF-8", N_("Unicode")}, - {SUBTITLE_ENCODING_UTF_16, FALSE, - "UTF-16", N_("Unicode")}, - {SUBTITLE_ENCODING_UCS_2, FALSE, - "UCS-2", N_("Unicode")}, - {SUBTITLE_ENCODING_UCS_4, FALSE, - "UCS-4", N_("Unicode")}, - - {SUBTITLE_ENCODING_ISO_8859_1, FALSE, - "ISO-8859-1", N_("Western")}, - {SUBTITLE_ENCODING_ISO_8859_15, FALSE, - "ISO-8859-15", N_("Western")}, - {SUBTITLE_ENCODING_IBM_850, FALSE, - "IBM850", N_("Western")}, - {SUBTITLE_ENCODING_MAC_ROMAN, FALSE, - "MAC_ROMAN", N_("Western")}, - {SUBTITLE_ENCODING_WINDOWS_1252, FALSE, - "WINDOWS-1252", N_("Western")}, - - {SUBTITLE_ENCODING_TCVN, FALSE, - "TCVN", N_("Vietnamese")}, - {SUBTITLE_ENCODING_VISCII, FALSE, - "VISCII", N_("Vietnamese")}, - {SUBTITLE_ENCODING_WINDOWS_1258, FALSE, - "WINDOWS-1258", N_("Vietnamese")} -}; - -static const SubtitleEncoding * -find_encoding_by_charset (const char *charset) -{ - int i; - - i = 1; /* skip current locale */ - while (i < SUBTITLE_ENCODING_LAST) { - if (strcasecmp (charset, encodings[i].charset) == 0) - return &encodings[i]; - - ++i; - } - - if (strcasecmp (charset, - encodings[SUBTITLE_ENCODING_CURRENT_LOCALE].charset) == 0) - return &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - - return NULL; -} - -static void -subtitle_encoding_init (void) -{ - int i; - gsize bytes_read, bytes_written; - gchar *converted; - gchar ascii_sample[96]; - - g_get_charset ((const char **) - &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE].charset); - - g_assert (G_N_ELEMENTS (encodings) == SUBTITLE_ENCODING_LAST); - - /* Initialize the sample text with all of the printing ASCII characters - * from space (32) to the tilde (126), 95 in all. */ - for (i = 0; i < (int) sizeof (ascii_sample); i++) - ascii_sample[i] = i + 32; - - ascii_sample[sizeof (ascii_sample) - 1] = '\0'; - - i = 0; - while (i < SUBTITLE_ENCODING_LAST) { - bytes_read = 0; - bytes_written = 0; - - g_assert (encodings[i].index == i); - - /* Translate the names */ - encodings[i].name = _(encodings[i].name); - - /* Test that the encoding is a proper superset of ASCII (which naive - * apps are going to use anyway) by attempting to validate the text - * using the current encoding. This also flushes out any encodings - * which the underlying GIConv implementation can't support. - */ - converted = g_convert (ascii_sample, sizeof (ascii_sample) - 1, - encodings[i].charset, encodings[i].charset, - &bytes_read, &bytes_written, NULL); - - /* The encoding is only valid if ASCII passes through cleanly. */ - if (i == SUBTITLE_ENCODING_CURRENT_LOCALE) - encodings[i].valid = TRUE; - else - encodings[i].valid = - (bytes_read == (sizeof (ascii_sample) - 1)) && - (converted != NULL) && (strcmp (converted, ascii_sample) == 0); - -#ifdef DEBUG_ENCODINGS - if (!encodings[i].valid) { - g_print ("Rejecting encoding %s as invalid:\n", encodings[i].charset); - g_print (" input \"%s\"\n", ascii_sample); - g_print (" output \"%s\"\n\n", converted ? converted : "(null)"); - } -#endif - - /* Discard the converted string. */ - g_free (converted); - - ++i; - } -} - -static int -subtitle_encoding_get_index (const char *charset) -{ - const SubtitleEncoding *e; - - e = find_encoding_by_charset (charset); - if (e != NULL) - return e->index; - else - return SUBTITLE_ENCODING_CURRENT_LOCALE; -} - -static const char * -subtitle_encoding_get_charset (int index_) -{ - const SubtitleEncoding *e; - - if (index_ >= SUBTITLE_ENCODING_LAST) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else if (index_ < SUBTITLE_ENCODING_CURRENT_LOCALE) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else if (!encodings[index_].valid) - e = &encodings[SUBTITLE_ENCODING_CURRENT_LOCALE]; - else - e = &encodings[index_]; - return e->charset; -} - -enum -{ - INDEX_COL, - NAME_COL -}; - -static gint -compare (GtkTreeModel * model, GtkTreeIter * a, GtkTreeIter * b, gpointer data) -{ - gchar *str_a, *str_b; - gint result; - - gtk_tree_model_get (model, a, NAME_COL, &str_a, -1); - gtk_tree_model_get (model, b, NAME_COL, &str_b, -1); - - result = strcmp (str_a, str_b); - - g_free (str_a); - g_free (str_b); - - return result; -} - -static void -is_encoding_sensitive (GtkCellLayout * cell_layout, - GtkCellRenderer * cell, - GtkTreeModel * tree_model, GtkTreeIter * iter, gpointer data) -{ - - gboolean sensitive; - - sensitive = !gtk_tree_model_iter_has_child (tree_model, iter); - g_object_set (cell, "sensitive", sensitive, NULL); -} - -static GtkTreeModel * -subtitle_encoding_create_store (void) -{ - gchar *label; - const gchar *lastlang = ""; - GtkTreeIter iter, iter2; - GtkTreeStore *store; - int i; - - store = gtk_tree_store_new (2, G_TYPE_INT, G_TYPE_STRING); - - for (i = 0; i < SUBTITLE_ENCODING_LAST; i++) { - if (encodings[i].valid) { - if (strcmp (lastlang, encodings[i].name)) { - lastlang = encodings[i].name; - gtk_tree_store_append (store, &iter, NULL); - gtk_tree_store_set (store, &iter, INDEX_COL, - -1, NAME_COL, lastlang, -1); - } - label = g_strdup_printf("%s (%s)", lastlang, encodings[i].charset); - gtk_tree_store_append (store, &iter2, &iter); - gtk_tree_store_set (store, &iter2, INDEX_COL, - encodings[i].index, NAME_COL, label, -1); - g_free(label); - } - } - gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store), - compare, NULL, NULL); - gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), - NAME_COL, GTK_SORT_ASCENDING); - return GTK_TREE_MODEL (store); -} - -static void -subtitle_encoding_combo_render (GtkComboBox * combo) -{ - GtkCellRenderer *renderer; - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, - "text", NAME_COL, NULL); - gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), - renderer, is_encoding_sensitive, NULL, NULL); -} - -const char * -totem_subtitle_encoding_get_selected (GtkComboBox * combo) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gint index_ = -1; - - model = gtk_combo_box_get_model (combo); - if (gtk_combo_box_get_active_iter (combo, &iter)) { - gtk_tree_model_get (model, &iter, INDEX_COL, &index_, -1); - } - if (index_ == -1) - return NULL; - return subtitle_encoding_get_charset (index_); -} - -void -totem_subtitle_encoding_set (GtkComboBox * combo, const char *encoding) -{ - GtkTreeModel *model; - GtkTreeIter iter, iter2; - gint index_, i; - - g_return_if_fail (encoding != NULL); - - model = gtk_combo_box_get_model (combo); - index_ = subtitle_encoding_get_index (encoding); - gtk_tree_model_get_iter_first (model, &iter); - do { - if (!gtk_tree_model_iter_has_child (model, &iter)) - continue; - if (!gtk_tree_model_iter_children (model, &iter2, &iter)) - continue; - do { - gtk_tree_model_get (model, &iter2, INDEX_COL, &i, -1); - if (i == index_) - break; - } while (gtk_tree_model_iter_next (model, &iter2)); - if (i == index_) - break; - } while (gtk_tree_model_iter_next (model, &iter)); - gtk_combo_box_set_active_iter (combo, &iter2); -} - -void -totem_subtitle_encoding_init (GtkComboBox *combo) -{ - GtkTreeModel *model; - subtitle_encoding_init (); - model = subtitle_encoding_create_store (); - gtk_combo_box_set_model (combo, model); - g_object_unref (model); - subtitle_encoding_combo_render (combo); -} - -/* - * vim: sw=2 ts=8 cindent noai bs=2 - */ diff --git a/tp-account-widgets/totem-subtitle-encoding.h b/tp-account-widgets/totem-subtitle-encoding.h deleted file mode 100644 index 656c0dec5..000000000 --- a/tp-account-widgets/totem-subtitle-encoding.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2001-2006 Bastien Nocera <hadess@hadess.net> - * - * encoding list copied from gnome-terminal/encoding.c - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * The Totem project hereby grant permission for non-gpl compatible GStreamer - * plugins to be used and distributed together with GStreamer and Totem. This - * permission are above and beyond the permissions granted by the GPL license - * Totem is covered by. - * - * Monday 7th February 2005: Christian Schaller: Add exception clause. - * See license_change file for details. - * - */ - -/* Encoding stuff */ - -#ifndef TOTEM_SUBTITLE_ENCODING_H -#define TOTEM_SUBTITLE_ENCODING_H - -#include <gtk/gtk.h> - -void totem_subtitle_encoding_init (GtkComboBox *combo); -void totem_subtitle_encoding_set (GtkComboBox *combo, const char *encoding); -const char * totem_subtitle_encoding_get_selected (GtkComboBox *combo); - -#endif /* SUBTITLE_ENCODING_H */ diff --git a/tp-account-widgets/tpaw-account-settings.c b/tp-account-widgets/tpaw-account-settings.c deleted file mode 100644 index 02abff60d..000000000 --- a/tp-account-widgets/tpaw-account-settings.c +++ /dev/null @@ -1,1653 +0,0 @@ -/* - * tpaw-account-settings.c - Source for TpawAccountSettings - * Copyright (C) 2009 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-account-settings.h" - -#include "tpaw-connection-managers.h" -#include "tpaw-keyring.h" -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT -#include "tpaw-debug.h" - -G_DEFINE_TYPE(TpawAccountSettings, tpaw_account_settings, G_TYPE_OBJECT) - -enum { - PROP_ACCOUNT = 1, - PROP_CM_NAME, - PROP_PROTOCOL, - PROP_SERVICE, - PROP_DISPLAY_NAME, - PROP_DISPLAY_NAME_OVERRIDDEN, - PROP_READY -}; - -enum { - PASSWORD_RETRIEVED = 1, - LAST_SIGNAL -}; - -static gulong signals[LAST_SIGNAL] = { 0, }; - -struct _TpawAccountSettingsPriv -{ - gboolean dispose_has_run; - TpawConnectionManagers *managers; - TpAccountManager *account_manager; - - TpConnectionManager *manager; - TpProtocol *protocol_obj; - - TpAccount *account; - gchar *cm_name; - gchar *protocol; - gchar *service; - gchar *display_name; - gchar *icon_name; - gchar *storage_provider; - gboolean display_name_overridden; - gboolean ready; - - gboolean supports_sasl; - gboolean remember_password; - - gchar *password; - gchar *password_original; - - gboolean password_retrieved; - gboolean password_requested; - - /* Parameter name (gchar *) -> parameter value (GVariant) */ - GHashTable *parameters; - /* Keys are parameter names from the hash above (gchar *). - * Values are regular expresions that should match corresponding parameter - * values (GRegex *). Possible regexp patterns are defined in - * tpaw-account-widget.c */ - GHashTable *param_regexps; - GArray *unset_parameters; - GList *required_params; - - gulong managers_ready_id; - gboolean preparing_protocol; - - /* If TRUE, the account should have 'tel' in its - * Account.Interface.Addressing.URISchemes property. */ - gboolean uri_scheme_tel; - /* If TRUE, Service property needs to be updated when applying changes */ - gboolean update_service; - - GSimpleAsyncResult *apply_result; -}; - -static void -tpaw_account_settings_init (TpawAccountSettings *obj) -{ - obj->priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), - TPAW_TYPE_ACCOUNT_SETTINGS, TpawAccountSettingsPriv); - - /* allocate any data required by the object here */ - obj->priv->managers = tpaw_connection_managers_dup_singleton (); - obj->priv->account_manager = tp_account_manager_dup (); - - obj->priv->parameters = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_variant_unref); - - obj->priv->param_regexps = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, (GDestroyNotify) g_regex_unref); - - obj->priv->unset_parameters = g_array_new (TRUE, FALSE, sizeof (gchar *)); - - obj->priv->required_params = NULL; -} - -static void tpaw_account_settings_dispose (GObject *object); -static void tpaw_account_settings_finalize (GObject *object); -static void tpaw_account_settings_account_ready_cb (GObject *source_object, - GAsyncResult *result, gpointer user_data); -static void tpaw_account_settings_managers_ready_cb (GObject *obj, - GParamSpec *pspec, gpointer user_data); -static void tpaw_account_settings_check_readyness ( - TpawAccountSettings *self); - -static void -tpaw_account_settings_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - - switch (prop_id) - { - case PROP_ACCOUNT: - self->priv->account = g_value_dup_object (value); - break; - case PROP_CM_NAME: - self->priv->cm_name = g_value_dup_string (value); - break; - case PROP_PROTOCOL: - self->priv->protocol = g_value_dup_string (value); - break; - case PROP_SERVICE: - self->priv->service = g_value_dup_string (value); - break; - case PROP_DISPLAY_NAME: - self->priv->display_name = g_value_dup_string (value); - break; - case PROP_DISPLAY_NAME_OVERRIDDEN: - self->priv->display_name_overridden = g_value_get_boolean (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_account_settings_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - - switch (prop_id) - { - case PROP_ACCOUNT: - g_value_set_object (value, self->priv->account); - break; - case PROP_CM_NAME: - g_value_set_string (value, self->priv->cm_name); - break; - case PROP_PROTOCOL: - g_value_set_string (value, self->priv->protocol); - break; - case PROP_SERVICE: - g_value_set_string (value, self->priv->service); - break; - case PROP_DISPLAY_NAME: - g_value_set_string (value, self->priv->display_name); - break; - case PROP_DISPLAY_NAME_OVERRIDDEN: - g_value_set_boolean (value, self->priv->display_name_overridden); - break; - case PROP_READY: - g_value_set_boolean (value, self->priv->ready); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_account_settings_constructed (GObject *object) -{ - TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - - if (self->priv->account != NULL) - { - g_free (self->priv->cm_name); - g_free (self->priv->protocol); - g_free (self->priv->service); - - self->priv->cm_name = - g_strdup (tp_account_get_cm_name (self->priv->account)); - self->priv->protocol = - g_strdup (tp_account_get_protocol_name (self->priv->account)); - self->priv->service = - g_strdup (tp_account_get_service (self->priv->account)); - self->priv->icon_name = g_strdup - (tp_account_get_icon_name (self->priv->account)); - } - else - { - self->priv->icon_name = tpaw_protocol_icon_name (self->priv->protocol); - } - - g_assert (self->priv->cm_name != NULL && self->priv->protocol != NULL); - - tpaw_account_settings_check_readyness (self); - - if (!self->priv->ready) - { - GQuark features[] = { - TP_ACCOUNT_FEATURE_CORE, - TP_ACCOUNT_FEATURE_STORAGE, - TP_ACCOUNT_FEATURE_ADDRESSING, - 0 }; - - if (self->priv->account != NULL) - { - tp_proxy_prepare_async (self->priv->account, features, - tpaw_account_settings_account_ready_cb, self); - } - - tp_g_signal_connect_object (self->priv->managers, "notify::ready", - G_CALLBACK (tpaw_account_settings_managers_ready_cb), object, 0); - } - - if (G_OBJECT_CLASS ( - tpaw_account_settings_parent_class)->constructed != NULL) - G_OBJECT_CLASS ( - tpaw_account_settings_parent_class)->constructed (object); -} - - -static void -tpaw_account_settings_class_init ( - TpawAccountSettingsClass *tpaw_account_settings_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (tpaw_account_settings_class); - - g_type_class_add_private (tpaw_account_settings_class, sizeof - (TpawAccountSettingsPriv)); - - object_class->dispose = tpaw_account_settings_dispose; - object_class->finalize = tpaw_account_settings_finalize; - object_class->set_property = tpaw_account_settings_set_property; - object_class->get_property = tpaw_account_settings_get_property; - object_class->constructed = tpaw_account_settings_constructed; - - g_object_class_install_property (object_class, PROP_ACCOUNT, - g_param_spec_object ("account", - "Account", - "The TpAccount backing these settings", - TP_TYPE_ACCOUNT, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_CM_NAME, - g_param_spec_string ("connection-manager", - "connection-manager", - "The name of the connection manager this account uses", - NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_PROTOCOL, - g_param_spec_string ("protocol", - "Protocol", - "The name of the protocol this account uses", - NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_SERVICE, - g_param_spec_string ("service", - "Service", - "The service of this account, or NULL", - NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_DISPLAY_NAME, - g_param_spec_string ("display-name", - "display-name", - "The display name account these settings belong to", - NULL, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_DISPLAY_NAME_OVERRIDDEN, - g_param_spec_boolean ("display-name-overridden", - "display-name-overridden", - "Whether the display name for this account has been manually " - "overridden", - FALSE, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_READY, - g_param_spec_boolean ("ready", - "Ready", - "Whether this account is ready to be used", - FALSE, - G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); - - signals[PASSWORD_RETRIEVED] = - g_signal_new ("password-retrieved", - G_TYPE_FROM_CLASS (tpaw_account_settings_class), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 0); -} - -static void -tpaw_account_settings_dispose (GObject *object) -{ - TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - - if (self->priv->dispose_has_run) - return; - - self->priv->dispose_has_run = TRUE; - - if (self->priv->managers_ready_id != 0) - g_signal_handler_disconnect (self->priv->managers, - self->priv->managers_ready_id); - self->priv->managers_ready_id = 0; - - tp_clear_object (&self->priv->managers); - tp_clear_object (&self->priv->manager); - tp_clear_object (&self->priv->account_manager); - tp_clear_object (&self->priv->account); - tp_clear_object (&self->priv->protocol_obj); - - /* release any references held by the object here */ - if (G_OBJECT_CLASS (tpaw_account_settings_parent_class)->dispose) - G_OBJECT_CLASS (tpaw_account_settings_parent_class)->dispose (object); -} - -static void -tpaw_account_settings_free_unset_parameters ( - TpawAccountSettings *settings) -{ - guint i; - - for (i = 0 ; i < settings->priv->unset_parameters->len; i++) - g_free (g_array_index (settings->priv->unset_parameters, gchar *, i)); - - g_array_set_size (settings->priv->unset_parameters, 0); -} - -static void -tpaw_account_settings_finalize (GObject *object) -{ - TpawAccountSettings *self = TPAW_ACCOUNT_SETTINGS (object); - GList *l; - - /* free any data held directly by the object here */ - g_free (self->priv->cm_name); - g_free (self->priv->protocol); - g_free (self->priv->service); - g_free (self->priv->display_name); - g_free (self->priv->icon_name); - g_free (self->priv->password); - g_free (self->priv->password_original); - g_free (self->priv->storage_provider); - - if (self->priv->required_params != NULL) - { - for (l = self->priv->required_params; l; l = l->next) - g_free (l->data); - g_list_free (self->priv->required_params); - } - - g_hash_table_unref (self->priv->parameters); - g_hash_table_unref (self->priv->param_regexps); - - tpaw_account_settings_free_unset_parameters (self); - g_array_unref (self->priv->unset_parameters); - - G_OBJECT_CLASS (tpaw_account_settings_parent_class)->finalize (object); -} - -static void -tpaw_account_settings_protocol_obj_prepared_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountSettings *self = user_data; - GError *error = NULL; - - if (!tp_proxy_prepare_finish (source, result, &error)) - { - DEBUG ("Failed to prepare protocol object: %s", error->message); - g_clear_error (&error); - return; - } - - tpaw_account_settings_check_readyness (self); -} - -static void -tpaw_account_settings_get_password_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountSettings *self = user_data; - const gchar *password; - GError *error = NULL; - - password = tpaw_keyring_get_account_password_finish (TP_ACCOUNT (source), - result, &error); - - if (error != NULL) - { - DEBUG ("Failed to get password: %s", error->message); - g_clear_error (&error); - } - - /* It doesn't really matter if getting the password failed; that - * just means that it's not there, or let's act like that at - * least. */ - - g_assert (self->priv->password == NULL); - - self->priv->password = g_strdup (password); - self->priv->password_original = g_strdup (password); - - g_signal_emit (self, signals[PASSWORD_RETRIEVED], 0); -} - -static gboolean -account_has_uri_scheme_tel (TpAccount *account) -{ - return tp_account_associated_with_uri_scheme (account, "tel"); -} - -static GVariant * tpaw_account_settings_dup ( - TpawAccountSettings *settings, - const gchar *param); - -static void -tpaw_account_settings_check_readyness (TpawAccountSettings *self) -{ - GQuark features[] = { TP_PROTOCOL_FEATURE_CORE, 0 }; - - if (self->priv->ready) - return; - - if (self->priv->account != NULL - && !tp_account_is_prepared (self->priv->account, - TP_ACCOUNT_FEATURE_CORE)) - return; - - if (!tpaw_connection_managers_is_ready (self->priv->managers)) - return; - - if (self->priv->manager == NULL) - { - self->priv->manager = tpaw_connection_managers_get_cm ( - self->priv->managers, self->priv->cm_name); - } - - if (self->priv->manager == NULL) - return; - - g_object_ref (self->priv->manager); - - if (self->priv->account != NULL) - { - g_free (self->priv->display_name); - self->priv->display_name = - g_strdup (tp_account_get_display_name (self->priv->account)); - - g_free (self->priv->icon_name); - self->priv->icon_name = - g_strdup (tp_account_get_icon_name (self->priv->account)); - - self->priv->uri_scheme_tel = account_has_uri_scheme_tel ( - self->priv->account); - } - - if (self->priv->protocol_obj == NULL) - { - self->priv->protocol_obj = g_object_ref ( - tp_connection_manager_get_protocol_object (self->priv->manager, - self->priv->protocol)); - } - - if (!tp_proxy_is_prepared (self->priv->protocol_obj, - TP_PROTOCOL_FEATURE_CORE) - && !self->priv->preparing_protocol) - { - self->priv->preparing_protocol = TRUE; - tp_proxy_prepare_async (self->priv->protocol_obj, features, - tpaw_account_settings_protocol_obj_prepared_cb, self); - return; - } - else - { - if (tp_strv_contains (tp_protocol_get_authentication_types ( - self->priv->protocol_obj), - TP_IFACE_CHANNEL_INTERFACE_SASL_AUTHENTICATION)) - { - self->priv->supports_sasl = TRUE; - } - } - - if (self->priv->required_params == NULL) - { - GList *params, *l; - - params = tp_protocol_dup_params (self->priv->protocol_obj); - for (l = params; l != NULL; l = g_list_next (l)) - { - TpConnectionManagerParam *cur = l->data; - - if (tp_connection_manager_param_is_required (cur)) - { - self->priv->required_params = g_list_append ( - self->priv->required_params, - g_strdup (tp_connection_manager_param_get_name (cur))); - } - } - - g_list_free_full (params, - (GDestroyNotify) tp_connection_manager_param_free); - } - - /* self->priv->account won't be a proper account if it's the account - * assistant showing this widget. */ - if (self->priv->supports_sasl && !self->priv->password_requested - && self->priv->account != NULL) - { - self->priv->password_requested = TRUE; - - /* Make this call but don't block on its readiness. We'll signal - * if it's updated later with ::password-retrieved. */ - tpaw_keyring_get_account_password_async (self->priv->account, - tpaw_account_settings_get_password_cb, self); - } - - self->priv->ready = TRUE; - g_object_notify (G_OBJECT (self), "ready"); -} - -static void -tpaw_account_settings_account_ready_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - TpAccount *account = TP_ACCOUNT (source_object); - GError *error = NULL; - - if (!tp_proxy_prepare_finish (account, result, &error)) - { - DEBUG ("Failed to prepare account: %s", error->message); - g_error_free (error); - return; - } - - tpaw_account_settings_check_readyness (settings); -} - -static void -tpaw_account_settings_managers_ready_cb (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - - tpaw_account_settings_check_readyness (settings); -} - -TpawAccountSettings * -tpaw_account_settings_new (const gchar *connection_manager, - const gchar *protocol, - const gchar *service, - const char *display_name) -{ - return g_object_new (TPAW_TYPE_ACCOUNT_SETTINGS, - "connection-manager", connection_manager, - "protocol", protocol, - "service", service, - "display-name", display_name, - NULL); -} - -TpawAccountSettings * -tpaw_account_settings_new_for_account (TpAccount *account) -{ - return g_object_new (TPAW_TYPE_ACCOUNT_SETTINGS, - "account", account, - NULL); -} - -GList * -tpaw_account_settings_dup_tp_params (TpawAccountSettings *settings) -{ - g_return_val_if_fail (settings->priv->protocol_obj != NULL, NULL); - - return tp_protocol_dup_params (settings->priv->protocol_obj); -} - -gboolean -tpaw_account_settings_is_ready (TpawAccountSettings *settings) -{ - return settings->priv->ready; -} - -const gchar * -tpaw_account_settings_get_cm (TpawAccountSettings *settings) -{ - return settings->priv->cm_name; -} - -const gchar * -tpaw_account_settings_get_protocol (TpawAccountSettings *settings) -{ - return settings->priv->protocol; -} - -const gchar * -tpaw_account_settings_get_service (TpawAccountSettings *settings) -{ - return settings->priv->service; -} - -void -tpaw_account_settings_set_service (TpawAccountSettings *settings, - const gchar *service) -{ - if (!tp_strdiff (settings->priv->service, service)) - return; - - g_free (settings->priv->service); - settings->priv->service = g_strdup (service); - g_object_notify (G_OBJECT (settings), "service"); - settings->priv->update_service = TRUE; -} - -gchar * -tpaw_account_settings_get_icon_name (TpawAccountSettings *settings) -{ - return settings->priv->icon_name; -} - -const gchar * -tpaw_account_settings_get_display_name (TpawAccountSettings *settings) -{ - return settings->priv->display_name; -} - -TpAccount * -tpaw_account_settings_get_account (TpawAccountSettings *settings) -{ - return settings->priv->account; -} - -static gboolean -tpaw_account_settings_is_unset (TpawAccountSettings *settings, - const gchar *param) -{ - GArray *a; - guint i; - - a = settings->priv->unset_parameters; - - for (i = 0; i < a->len; i++) - { - if (!tp_strdiff (g_array_index (a, gchar *, i), param)) - return TRUE; - } - - return FALSE; -} - -static const TpConnectionManagerParam * -tpaw_account_settings_get_tp_param (TpawAccountSettings *settings, - const gchar *param) -{ - return tp_protocol_get_param (settings->priv->protocol_obj, param); -} - -gboolean -tpaw_account_settings_have_tp_param (TpawAccountSettings *settings, - const gchar *param) -{ - return (tpaw_account_settings_get_tp_param (settings, param) != NULL); -} - -static void -account_settings_remove_from_unset (TpawAccountSettings *settings, - const gchar *param) -{ - guint idx; - gchar *val; - - for (idx = 0; idx < settings->priv->unset_parameters->len; idx++) - { - val = g_array_index (settings->priv->unset_parameters, gchar *, idx); - - if (!tp_strdiff (val, param)) - { - settings->priv->unset_parameters = - g_array_remove_index (settings->priv->unset_parameters, idx); - g_free (val); - - break; - } - } -} - -GVariant * -tpaw_account_settings_dup_default (TpawAccountSettings *settings, - const gchar *param) -{ - const TpConnectionManagerParam *p; - - p = tpaw_account_settings_get_tp_param (settings, param); - if (p == NULL) - return NULL; - - return tp_connection_manager_param_dup_default_variant (p); -} - -const gchar * -tpaw_account_settings_get_dbus_signature (TpawAccountSettings *settings, - const gchar *param) -{ - const TpConnectionManagerParam *p; - - p = tpaw_account_settings_get_tp_param (settings, param); - - if (p == NULL) - return NULL; - - return tp_connection_manager_param_get_dbus_signature (p); -} - -static GVariant * -tpaw_account_settings_dup (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *result; - - /* Lookup the update parameters we set */ - result = g_hash_table_lookup (settings->priv->parameters, param); - if (result != NULL) - return g_variant_ref (result); - - /* If the parameters isn't unset use the accounts setting if any */ - if (settings->priv->account != NULL - && !tpaw_account_settings_is_unset (settings, param)) - { - GVariant *parameters; - - parameters = tp_account_dup_parameters_vardict ( - settings->priv->account); - result = g_variant_lookup_value (parameters, param, NULL); - g_variant_unref (parameters); - - if (result != NULL) - /* g_variant_lookup_value() is (transfer full) */ - return result; - } - - /* fallback to the default */ - return tpaw_account_settings_dup_default (settings, param); -} - -void -tpaw_account_settings_unset (TpawAccountSettings *settings, - const gchar *param) -{ - gchar *v; - if (tpaw_account_settings_is_unset (settings, param)) - return; - - if (settings->priv->supports_sasl && !tp_strdiff (param, "password")) - { - g_free (settings->priv->password); - settings->priv->password = NULL; - return; - } - - v = g_strdup (param); - - g_array_append_val (settings->priv->unset_parameters, v); - g_hash_table_remove (settings->priv->parameters, param); -} - -void -tpaw_account_settings_discard_changes (TpawAccountSettings *settings) -{ - g_hash_table_remove_all (settings->priv->parameters); - tpaw_account_settings_free_unset_parameters (settings); - - g_free (settings->priv->password); - settings->priv->password = g_strdup (settings->priv->password_original); - - if (settings->priv->account != NULL) - settings->priv->uri_scheme_tel = account_has_uri_scheme_tel ( - settings->priv->account); - else - settings->priv->uri_scheme_tel = FALSE; -} - -gchar * -tpaw_account_settings_dup_string (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - gchar *result = NULL; - - if (!tp_strdiff (param, "password") && settings->priv->supports_sasl) - { - return g_strdup (settings->priv->password); - } - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return NULL; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) - result = g_variant_dup_string (v, NULL); - - g_variant_unref (v); - return result; -} - -GStrv -tpaw_account_settings_dup_strv (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - GStrv result = NULL; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return NULL; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING_ARRAY)) - result = g_variant_dup_strv (v, NULL); - - g_variant_unref (v); - return result; -} - -gint32 -tpaw_account_settings_get_int32 (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - gint32 ret = 0; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return 0; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) - ret = g_variant_get_byte (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) - ret = g_variant_get_int32 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) - ret = CLAMP (g_variant_get_uint32 (v), (guint) G_MININT32, - G_MAXINT32); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) - ret = CLAMP (g_variant_get_int64 (v), G_MININT32, G_MAXINT32); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) - ret = CLAMP (g_variant_get_uint64 (v), (guint64) G_MININT32, G_MAXINT32); - else - { - gchar *tmp; - - tmp = g_variant_print (v, TRUE); - DEBUG ("Unsupported type for param '%s': %s'", param, tmp); - g_free (tmp); - } - - g_variant_unref (v); - return ret; -} - -gint64 -tpaw_account_settings_get_int64 (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - gint64 ret = 0; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return 0; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) - ret = g_variant_get_byte (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) - ret = g_variant_get_int32 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) - ret = g_variant_get_uint32 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) - ret = g_variant_get_int64 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) - ret = CLAMP (g_variant_get_uint64 (v), (guint64) G_MININT64, G_MAXINT64); - else - { - gchar *tmp; - - tmp = g_variant_print (v, TRUE); - DEBUG ("Unsupported type for param '%s': %s'", param, tmp); - g_free (tmp); - } - - g_variant_unref (v); - return ret; -} - -guint32 -tpaw_account_settings_get_uint32 (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - guint32 ret = 0; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return 0; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) - ret = g_variant_get_byte (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) - ret = MAX (0, g_variant_get_int32 (v)); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) - ret = g_variant_get_uint32 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) - ret = CLAMP (g_variant_get_int64 (v), 0, G_MAXUINT32); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) - ret = MIN (g_variant_get_uint64 (v), G_MAXUINT32); - else - { - gchar *tmp; - - tmp = g_variant_print (v, TRUE); - DEBUG ("Unsupported type for param '%s': %s'", param, tmp); - g_free (tmp); - } - - g_variant_unref (v); - return ret; -} - -guint64 -tpaw_account_settings_get_uint64 (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - guint64 ret = 0; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return 0; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_BYTE)) - ret = g_variant_get_byte (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT32)) - ret = MAX (0, g_variant_get_int32 (v)); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT32)) - ret = g_variant_get_uint32 (v); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_INT64)) - ret = MAX (0, g_variant_get_int64 (v)); - else if (g_variant_is_of_type (v, G_VARIANT_TYPE_UINT64)) - ret = g_variant_get_uint64 (v); - else - { - gchar *tmp; - - tmp = g_variant_print (v, TRUE); - DEBUG ("Unsupported type for param '%s': %s'", param, tmp); - g_free (tmp); - } - - - g_variant_unref (v); - return ret; -} - -gboolean -tpaw_account_settings_get_boolean (TpawAccountSettings *settings, - const gchar *param) -{ - GVariant *v; - gboolean result = FALSE; - - v = tpaw_account_settings_dup (settings, param); - if (v == NULL) - return result; - - if (g_variant_is_of_type (v, G_VARIANT_TYPE_BOOLEAN)) - result = g_variant_get_boolean (v); - - return result; -} - -void -tpaw_account_settings_set (TpawAccountSettings *settings, - const gchar *param, - GVariant *v) -{ - g_return_if_fail (param != NULL); - g_return_if_fail (v != NULL); - - if (!tp_strdiff (param, "password") && settings->priv->supports_sasl && - g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) - { - g_free (settings->priv->password); - settings->priv->password = g_variant_dup_string (v, NULL); - } - else - { - g_hash_table_insert (settings->priv->parameters, g_strdup (param), - g_variant_ref_sink (v)); - } - - account_settings_remove_from_unset (settings, param); -} - -static void -account_settings_display_name_set_cb (GObject *src, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - TpAccount *account = TP_ACCOUNT (src); - GSimpleAsyncResult *set_result = user_data; - - tp_account_set_display_name_finish (account, res, &error); - - if (error != NULL) - { - g_simple_async_result_set_from_error (set_result, error); - g_error_free (error); - } - - g_simple_async_result_complete (set_result); - g_object_unref (set_result); -} - -void -tpaw_account_settings_set_display_name_async ( - TpawAccountSettings *settings, - const gchar *name, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - g_return_if_fail (name != NULL); - - result = g_simple_async_result_new (G_OBJECT (settings), - callback, user_data, tpaw_account_settings_set_display_name_finish); - - if (!tp_strdiff (name, settings->priv->display_name)) - { - /* Nothing to do */ - g_simple_async_result_complete_in_idle (result); - return; - } - - g_free (settings->priv->display_name); - settings->priv->display_name = g_strdup (name); - - if (settings->priv->account == NULL) - { - g_simple_async_result_complete_in_idle (result); - return; - } - - tp_account_set_display_name_async (settings->priv->account, name, - account_settings_display_name_set_cb, result); -} - -gboolean -tpaw_account_settings_set_display_name_finish ( - TpawAccountSettings *settings, - GAsyncResult *result, - GError **error) -{ - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), - error)) - return FALSE; - - g_return_val_if_fail (g_simple_async_result_is_valid (result, - G_OBJECT (settings), tpaw_account_settings_set_display_name_finish), - FALSE); - - return TRUE; -} - -static void -account_settings_icon_name_set_cb (GObject *src, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - TpAccount *account = TP_ACCOUNT (src); - GSimpleAsyncResult *set_result = user_data; - - tp_account_set_icon_name_finish (account, res, &error); - - if (error != NULL) - { - g_simple_async_result_set_from_error (set_result, error); - g_error_free (error); - } - - g_simple_async_result_complete (set_result); - g_object_unref (set_result); -} - -void -tpaw_account_settings_set_icon_name_async ( - TpawAccountSettings *settings, - const gchar *name, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - g_return_if_fail (name != NULL); - - result = g_simple_async_result_new (G_OBJECT (settings), - callback, user_data, tpaw_account_settings_set_icon_name_finish); - - if (settings->priv->account == NULL) - { - if (settings->priv->icon_name != NULL) - g_free (settings->priv->icon_name); - - settings->priv->icon_name = g_strdup (name); - - g_simple_async_result_complete_in_idle (result); - - return; - } - - tp_account_set_icon_name_async (settings->priv->account, name, - account_settings_icon_name_set_cb, result); -} - -gboolean -tpaw_account_settings_set_icon_name_finish ( - TpawAccountSettings *settings, - GAsyncResult *result, - GError **error) -{ - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), - error)) - return FALSE; - - g_return_val_if_fail (g_simple_async_result_is_valid (result, - G_OBJECT (settings), tpaw_account_settings_set_icon_name_finish), - FALSE); - - return TRUE; -} - -static void -tpaw_account_settings_processed_password (GObject *source, - GAsyncResult *result, - gpointer user_data, - gpointer finish_func) -{ - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - GSimpleAsyncResult *r; - GError *error = NULL; - gboolean (*func) (TpAccount *source, GAsyncResult *result, GError **error) = - finish_func; - - g_free (settings->priv->password_original); - settings->priv->password_original = g_strdup (settings->priv->password); - - if (!func (TP_ACCOUNT (source), result, &error)) - { - g_simple_async_result_set_from_error (settings->priv->apply_result, - error); - g_error_free (error); - } - - tpaw_account_settings_discard_changes (settings); - - r = settings->priv->apply_result; - settings->priv->apply_result = NULL; - - g_simple_async_result_complete (r); - g_object_unref (r); -} - -static void -tpaw_account_settings_set_password_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - tpaw_account_settings_processed_password (source, result, user_data, - tpaw_keyring_set_account_password_finish); -} - -static void -tpaw_account_settings_delete_password_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - tpaw_account_settings_processed_password (source, result, user_data, - tpaw_keyring_delete_account_password_finish); -} - -static void -update_account_uri_schemes (TpawAccountSettings *self) -{ - if (self->priv->uri_scheme_tel == account_has_uri_scheme_tel ( - self->priv->account)) - return; - - tp_account_set_uri_scheme_association_async (self->priv->account, "tel", - self->priv->uri_scheme_tel, NULL, NULL); -} - -static void -set_service_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GError *error = NULL; - - if (!tp_account_set_service_finish (TP_ACCOUNT (source), result, &error)) - { - DEBUG ("Failed to set Account.Service: %s", error->message); - g_error_free (error); - } -} - -static void -update_account_service (TpawAccountSettings *self) -{ - if (!self->priv->update_service) - return; - - tp_account_set_service_async (self->priv->account, - self->priv->service != NULL ? self->priv->service : "", - set_service_cb, self); -} - -static void -tpaw_account_settings_account_updated (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - GSimpleAsyncResult *r; - GError *error = NULL; - GStrv reconnect_required = NULL; - - if (!tp_account_update_parameters_vardict_finish (TP_ACCOUNT (source), - result, &reconnect_required, &error)) - { - g_simple_async_result_set_from_error (settings->priv->apply_result, - error); - g_error_free (error); - goto out; - } - - update_account_uri_schemes (settings); - update_account_service (settings); - - g_simple_async_result_set_op_res_gboolean (settings->priv->apply_result, - g_strv_length (reconnect_required) > 0); - - /* Only set the password in the keyring if the CM supports SASL. */ - if (settings->priv->supports_sasl) - { - if (settings->priv->password != NULL) - { - /* FIXME: we shouldn't save the password if we - * can't (MaySaveResponse=False) but we don't have API to check that - * at this point (fdo #35382). */ - tpaw_keyring_set_account_password_async (settings->priv->account, - settings->priv->password, settings->priv->remember_password, - tpaw_account_settings_set_password_cb, settings); - } - else - { - tpaw_keyring_delete_account_password_async ( - settings->priv->account, - tpaw_account_settings_delete_password_cb, settings); - } - - return; - } - -out: - tpaw_account_settings_discard_changes (settings); - - r = settings->priv->apply_result; - settings->priv->apply_result = NULL; - - g_simple_async_result_complete (r); - g_object_unref (r); - g_strfreev (reconnect_required); -} - -static void -tpaw_account_settings_created_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (user_data); - GError *error = NULL; - GSimpleAsyncResult *r; - - settings->priv->account = tp_account_request_create_account_finish ( - TP_ACCOUNT_REQUEST (source), result, &error); - - if (settings->priv->account == NULL) - { - g_simple_async_result_set_from_error (settings->priv->apply_result, - error); - } - else - { - if (settings->priv->supports_sasl && settings->priv->password != NULL) - { - /* Save the password before connecting */ - /* FIXME: we shouldn't save the password if we - * can't (MaySaveResponse=False) but we don't have API to check that - * at this point (fdo #35382). */ - tpaw_keyring_set_account_password_async (settings->priv->account, - settings->priv->password, settings->priv->remember_password, - tpaw_account_settings_set_password_cb, - settings); - return; - } - - update_account_uri_schemes (settings); - - tpaw_account_settings_discard_changes (settings); - } - - r = settings->priv->apply_result; - settings->priv->apply_result = NULL; - - g_simple_async_result_complete (r); - g_object_unref (r); -} - -static void -tpaw_account_settings_do_create_account (TpawAccountSettings *self) -{ - TpAccountRequest *account_req; - GHashTableIter iter; - gpointer k, v; - - account_req = tp_account_request_new (self->priv->account_manager, - self->priv->cm_name, self->priv->protocol, "New Account"); - - tp_account_request_set_icon_name (account_req, self->priv->icon_name); - - tp_account_request_set_display_name (account_req, - self->priv->display_name); - - if (self->priv->service != NULL) - tp_account_request_set_service (account_req, self->priv->service); - - g_hash_table_iter_init (&iter, self->priv->parameters); - while (g_hash_table_iter_next (&iter, &k, &v)) - { - const gchar *key = k; - GVariant *value = v; - - tp_account_request_set_parameter (account_req, key, value); - } - - if (self->priv->storage_provider != NULL) - { - tp_account_request_set_storage_provider (account_req, - self->priv->storage_provider); - } - - tp_account_request_create_account_async (account_req, - tpaw_account_settings_created_cb, self); -} - -static GVariant * -build_parameters_variant (TpawAccountSettings *self) -{ - GVariantBuilder *builder; - GHashTableIter iter; - gpointer k, v; - - builder = g_variant_builder_new (G_VARIANT_TYPE_VARDICT); - - g_hash_table_iter_init (&iter, self->priv->parameters); - while (g_hash_table_iter_next (&iter, &k, &v)) - { - const gchar *key = k; - GVariant *value = v; - GVariant *entry; - - entry = g_variant_new_dict_entry (g_variant_new_string (key), - g_variant_new_variant (value)); - - g_variant_builder_add_value (builder, entry); - } - - return g_variant_builder_end (builder); -} - -void -tpaw_account_settings_apply_async (TpawAccountSettings *settings, - GAsyncReadyCallback callback, - gpointer user_data) -{ - if (settings->priv->apply_result != NULL) - { - g_simple_async_report_error_in_idle (G_OBJECT (settings), - callback, user_data, - G_IO_ERROR, G_IO_ERROR_PENDING, "Applying already in progress"); - return; - } - - settings->priv->apply_result = g_simple_async_result_new ( - G_OBJECT (settings), callback, user_data, - tpaw_account_settings_apply_finish); - - /* We'll have to reconnect only if we change none DBus_Property on an - * existing account. */ - g_simple_async_result_set_op_res_gboolean (settings->priv->apply_result, - FALSE); - - if (settings->priv->account == NULL) - { - g_assert (settings->priv->apply_result != NULL && - settings->priv->account == NULL); - - tpaw_account_settings_do_create_account (settings); - } - else - { - tp_account_update_parameters_vardict_async (settings->priv->account, - build_parameters_variant (settings), - (const gchar **) settings->priv->unset_parameters->data, - tpaw_account_settings_account_updated, settings); - } -} - -gboolean -tpaw_account_settings_apply_finish (TpawAccountSettings *settings, - GAsyncResult *result, - gboolean *reconnect_required, - GError **error) -{ - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), - error)) - return FALSE; - - g_return_val_if_fail (g_simple_async_result_is_valid (result, - G_OBJECT (settings), tpaw_account_settings_apply_finish), FALSE); - - if (reconnect_required != NULL) - *reconnect_required = g_simple_async_result_get_op_res_gboolean ( - G_SIMPLE_ASYNC_RESULT (result)); - - return TRUE; -} - -gboolean -tpaw_account_settings_has_account (TpawAccountSettings *settings, - TpAccount *account) -{ - const gchar *account_path; - const gchar *priv_account_path; - - g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); - g_return_val_if_fail (TP_IS_ACCOUNT (account), FALSE); - - if (settings->priv->account == NULL) - return FALSE; - - account_path = tp_proxy_get_object_path (TP_PROXY (account)); - priv_account_path = tp_proxy_get_object_path ( - TP_PROXY (settings->priv->account)); - - return (!tp_strdiff (account_path, priv_account_path)); -} - -void -tpaw_account_settings_set_regex (TpawAccountSettings *settings, - const gchar *param, - const gchar *pattern) -{ - GRegex *regex; - GError *error = NULL; - - regex = g_regex_new (pattern, 0, 0, &error); - if (regex == NULL) - { - g_warning ("Failed to create reg exp: %s", error->message); - g_error_free (error); - return; - } - - g_hash_table_insert (settings->priv->param_regexps, g_strdup (param), - regex); -} - -gboolean -tpaw_account_settings_parameter_is_valid ( - TpawAccountSettings *settings, - const gchar *param) -{ - const GRegex *regex; - - g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); - - if (g_list_find_custom (settings->priv->required_params, param, - (GCompareFunc) g_strcmp0)) - { - /* first, look if it's set in our own parameters */ - if (g_hash_table_lookup (settings->priv->parameters, param) != NULL) - goto test_regex; - - /* if we did not unset the parameter, look if it's in the account */ - if (settings->priv->account != NULL && - !tpaw_account_settings_is_unset (settings, param)) - { - const GHashTable *account_params; - - account_params = tp_account_get_parameters ( - settings->priv->account); - if (tp_asv_lookup (account_params, param)) - goto test_regex; - } - - return FALSE; - } - -test_regex: - /* test whether parameter value matches its regex */ - regex = g_hash_table_lookup (settings->priv->param_regexps, param); - if (regex) - { - gchar *value; - gboolean match; - - value = tpaw_account_settings_dup_string (settings, param); - if (value == NULL) - return FALSE; - - match = g_regex_match (regex, value, 0, NULL); - - g_free (value); - return match; - } - - return TRUE; -} - -gboolean -tpaw_account_settings_is_valid (TpawAccountSettings *settings) -{ - const gchar *param; - GHashTableIter iter; - GList *l; - - g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), FALSE); - - for (l = settings->priv->required_params; l; l = l->next) - { - if (!tpaw_account_settings_parameter_is_valid (settings, l->data)) - return FALSE; - } - - g_hash_table_iter_init (&iter, settings->priv->param_regexps); - while (g_hash_table_iter_next (&iter, (gpointer *) ¶m, NULL)) - { - if (!tpaw_account_settings_parameter_is_valid (settings, param)) - return FALSE; - } - - return TRUE; -} - -TpProtocol * -tpaw_account_settings_get_tp_protocol (TpawAccountSettings *self) -{ - return self->priv->protocol_obj; -} - -gboolean -tpaw_account_settings_supports_sasl (TpawAccountSettings *self) -{ - return self->priv->supports_sasl; -} - -gboolean -tpaw_account_settings_param_is_supported (TpawAccountSettings *self, - const gchar *param) -{ - return tp_protocol_has_param (self->priv->protocol_obj, param); -} - -void -tpaw_account_settings_set_uri_scheme_tel (TpawAccountSettings *self, - gboolean associate) -{ - self->priv->uri_scheme_tel = associate; -} - -gboolean -tpaw_account_settings_has_uri_scheme_tel ( - TpawAccountSettings *self) -{ - return self->priv->uri_scheme_tel; -} - -void -tpaw_account_settings_set_storage_provider (TpawAccountSettings *self, - const gchar *storage) -{ - g_free (self->priv->storage_provider); - self->priv->storage_provider = g_strdup (storage); -} - -void -tpaw_account_settings_set_remember_password (TpawAccountSettings *self, - gboolean remember) -{ - self->priv->remember_password = remember; -} diff --git a/tp-account-widgets/tpaw-account-settings.h b/tp-account-widgets/tpaw-account-settings.h deleted file mode 100644 index d8e567fa3..000000000 --- a/tp-account-widgets/tpaw-account-settings.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * tpaw-account-settings.h - Header for TpawAccountSettings - * Copyright (C) 2009 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_ACCOUNT_SETTINGS_H__ -#define __TPAW_ACCOUNT_SETTINGS_H__ - -#include <glib-object.h> -#include <gio/gio.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpawAccountSettings TpawAccountSettings; -typedef struct _TpawAccountSettingsPriv TpawAccountSettingsPriv; -typedef struct _TpawAccountSettingsClass TpawAccountSettingsClass; - -struct _TpawAccountSettingsClass { - GObjectClass parent_class; -}; - -struct _TpawAccountSettings { - GObject parent; - - /*<private>*/ - TpawAccountSettingsPriv *priv; -}; - -GType tpaw_account_settings_get_type (void); - -/* TYPE MACROS */ -#define TPAW_TYPE_ACCOUNT_SETTINGS \ - (tpaw_account_settings_get_type ()) -#define TPAW_ACCOUNT_SETTINGS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), \ - TPAW_TYPE_ACCOUNT_SETTINGS, TpawAccountSettings)) -#define TPAW_ACCOUNT_SETTINGS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TPAW_TYPE_ACCOUNT_SETTINGS, \ - TpawAccountSettingsClass)) -#define TPAW_IS_ACCOUNT_SETTINGS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TPAW_TYPE_ACCOUNT_SETTINGS)) -#define TPAW_IS_ACCOUNT_SETTINGS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TPAW_TYPE_ACCOUNT_SETTINGS)) -#define TPAW_ACCOUNT_SETTINGS_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TPAW_TYPE_ACCOUNT_SETTINGS, \ - TpawAccountSettingsClass)) - -TpawAccountSettings * tpaw_account_settings_new ( - const gchar *connection_manager, - const gchar *protocol, - const gchar *service, - const char *display_name); - -TpawAccountSettings * tpaw_account_settings_new_for_account ( - TpAccount *account); - -gboolean tpaw_account_settings_is_ready (TpawAccountSettings *settings); - -const gchar *tpaw_account_settings_get_cm (TpawAccountSettings *settings); -const gchar *tpaw_account_settings_get_protocol ( - TpawAccountSettings *settings); - -const gchar *tpaw_account_settings_get_service ( - TpawAccountSettings *settings); - -void tpaw_account_settings_set_service (TpawAccountSettings *settings, - const gchar *service); - -TpAccount *tpaw_account_settings_get_account ( - TpawAccountSettings *settings); - -gboolean tpaw_account_settings_has_account ( - TpawAccountSettings *settings, TpAccount *account); - -GList * tpaw_account_settings_dup_tp_params ( - TpawAccountSettings *settings); - -gboolean tpaw_account_settings_have_tp_param ( - TpawAccountSettings *settings, - const gchar *param); - -void tpaw_account_settings_unset (TpawAccountSettings *settings, - const gchar *param); - -void tpaw_account_settings_discard_changes ( - TpawAccountSettings *settings); - -const gchar * -tpaw_account_settings_get_dbus_signature (TpawAccountSettings *setting, - const gchar *param); - -GVariant * -tpaw_account_settings_dup_default (TpawAccountSettings *settings, - const gchar *param); - -gchar * tpaw_account_settings_dup_string ( - TpawAccountSettings *settings, - const gchar *param); -GStrv tpaw_account_settings_dup_strv ( - TpawAccountSettings *settings, - const gchar *param); - -gint32 tpaw_account_settings_get_int32 (TpawAccountSettings *settings, - const gchar *param); -gint64 tpaw_account_settings_get_int64 (TpawAccountSettings *settings, - const gchar *param); -guint32 tpaw_account_settings_get_uint32 (TpawAccountSettings *settings, - const gchar *param); -guint64 tpaw_account_settings_get_uint64 (TpawAccountSettings *settings, - const gchar *param); -gboolean tpaw_account_settings_get_boolean (TpawAccountSettings *settings, - const gchar *param); - -void tpaw_account_settings_set (TpawAccountSettings *settings, - const gchar *param, - GVariant *v); - -gchar *tpaw_account_settings_get_icon_name ( - TpawAccountSettings *settings); - -void tpaw_account_settings_set_icon_name_async ( - TpawAccountSettings *settings, - const gchar *name, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_account_settings_set_icon_name_finish ( - TpawAccountSettings *settings, - GAsyncResult *result, - GError **error); - -const gchar *tpaw_account_settings_get_display_name ( - TpawAccountSettings *settings); - -void tpaw_account_settings_set_display_name_async ( - TpawAccountSettings *settings, - const gchar *name, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_account_settings_set_display_name_finish ( - TpawAccountSettings *settings, - GAsyncResult *result, - GError **error); - -void tpaw_account_settings_apply_async (TpawAccountSettings *settings, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_account_settings_apply_finish ( - TpawAccountSettings *settings, - GAsyncResult *result, - gboolean *reconnect_required, - GError **error); - -void tpaw_account_settings_set_regex (TpawAccountSettings *settings, - const gchar *param, - const gchar *regex); - -gboolean tpaw_account_settings_parameter_is_valid ( - TpawAccountSettings *settings, - const gchar *param); - -gboolean tpaw_account_settings_is_valid (TpawAccountSettings *settings); - -TpProtocol * tpaw_account_settings_get_tp_protocol ( - TpawAccountSettings *settings); - -gboolean tpaw_account_settings_supports_sasl (TpawAccountSettings *self); - -gboolean tpaw_account_settings_param_is_supported ( - TpawAccountSettings *self, - const gchar *param); - -void tpaw_account_settings_set_uri_scheme_tel (TpawAccountSettings *self, - gboolean associate); - -gboolean tpaw_account_settings_has_uri_scheme_tel ( - TpawAccountSettings *self); - -void tpaw_account_settings_set_storage_provider ( - TpawAccountSettings *self, - const gchar *storage); - -void tpaw_account_settings_set_remember_password ( - TpawAccountSettings *self, - gboolean remember); - -G_END_DECLS - -#endif /* #ifndef __TPAW_ACCOUNT_SETTINGS_H__*/ diff --git a/tp-account-widgets/tpaw-account-widget-aim.ui b/tp-account-widgets/tpaw-account-widget-aim.ui deleted file mode 100644 index 8ceacbf47..000000000 --- a/tp-account-widgets/tpaw-account-widget-aim.ui +++ /dev/null @@ -1,299 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkAdjustment" id="adjustment1"> - <property name="value">5222</property> - <property name="upper">65555</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_aim_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_screenname"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Screen _Name</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_screenname</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_screenname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> MyScreenName</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Port</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Server</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_aim_simple"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_screenname_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your AIM screen name?</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_screenname_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> MyScreenName</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your AIM password?</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-generic.ui b/tp-account-widgets/tpaw-account-widget-generic.ui deleted file mode 100644 index c37da5e01..000000000 --- a/tp-account-widgets/tpaw-account-widget-generic.ui +++ /dev/null @@ -1,122 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <!-- interface-requires gtk+ 3.0 --> - <object class="GtkVBox" id="vbox_generic_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander_advanced_settings"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="height_request">150</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport" id="viewport1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="resize_mode">queue</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-groupwise.ui b/tp-account-widgets/tpaw-account-widget-groupwise.ui deleted file mode 100644 index cfca2e345..000000000 --- a/tp-account-widgets/tpaw-account-widget-groupwise.ui +++ /dev/null @@ -1,292 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkAdjustment" id="adjustment1"> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_groupwise_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_groupwise_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Login I_D</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> username</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_groupwise_settings"> - <property name="visible">True</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Port</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Server</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_groupwise_simple"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_id_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your GroupWise User ID?</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_id_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> username</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your GroupWise password?</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-icq.ui b/tp-account-widgets/tpaw-account-widget-icq.ui deleted file mode 100644 index 865a33c08..000000000 --- a/tp-account-widgets/tpaw-account-widget-icq.ui +++ /dev/null @@ -1,320 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkAdjustment" id="adjustment1"> - <property name="value">5222</property> - <property name="upper">65555</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_icq_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_uin"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">ICQ _UIN</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_uin</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_uin"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> 123456789</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Ch_aracter set</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_charset</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Port</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Server</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_charset"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_icq_simple"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_uin_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your ICQ UIN?</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_uin_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> 123456789</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your ICQ password?</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-irc.c b/tp-account-widgets/tpaw-account-widget-irc.c deleted file mode 100644 index b6ef8776d..000000000 --- a/tp-account-widgets/tpaw-account-widget-irc.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-account-widget-irc.h" - -#include "tpaw-account-widget-private.h" -#include "tpaw-builder.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT | TPAW_DEBUG_IRC -#include "tpaw-debug.h" - -typedef struct { - TpawAccountWidget *self; - - GtkWidget *vbox_settings; - - GtkWidget *network_chooser; -} TpawAccountWidgetIrc; - -static void -account_widget_irc_destroy_cb (GtkWidget *widget, - TpawAccountWidgetIrc *settings) -{ - g_slice_free (TpawAccountWidgetIrc, settings); -} - -static void -account_widget_irc_setup (TpawAccountWidgetIrc *settings) -{ - gchar *nick = NULL; - gchar *fullname = NULL; - TpawAccountSettings *ac_settings; - - g_object_get (settings->self, "settings", &ac_settings, NULL); - - nick = tpaw_account_settings_dup_string (ac_settings, "account"); - fullname = tpaw_account_settings_dup_string (ac_settings, - "fullname"); - - if (nick == NULL) - { - nick = g_strdup (g_get_user_name ()); - - tpaw_account_settings_set (ac_settings, - "account", g_variant_new_string (nick)); - } - - if (fullname == NULL) - { - fullname = g_strdup (g_get_real_name ()); - - if (fullname == NULL) - fullname = g_strdup (nick); - - tpaw_account_settings_set (ac_settings, - "fullname", g_variant_new_string (fullname)); - } - - g_free (nick); - g_free (fullname); -} - -static void -network_changed_cb (TpawIrcNetworkChooser *chooser, - TpawAccountWidgetIrc *settings) -{ - tpaw_account_widget_changed (settings->self); -} - -/** - * set_password_prompt_if_needed: - * - * If @password is not empty, this function sets the 'password-prompt' param - * on @ac_settings. This will ensure that Idle actually asks for the password - * when connecting. - * - * Return: %TRUE if the password-prompt param has been changed - */ -static gboolean -set_password_prompt_if_needed (TpawAccountSettings *ac_settings, - const gchar *password) -{ - gboolean prompt; - - prompt = !tp_str_empty (password); - - if (prompt == tpaw_account_settings_get_boolean (ac_settings, - "password-prompt")) - return FALSE; - - tpaw_account_settings_set (ac_settings, "password-prompt", - g_variant_new_boolean (prompt)); - - return TRUE; -} - -static void -entry_password_changed_cb (GtkEntry *entry, - TpawAccountWidgetIrc *settings) -{ - const gchar *password; - TpawAccountSettings *ac_settings; - - g_object_get (settings->self, "settings", &ac_settings, NULL); - - password = gtk_entry_get_text (entry); - - set_password_prompt_if_needed (ac_settings, password); - - g_object_unref (ac_settings); -} - -TpawIrcNetworkChooser * -tpaw_account_widget_irc_build (TpawAccountWidget *self, - const char *filename, - GtkWidget **table_common_settings, - GtkWidget **box) -{ - TpawAccountWidgetIrc *settings; - TpawAccountSettings *ac_settings; - GtkWidget *entry_password; - gchar *password; - - settings = g_slice_new0 (TpawAccountWidgetIrc); - settings->self = self; - - self->ui_details->gui = tpaw_builder_get_resource (filename, - "table_irc_settings", table_common_settings, - "vbox_irc", box, - "table_irc_settings", &settings->vbox_settings, - "entry_password", &entry_password, - NULL); - - /* Add network chooser button */ - g_object_get (settings->self, "settings", &ac_settings, NULL); - - settings->network_chooser = tpaw_irc_network_chooser_new (ac_settings); - - g_signal_connect (settings->network_chooser, "changed", - G_CALLBACK (network_changed_cb), settings); - - gtk_grid_attach (GTK_GRID (*table_common_settings), - settings->network_chooser, 1, 0, 1, 1); - - gtk_widget_show (settings->network_chooser); - - account_widget_irc_setup (settings); - - tpaw_account_widget_handle_params (self, - "entry_nick", "account", - "entry_fullname", "fullname", - "entry_password", "password", - "entry_quit_message", "quit-message", - "entry_username", "username", - NULL); - - tpaw_builder_connect (self->ui_details->gui, settings, - "table_irc_settings", "destroy", account_widget_irc_destroy_cb, - NULL); - - self->ui_details->default_focus = g_strdup ("entry_nick"); - - g_object_unref (ac_settings); - - /* Automatically set password-prompt when needed */ - password = tpaw_account_settings_dup_string (ac_settings, "password"); - - if (set_password_prompt_if_needed (ac_settings, password)) - { - /* Apply right now to save password-prompt */ - tpaw_account_settings_apply_async (ac_settings, NULL, NULL); - } - - g_free (password); - - g_signal_connect (entry_password, "changed", - G_CALLBACK (entry_password_changed_cb), settings); - - return TPAW_IRC_NETWORK_CHOOSER (settings->network_chooser); -} - -TpawIrcNetworkChooser * -tpaw_account_widget_irc_build_simple (TpawAccountWidget *self, - const char *filename, - GtkWidget **box) -{ - TpawAccountWidgetIrc *settings; - TpawAccountSettings *ac_settings; - GtkAlignment *alignment; - - settings = g_slice_new0 (TpawAccountWidgetIrc); - settings->self = self; - - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_irc_simple", box, - "alignment_network_simple", &alignment, - NULL); - - /* Add network chooser button */ - g_object_get (settings->self, "settings", &ac_settings, NULL); - - settings->network_chooser = tpaw_irc_network_chooser_new (ac_settings); - - g_signal_connect (settings->network_chooser, "changed", - G_CALLBACK (network_changed_cb), settings); - - gtk_container_add (GTK_CONTAINER (alignment), settings->network_chooser); - - gtk_widget_show (settings->network_chooser); - - tpaw_account_widget_handle_params (self, - "entry_nick_simple", "account", - NULL); - - tpaw_builder_connect (self->ui_details->gui, settings, - "vbox_irc_simple", "destroy", account_widget_irc_destroy_cb, - NULL); - - self->ui_details->default_focus = g_strdup ("entry_nick_simple"); - - g_object_unref (ac_settings); - - return TPAW_IRC_NETWORK_CHOOSER (settings->network_chooser); -} diff --git a/tp-account-widgets/tpaw-account-widget-irc.h b/tp-account-widgets/tpaw-account-widget-irc.h deleted file mode 100644 index f913cbc56..000000000 --- a/tp-account-widgets/tpaw-account-widget-irc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_ACCOUNT_WIDGET_IRC_H__ -#define __TPAW_ACCOUNT_WIDGET_IRC_H__ - -#include "tpaw-account-widget.h" -#include "tpaw-irc-network-chooser.h" - -G_BEGIN_DECLS - -TpawIrcNetworkChooser * tpaw_account_widget_irc_build ( - TpawAccountWidget *self, - const char *filename, - GtkWidget **table_common_settings, - GtkWidget **box); - -TpawIrcNetworkChooser * tpaw_account_widget_irc_build_simple ( - TpawAccountWidget *self, - const char *filename, - GtkWidget **box); - -G_END_DECLS - -#endif /* __TPAW_ACCOUNT_WIDGET_IRC_H__ */ diff --git a/tp-account-widgets/tpaw-account-widget-irc.ui b/tp-account-widgets/tpaw-account-widget-irc.ui deleted file mode 100644 index fc72974b3..000000000 --- a/tp-account-widgets/tpaw-account-widget-irc.ui +++ /dev/null @@ -1,603 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <object class="GtkDialog" id="irc_network_dialog"> - <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">Network</property> - <property name="window_position">center-on-parent</property> - <property name="icon_name">gtk-edit</property> - <property name="type_hint">dialog</property> - <property name="skip_taskbar_hint">True</property> - <property name="skip_pager_hint">True</property> - <child internal-child="vbox"> - <object class="GtkBox" id="dialog-vbox10"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">2</property> - <child internal-child="action_area"> - <object class="GtkButtonBox" id="dialog-action_area10"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="button_close"> - <property name="label">gtk-close</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkFrame" id="frame14"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment" id="alignment28"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> - <child> - <object class="GtkGrid" id="greid14"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkLabel" id="label_network"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Network</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Character set</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_network"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="combobox_charset"> - <property name="visible">True</property> - <property name="can_focus">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label_network1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Network</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkFrame" id="frame15"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label_xalign">0</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment" id="alignment29"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="top_padding">6</property> - <property name="left_padding">12</property> - <child> - <object class="GtkGrid" id="grid15"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="spacing">0</property> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow_network_server"> - <property name="height_request">120</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <property name="expand">True</property> - <child> - <object class="GtkTreeView" id="treeview_servers"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="enable_search">False</property> - <child internal-child="selection"> - <object class="GtkTreeSelection" id="treeview-selection1"/> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkToolbar" id="toolbar_network_server"> - <property name="visible">True</property> - <property name="icon_size">1</property> - <style> - <class name="inline-toolbar"/> - </style> - <child> - <object class="GtkToolButton" id="button_add"> - <property name="tooltip-text" translatable="yes">Add…</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="icon_name">list-add-symbolic</property> - <property name="use_underline">True</property> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkToolButton" id="button_remove"> - <property name="tooltip-text" translatable="yes">Remove</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="icon_name">list-remove-symbolic</property> - <property name="use_underline">True</property> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkToolButton" id="button_up"> - <property name="tooltip-text" translatable="yes" comments="Translators: tooltip on a 'Go Up' button used to sort IRC servers by priority">Up</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="icon_name">go-up-symbolic</property> - <property name="use_underline">True</property> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkToolButton" id="button_down"> - <property name="tooltip-text" translatable="yes" comments="Translators: tooltip on a 'Go Down' button used to sort IRC servers by priority">Down</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="icon_name">go-down-symbolic</property> - <property name="use_underline">True</property> - </object> - <packing> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label_servers"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Servers</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - </object> - </child> - <action-widgets> - <action-widget response="-7">button_close</action-widget> - </action-widgets> - </object> - <object class="GtkVBox" id="vbox_irc"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkGrid" id="table_irc_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_nick"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_note"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes">Most IRC servers don't need a password, so if you're not sure, don't enter a password.</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_network2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Network</property> - <property name="use_underline">True</property>A - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_nick"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Nickname</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_nick</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Password</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander_advanced"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_irc_settings1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkEntry" id="entry_quit_message"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_quit_message"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Quit message</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_fullname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_fullname"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Real name</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_nick</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Username</property> - <property name="use_underline">True</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_username"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label_advanced"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_irc_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkLabel" id="label_network_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Which IRC network?</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment_network_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="top_padding">6</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_nick_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your IRC nickname?</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment_nick_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="top_padding">6</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_nick_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - </object> - <object class="GtkSizeGroup" id="sg_field_labels"> - <widgets> - <widget name="label_network2"/> - <widget name="label_nick"/> - <widget name="label_password"/> - <widget name="label_username"/> - <widget name="label_fullname"/> - <widget name="label_quit_message"/> - </widgets> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-jabber.ui b/tp-account-widgets/tpaw-account-widget-jabber.ui deleted file mode 100644 index 8422daa0c..000000000 --- a/tp-account-widgets/tpaw-account-widget-jabber.ui +++ /dev/null @@ -1,792 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <object class="GtkAdjustment" id="adjustment1"> - <property name="upper">127</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment2"> - <property name="upper">65555</property> - <property name="value">5222</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_fb_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkLabel" id="label_id_fb_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Facebook username?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">12</property> - <child> - <object class="GtkEntry" id="entry_id_fb_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_fb_example"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_top">4</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes">This is your username, not your normal Facebook login. -If you are facebook.com/<b>badger</b>, enter <b>badger</b>. -Use <a href="http://www.facebook.com/username/">this page</a> to choose a Facebook username if you don't have one.</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_fb_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="ypad">6</property> - <property name="label" translatable="yes">What is your Facebook password?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password_fb_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="margin_left">12</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_fb_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="xalign">0</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_gtalk_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkLabel" id="label_id_g_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Google ID?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox1b"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">12</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_id_g_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_g_example"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> user@gmail.com</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_g_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="ypad">6</property> - <property name="label" translatable="yes">What is your Google password?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password_g_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="margin_left">12</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_g_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_jabber_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="hexpand">True</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="valign">start</property> - <property name="hexpand">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkGrid" id="vbox1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="valign">start</property> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="hexpand">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> user@jabber.org</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_g_example"> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="hexpand">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> user@gmail.com</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_f_example"> - <property name="can_focus">False</property> - <property name="valign">start</property> - <property name="hexpand">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes" comments="This string is not wrapped in the dialog so you may have to add some '\n' to make it look nice.">This is your username, not your normal Facebook login. -If you are facebook.com/<b>badger</b>, enter <b>badger</b>. -Use <a href="http://www.facebook.com/username/">this page</a> to choose a Facebook username if you don't have one.</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="hexpand">True</property> - <property name="use_action_appearance">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Login I_D</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <property name="justify">right</property> - <property name="mnemonic_widget">entry_password</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander_advanced"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="height_request">200</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport" id="viewport1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="border_width">6</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - <child> - <object class="GtkEntry" id="entry_resource"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_priority"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="checkbutton_ignore_ssl_errors"> - <property name="label" translatable="yes">I_gnore SSL certificate errors</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_priority"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Priori_ty</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_priority</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">3</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_resource"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Reso_urce</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_resource</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">2</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="checkbutton_encryption"> - <property name="label" translatable="yes">Encr_yption required (TLS/SSL)</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Override server settings</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">4</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Server</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">5</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Port</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">6</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="checkbutton_ssl"> - <property name="label" translatable="yes">Use old SS_L</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">7</property> - <property name="width">2</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="adjustment">adjustment2</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">6</property> - <property name="width">1</property> - <property name="height">1</property> - </packing> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_jabber_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkLabel" id="label_id_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Jabber ID?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_id_create"> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your desired Jabber ID?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkVBox" id="vbox1a"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="margin_left">12</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_id_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> user@jabber.org</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="ypad">6</property> - <property name="label" translatable="yes">What is your Jabber password?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_create"> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="ypad">6</property> - <property name="label" translatable="yes">What is your desired Jabber password?</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="margin_left">12</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">5</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">6</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-local-xmpp.ui b/tp-account-widgets/tpaw-account-widget-local-xmpp.ui deleted file mode 100644 index 460c41cbf..000000000 --- a/tp-account-widgets/tpaw-account-widget-local-xmpp.ui +++ /dev/null @@ -1,217 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkVBox" id="vbox_salut_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkEntry" id="entry_nickname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_last_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_first_name"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_nickname"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Nic_kname</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_nickname</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_last_name"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Last Name</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_last_name</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_first_name"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_First Name</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_first_name</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander_advanced_settings"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkEntry" id="entry_published"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_published"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Published Name</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_published</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_jid"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_email"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_jid"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Jabber ID</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_jid</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_email"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">E-_mail address</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_email</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkSizeGroup" id="sg_field_labels"> - <widgets> - <widget name="label_nickname"/> - <widget name="label_last_name"/> - <widget name="label_first_name"/> - <widget name="label_published"/> - <widget name="label_jid"/> - <widget name="label_email"/> - </widgets> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-msn.ui b/tp-account-widgets/tpaw-account-widget-msn.ui deleted file mode 100644 index 4b0614f33..000000000 --- a/tp-account-widgets/tpaw-account-widget-msn.ui +++ /dev/null @@ -1,292 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkAdjustment" id="adjustment1"> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_msn_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_msn_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Login I_D</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> user@hotmail.com</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_msn_settings"> - <property name="visible">True</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Port</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_server"> - <property name="visible">True</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Server</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_server</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_msn_simple"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_id_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Windows Live ID?</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_id_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> user@hotmail.com</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Windows Live password?</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-private.h b/tp-account-widgets/tpaw-account-widget-private.h deleted file mode 100644 index de5f814d1..000000000 --- a/tp-account-widgets/tpaw-account-widget-private.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> - */ - -#ifndef __TPAW_ACCOUNT_WIDGET_PRIVATE_H__ -#define __TPAW_ACCOUNT_WIDGET_PRIVATE_H__ - -#include "tpaw-account-widget.h" - -G_BEGIN_DECLS - -struct _TpawAccountWidgetUIDetails { - GtkBuilder *gui; - - char *default_focus; -}; - - -void tpaw_account_widget_handle_params (TpawAccountWidget *self, - const gchar *first_widget, - ...); - -void tpaw_account_widget_setup_widget (TpawAccountWidget *self, - GtkWidget *widget, - const gchar *param_name); - -G_END_DECLS - -#endif /* __TPAW_ACCOUNT_WIDGET_PRIVATE_H__ */ diff --git a/tp-account-widgets/tpaw-account-widget-sip.c b/tp-account-widgets/tpaw-account-widget-sip.c deleted file mode 100644 index c3e8fdb32..000000000 --- a/tp-account-widgets/tpaw-account-widget-sip.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - * Frederic Peters <fpeters@0d.be> - */ - -#include "config.h" -#include "tpaw-account-widget-sip.h" - -#include <glib/gi18n-lib.h> - -#include "tpaw-account-widget-private.h" -#include "tpaw-builder.h" - -typedef struct { - TpawAccountWidget *self; - GtkWidget *vbox_settings; - - GtkWidget *label_stun_server; - GtkWidget *entry_stun_server; - GtkWidget *label_stun_port; - GtkWidget *spinbutton_stun_port; - GtkWidget *checkbutton_discover_stun; - GtkWidget *combobox_transport; - GtkWidget *combobox_keep_alive_mechanism; - GtkWidget *spinbutton_keepalive_interval; -} TpawAccountWidgetSip; - -static void -account_widget_sip_destroy_cb (GtkWidget *widget, - TpawAccountWidgetSip *settings) -{ - g_slice_free (TpawAccountWidgetSip, settings); -} - -static void -account_widget_sip_discover_stun_toggled_cb ( - GtkWidget *checkbox, - TpawAccountWidgetSip *settings) -{ - gboolean active; - - active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox)); - gtk_widget_set_sensitive (settings->label_stun_server, !active); - gtk_widget_set_sensitive (settings->entry_stun_server, !active); - gtk_widget_set_sensitive (settings->label_stun_port, !active); - gtk_widget_set_sensitive (settings->spinbutton_stun_port, !active); -} - -static void -keep_alive_mechanism_combobox_change_cb (GtkWidget *widget, - TpawAccountWidgetSip *self) -{ - GtkTreeIter iter; - GtkTreeModel *model; - gchar *mechanism; - gboolean enabled; - - /* Unsensitive the keep-alive spin button if keep-alive is disabled */ - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) - return; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - gtk_tree_model_get (model, &iter, 0, &mechanism, -1); - - enabled = tp_strdiff (mechanism, "none"); - - gtk_widget_set_sensitive (self->spinbutton_keepalive_interval, enabled); - g_free (mechanism); -} - -static void -checkbutton_tel_toggled ( - GtkWidget *checkbox, - TpawAccountWidgetSip *sip_settings) -{ - TpawAccountSettings *settings; - - settings = tpaw_account_widget_get_settings (sip_settings->self); - - tpaw_account_settings_set_uri_scheme_tel (settings, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbox))); - - tpaw_account_widget_changed (sip_settings->self); -} - -GtkWidget * -tpaw_account_widget_sip_build (TpawAccountWidget *self, - const char *filename, - GtkWidget **grid_common_settings) -{ - TpawAccountWidgetSip *settings; - GtkWidget *vbox_settings; - gboolean is_simple; - GtkWidget *grid_advanced; - - g_object_get (self, "simple", &is_simple, NULL); - - if (is_simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_sip_simple", &vbox_settings, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_userid_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_userid_simple"); - } - else - { - GtkListStore *store; - GtkCellRenderer *renderer; - GtkToggleButton *checkbutton_tel; - - settings = g_slice_new0 (TpawAccountWidgetSip); - settings->self = self; - - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", grid_common_settings, - "grid_advanced_sip_settings", &grid_advanced, - "vbox_sip_settings", &vbox_settings, - "label_stun-server", &settings->label_stun_server, - "entry_stun-server", &settings->entry_stun_server, - "label_stun-port", &settings->label_stun_port, - "spinbutton_stun-port", &settings->spinbutton_stun_port, - "checkbutton_discover-stun", &settings->checkbutton_discover_stun, - "spinbutton_keepalive-interval", - &settings->spinbutton_keepalive_interval, - "checkbutton_tel", &checkbutton_tel, - NULL); - settings->vbox_settings = vbox_settings; - - gtk_toggle_button_set_active (checkbutton_tel, - tpaw_account_settings_has_uri_scheme_tel ( - tpaw_account_widget_get_settings (self))); - - tpaw_account_widget_handle_params (self, - "entry_userid", "account", - "entry_password", "password", - "checkbutton_discover-stun", "discover-stun", - "entry_stun-server", "stun-server", - "spinbutton_stun-port", "stun-port", - "entry_auth-user", "auth-user", - "entry_proxy-host", "proxy-host", - "spinbutton_port", "port", - "checkbutton_loose-routing", "loose-routing", - "checkbutton_discover-binding", "discover-binding", - "spinbutton_keepalive-interval", "keepalive-interval", - "checkbutton_ignore-tls-errors", "ignore-tls-errors", - "entry_local-ip-address", "local-ip-address", - "spinbutton_local-port", "local-port", - NULL); - - account_widget_sip_discover_stun_toggled_cb ( - settings->checkbutton_discover_stun, - settings); - - tpaw_builder_connect (self->ui_details->gui, settings, - "vbox_sip_settings", "destroy", account_widget_sip_destroy_cb, - "checkbutton_discover-stun", "toggled", - account_widget_sip_discover_stun_toggled_cb, - "checkbutton_tel", "toggled", checkbutton_tel_toggled, - NULL); - - self->ui_details->default_focus = g_strdup ("entry_userid"); - - /* Create the 'transport' combo box. The first column has to contain the - * value of the param. */ - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - settings->combobox_transport = gtk_combo_box_new_with_model ( - GTK_TREE_MODEL (store)); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start ( - GTK_CELL_LAYOUT (settings->combobox_transport), renderer, TRUE); - gtk_cell_layout_add_attribute ( - GTK_CELL_LAYOUT (settings->combobox_transport), renderer, "text", 1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "auto", 1, _("Auto"), -1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "udp", 1, _("UDP"), -1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "tcp", 1, _("TCP"), -1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "tls", 1, _("TLS"), -1); - - tpaw_account_widget_setup_widget (self, settings->combobox_transport, - "transport"); - - gtk_grid_attach (GTK_GRID (grid_advanced), settings->combobox_transport, - 1, 11, 3, 1); - - gtk_widget_show (settings->combobox_transport); - - /* Create the 'keep-alive mechanism' combo box */ - store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING); - settings->combobox_keep_alive_mechanism = gtk_combo_box_new_with_model ( - GTK_TREE_MODEL (store)); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start ( - GTK_CELL_LAYOUT (settings->combobox_keep_alive_mechanism), renderer, - TRUE); - gtk_cell_layout_add_attribute ( - GTK_CELL_LAYOUT (settings->combobox_keep_alive_mechanism), renderer, - "text", 1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "auto", 1, _("Auto"), -1); - - /* translators: this string is very specific to SIP's internal; maybe - * best to keep the English version. */ - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "register", 1, _("Register"), -1); - - /* translators: this string is very specific to SIP's internal; maybe - * best to keep the English version. */ - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "options", 1, _("Options"), -1); - - gtk_list_store_insert_with_values (store, NULL, -1, - 0, "none", 1, _("None"), -1); - - g_signal_connect (settings->combobox_keep_alive_mechanism, "changed", - G_CALLBACK (keep_alive_mechanism_combobox_change_cb), settings); - - tpaw_account_widget_setup_widget (self, - settings->combobox_keep_alive_mechanism, "keepalive-mechanism"); - - gtk_grid_attach (GTK_GRID (grid_advanced), - settings->combobox_keep_alive_mechanism, - 1, 7, 3, 1); - - gtk_widget_show (settings->combobox_keep_alive_mechanism); - } - - return vbox_settings; -} diff --git a/tp-account-widgets/tpaw-account-widget-sip.h b/tp-account-widgets/tpaw-account-widget-sip.h deleted file mode 100644 index 7f08ab1ef..000000000 --- a/tp-account-widgets/tpaw-account-widget-sip.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Frederic Peters <fpeters@0d.be> - */ - -#ifndef __TPAW_ACCOUNT_WIDGET_SIP_H__ -#define __TPAW_ACCOUNT_WIDGET_SIP_H__ - -#include "tpaw-account-widget.h" - -G_BEGIN_DECLS - -GtkWidget * tpaw_account_widget_sip_build (TpawAccountWidget *self, - const char *filename, - GtkWidget **grid_common_settings); - -G_END_DECLS - -#endif /* __TPAW_ACCOUNT_WIDGET_SIP_H__ */ diff --git a/tp-account-widgets/tpaw-account-widget-sip.ui b/tp-account-widgets/tpaw-account-widget-sip.ui deleted file mode 100644 index 7caa7cad6..000000000 --- a/tp-account-widgets/tpaw-account-widget-sip.ui +++ /dev/null @@ -1,731 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <object class="GtkAdjustment" id="adjustment1"> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment2"> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment3"> - <property name="upper">10000</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkAdjustment" id="adjustment4"> - <property name="upper">65535</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_sip_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">Pass_word</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_userid"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_userid"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">1</property> - <property name="label" translatable="yes">_Username</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_userid</property> - <style> - <class name="dim-label"/> - </style> - </object> - <packing> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> user@my.sip.server</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="checkbutton_tel"> - <property name="label" translatable="yes">Use this account to call _landlines and mobile phones</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - <property name="xalign">0</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="top_attach">4</property> - <property name="left_attach">0</property> - <property name="width">4</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander_advanced"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkScrolledWindow" id="scrolledwindow1"> - <property name="height_request">200</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">never</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkViewport" id="viewport1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="resize_mode">queue</property> - <property name="shadow_type">none</property> - <child> - <object class="GtkAlignment" id="alignment3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="border_width">6</property> - <child> - <object class="GtkGrid" id="grid_advanced_sip_settings"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="column_spacing">6</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkEntry" id="entry_stun-server"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_auth-user"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">10</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_proxy-host"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_keepalive-interval"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment3</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">8</property> - <property name="width">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_local-ip-address"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">14</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_nat_traversal"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">NAT Traversal Options</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_proxy"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Proxy Options</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="top_attach">4</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_misc"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Miscellaneous Options</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="top_attach">9</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment7"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">24</property> - <child> - <object class="GtkLabel" id="label_stun-server"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">STUN Server</property> - <property name="mnemonic_widget">entry_stun-server</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="checkbutton_discover-stun"> - <property name="label" translatable="yes">Discover the STUN server automatically</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - <property name="width">4</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment5"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="checkbutton_discover-binding"> - <property name="label" translatable="yes">Discover Binding</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">0</property> - <property name="width">4</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment8"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_proxy-host"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Server</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">5</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_keep_alive"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Keep-Alive Options</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - <packing> - <property name="top_attach">6</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment10"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_keepalive-mechanism"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Mechanism</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">7</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment11"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_keepalive-interval"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Interval (seconds)</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">8</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment12"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_auth-user"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Authentication username</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">10</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment13"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_transport"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Transport</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">11</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment14"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="checkbutton_loose-routing"> - <property name="label" translatable="yes">Loose Routing</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">12</property> - <property name="left_attach">0</property> - <property name="width">4</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment15"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkCheckButton" id="checkbutton_ignore-tls-errors"> - <property name="label" translatable="yes">Ignore TLS Errors</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="draw_indicator">True</property> - </object> - </child> - </object> - <packing> - <property name="top_attach">13</property> - <property name="left_attach">0</property> - <property name="width">4</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_stun-port"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Port</property> - <property name="mnemonic_widget">spinbutton_stun-port</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_stun-port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Port</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment2</property> - <property name="climb_rate">1</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">5</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment16"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="left_padding">12</property> - <child> - <object class="GtkLabel" id="label_local-ip-address"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Local IP Address</property> - <property name="mnemonic_widget">entry_local-ip-address</property> - </object> - </child> - </object> - <packing> - <property name="left_attach">0</property> - <property name="top_attach">14</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_local-port"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Port</property> - <property name="mnemonic_widget">spinbutton_local-port</property> - </object> - <packing> - <property name="left_attach">2</property> - <property name="top_attach">14</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_local-port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment4</property> - </object> - <packing> - <property name="left_attach">3</property> - <property name="top_attach">14</property> - </packing> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label_expander"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_sip_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_userid_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your SIP login ID?</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_userid_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> user@my.sip.server</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.80000000000000004"/> - </attributes> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your SIP account password?</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember Password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_action_appearance">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget-yahoo.ui b/tp-account-widgets/tpaw-account-widget-yahoo.ui deleted file mode 100644 index 9d002538c..000000000 --- a/tp-account-widgets/tpaw-account-widget-yahoo.ui +++ /dev/null @@ -1,330 +0,0 @@ -<?xml version="1.0"?> -<interface> - <requires lib="gtk+" version="2.16"/> - <!-- interface-naming-policy toplevel-contextual --> - <object class="GtkAdjustment" id="adjustment1"> - <property name="value">5050</property> - <property name="lower">1</property> - <property name="upper">65555</property> - <property name="step_increment">1</property> - <property name="page_increment">10</property> - </object> - <object class="GtkVBox" id="vbox_yahoo_settings"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkGrid" id="grid_common_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkLabel" id="label_password"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Pass_word:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_password</property> - </object> - <packing> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_id"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Yahoo! I_D:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_id</property> - </object> - <packing> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_id"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_password"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_username_example"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="xpad">3</property> - <property name="label" translatable="yes"><b>Example:</b> username</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - <child> - <placeholder/> - </child> - <child> - <placeholder/> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkExpander" id="expander1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child> - <object class="GtkVBox" id="vbox1"> - <property name="visible">True</property> - <child> - <object class="GtkGrid" id="grid_advanced_settings"> - <property name="visible">True</property> - <property name="column_spacing">12</property> - <property name="row_spacing">6</property> - <child> - <object class="GtkCheckButton" id="checkbutton_ignore_invites"> - <property name="label" translatable="yes">I_gnore conference and chat room invitations</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="width">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_locale"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Room List locale:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_locale</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_charset"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Ch_aracter set:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">entry_charset</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_locale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">1</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="entry_charset"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_port"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">spinbutton_port</property> - </object> - <packing> - <property name="top_attach">3</property> - <property name="left_attach">0</property> - </packing> - </child> - <child> - <object class="GtkSpinButton" id="spinbutton_port"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="adjustment">adjustment1</property> - <property name="climb_rate">1</property> - <property name="numeric">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="top_attach">3</property> - </packing> - </child> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Advanced</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <object class="GtkVBox" id="vbox_yahoo_simple"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">6</property> - <child> - <object class="GtkLabel" id="label_id_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Yahoo! ID?</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="bottom_padding">3</property> - <property name="left_padding">12</property> - <child> - <object class="GtkVBox" id="vbox2"> - <property name="visible">True</property> - <property name="orientation">vertical</property> - <property name="spacing">4</property> - <child> - <object class="GtkEntry" id="entry_id_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - </object> - <packing> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_example"> - <property name="visible">True</property> - <property name="xalign">0.10000000149011612</property> - <property name="label" translatable="yes"><b>Example:</b> username</property> - <property name="use_markup">True</property> - <attributes> - <attribute name="scale" value="0.8"/><!-- PANGO_SCALE_SMALL --> - </attributes> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - </object> - </child> - </object> - <packing> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label_password_simple"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">What is your Yahoo! password?</property> - </object> - <packing> - <property name="position">2</property> - </packing> - </child> - <child> - <object class="GtkAlignment" id="alignment2"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xscale">0.34999999403953552</property> - <property name="yscale">0.34999999403953552</property> - <property name="left_padding">12</property> - <child> - <object class="GtkEntry" id="entry_password_simple"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - </object> - </child> - </object> - <packing> - <property name="position">3</property> - </packing> - </child> - <child> - <object class="GtkCheckButton" id="remember_password_simple"> - <property name="label" translatable="yes">Remember password</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="position">4</property> - </packing> - </child> - </object> -</interface> diff --git a/tp-account-widgets/tpaw-account-widget.c b/tp-account-widgets/tpaw-account-widget.c deleted file mode 100644 index 8c10b9c2d..000000000 --- a/tp-account-widgets/tpaw-account-widget.c +++ /dev/null @@ -1,2372 +0,0 @@ -/* - * Copyright (C) 2006-2007 Imendio AB - * Copyright (C) 2007-2009 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Martyn Russell <martyn@imendio.com> - * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> - * Jonathan Tellier <jonathan.tellier@gmail.com> - * Danielle Madeley <danielle.madeley@collabora.co.uk> - */ - -#include "config.h" -#include "tpaw-account-widget.h" -#include "tpaw-account-widget-private.h" - -#include <glib/gi18n-lib.h> -#include <dbus/dbus-protocol.h> - -#include "tpaw-account-widget-irc.h" -#include "tpaw-account-widget-private.h" -#include "tpaw-account-widget-sip.h" -#include "tpaw-builder.h" -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT -#include "tpaw-debug.h" - -G_DEFINE_TYPE (TpawAccountWidget, tpaw_account_widget, GTK_TYPE_BOX) - -typedef enum -{ - NO_SERVICE = 0, - GTALK_SERVICE, - FACEBOOK_SERVICE, - N_SERVICES -} Service; - -typedef struct -{ - const gchar *label_username_example; - gboolean show_advanced; -} ServiceInfo; - -static ServiceInfo services_infos[N_SERVICES] = { - { "label_username_example", TRUE }, - { "label_username_g_example", FALSE }, - { "label_username_f_example", FALSE }, -}; - -struct _TpawAccountWidgetPriv { - TpawAccountSettings *settings; - - GtkWidget *grid_common_settings; - GtkWidget *apply_button; - GtkWidget *cancel_button; - GtkWidget *entry_password; - GtkWidget *spinbutton_port; - GtkWidget *radiobutton_reuse; - GtkWidget *action_area; - - gboolean simple; - - gboolean contains_pending_changes; - - /* Whether the action area was provided or it's an internal one we - * created ourselves */ - gboolean external_action_area; - - /* An TpawAccountWidget can be used to either create an account or - * modify it. When we are creating an account, this member is set to TRUE */ - gboolean creating_account; - - /* whether there are any other real accounts. Necessary so we know whether - * it's safe to dismiss this widget in some cases (eg, whether the Cancel - * button should be sensitive) */ - gboolean other_accounts_exist; - - /* if TRUE, the GTK+ destroy signal has been fired and so the widgets - * embedded in this account widget can't be used any more - * workaround because some async callbacks can be called after the - * widget has been destroyed */ - gboolean destroyed; - - TpAccountManager *account_manager; - - GtkWidget *param_account_widget; - GtkWidget *param_password_widget; - - gboolean automatic_change; - GtkWidget *remember_password_widget; - - /* Used only for IRC accounts */ - TpawIrcNetworkChooser *irc_network_chooser; - - /* Used for 'special' XMPP account having a service associated ensuring that - * JIDs have a specific suffix; such as Facebook for example */ - gchar *jid_suffix; -}; - -enum { - PROP_PROTOCOL = 1, - PROP_SETTINGS, - PROP_SIMPLE, - PROP_CREATING_ACCOUNT, - PROP_OTHER_ACCOUNTS_EXIST, - PROP_ACTION_AREA, -}; - -enum { - HANDLE_APPLY, - ACCOUNT_CREATED, - CANCELLED, - CLOSE, - LAST_SIGNAL -}; - -enum { - RESPONSE_LAUNCH -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -#define CHANGED_TIMEOUT 300 - -#define DIGIT "0-9" -#define DIGITS "(["DIGIT"]+)" -#define ALPHA "a-zA-Z" -#define ALPHAS "(["ALPHA"]+)" -#define ALPHADIGIT ALPHA DIGIT -#define ALPHADIGITS "(["ALPHADIGIT"]+)" -#define ALPHADIGITDASH ALPHA DIGIT "-" -#define ALPHADIGITDASHS "(["ALPHADIGITDASH"]*)" - -#define HOSTNUMBER "("DIGITS"\\."DIGITS"\\."DIGITS"\\."DIGITS")" -#define TOPLABEL "("ALPHAS \ - "| (["ALPHA"]"ALPHADIGITDASHS "["ALPHADIGIT"]))" -#define DOMAINLABEL "("ALPHADIGITS"|(["ALPHADIGIT"]" ALPHADIGITDASHS \ - "["ALPHADIGIT"]))" -#define HOSTNAME "((" DOMAINLABEL "\\.)+" TOPLABEL ")" -/* Based on http://www.ietf.org/rfc/rfc1738.txt (section 5) */ -#define HOST "("HOSTNAME "|" HOSTNUMBER")" -/* Based on http://www.ietf.org/rfc/rfc0822.txt (appendix D) */ -#define EMAIL_LOCALPART "([^\\(\\)<>@,;:\\\\\"\\[\\]\\s]+)" - -/* UIN is digital according to the unofficial specification: - * http://iserverd.khstu.ru/docum_ext/icqv5.html#CTS - * 5 digits minimum according to http://en.wikipedia.org/wiki/ICQ#UIN - * According to an user, we can also provide an email address instead of the - * ICQ UIN. */ -#define ICQ_USER_NAME "((["DIGIT"]{5,})|"EMAIL_LOCALPART"@"HOST")" - -/* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */ -#define IRC_SPECIAL "_\\[\\]{}\\\\|`^" -#define IRC_NICK_NAME "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)" - -/* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2) - * We just exclude invalid characters to avoid ucschars and other redundant - * complexity */ -#define JABBER_USER_NAME "([^@:'\"<>&\\s]+)" -/* ID is an email according to the unofficial specification: - * http://www.hypothetic.org/docs/msn/general/names.php */ -#define MSN_USER_NAME EMAIL_LOCALPART -/* Based on the official help: - * http://help.yahoo.com/l/us/yahoo/edit/registration/edit-01.html - * Looks like an email address can be used as well (bgo #655959) - * */ -#define YAHOO_USER_NAME "(["ALPHA"]["ALPHADIGIT"_\\.]{3,31})|("EMAIL_LOCALPART"@"HOST")" - -#define ACCOUNT_REGEX_ICQ "^"ICQ_USER_NAME"$" -#define ACCOUNT_REGEX_IRC "^"IRC_NICK_NAME"$" -#define ACCOUNT_REGEX_JABBER "^"JABBER_USER_NAME"@[^@/]+" -#define ACCOUNT_REGEX_MSN "^"MSN_USER_NAME"@"HOST"$" -#define ACCOUNT_REGEX_YAHOO "^"YAHOO_USER_NAME"$" - -static void -account_widget_set_control_buttons_sensitivity (TpawAccountWidget *self, - gboolean sensitive) -{ - /* we hit this case because of the 'other-accounts-exist' property handler - * being called during init (before constructed()) */ - if (self->priv->apply_button == NULL || self->priv->cancel_button == NULL) - return; - - gtk_widget_set_sensitive (self->priv->apply_button, sensitive); - - if (sensitive) - { - /* We can't grab default if the widget hasn't be packed in a - * window */ - GtkWidget *window; - - window = gtk_widget_get_toplevel (self->priv->apply_button); - if (window != NULL && - gtk_widget_is_toplevel (window)) - { - gtk_widget_set_can_default (self->priv->apply_button, TRUE); - gtk_widget_grab_default (self->priv->apply_button); - } - } -} - -static void -account_widget_set_entry_highlighting (GtkEntry *entry, - gboolean highlight) -{ - g_return_if_fail (GTK_IS_ENTRY (entry)); - - if (highlight) - { - GtkStyleContext *style; - GdkRGBA color; - - style = gtk_widget_get_style_context (GTK_WIDGET (entry)); - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, - &color); - - /* Here we take the current theme colour and add it to - * the colour for white and average the two. This - * gives a colour which is inline with the theme but - * slightly whiter. - */ - tpaw_make_color_whiter (&color); - - gtk_widget_override_background_color (GTK_WIDGET (entry), 0, &color); - } - else - { - gtk_widget_override_background_color (GTK_WIDGET (entry), 0, NULL); - } -} - -static void -account_widget_handle_control_buttons_sensitivity (TpawAccountWidget *self) -{ - gboolean is_valid; - - is_valid = tpaw_account_settings_is_valid (self->priv->settings); - - account_widget_set_control_buttons_sensitivity (self, is_valid); - - g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid); -} - -static void -account_widget_entry_changed_common (TpawAccountWidget *self, - GtkEntry *entry, gboolean focus) -{ - const gchar *str; - const gchar *param_name; - gboolean prev_status; - gboolean curr_status; - - str = gtk_entry_get_text (entry); - param_name = g_object_get_data (G_OBJECT (entry), "param_name"); - prev_status = tpaw_account_settings_parameter_is_valid ( - self->priv->settings, param_name); - - if (TPAW_STR_EMPTY (str)) - { - tpaw_account_settings_unset (self->priv->settings, param_name); - - if (focus) - { - gchar *value; - - value = tpaw_account_settings_dup_string (self->priv->settings, - param_name); - - DEBUG ("Unset %s and restore to %s", param_name, value); - gtk_entry_set_text (entry, value ? value : ""); - g_free (value); - } - } - else - { - DEBUG ("Setting %s to %s", param_name, - tp_strdiff (param_name, "password") ? str : "***"); - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_string (str)); - } - - curr_status = tpaw_account_settings_parameter_is_valid ( - self->priv->settings, param_name); - - if (curr_status != prev_status) - account_widget_set_entry_highlighting (entry, !curr_status); -} - -static void -account_widget_entry_changed_cb (GtkEditable *entry, - TpawAccountWidget *self) -{ - if (self->priv->automatic_change) - return; - - account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE); - tpaw_account_widget_changed (self); -} - -static void -account_widget_entry_map_cb (GtkEntry *entry, - TpawAccountWidget *self) -{ - const gchar *param_name; - gboolean is_valid; - - /* need to initialize input highlighting */ - param_name = g_object_get_data (G_OBJECT (entry), "param_name"); - is_valid = tpaw_account_settings_parameter_is_valid (self->priv->settings, - param_name); - account_widget_set_entry_highlighting (entry, !is_valid); -} - -static void -account_widget_int_changed_cb (GtkWidget *widget, - TpawAccountWidget *self) -{ - const gchar *param_name; - gint value; - const gchar *signature; - - value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget)); - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - signature = tpaw_account_settings_get_dbus_signature (self->priv->settings, - param_name); - g_return_if_fail (signature != NULL); - - DEBUG ("Setting %s to %d", param_name, value); - - switch ((int)*signature) - { - case DBUS_TYPE_INT16: - case DBUS_TYPE_INT32: - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_int32 (value)); - break; - case DBUS_TYPE_INT64: - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_int64 (value)); - break; - case DBUS_TYPE_UINT16: - case DBUS_TYPE_UINT32: - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_uint32 (value)); - break; - case DBUS_TYPE_UINT64: - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_uint64 (value)); - break; - default: - g_return_if_reached (); - } - - tpaw_account_widget_changed (self); -} - -static void -account_widget_checkbutton_toggled_cb (GtkWidget *widget, - TpawAccountWidget *self) -{ - gboolean value; - gboolean default_value; - const gchar *param_name; - - value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - /* FIXME: This is ugly! checkbox don't have a "not-set" value so we - * always unset the param and set the value if different from the - * default value. */ - tpaw_account_settings_unset (self->priv->settings, param_name); - default_value = tpaw_account_settings_get_boolean (self->priv->settings, - param_name); - - if (default_value == value) - { - DEBUG ("Unset %s and restore to %d", param_name, default_value); - } - else - { - DEBUG ("Setting %s to %d", param_name, value); - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_boolean (value)); - } - - tpaw_account_widget_changed (self); -} - -static void -account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, - TpawAccountWidget *self) -{ - gboolean value; - gint32 port = 0; - - value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl)); - port = tpaw_account_settings_get_uint32 (self->priv->settings, "port"); - - if (value) - { - if (port == 5222 || port == 0) - port = 5223; - } - else - { - if (port == 5223 || port == 0) - port = 5222; - } - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->spinbutton_port), - port); - - self->priv->contains_pending_changes = TRUE; -} - -static void -account_widget_combobox_changed_cb (GtkWidget *widget, - TpawAccountWidget *self) -{ - GtkTreeIter iter; - GtkTreeModel *model; - const gchar *value; - GVariant *v; - const gchar *default_value = NULL; - const gchar *param_name; - - if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter)) - return; - - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - /* the param value is stored in the first column */ - gtk_tree_model_get (model, &iter, 0, &value, -1); - - param_name = g_object_get_data (G_OBJECT (widget), "param_name"); - - v = tpaw_account_settings_dup_default (self->priv->settings, param_name); - if (v != NULL && g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)) - default_value = g_variant_get_string (v, NULL); - - if (!tp_strdiff (value, default_value)) - { - DEBUG ("Unset %s and restore to %s", param_name, default_value); - tpaw_account_settings_unset (self->priv->settings, param_name); - } - else - { - DEBUG ("Setting %s to %s", param_name, value); - tpaw_account_settings_set (self->priv->settings, param_name, - g_variant_new_string (value)); - } - - tpaw_account_widget_changed (self); - - tp_clear_pointer (&v, g_variant_unref); -} - -static void -clear_icon_released_cb (GtkEntry *entry, - GtkEntryIconPosition icon_pos, - GdkEvent *event, - TpawAccountWidget *self) -{ - const gchar *param_name; - - param_name = g_object_get_data (G_OBJECT (entry), "param_name"); - - DEBUG ("Unset %s", param_name); - tpaw_account_settings_unset (self->priv->settings, param_name); - gtk_entry_set_text (entry, ""); - - tpaw_account_widget_changed (self); -} - -static void -password_entry_changed_cb (GtkEditable *entry, - TpawAccountWidget *self) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (entry)); - - gtk_entry_set_icon_sensitive (GTK_ENTRY (entry), - GTK_ENTRY_ICON_SECONDARY, !TPAW_STR_EMPTY (str)); -} - -static void -password_entry_activated_cb (GtkEntry *entry, - TpawAccountWidget *self) -{ - if (gtk_widget_get_sensitive (self->priv->apply_button)) - tpaw_account_widget_apply_and_log_in (self); -} - -static void -account_entry_activated_cb (GtkEntry *entry, - TpawAccountWidget *self) -{ - if (gtk_widget_get_sensitive (self->priv->apply_button)) - tpaw_account_widget_apply_and_log_in (self); -} - -void -tpaw_account_widget_setup_widget (TpawAccountWidget *self, - GtkWidget *widget, - const gchar *param_name) -{ - g_object_set_data_full (G_OBJECT (widget), "param_name", - g_strdup (param_name), g_free); - - if (GTK_IS_SPIN_BUTTON (widget)) - { - gint value = 0; - const gchar *signature; - - signature = tpaw_account_settings_get_dbus_signature ( - self->priv->settings, param_name); - g_return_if_fail (signature != NULL); - - switch ((int)*signature) - { - case DBUS_TYPE_INT16: - case DBUS_TYPE_INT32: - value = tpaw_account_settings_get_int32 (self->priv->settings, - param_name); - break; - case DBUS_TYPE_INT64: - value = tpaw_account_settings_get_int64 (self->priv->settings, - param_name); - break; - case DBUS_TYPE_UINT16: - case DBUS_TYPE_UINT32: - value = tpaw_account_settings_get_uint32 (self->priv->settings, - param_name); - break; - case DBUS_TYPE_UINT64: - value = tpaw_account_settings_get_uint64 (self->priv->settings, - param_name); - break; - default: - g_return_if_reached (); - } - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value); - - g_signal_connect (widget, "value-changed", - G_CALLBACK (account_widget_int_changed_cb), - self); - } - else if (GTK_IS_ENTRY (widget)) - { - gchar *str; - - str = tpaw_account_settings_dup_string (self->priv->settings, - param_name); - gtk_entry_set_text (GTK_ENTRY (widget), str ? str : ""); - - if (!tp_strdiff (param_name, "account")) - self->priv->param_account_widget = widget; - else if (!tp_strdiff (param_name, "password")) - self->priv->param_password_widget = widget; - - if (strstr (param_name, "password")) - { - gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE); - - /* Add 'clear' icon */ - gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), - GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR); - - gtk_entry_set_icon_sensitive (GTK_ENTRY (widget), - GTK_ENTRY_ICON_SECONDARY, !TPAW_STR_EMPTY (str)); - - g_signal_connect (widget, "icon-release", - G_CALLBACK (clear_icon_released_cb), self); - g_signal_connect (widget, "changed", - G_CALLBACK (password_entry_changed_cb), self); - g_signal_connect (widget, "activate", - G_CALLBACK (password_entry_activated_cb), self); - } - else if (strstr (param_name, "account")) - g_signal_connect (widget, "activate", - G_CALLBACK (account_entry_activated_cb), self); - - g_signal_connect (widget, "changed", - G_CALLBACK (account_widget_entry_changed_cb), self); - g_signal_connect (widget, "map", - G_CALLBACK (account_widget_entry_map_cb), self); - - g_free (str); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) - { - gboolean value = FALSE; - - value = tpaw_account_settings_get_boolean (self->priv->settings, - param_name); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); - - g_signal_connect (widget, "toggled", - G_CALLBACK (account_widget_checkbutton_toggled_cb), - self); - } - else if (GTK_IS_COMBO_BOX (widget)) - { - /* The combo box's model has to contain the param value in its first - * column (as a string) */ - gchar *str; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean valid; - - str = tpaw_account_settings_dup_string (self->priv->settings, - param_name); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget)); - - valid = gtk_tree_model_get_iter_first (model, &iter); - while (valid) - { - gchar *name; - - gtk_tree_model_get (model, &iter, 0, &name, -1); - if (!tp_strdiff (name, str)) - { - gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter); - valid = FALSE; - } - else - { - valid = gtk_tree_model_iter_next (model, &iter); - } - - g_free (name); - } - - g_free (str); - - g_signal_connect (widget, "changed", - G_CALLBACK (account_widget_combobox_changed_cb), - self); - } - else - { - DEBUG ("Unknown type of widget for param %s", param_name); - } - - gtk_widget_set_sensitive (widget, - tpaw_account_settings_param_is_supported (self->priv->settings, - param_name)); -} - -static GHashTable * -build_translated_params (void) -{ - GHashTable *hash; - - hash = g_hash_table_new (g_str_hash, g_str_equal); - g_hash_table_insert (hash, "account", _("Account")); - g_hash_table_insert (hash, "password", _("Password")); - g_hash_table_insert (hash, "server", _("Server")); - g_hash_table_insert (hash, "port", _("Port")); - - return hash; -} - -static gchar * -account_widget_generic_format_param_name (const gchar *param_name) -{ - gchar *str; - gchar *p; - static GHashTable *translated_params = NULL; - - g_return_val_if_fail (param_name != NULL, NULL); - - if (G_UNLIKELY (translated_params == NULL)) - translated_params = build_translated_params (); - - /* Translate most common parameters */ - str = g_hash_table_lookup (translated_params, param_name); - if (str != NULL) - return g_strdup (str); - - str = g_strdup (param_name); - - if (str && g_ascii_isalpha (str[0])) - str[0] = g_ascii_toupper (str[0]); - - while ((p = strchr (str, '-')) != NULL) - { - if (p[1] != '\0' && g_ascii_isalpha (p[1])) - { - p[0] = ' '; - p[1] = g_ascii_toupper (p[1]); - } - - p++; - } - - return str; -} - -static void -accounts_widget_generic_setup (TpawAccountWidget *self, - GtkWidget *grid_common_settings, - GtkWidget *grid_advanced_settings) -{ - GList *params, *l; - guint row_common = 0, row_advanced = 0; - - params = tpaw_account_settings_dup_tp_params (self->priv->settings); - - for (l = params; l != NULL; l = g_list_next (l)) - { - TpConnectionManagerParam *param = l->data; - GtkWidget *grid_settings; - guint row; - GtkWidget *widget = NULL; - gchar *param_name_formatted; - const gchar *dbus_signature; - - if (tp_connection_manager_param_is_required (param)) - { - grid_settings = grid_common_settings; - row = row_common++; - } - else if (self->priv->simple) - { - continue; - } - else - { - grid_settings = grid_advanced_settings; - row = row_advanced++; - } - - param_name_formatted = account_widget_generic_format_param_name ( - tp_connection_manager_param_get_name (param)); - - dbus_signature = tp_connection_manager_param_get_dbus_signature (param); - - if (dbus_signature[0] == 's') - { - gchar *str; - - str = g_strdup_printf (_("%s"), param_name_formatted); - widget = gtk_label_new (str); - gtk_misc_set_alignment (GTK_MISC (widget), 1., 0.5); - gtk_style_context_add_class (gtk_widget_get_style_context (widget), - GTK_STYLE_CLASS_DIM_LABEL); - g_free (str); - - gtk_grid_attach (GTK_GRID (grid_settings), - widget, 0, row, 1, 1); - - gtk_widget_show (widget); - - widget = gtk_entry_new (); - if (g_strcmp0 (tp_connection_manager_param_get_name (param), - "account") == 0) - { - g_signal_connect (widget, "realize", - G_CALLBACK (gtk_widget_grab_focus), - NULL); - } - - gtk_grid_attach (GTK_GRID (grid_settings), - widget, 1, row, 1, 1); - - gtk_widget_show (widget); - } - /* int types: ynqiuxt. double type is 'd' */ - else if (dbus_signature[0] == 'y' || - dbus_signature[0] == 'n' || - dbus_signature[0] == 'q' || - dbus_signature[0] == 'i' || - dbus_signature[0] == 'u' || - dbus_signature[0] == 'x' || - dbus_signature[0] == 't' || - dbus_signature[0] == 'd') - { - gchar *str = NULL; - gdouble minint = 0; - gdouble maxint = 0; - gdouble step = 1; - - switch (dbus_signature[0]) - { - case 'y': minint = G_MININT8; maxint = G_MAXINT8; break; - case 'n': minint = G_MININT16; maxint = G_MAXINT16; break; - case 'q': minint = 0; maxint = G_MAXUINT16; break; - case 'i': minint = G_MININT32; maxint = G_MAXINT32; break; - case 'u': minint = 0; maxint = G_MAXUINT32; break; - case 'x': minint = G_MININT64; maxint = G_MAXINT64; break; - case 't': minint = 0; maxint = G_MAXUINT64; break; - case 'd': minint = G_MININT32; maxint = G_MAXINT32; - step = 0.1; break; - default: g_assert_not_reached (); - } - - str = g_strdup_printf (_("%s:"), param_name_formatted); - widget = gtk_label_new (str); - gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5); - g_free (str); - - gtk_grid_attach (GTK_GRID (grid_settings), - widget, 0, row, 1, 1); - gtk_widget_show (widget); - - widget = gtk_spin_button_new_with_range (minint, maxint, step); - gtk_grid_attach (GTK_GRID (grid_settings), - widget, 1, row, 1, 1); - gtk_widget_show (widget); - } - else if (dbus_signature[0] == 'b') - { - widget = gtk_check_button_new_with_label (param_name_formatted); - gtk_grid_attach (GTK_GRID (grid_settings), - widget, 0, row, 2, 1); - gtk_widget_show (widget); - } - else - { - DEBUG ("Unknown signature for param %s: %s", - param_name_formatted, dbus_signature); - } - - if (widget) - tpaw_account_widget_setup_widget (self, widget, - tp_connection_manager_param_get_name (param)); - - g_free (param_name_formatted); - } - - g_list_free_full (params, (GDestroyNotify) tp_connection_manager_param_free); -} - -static void -account_widget_handle_params_valist (TpawAccountWidget *self, - const gchar *first_widget, - va_list args) -{ - GObject *object; - const gchar *name; - - for (name = first_widget; name; name = va_arg (args, const gchar *)) - { - const gchar *param_name; - - param_name = va_arg (args, const gchar *); - object = gtk_builder_get_object (self->ui_details->gui, name); - - if (!object) - { - g_warning ("Builder is missing object '%s'.", name); - continue; - } - - tpaw_account_widget_setup_widget (self, GTK_WIDGET (object), - param_name); - } -} - -static void -account_widget_cancel_clicked_cb (GtkWidget *button, - TpawAccountWidget *self) -{ - g_signal_emit (self, signals[CANCELLED], 0); - g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_CANCEL); -} - -static void -account_widget_account_enabled_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - TpAccount *account = TP_ACCOUNT (source_object); - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (user_data); - - tp_account_set_enabled_finish (account, res, &error); - - if (error != NULL) - { - DEBUG ("Could not enable the account: %s", error->message); - g_error_free (error); - } - else - { - tpaw_connect_new_account (account, self->priv->account_manager); - } - - g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY); - - /* unref self - part of the workaround */ - g_object_unref (self); -} - -static void -account_widget_applied_cb (GObject *source_object, - GAsyncResult *res, - gpointer user_data) -{ - GError *error = NULL; - TpAccount *account; - TpawAccountSettings *settings = TPAW_ACCOUNT_SETTINGS (source_object); - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (user_data); - gboolean reconnect_required; - gboolean fire_close = TRUE; - - tpaw_account_settings_apply_finish (settings, res, &reconnect_required, - &error); - - if (error != NULL) - { - DEBUG ("Could not apply changes to account: %s", error->message); - g_error_free (error); - return; - } - - account = tpaw_account_settings_get_account (self->priv->settings); - - if (account != NULL) - { - if (self->priv->creating_account) - { - /* By default, when an account is created, we enable it. */ - - /* workaround to keep self alive during async call */ - g_object_ref (self); - - tp_account_set_enabled_async (account, TRUE, - account_widget_account_enabled_cb, self); - g_signal_emit (self, signals[ACCOUNT_CREATED], 0, account); - - /* Will be fired in account_widget_account_enabled_cb */ - fire_close = FALSE; - } - else - { - /* If the account was offline, we always want to try reconnecting, - * to give it a chance to connect if the previous params were wrong. - * tp_account_reconnect_async() won't do anything if the requested - * presence is offline anyway. */ - if (tp_account_get_connection_status (account, NULL) == - TP_CONNECTION_STATUS_DISCONNECTED) - reconnect_required = TRUE; - - if (reconnect_required && tp_account_is_enabled (account) - && tp_account_is_enabled (account)) - { - /* After having applied changes to a user account, we - * reconnect it if needed. This is done so the new - * information entered by the user is validated on the server. */ - tp_account_reconnect_async (account, NULL, NULL); - } - } - } - - if (!self->priv->destroyed) - account_widget_set_control_buttons_sensitivity (self, FALSE); - - self->priv->contains_pending_changes = FALSE; - - if (fire_close) - { - /* announce the widget can be closed */ - g_signal_emit (self, signals[CLOSE], 0, GTK_RESPONSE_APPLY); - } - - /* unref the widget - part of the workaround */ - g_object_unref (self); -} - -void -tpaw_account_widget_apply_and_log_in (TpawAccountWidget *self) -{ - gboolean display_name_overridden; - - if (self->priv->radiobutton_reuse != NULL) - { - gboolean reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON ( - self->priv->radiobutton_reuse)); - - DEBUG ("Set register param: %d", !reuse); - tpaw_account_settings_set (self->priv->settings, "register", - g_variant_new_boolean (!reuse)); - } - - g_object_get (self->priv->settings, - "display-name-overridden", &display_name_overridden, NULL); - - if (self->priv->creating_account || !display_name_overridden) - { - gchar *display_name; - - /* set default display name for new accounts or update if user didn't - * manually override it. */ - display_name = tpaw_account_widget_get_default_display_name (self); - - tpaw_account_settings_set_display_name_async (self->priv->settings, - display_name, NULL, NULL); - - g_free (display_name); - } - - /* workaround to keep widget alive during async call */ - g_object_ref (self); - tpaw_account_settings_apply_async (self->priv->settings, - account_widget_applied_cb, self); -} - -static void -account_widget_apply_clicked_cb (GtkWidget *button, - TpawAccountWidget *self) -{ - tpaw_account_widget_apply_and_log_in (self); -} - -static void -account_widget_setup_generic (TpawAccountWidget *self) -{ - GtkWidget *grid_common_settings; - GtkWidget *grid_advanced_settings; - - grid_common_settings = GTK_WIDGET (gtk_builder_get_object - (self->ui_details->gui, "grid_common_settings")); - grid_advanced_settings = GTK_WIDGET (gtk_builder_get_object - (self->ui_details->gui, "grid_advanced_settings")); - - accounts_widget_generic_setup (self, grid_common_settings, - grid_advanced_settings); - - g_object_unref (self->ui_details->gui); -} - -static void -account_widget_settings_ready_cb (TpawAccountSettings *settings, - GParamSpec *pspec, - gpointer user_data) -{ - TpawAccountWidget *self = user_data; - - if (tpaw_account_settings_is_ready (self->priv->settings)) - account_widget_setup_generic (self); -} - -static GtkWidget * -account_widget_build_generic (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *expander_advanced, *box; - - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_generic_settings", &box, - "expander_advanced_settings", &expander_advanced, - NULL); - - if (self->priv->simple) - gtk_widget_hide (expander_advanced); - - g_object_ref (self->ui_details->gui); - - if (tpaw_account_settings_is_ready (self->priv->settings)) - account_widget_setup_generic (self); - else - g_signal_connect (self->priv->settings, "notify::ready", - G_CALLBACK (account_widget_settings_ready_cb), self); - - return box; -} - -static GtkWidget * -account_widget_build_salut (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *expander_advanced, *box; - - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_salut_settings", &box, - "expander_advanced_settings", &expander_advanced, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_published", "published-name", - "entry_nickname", "nickname", - "entry_first_name", "first-name", - "entry_last_name", "last-name", - "entry_email", "email", - "entry_jid", "jid", - NULL); - - if (self->priv->simple) - gtk_widget_hide (expander_advanced); - - self->ui_details->default_focus = g_strdup ("entry_first_name"); - - return box; -} - -static GtkWidget * -account_widget_build_irc (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *box; - - tpaw_account_settings_set_regex (self->priv->settings, "account", - ACCOUNT_REGEX_IRC); - - if (self->priv->simple) - { - self->priv->irc_network_chooser = tpaw_account_widget_irc_build_simple - (self, filename, &box); - } - else - { - self->priv->irc_network_chooser = tpaw_account_widget_irc_build (self, - filename, &self->priv->grid_common_settings, &box); - } - - return box; -} - -static GtkWidget * -account_widget_build_sip (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *box; - - box = tpaw_account_widget_sip_build (self, filename, - &self->priv->grid_common_settings); - - if (self->priv->simple) - { - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -static GtkWidget * -account_widget_build_msn (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *box; - - tpaw_account_settings_set_regex (self->priv->settings, "account", - ACCOUNT_REGEX_MSN); - - if (self->priv->simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_msn_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_msn_settings", &self->priv->grid_common_settings, - "vbox_msn_settings", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -static void -suffix_id_widget_changed_cb (GtkWidget *entry, - TpawAccountWidget *self) -{ - gchar *account; - - g_assert (self->priv->jid_suffix != NULL); - - account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE); - - account = tpaw_account_settings_dup_string (self->priv->settings, - "account"); - - if (!TPAW_STR_EMPTY (account) && - !g_str_has_suffix (account, self->priv->jid_suffix)) - { - gchar *tmp; - - tmp = g_strdup_printf ("%s%s", account, self->priv->jid_suffix); - - DEBUG ("Change account from '%s' to '%s'", account, tmp); - - tpaw_account_settings_set (self->priv->settings, "account", - g_variant_new_string (tmp)); - g_free (tmp); - } - - tpaw_account_widget_changed (self); - - g_free (account); -} - -static gchar * -remove_jid_suffix (TpawAccountWidget *self, - const gchar *str) -{ - g_assert (self->priv->jid_suffix != NULL); - - if (!g_str_has_suffix (str, self->priv->jid_suffix)) - return g_strdup (str); - - return g_strndup (str, strlen (str) - strlen (self->priv->jid_suffix)); -} - -static void -setup_id_widget_with_suffix (TpawAccountWidget *self, - GtkWidget *widget, - const gchar *suffix) -{ - gchar *str = NULL; - - g_object_set_data_full (G_OBJECT (widget), "param_name", - g_strdup ("account"), g_free); - - g_assert (self->priv->jid_suffix == NULL); - self->priv->jid_suffix = g_strdup (suffix); - - str = tpaw_account_settings_dup_string (self->priv->settings, "account"); - if (str != NULL) - { - gchar *tmp; - - tmp = remove_jid_suffix (self, str); - gtk_entry_set_text (GTK_ENTRY (widget), tmp); - g_free (tmp); - g_free (str); - } - - self->priv->param_account_widget = widget; - - g_signal_connect (widget, "changed", - G_CALLBACK (suffix_id_widget_changed_cb), self); -} - -static Service -account_widget_get_service (TpawAccountWidget *self) -{ - const gchar *icon_name, *service; - - icon_name = tpaw_account_settings_get_icon_name (self->priv->settings); - service = tpaw_account_settings_get_service (self->priv->settings); - - /* Previous versions of Tpaw didn't set the Service property on Facebook - * and gtalk accounts, so we check using the icon name as well. */ - if (!tp_strdiff (icon_name, "im-google-talk") || - !tp_strdiff (service, "google-talk")) - return GTALK_SERVICE; - - if (!tp_strdiff (icon_name, "im-facebook") || - !tp_strdiff (service, "facebook")) - return FACEBOOK_SERVICE; - - return NO_SERVICE; -} - -static GtkWidget * -account_widget_build_jabber (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *spinbutton_port; - GtkWidget *checkbutton_ssl; - GtkWidget *label_id, *label_password; - GtkWidget *label_id_create, *label_password_create; - GtkWidget *label_example_fb; - GtkWidget *label_example; - GtkWidget *expander_advanced; - GtkWidget *entry_id; - GtkWidget *box; - Service service; - - service = account_widget_get_service (self); - - tpaw_account_settings_set_regex (self->priv->settings, "account", - ACCOUNT_REGEX_JABBER); - - if (self->priv->simple && service == NO_SERVICE) - { - /* Simple widget for XMPP */ - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_jabber_simple", &box, - "label_id_simple", &label_id, - "label_id_create", &label_id_create, - "label_password_simple", &label_password, - "label_password_create", &label_password_create, - NULL); - - if (tpaw_account_settings_get_boolean (self->priv->settings, - "register")) - { - gtk_widget_hide (label_id); - gtk_widget_hide (label_password); - gtk_widget_show (label_id_create); - gtk_widget_show (label_password_create); - } - - tpaw_account_widget_handle_params (self, - "entry_id_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else if (self->priv->simple && service == GTALK_SERVICE) - { - /* Simple widget for Google Talk */ - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_gtalk_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id_g_simple", "account", - "entry_password_g_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id_g_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_g_simple")); - } - else if (self->priv->simple && service == FACEBOOK_SERVICE) - { - /* Simple widget for Facebook */ - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_fb_simple", &box, - "entry_id_fb_simple", &entry_id, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_password_fb_simple", "password", - NULL); - - setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com"); - - self->ui_details->default_focus = g_strdup ("entry_id_fb_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_fb_simple")); - } - else - { - ServiceInfo info = services_infos[service]; - - /* Full widget for XMPP, Google Talk and Facebook*/ - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_jabber_settings", &box, - "spinbutton_port", &spinbutton_port, - "checkbutton_ssl", &checkbutton_ssl, - "label_username_f_example", &label_example_fb, - info.label_username_example, &label_example, - "expander_advanced", &expander_advanced, - "entry_id", &entry_id, - "label_id", &label_id, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_password", "password", - "entry_resource", "resource", - "entry_server", "server", - "spinbutton_port", "port", - "spinbutton_priority", "priority", - "checkbutton_ssl", "old-ssl", - "checkbutton_ignore_ssl_errors", "ignore-ssl-errors", - "checkbutton_encryption", "require-encryption", - NULL); - - if (service == FACEBOOK_SERVICE) - { - gtk_label_set_label (GTK_LABEL (label_id), _("Username:")); - - /* Facebook special case the entry ID widget to hide the - * "@chat.facebook.com" part */ - setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com"); - } - else - { - tpaw_account_widget_setup_widget (self, entry_id, "account"); - } - - self->ui_details->default_focus = g_strdup ("entry_id"); - self->priv->spinbutton_port = spinbutton_port; - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - - g_signal_connect (checkbutton_ssl, "toggled", - G_CALLBACK (account_widget_jabber_ssl_toggled_cb), - self); - - if (service == FACEBOOK_SERVICE) - { - GtkContainer *parent; - GList *children; - - /* Removing the label from list of focusable widgets */ - parent = GTK_CONTAINER (gtk_widget_get_parent (label_example_fb)); - children = gtk_container_get_children (parent); - children = g_list_remove (children, label_example_fb); - gtk_container_set_focus_chain (parent, children); - g_list_free (children); - } - - gtk_widget_show (label_example); - - if (!info.show_advanced) - gtk_widget_hide (expander_advanced); - } - - return box; -} - -static GtkWidget * -account_widget_build_icq (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *spinbutton_port; - GtkWidget *box; - - tpaw_account_settings_set_regex (self->priv->settings, "account", - ACCOUNT_REGEX_ICQ); - - if (self->priv->simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_icq_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_uin_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_uin_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_icq_settings", &box, - "spinbutton_port", &spinbutton_port, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_uin", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - "entry_charset", "charset", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_uin"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -static GtkWidget * -account_widget_build_aim (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *spinbutton_port, *box; - - if (self->priv->simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_aim_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_screenname_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_screenname_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_aim_settings", &box, - "spinbutton_port", &spinbutton_port, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_screenname", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_screenname"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -static GtkWidget * -account_widget_build_yahoo (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *box; - - tpaw_account_settings_set_regex (self->priv->settings, "account", - ACCOUNT_REGEX_YAHOO); - - if (self->priv->simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_yahoo_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_settings", &self->priv->grid_common_settings, - "vbox_yahoo_settings", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id", "account", - "entry_password", "password", - "entry_locale", "room-list-locale", - "entry_charset", "charset", - "spinbutton_port", "port", - "checkbutton_ignore_invites", "ignore-invites", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -static GtkWidget * -account_widget_build_groupwise (TpawAccountWidget *self, - const char *filename) -{ - GtkWidget *box; - - if (self->priv->simple) - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "vbox_groupwise_simple", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id_simple", "account", - "entry_password_simple", "password", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id_simple"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, - "remember_password_simple")); - } - else - { - self->ui_details->gui = tpaw_builder_get_resource (filename, - "grid_common_groupwise_settings", &self->priv->grid_common_settings, - "vbox_groupwise_settings", &box, - NULL); - - tpaw_account_widget_handle_params (self, - "entry_id", "account", - "entry_password", "password", - "entry_server", "server", - "spinbutton_port", "port", - NULL); - - self->ui_details->default_focus = g_strdup ("entry_id"); - - self->priv->remember_password_widget = GTK_WIDGET ( - gtk_builder_get_object (self->ui_details->gui, "remember_password")); - } - - return box; -} - -void -tpaw_account_widget_set_other_accounts_exist (TpawAccountWidget *self, - gboolean others_exist) -{ - self->priv->other_accounts_exist = others_exist; - - if (self->priv->creating_account) - account_widget_handle_control_buttons_sensitivity (self); -} - -static void -do_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (object); - - switch (prop_id) - { - case PROP_SETTINGS: - self->priv->settings = g_value_dup_object (value); - break; - case PROP_SIMPLE: - self->priv->simple = g_value_get_boolean (value); - break; - case PROP_CREATING_ACCOUNT: - self->priv->creating_account = g_value_get_boolean (value); - break; - case PROP_OTHER_ACCOUNTS_EXIST: - tpaw_account_widget_set_other_accounts_exist ( - TPAW_ACCOUNT_WIDGET (object), g_value_get_boolean (value)); - break; - case PROP_ACTION_AREA: - self->priv->action_area = g_value_get_object (value); - if (self->priv->action_area != NULL) - { - g_object_ref_sink (self->priv->action_area); - self->priv->external_action_area = TRUE; - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -do_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (object); - - switch (prop_id) - { - case PROP_PROTOCOL: - g_value_set_string (value, - tpaw_account_settings_get_protocol (self->priv->settings)); - break; - case PROP_SETTINGS: - g_value_set_object (value, self->priv->settings); - break; - case PROP_SIMPLE: - g_value_set_boolean (value, self->priv->simple); - break; - case PROP_CREATING_ACCOUNT: - g_value_set_boolean (value, self->priv->creating_account); - break; - case PROP_OTHER_ACCOUNTS_EXIST: - g_value_set_boolean (value, self->priv->other_accounts_exist); - break; - case PROP_ACTION_AREA: - g_value_set_object (value, self->priv->action_area); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -set_apply_button (TpawAccountWidget *self) -{ - GtkWidget *image; - - /* We can't use the stock button as its accelerator ('A') clashes with the - * Add button. */ - gtk_button_set_use_stock (GTK_BUTTON (self->priv->apply_button), FALSE); - - gtk_button_set_label (GTK_BUTTON (self->priv->apply_button), _("A_pply")); - gtk_button_set_use_underline (GTK_BUTTON (self->priv->apply_button), TRUE); - - image = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (self->priv->apply_button), image); -} - -static void -presence_changed_cb (TpAccountManager *manager, - TpConnectionPresenceType state, - const gchar *status, - const gchar *message, - TpawAccountWidget *self) -{ - if (self->priv->destroyed) - return; - - if (self->priv->apply_button == NULL) - /* This button doesn't exist in 'simple' mode */ - return; - - if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE && - self->priv->creating_account) - { - /* We are online and creating a new account, display a Login button */ - GtkWidget *image; - - gtk_button_set_use_stock (GTK_BUTTON (self->priv->apply_button), FALSE); - gtk_button_set_label (GTK_BUTTON (self->priv->apply_button), - _("L_og in")); - - image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, - GTK_ICON_SIZE_BUTTON); - gtk_button_set_image (GTK_BUTTON (self->priv->apply_button), image); - } - else - { - /* We are offline or modifying an existing account, display - * a Save button */ - set_apply_button (self); - } -} - -static void -account_manager_ready_cb (GObject *source_object, - GAsyncResult *result, - gpointer user_data) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (user_data); - TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object); - GError *error = NULL; - TpConnectionPresenceType state; - - if (!tp_proxy_prepare_finish (account_manager, result, &error)) - { - DEBUG ("Failed to prepare account manager: %s", error->message); - g_error_free (error); - goto out; - } - - state = tp_account_manager_get_most_available_presence (account_manager, NULL, - NULL); - - /* simulate a presence change so the apply button will be changed - * if needed */ - presence_changed_cb (account_manager, state, NULL, NULL, self); - -out: - g_object_unref (self); -} - -#define WIDGET(cm, proto) \ - { #cm, #proto, TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/tpaw-account-widget-"#proto".ui", \ - account_widget_build_##proto } - -static void -add_register_buttons (TpawAccountWidget *self, - TpAccount *account) -{ - TpProtocol *protocol; - GtkWidget *radiobutton_register; - - if (!self->priv->creating_account) - return; - - protocol = tpaw_account_settings_get_tp_protocol (self->priv->settings); - if (protocol == NULL) - return; - - if (!tp_protocol_can_register (protocol)) - return; - - if (account_widget_get_service (self) != NO_SERVICE) - return; - - if (self->priv->simple) - return; - - self->priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL, - _("This account already exists on the server")); - radiobutton_register = gtk_radio_button_new_with_label ( - gtk_radio_button_get_group ( - GTK_RADIO_BUTTON (self->priv->radiobutton_reuse)), - _("Create a new account on the server")); - - gtk_box_pack_start (GTK_BOX (self), self->priv->radiobutton_reuse, FALSE, - FALSE, 0); - gtk_box_pack_start (GTK_BOX (self), radiobutton_register, FALSE, FALSE, 0); - gtk_box_reorder_child (GTK_BOX (self), self->priv->radiobutton_reuse, 0); - gtk_box_reorder_child (GTK_BOX (self), radiobutton_register, 1); - gtk_widget_show (self->priv->radiobutton_reuse); - gtk_widget_show (radiobutton_register); -} - -static void -remember_password_toggled_cb (GtkToggleButton *button, - TpawAccountWidget *self) -{ - tpaw_account_settings_set_remember_password (self->priv->settings, - gtk_toggle_button_get_active (button)); - - if (!self->priv->automatic_change) - tpaw_account_widget_changed (self); -} - -static void -account_settings_password_retrieved_cb (GObject *object, - gpointer user_data) -{ - TpawAccountWidget *self = user_data; - gchar *password; - - password = tpaw_account_settings_dup_string ( - self->priv->settings, "password"); - - /* We have to do this so that when we call gtk_entry_set_text, - * the ::changed callback doesn't think the user made the - * change. This is also used in remember_password_toggled_cb. */ - self->priv->automatic_change = TRUE; - - if (password != NULL) - { - gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget), - password); - } - - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), - !TPAW_STR_EMPTY (password)); - - self->priv->automatic_change = FALSE; - - g_free (password); -} - -static void -do_constructed (GObject *obj) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (obj); - TpAccount *account; - const gchar *display_name, *default_display_name; - guint i = 0; - struct { - const gchar *cm_name; - const gchar *protocol; - const char *file; - GtkWidget * (*func)(TpawAccountWidget *self, const gchar *filename); - } widgets [] = { - { "salut", "local-xmpp", TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/tpaw-account-widget-local-xmpp.ui", - account_widget_build_salut }, - WIDGET (gabble, jabber), - WIDGET (haze, msn), - WIDGET (haze, icq), - WIDGET (haze, aim), - WIDGET (haze, yahoo), - WIDGET (haze, groupwise), - WIDGET (idle, irc), - WIDGET (sofiasip, sip), - }; - const gchar *protocol, *cm_name; - GtkWidget *box; - - account = tpaw_account_settings_get_account (self->priv->settings); - - cm_name = tpaw_account_settings_get_cm (self->priv->settings); - protocol = tpaw_account_settings_get_protocol (self->priv->settings); - - for (i = 0 ; i < G_N_ELEMENTS (widgets); i++) - { - if (!tp_strdiff (widgets[i].cm_name, cm_name) && - !tp_strdiff (widgets[i].protocol, protocol)) - { - box = widgets[i].func (self, widgets[i].file); - break; - } - } - - if (i == G_N_ELEMENTS (widgets)) - { - gchar *filename = TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/tpaw-account-widget-generic.ui"; - box = account_widget_build_generic (self, filename); - } - - gtk_container_add (GTK_CONTAINER (self), box); - - /* handle default focus */ - if (self->ui_details->default_focus != NULL) - { - GObject *default_focus_entry; - - default_focus_entry = gtk_builder_get_object - (self->ui_details->gui, self->ui_details->default_focus); - g_signal_connect (default_focus_entry, "realize", - G_CALLBACK (gtk_widget_grab_focus), - NULL); - } - - /* remember password */ - if (self->priv->param_password_widget != NULL - && self->priv->remember_password_widget != NULL - && tpaw_account_settings_supports_sasl (self->priv->settings)) - { - if (self->priv->simple) - { - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), TRUE); - } - else - { - gchar *password; - - password = tpaw_account_settings_dup_string (self->priv->settings, - "password"); - - /* FIXME: we should enable this checkbox only if the password is - * stored for good in the password storage, not only for the session - * (bgo #683571) */ - gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), - !TPAW_STR_EMPTY (password)); - - /* The password might not have been retrieved from the - * keyring yet. We should update the remember password - * toggle button and the password entry when/if it is. */ - tp_g_signal_connect_object (self->priv->settings, - "password-retrieved", - G_CALLBACK (account_settings_password_retrieved_cb), self, 0); - - g_free (password); - } - - g_signal_connect (self->priv->remember_password_widget, "toggled", - G_CALLBACK (remember_password_toggled_cb), self); - - self->priv->automatic_change = TRUE; - remember_password_toggled_cb ( - GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), self); - self->priv->automatic_change = FALSE; - } - else if (self->priv->remember_password_widget != NULL - && !tpaw_account_settings_supports_sasl (self->priv->settings)) - { - gtk_widget_set_visible (self->priv->remember_password_widget, FALSE); - tpaw_account_settings_set_remember_password (self->priv->settings, - TRUE); - } - - /* dup and init the account-manager */ - self->priv->account_manager = tp_account_manager_dup (); - - g_object_ref (self); - tp_proxy_prepare_async (self->priv->account_manager, NULL, - account_manager_ready_cb, self); - - if (!self->priv->external_action_area) - { - g_assert (self->priv->action_area == NULL); - self->priv->action_area = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL); - gtk_button_box_set_layout (GTK_BUTTON_BOX (self->priv->action_area), - GTK_BUTTONBOX_END); - /* Hard code the default spacing as we cannot easily get this property - * as the widget is not in a GtkDialog yet (and it could end up packed - * in a non-GtkDialog window anyway */ - gtk_box_set_spacing (GTK_BOX (self->priv->action_area), 6); - /* If the action area is set by the user of this class then we keep a - * reference, so we do the same here */ - g_object_ref_sink (self->priv->action_area); - } - else - { - g_assert (self->priv->action_area != NULL); - } - - self->priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); - - self->priv->apply_button = gtk_button_new (); - set_apply_button (self); - - /* We'll change this button to a "Log in" one if we are creating a new - * account and are connected. */ - tp_g_signal_connect_object (self->priv->account_manager, - "most-available-presence-changed", - G_CALLBACK (presence_changed_cb), obj, 0); - - gtk_box_pack_end (GTK_BOX (self->priv->action_area), - self->priv->cancel_button, TRUE, TRUE, 3); - gtk_box_pack_end (GTK_BOX (self->priv->action_area), - self->priv->apply_button, TRUE, TRUE, 3); - - if (!self->priv->external_action_area) - gtk_box_pack_end (GTK_BOX (self), self->priv->action_area, FALSE, - FALSE, 3); - - g_signal_connect (self->priv->cancel_button, "clicked", - G_CALLBACK (account_widget_cancel_clicked_cb), - self); - g_signal_connect (self->priv->apply_button, "clicked", - G_CALLBACK (account_widget_apply_clicked_cb), - self); - gtk_widget_show_all (self->priv->action_area); - - if (self->priv->creating_account) - /* When creating an account, the user might have nothing to enter. - * That means that no control interaction might occur, - * so we update the control button sensitivity manually. - */ - account_widget_handle_control_buttons_sensitivity (self); - else - account_widget_set_control_buttons_sensitivity (self, FALSE); - - add_register_buttons (self, account); - - g_clear_object (&self->ui_details->gui); - - display_name = tpaw_account_settings_get_display_name ( - self->priv->settings); - default_display_name = tpaw_account_widget_get_default_display_name (self); - - if (tp_strdiff (display_name, default_display_name) && - !self->priv->creating_account) - { - /* The display name of the account is not the one that we'd assign by - * default; assume that the user changed it manually */ - g_object_set (self->priv->settings, "display-name-overridden", TRUE, - NULL); - } -} - -static void -do_dispose (GObject *obj) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (obj); - - g_clear_object (&self->priv->settings); - g_clear_object (&self->priv->account_manager); - g_clear_object (&self->priv->action_area); - - if (G_OBJECT_CLASS (tpaw_account_widget_parent_class)->dispose != NULL) - G_OBJECT_CLASS (tpaw_account_widget_parent_class)->dispose (obj); -} - -static void -do_finalize (GObject *obj) -{ - TpawAccountWidget *self = TPAW_ACCOUNT_WIDGET (obj); - - g_free (self->ui_details->default_focus); - g_slice_free (TpawAccountWidgetUIDetails, self->ui_details); - - g_free (self->priv->jid_suffix); - - if (G_OBJECT_CLASS (tpaw_account_widget_parent_class)->finalize != NULL) - G_OBJECT_CLASS (tpaw_account_widget_parent_class)->finalize (obj); -} - -static void -tpaw_account_widget_class_init (TpawAccountWidgetClass *klass) -{ - GObjectClass *oclass = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - oclass->get_property = do_get_property; - oclass->set_property = do_set_property; - oclass->constructed = do_constructed; - oclass->dispose = do_dispose; - oclass->finalize = do_finalize; - - param_spec = g_param_spec_string ("protocol", - "protocol", "The protocol of the account", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec); - - param_spec = g_param_spec_object ("settings", - "settings", "The settings of the account", - TPAW_TYPE_ACCOUNT_SETTINGS, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_SETTINGS, param_spec); - - param_spec = g_param_spec_boolean ("simple", - "simple", "Whether the account widget is a simple or an advanced one", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_SIMPLE, param_spec); - - param_spec = g_param_spec_boolean ("creating-account", - "creating-account", - "TRUE if we're creating an account, FALSE if we're modifying it", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec); - - param_spec = g_param_spec_boolean ("other-accounts-exist", - "other-accounts-exist", - "TRUE if there are any other accounts (even if this isn't yet saved)", - FALSE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_OTHER_ACCOUNTS_EXIST, - param_spec); - - param_spec = g_param_spec_object ("action-area", - "action-area", - "The widget where to pack the action buttons (or NULL)", - GTK_TYPE_BOX, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (oclass, PROP_ACTION_AREA, - param_spec); - - signals[HANDLE_APPLY] = - g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 1, G_TYPE_BOOLEAN); - - /* This signal is emitted when an account has been created and enabled. */ - signals[ACCOUNT_CREATED] = - g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 1, G_TYPE_OBJECT); - - signals[CANCELLED] = - g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 0); - - signals[CLOSE] = - g_signal_new ("close", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, G_TYPE_INT); - - g_type_class_add_private (klass, sizeof (TpawAccountWidgetPriv)); -} - -static void -tpaw_account_widget_init (TpawAccountWidget *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), TPAW_TYPE_ACCOUNT_WIDGET, - TpawAccountWidgetPriv); - - self->ui_details = g_slice_new0 (TpawAccountWidgetUIDetails); -} - -/* public methods */ - -void -tpaw_account_widget_discard_pending_changes (TpawAccountWidget *self) -{ - tpaw_account_settings_discard_changes (self->priv->settings); - self->priv->contains_pending_changes = FALSE; -} - -gboolean -tpaw_account_widget_contains_pending_changes (TpawAccountWidget *self) -{ - return self->priv->contains_pending_changes; -} - -void -tpaw_account_widget_handle_params (TpawAccountWidget *self, - const gchar *first_widget, - ...) -{ - va_list args; - - va_start (args, first_widget); - account_widget_handle_params_valist (self, first_widget, args); - va_end (args); -} - -TpawAccountWidget * -tpaw_account_widget_new_for_protocol (TpawAccountSettings *settings, - GtkBox *action_area, - gboolean simple) -{ - g_return_val_if_fail (TPAW_IS_ACCOUNT_SETTINGS (settings), NULL); - - return g_object_new (TPAW_TYPE_ACCOUNT_WIDGET, - "orientation", GTK_ORIENTATION_VERTICAL, - "settings", settings, - "simple", simple, - "creating-account", - tpaw_account_settings_get_account (settings) == NULL, - "action-area", action_area, - NULL); -} - -gchar * -tpaw_account_widget_get_default_display_name (TpawAccountWidget *self) -{ - gchar *login_id; - const gchar *protocol, *p; - gchar *default_display_name; - Service service; - - login_id = tpaw_account_settings_dup_string (self->priv->settings, - "account"); - protocol = tpaw_account_settings_get_protocol (self->priv->settings); - service = account_widget_get_service (self); - - if (login_id != NULL) - { - /* TODO: this should be done in tpaw-account-widget-irc */ - if (!tp_strdiff (protocol, "irc")) - { - TpawIrcNetwork *network; - - network = tpaw_irc_network_chooser_get_network ( - self->priv->irc_network_chooser); - g_assert (network != NULL); - - /* To translators: The first parameter is the login id and the - * second one is the network. The resulting string will be something - * like: "MyUserName on freenode". - * You should reverse the order of these arguments if the - * server should come before the login id in your locale.*/ - default_display_name = g_strdup_printf (_("%1$s on %2$s"), - login_id, tpaw_irc_network_get_name (network)); - } - else if (service == FACEBOOK_SERVICE && self->priv->jid_suffix != NULL) - { - gchar *tmp; - - tmp = remove_jid_suffix (self, login_id); - default_display_name = g_strdup_printf ("Facebook (%s)", tmp); - g_free (tmp); - } - else - { - default_display_name = g_strdup (login_id); - } - - return default_display_name; - } - - if ((p = tpaw_protocol_name_to_display_name (protocol)) != NULL) - protocol = p; - - if (protocol != NULL) - { - /* To translators: The parameter is the protocol name. The resulting - * string will be something like: "Jabber Account" */ - default_display_name = g_strdup_printf (_("%s Account"), protocol); - } - else - { - default_display_name = g_strdup (_("New account")); - } - - g_free (login_id); - - return default_display_name; -} - -/* Used by subclass to indicate that widget contains pending changes */ -void -tpaw_account_widget_changed (TpawAccountWidget *self) -{ - account_widget_handle_control_buttons_sensitivity (self); - self->priv->contains_pending_changes = TRUE; -} - -void -tpaw_account_widget_set_account_param (TpawAccountWidget *self, - const gchar *account) -{ - if (self->priv->param_account_widget == NULL) - return; - - gtk_entry_set_text (GTK_ENTRY (self->priv->param_account_widget), account); -} - -void -tpaw_account_widget_set_password_param (TpawAccountWidget *self, - const gchar *account) -{ - if (self->priv->param_password_widget == NULL) - return; - - gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget), account); -} - -TpawAccountSettings * -tpaw_account_widget_get_settings (TpawAccountWidget *self) -{ - return self->priv->settings; -} - -void -tpaw_account_widget_hide_buttons (TpawAccountWidget *self) -{ - gtk_widget_hide (self->priv->action_area); -} diff --git a/tp-account-widgets/tpaw-account-widget.h b/tp-account-widgets/tpaw-account-widget.h deleted file mode 100644 index 70ec32850..000000000 --- a/tp-account-widgets/tpaw-account-widget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2006-2007 Imendio AB - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Martyn Russell <martyn@imendio.com> - */ - -#ifndef __TPAW_ACCOUNT_WIDGET_H__ -#define __TPAW_ACCOUNT_WIDGET_H__ - -#include <gtk/gtk.h> - -#include "tpaw-account-settings.h" - -G_BEGIN_DECLS - -#define TPAW_TYPE_ACCOUNT_WIDGET tpaw_account_widget_get_type() -#define TPAW_ACCOUNT_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPAW_TYPE_ACCOUNT_WIDGET, TpawAccountWidget)) -#define TPAW_ACCOUNT_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), TPAW_TYPE_ACCOUNT_WIDGET, TpawAccountWidgetClass)) -#define TPAW_IS_ACCOUNT_WIDGET(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPAW_TYPE_ACCOUNT_WIDGET)) -#define TPAW_IS_ACCOUNT_WIDGET_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), TPAW_TYPE_ACCOUNT_WIDGET)) -#define TPAW_ACCOUNT_WIDGET_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TPAW_TYPE_ACCOUNT_WIDGET, TpawAccountWidgetClass)) - -typedef struct _TpawAccountWidgetPriv TpawAccountWidgetPriv; -typedef struct _TpawAccountWidgetUIDetails TpawAccountWidgetUIDetails; - -typedef struct { - GtkBox parent; - - TpawAccountWidgetUIDetails *ui_details; - - TpawAccountWidgetPriv *priv; -} TpawAccountWidget; - -typedef struct { - GtkBoxClass parent_class; -} TpawAccountWidgetClass; - -GType tpaw_account_widget_get_type (void); - -TpawAccountWidget * tpaw_account_widget_new_for_protocol ( - TpawAccountSettings *settings, - GtkBox *action_area, - gboolean simple); - -gboolean tpaw_account_widget_contains_pending_changes - (TpawAccountWidget *widget); -void tpaw_account_widget_discard_pending_changes - (TpawAccountWidget *widget); - -gchar * tpaw_account_widget_get_default_display_name ( - TpawAccountWidget *widget); - -void tpaw_account_widget_set_account_param (TpawAccountWidget *widget, - const gchar *account); - -void tpaw_account_widget_set_password_param (TpawAccountWidget *self, - const gchar *password); - -void tpaw_account_widget_set_other_accounts_exist ( - TpawAccountWidget *self, gboolean others_exist); - -void tpaw_account_widget_hide_buttons (TpawAccountWidget *self); - -void tpaw_account_widget_apply_and_log_in (TpawAccountWidget *self); - -/* protected methods */ -void tpaw_account_widget_changed (TpawAccountWidget *widget); - -TpawAccountSettings * tpaw_account_widget_get_settings ( - TpawAccountWidget *self); - -G_END_DECLS - -#endif /* __TPAW_ACCOUNT_WIDGET_H__ */ diff --git a/tp-account-widgets/tpaw-account-widgets.gresource.xml b/tp-account-widgets/tpaw-account-widgets.gresource.xml deleted file mode 100644 index 6645041e5..000000000 --- a/tp-account-widgets/tpaw-account-widgets.gresource.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<gresources> - <gresource prefix="/org/gnome/AccountWidgets"> - <file>tpaw-irc-networks.dtd</file> - <file compressed="true">tpaw-account-widget-generic.ui</file> - <file compressed="true">tpaw-account-widget-jabber.ui</file> - <file compressed="true">tpaw-account-widget-msn.ui</file> - <file compressed="true">tpaw-account-widget-sip.ui</file> - <file compressed="true">tpaw-account-widget-local-xmpp.ui</file> - <file compressed="true">tpaw-account-widget-irc.ui</file> - <file compressed="true">tpaw-account-widget-icq.ui</file> - <file compressed="true">tpaw-account-widget-yahoo.ui</file> - <file compressed="true">tpaw-account-widget-groupwise.ui</file> - <file compressed="true">tpaw-account-widget-aim.ui</file> - </gresource> -</gresources> - diff --git a/tp-account-widgets/tpaw-avatar-chooser.c b/tp-account-widgets/tpaw-avatar-chooser.c deleted file mode 100644 index d40666e75..000000000 --- a/tp-account-widgets/tpaw-avatar-chooser.c +++ /dev/null @@ -1,1221 +0,0 @@ -/* - * Copyright (C) 2006-2007 Imendio AB. - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Based on Novell's e-image-chooser. - * Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" -#include "tpaw-avatar-chooser.h" - -#include <glib/gi18n-lib.h> -#include <tp-account-widgets/tpaw-camera-monitor.h> -#include <tp-account-widgets/tpaw-gsettings.h> -#include <tp-account-widgets/tpaw-images.h> -#include <tp-account-widgets/tpaw-pixbuf-utils.h> -#include <tp-account-widgets/tpaw-utils.h> - -#ifdef HAVE_CHEESE -#include <cheese-avatar-chooser.h> -#endif /* HAVE_CHEESE */ - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -/** - * SECTION:tpaw-avatar-chooser - * @title: TpawAvatarChooser - * @short_description: A widget used to change avatar - * @include: tp-account-widgets/tpaw-avatar-chooser.h - * - * #TpawAvatarChooser is a widget which extends #GtkButton to - * provide a way of changing avatar. - */ - -/** - * TpawAvatarChooser: - * @parent: parent object - * - * Widget which extends #GtkButton to provide a way of changing avatar. - */ - -#define AVATAR_SIZE_SAVE 96 -#define AVATAR_SIZE_VIEW 64 -#define DEFAULT_DIR DATADIR"/pixmaps/faces" - -#ifdef HAVE_CHEESE -/* - * A custom GtkResponseType used when the user presses the - * "Camera Picture" button. Any positive value would be sufficient. - */ -#define TPAW_AVATAR_CHOOSER_RESPONSE_WEBCAM 10 -#endif -#define TPAW_AVATAR_CHOOSER_RESPONSE_NO_IMAGE GTK_RESPONSE_NO -#define TPAW_AVATAR_CHOOSER_RESPONSE_CANCEL GTK_RESPONSE_CANCEL -#define TPAW_AVATAR_CHOOSER_RESPONSE_FILE GTK_RESPONSE_OK - -struct _TpawAvatarChooserPrivate -{ - TpAccount *account; - - GArray *avatar; - gchar *mime_type; - gboolean changed; - - GtkFileChooser *chooser_dialog; - GSettings *gsettings_ui; -}; - -enum -{ - PROP_0, - PROP_ACCOUNT -}; - -G_DEFINE_TYPE (TpawAvatarChooser, tpaw_avatar_chooser, GTK_TYPE_BUTTON); - -/* - * Drag and drop stuff - */ -#define URI_LIST_TYPE "text/uri-list" - -enum DndTargetType -{ - DND_TARGET_TYPE_URI_LIST -}; - -static const GtkTargetEntry drop_types[] = -{ - { URI_LIST_TYPE, 0, DND_TARGET_TYPE_URI_LIST }, -}; - -static void avatar_chooser_set_image (TpawAvatarChooser *self, - GArray *avatar, - gchar *mime_type, - GdkPixbuf *pixbuf, - gboolean maybe_convert); -static void avatar_chooser_clear_image (TpawAvatarChooser *self); - -static void -get_avatar_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpWeakRef *wr = user_data; - TpawAvatarChooser *self = tp_weak_ref_dup_object (wr); - const GArray *avatar; - GdkPixbuf *pixbuf; - gchar *mime_type; - GError *error = NULL; - - if (self == NULL) - { - tp_weak_ref_destroy (wr); - return; - } - - avatar = tp_account_get_avatar_finish (self->priv->account, result, &error); - if (avatar == NULL) - { - DEBUG ("Error getting account's avatar: %s", error->message); - g_clear_error (&error); - goto out; - } - - if (avatar->len == 0) - { - avatar_chooser_clear_image (self); - goto out; - } - - pixbuf = tpaw_pixbuf_from_data_and_mime ((gchar *) avatar->data, - avatar->len, &mime_type); - if (pixbuf == NULL) - { - DEBUG ("couldn't make a pixbuf from avatar; giving up"); - goto out; - } - - avatar_chooser_set_image (self, (GArray *) avatar, mime_type, pixbuf, FALSE); - g_free (mime_type); - - self->priv->changed = FALSE; - -out: - tp_weak_ref_destroy (wr); - g_object_unref (self); -} - -static void -avatar_changed_cb (TpAccount *account, - gpointer user_data, - GObject *weak_object) -{ - TpawAvatarChooser *self = (TpawAvatarChooser *) weak_object; - - tp_account_get_avatar_async (self->priv->account, - get_avatar_cb, tp_weak_ref_new (self, NULL, NULL)); -} - -static void -avatar_chooser_constructed (GObject *object) -{ - TpawAvatarChooser *self = (TpawAvatarChooser *) object; - - G_OBJECT_CLASS (tpaw_avatar_chooser_parent_class)->constructed (object); - - tp_account_get_avatar_async (self->priv->account, - get_avatar_cb, tp_weak_ref_new (self, NULL, NULL)); - - /* FIXME: no signal on TpAccount, yet. - * See https://bugs.freedesktop.org/show_bug.cgi?id=52938 */ - tp_cli_account_interface_avatar_connect_to_avatar_changed ( - self->priv->account, avatar_changed_cb, NULL, NULL, (GObject *) self, - NULL); -} - -static void -avatar_chooser_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - TpawAvatarChooser *self = (TpawAvatarChooser *) object; - - switch (param_id) - { - case PROP_ACCOUNT: - g_value_set_object (value, self->priv->account); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -avatar_chooser_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawAvatarChooser *self = TPAW_AVATAR_CHOOSER (object); - - switch (param_id) - { - case PROP_ACCOUNT: - g_assert (self->priv->account == NULL); /* construct-only */ - self->priv->account = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -avatar_chooser_dispose (GObject *object) -{ - TpawAvatarChooser *self = (TpawAvatarChooser *) object; - - tp_clear_object (&self->priv->account); - tp_clear_pointer (&self->priv->avatar, g_array_unref); - tp_clear_pointer (&self->priv->mime_type, g_free); - tp_clear_object (&self->priv->gsettings_ui); - - G_OBJECT_CLASS (tpaw_avatar_chooser_parent_class)->dispose (object); -} - -static void -tpaw_avatar_chooser_class_init (TpawAvatarChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->constructed = avatar_chooser_constructed; - object_class->dispose = avatar_chooser_dispose; - object_class->get_property = avatar_chooser_get_property; - object_class->set_property = avatar_chooser_set_property; - - /** - * TpawAvatarChooser:account: - * - * The #TpAccount whose avatar should be shown and modified by - * the #TpawAvatarChooser instance. - */ - param_spec = g_param_spec_object ("account", - "TpAccount", - "TpAccount whose avatar should be " - "shown and modified by this widget", - TP_TYPE_ACCOUNT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, - PROP_ACCOUNT, - param_spec); - - g_type_class_add_private (object_class, sizeof (TpawAvatarChooserPrivate)); -} - -static gboolean -avatar_chooser_drag_motion_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time_, - TpawAvatarChooser *self) -{ - GList *p; - - for (p = gdk_drag_context_list_targets (context); p != NULL; - p = p->next) - { - gchar *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - - if (!strcmp (possible_type, URI_LIST_TYPE)) - { - g_free (possible_type); - gdk_drag_status (context, GDK_ACTION_COPY, time_); - - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static gboolean -avatar_chooser_drag_drop_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time_, - TpawAvatarChooser *self) -{ - GList *p; - - if (gdk_drag_context_list_targets (context) == NULL) - return FALSE; - - for (p = gdk_drag_context_list_targets (context); - p != NULL; p = p->next) - { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, URI_LIST_TYPE)) - { - g_free (possible_type); - gtk_drag_get_data (widget, context, - GDK_POINTER_TO_ATOM (p->data), - time_); - - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static void -avatar_chooser_clear_image (TpawAvatarChooser *self) -{ - GtkWidget *image; - - tp_clear_pointer (&self->priv->avatar, g_array_unref); - tp_clear_pointer (&self->priv->mime_type, g_free); - self->priv->changed = TRUE; - - image = gtk_image_new_from_icon_name (TPAW_IMAGE_AVATAR_DEFAULT, - GTK_ICON_SIZE_DIALOG); - gtk_button_set_image (GTK_BUTTON (self), image); -} - -static gboolean -str_in_strv (const gchar *str, - gchar **strv) -{ - if (strv == NULL) - return FALSE; - - while (*strv != NULL) - { - if (g_str_equal (str, *strv)) - return TRUE; - - strv++; - } - - return FALSE; -} - -/* The caller must free the strings stored in satisfactory_format_name and - * satisfactory_mime_type. - */ -static gboolean -avatar_chooser_need_mime_type_conversion (const gchar *current_mime_type, - gchar **accepted_mime_types, - gchar **satisfactory_format_name, - gchar **satisfactory_mime_type) -{ - gchar *good_mime_types[] = {"image/jpeg", "image/png", NULL}; - guint i; - GSList *formats, *l; - gboolean found = FALSE; - - *satisfactory_format_name = NULL; - *satisfactory_mime_type = NULL; - - /* If there is no accepted format there is nothing we can do */ - if (accepted_mime_types == NULL || *accepted_mime_types == NULL) - return TRUE; - - /* If the current mime type is good and accepted, don't change it! - * jpeg is compress better pictures, but png is better for logos and - * could have an alpha layer. */ - if (str_in_strv (current_mime_type, good_mime_types) && - str_in_strv (current_mime_type, accepted_mime_types)) - { - *satisfactory_mime_type = g_strdup (current_mime_type); - *satisfactory_format_name = g_strdup (current_mime_type + - strlen ("image/")); - return FALSE; - } - - /* The current mime type is either not accepted or not good to use. - * Check if one of the good format is supported... */ - for (i = 0; good_mime_types[i] != NULL; i++) - { - if (str_in_strv (good_mime_types[i], accepted_mime_types)) - { - *satisfactory_mime_type = g_strdup (good_mime_types[i]); - *satisfactory_format_name = g_strdup (good_mime_types[i] + - strlen ("image/")); - return TRUE; - } - } - - /* Pick the first supported format we can write */ - formats = gdk_pixbuf_get_formats (); - for (l = formats; !found && l != NULL; l = l->next) - { - GdkPixbufFormat *format = l->data; - gchar **format_mime_types; - gchar **iter; - - if (!gdk_pixbuf_format_is_writable (format)) - continue; - - format_mime_types = gdk_pixbuf_format_get_mime_types (format); - for (iter = format_mime_types; *iter != NULL; iter++) - { - if (str_in_strv (*iter, accepted_mime_types)) - { - *satisfactory_format_name = gdk_pixbuf_format_get_name (format); - *satisfactory_mime_type = g_strdup (*iter); - found = TRUE; - break; - } - } - g_strfreev (format_mime_types); - } - g_slist_free (formats); - - return TRUE; -} - -static void -avatar_chooser_error_show (TpawAvatarChooser *self, - const gchar *primary_text, - const gchar *secondary_text) -{ - GtkWidget *parent; - GtkWidget *dialog; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (self)); - if (!GTK_IS_WINDOW (parent)) - parent = NULL; - - dialog = gtk_message_dialog_new (parent ? GTK_WINDOW (parent) : NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_CLOSE, - "%s", primary_text); - - if (secondary_text != NULL) - { - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", secondary_text); - } - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - -} - -static TpAvatarRequirements * -get_requirements (TpawAvatarChooser *self) -{ - TpConnection *connection; - - /* FIXME: Should get on TpProtocol if account is offline */ - connection = tp_account_get_connection (self->priv->account); - return tp_connection_get_avatar_requirements (connection); -} - - -static gboolean -avatar_chooser_maybe_convert_and_scale (TpawAvatarChooser *self, - GdkPixbuf *pixbuf, - GArray *avatar, - gchar *mime_type, - GArray **ret_avatar, - gchar **ret_mime_type) -{ - TpAvatarRequirements *req; - gboolean needs_conversion = FALSE; - guint width, height; - gchar *new_format_name = NULL; - gchar *new_mime_type = NULL; - gdouble min_factor, max_factor; - gdouble factor; - gchar *best_image_data = NULL; - gsize best_image_size = 0; - guint count = 0; - - g_assert (ret_avatar != NULL); - g_assert (ret_mime_type != NULL); - - req = get_requirements (self); - if (req == NULL) - { - DEBUG ("Avatar requirements not ready"); - return FALSE; - } - - /* Smaller is the factor, smaller will be the image. - * 0 is an empty image, 1 is the full size. */ - min_factor = 0; - max_factor = 1; - factor = 1; - - /* Check if we need to convert to another image format */ - if (avatar_chooser_need_mime_type_conversion (mime_type, - req->supported_mime_types, &new_format_name, &new_mime_type)) - { - DEBUG ("Format conversion needed, we'll use mime type '%s' " - "and format name '%s'. Current mime type is '%s'", - new_mime_type, new_format_name, mime_type); - needs_conversion = TRUE; - } - - /* If there is no format we can use, report error to the user. */ - if (new_mime_type == NULL || new_format_name == NULL) - { - avatar_chooser_error_show (self, _("Couldn't convert image"), - _("None of the accepted image formats are " - "supported on your system")); - return FALSE; - } - - /* If width or height are too big, it needs converting. */ - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - if ((req->maximum_width > 0 && width > req->maximum_width) || - (req->maximum_height > 0 && height > req->maximum_height)) - { - gdouble h_factor, v_factor; - - h_factor = (gdouble) req->maximum_width / width; - v_factor = (gdouble) req->maximum_height / height; - factor = max_factor = MIN (h_factor, v_factor); - - DEBUG ("Image dimensions (%dx%d) are too big. Max is %dx%d.", - width, height, req->maximum_width, req->maximum_height); - - needs_conversion = TRUE; - } - - /* If the data len is too big and no other conversion is needed, - * try with a lower factor. */ - if (req->maximum_bytes > 0 && avatar->len > req->maximum_bytes && - !needs_conversion) - { - DEBUG ("Image data (%u bytes) is too big " - "(max is %u bytes), conversion needed.", - avatar->len, req->maximum_bytes); - - factor = 0.5; - needs_conversion = TRUE; - } - - /* If no conversion is needed, return the avatar */ - if (!needs_conversion) - { - *ret_avatar = g_array_ref (avatar); - *ret_mime_type = g_strdup (mime_type); - return TRUE; - } - - do - { - GdkPixbuf *pixbuf_scaled = NULL; - gboolean saved; - gint new_width, new_height; - gchar *converted_image_data; - gsize converted_image_size; - GError *error = NULL; - - if (factor != 1) - { - new_width = width * factor; - new_height = height * factor; - pixbuf_scaled = gdk_pixbuf_scale_simple (pixbuf, - new_width, - new_height, - GDK_INTERP_HYPER); - } - else - { - new_width = width; - new_height = height; - pixbuf_scaled = g_object_ref (pixbuf); - } - - DEBUG ("Trying with factor %f (%dx%d) and format %s...", factor, - new_width, new_height, new_format_name); - - saved = gdk_pixbuf_save_to_buffer (pixbuf_scaled, - &converted_image_data, - &converted_image_size, - new_format_name, - &error, NULL); - g_object_unref (pixbuf_scaled); - - if (!saved) - { - g_free (new_format_name); - g_free (new_mime_type); - avatar_chooser_error_show (self, - _("Couldn't convert image"), - error ? error->message : NULL); - g_clear_error (&error); - return FALSE; - } - - DEBUG ("Produced an image data of %"G_GSIZE_FORMAT" bytes.", - converted_image_size); - - /* If the new image satisfy the req, keep it as current best */ - if (req->maximum_bytes == 0 || converted_image_size <= req->maximum_bytes) - { - g_free (best_image_data); - - best_image_data = converted_image_data; - best_image_size = converted_image_size; - - /* If this image is close enough to the optimal size, - * stop searching */ - if (req->maximum_bytes == 0 || - req->maximum_bytes - converted_image_size <= 1024) - break; - } - else - { - g_free (converted_image_data); - } - - /* Make a binary search for the bigest factor that produce - * an image data size less than max_size */ - if (converted_image_size > req->maximum_bytes) - max_factor = factor; - if (converted_image_size < req->maximum_bytes) - min_factor = factor; - factor = (min_factor + max_factor)/2; - - if ((int) (width * factor) == new_width || - (int) (height * factor) == new_height) - { - /* min_factor and max_factor are too close, so the new - * factor will produce the same image as previous - * iteration. No need to continue, we already found - * the optimal size. */ - break; - } - - /* Do 10 iterations in the worst case */ - } while (++count < 10); - - g_free (new_format_name); - - /* FIXME: there is no way to create a GArray with zero copy? */ - *ret_avatar = g_array_sized_new (FALSE, FALSE, sizeof (gchar), - best_image_size); - g_array_append_vals (*ret_avatar, best_image_data, best_image_size); - g_free (best_image_data); - - *ret_mime_type = new_mime_type; - - return TRUE; -} - -/* Take ownership of @pixbuf */ -static void -avatar_chooser_set_image (TpawAvatarChooser *self, - GArray *avatar, - gchar *mime_type, - GdkPixbuf *pixbuf, - gboolean maybe_convert) -{ - GdkPixbuf *pixbuf_view; - GtkWidget *image; - - g_assert (avatar != NULL); - g_assert (pixbuf != NULL); - - if (maybe_convert) - { - GArray *conv_avatar = NULL; - gchar *conv_mime_type = NULL; - - if (!avatar_chooser_maybe_convert_and_scale (self, - pixbuf, avatar, mime_type, &conv_avatar, &conv_mime_type)) - return; - - /* Transfer ownership */ - tp_clear_pointer (&self->priv->avatar, g_array_unref); - self->priv->avatar = conv_avatar; - - g_free (self->priv->mime_type); - self->priv->mime_type = conv_mime_type; - } - else - { - tp_clear_pointer (&self->priv->avatar, g_array_unref); - self->priv->avatar = g_array_ref (avatar); - - g_free (self->priv->mime_type); - self->priv->mime_type = g_strdup (mime_type); - } - - self->priv->changed = TRUE; - - pixbuf_view = tpaw_pixbuf_scale_down_if_necessary (pixbuf, - AVATAR_SIZE_VIEW); - image = gtk_image_new_from_pixbuf (pixbuf_view); - - gtk_button_set_image (GTK_BUTTON (self), image); - - g_object_unref (pixbuf_view); - g_object_unref (pixbuf); -} - -/* takes ownership of @data */ -static void -avatar_chooser_set_image_from_data (TpawAvatarChooser *self, - gchar *data, - gsize size) -{ - GdkPixbuf *pixbuf; - GArray *avatar; - gchar *mime_type = NULL; - - if (data == NULL) - { - avatar_chooser_clear_image (self); - return; - } - - pixbuf = tpaw_pixbuf_from_data_and_mime (data, size, &mime_type); - if (pixbuf == NULL) - { - g_free (data); - return; - } - - /* FIXME: there is no way to create a GArray with zero copy? */ - avatar = g_array_sized_new (FALSE, FALSE, sizeof (gchar), size); - g_array_append_vals (avatar, data, size); - - avatar_chooser_set_image (self, avatar, mime_type, pixbuf, TRUE); - - g_free (mime_type); - g_array_unref (avatar); - g_free (data); -} - -static void -avatar_chooser_drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint time_, - TpawAvatarChooser *self) -{ - gchar *target_type; - gboolean handled = FALSE; - - target_type = gdk_atom_name (gtk_selection_data_get_target (selection_data)); - if (!strcmp (target_type, URI_LIST_TYPE)) - { - GFile *file; - gchar *nl; - gchar *data = NULL; - gsize bytes_read; - - nl = strstr ((gchar *) gtk_selection_data_get_data (selection_data), - "\r\n"); - if (nl != NULL) - { - gchar *uri; - - uri = g_strndup ( - (gchar *) gtk_selection_data_get_data (selection_data), - nl - (gchar *) gtk_selection_data_get_data (selection_data)); - - file = g_file_new_for_uri (uri); - g_free (uri); - } - else - { - file = g_file_new_for_uri ((gchar *) gtk_selection_data_get_data ( - selection_data)); - } - - handled = g_file_load_contents (file, NULL, &data, &bytes_read, - NULL, NULL); - - if (handled) - { - /* pass data to the avatar_chooser_set_image_from_data */ - avatar_chooser_set_image_from_data (self, data, bytes_read); - } - - g_object_unref (file); - } - - gtk_drag_finish (context, handled, FALSE, time_); -} - -static void -avatar_chooser_update_preview_cb (GtkFileChooser *file_chooser, - TpawAvatarChooser *self) -{ - gchar *filename; - - filename = gtk_file_chooser_get_preview_filename (file_chooser); - - if (filename != NULL) - { - GtkWidget *image; - GdkPixbuf *pixbuf = NULL; - GdkPixbuf *scaled_pixbuf; - - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - - image = gtk_file_chooser_get_preview_widget (file_chooser); - - if (pixbuf != NULL) - { - scaled_pixbuf = tpaw_pixbuf_scale_down_if_necessary (pixbuf, - AVATAR_SIZE_SAVE); - - gtk_image_set_from_pixbuf (GTK_IMAGE (image), scaled_pixbuf); - g_object_unref (scaled_pixbuf); - g_object_unref (pixbuf); - } - else - { - gtk_image_set_from_stock (GTK_IMAGE (image), - "dialog-question", - GTK_ICON_SIZE_DIALOG); - } - - g_free (filename); - } - - gtk_file_chooser_set_preview_widget_active (file_chooser, TRUE); -} - -static void -avatar_chooser_set_image_from_file (TpawAvatarChooser *self, - const gchar *filename) -{ - gchar *image_data = NULL; - gsize image_size = 0; - GError *error = NULL; - - if (!g_file_get_contents (filename, &image_data, &image_size, &error)) - { - DEBUG ("Failed to load image from '%s': %s", filename, - error ? error->message : "No error given"); - - g_clear_error (&error); - return; - } - - /* pass image_data to the avatar_chooser_set_image_from_data */ - avatar_chooser_set_image_from_data (self, image_data, image_size); -} - -#ifdef HAVE_CHEESE -static void -avatar_chooser_set_avatar_from_pixbuf (TpawAvatarChooser *self, - GdkPixbuf *pb) -{ - gsize size; - gchar *buf; - GArray *avatar; - GError *error = NULL; - - if (!gdk_pixbuf_save_to_buffer (pb, &buf, &size, "png", &error, NULL)) - { - avatar_chooser_error_show (self, - _("Couldn't save picture to file"), - error ? error->message : NULL); - g_clear_error (&error); - return; - } - - /* FIXME: there is no way to create a GArray with zero copy? */ - avatar = g_array_sized_new (FALSE, FALSE, sizeof (gchar), size); - g_array_append_vals (avatar, buf, size); - - avatar_chooser_set_image (self, avatar, "image/png", pb, TRUE); - - g_free (buf); - g_array_unref (avatar); -} - -static gboolean -destroy_chooser (GtkWidget *self) -{ - gtk_widget_destroy (self); - return FALSE; -} - -static void -webcam_response_cb (GtkDialog *dialog, - int response, - TpawAvatarChooser *self) -{ - if (response == GTK_RESPONSE_ACCEPT) - { - GdkPixbuf *pb; - CheeseAvatarChooser *cheese_chooser; - - cheese_chooser = CHEESE_AVATAR_CHOOSER (dialog); - pb = cheese_avatar_chooser_get_picture (cheese_chooser); - avatar_chooser_set_avatar_from_pixbuf (self, pb); - } - - if (response != GTK_RESPONSE_DELETE_EVENT && - response != GTK_RESPONSE_NONE) - g_idle_add ((GSourceFunc) destroy_chooser, dialog); -} - -static void -choose_avatar_from_webcam (GtkWidget *widget, - TpawAvatarChooser *self) -{ - GtkWidget *window; - - window = cheese_avatar_chooser_new (); - - gtk_window_set_transient_for (GTK_WINDOW (window), - GTK_WINDOW (tpaw_get_toplevel_window (GTK_WIDGET (self)))); - gtk_window_set_modal (GTK_WINDOW (window), TRUE); - g_signal_connect (G_OBJECT (window), "response", - G_CALLBACK (webcam_response_cb), self); - gtk_widget_show (window); -} -#endif /* HAVE_CHEESE */ - -static void -avatar_chooser_response_cb (GtkWidget *widget, - gint response, - TpawAvatarChooser *self) -{ - self->priv->chooser_dialog = NULL; - - if (response == TPAW_AVATAR_CHOOSER_RESPONSE_FILE) - { - gchar *filename; - gchar *path; - - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)); - avatar_chooser_set_image_from_file (self, filename); - g_free (filename); - - path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget)); - if (path != NULL) - { - g_settings_set_string (self->priv->gsettings_ui, - TPAW_PREFS_UI_AVATAR_DIRECTORY, - path); - - g_free (path); - } - } - else if (response == TPAW_AVATAR_CHOOSER_RESPONSE_NO_IMAGE) - { - /* This corresponds to "No Image", not to "Cancel" */ - avatar_chooser_clear_image (self); - } - #ifdef HAVE_CHEESE - else if (response == TPAW_AVATAR_CHOOSER_RESPONSE_WEBCAM) - { - /* This corresponds to "Camera Picture" */ - choose_avatar_from_webcam (widget, self); - } - #endif - - gtk_widget_destroy (widget); -} - -static void -avatar_chooser_clicked_cb (GtkWidget *button, - TpawAvatarChooser *self) -{ - GtkFileChooser *chooser_dialog; - GtkWidget *image; - gchar *saved_dir = NULL; - const gchar *default_dir = DEFAULT_DIR; - const gchar *pics_dir; - GtkFileFilter *filter; -#ifdef HAVE_CHEESE - GtkWidget *picture_button; - TpawCameraMonitor *monitor; -#endif - - if (self->priv->chooser_dialog != NULL) - { - gtk_window_present (GTK_WINDOW (self->priv->chooser_dialog)); - return; - } - - self->priv->chooser_dialog = GTK_FILE_CHOOSER ( - gtk_file_chooser_dialog_new (_("Select Your Avatar Image"), - tpaw_get_toplevel_window (GTK_WIDGET (self)), - GTK_FILE_CHOOSER_ACTION_OPEN, - NULL, NULL)); - -#ifdef HAVE_CHEESE - picture_button = gtk_dialog_add_button ( - GTK_DIALOG (self->priv->chooser_dialog), - _("Take a picture..."), TPAW_AVATAR_CHOOSER_RESPONSE_WEBCAM); - - /* Button is sensitive only if there is one camera connected */ - monitor = tpaw_camera_monitor_dup_singleton (); - - g_object_set_data_full (G_OBJECT (picture_button), - "monitor", monitor, g_object_unref); - - g_object_bind_property (monitor, "available", picture_button, "sensitive", - G_BINDING_SYNC_CREATE); -#endif - - gtk_dialog_add_buttons (GTK_DIALOG (self->priv->chooser_dialog), - _("No Image"), TPAW_AVATAR_CHOOSER_RESPONSE_NO_IMAGE, - GTK_STOCK_CANCEL, TPAW_AVATAR_CHOOSER_RESPONSE_CANCEL, - GTK_STOCK_OPEN, TPAW_AVATAR_CHOOSER_RESPONSE_FILE, - NULL); - - chooser_dialog = self->priv->chooser_dialog; - gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser_dialog), TRUE); - - /* Get special dirs */ - saved_dir = g_settings_get_string (self->priv->gsettings_ui, - TPAW_PREFS_UI_AVATAR_DIRECTORY); - - if (saved_dir != NULL && - !g_file_test (saved_dir, G_FILE_TEST_IS_DIR)) - { - g_free (saved_dir); - saved_dir = NULL; - } - - if (!g_file_test (default_dir, G_FILE_TEST_IS_DIR)) - default_dir = NULL; - - pics_dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); - if (pics_dir != NULL && !g_file_test (pics_dir, G_FILE_TEST_IS_DIR)) - pics_dir = NULL; - - /* Set current dir to the last one or to DEFAULT_DIR or to home */ - if (saved_dir != NULL) - gtk_file_chooser_set_current_folder (chooser_dialog, saved_dir); - else if (pics_dir != NULL) - gtk_file_chooser_set_current_folder (chooser_dialog, pics_dir); - else if (default_dir != NULL) - gtk_file_chooser_set_current_folder (chooser_dialog, default_dir); - else - gtk_file_chooser_set_current_folder (chooser_dialog, g_get_home_dir ()); - - /* Add shortcuts to special dirs */ - if (saved_dir) - gtk_file_chooser_add_shortcut_folder (chooser_dialog, saved_dir, NULL); - else if (pics_dir) - gtk_file_chooser_add_shortcut_folder (chooser_dialog, pics_dir, NULL); - - if (default_dir != NULL) - gtk_file_chooser_add_shortcut_folder (chooser_dialog, default_dir, NULL); - - /* Setup preview image */ - image = gtk_image_new (); - gtk_file_chooser_set_preview_widget (chooser_dialog, image); - gtk_widget_set_size_request (image, AVATAR_SIZE_SAVE, AVATAR_SIZE_SAVE); - gtk_widget_show (image); - gtk_file_chooser_set_use_preview_label (chooser_dialog, FALSE); - g_signal_connect (chooser_dialog, "update-preview", - G_CALLBACK (avatar_chooser_update_preview_cb), - self); - - /* Setup filers */ - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("Images")); - gtk_file_filter_add_pixbuf_formats (filter); - gtk_file_chooser_add_filter (chooser_dialog, filter); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("All Files")); - gtk_file_filter_add_pattern (filter, "*"); - gtk_file_chooser_add_filter (chooser_dialog, filter); - - /* Setup response */ - gtk_dialog_set_default_response (GTK_DIALOG (chooser_dialog), - TPAW_AVATAR_CHOOSER_RESPONSE_FILE); - - g_signal_connect (chooser_dialog, "response", - G_CALLBACK (avatar_chooser_response_cb), - self); - - gtk_widget_show (GTK_WIDGET (chooser_dialog)); - - g_free (saved_dir); -} - -static void -tpaw_avatar_chooser_init (TpawAvatarChooser *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_AVATAR_CHOOSER, TpawAvatarChooserPrivate); - - gtk_drag_dest_set (GTK_WIDGET (self), - GTK_DEST_DEFAULT_ALL, - drop_types, - G_N_ELEMENTS (drop_types), - GDK_ACTION_COPY); - - self->priv->gsettings_ui = g_settings_new (TPAW_PREFS_UI_SCHEMA); - - g_signal_connect (self, "drag-motion", - G_CALLBACK (avatar_chooser_drag_motion_cb), - self); - g_signal_connect (self, "drag-drop", - G_CALLBACK (avatar_chooser_drag_drop_cb), - self); - g_signal_connect (self, "drag-data-received", - G_CALLBACK (avatar_chooser_drag_data_received_cb), - self); - g_signal_connect (self, "clicked", - G_CALLBACK (avatar_chooser_clicked_cb), - self); - - avatar_chooser_clear_image (self); -} - -/** - * tpaw_avatar_chooser_new: - * @account: a #TpAccount - * - * Creates a new #TpawAvatarChooser. - * - * Return value: a new #TpawAvatarChooser - */ -GtkWidget * -tpaw_avatar_chooser_new (TpAccount *account) -{ - g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); - - return g_object_new (TPAW_TYPE_AVATAR_CHOOSER, - "account", account, - NULL); -} - -static void -set_avatar_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GSimpleAsyncResult *my_result = user_data; - GError *error = NULL; - - if (!tp_account_set_avatar_finish (TP_ACCOUNT (source), result, &error)) - g_simple_async_result_take_error (my_result, error); - - g_simple_async_result_complete (my_result); - g_object_unref (my_result); -} - -void -tpaw_avatar_chooser_apply_async (TpawAvatarChooser *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - g_return_if_fail (TPAW_IS_AVATAR_CHOOSER (self)); - - result = g_simple_async_result_new ((GObject *) self, callback, user_data, - tpaw_avatar_chooser_apply_async); - - if (!self->priv->changed) - { - g_simple_async_result_complete_in_idle (result); - g_object_unref (result); - return; - } - - self->priv->changed = FALSE; - - DEBUG ("%s Account.Avatar on %s", self->priv->avatar != NULL ? "Set": "Clear", - tp_proxy_get_object_path (self->priv->account)); - - tp_account_set_avatar_async (self->priv->account, - self->priv->avatar != NULL ? (guchar *) self->priv->avatar->data : NULL, - self->priv->avatar != NULL ? self->priv->avatar->len : 0, - self->priv->mime_type, set_avatar_cb, result); -} - -gboolean -tpaw_avatar_chooser_apply_finish (TpawAvatarChooser *self, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_void (self, tpaw_avatar_chooser_apply_async); -} diff --git a/tp-account-widgets/tpaw-avatar-chooser.h b/tp-account-widgets/tpaw-avatar-chooser.h deleted file mode 100644 index 0aadef154..000000000 --- a/tp-account-widgets/tpaw-avatar-chooser.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2006-2007 Imendio AB. - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Based on Novell's e-image-chooser. - * Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __TPAW_AVATAR_CHOOSER_H__ -#define __TPAW_AVATAR_CHOOSER_H__ - -#include <gio/gio.h> -#include <gtk/gtk.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -#define TPAW_TYPE_AVATAR_CHOOSER (tpaw_avatar_chooser_get_type ()) -#define TPAW_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPAW_TYPE_AVATAR_CHOOSER, TpawAvatarChooser)) -#define TPAW_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TPAW_TYPE_AVATAR_CHOOSER, TpawAvatarChooserClass)) -#define TPAW_IS_AVATAR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPAW_TYPE_AVATAR_CHOOSER)) -#define TPAW_IS_AVATAR_CHOOSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), TPAW_TYPE_AVATAR_CHOOSER)) - -typedef struct _TpawAvatarChooser TpawAvatarChooser; -typedef struct _TpawAvatarChooserClass TpawAvatarChooserClass; -typedef struct _TpawAvatarChooserPrivate TpawAvatarChooserPrivate; - -struct _TpawAvatarChooser -{ - GtkButton parent; - - /*<private>*/ - TpawAvatarChooserPrivate *priv; -}; - -struct _TpawAvatarChooserClass -{ - GtkButtonClass parent_class; -}; - -GType tpaw_avatar_chooser_get_type (void); - -GtkWidget *tpaw_avatar_chooser_new (TpAccount *account); - -void tpaw_avatar_chooser_apply_async (TpawAvatarChooser *self, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean tpaw_avatar_chooser_apply_finish (TpawAvatarChooser *self, - GAsyncResult *result, - GError **error); - -#endif /* __TPAW_AVATAR_CHOOSER_H__ */ diff --git a/tp-account-widgets/tpaw-builder.c b/tp-account-widgets/tpaw-builder.c deleted file mode 100644 index 98b1dbe19..000000000 --- a/tp-account-widgets/tpaw-builder.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2013 Collabora Ltd. - * - * Authors: Marco Barisione <marco.barisione@collabora.co.uk> - * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-builder.h" - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -enum _BuilderSource -{ - BUILDER_SOURCE_FILE, - BUILDER_SOURCE_RESOURCE -}; - -static GtkBuilder * -builder_get_valist (const gchar *sourcename, - enum _BuilderSource source, - const gchar *first_object, - va_list args) -{ - GtkBuilder *gui; - const gchar *name; - GObject **object_ptr; - GError *error = NULL; - gboolean success; - - DEBUG ("Loading %s '%s'", source == BUILDER_SOURCE_FILE ? "file" : "resource", sourcename); - - gui = gtk_builder_new (); - gtk_builder_set_translation_domain (gui, GETTEXT_PACKAGE); - - switch (source) - { - case BUILDER_SOURCE_FILE: - success = gtk_builder_add_from_file (gui, sourcename, &error); - break; - case BUILDER_SOURCE_RESOURCE: - success = gtk_builder_add_from_resource (gui, sourcename, &error); - break; - default: - g_assert_not_reached (); - } - - if (!success) - { - g_critical ("GtkBuilder Error (%s): %s", - sourcename, error->message); - - g_clear_error (&error); - g_object_unref (gui); - - /* we need to iterate and set all of the pointers to NULL */ - for (name = first_object; name; name = va_arg (args, const gchar *)) - { - object_ptr = va_arg (args, GObject**); - - *object_ptr = NULL; - } - - return NULL; - } - - for (name = first_object; name; name = va_arg (args, const gchar *)) - { - object_ptr = va_arg (args, GObject**); - - *object_ptr = gtk_builder_get_object (gui, name); - - if (!*object_ptr) - { - g_warning ("File is missing object '%s'.", name); - continue; - } - } - - return gui; -} - -GtkBuilder * -tpaw_builder_get_file (const gchar *filename, - const gchar *first_object, - ...) -{ - GtkBuilder *gui; - va_list args; - - va_start (args, first_object); - gui = builder_get_valist (filename, BUILDER_SOURCE_FILE, first_object, args); - va_end (args); - - return gui; -} - -GtkBuilder * -tpaw_builder_get_resource (const gchar *resourcename, - const gchar *first_object, - ...) -{ - GtkBuilder *gui; - va_list args; - - va_start (args, first_object); - gui = builder_get_valist (resourcename, BUILDER_SOURCE_RESOURCE, first_object, args); - va_end (args); - - return gui; -} - -void -tpaw_builder_connect (GtkBuilder *gui, - gpointer user_data, - const gchar *first_object, - ...) -{ - va_list args; - const gchar *name; - const gchar *sig; - GObject *object; - GCallback callback; - - va_start (args, first_object); - for (name = first_object; name; name = va_arg (args, const gchar *)) - { - sig = va_arg (args, const gchar *); - callback = va_arg (args, GCallback); - - object = gtk_builder_get_object (gui, name); - if (!object) - { - g_warning ("File is missing object '%s'.", name); - continue; - } - - g_signal_connect (object, sig, callback, user_data); - } - - va_end (args); -} - -GtkWidget * -tpaw_builder_unref_and_keep_widget (GtkBuilder *gui, - GtkWidget *widget) -{ - /* On construction gui sinks the initial reference to widget. When gui - * is finalized it will drop its ref to widget. We take our own ref to - * prevent widget being finalised. The widget is forced to have a - * floating reference, like when it was initially unowned so that it can - * be used like any other GtkWidget. */ - - g_object_ref (widget); - g_object_force_floating (G_OBJECT (widget)); - g_object_unref (gui); - - return widget; -} diff --git a/tp-account-widgets/tpaw-builder.h b/tp-account-widgets/tpaw-builder.h deleted file mode 100644 index 57134ce12..000000000 --- a/tp-account-widgets/tpaw-builder.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2013 Collabora Ltd. - * - * Authors: Marco Barisione <marco.barisione@collabora.co.uk> - * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_BUILDER_H__ -#define __TPAW_BUILDER_H__ - -#include <glib.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -GtkBuilder * tpaw_builder_get_file (const gchar *filename, - const gchar *first_object, - ...); -GtkBuilder * tpaw_builder_get_resource (const gchar *resourcename, - const gchar *first_object, - ...); -void tpaw_builder_connect (GtkBuilder *gui, - gpointer user_data, - const gchar *first_object, - ...); -GtkWidget * tpaw_builder_unref_and_keep_widget (GtkBuilder *gui, - GtkWidget *root); - -G_END_DECLS - -#endif /* __TPAW_BUILDER_H__ */ diff --git a/tp-account-widgets/tpaw-calendar-button.c b/tp-account-widgets/tpaw-calendar-button.c deleted file mode 100644 index e0ab9be4b..000000000 --- a/tp-account-widgets/tpaw-calendar-button.c +++ /dev/null @@ -1,273 +0,0 @@ -/* - * tpaw-calendar-button.c - Source for TpawCalendarButton - * Copyright (C) 2012 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-calendar-button.h" - -#include <glib/gi18n-lib.h> - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -G_DEFINE_TYPE (TpawCalendarButton, tpaw_calendar_button, GTK_TYPE_BOX) - -/* signal enum */ -enum { - DATE_CHANGED, - LAST_SIGNAL, -}; - -static guint signals[LAST_SIGNAL] = {0}; - -struct _TpawCalendarButtonPriv { - GDate *date; - - GtkWidget *button_date; - GtkWidget *button_clear; - GtkWidget *dialog; - GtkWidget *calendar; -}; - -static void -tpaw_calendar_button_finalize (GObject *object) -{ - TpawCalendarButton *self = (TpawCalendarButton *) object; - - tp_clear_pointer (&self->priv->date, g_date_free); - - G_OBJECT_CLASS (tpaw_calendar_button_parent_class)->finalize (object); -} - -static void -update_label (TpawCalendarButton *self) -{ - if (self->priv->date == NULL) - { - gtk_button_set_label (GTK_BUTTON (self->priv->button_date), - _("Select...")); - } - else - { - gchar buffer[128]; - - g_date_strftime (buffer, 128, "%e %b %Y", self->priv->date); - gtk_button_set_label (GTK_BUTTON (self->priv->button_date), buffer); - } -} - -static void -tpaw_calendar_button_constructed (GObject *object) -{ - TpawCalendarButton *self = (TpawCalendarButton *) object; - - G_OBJECT_CLASS (tpaw_calendar_button_parent_class)->constructed ( - object); - - update_label (self); -} - -static void -dialog_response (GtkDialog *dialog, - gint response, - TpawCalendarButton *self) -{ - GDate *date; - guint year, month, day; - - if (response != GTK_RESPONSE_OK) - goto out; - - gtk_calendar_get_date (GTK_CALENDAR (self->priv->calendar), - &year, &month, &day); - date = g_date_new_dmy (day, month + 1, year); - - tpaw_calendar_button_set_date (self, date); - - g_date_free (date); - -out: - gtk_widget_hide (GTK_WIDGET (dialog)); -} - -static gboolean -dialog_destroy (GtkWidget *widget, - TpawCalendarButton *self) -{ - self->priv->dialog = NULL; - self->priv->calendar = NULL; - - return FALSE; -} - -static void -update_calendar (TpawCalendarButton *self) -{ - if (self->priv->calendar == NULL) - return; - - gtk_calendar_clear_marks (GTK_CALENDAR (self->priv->calendar)); - - if (self->priv->date == NULL) - return; - - gtk_calendar_select_day (GTK_CALENDAR (self->priv->calendar), - g_date_get_day (self->priv->date)); - gtk_calendar_select_month (GTK_CALENDAR (self->priv->calendar), - g_date_get_month (self->priv->date) - 1, - g_date_get_year (self->priv->date)); - gtk_calendar_mark_day (GTK_CALENDAR (self->priv->calendar), - g_date_get_day (self->priv->date)); -} - -static void -tpaw_calendar_button_date_clicked (GtkButton *button, - TpawCalendarButton *self) -{ - if (self->priv->dialog == NULL) - { - GtkWidget *parent, *content; - - parent = gtk_widget_get_toplevel (GTK_WIDGET (button)); - - self->priv->dialog = gtk_dialog_new_with_buttons (NULL, - GTK_WINDOW (parent), GTK_DIALOG_MODAL, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - _("_Select"), GTK_RESPONSE_OK, - NULL); - - gtk_window_set_transient_for (GTK_WINDOW (self->priv->dialog), - GTK_WINDOW (parent)); - - self->priv->calendar = gtk_calendar_new (); - - update_calendar (self); - - content = gtk_dialog_get_content_area (GTK_DIALOG (self->priv->dialog)); - - gtk_box_pack_start (GTK_BOX (content), self->priv->calendar, TRUE, TRUE, - 6); - gtk_widget_show (self->priv->calendar); - - g_signal_connect (self->priv->dialog, "response", - G_CALLBACK (dialog_response), self); - g_signal_connect (self->priv->dialog, "destroy", - G_CALLBACK (dialog_destroy), self); - } - - gtk_window_present (GTK_WINDOW (self->priv->dialog)); -} - -static void -tpaw_calendar_button_clear_clicked (GtkButton *button, - TpawCalendarButton *self) -{ - tpaw_calendar_button_set_date (self, NULL); -} - -static void -tpaw_calendar_button_init (TpawCalendarButton *self) -{ - GtkWidget *image; - GtkStyleContext *context; - - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_CALENDAR_BUTTON, TpawCalendarButtonPriv); - - context = gtk_widget_get_style_context (GTK_WIDGET (self)); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED); - - /* Date */ - self->priv->button_date = gtk_button_new (); - - g_signal_connect (self->priv->button_date, "clicked", - G_CALLBACK (tpaw_calendar_button_date_clicked), self); - - gtk_button_set_alignment (GTK_BUTTON (self->priv->button_date), 0, 0.5); - - gtk_box_pack_start (GTK_BOX (self), self->priv->button_date, TRUE, TRUE, 0); - gtk_widget_show (self->priv->button_date); - - /* Clear */ - self->priv->button_clear = gtk_button_new (); - - image = gtk_image_new_from_stock (GTK_STOCK_CLEAR, - GTK_ICON_SIZE_MENU); - gtk_button_set_image (GTK_BUTTON (self->priv->button_clear), image); - gtk_widget_show (image); - - g_signal_connect (self->priv->button_clear, "clicked", - G_CALLBACK (tpaw_calendar_button_clear_clicked), self); - - gtk_box_pack_start (GTK_BOX (self), self->priv->button_clear, - FALSE, FALSE, 0); - gtk_widget_show (self->priv->button_clear); -} - -static void -tpaw_calendar_button_class_init (TpawCalendarButtonClass *klass) -{ - GObjectClass *oclass = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (TpawCalendarButtonPriv)); - - oclass->finalize = tpaw_calendar_button_finalize; - oclass->constructed = tpaw_calendar_button_constructed; - - signals[DATE_CHANGED] = g_signal_new ("date-changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, 0, - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, G_TYPE_DATE); -} - -GtkWidget * -tpaw_calendar_button_new (void) -{ - return g_object_new (TPAW_TYPE_CALENDAR_BUTTON, - "orientation", GTK_ORIENTATION_HORIZONTAL, - NULL); -} - -GDate * -tpaw_calendar_button_get_date (TpawCalendarButton *self) -{ - return self->priv->date; -} - -void -tpaw_calendar_button_set_date (TpawCalendarButton *self, - GDate *date) -{ - if (date == self->priv->date) - return; - - tp_clear_pointer (&self->priv->date, g_date_free); - - if (date != NULL) - { - /* There is no g_date_copy()... */ - self->priv->date = g_date_new_dmy (date->day, date->month, date->year); - } - - update_label (self); - update_calendar (self); - - g_signal_emit (self, signals[DATE_CHANGED], 0, self->priv->date); -} diff --git a/tp-account-widgets/tpaw-calendar-button.h b/tp-account-widgets/tpaw-calendar-button.h deleted file mode 100644 index 38f23224e..000000000 --- a/tp-account-widgets/tpaw-calendar-button.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * tpaw-calendar-button.h - Header for TpawCalendarButton - * Copyright (C) 2012 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_CALENDAR_BUTTON_H__ -#define __TPAW_CALENDAR_BUTTON_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -typedef struct _TpawCalendarButton TpawCalendarButton; -typedef struct _TpawCalendarButtonClass TpawCalendarButtonClass; -typedef struct _TpawCalendarButtonPriv TpawCalendarButtonPriv; - -struct _TpawCalendarButtonClass { - GtkBoxClass parent_class; -}; - -struct _TpawCalendarButton { - GtkBox parent; - TpawCalendarButtonPriv *priv; -}; - -GType tpaw_calendar_button_get_type (void); - -#define TPAW_TYPE_CALENDAR_BUTTON \ - (tpaw_calendar_button_get_type ()) -#define TPAW_CALENDAR_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TPAW_TYPE_CALENDAR_BUTTON, \ - TpawCalendarButton)) -#define TPAW_CALENDAR_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TPAW_TYPE_CALENDAR_BUTTON, \ - TpawCalendarButtonClass)) -#define TPAW_IS_CALENDAR_BUTTON(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TPAW_TYPE_CALENDAR_BUTTON)) -#define TPAW_IS_CALENDAR_BUTTON_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TPAW_TYPE_CALENDAR_BUTTON)) -#define TPAW_CALENDAR_BUTTON_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TPAW_TYPE_CALENDAR_BUTTON, \ - TpawCalendarButtonClass)) - -GtkWidget * tpaw_calendar_button_new (void); - -GDate * tpaw_calendar_button_get_date (TpawCalendarButton *self); - -void tpaw_calendar_button_set_date (TpawCalendarButton *self, - GDate *date); - -G_END_DECLS - -#endif /* #ifndef __TPAW_CALENDAR_BUTTON_H__*/ diff --git a/tp-account-widgets/tpaw-camera-monitor.c b/tp-account-widgets/tpaw-camera-monitor.c deleted file mode 100644 index 4c918d7a0..000000000 --- a/tp-account-widgets/tpaw-camera-monitor.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright (C) 2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> - */ - -#include "config.h" -#include "tpaw-camera-monitor.h" - -#include <tp-account-widgets/cheese-camera-device-monitor.h> - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -struct _TpawCameraMonitorPrivate -{ - TpawCameraDeviceMonitor *tpaw_monitor; - GQueue *cameras; - gint num_cameras; -}; - -enum -{ - PROP_0, - PROP_AVAILABLE, -}; - -enum -{ - CAMERA_ADDED, - CAMERA_REMOVED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -G_DEFINE_TYPE (TpawCameraMonitor, tpaw_camera_monitor, G_TYPE_OBJECT); - -static TpawCameraMonitor *manager_singleton = NULL; - -static TpawCamera * -tpaw_camera_new (const gchar *id, - const gchar *device, - const gchar *name) -{ - TpawCamera *camera = g_slice_new (TpawCamera); - - camera->id = g_strdup (id); - camera->device = g_strdup (device); - camera->name = g_strdup (name); - - return camera; -} - -static TpawCamera * -tpaw_camera_copy (TpawCamera *camera) -{ - return tpaw_camera_new (camera->id, camera->device, camera->name); -} - -static void -tpaw_camera_free (TpawCamera *camera) -{ - g_free (camera->id); - g_free (camera->device); - g_free (camera->name); - - g_slice_free (TpawCamera, camera); -} - -G_DEFINE_BOXED_TYPE (TpawCamera, tpaw_camera, - tpaw_camera_copy, tpaw_camera_free) - -static gint -tpaw_camera_find (gconstpointer a, - gconstpointer b) -{ - const TpawCamera *camera = a; - const gchar *id = b; - - return g_strcmp0 (camera->id, id); -} - -static void -tpaw_camera_monitor_free_camera_foreach (gpointer data, - gpointer user_data) -{ - tpaw_camera_free (data); -} - -static void -on_camera_added (TpawCameraDeviceMonitor *device, - gchar *id, - gchar *filename, - gchar *product_name, - gint api_version, - TpawCameraMonitor *self) -{ - TpawCamera *camera; - - if (self->priv->cameras == NULL) - return; - - camera = tpaw_camera_new (id, filename, product_name); - - g_queue_push_tail (self->priv->cameras, camera); - - self->priv->num_cameras++; - - if (self->priv->num_cameras == 1) - g_object_notify (G_OBJECT (self), "available"); - - g_signal_emit (self, signals[CAMERA_ADDED], 0, camera); -} - -static void -on_camera_removed (TpawCameraDeviceMonitor *device, - gchar *id, - TpawCameraMonitor *self) -{ - TpawCamera *camera; - GList *l; - - if (self->priv->cameras == NULL) - return; - - l = g_queue_find_custom (self->priv->cameras, id, tpaw_camera_find); - - g_return_if_fail (l != NULL); - - camera = l->data; - - g_queue_delete_link (self->priv->cameras, l); - - self->priv->num_cameras--; - - if (self->priv->num_cameras == 0) - g_object_notify (G_OBJECT (self), "available"); - - g_signal_emit (self, signals[CAMERA_REMOVED], 0, camera); - - tpaw_camera_free (camera); -} - -const GList * -tpaw_camera_monitor_get_cameras (TpawCameraMonitor *self) -{ - if (self->priv->cameras != NULL) - return self->priv->cameras->head; - else - return NULL; -} - -static void -tpaw_camera_monitor_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawCameraMonitor *self = (TpawCameraMonitor *) object; - - switch (prop_id) - { - case PROP_AVAILABLE: - g_value_set_boolean (value, self->priv->num_cameras > 0); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_camera_monitor_dispose (GObject *object) -{ - TpawCameraMonitor *self = TPAW_CAMERA_MONITOR (object); - - tp_clear_object (&self->priv->tpaw_monitor); - - g_queue_foreach (self->priv->cameras, - tpaw_camera_monitor_free_camera_foreach, NULL); - tp_clear_pointer (&self->priv->cameras, g_queue_free); - - G_OBJECT_CLASS (tpaw_camera_monitor_parent_class)->dispose (object); -} - -static void -tpaw_camera_monitor_constructed (GObject *object) -{ - TpawCameraMonitor *self = (TpawCameraMonitor *) object; - - G_OBJECT_CLASS (tpaw_camera_monitor_parent_class)->constructed (object); - - tpaw_camera_device_monitor_coldplug (self->priv->tpaw_monitor); -} - -static void -tpaw_camera_monitor_class_init (TpawCameraMonitorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = tpaw_camera_monitor_dispose; - object_class->constructed = tpaw_camera_monitor_constructed; - object_class->get_property = tpaw_camera_monitor_get_property; - - g_object_class_install_property (object_class, PROP_AVAILABLE, - g_param_spec_boolean ("available", "Available", - "Camera available", TRUE, G_PARAM_READABLE)); - - signals[CAMERA_ADDED] = - g_signal_new ("added", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, TPAW_TYPE_CAMERA); - - signals[CAMERA_REMOVED] = - g_signal_new ("removed", G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 1, TPAW_TYPE_CAMERA); - - g_type_class_add_private (object_class, - sizeof (TpawCameraMonitorPrivate)); -} - -static void -tpaw_camera_monitor_init (TpawCameraMonitor *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_CAMERA_MONITOR, TpawCameraMonitorPrivate); - - self->priv->cameras = g_queue_new (); - - self->priv->tpaw_monitor = tpaw_camera_device_monitor_new (); - - g_signal_connect (self->priv->tpaw_monitor, "added", - G_CALLBACK (on_camera_added), self); - g_signal_connect (self->priv->tpaw_monitor, "removed", - G_CALLBACK (on_camera_removed), self); - -#ifndef HAVE_UDEV - /* No udev, assume there are cameras present */ - self->priv->num_cameras = 1; -#endif -} - -TpawCameraMonitor * -tpaw_camera_monitor_dup_singleton (void) -{ - GObject *retval; - - if (manager_singleton) - { - retval = g_object_ref (manager_singleton); - } - else - { - retval = g_object_new (TPAW_TYPE_CAMERA_MONITOR, NULL); - - manager_singleton = TPAW_CAMERA_MONITOR (retval); - g_object_add_weak_pointer (retval, (gpointer) &manager_singleton); - } - - return TPAW_CAMERA_MONITOR (retval); -} - -TpawCameraMonitor * -tpaw_camera_monitor_new (void) -{ - return TPAW_CAMERA_MONITOR ( - g_object_new (TPAW_TYPE_CAMERA_MONITOR, NULL)); -} - -gboolean tpaw_camera_monitor_get_available (TpawCameraMonitor *self) -{ - g_return_val_if_fail (TPAW_IS_CAMERA_MONITOR (self), FALSE); - - return self->priv->num_cameras > 0; -} diff --git a/tp-account-widgets/tpaw-camera-monitor.h b/tp-account-widgets/tpaw-camera-monitor.h deleted file mode 100644 index 773e19cea..000000000 --- a/tp-account-widgets/tpaw-camera-monitor.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Emilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk> - */ - -#ifndef __TPAW_CAMERA_MONITOR_H__ -#define __TPAW_CAMERA_MONITOR_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS -#define TPAW_TYPE_CAMERA_MONITOR (tpaw_camera_monitor_get_type ()) -#define TPAW_CAMERA_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_CAMERA_MONITOR, TpawCameraMonitor)) -#define TPAW_CAMERA_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TPAW_TYPE_CAMERA_MONITOR, TpawCameraMonitorClass)) -#define TPAW_IS_CAMERA_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_CAMERA_MONITOR)) -#define TPAW_IS_CAMERA_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_CAMERA_MONITOR)) -#define TPAW_CAMERA_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_CAMERA_MONITOR, TpawCameraMonitorClass)) - -typedef struct _TpawCameraMonitor TpawCameraMonitor; -typedef struct _TpawCameraMonitorClass TpawCameraMonitorClass; -typedef struct _TpawCameraMonitorPrivate TpawCameraMonitorPrivate; - -struct _TpawCameraMonitor -{ - GObject parent; - TpawCameraMonitorPrivate *priv; -}; - -struct _TpawCameraMonitorClass -{ - GObjectClass parent_class; -}; - -typedef struct -{ - gchar *id; - gchar *device; - gchar *name; -} TpawCamera; - -#define TPAW_TYPE_CAMERA (tpaw_camera_get_type ()) -GType tpaw_camera_get_type (void) G_GNUC_CONST; - -GType tpaw_camera_monitor_get_type (void) G_GNUC_CONST; - -TpawCameraMonitor *tpaw_camera_monitor_dup_singleton (void); -TpawCameraMonitor *tpaw_camera_monitor_new (void); - -gboolean tpaw_camera_monitor_get_available (TpawCameraMonitor *self); - -const GList * tpaw_camera_monitor_get_cameras (TpawCameraMonitor *self); - -G_END_DECLS -#endif /* __TPAW_CAMERA_MONITOR_H__ */ diff --git a/tp-account-widgets/tpaw-connection-managers.c b/tp-account-widgets/tpaw-connection-managers.c deleted file mode 100644 index d7cd8b69f..000000000 --- a/tp-account-widgets/tpaw-connection-managers.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * tpaw-connection-managers.c - Source for TpawConnectionManagers - * Copyright (C) 2009 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-connection-managers.h" - -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -static GObject *managers = NULL; - -G_DEFINE_TYPE(TpawConnectionManagers, tpaw_connection_managers, - G_TYPE_OBJECT) - -/* signal enum */ -enum -{ - UPDATED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -/* properties */ -enum { - PROP_READY = 1 -}; - -/* private structure */ -struct _TpawConnectionManagersPriv -{ - gboolean dispose_has_run; - gboolean ready; - - GList *cms; - - TpDBusDaemon *dbus; -}; - -static void -tpaw_connection_managers_init (TpawConnectionManagers *obj) -{ - obj->priv = G_TYPE_INSTANCE_GET_PRIVATE ((obj), - TPAW_TYPE_CONNECTION_MANAGERS, TpawConnectionManagersPriv); - - obj->priv->dbus = tp_dbus_daemon_dup (NULL); - g_assert (obj->priv->dbus != NULL); - - tpaw_connection_managers_update (obj); - - /* allocate any data required by the object here */ -} - -static void tpaw_connection_managers_dispose (GObject *object); - -static GObject * -tpaw_connection_managers_constructor (GType type, - guint n_construct_params, - GObjectConstructParam *construct_params) -{ - if (managers != NULL) - return g_object_ref (managers); - - managers = - G_OBJECT_CLASS (tpaw_connection_managers_parent_class)->constructor - (type, n_construct_params, construct_params); - - g_object_add_weak_pointer (managers, (gpointer) &managers); - - return managers; -} - - - -static void -tpaw_connection_managers_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawConnectionManagers *self = TPAW_CONNECTION_MANAGERS (object); - - switch (prop_id) - { - case PROP_READY: - g_value_set_boolean (value, self->priv->ready); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_connection_managers_class_init ( - TpawConnectionManagersClass *tpaw_connection_managers_class) -{ - GObjectClass *object_class = - G_OBJECT_CLASS (tpaw_connection_managers_class); - - g_type_class_add_private (tpaw_connection_managers_class, sizeof - (TpawConnectionManagersPriv)); - - object_class->constructor = tpaw_connection_managers_constructor; - object_class->dispose = tpaw_connection_managers_dispose; - object_class->get_property = tpaw_connection_managers_get_property; - - g_object_class_install_property (object_class, PROP_READY, - g_param_spec_boolean ("ready", - "Ready", - "Whether the connection manager information is ready to be used", - FALSE, - G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); - - signals[UPDATED] = g_signal_new ("updated", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 0); -} - -static void -tpaw_connection_managers_free_cm_list (TpawConnectionManagers *self) -{ - GList *l; - - for (l = self->priv->cms ; l != NULL ; l = g_list_next (l)) - { - g_object_unref (l->data); - } - g_list_free (self->priv->cms); - - self->priv->cms = NULL; -} - -static void -tpaw_connection_managers_dispose (GObject *object) -{ - TpawConnectionManagers *self = TPAW_CONNECTION_MANAGERS (object); - - if (self->priv->dispose_has_run) - return; - - self->priv->dispose_has_run = TRUE; - - if (self->priv->dbus != NULL) - g_object_unref (self->priv->dbus); - self->priv->dbus = NULL; - - tpaw_connection_managers_free_cm_list (self); - - /* release any references held by the object here */ - - if (G_OBJECT_CLASS (tpaw_connection_managers_parent_class)->dispose) - G_OBJECT_CLASS (tpaw_connection_managers_parent_class)->dispose (object); -} - -TpawConnectionManagers * -tpaw_connection_managers_dup_singleton (void) -{ - return TPAW_CONNECTION_MANAGERS ( - g_object_new (TPAW_TYPE_CONNECTION_MANAGERS, NULL)); -} - -gboolean -tpaw_connection_managers_is_ready (TpawConnectionManagers *self) -{ - return self->priv->ready; -} - -static void -tpaw_connection_managers_listed_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpWeakRef *wr = user_data; - GError *error = NULL; - TpawConnectionManagers *self = tp_weak_ref_dup_object (wr); - GList *cms, *l; - - if (self == NULL) - { - tp_weak_ref_destroy (wr); - return; - } - - tpaw_connection_managers_free_cm_list (self); - - cms = tp_list_connection_managers_finish (result, &error); - if (error != NULL) - { - DEBUG ("Failed to get connection managers: %s", error->message); - g_error_free (error); - goto out; - } - - for (l = cms ; l != NULL; l = g_list_next (l)) - { - TpConnectionManager *cm = l->data; - - /* only list cms that didn't hit errors */ - if (tp_proxy_is_prepared (cm, TP_CONNECTION_MANAGER_FEATURE_CORE)) - self->priv->cms = g_list_prepend (self->priv->cms, - g_object_ref (cm)); - } - -out: - if (!self->priv->ready) - { - self->priv->ready = TRUE; - g_object_notify (G_OBJECT (self), "ready"); - } - - g_signal_emit (self, signals[UPDATED], 0); - g_object_unref (self); - tp_weak_ref_destroy (wr); -} - -void -tpaw_connection_managers_update (TpawConnectionManagers *self) -{ - tp_list_connection_managers_async (self->priv->dbus, - tpaw_connection_managers_listed_cb, - tp_weak_ref_new (self, NULL, NULL)); -} - -GList * -tpaw_connection_managers_get_cms (TpawConnectionManagers *self) -{ - return self->priv->cms; -} - -TpConnectionManager * -tpaw_connection_managers_get_cm (TpawConnectionManagers *self, - const gchar *cm) -{ - GList *l; - - for (l = self->priv->cms ; l != NULL; l = g_list_next (l)) - { - TpConnectionManager *c = TP_CONNECTION_MANAGER (l->data); - - if (!tp_strdiff (tp_connection_manager_get_name (c), cm)) - return c; - } - - return NULL; -} - -guint -tpaw_connection_managers_get_cms_num (TpawConnectionManagers *self) -{ - g_return_val_if_fail (TPAW_IS_CONNECTION_MANAGERS (self), 0); - - return g_list_length (self->priv->cms); -} - -static void -notify_ready_cb (TpawConnectionManagers *self, - GParamSpec *spec, - GSimpleAsyncResult *result) -{ - g_simple_async_result_complete (result); - g_object_unref (result); -} - -void -tpaw_connection_managers_prepare_async ( - TpawConnectionManagers *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - - result = g_simple_async_result_new (G_OBJECT (managers), - callback, user_data, tpaw_connection_managers_prepare_finish); - - if (self->priv->ready) - { - g_simple_async_result_complete_in_idle (result); - g_object_unref (result); - return; - } - - g_signal_connect (self, "notify::ready", G_CALLBACK (notify_ready_cb), - result); -} - -gboolean -tpaw_connection_managers_prepare_finish ( - TpawConnectionManagers *self, - GAsyncResult *result, - GError **error) -{ - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); - - g_return_val_if_fail (g_simple_async_result_is_valid (result, - G_OBJECT (self), tpaw_connection_managers_prepare_finish), FALSE); - - if (g_simple_async_result_propagate_error (simple, error)) - return FALSE; - - return TRUE; -} diff --git a/tp-account-widgets/tpaw-connection-managers.h b/tp-account-widgets/tpaw-connection-managers.h deleted file mode 100644 index dba476b47..000000000 --- a/tp-account-widgets/tpaw-connection-managers.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * tpaw-connection-managers.h - Header for TpawConnectionManagers - * Copyright (C) 2009 Collabora Ltd. - * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_CONNECTION_MANAGERS_H__ -#define __TPAW_CONNECTION_MANAGERS_H__ - -#include <glib-object.h> -#include <gio/gio.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef struct _TpawConnectionManagers TpawConnectionManagers; -typedef struct _TpawConnectionManagersPriv TpawConnectionManagersPriv; -typedef struct _TpawConnectionManagersClass TpawConnectionManagersClass; - -struct _TpawConnectionManagersClass { - GObjectClass parent_class; -}; - -struct _TpawConnectionManagers { - GObject parent; - /*<private>*/ - TpawConnectionManagersPriv *priv; -}; - -GType tpaw_connection_managers_get_type (void); - -/* TYPE MACROS */ -#define TPAW_TYPE_CONNECTION_MANAGERS \ - (tpaw_connection_managers_get_type ()) -#define TPAW_CONNECTION_MANAGERS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), TPAW_TYPE_CONNECTION_MANAGERS, \ - TpawConnectionManagers)) -#define TPAW_CONNECTION_MANAGERS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass), TPAW_TYPE_CONNECTION_MANAGERS, \ - TpawConnectionManagersClass)) -#define TPAW_IS_CONNECTION_MANAGERS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), TPAW_TYPE_CONNECTION_MANAGERS)) -#define TPAW_IS_CONNECTION_MANAGERS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), TPAW_TYPE_CONNECTION_MANAGERS)) -#define TPAW_CONNECTION_MANAGERS_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TPAW_TYPE_CONNECTION_MANAGERS, \ - TpawConnectionManagersClass)) - -TpawConnectionManagers *tpaw_connection_managers_dup_singleton (void); -gboolean tpaw_connection_managers_is_ready ( - TpawConnectionManagers *managers); - -void tpaw_connection_managers_update (TpawConnectionManagers *managers); - -GList * tpaw_connection_managers_get_cms ( - TpawConnectionManagers *managers); -guint tpaw_connection_managers_get_cms_num - (TpawConnectionManagers *managers); - -TpConnectionManager *tpaw_connection_managers_get_cm ( - TpawConnectionManagers *managers, const gchar *cm); - -void tpaw_connection_managers_prepare_async ( - TpawConnectionManagers *managers, - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_connection_managers_prepare_finish ( - TpawConnectionManagers *managers, - GAsyncResult *result, - GError **error); - -G_END_DECLS - -#endif /* #ifndef __TPAW_CONNECTION_MANAGERS_H__*/ diff --git a/tp-account-widgets/tpaw-contactinfo-utils.c b/tp-account-widgets/tpaw-contactinfo-utils.c deleted file mode 100644 index bb3ce966d..000000000 --- a/tp-account-widgets/tpaw-contactinfo-utils.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright (C) 2007-2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Philip Withnall <philip.withnall@collabora.co.uk> - * Danielle Madeley <danielle.madeley@collabora.co.uk> - */ - -#include "config.h" -#include "tpaw-contactinfo-utils.h" - -#include <stdlib.h> -#include <glib/gi18n-lib.h> -#include <tp-account-widgets/tpaw-time.h> -#include <tp-account-widgets/tpaw-string-parser.h> - -static gchar * -linkify_first_value (GStrv values) -{ - return tpaw_add_link_markup (values[0]); -} - -static gchar * -format_idle_time (GStrv values) -{ - const gchar *value = values[0]; - int duration = strtol (value, NULL, 10); - - if (duration <= 0) - return NULL; - - return tpaw_duration_to_string (duration); -} - -static gchar * -format_server (GStrv values) -{ - g_assert (values[0] != NULL); - - if (values[1] == NULL) - return g_markup_escape_text (values[0], -1); - else - return g_markup_printf_escaped ("%s (%s)", values[0], values[1]); -} - -static gchar * -presence_hack (GStrv values) -{ - if (tp_str_empty (values[0])) - return NULL; - - return g_markup_escape_text (values[0], -1); -} - -typedef struct -{ - const gchar *field_name; - const gchar *title; - TpawContactInfoFormatFunc format; -} InfoFieldData; - -/* keep this syncronised with info_field_data below */ -static const char *info_field_names[] = -{ - "fn", - "tel", - "email", - "url", - "bday", - - "x-idle-time", - "x-irc-server", - "x-host", - - "x-presence-status-message", - - NULL -}; - -static InfoFieldData info_field_data[G_N_ELEMENTS (info_field_names)] = -{ - { "fn", N_("Full name"), NULL }, - { "tel", N_("Phone number"), NULL }, - { "email", N_("E-mail address"), linkify_first_value }, - { "url", N_("Website"), linkify_first_value }, - { "bday", N_("Birthday"), NULL }, - - /* Note to translators: this is the caption for a string of the form "5 - * minutes ago", and refers to the time since the contact last interacted - * with their IM client. */ - { "x-idle-time", N_("Last seen:"), format_idle_time }, - { "x-irc-server", N_("Server:"), format_server }, - { "x-host", N_("Connected from:"), format_server }, - - /* FIXME: once Idle implements SimplePresence using this information, we can - * and should bin this. */ - { "x-presence-status-message", N_("Away message:"), presence_hack }, - - { NULL, NULL } -}; - -typedef struct -{ - const gchar *type; - const gchar *title; -} InfoParameterData; - -static InfoParameterData info_parameter_data[] = -{ - { "work", N_("work") }, - { "home", N_("home") }, - { "cell", N_("mobile") }, - { "voice", N_("voice") }, - { "pref", N_("preferred") }, - { "postal", N_("postal") }, - { "parcel", N_("parcel") }, - { NULL, NULL } -}; - -const char ** -tpaw_contact_info_get_field_names (guint *nnames) -{ - if (nnames != NULL) - *nnames = G_N_ELEMENTS (info_field_names) - 1; - - return info_field_names; -} - -gboolean -tpaw_contact_info_lookup_field (const gchar *field_name, - const gchar **title, - TpawContactInfoFormatFunc *format) -{ - guint i; - - for (i = 0; info_field_data[i].field_name != NULL; i++) - { - if (tp_strdiff (info_field_data[i].field_name, field_name) == FALSE) - { - if (title != NULL) - *title = gettext (info_field_data[i].title); - - if (format != NULL) - *format = info_field_data[i].format; - - return TRUE; - } - } - - return FALSE; -} - -static char * -build_parameters_string (GStrv parameters) -{ - GPtrArray *output = g_ptr_array_new (); - char *join; - GStrv iter; - - for (iter = parameters; iter != NULL && *iter != NULL; iter++) - { - static const char *prefix = "type="; - const char *param = *iter; - InfoParameterData *iter2; - - if (!g_str_has_prefix (param, prefix)) - continue; - - param += strlen (prefix); - - for (iter2 = info_parameter_data; iter2->type != NULL; iter2++) - { - if (!tp_strdiff (iter2->type, param)) - { - g_ptr_array_add (output, gettext (iter2->title)); - break; - } - } - } - - if (output->len == 0) - return NULL; - - g_ptr_array_add (output, NULL); /* NULL-terminate */ - - join = g_strjoinv (", ", (char **) output->pdata); - g_ptr_array_unref (output); - - return join; -} - -char * -tpaw_contact_info_field_label (const char *field_name, - GStrv parameters, - gboolean show_parameters) -{ - char *ret; - const char *title; - char *join = NULL; - - if (!tpaw_contact_info_lookup_field (field_name, &title, NULL)) - return NULL; - - if (show_parameters) - join = build_parameters_string (parameters); - - if (join != NULL) - ret = g_strdup_printf ("%s (%s)", title, join); - else - ret = g_strdup_printf ("%s", title); - - g_free (join); - - return ret; -} - -static gint -contact_info_field_name_cmp (const gchar *name1, - const gchar *name2) -{ - guint i; - - if (tp_strdiff (name1, name2) == FALSE) - return 0; - - /* We use the order of info_field_data */ - for (i = 0; info_field_data[i].field_name != NULL; i++) - { - if (tp_strdiff (info_field_data[i].field_name, name1) == FALSE) - return -1; - if (tp_strdiff (info_field_data[i].field_name, name2) == FALSE) - return +1; - } - - return g_strcmp0 (name1, name2); -} - -gint -tpaw_contact_info_field_cmp (TpContactInfoField *field1, - TpContactInfoField *field2) -{ - return contact_info_field_name_cmp (field1->field_name, field2->field_name); -} - -gint -tpaw_contact_info_field_spec_cmp (TpContactInfoFieldSpec *spec1, - TpContactInfoFieldSpec *spec2) -{ - return contact_info_field_name_cmp (spec1->name, spec2->name); -} - diff --git a/tp-account-widgets/tpaw-contactinfo-utils.h b/tp-account-widgets/tpaw-contactinfo-utils.h deleted file mode 100644 index ced81b191..000000000 --- a/tp-account-widgets/tpaw-contactinfo-utils.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk> - */ - -#ifndef __TPAW_CONTACTINFO_UTILS_H__ -#define __TPAW_CONTACTINFO_UTILS_H__ - -#include <gtk/gtk.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -typedef gchar * (* TpawContactInfoFormatFunc) (GStrv); - -const char **tpaw_contact_info_get_field_names (guint *nnames); -gboolean tpaw_contact_info_lookup_field (const gchar *field_name, - const gchar **title, TpawContactInfoFormatFunc *linkify); -char *tpaw_contact_info_field_label (const char *field_name, - GStrv parameters, - gboolean show_parameters); - -gint tpaw_contact_info_field_cmp (TpContactInfoField *field1, - TpContactInfoField *field2); -gint tpaw_contact_info_field_spec_cmp (TpContactInfoFieldSpec *spec1, - TpContactInfoFieldSpec *spec2); - -G_END_DECLS - -#endif /* __TPAW_UTILS_H__ */ diff --git a/tp-account-widgets/tpaw-debug.c b/tp-account-widgets/tpaw-debug.c deleted file mode 100644 index 0e05a2d29..000000000 --- a/tp-account-widgets/tpaw-debug.c +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * Copyright (C) 2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-debug.h" - -#ifdef ENABLE_DEBUG - -static TpawDebugFlags flags = 0; - -static GDebugKey keys[] = { - { "Account", TPAW_DEBUG_ACCOUNT }, - { "Irc", TPAW_DEBUG_IRC }, - { "Other", TPAW_DEBUG_OTHER }, - { 0, } -}; - -static void -debug_set_flags (TpawDebugFlags new_flags) -{ - flags |= new_flags; -} - -void -tpaw_debug_set_flags (const gchar *flags_string) -{ - guint nkeys; - - for (nkeys = 0; keys[nkeys].value; nkeys++); - - if (flags_string) - debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys)); -} - -gboolean -tpaw_debug_flag_is_set (TpawDebugFlags flag) -{ - return (flag & flags) != 0; -} - -GHashTable *flag_to_keys = NULL; - -static const gchar * -debug_flag_to_key (TpawDebugFlags flag) -{ - if (flag_to_keys == NULL) - { - guint i; - - flag_to_keys = g_hash_table_new_full (g_direct_hash, g_direct_equal, - NULL, g_free); - - for (i = 0; keys[i].value; i++) - { - GDebugKey key = (GDebugKey) keys[i]; - g_hash_table_insert (flag_to_keys, GUINT_TO_POINTER (key.value), - g_strdup (key.key)); - } - } - - return g_hash_table_lookup (flag_to_keys, GUINT_TO_POINTER (flag)); -} - -void -tpaw_debug_free (void) -{ - if (flag_to_keys == NULL) - return; - - g_hash_table_unref (flag_to_keys); - flag_to_keys = NULL; -} - -static void -log_to_debug_sender (TpawDebugFlags flag, - const gchar *message) -{ - TpDebugSender *sender; - gchar *domain; - GTimeVal now; - - sender = tp_debug_sender_dup (); - - g_get_current_time (&now); - - domain = g_strdup_printf ("%s/%s", G_LOG_DOMAIN, debug_flag_to_key (flag)); - - tp_debug_sender_add_message (sender, &now, domain, G_LOG_LEVEL_DEBUG, message); - - g_free (domain); - g_object_unref (sender); -} - -void -tpaw_debug (TpawDebugFlags flag, - const gchar *format, - ...) -{ - gchar *message; - va_list args; - - va_start (args, format); - message = g_strdup_vprintf (format, args); - va_end (args); - - log_to_debug_sender (flag, message); - - if (flag & flags) - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "%s", message); - - g_free (message); -} - -#else - -gboolean -tpaw_debug_flag_is_set (TpawDebugFlags flag) -{ - return FALSE; -} - -void -tpaw_debug (TpawDebugFlags flag, const gchar *format, ...) -{ -} - -void -tpaw_debug_set_flags (const gchar *flags_string) -{ -} - -#endif /* ENABLE_DEBUG */ diff --git a/tp-account-widgets/tpaw-debug.h b/tp-account-widgets/tpaw-debug.h deleted file mode 100644 index 51ed827a6..000000000 --- a/tp-account-widgets/tpaw-debug.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007 Collabora Ltd. - * Copyright (C) 2007 Nokia Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_DEBUG_H__ -#define __TPAW_DEBUG_H__ - -#include <glib.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -/* Please keep this enum in sync with #keys in tpaw-debug.c */ -typedef enum -{ - TPAW_DEBUG_CONTACT = 1 << 1, - TPAW_DEBUG_ACCOUNT = 1 << 2, - TPAW_DEBUG_IRC = 1 << 3, - TPAW_DEBUG_OTHER = 1 << 4, -} TpawDebugFlags; - -gboolean tpaw_debug_flag_is_set (TpawDebugFlags flag); -void tpaw_debug (TpawDebugFlags flag, const gchar *format, ...) - G_GNUC_PRINTF (2, 3); -void tpaw_debug_free (void); -void tpaw_debug_set_flags (const gchar *flags_string); -G_END_DECLS - -#endif /* __TPAW_DEBUG_H__ */ - -/* ------------------------------------ */ - -/* Below this point is outside the __DEBUG_H__ guard - so it can take effect - * more than once. So you can do: - * - * #define DEBUG_FLAG TPAW_DEBUG_ONE_THING - * #include "internal-debug.h" - * ... - * DEBUG ("if we're debugging one thing"); - * ... - * #undef DEBUG_FLAG - * #define DEBUG_FLAG TPAW_DEBUG_OTHER_THING - * #include "internal-debug.h" - * ... - * DEBUG ("if we're debugging the other thing"); - * ... - */ - -#ifdef DEBUG_FLAG -#ifdef ENABLE_DEBUG - -#undef DEBUG -#define DEBUG(format, ...) \ - tpaw_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ##__VA_ARGS__) - -#undef DEBUGGING -#define DEBUGGING tpaw_debug_flag_is_set (DEBUG_FLAG) - -#else /* !defined (ENABLE_DEBUG) */ - -#undef DEBUG -#define DEBUG(format, ...) do {} while (0) - -#undef DEBUGGING -#define DEBUGGING 0 - -#endif /* !defined (ENABLE_DEBUG) */ - -#define gabble_debug_free() G_STMT_START { } G_STMT_END - -#endif /* defined (DEBUG_FLAG) */ diff --git a/tp-account-widgets/tpaw-gsettings.h b/tp-account-widgets/tpaw-gsettings.h deleted file mode 100644 index 527af141c..000000000 --- a/tp-account-widgets/tpaw-gsettings.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2010-2013 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk> - */ - -#ifndef __TPAW_GSETTINGS_H__ -#define __TPAW_GSETTINGS_H__ - -#include <gio/gio.h> - -G_BEGIN_DECLS - -/* FIXME: Move this after the split of tp-account-widgets. */ -#define TPAW_PREFS_SCHEMA "org.gnome.Empathy" - -#define TPAW_PREFS_UI_SCHEMA TPAW_PREFS_SCHEMA ".ui" -#define TPAW_PREFS_UI_AVATAR_DIRECTORY "avatar-directory" - -G_END_DECLS - -#endif /* __TPAW_GSETTINGS_H__ */ - diff --git a/tp-account-widgets/tpaw-images.h b/tp-account-widgets/tpaw-images.h deleted file mode 100644 index 48bc4cbf4..000000000 --- a/tp-account-widgets/tpaw-images.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2007-2008 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __TPAW_IMAGES_H__ -#define __TPAW_IMAGES_H__ - -G_BEGIN_DECLS - -#define TPAW_IMAGE_AVATAR_DEFAULT "avatar-default-symbolic" - -G_END_DECLS - -#endif /* __TPAW_IMAGES_ICONS_H__ */ diff --git a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c b/tp-account-widgets/tpaw-irc-network-chooser-dialog.c deleted file mode 100644 index 80d76a747..000000000 --- a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c +++ /dev/null @@ -1,731 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-network-chooser-dialog.h" - -#include <glib/gi18n-lib.h> - -#include "tpaw-irc-network-dialog.h" -#include "tpaw-irc-network-manager.h" -#include "tpaw-live-search.h" -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT | TPAW_DEBUG_IRC -#include "tpaw-debug.h" - -#include "tpaw-irc-network-chooser-dialog.h" - -enum { - PROP_SETTINGS = 1, - PROP_NETWORK -}; - -enum { - RESPONSE_RESET = 0 -}; - -struct _TpawIrcNetworkChooserDialogPriv { - TpawAccountSettings *settings; - TpawIrcNetwork *network; - - TpawIrcNetworkManager *network_manager; - gboolean changed; - - GtkWidget *treeview; - GtkListStore *store; - GtkTreeModelFilter *filter; - GtkWidget *search; - GtkWidget *select_button; - - gulong search_sig; - gulong activate_sig; -}; - -enum { - COL_NETWORK_OBJ, - COL_NETWORK_NAME, -}; - -G_DEFINE_TYPE (TpawIrcNetworkChooserDialog, tpaw_irc_network_chooser_dialog, - GTK_TYPE_DIALOG); - -static void -tpaw_irc_network_chooser_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkChooserDialog *self = - TPAW_IRC_NETWORK_CHOOSER_DIALOG (object); - - switch (prop_id) - { - case PROP_SETTINGS: - self->priv->settings = g_value_dup_object (value); - break; - case PROP_NETWORK: - self->priv->network = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_irc_network_chooser_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkChooserDialog *self = - TPAW_IRC_NETWORK_CHOOSER_DIALOG (object); - - switch (prop_id) - { - case PROP_SETTINGS: - g_value_set_object (value, self->priv->settings); - break; - case PROP_NETWORK: - g_value_set_object (value, self->priv->network); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* The iter returned by *it is a self->priv->store iter (not a filter one) */ -static TpawIrcNetwork * -dup_selected_network (TpawIrcNetworkChooserDialog *self, - GtkTreeIter *it) -{ - TpawIrcNetwork *network; - GtkTreeSelection *selection; - GtkTreeIter iter; - GtkTreeModel *model; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (self->priv->treeview)); - if (selection == NULL) - return NULL; - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return NULL; - - gtk_tree_model_get (model, &iter, COL_NETWORK_OBJ, &network, -1); - g_assert (network != NULL); - - if (it != NULL) - { - gtk_tree_model_filter_convert_iter_to_child_iter ( self->priv->filter, - it, &iter); - } - - return network; -} - -static void -treeview_changed_cb (GtkTreeView *treeview, - TpawIrcNetworkChooserDialog *self) -{ - TpawIrcNetwork *network; - - network = dup_selected_network (self, NULL); - if (network == self->priv->network) - { - g_clear_object (&network); - return; - } - - tp_clear_object (&self->priv->network); - /* Transfer the reference */ - self->priv->network = network; - - self->priv->changed = TRUE; -} - -/* Take a filter iterator as argument */ -static void -scroll_to_iter (TpawIrcNetworkChooserDialog *self, - GtkTreeIter *filter_iter) -{ - GtkTreePath *path; - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->filter), - filter_iter); - - if (path != NULL) - { - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self->priv->treeview), - path, NULL, FALSE, 0, 0); - - gtk_tree_path_free (path); - } -} - -/* Take a filter iterator as argument */ -static void -select_iter (TpawIrcNetworkChooserDialog *self, - GtkTreeIter *filter_iter, - gboolean emulate_changed) -{ - GtkTreeSelection *selection; - GtkTreePath *path; - - /* Select the network */ - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (self->priv->treeview)); - - gtk_tree_selection_select_iter (selection, filter_iter); - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->priv->filter), - filter_iter); - if (path != NULL) - { - gtk_tree_view_set_cursor (GTK_TREE_VIEW (self->priv->treeview), path, - NULL, FALSE); - - gtk_tree_path_free (path); - } - - /* Scroll to the selected network */ - scroll_to_iter (self, filter_iter); - - if (emulate_changed) - { - /* gtk_tree_selection_select_iter doesn't fire the 'cursor-changed' signal - * so we call the callback manually. */ - treeview_changed_cb (GTK_TREE_VIEW (self->priv->treeview), self); - } -} - -static GtkTreeIter -iter_to_filter_iter (TpawIrcNetworkChooserDialog *self, - GtkTreeIter *iter) -{ - GtkTreeIter filter_iter; - - g_assert ( - gtk_tree_model_filter_convert_child_iter_to_iter (self->priv->filter, - &filter_iter, iter)); - - return filter_iter; -} - -static void -fill_store (TpawIrcNetworkChooserDialog *self) -{ - GSList *networks, *l; - - networks = tpaw_irc_network_manager_get_networks ( - self->priv->network_manager); - - for (l = networks; l != NULL; l = g_slist_next (l)) - { - TpawIrcNetwork *network = l->data; - GtkTreeIter iter; - - gtk_list_store_insert_with_values (self->priv->store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, tpaw_irc_network_get_name (network), - -1); - - if (network == self->priv->network) - { - GtkTreeIter filter_iter = iter_to_filter_iter (self, &iter); - - select_iter (self, &filter_iter, FALSE); - } - - g_object_unref (network); - } - - g_slist_free (networks); -} - -static void -irc_network_dialog_destroy_cb (GtkWidget *widget, - TpawIrcNetworkChooserDialog *self) -{ - TpawIrcNetwork *network; - GtkTreeIter iter, filter_iter; - - self->priv->changed = TRUE; - - network = dup_selected_network (self, &iter); - if (network == NULL) - return; - - /* name could be changed */ - gtk_list_store_set (GTK_LIST_STORE (self->priv->store), &iter, - COL_NETWORK_NAME, tpaw_irc_network_get_name (network), -1); - - filter_iter = iter_to_filter_iter (self, &iter); - scroll_to_iter (self, &filter_iter); - - gtk_widget_grab_focus (self->priv->treeview); - - g_object_unref (network); -} - -static void -display_irc_network_dialog (TpawIrcNetworkChooserDialog *self, - TpawIrcNetwork *network) -{ - GtkWidget *dialog; - - dialog = tpaw_irc_network_dialog_show (network, GTK_WIDGET (self)); - - g_signal_connect (dialog, "destroy", - G_CALLBACK (irc_network_dialog_destroy_cb), self); -} - -static void -edit_network (TpawIrcNetworkChooserDialog *self) -{ - TpawIrcNetwork *network; - - network = dup_selected_network (self, NULL); - if (network == NULL) - return; - - display_irc_network_dialog (self, network); - - g_object_unref (network); -} - -static void -add_network (TpawIrcNetworkChooserDialog *self) -{ - TpawIrcNetwork *network; - GtkTreeIter iter, filter_iter; - - gtk_widget_hide (self->priv->search); - - network = tpaw_irc_network_new (_("New Network")); - tpaw_irc_network_manager_add (self->priv->network_manager, network); - - gtk_list_store_insert_with_values (self->priv->store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, tpaw_irc_network_get_name (network), - -1); - - filter_iter = iter_to_filter_iter (self, &iter); - select_iter (self, &filter_iter, TRUE); - - display_irc_network_dialog (self, network); - - g_object_unref (network); -} - -static void -remove_network (TpawIrcNetworkChooserDialog *self) -{ - TpawIrcNetwork *network; - GtkTreeIter iter; - - network = dup_selected_network (self, &iter); - if (network == NULL) - return; - - /* Hide the search after picking the network to get the right one */ - gtk_widget_hide (self->priv->search); - - DEBUG ("Remove network %s", tpaw_irc_network_get_name (network)); - - /* Delete network and select next network */ - if (gtk_list_store_remove (self->priv->store, &iter)) - { - GtkTreeIter filter_iter = iter_to_filter_iter (self, &iter); - - select_iter (self, &filter_iter, TRUE); - } - else - { - /* this should only happen if the last network was deleted */ - GtkTreeIter last, filter_iter; - gint n_elements; - - n_elements = gtk_tree_model_iter_n_children ( - GTK_TREE_MODEL (self->priv->store), NULL); - - if (n_elements > 0) - { - gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (self->priv->store), - &last, NULL, (n_elements-1)); - filter_iter = iter_to_filter_iter (self, &last); - - select_iter (self, &filter_iter, TRUE); - } - } - - tpaw_irc_network_manager_remove (self->priv->network_manager, network); - gtk_widget_grab_focus (self->priv->treeview); - - g_object_unref (network); -} - -static void -reset_networks (TpawIrcNetworkChooserDialog *self) -{ - GSList *networks, *l; - - networks = tpaw_irc_network_manager_get_dropped_networks ( - self->priv->network_manager); - - for (l = networks; l != NULL; l = g_slist_next (l)) - { - TpawIrcNetwork *network; - GtkTreeIter iter; - - network = TPAW_IRC_NETWORK (l->data); - tpaw_irc_network_activate (network); - - gtk_list_store_insert_with_values (self->priv->store, &iter, -1, - COL_NETWORK_OBJ, network, - COL_NETWORK_NAME, tpaw_irc_network_get_name (network), - -1); - } - - g_slist_foreach (networks, (GFunc) g_object_unref, NULL); -} - -static void -dialog_response_cb (GtkDialog *dialog, - gint response, - TpawIrcNetworkChooserDialog *self) -{ - if (response == RESPONSE_RESET) - reset_networks (self); -} - -static gboolean -filter_visible_func (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer user_data) -{ - TpawIrcNetworkChooserDialog *self = user_data; - TpawIrcNetwork *network; - gboolean visible; - - gtk_tree_model_get (model, iter, COL_NETWORK_OBJ, &network, -1); - - visible = tpaw_live_search_match (TPAW_LIVE_SEARCH (self->priv->search), - tpaw_irc_network_get_name (network)); - - g_object_unref (network); - return visible; -} - -static void -search_activate_cb (GtkWidget *search, - TpawIrcNetworkChooserDialog *self) -{ - gtk_widget_hide (search); - gtk_dialog_response (GTK_DIALOG (self), GTK_RESPONSE_CLOSE); -} - -static void -search_text_notify_cb (TpawLiveSearch *search, - GParamSpec *pspec, - TpawIrcNetworkChooserDialog *self) -{ - GtkTreeIter filter_iter; - gboolean sensitive = FALSE; - - gtk_tree_model_filter_refilter (self->priv->filter); - - /* Is there at least one network in the view ? */ - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (self->priv->filter), - &filter_iter)) - { - const gchar *text; - - text = tpaw_live_search_get_text ( - TPAW_LIVE_SEARCH (self->priv->search)); - if (!TPAW_STR_EMPTY (text)) - { - /* We are doing a search, select the first matching network */ - select_iter (self, &filter_iter, TRUE); - } - else - { - /* Search has been cancelled. Scroll to the selected network */ - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (self->priv->treeview)); - - if (gtk_tree_selection_get_selected (selection, NULL, - &filter_iter)) - scroll_to_iter (self, &filter_iter); - } - - sensitive = TRUE; - } - - gtk_widget_set_sensitive (self->priv->select_button, sensitive); -} - -static void -add_clicked_cb (GtkToolButton *button, - TpawIrcNetworkChooserDialog *self) -{ - add_network (self); -} - -static void -remove_clicked_cb (GtkToolButton *button, - TpawIrcNetworkChooserDialog *self) -{ - remove_network (self); -} - -static void -edit_clicked_cb (GtkToolButton *button, - TpawIrcNetworkChooserDialog *self) -{ - edit_network (self); -} - -static void -tpaw_irc_network_chooser_dialog_constructed (GObject *object) -{ - TpawIrcNetworkChooserDialog *self = (TpawIrcNetworkChooserDialog *) object; - GtkDialog *dialog = GTK_DIALOG (self); - GtkCellRenderer *renderer; - GtkWidget *vbox; - GtkTreeViewColumn *column; - GtkWidget *scroll; - GtkWidget *toolbar; - GtkToolItem *item; - GtkStyleContext *context; - - g_assert (self->priv->settings != NULL); - - gtk_window_set_title (GTK_WINDOW (self), _("Choose an IRC network")); - - /* Create store and treeview */ - self->priv->store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING); - - gtk_tree_sortable_set_sort_column_id ( - GTK_TREE_SORTABLE (self->priv->store), - COL_NETWORK_NAME, - GTK_SORT_ASCENDING); - - self->priv->treeview = gtk_tree_view_new (); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (self->priv->treeview), - FALSE); - gtk_tree_view_set_enable_search (GTK_TREE_VIEW (self->priv->treeview), - FALSE); - - column = gtk_tree_view_column_new (); - gtk_tree_view_append_column (GTK_TREE_VIEW (self->priv->treeview), column); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (column), - renderer, - "text", COL_NETWORK_NAME, - NULL); - - /* add the treeview in a GtkScrolledWindow */ - vbox = gtk_dialog_get_content_area (dialog); - - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scroll), self->priv->treeview); - gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 6); - - /* Treeview toolbar */ - toolbar = gtk_toolbar_new (); - gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU); - gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0); - - item = gtk_tool_button_new (NULL, ""); - gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), "list-add-symbolic"); - g_signal_connect (item, "clicked", G_CALLBACK (add_clicked_cb), self); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); - - item = gtk_tool_button_new (NULL, ""); - gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), - "list-remove-symbolic"); - g_signal_connect (item, "clicked", G_CALLBACK (remove_clicked_cb), self); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); - - item = gtk_tool_button_new (NULL, ""); - gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (item), - "preferences-system-symbolic"); - g_signal_connect (item, "clicked", G_CALLBACK (edit_clicked_cb), self); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1); - - context = gtk_widget_get_style_context (scroll); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); - - context = gtk_widget_get_style_context (toolbar); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); - - /* Live search */ - self->priv->search = tpaw_live_search_new (self->priv->treeview); - - gtk_box_pack_start (GTK_BOX (vbox), self->priv->search, FALSE, TRUE, 0); - - self->priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new ( - GTK_TREE_MODEL (self->priv->store), NULL)); - gtk_tree_model_filter_set_visible_func (self->priv->filter, - filter_visible_func, self, NULL); - - gtk_tree_view_set_model (GTK_TREE_VIEW (self->priv->treeview), - GTK_TREE_MODEL (self->priv->filter)); - - self->priv->search_sig = g_signal_connect (self->priv->search, - "notify::text", G_CALLBACK (search_text_notify_cb), self); - - self->priv->activate_sig = g_signal_connect (self->priv->search, - "activate", G_CALLBACK (search_activate_cb), self); - - /* Add buttons */ - gtk_dialog_add_buttons (dialog, - _("Reset _Networks List"), RESPONSE_RESET, - NULL); - - self->priv->select_button = gtk_dialog_add_button (dialog, - C_("verb displayed on a button to select an IRC network", "Select"), - GTK_RESPONSE_CLOSE); - - fill_store (self); - - g_signal_connect (self->priv->treeview, "cursor-changed", - G_CALLBACK (treeview_changed_cb), self); - - g_signal_connect (self, "response", - G_CALLBACK (dialog_response_cb), self); - - /* Request a side ensuring to display at least some networks */ - gtk_widget_set_size_request (GTK_WIDGET (self), -1, 300); - - gtk_window_set_modal (GTK_WINDOW (self), TRUE); -} - -static void -tpaw_irc_network_chooser_dialog_dispose (GObject *object) -{ - TpawIrcNetworkChooserDialog *self = (TpawIrcNetworkChooserDialog *) object; - - if (self->priv->search_sig != 0) - { - g_signal_handler_disconnect (self->priv->search, - self->priv->search_sig); - self->priv->search_sig = 0; - } - - if (self->priv->activate_sig != 0) - { - g_signal_handler_disconnect (self->priv->search, - self->priv->activate_sig); - self->priv->activate_sig = 0; - } - - if (self->priv->search != NULL) - { - tpaw_live_search_set_hook_widget ( - TPAW_LIVE_SEARCH (self->priv->search), NULL); - - self->priv->search = NULL; - } - - tp_clear_object (&self->priv->settings); - tp_clear_object (&self->priv->network); - tp_clear_object (&self->priv->network_manager); - tp_clear_object (&self->priv->store); - tp_clear_object (&self->priv->filter); - - if (G_OBJECT_CLASS (tpaw_irc_network_chooser_dialog_parent_class)->dispose) - G_OBJECT_CLASS (tpaw_irc_network_chooser_dialog_parent_class)->dispose (object); -} - -static void -tpaw_irc_network_chooser_dialog_class_init (TpawIrcNetworkChooserDialogClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = tpaw_irc_network_chooser_dialog_get_property; - object_class->set_property = tpaw_irc_network_chooser_dialog_set_property; - object_class->constructed = tpaw_irc_network_chooser_dialog_constructed; - object_class->dispose = tpaw_irc_network_chooser_dialog_dispose; - - g_object_class_install_property (object_class, PROP_SETTINGS, - g_param_spec_object ("settings", - "Settings", - "The TpawAccountSettings to show and edit", - TPAW_TYPE_ACCOUNT_SETTINGS, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property (object_class, PROP_NETWORK, - g_param_spec_object ("network", - "Network", - "The TpawIrcNetwork selected in the treeview", - TPAW_TYPE_IRC_NETWORK, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_type_class_add_private (object_class, - sizeof (TpawIrcNetworkChooserDialogPriv)); -} - -static void -tpaw_irc_network_chooser_dialog_init (TpawIrcNetworkChooserDialog *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, TpawIrcNetworkChooserDialogPriv); - - self->priv->network_manager = tpaw_irc_network_manager_dup_default (); -} - -GtkWidget * -tpaw_irc_network_chooser_dialog_new (TpawAccountSettings *settings, - TpawIrcNetwork *network, - GtkWindow *parent) -{ - return g_object_new (TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, - "settings", settings, - "network", network, - "transient-for", parent, - NULL); -} - -TpawIrcNetwork * -tpaw_irc_network_chooser_dialog_get_network ( - TpawIrcNetworkChooserDialog *self) -{ - return self->priv->network; -} - -gboolean -tpaw_irc_network_chooser_dialog_get_changed ( - TpawIrcNetworkChooserDialog *self) -{ - return self->priv->changed; -} diff --git a/tp-account-widgets/tpaw-irc-network-chooser-dialog.h b/tp-account-widgets/tpaw-irc-network-chooser-dialog.h deleted file mode 100644 index fb5edf1f8..000000000 --- a/tp-account-widgets/tpaw-irc-network-chooser-dialog.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_NETWORK_CHOOSER_DIALOG_H__ -#define __TPAW_IRC_NETWORK_CHOOSER_DIALOG_H__ - -#include <gtk/gtk.h> - -#include "tpaw-account-settings.h" -#include "tpaw-irc-network.h" - -G_BEGIN_DECLS - -#define TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG (tpaw_irc_network_chooser_dialog_get_type ()) -#define TPAW_IRC_NETWORK_CHOOSER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, TpawIrcNetworkChooserDialog)) -#define TPAW_IRC_NETWORK_CHOOSER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, TpawIrcNetworkChooserDialogClass)) -#define TPAW_IS_IRC_NETWORK_CHOOSER_DIALOG(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG)) -#define TPAW_IS_IRC_NETWORK_CHOOSER_DIALOG_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG)) -#define TPAW_IRC_NETWORK_CHOOSER_DIALOG_GET_CLASS(o) ( \ - G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK_CHOOSER_DIALOG, \ - TpawIrcNetworkChooserDialogClass)) - -typedef struct _TpawIrcNetworkChooserDialogPriv TpawIrcNetworkChooserDialogPriv; - -typedef struct { - GtkDialog parent; - - /*<private>*/ - TpawIrcNetworkChooserDialogPriv *priv; -} TpawIrcNetworkChooserDialog; - -typedef struct { - GtkDialogClass parent_class; -} TpawIrcNetworkChooserDialogClass; - -GType tpaw_irc_network_chooser_dialog_get_type (void) G_GNUC_CONST; - -GtkWidget * tpaw_irc_network_chooser_dialog_new ( - TpawAccountSettings *settings, - TpawIrcNetwork *network, - GtkWindow *parent); - -TpawIrcNetwork * tpaw_irc_network_chooser_dialog_get_network ( - TpawIrcNetworkChooserDialog *self); - -gboolean tpaw_irc_network_chooser_dialog_get_changed ( - TpawIrcNetworkChooserDialog *self); - -G_END_DECLS - -#endif /* __TPAW_IRC_NETWORK_CHOOSER_DIALOG_H__ */ diff --git a/tp-account-widgets/tpaw-irc-network-chooser.c b/tp-account-widgets/tpaw-irc-network-chooser.c deleted file mode 100644 index 977f0ac3e..000000000 --- a/tp-account-widgets/tpaw-irc-network-chooser.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-network-chooser.h" - -#include "tpaw-irc-network-chooser-dialog.h" -#include "tpaw-irc-network-manager.h" -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT | TPAW_DEBUG_IRC -#include "tpaw-debug.h" - -#define DEFAULT_IRC_NETWORK "irc.gimp.org" -#define DEFAULT_IRC_PORT 6667 -#define DEFAULT_IRC_SSL FALSE - -enum { - PROP_SETTINGS = 1 -}; - -enum { - SIG_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -struct _TpawIrcNetworkChooserPriv { - TpawAccountSettings *settings; - - TpawIrcNetworkManager *network_manager; - GtkWidget *dialog; - /* Displayed network */ - TpawIrcNetwork *network; -}; - -G_DEFINE_TYPE (TpawIrcNetworkChooser, tpaw_irc_network_chooser, - GTK_TYPE_BUTTON); - -static void -tpaw_irc_network_chooser_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (object); - - switch (prop_id) - { - case PROP_SETTINGS: - self->priv->settings = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tpaw_irc_network_chooser_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (object); - - switch (prop_id) - { - case PROP_SETTINGS: - g_value_set_object (value, self->priv->settings); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -unset_server_params (TpawIrcNetworkChooser *self) -{ - DEBUG ("Unset server, port and use-ssl"); - tpaw_account_settings_unset (self->priv->settings, "server"); - tpaw_account_settings_unset (self->priv->settings, "port"); - tpaw_account_settings_unset (self->priv->settings, "use-ssl"); -} - -static gchar * -dup_network_service (TpawIrcNetwork *network) -{ - /* Account.Service has to be a lower case alphanumeric string which may - * also contain '-' but not start with it. */ -#define VALID G_CSET_a_2_z G_CSET_DIGITS "-" - gchar *service, *tmp; - - service = g_strdup (tpaw_irc_network_get_name (network)); - service = g_strstrip (service); - - if (tp_str_empty (service)) - { - g_free (service); - return NULL; - } - - tmp = service; - service = g_ascii_strdown (service, -1); - g_free (tmp); - - service = g_strcanon (service, VALID, '-'); - - if (service[0] == '-') - { - tmp = service; - service = g_strdup (service + 1); - - g_free (tmp); - } - - return service; -} - -static void -update_server_params (TpawIrcNetworkChooser *self) -{ - GSList *servers; - const gchar *charset; - - g_assert (self->priv->network != NULL); - - charset = tpaw_irc_network_get_charset (self->priv->network); - DEBUG ("Setting charset to %s", charset); - tpaw_account_settings_set (self->priv->settings, "charset", - g_variant_new_string (charset)); - - servers = tpaw_irc_network_get_servers (self->priv->network); - if (g_slist_length (servers) > 0) - { - /* set the first server as CM server */ - TpawIrcServer *server = servers->data; - gchar *address; - guint port; - gboolean ssl; - gchar *service; - - g_object_get (server, - "address", &address, - "port", &port, - "ssl", &ssl, - NULL); - - DEBUG ("Setting server to %s", address); - tpaw_account_settings_set (self->priv->settings, "server", - g_variant_new_string (address)); - DEBUG ("Setting port to %u", port); - tpaw_account_settings_set (self->priv->settings, "port", - g_variant_new_uint32 (port)); - DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" ); - tpaw_account_settings_set (self->priv->settings, "use-ssl", - g_variant_new_boolean (ssl)); - - /* Set Account.Service */ - service = dup_network_service (self->priv->network); - DEBUG ("Setting Service to %s", service); - tpaw_account_settings_set_service (self->priv->settings, service); - - g_free (address); - g_free (service); - } - else - { - /* No server. Unset values */ - unset_server_params (self); - } - - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); -} - -static void -set_label (TpawIrcNetworkChooser *self) -{ - g_assert (self->priv->network != NULL); - - gtk_button_set_label (GTK_BUTTON (self), - tpaw_irc_network_get_name (self->priv->network)); -} - -static void -set_label_from_settings (TpawIrcNetworkChooser *self) -{ - gchar *server; - - tp_clear_object (&self->priv->network); - - server = tpaw_account_settings_dup_string (self->priv->settings, "server"); - - if (server != NULL) - { - TpawIrcServer *srv; - gint port; - gboolean ssl; - - self->priv->network = - tpaw_irc_network_manager_find_network_by_address ( - self->priv->network_manager, server); - - if (self->priv->network != NULL) - { - /* The network is known */ - g_object_ref (self->priv->network); - set_label (self); - return; - } - - /* We don't have this network. Let's create it */ - port = tpaw_account_settings_get_uint32 (self->priv->settings, "port"); - ssl = tpaw_account_settings_get_boolean (self->priv->settings, - "use-ssl"); - - DEBUG ("Create a network %s", server); - self->priv->network = tpaw_irc_network_new (server); - srv = tpaw_irc_server_new (server, port, ssl); - - tpaw_irc_network_append_server (self->priv->network, srv); - tpaw_irc_network_manager_add (self->priv->network_manager, - self->priv->network); - - set_label (self); - - g_object_unref (srv); - g_free (server); - return; - } - - /* Set default network */ - self->priv->network = tpaw_irc_network_manager_find_network_by_address ( - self->priv->network_manager, DEFAULT_IRC_NETWORK); - - if (self->priv->network == NULL) - { - /* Default network is not known, recreate it */ - TpawIrcServer *srv; - - self->priv->network = tpaw_irc_network_new (DEFAULT_IRC_NETWORK); - - srv = tpaw_irc_server_new (DEFAULT_IRC_NETWORK, DEFAULT_IRC_PORT, - DEFAULT_IRC_SSL); - - tpaw_irc_network_append_server (self->priv->network, srv); - tpaw_irc_network_manager_add (self->priv->network_manager, - self->priv->network); - - g_object_unref (srv); - } - - set_label (self); - update_server_params (self); - g_object_ref (self->priv->network); -} - -static void -dialog_response_cb (GtkDialog *dialog, - gint response, - TpawIrcNetworkChooser *self) -{ - TpawIrcNetworkChooserDialog *chooser = - TPAW_IRC_NETWORK_CHOOSER_DIALOG (self->priv->dialog); - - if (response != GTK_RESPONSE_CLOSE && - response != GTK_RESPONSE_DELETE_EVENT) - return; - - if (tpaw_irc_network_chooser_dialog_get_changed (chooser)) - { - tp_clear_object (&self->priv->network); - - self->priv->network = g_object_ref ( - tpaw_irc_network_chooser_dialog_get_network (chooser)); - - update_server_params (self); - set_label (self); - - g_signal_emit (self, signals[SIG_CHANGED], 0); - } - - gtk_widget_destroy (self->priv->dialog); - self->priv->dialog = NULL; -} - -static void -clicked_cb (GtkButton *button, - gpointer user_data) -{ - TpawIrcNetworkChooser *self = TPAW_IRC_NETWORK_CHOOSER (button); - GtkWindow *window; - - if (self->priv->dialog != NULL) - goto out; - - window = tpaw_get_toplevel_window (GTK_WIDGET (button)); - - self->priv->dialog = tpaw_irc_network_chooser_dialog_new ( - self->priv->settings, self->priv->network, window); - gtk_widget_show_all (self->priv->dialog); - - tp_g_signal_connect_object (self->priv->dialog, "response", - G_CALLBACK (dialog_response_cb), button, 0); - -out: - tpaw_window_present (GTK_WINDOW (self->priv->dialog)); -} - -static void -tpaw_irc_network_chooser_constructed (GObject *object) -{ - TpawIrcNetworkChooser *self = (TpawIrcNetworkChooser *) object; - - g_assert (self->priv->settings != NULL); - - set_label_from_settings (self); - - g_signal_connect (self, "clicked", G_CALLBACK (clicked_cb), self); -} - -static void -tpaw_irc_network_chooser_dispose (GObject *object) -{ - TpawIrcNetworkChooser *self = (TpawIrcNetworkChooser *) object; - - tp_clear_object (&self->priv->settings); - tp_clear_object (&self->priv->network_manager); - tp_clear_object (&self->priv->network); - - if (G_OBJECT_CLASS (tpaw_irc_network_chooser_parent_class)->dispose) - G_OBJECT_CLASS (tpaw_irc_network_chooser_parent_class)->dispose (object); -} - -static void -tpaw_irc_network_chooser_class_init (TpawIrcNetworkChooserClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = tpaw_irc_network_chooser_get_property; - object_class->set_property = tpaw_irc_network_chooser_set_property; - object_class->constructed = tpaw_irc_network_chooser_constructed; - object_class->dispose = tpaw_irc_network_chooser_dispose; - - g_object_class_install_property (object_class, PROP_SETTINGS, - g_param_spec_object ("settings", - "Settings", - "The TpawAccountSettings to show and edit", - TPAW_TYPE_ACCOUNT_SETTINGS, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - signals[SIG_CHANGED] = g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, - 0); - - g_type_class_add_private (object_class, - sizeof (TpawIrcNetworkChooserPriv)); -} - -static void -tpaw_irc_network_chooser_init (TpawIrcNetworkChooser *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_IRC_NETWORK_CHOOSER, TpawIrcNetworkChooserPriv); - - self->priv->network_manager = tpaw_irc_network_manager_dup_default (); -} - -GtkWidget * -tpaw_irc_network_chooser_new (TpawAccountSettings *settings) -{ - return g_object_new (TPAW_TYPE_IRC_NETWORK_CHOOSER, - "settings", settings, - NULL); -} - -TpawIrcNetwork * -tpaw_irc_network_chooser_get_network (TpawIrcNetworkChooser *self) -{ - return self->priv->network; -} diff --git a/tp-account-widgets/tpaw-irc-network-chooser.h b/tp-account-widgets/tpaw-irc-network-chooser.h deleted file mode 100644 index 175679c37..000000000 --- a/tp-account-widgets/tpaw-irc-network-chooser.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_NETWORK_CHOOSER_H__ -#define __TPAW_IRC_NETWORK_CHOOSER_H__ - -#include <gtk/gtk.h> - -#include "tpaw-account-settings.h" -#include "tpaw-irc-network.h" - -G_BEGIN_DECLS - -#define TPAW_TYPE_IRC_NETWORK_CHOOSER (tpaw_irc_network_chooser_get_type ()) -#define TPAW_IRC_NETWORK_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER, TpawIrcNetworkChooser)) -#define TPAW_IRC_NETWORK_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER, TpawIrcNetworkChooserClass)) -#define TPAW_IS_IRC_NETWORK_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER)) -#define TPAW_IS_IRC_NETWORK_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \ - TPAW_TYPE_IRC_NETWORK_CHOOSER)) -#define TPAW_IRC_NETWORK_CHOOSER_GET_CLASS(o) ( \ - G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK_CHOOSER, \ - TpawIrcNetworkChooserClass)) - -typedef struct _TpawIrcNetworkChooserPriv TpawIrcNetworkChooserPriv; - -typedef struct { - GtkButton parent; - - /*<private>*/ - TpawIrcNetworkChooserPriv *priv; -} TpawIrcNetworkChooser; - -typedef struct { - GtkButtonClass parent_class; -} TpawIrcNetworkChooserClass; - -GType tpaw_irc_network_chooser_get_type (void) G_GNUC_CONST; - -GtkWidget * tpaw_irc_network_chooser_new (TpawAccountSettings *settings); - -TpawIrcNetwork * tpaw_irc_network_chooser_get_network ( - TpawIrcNetworkChooser *self); - -G_END_DECLS - -#endif /* __TPAW_IRC_NETWORK_CHOOSER_H__ */ diff --git a/tp-account-widgets/tpaw-irc-network-dialog.c b/tp-account-widgets/tpaw-irc-network-dialog.c deleted file mode 100644 index 3a83d947d..000000000 --- a/tp-account-widgets/tpaw-irc-network-dialog.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-network-dialog.h" - -#include <glib/gi18n-lib.h> -#include <stdlib.h> - -#include "tpaw-builder.h" -#include "tpaw-utils.h" -#include "totem-subtitle-encoding.h" - -typedef struct { - TpawIrcNetwork *network; - - GtkWidget *dialog; - GtkWidget *button_close; - - GtkWidget *entry_network; - GtkWidget *combobox_charset; - - GtkWidget *treeview_servers; - GtkWidget *button_add; - GtkWidget *button_remove; - GtkWidget *button_up; - GtkWidget *button_down; -} TpawIrcNetworkDialog; - -static void -irc_network_dialog_destroy_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - g_object_unref (dialog->network); - - g_slice_free (TpawIrcNetworkDialog, dialog); -} - -static void -irc_network_dialog_close_clicked_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - gtk_widget_destroy (dialog->dialog); -} - -enum { - COL_SRV_OBJ, - COL_ADR, - COL_PORT, - COL_SSL -}; - -static void -add_server_to_store (GtkListStore *store, - TpawIrcServer *server, - GtkTreeIter *iter) -{ - gchar *address; - guint port; - gboolean ssl; - - g_object_get (server, - "address", &address, - "port", &port, - "ssl", &ssl, - NULL); - - gtk_list_store_insert_with_values (store, iter, -1, - COL_SRV_OBJ, server, - COL_ADR, address, - COL_PORT, port, - COL_SSL, ssl, - -1); - - g_free (address); -} - -static void -irc_network_dialog_setup (TpawIrcNetworkDialog *dialog) -{ - gchar *name, *charset; - GSList *servers, *l; - GtkListStore *store; - - g_object_get (dialog->network, - "name", &name, - "charset", &charset, - NULL); - gtk_entry_set_text (GTK_ENTRY (dialog->entry_network), name); - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - - servers = tpaw_irc_network_get_servers (dialog->network); - for (l = servers; l != NULL; l = g_slist_next (l)) - { - TpawIrcServer *server = l->data; - GtkTreeIter iter; - - add_server_to_store (store, server, &iter); - } - - totem_subtitle_encoding_set (GTK_COMBO_BOX (dialog->combobox_charset), - charset); - - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); - g_free (name); - g_free (charset); -} - -static void -irc_network_dialog_address_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - TpawIrcNetworkDialog *dialog) -{ - TpawIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - -1); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_ADR, new_text, - -1); - - g_object_set (server, "address", new_text, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static void -irc_network_dialog_port_edited_cb (GtkCellRendererText *renderer, - gchar *path, - gchar *new_text, - TpawIrcNetworkDialog *dialog) -{ - TpawIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - guint port; - - port = strtoul (new_text, NULL, 10); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - -1); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_PORT, port, - -1); - - g_object_set (server, "port", port, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static void -irc_network_dialog_ssl_toggled_cb (GtkCellRendererText *renderer, - gchar *path, - TpawIrcNetworkDialog *dialog) -{ - TpawIrcServer *server; - GtkTreeModel *model; - GtkTreePath *treepath; - GtkTreeIter iter; - gboolean ssl; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_servers)); - treepath = gtk_tree_path_new_from_string (path); - gtk_tree_model_get_iter (model, &iter, treepath); - gtk_tree_model_get (model, &iter, - COL_SRV_OBJ, &server, - COL_SSL, &ssl, - -1); - ssl = !ssl; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - COL_SSL, ssl, - -1); - - g_object_set (server, "ssl", ssl, NULL); - - gtk_tree_path_free (treepath); - g_object_unref (server); -} - -static gboolean -irc_network_dialog_network_focus_cb (GtkWidget *widget, - GdkEventFocus *event, - TpawIrcNetworkDialog *dialog) -{ - const gchar *str; - - str = gtk_entry_get_text (GTK_ENTRY (widget)); - - g_object_set (dialog->network, "name", str, NULL); - - return FALSE; -} - -static void -irc_network_dialog_network_update_buttons (TpawIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gboolean can_remove = FALSE, can_move_up = FALSE, can_move_down = FALSE; - int selected; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW ( - dialog->treeview_servers)); - - if (gtk_tree_selection_get_selected (selection, &model, &iter)) - { - path = gtk_tree_model_get_path (model, &iter); - - selected = gtk_tree_path_get_indices (path)[0]; - - can_remove = TRUE; - can_move_up = selected > 0; - can_move_down = - selected < gtk_tree_model_iter_n_children (model, NULL) - 1; - - gtk_tree_path_free (path); - } - - gtk_widget_set_sensitive (dialog->button_remove, can_remove); - gtk_widget_set_sensitive (dialog->button_up, can_move_up); - gtk_widget_set_sensitive (dialog->button_down, can_move_down); -} - -static void -irc_network_dialog_button_add_clicked_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - TpawIrcServer *server; - GtkListStore *store; - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeViewColumn *column; - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - - server = tpaw_irc_server_new (_("new server"), 6667, FALSE); - tpaw_irc_network_append_server (dialog->network, server); - add_server_to_store (store, server, &iter); - - path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 0); - gtk_tree_view_set_cursor (GTK_TREE_VIEW (dialog->treeview_servers), path, - column, TRUE); - - irc_network_dialog_network_update_buttons (dialog); - - gtk_tree_path_free (path); - g_object_unref (server); -} - -static void -irc_network_dialog_button_remove_clicked_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter; - TpawIrcServer *server; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_list_store_remove (GTK_LIST_STORE (model), &iter); - tpaw_irc_network_remove_server (dialog->network, server); - - irc_network_dialog_network_update_buttons (dialog); - - g_object_unref (server); -} - -static void -irc_network_dialog_button_up_clicked_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter, iter_prev; - GtkTreePath *path; - gint *pos; - TpawIrcServer *server; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - path = gtk_tree_model_get_path (model, &iter); - - if (!gtk_tree_path_prev (path)) - { - gtk_tree_path_free (path); - return; - } - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_tree_model_get_iter (model, &iter_prev, path); - gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter); - - pos = gtk_tree_path_get_indices (path); - tpaw_irc_network_set_server_position (dialog->network, server, *pos); - - irc_network_dialog_network_update_buttons (dialog); - - g_object_unref (server); - gtk_tree_path_free (path); -} - -static void -irc_network_dialog_button_down_clicked_cb (GtkWidget *widget, - TpawIrcNetworkDialog *dialog) -{ - GtkTreeSelection *selection; - GtkTreeModel *model; - GtkTreeIter iter, iter_prev; - GtkTreePath *path; - TpawIrcServer *server; - gint *pos; - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - - if (!gtk_tree_selection_get_selected (selection, &model, &iter)) - return; - - path = gtk_tree_model_get_path (model, &iter); - - gtk_tree_path_next (path); - if (!gtk_tree_model_get_iter (model, &iter_prev, path)) - { - gtk_tree_path_free (path); - return; - } - - gtk_tree_model_get (model, &iter, COL_SRV_OBJ, &server, -1); - - gtk_list_store_swap (GTK_LIST_STORE (model), &iter_prev, &iter); - - pos = gtk_tree_path_get_indices (path); - tpaw_irc_network_set_server_position (dialog->network, server, *pos); - - irc_network_dialog_network_update_buttons (dialog); - - gtk_tree_path_free (path); -} - -static void -irc_network_dialog_selection_changed_cb (GtkTreeSelection *treeselection, - TpawIrcNetworkDialog *dialog) -{ - irc_network_dialog_network_update_buttons (dialog); -} - -static void -irc_network_dialog_combobox_charset_changed_cb (GtkWidget *combobox, - TpawIrcNetworkDialog *dialog) -{ - const gchar *charset; - - charset = totem_subtitle_encoding_get_selected (GTK_COMBO_BOX (combobox)); - g_object_set (dialog->network, "charset", charset, NULL); -} - -static void -change_network (TpawIrcNetworkDialog *dialog, - TpawIrcNetwork *network) -{ - GtkListStore *store; - - if (dialog->network == network) - /* No need to change */ - return; - - if (dialog->network != NULL) - { - g_object_unref (dialog->network); - } - - dialog->network = network; - g_object_ref (network); - - store = GTK_LIST_STORE (gtk_tree_view_get_model ( - GTK_TREE_VIEW (dialog->treeview_servers))); - gtk_list_store_clear (store); - - irc_network_dialog_setup (dialog); -} - -/** - * tpaw_irc_network_dialog_show: - * @network: the #TpawIrcNetwork to configure - * @parent: the parent of this dialog - * - * Display a dialog to configure a given #TpawIrcNetwork. - * This function is a singleton so if a configuration dialog already - * exists we use this one to edit the network. - * - * Returns: The displayed #GtkDialog - */ -GtkWidget * -tpaw_irc_network_dialog_show (TpawIrcNetwork *network, - GtkWidget *parent) -{ - static TpawIrcNetworkDialog *dialog = NULL; - GtkBuilder *gui; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkAdjustment *adjustment; - GtkTreeSelection *selection; - GtkTreeViewColumn *column; - GtkWidget *sw, *toolbar; - GtkStyleContext *context; - - g_return_val_if_fail (network != NULL, NULL); - - if (dialog != NULL) - { - change_network (dialog, network); - gtk_window_present (GTK_WINDOW (dialog->dialog)); - - return dialog->dialog; - } - - dialog = g_slice_new0 (TpawIrcNetworkDialog); - - dialog->network = network; - g_object_ref (dialog->network); - - gui = tpaw_builder_get_resource (TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/tpaw-account-widget-irc.ui", - "irc_network_dialog", &dialog->dialog, - "button_close", &dialog->button_close, - "entry_network", &dialog->entry_network, - "combobox_charset", &dialog->combobox_charset, - "treeview_servers", &dialog->treeview_servers, - "button_add", &dialog->button_add, - "button_remove", &dialog->button_remove, - "button_up", &dialog->button_up, - "button_down", &dialog->button_down, - "scrolledwindow_network_server", &sw, - "toolbar_network_server", &toolbar, - NULL); - - store = gtk_list_store_new (4, G_TYPE_OBJECT, G_TYPE_STRING, - G_TYPE_UINT, G_TYPE_BOOLEAN); - gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview_servers), - GTK_TREE_MODEL (store)); - g_object_unref (store); - - /* address */ - renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "editable", TRUE, NULL); - g_signal_connect (renderer, "edited", - G_CALLBACK (irc_network_dialog_address_edited_cb), dialog); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("Server"), renderer, "text", COL_ADR, - NULL); - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 0); - - gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_expand (column, TRUE); - - /* port */ - adjustment = (GtkAdjustment *) gtk_adjustment_new (6667, 1, G_MAXUINT16, - 1, 10, 0); - renderer = gtk_cell_renderer_spin_new (); - g_object_set (renderer, - "editable", TRUE, - "adjustment", adjustment, - NULL); - g_signal_connect (renderer, "edited", - G_CALLBACK (irc_network_dialog_port_edited_cb), dialog); - - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("Port"), renderer, "text", COL_PORT, - NULL); - - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 1); - gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - gtk_tree_view_column_set_expand (column, TRUE); - - /* SSL */ - renderer = gtk_cell_renderer_toggle_new (); - g_object_set (renderer, "activatable", TRUE, NULL); - g_signal_connect (renderer, "toggled", - G_CALLBACK (irc_network_dialog_ssl_toggled_cb), dialog); - gtk_tree_view_insert_column_with_attributes ( - GTK_TREE_VIEW (dialog->treeview_servers), - -1, _("SSL"), renderer, "active", COL_SSL, - NULL); - - selection = gtk_tree_view_get_selection ( - GTK_TREE_VIEW (dialog->treeview_servers)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), - 2); - gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); - - gtk_tree_view_column_set_expand (column, TRUE); - /* charset */ - totem_subtitle_encoding_init (GTK_COMBO_BOX (dialog->combobox_charset)); - - irc_network_dialog_setup (dialog); - - tpaw_builder_connect (gui, dialog, - "irc_network_dialog", "destroy", irc_network_dialog_destroy_cb, - "button_close", "clicked", irc_network_dialog_close_clicked_cb, - "entry_network", "focus-out-event", irc_network_dialog_network_focus_cb, - "button_add", "clicked", irc_network_dialog_button_add_clicked_cb, - "button_remove", "clicked", irc_network_dialog_button_remove_clicked_cb, - "button_up", "clicked", irc_network_dialog_button_up_clicked_cb, - "button_down", "clicked", irc_network_dialog_button_down_clicked_cb, - "combobox_charset", "changed", irc_network_dialog_combobox_charset_changed_cb, - NULL); - - g_object_unref (gui); - - g_object_add_weak_pointer (G_OBJECT (dialog->dialog), - (gpointer) &dialog); - - g_signal_connect (selection, "changed", - G_CALLBACK (irc_network_dialog_selection_changed_cb), - dialog); - - gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), - GTK_WINDOW (parent)); - gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); - - /* join the add/remove toolbar to the treeview */ - context = gtk_widget_get_style_context (sw); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM); - - context = gtk_widget_get_style_context (toolbar); - gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP); - - irc_network_dialog_network_update_buttons (dialog); - gtk_widget_show_all (dialog->dialog); - - gtk_window_set_resizable (GTK_WINDOW (dialog->dialog), FALSE); - - return dialog->dialog; -} diff --git a/tp-account-widgets/tpaw-irc-network-dialog.h b/tp-account-widgets/tpaw-irc-network-dialog.h deleted file mode 100644 index a65754bb9..000000000 --- a/tp-account-widgets/tpaw-irc-network-dialog.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_NETWORK_DIALOG_H__ -#define __TPAW_IRC_NETWORK_DIALOG_H__ - -#include <gtk/gtk.h> - -#include "tpaw-irc-network.h" - -G_BEGIN_DECLS - -GtkWidget * tpaw_irc_network_dialog_show (TpawIrcNetwork *network, - GtkWidget *parent); - -G_END_DECLS - -#endif /* __TPAW_IRC_NETWORK_DIALOG_H__ */ diff --git a/tp-account-widgets/tpaw-irc-network-manager.c b/tp-account-widgets/tpaw-irc-network-manager.c deleted file mode 100644 index 8d074509b..000000000 --- a/tp-account-widgets/tpaw-irc-network-manager.c +++ /dev/null @@ -1,822 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-network-manager.h" - -#include <sys/stat.h> - -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_IRC -#include "tpaw-debug.h" - -#define IRC_NETWORKS_DTD_RESOURCENAME "/org/gnome/AccountWidgets/tpaw-irc-networks.dtd" -#define IRC_NETWORKS_FILENAME "irc-networks.xml" -#define SAVE_TIMER 4 - -struct _TpawIrcNetworkManagerPriv { - GHashTable *networks; - - gchar *global_file; - gchar *user_file; - guint last_id; - - /* Do we have to save modifications to the user file ? */ - gboolean have_to_save; - /* Are we loading networks from XML files ? */ - gboolean loading; - /* source id of the autosave timer */ - gint save_timer_id; -}; - -/* properties */ -enum -{ - PROP_GLOBAL_FILE = 1, - PROP_USER_FILE, - LAST_PROPERTY -}; - -G_DEFINE_TYPE (TpawIrcNetworkManager, tpaw_irc_network_manager, - G_TYPE_OBJECT); - -static void irc_network_manager_load_servers ( - TpawIrcNetworkManager *manager); -static gboolean irc_network_manager_file_parse ( - TpawIrcNetworkManager *manager, const gchar *filename, - gboolean user_defined); -static gboolean irc_network_manager_file_save ( - TpawIrcNetworkManager *manager); - -static void -tpaw_irc_network_manager_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - - switch (property_id) - { - case PROP_GLOBAL_FILE: - g_value_set_string (value, self->priv->global_file); - break; - case PROP_USER_FILE: - g_value_set_string (value, self->priv->user_file); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_irc_network_manager_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - - switch (property_id) - { - case PROP_GLOBAL_FILE: - g_free (self->priv->global_file); - self->priv->global_file = g_value_dup_string (value); - break; - case PROP_USER_FILE: - g_free (self->priv->user_file); - self->priv->user_file = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static GObject * -tpaw_irc_network_manager_constructor (GType type, - guint n_props, - GObjectConstructParam *props) -{ - GObject *obj; - TpawIrcNetworkManager *self; - - /* Parent constructor chain */ - obj = G_OBJECT_CLASS (tpaw_irc_network_manager_parent_class)-> - constructor (type, n_props, props); - - self = TPAW_IRC_NETWORK_MANAGER (obj); - irc_network_manager_load_servers (self); - - return obj; -} - -static void -tpaw_irc_network_manager_finalize (GObject *object) -{ - TpawIrcNetworkManager *self = TPAW_IRC_NETWORK_MANAGER (object); - - if (self->priv->save_timer_id > 0) - { - g_source_remove (self->priv->save_timer_id); - } - - if (self->priv->have_to_save) - { - irc_network_manager_file_save (self); - } - - g_free (self->priv->global_file); - g_free (self->priv->user_file); - - g_hash_table_unref (self->priv->networks); - - G_OBJECT_CLASS (tpaw_irc_network_manager_parent_class)->finalize (object); -} - -static void -tpaw_irc_network_manager_init (TpawIrcNetworkManager *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_IRC_NETWORK_MANAGER, TpawIrcNetworkManagerPriv); - - self->priv->networks = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref); - - self->priv->last_id = 0; - - self->priv->have_to_save = FALSE; - self->priv->loading = FALSE; - self->priv->save_timer_id = 0; -} - -static void -tpaw_irc_network_manager_class_init (TpawIrcNetworkManagerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->constructor = tpaw_irc_network_manager_constructor; - object_class->get_property = tpaw_irc_network_manager_get_property; - object_class->set_property = tpaw_irc_network_manager_set_property; - - g_type_class_add_private (object_class, sizeof (TpawIrcNetworkManagerPriv)); - - object_class->finalize = tpaw_irc_network_manager_finalize; - - param_spec = g_param_spec_string ( - "global-file", - "path of the global networks file", - "The path of the system-wide filename from which we have to load" - " the networks list", - NULL, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_GLOBAL_FILE, param_spec); - - param_spec = g_param_spec_string ( - "user-file", - "path of the user networks file", - "The path of user's filename from which we have to load" - " the networks list and to which we'll save his modifications", - NULL, - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_USER_FILE, param_spec); -} - -/** - * tpaw_irc_network_manager_new: - * @global_file: the path of the global networks file, or %NULL - * @user_file: the path of the user networks file, or %NULL - * - * Creates a new #TpawIrcNetworkManager - * - * Returns: a new #TpawIrcNetworkManager - */ -TpawIrcNetworkManager * -tpaw_irc_network_manager_new (const gchar *global_file, - const gchar *user_file) -{ - TpawIrcNetworkManager *manager; - - manager = g_object_new (TPAW_TYPE_IRC_NETWORK_MANAGER, - "global-file", global_file, - "user-file", user_file, - NULL); - - return manager; -} - -static gboolean -save_timeout (TpawIrcNetworkManager *self) -{ - self->priv->save_timer_id = 0; - irc_network_manager_file_save (self); - - return FALSE; -} - -static void -reset_save_timeout (TpawIrcNetworkManager *self) -{ - if (self->priv->save_timer_id > 0) - { - g_source_remove (self->priv->save_timer_id); - } - - self->priv->save_timer_id = g_timeout_add_seconds (SAVE_TIMER, - (GSourceFunc) save_timeout, self); -} - -static void -network_modified (TpawIrcNetwork *network, - TpawIrcNetworkManager *self) -{ - network->user_defined = TRUE; - - if (!self->priv->loading) - { - self->priv->have_to_save = TRUE; - reset_save_timeout (self); - } -} - -static void -add_network (TpawIrcNetworkManager *self, - TpawIrcNetwork *network, - const gchar *id) -{ - g_hash_table_insert (self->priv->networks, g_strdup (id), - g_object_ref (network)); - - g_signal_connect (network, "modified", G_CALLBACK (network_modified), self); -} - -/** - * tpaw_irc_network_manager_add: - * @manager: an #TpawIrcNetworkManager - * @network: the #TpawIrcNetwork to add - * - * Add an #TpawIrcNetwork to the given #TpawIrcNetworkManager. - * - */ -void -tpaw_irc_network_manager_add (TpawIrcNetworkManager *self, - TpawIrcNetwork *network) -{ - gchar *id = NULL; - - g_return_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self)); - g_return_if_fail (TPAW_IS_IRC_NETWORK (network)); - - /* generate an id for this network */ - do - { - g_free (id); - id = g_strdup_printf ("id%u", ++self->priv->last_id); - } while (g_hash_table_lookup (self->priv->networks, id) != NULL && - self->priv->last_id < G_MAXUINT); - - if (self->priv->last_id == G_MAXUINT) - { - DEBUG ("Can't add network: too many networks using a similar ID"); - return; - } - - DEBUG ("add server with \"%s\" as ID", id); - - network->user_defined = TRUE; - add_network (self, network, id); - - self->priv->have_to_save = TRUE; - reset_save_timeout (self); - - g_free (id); -} - -/** - * tpaw_irc_network_manager_remove: - * @manager: an #TpawIrcNetworkManager - * @network: the #TpawIrcNetwork to remove - * - * Remove an #TpawIrcNetwork from the given #TpawIrcNetworkManager. - * - */ -void -tpaw_irc_network_manager_remove (TpawIrcNetworkManager *self, - TpawIrcNetwork *network) -{ - g_return_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self)); - g_return_if_fail (TPAW_IS_IRC_NETWORK (network)); - - network->user_defined = TRUE; - network->dropped = TRUE; - - self->priv->have_to_save = TRUE; - reset_save_timeout (self); -} - -static void -append_active_networks_to_list (const gchar *id, - TpawIrcNetwork *network, - GSList **list) -{ - if (network->dropped) - return; - - *list = g_slist_prepend (*list, g_object_ref (network)); -} - -static void -append_dropped_networks_to_list (const gchar *id, - TpawIrcNetwork *network, - GSList **list) -{ - if (!network->dropped) - return; - - *list = g_slist_prepend (*list, g_object_ref (network)); -} - -static GSList * -get_network_list (TpawIrcNetworkManager *self, - gboolean get_active) -{ - GSList *irc_networks = NULL; - - g_return_val_if_fail (TPAW_IS_IRC_NETWORK_MANAGER (self), NULL); - - if (get_active) - { - g_hash_table_foreach (self->priv->networks, - (GHFunc) append_active_networks_to_list, &irc_networks); - } - else - { - g_hash_table_foreach (self->priv->networks, - (GHFunc) append_dropped_networks_to_list, &irc_networks); - } - - return irc_networks; -} - -/** - * tpaw_irc_network_manager_get_networks: - * @manager: an #TpawIrcNetworkManager - * - * Get the list of #TpawIrcNetwork associated with the given - * manager. - * - * Returns: a new #GSList of refed #TpawIrcNetwork - */ -GSList * -tpaw_irc_network_manager_get_networks (TpawIrcNetworkManager *self) -{ - return get_network_list (self, TRUE); -} - -/** - * tpaw_irc_network_manager_get_dropped_networks: - * @manager: an #TpawIrcNetworkManager - * - * Get the list of dropped #TpawIrcNetworks associated with the given - * manager. - * - * Returns: a new #GSList of refed dropped #TpawIrcNetworks - */ -GSList * -tpaw_irc_network_manager_get_dropped_networks (TpawIrcNetworkManager *self) -{ - return get_network_list (self, FALSE); -} - -/* - * API to save/load and parse the irc_networks file. - */ - -static void -load_global_file (TpawIrcNetworkManager *self) -{ - if (self->priv->global_file == NULL) - return; - - if (!g_file_test (self->priv->global_file, G_FILE_TEST_EXISTS)) - { - DEBUG ("Global networks file %s doesn't exist", - self->priv->global_file); - return; - } - - irc_network_manager_file_parse (self, self->priv->global_file, FALSE); -} - -static void -load_user_file (TpawIrcNetworkManager *self) -{ - if (self->priv->user_file == NULL) - return; - - if (!g_file_test (self->priv->user_file, G_FILE_TEST_EXISTS)) - { - DEBUG ("User networks file %s doesn't exist", self->priv->global_file); - return; - } - - irc_network_manager_file_parse (self, self->priv->user_file, TRUE); -} - -static void -irc_network_manager_load_servers (TpawIrcNetworkManager *self) -{ - self->priv->loading = TRUE; - - load_global_file (self); - load_user_file (self); - - self->priv->loading = FALSE; - self->priv->have_to_save = FALSE; -} - -static void -irc_network_manager_parse_irc_server (TpawIrcNetwork *network, - xmlNodePtr node) -{ - xmlNodePtr server_node; - - for (server_node = node->children; server_node; - server_node = server_node->next) - { - gchar *address = NULL, *port = NULL, *ssl = NULL; - - if (g_strcmp0 ((const gchar *) server_node->name, "server") != 0) - continue; - - address = (gchar *) xmlGetProp (server_node, (const xmlChar *) "address"); - port = (gchar *) xmlGetProp (server_node, (const xmlChar *) "port"); - ssl = (gchar *) xmlGetProp (server_node, (const xmlChar *) "ssl"); - - if (address != NULL) - { - gint port_nb = 0; - gboolean have_ssl = FALSE; - TpawIrcServer *server; - - if (port != NULL) - port_nb = strtol (port, NULL, 10); - - if (port_nb <= 0 || port_nb > G_MAXUINT16) - port_nb = 6667; - - if (ssl == NULL || g_strcmp0 (ssl, "TRUE") == 0) - have_ssl = TRUE; - - DEBUG ("parsed server %s port %d ssl %d", address, port_nb, have_ssl); - - server = tpaw_irc_server_new (address, port_nb, have_ssl); - tpaw_irc_network_append_server (network, server); - } - - if (address) - xmlFree (address); - if (port) - xmlFree (port); - if (ssl) - xmlFree (ssl); - } -} - -static void -irc_network_manager_parse_irc_network (TpawIrcNetworkManager *self, - xmlNodePtr node, - gboolean user_defined) -{ - TpawIrcNetwork *network; - xmlNodePtr child; - gchar *str; - gchar *id, *name; - - id = (gchar *) xmlGetProp (node, (const xmlChar *) "id"); - if (xmlHasProp (node, (const xmlChar *) "dropped")) - { - if (!user_defined) - { - DEBUG ("the 'dropped' attribute shouldn't be used in the global file"); - } - - network = g_hash_table_lookup (self->priv->networks, id); - if (network != NULL) - { - network->dropped = TRUE; - network->user_defined = TRUE; - } - xmlFree (id); - return; - } - - if (!xmlHasProp (node, (const xmlChar *) "name")) - return; - - name = (gchar *) xmlGetProp (node, (const xmlChar *) "name"); - network = tpaw_irc_network_new (name); - - if (xmlHasProp (node, (const xmlChar *) "network_charset")) - { - gchar *charset; - charset = (gchar *) xmlGetProp (node, (const xmlChar *) "network_charset"); - g_object_set (network, "charset", charset, NULL); - xmlFree (charset); - } - - add_network (self, network, id); - DEBUG ("add network %s (id %s)", name, id); - - for (child = node->children; child; child = child->next) - { - gchar *tag; - - tag = (gchar *) child->name; - str = (gchar *) xmlNodeGetContent (child); - - if (!str) - continue; - - if (g_strcmp0 (tag, "servers") == 0) - { - irc_network_manager_parse_irc_server (network, child); - } - - xmlFree (str); - } - - network->user_defined = user_defined; - g_object_unref (network); - xmlFree (name); - xmlFree (id); -} - -static gboolean -irc_network_manager_file_parse (TpawIrcNetworkManager *self, - const gchar *filename, - gboolean user_defined) -{ - xmlParserCtxtPtr ctxt; - xmlDocPtr doc; - xmlNodePtr networks; - xmlNodePtr node; - - DEBUG ("Attempting to parse file:'%s'...", filename); - - ctxt = xmlNewParserCtxt (); - - /* Parse and validate the file. */ - doc = xmlCtxtReadFile (ctxt, filename, NULL, 0); - if (!doc) - { - g_warning ("Failed to parse file:'%s'", filename); - xmlFreeParserCtxt (ctxt); - return FALSE; - } - - if (!tpaw_xml_validate_from_resource (doc, IRC_NETWORKS_DTD_RESOURCENAME)) { - g_warning ("Failed to validate file:'%s'", filename); - xmlFreeDoc (doc); - xmlFreeParserCtxt (ctxt); - return FALSE; - } - - /* The root node, networks. */ - networks = xmlDocGetRootElement (doc); - - for (node = networks->children; node; node = node->next) - { - irc_network_manager_parse_irc_network (self, node, user_defined); - } - - xmlFreeDoc (doc); - xmlFreeParserCtxt (ctxt); - - return TRUE; -} - -static void -write_network_to_xml (const gchar *id, - TpawIrcNetwork *network, - xmlNodePtr root) -{ - xmlNodePtr network_node, servers_node; - GSList *servers, *l; - gchar *name, *charset; - - if (!network->user_defined) - /* no need to write this network to the XML */ - return; - - network_node = xmlNewChild (root, NULL, (const xmlChar *) "network", NULL); - xmlNewProp (network_node, (const xmlChar *) "id", (const xmlChar *) id); - - if (network->dropped) - { - xmlNewProp (network_node, (const xmlChar *) "dropped", - (const xmlChar *) "1"); - return; - } - - g_object_get (network, - "name", &name, - "charset", &charset, - NULL); - xmlNewProp (network_node, (const xmlChar *) "name", (const xmlChar *) name); - xmlNewProp (network_node, (const xmlChar *) "network_charset", - (const xmlChar *) charset); - g_free (name); - g_free (charset); - - servers = tpaw_irc_network_get_servers (network); - - servers_node = xmlNewChild (network_node, NULL, (const xmlChar *) "servers", - NULL); - for (l = servers; l != NULL; l = g_slist_next (l)) - { - TpawIrcServer *server; - xmlNodePtr server_node; - gchar *address, *tmp; - guint port; - gboolean ssl; - - server = l->data; - - server_node = xmlNewChild (servers_node, NULL, (const xmlChar *) "server", - NULL); - - g_object_get (server, - "address", &address, - "port", &port, - "ssl", &ssl, - NULL); - - xmlNewProp (server_node, (const xmlChar *) "address", - (const xmlChar *) address); - - tmp = g_strdup_printf ("%u", port); - xmlNewProp (server_node, (const xmlChar *) "port", - (const xmlChar *) tmp); - g_free (tmp); - - xmlNewProp (server_node, (const xmlChar *) "ssl", - ssl ? (const xmlChar *) "TRUE": (const xmlChar *) "FALSE"); - - g_free (address); - } - - /* free the list */ - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); -} - -static gboolean -irc_network_manager_file_save (TpawIrcNetworkManager *self) -{ - xmlDocPtr doc; - xmlNodePtr root; - - if (self->priv->user_file == NULL) - { - DEBUG ("can't save: no user file defined"); - return FALSE; - } - - DEBUG ("Saving IRC networks"); - - doc = xmlNewDoc ((const xmlChar *) "1.0"); - root = xmlNewNode (NULL, (const xmlChar *) "networks"); - xmlDocSetRootElement (doc, root); - - g_hash_table_foreach (self->priv->networks, - (GHFunc) write_network_to_xml, root); - - /* Make sure the XML is indented properly */ - xmlIndentTreeOutput = 1; - - xmlSaveFormatFileEnc (self->priv->user_file, doc, "utf-8", 1); - xmlFreeDoc (doc); - - xmlMemoryDump (); - - self->priv->have_to_save = FALSE; - - return TRUE; -} - -static gboolean -find_network_by_address (const gchar *id, - TpawIrcNetwork *network, - const gchar *address) -{ - GSList *servers, *l; - gboolean found = FALSE; - - if (network->dropped) - return FALSE; - - servers = tpaw_irc_network_get_servers (network); - - for (l = servers; l != NULL && !found; l = g_slist_next (l)) - { - TpawIrcServer *server = l->data; - gchar *_address; - - g_object_get (server, "address", &_address, NULL); - found = (_address != NULL && g_strcmp0 (address, _address) == 0); - - g_free (_address); - } - - g_slist_foreach (servers, (GFunc) g_object_unref, NULL); - g_slist_free (servers); - - return found; -} - -/** - * tpaw_irc_network_manager_find_network_by_address: - * @manager: an #TpawIrcNetworkManager - * @address: the server address to look for - * - * Find the #TpawIrcNetwork which owns an #TpawIrcServer - * that has the given address. - * - * Returns: the found #TpawIrcNetwork, or %NULL if not found. - */ -TpawIrcNetwork * -tpaw_irc_network_manager_find_network_by_address ( - TpawIrcNetworkManager *self, - const gchar *address) -{ - TpawIrcNetwork *network; - - g_return_val_if_fail (address != NULL, NULL); - - network = g_hash_table_find (self->priv->networks, - (GHRFunc) find_network_by_address, (gchar *) address); - - return network; -} - -TpawIrcNetworkManager * -tpaw_irc_network_manager_dup_default (void) -{ - static TpawIrcNetworkManager *default_mgr = NULL; - gchar *dir, *user_file_with_path, *global_file_with_path; - - if (default_mgr != NULL) - return g_object_ref (default_mgr); - - dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL); - g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR); - user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL); - g_free (dir); - - global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"), - "tp-account-widgets", IRC_NETWORKS_FILENAME, NULL); - if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS)) - { - g_free (global_file_with_path); - global_file_with_path = g_build_filename (DATADIR, "empathy", - IRC_NETWORKS_FILENAME, NULL); - } - - default_mgr = tpaw_irc_network_manager_new ( - global_file_with_path, user_file_with_path); - - g_object_add_weak_pointer (G_OBJECT (default_mgr), (gpointer *) &default_mgr); - - g_free (global_file_with_path); - g_free (user_file_with_path); - return default_mgr; -} diff --git a/tp-account-widgets/tpaw-irc-network-manager.h b/tp-account-widgets/tpaw-irc-network-manager.h deleted file mode 100644 index b44209a02..000000000 --- a/tp-account-widgets/tpaw-irc-network-manager.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_NETWORK_MANAGER_H__ -#define __TPAW_IRC_NETWORK_MANAGER_H__ - -#include <glib-object.h> - -#include "tpaw-irc-network.h" - -G_BEGIN_DECLS - -typedef struct _TpawIrcNetworkManager TpawIrcNetworkManager; -typedef struct _TpawIrcNetworkManagerPriv TpawIrcNetworkManagerPriv; -typedef struct _TpawIrcNetworkManagerClass TpawIrcNetworkManagerClass; - -struct _TpawIrcNetworkManager -{ - GObject parent; - - /*<private>*/ - TpawIrcNetworkManagerPriv *priv; -}; - -struct _TpawIrcNetworkManagerClass -{ - GObjectClass parent_class; -}; - -GType tpaw_irc_network_manager_get_type (void); - -/* TYPE MACROS */ -#define TPAW_TYPE_IRC_NETWORK_MANAGER \ - (tpaw_irc_network_manager_get_type ()) -#define TPAW_IRC_NETWORK_MANAGER(o) \ - (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_IRC_NETWORK_MANAGER, \ - TpawIrcNetworkManager)) -#define TPAW_IRC_NETWORK_MANAGER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_IRC_NETWORK_MANAGER, \ - TpawIrcNetworkManagerClass)) -#define TPAW_IS_IRC_NETWORK_MANAGER(o) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_IRC_NETWORK_MANAGER)) -#define TPAW_IS_IRC_NETWORK_MANAGER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_IRC_NETWORK_MANAGER)) -#define TPAW_IRC_NETWORK_MANAGER_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK_MANAGER, \ - TpawIrcNetworkManagerClass)) - -TpawIrcNetworkManager * tpaw_irc_network_manager_new ( - const gchar *global_file, const gchar *user_file); - -TpawIrcNetworkManager * tpaw_irc_network_manager_dup_default (void); - -void tpaw_irc_network_manager_add (TpawIrcNetworkManager *manager, - TpawIrcNetwork *network); - -void tpaw_irc_network_manager_remove (TpawIrcNetworkManager *manager, - TpawIrcNetwork *network); - -GSList * tpaw_irc_network_manager_get_networks ( - TpawIrcNetworkManager *manager); - -GSList * tpaw_irc_network_manager_get_dropped_networks ( - TpawIrcNetworkManager *manager); - -TpawIrcNetwork * tpaw_irc_network_manager_find_network_by_address ( - TpawIrcNetworkManager *manager, const gchar *address); - -G_END_DECLS - -#endif /* __TPAW_IRC_NETWORK_MANAGER_H__ */ diff --git a/tp-account-widgets/tpaw-irc-network.c b/tp-account-widgets/tpaw-irc-network.c deleted file mode 100644 index f7355f369..000000000 --- a/tp-account-widgets/tpaw-irc-network.c +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright (C) 2007 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-network.h" - -#include "tpaw-utils.h" - -struct _TpawIrcNetworkPriv -{ - gchar *name; - gchar *charset; - GSList *servers; -}; - -/* properties */ -enum -{ - PROP_NAME = 1, - PROP_CHARSET, - LAST_PROPERTY -}; - -/* signals */ -enum -{ - MODIFIED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -G_DEFINE_TYPE (TpawIrcNetwork, tpaw_irc_network, G_TYPE_OBJECT); - -static void -server_modified_cb (TpawIrcServer *server, - TpawIrcNetwork *self) -{ - g_signal_emit (self, signals[MODIFIED], 0); -} - -static void -tpaw_irc_network_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - - switch (property_id) - { - case PROP_NAME: - g_value_set_string (value, self->priv->name); - break; - case PROP_CHARSET: - g_value_set_string (value, self->priv->charset); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_irc_network_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - - switch (property_id) - { - case PROP_NAME: - if (tp_strdiff (self->priv->name, g_value_get_string (value))) - { - g_free (self->priv->name); - self->priv->name = g_value_dup_string (value); - g_signal_emit (object, signals[MODIFIED], 0); - } - break; - case PROP_CHARSET: - if (tp_strdiff (self->priv->charset, g_value_get_string (value))) - { - g_free (self->priv->charset); - self->priv->charset = g_value_dup_string (value); - g_signal_emit (object, signals[MODIFIED], 0); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_irc_network_dispose (GObject *object) -{ - TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - GSList *l; - - for (l = self->priv->servers; l != NULL; l = g_slist_next (l)) - { - g_signal_handlers_disconnect_by_func (l->data, - G_CALLBACK (server_modified_cb), self); - g_object_unref (l->data); - } - - G_OBJECT_CLASS (tpaw_irc_network_parent_class)->dispose (object); -} - -static void -tpaw_irc_network_finalize (GObject *object) -{ - TpawIrcNetwork *self = TPAW_IRC_NETWORK (object); - - g_slist_free (self->priv->servers); - g_free (self->priv->name); - g_free (self->priv->charset); - - G_OBJECT_CLASS (tpaw_irc_network_parent_class)->finalize (object); -} - -static void -tpaw_irc_network_init (TpawIrcNetwork *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_NETWORK, - TpawIrcNetworkPriv); - - self->priv->servers = NULL; - - self->user_defined = TRUE; - self->dropped = FALSE; -} - -static void -tpaw_irc_network_class_init (TpawIrcNetworkClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->get_property = tpaw_irc_network_get_property; - object_class->set_property = tpaw_irc_network_set_property; - - g_type_class_add_private (object_class, sizeof (TpawIrcNetworkPriv)); - - object_class->dispose = tpaw_irc_network_dispose; - object_class->finalize = tpaw_irc_network_finalize; - - param_spec = g_param_spec_string ( - "name", - "Network name", - "The displayed name of this network", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_NAME, param_spec); - - param_spec = g_param_spec_string ( - "charset", - "Charset", - "The charset to use on this network", - "UTF-8", - G_PARAM_CONSTRUCT | - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_CHARSET, param_spec); - - /** - * TpawIrcNetwork::modified: - * @network: the object that received the signal - * - * Emitted when either a property or a server of the network is modified or - * when a network is activated. - * - */ - signals[MODIFIED] = g_signal_new ( - "modified", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 0); -} - -/** - * tpaw_irc_network_activate: - * @self: the name of the network - * - * Activates a #TpawIrcNetwork. - * - */ -void -tpaw_irc_network_activate (TpawIrcNetwork *self) -{ - g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); - g_return_if_fail (self->dropped); - - self->dropped = FALSE; - - g_signal_emit (self, signals[MODIFIED], 0); -} - -/** - * tpaw_irc_network_new: - * @name: the name of the network - * - * Creates a new #TpawIrcNetwork. - * - * Returns: a new #TpawIrcNetwork - */ -TpawIrcNetwork * -tpaw_irc_network_new (const gchar *name) -{ - return g_object_new (TPAW_TYPE_IRC_NETWORK, - "name", name, - NULL); -} - -/** - * tpaw_irc_network_get_servers: - * @network: an #TpawIrcNetwork - * - * Get the list of #TpawIrcServer that belongs to this network. - * These servers are sorted according their priority. - * So the first one will be the first used when trying to connect to - * the network. - * - * Returns: a new #GSList of refed #TpawIrcServer. - */ -GSList * -tpaw_irc_network_get_servers (TpawIrcNetwork *self) -{ - GSList *servers = NULL, *l; - - g_return_val_if_fail (TPAW_IS_IRC_NETWORK (self), NULL); - - for (l = self->priv->servers; l != NULL; l = g_slist_next (l)) - { - servers = g_slist_prepend (servers, g_object_ref (l->data)); - } - - return g_slist_reverse (servers); -} - -/** - * tpaw_irc_network_append_server: - * @network: an #TpawIrcNetwork - * @server: the #TpawIrcServer to add - * - * Add an #TpawIrcServer to the given #TpawIrcNetwork. The server - * is added at the last position in network's servers list. - * - */ -void -tpaw_irc_network_append_server (TpawIrcNetwork *self, - TpawIrcServer *server) -{ - g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); - g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); - g_return_if_fail (g_slist_find (self->priv->servers, server) == NULL); - - self->priv->servers = g_slist_append (self->priv->servers, g_object_ref (server)); - - g_signal_connect (server, "modified", G_CALLBACK (server_modified_cb), self); - - g_signal_emit (self, signals[MODIFIED], 0); -} - -/** - * tpaw_irc_network_remove_server: - * @network: an #TpawIrcNetwork - * @server: the #TpawIrcServer to remove - * - * Remove an #TpawIrcServer from the servers list of the - * given #TpawIrcNetwork. - * - */ -void -tpaw_irc_network_remove_server (TpawIrcNetwork *self, - TpawIrcServer *server) -{ - GSList *l; - - g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); - g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); - - l = g_slist_find (self->priv->servers, server); - if (l == NULL) - return; - - g_object_unref (l->data); - self->priv->servers = g_slist_delete_link (self->priv->servers, l); - g_signal_handlers_disconnect_by_func (server, G_CALLBACK (server_modified_cb), - self); - - g_signal_emit (self, signals[MODIFIED], 0); -} - -/** - * tpaw_irc_network_set_server_position: - * @network: an #TpawIrcNetwork - * @server: the #TpawIrcServer to move - * @pos: the position to move the server. If this is negative, or is larger than - * the number of servers in the list, the server is moved to the end of the - * list. - * - * Move an #TpawIrcServer in the servers list of the given - * #TpawIrcNetwork. - * - */ -void -tpaw_irc_network_set_server_position (TpawIrcNetwork *self, - TpawIrcServer *server, - gint pos) -{ - GSList *l; - - g_return_if_fail (TPAW_IS_IRC_NETWORK (self)); - g_return_if_fail (server != NULL && TPAW_IS_IRC_SERVER (server)); - - l = g_slist_find (self->priv->servers, server); - if (l == NULL) - return; - - self->priv->servers = g_slist_delete_link (self->priv->servers, l); - self->priv->servers = g_slist_insert (self->priv->servers, server, pos); - - g_signal_emit (self, signals[MODIFIED], 0); -} - -const gchar * -tpaw_irc_network_get_name (TpawIrcNetwork *self) -{ - return self->priv->name; -} - -const gchar * -tpaw_irc_network_get_charset (TpawIrcNetwork *self) -{ - return self->priv->charset; -} diff --git a/tp-account-widgets/tpaw-irc-network.h b/tp-account-widgets/tpaw-irc-network.h deleted file mode 100644 index d305319fc..000000000 --- a/tp-account-widgets/tpaw-irc-network.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_NETWORK_H__ -#define __TPAW_IRC_NETWORK_H__ - -#include <glib-object.h> - -#include "tpaw-irc-server.h" - -G_BEGIN_DECLS - -typedef struct _TpawIrcNetwork TpawIrcNetwork; -typedef struct _TpawIrcNetworkPriv TpawIrcNetworkPriv; -typedef struct _TpawIrcNetworkClass TpawIrcNetworkClass; - -struct _TpawIrcNetwork -{ - GObject parent; - TpawIrcNetworkPriv *priv; - - gboolean user_defined; - gboolean dropped; -}; - -struct _TpawIrcNetworkClass -{ - GObjectClass parent_class; -}; - -GType tpaw_irc_network_get_type (void); - -/* TYPE MACROS */ -#define TPAW_TYPE_IRC_NETWORK (tpaw_irc_network_get_type ()) -#define TPAW_IRC_NETWORK(o) \ - (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_IRC_NETWORK, \ - TpawIrcNetwork)) -#define TPAW_IRC_NETWORK_CLASS(k) \ - (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_IRC_NETWORK,\ - TpawIrcNetworkClass)) -#define TPAW_IS_IRC_NETWORK(o) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_IRC_NETWORK)) -#define TPAW_IS_IRC_NETWORK_CLASS(k) \ - (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_IRC_NETWORK)) -#define TPAW_IRC_NETWORK_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_NETWORK, \ - TpawIrcNetworkClass)) - -void tpaw_irc_network_activate (TpawIrcNetwork *self); - -TpawIrcNetwork * tpaw_irc_network_new (const gchar *name); - -GSList * tpaw_irc_network_get_servers (TpawIrcNetwork *network); - -void tpaw_irc_network_append_server (TpawIrcNetwork *network, - TpawIrcServer *server); - -void tpaw_irc_network_remove_server (TpawIrcNetwork *network, - TpawIrcServer *server); - -void tpaw_irc_network_set_server_position (TpawIrcNetwork *network, - TpawIrcServer *server, gint pos); - -const gchar * tpaw_irc_network_get_name (TpawIrcNetwork *network); - -const gchar * tpaw_irc_network_get_charset (TpawIrcNetwork *network); - -G_END_DECLS - -#endif /* __TPAW_IRC_NETWORK_H__ */ diff --git a/tp-account-widgets/tpaw-irc-networks.dtd b/tp-account-widgets/tpaw-irc-networks.dtd deleted file mode 100644 index 599081f05..000000000 --- a/tp-account-widgets/tpaw-irc-networks.dtd +++ /dev/null @@ -1,18 +0,0 @@ -<!-- - DTD for tp-account-widgets irc networks. - by Xavier Claessens <xclaesse@gmail.com> ---> - - -<!ELEMENT networks (network*)> -<!ELEMENT network (servers*)> -<!ATTLIST network id ID #REQUIRED> -<!ATTLIST network name CDATA #IMPLIED> -<!ATTLIST network network_charset CDATA #IMPLIED> -<!ATTLIST network dropped CDATA #IMPLIED> - -<!ELEMENT servers (server*)> -<!ELEMENT server EMPTY> -<!ATTLIST server address CDATA #REQUIRED> -<!ATTLIST server port CDATA #REQUIRED> -<!ATTLIST server ssl CDATA #REQUIRED> diff --git a/tp-account-widgets/tpaw-irc-server.c b/tp-account-widgets/tpaw-irc-server.c deleted file mode 100644 index 1bc3b8875..000000000 --- a/tp-account-widgets/tpaw-irc-server.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#include "config.h" -#include "tpaw-irc-server.h" - -#include "tpaw-utils.h" - -struct _TpawIrcServerPriv -{ - gchar *address; - guint port; - gboolean ssl; -}; - -/* properties */ -enum -{ - PROP_ADDRESS = 1, - PROP_PORT, - PROP_SSL, - LAST_PROPERTY -}; - -/* signals */ -enum -{ - MODIFIED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = {0}; - -G_DEFINE_TYPE (TpawIrcServer, tpaw_irc_server, G_TYPE_OBJECT); - -static void -tpaw_irc_server_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TpawIrcServer *self = TPAW_IRC_SERVER (object); - - switch (property_id) - { - case PROP_ADDRESS: - g_value_set_string (value, self->priv->address); - break; - case PROP_PORT: - g_value_set_uint (value, self->priv->port); - break; - case PROP_SSL: - g_value_set_boolean (value, self->priv->ssl); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_irc_server_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawIrcServer *self = TPAW_IRC_SERVER (object); - - switch (property_id) - { - case PROP_ADDRESS: - if (tp_strdiff (self->priv->address, g_value_get_string (value))) - { - g_free (self->priv->address); - self->priv->address = g_value_dup_string (value); - g_signal_emit (object, signals[MODIFIED], 0); - } - break; - case PROP_PORT: - if (self->priv->port != g_value_get_uint (value)) - { - self->priv->port = g_value_get_uint (value); - g_signal_emit (object, signals[MODIFIED], 0); - } - break; - case PROP_SSL: - if (self->priv->ssl != g_value_get_boolean (value)) - { - self->priv->ssl = g_value_get_boolean (value); - g_signal_emit (object, signals[MODIFIED], 0); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_irc_server_finalize (GObject *object) -{ - TpawIrcServer *self = TPAW_IRC_SERVER (object); - - g_free (self->priv->address); - - G_OBJECT_CLASS (tpaw_irc_server_parent_class)->finalize (object); -} - -static void -tpaw_irc_server_init (TpawIrcServer *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_IRC_SERVER, - TpawIrcServerPriv); -} - -static void -tpaw_irc_server_class_init (TpawIrcServerClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->get_property = tpaw_irc_server_get_property; - object_class->set_property = tpaw_irc_server_set_property; - - g_type_class_add_private (object_class, sizeof (TpawIrcServerPriv)); - - object_class->finalize = tpaw_irc_server_finalize; - - param_spec = g_param_spec_string ( - "address", - "Server address", - "The address of this server", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_ADDRESS, param_spec); - - param_spec = g_param_spec_uint ( - "port", - "Server port", - "The port to use to connect on this server", - 1, G_MAXUINT16, 6667, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_PORT, param_spec); - - param_spec = g_param_spec_boolean ( - "ssl", - "SSL", - "If this server needs SSL connection", - FALSE, - G_PARAM_READWRITE | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB); - g_object_class_install_property (object_class, PROP_SSL, param_spec); - - /** - * TpawIrcServer::modified: - * @server: the object that received the signal - * - * Emitted when a property of the server is modified. - * - */ - signals[MODIFIED] = g_signal_new ( - "modified", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 0); -} - -/** - * tpaw_irc_server_new: - * @address: the address - * @port: the port - * @ssl: %TRUE if the server needs a SSL connection - * - * Creates a new #TpawIrcServer - * - * Returns: a new #TpawIrcServer - */ -TpawIrcServer * -tpaw_irc_server_new (const gchar *address, - guint port, - gboolean ssl) -{ - return g_object_new (TPAW_TYPE_IRC_SERVER, - "address", address, - "port", port, - "ssl", ssl, - NULL); -} diff --git a/tp-account-widgets/tpaw-irc-server.h b/tp-account-widgets/tpaw-irc-server.h deleted file mode 100644 index 046ae4775..000000000 --- a/tp-account-widgets/tpaw-irc-server.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007-2008 Guillaume Desmottes - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Guillaume Desmottes <gdesmott@gnome.org> - */ - -#ifndef __TPAW_IRC_SERVER_H__ -#define __TPAW_IRC_SERVER_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -typedef struct _TpawIrcServer TpawIrcServer; -typedef struct _TpawIrcServerPriv TpawIrcServerPriv; -typedef struct _TpawIrcServerClass TpawIrcServerClass; - -struct _TpawIrcServer -{ - GObject parent; - TpawIrcServerPriv *priv; -}; - -struct _TpawIrcServerClass -{ - GObjectClass parent_class; -}; - -GType tpaw_irc_server_get_type (void); - -/* TYPE MACROS */ -#define TPAW_TYPE_IRC_SERVER (tpaw_irc_server_get_type ()) -#define TPAW_IRC_SERVER(o) \ - (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_IRC_SERVER, TpawIrcServer)) -#define TPAW_IRC_SERVER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_IRC_SERVER, \ - TpawIrcServerClass)) -#define TPAW_IS_IRC_SERVER(o) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_IRC_SERVER)) -#define TPAW_IS_IRC_SERVER_CLASS(k) \ - (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_IRC_SERVER)) -#define TPAW_IRC_SERVER_GET_CLASS(o) \ - (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_IRC_SERVER,\ - TpawIrcServerClass)) - -TpawIrcServer * tpaw_irc_server_new (const gchar *address, guint port, - gboolean ssl); - -G_END_DECLS - -#endif /* __TPAW_IRC_SERVER_H__ */ diff --git a/tp-account-widgets/tpaw-keyring.c b/tp-account-widgets/tpaw-keyring.c deleted file mode 100644 index 533b0da7a..000000000 --- a/tp-account-widgets/tpaw-keyring.c +++ /dev/null @@ -1,720 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-keyring.h" - -#include <glib/gi18n-lib.h> -#include <libsecret/secret.h> - -#ifdef HAVE_UOA -#include <libaccounts-glib/ag-account.h> -#include <libaccounts-glib/ag-account-service.h> -#include <libaccounts-glib/ag-auth-data.h> -#include <libaccounts-glib/ag-manager.h> -#include <libaccounts-glib/ag-service.h> -#include <libsignon-glib/signon-identity.h> -#include "tpaw-uoa-utils.h" -#endif - -#include "tpaw-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -/* We cannot change the schema name for compatibility, so it's still - * referring to Empathy */ -static const SecretSchema account_keyring_schema = - { "org.gnome.Empathy.Account", SECRET_SCHEMA_DONT_MATCH_NAME, - { { "account-id", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "param-name", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { NULL } } }; - -static const SecretSchema room_keyring_schema = - { "org.gnome.Empathy.Room", SECRET_SCHEMA_DONT_MATCH_NAME, - { { "account-id", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { "room-id", SECRET_SCHEMA_ATTRIBUTE_STRING }, - { NULL } } }; - -/* get */ - -static void -lookup_item_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); - GError *error = NULL; - gchar *password; - - password = secret_password_lookup_finish (result, &error); - if (error != NULL) - { - g_simple_async_result_set_error (simple, TP_ERROR, - TP_ERROR_DOES_NOT_EXIST, "%s", error->message); - g_clear_error (&error); - goto out; - } - - if (password == NULL) - { - g_simple_async_result_set_error (simple, TP_ERROR, - TP_ERROR_DOES_NOT_EXIST, _("Password not found")); - goto out; - } - - g_simple_async_result_set_op_res_gpointer (simple, password, - (GDestroyNotify) secret_password_free); - -out: - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -#ifdef HAVE_UOA -static AgAccountService * -uoa_password_common (TpAccount *tp_account, - GSimpleAsyncResult *result, - AgAuthData **ret_auth_data) -{ - const GValue *storage_id; - AgAccountId account_id; - AgManager *manager = NULL; - AgAccount *account = NULL; - GList *l; - AgAccountService *service = NULL; - AgAuthData *auth_data = NULL; - - g_assert (ret_auth_data != NULL); - *ret_auth_data = NULL; - - storage_id = tp_account_get_storage_identifier (tp_account); - account_id = g_value_get_uint (storage_id); - if (account_id == 0) - { - g_simple_async_result_set_error (result, - TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "StorageId is invalid, cannot get the AgAccount for this TpAccount"); - g_simple_async_result_complete_in_idle (result); - goto error; - } - - manager = tpaw_uoa_manager_dup (); - account = ag_manager_get_account (manager, account_id); - - /* Assuming there is only one IM service */ - l = ag_account_list_services_by_type (account, TPAW_UOA_SERVICE_TYPE); - if (l == NULL) - { - g_simple_async_result_set_error (result, - TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "AgAccount has no IM service"); - g_simple_async_result_complete_in_idle (result); - goto error; - } - service = ag_account_service_new (account, l->data); - ag_service_list_free (l); - - auth_data = ag_account_service_get_auth_data (service); - if (auth_data == NULL) - { - g_simple_async_result_set_error (result, - TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "Service has no AgAuthData"); - g_simple_async_result_complete_in_idle (result); - goto error; - } - - if (tp_strdiff (ag_auth_data_get_mechanism (auth_data), "password") || - tp_strdiff (ag_auth_data_get_method (auth_data), "password")) - { - g_simple_async_result_set_error (result, - TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "Service does not use password authentication"); - g_simple_async_result_complete_in_idle (result); - goto error; - } - - g_object_unref (manager); - g_object_unref (account); - - *ret_auth_data = auth_data; - return service; - -error: - g_clear_object (&manager); - g_clear_object (&account); - g_clear_object (&service); - tp_clear_pointer (&auth_data, ag_auth_data_unref); - return NULL; -} - -static void -uoa_session_process_cb (SignonAuthSession *session, - GHashTable *session_data, - const GError *error, - gpointer user_data) -{ - GSimpleAsyncResult *result = user_data; - const gchar *password; - - if (error != NULL) - { - g_simple_async_result_set_from_error (result, error); - goto out; - } - - password = tp_asv_get_string (session_data, "Secret"); - if (tp_str_empty (password)) - { - g_simple_async_result_set_error (result, TP_ERROR, - TP_ERROR_DOES_NOT_EXIST, _("Password not found")); - goto out; - } - - g_simple_async_result_set_op_res_gpointer (result, g_strdup (password), - g_free); - -out: - /* libaccounts-glib API does not guarantee the callback happens after - * reentering mainloop */ - g_simple_async_result_complete_in_idle (result); - g_object_unref (result); - g_object_unref (session); -} - -static void -uoa_get_account_password (TpAccount *tp_account, - GSimpleAsyncResult *result) -{ - AgAccountService *service; - AgAuthData *auth_data; - guint cred_id; - SignonIdentity *identity; - SignonAuthSession *session; - GError *error = NULL; - - DEBUG ("Store password for %s in signond", - tp_account_get_path_suffix (tp_account)); - - service = uoa_password_common (tp_account, result, &auth_data); - if (service == NULL) - return; - - cred_id = ag_auth_data_get_credentials_id (auth_data); - if (cred_id == 0) - { - g_simple_async_result_set_error (result, - TP_ERROR, TP_ERROR_INVALID_ARGUMENT, - "AgAccount has no CredentialsId"); - g_simple_async_result_complete_in_idle (result); - goto out; - } - - identity = signon_identity_new_from_db (cred_id); - session = signon_identity_create_session (identity, - ag_auth_data_get_method (auth_data), &error); - g_object_unref (identity); - - if (session == NULL) - { - g_simple_async_result_set_from_error (result, error); - g_simple_async_result_complete_in_idle (result); - goto out; - } - - signon_auth_session_process (session, - ag_auth_data_get_parameters (auth_data), - ag_auth_data_get_mechanism (auth_data), - uoa_session_process_cb, - g_object_ref (result)); - -out: - ag_auth_data_unref (auth_data); - g_object_unref (service); -} -#endif - -void -tpaw_keyring_get_account_password_async (TpAccount *account, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - const gchar *account_id; - - g_return_if_fail (TP_IS_ACCOUNT (account)); - g_return_if_fail (callback != NULL); - - simple = g_simple_async_result_new (G_OBJECT (account), callback, - user_data, tpaw_keyring_get_account_password_async); - - account_id = tp_proxy_get_object_path (account) + - strlen (TP_ACCOUNT_OBJECT_PATH_BASE); - - DEBUG ("Trying to get password for: %s", account_id); - -#ifdef HAVE_UOA - { - const gchar *provider; - - provider = tp_account_get_storage_provider (account); - if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER)) - { - uoa_get_account_password (account, simple); - g_object_unref (simple); - return; - } - } -#endif - - secret_password_lookup (&account_keyring_schema, NULL, - lookup_item_cb, simple, - "account-id", account_id, - "param-name", "password", - NULL); -} - -void -tpaw_keyring_get_room_password_async (TpAccount *account, - const gchar *id, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - const gchar *account_id; - - g_return_if_fail (TP_IS_ACCOUNT (account)); - g_return_if_fail (id != NULL); - g_return_if_fail (callback != NULL); - - simple = g_simple_async_result_new (G_OBJECT (account), callback, - user_data, tpaw_keyring_get_room_password_async); - - account_id = tp_proxy_get_object_path (account) + - strlen (TP_ACCOUNT_OBJECT_PATH_BASE); - - DEBUG ("Trying to get password for room '%s' on account '%s'", - id, account_id); - - secret_password_lookup (&room_keyring_schema, NULL, - lookup_item_cb, simple, - "account-id", account_id, - "room-id", id, - NULL); -} - -const gchar * -tpaw_keyring_get_account_password_finish (TpAccount *account, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_return_pointer (account, - tpaw_keyring_get_account_password_async); -} - -const gchar * -tpaw_keyring_get_room_password_finish (TpAccount *account, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_return_pointer (account, - tpaw_keyring_get_room_password_async); -} - -/* set */ - -static void -store_password_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); - GError *error = NULL; - - if (!secret_password_store_finish (result, &error)) - { - g_simple_async_result_set_error (simple, TP_ERROR, - TP_ERROR_DOES_NOT_EXIST, "%s", error->message); - g_error_free (error); - } - - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -#ifdef HAVE_UOA -typedef struct -{ - AgAccountService *service; - gchar *password; - gboolean remember; - GSimpleAsyncResult *result; -} UoaChangePasswordData; - -static UoaChangePasswordData * -uoa_change_password_data_new (AgAccountService *service, - const gchar *password, - gboolean remember, - GSimpleAsyncResult *result) -{ - UoaChangePasswordData *data; - - data = g_slice_new0 (UoaChangePasswordData); - data->service = g_object_ref (service); - data->password = g_strdup (password); - data->remember = remember; - data->result = g_object_ref (result); - - return data; -} - -static void -uoa_change_password_data_free (UoaChangePasswordData *data) -{ - g_object_unref (data->service); - g_free (data->password); - g_object_unref (data->result); - g_slice_free (UoaChangePasswordData, data); -} - -static void -uoa_identity_store_cb (SignonIdentity *identity, - guint32 id, - const GError *error, - gpointer user_data) -{ - UoaChangePasswordData *data = user_data; - - if (error != NULL) - g_simple_async_result_set_from_error (data->result, error); - - g_simple_async_result_complete (data->result); - uoa_change_password_data_free (data); - g_object_unref (identity); -} - -static void -uoa_identity_query_info_cb (SignonIdentity *identity, - const SignonIdentityInfo *info, - const GError *error, - gpointer user_data) -{ - UoaChangePasswordData *data = user_data; - - if (error != NULL) - { - g_simple_async_result_set_from_error (data->result, error); - /* libaccounts-glib API does not guarantee the callback happens after - * reentering mainloop */ - g_simple_async_result_complete_in_idle (data->result); - uoa_change_password_data_free (data); - g_object_unref (identity); - return; - } - - /* const SignonIdentityInfo is a lie, cast it! - Mardy */ - signon_identity_info_set_secret ((SignonIdentityInfo *) info, - data->password, data->remember); - - signon_identity_store_credentials_with_info (identity, info, - uoa_identity_store_cb, data); -} - -static void -uoa_initial_account_store_cb (AgAccount *account, - const GError *error, - gpointer user_data) -{ - UoaChangePasswordData *data = user_data; - - if (error != NULL) - g_simple_async_result_set_from_error (data->result, error); - - /* libaccounts-glib API does not guarantee the callback happens after - * reentering mainloop */ - g_simple_async_result_complete_in_idle (data->result); - uoa_change_password_data_free (data); -} - -static void -uoa_initial_identity_store_cb (SignonIdentity *identity, - guint32 id, - const GError *error, - gpointer user_data) -{ - UoaChangePasswordData *data = user_data; - AgAccount *account = ag_account_service_get_account (data->service); - GValue value = G_VALUE_INIT; - - if (error != NULL) - { - g_simple_async_result_set_from_error (data->result, error); - /* libaccounts-glib API does not guarantee the callback happens after - * reentering mainloop */ - g_simple_async_result_complete_in_idle (data->result); - uoa_change_password_data_free (data); - g_object_unref (identity); - return; - } - - g_value_init (&value, G_TYPE_UINT); - g_value_set_uint (&value, id); - ag_account_select_service (account, NULL); - ag_account_set_value (account, "CredentialsId", &value); - g_value_unset (&value); - - ag_account_store (account, uoa_initial_account_store_cb, data); - - g_object_unref (identity); -} - -static void -uoa_set_account_password (TpAccount *tp_account, - const gchar *password, - gboolean remember, - GSimpleAsyncResult *result) -{ - AgAccountService *service; - AgAuthData *auth_data; - guint cred_id; - UoaChangePasswordData *data; - SignonIdentity *identity; - - DEBUG ("Store password for %s in signond", - tp_account_get_path_suffix (tp_account)); - - service = uoa_password_common (tp_account, result, &auth_data); - if (service == NULL) - return; - - data = uoa_change_password_data_new (service, password, remember, result); - - cred_id = ag_auth_data_get_credentials_id (auth_data); - if (cred_id == 0) - { - SignonIdentityInfo *info; - const GHashTable *params; - const gchar *username; - const gchar *acl_all[] = { "*", NULL }; - - /* This is the first time we store password for this account. - * First check if we have an 'username' param as this is more accurate - * in the tp-idle case. */ - params = tp_account_get_parameters (tp_account); - username = tp_asv_get_string (params, "username"); - if (username == NULL) - username = tp_asv_get_string (params, "account"); - - identity = signon_identity_new (); - info = signon_identity_info_new (); - signon_identity_info_set_username (info, username); - signon_identity_info_set_secret (info, password, remember); - signon_identity_info_set_access_control_list (info, acl_all); - - /* Give identity and data ownership to the callback */ - signon_identity_store_credentials_with_info (identity, info, - uoa_initial_identity_store_cb, data); - - signon_identity_info_free (info); - } - else - { - /* There is already a password stored, query info to update it. - * Give identity and data ownership to the callback */ - identity = signon_identity_new_from_db (cred_id); - signon_identity_query_info (identity, - uoa_identity_query_info_cb, data); - } - - g_object_unref (service); - ag_auth_data_unref (auth_data); -} -#endif - -void -tpaw_keyring_set_account_password_async (TpAccount *account, - const gchar *password, - gboolean remember, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - const gchar *account_id; - gchar *name; - - g_return_if_fail (TP_IS_ACCOUNT (account)); - g_return_if_fail (password != NULL); - - simple = g_simple_async_result_new (G_OBJECT (account), callback, - user_data, tpaw_keyring_set_account_password_async); - - account_id = tp_proxy_get_object_path (account) + - strlen (TP_ACCOUNT_OBJECT_PATH_BASE); - - DEBUG ("Remembering password for %s", account_id); - -#ifdef HAVE_UOA - { - const gchar *provider; - - provider = tp_account_get_storage_provider (account); - if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER)) - { - uoa_set_account_password (account, password, remember, simple); - g_object_unref (simple); - return; - } - } -#endif - - name = g_strdup_printf (_("IM account password for %s (%s)"), - tp_account_get_display_name (account), account_id); - - secret_password_store (&account_keyring_schema, - remember ? NULL : SECRET_COLLECTION_SESSION, - name, password, - NULL, store_password_cb, simple, - "account-id", account_id, - "param-name", "password", - NULL); - - g_free (name); -} - -void -tpaw_keyring_set_room_password_async (TpAccount *account, - const gchar *id, - const gchar *password, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - const gchar *account_id; - gchar *name; - - g_return_if_fail (TP_IS_ACCOUNT (account)); - g_return_if_fail (id != NULL); - g_return_if_fail (password != NULL); - - simple = g_simple_async_result_new (G_OBJECT (account), callback, - user_data, tpaw_keyring_set_room_password_async); - - account_id = tp_proxy_get_object_path (account) + - strlen (TP_ACCOUNT_OBJECT_PATH_BASE); - - DEBUG ("Remembering password for room '%s' on account '%s'", id, account_id); - - name = g_strdup_printf (_("Password for chatroom '%s' on account %s (%s)"), - id, tp_account_get_display_name (account), account_id); - - secret_password_store (&room_keyring_schema, NULL, name, password, - NULL, store_password_cb, simple, - "account-id", account_id, - "room-id", id, - NULL); - - g_free (name); -} - -gboolean -tpaw_keyring_set_account_password_finish (TpAccount *account, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_void (account, tpaw_keyring_set_account_password_async); -} - -gboolean -tpaw_keyring_set_room_password_finish (TpAccount *account, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_void (account, tpaw_keyring_set_room_password_async); -} - -/* delete */ - -static void -items_delete_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (user_data); - GError *error = NULL; - - secret_password_clear_finish (result, &error); - if (error != NULL) - { - g_simple_async_result_set_error (simple, TP_ERROR, - TP_ERROR_DOES_NOT_EXIST, "%s", error->message); - g_error_free (error); - } - - g_simple_async_result_complete (simple); - g_object_unref (simple); -} - -void -tpaw_keyring_delete_account_password_async (TpAccount *account, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *simple; - const gchar *account_id; - - g_return_if_fail (TP_IS_ACCOUNT (account)); - - simple = g_simple_async_result_new (G_OBJECT (account), callback, - user_data, tpaw_keyring_delete_account_password_async); - - account_id = tp_proxy_get_object_path (account) + - strlen (TP_ACCOUNT_OBJECT_PATH_BASE); - - DEBUG ("Deleting password for %s", account_id); - -#ifdef HAVE_UOA - { - const gchar *provider; - - provider = tp_account_get_storage_provider (account); - if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER)) - { - /* I see no other way to forget the stored password than overwriting - * with an empty one. */ - uoa_set_account_password (account, "", FALSE, simple); - g_object_unref (simple); - return; - } - } -#endif - - secret_password_clear (&account_keyring_schema, NULL, - items_delete_cb, simple, - "account-id", account_id, - "param-name", "password", - NULL); -} - -gboolean -tpaw_keyring_delete_account_password_finish (TpAccount *account, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_void (account, tpaw_keyring_delete_account_password_async); -} diff --git a/tp-account-widgets/tpaw-keyring.h b/tp-account-widgets/tpaw-keyring.h deleted file mode 100644 index bf2e65203..000000000 --- a/tp-account-widgets/tpaw-keyring.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_KEYRING_H__ -#define __TPAW_KEYRING_H__ - -#include <gio/gio.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -void tpaw_keyring_get_account_password_async (TpAccount *account, - GAsyncReadyCallback callback, gpointer user_data); - -const gchar * tpaw_keyring_get_account_password_finish (TpAccount *account, - GAsyncResult *result, GError **error); - -void tpaw_keyring_get_room_password_async (TpAccount *account, - const gchar *id, - GAsyncReadyCallback callback, gpointer user_data); - -const gchar * tpaw_keyring_get_room_password_finish (TpAccount *account, - GAsyncResult *result, GError **error); - -void tpaw_keyring_set_account_password_async (TpAccount *account, - const gchar *password, gboolean remember, GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_keyring_set_account_password_finish (TpAccount *account, - GAsyncResult *result, GError **error); - -void tpaw_keyring_set_room_password_async (TpAccount *account, - const gchar *id, const gchar *password, GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_keyring_set_room_password_finish (TpAccount *account, - GAsyncResult *result, GError **error); - -void tpaw_keyring_delete_account_password_async (TpAccount *account, - GAsyncReadyCallback callback, gpointer user_data); - -gboolean tpaw_keyring_delete_account_password_finish (TpAccount *account, - GAsyncResult *result, GError **error); - -G_END_DECLS - -#endif /* __TPAW_KEYRING_H__ */ diff --git a/tp-account-widgets/tpaw-live-search.c b/tp-account-widgets/tpaw-live-search.c deleted file mode 100644 index 99d87f224..000000000 --- a/tp-account-widgets/tpaw-live-search.c +++ /dev/null @@ -1,699 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * Copyright (C) 2007-2010 Nokia Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Felix Kaser <felix.kaser@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Claudio Saavedra <csaavedra@igalia.com> - */ - -#include "config.h" -#include "tpaw-live-search.h" - -#include "tpaw-utils.h" - -G_DEFINE_TYPE (TpawLiveSearch, tpaw_live_search, GTK_TYPE_HBOX) - -struct _TpawLiveSearchPriv -{ - GtkWidget *search_entry; - GtkWidget *hook_widget; - - GPtrArray *stripped_words; -}; - -enum -{ - PROP_0, - PROP_HOOK_WIDGET, - PROP_TEXT -}; - -enum -{ - ACTIVATE, - KEYNAV, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -static void live_search_hook_widget_destroy_cb (GtkWidget *object, - gpointer user_data); - -/** - * stripped_char: - * - * Returns a stripped version of @ch, removing any case, accentuation - * mark, or any special mark on it. - **/ -static gunichar -stripped_char (gunichar ch) -{ - gunichar retval = 0; - GUnicodeType utype; - - utype = g_unichar_type (ch); - - switch (utype) - { - case G_UNICODE_CONTROL: - case G_UNICODE_FORMAT: - case G_UNICODE_UNASSIGNED: - case G_UNICODE_NON_SPACING_MARK: - case G_UNICODE_COMBINING_MARK: - case G_UNICODE_ENCLOSING_MARK: - /* Ignore those */ - break; - case G_UNICODE_PRIVATE_USE: - case G_UNICODE_SURROGATE: - case G_UNICODE_LOWERCASE_LETTER: - case G_UNICODE_MODIFIER_LETTER: - case G_UNICODE_OTHER_LETTER: - case G_UNICODE_TITLECASE_LETTER: - case G_UNICODE_UPPERCASE_LETTER: - case G_UNICODE_DECIMAL_NUMBER: - case G_UNICODE_LETTER_NUMBER: - case G_UNICODE_OTHER_NUMBER: - case G_UNICODE_CONNECT_PUNCTUATION: - case G_UNICODE_DASH_PUNCTUATION: - case G_UNICODE_CLOSE_PUNCTUATION: - case G_UNICODE_FINAL_PUNCTUATION: - case G_UNICODE_INITIAL_PUNCTUATION: - case G_UNICODE_OTHER_PUNCTUATION: - case G_UNICODE_OPEN_PUNCTUATION: - case G_UNICODE_CURRENCY_SYMBOL: - case G_UNICODE_MODIFIER_SYMBOL: - case G_UNICODE_MATH_SYMBOL: - case G_UNICODE_OTHER_SYMBOL: - case G_UNICODE_LINE_SEPARATOR: - case G_UNICODE_PARAGRAPH_SEPARATOR: - case G_UNICODE_SPACE_SEPARATOR: - default: - ch = g_unichar_tolower (ch); - g_unichar_fully_decompose (ch, FALSE, &retval, 1); - } - - return retval; -} - -static void -append_word (GPtrArray **word_array, - GString **word) -{ - if (*word != NULL) - { - if (*word_array == NULL) - *word_array = g_ptr_array_new_with_free_func (g_free); - g_ptr_array_add (*word_array, g_string_free (*word, FALSE)); - *word = NULL; - } -} - -GPtrArray * -tpaw_live_search_strip_utf8_string (const gchar *string) -{ - GPtrArray *word_array = NULL; - GString *word = NULL; - const gchar *p; - - if (TPAW_STR_EMPTY (string)) - return NULL; - - for (p = string; *p != '\0'; p = g_utf8_next_char (p)) - { - gunichar sc; - - /* Make the char lower-case, remove its accentuation marks, and ignore it - * if it is just unicode marks */ - sc = stripped_char (g_utf8_get_char (p)); - if (sc == 0) - continue; - - /* If it is not alpha-num, it is separator between words */ - if (!g_unichar_isalnum (sc)) - { - append_word (&word_array, &word); - continue; - } - - /* It is alpha-num, append this char to current word, or start new word */ - if (word == NULL) - word = g_string_new (NULL); - g_string_append_unichar (word, sc); - } - - append_word (&word_array, &word); - - return word_array; -} - -static gboolean -live_search_match_prefix (const gchar *string, - const gchar *prefix) -{ - const gchar *p; - const gchar *prefix_p; - gboolean next_word = FALSE; - - if (prefix == NULL || prefix[0] == 0) - return TRUE; - - if (TPAW_STR_EMPTY (string)) - return FALSE; - - prefix_p = prefix; - for (p = string; *p != '\0'; p = g_utf8_next_char (p)) - { - gunichar sc; - - /* Make the char lower-case, remove its accentuation marks, and ignore it - * if it is just unicode marks */ - sc = stripped_char (g_utf8_get_char (p)); - if (sc == 0) - continue; - - /* If we want to go to next word, ignore alpha-num chars */ - if (next_word && g_unichar_isalnum (sc)) - continue; - next_word = FALSE; - - /* Ignore word separators */ - if (!g_unichar_isalnum (sc)) - continue; - - /* If this char does not match prefix_p, go to next word and start again - * from the beginning of prefix */ - if (sc != g_utf8_get_char (prefix_p)) - { - next_word = TRUE; - prefix_p = prefix; - continue; - } - - /* prefix_p match, verify to next char. If this was the last of prefix, - * it means it completely machted and we are done. */ - prefix_p = g_utf8_next_char (prefix_p); - if (*prefix_p == '\0') - return TRUE; - } - - return FALSE; -} - -gboolean -tpaw_live_search_match_words (const gchar *string, - GPtrArray *words) -{ - guint i; - - if (words == NULL) - return TRUE; - - for (i = 0; i < words->len; i++) - if (!live_search_match_prefix (string, g_ptr_array_index (words, i))) - return FALSE; - - return TRUE; -} - -static gboolean -fire_key_navigation_sig (TpawLiveSearch *self, - GdkEventKey *event) -{ - gboolean ret; - - g_signal_emit (self, signals[KEYNAV], 0, event, &ret); - return ret; -} - -static gboolean -live_search_entry_key_pressed_cb (GtkEntry *entry, - GdkEventKey *event, - gpointer user_data) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - - /* if esc key pressed, hide the search */ - if (event->keyval == GDK_KEY_Escape) - { - gtk_widget_hide (GTK_WIDGET (self)); - return TRUE; - } - - /* emit key navigation signal, so other widgets can respond to it properly */ - if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_Down - || event->keyval == GDK_KEY_Page_Up || event->keyval == GDK_KEY_Page_Down - || event->keyval == GDK_KEY_Menu) - { - return fire_key_navigation_sig (self, event); - } - - if (event->keyval == GDK_KEY_Home || event->keyval == GDK_KEY_End || - event->keyval == GDK_KEY_space) - { - /* If the live search is visible, the entry should catch the Home/End - * and space events */ - if (!gtk_widget_get_visible (GTK_WIDGET (self))) - { - return fire_key_navigation_sig (self, event); - } - } - - return FALSE; -} - -static void -live_search_text_changed (GtkEntry *entry, - gpointer user_data) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - const gchar *text; - - text = gtk_entry_get_text (entry); - - if (TPAW_STR_EMPTY (text)) - gtk_widget_hide (GTK_WIDGET (self)); - else - gtk_widget_show (GTK_WIDGET (self)); - - if (self->priv->stripped_words != NULL) - g_ptr_array_unref (self->priv->stripped_words); - - self->priv->stripped_words = tpaw_live_search_strip_utf8_string (text); - - g_object_notify (G_OBJECT (self), "text"); -} - -static void -live_search_close_pressed (GtkEntry *entry, - GtkEntryIconPosition icon_pos, - GdkEvent *event, - gpointer user_data) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - - gtk_widget_hide (GTK_WIDGET (self)); -} - -static gboolean -live_search_key_press_event_cb (GtkWidget *widget, - GdkEventKey *event, - gpointer user_data) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - GdkEvent *new_event; - gboolean ret; - - /* dont forward this event to the entry, else the event is consumed by the - * entry and does not close the window */ - if (!gtk_widget_get_visible (GTK_WIDGET (self)) && - event->keyval == GDK_KEY_Escape) - return FALSE; - - /* do not show the search if CTRL and/or ALT are pressed with a key - * this is needed, because otherwise the CTRL + F accel would not work, - * because the entry consumes it */ - if (event->state & (GDK_MOD1_MASK | GDK_CONTROL_MASK) || - event->keyval == GDK_KEY_Control_L || - event->keyval == GDK_KEY_Control_R) - return FALSE; - - /* dont forward the up/down and Page Up/Down arrow keys to the entry, - * they are needed for navigation in the treeview and are not needed in - * the search entry */ - if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_Down || - event->keyval == GDK_KEY_Page_Up || event->keyval == GDK_KEY_Page_Down || - event->keyval == GDK_KEY_Menu) - return FALSE; - - if (event->keyval == GDK_KEY_Home || event->keyval == GDK_KEY_End || - event->keyval == GDK_KEY_space) - { - /* Home/End and space keys have to be forwarded to the entry only if - * the live search is visible (to move the cursor inside the entry). */ - if (!gtk_widget_get_visible (GTK_WIDGET (self))) - return FALSE; - } - - /* Don't forward shift keys events as focusing the search entry would - * cancel an in-progress editing on a cell renderer (like when renaming a - * group). There is no point focusing it anyway as we don't display the - * search entry when only a shift key is pressed. */ - if (event->keyval == GDK_KEY_Shift_L || - event->keyval == GDK_KEY_Shift_R) - return FALSE; - - /* realize the widget if it is not realized yet */ - gtk_widget_realize (self->priv->search_entry); - if (!gtk_widget_has_focus (self->priv->search_entry)) - { - gtk_widget_grab_focus (self->priv->search_entry); - gtk_editable_set_position (GTK_EDITABLE (self->priv->search_entry), -1); - } - - /* forward the event to the search entry */ - new_event = gdk_event_copy ((GdkEvent *) event); - ret = gtk_widget_event (self->priv->search_entry, new_event); - gdk_event_free (new_event); - - return ret; -} - -static void -live_search_entry_activate_cb (GtkEntry *entry, - TpawLiveSearch *self) -{ - g_signal_emit (self, signals[ACTIVATE], 0); -} - -static void -live_search_release_hook_widget (TpawLiveSearch *self) -{ - /* remove old handlers if old source was not null */ - if (self->priv->hook_widget != NULL) - { - g_signal_handlers_disconnect_by_func (self->priv->hook_widget, - live_search_key_press_event_cb, self); - g_signal_handlers_disconnect_by_func (self->priv->hook_widget, - live_search_hook_widget_destroy_cb, self); - g_object_unref (self->priv->hook_widget); - self->priv->hook_widget = NULL; - } -} - -static void -live_search_hook_widget_destroy_cb (GtkWidget *object, - gpointer user_data) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data); - - /* unref the hook widget and hide search */ - gtk_widget_hide (GTK_WIDGET (self)); - live_search_release_hook_widget (self); -} - -static void -live_search_dispose (GObject *obj) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (obj); - - live_search_release_hook_widget (self); - - if (G_OBJECT_CLASS (tpaw_live_search_parent_class)->dispose != NULL) - G_OBJECT_CLASS (tpaw_live_search_parent_class)->dispose (obj); -} - -static void -live_search_finalize (GObject *obj) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (obj); - - if (self->priv->stripped_words != NULL) - g_ptr_array_unref (self->priv->stripped_words); - - if (G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize != NULL) - G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize (obj); -} - -static void -live_search_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (object); - - switch (param_id) - { - case PROP_HOOK_WIDGET: - g_value_set_object (value, tpaw_live_search_get_hook_widget (self)); - break; - case PROP_TEXT: - g_value_set_string (value, tpaw_live_search_get_text (self)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -live_search_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (object); - - switch (param_id) { - case PROP_HOOK_WIDGET: - tpaw_live_search_set_hook_widget (self, g_value_get_object (value)); - break; - case PROP_TEXT: - tpaw_live_search_set_text (self, g_value_get_string (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - }; -} - -static void -live_search_unmap (GtkWidget *widget) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - - GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->unmap (widget); - - /* unmap can happen if a parent gets hidden, in that case we want to hide - * the live search as well, so when it gets mapped again, the live search - * won't be shown. */ - gtk_widget_hide (widget); - - gtk_entry_set_text (GTK_ENTRY (self->priv->search_entry), ""); - - if (self->priv->hook_widget != NULL) - gtk_widget_grab_focus (self->priv->hook_widget); -} - -static void -live_search_show (GtkWidget *widget) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - - if (!gtk_widget_has_focus (self->priv->search_entry)) - gtk_widget_grab_focus (self->priv->search_entry); - - GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->show (widget); -} - -static void -live_search_grab_focus (GtkWidget *widget) -{ - TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget); - - if (!gtk_widget_has_focus (self->priv->search_entry)) - { - gtk_widget_grab_focus (self->priv->search_entry); - gtk_editable_set_position (GTK_EDITABLE (self->priv->search_entry), -1); - } -} - -static void -tpaw_live_search_class_init (TpawLiveSearchClass *klass) -{ - GObjectClass *object_class = (GObjectClass *) klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; - GParamSpec *param_spec; - - object_class->finalize = live_search_finalize; - object_class->dispose = live_search_dispose; - object_class->get_property = live_search_get_property; - object_class->set_property = live_search_set_property; - - widget_class->unmap = live_search_unmap; - widget_class->show = live_search_show; - widget_class->grab_focus = live_search_grab_focus; - - signals[ACTIVATE] = g_signal_new ("activate", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, - NULL, NULL, - g_cclosure_marshal_generic, - G_TYPE_NONE, 0); - - signals[KEYNAV] = g_signal_new ("key-navigation", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - 0, - g_signal_accumulator_true_handled, NULL, - g_cclosure_marshal_generic, - G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - - param_spec = g_param_spec_object ("hook-widget", "Live Search Hook Widget", - "The live search catches key-press-events on this widget", - GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_HOOK_WIDGET, - param_spec); - - param_spec = g_param_spec_string ("text", "Live Search Text", - "The text of the live search entry", - "", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (object_class, PROP_TEXT, param_spec); - - g_type_class_add_private (klass, sizeof (TpawLiveSearchPriv)); -} - -static void -tpaw_live_search_init (TpawLiveSearch *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), TPAW_TYPE_LIVE_SEARCH, - TpawLiveSearchPriv); - - gtk_widget_set_no_show_all (GTK_WIDGET (self), TRUE); - - self->priv->search_entry = gtk_entry_new (); - gtk_entry_set_icon_from_stock (GTK_ENTRY (self->priv->search_entry), - GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLOSE); - gtk_entry_set_icon_activatable (GTK_ENTRY (self->priv->search_entry), - GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_entry_set_icon_sensitive (GTK_ENTRY (self->priv->search_entry), - GTK_ENTRY_ICON_SECONDARY, TRUE); - gtk_widget_show (self->priv->search_entry); - - gtk_box_pack_start (GTK_BOX (self), self->priv->search_entry, TRUE, TRUE, 0); - - g_signal_connect (self->priv->search_entry, "icon_release", - G_CALLBACK (live_search_close_pressed), self); - g_signal_connect (self->priv->search_entry, "changed", - G_CALLBACK (live_search_text_changed), self); - g_signal_connect (self->priv->search_entry, "key-press-event", - G_CALLBACK (live_search_entry_key_pressed_cb), self); - g_signal_connect (self->priv->search_entry, "activate", - G_CALLBACK (live_search_entry_activate_cb), self); - - self->priv->hook_widget = NULL; -} - -GtkWidget * -tpaw_live_search_new (GtkWidget *hook) -{ - g_return_val_if_fail (hook == NULL || GTK_IS_WIDGET (hook), NULL); - - return g_object_new (TPAW_TYPE_LIVE_SEARCH, - "hook-widget", hook, - NULL); -} - -/* public methods */ - -GtkWidget * -tpaw_live_search_get_hook_widget (TpawLiveSearch *self) -{ - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL); - - return self->priv->hook_widget; -} - -void -tpaw_live_search_set_hook_widget (TpawLiveSearch *self, - GtkWidget *hook) -{ - g_return_if_fail (TPAW_IS_LIVE_SEARCH (self)); - g_return_if_fail (hook == NULL || GTK_IS_WIDGET (hook)); - - /* release the actual widget */ - live_search_release_hook_widget (self); - - /* connect handlers if new source is not null */ - if (hook != NULL) - { - self->priv->hook_widget = g_object_ref (hook); - g_signal_connect (self->priv->hook_widget, "key-press-event", - G_CALLBACK (live_search_key_press_event_cb), - self); - g_signal_connect (self->priv->hook_widget, "destroy", - G_CALLBACK (live_search_hook_widget_destroy_cb), - self); - } -} - -const gchar * -tpaw_live_search_get_text (TpawLiveSearch *self) -{ - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL); - - return gtk_entry_get_text (GTK_ENTRY (self->priv->search_entry)); -} - -void -tpaw_live_search_set_text (TpawLiveSearch *self, - const gchar *text) -{ - g_return_if_fail (TPAW_IS_LIVE_SEARCH (self)); - g_return_if_fail (text != NULL); - - gtk_entry_set_text (GTK_ENTRY (self->priv->search_entry), text); -} - -/** - * tpaw_live_search_match: - * @self: a #TpawLiveSearch - * @string: a string where to search, must be valid UTF-8. - * - * Search if one of the words in @string string starts with the current text - * of @self. - * - * Searching for "aba" in "Abasto" will match, searching in "Moraba" will not, - * and searching in "A tool (abacus)" will do. - * - * The match is not case-sensitive, and regardless of the accentuation marks. - * - * Returns: %TRUE if a match is found, %FALSE otherwise. - * - **/ -gboolean -tpaw_live_search_match (TpawLiveSearch *self, - const gchar *string) -{ - g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), FALSE); - - return tpaw_live_search_match_words (string, self->priv->stripped_words); -} - -gboolean -tpaw_live_search_match_string (const gchar *string, - const gchar *prefix) -{ - GPtrArray *words; - gboolean match; - - words = tpaw_live_search_strip_utf8_string (prefix); - match = tpaw_live_search_match_words (string, words); - if (words != NULL) - g_ptr_array_unref (words); - - return match; -} - -GPtrArray * -tpaw_live_search_get_words (TpawLiveSearch *self) -{ - return self->priv->stripped_words; -} diff --git a/tp-account-widgets/tpaw-live-search.h b/tp-account-widgets/tpaw-live-search.h deleted file mode 100644 index 0772d9d91..000000000 --- a/tp-account-widgets/tpaw-live-search.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * Copyright (C) 2007-2010 Nokia Corporation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Felix Kaser <felix.kaser@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Claudio Saavedra <csaavedra@igalia.com> - */ - -#ifndef __TPAW_LIVE_SEARCH_H__ -#define __TPAW_LIVE_SEARCH_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define TPAW_TYPE_LIVE_SEARCH (tpaw_live_search_get_type ()) -#define TPAW_LIVE_SEARCH(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_LIVE_SEARCH, TpawLiveSearch)) -#define TPAW_LIVE_SEARCH_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_LIVE_SEARCH, TpawLiveSearchClass)) -#define TPAW_IS_LIVE_SEARCH(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_LIVE_SEARCH)) -#define TPAW_IS_LIVE_SEARCH_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_LIVE_SEARCH)) -#define TPAW_LIVE_SEARCH_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_LIVE_SEARCH, TpawLiveSearchClass)) - -typedef struct _TpawLiveSearch TpawLiveSearch; -typedef struct _TpawLiveSearchPriv TpawLiveSearchPriv; -typedef struct _TpawLiveSearchClass TpawLiveSearchClass; - -struct _TpawLiveSearch { - GtkHBox parent; - - /*<private>*/ - TpawLiveSearchPriv *priv; -}; - -struct _TpawLiveSearchClass { - GtkHBoxClass parent_class; -}; - -GType tpaw_live_search_get_type (void) G_GNUC_CONST; -GtkWidget *tpaw_live_search_new (GtkWidget *hook); - -GtkWidget *tpaw_live_search_get_hook_widget (TpawLiveSearch *self); -void tpaw_live_search_set_hook_widget (TpawLiveSearch *self, - GtkWidget *hook); - -const gchar *tpaw_live_search_get_text (TpawLiveSearch *self); -void tpaw_live_search_set_text (TpawLiveSearch *self, - const gchar *text); - -gboolean tpaw_live_search_match (TpawLiveSearch *self, - const gchar *string); - -GPtrArray * tpaw_live_search_strip_utf8_string (const gchar *string); - -gboolean tpaw_live_search_match_words (const gchar *string, - GPtrArray *words); - -GPtrArray * tpaw_live_search_get_words (TpawLiveSearch *self); - -/* Made public for unit tests */ -gboolean tpaw_live_search_match_string (const gchar *string, - const gchar *prefix); - -G_END_DECLS - -#endif /* __TPAW_LIVE_SEARCH_H__ */ diff --git a/tp-account-widgets/tpaw-pixbuf-utils.c b/tp-account-widgets/tpaw-pixbuf-utils.c deleted file mode 100644 index 1d73f53c4..000000000 --- a/tp-account-widgets/tpaw-pixbuf-utils.c +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007-2013 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - * Travis Reitter <travis.reitter@collabora.co.uk> - */ - -#include "config.h" -#include "tpaw-pixbuf-utils.h" - -#include <gdk/gdkx.h> - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -GdkPixbuf * -tpaw_pixbuf_from_data (gchar *data, - gsize data_size) -{ - return tpaw_pixbuf_from_data_and_mime (data, data_size, NULL); -} - -GdkPixbuf * -tpaw_pixbuf_from_data_and_mime (gchar *data, - gsize data_size, - gchar **mime_type) -{ - GdkPixbufLoader *loader; - GdkPixbufFormat *format; - GdkPixbuf *pixbuf = NULL; - gchar **mime_types; - GError *error = NULL; - - if (!data) - return NULL; - - loader = gdk_pixbuf_loader_new (); - if (!gdk_pixbuf_loader_write (loader, (guchar *) data, data_size, &error)) - { - DEBUG ("Failed to write to pixbuf loader: %s", - error ? error->message : "No error given"); - goto out; - } - - if (!gdk_pixbuf_loader_close (loader, &error)) - { - DEBUG ("Failed to close pixbuf loader: %s", - error ? error->message : "No error given"); - goto out; - } - - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) - { - g_object_ref (pixbuf); - - if (mime_type != NULL) - { - format = gdk_pixbuf_loader_get_format (loader); - mime_types = gdk_pixbuf_format_get_mime_types (format); - - *mime_type = g_strdup (*mime_types); - if (mime_types[1] != NULL) - DEBUG ("Loader supports more than one mime " - "type! Picking the first one, %s", - *mime_type); - - g_strfreev (mime_types); - } - } - -out: - g_clear_error (&error); - g_object_unref (loader); - - return pixbuf; -} - -GdkPixbuf * -tpaw_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, - gint max_size) -{ - gint width, height; - gdouble factor; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - - if (width > 0 && (width > max_size || height > max_size)) - { - factor = (gdouble) max_size / MAX (width, height); - - width = width * factor; - height = height * factor; - - return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_HYPER); - } - - return g_object_ref (pixbuf); -} - -GdkPixbuf * -tpaw_pixbuf_from_icon_name_sized (const gchar *icon_name, - gint size) -{ - GtkIconTheme *theme; - GdkPixbuf *pixbuf; - GError *error = NULL; - - if (!icon_name) - return NULL; - - theme = gtk_icon_theme_get_default (); - - pixbuf = gtk_icon_theme_load_icon (theme, icon_name, size, 0, &error); - - if (error) - { - DEBUG ("Error loading icon: %s", error->message); - g_clear_error (&error); - } - - return pixbuf; -} - -GdkPixbuf * -tpaw_pixbuf_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size) -{ - gint w, h; - gint size = 48; - - if (!icon_name) - return NULL; - - if (gtk_icon_size_lookup (icon_size, &w, &h)) - size = (w + h) / 2; - - return tpaw_pixbuf_from_icon_name_sized (icon_name, size); -} - -gchar * -tpaw_filename_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size) -{ - GtkIconTheme *icon_theme; - GtkIconInfo *icon_info; - gint w, h; - gint size = 48; - gchar *ret; - - icon_theme = gtk_icon_theme_get_default (); - - if (gtk_icon_size_lookup (icon_size, &w, &h)) - size = (w + h) / 2; - - icon_info = gtk_icon_theme_lookup_icon (icon_theme, icon_name, size, 0); - if (icon_info == NULL) - return NULL; - - ret = g_strdup (gtk_icon_info_get_filename (icon_info)); - gtk_icon_info_free (icon_info); - - return ret; -} diff --git a/tp-account-widgets/tpaw-pixbuf-utils.h b/tp-account-widgets/tpaw-pixbuf-utils.h deleted file mode 100644 index 0521f71aa..000000000 --- a/tp-account-widgets/tpaw-pixbuf-utils.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2002-2007 Imendio AB - * Copyright (C) 2007-2013 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * Authors: Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Xavier Claessens <xclaesse@gmail.com> - * Travis Reitter <travis.reitter@collabora.co.uk> - */ - -#ifndef __TPAW_UI_UTILS_H__ -#define __TPAW_UI_UTILS_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -GdkPixbuf * tpaw_pixbuf_from_data (gchar *data, - gsize data_size); -GdkPixbuf * tpaw_pixbuf_from_data_and_mime (gchar *data, - gsize data_size, - gchar **mime_type); -GdkPixbuf * tpaw_pixbuf_scale_down_if_necessary (GdkPixbuf *pixbuf, - gint max_size); -GdkPixbuf * tpaw_pixbuf_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size); -GdkPixbuf * tpaw_pixbuf_from_icon_name_sized (const gchar *icon_name, - gint size); -gchar * tpaw_filename_from_icon_name (const gchar *icon_name, - GtkIconSize icon_size); - -G_END_DECLS - -#endif /* __TPAW_UI_UTILS_H__ */ diff --git a/tp-account-widgets/tpaw-protocol.c b/tp-account-widgets/tpaw-protocol.c deleted file mode 100644 index 55b43b97f..000000000 --- a/tp-account-widgets/tpaw-protocol.c +++ /dev/null @@ -1,544 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007-2013 Collabora Ltd. - * Copyright (C) 2013 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Jonny Lamb <jonny.lamb@collabora.co.uk> - * Marco Barisione <marco.barisione@collabora.co.uk> - */ - -#include "config.h" -#include "tpaw-protocol.h" - -#include <glib/gi18n-lib.h> -#include <tp-account-widgets/tpaw-connection-managers.h> -#include <tp-account-widgets/tpaw-utils.h> - -struct _TpawProtocolPriv -{ - TpConnectionManager *cm; - gchar *protocol_name; - gchar *service_name; - gchar *display_name; - gchar *icon_name; -}; - -enum { - PROP_CM = 1, - PROP_CM_NAME, - PROP_PROTOCOL_NAME, - PROP_SERVICE_NAME, - PROP_DISPLAY_NAME, - PROP_ICON_NAME, -}; - -G_DEFINE_TYPE (TpawProtocol, tpaw_protocol, G_TYPE_OBJECT); - -TpawAccountSettings * -tpaw_protocol_create_account_settings (TpawProtocol *self) -{ - TpawAccountSettings *settings = NULL; - gchar *str; - - /* Create account */ - /* To translator: %s is the name of the protocol, such as "Google Talk" or - * "Yahoo!" - */ - str = g_strdup_printf (_("New %s account"), self->priv->display_name); - - settings = tpaw_account_settings_new (tpaw_protocol_get_cm_name (self), - self->priv->protocol_name, - self->priv->service_name, - str); - - g_free (str); - - if (!tp_strdiff (self->priv->service_name, "google-talk")) - { - const gchar *fallback_servers[] = { - "talkx.l.google.com", - "talkx.l.google.com:443,oldssl", - "talkx.l.google.com:80", - NULL}; - - const gchar *extra_certificate_identities[] = { - "talk.google.com", - NULL}; - - tpaw_account_settings_set_icon_name_async (settings, "im-google-talk", - NULL, NULL); - tpaw_account_settings_set (settings, "server", - g_variant_new_string (extra_certificate_identities[0])); - tpaw_account_settings_set (settings, "require-encryption", - g_variant_new_boolean (TRUE)); - tpaw_account_settings_set (settings, "fallback-servers", - g_variant_new_strv (fallback_servers, -1)); - - if (tpaw_account_settings_have_tp_param (settings, - "extra-certificate-identities")) - { - tpaw_account_settings_set (settings, - "extra-certificate-identities", - g_variant_new_strv (extra_certificate_identities, -1)); - } - } - else if (!tp_strdiff (self->priv->service_name, "facebook")) - { - const gchar *fallback_servers[] = { - "chat.facebook.com:443", - NULL }; - - tpaw_account_settings_set_icon_name_async (settings, "im-facebook", - NULL, NULL); - tpaw_account_settings_set (settings, "require-encryption", - g_variant_new_boolean (TRUE)); - tpaw_account_settings_set (settings, "server", - g_variant_new_string ("chat.facebook.com")); - tpaw_account_settings_set (settings, "fallback-servers", - g_variant_new_strv (fallback_servers, -1)); - } - - return settings; -} - -TpConnectionManager * -tpaw_protocol_get_cm (TpawProtocol *self) -{ - return self->priv->cm; -} - -const gchar * -tpaw_protocol_get_cm_name (TpawProtocol *self) -{ - return tp_connection_manager_get_name (self->priv->cm); -} - -const gchar * -tpaw_protocol_get_protocol_name (TpawProtocol *self) -{ - return self->priv->protocol_name; -} - -const gchar * -tpaw_protocol_get_service_name (TpawProtocol *self) -{ - return self->priv->service_name; -} - -const gchar * -tpaw_protocol_get_display_name (TpawProtocol *self) -{ - return self->priv->display_name; -} - -const gchar * -tpaw_protocol_get_icon_name (TpawProtocol *self) -{ - return self->priv->icon_name; -} - -static void -tpaw_protocol_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TpawProtocol *self = TPAW_PROTOCOL (object); - - switch (prop_id) - { - case PROP_CM: - g_value_set_object (value, self->priv->cm); - break; - case PROP_CM_NAME: - g_value_set_string (value, - tp_connection_manager_get_name (self->priv->cm)); - break; - case PROP_PROTOCOL_NAME: - g_value_set_string (value, self->priv->protocol_name); - break; - case PROP_SERVICE_NAME: - g_value_set_string (value, self->priv->service_name); - break; - case PROP_DISPLAY_NAME: - g_value_set_string (value, self->priv->display_name); - break; - case PROP_ICON_NAME: - g_value_set_string (value, self->priv->icon_name); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -tpaw_protocol_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawProtocol *self = TPAW_PROTOCOL (object); - - switch (prop_id) - { - case PROP_CM: - self->priv->cm = g_value_dup_object (value); - break; - case PROP_PROTOCOL_NAME: - self->priv->protocol_name = g_value_dup_string (value); - break; - case PROP_SERVICE_NAME: - self->priv->service_name = g_value_dup_string (value); - break; - case PROP_DISPLAY_NAME: - self->priv->display_name = g_value_dup_string (value); - break; - case PROP_ICON_NAME: - self->priv->icon_name = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -tpaw_protocol_constructed (GObject *object) -{ - TpawProtocol *self = TPAW_PROTOCOL (object); - - if (G_OBJECT_CLASS (tpaw_protocol_parent_class)->constructed != NULL) - G_OBJECT_CLASS (tpaw_protocol_parent_class)->constructed (object); - - if (g_strcmp0 (self->priv->protocol_name, self->priv->service_name) == 0) - { - /* We want the service name only if it's different from the - * protocol name */ - g_clear_pointer (&self->priv->service_name, g_free); - } -} - -static void -tpaw_protocol_init (TpawProtocol *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TPAW_TYPE_PROTOCOL, - TpawProtocolPriv); -} - -static void -tpaw_protocol_finalize (GObject *object) -{ - TpawProtocol *self = TPAW_PROTOCOL (object); - - g_clear_object (&self->priv->cm); - g_free (self->priv->protocol_name); - g_free (self->priv->display_name); - g_free (self->priv->icon_name); - - (G_OBJECT_CLASS (tpaw_protocol_parent_class)->finalize) (object); -} - -static void -tpaw_protocol_class_init (TpawProtocolClass *klass) -{ - GObjectClass *oclass = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - oclass->finalize = tpaw_protocol_finalize; - oclass->constructed = tpaw_protocol_constructed; - oclass->get_property = tpaw_protocol_get_property; - oclass->set_property = tpaw_protocol_set_property; - - g_type_class_add_private (oclass, sizeof (TpawProtocolPriv)); - - param_spec = g_param_spec_object ("cm", - "CM", "The connection manager", - TP_TYPE_CONNECTION_MANAGER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_CM, param_spec); - - param_spec = g_param_spec_string ("cm-name", - "CM name", "The connection manager name", - NULL, - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_CM_NAME, param_spec); - - param_spec = g_param_spec_string ("protocol-name", - "Protocol name", "The name of the protocol", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_PROTOCOL_NAME, param_spec); - - param_spec = g_param_spec_string ("service-name", - "Service name", "The name of the service", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_SERVICE_NAME, param_spec); - - param_spec = g_param_spec_string ("display-name", - "Display name", "The human-readable name of the protocol", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_DISPLAY_NAME, param_spec); - - param_spec = g_param_spec_string ("icon-name", - "Icon name", "The name of the icon for the protocol", - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); - g_object_class_install_property (oclass, PROP_ICON_NAME, param_spec); -} - -typedef struct -{ - GSimpleAsyncResult *result; - GList *protocols; /* List of (owned) TpawProtocol* */ - GHashTable *seen_protocols; /* Table of (owned) protocol names -> (owned) cm names */ -} GetProtocolsData; - -static void -add_protocol (GetProtocolsData *data, - TpConnectionManager *cm, - const gchar *protocol_name, - const gchar *service_name, - const gchar *display_name, - const gchar *icon_name) -{ - TpawProtocol *protocol; - - protocol = g_object_new (TPAW_TYPE_PROTOCOL, - "cm", cm, - "protocol-name", protocol_name, - "service-name", service_name, - "display-name", display_name, - "icon-name", icon_name, - NULL); - data->protocols = g_list_prepend (data->protocols, protocol); -} - -static gint -compare_protocol_to_name (TpawProtocol *protocol, - const gchar *proto_name) -{ - return g_strcmp0 (tpaw_protocol_get_protocol_name (protocol), proto_name); -} - -static void -add_cm (GetProtocolsData *data, - TpConnectionManager *cm) -{ - GList *protocols, *l; - const gchar *cm_name; - - cm_name = tp_connection_manager_get_name (cm); - protocols = tp_connection_manager_dup_protocols (cm); - - for (l = protocols; l != NULL; l = l->next) - { - TpProtocol *tp_protocol = l->data; - gchar *icon_name; - const gchar *display_name; - const gchar *proto_name; - const gchar *saved_cm_name; - - proto_name = tp_protocol_get_name (tp_protocol); - saved_cm_name = g_hash_table_lookup (data->seen_protocols, proto_name); - - if (!tp_strdiff (cm_name, "haze") && saved_cm_name != NULL && - tp_strdiff (saved_cm_name, "haze")) - /* the CM we're adding is a haze implementation of something we already - * have; drop it. */ - continue; - - if (!tp_strdiff (cm_name, "haze") && - !tp_strdiff (proto_name, "facebook")) - /* Facebook now supports XMPP so drop the purple facebook plugin; user - * should use Gabble */ - continue; - - if (!tp_strdiff (cm_name, "haze") && - !tp_strdiff (proto_name, "sip")) - /* Haze's SIP implementation is pretty useless (bgo #629736) */ - continue; - - if (!tp_strdiff (cm_name, "butterfly")) - /* Butterfly isn't supported any more */ - continue; - - if (tp_strdiff (cm_name, "haze") && !tp_strdiff (saved_cm_name, "haze")) - { - /* Let this CM replace the haze implementation */ - GList *existing = g_list_find_custom (data->protocols, proto_name, - (GCompareFunc) compare_protocol_to_name); - g_assert (existing); - g_object_unref (existing->data); - data->protocols = g_list_delete_link (data->protocols, existing); - } - - g_hash_table_replace (data->seen_protocols, - g_strdup (proto_name), g_strdup (cm_name)); - - display_name = tpaw_protocol_name_to_display_name (proto_name); - icon_name = tpaw_protocol_icon_name (proto_name); - - add_protocol (data, cm, proto_name, proto_name, display_name, - icon_name); - - if (!tp_strdiff (proto_name, "jabber") && - !tp_strdiff (cm_name, "gabble")) - { - add_protocol (data, cm, proto_name, "google-talk", - tpaw_service_name_to_display_name ("google-talk"), - "im-google-talk"); - - add_protocol (data, cm, proto_name, "facebook", - tpaw_service_name_to_display_name ("facebook"), - "im-facebook"); - } - - g_free (icon_name); - } - - g_list_free_full (protocols, g_object_unref); -} - -static gint -sort_protocol_value (const gchar *protocol_name) -{ - guint i; - const gchar *names[] = { - "jabber", - "local-xmpp", - "gtalk", - NULL - }; - - for (i = 0 ; names[i]; i++) - { - if (g_strcmp0 (protocol_name, names[i]) == 0) - return i; - } - - return i; -} - -static gint -protocol_sort_func (TpawProtocol *proto_a, - TpawProtocol *proto_b) -{ - const gchar *name_a = tpaw_protocol_get_protocol_name (proto_a); - const gchar *name_b = tpaw_protocol_get_protocol_name (proto_b); - gint cmp = 0; - - cmp = sort_protocol_value (name_a); - cmp -= sort_protocol_value (name_b); - if (cmp == 0) - { - cmp = g_strcmp0 (name_a, name_b); - /* only happens for jabber where there is one entry for gtalk and one for - * non-gtalk */ - if (cmp == 0) - { - const gchar *service = tpaw_protocol_get_service_name (proto_a); - - if (service != NULL) - cmp = 1; - else - cmp = -1; - } - } - - return cmp; -} - -static void -cms_prepare_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawConnectionManagers *cms = TPAW_CONNECTION_MANAGERS (source); - GetProtocolsData *data = user_data; - GList *l = NULL; - GError *error = NULL; - - if (!tpaw_connection_managers_prepare_finish (cms, result, &error)) - { - g_simple_async_result_take_error (data->result, error); - g_simple_async_result_complete_in_idle (data->result); - return; - } - - for (l = tpaw_connection_managers_get_cms (cms); l != NULL; l = l->next) - add_cm (data, l->data); - - data->protocols = g_list_sort (data->protocols, - (GCompareFunc) protocol_sort_func); - - g_simple_async_result_complete_in_idle (data->result); -} - -static void -destroy_get_protocols_data (GetProtocolsData *data) -{ - g_object_unref (data->result); - g_hash_table_unref (data->seen_protocols); - g_list_free_full (data->protocols, g_object_unref); - g_slice_free (GetProtocolsData, data); -} - -void -tpaw_protocol_get_all_async (GAsyncReadyCallback callback, - gpointer user_data) -{ - GetProtocolsData *data; - TpawConnectionManagers *cms; - - data = g_slice_new0 (GetProtocolsData); - data->result = g_simple_async_result_new (NULL, callback, user_data, - tpaw_protocol_get_all_async); - g_simple_async_result_set_op_res_gpointer (data->result, data, - (GDestroyNotify) destroy_get_protocols_data); - data->seen_protocols = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, g_free); - - cms = tpaw_connection_managers_dup_singleton (); - tpaw_connection_managers_prepare_async (cms, - cms_prepare_cb, data); - g_object_unref (cms); -} - -gboolean -tpaw_protocol_get_all_finish (GList **out_protocols, - GAsyncResult *result, - GError **error) -{ - GSimpleAsyncResult *simple = (GSimpleAsyncResult *) result; - GetProtocolsData *data; - - g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, - tpaw_protocol_get_all_async), FALSE); - - if (g_simple_async_result_propagate_error (simple, error)) - return FALSE; - - if (out_protocols != NULL) - { - data = g_simple_async_result_get_op_res_gpointer (simple); - *out_protocols = g_list_copy_deep (data->protocols, (GCopyFunc) g_object_ref, NULL); - } - - return TRUE; -} diff --git a/tp-account-widgets/tpaw-protocol.h b/tp-account-widgets/tpaw-protocol.h deleted file mode 100644 index 1abc6a1e5..000000000 --- a/tp-account-widgets/tpaw-protocol.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ -/* - * Copyright (C) 2007-2013 Collabora Ltd. - * Copyright (C) 2013 Intel Corporation - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - * Jonny Lamb <jonny.lamb@collabora.co.uk - * Marco Barisione <marco.barisione@collabora.co.uk> - */ - -#ifndef __TPAW_PROTOCOL_H__ -#define __TPAW_PROTOCOL_H__ - -#include <tp-account-widgets/tpaw-account-settings.h> - -G_BEGIN_DECLS - -#define TPAW_TYPE_PROTOCOL (tpaw_protocol_get_type ()) -#define TPAW_PROTOCOL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \ - TPAW_TYPE_PROTOCOL, TpawProtocol)) -#define TPAW_PROTOCOL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \ - TPAW_TYPE_PROTOCOL, TpawProtocolClass)) -#define TPAW_IS_PROTOCOL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \ - TPAW_TYPE_PROTOCOL)) -#define TPAW_IS_PROTOCOL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \ - TPAW_TYPE_PROTOCOL)) -#define TPAW_PROTOCOL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),\ - TPAW_TYPE_PROTOCOL, TpawProtocolClass)) - -typedef struct _TpawProtocol TpawProtocol; -typedef struct _TpawProtocolPriv TpawProtocolPriv; -typedef struct _TpawProtocolClass TpawProtocolClass; - -struct _TpawProtocol -{ - GObject parent; - - /*<private>*/ - TpawProtocolPriv *priv; -}; - -struct _TpawProtocolClass -{ - GObjectClass parent_class; -}; - -GType tpaw_protocol_get_type (void) G_GNUC_CONST; - -TpawAccountSettings * tpaw_protocol_create_account_settings ( - TpawProtocol *self); - -TpConnectionManager * tpaw_protocol_get_cm ( - TpawProtocol *self); - -const gchar * tpaw_protocol_get_cm_name ( - TpawProtocol *self); - -const gchar * tpaw_protocol_get_protocol_name ( - TpawProtocol *self); - -const gchar * tpaw_protocol_get_service_name ( - TpawProtocol *self); - -const gchar * tpaw_protocol_get_display_name ( - TpawProtocol *self); - -const gchar * tpaw_protocol_get_icon_name ( - TpawProtocol *self); - -void tpaw_protocol_get_all_async ( - GAsyncReadyCallback callback, - gpointer user_data); - -gboolean tpaw_protocol_get_all_finish ( - GList **out_protocols, - GAsyncResult *result, - GError **error); - -G_END_DECLS - -#endif /* __TPAW_PROTOCOL_H__ */ diff --git a/tp-account-widgets/tpaw-string-parser.c b/tp-account-widgets/tpaw-string-parser.c deleted file mode 100644 index eb70c06d3..000000000 --- a/tp-account-widgets/tpaw-string-parser.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#include "config.h" -#include "tpaw-string-parser.h" - -#include <string.h> -#include <tp-account-widgets/tpaw-utils.h> - -#define SCHEMES "([a-zA-Z\\+]+)" -#define INVALID_CHARS "\\s\"<>" -#define INVALID_CHARS_EXT INVALID_CHARS "\\[\\](){},;:" -#define INVALID_CHARS_FULL INVALID_CHARS_EXT "?'" -#define BODY "([^"INVALID_CHARS_FULL"])([^"INVALID_CHARS_EXT"]*)" -#define BODY_END "([^"INVALID_CHARS"]*)[^"INVALID_CHARS_FULL".]" -#define URI_REGEX "("SCHEMES"://"BODY_END")" \ - "|((www|ftp)\\."BODY_END")" \ - "|((mailto:)?"BODY"@"BODY"\\."BODY_END")" - -static GRegex * -uri_regex_dup_singleton (void) -{ - static GRegex *uri_regex = NULL; - - /* We intentionally leak the regex so it's not recomputed */ - if (!uri_regex) { - GError *error = NULL; - - uri_regex = g_regex_new (URI_REGEX, 0, 0, &error); - if (uri_regex == NULL) { - g_warning ("Failed to create reg exp: %s", error->message); - g_error_free (error); - return NULL; - } - } - - return g_regex_ref (uri_regex); -} - -void -tpaw_string_parser_substr (const gchar *text, - gssize len, - TpawStringParser *parsers, - gpointer user_data) -{ - if (parsers != NULL && parsers[0].match_func != NULL) { - parsers[0].match_func (text, len, - parsers[0].replace_func, parsers + 1, - user_data); - } -} - -void -tpaw_string_match_link (const gchar *text, - gssize len, - TpawStringReplace replace_func, - TpawStringParser *sub_parsers, - gpointer user_data) -{ - GRegex *uri_regex; - GMatchInfo *match_info; - gboolean match; - gint last = 0; - - uri_regex = uri_regex_dup_singleton (); - if (uri_regex == NULL) { - tpaw_string_parser_substr (text, len, sub_parsers, user_data); - return; - } - - match = g_regex_match_full (uri_regex, text, len, 0, 0, &match_info, NULL); - if (match) { - gint s = 0, e = 0; - - do { - g_match_info_fetch_pos (match_info, 0, &s, &e); - - if (s > last) { - /* Append the text between last link (or the - * start of the message) and this link */ - tpaw_string_parser_substr (text + last, - s - last, - sub_parsers, - user_data); - } - - replace_func (text + s, e - s, NULL, user_data); - - last = e; - } while (g_match_info_next (match_info, NULL)); - } - - tpaw_string_parser_substr (text + last, len - last, - sub_parsers, user_data); - - g_match_info_free (match_info); - g_regex_unref (uri_regex); -} - -void -tpaw_string_match_all (const gchar *text, - gssize len, - TpawStringReplace replace_func, - TpawStringParser *sub_parsers, - gpointer user_data) -{ - replace_func (text, len, NULL, user_data); -} - -void -tpaw_string_replace_link (const gchar *text, - gssize len, - gpointer match_data, - gpointer user_data) -{ - GString *string = user_data; - gchar *real_url; - gchar *title; - gchar *markup; - - real_url = tpaw_make_absolute_url_len (text, len); - - /* Need to copy manually, because g_markup_printf_escaped does not work - * with string precision pitfalls. */ - title = g_strndup (text, len); - - /* Append the link inside <a href=""></a> tag */ - markup = g_markup_printf_escaped ("<a href=\"%s\">%s</a>", - real_url, title); - - g_string_append (string, markup); - - g_free (real_url); - g_free (title); - g_free (markup); -} - -void -tpaw_string_replace_escaped (const gchar *text, - gssize len, - gpointer match_data, - gpointer user_data) -{ - GString *string = user_data; - gchar *escaped; - guint i; - gsize escaped_len, old_len; - - escaped = g_markup_escape_text (text, len); - escaped_len = strlen (escaped); - - /* Allocate more space to string (we really need a g_string_extend...) */ - old_len = string->len; - g_string_set_size (string, old_len + escaped_len); - g_string_truncate (string, old_len); - - /* Remove '\r' */ - for (i = 0; i < escaped_len; i++) { - if (escaped[i] != '\r') - g_string_append_c (string, escaped[i]); - } - - g_free (escaped); -} - -gchar * -tpaw_add_link_markup (const gchar *text) -{ - TpawStringParser parsers[] = { - {tpaw_string_match_link, tpaw_string_replace_link}, - {tpaw_string_match_all, tpaw_string_replace_escaped}, - {NULL, NULL} - }; - GString *string; - - g_return_val_if_fail (text != NULL, NULL); - - string = g_string_sized_new (strlen (text)); - tpaw_string_parser_substr (text, -1, parsers, string); - - return g_string_free (string, FALSE); -} diff --git a/tp-account-widgets/tpaw-string-parser.h b/tp-account-widgets/tpaw-string-parser.h deleted file mode 100644 index 629fa4114..000000000 --- a/tp-account-widgets/tpaw-string-parser.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2010 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Xavier Claessens <xclaesse@gmail.com> - */ - -#ifndef __TPAW_STRING_PARSER_H__ -#define __TPAW_STRING_PARSER_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -typedef struct _TpawStringParser TpawStringParser; - -typedef void (*TpawStringReplace) (const gchar *text, - gssize len, - gpointer match_data, - gpointer user_data); -typedef void (*TpawStringMatch) (const gchar *text, - gssize len, - TpawStringReplace replace_func, - TpawStringParser *sub_parsers, - gpointer user_data); - -struct _TpawStringParser { - TpawStringMatch match_func; - TpawStringReplace replace_func; -}; - -void -tpaw_string_parser_substr (const gchar *text, - gssize len, - TpawStringParser *parsers, - gpointer user_data); - -void -tpaw_string_match_link (const gchar *text, - gssize len, - TpawStringReplace replace_func, - TpawStringParser *sub_parsers, - gpointer user_data); - -void -tpaw_string_match_all (const gchar *text, - gssize len, - TpawStringReplace replace_func, - TpawStringParser *sub_parsers, - gpointer user_data); - -/* Replace functions assume user_data is a GString */ -void -tpaw_string_replace_link (const gchar *text, - gssize len, - gpointer match_data, - gpointer user_data); - -void -tpaw_string_replace_escaped (const gchar *text, - gssize len, - gpointer match_data, - gpointer user_data); - -/* Returns a new string with <a> html tag around links, and escape the rest. - * To be used with gtk_label_set_markup() for example */ -gchar * -tpaw_add_link_markup (const gchar *text); - -G_END_DECLS - -#endif /* __TPAW_STRING_PARSER_H__ */ diff --git a/tp-account-widgets/tpaw-time.c b/tp-account-widgets/tpaw-time.c deleted file mode 100644 index d169fcb12..000000000 --- a/tp-account-widgets/tpaw-time.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2003-2007 Imendio AB - * Copyright (C) 2007-2012 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * Authors: Richard Hult <richard@imendio.com> - */ - -#include "config.h" -#include "tpaw-time.h" - -#include <glib/gi18n-lib.h> - -/* Note: TpawTime is always in UTC. */ - -gint64 -tpaw_time_get_current (void) -{ - GDateTime *now; - gint64 result; - - now = g_date_time_new_now_utc (); - result = g_date_time_to_unix (now); - g_date_time_unref (now); - - return result; -} - -/* Converts the UTC timestamp to a string, also in UTC. - * Returns NULL on failure. */ -gchar * -tpaw_time_to_string_utc (gint64 t, - const gchar *format) -{ - GDateTime *d; - char *result; - - g_return_val_if_fail (format != NULL, NULL); - - d = g_date_time_new_from_unix_utc (t); - result = g_date_time_format (d, format); - g_date_time_unref (d); - - return result; -} - -/* Converts the UTC timestamp to a string, in local time. - * Returns NULL on failure. */ -gchar * -tpaw_time_to_string_local (gint64 t, - const gchar *format) -{ - GDateTime *d, *local; - gchar *result; - - g_return_val_if_fail (format != NULL, NULL); - - d = g_date_time_new_from_unix_utc (t); - local = g_date_time_to_local (d); - g_date_time_unref (d); - - result = g_date_time_format (local, format); - g_date_time_unref (local); - - return result; -} - -gchar * -tpaw_duration_to_string (guint seconds) -{ - if (seconds < 60) - { - return g_strdup_printf (ngettext ("%d second ago", - "%d seconds ago", seconds), seconds); - } - else if (seconds < (60 * 60)) - { - seconds /= 60; - return g_strdup_printf (ngettext ("%d minute ago", - "%d minutes ago", seconds), seconds); - } - else if (seconds < (60 * 60 * 24)) - { - seconds /= 60 * 60; - return g_strdup_printf (ngettext ("%d hour ago", - "%d hours ago", seconds), seconds); - } - else if (seconds < (60 * 60 * 24 * 7)) - { - seconds /= 60 * 60 * 24; - return g_strdup_printf (ngettext ("%d day ago", - "%d days ago", seconds), seconds); - } - else if (seconds < (60 * 60 * 24 * 30)) - { - seconds /= 60 * 60 * 24 * 7; - return g_strdup_printf (ngettext ("%d week ago", - "%d weeks ago", seconds), seconds); - } - else - { - seconds /= 60 * 60 * 24 * 30; - return g_strdup_printf (ngettext ("%d month ago", - "%d months ago", seconds), seconds); - } -} - -gchar * -tpaw_time_to_string_relative (gint64 t) -{ - GDateTime *now, *then; - gint seconds; - GTimeSpan delta; - gchar *result; - - now = g_date_time_new_now_utc (); - then = g_date_time_new_from_unix_utc (t); - - delta = g_date_time_difference (now, then); - seconds = delta / G_TIME_SPAN_SECOND; - - if (seconds > 0) - result = tpaw_duration_to_string (seconds); - else - result = g_strdup (_("in the future")); - - g_date_time_unref (now); - g_date_time_unref (then); - - return result; -} diff --git a/tp-account-widgets/tpaw-time.h b/tp-account-widgets/tpaw-time.h deleted file mode 100644 index 2277483be..000000000 --- a/tp-account-widgets/tpaw-time.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2004 Imendio AB - * Copyright (C) 2007-2012 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_TIME_H__ -#define __TPAW_TIME_H__ - -#ifndef __USE_XOPEN -#define __USE_XOPEN -#endif -#include <time.h> -#include <glib.h> - -G_BEGIN_DECLS - -/* FIXME: ideally we should only display the hour and minutes but - * there is no localized format for that (bgo #668323) */ -#define TPAW_TIME_FORMAT_DISPLAY_SHORT "%X" -#define TPAW_DATE_FORMAT_DISPLAY_SHORT "%a %d %b %Y" -#define TPAW_TIME_DATE_FORMAT_DISPLAY_SHORT "%a %d %b %Y, %X" - -gint64 tpaw_time_get_current (void); -gchar *tpaw_time_to_string_utc (gint64 t, - const gchar *format); -gchar *tpaw_time_to_string_local (gint64 t, - const gchar *format); -gchar *tpaw_time_to_string_relative (gint64 t); -gchar *tpaw_duration_to_string (guint seconds); - -G_END_DECLS - -#endif /* __TPAW_TIME_H__ */ - diff --git a/tp-account-widgets/tpaw-uoa-utils.c b/tp-account-widgets/tpaw-uoa-utils.c deleted file mode 100644 index 46c627ab2..000000000 --- a/tp-account-widgets/tpaw-uoa-utils.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * tpaw-uoa-utils.c - Source for UOA utilities - * Copyright (C) 2012 Collabora Ltd. - * @author Xavier Claessens <xavier.claessens@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-uoa-utils.h" - -#define DEBUG_FLAG TPAW_DEBUG_ACCOUNT -#include "tpaw-debug.h" - -static AgManager *singleton = NULL; - -void -tpaw_uoa_manager_set_default (AgManager *manager) -{ - if (singleton != NULL) - return; - - singleton = manager; - g_object_add_weak_pointer ((GObject *) singleton, (gpointer) &singleton); -} - -AgManager * -tpaw_uoa_manager_dup (void) -{ - if (singleton != NULL) - return g_object_ref (singleton); - - singleton = ag_manager_new_for_service_type (TPAW_UOA_SERVICE_TYPE); - g_object_add_weak_pointer ((GObject *) singleton, (gpointer) &singleton); - - return singleton; -} diff --git a/tp-account-widgets/tpaw-uoa-utils.h b/tp-account-widgets/tpaw-uoa-utils.h deleted file mode 100644 index 3529e1ae2..000000000 --- a/tp-account-widgets/tpaw-uoa-utils.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * tpaw-utils.h - Header for UOA utilities - * Copyright (C) 2012 Collabora Ltd. - * @author Xavier Claessens <xavier.claessens@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_UOA_UTILS_H__ -#define __TPAW_UOA_UTILS_H__ - -#include <libaccounts-glib/ag-manager.h> - -#define TPAW_UOA_SERVICE_TYPE "IM" - -G_BEGIN_DECLS - -void tpaw_uoa_manager_set_default (AgManager *manager); -AgManager *tpaw_uoa_manager_dup (void); - -G_END_DECLS - -#endif /* #ifndef __TPAW_UOA_UTILS_H__*/ diff --git a/tp-account-widgets/tpaw-user-info.c b/tp-account-widgets/tpaw-user-info.c deleted file mode 100644 index 76b2f1d1f..000000000 --- a/tp-account-widgets/tpaw-user-info.c +++ /dev/null @@ -1,775 +0,0 @@ -/* - * tpaw-user-info.c - Source for TpawUserInfo - * - * Copyright (C) 2012 - Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with This library. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "config.h" -#include "tpaw-user-info.h" - -#include <glib/gi18n-lib.h> -#include <tp-account-widgets/tpaw-avatar-chooser.h> -#include <tp-account-widgets/tpaw-calendar-button.h> -#include <tp-account-widgets/tpaw-contactinfo-utils.h> -#include <tp-account-widgets/tpaw-time.h> -#include <tp-account-widgets/tpaw-utils.h> - -#define DEBUG_FLAG TPAW_DEBUG_CONTACT -#include "tpaw-debug.h" - -G_DEFINE_TYPE (TpawUserInfo, tpaw_user_info, GTK_TYPE_GRID) - -struct _TpawUserInfoPrivate -{ - TpAccount *account; - - GtkWidget *avatar_chooser; - GtkWidget *identifier_label; - GtkWidget *nickname_entry; - GtkWidget *details_label; - GtkWidget *details_spinner; - - GList *details_to_set; - gboolean details_changed; - GCancellable *details_cancellable; -}; - -enum -{ - PROP_0, - PROP_ACCOUNT, -}; - -#define DATA_FIELD "contact-info-field" -#define DATA_IS_CONTACT_INFO "is-contact-info" - -static void -contact_info_changed_cb (GtkEntry *entry, - TpawUserInfo *self) -{ - const gchar *strv[] = { NULL, NULL }; - TpContactInfoField *field; - - self->priv->details_changed = TRUE; - - field = g_object_get_data ((GObject *) entry, DATA_FIELD); - g_assert (field != NULL); - - strv[0] = gtk_entry_get_text (entry); - - if (field->field_value != NULL) - g_strfreev (field->field_value); - field->field_value = g_strdupv ((GStrv) strv); -} - -static void -bday_changed_cb (TpawCalendarButton *button, - GDate *date, - TpawUserInfo *self) -{ - const gchar *strv[] = { NULL, NULL }; - TpContactInfoField *field; - - self->priv->details_changed = TRUE; - - field = g_object_get_data ((GObject *) button, DATA_FIELD); - g_assert (field != NULL); - - if (date != NULL) - { - gchar tmp[255]; - - g_date_strftime (tmp, sizeof (tmp), TPAW_DATE_FORMAT_DISPLAY_SHORT, - date); - strv[0] = tmp; - } - - if (field->field_value != NULL) - g_strfreev (field->field_value); - field->field_value = g_strdupv ((GStrv) strv); -} - -static gboolean -field_name_in_field_list (GList *list, - const gchar *name) -{ - GList *l; - - for (l = list; l != NULL; l = g_list_next (l)) - { - TpContactInfoField *field = l->data; - - if (!tp_strdiff (field->field_name, name)) - return TRUE; - } - - return FALSE; -} - -static TpContactInfoFieldSpec * -get_spec_from_list (GList *list, - const gchar *name) -{ - GList *l; - - for (l = list; l != NULL; l = g_list_next (l)) - { - TpContactInfoFieldSpec *spec = l->data; - - if (!tp_strdiff (spec->name, name)) - return spec; - } - - return NULL; -} - -static void -add_row (GtkGrid *grid, - GtkWidget *title, - GtkWidget *value, - gboolean contact_info) -{ - /* Title */ - gtk_grid_attach_next_to (grid, title, NULL, GTK_POS_BOTTOM, 1, 1); - gtk_misc_set_alignment (GTK_MISC (title), 1, 0.5); - gtk_style_context_add_class (gtk_widget_get_style_context (title), - GTK_STYLE_CLASS_DIM_LABEL); - gtk_widget_show (title); - - /* Value */ - gtk_grid_attach_next_to (grid, value, title, GTK_POS_RIGHT, - contact_info ? 2 : 1, 1); - gtk_widget_set_hexpand (value, TRUE); - if (GTK_IS_LABEL (value)) - { - gtk_misc_set_alignment (GTK_MISC (value), 0, 0.5); - gtk_label_set_selectable (GTK_LABEL (value), TRUE); - } - gtk_widget_show (value); - - if (contact_info) - { - g_object_set_data (G_OBJECT (title), - DATA_IS_CONTACT_INFO, (gpointer) TRUE); - g_object_set_data (G_OBJECT (value), - DATA_IS_CONTACT_INFO, (gpointer) TRUE); - } -} - -static guint -fill_contact_info_grid (TpawUserInfo *self) -{ - TpConnection *connection; - TpContact *contact; - GList *specs, *l; - guint n_rows = 0; - GList *info; - const char **field_names = tpaw_contact_info_get_field_names (NULL); - guint i; - - g_assert (self->priv->details_to_set == NULL); - - connection = tp_account_get_connection (self->priv->account); - contact = tp_connection_get_self_contact (connection); - specs = tp_connection_dup_contact_info_supported_fields (connection); - info = tp_contact_dup_contact_info (contact); - - /* Look at the fields set in our vCard */ - for (l = info; l != NULL; l = l->next) - { - TpContactInfoField *field = l->data; - - /* For some reason it can happen that the vCard contains fields the CM - * claims to be not supported. This is a workaround for gabble bug - * https://bugs.freedesktop.org/show_bug.cgi?id=64319. But we shouldn't - * crash on buggy CM anyway. */ - if (get_spec_from_list (specs, field->field_name) == NULL) - { - DEBUG ("Buggy CM: self's vCard contains %s field but it is not in " - "Connection' supported fields", field->field_name); - continue; - } - - /* make a copy for the details_to_set list */ - field = tp_contact_info_field_copy (field); - DEBUG ("Field %s is in our vCard", field->field_name); - - self->priv->details_to_set = g_list_prepend (self->priv->details_to_set, - field); - } - - /* Add fields which are supported but not in the vCard */ - for (i = 0; field_names[i] != NULL; i++) - { - TpContactInfoFieldSpec *spec; - TpContactInfoField *field; - - /* Check if the field was in the vCard */ - if (field_name_in_field_list (self->priv->details_to_set, - field_names[i])) - continue; - - /* Check if the CM supports the field */ - spec = get_spec_from_list (specs, field_names[i]); - if (spec == NULL) - continue; - - /* add an empty field so user can set a value */ - field = tp_contact_info_field_new (spec->name, spec->parameters, NULL); - - self->priv->details_to_set = g_list_prepend (self->priv->details_to_set, - field); - } - - /* Add widgets for supported fields */ - self->priv->details_to_set = g_list_sort (self->priv->details_to_set, - (GCompareFunc) tpaw_contact_info_field_spec_cmp); - - for (l = self->priv->details_to_set; l != NULL; l= g_list_next (l)) - { - TpContactInfoField *field = l->data; - GtkWidget *label, *w; - TpContactInfoFieldSpec *spec; - gboolean has_field; - char *title; - - has_field = tpaw_contact_info_lookup_field (field->field_name, - NULL, NULL); - if (!has_field) - { - /* We don't display this field so we can't change it. - * But we put it in the details_to_set list so it won't be erased - * when calling SetContactInfo (bgo #630427) */ - DEBUG ("Unhandled ContactInfo field spec: %s", field->field_name); - continue; - } - - spec = get_spec_from_list (specs, field->field_name); - /* We shouldn't have added the field to details_to_set if it's not - * supported by the CM */ - g_assert (spec != NULL); - - if (spec->flags & TP_CONTACT_INFO_FIELD_FLAG_OVERWRITTEN_BY_NICKNAME) - { - DEBUG ("Ignoring field '%s' due it to having the " - "Overwritten_By_Nickname flag", field->field_name); - continue; - } - - /* Add Title */ - title = tpaw_contact_info_field_label (field->field_name, - field->parameters, - (spec->flags & TP_CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT)); - label = gtk_label_new (title); - g_free (title); - - /* TODO: if TP_CONTACT_INFO_FIELD_FLAG_PARAMETERS_EXACT is not set we - * should allow user to tag the vCard fields (bgo#672034) */ - - /* Add Value */ - if (!tp_strdiff (field->field_name, "bday")) - { - w = tpaw_calendar_button_new (); - - if (field->field_value[0]) - { - GDate date; - - g_date_set_parse (&date, field->field_value[0]); - if (g_date_valid (&date)) - { - tpaw_calendar_button_set_date (TPAW_CALENDAR_BUTTON (w), - &date); - } - } - - g_signal_connect (w, "date-changed", - G_CALLBACK (bday_changed_cb), self); - } - else - { - w = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (w), - field->field_value[0] ? field->field_value[0] : ""); - g_signal_connect (w, "changed", - G_CALLBACK (contact_info_changed_cb), self); - } - - add_row (GTK_GRID (self), label, w, TRUE); - - g_object_set_data ((GObject *) w, DATA_FIELD, field); - - n_rows++; - } - - tp_contact_info_spec_list_free (specs); - tp_contact_info_list_free (info); - - return n_rows; -} - -static void -grid_foreach_cb (GtkWidget *widget, - gpointer data) -{ - if (g_object_get_data (G_OBJECT (widget), DATA_IS_CONTACT_INFO) != NULL) - gtk_widget_destroy (widget); -} - -static void -request_contact_info_cb (GObject *object, - GAsyncResult *res, - gpointer user_data) -{ - TpawUserInfo *self = user_data; - TpContact *contact = TP_CONTACT (object); - guint n_rows; - GError *error = NULL; - - if (!tp_contact_request_contact_info_finish (contact, res, &error)) - { - /* If the request got cancelled it could mean the contact widget is - * destroyed, so we should not dereference self */ - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) - { - g_clear_error (&error); - return; - } - g_clear_error (&error); - } - - n_rows = fill_contact_info_grid (self); - - gtk_widget_set_visible (self->priv->details_label, n_rows > 0); - gtk_spinner_stop (GTK_SPINNER (self->priv->details_spinner)); - gtk_widget_hide (self->priv->details_spinner); -} - -static void -reload_contact_info (TpawUserInfo *self) -{ - TpConnection *connection; - TpContact *contact = NULL; - TpContactInfoFlags flags; - - /* Cancel previous RequestContactInfo, if any */ - if (self->priv->details_cancellable != NULL) - g_cancellable_cancel (self->priv->details_cancellable); - g_clear_object (&self->priv->details_cancellable); - - /* Remove current contact info widgets, if any */ - gtk_container_foreach (GTK_CONTAINER (self), grid_foreach_cb, NULL); - gtk_widget_hide (self->priv->details_label); - gtk_widget_hide (self->priv->details_spinner); - - tp_clear_pointer (&self->priv->details_to_set, tp_contact_info_list_free); - self->priv->details_changed = FALSE; - - connection = tp_account_get_connection (self->priv->account); - if (connection != NULL) - contact = tp_connection_get_self_contact (connection); - - /* Display infobar if we don't have a self contact (probably offline) */ - if (contact == NULL) - { - GtkWidget *infobar; - GtkWidget *content; - GtkWidget *label; - - infobar = gtk_info_bar_new (); - gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), GTK_MESSAGE_INFO); - content = gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar)); - label = gtk_label_new (_("Go online to edit your personal information.")); - gtk_container_add (GTK_CONTAINER (content), label); - gtk_widget_show (label); - - gtk_grid_attach_next_to ((GtkGrid *) self, infobar, - NULL, GTK_POS_BOTTOM, 3, 1); - gtk_widget_show (infobar); - - g_object_set_data (G_OBJECT (infobar), - DATA_IS_CONTACT_INFO, (gpointer) TRUE); - return; - } - - if (!tp_proxy_has_interface_by_id (connection, - TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACT_INFO)) - return; - - flags = tp_connection_get_contact_info_flags (connection); - if ((flags & TP_CONTACT_INFO_FLAG_CAN_SET) == 0) - return; - - /* Request the contact's info */ - gtk_widget_show (self->priv->details_spinner); - gtk_spinner_start (GTK_SPINNER (self->priv->details_spinner)); - - g_assert (self->priv->details_cancellable == NULL); - self->priv->details_cancellable = g_cancellable_new (); - tp_contact_request_contact_info_async (contact, - self->priv->details_cancellable, request_contact_info_cb, - self); -} - -static void -connection_notify_cb (TpawUserInfo *self) -{ - TpConnection *connection = tp_account_get_connection (self->priv->account); - - if (connection != NULL) - { - tp_g_signal_connect_object (connection, "notify::self-contact", - G_CALLBACK (reload_contact_info), self, G_CONNECT_SWAPPED); - } - - reload_contact_info (self); -} - -static void -identifier_notify_cb (TpAccount *account, - GParamSpec *param_spec, - TpawUserInfo *self) -{ - gtk_label_set_label (GTK_LABEL (self->priv->identifier_label), - tp_account_get_normalized_name (self->priv->account)); -} - -static void -nickname_notify_cb (TpAccount *account, - GParamSpec *param_spec, - TpawUserInfo *self) -{ - gtk_entry_set_text (GTK_ENTRY (self->priv->nickname_entry), - tp_account_get_nickname (self->priv->account)); -} - -static void -tpaw_user_info_constructed (GObject *object) -{ - TpawUserInfo *self = (TpawUserInfo *) object; - GtkGrid *grid = (GtkGrid *) self; - GtkWidget *title; - - G_OBJECT_CLASS (tpaw_user_info_parent_class)->constructed (object); - - gtk_grid_set_column_spacing (grid, 6); - gtk_grid_set_row_spacing (grid, 6); - - /* Setup id label */ - title = gtk_label_new (_("Identifier")); - self->priv->identifier_label = gtk_label_new ( - tp_account_get_normalized_name (self->priv->account)); - add_row (grid, title, self->priv->identifier_label, FALSE); - g_signal_connect_object (self->priv->account, "notify::normalized-name", - G_CALLBACK (identifier_notify_cb), self, 0); - - /* Setup nickname entry */ - title = gtk_label_new (_("Alias")); - self->priv->nickname_entry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (self->priv->nickname_entry), - tp_account_get_nickname (self->priv->account)); - add_row (grid, title, self->priv->nickname_entry, FALSE); - g_signal_connect_object (self->priv->account, "notify::nickname", - G_CALLBACK (nickname_notify_cb), self, 0); - - /* Set up avatar chooser */ - self->priv->avatar_chooser = tpaw_avatar_chooser_new (self->priv->account); - gtk_grid_attach (grid, self->priv->avatar_chooser, - 2, 0, 1, 3); - gtk_widget_show (self->priv->avatar_chooser); - - /* Details label */ - self->priv->details_label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (self->priv->details_label), - _("<b>Personal Details</b>")); - gtk_misc_set_alignment (GTK_MISC (self->priv->details_label), 0, 0.5); - gtk_grid_attach_next_to (grid, self->priv->details_label, NULL, - GTK_POS_BOTTOM, 3, 1); - - /* Details spinner */ - self->priv->details_spinner = gtk_spinner_new (); - gtk_widget_set_hexpand (self->priv->details_spinner, TRUE); - gtk_widget_set_vexpand (self->priv->details_spinner, TRUE); - gtk_grid_attach_next_to (grid, self->priv->details_spinner, NULL, - GTK_POS_BOTTOM, 3, 1); - - g_signal_connect_swapped (self->priv->account, "notify::connection", - G_CALLBACK (connection_notify_cb), self); - connection_notify_cb (self); -} - -static void -tpaw_user_info_dispose (GObject *object) -{ - TpawUserInfo *self = (TpawUserInfo *) object; - - if (self->priv->account != NULL) - { - /* Disconnect the signal manually, because TpAccount::dispose will emit - * "notify::connection" signal before tp_g_signal_connect_object() had - * a chance to disconnect. */ - g_signal_handlers_disconnect_by_func (self->priv->account, - connection_notify_cb, self); - g_clear_object (&self->priv->account); - } - - if (self->priv->details_cancellable != NULL) - g_cancellable_cancel (self->priv->details_cancellable); - g_clear_object (&self->priv->details_cancellable); - - G_OBJECT_CLASS (tpaw_user_info_parent_class)->dispose (object); -} - -static void -tpaw_user_info_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - TpawUserInfo *self = (TpawUserInfo *) object; - - switch (property_id) - { - case PROP_ACCOUNT: - g_value_set_object (value, self->priv->account); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_user_info_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - TpawUserInfo *self = (TpawUserInfo *) object; - - switch (property_id) - { - case PROP_ACCOUNT: - g_assert (self->priv->account == NULL); /* construct-only */ - self->priv->account = g_value_dup_object (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -tpaw_user_info_init (TpawUserInfo *self) -{ - self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, - TPAW_TYPE_USER_INFO, TpawUserInfoPrivate); -} - -static void -tpaw_user_info_class_init (TpawUserInfoClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GParamSpec *param_spec; - - object_class->constructed = tpaw_user_info_constructed; - object_class->dispose = tpaw_user_info_dispose; - object_class->get_property = tpaw_user_info_get_property; - object_class->set_property = tpaw_user_info_set_property; - - g_type_class_add_private (object_class, sizeof (TpawUserInfoPrivate)); - - param_spec = g_param_spec_object ("account", - "account", - "The #TpAccount on which user info should be edited", - TP_TYPE_ACCOUNT, - G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); - g_object_class_install_property (object_class, PROP_ACCOUNT, param_spec); -} - -GtkWidget * -tpaw_user_info_new (TpAccount *account) -{ - g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL); - - return g_object_new (TPAW_TYPE_USER_INFO, - "account", account, - NULL); -} - -void -tpaw_user_info_discard (TpawUserInfo *self) -{ - g_return_if_fail (TPAW_IS_USER_INFO (self)); - - reload_contact_info (self); - gtk_entry_set_text ((GtkEntry *) self->priv->nickname_entry, - tp_account_get_nickname (self->priv->account)); -} - -static void -apply_complete_one (GSimpleAsyncResult *result) -{ - guint count; - - count = g_simple_async_result_get_op_res_gssize (result); - count--; - g_simple_async_result_set_op_res_gssize (result, count); - - if (count == 0) - g_simple_async_result_complete (result); -} - -static void -avatar_chooser_apply_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpawAvatarChooser *avatar_chooser = (TpawAvatarChooser *) source; - GSimpleAsyncResult *my_result = user_data; - GError *error = NULL; - - if (!tpaw_avatar_chooser_apply_finish (avatar_chooser, result, &error)) - g_simple_async_result_take_error (my_result, error); - - apply_complete_one (my_result); - g_object_unref (my_result); -} - -static void -set_nickname_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpAccount *account = (TpAccount *) source; - GSimpleAsyncResult *my_result = user_data; - GError *error = NULL; - - if (!tp_account_set_nickname_finish (account, result, &error)) - g_simple_async_result_take_error (my_result, error); - - apply_complete_one (my_result); - g_object_unref (my_result); -} - -static void -set_contact_info_cb (GObject *source, - GAsyncResult *result, - gpointer user_data) -{ - TpConnection *connection = (TpConnection *) source; - GSimpleAsyncResult *my_result = user_data; - GError *error = NULL; - - if (!tp_connection_set_contact_info_finish (connection, result, &error)) - g_simple_async_result_take_error (my_result, error); - - apply_complete_one (my_result); - g_object_unref (my_result); -} - -static gboolean -field_value_is_empty (TpContactInfoField *field) -{ - guint i; - - if (field->field_value == NULL) - return TRUE; - - /* Field is empty if all its values are empty */ - for (i = 0; field->field_value[i] != NULL; i++) - { - if (!tp_str_empty (field->field_value[i])) - return FALSE; - } - - return TRUE; -} - -void -tpaw_user_info_apply_async (TpawUserInfo *self, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GSimpleAsyncResult *result; - const gchar *new_nickname; - guint count = 0; - GList *l, *next; - - g_return_if_fail (TPAW_IS_USER_INFO (self)); - - result = g_simple_async_result_new ((GObject *) self, callback, user_data, - tpaw_user_info_apply_async); - - /* Apply avatar */ - tpaw_avatar_chooser_apply_async ( - (TpawAvatarChooser *) self->priv->avatar_chooser, - avatar_chooser_apply_cb, g_object_ref (result)); - count++; - - /* Apply nickname */ - new_nickname = gtk_entry_get_text (GTK_ENTRY (self->priv->nickname_entry)); - if (tp_strdiff (new_nickname, tp_account_get_nickname (self->priv->account))) - { - tp_account_set_nickname_async (self->priv->account, new_nickname, - set_nickname_cb, g_object_ref (result)); - count++; - } - - /* Remove empty fields */ - for (l = self->priv->details_to_set; l != NULL; l = next) - { - TpContactInfoField *field = l->data; - - next = l->next; - if (field_value_is_empty (field)) - { - DEBUG ("Drop empty field: %s", field->field_name); - tp_contact_info_field_free (field); - self->priv->details_to_set = - g_list_delete_link (self->priv->details_to_set, l); - } - } - - if (self->priv->details_to_set != NULL) - { - if (self->priv->details_changed) - { - tp_connection_set_contact_info_async ( - tp_account_get_connection (self->priv->account), - self->priv->details_to_set, set_contact_info_cb, - g_object_ref (result)); - count++; - } - - tp_contact_info_list_free (self->priv->details_to_set); - self->priv->details_to_set = NULL; - } - - self->priv->details_changed = FALSE; - - g_simple_async_result_set_op_res_gssize (result, count); - - g_object_unref (result); -} - -gboolean -tpaw_user_info_apply_finish (TpawUserInfo *self, - GAsyncResult *result, - GError **error) -{ - tpaw_implement_finish_void (self, tpaw_user_info_apply_async); -} diff --git a/tp-account-widgets/tpaw-user-info.h b/tp-account-widgets/tpaw-user-info.h deleted file mode 100644 index 454884966..000000000 --- a/tp-account-widgets/tpaw-user-info.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * tpaw-user-info.h - Header for TpawUserInfo - * - * Copyright (C) 2012 - Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with This library. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __TPAW_USER_INFO_H__ -#define __TPAW_USER_INFO_H__ - -#include <gtk/gtk.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -#define TPAW_TYPE_USER_INFO \ - (tpaw_user_info_get_type ()) -#define TPAW_USER_INFO(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), TPAW_TYPE_USER_INFO, \ - TpawUserInfo)) -#define TPAW_USER_INFO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), TPAW_TYPE_USER_INFO, \ - TpawUserInfoClass)) -#define TPAW_IS_USER_INFO(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPAW_TYPE_USER_INFO)) -#define TPAW_IS_USER_INFO_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), TPAW_TYPE_USER_INFO)) -#define TPAW_USER_INFO_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), TPAW_TYPE_USER_INFO, \ - TpawUserInfoClass)) - -typedef struct _TpawUserInfo TpawUserInfo; -typedef struct _TpawUserInfoClass TpawUserInfoClass; -typedef struct _TpawUserInfoPrivate TpawUserInfoPrivate; - -struct _TpawUserInfo { - GtkGrid parent; - - TpawUserInfoPrivate *priv; -}; - -struct _TpawUserInfoClass { - GtkGridClass parent_class; -}; - -GType tpaw_user_info_get_type (void) G_GNUC_CONST; - -GtkWidget *tpaw_user_info_new (TpAccount *account); - -void tpaw_user_info_discard (TpawUserInfo *self); - -void tpaw_user_info_apply_async (TpawUserInfo *self, - GAsyncReadyCallback callback, - gpointer user_data); -gboolean tpaw_user_info_apply_finish (TpawUserInfo *self, - GAsyncResult *result, - GError **error); - - -G_END_DECLS - -#endif /* __TPAW_USER_INFO_H__ */ diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c deleted file mode 100644 index 70f40868e..000000000 --- a/tp-account-widgets/tpaw-utils.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (C) 2007-2013 Collabora Ltd. - * Copyright (C) 2005-2006 Imendio AB - * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com> - * Copyright (C) 2009 Steve Frécinaux <code@istique.net> - * - * Authors: Marco Barisione <marco.barisione@collabora.co.uk> - * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> - * Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Steve Frécinaux <code@istique.net> - * Emanuele Aina <emanuele.aina@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" -#include "tpaw-utils.h" - -#include <glib/gi18n-lib.h> -#include <gdk/gdkx.h> - -#define DEBUG_FLAG TPAW_DEBUG_OTHER -#include "tpaw-debug.h" - -#define TPAW_RECT_IS_ON_SCREEN(x,y,w,h) ((x) + (w) > 0 && \ - (y) + (h) > 0 && \ - (x) < gdk_screen_width () && \ - (y) < gdk_screen_height ()) - -/* Change the RequestedPresence of a newly created account to ensure that it - * is actually connected. */ -void -tpaw_connect_new_account (TpAccount *account, - TpAccountManager *account_manager) -{ - TpConnectionPresenceType presence; - gchar *status, *message; - - /* only force presence if presence was offline, unknown or unset */ - presence = tp_account_get_requested_presence (account, NULL, NULL); - switch (presence) - { - case TP_CONNECTION_PRESENCE_TYPE_OFFLINE: - case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN: - case TP_CONNECTION_PRESENCE_TYPE_UNSET: - presence = tp_account_manager_get_most_available_presence ( - account_manager, &status, &message); - - if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE) - /* Global presence is offline; we force it so user doesn't have to - * manually change the presence to connect his new account. */ - presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE; - - tp_account_request_presence_async (account, presence, - status, NULL, NULL, NULL); - - g_free (status); - g_free (message); - break; - - case TP_CONNECTION_PRESENCE_TYPE_AVAILABLE: - case TP_CONNECTION_PRESENCE_TYPE_AWAY: - case TP_CONNECTION_PRESENCE_TYPE_EXTENDED_AWAY: - case TP_CONNECTION_PRESENCE_TYPE_HIDDEN: - case TP_CONNECTION_PRESENCE_TYPE_BUSY: - case TP_CONNECTION_PRESENCE_TYPE_ERROR: - default: - /* do nothing if the presence is not offline */ - break; - } -} - -gchar * -tpaw_protocol_icon_name (const gchar *protocol) -{ - if (!tp_strdiff (protocol, "yahoojp")) - /* Yahoo Japan uses the same icon as Yahoo */ - protocol = "yahoo"; - else if (!tp_strdiff (protocol, "simple")) - /* SIMPLE uses the same icon as SIP */ - protocol = "sip"; - else if (!tp_strdiff (protocol, "sms")) - return g_strdup ("phone"); - - return g_strdup_printf ("im-%s", protocol); -} - -const char * -tpaw_protocol_name_to_display_name (const gchar *proto_name) -{ - int i; - static struct { - const gchar *proto; - const gchar *display; - gboolean translated; - } names[] = { - { "jabber", "Jabber", FALSE }, - { "msn", "Windows Live (MSN)", FALSE, }, - { "local-xmpp", N_("People Nearby"), TRUE }, - { "irc", "IRC", FALSE }, - { "icq", "ICQ", FALSE }, - { "aim", "AIM", FALSE }, - { "yahoo", "Yahoo!", FALSE }, - { "yahoojp", N_("Yahoo! Japan"), TRUE }, - { "groupwise", "GroupWise", FALSE }, - { "sip", "SIP", FALSE }, - { "gadugadu", "Gadu-Gadu", FALSE }, - { "mxit", "Mxit", FALSE }, - { "myspace", "Myspace", FALSE }, - { "sametime", "Sametime", FALSE }, - { "skype-dbus", "Skype (D-BUS)", FALSE }, - { "skype-x11", "Skype (X11)", FALSE }, - { "zephyr", "Zephyr", FALSE }, - { NULL, NULL } - }; - - for (i = 0; names[i].proto != NULL; i++) - { - if (!tp_strdiff (proto_name, names[i].proto)) - { - if (names[i].translated) - return gettext (names[i].display); - else - return names[i].display; - } - } - - return proto_name; -} - -const char * -tpaw_service_name_to_display_name (const gchar *service_name) -{ - int i; - static struct { - const gchar *service; - const gchar *display; - gboolean translated; - } names[] = { - { "google-talk", N_("Google Talk"), FALSE }, - { "facebook", N_("Facebook Chat"), TRUE }, - { NULL, NULL } - }; - - for (i = 0; names[i].service != NULL; i++) - { - if (!tp_strdiff (service_name, names[i].service)) - { - if (names[i].translated) - return gettext (names[i].display); - else - return names[i].display; - } - } - - return service_name; -} - -void -tpaw_make_color_whiter (GdkRGBA *color) -{ - const GdkRGBA white = { 1.0, 1.0, 1.0, 1.0 }; - - color->red = (color->red + white.red) / 2; - color->green = (color->green + white.green) / 2; - color->blue = (color->blue + white.blue) / 2; -} - -gboolean -tpaw_xml_validate_from_resource (xmlDoc *doc, - const gchar *dtd_resourcename) -{ - GBytes *resourcecontents; - gconstpointer resourcedata; - gsize resourcesize; - xmlParserInputBufferPtr buffer; - xmlValidCtxt cvp; - xmlDtd *dtd; - GError *error = NULL; - gboolean ret; - - DEBUG ("Loading dtd resource %s", dtd_resourcename); - - resourcecontents = g_resources_lookup_data (dtd_resourcename, G_RESOURCE_LOOKUP_FLAGS_NONE, &error); - if (error != NULL) - { - g_warning ("Unable to load dtd resource '%s': %s", dtd_resourcename, error->message); - g_error_free (error); - return FALSE; - } - resourcedata = g_bytes_get_data (resourcecontents, &resourcesize); - buffer = xmlParserInputBufferCreateStatic (resourcedata, resourcesize, XML_CHAR_ENCODING_UTF8); - - memset (&cvp, 0, sizeof (cvp)); - dtd = xmlIOParseDTD (NULL, buffer, XML_CHAR_ENCODING_UTF8); - ret = xmlValidateDtd (&cvp, doc, dtd); - - xmlFreeDtd (dtd); - g_bytes_unref (resourcecontents); - - return ret; -} - -/* Takes care of moving the window to the current workspace. */ -void -tpaw_window_present_with_time (GtkWindow *window, - guint32 timestamp) -{ - GdkWindow *gdk_window; - - g_return_if_fail (GTK_IS_WINDOW (window)); - - /* Move the window to the current workspace before trying to show it. - * This is the behaviour people expect when clicking on the statusbar icon. */ - gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); - - if (gdk_window) - { - gint x, y; - gint w, h; - - /* Has no effect if the WM has viewports, like compiz */ - gdk_x11_window_move_to_current_desktop (gdk_window); - - /* If window is still off-screen, hide it to force it to - * reposition on the current workspace. */ - gtk_window_get_position (window, &x, &y); - gtk_window_get_size (window, &w, &h); - if (!TPAW_RECT_IS_ON_SCREEN (x, y, w, h)) - gtk_widget_hide (GTK_WIDGET (window)); - } - - if (timestamp == GDK_CURRENT_TIME) - gtk_window_present (window); - else - gtk_window_present_with_time (window, timestamp); -} - -void -tpaw_window_present (GtkWindow *window) -{ - tpaw_window_present_with_time (window, gtk_get_current_event_time ()); -} - -GtkWindow * -tpaw_get_toplevel_window (GtkWidget *widget) -{ - GtkWidget *toplevel; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - toplevel = gtk_widget_get_toplevel (widget); - if (GTK_IS_WINDOW (toplevel) && - gtk_widget_is_toplevel (toplevel)) - return GTK_WINDOW (toplevel); - - return NULL; -} - -/** tpaw_make_absolute_url_len: - * @url: an url - * @len: a length - * - * Same as #tpaw_make_absolute_url but for a limited string length - */ -gchar * -tpaw_make_absolute_url_len (const gchar *url, - guint len) -{ - g_return_val_if_fail (url != NULL, NULL); - - if (g_str_has_prefix (url, "help:") || - g_str_has_prefix (url, "mailto:") || - strstr (url, ":/")) - return g_strndup (url, len); - - if (strstr (url, "@")) - return g_strdup_printf ("mailto:%.*s", len, url); - - return g_strdup_printf ("http://%.*s", len, url); -} - -/** tpaw_make_absolute_url: - * @url: an url - * - * The URL opening code can't handle schemeless strings, so we try to be - * smart and add http if there is no scheme or doesn't look like a mail - * address. This should work in most cases, and let us click on strings - * like "www.gnome.org". - * - * Returns: a newly allocated url with proper mailto: or http:// prefix, use - * g_free when your are done with it - */ -gchar * -tpaw_make_absolute_url (const gchar *url) -{ - return tpaw_make_absolute_url_len (url, strlen (url)); -} diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h deleted file mode 100644 index d9cdc6d94..000000000 --- a/tp-account-widgets/tpaw-utils.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (C) 2007-2013 Collabora Ltd. - * Copyright (C) 2005-2006 Imendio AB - * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com> - * Copyright (C) 2009 Steve Frécinaux <code@istique.net> - * - * Authors: Marco Barisione <marco.barisione@collabora.co.uk> - * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> - * Sjoerd Simons <sjoerd.simons@collabora.co.uk> - * Xavier Claessens <xavier.claessens@collabora.co.uk> - * Mikael Hallendal <micke@imendio.com> - * Richard Hult <richard@imendio.com> - * Martyn Russell <martyn@imendio.com> - * Steve Frécinaux <code@istique.net> - * Emanuele Aina <emanuele.aina@collabora.co.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __TPAW_UTILS_H__ -#define __TPAW_UTILS_H__ - -#include <glib.h> -#include <gtk/gtk.h> -#include <libxml/tree.h> -#include <telepathy-glib/telepathy-glib.h> - -G_BEGIN_DECLS - -#define TPAW_STR_EMPTY(s) ((s) == NULL || (s)[0] == '\0') - -#define TPAW_ACCOUNT_WIDGETS_RESOURCES_PREFIX "/org/gnome/AccountWidgets" - -void tpaw_connect_new_account (TpAccount *account, - TpAccountManager *account_manager); - -gchar *tpaw_protocol_icon_name (const gchar *protocol); -const gchar *tpaw_protocol_name_to_display_name (const gchar *proto_name); -const gchar *tpaw_service_name_to_display_name (const gchar *proto_name); - -/* XML */ -gboolean tpaw_xml_validate_from_resource (xmlDoc *doc, - const gchar *dtd_resourcename); - -void tpaw_make_color_whiter (GdkRGBA *color); - -/* Windows */ -void tpaw_window_present (GtkWindow *window); -void tpaw_window_present_with_time (GtkWindow *window, - guint32 timestamp); -GtkWindow * tpaw_get_toplevel_window (GtkWidget *widget); - -/* URL */ -gchar * tpaw_make_absolute_url (const gchar *url); -gchar * tpaw_make_absolute_url_len (const gchar *url, - guint len); - -/* Copied from wocky/wocky-utils.h */ - -#define tpaw_implement_finish_void(source, tag) \ - if (g_simple_async_result_propagate_error (\ - G_SIMPLE_ASYNC_RESULT (result), error)) \ - return FALSE; \ - g_return_val_if_fail (g_simple_async_result_is_valid (result, \ - G_OBJECT(source), tag), \ - FALSE); \ - return TRUE; - -#define tpaw_implement_finish_copy_pointer(source, tag, copy_func, \ - out_param) \ - GSimpleAsyncResult *_simple; \ - _simple = (GSimpleAsyncResult *) result; \ - if (g_simple_async_result_propagate_error (_simple, error)) \ - return FALSE; \ - g_return_val_if_fail (g_simple_async_result_is_valid (result, \ - G_OBJECT (source), tag), \ - FALSE); \ - if (out_param != NULL) \ - *out_param = copy_func ( \ - g_simple_async_result_get_op_res_gpointer (_simple)); \ - return TRUE; - -#define tpaw_implement_finish_return_copy_pointer(source, tag, copy_func) \ - GSimpleAsyncResult *_simple; \ - _simple = (GSimpleAsyncResult *) result; \ - if (g_simple_async_result_propagate_error (_simple, error)) \ - return NULL; \ - g_return_val_if_fail (g_simple_async_result_is_valid (result, \ - G_OBJECT (source), tag), \ - NULL); \ - return copy_func (g_simple_async_result_get_op_res_gpointer (_simple)); - -#define tpaw_implement_finish_return_pointer(source, tag) \ - GSimpleAsyncResult *_simple; \ - _simple = (GSimpleAsyncResult *) result; \ - if (g_simple_async_result_propagate_error (_simple, error)) \ - return NULL; \ - g_return_val_if_fail (g_simple_async_result_is_valid (result, \ - G_OBJECT (source), tag), \ - NULL); \ - return g_simple_async_result_get_op_res_gpointer (_simple); - -G_END_DECLS - -#endif /* __TPAW_UTILS_H__ */ |