#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"
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)
+ if (!empathy_conf_get_bool (empathy_conf_get (),
+ EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
+ &enable_webkit_developer_tools)) {
return;
+ }
g_object_set (G_OBJECT (webkit_web_view_get_settings (web_view)),
"enable-developer-extras",
} 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;
/* 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);
static gboolean
theme_adium_inspector_show_window_cb (WebKitWebInspector *inspector,
- gpointer user_data)
+ EmpathyThemeAdium *theme)
{
- EmpathyThemeAdium *theme = user_data;
EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
- gtk_widget_show_all (priv->inspector_window);
+ if (priv->inspector_window) {
+ gtk_widget_show_all (priv->inspector_window);
+ }
return TRUE;
}
static gboolean
theme_adium_inspector_close_window_cb (WebKitWebInspector *inspector,
- gpointer user_data)
+ EmpathyThemeAdium *theme)
{
- 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);
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
if (priv->inspector_window) {
gtk_widget_hide (priv->inspector_window);
static WebKitWebView *
theme_adium_inspect_web_view_cb (WebKitWebInspector *inspector,
- WebKitWebView *web_view,
- gpointer data)
+ WebKitWebView *web_view,
+ EmpathyThemeAdium *theme)
{
- EmpathyThemeAdiumPriv *priv = GET_PRIV (EMPATHY_THEME_ADIUM (web_view));
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
GtkWidget *scrolled_window;
GtkWidget *inspector_web_view;
if (!priv->inspector_window) {
+ /* Create main 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);
+ /* Pack a scrolled window */
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);
-
+ 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);
+ gtk_widget_show (scrolled_window);
+
+ /* Pack a webview in the scrolled window. That webview will be
+ * used to render the inspector tool. */
inspector_web_view = webkit_web_view_new ();
- gtk_container_add (GTK_CONTAINER (scrolled_window), inspector_web_view);
+ gtk_container_add (GTK_CONTAINER (scrolled_window),
+ inspector_web_view);
+ gtk_widget_show (scrolled_window);
return WEBKIT_WEB_VIEW (inspector_web_view);
}
gchar *basedir_uri;
const gchar *font_family = NULL;
gint font_size = 0;
+ WebKitWebView *webkit_view = WEBKIT_WEB_VIEW (object);
WebKitWebSettings *webkit_settings;
+ WebKitWebInspector *webkit_inspector;
/* Set default settings */
font_family = tp_asv_get_string (priv->data->info, "DefaultFontFamily");
font_size = tp_asv_get_int32 (priv->data->info, "DefaultFontSize", NULL);
- webkit_settings = webkit_web_settings_new ();
+ webkit_settings = webkit_web_view_get_settings (webkit_view);
if (font_family) {
- g_object_set (G_OBJECT (webkit_settings), "default-font-family", font_family, NULL);
+ g_object_set (webkit_settings,
+ "default-font-family", font_family,
+ NULL);
}
if (font_size) {
- g_object_set (G_OBJECT (webkit_settings), "default-font-size", font_size, NULL);
+ g_object_set (webkit_settings,
+ "default-font-size", font_size,
+ NULL);
}
- 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);
+ /* Setup webkit inspector */
+ webkit_inspector = webkit_web_view_get_inspector (webkit_view);
+ g_signal_connect (webkit_inspector, "inspect-web-view",
+ G_CALLBACK (theme_adium_inspect_web_view_cb),
+ object);
+ g_signal_connect (webkit_inspector, "show-window",
+ G_CALLBACK (theme_adium_inspector_show_window_cb),
+ object);
+ g_signal_connect (webkit_inspector, "close-window",
+ G_CALLBACK (theme_adium_inspector_close_window_cb),
+ object);
/* Load template */
basedir_uri = g_strconcat ("file://", priv->data->basedir, NULL);
webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (object),
priv->data->template_html,
basedir_uri);
-
- g_object_unref (webkit_settings);
g_free (basedir_uri);
}
priv->notify_enable_webkit_developer_tools_id =
empathy_conf_notify_add (empathy_conf_get (),
- "/apps/empathy/conversation/enable_webkit_developer_tools",
+ EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
theme_adium_notify_enable_webkit_developer_tools_cb,
theme);
#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>
manager = empathy_account_manager_dup_singleton ();
connection = empathy_tp_chat_get_connection (tp_chat);
- account = empathy_account_manager_get_account (manager,
+ account = empathy_account_manager_get_account_for_connection (manager,
connection);
chat = empathy_chat_window_find_chat (account, id);
g_object_unref (manager);
}
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)
{
}
#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;
empathy_init ();
if (!gtk_init_with_args (&argc, &argv,
- N_("- Empathy Instant Messenger"),
+ N_("- Empathy IM Client"),
options, GETTEXT_PACKAGE, &error)) {
g_warning ("Error in empathy init: %s", error->message);
return EXIT_FAILURE;
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);
migrate_config_to_xdg_dir ();
- create_salut_account ();
/* Setting up UI */
window = empathy_main_window_show ();
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;
}
-