/usr/share/ada/adainclude/dbus-ada/d_bus-connection-g_main.adb is in libdbusada0.2-dev 0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | --
-- D_Bus/Ada - An Ada binding to D-Bus
--
-- Copyright (C) 2011 Reto Buerki <reet@codelabs.ch>
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
-- USA.
--
-- As a special exception, if other files instantiate generics from this
-- unit, or you link this unit with other files to produce an
-- executable this unit does not by itself cause the resulting
-- executable to be covered by the GNU General Public License. This
-- exception does not however invalidate any other reasons why the
-- executable file might be covered by the GNU Public License.
--
with Interfaces.C.Strings;
with dbus_types_h;
with dbus_connection_h;
with dbus_shared_h;
with D_Bus.Messages;
package body D_Bus.Connection.G_Main is
package C renames Interfaces.C;
procedure dbus_connection_setup_with_g_main
(connection : System.Address;
context : System.Address);
pragma Import (C, dbus_connection_setup_with_g_main,
"dbus_connection_setup_with_g_main");
function Object_Path_Message
(conn : System.Address;
msg : System.Address;
data : System.Address)
return dbus_shared_h.DBusHandlerResult;
-- Handler for path messages.
procedure Object_Path_Unregister
(conn : System.Address;
data : System.Address) is null;
procedure Nul_Pad (arg1 : System.Address) is null;
Obj_Path_Table : aliased constant dbus_connection_h.DBusObjectPathVTable
:= (unregister_function => Object_Path_Unregister'Access,
message_function => Object_Path_Message'Access,
dbus_internal_pad1 => Nul_Pad'Access,
dbus_internal_pad2 => Nul_Pad'Access,
dbus_internal_pad3 => Nul_Pad'Access,
dbus_internal_pad4 => Nul_Pad'Access);
-- Object V path table.
-------------------------------------------------------------------------
function Object_Path_Message
(conn : System.Address;
msg : System.Address;
data : System.Address)
return dbus_shared_h.DBusHandlerResult
is
pragma Unreferenced (data);
use D_Bus.Messages;
use type SOMP.Cursor;
Reply : Message_Type;
Message : constant Message_Type := Create (D_Msg => msg);
Path : constant String := Get_Path (Msg => Message);
Method : constant String := Get_Member (Msg => Message);
Obj : constant Object'Class := Services.Element
(Key => To_Unbounded_String (Path));
begin
Obj.Call (Name => Method,
Request => Message,
Reply => Reply);
Send (Connection => (Thin_Connection => conn),
Message => Reply);
return dbus_shared_h.DBUS_HANDLER_RESULT_HANDLED;
exception
when Unknown_Method =>
declare
Error : constant Message_Type := New_Error
(Reply_To => Message,
Error_Name => "org.freedesktop.DBus.Error.UnknownMethod",
Error_Message => "Received unknown method call: " & Method);
begin
Send (Connection => (Thin_Connection => conn),
Message => Error);
return dbus_shared_h.DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
end;
end Object_Path_Message;
-------------------------------------------------------------------------
procedure Register_Object
(Connection : Connection_Type;
Path : String := "/";
Object : in out Service.Object'Class)
is
use type dbus_types_h.dbus_bool_t;
C_Path : C.Strings.chars_ptr := C.Strings.New_String (Str => Path);
D_Res : dbus_types_h.dbus_bool_t;
begin
D_Res := dbus_connection_h.dbus_connection_register_object_path
(arg1 => Connection.Thin_Connection,
arg2 => C_Path,
arg3 => Obj_Path_Table'Access,
arg4 => System.Null_Address);
C.Strings.Free (Item => C_Path);
if D_Res /= 1 then
raise D_Bus_Error with "Could not register object on path '"
& Path & "'";
end if;
Object.Initialize;
Services.Insert (Key => To_Unbounded_String (Source => Path),
New_Item => Object);
end Register_Object;
-------------------------------------------------------------------------
procedure Setup_With_G_Main (Connection : in out Connection_Type)
is
begin
dbus_connection_setup_with_g_main
(connection => Connection.Thin_Connection,
context => System.Null_Address);
end Setup_With_G_Main;
end D_Bus.Connection.G_Main;
|