Exemplo n.º 1
0
static void
tmc_client_factory_init (TmcClientFactory *self)
{
	tp_simple_client_factory_add_contact_features_varargs (TP_SIMPLE_CLIENT_FACTORY (self),
							       TP_CONTACT_FEATURE_ALIAS,
							       TP_CONTACT_FEATURE_PRESENCE,
							       TP_CONTACT_FEATURE_INVALID);
#if 0
	tp_simple_client_factory_add_channel_features_varargs (TP_SIMPLE_CLIENT_FACTORY (self),
							       TP_CHANNEL_FEATURE_CONTACTS,
							       TP_TEXT_CHANNEL_FEATURE_INCOMING_MESSAGES,
							       TP_CONTACT_FEATURE_INVALID);
#endif
}
int
main (int argc,
    char **argv)
  {
    EmpathyClientFactory *factory;
    TpAccountManager *am;
    GMainLoop *loop;

    gtk_init (&argc, &argv);
    empathy_gtk_init ();

    /* The blocking dialog needs the contact list for the contacts completion
     * so we prepare it first. */
    factory = empathy_client_factory_dup ();

    tp_simple_client_factory_add_connection_features_varargs (
        TP_SIMPLE_CLIENT_FACTORY (factory),
        TP_CONNECTION_FEATURE_CONTACT_LIST,
        NULL);

    am = tp_account_manager_dup ();

    loop = g_main_loop_new (NULL, FALSE);

    tp_proxy_prepare_async (am, NULL, am_prepare_cb, loop);

    g_main_loop_run (loop);

    g_object_unref (am);
    return 0;
  }
