Implementing a searchable phone directory for snom phones

After getting my Snom phones to load their directories from my home server instead of using their local ones, I quickly noticed that scrolling through a directory with 96 entries on a one-line display is no fun at all and the thing definitely needs to be searchable.

Fortunately, the Snom minibrowser also allows prompting for user input using the SnomIPPhoneInput XML stanza. So now, whenever I press the Directory button on my phone, it loads a URL from the server that does not return the directory, but instead returns this:

     <DisplayName>Search for entry...</DisplayName>

This causes the phone to display "Search for entry", and to wait for me to enter some kind of number. So now, I press the Directory button, and then just type in the name of a contact using the number key. If I want to search for "Jürgen", I press the buttons "5-8-7-4-3-6", so the phone will send 587436 as the number. My server then just iterates over all my contacts, calculates the button sequence I'd have to use to dial their names, and if it contains 587436, include the contact in the directory sent to the phone. Additionally, it'll match the number I typed against the contacts' actual phone numbers, so I can dial a part of the number and get the contact as well.