Esempio n. 1
0
static EmpathyRosterGroup *
ensure_roster_group (EmpathyRosterView *self,
    const gchar *group)
{
  GtkWidget *roster_group;

  roster_group = (GtkWidget *) lookup_roster_group (self, group);
  if (roster_group != NULL)
    return EMPATHY_ROSTER_GROUP (roster_group);

  if (!tp_strdiff (group, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
    roster_group = empathy_roster_group_new (group, "emblem-favorite-symbolic");
  else if (!tp_strdiff (group, EMPATHY_ROSTER_MODEL_GROUP_PEOPLE_NEARBY))
    roster_group = empathy_roster_group_new (group, "im-local-xmpp");
  else
    roster_group = empathy_roster_group_new (group, NULL);

  gtk_expander_set_expanded (EMPATHY_ROSTER_GROUP (roster_group)->expander,
      empathy_contact_group_get_expanded (group));

  g_signal_connect (EMPATHY_ROSTER_GROUP (roster_group)->expander,
      "notify::expanded", G_CALLBACK (group_expanded_cb), roster_group);

  gtk_widget_show (roster_group);
  gtk_container_add (GTK_CONTAINER (self), roster_group);

  g_hash_table_insert (self->priv->roster_groups, g_strdup (group),
      roster_group);

  return EMPATHY_ROSTER_GROUP (roster_group);
}
static void
empathy_irc_network_set_property (GObject *object,
                                  guint property_id,
                                  const GValue *value,
                                  GParamSpec *pspec)
{
  EmpathyIrcNetwork *self = EMPATHY_IRC_NETWORK (object);
  EmpathyIrcNetworkPriv *priv = GET_PRIV (self);

  switch (property_id)
    {
      case PROP_NAME:
        if (tp_strdiff (priv->name, g_value_get_string (value)))
          {
            g_free (priv->name);
            priv->name = g_value_dup_string (value);
            g_signal_emit (object, signals[MODIFIED], 0);
          }
        break;
      case PROP_CHARSET:
        if (tp_strdiff (priv->charset, g_value_get_string (value)))
          {
            g_free (priv->charset);
            priv->charset = g_value_dup_string (value);
            g_signal_emit (object, signals[MODIFIED], 0);
          }
        break;
      default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}
Esempio n. 3
0
void
empathy_idle_set_presence (EmpathyIdle *idle,
			   TpConnectionPresenceType   state,
			   const gchar *status)
{
	EmpathyIdlePriv *priv;
	const gchar     *default_status;

	priv = GET_PRIV (idle);

	DEBUG ("Changing presence to %s (%d)", status, state);

	/* Do not set translated default messages */
	default_status = empathy_presence_get_default_message (state);
	if (!tp_strdiff (status, default_status)) {
		status = NULL;
	}

	if (state != TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
			!empathy_connectivity_is_online (priv->connectivity)) {
		DEBUG ("Empathy is not online");

		priv->saved_state = state;
		if (tp_strdiff (priv->status, status)) {
			g_free (priv->saved_status);
			priv->saved_status = NULL;
			if (!EMP_STR_EMPTY (status)) {
				priv->saved_status = g_strdup (status);
			}
		}
		return;
	}

	empathy_idle_do_set_presence (idle, state, status);
}
Esempio n. 4
0
static void
tp_contact_notify_cb (TpContact *tp_contact,
                      GParamSpec *param,
                      GObject *contact)
{
  EmpathyContactPriv *priv = GET_PRIV (contact);

  /* Forward property notifications */
  if (!tp_strdiff (param->name, "alias"))
    g_object_notify (contact, "name");
  else if (!tp_strdiff (param->name, "presence-type")) {
    McPresence presence;

    presence = empathy_contact_get_presence (EMPATHY_CONTACT (contact));
    g_signal_emit (contact, signals[PRESENCE_CHANGED], 0, presence, priv->presence);
    priv->presence = presence;
    g_object_notify (contact, "presence");
  }
  else if (!tp_strdiff (param->name, "presence-message"))
    g_object_notify (contact, "presence-message");
  else if (!tp_strdiff (param->name, "identifier"))
    g_object_notify (contact, "id");
  else if (!tp_strdiff (param->name, "handle"))
    g_object_notify (contact, "handle");
}
static void
update_join_button_sensitivity (EmpathyNewChatroomDialog *dialog)
{
	const gchar           *room;
	const gchar	      *protocol;
	gboolean               sensitive = FALSE;


	room = gtk_entry_get_text (GTK_ENTRY (dialog->entry_room));
	protocol = tp_account_get_protocol (dialog->account);
	if (EMP_STR_EMPTY (room))
		goto out;

	if (!tp_strdiff (protocol, "irc") && (!tp_strdiff (room, "#") ||
	                                      !tp_strdiff (room, "&")))
	{
		goto out;
	}

	if (dialog->account == NULL)
		goto out;

	if (tp_account_get_connection_status (dialog->account, NULL) !=
		      TP_CONNECTION_STATUS_CONNECTED)
		goto out;

	sensitive = TRUE;

out:
	gtk_widget_set_sensitive (dialog->button_join, sensitive);
}
Esempio n. 6
0
static void
conference_element_added (FsElementAddedNotifier *notifier,
    GstBin *bin,
    GstElement *element,
    gpointer user_data)
{
  GstElementFactory *factory;
  const gchar *name;

  factory = gst_element_get_factory (element);
  name = gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory));

  if (!tp_strdiff (name, "x264enc"))
    {
      /* Ensure that the encoder creates the baseline profile */
      g_object_set (element,
          "byte-stream", TRUE,
          "bframes", 0,
          "b-adapt", FALSE,
          "cabac", FALSE,
          "dct8x8", FALSE,
          NULL);
    }
  else if (!tp_strdiff (name, "gstrtpbin"))
    {
      /* Lower the jitterbuffer latency to make it more suitable for video
       * conferencing */
      g_object_set (element, "latency", 100, NULL);
    }
}
static EmpathyContact *
contact_manager_lookup_contact (EmpathyContactManager *manager,
				const gchar           *account_name,
				const gchar           *contact_id)
{
	EmpathyContact *retval = NULL;
	GList *members, *l;

	/* XXX: any more efficient way to do this (other than having to build
	 * and maintain a hash)? */
	members = empathy_contact_list_get_members (
			EMPATHY_CONTACT_LIST (manager));
	for (l = members; l; l = l->next) {
		EmpathyContact *contact = l->data;
		TpAccount *account = empathy_contact_get_account (contact);
		const gchar *id_cur;
		const gchar *name_cur;

		id_cur = empathy_contact_get_id (contact);
		name_cur = tp_proxy_get_object_path (TP_PROXY (account));

		if (!tp_strdiff (contact_id, id_cur) &&
			!tp_strdiff (account_name, name_cur)) {
			retval = contact;
		}

		g_object_unref (contact);
	}

	g_list_free (members);

	return retval;
}
Esempio n. 8
0
gboolean
_capabilities_has_stream_tube (TpCapabilities *caps)
{
  GPtrArray *classes;
  guint i;

  if (caps == NULL)
    return FALSE;

  classes = tp_capabilities_get_channel_classes (caps);
  for (i = 0; i < classes->len; i++)
    {
      GValueArray *arr = g_ptr_array_index (classes, i);
      GHashTable *fixed;
      const gchar *chan_type;
      const gchar *service;
      TpHandleType handle_type;

      fixed = g_value_get_boxed (g_value_array_get_nth (arr, 0));
      chan_type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
      service = tp_asv_get_string (fixed,
          TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE);
      handle_type = tp_asv_get_uint32 (fixed,
          TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL);

      if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE) &&
          handle_type == TP_HANDLE_TYPE_CONTACT &&
          (!tp_capabilities_is_specific_to_contact (caps) ||
           !tp_strdiff (service, TUBE_SERVICE)))
        return TRUE;
    }

  return FALSE;
}
static void
got_list_channel (EmpathyTpContactList *list,
		  TpChannel *channel)
{
	EmpathyTpContactListPriv *priv = GET_PRIV (list);
	const gchar *id;

	/* We requested that channel by providing TargetID property, so it's
	 * guaranteed that tp_channel_get_identifier will return it. */
	id = tp_channel_get_identifier (channel);

	/* TpChannel emits initial set of members just before being ready */
	if (!tp_strdiff (id, "stored")) {
		if (priv->stored != NULL)
			return;
		priv->stored = g_object_ref (channel);
		g_signal_connect (priv->stored, "group-members-changed",
				  G_CALLBACK (tp_contact_list_store_group_members_changed_cb),
				  list);
	} else if (!tp_strdiff (id, "publish")) {
		if (priv->publish != NULL)
			return;
		priv->publish = g_object_ref (channel);
		g_signal_connect (priv->publish, "group-members-changed",
				  G_CALLBACK (tp_contact_list_publish_group_members_changed_cb),
				  list);
	} else if (!tp_strdiff (id, "subscribe")) {
		if (priv->subscribe != NULL)
			return;
		priv->subscribe = g_object_ref (channel);
		g_signal_connect (priv->subscribe, "group-members-changed",
				  G_CALLBACK (tp_contact_list_subscribe_group_members_changed_cb),
				  list);
	}
}
Esempio n. 10
0
void
conn_location_properties_getter (GObject *object,
                                 GQuark interface,
                                 GQuark name,
                                 GValue *value,
                                 gpointer getter_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (object);

  if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControlTypes"))
    {
      guint access_control_type =
        TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST;
      GArray *access_control = g_array_sized_new (FALSE, FALSE,
          sizeof (guint), 1);

      g_array_append_val (access_control, access_control_type);
      g_value_take_boxed (value, access_control);
    }
  else if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControl"))
    {
      GValueArray *access_control = g_value_array_new (2);
      GValue type = {0,};
      GValue variant = {0,};
      GValue *allocated_value;

      /* G_TYPE_UINT is the D-Bus type of TpRichPresenceAccessControlType */
      g_value_init (&type, G_TYPE_UINT);
      g_value_set_uint (&type,
          TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST);
      g_value_array_append (access_control, &type);
      g_value_unset (&type);

      g_value_init (&variant, G_TYPE_VALUE);
      /* For Publish_List, the variant isn't used, so we set a dummy value,
       * (guint) 0 */
      allocated_value = tp_g_value_slice_new (G_TYPE_UINT);
      g_value_set_uint (allocated_value, 0);
      g_value_set_boxed (&variant, allocated_value);
      g_value_array_append (access_control, &variant);
      g_value_unset (&variant);
      tp_g_value_slice_free (allocated_value);

      g_value_take_boxed (value, access_control);
    }
  else if (name == g_quark_from_static_string ("SupportedLocationFeatures"))
    {
      TpLocationFeatures flags = 0;

      if (conn->features & GABBLE_CONNECTION_FEATURES_PEP)
        flags |= TP_LOCATION_FEATURE_CAN_SET;

      g_value_set_uint (value, flags);
    }
  else
    {
      g_assert_not_reached ();
    }
}
Esempio n. 11
0
static gboolean
set_own_status (GObject *object,
    const TpPresenceStatus *status,
    GError **error)
{
  ExampleCallConnection *self =
    EXAMPLE_CALL_CONNECTION (object);
  TpBaseConnection *base = TP_BASE_CONNECTION (object);
  GHashTable *presences;
  const gchar *message = "";

  if (status->optional_arguments != NULL)
    {
      GValue *v = g_hash_table_lookup (status->optional_arguments, "message");

      if (v != NULL && G_VALUE_HOLDS_STRING (v))
        {
          message = g_value_get_string (v);

          if (message == NULL)
            message = "";
        }
    }

  if (status->index == EXAMPLE_CALL_PRESENCE_AWAY)
    {
      if (self->priv->away && !tp_strdiff (message,
            self->priv->presence_message))
        return TRUE;

      self->priv->away = TRUE;
    }
  else
    {
      if (!self->priv->away && !tp_strdiff (message,
            self->priv->presence_message))
        return TRUE;

      self->priv->away = FALSE;
    }

  g_free (self->priv->presence_message);
  self->priv->presence_message = g_strdup (message);

  presences = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, NULL);
  g_hash_table_insert (presences, GUINT_TO_POINTER (base->self_handle),
      (gpointer) status);
  tp_presence_mixin_emit_presence_update (object, presences);
  g_hash_table_destroy (presences);

  if (!self->priv->away)
    {
      g_signal_emit (self, signals[SIGNAL_AVAILABLE], 0, message);
    }

  return TRUE;
}
Esempio n. 12
0
static void
empathy_tube_dispatch_constructed (GObject *object)
{
  EmpathyTubeDispatch *self = EMPATHY_TUBE_DISPATCH (object);
  EmpathyTubeDispatchPriv *priv = GET_PRIV (self);
  TpChannel *channel;
  GHashTable *properties;
  const gchar *service;
  const gchar *channel_type;
  TpTubeType type;

  priv->dbus = tp_dbus_daemon_new (tp_get_bus());

  channel = empathy_dispatch_operation_get_channel (priv->operation);
  properties = tp_channel_borrow_immutable_properties (channel);

  channel_type = tp_asv_get_string (properties,
    TP_IFACE_CHANNEL ".ChannelType");
  if (channel_type == NULL)
    goto failed;

  if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE))
    {
      type = TP_TUBE_TYPE_STREAM;
      service = tp_asv_get_string (properties,
        EMP_IFACE_CHANNEL_TYPE_STREAM_TUBE  ".Service");
    }
  else if (!tp_strdiff (channel_type, EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE))
    {
      type = TP_TUBE_TYPE_DBUS;
      service = tp_asv_get_string (properties,
        EMP_IFACE_CHANNEL_TYPE_DBUS_TUBE  ".ServiceName");
    }
  else
    {
      goto failed;
    }


  if (service == NULL)
    goto failed;

  priv->bus_name = empathy_tube_handler_build_bus_name (type, service);
  priv->object_path = empathy_tube_handler_build_object_path (type, service);

  priv->service = g_strdup (service);

  DEBUG ("Look for tube handler %s\n", priv->bus_name);
  tp_cli_dbus_daemon_call_name_has_owner (priv->dbus, -1, priv->bus_name,
    empathy_tube_dispatch_name_has_owner_cb, NULL, NULL, G_OBJECT (self));

  return;

