| 1 | /* |
|---|
| 2 | * Copyright (C) 2011-2012 Michael 'Mickey' Lauer <mlauer@vanille-media.de> |
|---|
| 3 | * |
|---|
| 4 | * This program is free software; you can redistribute it and/or |
|---|
| 5 | * modify it under the terms of the GNU General Public License |
|---|
| 6 | * as published by the Free Software Foundation; either version 2 |
|---|
| 7 | * of the License, or (at your option) any later version. |
|---|
| 8 | |
|---|
| 9 | * This program is distributed in the hope that it will be useful, |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | * GNU General Public License for more details. |
|---|
| 13 | |
|---|
| 14 | * You should have received a copy of the GNU General Public License |
|---|
| 15 | * along with this program; if not, write to the Free Software |
|---|
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|---|
| 17 | */ |
|---|
| 18 | |
|---|
| 19 | using GLib; |
|---|
| 20 | |
|---|
| 21 | namespace FsoAudio.GsmVoiceCmtspeechdata |
|---|
| 22 | { |
|---|
| 23 | public const string MODULE_NAME = "fsoaudio.gsmvoice_alsa_cmtspeechdata"; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | class FsoAudio.GsmVoiceCmtspeechdata.Plugin : FsoFramework.AbstractObject |
|---|
| 27 | { |
|---|
| 28 | private FsoFramework.Subsystem subsystem; |
|---|
| 29 | private CmtHandler cmthandler; |
|---|
| 30 | private FreeSmartphone.GSM.Call gsmcallproxy; |
|---|
| 31 | |
|---|
| 32 | // |
|---|
| 33 | // Private API |
|---|
| 34 | // |
|---|
| 35 | private void onCallStatusSignal( int id, FreeSmartphone.GSM.CallStatus status, GLib.HashTable<string,Variant> properties ) |
|---|
| 36 | { |
|---|
| 37 | assert( logger.debug( @"onCallStatusSignal $id w/ status $status" ) ); |
|---|
| 38 | switch ( status ) |
|---|
| 39 | { |
|---|
| 40 | case FreeSmartphone.GSM.CallStatus.OUTGOING: |
|---|
| 41 | case FreeSmartphone.GSM.CallStatus.ACTIVE: |
|---|
| 42 | cmthandler.setAudioStatus( true ); |
|---|
| 43 | break; |
|---|
| 44 | |
|---|
| 45 | case FreeSmartphone.GSM.CallStatus.RELEASE: |
|---|
| 46 | cmthandler.setAudioStatus( false ); |
|---|
| 47 | break; |
|---|
| 48 | |
|---|
| 49 | default: |
|---|
| 50 | assert( logger.debug( @"Unhandled call status $status" ) ); |
|---|
| 51 | break; |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | // |
|---|
| 56 | // Public API |
|---|
| 57 | // |
|---|
| 58 | public Plugin( FsoFramework.Subsystem subsystem ) |
|---|
| 59 | { |
|---|
| 60 | this.subsystem = subsystem; |
|---|
| 61 | cmthandler = new CmtHandler(); |
|---|
| 62 | |
|---|
| 63 | try |
|---|
| 64 | { |
|---|
| 65 | gsmcallproxy = Bus.get_proxy_sync<FreeSmartphone.GSM.Call>( BusType.SYSTEM, "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device", DBusProxyFlags.DO_NOT_AUTO_START ); |
|---|
| 66 | gsmcallproxy.call_status.connect( onCallStatusSignal ); |
|---|
| 67 | } |
|---|
| 68 | catch ( Error e ) |
|---|
| 69 | { |
|---|
| 70 | logger.error( @"Could not hook to fsogsmd: $(e.message)" ); |
|---|
| 71 | } |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | public override string repr() |
|---|
| 75 | { |
|---|
| 76 | return "<>"; |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | internal FsoAudio.GsmVoiceCmtspeechdata.Plugin instance; |
|---|
| 81 | |
|---|
| 82 | /** |
|---|
| 83 | * This function gets called on plugin initialization time. |
|---|
| 84 | * @return the name of your plugin here |
|---|
| 85 | * @note that it needs to be a name in the format <subsystem>.<plugin> |
|---|
| 86 | * else your module will be unloaded immediately. |
|---|
| 87 | **/ |
|---|
| 88 | public static string fso_factory_function( FsoFramework.Subsystem subsystem ) throws Error |
|---|
| 89 | { |
|---|
| 90 | instance = new FsoAudio.GsmVoiceCmtspeechdata.Plugin( subsystem ); |
|---|
| 91 | return FsoAudio.GsmVoiceCmtspeechdata.MODULE_NAME; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | [ModuleInit] |
|---|
| 95 | public static void fso_register_function( TypeModule module ) |
|---|
| 96 | { |
|---|
| 97 | FsoFramework.theLogger.debug( "fsoaudio.gsmvoice_alsa_cmtspeechdata fso_register_function" ); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | /** |
|---|
| 101 | * This function gets called on plugin load time. |
|---|
| 102 | * @return false, if the plugin operating conditions are present. |
|---|
| 103 | * @note Some versions of glib contain a bug that leads to a SIGSEGV |
|---|
| 104 | * in g_module_open, if you return true here. |
|---|
| 105 | **/ |
|---|
| 106 | /*public static bool g_module_check_init( void* m ) |
|---|
| 107 | { |
|---|
| 108 | var ok = FsoFramework.FileHandling.isPresent( Kernel26.SYS_CLASS_LEDS ); |
|---|
| 109 | return (!ok); |
|---|
| 110 | } |
|---|
| 111 | */ |
|---|
| 112 | |
|---|
| 113 | // vim:ts=4:sw=4:expandtab |
|---|