- AC_INIT(Empathy, 2.27.4, http://bugzilla.gnome.org/browse.cgi?product=empathy)
+ AC_INIT(Empathy, 2.27.5, http://bugzilla.gnome.org/browse.cgi?product=empathy)
AC_PREREQ(2.59)
AC_COPYRIGHT([
Copyright (C) 2003-2007 Imendio AB
# (Interfaces removed: CURRENT++, AGE=0, REVISION=0)
# (Interfaces added: CURRENT++, AGE++, REVISION=0)
# (No interfaces changed: REVISION++)
- LIBEMPATHY_CURRENT=26
+ LIBEMPATHY_CURRENT=27
LIBEMPATHY_AGE=0
LIBEMPATHY_REVISION=0
- LIBEMPATHY_GTK_CURRENT=24
+ LIBEMPATHY_GTK_CURRENT=25
LIBEMPATHY_GTK_AGE=0
LIBEMPATHY_GTK_REVISION=0
GCONF_REQUIRED=1.2.0
LIBPANELAPPLET_REQUIRED=2.10.0
TELEPATHY_GLIB_REQUIRED=0.7.31
-MISSION_CONTROL_REQUIRED=4.61
ENCHANT_REQUIRED=1.2.0
ISO_CODES_REQUIRED=0.35
LIBNOTIFY_REQUIRED=0.4.4
gio-unix-2.0 >= $GLIB_REQUIRED
libxml-2.0
telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
telepathy-farsight
farsight2-0.10
gstreamer-0.10
gtk+-2.0 >= $GTK_REQUIRED
libcanberra-gtk >= $LIBCANBERRA_GTK_REQUIRED
telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
farsight2-0.10
gstreamer-0.10
gstreamer-interfaces-0.10
libebook-1.2
dbus-glib-1
telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
telepathy-farsight
gstreamer-0.10
])
AC_ARG_ENABLE(network-manager,
AS_HELP_STRING([--enable-network-manager=@<:@no/yes/auto@:>@],
[build with network-manager support]), ,
- enable_webkit=auto)
+ enable_network_manager=auto)
if test "x$enable_network_manager" != "xno"; then
PKG_CHECK_MODULES(NETWORK_MANAGER,
glib-2.0 >= $GLIB_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
+ telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
], have_megaphone="yes", have_megaphone="no")
else
have_megaphone=no
glib-2.0 >= $GLIB_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
+ telepathy-glib >= $TELEPATHY_GLIB_REQUIRED
], have_nothere="yes", have_nothere="no")
else
have_nothere=no
gobject-2.0
gconf-2.0 >= $GCONF_REQUIRED
libxml-2.0
- libmissioncontrol >= $MISSION_CONTROL_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
gstreamer-0.10
gstreamer-interfaces-0.10
empathy-contact-list-store.c \
empathy-contact-list-view.c \
empathy-contact-menu.c \
+ empathy-share-my-desktop.c \
empathy-contact-selector.c \
empathy-contact-widget.c \
empathy-geometry.c \
empathy-log-window.c \
empathy-new-message-dialog.c \
empathy-presence-chooser.c \
- empathy-profile-chooser.c \
+ empathy-protocol-chooser.c \
empathy-smiley-manager.c \
empathy-sound.c \
empathy-spell.c \
empathy-theme-boxes.c \
empathy-theme-irc.c \
empathy-theme-manager.c \
+ empathy-kludge-label.c \
empathy-ui-utils.c
libempathy_gtk_la_SOURCES = \
empathy-contact-list-store.h \
empathy-contact-list-view.h \
empathy-contact-menu.h \
+ empathy-share-my-desktop.h \
empathy-contact-selector.h \
empathy-contact-widget.h \
empathy-geometry.h \
empathy-log-window.h \
empathy-new-message-dialog.h \
empathy-presence-chooser.h \
- empathy-profile-chooser.h \
+ empathy-protocol-chooser.h \
empathy-smiley-manager.h \
empathy-sound.h \
empathy-spell.h \
empathy-theme-boxes.h \
empathy-theme-irc.h \
empathy-theme-manager.h \
+ empathy-kludge-label.h \
empathy-ui-utils.h
check_c_sources = \
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-utils.h>
typedef struct {
EmpathyAccountManager *manager;
gboolean set_active_item;
+ gboolean account_manually_set;
gboolean has_all_option;
EmpathyAccountChooserFilterFunc filter;
gpointer filter_data;
chooser->priv = priv;
priv->set_active_item = FALSE;
+ priv->account_manually_set = FALSE;
priv->filter = NULL;
priv->filter_data = NULL;
empathy_account_chooser_set_account (EmpathyAccountChooser *chooser,
EmpathyAccount *account)
{
+ EmpathyAccountChooserPriv *priv;
GtkComboBox *combobox;
GtkTreeModel *model;
GtkTreeIter iter;
g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), FALSE);
+ priv = GET_PRIV (chooser);
+
combobox = GTK_COMBO_BOX (chooser);
model = gtk_combo_box_get_model (combobox);
gtk_combo_box_get_active_iter (combobox, &iter);
(GtkTreeModelForeachFunc) account_chooser_set_account_foreach,
&data);
+ priv->account_manually_set = data.set;
+
return data.set;
}
COL_ACCOUNT_POINTER, &account,
-1);
- icon_name = empathy_icon_name_from_account (account);
+ icon_name = empathy_account_get_icon_name (account);
if (priv->filter) {
is_enabled = priv->filter (account, priv->filter_data);
}
-1);
/* set first connected account as active account */
- if (priv->set_active_item == FALSE && is_enabled) {
+ if (priv->account_manually_set == FALSE &&
+ priv->set_active_item == FALSE && is_enabled) {
priv->set_active_item = TRUE;
gtk_combo_box_set_active_iter (combobox, iter);
}
{
TpConnectionStatus status;
- g_object_get (account, "status", &status, NULL);
+ g_object_get (account, "connection-status", &status, NULL);
return status == TP_CONNECTION_STATUS_CONNECTED;
}
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-protocol.h>
-
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-irc-network-manager.h>
#define IRC_NETWORKS_FILENAME "irc-networks.xml"
typedef struct {
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
EmpathyIrcNetworkManager *network_manager;
GtkWidget *vbox_settings;
EmpathyAccountWidgetIrc *settings)
{
g_object_unref (settings->network_manager);
- g_object_unref (settings->account);
+ g_object_unref (settings->settings);
g_slice_free (EmpathyAccountWidgetIrc, settings);
}
unset_server_params (EmpathyAccountWidgetIrc *settings)
{
DEBUG ("Unset server, port and use-ssl");
- empathy_account_unset_param (settings->account, "server");
- empathy_account_unset_param (settings->account, "port");
- empathy_account_unset_param (settings->account, "use-ssl");
+ empathy_account_settings_unset (settings->settings, "server");
+ empathy_account_settings_unset (settings->settings, "port");
+ empathy_account_settings_unset (settings->settings, "use-ssl");
}
static void
g_object_get (network, "charset", &charset, NULL);
DEBUG ("Setting charset to %s", charset);
- empathy_account_set_param_string (settings->account, "charset", charset);
+ empathy_account_settings_set_string (settings->settings, "charset", charset);
g_free (charset);
servers = empathy_irc_network_get_servers (network);
NULL);
DEBUG ("Setting server to %s", address);
- empathy_account_set_param_string (settings->account, "server", address);
+ empathy_account_settings_set_string (settings->settings,
+ "server", address);
DEBUG ("Setting port to %u", port);
- empathy_account_set_param_int (settings->account, "port", port);
+ empathy_account_settings_set_uint32 (settings->settings, "port", port);
DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
- empathy_account_set_param_boolean (settings->account, "use-ssl", ssl);
+ empathy_account_settings_set_boolean (settings->settings,
+ "use-ssl", ssl);
g_free (address);
}
static void
account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
{
- gchar *nick = NULL;
- gchar *fullname = NULL;
- gchar *server = NULL;
+ const gchar *nick = NULL;
+ const gchar *fullname = NULL;
+ const gchar *server = NULL;
gint port = 6667;
- gchar *charset;
+ const gchar *charset;
gboolean ssl = FALSE;
EmpathyIrcNetwork *network = NULL;
- nick = empathy_account_get_param_string (settings->account, "account");
- fullname = empathy_account_get_param_string (settings->account, "fullname");
- server = empathy_account_get_param_string (settings->account, "server");
- charset = empathy_account_get_param_string (settings->account, "charset");
- port = empathy_account_get_param_int (settings->account, "port");
- ssl = empathy_account_get_param_boolean (settings->account, "use-ssl");
+ nick = empathy_account_settings_get_string (settings->settings, "account");
+ fullname = empathy_account_settings_get_string (settings->settings,
+ "fullname");
+ server = empathy_account_settings_get_string (settings->settings, "server");
+ charset = empathy_account_settings_get_string (settings->settings, "charset");
+ port = empathy_account_settings_get_uint32 (settings->settings, "port");
+ ssl = empathy_account_settings_get_boolean (settings->settings, "use-ssl");
if (!nick)
{
nick = g_strdup (g_get_user_name ());
- empathy_account_set_param_string (settings->account, "account", nick);
+ empathy_account_settings_set_string (settings->settings,
+ "account", nick);
}
if (!fullname)
{
fullname = g_strdup (nick);
}
- empathy_account_set_param_string (settings->account, "fullname", fullname);
+ empathy_account_settings_set_string (settings->settings,
+ "fullname", fullname);
}
if (server != NULL)
fill_networks_model (settings, network);
-
- g_free (nick);
- g_free (fullname);
- g_free (server);
- g_free (charset);
}
/**
* empathy_account_widget_irc_new:
- * @account: the #EmpathyAccount to configure
+ * @settings: the #EmpathyAccountSettings to configure
*
* Creates a new IRC account widget to configure a given #EmpathyAccount
*
* Returns: The toplevel container of the configuration widget
*/
GtkWidget *
-empathy_account_widget_irc_new (EmpathyAccount *account)
+empathy_account_widget_irc_new (EmpathyAccountSettings *account_settings)
{
EmpathyAccountWidgetIrc *settings;
gchar *dir, *user_file_with_path, *global_file_with_path;
GtkBuilder *gui;
+ GtkWidget *widget;
GtkListStore *store;
GtkCellRenderer *renderer;
gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetIrc);
- settings->account = g_object_ref (account);
+ settings->settings = g_object_ref (account_settings);
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+ 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);
filename = empathy_file_lookup ("empathy-account-widget-irc.ui",
"libempathy-gtk");
gui = empathy_builder_get_file (filename,
- "vbox_irc_settings", &settings->vbox_settings,
+ "vbox_irc", &widget,
+ "table_irc_settings", &settings->vbox_settings,
"combobox_network", &settings->combobox_network,
NULL);
g_free (filename);
account_widget_irc_setup (settings);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (account_settings, gui,
"entry_nick", "account",
"entry_fullname", "fullname",
"entry_password", "password",
NULL);
empathy_builder_connect (gui, settings,
- "vbox_irc_settings", "destroy", account_widget_irc_destroy_cb,
- "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb,
- "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb,
- "button_remove_network", "clicked", account_widget_irc_button_remove_clicked_cb,
- "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb,
+ "table_irc_settings", "destroy", account_widget_irc_destroy_cb,
+ "button_network", "clicked",
+ account_widget_irc_button_edit_network_clicked_cb,
+ "button_add_network", "clicked",
+ account_widget_irc_button_add_network_clicked_cb,
+ "button_remove_network", "clicked",
+ account_widget_irc_button_remove_clicked_cb,
+ "combobox_network", "changed",
+ account_widget_irc_combobox_network_changed_cb,
NULL);
empathy_account_widget_set_default_focus (gui, "entry_nick");
+ empathy_account_widget_add_apply_button (account_settings, widget);
- return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings);
+ return empathy_builder_unref_and_keep_widget (gui, widget);
}
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-contact-list.h>
EMPATHY_CONTACT_WIDGET_SHOW_LOCATION |
EMPATHY_CONTACT_WIDGET_EDIT_NONE);
gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
contact_widget,
TRUE, TRUE, 0);
gtk_widget_show (contact_widget);
EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
contact_widget,
TRUE, TRUE, 0);
gtk_widget_show (contact_widget);
EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
EMPATHY_CONTACT_WIDGET_EDIT_AVATAR);
gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (personal_dialog)->vbox),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (personal_dialog))),
contact_widget,
TRUE, TRUE, 0);
empathy_contact_widget_set_account_filter (contact_widget,
gboolean result;
connection = empathy_account_get_connection (account);
+ if (connection == NULL)
+ return FALSE;
contact_manager = empathy_contact_manager_dup_singleton ();
- result = empathy_contact_manager_can_add (contact_manager, connection);
+ result = empathy_contact_manager_get_flags_for_connection (contact_manager, connection) & EMPATHY_CONTACT_LIST_CAN_ADD;
g_object_unref (contact_manager);
return result;
void
empathy_new_contact_dialog_show (GtkWindow *parent)
+ {
+ empathy_new_contact_dialog_show_with_contact (parent, NULL);
+ }
+
+ void
+ empathy_new_contact_dialog_show_with_contact (GtkWindow *parent,
+ EmpathyContact *contact)
{
GtkWidget *dialog;
GtkWidget *button;
gtk_widget_show (button);
/* Contact info widget */
- contact_widget = empathy_contact_widget_new (NULL,
+ contact_widget = empathy_contact_widget_new (contact,
EMPATHY_CONTACT_WIDGET_EDIT_ALIAS |
EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT |
EMPATHY_CONTACT_WIDGET_EDIT_ID |
EMPATHY_CONTACT_WIDGET_EDIT_GROUPS);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
contact_widget,
TRUE, TRUE, 0);
empathy_contact_widget_set_account_filter (contact_widget,
#include <libempathy/empathy-time.h>
#include <libempathy/empathy-utils.h>
-#include <libmissioncontrol/mc-profile.h>
#include "empathy-theme-adium.h"
#include "empathy-smiley-manager.h"
EmpathySmileyManager *smiley_manager;
EmpathyContact *last_contact;
time_t last_timestamp;
+ gboolean last_is_backlog;
gboolean page_loaded;
GList *message_queue;
+ gchar *hovered_uri;
+ guint notify_enable_webkit_developer_tools_id;
+ GtkWidget *inspector_window;
} EmpathyThemeAdiumPriv;
struct _EmpathyAdiumData {
gchar *template_html;
gchar *in_content_html;
gsize in_content_len;
+ gchar *in_context_html;
+ gsize in_context_len;
gchar *in_nextcontent_html;
gsize in_nextcontent_len;
+ gchar *in_nextcontext_html;
+ gsize in_nextcontext_len;
gchar *out_content_html;
gsize out_content_len;
+ gchar *out_context_html;
+ gsize out_context_len;
gchar *out_nextcontent_html;
gsize out_nextcontent_len;
+ gchar *out_nextcontext_html;
+ gsize out_nextcontext_len;
gchar *status_html;
gsize status_len;
GHashTable *info;
G_IMPLEMENT_INTERFACE (EMPATHY_TYPE_CHAT_VIEW,
theme_adium_iface_init));
+ static void
+ theme_adium_update_enable_webkit_developer_tools (EmpathyThemeAdium *theme)
+ {
+ WebKitWebView *web_view = WEBKIT_WEB_VIEW (theme);
+ gboolean enable_webkit_developer_tools;
+
+ if (empathy_conf_get_bool (empathy_conf_get (), "/apps/empathy/conversation/enable_webkit_developer_tools", &enable_webkit_developer_tools) == FALSE)
+ return;
+
+ g_object_set (G_OBJECT (webkit_web_view_get_settings (web_view)),
+ "enable-developer-extras",
+ enable_webkit_developer_tools,
+ NULL);
+ }
+
+ static void
+ theme_adium_notify_enable_webkit_developer_tools_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
+ {
+ EmpathyThemeAdium *theme = user_data;
+
+ theme_adium_update_enable_webkit_developer_tools (theme);
+ }
+
static WebKitNavigationResponse
theme_adium_navigation_requested_cb (WebKitWebView *view,
WebKitWebFrame *frame,
return WEBKIT_NAVIGATION_RESPONSE_IGNORE;
}
+ static void
+ theme_adium_hovering_over_link_cb (EmpathyThemeAdium *theme,
+ gchar *title,
+ gchar *uri,
+ gpointer user_data)
+ {
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+
+ if (tp_strdiff (uri, priv->hovered_uri)) {
+ g_free (priv->hovered_uri);
+ priv->hovered_uri = g_strdup (uri);
+ }
+ }
+
+ static void
+ theme_adium_copy_address_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+ {
+ EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (user_data);
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ gtk_clipboard_set_text (clipboard, priv->hovered_uri, -1);
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
+ gtk_clipboard_set_text (clipboard, priv->hovered_uri, -1);
+ }
+
+ static void
+ theme_adium_open_address_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+ {
+ EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (user_data);
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+
+ empathy_url_show (GTK_WIDGET (menuitem), priv->hovered_uri);
+ }
+
static void
theme_adium_populate_popup_cb (WebKitWebView *view,
GtkMenu *menu,
gpointer user_data)
{
- GtkWidget *item;
+ EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (view);
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+ GtkWidget *item;
+ GList *items;
+ GtkWidget *icon;
+ gchar *stock_id;
+ gboolean is_link = FALSE;
+ gboolean developer_tools_enabled;
+
+ /* FIXME: WebKitGTK+'s context menu API clearly needs an
+ * overhaul. There is currently no way to know what is being
+ * clicked, to decide what features to provide. You either
+ * take what it gives you as a menu, or use hacks to figure
+ * out what to display. */
+ items = gtk_container_get_children (GTK_CONTAINER (menu));
+ item = GTK_WIDGET (g_list_nth_data (items, 0));
+ g_list_free (items);
+
+ if (GTK_IS_IMAGE_MENU_ITEM (item)) {
+ icon = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (item));
+ gtk_image_get_stock (GTK_IMAGE (icon), &stock_id, NULL);
+
+ if ((!strcmp (stock_id, GTK_STOCK_OPEN)) && priv->hovered_uri)
+ is_link = TRUE;
+ }
/* Remove default menu items */
- gtk_container_foreach (GTK_CONTAINER (menu),
- (GtkCallback) gtk_widget_destroy, NULL);
+ g_object_get (G_OBJECT (webkit_web_view_get_settings (view)),
+ "enable-developer-extras", &developer_tools_enabled, NULL);
+ if (!developer_tools_enabled)
+ gtk_container_foreach (GTK_CONTAINER (menu),
+ (GtkCallback) gtk_widget_destroy, NULL);
/* Select all item */
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SELECT_ALL, NULL);
G_CALLBACK (empathy_chat_view_clear),
view);
- /* FIXME: Add open_link and copy_link when those bugs are fixed:
- * https://bugs.webkit.org/show_bug.cgi?id=16092
- * https://bugs.webkit.org/show_bug.cgi?id=16562
- */
+ /* We will only add the following menu items if we are
+ * right-clicking a link */
+ if (!is_link)
+ return;
+
+ /* Separator */
+ item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* Copy Link Address menu item */
+ item = gtk_menu_item_new_with_mnemonic (_("_Copy Link Address"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (theme_adium_copy_address_cb),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
+
+ /* Open Link menu item */
+ item = gtk_menu_item_new_with_mnemonic (_("_Open Link"));
+ g_signal_connect (item, "activate",
+ G_CALLBACK (theme_adium_open_address_cb),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item);
+ gtk_widget_show (item);
}
static gchar *
} else if (theme_adium_match (&cur, "%time")) {
gchar *format = NULL;
gchar *end;
-
/* Time can be in 2 formats:
* %time% or %time{strftime format}%
* Extract the time format if provided. */
EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
EmpathyContact *sender;
EmpathyAccount *account;
- McProfile *account_profile;
gchar *dup_body = NULL;
const gchar *body;
const gchar *name;
gsize len = 0;
const gchar *func;
const gchar *service_name;
- const gchar *message_classes = NULL;
+ GString *message_classes = NULL;
+ gboolean is_backlog;
if (!priv->page_loaded) {
priv->message_queue = g_list_prepend (priv->message_queue,
/* Get information */
sender = empathy_message_get_sender (msg);
account = empathy_contact_get_account (sender);
- account_profile = empathy_account_get_profile (account);
- service_name = mc_profile_get_display_name (account_profile);
+ service_name = empathy_account_get_protocol (account);
timestamp = empathy_message_get_timestamp (msg);
body = empathy_message_get_body (msg);
dup_body = theme_adium_parse_body (theme, body);
}
}
+ is_backlog = empathy_message_is_backlog (msg);
+
/* Get the right html/func to add the message */
func = "appendMessage";
+
+ message_classes = g_string_new ("message");
+
+ /* eventually append the "history" class */
+ if (is_backlog) {
+ g_string_append (message_classes, " history");
+ }
+
+ /* check the sender of the message and append the appropriate class */
+ if (empathy_contact_is_user (sender)) {
+ g_string_append (message_classes, " outgoing");
+ }
+ else {
+ g_string_append (message_classes, " incoming");
+ }
+
/*
* To mimick Adium's behavior, we only want to join messages
- * sent within a 5 minute time frame.
+ * sent by the same contact within a 5 minute time frame.
*/
if (empathy_contact_equal (priv->last_contact, sender) &&
- (timestamp - priv->last_timestamp < MESSAGE_JOIN_PERIOD)) {
+ (timestamp - priv->last_timestamp < MESSAGE_JOIN_PERIOD) &&
+ (is_backlog == priv->last_is_backlog)) {
+ /* the messages can be appended */
func = "appendNextMessage";
+ g_string_append (message_classes, " consecutive");
+
+ /* check who is the sender of the message to use the correct html file */
if (empathy_contact_is_user (sender)) {
- message_classes = "consecutive incoming message";
- html = priv->data->out_nextcontent_html;
- len = priv->data->out_nextcontent_len;
+ /* check if this is a backlog message and use NextContext.html */
+ if (is_backlog) {
+ html = priv->data->out_nextcontext_html;
+ len = priv->data->out_nextcontext_len;
+ }
+
+ /*
+ * html is null if this is not a backlog message or
+ * if we have to fallback (NextContext.html missing).
+ * use NextContent.html
+ */
+ if (html == NULL) {
+ html = priv->data->out_nextcontent_html;
+ len = priv->data->out_nextcontent_len;
+ }
}
- if (!html) {
- message_classes = "consecutive message outgoing";
- html = priv->data->in_nextcontent_html;
- len = priv->data->in_nextcontent_len;
+ else {
+ if (is_backlog) {
+ html = priv->data->in_nextcontext_html;
+ len = priv->data->in_nextcontext_len;
+ }
+
+ if (html == NULL) {
+ html = priv->data->in_nextcontent_html;
+ len = priv->data->in_nextcontent_len;
+ }
}
}
- if (!html) {
+
+ /*
+ * we have html == NULL here if:
+ * 1. the message didn't have to be appended because
+ * the sender was different or the timestamp was too far
+ * 2. NextContent.html file does not exist, so we must
+ * not forget to fallback to the correct Content.html
+ */
+ if (html == NULL) {
if (empathy_contact_is_user (sender)) {
- if (!message_classes) {
- message_classes = "incoming message";
+ if (is_backlog) {
+ html = priv->data->out_context_html;
+ len = priv->data->out_context_len;
+ }
+
+ if (html == NULL) {
+ html = priv->data->out_content_html;
+ len = priv->data->out_content_len;
}
- html = priv->data->out_content_html;
- len = priv->data->out_content_len;
}
- if (!html) {
- if (!message_classes) {
- message_classes = "message outgoing";
+ else {
+ if (is_backlog) {
+ html = priv->data->in_context_html;
+ len = priv->data->in_context_len;
+ }
+
+ if (html == NULL) {
+ html = priv->data->in_content_html;
+ len = priv->data->in_content_len;
}
- html = priv->data->in_content_html;
- len = priv->data->in_content_len;
}
}
theme_adium_append_html (theme, func, html, len, body, avatar_filename,
- name, contact_id, service_name, message_classes,
+ name, contact_id, service_name, message_classes->str,
timestamp);
/* Keep the sender of the last displayed message */
}
priv->last_contact = g_object_ref (sender);
priv->last_timestamp = timestamp;
+ priv->last_is_backlog = is_backlog;
g_free (dup_body);
+ g_string_free (message_classes, TRUE);
}
static void
priv->data->template_html,
basedir_uri);
g_free (basedir_uri);
+
+ /* Clear last contact to avoid trying to add a 'joined'
+ * message when we don't have an insertion point. */
+ if (priv->last_contact) {
+ g_object_unref (priv->last_contact);
+ priv->last_contact = NULL;
+ }
}
static gboolean
EmpathyThemeAdiumPriv *priv = GET_PRIV (object);
empathy_adium_data_unref (priv->data);
+ g_free (priv->hovered_uri);
+
+ empathy_conf_notify_remove (empathy_conf_get (),
+ priv->notify_enable_webkit_developer_tools_id);
G_OBJECT_CLASS (empathy_theme_adium_parent_class)->finalize (object);
}
priv->last_contact = NULL;
}
+ if (priv->inspector_window) {
+ gtk_widget_destroy (priv->inspector_window);
+ priv->inspector_window = NULL;
+ }
+
G_OBJECT_CLASS (empathy_theme_adium_parent_class)->dispose (object);
}
+ static gboolean
+ theme_adium_inspector_show_window_cb (WebKitWebInspector *inspector,
+ gpointer user_data)
+ {
+ EmpathyThemeAdium *theme = user_data;
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
+
+ gtk_widget_show_all (priv->inspector_window);
+
+ return TRUE;
+ }
+
+ static gboolean
+ theme_adium_inspector_close_window_cb (WebKitWebInspector *inspector,
+ gpointer user_data)
+ {
+ EmpathyThemeAdium *theme = user_data;
+ EmpathyThemeAdiumPriv *priv;
+
+ /* We may be called too late - when the theme has already been
+ * destroyed */
+ if (!theme)
+ return FALSE;
+
+ priv = GET_PRIV (theme);
+
+ if (priv->inspector_window) {
+ gtk_widget_hide (priv->inspector_window);
+ }
+
+ return TRUE;
+ }
+
+ static WebKitWebView *
+ theme_adium_inspect_web_view_cb (WebKitWebInspector *inspector,
+ WebKitWebView *web_view,
+ gpointer data)
+ {
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (EMPATHY_THEME_ADIUM (web_view));
+ GtkWidget *scrolled_window;
+ GtkWidget *inspector_web_view;
+
+ if (!priv->inspector_window) {
+ priv->inspector_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_default_size (GTK_WINDOW (priv->inspector_window),
+ 800, 600);
+
+ g_signal_connect (priv->inspector_window, "delete-event",
+ G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+ scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_container_add (GTK_CONTAINER (priv->inspector_window), scrolled_window);
+
+ inspector_web_view = webkit_web_view_new ();
+ gtk_container_add (GTK_CONTAINER (scrolled_window), inspector_web_view);
+
+ return WEBKIT_WEB_VIEW (inspector_web_view);
+ }
+
+ return NULL;
+ }
+
static void
theme_adium_constructed (GObject *object)
{
if (font_size) {
g_object_set (G_OBJECT (webkit_settings), "default-font-size", font_size, NULL);
}
- webkit_web_view_set_settings (WEBKIT_WEB_VIEW (object), webkit_settings);
+
+ g_signal_connect (webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (object)), "inspect-web-view",
+ G_CALLBACK (theme_adium_inspect_web_view_cb), NULL);
+
+ g_signal_connect (webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (object)), "show-window",
+ G_CALLBACK (theme_adium_inspector_show_window_cb), object);
+
+ g_signal_connect (webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (object)), "close-window",
+ G_CALLBACK (theme_adium_inspector_close_window_cb), NULL);
/* Load template */
basedir_uri = g_strconcat ("file://", priv->data->basedir, NULL);
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
-
g_type_class_add_private (object_class, sizeof (EmpathyThemeAdiumPriv));
}
g_signal_connect (theme, "populate-popup",
G_CALLBACK (theme_adium_populate_popup_cb),
NULL);
+ g_signal_connect (theme, "hovering-over-link",
+ G_CALLBACK (theme_adium_hovering_over_link_cb),
+ NULL);
+
+ priv->notify_enable_webkit_developer_tools_id =
+ empathy_conf_notify_add (empathy_conf_get (),
+ "/apps/empathy/conversation/enable_webkit_developer_tools",
+ theme_adium_notify_enable_webkit_developer_tools_cb,
+ theme);
+
+ theme_adium_update_enable_webkit_developer_tools (theme);
}
EmpathyThemeAdium *
gboolean ret;
gchar *file;
+ /* The theme is not valid if there is no Info.plist */
+ file = g_build_filename (path, "Contents", "Info.plist",
+ NULL);
+ ret = g_file_test (file, G_FILE_TEST_EXISTS);
+ g_free (file);
+
+ if (ret == FALSE)
+ return ret;
+
/* We ship a default Template.html as fallback if there is any problem
* with the one inside the theme. The only other required file is
* Content.html for incoming messages (outgoing fallback to use
value = empathy_plist_parse_from_file (file);
g_free (file);
- if (value) {
- info = g_value_dup_boxed (value);
- tp_g_value_slice_free (value);
- }
+ if (value == NULL)
+ return NULL;
+
+ info = g_value_dup_boxed (value);
+ tp_g_value_slice_free (value);
+
+ /* Insert the theme's path into the hash table,
+ * keys have to be dupped */
+ tp_asv_set_string (info, g_strdup ("path"), path);
return info;
}
g_file_get_contents (file, &data->in_nextcontent_html, &data->in_nextcontent_len, NULL);
g_free (file);
+ file = g_build_filename (data->basedir, "Incoming", "Context.html", NULL);
+ g_file_get_contents (file, &data->in_context_html, &data->in_context_len, NULL);
+ g_free (file);
+
+ file = g_build_filename (data->basedir, "Incoming", "NextContext.html", NULL);
+ g_file_get_contents (file, &data->in_nextcontext_html, &data->in_nextcontext_len, NULL);
+ g_free (file);
+
file = g_build_filename (data->basedir, "Outgoing", "Content.html", NULL);
g_file_get_contents (file, &data->out_content_html, &data->out_content_len, NULL);
g_free (file);
g_file_get_contents (file, &data->out_nextcontent_html, &data->out_nextcontent_len, NULL);
g_free (file);
+ file = g_build_filename (data->basedir, "Outgoing", "Context.html", NULL);
+ g_file_get_contents (file, &data->out_context_html, &data->out_context_len, NULL);
+ g_free (file);
+
+ file = g_build_filename (data->basedir, "Outgoing", "NextContext.html", NULL);
+ g_file_get_contents (file, &data->out_nextcontext_html, &data->out_nextcontext_len, NULL);
+ g_free (file);
+
file = g_build_filename (data->basedir, "Status.html", NULL);
g_file_get_contents (file, &data->status_html, &data->status_len, NULL);
g_free (file);
{
g_return_val_if_fail (data != NULL, NULL);
- data->ref_count++;
+ g_atomic_int_inc (&data->ref_count);
return data;
}
{
g_return_if_fail (data != NULL);
- data->ref_count--;
- if (data->ref_count == 0) {
+ if (g_atomic_int_dec_and_test (&data->ref_count)) {
g_free (data->path);
g_free (data->basedir);
g_free (data->template_html);
g_free (data->in_content_html);
g_free (data->in_nextcontent_html);
+ g_free (data->in_context_html);
+ g_free (data->in_nextcontext_html);
g_free (data->out_content_html);
g_free (data->out_nextcontent_html);
+ g_free (data->out_context_html);
+ g_free (data->out_nextcontext_html);
g_free (data->default_avatar_filename);
g_free (data->default_incoming_avatar_filename);
g_free (data->default_outgoing_avatar_filename);
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <libmissioncontrol/mc-profile.h>
-
#include "empathy-ui-utils.h"
#include "empathy-images.h"
#include "empathy-conf.h"
return widget;
}
-const gchar *
-empathy_icon_name_from_account (EmpathyAccount *account)
-{
- McProfile *profile;
-
- profile = empathy_account_get_profile (account);
-
- return mc_profile_get_icon_name (profile);
-}
-
const gchar *
empathy_icon_name_for_presence (TpConnectionPresenceType presence)
{
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
- gdk_window = GTK_WIDGET (window)->window;
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
if (!gdk_window) {
return FALSE;
}
GdkWindow *gdk_window;
gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL);
- gdk_window = GTK_WIDGET (window)->window;
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
dpy = gdk_x11_drawable_get_xdisplay (gdk_window);
data[0] = icon_location.x;
static gchar *
fixup_url (const gchar *url)
{
+ g_return_val_if_fail (url != NULL, NULL);
+
if (g_str_has_prefix (url, "ghelp:") ||
g_str_has_prefix (url, "mailto:") ||
strstr (url, ":/")) {
gchar *real_url;
GError *error = NULL;
+ g_return_if_fail (GTK_IS_WIDGET (parent));
+ g_return_if_fail (url != NULL);
+
real_url = fixup_url (url);
if (real_url) {
url = real_url;
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <telepathy-glib/interfaces.h>
+
#include "empathy-tp-chat.h"
#include "empathy-chatroom-manager.h"
#include "empathy-account-manager.h"
/* Set the default file path */
gchar *dir;
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+ dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
+
+ /* FIXME: g_mapped_file_free has been deprecated in GLib 2.22, but the
+ * replacement symbol, g_mapped_file_unref is not available in older Glib
+ * and we're not ready to bump our version requirement just for this. When
+ * we're ready to bump our version requirement, just revert this patch. */
+ #undef G_DISABLE_DEPRECATED
#include <glib/gstdio.h>
+ #define G_DISABLE_DEPRECATED
+#include <telepathy-glib/util.h>
+
#include "empathy-log-store.h"
#include "empathy-log-store-empathy.h"
#include "empathy-log-manager.h"
self->priv = priv;
- priv->basedir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (),
- ".gnome2", PACKAGE_NAME, "logs", NULL);
+ priv->basedir = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (),
+ PACKAGE_NAME, "logs", NULL);
priv->name = g_strdup ("Empathy");
priv->account_manager = empathy_account_manager_dup_singleton ();
const gchar *chat_id,
gboolean chatroom)
{
- const gchar *account_id;
gchar *basedir;
+ gchar *escaped;
EmpathyLogStoreEmpathyPriv *priv;
priv = GET_PRIV (self);
- account_id = empathy_account_get_unique_name (account);
+ /* unique name is an object path, ignore the initial / and replace the others
+ * by % */
+ escaped = g_strdup (empathy_account_get_unique_name (account) + 1);
+
+ g_strdelimit (escaped, "/", '%');
if (chatroom)
- basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir, account_id,
+ basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir, escaped,
LOG_DIR_CHATROOMS, chat_id, NULL);
else
basedir = g_build_path (G_DIR_SEPARATOR_S, priv->basedir,
- account_id, chat_id, NULL);
+ escaped, chat_id, NULL);
+
+ g_free (escaped);
return basedir;
}
{
EmpathyLogStoreEmpathyPriv *priv = GET_PRIV (self);
EmpathyLogSearchHit *hit;
- const gchar *account_name;
+ gchar *unescaped;
+ gchar *account_name;
const gchar *end;
gchar **strv;
guint len;
else
account_name = strv[len-3];
+ unescaped = g_strdup_printf ("/%s", g_strdelimit (account_name, "%", '/'));
+
hit->account = empathy_account_manager_lookup (priv->account_manager,
- account_name);
+ unescaped);
hit->filename = g_strdup (filename);
+ g_free (unescaped);
g_strfreev (strv);
return hit;
/* Get the account from the filename */
hit = log_store_empathy_search_hit_new (self, filename);
- account = g_object_ref (hit->account);
+
+ if (hit->account != NULL)
+ account = g_object_ref (hit->account);
+
empathy_log_manager_search_hit_free (hit);
+ if (hit->account == NULL)
+ return NULL;
+
/* Create parser. */
ctxt = xmlNewParserCtxt ();
empathy_message_set_sender (message, sender);
empathy_message_set_timestamp (message, t);
empathy_message_set_tptype (message, msg_type);
+ empathy_message_set_is_backlog (message, TRUE);
if (cm_id_str)
empathy_message_set_id (message, cm_id);
#include <telepathy-glib/channel.h>
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
+#include <telepathy-glib/interfaces.h>
#include "empathy-tp-chat.h"
#include "empathy-tp-contact-factory.h"
tp_chat_check_if_ready (EMPATHY_TP_CHAT (chat));
}
+ static EmpathyContact *
+ chat_lookup_contact (EmpathyTpChat *chat,
+ TpHandle handle,
+ gboolean remove)
+ {
+ EmpathyTpChatPriv *priv = GET_PRIV (chat);
+ GList *l;
+
+ for (l = priv->members; l; l = l->next) {
+ EmpathyContact *c = l->data;
+
+ if (empathy_contact_get_handle (c) != handle) {
+ continue;
+ }
+
+ if (remove) {
+ /* Caller takes the reference. */
+ priv->members = g_list_delete_link (priv->members, l);
+ } else {
+ g_object_ref (c);
+ }
+
+ return c;
+ }
+
+ return NULL;
+ }
+
static void
tp_chat_group_members_changed_cb (TpChannel *self,
gchar *message,
{
EmpathyTpChatPriv *priv = GET_PRIV (chat);
EmpathyContact *contact;
- TpHandle handle;
+ EmpathyContact *actor_contact = NULL;
guint i;
- GList *l;
+
+ if (actor != 0) {
+ actor_contact = chat_lookup_contact (chat, actor, FALSE);
+ if (actor_contact == NULL) {
+ /* FIXME: handle this a tad more gracefully: perhaps
+ * the actor was a server op. We could use the
+ * contact-ids detail of MembersChangedDetailed.
+ */
+ DEBUG ("actor %u not a channel member", actor);
+ }
+ }
/* Remove contacts that are not members anymore */
for (i = 0; i < removed->len; i++) {
- for (l = priv->members; l; l = l->next) {
- contact = l->data;
- handle = empathy_contact_get_handle (contact);
- if (handle == g_array_index (removed, TpHandle, i)) {
- priv->members = g_list_delete_link (priv->members, l);
- g_signal_emit_by_name (chat, "members-changed",
- contact, NULL, reason,
- message, FALSE);
- g_object_unref (contact);
- break;
- }
+ contact = chat_lookup_contact (chat,
+ g_array_index (removed, TpHandle, i), TRUE);
+
+ if (contact != NULL) {
+ g_signal_emit_by_name (chat, "members-changed", contact,
+ actor_contact, reason, message,
+ FALSE);
+ g_object_unref (contact);
}
}
}
tp_chat_update_remote_contact (chat);
+
+ if (actor_contact != NULL) {
+ g_object_unref (actor_contact);
+ }
}
static void
#include <telepathy-glib/connection.h>
#include <telepathy-glib/util.h>
#include <telepathy-glib/dbus.h>
+#include <telepathy-glib/interfaces.h>
#include "empathy-tp-contact-list.h"
#include "empathy-tp-contact-factory.h"
GHashTable *pendings; /* handle -> EmpathyContact */
GHashTable *groups; /* group name -> TpChannel */
GHashTable *add_to_group; /* group name -> GArray of handles */
+
+ EmpathyContactListFlags flags;
} EmpathyTpContactListPriv;
typedef enum {
/* We refuse to send our presence to those contacts, remove from pendings */
for (i = 0; i < removed->len; i++) {
tp_contact_list_remove_handle (list, priv->pendings,
- g_array_index (added, TpHandle, i));
+ g_array_index (removed, TpHandle, i));
}
/* Those contacts want our presence, auto accept those that are already
list);
}
+ static void
+ tp_contact_list_get_alias_flags_cb (TpConnection *connection,
+ guint flags,
+ const GError *error,
+ gpointer user_data,
+ GObject *list)
+ {
+ EmpathyTpContactListPriv *priv = GET_PRIV (list);
+
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
+ if (flags & TP_CONNECTION_ALIAS_FLAG_USER_SET) {
+ priv->flags |= EMPATHY_CONTACT_LIST_CAN_ALIAS;
+ }
+ }
+
+ static void
+ tp_contact_list_get_requestablechannelclasses_cb (TpProxy *connection,
+ const GValue *value,
+ const GError *error,
+ gpointer user_data,
+ GObject *list)
+ {
+ EmpathyTpContactListPriv *priv = GET_PRIV (list);
+ GPtrArray *classes;
+ int i;
+
+ if (error) {
+ DEBUG ("Error: %s", error->message);
+ return;
+ }
+
+ classes = g_value_get_boxed (value);
+ for (i = 0; i < classes->len; i++) {
+ GValueArray *class = g_ptr_array_index (classes, i);
+ GHashTable *props;
+ const char *channel_type;
+ guint handle_type;
+
+ props = g_value_get_boxed (g_value_array_get_nth (class, 0));
+
+ channel_type = tp_asv_get_string (props,
+ TP_IFACE_CHANNEL ".ChannelType");
+ handle_type = tp_asv_get_uint32 (props,
+ TP_IFACE_CHANNEL ".TargetHandleType", NULL);
+
+ if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_CONTACT_LIST) &&
+ handle_type == TP_HANDLE_TYPE_GROUP) {
+ DEBUG ("Got channel class for a contact group");
+ priv->flags |= EMPATHY_CONTACT_LIST_CAN_GROUP;
+ break;
+ }
+ }
+ }
+
static void
tp_contact_list_publish_request_handle_cb (TpConnection *connection,
const GArray *handles,
/* Those contacts refuse to send us their presence, remove from members. */
for (i = 0; i < removed->len; i++) {
tp_contact_list_remove_handle (list, priv->members,
- g_array_index (added, TpHandle, i));
+ g_array_index (removed, TpHandle, i));
}
/* We want those contacts in our contact list but we don't get their
priv->factory = empathy_tp_contact_factory_dup_singleton (priv->connection);
+ /* call GetAliasFlags */
+ if (tp_proxy_has_interface_by_id (priv->connection,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING)) {
+ tp_cli_connection_interface_aliasing_call_get_alias_flags (
+ priv->connection,
+ -1,
+ tp_contact_list_get_alias_flags_cb,
+ NULL, NULL,
+ G_OBJECT (list));
+ }
+
+ /* lookup RequestableChannelClasses */
+ if (tp_proxy_has_interface_by_id (priv->connection,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS)) {
+ tp_cli_dbus_properties_call_get (priv->connection,
+ -1,
+ TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
+ "RequestableChannelClasses",
+ tp_contact_list_get_requestablechannelclasses_cb,
+ NULL, NULL,
+ G_OBJECT (list));
+ } else {
+ /* we just don't know... better mark the flag just in case */
+ priv->flags |= EMPATHY_CONTACT_LIST_CAN_GROUP;
+ }
+
names[0] = "publish";
tp_cli_connection_call_request_handles (priv->connection,
-1,
g_array_free (handles, TRUE);
}
+ static EmpathyContactListFlags
+ tp_contact_list_get_flags (EmpathyContactList *list)
+ {
+ EmpathyTpContactListPriv *priv;
+ EmpathyContactListFlags flags;
+ TpChannelGroupFlags group_flags;
+
+ g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE);
+
+ priv = GET_PRIV (list);
+ flags = priv->flags;
+
+ group_flags = tp_channel_group_get_flags (priv->subscribe);
+
+ if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) {
+ flags |= EMPATHY_CONTACT_LIST_CAN_ADD;
+ }
+
+ if (group_flags & TP_CHANNEL_GROUP_FLAG_CAN_REMOVE) {
+ flags |= EMPATHY_CONTACT_LIST_CAN_REMOVE;
+ }
+
+ return flags;
+ }
+
static void
tp_contact_list_iface_init (EmpathyContactListIface *iface)
{
iface->remove_from_group = tp_contact_list_remove_from_group;
iface->rename_group = tp_contact_list_rename_group;
iface->remove_group = tp_contact_list_remove_group;
- }
-
- gboolean
- empathy_tp_contact_list_can_add (EmpathyTpContactList *list)
- {
- EmpathyTpContactListPriv *priv;
- TpChannelGroupFlags flags;
-
- g_return_val_if_fail (EMPATHY_IS_TP_CONTACT_LIST (list), FALSE);
-
- priv = GET_PRIV (list);
-
- if (priv->subscribe == NULL)
- return FALSE;
-
- flags = tp_channel_group_get_flags (priv->subscribe);
- return (flags & TP_CHANNEL_GROUP_FLAG_CAN_ADD) != 0;
+ iface->get_flags = tp_contact_list_get_flags;
}
void
#include <panel-2.0/panel-applet-gconf.h>
#include <gconf/gconf-client.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-dispatcher.h>
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 500);
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (contact_list));
- gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), scroll);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), scroll);
gtk_widget_show (scroll);
g_object_set_data (G_OBJECT (dialog), "contact-list", contact_list);
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkImage" id="add_image">
+ <property name="stock">gtk-add</property>
+ <property name="icon-size">4</property>
+ </object>
<object class="GtkDialog" id="accounts_dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Accounts</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <child>
- <object class="GtkAlignment" id="alignment2">
- <property name="visible">True</property>
- <property name="xscale">0</property>
- <property name="yscale">0</property>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-add</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="label3">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Add...</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- </child>
+ <property name="image">add_image</property>
+ <property name="label" translatable="yes">_Add...</property>
+ <property name="use_underline">True</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkFrame" id="frame_no_profile">
+ <object class="GtkFrame" id="frame_no_protocol">
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
#include <libnotify/notification.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mission-control.h>
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
"chat-window-tab-close-button");
context = gtk_widget_get_pango_context (hbox);
- metrics = pango_context_get_metrics (context, hbox->style->font_desc,
+ metrics = pango_context_get_metrics (context, gtk_widget_get_style (hbox)->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
g_free (escaped);
}
+ static void
+ chat_window_set_highlight_room_tab_label (EmpathyChat *chat)
+ {
+ gchar *markup;
+ GtkWidget *widget;
+
+ if (empathy_chat_is_room (chat) == FALSE)
+ return;
+
+ markup = g_markup_printf_escaped ("<span color=\"%s\">%s</span>",
+ "red",
+ empathy_chat_get_name (chat));
+
+ widget = g_object_get_data (G_OBJECT (chat), "chat-window-tab-label");
+ gtk_label_set_markup (GTK_LABEL (widget), markup);
+ g_free (markup);
+ }
+
static void
chat_window_new_message_cb (EmpathyChat *chat,
EmpathyMessage *message,
return;
}
+ if (!g_list_find (priv->chats_new_msg, chat)) {
+ priv->chats_new_msg = g_list_prepend (priv->chats_new_msg, chat);
+ chat_window_update_chat_tab (chat);
+ }
+
/* If empathy_chat_is_room () returns TRUE, that means it's a named MUC.
* If empathy_chat_get_remote_contact () returns NULL, that means it's
* an unamed MUC (msn-like).
}
if (needs_urgency) {
- if (!has_focus)
+ if (!has_focus) {
chat_window_set_urgency_hint (window, TRUE);
+ chat_window_set_highlight_room_tab_label (chat);
+ }
empathy_sound_play (GTK_WIDGET (priv->dialog),
EMPATHY_SOUND_MESSAGE_INCOMING);
chat_window_show_or_update_notification (window, message, chat);
}
-
- if (!g_list_find (priv->chats_new_msg, chat)) {
- priv->chats_new_msg = g_list_prepend (priv->chats_new_msg, chat);
- chat_window_update_chat_tab (chat);
- }
}
static GtkNotebook *
const gchar *account_id;
const gchar *contact_id;
- id = (const gchar*) selection->data;
+ id = (const gchar*) gtk_selection_data_get_data (selection);
account_manager = empathy_account_manager_dup_singleton ();
DEBUG ("DND contact from roster with id:'%s'", id);
DEBUG ("DND tab");
- chat = (void *) selection->data;
+ chat = (void *) gtk_selection_data_get_data (selection);
old_window = chat_window_find_chat (*chat);
if (old_window) {
gboolean sensitive)
{
EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
- GtkWidget *vbox = GTK_DIALOG (debug_dialog)->vbox;
+ GtkWidget *vbox = gtk_dialog_get_content_area (GTK_DIALOG (debug_dialog));
gtk_widget_set_sensitive (GTK_WIDGET (priv->save_button), sensitive);
gtk_widget_set_sensitive (GTK_WIDGET (priv->copy_button), sensitive);
EmpathyDebugDialog *debug_dialog)
{
EmpathyDebugDialogPriv *priv = GET_PRIV (debug_dialog);
- MissionControl *mc;
TpDBusDaemon *dbus;
GError *error = NULL;
gchar *bus_name;
return;
}
- mc = empathy_mission_control_dup_singleton ();
dbus = tp_dbus_daemon_dup (&error);
if (error != NULL)
{
DEBUG ("Failed at duping the dbus daemon: %s", error->message);
- g_object_unref (mc);
}
gtk_tree_model_get (GTK_TREE_MODEL (priv->cms), &iter,
debug_dialog_get_messages_cb, debug_dialog, NULL, NULL);
g_object_unref (dbus);
- g_object_unref (mc);
}
typedef struct
gtk_window_set_title (GTK_WINDOW (object), _("Debug Window"));
gtk_window_set_default_size (GTK_WINDOW (object), 800, 400);
- vbox = GTK_DIALOG (object)->vbox;
+ vbox = gtk_dialog_get_content_area (GTK_DIALOG (object));
toolbar = gtk_toolbar_new ();
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
#include <libempathy-gtk/empathy-sound.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libmissioncontrol/mission-control.h>
-
#include "empathy-accounts-dialog.h"
#include "empathy-main-window.h"
#include "ephy-spinner.h"
typedef struct {
EmpathyContactListView *list_view;
EmpathyContactListStore *list_store;
- MissionControl *mc;
EmpathyAccountManager *account_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyEventManager *event_manager;
GtkWidget *presence_chooser;
GtkWidget *errors_vbox;
+ GtkRadioAction *sort_by_name;
+ GtkRadioAction *sort_by_status;
+ GtkRadioAction *normal_with_avatars;
+ GtkRadioAction *normal_size;
+ GtkRadioAction *compact_size;
+
GtkUIManager *ui_manager;
GtkAction *view_history;
GtkAction *room_join_favorites;
{
gchar *filename;
- filename = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, ACCELS_FILENAME, NULL);
+ filename = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, ACCELS_FILENAME, NULL);
if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
DEBUG ("Loading from:'%s'", filename);
gtk_accel_map_load (filename);
gchar *dir;
gchar *file_with_path;
- dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+ dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
file_with_path = g_build_filename (dir, ACCELS_FILENAME, NULL);
g_free (dir);
g_list_free (window->actions_connected);
- g_object_unref (window->mc);
g_object_unref (window->account_manager);
g_object_unref (window->list_store);
g_hash_table_destroy (window->errors);
//empathy_sound_set_enabled (TRUE);
}
+ static void
+ main_window_notify_sort_contact_cb (EmpathyConf *conf,
+ const gchar *key,
+ EmpathyMainWindow *window)
+ {
+ gchar *str = NULL;
+
+ if (empathy_conf_get_string (conf, key, &str) && str) {
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ type = empathy_contact_list_store_sort_get_type ();
+ enum_class = G_ENUM_CLASS (g_type_class_peek (type));
+ enum_value = g_enum_get_value_by_nick (enum_class, str);
+ if (enum_value) {
+ /* By changing the value of the GtkRadioAction,
+ it emits a signal that calls main_window_view_sort_contacts_cb
+ which updates the contacts list */
+ gtk_radio_action_set_current_value (window->sort_by_name,
+ enum_value->value);
+ } else {
+ g_warning ("Wrong value for sort_criterium configuration : %s", str);
+ }
+ g_free (str);
+ }
+ }
+
+ static void
+ main_window_view_sort_contacts_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EmpathyMainWindow *window)
+ {
+ EmpathyContactListStoreSort value;
+ GSList *group;
+ GType type;
+ GEnumClass *enum_class;
+ GEnumValue *enum_value;
+
+ value = gtk_radio_action_get_current_value (action);
+ group = gtk_radio_action_get_group (action);
+
+ /* Get string from index */
+ type = empathy_contact_list_store_sort_get_type ();
+ enum_class = G_ENUM_CLASS (g_type_class_peek (type));
+ enum_value = g_enum_get_value (enum_class, g_slist_index (group, current));
+
+ if (!enum_value) {
+ g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
+ g_slist_index (group, action));
+ } else {
+ empathy_conf_set_string (empathy_conf_get (),
+ EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
+ enum_value->value_nick);
+ }
+ empathy_contact_list_store_set_sort_criterium (window->list_store, value);
+ }
+
+ /* Matches GtkRadioAction values set in empathy-main-window.ui */
+ #define CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS 0
+ #define CONTACT_LIST_NORMAL_SIZE 1
+ #define CONTACT_LIST_COMPACT_SIZE 2
+
+ static void
+ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
+ GtkRadioAction *current,
+ EmpathyMainWindow *window)
+ {
+ gint value;
+
+ value = gtk_radio_action_get_current_value (action);
+
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_UI_SHOW_AVATARS,
+ value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
+ value == CONTACT_LIST_COMPACT_SIZE);
+
+ empathy_contact_list_store_set_show_avatars (window->list_store,
+ value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
+ empathy_contact_list_store_set_is_compact (window->list_store,
+ value == CONTACT_LIST_COMPACT_SIZE);
+ }
+
+ static void
+ main_window_notify_contact_list_size_cb (EmpathyConf *conf,
+ const gchar *key,
+ EmpathyMainWindow *window)
+ {
+ gboolean show_avatars;
+ gboolean compact_contact_list;
+ gint value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
+
+ if (empathy_conf_get_bool (conf,
+ EMPATHY_PREFS_UI_SHOW_AVATARS,
+ &show_avatars)
+ && empathy_conf_get_bool (conf,
+ EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
+ &compact_contact_list)) {
+ if (compact_contact_list) {
+ value = CONTACT_LIST_COMPACT_SIZE;
+ } else if (show_avatars) {
+ value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
+ } else {
+ value = CONTACT_LIST_NORMAL_SIZE;
+ }
+ }
+ /* By changing the value of the GtkRadioAction,
+ it emits a signal that calls main_window_view_contacts_list_size_cb
+ which updates the contacts list */
+ gtk_radio_action_set_current_value (window->normal_with_avatars, value);
+ }
+
static void
main_window_view_show_map_cb (GtkCheckMenuItem *item,
EmpathyMainWindow *window)
}
}
- static void
- main_window_notify_show_avatars_cb (EmpathyConf *conf,
- const gchar *key,
- EmpathyMainWindow *window)
- {
- gboolean show_avatars;
-
- if (empathy_conf_get_bool (conf, key, &show_avatars)) {
- empathy_contact_list_store_set_show_avatars (window->list_store,
- show_avatars);
- }
- }
-
- static void
- main_window_notify_compact_contact_list_cb (EmpathyConf *conf,
- const gchar *key,
- EmpathyMainWindow *window)
- {
- gboolean compact_contact_list;
-
- if (empathy_conf_get_bool (conf, key, &compact_contact_list)) {
- empathy_contact_list_store_set_is_compact (window->list_store,
- compact_contact_list);
- }
- }
-
- static void
- main_window_notify_sort_criterium_cb (EmpathyConf *conf,
- const gchar *key,
- EmpathyMainWindow *window)
- {
- gchar *str = NULL;
-
- if (empathy_conf_get_string (conf, key, &str) && str) {
- GType type;
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- type = empathy_contact_list_store_sort_get_type ();
- enum_class = G_ENUM_CLASS (g_type_class_peek (type));
- enum_value = g_enum_get_value_by_nick (enum_class, str);
- g_free (str);
-
- if (enum_value) {
- empathy_contact_list_store_set_sort_criterium (window->list_store,
- enum_value->value);
- }
- }
- }
-
static void
main_window_connection_items_setup (EmpathyMainWindow *window,
GtkBuilder *gui)
GtkAction *show_map_widget;
GtkToolItem *item;
gboolean show_offline;
- gboolean show_avatars;
- gboolean compact_contact_list;
gint x, y, w, h;
gchar *filename;
GSList *l;
"errors_vbox", &window->errors_vbox,
"ui_manager", &window->ui_manager,
"view_show_offline", &show_offline_widget,
+ "view_sort_by_name", &window->sort_by_name,
+ "view_sort_by_status", &window->sort_by_status,
+ "view_normal_size_with_avatars", &window->normal_with_avatars,
+ "view_normal_size", &window->normal_size,
+ "view_compact_size", &window->compact_size,
"view_history", &window->view_history,
"view_show_map", &show_map_widget,
"room_join_favorites", &window->room_join_favorites,
"chat_add_contact", "activate", main_window_chat_add_contact_cb,
"view_show_ft_manager", "activate", main_window_view_show_ft_manager,
"view_show_offline", "toggled", main_window_view_show_offline_cb,
+ "view_sort_by_name", "changed", main_window_view_sort_contacts_cb,
+ "view_normal_size_with_avatars", "changed", main_window_view_contacts_list_size_cb,
"view_show_map", "activate", main_window_view_show_map_cb,
"edit", "activate", main_window_edit_cb,
"edit_accounts", "activate", main_window_edit_accounts_cb,
gtk_action_set_visible (show_map_widget, FALSE);
#endif
- window->mc = empathy_mission_control_dup_singleton ();
window->account_manager = empathy_account_manager_dup_singleton ();
g_signal_connect (window->account_manager,
gtk_toggle_action_set_active (show_offline_widget, show_offline);
- /* Show avatars ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- &show_avatars);
+ /* Sort by name / by status ? */
empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- (EmpathyConfNotifyFunc) main_window_notify_show_avatars_cb,
- window);
- empathy_contact_list_store_set_show_avatars (window->list_store, show_avatars);
+ EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
+ (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb,
+ window);
- /* Is compact ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- &compact_contact_list);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- (EmpathyConfNotifyFunc) main_window_notify_compact_contact_list_cb,
- window);
- empathy_contact_list_store_set_is_compact (window->list_store, compact_contact_list);
+ main_window_notify_sort_contact_cb (conf,
+ EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
+ window);
- /* Sort criterium */
+ /* Contacts list size */
empathy_conf_notify_add (conf,
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- (EmpathyConfNotifyFunc) main_window_notify_sort_criterium_cb,
- window);
- main_window_notify_sort_criterium_cb (conf,
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- window);
+ EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
+ (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
+ window);
+ empathy_conf_notify_add (conf,
+ EMPATHY_PREFS_UI_SHOW_AVATARS,
+ (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
+ window);
+
+ main_window_notify_contact_list_size_cb (conf,
+ EMPATHY_PREFS_UI_SHOW_AVATARS,
+ window);
main_window_update_status (window, window->account_manager);
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mission-control.h>
+#include <telepathy-glib/connection-manager.h>
+#include <telepathy-glib/interfaces.h>
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-account-settings.h>
#include <libempathy/empathy-account-manager.h>
+#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-debugger.h>
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-dispatch-operation.h>
}
static void
-service_ended_cb (MissionControl *mc,
- gpointer user_data)
+use_nm_notify_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
{
- DEBUG ("Mission Control stopped");
+ EmpathyIdle *idle = user_data;
+ gboolean use_nm;
+
+ if (empathy_conf_get_bool (conf, key, &use_nm)) {
+ empathy_idle_set_use_nm (idle, use_nm);
+ }
}
-static void
-operation_error_cb (MissionControl *mc,
- guint operation_id,
- guint error_code,
- gpointer user_data)
+/* Salut account creation */
+static gboolean
+should_create_salut_account (void)
{
- const gchar *message;
-
- switch (error_code) {
- case MC_DISCONNECTED_ERROR:
- message = "Disconnected";
- break;
- case MC_INVALID_HANDLE_ERROR:
- message = "Invalid handle";
- break;
- case MC_NO_MATCHING_CONNECTION_ERROR:
- message = "No matching connection";
- break;
- case MC_INVALID_ACCOUNT_ERROR:
- message = "Invalid account";
- break;
- case MC_PRESENCE_FAILURE_ERROR:
- message = "Presence failure";
- break;
- case MC_NO_ACCOUNTS_ERROR:
- message = "No accounts";
- break;
- case MC_NETWORK_ERROR:
- message = "Network error";
- break;
- case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR:
- message = "Contact does not support voice";
- break;
- case MC_LOWMEM_ERROR:
- message = "Lowmem";
- break;
- case MC_CHANNEL_REQUEST_GENERIC_ERROR:
- message = "Channel request generic error";
- break;
- case MC_CHANNEL_BANNED_ERROR:
- message = "Channel banned";
- break;
- case MC_CHANNEL_FULL_ERROR:
- message = "Channel full";
- break;
- case MC_CHANNEL_INVITE_ONLY_ERROR:
- message = "Channel invite only";
- break;
- default:
- message = "Unknown error code";
+ EmpathyAccountManager *manager;
+ gboolean salut_created = FALSE;
+ GList *accounts, *l;
+
+ /* Check if we already created a salut account */
+ empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ &salut_created);
+
+ if (salut_created)
+ {
+ DEBUG ("Gconf says we already created a salut account once");
+ return FALSE;
+ }
+
+ manager = empathy_account_manager_dup_singleton ();
+ accounts = empathy_account_manager_dup_accounts (manager);
+
+ for (l = accounts; l != NULL; l = g_list_next (l)) {
+ EmpathyAccount *account = EMPATHY_ACCOUNT (l->data);
+
+ if (!tp_strdiff (empathy_account_get_protocol (account), "local-xmpp"))
+ salut_created = TRUE;
+
+ g_object_unref (account);
}
- DEBUG ("Error during operation %d: %s", operation_id, message);
+ g_object_unref (manager);
+
+ if (salut_created)
+ {
+ DEBUG ("Existing salut account already exists, flagging so in gconf");
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ TRUE);
+ }
+
+ return !salut_created;
}
static void
-use_nm_notify_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
+salut_account_created (GObject *source,
+ GAsyncResult *result, gpointer user_data)
{
- EmpathyIdle *idle = user_data;
- gboolean use_nm;
+ EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source);
+ EmpathyAccount *account;
+ GError *error = NULL;
+
+ if (!empathy_account_settings_apply_finish (settings, result, &error))
+ {
+ DEBUG ("Failed to create salut account: %s", error->message);
+ g_error_free (error);
+ return;
+ }
- if (empathy_conf_get_bool (conf, key, &use_nm)) {
- empathy_idle_set_use_nm (idle, use_nm);
- }
+ account = empathy_account_settings_get_account (settings);
+
+ empathy_account_set_enabled (account, TRUE);
+ empathy_conf_set_bool (empathy_conf_get (),
+ EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
+ TRUE);
}
static void
-create_salut_account (void)
+create_salut_account_if_needed (EmpathyConnectionManagers *managers)
{
- McProfile *profile;
- McProtocol *protocol;
- gboolean salut_created = FALSE;
- EmpathyAccount *account;
- EmpathyAccountManager *account_manager;
- GList *accounts;
+ EmpathyAccountSettings *settings;
+ TpConnectionManager *manager;
+ const TpConnectionManagerProtocol *protocol;
EBook *book;
EContact *contact;
gchar *nickname = NULL;
gchar *jid = NULL;
GError *error = NULL;
- /* Check if we already created a salut account */
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
- &salut_created);
- if (salut_created) {
+
+ if (!should_create_salut_account ())
return;
- }
- DEBUG ("Try to add a salut account...");
+ manager = empathy_connection_managers_get_cm (managers, "salut");
+ if (manager == NULL)
+ {
+ DEBUG ("Salut not installed, not making a salut account");
+ return;
+ }
- /* Check if the salut CM is installed */
- profile = mc_profile_lookup ("salut");
- if (!profile) {
- DEBUG ("No salut profile");
- return;
- }
- protocol = mc_profile_get_protocol (profile);
- if (!protocol) {
- DEBUG ("Salut not installed");
- g_object_unref (profile);
- return;
- }
- g_object_unref (protocol);
+ protocol = tp_connection_manager_get_protocol (manager, "local-xmpp");
+ if (protocol == NULL)
+ {
+ DEBUG ("Salut doesn't support local-xmpp!!");
+ return;
+ }
+
+ DEBUG ("Trying to add a salut account...");
/* Get self EContact from EDS */
if (!e_book_get_self (&contact, &book, &error)) {
DEBUG ("Failed to get self econtact: %s",
error ? error->message : "No error given");
g_clear_error (&error);
- g_object_unref (profile);
return;
}
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_SALUT_ACCOUNT_CREATED,
- TRUE);
-
- /* Check if there is already a salut account */
- accounts = mc_accounts_list_by_profile (profile);
- if (accounts) {
- DEBUG ("There is already a salut account");
- mc_accounts_list_free (accounts);
- g_object_unref (profile);
- return;
- }
-
- account_manager = empathy_account_manager_dup_singleton ();
- account = empathy_account_manager_create (account_manager, profile);
- empathy_account_set_display_name (account, _("People nearby"));
- g_object_unref (account_manager);
+ settings = empathy_account_settings_new ("salut", "local-xmpp",
+ _("People nearby"));
nickname = e_contact_get (contact, E_CONTACT_NICKNAME);
first_name = e_contact_get (contact, E_CONTACT_GIVEN_NAME);
"last-name=%s\nemail=%s\njid=%s\n",
nickname, first_name, last_name, email, jid);
- empathy_account_set_param_string (account, "nickname", nickname ? nickname : "");
- empathy_account_set_param_string (account, "first-name", first_name ? first_name : "");
- empathy_account_set_param_string (account, "last-name", last_name ? last_name : "");
- empathy_account_set_param_string (account, "email", email ? email : "");
- empathy_account_set_param_string (account, "jid", jid ? jid : "");
+ empathy_account_settings_set_string (settings, "nickname", nickname ? nickname : "");
+ empathy_account_settings_set_string (settings, "first-name", first_name ? first_name : "");
+ empathy_account_settings_set_string (settings, "last-name", last_name ? last_name : "");
+ empathy_account_settings_set_string (settings, "email", email ? email : "");
+ empathy_account_settings_set_string (settings, "jid", jid ? jid : "");
+
+ empathy_account_settings_apply_async (settings,
+ salut_account_created, NULL);
g_free (nickname);
g_free (first_name);
g_free (last_name);
g_free (email);
g_free (jid);
- g_object_unref (account);
- g_object_unref (profile);
+ g_object_unref (settings);
g_object_unref (contact);
g_object_unref (book);
}
+static void
+connection_managers_ready_cb (EmpathyConnectionManagers *managers,
+ GParamSpec *spec, gpointer user_data)
+{
+ if (empathy_connection_managers_is_ready (managers))
+ {
+ create_salut_account_if_needed (managers);
+ g_object_unref (managers);
+ managers = NULL;
+ }
+}
+
+static void
+create_salut_account (void)
+{
+ EmpathyConnectionManagers *managers;
+
+ if (!should_create_salut_account ())
+ return;
+
+ managers = empathy_connection_managers_dup_singleton ();
+
+ if (empathy_connection_managers_is_ready (managers))
+ {
+ create_salut_account_if_needed (managers);
+ g_object_unref (managers);
+ }
+ else
+ {
+ g_signal_connect (managers, "notify::ready",
+ G_CALLBACK (connection_managers_ready_cb), NULL);
+ }
+}
+
+ static void
+ migrate_config_to_xdg_dir (void)
+ {
+ gchar *xdg_dir, *old_dir, *xdg_filename, *old_filename;
+ int i;
+ GFile *xdg_file, *old_file;
+ static const gchar* filenames[] = {
+ "geometry.ini",
+ "irc-networks.xml",
+ "chatrooms.xml",
+ "contact-groups.xml",
+ "status-presets.xml",
+ "accels.txt",
+ NULL
+ };
+
+ xdg_dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
+ if (g_file_test (xdg_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+ /* xdg config dir already exists */
+ g_free (xdg_dir);
+ return;
+ }
+
+ old_dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
+ if (!g_file_test (old_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+ /* old config dir didn't exist */
+ g_free (xdg_dir);
+ g_free (old_dir);
+ return;
+ }
+
+ if (g_mkdir_with_parents (xdg_dir, (S_IRUSR | S_IWUSR | S_IXUSR)) == -1) {
+ DEBUG ("Failed to create configuration directory; aborting migration");
+ g_free (xdg_dir);
+ g_free (old_dir);
+ return;
+ }
+
+ for (i = 0; filenames[i]; i++) {
+ old_filename = g_build_filename (old_dir, filenames[i], NULL);
+ if (!g_file_test (old_filename, G_FILE_TEST_EXISTS)) {
+ g_free (old_filename);
+ continue;
+ }
+ xdg_filename = g_build_filename (xdg_dir, filenames[i], NULL);
+ old_file = g_file_new_for_path (old_filename);
+ xdg_file = g_file_new_for_path (xdg_filename);
+ if (!g_file_move (old_file, xdg_file, G_FILE_COPY_NONE,
+ NULL, NULL, NULL, NULL)) {
+ DEBUG ("Failed to migrate %s", filenames[i]);
+ }
+ g_free (old_filename);
+ g_free (xdg_filename);
+ g_object_unref (old_file);
+ g_object_unref (xdg_file);
+ }
+
+ g_free (xdg_dir);
+ g_free (old_dir);
+ }
+
/* The code that handles single-instance and startup notification is
* copied from gedit.
*
gtk_widget_realize (GTK_WIDGET (window));
}
- startup_timestamp = gdk_x11_get_server_time (window->window);
+ startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (window));
}
gtk_window_present_with_time (GTK_WINDOW (window), startup_timestamp);
}
#endif /* ENABLE_DEBUG */
+static void
+account_manager_ready_cb (EmpathyAccountManager *manager,
+ GParamSpec *spec,
+ gpointer user_data)
+{
+ if (!empathy_account_manager_is_ready (manager))
+ return;
+
+ if (empathy_account_manager_get_count (manager) == 0)
+ {
+ empathy_accounts_dialog_show (GTK_WINDOW (empathy_main_window_get ()),
+ NULL);
+ }
+ create_salut_account ();
+}
+
int
main (int argc, char *argv[])
{
#endif
EmpathyStatusIcon *icon;
EmpathyDispatcher *dispatcher;
+ EmpathyAccountManager *account_manager;
EmpathyLogManager *log_manager;
EmpathyChatroomManager *chatroom_manager;
EmpathyCallFactory *call_factory;
EmpathyFTFactory *ft_factory;
GtkWidget *window;
- MissionControl *mc;
EmpathyIdle *idle;
gboolean autoconnect = TRUE;
gboolean no_connect = FALSE;
g_clear_error (&error);
}
- /* Setting up MC */
- mc = empathy_mission_control_dup_singleton ();
- g_signal_connect (mc, "ServiceEnded",
- G_CALLBACK (service_ended_cb),
- NULL);
- g_signal_connect (mc, "Error",
- G_CALLBACK (operation_error_cb),
- NULL);
-
if (accounts_dialog) {
GtkWidget *dialog;
if (autoconnect && ! no_connect &&
tp_connection_presence_type_cmp_availability (empathy_idle_get_state
(idle), TP_CONNECTION_PRESENCE_TYPE_OFFLINE) <= 0) {
- empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
+ empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_AVAILABLE);
}
+ /* account management */
+ account_manager = empathy_account_manager_dup_singleton ();
+ g_signal_connect (account_manager, "notify::ready",
+ G_CALLBACK (account_manager_ready_cb), NULL);
- create_salut_account ();
+ migrate_config_to_xdg_dir ();
+
/* Setting up UI */
window = empathy_main_window_show ();
icon = empathy_status_icon_new (GTK_WINDOW (window), hide_contact_list);
empathy_idle_set_state (idle, TP_CONNECTION_PRESENCE_TYPE_OFFLINE);
- g_object_unref (mc);
g_object_unref (idle);
g_object_unref (icon);
+ g_object_unref (account_manager);
g_object_unref (log_manager);
g_object_unref (dispatcher);
g_object_unref (chatroom_manager);
return EXIT_SUCCESS;
}
-