Newly single Jesse James has won sole custody of his seven-year-old daughter with his ex-wife, adult film star Janine Lindemulder.

The former couple, which split in 2004, has been embroiled in a nasty legal battle over little Sunny for years and James was initially awarded custody in 2009 when Lindemulder was jailed on tax evasion charges.

She was placed behind bars again in Austin, Texas earlier this year for allegedly harassing the TV mechanic in a series of threatening emails and voicemails, and now a judge in Orange County, California has given James sole custody of the child.

James' attorney, John Schilling, tells that the porn actress will be ordered to enroll in inpatient rehab if she chooses to move from California to Texas, where James now lives, to be close to Sunny. If Lindemulder chooses to stay in California, she will only be allowed monitored visitation with the girl.

Schilling says, "Jesse feels vindicated. This is what he's been claiming all along, that Janine needs therapy."

The custody news will give James something to smile about this week - he announced he'd broken off his engagement to celebrity tattoo artist Kat Von D on Tuesday.

He also has two other children from his first marriage.