[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteDelegate(string cmd, IntPtr streamH, IntPtr eventH);\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ExecuteBackgroundDelegate(string cmd);\r
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool RunDelegate(string cmd, IntPtr session);\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd); \r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ReloadDelegate(string cmd);\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)] delegate bool ListDelegate(string cmd, IntPtr streamH, IntPtr eventH);\r
static readonly ExecuteDelegate _execute = Execute;\r
static readonly ExecuteBackgroundDelegate _executeBackground = ExecuteBackground;\r
static readonly RunDelegate _run = Run;\r
static readonly ReloadDelegate _reload = Reload;\r
- static readonly ExecuteDelegate _list = List;\r
+ static readonly ListDelegate _list = List;\r
\r
[DllImport("mod_managed", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]\r
- static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ExecuteDelegate list);\r
+ static extern void InitManagedDelegates(RunDelegate run, ExecuteDelegate execute, ExecuteBackgroundDelegate executeBackground, ReloadDelegate reload, ListDelegate list);\r
\r
static readonly object loaderLock = new object();\r
\r
public static bool Load() {\r
managedDir = Path.Combine(Native.freeswitch.SWITCH_GLOBAL_dirs.mod_dir, "managed");\r
shadowDir = Path.Combine(managedDir, "shadow");\r
- if (Directory.Exists(shadowDir)) \r
- {\r
- try\r
- {\r
+ if (Directory.Exists(shadowDir)) {\r
+ try {\r
Directory.Delete(shadowDir, true);\r
- }\r
- catch (Exception ex)\r
- {\r
+ } catch (Exception ex) {\r
Log.WriteLine(LogLevel.Warning, "Cannot delete shadow directory: {0}", ex);\r
}\r
\r
}\r
\r
Log.WriteLine(LogLevel.Debug, "FreeSWITCH.Managed loader is starting with directory '{0}'.", managedDir);\r
- if (!Directory.Exists(managedDir))\r
- {\r
+ if (!Directory.Exists(managedDir)) {\r
Log.WriteLine(LogLevel.Error, "Managed directory not found: {0}", managedDir);\r
return false;\r
}\r
.ToList();\r
\r
// adding "managed" (modules) directory\r
- if (!binPaths.Contains("managed", StringComparer.OrdinalIgnoreCase))\r
- {\r
+ if (!binPaths.Contains("managed", StringComparer.OrdinalIgnoreCase)) {\r
binPaths.Add("managed");\r
}\r
\r
var moduleRefsDir = Path.GetFileName(fileName);\r
moduleRefsDir = Path.GetFileNameWithoutExtension(moduleRefsDir);\r
\r
- if (moduleRefsDir != null && moduleRefsDir.Trim() != "")\r
- {\r
+ if (moduleRefsDir != null && moduleRefsDir.Trim() != "") {\r
moduleRefsDir = Path.Combine("managed", moduleRefsDir);\r
- if (!binPaths.Contains(moduleRefsDir, StringComparer.OrdinalIgnoreCase))\r
- {\r
+ if (!binPaths.Contains(moduleRefsDir, StringComparer.OrdinalIgnoreCase)) {\r
binPaths.Add(moduleRefsDir);\r
}\r
}\r
\r
public static bool List(string command, IntPtr streamHandle, IntPtr eventHandle)\r
{\r
- try\r
- {\r
- if (streamHandle != IntPtr.Zero)\r
- {\r
- using (var stream = new Native.Stream(new Native.switch_stream_handle(streamHandle, false)))\r
- {\r
+ try {\r
+ if (streamHandle != IntPtr.Zero) {\r
+ using (var stream = new Native.Stream(new Native.switch_stream_handle(streamHandle, false))) {\r
stream.Write("Available APIs:\n");\r
\r
getApiExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));\r
stream.Write("Available Apps:\n");\r
getAppExecs().Values.ForEach(x => stream.Write(string.Format("{0}: {1}\n", x.Name, String.Join(",", x.Aliases.ToArray()))));\r
}\r
- }\r
- else\r
- {\r
+ } else {\r
Log.WriteLine(LogLevel.Info, "Available APIs:");\r
getApiExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));\r
Log.WriteLine(LogLevel.Info, "Available Apps:");\r
getAppExecs().Values.ForEach(x => Log.WriteLine(LogLevel.Info, "{0}: {1}", x.Name, String.Join(",", x.Aliases.ToArray())));\r
}\r
return true;\r
- }\r
- catch (Exception ex)\r
- {\r
+ } catch (Exception ex) {\r
Log.WriteLine(LogLevel.Error, "Exception listing managed modules: {0}", ex.ToString());\r
return false;\r
}\r
typedef int (*executeFunction)(const char *cmd, void *stream, void *Event);
typedef int (*executeBackgroundFunction)(const char* cmd);
typedef int (*reloadFunction)(const char* cmd);
+typedef int (*listFunction)(const char *cmd, void *stream, void *Event);
static runFunction runDelegate;
static executeFunction executeDelegate;
static executeBackgroundFunction executeBackgroundDelegate;
static reloadFunction reloadDelegate;
-static executeFunction listDelegate;
+static listFunction listDelegate;
-SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload, executeFunction list)
+SWITCH_MOD_DECLARE_NONSTD(void) InitManagedDelegates(runFunction run, executeFunction execute, executeBackgroundFunction executeBackground, reloadFunction reload, listFunction list)
{
runDelegate = run;
executeDelegate = execute;