72 lines
2.1 KiB
Nix
72 lines
2.1 KiB
Nix
{ lib, pkgs, cfg, intercomEntries }:
|
|
|
|
let
|
|
baseUrl = "http://${cfg.serverAddress}:${toString cfg.directoryPort}";
|
|
|
|
hasPageExtensions = lib.any (e: e.mode == "page") (lib.attrValues cfg.extensions);
|
|
|
|
menuXml = ''
|
|
<CiscoIPPhoneMenu>
|
|
<Title>${cfg.directoryName} Telefonbuch</Title>
|
|
<Prompt>Ihre Wahl</Prompt>
|
|
<MenuItem>
|
|
<Name>Internes Telefonbuch</Name>
|
|
<URL>${baseUrl}/directory-list.xml</URL>
|
|
</MenuItem>
|
|
'' + lib.optionalString (intercomEntries != [] || hasPageExtensions) ''
|
|
<MenuItem>
|
|
<Name>Intercom / Durchsage</Name>
|
|
<URL>${baseUrl}/intercom.xml</URL>
|
|
</MenuItem>
|
|
'' + ''
|
|
</CiscoIPPhoneMenu>
|
|
'';
|
|
|
|
listXml = ''
|
|
<CiscoIPPhoneDirectory>
|
|
<Title>${cfg.directoryName} Telefonbuch</Title>
|
|
<Prompt>Ihre Wahl</Prompt>
|
|
'' + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
|
lib.optionalString (extCfg.mode == "line" && extCfg.displayName != "") ''
|
|
<DirectoryEntry>
|
|
<Name>${extCfg.displayName}</Name>
|
|
<Telephone>${ext}</Telephone>
|
|
</DirectoryEntry>
|
|
'') cfg.extensions)
|
|
+ ''
|
|
</CiscoIPPhoneDirectory>
|
|
'';
|
|
|
|
intercomXml = ''
|
|
<CiscoIPPhoneDirectory>
|
|
<Title>Intercom / Durchsage</Title>
|
|
<Prompt>Ihre Wahl</Prompt>
|
|
'' + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
|
|
lib.optionalString (extCfg.mode == "page" && extCfg.displayName != "") ''
|
|
<DirectoryEntry>
|
|
<Name>${extCfg.displayName}</Name>
|
|
<Telephone>${ext}</Telephone>
|
|
</DirectoryEntry>
|
|
'') cfg.extensions)
|
|
+ lib.concatMapStringsSep "\n" (ic: ''
|
|
<DirectoryEntry>
|
|
<Name>${ic.displayName}</Name>
|
|
<Telephone>${ic.extension}</Telephone>
|
|
</DirectoryEntry>
|
|
'') intercomEntries
|
|
+ ''
|
|
</CiscoIPPhoneDirectory>
|
|
'';
|
|
|
|
voicemailMenuXml = ''
|
|
<CiscoIPPhoneExecute>
|
|
<ExecuteItem Priority="0" URL="Dial:997"/>
|
|
</CiscoIPPhoneExecute>
|
|
'';
|
|
|
|
in {
|
|
menuFile = pkgs.writeText "directory.xml" menuXml;
|
|
listFile = pkgs.writeText "directory-list.xml" listXml;
|
|
intercomFile = pkgs.writeText "intercom.xml" intercomXml;
|
|
voicemailFile = pkgs.writeText "voicemail.xml" voicemailMenuXml;
|
|
}
|