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.

91 lines
2.0KB

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