I'm tearing my hair out...

Why doesn't this work?!?

It complies and downloads an image, but it just will not set the wallpaper; I think there's a problem somewhere in the 'setPreference'

Please help!


MainAssistant.prototype.setWallpaper = function(){


Mojo.Controller.getAppController().showBanner("Downloading wallpaper",{source: 'notification'});

var contr = this.controller;
this.controller.serviceRequest('palm://com.palm.downloadmanager/',
{
method: 'download',
parameters: {
target: "SOME_URL/FILENAME.jpg",
"mime": "image/jpeg",
"targetDir" : "/media/internal/wallpapers/",
"targetFilename" : "FILENAME.jpg",
keepFilenameOnRedirect: true
subscribe: false
},
onSuccess: function (resp)
{
contr.serviceRequest('palm://com.palm.systemservice/wallpaper',
{
method:"importWallpaper",
parameters:{
"target":"file:///media/internal/wallpapers/FILENAME.jpg"
},
onSuccess: function(returnValue, wallpaper) {

contr.serviceRequest('palm://com.palm.systemservice/wallpaper',
{
method:"refresh",
onSuccess: function(){},
onFailure: function(){}
});

contr.serviceRequest('palm://com.palm.systemservice/',
{
method:"setPreferences",
parameters:{
"wallpaper":wallpaper
},
onSuccess: function(){

Mojo.Controller.getAppController().showBanner("Wallpaper set",{source: 'notification'});

},
onFailure: function(){}
});

},
onFailure: function(e){
Mojo.Controller.getAppController().showBanner("Could not set wallpaper",{source: 'notification'});
Mojo.Log.info(Object.toJSON(e))
}
});
},
onFailure: function (e){
Mojo.Controller.getAppController().showBanner("Could not download wallpaper",{source: 'notification'});
Mojo.Log.info(Object.toJSON(e))
}
});
}