home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / perl5 / Net / DBus / Annotation.pm next >
Encoding:
Perl POD Document  |  2006-06-03  |  3.0 KB  |  134 lines

  1. # -*- perl -*-
  2. #
  3. # Copyright (C) 2006 Daniel P. Berrange
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18. #
  19. # $Id: RemoteObject.pm,v 1.20 2006/01/27 15:34:24 dan Exp $
  20.  
  21. =pod
  22.  
  23. =head1 NAME
  24.  
  25. Net::DBus::Annotation - annotations for changing behaviour of APIs
  26.  
  27. =head1 SYNOPSIS
  28.  
  29.   use Net::DBus::Annotation qw(:call);
  30.  
  31.   my $object = $service->get_object("/org/example/systemMonitor");
  32.  
  33.   # Block until processes are listed
  34.   my $processes = $object->list_processes("someuser");
  35.  
  36.   # Just throw away list of processes, pretty pointless
  37.   # in this example, but useful if the method doesn't have
  38.   # a return value
  39.   $object->list_processes(dbus_call_noreply, "someuser");
  40.  
  41.   # List processes & get on with other work until
  42.   # the list is returned.
  43.   my $asyncreply = $object->list_processes(dbus_call_async, "someuser");
  44.  
  45.   ... some time later...
  46.   my $processes = $asyncreply->get_data;
  47.  
  48. =head1 DESCRIPTION
  49.  
  50. This module provides a number of annotations which will be useful
  51. when dealing with the DBus APIs. There are annotations for switching
  52. remote calls between sync, async and no-reply mode. More annotations
  53. may be added over time.
  54.  
  55. =head1 METHODS
  56.  
  57. =over 4
  58.  
  59. =cut
  60.  
  61. package Net::DBus::Annotation;
  62.  
  63. use strict;
  64. use warnings;
  65.  
  66. our $CALL_SYNC = "sync";
  67. our $CALL_ASYNC = "async";
  68. our $CALL_NOREPLY = "noreply";
  69.  
  70. bless \$CALL_SYNC, __PACKAGE__;
  71. bless \$CALL_ASYNC, __PACKAGE__;
  72. bless \$CALL_NOREPLY, __PACKAGE__;
  73.  
  74. require Exporter;
  75.  
  76. our @ISA = qw(Exporter);
  77. our @EXPORT_OK = qw(dbus_call_sync dbus_call_async dbus_call_noreply);
  78. our %EXPORT_TAGS = (call => [qw(dbus_call_sync dbus_call_async dbus_call_noreply)]);
  79.  
  80. =item dbus_call_sync
  81.  
  82. Requests that a method call be performed synchronously, waiting
  83. for the reply or error return to be received before continuing.
  84.  
  85. =cut
  86.  
  87. sub dbus_call_sync() {
  88.     return \$CALL_SYNC;
  89. }
  90.  
  91.  
  92. =item dbus_call_async
  93.  
  94. Requests that a method call be performed a-synchronously, returning
  95. a pending call object, which will collect the reply when it eventually
  96. arrives.
  97.  
  98. =cut
  99.  
  100. sub dbus_call_async() {
  101.     return \$CALL_ASYNC;
  102. }
  103.  
  104. =item dbus_call_noreply
  105.  
  106. Requests that a method call be performed a-synchronously, discarding
  107. any possible reply or error message.
  108.  
  109. =cut
  110.  
  111. sub dbus_call_noreply() {
  112.     return \$CALL_NOREPLY;
  113. }
  114.  
  115. 1;
  116.  
  117. =pod
  118.  
  119. =back
  120.  
  121. =head1 AUTHOR
  122.  
  123. Daniel Berrange <dan@berrange.com>
  124.  
  125. =head1 COPYRIGHT
  126.  
  127. Copright (C) 2006, Daniel Berrange.
  128.  
  129. =head1 SEE ALSO
  130.  
  131. L<Net::DBus>, L<Net::DBus::RemoteObject>
  132.  
  133. =cut
  134.