Turn On Relay by Phone Line Power
The basic part for this would probably be a two coil latching relay like this one: -





I've put red boxes close to the two coils on the lower part of the above picture.

One coil being activated latches (sets) the relay and the other coil de-latches (resets) the relay. To activate or deactivate you momentarily drive the relevant coil with voltage but where to get that voltage from?

Well, you have two incoming lines and you could, on both lines independently charge up capacitors via 1 Mohm resistors. If both lines are inactive then both charge up to about 48 volts. So that gives you some stored energy to drive the coils.

Then you need to have ring detector circuits as shown in the diagram in the question - it's the opto-coupler part and is quite a conventional ring detection circuit for remote bells and buzzers. Between the ring detectors and the relay coils you need to operate a MOSFET or BJT that dumps the energy into its respective relay coil.

Sure, there are going to be details that need ironing out but I got one of these to work back in the 1980s when I designed POTs.