static void
contact_list_view_drag_data_get (GtkWidget        *widget,
				 GdkDragContext   *context,
				 GtkSelectionData *selection,
				 guint             info,
				 guint             time)
{
	EmpathyContactListViewPriv *priv;
	GtkTreePath                *src_path;
	GtkTreeIter                 iter;
	GtkTreeModel               *model;
	EmpathyContact             *contact;
	EmpathyAccount             *account;
	const gchar                *contact_id;
	const gchar                *account_id;
	gchar                      *str;

	priv = GET_PRIV (widget);

	model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
	if (!priv->drag_row) {
		return;
	}

	src_path = gtk_tree_row_reference_get_path (priv->drag_row);
	if (!src_path) {
		return;
	}

	if (!gtk_tree_model_get_iter (model, &iter, src_path)) {
		gtk_tree_path_free (src_path);
		return;
	}

	gtk_tree_path_free (src_path);

	contact = empathy_contact_list_view_dup_selected (EMPATHY_CONTACT_LIST_VIEW (widget));
	if (!contact) {
		return;
	}

	account = empathy_contact_get_account (contact);
	account_id = empathy_account_get_unique_name (account);
	contact_id = empathy_contact_get_id (contact);
	g_object_unref (contact);
	str = g_strconcat (account_id, "/", contact_id, NULL);

	switch (info) {
	case DND_DRAG_TYPE_CONTACT_ID:
		gtk_selection_data_set (selection, drag_atoms_source[info], 8,
					(guchar *) str, strlen (str) + 1);
		break;
	}

	g_free (str);
}
Example #2
0
static void
empathy_account_connection_ready_cb (TpConnection *connection,
    const GError *error,
    gpointer user_data)
{
  EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);

  if (error != NULL)
    {
      DEBUG ("(%s) Connection failed to become ready: %s",
        empathy_account_get_unique_name (account), error->message);
      empathy_account_free_connection (account);
    }
  else
    {
      DEBUG ("(%s) Connection ready",
        empathy_account_get_unique_name (account));
      g_object_notify (G_OBJECT (account), "connection");
    }
}
Example #3
0
static gboolean
chatroom_manager_file_save (EmpathyChatroomManager *manager)
{
	EmpathyChatroomManagerPriv *priv;
	xmlDocPtr                  doc;
	xmlNodePtr                 root;
	GList                     *l;

	priv = GET_PRIV (manager);

	doc = xmlNewDoc ((const xmlChar *) "1.0");
	root = xmlNewNode (NULL, (const xmlChar *) "chatrooms");
	xmlDocSetRootElement (doc, root);

	for (l = priv->chatrooms; l; l = l->next) {
		EmpathyChatroom *chatroom;
		xmlNodePtr       node;
		const gchar     *account_id;

		chatroom = l->data;

		if (!empathy_chatroom_is_favorite (chatroom)) {
			continue;
		}

		account_id = empathy_account_get_unique_name (
		  empathy_chatroom_get_account (chatroom));

		node = xmlNewChild (root, NULL, (const xmlChar *) "chatroom", NULL);
		xmlNewTextChild (node, NULL, (const xmlChar *) "name",
			(const xmlChar *) empathy_chatroom_get_name (chatroom));
		xmlNewTextChild (node, NULL, (const xmlChar *) "room",
			(const xmlChar *) empathy_chatroom_get_name (chatroom));
		xmlNewTextChild (node, NULL, (const xmlChar *) "account",
			(const xmlChar *) account_id);
		xmlNewTextChild (node, NULL, (const xmlChar *) "auto_connect",
			empathy_chatroom_get_auto_connect (chatroom) ?
			(const xmlChar *) "yes" : (const xmlChar *) "no");
	}

	/* Make sure the XML is indented properly */
	xmlIndentTreeOutput = 1;

	DEBUG ("Saving file:'%s'", priv->file);
	xmlSaveFormatFileEnc (priv->file, doc, "utf-8", 1);
	xmlFreeDoc (doc);

	xmlCleanupParser ();
	xmlMemoryDump ();

	return TRUE;
}
Example #4
0
static void
empathy_account_get_property (GObject *object,
    guint prop_id,
    GValue *value,
    GParamSpec *pspec)
{
  EmpathyAccount *account = EMPATHY_ACCOUNT (object);
  EmpathyAccountPriv *priv = GET_PRIV (account);

  switch (prop_id)
    {
      case PROP_ENABLED:
        g_value_set_boolean (value, priv->enabled);
        break;
      case PROP_READY:
        g_value_set_boolean (value, priv->ready);
        break;
      case PROP_PRESENCE:
        g_value_set_uint (value, priv->presence);
        break;
      case PROP_STATUS:
        g_value_set_string (value, priv->status);
        break;
      case PROP_STATUS_MESSAGE:
        g_value_set_string (value, priv->message);
        break;
      case PROP_CONNECTION_STATUS:
        g_value_set_uint (value, priv->connection_status);
        break;
      case PROP_CONNECTION_STATUS_REASON:
        g_value_set_uint (value, priv->reason);
        break;
      case PROP_CONNECTION:
        g_value_set_object (value,
            empathy_account_get_connection (account));
        break;
      case PROP_UNIQUE_NAME:
        g_value_set_string (value,
            empathy_account_get_unique_name (account));
        break;
      case PROP_DISPLAY_NAME:
        g_value_set_string (value,
            empathy_account_get_display_name (account));
        break;
      case PROP_DBUS_DAEMON:
        g_value_set_object (value, priv->dbus);
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
        break;
    }
}
static gboolean
change_account_name_in_file (EmpathyAccount *account,
                             const gchar *file)
{
  gchar *cmd;

  cmd = g_strdup_printf ("sed -i 's/CHANGE_ME/%s/' %s",
      empathy_account_get_unique_name (account), file);

  if (system (cmd) == -1)
    {
      g_print ("'%s' call failed\n", cmd);
      g_free (cmd);
      return FALSE;
    }

  g_free (cmd);
  return TRUE;
}
Example #6
0
static void
empathy_account_got_all_cb (TpProxy *proxy,
    GHashTable *properties,
    const GError *error,
    gpointer user_data,
    GObject *weak_object)
{
  EmpathyAccount *account = EMPATHY_ACCOUNT (weak_object);

  DEBUG ("Got whole set of properties for %s",
    empathy_account_get_unique_name (account));

  if (error != NULL)
    {
      DEBUG ("Failed to get the initial set of account properties: %s",
        error->message);
      return;
    }

  empathy_account_update (account, properties);
}
Example #7
0
static void
_empathy_account_connection_invalidated_cb (TpProxy *self,
  guint    domain,
  gint     code,
  gchar   *message,
  gpointer user_data)
{
  EmpathyAccount *account = EMPATHY_ACCOUNT (user_data);
  EmpathyAccountPriv *priv = GET_PRIV (account);

  if (priv->connection == NULL)
    return;

  DEBUG ("(%s) Connection invalidated",
    empathy_account_get_unique_name (account));

  g_assert (priv->connection == TP_CONNECTION (self));

  empathy_account_free_connection (account);

  g_object_notify (G_OBJECT (account), "connection");
}
Example #8
0
static void
megaphone_applet_preferences_response_cb (GtkWidget       *dialog,
					  gint             response,
					  MegaphoneApplet *applet) 
{
	if (response == GTK_RESPONSE_ACCEPT) {
		EmpathyContactListView *contact_list;
		EmpathyContact         *contact;

		/* Retrieve the selected contact, if any and set it up in gconf.
		 * GConf will notify us from the change and we will adjust ourselves */
		contact_list = g_object_get_data (G_OBJECT (dialog), "contact-list");
		contact = empathy_contact_list_view_dup_selected (contact_list);
		if (contact) {
			EmpathyAccount   *account;
			const gchar *account_id;
			const gchar *contact_id;
			gchar       *str;

			account = empathy_contact_get_account (contact);
			account_id = empathy_account_get_unique_name (account);
			contact_id = empathy_contact_get_id (contact);

			str = g_strconcat (account_id, "/", contact_id, NULL);
			panel_applet_gconf_set_string (PANEL_APPLET (applet),
						       "avatar_token", "",
						       NULL);
			panel_applet_gconf_set_string (PANEL_APPLET (applet),
						       "contact_id", str,
						       NULL);
			g_free (str);
			g_object_unref (contact);
		}
	}
	gtk_widget_destroy (dialog);
}
Example #9
0
/* Not used for now as there is no API to remove completely gconf keys.
 * So we reuse existing accounts instead of creating new ones */
