Exemple #1
0
int
main (int argc,
      char **argv)
{
  TpAccountManager *manager;
  TpSimpleClientFactory *factory;
  TpBaseClient *approver;
  GError *error = NULL;

  gtk_init (&argc, &argv);
  tp_debug_set_flags (g_getenv ("LIBO_APPROVER_DEBUG"));

  manager = tp_account_manager_dup ();

    factory = tp_proxy_get_factory (manager);
    /* We want the target contact on channels to be available... */
    tp_simple_client_factory_add_channel_features_varargs (factory,
        TP_CHANNEL_FEATURE_CONTACTS,
        0);
    /* ...and for it to have its alias and avatar available */
    tp_simple_client_factory_add_contact_features_varargs (factory,
        TP_CONTACT_FEATURE_ALIAS,
        TP_CONTACT_FEATURE_AVATAR_DATA,
        TP_CONTACT_FEATURE_INVALID);

  approver = tp_simple_approver_new_with_am (manager, "LibreOfficeApprover",
      FALSE, add_dispatch_operation_cb, NULL, NULL);

  tp_base_client_take_approver_filter (approver, tp_asv_new (
        TP_PROP_CHANNEL_CHANNEL_TYPE, G_TYPE_STRING,
          TP_IFACE_CHANNEL_TYPE_DBUS_TUBE,
        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, G_TYPE_UINT,
          TP_HANDLE_TYPE_CONTACT,
        TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME, G_TYPE_STRING,
          LIBO_DTUBE_SERVICE,
        NULL));

  if (!tp_base_client_register (approver, &error))
    {
      g_warning ("Failed to register Approver: %s\n", error->message);
      g_error_free (error);
      goto out;
    }

  g_print ("Start approving\n");

  mainloop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (mainloop);
  /* TODO: time out after 5 seconds of inactivity? */

  if (mainloop != NULL)
    g_main_loop_unref (mainloop);

out:
  g_object_unref (manager);
  g_object_unref (approver);

  return 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
}
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);
    }
}