Afaik its just enough that you enter CODE on the dialog when it regognizes different operator sim, you dont have to enter #pw, just the code part. And yes, there is dbus API, but it should be enough just to put your sim in and enter unlock code.