Mercurial > projects > dbus-d
comparison dbus-d-javatests/jsrc/filetree/DataItem.d @ 0:a5576806d36d
recreate repository without any libs for lightweight repository
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 20 Oct 2007 18:07:18 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a5576806d36d |
---|---|
1 /* | |
2 * Generated with TioLink | |
3 * TioLink was written by Frank Benoit <benoit@tionex.de> | |
4 * http://www.dsource.org/projects/tiolink | |
5 * | |
6 * User specific code can be place after the generated comment line containing: | |
7 * "USER CONTENT STARTS HERE". | |
8 * Everything before that line will be programmatically overwritten. | |
9 * | |
10 * File type: D programming language source code | |
11 */ | |
12 module filetree.DataItem; | |
13 | |
14 import org.freedesktop.dbus.DBus; | |
15 import org.freedesktop.dbus.Introspectable; | |
16 | |
17 // Interface for DataItem | |
18 | |
19 interface DataItem : org.freedesktop.dbus.DBusInterface.DBusInterface { | |
20 public filetree.DataItem.DataItem[] getChilds(); | |
21 public bool isFolder(); | |
22 public bool isDrive(); | |
23 public char[] getName(); | |
24 const static char[] introspectionXml = | |
25 `<interface name="filetree.DataItem"/>`\n | |
26 ` <method name="getChilds">`\n | |
27 ` <arg name="p0" type="ao" direction="out"/>`\n | |
28 ` </method>`\n | |
29 ` <method name="isFolder">`\n | |
30 ` <arg name="p0" type="b" direction="out"/>`\n | |
31 ` </method>`\n | |
32 ` <method name="isDrive">`\n | |
33 ` <arg name="p0" type="b" direction="out"/>`\n | |
34 ` </method>`\n | |
35 ` <method name="getName">`\n | |
36 ` <arg name="p0" type="s" direction="out"/>`\n | |
37 ` </method>`\n | |
38 `</interface>`\n | |
39 ; | |
40 } | |
41 | |
42 CConnection.DBusHandlerResult intfHandler__filetree_DataItem_DataItem( CConnection.DBusConnection* conn, CConnection.DBusMessage* message, void* user_data ){ | |
43 DataItem o = cast(DataItem)cast(Object)user_data; | |
44 if( o is null || !checkIntf( "filetree.DataItem", message) ) | |
45 return CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
46 | |
47 try{ | |
48 char[METHOD_SIG_MAXLENGTH] buf; | |
49 switch( methodSignature( message, buf ) ){ | |
50 case "getChilds|": | |
51 { | |
52 filetree.DataItem.DataItem[] callResult = o.getChilds(); | |
53 sendReply( conn, message, callResult ); | |
54 } | |
55 break; | |
56 case "isFolder|": | |
57 { | |
58 bool callResult = o.isFolder(); | |
59 sendReply( conn, message, callResult ); | |
60 } | |
61 break; | |
62 case "isDrive|": | |
63 { | |
64 bool callResult = o.isDrive(); | |
65 sendReply( conn, message, callResult ); | |
66 } | |
67 break; | |
68 case "getName|": | |
69 { | |
70 char[] callResult = o.getName(); | |
71 sendReply( conn, message, callResult ); | |
72 } | |
73 break; | |
74 default: | |
75 return CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
76 } | |
77 } | |
78 catch( Exception e ){ | |
79 sendException( conn, message, e ); | |
80 } | |
81 return CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_HANDLED; | |
82 } | |
83 void intfFree__filetree_DataItem_DataItem( CConnection.DBusConnection *connection, void *user_data ){ | |
84 } | |
85 | |
86 | |
87 // Dimpl for MyDataItem | |
88 | |
89 extern(C) CConnection.DBusHandlerResult dimplHandler__filetree_DataItem_MyDataItem( CConnection.DBusConnection* conn, CConnection.DBusMessage* message, void* user_data ){ | |
90 CConnection.DBusHandlerResult res = CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED; | |
91 if( res == CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED ){ | |
92 res = intfHandler__filetree_DataItem_DataItem( conn, message, user_data ); | |
93 } | |
94 if( res == CConnection.DBusHandlerResult.DBUS_HANDLER_RESULT_NOT_YET_HANDLED ){ | |
95 res = intfHandler__org_freedesktop_dbus_Introspectable_Introspectable( conn, message, user_data ); | |
96 } | |
97 return res; | |
98 } | |
99 | |
100 extern(C) void dimplFree__filetree_DataItem_MyDataItem( CConnection.DBusConnection *connection, void *user_data ){ | |
101 } | |
102 | |
103 CConnection.DBusObjectPathVTable vtable__filetree_DataItem_MyDataItem = { | |
104 unregister_function : & dimplFree__filetree_DataItem_MyDataItem, | |
105 message_function : & dimplHandler__filetree_DataItem_MyDataItem | |
106 }; | |
107 | |
108 | |
109 static assert( is( MyDataItem : filetree.DataItem.DataItem )); | |
110 static assert( is( MyDataItem : org.freedesktop.dbus.Introspectable.Introspectable )); | |
111 | |
112 // --- USER CONTENT STARTS HERE (do not change this marker line) --- | |
113 | |
114 import tango.core.Exception; | |
115 import tango.io.Stdout; | |
116 import tango.io.FilePath; | |
117 | |
118 class MyDataItem : DBusObject, DataItem, Introspectable { | |
119 FilePath file; | |
120 | |
121 public this( FilePath absPath ){ | |
122 super( this.classinfo ); | |
123 file = absPath; | |
124 //Stdout.formatln( "{} {} {}", __LINE__, __FILE__, file.toUtf8() ); | |
125 } | |
126 | |
127 public char[] Introspect(){ | |
128 return buildIntrospect( [DataItem.introspectionXml, Introspectable.introspectionXml ], null ); | |
129 } | |
130 public DBusObjectPathVTable* getDBusVTable(){ | |
131 return &vtable__filetree_DataItem_MyDataItem; | |
132 } | |
133 public DataItem[] getChilds(){ | |
134 //Stdout.formatln( "{} {} ", __LINE__, __FILE__ ); | |
135 char[][] names; | |
136 try{ | |
137 int i; | |
138 char[][] list; | |
139 void add (char[] path, char[] name, bool dir) { | |
140 if( name == "." || name == ".." ){ | |
141 return; | |
142 } | |
143 if (i >= list.length) | |
144 list.length = list.length * 2; | |
145 | |
146 list[i++] = path~name; | |
147 } | |
148 list = new char[][512]; | |
149 file.toList (&add); | |
150 names = list [0 .. i]; | |
151 } catch( IOException e ){ | |
152 // nothing happends | |
153 } | |
154 | |
155 //Stdout.formatln( "{} {} ", __LINE__, __FILE__ ); | |
156 DataItem[] res = new DataItem[ names.length ]; | |
157 //Stdout.formatln( "{} {} ", __LINE__, __FILE__ ); | |
158 for( int i = 0; i < names.length; i++ ){ | |
159 char[] path = names[i]; | |
160 //Stdout.formatln( "{} {} {}", __LINE__, __FILE__, path ); | |
161 res[i] = new MyDataItem( new FilePath( path ) ); | |
162 } | |
163 //Stdout.formatln( "{} {} ", __LINE__, __FILE__ ); | |
164 return res; | |
165 } | |
166 public char[] getName(){ | |
167 return file.file(); | |
168 } | |
169 public bool isFolder(){ | |
170 //Stdout.formatln( "{} {} {}", __LINE__, __FILE__, file.toUtf8() ); | |
171 bool res = false; | |
172 try{ | |
173 res = file.isFolder(); | |
174 } catch( IOException e ){ | |
175 } | |
176 return res; | |
177 } | |
178 | |
179 public bool isDrive(){ | |
180 Stdout.formatln( "{} {} ", __LINE__, __FILE__ ); | |
181 return false; | |
182 } | |
183 public override char[] toUtf8(){ | |
184 return file.toUtf8(); | |
185 } | |
186 } | |
187 |