Original DBUS bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
2.0 KiB

  1. /* server.h: TQt wrapper for DBusServer
  2. *
  3. * Copyright (C) 2003 Zack Rusin <zack@kde.org>
  4. *
  5. * Licensed under the Academic Free License version 2.0
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #include "server.h"
  23. #include "connection.h"
  24. #include "integrator.h"
  25. using DBusQt::Internal::Integrator;
  26. namespace DBusQt
  27. {
  28. struct Server::Private {
  29. Private() : integrator( 0 ), server( 0 )
  30. {}
  31. Integrator *integrator;
  32. DBusServer *server;
  33. DBusError error;
  34. };
  35. Server::Server( const TQString& addr, TQObject *parent )
  36. : TQObject( parent )
  37. {
  38. d = new Private;
  39. if ( !addr.isEmpty() ) {
  40. init( addr );
  41. }
  42. }
  43. Server::~Server()
  44. {
  45. delete d;
  46. }
  47. bool Server::isConnected() const
  48. {
  49. return dbus_server_get_is_connected( d->server );
  50. }
  51. void Server::disconnect()
  52. {
  53. dbus_server_disconnect( d->server );
  54. }
  55. TQString Server::address() const
  56. {
  57. //FIXME: leak?
  58. return dbus_server_get_address( d->server );
  59. }
  60. void Server::listen( const TQString& addr )
  61. {
  62. if ( !d->server ) {
  63. init( addr );
  64. }
  65. }
  66. void Server::init( const TQString& addr )
  67. {
  68. d->server = dbus_server_listen( addr.ascii(), &d->error );
  69. d->integrator = new Integrator( d->server, this );
  70. connect( d->integrator, TQT_SIGNAL(newConnection(Connection*)),
  71. TQT_SIGNAL(newConnection(Connection*)) );
  72. }
  73. }
  74. #include "server.moc"