Beispiel #1
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;
    }
}
/**
 * empathy_account_chooser_get_connection:
 * @chooser: an #EmpathyAccountChooser
 *
 * Returns a borrowed reference to the #TpConnection associated with the
 * account currently selected. The caller must reference the returned object with
 * g_object_ref() if it will be kept
 *
 * Return value: a borrowed reference to the #TpConnection associated with the
 * account curently selected.
 */
TpConnection *
empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser)
{
	EmpathyAccountChooserPriv *priv;
	EmpathyAccount            *account;
	TpConnection              *connection;

	g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL);

	priv = GET_PRIV (chooser);

	account = empathy_account_chooser_dup_account (chooser);
	connection = empathy_account_get_connection (account);
	g_object_unref (account);

	return connection;
}
static gboolean
can_add_contact_to_account (EmpathyAccount *account,
			    gpointer   user_data)
{
	EmpathyContactManager *contact_manager;
	TpConnection          *connection;
	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);
	g_object_unref (contact_manager);

	return result;
}
static void
contact_list_view_drag_data_received (GtkWidget         *view,
				      GdkDragContext    *context,
				      gint               x,
				      gint               y,
				      GtkSelectionData  *selection,
				      guint              info,
				      guint              time)
{
	EmpathyContactListViewPriv *priv;
	EmpathyAccountManager      *account_manager;
	EmpathyTpContactFactory    *factory = NULL;
	EmpathyAccount             *account;
	GtkTreeModel               *model;
	GtkTreeViewDropPosition     position;
	GtkTreePath                *path;
	const gchar                *id;
	gchar                     **strv = NULL;
	const gchar                *account_id;
	const gchar                *contact_id;
	gchar                      *new_group = NULL;
	gchar                      *old_group = NULL;
	DndGetContactData          *data;
	gboolean                    is_row;
	gboolean                    success = TRUE;

	priv = GET_PRIV (view);
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));

	/* Get destination group information. */
	is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view),
						    x,
						    y,
						    &path,
						    &position);

	if (is_row) {
		new_group = empathy_contact_list_store_get_parent_group (model,
			path, NULL);
		gtk_tree_path_free (path);
	}

	/* Get source group information. */
	if (priv->drag_row) {
		path = gtk_tree_row_reference_get_path (priv->drag_row);
		if (path) {
			old_group = empathy_contact_list_store_get_parent_group (
				model, path, NULL);
			gtk_tree_path_free (path);
		}
	}

	if (!tp_strdiff (old_group, new_group)) {
		g_free (new_group);
		g_free (old_group);
		goto OUT;
	}

	id = (const gchar*) gtk_selection_data_get_data (selection);
	DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'",
		context->action == GDK_ACTION_MOVE ? "move" : "",
		context->action == GDK_ACTION_COPY ? "copy" : "",
		id);

	strv = g_strsplit (id, "/", 2);
	account_id = strv[0];
	contact_id = strv[1];
  account_manager = empathy_account_manager_dup_singleton ();
	account = empathy_account_manager_lookup (account_manager, account_id);
	if (account) {
		TpConnection *connection;

		connection = empathy_account_get_connection (account);
		if (connection) {
			factory = empathy_tp_contact_factory_dup_singleton (connection);
		}
	}
	g_object_unref (account_manager);

	if (!factory) {
		DEBUG ("Failed to get factory for account '%s'", account_id);
		success = FALSE;
		g_free (new_group);
		g_free (old_group);
		goto OUT;
	}

	data = g_slice_new0 (DndGetContactData);
	data->new_group = new_group;
	data->old_group = old_group;
	data->action = context->action;

	/* FIXME: We should probably wait for the cb before calling
	 * gtk_drag_finish */
	empathy_tp_contact_factory_get_from_id (factory, contact_id,
		contact_list_view_drag_got_contact,
		data, (GDestroyNotify) contact_list_view_dnd_get_contact_free,
		G_OBJECT (view));

	g_object_unref (factory);

OUT:
	g_strfreev (strv);
	gtk_drag_finish (context, success, FALSE, GDK_CURRENT_TIME);
}