failed:
  empathy_tube_dispatch_set_ability (self,
    EMPATHY_TUBE_DISPATCHABILITY_IMPOSSIBLE);
}
Esempio n. 13
0
static void
preferences_theme_notify_cb (GSettings   *gsettings,
                             const gchar *key,
                             gpointer     user_data)
{
    EmpathyPreferences *preferences = user_data;
    EmpathyPreferencesPriv *priv = GET_PRIV (preferences);
    GtkComboBox        *combo;
    gchar              *conf_name;
    gchar              *conf_path;
    GtkTreeModel       *model;
    GtkTreeIter         iter;
    gboolean            found = FALSE;

    conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
    conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);

    combo = GTK_COMBO_BOX (priv->combobox_chat_theme);
    model = gtk_combo_box_get_model (combo);
    if (gtk_tree_model_get_iter_first (model, &iter)) {
        gboolean is_adium;
        gchar *name;
        gchar *path;

        do {
            gtk_tree_model_get (model, &iter,
                                COL_COMBO_IS_ADIUM, &is_adium,
                                COL_COMBO_NAME, &name,
                                COL_COMBO_PATH, &path,
                                -1);

            if (!tp_strdiff (name, conf_name)) {
                if (tp_strdiff (name, "adium") ||
                        !tp_strdiff (path, conf_path)) {
                    found = TRUE;
                    gtk_combo_box_set_active_iter (combo, &iter);
                    g_free (name);
                    g_free (path);
                    break;
                }
            }

            g_free (name);
            g_free (path);
        } while (gtk_tree_model_iter_next (model, &iter));
    }

    /* Fallback to the first one. */
    if (!found) {
        if (gtk_tree_model_get_iter_first (model, &iter)) {
            gtk_combo_box_set_active_iter (combo, &iter);
        }
    }

    g_free (conf_name);
    g_free (conf_path);
}
EmpathyAccountSettings *
empathy_protocol_chooser_create_account_settings (EmpathyProtocolChooser *self)
{
  EmpathyAccountSettings *settings;
  gchar *str;
  const gchar *display_name;
  TpConnectionManager *cm;
  TpConnectionManagerProtocol *proto;
  gchar *service;

  cm = empathy_protocol_chooser_dup_selected (self, &proto, &service);
  if (cm == NULL || proto == NULL)
    return NULL;

  if (service != NULL)
    display_name = empathy_service_name_to_display_name (service);
  else
    display_name = empathy_protocol_name_to_display_name (proto->name);

  /* Create account */
  /* To translator: %s is the name of the protocol, such as "Google Talk" or
   * "Yahoo!"
   */
  str = g_strdup_printf (_("New %s account"), display_name);
  settings = empathy_account_settings_new (cm->name, proto->name, service, str);

  g_free (str);

  if (!tp_strdiff (service, "google-talk"))
    {
      gchar *fallback_servers[] = {
          "talkx.l.google.com",
          "talkx.l.google.com:443,oldssl",
          "talkx.l.google.com:80",
          NULL};

      empathy_account_settings_set_icon_name_async (settings, "im-google-talk",
          NULL, NULL);

      empathy_account_settings_set_strv (settings, "fallback-servers",
          fallback_servers);
    }
  else if (!tp_strdiff (service, "facebook"))
    {
      empathy_account_settings_set_icon_name_async (settings, "im-facebook",
          NULL, NULL);

      empathy_account_settings_set_string (settings, "server",
          "chat.facebook.com");
    }

  g_object_unref (cm);
  g_free (service);
  return settings;
}
Esempio n. 15
0
static gboolean
account_assistant_chooser_enter_details_filter_func (
    TpConnectionManager *cm,
    TpConnectionManagerProtocol *protocol,
    gpointer user_data)
{
  if (!tp_strdiff (protocol->name, "local-xmpp") ||
      !tp_strdiff (protocol->name, "irc"))
    return FALSE;

  return TRUE;
}
Esempio n. 16
0
void
conn_location_properties_getter (GObject *object,
                                 GQuark interface,
                                 GQuark name,
                                 GValue *value,
                                 gpointer getter_data)
{
  GabbleConnection *conn = GABBLE_CONNECTION (object);

  if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControlTypes"))
    {
      guint access_control_type =
        TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST;
      GArray *access_control = g_array_sized_new (FALSE, FALSE,
          sizeof (guint), 1);

      g_array_append_val (access_control, access_control_type);
      g_value_take_boxed (value, access_control);
    }
  else if (!tp_strdiff (g_quark_to_string (name), "LocationAccessControl"))
    {
      GValueArray *access_control;
      GValue dummy = G_VALUE_INIT;

      /* For Publish_List, the variant isn't used, so we set a dummy value,
       * (guint) 0 */
      g_value_init (&dummy, G_TYPE_UINT);
      g_value_set_uint (&dummy, 0);

      access_control = tp_value_array_build (2,
          G_TYPE_UINT,
              (guint) TP_RICH_PRESENCE_ACCESS_CONTROL_TYPE_PUBLISH_LIST,
          G_TYPE_VALUE, &dummy,
          G_TYPE_INVALID);

      g_value_unset (&dummy);
      g_value_take_boxed (value, access_control);
    }
  else if (name == g_quark_from_static_string ("SupportedLocationFeatures"))
    {
      TpLocationFeatures flags = 0;

      if (conn->features & GABBLE_CONNECTION_FEATURES_PEP)
        flags |= TP_LOCATION_FEATURE_CAN_SET;

      g_value_set_uint (value, flags);
    }
  else
    {
      g_assert_not_reached ();
    }
}
Esempio n. 17
0
gboolean
empathy_client_types_contains_mobile_device (const GStrv types) {
  int i;

  if (types == NULL)
    return FALSE;

  for (i = 0; types[i] != NULL; i++)
    if (!tp_strdiff (types[i], "phone") || !tp_strdiff (types[i], "handheld"))
        return TRUE;

  return FALSE;
}
Esempio n. 18
0
gchar *
empathy_protocol_icon_name (const gchar *protocol)
{
  if (!tp_strdiff (protocol, "yahoojp"))
    /* Yahoo Japan uses the same icon as Yahoo */
    protocol = "yahoo";
  else if (!tp_strdiff (protocol, "simple"))
    /* SIMPLE uses the same icon as SIP */
    protocol = "sip";
  else if (!tp_strdiff (protocol, "sms"))
    return g_strdup ("phone");

  return g_strdup_printf ("im-%s", protocol);
}
static EmpathyCapabilities
channel_classes_to_capabilities (GPtrArray *classes,
				 gboolean audio_video)
{
	EmpathyCapabilities capabilities = 0;
	guint i;

	for (i = 0; i < classes->len; i++) {
		GValueArray *class_struct;
		GHashTable *fixed_prop;
		GStrv allowed_prop;
		TpHandleType handle_type;
		const gchar *chan_type;

		class_struct = g_ptr_array_index (classes, i);
		fixed_prop = g_value_get_boxed (g_value_array_get_nth (class_struct, 0));
		allowed_prop = g_value_get_boxed (g_value_array_get_nth (class_struct, 1));

		handle_type = tp_asv_get_uint32 (fixed_prop,
			TP_IFACE_CHANNEL ".TargetHandleType", NULL);
		if (handle_type != TP_HANDLE_TYPE_CONTACT)
			continue;

		chan_type = tp_asv_get_string (fixed_prop,
			TP_IFACE_CHANNEL ".ChannelType");

		if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_FILE_TRANSFER)) {
			capabilities |= EMPATHY_CAPABILITIES_FT;
		}

		else if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE)) {
			capabilities |= EMPATHY_CAPABILITIES_STREAM_TUBE;
		}
		else if (audio_video && !tp_strdiff (chan_type,
			TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) {
			guint j;

			for (j = 0; allowed_prop[j] != NULL; j++) {
				if (!tp_strdiff (allowed_prop[j],
						TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialAudio"))
					capabilities |= EMPATHY_CAPABILITIES_AUDIO;
				else if (!tp_strdiff (allowed_prop[j],
						TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo"))
					capabilities |= EMPATHY_CAPABILITIES_VIDEO;
			}
		}
	}

	return capabilities;
}
static void
check_chatroom (EmpathyChatroom *chatroom,
                const gchar *name,
                const gchar *room,
                gboolean auto_connect,
                gboolean favorite)
{
  gboolean _favorite;

  fail_if (tp_strdiff (empathy_chatroom_get_name (chatroom), name));
  fail_if (tp_strdiff (empathy_chatroom_get_room (chatroom), room));
  fail_if (empathy_chatroom_get_auto_connect (chatroom) != auto_connect);
  g_object_get (chatroom, "favorite", &_favorite, NULL);
  fail_if (favorite != _favorite);
}
Esempio n. 21
0
GabbleCallMemberContent *
gabble_call_member_ensure_content (GabbleCallMember *self,
  const gchar *name,
  JingleMediaType mtype)
{
  GabbleCallMemberPrivate *priv = self->priv;
  GList *l;
  GabbleCallMemberContent *content = NULL;

  for (l = priv->contents ; l != NULL; l = g_list_next (l))
    {
      GabbleCallMemberContent *c = GABBLE_CALL_MEMBER_CONTENT (l->data);

      if (gabble_call_member_content_get_media_type (c) == mtype &&
          !tp_strdiff (gabble_call_member_content_get_name (c), name))
        {
          content = c;
          break;
        }
    }

  if (content == NULL)
    {
      content = gabble_call_member_content_new (name, mtype, self);
      gabble_call_member_add_member_content (self, content);
    }

  return content;
}
Esempio n. 22
0
EmpathyChat *
empathy_chat_window_find_chat (McAccount   *account,
			       const gchar *id)
{
	GList *l;

	g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL);
	g_return_val_if_fail (!G_STR_EMPTY (id), NULL);

	for (l = chat_windows; l; l = l->next) {
		EmpathyChatWindowPriv *priv;
		EmpathyChatWindow     *window;
		GList                *ll;

		window = l->data;
		priv = GET_PRIV (window);

		for (ll = priv->chats; ll; ll = ll->next) {
			EmpathyChat *chat;

			chat = ll->data;

			if (empathy_account_equal (account, empathy_chat_get_account (chat)) &&
			    !tp_strdiff (id, empathy_chat_get_id (chat))) {
				return chat;
			}
		}
	}

	return NULL;
}
Esempio n. 23
0
/* Return the TpContact on @conn associated with @individual, if any */
TpContact *
empathy_get_tp_contact_for_individual (FolksIndividual *individual,
    TpConnection *conn)
{
  TpContact *contact = NULL;
  GeeSet *personas;
  GeeIterator *iter;

  personas = folks_individual_get_personas (individual);
  iter = gee_iterable_iterator (GEE_ITERABLE (personas));
  while (contact == NULL && gee_iterator_next (iter))
    {
      TpfPersona *persona = gee_iterator_get (iter);
      TpConnection *contact_conn;
      TpContact *contact_cur = NULL;

      if (TPF_IS_PERSONA (persona))
        {
          contact_cur = tpf_persona_get_contact (persona);
          if (contact_cur != NULL)
            {
              contact_conn = tp_contact_get_connection (contact_cur);

              if (!tp_strdiff (tp_proxy_get_object_path (contact_conn),
                    tp_proxy_get_object_path (conn)))
                contact = contact_cur;
            }
        }

      g_clear_object (&persona);
    }
  g_clear_object (&iter);

  return contact;
}
Esempio n. 24
0
const char *
empathy_service_name_to_display_name (const gchar *service_name)
{
  int i;
  static struct {
    const gchar *service;
    const gchar *display;
    gboolean translated;
  } names[] = {
    { "google-talk", N_("Google Talk"), FALSE },
    { "facebook", N_("Facebook Chat"), TRUE },
    { NULL, NULL }
  };

  for (i = 0; names[i].service != NULL; i++)
    {
      if (!tp_strdiff (service_name, names[i].service))
        {
          if (names[i].translated)
            return gettext (names[i].display);
          else
            return names[i].display;
        }
    }

  return service_name;
}
gboolean
empathy_migrate_butterfly_logs (EmpathyContact *contact)
{
  GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
  gchar *cm;

  /* Already in progress. */
  if (butterfly_log_migration_id != 0)
    return FALSE;

  /* Already done. */
  if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED))
    return FALSE;

  tp_account_parse_object_path (
      tp_proxy_get_object_path (empathy_contact_get_account (contact)),
      &cm, NULL, NULL, NULL);

  if (tp_strdiff (cm, "butterfly"))
    {
      g_free (cm);
      return TRUE;
    }
  g_free (cm);

  if (g_str_has_suffix (empathy_contact_get_id (contact), "#32")
      || g_str_has_suffix (empathy_contact_get_id (contact), "#1"))
    return TRUE;

  /* Okay, we know a new butterfly is being used, so we should migrate its logs */
  butterfly_log_migration_id = g_idle_add_full (G_PRIORITY_LOW,
      migrate_logs, NULL, NULL);

  return FALSE;
}
Esempio n. 26
0
static gboolean
contact_in_top (EmpathyRosterView *self,
    EmpathyRosterContact *contact)
{
  if (!self->priv->show_groups)
    {
      /* Always display top contacts in non-group mode. */
      GList *groups;
      FolksIndividual *individual;
      gboolean result = FALSE;

      individual = empathy_roster_contact_get_individual (contact);

      groups = empathy_roster_model_dup_groups_for_individual (
          self->priv->model, individual);

      if (g_list_find_custom (groups, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP,
            (GCompareFunc) g_strcmp0) != NULL)
        result = TRUE;

      g_list_free_full (groups, g_free);

      return result;
    }

  if (!tp_strdiff (empathy_roster_contact_get_group (contact),
          EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP))
    /* If we are displaying contacts, we only want to *always* display the
     * RosterContact which is displayed at the top; not the ones displayed in
     * the 'normal' group sections */
    return TRUE;

  return FALSE;
}
Esempio n. 27
0
static gboolean
contact_list_store_get_group_foreach (GtkTreeModel *model,
				      GtkTreePath  *path,
				      GtkTreeIter  *iter,
				      FindGroup    *fg)
{
	gchar    *str;
	gboolean  is_group;

	/* Groups are only at the top level. */
	if (gtk_tree_path_get_depth (path) != 1) {
		return FALSE;
	}

	gtk_tree_model_get (model, iter,
			    EMPATHY_CONTACT_LIST_STORE_COL_NAME, &str,
			    EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
			    -1);

	if (is_group && !tp_strdiff (str, fg->name)) {
		fg->found = TRUE;
		fg->iter = *iter;
	}

	g_free (str);

	return fg->found;
}
static gboolean
tp_contact_factory_avatar_maybe_update (EmpathyTpContactFactory *tp_factory,
					guint                    handle,
					const gchar             *token)
{
	EmpathyContact *contact;
	EmpathyAvatar  *avatar;

	contact = tp_contact_factory_find_by_handle (tp_factory, handle);
	if (!contact) {
		return TRUE;
	}

	/* Check if we have an avatar */
	if (EMP_STR_EMPTY (token)) {
		empathy_contact_set_avatar (contact, NULL);
		return TRUE;
	}

	/* Check if the avatar changed */
	avatar = empathy_contact_get_avatar (contact);
	if (avatar && !tp_strdiff (avatar->token, token)) {
		return TRUE;
	}

	/* The avatar changed, search the new one in the cache */
	if (empathy_contact_load_avatar_cache (contact, token)) {
		/* Got from cache, use it */
		return TRUE;
	}

	/* Avatar is not up-to-date, we have to request it. */
	return FALSE;
}
static gboolean
import_dialog_account_id_in_list (GList *accounts,
                                  const gchar *account_id)
{
  GList *l;

  for (l = accounts; l; l = l->next)
    {
      McAccount *account = l->data;
      gchar *value;
      gboolean result;

      if (mc_account_get_param_string (account, "account", &value)
          == MC_ACCOUNT_SETTING_ABSENT)
        continue;

      result = tp_strdiff (value, account_id);

      g_free (value);

      if (!result)
        return TRUE;
    }

  return FALSE;
}
static void
account_widget_entry_changed_common (EmpathyAccountWidget *self,
    GtkEntry *entry, gboolean focus)
{
  const gchar *str;
  const gchar *param_name;
  EmpathyAccountWidgetPriv *priv = GET_PRIV (self);

  str = gtk_entry_get_text (entry);
  param_name = g_object_get_data (G_OBJECT (entry), "param_name");

  if (EMP_STR_EMPTY (str))
    {
      const gchar *value = NULL;

      empathy_account_settings_unset (priv->settings, param_name);

      if (focus)
        {
          value = empathy_account_settings_get_string (priv->settings,
              param_name);
          DEBUG ("Unset %s and restore to %s", param_name, value);
          gtk_entry_set_text (entry, value ? value : "");
        }
    }
  else
    {
      DEBUG ("Setting %s to %s", param_name,
          tp_strdiff (param_name, "password") ? str : "***");
      empathy_account_settings_set_string (priv->settings, param_name, str);
    }
}