Exemplo n.º 3
0
void
empathy_init (void)
{
  static gboolean initialized = FALSE;
  TpAccountManager *am;
  EmpathyClientFactory *factory;

  if (initialized)
    return;

  g_type_init ();

  /* Setup gettext */
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");

  /* Setup debug output for empathy and telepathy-glib */
  if (g_getenv ("EMPATHY_TIMING") != NULL)
    g_log_set_default_handler (tp_debug_timestamped_log_handler, NULL);

  empathy_debug_set_flags (g_getenv ("EMPATHY_DEBUG"));
  tp_debug_divert_messages (g_getenv ("EMPATHY_LOGFILE"));

  emp_cli_init ();

  initialized = TRUE;

  factory = empathy_client_factory_dup ();
  am = tp_account_manager_new_with_factory (TP_SIMPLE_CLIENT_FACTORY (factory));
  tp_account_manager_set_default (am);

  g_object_unref (factory);
  g_object_unref (am);
}
Exemplo n.º 4
0
static void
contacts_ready (GObject      *source,
                GAsyncResult *result,
                gpointer      user_data)
{
    ChVisitor *self = (ChVisitor*) user_data;
    TpSimpleClientFactory *factory = TP_SIMPLE_CLIENT_FACTORY (source);
    GError *error = NULL;
    GPtrArray *contacts;

    if (!tp_simple_client_factory_upgrade_contacts_finish (factory, result,
                                                           &contacts, &error)
    ) {
        g_printerr ("error loading contacts: %s\n", error->message);
    }

    for (unsigned int i = 0; i < contacts->len; i++) {
        TpContact *contact = g_ptr_array_index (contacts, i);

        if (self->visit_contact) {
            self->visit_contact (self, contact);
        }
    }

    g_ptr_array_free (contacts, TRUE);
    ch_visitor_decref (self);
}
Exemplo n.º 5
0
static void
ensure_contact_by_id_cb (GObject      *source,
                         GAsyncResult *result,
                         gpointer      user_data)
{
    TpSimpleClientFactory *factory = TP_SIMPLE_CLIENT_FACTORY (source);
    ChVisitor *self = (ChVisitor*) user_data;
    GError *error = NULL;
    TpContact *contact;

    contact = tp_simple_client_factory_ensure_contact_by_id_finish (factory,
                                                                    result,
                                                                    &error);

    if (error) {
        g_printerr ("error loading contact: %s\n", error->message);
        ch_visitor_decref (self);
        return;
    }

    if (self->visit_contact) {
        self->visit_contact (self, contact);
    }

    ch_visitor_decref (self);
}
Exemplo n.º 6
0
static void
vino_tube_servers_manager_init (VinoTubeServersManager *self)
{
  TpDBusDaemon *dbus;
  GError *error = NULL;
  TpSimpleClientFactory *factory;

  self->priv = VINO_TUBE_SERVERS_MANAGER_GET_PRIVATE (self);
  self->priv->vino_tube_servers = NULL;
  self->priv->alternative_port = 26570;

  dbus = tp_dbus_daemon_dup (NULL);
  factory = TP_SIMPLE_CLIENT_FACTORY (tp_automatic_client_factory_new (dbus));
  g_object_unref (dbus);

  tp_simple_client_factory_add_contact_features_varargs (factory,
      TP_CONTACT_FEATURE_ALIAS,
      TP_CONTACT_FEATURE_AVATAR_DATA,
      TP_CONTACT_FEATURE_INVALID);

  tp_simple_client_factory_add_channel_features_varargs (factory,
      TP_CHANNEL_FEATURE_CONTACTS,
      0);

  self->priv->handler = tp_simple_handler_new_with_factory (factory, FALSE,
      FALSE, "Vino", FALSE, handle_channels_cb, self, NULL);

  g_object_unref (factory);

  tp_base_client_take_handler_filter (self->priv->handler, tp_asv_new (
        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
          TP_IFACE_CHANNEL_TYPE_STREAM_TUBE,
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
          TP_HANDLE_TYPE_CONTACT,
        TP_PROP_CHANNEL_REQUESTED, G_TYPE_BOOLEAN,
          TRUE,
        TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, G_TYPE_STRING,
          "rfb",
        NULL));

  if (!tp_base_client_register (self->priv->handler, &error))
    {
      dprintf (TUBE, "Failed to register Handler: %s\n", error->message);
      g_error_free (error);
    }
}
static void
chatroom_manager_parse_chatroom (EmpathyChatroomManager *manager,
    xmlNodePtr node)
{
  EmpathyChatroom *chatroom = NULL;
  TpAccount *account;
  xmlNodePtr child;
  gchar *str;
  gchar *name;
  gchar *room;
  gchar *account_id;
  gboolean auto_connect;
  gboolean always_urgent;
  EmpathyClientFactory *factory;
  GError *error = NULL;

  /* default values. */
  name = NULL;
  room = NULL;
  auto_connect = TRUE;
  always_urgent = FALSE;
  account_id = NULL;

  for (child = node->children; child; child = child->next)
    {
      gchar *tag;

      if (xmlNodeIsText (child))
        continue;

      tag = (gchar *) child->name;
      str = (gchar *) xmlNodeGetContent (child);

      if (strcmp (tag, "name") == 0)
        {
          name = g_strdup (str);
        }
      else if (strcmp (tag, "room") == 0)
        {
          room = g_strdup (str);
        }
      else if (strcmp (tag, "auto_connect") == 0)
        {
          if (strcmp (str, "yes") == 0)
            auto_connect = TRUE;
          else
            auto_connect = FALSE;
        }
      else if (!tp_strdiff (tag, "always_urgent"))
        {
          if (strcmp (str, "yes") == 0)
            always_urgent = TRUE;
          else
            always_urgent = FALSE;
        }
      else if (strcmp (tag, "account") == 0)
        {
          account_id = g_strdup (str);
        }

      xmlFree (str);
    }

  /* account has to be a valid Account object path */
  if (!tp_dbus_check_valid_object_path (account_id, NULL) ||
      !g_str_has_prefix (account_id, TP_ACCOUNT_OBJECT_PATH_BASE))
    goto out;

  factory = empathy_client_factory_dup ();

  account = tp_simple_client_factory_ensure_account (
          TP_SIMPLE_CLIENT_FACTORY (factory), account_id, NULL, &error);
  g_object_unref (factory);

  if (account == NULL)
    {
      DEBUG ("Failed to create account: %s", error->message);
      g_error_free (error);

      g_free (name);
      g_free (room);
      g_free (account_id);
      return;
    }

  chatroom = empathy_chatroom_new_full (account, room, name, auto_connect);
  empathy_chatroom_set_favorite (chatroom, TRUE);
  empathy_chatroom_set_always_urgent (chatroom, always_urgent);
  add_chatroom (manager, chatroom);
  g_signal_emit (manager, signals[CHATROOM_ADDED], 0, chatroom);

out:
  g_free (name);
  g_free (room);
  g_free (account_id);
  tp_clear_object (&chatroom);
}