Skip to content

Commit

Permalink
Add device/modem as first parameter to DynamicConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Lindenberg committed May 20, 2014
1 parent 7f92f28 commit 2693e47
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
40 changes: 20 additions & 20 deletions src/gofaxd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,29 @@ func (e *EventSocketServer) handler(c *eventsocket.Connection) {

logger.Logger.Printf("Incoming call to %v from %v <%v>", recipient, cidname, cidnum)

var device *Device
if gofaxlib.Config.Gofaxd.AllocateOutboundDevices {
// Find free device
device, err := devmanager.FindDevice(fmt.Sprintf("Receiving facsimile"))
if err != nil {
logger.Logger.Println(err)
c.Execute("respond", "404", true)
c.Send("exit")
}
defer device.SetReady()
}

var used_device string
if device != nil {
used_device = device.Name
} else {
used_device = DEFAULT_DEVICE
}

// Query DynamicConfig
if dc_cmd := gofaxlib.Config.Gofaxd.DynamicConfig; dc_cmd != "" {
logger.Logger.Println("Calling DynamicConfig script", dc_cmd)
dc, err := gofaxlib.DynamicConfig(dc_cmd, cidnum, cidname, recipient)
dc, err := gofaxlib.DynamicConfig(dc_cmd, used_device, cidnum, cidname, recipient)
if err != nil {
logger.Logger.Println("Error calling DynamicConfig:", err)
} else {
Expand All @@ -127,18 +146,6 @@ func (e *EventSocketServer) handler(c *eventsocket.Connection) {

}

var device *Device
if gofaxlib.Config.Gofaxd.AllocateOutboundDevices {
// Find free device
device, err := devmanager.FindDevice(fmt.Sprintf("Receiving facsimile"))
if err != nil {
logger.Logger.Println(err)
c.Execute("respond", "404", true)
c.Send("exit")
}
defer device.SetReady()
}

sessionlog, err := gofaxlib.NewSessionLogger()
if err != nil {
c.Send("exit")
Expand Down Expand Up @@ -235,13 +242,6 @@ EventLoop:
}
sessionlog.Log(fmt.Sprintf("Success: %v, Hangup Cause: %v, Result: %v", result.Success, result.Hangupcause, result.ResultText))

var used_device string
if device != nil {
used_device = device.Name
} else {
used_device = DEFAULT_DEVICE
}

xfl := gofaxlib.NewXFRecord(result)
xfl.Modem = used_device
xfl.Filename = filename
Expand Down
4 changes: 2 additions & 2 deletions src/gofaxlib/dynamicconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ func (h *HylaConfig) GetFirst(tag string) string {
return ""
}

func DynamicConfig(command string, cidnum string, cidname string, recipient string) (*HylaConfig, error) {
func DynamicConfig(command string, device string, cidnum string, cidname string, recipient string) (*HylaConfig, error) {
if Config.Gofaxd.DynamicConfig == "" {
return nil, errors.New("No DynamicConfig command provided")
}

cmd := exec.Command(Config.Gofaxd.DynamicConfig, cidnum, cidname, recipient)
cmd := exec.Command(Config.Gofaxd.DynamicConfig, device, cidnum, cidname, recipient)
out, err := cmd.Output()
if err != nil {
return nil, err
Expand Down

0 comments on commit 2693e47

Please sign in to comment.