void
destroy_test_account (EmpathyAccount *account)
{
  GConfClient *client;
  gchar *path;
  GError *error = NULL;
  GSList *entries = NULL, *l;
  EmpathyAccountManager *manager;

  client = gconf_client_get_default ();
  path = g_strdup_printf ("/apps/telepathy/mc/accounts/%s",
      empathy_account_get_unique_name (account));

  entries = gconf_client_all_entries (client, path, &error);
  if (error != NULL)
    {
      g_print ("failed to list entries in %s: %s\n", path, error->message);
      g_error_free (error);
      error = NULL;
    }

  for (l = entries; l != NULL; l = g_slist_next (l))
    {
      GConfEntry *entry = l->data;

      if (g_str_has_suffix (entry->key, "data_dir"))
        {
          gchar *dir;

          dir = gconf_client_get_string (client, entry->key, &error);
          if (error != NULL)
            {
              g_print ("get data_dir string failed: %s\n", entry->key);
              g_error_free (error);
              error = NULL;
            }
          else
            {
              if (g_rmdir (dir) != 0)
                g_print ("can't remove %s\n", dir);
            }

          g_free (dir);
        }

      /* FIXME: this doesn't remove the key */
      gconf_client_unset (client, entry->key, &error);
      if (error != NULL)
        {
          g_print ("unset of %s failed: %s\n", path, error->message);
          g_error_free (error);
          error = NULL;
        }

      gconf_entry_unref (entry);
    }

  g_slist_free (entries);

  g_object_unref (client);
  g_free (path);

  manager = empathy_account_manager_dup_singleton ();
  empathy_account_manager_remove (manager, account);
  g_object_unref (account);
  g_object_unref (manager);
}