casa
$Rev:20696$
|
00001 //# DBusSession.h: connection to the DBus session 00002 //# Copyright (C) 2009 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef DBUS_SESSION_H_ 00029 #define DBUS_SESSION_H_ 00030 00031 #include <vector> 00032 #include <string> 00033 #include <casadbus/session/DBusSession.proxy.h> 00034 #include <casadbus/session/Dispatcher.h> 00035 00036 namespace casa { 00037 00038 class DBusSession : 00039 private org::freedesktop::DBus_proxy, 00040 public DBus::IntrospectableProxy, 00041 public DBus::ObjectProxy { 00042 public: 00043 00044 static DBusSession &instance( ); 00045 std::vector<std::string> listNames( ) { return ListNames( ); } 00046 DBus::Connection &connection( ) { return conn; } 00047 dbus::Dispatcher &dispatcher( ) { return *dispatcher_; } 00048 00049 private: 00050 00051 DBus::Connection conn; 00052 DBusSession( DBus::Connection & ); 00053 DBusSession( ); 00054 00055 static dbus::Dispatcher *dispatcher_; 00056 00057 // pure virtual functions (i.e. dbus signals) 00058 void NameOwnerChanged(const std::string&, const std::string&, const std::string&); 00059 void NameLost(const std::string&); 00060 void NameAcquired(const std::string&); 00061 00062 friend class init_dispatcher; 00063 }; 00064 00065 static class init_dispatcher { 00066 public: 00067 init_dispatcher( ) { 00068 if ( ! initalized ) { 00069 initalized = true; 00070 DBusSession::dispatcher_ = new dbus::Dispatcher( ); 00071 DBus::default_dispatcher = DBusSession::dispatcher_; 00072 } 00073 } 00074 private: 00075 static bool initalized; 00076 } init_dispatcher_; 00077 00078 } 00079 #endif