3 * Creation Date: 06-02-2009
4 * Last Modified: 09-02-2009
6 * Authored by Frederik 'playya' Sdun <Frederik.Sdun@googlemail.com>
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 public class GSM
:FSO
.System
31 public static const string BUS_NAME
= "org.freesmartphone.ogsmd";
32 public GSM( Logger l
, DBus
.Connection c
)
35 this
.busname
= BUS_NAME
;
36 this
.subsystems
.prepend( new
Call( l
,c
) );
37 this
.subsystems
.prepend( new
CellBroadcast( l
,c
) );
38 this
.subsystems
.prepend( new
HomeZone( l
,c
) );
39 this
.subsystems
.prepend( new
MUX( l
,c
) );
40 this
.subsystems
.prepend( new
Network( l
,c
) );
41 this
.subsystems
.prepend( new
PDP( l
,c
) );
42 //this.subsystems.prepend( new Phone( l,c ) );
43 this
.subsystems
.prepend( new
SIM( l
,c
) );
44 this
.subsystems
.prepend( new
SMS( l
,c
) );
46 public class Call
:Subsystem
48 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
49 public static const string IFACE
= "org.freesmartphone.GSM.Call";
51 public Call( Logger l
, DBus
.Connection c
,string name
= "")
55 this
._OBJ_PATH
= OBJ_PATH
;
56 this
._BUS_NAME
= BUS_NAME
;
59 public override void run() throws GLib
.Error
62 this
.object.CallStatus
+= this
.call_status_changed
;
64 public override void stop()
68 private void call_status_changed( dynamic DBus
.Object obj
, int id
,
69 string status
, GLib
.HashTable
<string,Value?
> properties
)
71 this
.logger
.log("CALL").signal( "Status" )
72 .name( "ID" ).type( typeof( int) ).value( id
.to_string() )
73 .name( "status").type ( typeof( string ) ).value( status
)
74 .name( "properties" ).attributes( properties
).end();
77 public class CellBroadcast
: Subsystem
79 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
80 public static const string IFACE
= "org.freesmartphone.GSM.CB";
81 public CellBroadcast( FSO
.Logger l
, DBus
.Connection c
,string name
= "")
85 this
._OBJ_PATH
= OBJ_PATH
;
86 this
._BUS_NAME
= BUS_NAME
;
88 public override void run() throws GLib
.Error
91 this
.object.IncomingCellBroadcast
+= this
.incoming_cb
;
93 public override void stop()
97 private void incoming_cb(dynamic DBus
.Object obj
, int serial
, int channel
,
98 int encoding
, int page
, string data
)
100 this
.logger
.log("CB").signal("IncomingCellBroadcast" )
101 .name( "serial" ).type( typeof( int ) ).value( serial
.to_string() )
102 .name( "channel" ).type( typeof( int ) ).value( channel
.to_string() )
103 .name( "encoding" ).type( typeof( int ) ).value( encoding
.to_string() )
104 .name( "page" ).type( typeof( int ) ).value( page
.to_string() )
105 .name( "data" ).type( typeof( string ) ).value( data
).end( );
109 public class HomeZone
: Subsystem
111 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Server";
112 public static const string IFACE
= "org.freesmartphone.GSM.HZ";
113 private string current_home_zone
;
114 public HomeZone( FSO
.Logger l
, DBus
.Connection c
,string name
= "")
118 this
._OBJ_PATH
= OBJ_PATH
;
119 this
._BUS_NAME
= BUS_NAME
;
121 public override void run() throws GLib
.Error
124 this
.object.HomeZoneStatus
+= this
.home_zone_changed
;
125 this
.object.GetHomeZoneStatus( this
.get_home_zone
);
127 public override void stop()
131 private void get_home_zone(dynamic DBus
.Object obj
, string zone
, GLib
.Error error
)
135 debug("HZ: Can't get homezone: %s", error
.message
);
139 this
.current_home_zone
= zone
;
143 private void home_zone_changed( dynamic GLib
.Object obj
, string zone
)
145 this
.logger
.log("HZ").signal( "HomeZoneStatus" ).name( "zone" ).type( typeof(string)).from(this
.current_home_zone
).to( zone
).end();
146 this
.current_home_zone
= zone
;
150 public class MUX
: Subsystem
152 public static const string BUS_NAME
= "org.pyneo.muxer";
153 public static const string OBJ_PATH
= "/org/pyneo/Muxer";
154 public static const string IFACE
= "org.freesmartphone.GSM.MUX";
155 public MUX( FSO
.Logger l
, DBus
.Connection c
,string name
= "" )
159 this
._OBJ_PATH
= OBJ_PATH
;
160 this
._BUS_NAME
= BUS_NAME
;
162 public override void run() throws GLib
.Error
165 this
.object.Status
+= this
.status_changed
;
167 public override void stop()
169 this
.object.Status
-= this
.status_changed
;
172 private void status_changed( dynamic DBus
.Object obj
, string status
)
174 logger
.log("GSM.MUX").name("status").type( typeof(string) ).value( status
).end();
178 public class Network
: Subsystem
180 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
181 public static const string IFACE
= "org.freesmartphone.GSM.Network";
182 private string current_gsm_cipher
= "UNKNOWN";
183 private string current_gprs_cipher
= "UNKNOWN";
184 private int current_signal_strength
;
185 public Network( FSO
.Logger l
, DBus
.Connection c
,string name
= "" )
189 this
._OBJ_PATH
= OBJ_PATH
;
190 this
._BUS_NAME
= BUS_NAME
;
192 public override void run() throws GLib
.Error
195 this
.object.NetworkStatus
+= this
.network_status_changed
;
196 this
.object.SignalStrength
+= this
.network_signal_strength_changed
;
197 this
.object.IncomingUssd
+= this
.network_incoming_ussd
;
198 this
.object.CipherStatus
+= this
.cipher_status_changed
;
199 this
.object.GetSignalStrength( this
.set_signal_strength
);
201 public override void stop()
205 private void cipher_status_changed(dynamic DBus
.Object obj
, string gsm
, string gprs
)
207 this
.logger
.log("NETWORK").signal( "CipherStatus")
208 .name( "GSM" ).type(typeof(string)).from( this
.current_gsm_cipher
).to( gsm
)
209 .name("GPRS").type(typeof(string)).from( this
.current_gprs_cipher
).to(gprs
).end();
210 this
.current_gsm_cipher
= gsm
;
211 this
.current_gprs_cipher
= gprs
;
213 private void network_incoming_ussd( dynamic DBus
.Object obj
, string mode
, string message
)
215 this
.logger
.log("NETWORK").signal("IncomingUSSD")
216 .name( "mode" ).type( typeof(string)).value( mode
)
217 .name( "message" ).type( typeof(string) ).value( message
).end();
220 private void network_signal_strength_changed(dynamic DBus
.Object obj
, int i
)
222 this
.logger
.log("NETWORK").signal( "SignalStrength" ).name( "strength").type( typeof(int) ).from( this
.current_signal_strength
.to_string() ).to( i
.to_string() ).end();
223 this
.current_signal_strength
= i
;
226 private void set_signal_strength(dynamic DBus
.Object obj
, int i
, GLib
.Error error
)
230 debug("NETWORK: Can't get signal strength: %s", error
.message
);
231 this
.current_signal_strength
= -1;
235 this
.current_signal_strength
= i
;
239 private void network_status_changed(dynamic DBus
.Object obj
, HashTable
<string,Value?
> properties
)
241 this
.logger
.log("NETWORK").signal( "NetworkStatus" ).name( "properties" ).attributes( properties
).end();
245 public class PDP
: Subsystem
247 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
248 public static const string IFACE
= "org.freesmartphone.GSM.PDP";
249 private HashTable
<string,string> current_network_status
;
250 public PDP( FSO
.Logger l
, DBus
.Connection c
,string name
= "")
254 this
._OBJ_PATH
= OBJ_PATH
;
255 this
._BUS_NAME
= BUS_NAME
;
259 this
.current_network_status
= new HashTable
<string,string>(GLib
.str_hash
, GLib
.str_equal
);
261 public override void run() throws GLib
.Error
264 this
.object.NetworkStatus
+= this
.pdp_network_status_changed
;
265 this
.object.ContextStatus
+= this
.pdp_context_status_changed
;
266 this
.object.GetNetworkStatus (this
.get_network_status
);
269 public override void stop()
273 private void pdp_context_status_changed( dynamic DBus
.Object obj
, int id
, string status
, HashTable
<string,Value?
> properties
)
275 this
.logger
.log("PDP").signal( "ContextStatus" )
276 .name( "ID" ).type( typeof(int) ).value( id
.to_string() )
277 .name( "status" ).type( typeof(string) ).value( status
)
278 .name( "properties").attributes( properties
).end();
280 private void get_network_status( dynamic DBus
.Object obj
, HashTable
<string, Value?
> status
, GLib
.Error error
)
284 debug( "Can't get network status: %s", error
.message
);
288 status
.for_each( (HFunc
) get_network_status_to_string
);
291 private void get_network_status_to_string( string key
, Value value
)
293 this
.current_network_status
.insert( key
, value
.get_string() );
295 private void pdp_network_status_changed( dynamic DBus
.Object obj
, HashTable
<string, Value?
> status
)
297 this
.logger
.log("PDP").signal( "NetworkStatus").name("status").attributes( status
).end();
301 public class Phone
: Subsystem
303 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Server";
304 public static const string IFACE
= "org.freesmartphone.GSM.Phone";
305 private string cur_status
= null;
306 public Phone( FSO
.Logger l
, DBus
.Connection c
,string name
= "")
310 this
._OBJ_PATH
= OBJ_PATH
;
311 this
._BUS_NAME
= BUS_NAME
;
313 public override void run() throws GLib
.Error
316 this
.object.ServiceStatus
+= this
.status_changed
;
318 public override void stop()
320 this
.object.ServiceStatus
-= this
.status_changed
;
323 private void status_changed( dynamic DBus
.Object obj
, string status
)
325 this
.logger
.log( "GSM:Phone" ).signal( "StatusChanged" ).name( "status" ).type( typeof( string ) ).from( this
.cur_status
).to( status
).end( );
326 this
.cur_status
= status
;
329 public class SIM
:Subsystem
331 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
332 public static const string IFACE
= "org.freesmartphone.GSM.SIM";
334 private string cur_auth_status
= null;
336 public SIM( FSO
.Logger l
, DBus
.Connection c
,string name
= "")
340 this
._OBJ_PATH
= OBJ_PATH
;
341 this
._BUS_NAME
= BUS_NAME
;
343 public override void run() throws GLib
.Error
346 this
.object.AuthStatus
+= auth_status_changed
;
347 this
.object.IncomingStoredMessage
+= incoming_stored_message
;
348 this
.object.ReadyStatus
+= this
.ready_status
;
349 this
.object.GetAuthStatus ( get_auth_status
);
351 public override void stop()
353 this
.object.AuthStatus
-= auth_status_changed
;
354 this
.object.IncomingStoredMessage
-= incoming_stored_message
;
357 private void auth_status_changed(dynamic DBus
.Object obj
, string status
)
359 this
.logger
.log("SIM" ).signal( "AuthStatus").name("status").type(typeof(string)).from( this
.cur_auth_status
).to( status
).end();
360 this
.cur_auth_status
= status
;
362 private void get_auth_status( dynamic DBus
.Object obj
, string status
, GLib
.Error error
)
366 debug( "Can't get authstatus: %s", error
.message
);
370 this
.cur_auth_status
= status
;
373 private void incoming_stored_message( dynamic DBus
.Object obj
, int idx
)
375 this
.logger
.log("SIM").signal("IncomingStoredMessage").name( "index" ).type( typeof(int) ).value( idx
.to_string() ).end();
377 private void ready_status ( dynamic DBus
.Object obj
, bool status
)
379 this
.logger
.log( "GSM.SIM" ).signal( "ReadyStatus" ).name( "status" ).type( typeof( string ) ).value( status
.to_string( ) ).end( );
382 public class SMS
: Subsystem
384 public static const string OBJ_PATH
= "/org/freesmartphone/GSM/Device";
385 public static const string IFACE
= "org.freesmartphone.GSM.SMS";
386 public SMS( FSO
.Logger l
, DBus
.Connection c
,string name
= "" )
390 this
._OBJ_PATH
= OBJ_PATH
;
391 this
._BUS_NAME
= BUS_NAME
;
393 public override void run() throws GLib
.Error
396 this
.object.IncomingMessage
+= this
.sms_incoming_message
;
399 public override void stop()
403 private void sms_incoming_message(dynamic DBus
.Object obj
, string sender
, string content
, HashTable
<string,Value?
> properties
)
405 this
.logger
.log("SMS").signal( "IncomingMessage")
406 .name("sender").type( typeof(string) ).value( sender
)
407 .name( "content" ).type( typeof(string) ).value( content
)
408 .name( "properties" ).attributes( properties
).end();